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 |
---|---|---|---|---|---|---|
DELETE /categories/1 DELETE /categories/1.json | def destroy
@category.destroy
respond_to do |format|
format.html { redirect_to admin_good_categories_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @category.destroy\n render json: @category, status: :ok\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_categories_path }\n format.json { head :no_content }\n end\n end",
"def deleteCat()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n c = Category.find(params[:id])\n status = c.destroy\n error = \"\"\n if(c.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end",
"def destroy\n @category.destroy\n render json: { notice: 'Categoria eliminada exitosamente' }\n end",
"def destroy\n category = set_category\n if category.destroy\n head :no_content\n else\n render json: { status: 500 }\n end\n \n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_categories_path, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = @collection.category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alien_category.destroy\n respond_to do |format|\n format.html { redirect_to alien_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: t('destroy.notice', name: t('activerecord.models.category')) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to cm_post_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categoria = Categoria.find(params[:id])\n @categoria.destroy\n\n respond_to do |format|\n format.html { redirect_to categoria_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = current_mall.categories.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to api_wmall_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n head :no_content\n end",
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def delete_category id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete CATEGORIES, id ).code\n\t\t\t\t\tend\n\t\t\t\tend",
"def destroy\n IndicatorCategory.delete_hack(params[:id])\n\n respond_to do |format|\n format.html { redirect_to indicator_categories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post_category = Post::Category.find(params[:id])\n @post_category.destroy\n\n respond_to do |format|\n format.html { redirect_to post_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categ.destroy\n respond_to do |format|\n format.html { redirect_to categs_url, notice: 'Categ was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category_db.destroy\n respond_to do |format|\n format.html { redirect_to category_dbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categoria.destroy\n respond_to do |format|\n format.html { redirect_to categorias_path, notice: @@titulo + t('msg.remove') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categorie = Categorie.find(params[:id])\n @categorie.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>[]}}\n end\n end",
"def destroy\n @category.delete\n end",
"def destroy\n @admin_category.destroy\n respond_to do |format|\n format.html { redirect_to admin_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_category = RecipeCategory.find(params[:id])\n @recipe_category.destroy\n\n respond_to do |format|\n format.html { redirect_to recipe_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxonomy_category = TaxonomyCategory.find(params[:id])\n @taxonomy_category.destroy\n\n respond_to do |format|\n format.html { redirect_to taxonomy_categories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: \"Journal was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_scenic_spots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @desserts_category.destroy\n respond_to do |format|\n format.html { redirect_to desserts_categories_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @level_category = LevelCategory.find(params[:id])\n @level_category.destroy\n\n respond_to do |format|\n format.html { redirect_to level_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cat.destroy\n respond_to do |format|\n format.html { redirect_to cats_url, notice: 'Cat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n begin\n @category.destroy\n rescue ActiveRecord::DeleteRestrictionError\n error = 'Эта категория не может быть удалена, пока с ней связан хоть один файл.'\n ensure\n respond_to do |format|\n format.html { redirect_to categories_url, notice: error }\n format.json { head :ok }\n end\n end\n end",
"def destroy\n @kategory = Kategory.find(params[:id])\n @kategory.destroy\n\n respond_to do |format|\n format.html { redirect_to kategories_url }\n format.json { head :ok }\n end\n end",
"def destroy\n return unless admin?\n\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_path, notice: \"Category was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categor.destroy\n respond_to do |format|\n format.html { redirect_to categors_url, notice: 'Categor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to \"index\", notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = current_user.user_categories.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categorias_tipo = CatTipo.find(params[:id])\n @categorias_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to cat_tipos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cathegory.destroy\n respond_to do |format|\n format.html { redirect_to cathegories_url, notice: 'Cathegory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #locates the category to be destroyed\n @category = Category.find(params[:id])\n #Creates an array of all categories\n @all_categories = Category.all\n #creates an empty hash\n @all_categories_hash = {}\n #calls function to populate & sort @all_categories_hash\n sort_categories()\n #calls function to destroy the category\n destroy_category(@category)\n\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize! :destroy, @category\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to backend_shop_branch_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cat = Cat.find(params[:id])\n @cat.destroy\n\n respond_to do |format|\n format.html { redirect_to(cats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mk_categoria.destroy\n respond_to do |format|\n format.html { redirect_to mk_categories_url, notice: 'Mk categoria was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category_type = CategoryType.find(params[:id])\n @category_type.destroy\n\n respond_to do |format|\n format.html { redirect_to category_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @categorie_droit.destroy\n respond_to do |format|\n format.html { redirect_to categorie_droits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.delete_context #there you go, this little fatty kills em all!\n #fred and post have equal methods, makes it slim and easy\n\n respond_to do |format|\n format.html { redirect_to categories_url, :method => :get, :notice => t(:deleted_category_success) }\n format.json { head :ok }\n end\n end",
"def destroy\n @activity_category.destroy\n respond_to do |format|\n format.html { redirect_to activity_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_category.destroy\n respond_to do |format|\n format.html { redirect_to dish_categories_url, notice: 'Категория блюда удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n CategoryService.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n #######\n format.html { redirect_to category_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \tauthorize! :destroy, @category\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status_category.destroy\n respond_to do |format|\n format.html { redirect_to status_categories_url, notice: 'Status category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_category = current_user.post_categories.find(params[:id])\n @post_category.destroy\n\n respond_to do |format|\n format.html { redirect_to [:client, :post_categories] }\n format.json { head :no_content }\n end\n end",
"def destroy\n @course_category = CourseCategory.find(params[:id])\n @course_category.destroy\n\n respond_to do |format|\n format.html { redirect_to course_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: '分类删除成功~' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gt_category.destroy\n respond_to do |format|\n format.html { redirect_to gt_categories_url, notice: 'Gt category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cover_cat = CoverCat.find(params[:id])\n @cover_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to cover_cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n end",
"def destroy\n @category = DishCategory.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Категория удалена.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |format|\n format.html { redirect_to(categories_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category.destroy\n respond_to do |format|\n format.html { redirect_to management_categories_url, notice: 'Category was successfully removed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.78272814",
"0.77353686",
"0.76392984",
"0.7488916",
"0.74731207",
"0.74233276",
"0.7399541",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7385346",
"0.7378597",
"0.7378597",
"0.7378597",
"0.7372517",
"0.7366761",
"0.7362291",
"0.7334964",
"0.7334964",
"0.7333799",
"0.73254865",
"0.7318471",
"0.7294363",
"0.728636",
"0.7283016",
"0.72823733",
"0.7242075",
"0.72370917",
"0.71940225",
"0.7186593",
"0.7184272",
"0.71675783",
"0.7166838",
"0.7147197",
"0.71468467",
"0.7146009",
"0.71421075",
"0.712865",
"0.71269435",
"0.7125966",
"0.7122311",
"0.71151847",
"0.7114038",
"0.711263",
"0.71069294",
"0.7101981",
"0.71015203",
"0.7098744",
"0.70979154",
"0.70844114",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.708277",
"0.7077371",
"0.70768744",
"0.7076328",
"0.7075828",
"0.70738447",
"0.7071764",
"0.7064413",
"0.70556885",
"0.70518345",
"0.7051709",
"0.7048051",
"0.7047651",
"0.70454115",
"0.7042982",
"0.70411265",
"0.7030913",
"0.7013192",
"0.70061165",
"0.69993097",
"0.6998523",
"0.6996587",
"0.69943523",
"0.6993104",
"0.69879425",
"0.69879425",
"0.69879425",
"0.6978936",
"0.69772786"
] | 0.7245488 | 34 |
Use callbacks to share common setup or constraints between actions. | def set_category
@category = GoodCategory.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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\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 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\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\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 init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def 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 setup\n #implement in subclass;\n end",
"def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; 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 setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def 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 call\n setup_context\n super\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.5330087",
"0.5311993",
"0.5297402",
"0.5296789",
"0.52957207",
"0.52596015",
"0.5245442",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5235431",
"0.5231888",
"0.5226663",
"0.52220625",
"0.5217086",
"0.52137345",
"0.5208314",
"0.5205469",
"0.5175606",
"0.5174914",
"0.5173361",
"0.51662856",
"0.5161792",
"0.51572216",
"0.5153063",
"0.5152982",
"0.5152632",
"0.51435786",
"0.5139829",
"0.51346594",
"0.511372",
"0.511372",
"0.51136476",
"0.51083213",
"0.5108011",
"0.5091935",
"0.5089297",
"0.5081576",
"0.50807106",
"0.50656676",
"0.50548106",
"0.50537366",
"0.505074",
"0.505074",
"0.5033361",
"0.5025158",
"0.5020441",
"0.5015611",
"0.50142473",
"0.5000281",
"0.50001067",
"0.49989453",
"0.4989465",
"0.4989465",
"0.4985425",
"0.49805096",
"0.49795893",
"0.49783278",
"0.49676263",
"0.49656346",
"0.49579078",
"0.4955427",
"0.49554235",
"0.49536413",
"0.49523768",
"0.49457142",
"0.49433607",
"0.4933641",
"0.49320185",
"0.49265638",
"0.49262375",
"0.49259067",
"0.4922456",
"0.49201223",
"0.49165115",
"0.49158815",
"0.49151883",
"0.49149552",
"0.4914386"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def order_params
params.require(:order)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
def scrapped_recipes_with_ingredient(ingredient, difficulty) recipes = search_recipe_with_ingredient(ingredient, difficulty) recipes.map! do |recipe| Recipe.new(recipe[:title], recipe[:description], recipe[:prep_time], difficulty) end return recipes end | def recipe_done(recipe_index)
@recipes[recipe_index].done!
save_recipes_in_csv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipe_instances\n recipe_ingredients.map { |ri| ri.recipe }\n end",
"def scrape_recipe(ingredient)\n @recipes_array = []\n @ingredient = ingredient\n url = \"https://www.allrecipes.com/search/results/?search=#{@ingredient}\"\n html_file = URI.open(url).read\n html_doc = Nokogiri::HTML(html_file)\n html_doc.search('.card__detailsContainer').each do |element|\n title = element.search('.card__title').first.text.strip\n description = element.search('.card__summary').first.text.strip\n rating = element.search('.review-star-text').text.strip.slice(/(\\d.?\\d*)/)\n url = element.search('.card__titleLink').first.attribute('href').value\n\n @recipes_array << {\n title: title,\n description: description,\n rating: rating,\n url: url\n }\n end\n @recipes_array\n end",
"def ingredient_recipes\n self.doses.map { |d| d.recipe }.uniq\n end",
"def get_recipes(recipe_name, recipe_tag, recipe_ingredients)\n\t\t\t\trecipes_ids = Set.new\n\t\t\t\tingredients_upcase = Set.new\n\t\t\t\t#search by\n\t\t\t\tcase\n\t\t\t\twhen !recipe_name.blank?\n\t\t\t\t\trecipes_ids = Recipe.where('UPPER(name) LIKE UPPER(?)', \"%#{recipe_name}%\").pluck(:id)\n\t\t\t\twhen !recipe_tag.blank?\n\t\t\t\t\trecipes_ids = RecipeTag.where('UPPER(tag) LIKE UPPER(?)', \"%#{recipe_tag}%\").pluck(:recipe_id)\n\t\t\t\twhen !recipe_ingredients.blank?\n\n\t\t\t\t\tingredients = recipe_ingredients.to_s.delete \"[\"\n\t\t\t\t\tingredients = ingredients.delete \"]\"\n\t\t\t\t\tingredients = ingredients.delete \" \"\n\n\t\t\t\t\tingredients_array = ingredients.split(\",\") \n\n\t\t\t\t\tingredients_array.each do |ingredient|\n\t\t\t\t\t\tingredients_upcase << ingredient.upcase\n\t\t\t\t\tend\n\n\t\t\t\t\trecipes_ids = RecipeIngredient.where('UPPER(ingredient) IN (?)', ingredients_upcase).pluck(:recipe_id)\n\t\t\t\telse\n\t\t\t\t\trecipes_ids = Recipe.all.pluck(:id)\n\t\t\t\tend\n\t\t\t\t#get recipes matching the ID\n\t\t\t\tif !recipes_ids.blank?\n\t\t\t\t\trecipes = Recipe.where(\"id IN (?)\", recipes_ids).order('created_at DESC')\n\t\t\t\t\t#get tags and ingredients for each recipe\n\t\t\t\t\trecipes.each do |recipe|\n\t\t\t\t\t\trecipe.tags = RecipeTag.where('recipe_id = ?', recipe.id).pluck(:tag)\n\t\t\t\t\t\trecipe.ingredients = RecipeIngredient.where('recipe_id = ?', recipe.id).pluck(:ingredient)\n\t\t\t\t\tend\n\n\t\t\t\t\treturn recipes\n\t\t\t\tend\n\t\t\tend",
"def recipes\n recipe_cards.map { |c| c.recipe }\n end",
"def recipes\n return self.selected_recipes.map do |selected_recipe|\n selected_recipe.recipe\n end\n # recipes = []\n # self.selected_recipes.each do |selected_recipe|\n # recipes << selected_recipe.recipe\n # end\n # return recipes\n end",
"def recipes\n recipe_cards.map {|recipe_card| recipe_card.recipe}\n end",
"def recipes\n @recipes ||= []\n end",
"def assemble_recipe_data recipe\n ingredients = []\n\n # sum of (1-quality) for each substitution\n score = 0\n\n recipe.inclusions.each do |inclusion|\n ingredient = inclusion.ingredient\n ingredient_data = {}\n\n # deal with substitutons\n if forbidden? ingredient\n subs = substitutions(ingredient)\n if subs.length == 0\n # no substitutions, reject this recipe\n return nil\n else\n # add the substitution\n ingredient_data[\"substitute\"] = subs.map do |sub|\n [apply_ratio(inclusion.amount, sub.ratio), sub.name]\n end\n score += (1 - subs.first.quality)\n end\n end\n\n # add the rest of the data\n ingredient_data[\"original\"] = [inclusion.amount, ingredient.name]\n\n # TODO: fix this\n ingredient_data[\"where_to_buy\"] = [\"Whole Foods\", \"http://wholefoodsmarket.com/stores/list\"]\n\n ingredients.push ingredient_data\n end\n\n [{\n \"name\" => recipe.name,\n \"source\" => [recipe.source.name, recipe.url],\n \"directions\" => recipe.directions,\n \"ingredients\" => ingredients\n }, score]\n end",
"def find_recipes_that_use_me_and_create_link\n my_recipes = Recipe.search_recipe_ingredient_lists_for_ingredient(self)\n my_recipes.each {|recipe| self.recipes << recipe}\n end",
"def recipes\n self.recipe_cards.map {|recipecard| recipecard.recipe}\n end",
"def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end",
"def recipes\n # @recipe.all.select {|recipe| recipe.all = self}\n recipecards.map {|recipecard| recipecard.recipe}\n end",
"def recipes\n # Loop through RecipeCard\n #Find cards for this user\n #Gather recipes on those cards\n self.recipe_cards.map do |recipecard|\n recipecard.recipe\n end\n end",
"def recipes\n @recipes.sort.collect {|id| $data_recipes[id] }\n end",
"def recipes\n self.recipe_cards.map do |recipe_card|\n recipe_card.recipe\n end\n end",
"def scrape_recipes(ingredient)\n\turl = \"https://www.bbcgoodfood.com/search/recipes?query=#{ingredient}\"\n\n\thtml_string = open(url).read\n\thtml = Nokogiri::HTML(html_string)\n\n\t# We are searching for this:\n\t# <h3 class=\"teaser-item__title\">\n\t# \t<a href=\"\">Chocolate brownies</a>\n\t# </h3>\n\n\thtml.search(\".teaser-item__title a\")[0...2].each do |element|\n\t\ttitle = \"********\" + element.text + \"********\"\n\t\turl = element.attribute(\"href\").value\n\n\t\tsteps = scrape_steps(url)\n\n\t\tputs title\n\n\t\tsteps.each_with_index do |step, index|\n\t\t\tputs \"#{index + 1} - #{step}\"\n\t\t\tputs\n\t\tend\n\n\t\tputs\n\tend\nend",
"def recipes_from_allrecipes(keyword)\n url = \"https://www.allrecipes.com/search/results/?search=#{keyword}\"\n doc = Nokogiri::HTML(URI.open(url))\n doc.search('.card__recipe').map do |card|\n name = card.search('.card__title').first.text.strip\n description = card.search('.card__summary').first.text.strip\n rating = card.search('.rating-star.active').size\n rating = nil if rating.zero?\n Recipe.new(name, description, rating)\n end\nend",
"def by_ingredient\n # If ingredient exists, find recipes that use it\n if Ingredient.exists?(params[:id])\n ingredient = Ingredient.find(params[:id])\n recipes = Recipe.recipes_of_ingredient(params[:id])\n else\n recipes = Recipe.all\n end\n\n # Render json\n render json: {recipes: recipes}, status: 200 \n end",
"def set_recipes(fridge)\r\n # put recipes you want to puts manumally\r\n recipe_ingredients = {\"Teriyaki\" =>[\"chicken\",\"sugar\",\"mirin\",\"soy sauce\"],\r\n \"Curry rice\" => [\"rice\",\"curry mix\",\"potato\",\"onion\",\"beef\",\"carrot\"],\r\n \"Oyakodon\" => [\"chicken\",\"sugar\",\"mirin\",\"soy sauce\",\"rice\",\"egg\",\"onion\"],\r\n \"Takoyaki\" => [\"flour\",\"octopus\",\"ginger\",\"dashi\"],\r\n \"Nikujyaga\" => [\"beef\",\"sugar\",\"mirin\",\"soy sauce\",\"carrot\",\"onion\",\"potato\"],\r\n \"Octopus Sashimi\" => [\"octopus\",\"soy sauce\"],\r\n \"Miso soup\" => [\"miso\",\"dashi\"]}\r\n\r\n # set recipes_array to make new instence of Recipe\r\n recipes_array = {\"Teriyaki\" => [\"http://natashaskitchen.com/2015/12/11/easy-teriyaki-chicken/\",15],\r\n \"Curry rice\" => [\"http://www.japanesecooking101.com/curry-and-rice-recipe/\",40],\r\n \"Oyakodon\" => [\"http://www.justonecookbook.com/oyakodon/\",30],\r\n \"Takoyaki\" => [\"http://www.justonecookbook.com/takoyaki-recipe/\",20],\r\n \"Nikujyaga\" => [\"http://www.justonecookbook.com/nikujaga/\",30],\r\n \"Octopus Sashimi\" => [\"http://www.makesushi.com/sashimi/\",5],\r\n \"Miso soup\" =>[ \"http://steamykitchen.com/106-simple-10-minute-miso-soup.html\",5]}\r\n\r\n # make new instance and put to fridge.recipes\r\n recipes_array.each do |key,value|\r\n new_recipe = Recipe.new(key,value[0],value[1])\r\n new_recipe.ingredients = recipe_ingredients[\"#{key}\"]\r\n fridge.recipes << new_recipe\r\nend # recipes_array each end\r\nend",
"def safe_recipes\n safe_recipes_array =[]\n #get all the recipies of a user\n all_user_rec = self.recipes\n #get user allergens\n user_allergens = self.allergens\n all_user_rec.each do |recipe|\n y = 0\n recipe.ingredients.each do |ingredient|\n if user_allergens.include?(ingredient)\n y = 1\n end\n end\n safe_recipes_array << recipe if y == 0\n end\n safe_recipes_array\n\n #return array of recipe objects that are safe\n\n end",
"def get_recipe_titles(user_ingredients)\n \n search_params = 'http://www.recipepuppy.com/api/?i=' + user_ingredients.join(\",\")\n \n\n recipes = []\n search_string = RestClient.get(search_params)\n search_hash = JSON.parse(search_string)\n relevant_recipes = search_hash[\"results\"]\n relevant_recipes.collect do |recipe|\n recipes << recipe[\"title\"].strip\n end\n \n recipes\nend",
"def safe_recipes\n #want all of the recipes that do not contain ingredients in allergens (array of ingredients)\n #look through all of our recipes\n my_ingredients = self.recipes.map do |recipe|\n #for each recipe, get the ingredients\n recipe.ingredients #array, map makes it an array within an array\n end.flatten.uniq\n #see if any of those ingredients are not our allergens\n my_safe_ingredients = my_ingredients.select do |ingredient|\n !(self.allergens.include?(ingredient))\n end\n #select all recipe ingredients that have our safe ingredients\n my_safe_ris = RecipeIngredient.all.select do |ri|\n my_safe_ingredients.include?(ri.ingredient)\n end\n #return the recipe\n my_safe_ris.map do |ri|\n ri.recipe\n end\n\n end",
"def ingredients\n recipeingredient.map {|ri| ri.ingredient}\n end",
"def get_recipe_ingredient_list(url, ingredients, a, need, got)\n page = HTTParty.get(url)\n parse_page = Nokogiri::HTML(page)\n scraped_ingredient = []\n parse_page.css(\".ingredient-description\").map do |a|\n ing = a.text\n scraped_ingredient.push(ing)\n end\n\n for i in scraped_ingredient\n j = 0\n while j < a\n if i.downcase.include?(ingredients[j].downcase) == false\n need.push(i)\n j += 1\n else\n got.push(i)\n j += 1\n end\n end\n end\nend",
"def find_ingredients(recipe_object)\n ingredients = []\n ing_array = recipe_to_string(recipe_object).split(\" \")\n ing_array.each do |ing|\n ingredients << Ingredient.find_by(name: ing.capitalize!)\n end\n return (ingredients - [nil])\n end",
"def createRecipeFromAPI(randRecipe)\n # make a recipe obj to create for our DB\n recipe = Recipe.create(title: randRecipe[\"title\"], cookbook: Cookbook.all.sample, instructions: randRecipe[\"instructions\"])\n photo = Photo.create(recipe: recipe, img_url: randRecipe[\"image\"], description: \"test photo\")\n ingredients = randRecipe[\"extendedIngredients\"].map do |ing| \n ingredient = Ingredient.find_or_create_by(name: ing[\"name\"].titlecase)\n ri = RecipeIngredient.create(recipe: recipe, ingredient: ingredient, quantity: \"#{ing[\"amount\"]} #{ing[\"unit\"]}\")\n end\nend",
"def recipe_ingredients\n RecipeIngredient.all.select { |ri| ri.ingredient.name == @ing }\n end",
"def safe_recipes\n #Look at each allergen. Look at each recipeingredient to determine if any ingredients match any allergens. return recipe if not\n allergens = self.user_allergens ##array of allergies (ingredients objects)\n ri_array = RecipeIngredient.all\n binding.pry\n allergens.each do |allergen|\n binding.pry\n ri_array.delete_if {|recipeingredient| recipeingredient.ingredient == allergen}\n end\n binding.pry\n ri_array.map {|recipeingredient| recipeingredient.recipe}\n\n\n end",
"def items_for_recipe(recipe)\n\t\t# Everything will be stored in terms of ounces\n\t\tids = []\n\t\t# Loop through the structured ingredients\n\t\trecipe.each do |r|\n\t\t\t# Pull all items from database with matching length\n\t\t\titems = Item.allForName(r[\"name\"])\n\t\t\t# Mostly for proof of concept, if there is only one item matching, add it to the list.\n\t\t\tif items.length == 1\n\t\t\t\tids << items.first.id\n\t\t\telse\n\t\t\t\t# Loop through resulting items from database.\n\t\t\t\titems.each do |item|\n\t\t\t\t\t# Compare quantities, if the recipe calls for a quantity of less than the item,\n\t\t\t\t\t# add it to the database and exit the loop. \n\t\t\t\t\tif r[\"qty\"] <= item.qty\n\t\t\t\t\t\tids << item.id\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# Return the list of matching IDs\n\t\treturn ids\n\tend",
"def recipe_ingredients(perfect_10_recipe)\n return perfect_10_recipe\nend",
"def recipes\n my_recipe_cards = RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n my_recipe_cards.map do |recipe_card|\n recipe_card.recipe\n end\n end",
"def getRecipeByIngredientsList\n begin\n ingredientsList = params[:ingredients].split(\",\")\n\n @recipe = []\n ingredientsList.each do |ingredient|\n @recipe.push(Recipe.where('ingredients ILIKE ?', '%'+ingredient+'%').all)\n end\n \n if [email protected]?\n render json: { status: 'SUCCESS', message: 'Loaded recipe!', data: @recipe }, status: :ok\n else\n render json: { status: 'SUCCESS', message: 'No recipe found', data: {} }, status: :not_found\n end\n rescue\n render json: { status: 'ERROR', message: 'Error loading recipe', data: {} }, status: :not_found\n end\n end",
"def ingredients\n recipe_ingredients.map {|recipe_ingredient| recipe_ingredient.ing}\n end",
"def ingredients\n recipes = RecipeIngredient.all.select { |recipeing| recipeing.recipe == self}\n recipes.collect {|recipeing| recipeing.ingredient}\n end",
"def recipe (recipe_id, name)\n if recipe_id\n this_recipe = Recipe.find(recipe_id.to_i)\n else\n this_recipe = Recipe.find_by(name)\n end\n\n creation = {\n :name => this_recipe[:name],\n :instructions => this_recipe.instructions.all,\n :ingredients => this_recipe.ingredients.all\n }\n # return the object\n creation\n end",
"def all\n # returns all recipes\n @recipes\n end",
"def load_recipes(recipes)\n # loads a placeholder recipe hash in event of empty recipes value hash\n if recipes[\"recipes\"].empty? \n placeholder_recipe = {\"Placeholder\"=>[{\"flour\"=>0.5}]}\n RecipeBook.new(placeholder_recipe)\n else\n recipes[\"recipes\"].each do | recipe_name,recipe_ingredients |\n recipe = {\"#{recipe_name}\" => recipe_ingredients}\n recipe_name = RecipeBook.new(recipe)\n end\n end\nend",
"def recipe_ingredients\n RecipeIngredient.all.select{|ingredient| ingredient.recipe == self}\n end",
"def ingredients\n # self.recipe_ingredients\n recipe_ingredients.map do |r_i|\n r_i.ingredient\n end\n end",
"def ingredient_logic(ingredient)\n if all_ingredients.include?(ingredient)\n new_recipe_ingredient = ingredient_instance(ingredient)\n Recipe.last.ingredients << new_recipe_ingredient\n else\n new_recipe_ingredient = Ingredient.create(name: ingredient)\n Recipe.last.ingredients << new_recipe_ingredient\n end\n end",
"def ingredients_helper\n RecipeIngredient.all.select {|instance| instance.recipe == self}\n end",
"def recipe_ingredients\n RecipeIngredient.all.select do |recipe_ingredient|\n recipe_ingredient.recipe == self\n end\n end",
"def recipe_ingredients\n RecipeIngredient.all.select do |ri|\n ri.recipe == self\n end\n end",
"def recipe_ingredients\n RecipeIngredient.all.select do |ri|\n ri.recipe == self\n end\n end",
"def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end",
"def get_recipes(section)\n # Example: https://terraria.gamepedia.com/index.php?title=Recipes/Iron_Anvil&action=raw\n @connection.get '/index.php', {\n 'title' => \"Recipes/#{section}\",\n 'action' => 'raw'\n }\n end",
"def all\n return @recipes\n end",
"def recipes\n recipe_card_array = RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n\n recipe_card_array.map do |recipe_card|\n recipe_card.recipe\n end\n end",
"def call\n url = \"https://www.allrecipes.com/search/results/?search=#{@keyword}\"\n html = URI.open(url).read\n doc = Nokogiri::HTML(html)\n\n doc.search('.card__detailsContainer').first(5).map do |element|\n name = element.search('.card__title').text.strip\n description = element.search('.card__summary').text.strip\n rating = element.search('.rating-star.active').count\n\n # prep time\n prep_time = parse_prep_time(element)\n\n Recipe.new({ name: name, description: description, rating: rating, prep_time: prep_time })\n end\n end",
"def ingredients\n RecipeIngrediant.all.select do |recing|\n recing.recipe == self\n end\n #map to ing\n\n end",
"def generate_recipes_list\n recipes = YARD::Registry.all(:recipe).uniq.sort_by {|recipe| recipe.Name.to_s}\n generate_full_list(recipes, 'Recipe', 'recipes')\nend",
"def get_recipe_by_id(recipe_id)\n\t\t\t\trecipe = Recipe.find_by(id: recipe_id)\n\t\t\t\trecipe.tags = RecipeTag.where('recipe_id = ?', recipe.id).pluck(:tag)\n\t\t\t\trecipe.ingredients = RecipeIngredient.where('recipe_id = ?', recipe.id).pluck(:ingredient)\n\n\t\t\t\treturn recipe\n\t\t\tend",
"def process_ingredient_list\n return if @ingredient_list.blank?\n\n # if this recipe was just created, save original_ingredient_list\n if original_ingredient_list.blank?\n self.original_ingredient_list = @ingredient_list\n end\n \n if @ingredient_list.is_a?(String)\n ingr_array = @ingredient_list.split(/\\n/)\n else\n ingr_array = @ingredient_list\n end\n\n # Usually Rails just sets the key to null. To really delete the record, the following two lines are needed\n ingredients_recipes.each {|ir| ir.delete}\n ingredients_recipes.reload\n \n ingr_array.each_with_index do |line, index|\n line.strip!\n next if line.empty?\n \n # check for groups first, then ingredients. Groups are deliminated with stars like this: *Group*\n attrs = {}\n if line =~ /^\\*(.*)\\*$/\n attrs[:description] = $1\n attrs[:group] = true\n else\n # If a comma, assume everything past is a comment so only parse the first part but then \n # add it back in before processing the description\n line.downcase!\n comma_index = line.index(\",\")\n desc_part = ''\n unless comma_index.blank?\n desc_part = line.slice!(comma_index .. -1)\n end\n attrs[:ingredient] = Ingredient.find_name_and_create(line)\n attrs[:weight] = Ingredient.find_num(line)\n attrs[:unit] = Ingredient.find_unit(line)\n line.slice!(desc_part) # Make sure desc_part is not included twice\n \n # if using the whole_unit, take it out here so it doesn't get repeated in the description\n if attrs[:unit] == 'whole' && !attrs[:ingredient].whole_unit.blank?\n line.slice!(attrs[:ingredient].whole_unit)\n end\n attrs[:description] = Ingredient.find_description(line + desc_part) \n end\n attrs[:line_num] = index\n attrs[:recipe_id] = self.id\n \n ingredient_recipe = IngredientsRecipe.create!(attrs)\n ingredients_recipes << ingredient_recipe\n Ingredient.standardize_unit(ingredient_recipe)\n end\n @ingredient_list = nil\n end",
"def recipe_condense\n @recipe_pools = []\n for recipe in $mix_recipes\n input, output = recipe[0], recipe[1]\n input_s = []\n for component in input\n #fill default values\n if component.length < 2\n component = [component[0],1,0]\n elsif component.length < 3\n component = [component[0], component[1], 0]\n end\n updated = false\n for item in input_s\n #condense items of the same type\n if component[0] == item[0] && component[1] == item[1]\n item[2] += component[2]\n updated = true\n break\n end\n end\n if !updated then input_s.push(component) end\n end\n #sort input_s to have highest-quality requirements first, makes\n #things easier later\n input_s.sort! { |a, b| a[2] <=> b[2] }\n @recipe_pools.push([input_s, output]) \n end\n end",
"def ingredients\n my_recipe_ingredients = RecipeIngredient.all.select do |recipeingredient|\n recipeingredient.recipe == self\n end\n my_recipe_ingredients.map do |recipe_ingredient|\n recipe_ingredient.ingredient\n end.uniq\n end",
"def summary\n @recipes.map do |recipe|\n recipe.ingredients_required.sort_by do |ingredient, amt|\n ingredient.calories * amt\n end\n end\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def find_recipe_by_ingredient\n print(\"What ingredients do you have? (Separate by comma)\")\n user_food = gets.chomp\n\n ingredient_ids = user_food.split(\",\").collect do |ingredient|\n Ingredient.find_by(name: ingredient).id\n end\n meal_arr = Meals.all.select do |meal|\n ingredent_ids.include?(meal.ingredient_id)\n end\n hash = {}\n meal_arr.each do |meal|\n if hash.keys.include?(meal.recipe_id)\n hash[meal.recipe_id] += 1\n else\n hash[meal.recipe_id] = 1\n end\n end\n arr = []\n hash.each do |recipe_id, ingredient_count|\n total_ingredients.to_f = Recipe.find(recipe_id).ingredients.size\n if ingredient_count / total_ingredients > 0.80\n arr << Recipe.find(recipe_id).name\n end\n end\n return arr\nend",
"def recipeingredientsearch\n @query = params[:search]\n @searchedingredients = params[:searchingredients].split(/, */)\n @searchtest = []\n @searchedingredients.each do |si|\n @searchtest.push(si.downcase)\n end\n \n Ingredient.where(\"lower(name) IN (:searching)\", \n {searching: @searchtest}).find_each do |ingredigrab|\n @searchingreed.push(ingredigrab)\n end\n RecipeIngredient.where(ingredient_id: @searchingreed).find_each do |ids|\n @recing.push(ids)\n end\n \n if params[:exclusive] == \"1\"\n Recipe.where(\"name like :name\", {name: \"%#{@query}%\"}).find_each do |r|\n insert = false\n if @recing != nil\n RecipeIngredient.where(\"recipe_id = ?\", r.id).find_each do |i|\n if @recing.include?(i) == true\n insert = true\n end\n end\n if insert == true\n @recipes.push(r)\n end\n end\n end\n else\n Recipe.where(\"name like :name\", {name: \"%#{@query}%\"}).find_each do |r|\n insert = true\n if (r.recipe_ingredients.all.empty? == true)\n @recipes.push(r)\n else\n if @recing != nil\n RecipeIngredient.where(\"recipe_id = ?\", r.id).find_each do |i|\n if @recing.include?(i) == true\n else\n insert = false\n end\n end\n if insert == true\n @recipes.push(r)\n end\n end\n end\n end\n end\n return @recipes\n end",
"def ingredients\n RecipeIngredient.all.select { |ri| ri.recipe == self }.map { |ri| ri.ingredient }\n end",
"def recipes\n # should return all of the recipes this user has recipe cards for\n\n # first match up the user with their recipe cards\n # my_recipe_cards = RecipeCard.all.select do |recipe_card| #rc\n # # self == recipe_card.user # recipe_card.user == self\n # recipe_card.user == self\n # end\n\n # binding.pry\n # then take that array and get the recipes out of it\n self.recipe_cards.map do |recipe_card| # what is this an array of?\n recipe_card.recipe\n end\n # [recipe card objects for that user]\n\n # return an array of recipes\n end",
"def associate_ingredients_to_recipes\n Recipe.all.each do |recipe|\n 5.times do\n recipe.ingredients << Ingredient.all.sample\n end\n \n recipe.ingredients = recipe.ingredients.uniq\n \n while recipe.ingredients.count < 5\n recipe.ingredients << Ingredient.all.sample\n recipe.ingredients = recipe.ingredients.uniq\n end\n end\nend",
"def ingredient(ingredient_name, units)\n RecipeIngredient.new(ingredient_name, units)\n end",
"def all\n @recipes\n end",
"def all\n @recipes\n end",
"def all\n @recipes\n end",
"def show\n recipe_ingredients = RecipeIngredient.where(recipe_id: @recipe[:id])\n recipe_ingredient_ids = recipe_ingredients.pluck(:ingredient_id)\n @recipe_ingredients = recipe_ingredients.group_by(&:ingredient_id)\n @ingredients_like_ids = []\n fridge_items = FridgeItem.all\n fridge_items.each do |fi|\n @ingredients_like_ids << find_ingredients_like(fi.ingredient_id)\n end\n @ingredients_like_ids.flatten!\n @ingredients = Ingredient.find(recipe_ingredient_ids)\n @fridge_item_ids = []\n @ingredients.each do |ingredient|\n if @ingredients_like_ids.include?(ingredient.id)\n @fridge_item_ids << ingredient.id\n end\n end\n @fridge_item = FridgeItem.new\n end",
"def initialize(ingredient, recipe)\n @recipe = recipe\n @ingredient = ingredient\n @@all << self\n end",
"def get_recipe(id)\n recipe = Recipe.find(id)\n url = \"https://api2.bigoven.com/recipe/steps/#{recipe.id}?&api_key=#{ENV['API_KEY']}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n # puts response\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n # recipe.ingredients.create!(\n if (!Ingredient.exists?(ingredient[\"IngredientID\"])) \n Ingredient.create!(\n id: ingredient[\"IngredientID\"],\n name: ingredient[\"Name\"],\n html_name: ingredient[\"HTMLName\"]\n )\n end\n end\n\n if (recipe.recipe_ingredients.count > 0)\n recipe.recipe_ingredients.destroy_all\n recipe.save\n recipe.reload\n end\n\n JSON.parse(response)[\"Ingredients\"].each do |ingredient|\n \n # if (!recipe.recipe_ingredients.find_by(ingredient_id: ingredient[\"IngredientID\"]))\n recipe.recipe_ingredients.create!(\n ingredient_id: ingredient[\"IngredientID\"],\n quantity: ingredient[\"Quantity\"],\n display_quantity: ingredient[\"DisplayQuantity\"],\n unit: ingredient[\"Unit\"],\n metric_quantity: ingredient[\"MetricQuantity\"],\n metric_display_quantity: ingredient[\"MetricDisplayQuantity\"],\n metric_unit: ingredient[\"MetricUnit\"],\n preparation_notes: ingredient[\"PreparationNotes\"]\n )\n # end\n end\n \n recipe.steps = ''\n steps = JSON.parse(response)[\"Steps\"]\n steps.each do |step|\n step != steps.last ? recipe.steps += step[\"Text\"] + '$' : recipe.steps += step[\"Text\"]\n # recipe.steps += step[\"Text\"] + ','\n end\n \n recipe.save\n end",
"def add_recipe(recipe:, multiplier: 1)\n full_names = recipe.ingredients_full_names(multiplier: multiplier)\n full_names.map { |ingredient| create_task(ingredient) }\n # TODO: count the responses instead of the given list\n full_names.count\n end",
"def scrap_recipe\n recipe = RecipeScraper::Recipe.new @marmiton_url\n # convert recipe object to hash and merge\n @recipe_hash.merge!(recipe.to_hash)\n # rename keys\n @recipe_hash[:servings] = @recipe_hash.delete :nb_of_persons\n @recipe_hash[:prep_time] = @recipe_hash.delete :preptime\n @recipe_hash[:cook_time] = @recipe_hash.delete :cooktime\n @recipe_hash[:image_url] = @recipe_hash.delete :image\n @recipe_hash[:ingredients_list] = @recipe_hash.delete :ingredients\n @recipe_hash[:marmiton_url] = @marmiton_url\n # format strings\n @recipe_hash[:ingredients_list].each { |ingredient| ingredient.gsub!(/\\d+/, ' \\0 ') }\n @recipe_hash[:title].delete!(\"\\n\").strip!\n end",
"def ingredients\n RecipeIngredient.all.map do |reci_ingred|\n reci_ingred.ingredient_O if reci_ingred.recipe_O == self\n end.compact\n end",
"def ingredientsearch\n @searchedingredients = params[:searchingredients].split(/, */)\n @searchtest = []\n @searchedingredients.each do |si|\n @searchtest.push(si.downcase)\n end\n \n Ingredient.where(\"lower(name) IN (:searching)\", \n {searching: @searchtest}).find_each do |ingredigrab|\n @searchingreed.push(ingredigrab)\n end\n RecipeIngredient.where(ingredient_id: @searchingreed).find_each do |ids|\n @recing.push(ids)\n end\n \n if params[:exclusive] == \"1\"\n Recipe.all.find_each do |r|\n insert = false\n if @recing != nil\n RecipeIngredient.where(\"recipe_id = ?\", r.id).find_each do |i|\n if @recing.include?(i) == true\n insert = true\n end\n end\n if insert == true\n @recipes.push(r)\n end\n end\n end\n else\n Recipe.all.find_each do |r|\n insert = true\n if (r.recipe_ingredients.all.empty? == true)\n @recipes.push(r)\n else\n if @recing != nil\n RecipeIngredient.where(\"recipe_id = ?\", r.id).find_each do |i|\n if @recing.include?(i) == true\n else\n insert = false\n end\n end\n if insert == true\n @recipes.push(r)\n end\n end\n end\n end\n end \n return @recipes\n end",
"def all\n return @recipearray\n end",
"def perform\n build_recipes # this returns array of recipes\n self # return the scrapper\n end",
"def find_mached_recipe(fridge)\r\n system \"clear\"\r\nrecipes_you_can_make = []\r\nrecipe_count = 1\r\n fridge.recipes.each do |recipe|\r\n if recipe.ingredients & fridge.what_you_have.map(&:name) == recipe.ingredients\r\n recipes_you_can_make << recipe\r\n recipe_count += 1\r\n end #if end\r\n end # fridge.recipes.each end\r\n if recipe_count ==1\r\n puts \"Nothing! You better go out and get some food.\"\r\n sleep 2\r\n abort\r\n else\r\n puts \"Thank you! You can make these Japanese food\"\r\n end # if end\r\n recipes_you_can_make\r\nend",
"def add_ingredients(ingredients)\n ingredients.map do |ingredient|\n RecipeIngredient.new(self, ingredient)\n end \n end",
"def recipes\n RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n # RecipeCard.name\n end.map do |recipe_card|\n recipe_card.recipe\n end\n end",
"def create_recipe(row, db)\n name = row[0]\n ingredients= Array.new\n # function to run through row after index\n\n row[2..-1].each do |item|\n get_food = db[item]\n ingredients.push(get_food)\n end\n Recipe.new(name, ingredients)\n end",
"def recipes # /v1/user/:id/recipes (GET)\n recipes = ::Recipe.all\n render json: recipes, :each_serializer => RecipeSmallSerializer, root: false, status: 200\n end",
"def index\n @ingredient_recipes = IngredientRecipe.all\n end",
"def recipes\n Array fetch(:run_list)\n end",
"def get_from_npr(user_ingredients)\n raw_response=RestClient.get('http://api.npr.org/query?id=1139&fields=title,teaser,storyDate,byline,text&date&searchTerm=' + user_ingredients + '&dateType=story&output=JSON&apiKey=MDE5MDExNzc1MDE0MzA0MDE1NTViZDViOQ001')\n response = JSON.load(raw_response)\n\n if response[\"list\"][\"story\"] == nil\n puts \"Your search did not find any recipes...\"\n else\n recipes = response[\"list\"][\"story\"].map do |recipe|\n Recipe.new(\n title = recipe[\"title\"][\"$text\"],\n teaser = recipe[\"teaser\"][\"$text\"],\n link = recipe[\"link\"].first[\"$text\"],\n storyDate = recipe[\"storyDate\"][\"$text\"]\n )\n end\n end\n\nend",
"def scrap(ingredient)\n scraper = ScraperMarmiton.new(ingredient)\n scraper.doc.search('m.search').each do |element|\n name = element.search('.m_search_titre_recette > a').inner_text\n rating = element.search('etoile1').size\n prep_time = 10 #element.search('m_search_result_part4').inner_text.match(/\\d+/)[1]\n cooking_time = 10 #\n create(name, rating, preparation_time, cooking_time)\n end\n end",
"def recipe_instance(recipe_name) \n Recipe.find_by name: recipe_name\n end",
"def use(new_recipe)\n recipes.push(new_recipe)\n end",
"def vegan_recipe\n Recipe.where(vegan: true).map { |n| n.recipe_payload }\n end",
"def ingredient_related_product(ingredient)\n @products = Productitem.where(:ingredient_id => ingredient.id).map {|x| [x.product_id]}\n @products = @products.uniq\n end",
"def recipe_ingredients(recipe_id)\n recipe_status_helper(recipe_id)\n @recipe_ingredient_arr = recipe_ingredient.split(\", \")\n puts \" \"\n p user.recipes.where(id: recipe_id)[0].ingredient\n prompt.select(\"Options\") do |menu|\n puts \" \"\n menu.choice \"Choose New Protein\", -> {choose_protein}\n menu.choice \"Update Recipe Rating\", -> {update_recipe_rating(recipe_id)}\n menu.choice \"Add Ingredient\", -> {ingredient_add_helper(recipe_id)}\n menu.choice \"Remove Ingredient\", -> {ingredient_remove_helper(recipe_id)}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end",
"def add_ingredients(ing_array)\n ing_array.each do |ing|\n RecipeIngredient.new(self, ing)\n end\n end",
"def ingredients\n RecipeIngredient.all.select do |recipe_ingredient|\n recipe_ingredient.recipe == self\n end.map do |recipe_ingredient|\n recipe_ingredient.ingredient\n end\n end",
"def favorite_recipes\n favorites.each do |f|\n f.recipe\n end\n end",
"def index\n @recipes = Recipe.search(params[:search])\n @ingredients = Ingredient.all\n end",
"def by_ingredient_search(query)\n ingredient_query = Ingredient.where('name LIKE ?', \"%#{query}%\")\n if ingredient_query.any?\n return self.approved.where(:id => ingredient_query.collect(&:recipes).flatten.uniq.collect(&:id))\n end\n return self.approved\n end",
"def index\n @recipes = Recipe.where(nil)\n if params[:recipe].present?\n filtering_params(params).each do |key, value|\n @recipes = @recipes.public_send(key, value) if value.present?\n end\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n if params['ingredients']\n params['ingredients'].each do |ingredient_name|\n @recipe.ingredients << Ingredient.find_by(name: ingredient_name)\n end\n end\n\n @recipe.save \n redirect_to recipes_path\n end",
"def extract_ingredients(meal_data, main_ingredient)\n # if COUNTER < 100\n # result = []\n meal_data[\"meals\"].each do |meal|\n for i in 1..20 do\n if meal[\"strIngredient#{i}\"]\n if meal[\"strIngredient#{i}\"].downcase == main_ingredient.downcase\n puts meal\n end\n else\n get_recipes_from_api(main_ingredient)\n puts meal\n end\n end\n # if result.length == 0\n # get_recipes_from_api(main_ingredient)\n # end\n # # COUNTER += 1\n # # else\n # # p \"Sorry, can't find #{main_ingredient}\"\n # end\n # p result\nend\nend",
"def construct_ingredient_costs(recipe)\n recipe_obj = {}\n \n # Map costs per ingredient\n recipe_ingredients = recipe.recipe_ingredients.map do |ingredient| \n CombinedIngredient.new(ingredient)\n end\n \n # Calculate total cost\n recipe_obj[:total_cost] = recipe.calc_cost(recipe_ingredients)\n \n # Calculate cost per serving\n recipe_obj[:cost_per_serving] = ''\n recipe_obj[:cost_per_serving] = recipe.calc_cost_per_serving(recipe_obj[:total_cost]) if recipe.servings\n \n # Add all ingredients with costs to object\n recipe_obj[:ingredients] = recipe_ingredients\n \n return recipe_obj\n end",
"def for_ingredient_group(ingredient_group_id)\n ingredient_group = IngredientGroup.find_by_id(ingredient_group_id)\n if ingredient_group.present?\n recipe_ingredients = RecipeIngredient.where(:ingredient_id => ingredient_group.ingredient_ids )\n recipes = recipe_ingredients.collect {|ri| ri.recipe }\n return recipes.uniq\n end\n return [ self.approved, FAIL_SEARCH_MESSAGE ]\n end",
"def insert_recipe_from_yummly_search(yummly_search_result)\n\n recipe_info = {\n yummly_id: yummly_search_result[\"id\"],\n name: yummly_search_result[\"recipeName\"],\n time: yummly_search_result[\"totalTimeInSeconds\"],\n small_img_url: yummly_search_result[\"imageUrlsBySize\"][\"90\"],\n is_data_complete: false\n }\n Recipe.create(recipe_info)\n end"
] | [
"0.74096835",
"0.72532356",
"0.71460694",
"0.7139655",
"0.70501655",
"0.6990193",
"0.6939288",
"0.6922007",
"0.6911624",
"0.6875349",
"0.68605465",
"0.6813661",
"0.6806659",
"0.6799779",
"0.67432016",
"0.6737293",
"0.6724071",
"0.6717115",
"0.66972363",
"0.6656441",
"0.6656134",
"0.66489965",
"0.6645458",
"0.660372",
"0.6580934",
"0.6579447",
"0.6556659",
"0.6543504",
"0.6524869",
"0.6496034",
"0.6483004",
"0.6479255",
"0.64754647",
"0.646587",
"0.6430409",
"0.64117354",
"0.64007324",
"0.6393928",
"0.6381449",
"0.63706446",
"0.6351514",
"0.63499045",
"0.63446385",
"0.6325945",
"0.6325945",
"0.63212335",
"0.63173175",
"0.6316462",
"0.6311995",
"0.6311403",
"0.6308356",
"0.62985706",
"0.6292152",
"0.62889695",
"0.6275655",
"0.6272683",
"0.62677276",
"0.6261437",
"0.62540597",
"0.624549",
"0.62433255",
"0.6236562",
"0.62289816",
"0.62196326",
"0.6214368",
"0.6214368",
"0.6214368",
"0.6205241",
"0.61987305",
"0.6198722",
"0.6195046",
"0.6174321",
"0.6170547",
"0.6150527",
"0.61462",
"0.6144843",
"0.6140117",
"0.61358017",
"0.61337817",
"0.61255294",
"0.61216253",
"0.6114593",
"0.6095052",
"0.6093947",
"0.60929435",
"0.60860324",
"0.60857874",
"0.60821605",
"0.6077931",
"0.60739934",
"0.6069562",
"0.6055977",
"0.60524124",
"0.6042806",
"0.60400325",
"0.60362685",
"0.60214895",
"0.6021179",
"0.6003259",
"0.6002848",
"0.6000384"
] | 0.0 | -1 |
Returns the depth of a node | def depth
return 0 if nil?
@accumulator_depth = 1
depth_aux(self, @accumulator_depth)
@accumulator_depth
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end",
"def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end",
"def depth\n @traversal_position.depth\n end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def depth()\n #This is a stub, used for indexing\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def depth(node = root, parent = root, edges = 0)\n return 0 if node == parent\n return -1 if node.nil?\n\n if node < parent.data\n edges += 1\n depth(node, parent.left, edges)\n elsif node > parent.data\n edges += 1\n depth(node, parent.right, edges)\n else\n edges\n end\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def depth\n @attributes[:depth]\n end",
"def depth(value)\n node = find(value)\n find_depth(node)\n end",
"def depth\n self[:depth]\n end",
"def depth(node, current = @root, count = 0)\n if current.eql?(node)\n return count\n elsif current.nil?\n return 0\n else\n count += 1\n count = [depth(node, current.left_node, count), depth(node, current.right_node, count)].max\n return count\n end\n end",
"def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end",
"def depth(sought_node, current_node = @root)\n # Base case we've reached beyond a leaf node.\n return -1 if current_node.nil?\n\n # Base case: We've reached the node.\n return 0 if current_node == sought_node\n\n # Otherwise, return the minimum of the depths\n 1 + [depth(sought_node, current_node.left), depth(sought_node, current_node.right)].max\n end",
"def depth\n children_depth + my_depth\n end",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def depth_support(node)\n return 0 if node.nil?\n l_depth = depth_support(node.left)\n r_depth = depth_support(node.right)\n [l_depth, r_depth].max + 1\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end",
"def depth\n depth_support(self.root)\n end",
"def depth\n ancestors.count\n end",
"def depth\n ancestors.count\n end",
"def depth; end",
"def depth_of(data_to_find)\n @depth = 0\n if @head.nil?\n return @depth\n else\n depth_search(data_to_find, head)\n end\n return @depth\n end",
"def max_depth(node)\n return 0 if node.nil?\n [max_depth(node.left), max_depth(node.right)].max + 1\nend",
"def node_depths(root, depth = 0)\n if root.nil?\n return 0\n end\n\n return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)\nend",
"def maximum_depth(node, depth = 0)\n @h = depth\n node.descendants.map{|d| @h = d.depth if d.depth >= @h }\n @h \nend",
"def depth(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n _pre_order(root, [], nil).first\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end",
"def my_depth\n 1\n end",
"def depth_max; depths.max end",
"def depth\n crumbs.size\n end",
"def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end",
"def test_depth_of_method\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n tree.insert(40, \"movie c\")\n tree.insert(35, \"movie d\")\n assert_equal 3, tree.depth_of(35)\n end",
"def depth\n @breadcrumb.scan( \"/\" ).size\n end",
"def depth\n self.parents.size\n end",
"def depth\n breadcrumbs.size\n end",
"def depth\n n = 0\n p, q = lftp, lftq\n while p != 0\n x = p.inverse(q)\n p, q = (x * p - 1) / q, x\n n += 1\n end\n n\n end",
"def depth_min; depths.min end",
"def get_depth(id)\n if id.nil?\n return 0\n end\n \n old_pairing = AssignmentPairing.find_by_assignment_id(id)\n if old_pairing.nil? \n return 0\n end\n\n old_pairing.depth + 1\n end",
"def length\n @tree.length\n end",
"def depth\n level = 0\n scopelist=[]\n if (doe_scope == \"hvac\")\n scopelist = @hvacLevel\n else\n scopelist = @envelopeLevel\n end\n scopelist.each_index do |index|\n scopelist[index].each do |name|\n if (@commandName == name )\n level = index\n end\n end\n end\n return level\n end",
"def depth_of(score, current = @head, count = 0)\n if current.score == nil\n nil\n elsif current.score > score\n count += 1 \n depth_of(score, current.left, count)\n elsif\n current.score < score \n count += 1\n depth_of(score, current.right, count)\n else\n count\n end\n end",
"def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def find_max_depth(node, depth=0)\n if node.nil?\n return depth\n else\n left_depth = find_max_depth(node.left, depth + 1)\n right_depth = find_max_depth(node.right, depth + 1)\n if left_depth > right_depth\n return left_depth\n else\n return right_depth\n end\n end\n end",
"def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend",
"def height(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_height = height(node.left_child)\n right_height = height(node.right_child)\n if left_height >= right_height\n return left_height + 1\n else\n return right_height + 1\n end\n end\nend",
"def max_depth(root)\n return 0 if root.nil?\n left_height = max_depth(root.left)\n right_height = max_depth(root.right)\n return left_height > right_height ? left_height + 1 : right_height + 1;\nend",
"def depth=(_arg0); end",
"def depth\n self.dotted_ids.scan(/\\./).size\n end",
"def depth_search(data_to_find, node)\n if data_to_find < node.data && node.left\n @depth += 1\n depth_search(data_to_find, node.left)\n elsif data_to_find > node.data && node.right\n @depth += 1\n depth_search(data_to_find, node.right)\n elsif data_to_find == node.data\n @depth += 1\n else\n @depth = 0\n end\n end",
"def max_depth\n if @head.nil?\n return nil\n else\n max_depth = find_max_depth(head)\n end\n return max_depth\n end",
"def depth_of(k)\n if @root.key_array.empty?\n traverse_tree\n end\n @root.key_array.detect do | pair |\n pair.first == k\n end.last\n end",
"def get_height_wid_recursion(node = root)\n if node.nil?\n return 0\n end\n ldepth = get_height_wid_recursion(node.left)\n rdepth = get_height_wid_recursion(node.right)\n depth = [ldepth, rdepth].max + 1\n return depth\n end",
"def depth_of(score)\n if @head.score == score\n #depth at head is nil, this conditional assigns a zero\n #value to the head\n if @head.depth == nil\n 0\n else\n @head.depth\n end\n else\n #searches tree for node with inputted score\n if score < @head.score && @head.left_link != nil\n @head = @head.left_link\n depth_of(score)\n elsif score > @head.score && @head.right_link != nil\n @head = @head.right_link\n depth_of(score)\n end\n end\n end",
"def test_node_depth\n assert_equal(0, @root.node_depth, \"A root node's depth is 0\")\n\n setup_test_tree\n\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.node_depth, \"Node #{child.name} should have depth 1\")\n end\n\n assert_equal(2, @child4.node_depth, \"Child 4 should have depth 2\")\n end",
"def depth\n @env.length\n end",
"def current_depth\n 0\n end",
"def in_degree(node)\n self[node].length\n end",
"def num_tree_levels\n level = 0\n num_nodes= all_node_values_with_nil.length # considers tree as 'complete\n num_nodes_in_full_tree = 2**level\n until num_nodes_in_full_tree >= num_nodes\n level += 1\n num_nodes_in_full_tree += 2**level\n end\n num_tree_levels = level + 1 # (started count at 0)\n num_tree_levels = 0 if @root.nil?\n return num_tree_levels\n end",
"def node_count\n @nodes.length - 1\n end",
"def depth(key, count = 0, child = key)\n count += 1\n if root.data == child\n return count - 1\n else\n parent = find_parent(child).data\n depth(key, count, parent)\n end\n end",
"def depth(ast, acc=1)\n if null?(ast)\n acc\n elsif pair?(car(ast))\n depth(cdr(ast), [acc, depth(car(ast), 1 + acc)].max)\n else\n depth(cdr(ast), acc)\n end\n end",
"def test_depth_of_method_returns_nil\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(45, \"movie b\")\n assert_nil tree.depth_of(35)\n end",
"def get_node_level(node, key)\n get_level_of_node(node, key, 1)\nend",
"def depth\n @locals.size\n end",
"def height\n count_right = 0\n count_left = 0\n node = @root\n return count_left if node.nil?\n\n count_left = height_helper(node, 'left', count_left)\n count_right = height_helper(node, 'right', count_right)\n if count_right > count_left\n count_right\n else\n count_left\n end\n end",
"def size\n return @tree.size\n end",
"def node_count(type = nil)\n if type\n value = @db.m_get(\"node#{type}\")\n if value\n value.to_i\n end\n else\n @db.m_get(\"n\").to_i\n end\n end",
"def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.level + 1\n # @todo move it adapters\n else ancestors.size\n end\n end",
"def depth\n self.ancestors.size\n end",
"def number_of_nodes(node_name)\n nodes(node_name).count\nend",
"def line_depth(line)\n whitespace = line.scan(/^([\\s]+)/).flatten.first\n if whitespace\n whitespace.length\n else\n 0\n end\n end",
"def level\n return 0 if root?\n\n @parent.level + 1\n end",
"def current_depth\n current = Fiber.current\n managed_fiber?(current) ? current.depth : 0\n end",
"def depth(ast, acc=1)\n if null?(ast)\n acc\n elsif pair?(car(ast))\n v = depth(car(ast), 1 + acc)\n depth(cdr(ast), [acc, v].max)\n else\n depth(cdr(ast), acc)\n end\nend",
"def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end",
"def max_depth root\n return 0 if root == nil\n\n [max_depth(root.left), max_depth(root.right)].max + 1\nend",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def degree node\n d = 0\n if (@connections[node].is_a? (Array)) && nodes.include?(node)\n d = @connections[node].count\n if @connections[node].include?(node)\n d += 1\n end\n end\n return d\n end",
"def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end",
"def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end",
"def max_depth(root)\n return 0 if root.nil?\n\n left_depth = max_depth(root.left)\n right_depth = max_depth(root.right)\n\n (left_depth > right_depth ? left_depth : right_depth) + 1\nend",
"def depth\n @queue.depth\n end",
"def count_nodes(node = @root)\n node.children.map do |child_node|\n @node_count +=1\n # binding.pry if child_node.is_word\n count_nodes(child_node)\n end\n @node_count\n end",
"def nodes\n @graph.keys.length\n end",
"def level\n root? ? 0 : ancestors.count\n end",
"def test_depth_of_root\n tree = BinarySearchTree.new\n tree.insert(13, \"Test1\")\n assert_equal tree.depth_of(13), 0\n end",
"def leaves(node, depth=0)\n if node.left.nil? && node.right.nil?\n puts \"#{node.value}, depth: #{depth}\"\n return 1\n else\n leaves(node.left, depth+1) + leaves(node.right, depth+1)\n end\nend",
"def max_depth(root)\n return 0 if root.nil?\n\n left_result = max_depth(root.left)\n right_result = max_depth(root.right)\n\n return (left_result > right_result ? left_result : right_result) + 1\nend",
"def height\n depths = []\n recursive_yield_leaf_heights(current_node: @root, depth: 0) { |depth| depths << depth }\n return depths.max || 0 # The depth of an empty tree is zero.\n end",
"def depth_traversal(node, &block)\n yield node.value # print the current block\n\n # recurse down to the left child\n depth_traversal(node.left, &block) if node.left\n\n # recurse down to the right child\n depth_traversal(node.right, &block) if node.right\nend",
"def get_level\n level = 1\n p = parent\n while !p.nil?\n level += 1\n p = p.parent\n end\n \n return level\n end",
"def leaf_count\n @leaf_count\n end",
"def height(node = @root)\n return 0 unless node\n\n [height(node.left), height(node.right)].max + 1\n end",
"def length\n @node[\"length\"]\n end"
] | [
"0.7982543",
"0.78039885",
"0.776212",
"0.7581981",
"0.7463969",
"0.7426475",
"0.74191433",
"0.74070585",
"0.73817444",
"0.73544765",
"0.7267967",
"0.7193124",
"0.7171441",
"0.7169074",
"0.71485484",
"0.710232",
"0.70936257",
"0.7085758",
"0.70428896",
"0.69886154",
"0.69760704",
"0.69472647",
"0.69472647",
"0.6894084",
"0.68856233",
"0.68385106",
"0.6830901",
"0.6794588",
"0.6742392",
"0.67138076",
"0.6703284",
"0.66923237",
"0.6671114",
"0.6607727",
"0.65890217",
"0.6585431",
"0.6577537",
"0.65739954",
"0.6564345",
"0.65429205",
"0.6535233",
"0.64990926",
"0.64981616",
"0.64784557",
"0.6472559",
"0.64721376",
"0.6464785",
"0.64513826",
"0.64308256",
"0.64038813",
"0.6383339",
"0.636494",
"0.6352422",
"0.6347443",
"0.63404214",
"0.6320805",
"0.63176966",
"0.6292837",
"0.6290159",
"0.62898225",
"0.62875116",
"0.62779737",
"0.62713957",
"0.6248482",
"0.6241168",
"0.62388134",
"0.62324697",
"0.6221291",
"0.621998",
"0.621257",
"0.61914647",
"0.6190764",
"0.6186368",
"0.61728984",
"0.6162227",
"0.6162192",
"0.61615545",
"0.6150888",
"0.61469805",
"0.61364913",
"0.6118446",
"0.6117085",
"0.60964096",
"0.60844946",
"0.6049362",
"0.60474825",
"0.6042652",
"0.6017207",
"0.6007953",
"0.59996206",
"0.59974825",
"0.5984744",
"0.59580916",
"0.5954292",
"0.5950836",
"0.59451956",
"0.5942751",
"0.59415877",
"0.5933063",
"0.5930675"
] | 0.65800434 | 36 |
Aux function to depth | def depth_aux(current_node, accumulator)
@accumulator_depth = accumulator if accumulator > @accumulator_depth
depth_aux(current_node.left_child, accumulator + 1) unless current_node.left_child.nil?
depth_aux(current_node.right_child, accumulator + 1) unless current_node.right_child.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth=(_arg0); end",
"def depth; end",
"def my_depth\n 1\n end",
"def depth_helper(node, arr, depth)\n if node.left.nil? && node.right.nil? \n arr << depth\n return\n else \n depth += 1 \n if node.left\n depth_helper(node.left, arr, depth) \n end \n if node.right\n depth_helper(node.right, arr, depth)\n end \n end \n end",
"def depth()\n #This is a stub, used for indexing\n end",
"def depth\n @cur_level - @base_level + 1\n end",
"def depth\n return 0 if nil?\n\n @accumulator_depth = 1\n depth_aux(self, @accumulator_depth)\n @accumulator_depth\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def dfs_levels(node, result, depth = 0)\n return if node.nil?\n\n result[depth] ||= [node.val.to_i, 1]\n\n result[depth] = [(result[depth].first + node.val.to_i), result[depth].last + 1]\n\n dfs_levels(node.left, result, depth + 1)\n dfs_levels(node.right, result, depth + 1)\nend",
"def depth\n @depth ||= to && to.depth + 1 || 0\n end",
"def look_deeper contexts, deep, max_item_depth = 9, max_aspect_depth = 9, item_depth = 0\n unless item_depth == 0\n deep = look_wider contexts, deep, max_aspect_depth, 0\n deep[:row] += 1\n end\n deep[:indents] ||= []\n # deep[:numberings] ||= []\n deep[:indents ][deep[:row]] = item_depth || 0\n # deep[:numberings][deep[:row]] = self.class.numbering_list || []\n self.class.numbering_push\n unless (item_depth += 1) >= max_item_depth\n items.each do |item|\n self.class.numbering_increment\n deep = (item.recursive_ref || item).look_deeper contexts, deep, max_item_depth, max_aspect_depth, item_depth\n end\n end\n self.class.numbering_pop\n item_depth -= 1\n deep\n end",
"def depth\n children_depth + my_depth\n end",
"def depth\n depth_support(self.root)\n end",
"def current_depth\n 0\n end",
"def swimInDepth _obj, _args\n \"_obj swimInDepth _args;\" \n end",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def get_depth\n raise \"Not implemented\"\n end",
"def depth_min; depths.min end",
"def total_depth(node, depth = 0)\n @d = depth\n @d = @d + 1 if node.children.size > 0\n node.children.map{|c| x = total_depth(c,@d) - 1; @d = x if x > @d }\n return @d\nend",
"def recursive => nil",
"def depth_first(value)\n\tend",
"def depth(ast, acc=1)\n if null?(ast)\n acc\n elsif pair?(car(ast))\n depth(cdr(ast), [acc, depth(car(ast), 1 + acc)].max)\n else\n depth(cdr(ast), acc)\n end\n end",
"def depth(ast, acc=1)\n if null?(ast)\n acc\n elsif pair?(car(ast))\n v = depth(car(ast), 1 + acc)\n depth(cdr(ast), [acc, v].max)\n else\n depth(cdr(ast), acc)\n end\nend",
"def with_depth(name = 'depth', start: 0, as: nil)\n @depth = [name.to_s, start, as&.to_s] if recursive?\n end",
"def depth\n @options[:depth] += 1\n ret = yield\n @options[:depth] -= 1\n ret\n end",
"def maximum_depth(node, depth = 0)\n @h = depth\n node.descendants.map{|d| @h = d.depth if d.depth >= @h }\n @h \nend",
"def depth\n self[:depth]\n end",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def max_nesting=(depth)\n #This is a stub, used for indexing\n end",
"def depth\n if empty?\n 0\n else\n if @left==nil || @right==nil\n if (@left==nil&&@right==nil) then 1\n else -1\n end\n else\n left, right = @left.depth, @right.depth\n if left==-1||right==-1||left!=right then -1\n else 1+left\n end\n end\n end\n end",
"def node_depths(root)\n sum_of_depths = 0\n stack = [{\"node\"=> root, \"depth\"=> 0}]\n\n while stack.length > 0\n node_info = stack.pop()\n node, depth = node_info[\"node\"], node_info[\"depth\"]\n if node.nil?\n next\n end\n sum_of_depths += depth\n stack.append({\"node\"=> node.left, \"depth\"=> depth + 1})\n stack.append({\"node\"=> node.right, \"depth\"=> depth + 1})\n end\n return sum_of_depths\n\nend",
"def with_depth_and_path\n with_depth && with_path\n end",
"def depth\n ancestors.count\n end",
"def depth\n ancestors.count\n end",
"def test_depth_three_levels\n @tree.insert(\"c\")\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n assert_equal 2, @tree.depth_of?(\"a\")\n end",
"def depth\n self.ancestors.size\n end",
"def depth(person)\n count = 0\n \n until person.ancestor == nil do\n person = person.ancestor\n count += 1\n end\n\n count\n end",
"def depth_max; depths.max end",
"def set_depth(id=0, d=0, depth=Hash.new)\n depth[id] = d\n set_depth(self[id].right, d, depth) if self[id].right != nil\n set_depth(self[id].left, d + 1, depth) if self[id].left != nil\n depth\n end",
"def count_structure_levels(obj)\n if obj.respond_to?(:keys)\n # empty hash also has depth 0.\n max_depth = 0\n obj.keys.each do |key|\n child_levels = 1 + count_structure_levels(obj[key])\n max_depth = [max_depth, child_levels].max\n end\n max_depth\n elsif obj.is_a?(Array)\n # empty array also has depth 0.\n max_depth = 0\n obj.each do |child|\n child_levels = 1 + count_structure_levels(child)\n max_depth = [max_depth, child_levels].max\n end\n max_depth\n else\n 0\n end\nend",
"def nesting() end",
"def elegant_tree_by_levels(node)\n stack=[]\n stack.push node if node\n stack.each do |n|\n stack.push n.left if n.left\n stack.push n.right if n.right\n end\n stack.map! &:value\nend",
"def test_depth_two_levels\n @tree.insert(\"a\")\n @tree.insert(\"b\")\n assert_equal 1, @tree.depth_of?(\"b\")\n end",
"def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end",
"def depth\n breadcrumbs.size\n end",
"def depth\n return 0 unless has_children?\n children.inject(0) {|dep,c| dep > c.depth ? dep : c.depth} + 1\n end",
"def print_depth(item)\n return if item.hidden?\n print_item item, 0\n list_recur_print item, 2\n end",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def depth_traversal(node, &block)\n yield node.value # print the current block\n\n # recurse down to the left child\n depth_traversal(node.left, &block) if node.left\n\n # recurse down to the right child\n depth_traversal(node.right, &block) if node.right\nend",
"def depth\n n = 0\n p, q = lftp, lftq\n while p != 0\n x = p.inverse(q)\n p, q = (x * p - 1) / q, x\n n += 1\n end\n n\n end",
"def too_deep?( depth )\n depth.to_i > 0 && (depth + 1) <= path.to_s.count( '/' )\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def node_depths(root, depth = 0)\n if root.nil?\n return 0\n end\n\n return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)\nend",
"def printDepthFirst()\n # println(\"printDepthFirst\");\n # # // global fileCounter\n # @fileCounter = 0;\n # printRealDepthFirst(0,-1);\n # println(fileCounter+\" files\");\n end",
"def traverse; end",
"def depth(d)\n @depth = d\n self\n end",
"def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end",
"def depth\n @traversal_position.depth\n end",
"def deep_cur\n self.cur.deep_cur\n end",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end",
"def depth=(depth)\n #This is a stub, used for indexing\n end",
"def set_level current_depth, current_element,next_element\n if next_element.level > current_element.level\n current_depth.push current_element \n elsif next_element.level < current_element.level\n current_depth.pop \n end\n #if depths are equal, or next item doesn't exist, return same level\n current_depth\n end",
"def update_depth\n if depth?\n self.update_attribute(:depth, level)\n end\n self\n end",
"def produce_tree(ary); end",
"def depth_of(score, current = @head, count = 0)\n if current.score == nil\n nil\n elsif current.score > score\n count += 1 \n depth_of(score, current.left, count)\n elsif\n current.score < score \n count += 1\n depth_of(score, current.right, count)\n else\n count\n end\n end",
"def tree_by_levels_rec(node, level, acc)\n return unless node\n\n acc[level].push(node.value)\n tree_by_levels_rec(node.left, level + 1, acc)\n tree_by_levels_rec(node.right, level + 1, acc)\nend",
"def make_depth(depth)\n if depth then\n @depth = depth\n else\n # There is no default depth, use the heuristic that the\n # depth is more or less equal to the bit width of the\n # largest argument type.\n @depth = @funcE.each_argT.map {|t| t.width }.max\n end\n # Resize the stackes according to the depth.\n @stack_sigs.each do |sig|\n sig.type.instance_variable_set(:@range,0..@depth-1)\n end\n @stack_ptr.type.instance_variable_set(:@range,(@depth+1).width-1..0)\n end",
"def tree(visited, tree_ary, mod, depth=0)\n if !mod.is_a?(Module) || visited[mod]\n return nil\n end\n ary = []\n tree_ary.push(mod, ary)\n visited[mod] = true\n mod.constants.map do |name|\n tree(visited, ary, mod.const_get(name), depth+1)\n end\nend",
"def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end",
"def depth(key, count = 0, child = key)\n count += 1\n if root.data == child\n return count - 1\n else\n parent = find_parent(child).data\n depth(key, count, parent)\n end\n end",
"def apply_depth(depth)\n @min_depth = depth if depth < @min_depth\n end",
"def eval_depth(name)\n depth = (name.length - name.lstrip.length) / 3 + 2\n if depth < @dir.length\n (@dir.length - depth).times {@dir.pop}\n end\n end",
"def test_recursive_methods\n assert_equal 0, find_node(1).ancestors_r.size\n assert_equal 8, find_node(1).descendants_r.size\n assert_equal 4, find_node('1_1_2_1_1').ancestors_r.size\n end",
"def depth\n @env.length\n end",
"def initialize level = 1, seq = nil\n super()\n @path = [:fw]\n seq = [:fw, :left, :fw, :right, :fw, :right, :fw, :left, :fw]\n level.times do\n @path.map! { |el| el == :fw ? seq.dup : el }.flatten!\n end\n end",
"def get_moves_in_depth(num)\n get_moves_in_depth_helper(num, @root, 0).flatten\n end",
"def at_depth(depth)\n where \"NLEVEL(#{table_name}.#{ltree_path_column}) = ?\", depth\n end",
"def nodes_by_level (depth, node = self.node)\n if depth == 0\n return [node]\n elsif !node.nodes.empty?\n nodes = []\n node.nodes.each {|n| nodes = nodes + nodes_by_level(depth-1, n)}\n return nodes\n else\n return []\n end\n end",
"def depth\n @locals.size\n end",
"def build_default_proc(_left, _right, _total, _path, _last_height)\n ->(h, level) do\n left, right, total, path, last_height = _left, _right, _total, _path, _last_height\n levels = level - last_height\n if path == 1\n increase = left * levels\n path = 0\n total += increase\n right += increase\n else\n increase = right * levels\n path = 1\n total += increase\n left += increase\n end\n last_height = level\n nested = {\n left: left,\n right: right,\n total: total,\n path: path,\n next: nested\n }\n nested.default_proc = build_default_proc(left, right, total, path, last_height)\n\n\n h[level] = nested\n end\nend",
"def depth\n return call_ancestry_method(:depth) if use_ancestry?\n\n rel = relationship(:raise_on_multiple => true) # TODO: Handle multiple nodes with a way to detect which node you want\n rel.nil? ? 0 : rel.depth\n end",
"def depth\n self.parents.size\n end",
"def depthTraversal2(path, parent = nil)\n\tif File.directory?(path)\n\t\tdir = handler.addDirectory(parent, path)\n\n\t\tDir.foreach(path) { |item|\n\t\t\tchild = path +\"/\"+ item\n\t\t\tif File.directory?(child)\n\t\t\t\tif item != '.' && item != '..'\n\t\t\t\t\tdepthTraversal(child, dir)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\thandler.addFile(dir, item)\n\t\t\tend\n\t\t}\n\tend\nend",
"def depth_of(score)\n if include?(score) #This is calling the method on line 44\n 1 + @root_node.depth_of(score) \n else \n nil\n end \nend",
"def sum_depth ( x, weight = 1 )\n sum = 0\n\n x = [ x ] if x.is_a? Integer\n\n x.each do | n |\n if n.is_a? Array\n sum += sum_depth( n, weight + 1 )\n else\n sum += n * weight\n end\n end\n\n return sum\nend",
"def depth\n @attributes[:depth]\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def deep_thaw!\n replace deep_thaw\n end",
"def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end",
"def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end",
"def depth_search(node, proc)\n res = nil\n counter = 0\n number_of_children = node.children.length\n\n while counter < number_of_children\n return res if res\n\n child = node.children[counter]\n res = proc.call(child)\n return res if res\n\n res = depth_search(child, proc)\n counter += 1\n end\n res\n end",
"def recursiveTreeTraversal(element)\n if StereotypesHelper.hasStereotype(element, $veStereotype)\n findOrCreateRefinedParameters(element)\n end\n for child in element.getOwnedElement()\n recursiveTreeTraversal(child)\n end\nend",
"def do_deprecated_depth\n assert_equal(1, @root.depth, \"A single node's depth is 1\")\n\n @root << @child1\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @root << @child2\n assert_equal(2, @root.depth, \"This should be of depth 2\")\n\n @child2 << @child3\n assert_equal(3, @root.depth, \"This should be of depth 3\")\n assert_equal(2, @child2.depth, \"This should be of depth 2\")\n\n @child3 << @child4\n assert_equal(4, @root.depth, \"This should be of depth 4\")\n end",
"def rec_r(depth, arr)\n return arr if depth == 0\n\n rec_r(depth-1, arr.map do |v|\n ['a', 'b', 'c'].map do |chr|\n v + chr\n end\n end.flatten)\nend",
"def ids_recursive(vertex, goal_vertex, depth, max_depth)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @stack.pop() && return if depth == max_depth\n @explored[vertex.label] = true # Mark vertex as being explored\n depth = depth + 1\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if ids_recursive(edge, goal_vertex, depth, max_depth) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def level_order_traversal(node)\n h = height(node)\n (1..h).each do |n|\n print_given_level(node, n)\n end\nend",
"def build_tree(arr)\n\tend",
"def depth\n self.dotted_ids.scan(/\\./).size\n end"
] | [
"0.8176865",
"0.76371735",
"0.75289",
"0.7167133",
"0.7078402",
"0.684866",
"0.6810365",
"0.6797169",
"0.67596865",
"0.6729017",
"0.66827774",
"0.66722256",
"0.6633537",
"0.6603984",
"0.66034657",
"0.6572468",
"0.65552247",
"0.6534248",
"0.649647",
"0.6430507",
"0.6423622",
"0.6384076",
"0.63827866",
"0.6341189",
"0.63373053",
"0.63362193",
"0.63241005",
"0.62624776",
"0.62322897",
"0.622482",
"0.6222729",
"0.61669886",
"0.6148137",
"0.61421984",
"0.61421984",
"0.6117255",
"0.609844",
"0.6077529",
"0.6068668",
"0.6064514",
"0.6045973",
"0.6045864",
"0.6045289",
"0.60427284",
"0.60407215",
"0.603124",
"0.60120964",
"0.5994253",
"0.59928834",
"0.5987977",
"0.5958297",
"0.5957522",
"0.59566677",
"0.5956128",
"0.5954301",
"0.59509575",
"0.59334564",
"0.5924734",
"0.5918422",
"0.58999395",
"0.5892088",
"0.5889965",
"0.5883872",
"0.5877807",
"0.5877779",
"0.5875325",
"0.58615464",
"0.5851703",
"0.58479047",
"0.58476555",
"0.58338237",
"0.582916",
"0.58205193",
"0.5816014",
"0.58135265",
"0.5791348",
"0.57889223",
"0.5781715",
"0.5766866",
"0.5757796",
"0.57494575",
"0.5746956",
"0.5746082",
"0.57337576",
"0.5731097",
"0.57290787",
"0.5728553",
"0.57272005",
"0.57251644",
"0.5722879",
"0.5719989",
"0.5716921",
"0.5710578",
"0.5700675",
"0.5679095",
"0.56785244",
"0.567088",
"0.56577986",
"0.5651654",
"0.56502116"
] | 0.6557452 | 16 |
Consumes an input array and returns a balanced binary tree. | def build_tree(input_array)
sorted_set = input_array.sort.uniq
build_tree_aux(sorted_set, 0, sorted_set.length - 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend",
"def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end",
"def make_binary_tree(sorted_array)\n if sorted_array.length == 0\n return nil\n elsif sorted_array.length == 1\n return TreeNode.new(sorted_array[0])\n end\n divide_index = sorted_array.length / 2\n tree_node = TreeNode.new(sorted_array[divide_index])\n tree_node.left = make_binary_tree(sorted_array[0..divide_index-1])\n tree_node.right = make_binary_tree(sorted_array[divide_index+1..sorted_array.length-1])\n return tree_node\nend",
"def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end",
"def build_tree(array)\n return nil if array.empty?\n \n middle = (array.size - 1) / 2\n root_node = Node.new(array[middle])\n \n root_node.left = build_tree(array[0...middle])\n root_node.right = build_tree(array[(middle + 1)..-1])\n \n root_node\n end",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end",
"def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend",
"def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend",
"def array_to_bst(array, l, r, parent=nil, d=1)\n return if l > r\n mid = (l + r)/2\n node = Node.new(array[mid], nil, nil, nil, d)\n node.l = array_to_bst(array, l, mid - 1, node, d + 1)\n node.r = array_to_bst(array, mid + 1, r, node, d + 1)\n node.parent = parent\n node\n end",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def produce_tree(ary); end",
"def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def build_tree(arr)\n\tend",
"def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend",
"def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end",
"def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend",
"def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end",
"def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend",
"def minimal_tree(array)\n raise \"Please enter an array of at least one element\" if array.empty?\n\n midpoint = array.length/2\n root = BinaryTreeNode.new(array[midpoint])\n\n add_node = lambda do |left, right|\n return if left > right\n\n mid = left + (right-left) / 2\n\n node = BinaryTreeNode.new(array[mid])\n\n node.left = add_node.call(left, mid - 1)\n node.right = add_node.call(mid + 1, right)\n\n node\n end\n\n root.left = add_node.call(0, midpoint - 1)\n root.right = add_node.call(midpoint + 1, array.length - 1)\n\n root\nend",
"def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend",
"def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end",
"def build_tree_from_unsorted(arr)\n return nil if arr.empty?\n @root = Node.new(arr.shift)\n\n until arr.empty?\n child_node = Node.new(arr.shift)\n assign_children(@root, child_node)\n end\n end",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend",
"def array_tree\n return @array_tree if @array_tree\n @description.strip!\n #@description.gsub!(/[^\\s()]+/, '\"\\0\"')\n @description.gsub!(/[^\\s()]+/) {|w| '\"'+w.gsub('\"', '\\'')+'\"'}\n @description.gsub!('(', '[')\n @description.gsub!(')', ']')\n @description.gsub!(/\\s+/,\" \")\n @description.gsub!(' ', ', ')\n @description.gsub!('\\\\', '\\\\\\\\\\\\')\n begin\n @array_tree = eval(@description) # TODO safety level\n rescue Exception => ex\n puts \"Error while parsing:\\n#{@description}\"\n end\n @array_tree\n end",
"def build_tree(arr, start_index = 0, end_index = arr.length - 1)\n return nil if start_index > end_index\n\n mid = (start_index + end_index) / 2\n curr_root = arr[mid].is_a?(Node) ? arr[mid] : Node.new(arr[mid])\n curr_root.left = build_tree(arr, start_index, mid - 1)\n curr_root.right = build_tree(arr, mid + 1, end_index)\n curr_root\n end",
"def initialize(array = [], sorted = false)\n raise TypeError, 'Tree requires an array to initialize.' unless array.is_a? Array\n\n # Extract unique elements for sorting\n build_array = array.uniq\n\n # Requires a sorted array to properly build the tree.\n build_array.sort! unless sorted\n\n @root = build_tree(build_array)\n end",
"def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def treeify(arr, pre)\n arr.map { |elem| (elem.is_a? Array) ? treeify(elem, pre + \"-\") : nodeify(pre, elem) }\n end",
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def func(node,subtree_node_index_in_array,subtree_begin_index,subtree_end_index)\n\tif subtree_begin_index == subtree_end_index\n\t\t#puts \"leaf node begin #{subtree_begin_index} and end #{subtree_end_index}\"\n\t\t#puts $inorder_array[subtree_begin_index]\n\telse\n\t\t$preorder_index = $preorder_index + 1\n\t\tleft_subtree_node_value = $preorder_array[$preorder_index]\n\t\tleft_subtree_node_index_in_array = find_index_of_value_in_in_array(left_subtree_node_value,subtree_begin_index,subtree_node_index_in_array - 1)\n\t\tleft_node = Btnode.new($inorder_array[left_subtree_node_index_in_array])\n\t\tnode.left = left_node\n\t\tfunc(left_node,left_subtree_node_index_in_array,subtree_begin_index,subtree_node_index_in_array - 1 )\n\t\t#puts \"subtree node at #{$inorder_array[subtree_node_index_in_array]}\"\n\t\t#puts $inorder_array[subtree_node_index_in_array]\n\t\t$preorder_index = $preorder_index + 1\n\t\tright_subtree_node_value = $preorder_array[$preorder_index]\n\t\tright_subtree_node_index_in_array = find_index_of_value_in_in_array(right_subtree_node_value,subtree_node_index_in_array + 1,subtree_end_index)\n\t\tright_node = Btnode.new($inorder_array[right_subtree_node_index_in_array]) \n\t\tnode.right = right_node\n\t\tfunc(right_node,right_subtree_node_index_in_array,subtree_node_index_in_array + 1,subtree_end_index)\n\tend\nend",
"def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end",
"def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end",
"def build_driver(array, left, right)\n if right - left <= 0\n return \n end\n\n middle = left + (right - left) / 2\n root = Node.new(array[middle])\n\n root.left_node = build_driver(array, left, middle)\n root.right_node = build_driver(array, middle + 1, right)\n\n @root = root\n return root\n end",
"def build_tree_aux(input_array, start_index, stop_index)\n return nil if start_index > stop_index\n\n middle_index = (start_index + stop_index) / 2\n left_half = build_tree_aux(input_array, start_index, middle_index - 1)\n middle_value = input_array[middle_index]\n right_half = build_tree_aux(input_array, middle_index + 1, stop_index)\n Node.new(middle_value, left_half, right_half)\n end",
"def main8()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n print(t.ancestor(1, 10).value,\"\\n\")\n # 5\n print(t.ceilBST(5.5),\"\\n\")\n\t# 6\n print(t.floorBST(5.5),\"\\n\")\n\t# 5\n arr1 = [5, 2, 4, 6, 9, 10]\n arr2 = [5, 2, 6, 4, 7, 9, 10]\n print(t.isBSTArray(arr1),\"\\n\")\n print(t.isBSTArray(arr2),\"\\n\")\n # true\n # false\nend",
"def initialize(arr=[])\n @tree = []\n @tree.push(:dummy_head)\n 0.upto(arr.size-1) do |i|\n push(arr[i])\n end\n end",
"def question_2(array)\n bst = BST.new\n mid_element = array[array.length/2] #get the middle element of the array\n bst.insert(mid_element) #insert the middle into bst\n array.delete_at(array.length/2) # delete the middle value of the array\n array.each do |el| #iterate through the rest of the array and insert\n bst.insert(el)\n end\nend",
"def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend",
"def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend",
"def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end",
"def sorted_array_to_bst(nums)\n helper(nums, 0 ,nums.size - 1)\nend",
"def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend",
"def create_binary_search_tree(size)\n\t\tarray_of_nums = (0..size).to_a.shuffle\n\t\tnew_tree = BinarySearchTree.new\n\t\tarray_of_nums.each do |num|\n\t\t\tnew_tree.insert(num)\n\t\tend\n\t\treturn new_tree\n\tend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end",
"def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def build_tree(preorder, inorder)\n return nil if preorder.empty? || inorder.empty?\n \n root = TreeNode.new(preorder.first)\n idx = inorder.find_index(preorder.first)\n preorder.shift\n\n root.left = build_tree(preorder, inorder.slice(0..(idx-1))) unless idx==0\n root.right = build_tree(preorder, inorder.slice((idx+1)..-1)) if idx!=inorder.size-1\n \n return root\nend",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def n_ary_trees(range=2..2, minimize=true)\n raise \"Range parameter expected\" unless range.is_a? Range\n min = range.first.to_i\n raise \"minimum branches must be at least 2\" unless min > 1\n max = range.last.to_i\n max -= 1 if range.exclude_end?\n raise \"maximum branches less than minimum branches\" if max < min\n return [] if empty?\n\n # a lambda so we can do recursion without sticking private methods in Array\n\n # all n-way branches of a\n nwb = -> (a, n) do\n n = a.length if n > a.length\n if n == 1\n [a]\n else\n rv = []\n (1..( a.length - n + 1 )).each do |i|\n a1 = a[0...i]\n r = n - 1\n nwb.call( a[i..-1], r ).each do |branches|\n branches = [branches] if r == 1\n rv << [a1.dup] + branches\n end\n end\n rv\n end\n end\n\n # faux method for recursively making n-ary trees\n nt = -> (a) do\n if a.length <= min\n [a]\n else\n rv = []\n (min..( a.length < max ? a.length : max )).each do |branchiness|\n nwb.call( a, branchiness ).each do |part|\n head, *tail = part.map{ |a2| nt.call a2 }\n if tail.any?\n head = head.map{ |t| [t] }\n tail.each do |nxt|\n h = []\n head.each do |a1|\n nxt.each do |a2|\n h << a1 + [a2]\n end\n end\n head = h\n end\n end\n rv += head\n end\n end\n rv\n end\n end\n\n trees = nt.(self)\n\n if minimize\n m = -> (t) do\n if t.is_a? Array\n if t.length == 1\n m.call( t[0] )\n else\n t.map{ |t2| m.call t2 }\n end\n else\n t\n end\n end\n\n m.call trees\n else\n trees\n end\n end",
"def generate_unique_bst\n print 'Please enter the numbers in array separated by space :: '\n input_arr = gets.split(' ')\n input_arr.sort!\n unique_bst_arr = []\n generate_unique_bst_supp(unique_bst_arr, input_arr, 0, input_arr.length-1)\n unique_bst_arr.each do |node|\n puts node.inspect\n puts '***************'\n end\n nil\n end",
"def mk_tree(ch_arr)\n\t# set up top node based on smallest 2 values\n\ttop = Node.new # initial top node; no values yet\n\tmins = min_vals(ch_arr, 2)\n\tputs mins[0], mins[1]\n\tputs ch_arr[mins[0]]\n\tputs ch_arr[mins[1]]\n\ttop.set_left(Node.new(ch_arr[mins[0]], mins[0]))\n\ttop.set_right(Node.new(ch_arr[mins[1]], mins[1]))\n\ttop.set_count(ch_arr[mins[0]] + ch_arr[mins[1]])\n\tch_arr.delete(mins[0])\n\tch_arr.delete(mins[1])\n\t# build tree based upon current top node and next smallest value; repeat until no values left in hash\n\twhile(ch_arr.length >= 1)\n\t\ttemp = Node.new # temporary new node; this will become the top node\n\t\tmin = min_vals(ch_arr, 1)\n\t\tputs min\n\t\tputs ch_arr[min]\n\t\t# if top node's value is less than lowest number, put it on left; otherwise, put it on right\n\t\t#puts top.get_count, ch_arr[min]\n\t\tif(top.get_count <= ch_arr[min])\n\t\t\ttemp.set_left(top)\n\t\t\ttemp.set_right(Node.new(ch_arr[min], min))\n\t\telse\n\t\t\ttemp.set_left(Node.new(ch_arr[min], min))\n\t\t\ttemp.set_right(top)\n\t\tend\n\t\ttemp.set_count(ch_arr[min] + top.get_count)\n\t\ttop = temp\n\t\tch_arr.delete(min)\n\tend\n\t# return reference to top node\n\treturn top\nend",
"def test_return_array_root_node\n @tree.insert(\"f\")\n assert_equal [\"f\"], @tree.sort\n end",
"def main7()\n t = Tree.new()\n arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n t.createBinarySearchTree(arr)\n t.printInOrder()\n t.printInRange(4, 7)\n t.trimOutsideRange(4, 7)\n t.printInOrder()\nend",
"def build_parse_tree(exp)\n exp_arr = exp.split\n tree_stack = Stack.new\n tree = BinaryTree.new('')\n current_tree = tree\n exp_arr.each do |i|\n if i == '('\n current_tree.insert_left('')\n tree_stack.push(current_tree)\n current_tree = current_tree.left_child\n elsif i.match(/\\d/)\n current_tree.set_root_value(Integer(i))\n parent = tree_stack.pop\n current_tree = parent\n elsif ['+', '-', '*', '/'].include?(i)\n current_tree.set_root_value(i)\n current_tree.insert_right('')\n tree_stack.push(current_tree)\n current_tree = current_tree.right_child\n elsif i == ')'\n current_tree = tree_stack.pop\n else\n fail 'Invalid Argument'\n end\n end\n tree\nend",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def balanced_copy\n return BinaryTree.new(root: create_balanced_copy_subtree(elements: inorder_traversal.to_a))\n end",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end",
"def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end",
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def object_tree\n head, *rest = array_tree\n object_subtree(head,rest)\n end",
"def pre_order_array(tree)\n output = tree.nil? || tree.data == 0 ? \"\" : tree.data.to_s + \" \"\n left = tree.left.nil? ? \"\" : pre_order_array(tree.left)\n right = tree.right.nil? ? \"\" : pre_order_array(tree.right)\n output + left + right\nend",
"def serialize(root, array)\n if root == nil\n array.push('N')\n return\n else\n array.push(root.val)\n serialize(root.left, array)\n serialize(root.right, array)\n end\n array.join(\",\")\nend",
"def inorder(node = root, array = [], &block)\n return nil if node.nil?\n\n inorder(node.left, array, &block) unless node.left.nil?\n yield node if block_given?\n array << node\n inorder(node.right, array, &block) unless node.right.nil?\n array\n end",
"def to_a (root = self, array = [])\n to_a(root.left, array) unless root.left.nil?\n array << root.value\n to_a(root.right, array) unless root.right.nil?\n array\n end",
"def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end",
"def pre_order(node = root, array = [])\n return if node.nil?\n\n array << node.data\n pre_order(node.left, array)\n pre_order(node.right, array)\n array\n end",
"def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end",
"def test_sort_returns_an_array\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n target = tree.sort\n assert_equal Array, target.class\n assert_equal 4, target.length\n end",
"def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend",
"def plant_a_tree\n new_tree = [OrangeTree.new]\n @tree_array = @tree_array + new_tree\n end",
"def build_tree(values)\n return nil if values.length == 0\n\n middle = values.length / 2\n middle_value = values[middle]\n left = values.take(middle)\n right = values.drop(middle + 1)\n\n Node.new(middle_value, build_tree(left), build_tree(right))\n end",
"def construct_segment_tree(input_arr, segment_arr, low, hi, pos)\n if(low == hi)\n segment_arr[pos] = input_arr[low]\n return\n end\n\n mid = (low+hi)/2\n construct_segment_tree(input_arr, segment_arr, low, mid, pos*2+1) #left\n construct_segment_tree(input_arr, segment_arr, mid+1, hi, pos*2+2) #right\n segment_arr[pos] = [segment_arr[pos*2+1], segment_arr[pos*2+2]].min\nend",
"def in_order_traversal(tree_node, arr = [])\n return arr if tree_node == nil\n\n arr = in_order_traversal(tree_node.right, arr)\n arr << tree_node\n arr = in_order_traversal(tree_node.left, arr)\n\n arr\nend",
"def serialize_binary_search_tree_helper( node, nodes_array)\n \n if node.nil?\n return nil\n end\n \n s_node = Serilized_Node.new(node.value)\n \n nodes_array.push(s_node)\n node_index = nodes_array.size - 1 #the index of the sub tree root\n s_node.left_child_index = serialize_binary_search_tree_helper(node.left, nodes_array)\n s_node.right_child_index = serialize_binary_search_tree_helper(node.right, nodes_array)\n\n \n return node_index\nend",
"def build_tree(s)\n bytes = s.bytes\n uniq_b = bytes.uniq\n nodes = uniq_b.map { |byte| Leaf.new(byte, bytes.count(byte)) }\n until nodes.length == 1\n node1 = nodes.delete(nodes.min_by(&:count))\n node2 = nodes.delete(nodes.min_by(&:count))\n nodes << Node.new(node1, node2, node1.count + node2.count)\n end\n nodes.fetch(0)\nend",
"def create_balanced_copy_subtree(elements:)\n return nil if elements.empty?\n\n\n centre_ix = (elements.size / 2).floor\n return Node.new(\n elements[centre_ix][0],\n elements[centre_ix][1],\n create_balanced_copy_subtree(elements: elements[0...(centre_ix)]),\n create_balanced_copy_subtree(elements: elements[(centre_ix+1)..-1]),\n )\n end",
"def hierarchies(array)\n count = 0\n array.reduce([]) { |acc, value| acc << array.slice(0, count += 1) }\n end",
"def initialize(input_array)\n unless input_array.is_a? Array\n raise ValidationError, \"Supplied parameter (#{input_array.inspect}) to #{self.class}#initialize should be of type Array!\"\n end\n\n @child_id_of = {}\n validated_array = []\n\n input_array.each_with_index do |child, i|\n validate_expected_child_type(child, i)\n new_initialized_child = nil\n new_initialized_child_type = nil\n\n self.class.child_types.each do |child_type|\n if child.class == child_type[0] && child.has_key?(child_type[1])\n new_initialized_child = child\n new_initialized_child_type = child_type\n break\n elsif child.has_key?(child_type[1])\n new_initialized_child = child_type[0].new(child)\n new_initialized_child_type = child_type\n break\n end\n end\n\n if new_initialized_child\n validate_unique(new_initialized_child, new_initialized_child_type)\n child_id_of[new_initialized_child_type[0]] ||= {}\n child_id_of[new_initialized_child_type[0]][new_initialized_child[new_initialized_child_type[1]]] = new_initialized_child\n validated_array << new_initialized_child\n end\n end\n\n super validated_array\n end"
] | [
"0.7178468",
"0.7052835",
"0.6953921",
"0.69506204",
"0.6894124",
"0.68749267",
"0.68042964",
"0.6784026",
"0.67772186",
"0.67171127",
"0.66846347",
"0.66815245",
"0.6665387",
"0.6660863",
"0.6652068",
"0.66337943",
"0.65953887",
"0.65851086",
"0.6578991",
"0.65423375",
"0.6517616",
"0.6513462",
"0.65122753",
"0.6433106",
"0.641883",
"0.6392821",
"0.6388658",
"0.6373657",
"0.6359865",
"0.63455546",
"0.6334386",
"0.62987566",
"0.6189992",
"0.6171947",
"0.6056879",
"0.60097086",
"0.6007363",
"0.5949076",
"0.59370995",
"0.59252006",
"0.58680296",
"0.5852711",
"0.58282244",
"0.57713354",
"0.57654196",
"0.5754254",
"0.5739037",
"0.57301307",
"0.5718774",
"0.5704147",
"0.569411",
"0.56607294",
"0.5648468",
"0.56277496",
"0.5592326",
"0.55917245",
"0.5583667",
"0.55422395",
"0.55376565",
"0.55329764",
"0.54997015",
"0.54992634",
"0.54754573",
"0.5465139",
"0.54594535",
"0.54590404",
"0.543642",
"0.54178464",
"0.5414599",
"0.5404576",
"0.5402272",
"0.53921944",
"0.5373036",
"0.5370331",
"0.5302815",
"0.5299871",
"0.52858484",
"0.527398",
"0.5239379",
"0.52278626",
"0.52180195",
"0.52167517",
"0.52053726",
"0.5182939",
"0.51803505",
"0.51740354",
"0.5169565",
"0.5167549",
"0.51653916",
"0.51634896",
"0.5153958",
"0.5137541",
"0.51346403",
"0.51340014",
"0.51147383",
"0.5081659",
"0.50720125",
"0.5055486",
"0.5055458",
"0.5022375"
] | 0.7092395 | 1 |
Aux function to build_tree | def build_tree_aux(input_array, start_index, stop_index)
return nil if start_index > stop_index
middle_index = (start_index + stop_index) / 2
left_half = build_tree_aux(input_array, start_index, middle_index - 1)
middle_value = input_array[middle_index]
right_half = build_tree_aux(input_array, middle_index + 1, stop_index)
Node.new(middle_value, left_half, right_half)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(arr)\n\tend",
"def produce_tree(ary); end",
"def tree\n @tree ||= build_tree\n end",
"def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def build_tree_unsorted(arr)\n root = nil\n arr.each do |item|\n root = insert_tree(item, root)\n end\n\n root\nend",
"def parsed_tree; end",
"def transform(tree); end",
"def build_tree(arr)\n @root = insert_node(nil, arr.shift)\n arr.each { |value| insert_node(@root, value) }\n end",
"def build_tree(array)\n\t\t@root = Node.new(array.shift)\n\t\tarray.each { |value| add_node(value, @root)}\n\tend",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def build_tree(arr)\n @root = Node.new(arr.shift)\n arr.each { |data| insert_data(data, @root) }\n end",
"def build_tree(data)\n @root = Node.new(data[0])\n data.shift\n data.each { |value| @root.insert(value) }\n end",
"def build_tree(array)\n\t\t@root = Node.new(array[0])\n\t\ttemp_root = @root\n\n\t\tarray[1..-1].each do |node_value|\n\t\t\tinsert_node(node_value, temp_root)\n\t\tend\n\tend",
"def build_tree(arr)\n #arr.shuffle!\n arr.each do |x|\n if @root == nil\n @root = Node.new(x)\n else\n current_node = @root\n until current_node == nil\n if x < current_node.value\n parent = current_node\n direction = \"left\"\n current_node = current_node.left_child\n elsif x > current_node.value\n parent = current_node\n direction = \"right\"\n current_node = current_node.right_child\n end\n end\n if direction == \"left\"\n parent.left_child = Node.new(x)\n elsif direction == \"right\"\n parent.right_child = Node.new(x)\n end\n end\n end\n end",
"def build_tree(arr)\n #take array, turn into bt with node objs\n return nil if arr.empty?\n\n mid = (arr.size - 1)/2\n current_node = Node.new(arr[mid])\n\n current_node.left = build_tree(arr[0...mid])\n current_node.right = build_tree(arr[(mid+1)..-1])\n \n current_node\n end",
"def build_tree(unit, node, level = 0)\r\n return nil if level > @max_depth\r\n \t\r\n unit.next_move(node.current_case).each do |next_case|\r\n next if next_case[0] < 0 || next_case[0] > 7 ||\r\n next_case[1] < 0 || next_case[1] > 7 \r\n \r\n next_node = Node.new(next_case, node)\r\n node.children << next_node\r\n\r\n build_tree(unit, next_node, level + 1)\r\n end \r\n end",
"def build_tree\n c1 = ComponentNode.new(110)\n c2 = ComponentNode.new(20)\n c3 = ComponentNode.new(20)\n c4 = ComponentNode.new(150)\n c5 = ComponentNode.new(80)\n c6 = ComponentNode.new(120, [c1, c2, c3])\n c7 = ComponentNode.new(180, [c4, c5])\n return(ComponentNode.new(200, [c6, c7]))\n end",
"def gen_tree\n new_tree = {}\n node_list = {}\n @json_tree.each do |k, v|\n if v['child_of'].nil?\n # top\n new_tree[k] = v\n node_list[k] = new_tree[k]\n else\n parent = v['child_of']\n if v['condition'] == 'and'\n node_list[parent]['and'] ||= {}\n node_list[parent]['and'][k] = v\n node_list[k] = node_list[parent]['and'][k]\n elsif v['condition'] == 'or'\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n else\n # TODO: sink?\n node_list[parent]['or'] ||= {}\n node_list[parent]['or'][k] = v\n node_list[k] = node_list[parent]['or'][k]\n end\n end\n end\n\n @json_tree_type = 'tree'\n @json_tree = new_tree\n end",
"def create_tree(node, elem, level, parent)\n node.level = level\n elemtype = check_type(elem[1])\n case elemtype\n when \"array\"\n node.kind = \"array\"\n node.arrsize = elem[1][\".array_size\"].to_i\n if elem[1].has_key?(\".subtype\") && elem[1][\".subtype\"].has_key?(\".members\")\n elem[1][\".subtype\"][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.s_u_name = $2.clone\n else\n node.s_u_name = \"__ANON__\"\n end\n node.basetype = node.data = elem[1][\".subtype\"][\".type\"].clone\n else\n subkind = check_type(elem[1][\".subtype\"])\n case subkind\n when \"enum\"\n node.basetype = \"enum\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n arr = []\n elem[1][\".subtype\"][\".values\"].each { |k,v| arr << [k,v] }\n node.data[\".values\"] = arr.clone\n node.data[\".values\"].sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\", \"boolean\"\n elem[1][\".subtype\"][\".type_or_id_name\"] =~ /\\((.+)\\): (\\w+)/\n node.basetype = $2.clone\n when \"native\", \"numeric_other\"\n node.basetype = \"OTHER\"\n node.data = {\".type\" => elem[1][\".subtype\"][\".type\"]}\n if elem[1][\".subtype\"].has_key?(\".signed\")\n node.data[\".signed\"] = elem[1][\".subtype\"][\".signed\"] \n end\n if elem[1][\".subtype\"].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".subtype\"][\".type_or_id_name\"]\n end\n end\n node.leaf = true\n end\n when \"struct\", \"union\"\n node.kind = elemtype\n if is_anon?(elem[1])\n node.s_u_name = \"__ANON__\"\n else\n node.s_u_name = item_name(elem[1])\n end\n elem[1][\".members\"].each do |m|\n x = Tree.new(m[0], item_type(elem[1]), node)\n node.create_child(x)\n create_tree(x, m, level+1, node)\n end\n when \"enum\"\n node.kind = \"enum\"\n node.basetype = \"enum\"\n node.s_u_name = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n arr = []\n elem[1][\".values\"].each { |k,v| arr << [k,v] }\n node.data = arr.clone\n node.data.sort! { |a,b| a[1] <=> b[1] }\n when \"numeric_ose\"\n node.kind = \"numeric\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"boolean\"\n node.kind = \"boolean\"\n node.basetype = item_name(elem[1])\n node.parent = parent\n node.leaf = true\n when \"native\", \"numeric_other\"\n node.kind = \"numeric\"\n node.basetype = \"OTHER\"\n node.data = {'.type' => elem[1][\".type\"]}\n node.data[\".signed\"] = elem[1][\".signed\"] if elem[1].has_key?(\".signed\")\n if elem[1].has_key?(\".type_or_id_name\")\n node.data[\".type_or_id_name\"] = elem[1][\".type_or_id_name\"]\n end\n node.parent = parent\n node.leaf = true\n else\n raise \"Node #{node.name} contains erroneous data\" \n end\n end",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def build_tree(array, left=0, right=array.length-1)\n \n# base case\n return if left > right\n\n# from smallest to largest\n array = merge_sort(array)\n\n# middle index, make this the first node\n index_mid = left + (right-left) / 2 \n node = Node.new(array[index_mid]) \n \n# i think it's making the left node (smaller), & right (larger)\n# looks like it is recursion\n node.left_child = build_tree(array, left, index_mid-1) \n node.right_child = build_tree(array, index_mid+1, right) \n\n @tree = node\n @tree\n end",
"def build_tree_helper(arr)\n\treturn Node.new(arr[0]) if arr.size == 1\n\tnode = Node.new(arr.slice!(arr.size / 2))\n\ttree = build_tree(arr)\n\tuntil (node.value > tree.value && tree.right_child.nil?) || (node.value <= tree.value && tree.left_child.nil?)\n\t\ttree = node.value > tree.value ? tree.right_child : tree.left_child\n\tend\n\tif node.value > tree.value\n\t\ttree.right_child = node\n\t\tnode.parent = tree\n\telse\n\t\ttree.left_child = node\n\t\tnode.parent = tree\n\tend\nend",
"def build_tree(array)\n array.sort!.uniq!\n left = 0\n right = array.length\n\n return build_driver(array, left, right)\n end",
"def build_server_tree(tree, options= {})\n result = ''\n tree = Array.wrap tree\n opts = {\n # node and base node params\n :id => :id, # node id field\n :title => :title, # name of title fileld\n :node => nil, # node\n\n # base options\n :type => :tree, # tree type\n :root => false, # is it root node?\n :level => 0, # recursion level\n :namespace => [], # :admin\n\n # BOOST! hash\n :boost => {}\n }.merge!(options)\n\n # Basic vars\n root = opts[:root]\n node = opts[:node]\n\n # namespace prepare [Rails require]\n opts[:namespace] = Array.wrap opts[:namespace]\n\n # Module with **Render** class\n opts[:render_module] = TREE_RENDERERS[opts[:type]] unless opts[:render_module]\n\n # Define tree class\n opts[:klass] = define_class_of_elements_of(tree) unless opts[:klass]\n\n # BOOST PATCH (BUILD ONCE)\n # solution of main perfomance problem\n # magick index-hash, which made me happy!\n\n # Performance comparison\n # Boost OFF: 8000 nodes, 3 levels => (Views: 176281.9ms | ActiveRecord: 189.8ms)\n # Boost ON: 8000 nodes, 3 levels => (Views: 8987.8ms | ActiveRecord: 141.6ms)\n\n if opts[:boost].empty?\n tree.each do |item|\n num = item.parent_id || -1\n opts[:boost][num.to_s] = [] unless opts[:boost][num.to_s]\n opts[:boost][num.to_s].push item\n end\n end\n\n unless node\n # RENDER ROOTS\n roots = opts[:boost]['-1']\n\n # Boost OFF\n # roots = tree.select{ |node| node.parent_id.blank? }\n\n # define roots, if it's need\n if roots.nil? && !tree.empty?\n # Looks like the new algo really does what we need (28 sept. 2016)\n # Thanks to: https://github.com/patrick-nits\n #\n ids = tree.map(&:id)\n opt_ids = opts[:boost].keys.map(&:to_i)\n candidate_ids = (ids + opt_ids).uniq - (ids & opt_ids) # xor\n roots = candidate_ids.map {|c| opts[:boost][c.to_s]}.compact.flatten\n end\n\n # children rendering\n if roots\n roots.each do |root|\n _opts = opts.merge({ :node => root, :root => true, :level => opts[:level].next, :boost => opts[:boost] })\n result << build_server_tree(tree, _opts)\n end\n end\n else\n # RENDER NODE'S CHILDREN\n children_res = ''\n children = opts[:boost][node.id.to_s]\n\n # Boost OFF\n # children = tree.select{ |_node| _node.parent_id == node.id }\n\n opts.merge!({ :has_children => children.blank? })\n\n unless children.nil?\n children.each do |elem|\n _opts = opts.merge({ :node => elem, :root => false, :level => opts[:level].next, :boost => opts[:boost] })\n children_res << build_server_tree(tree, _opts)\n end\n end\n\n result << build_tree_html(self, opts[:render_module], opts.merge({ :root => root, :node => node, :children => children_res }))\n end\n\n raw result\n end",
"def build_tree(array)\n first_node = Node.new(nil, nil, array[0])\n this_node = first_node\n i = 1\n\n finished = false\n while !finished\n if array[i] == nil\n finished = true\n elsif array[i] < this_node.data\n if this_node.left_child == nil\n this_node.left_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.left_child\n end\n elsif array[i] > this_node.data\n if this_node.right_child == nil\n this_node.right_child = Node.new(nil, nil, array[i])\n this_node = first_node\n i += 1\n else\n this_node = this_node.right_child\n end \n elsif array[i] == this_node.data\n i += 1\n end\n end\n return first_node\nend",
"def make_tree_for(position)\n root = TreeNode.new(nil, position)\n\n\nend",
"def build_tree(data, node=self)\n data = data.sort\n build_bin_tree(data, 0, data.length - 1, node)\n end",
"def build_struct_tree data\n data.to_hashugar\n end",
"def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n root.right = \tright\n root\nend",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def buildTree(node,arr)\n node.value = arr.shift\n size = (arr.size/2.0).round\n if size > 0\n left, right = arr.each_slice( size ).to_a\n if left and left.count > 0\n node.left = TreeNode.new\n buildTree(node.left, left)\n end\n if right and right.count > 0\n node.right = TreeNode.new\n buildTree(node.right, right)\n end\n end\nend",
"def navtree_build(ret, item, el, el_type = \"\")\n module_name = item[:classnames][2] ? item[:classnames][2] : item[:classnames][1];\n page_name = item[:crumb]\n\n if !ret[module_name]\n ret[module_name] = {:id => module_name, :children => Hash.new}\n #if item[:deprecated] ret[module_name][:deprecated] = true\n end\n\n if !ret[module_name][:children][page_name]\n ret[module_name][:children][page_name] = {\n :id => page_name,\n :path => item.identifier,\n :children => Hash.new\n }\n #if item[:deprecated] ret[module_name][:deprecated] = true\n end\n\n el_name = el.respond_to?(:name) ? el.name : el\n ret[module_name][:children][page_name][:children][el_name] = {\n :signature => el.respond_to?(:sass_signature) ? el.sass_signature(:none) : el,\n :el_type => el_type\n }\n\n ret\nend",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def build_tree(data_array)\n root = nil\n \n data_array.each do |elem|\n cur_node = root\n \n node = Node.new(elem)\n\tnode.children = Array.new(2, nil)\n\t\n\twhile !cur_node.nil?\n\t if elem < cur_node.value\n\t if cur_node.children[0].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[0] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[0]\n\t else\n\t if cur_node.children[1].nil?\n\t\t node.parent = cur_node\n\t\t cur_node.children[1] = node\n\t\t cur_node = node\n\t\tend\n\t\tcur_node = cur_node.children[1]\n\t end\n\tend\n\t\n\troot ||= node\n\t \n end\n \n root\nend",
"def init_simple_tree\n @root_org = Org.create(name: 'root')\n @lv1_child_org = Org.create(name: 'lv1')\n @lv1_child_org2 = Org.create(name: 'lv1-2')\n @lv2_child_org = Org.create(name: 'lv2')\n @lv2_child_org2 = Org.create(name: 'lv2-2')\n @lv2_child_org3 = Org.create(name: 'lv2-3')\n @lv2_child_org4 = Org.create(name: 'lv2-4')\n @lv3_child_org = Org.create(name: 'lv3')\n @lv3_child_org2 = Org.create(name: 'lv3-2')\n @lv4_child_org = Org.create(name: 'lv4')\n @lv4_child_org2 = Org.create(name: 'lv4-2')\n @lv5_child_org = Org.create(name: 'lv5')\n @lv5_child_org2 = Org.create(name: 'lv5-2')\n\n current_time = Time.now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @root_org.id,\n distance: 0,\n start_time: 10.minutes.ago(current_time),\n end_time: 1000.years.from_now,\n scope_name: 'default'\n )\n\n # 10 minutes ago\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 2,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: 10.minutes.ago(current_time),\n end_time: current_time,\n scope_name: 'default'\n )\n\n # now\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv1_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv2_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org3.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org3.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv2_child_org4.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org2.id,\n child_id: @lv2_child_org4.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv3_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv4_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org.id,\n child_id: @lv5_child_org.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv3_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv3_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv3_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv4_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv4_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv4_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @root_org.id,\n child_id: @lv5_child_org2.id,\n distance: 5,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv1_child_org.id,\n child_id: @lv5_child_org2.id,\n distance: 4,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv2_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 3,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv3_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 2,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\n\n @root_org.elements_under_default_root.create(\n parent_id: @lv4_child_org2.id,\n child_id: @lv5_child_org2.id,\n distance: 1,\n start_time: current_time,\n end_time: 1000.years.since(current_time),\n scope_name: 'default'\n )\nend",
"def build_tree tree_root=nil\n tree_root ||= self.tree_root\n Dir.mkdir(tree_root) unless File.directory?(tree_root)\n Dir.chdir(tree_root) do\n self.files.each do |entry|\n visit_tree entry do |type, name|\n case type\n when :file\n FileUtils.touch(name)\n when :directory\n Dir.mkdir(name)\n else\n throw \"BAD VISIT TREE TYPE. #{type}\"\n end\n end\n end\n end\n end",
"def create_tree(father,tree)\n tree.each do |name|\n n = Meta::create_class(father, name[0], name[1])\n create_tree(n, name[2])\n end\nend",
"def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end",
"def build_tree\n t = RDTree.new\n t.add_node(0, DummyRoot)\n root = root_node_of\n t.add_edge(0, root.attributes[\"ID\"])\n do_build_tree(root, 1, t) \n t\n end",
"def build_tree(item_list = @sorted_list,root_node = nil)\n #sorted root sorts and removes duplicates from the item list\n if (item_list[0] == nil)\n return nil\n else\n start = 0\n end_of_item_list = item_list.length - 1\n mid = (start + item_list.length) / 2\n #set the root node then start creating a tree node for the left and right side of the array\n #Then after that branch is created attach it to the correct position\n root_node = Node.new(item_list[item_list.length/2])\n root_node.right = build_tree(item_list[0,mid],root_node) \n root_node.left = build_tree(item_list[mid+1,end_of_item_list],root_node)\n return root_node\n end\n \n end",
"def build_tree(arr, root, i, n)\n\tif i < n\n\t\troot = TreeNode.new(arr[i])\n\t\troot.left = build_tree(arr, root.left, i*2+1, n)\n\t\troot.right = build_tree(arr, root.right, i*2+2, n)\n\tend\n\treturn root\nend",
"def build_internal_nodes\n names.each do |tmp_geo_area|\n recurse_nodes(tmp_geo_area.parent_names, tmp_geo_area)\n end\n end",
"def build_tree(tree_size, input)\n nodes = Array.new(tree_size) { Node.new(nil, nil, nil) }\n\n tree_size.times do |i|\n line = input.next\n val, left, right = line.chomp.split.map(&:to_i)\n nodes[i].val = val\n nodes[i].left = nodes[left] unless left == -1\n nodes[i].right = nodes[right] unless right == -1\n end\n \n nodes.first\nend",
"def build_tree_arbitrary(arr)\n node = Node.new(arr[0])\n queue = [node]\n @root = node\n i = 0\n\n until queue.empty?\n node = queue.shift\n children = node_children(node, i, arr)\n queue.concat(children)\n i += 2\n end\n end",
"def build_tree_rec(preorder, inorder)\n if inorder.length != 0\n original = preorder.shift\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.left = build_tree(preorder, inorder[0...ind])\n root.right = build_tree(preorder, inorder[ind + 1..-1])\n root\n end\nend",
"def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend",
"def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end",
"def update_tree(element); end",
"def tree(capa = 1)\n R3::Tree.new(capa)\nend",
"def make_tree(pre, inord)\n return if pre.size == 0\n root_node = Node.new(pre[0])\n idx = inord.index(pre[0])\n root_node.left = make_tree(pre[1..idx], inord[0...idx])\n root_node.right = make_tree(pre[idx+1...pre.size], inord[idx+1...inord.size])\n return root_node\nend",
"def recurse_nodes(parent_names, source_tmp_geo_area)\n if parent_names.count > 1\n parents = parent_names.dup # Tricky! \n name = parents.shift\n puts \"building internal node: #{name} : #{parents} \"\n add_item(\n name: name,\n parent_names: parents,\n source_table: source_tmp_geo_area.source_table,\n source_table_gid: source_tmp_geo_area.source_table_gid,\n is_internal_node: true\n )\n recurse_nodes(parents, source_tmp_geo_area)\n end\n end",
"def build_tree(data, par_node)\n return nil if data.empty?\n \n if @node.value <= par_node.value\n if par_node.left == nil\n par_node.left = @node\n else\n build_tree(data, par_node.left)\n end\n else\n if par_node.right == nil\n par_node.right = @node\n else\n build_tree(data, par_node.right)\n end\n end\n\n @node = Node.new(data.shift)\n build_tree(data, @root)\n end",
"def build_tree(array)\n\t\t@root_node = Node.new(array[array.length / 2])\n\t\tarray[array.length / 2] = nil\n\t\tcounter = 0\n\t\tuntil counter == array.length\n\t\t\tset_value(array[counter], @root_node) if array[counter] != nil\n\t\t\tcounter += 1\n\t\tend\n\n\tend",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def build_tree(inorder, postorder)\n return nil if inorder.empty?\n last_node_val = postorder.last\n last_node_index = inorder.index(last_node_val)\n node = TreeNode.new(last_node_val)\n \n if last_node_index > 0\n node.left = build_tree(inorder[0..last_node_index-1], postorder[0..last_node_index-1])\n end\n \n if last_node_index < inorder.length-1\n node.right = build_tree(inorder[last_node_index+1..-1], postorder[last_node_index..-2])\n end\n node\nend",
"def build_tree(tree, parts, path)\n path += '/' unless path.empty? || path.end_with?('/')\n parts[0...-1].each do |p|\n path += \"#{p}/\"\n tree[p] ||= { type: :directory, path: path, sub: {} }\n tree = tree[p][:sub]\n end\n fname = parts[-1]\n tree[fname] = { type: :text, path: path + fname }\n end",
"def populate(array)\n @root = Node.new({type: :document}, [], nil, 0)\n @total_nodes += 1\n @max_depth = 0\n current_node = @root\n current_depth = 0\n array.each do |hash|\n # opening tag - create new node\n if NODE_DOWN.include? hash[:type]\n #if <> depth += 1\n new_node = Node.new(hash, [], current_node, current_node.depth + 1)\n current_node.children << new_node\n current_node = new_node\n current_depth += 1\n @total_nodes += 1\n else #hash[:type] == \"close\"\n #if </> depth -= 1\n new_node = Node.new(hash, [], current_node, current_node.depth)\n current_node.children << new_node\n current_node = current_node.parent\n current_depth -= 1\n @total_nodes += 1\n end\n\n if current_depth > @max_depth\n @max_depth = current_depth\n end\n\n if hash[:type] == :text && current_node.children.empty?\n current_depth -= 1\n current_node = current_node.parent\n end\n end\n self\n end",
"def trees_to_html(trees)\nend",
"def build_tree(list)\n root = Node.new(list[0], nil)\n list[1...list.length].each do |item|\n current_node = root\n while !item.nil?\n if item > current_node.value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.right_child\n end\n elsif item < current_node.value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(item, current_node)\n item = nil\n else\n current_node = current_node.left_child\n end\n else\n item = nil\n end\n end\n end\n root\nend",
"def build_tree(arr)\n if arr.empty?\n return nil\n end\n\n mid = arr.length/2\n root = Node.new(arr[mid])\n\n root.left = build_tree(arr[0...mid])\n root.right = build_tree(arr[(mid+1)..-1])\n\n root\nend",
"def tree(data_path, options = {})\n\t\t\t\tresult = \"\"\n\n\t\t\t\t# Unique hash\n\t\t\t\t@hash = Digest::SHA1.hexdigest(data_path.to_s)\n\n\t\t\t\t# Options\n\t\t\t\t@options = options.nil? ? {} : options\n\n\t\t\t\t# Clipboard\n\t\t\t\tif @options[:clipboard_attrs]\n\t\t\t\t\tclipboard = true\n\t\t\t\t\t@options[:clipboard_attrs] = [@options[:clipboard_attrs]] if !@options[:clipboard_attrs].is_a?(Array)\n\t\t\t\t\tclipboard_attrs_js = \"[\" + @options[:clipboard_attrs].map { |item| \"'#{item}'\" }.join(\",\") + \"]\"\n\t\t\t\telse\n\t\t\t\t\tclipboard = false\n\t\t\t\t\tclipboard_attrs_js = \"[]\"\n\t\t\t\tend\n\n\t\t\t\t# Actions\n\t\t\t\tif @options[:actions]\n\t\t\t\t\tactions_js = \"[\"\n\t\t\t\t\toptions[:actions].each do |key, action|\n\t\t\t\t\t\tactions_js += %{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\turl: '#{action[:path] ? @path_resolver.resolve(action[:path], \":id\") : \"\"}',\n\t\t\t\t\t\t\t\ticon: '#{action[:icon]}',\n\t\t\t\t\t\t\t\tlabel: '#{action[:label]}',\n\t\t\t\t\t\t\t\tcollapsed: #{action[:collapsed] == true ? \"true\" : \"false\"},\n\t\t\t\t\t\t\t\tstyle: '#{action[:style] ? action[:style] : \"default\"}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\t\tactions_js += \"]\"\n\t\t\t\telse\n\t\t\t\t\tactions_js = \"[]\"\n\t\t\t\tend\n\n\t\t\t\t# Parent\n\t\t\t\tparent = (options[:parent] ? options[:parent] : nil)\n\n\t\t\t\t# Save state\n\t\t\t\tsave_state = (options[:save_state] ? options[:save_state] : :simple)\n\n\t\t\t\t# Application JS\n\t\t\t\tresult += @template.javascript_tag(%{\n\t\t\t\t\tvar rug_tree_#{@hash} = null;\n\t\t\t\t\t$(document).ready(function() {\n\t\t\t\t\t\trug_tree_#{@hash} = new RugTree('#{@hash}', {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Model\n\t\t\t\t\t\t\tmodel: 'node',\n\n\t\t\t\t\t\t\t// State\n\t\t\t\t\t\t\tsaveState: '#{save_state.to_s}',\n\n\t\t\t\t\t\t\t// Parent element\n\t\t\t\t\t\t\tparent: '#{parent.to_s}',\n\n\t\t\t\t\t\t\t// Icons\n\t\t\t\t\t\t\tclosedIcon: '#{@icon_builder.render(@options[:closed_icon] ? @options[:closed_icon] : \"chevron-right\")}',\n\t\t\t\t\t\t\topenedIcon: '#{@icon_builder.render(@options[:opened_icon] ? @options[:opened_icon] : \"chevron-down\")}',\n\n\t\t\t\t\t\t\t// Show\n\t\t\t\t\t\t\tshow: #{check_show(@options) ? 'true' : 'false'},\n\t\t\t\t\t\t\tshowEvent: '#{@options[:show_event] && @options[:show_event].to_sym == :double_click ? \"dblclick\" : \"click\"}',\n\t\t\t\t\t\t\tshowUrl: '#{@path_resolver.resolve(@options[:paths][:show], \":id\")}',\n\n\t\t\t\t\t\t\t// Create\n\t\t\t\t\t\t\tcreate: #{check_create(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tcreateUrl: '#{@path_resolver.resolve(@options[:paths][:create])}',\n\t\t\t\t\t\t\tcreateIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"plus\")}',\n\t\t\t\t\t\t\tcreateLabel: '#{I18n.t(\"general.action.create_child\").upcase_first}',\n\t\t\t\t\t\t\tcreateActionCollapsed: #{@options[:create_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tcreateSuccessMessage: '#{I18n.t(\"general.messages.create.success\")}',\n\n\t\t\t\t\t\t\t// Update\n\t\t\t\t\t\t\tupdate: #{check_update(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tupdateUrl: '#{@path_resolver.resolve(@options[:paths][:update], \":id\")}', \n\t\t\t\t\t\t\tupdateIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"pencil\")}',\n\t\t\t\t\t\t\tupdateLabel: '#{I18n.t(\"general.action.update\").upcase_first}',\n\t\t\t\t\t\t\tupdateActionCollapsed: #{@options[:update_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tupdateSuccessMessage: '#{I18n.t(\"general.messages.create.success\")}',\n\n\t\t\t\t\t\t\t// Destroy\n\t\t\t\t\t\t\tdestroy: #{check_destroy(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tdestroyUrl: '#{@path_resolver.resolve(@options[:paths][:destroy], \":id\")}', \n\t\t\t\t\t\t\tdestroyIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"trash\")}',\n\t\t\t\t\t\t\tdestroyLabel: '#{I18n.t(\"general.action.destroy\").upcase_first}',\n\t\t\t\t\t\t\tdestroyActionCollapsed: #{@options[:destroy_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tdestroyConfirmMessage: '#{I18n.t(\"general.are_you_sure\")}',\n\t\t\t\t\t\t\tdestroySuccessMessage: '#{I18n.t(\"general.messages.destroy.success\")}',\n\n\t\t\t\t\t\t\t// Moving\n\t\t\t\t\t\t\tmoving: #{check_moving(@options) ? 'true' : 'false'},\n\t\t\t\t\t\t\tmovingUrl: '#{@path_resolver.resolve(@options[:paths][:move], \":id\", \":relation\", \":destination_id\")}',\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Type\n\t\t\t\t\t\t\ttypeIconTemplate: '#{@icon_builder.render(\":icon\", class: \"jqtree-icon\")}',\n\t\t\t\t\t\t\ttypeIconAttr: '#{@options[:type_icon_attr]}',\n\n\t\t\t\t\t\t\t// Actions\n\t\t\t\t\t\t\tactions: #{actions_js},\n\t\t\t\t\t\t\tactionsIconTemplate: '#{@icon_builder.render(\":icon\")}',\n\n\t\t\t\t\t\t\t// Clipboard\n\t\t\t\t\t\t\tclipboard: #{clipboard ? 'true' : 'false'},\n\t\t\t\t\t\t\tclipboardIcon: '#{@icon_builder.render(@options[:clipboard_icon] ? @options[:clipboard_icon] : \"clipboard\")}',\n\t\t\t\t\t\t\tclipboardTemplate: \"#{clipboard ? (@options[:clipboard_template] ? @options[:clipboard_template].gsub('\"', \"'\") : \":\" + @options[:clipboard_attrs].first) : \"\"}\",\n\t\t\t\t\t\t\tclipboardAttrs: #{clipboard_attrs_js},\n\t\t\t\t\t\t\tclipboardActionCollapsed: #{@options[:clipboard_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Select\n\t\t\t\t\t\t\tselectByDefault: #{@options[:select_by_default] ? @options[:select_by_default].to_i : \"null\"},\n\n\t\t\t\t\t\t\t// Reload\n\t\t\t\t\t\t\treloadIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"refresh\")}',\n\t\t\t\t\t\t\treloadLabel: '#{I18n.t(\"general.action.reload\").upcase_first}',\n\t\t\t\t\t\t});\n\t\t\t\t\t\trug_tree_#{@hash}.ready();\n\t\t\t\t\t});\n\t\t\t\t\t$(document).on('turbolinks:load', function() {\n\t\t\t\t\t\trug_tree_#{@hash}.repair();\n\t\t\t\t\t});\n\t\t\t\t})\n\n\t\t\t\tresult += %{\n\t\t\t\t\t<div id=\"tree-#{@hash}\" data-url=\"#{data_path.to_s}\"></div>\n\t\t\t\t}\n\n\t\t\t\treturn result.html_safe\n\t\t\tend",
"def tree(name, finder, partial = T.unsafe(nil), seen = T.unsafe(nil)); end",
"def method_missing(name, *args, &block)\n super unless respond_to? name\n @builder = Builder.new(builder.tree) do\n __send__(name, *args, &block)\n end\n end",
"def build_tree(preorder, inorder)\n return nil if preorder.empty? || inorder.empty?\n \n root = TreeNode.new(preorder.first)\n idx = inorder.find_index(preorder.first)\n preorder.shift\n\n root.left = build_tree(preorder, inorder.slice(0..(idx-1))) unless idx==0\n root.right = build_tree(preorder, inorder.slice((idx+1)..-1)) if idx!=inorder.size-1\n \n return root\nend",
"def build\n reset\n visit(root, @root)\n end",
"def build_tree(nodes_fragement)\n nodes_element = LonelyPlanet::Node.new nodes_fragement\n node = LonelyPlanet::TreeNode.new(nodes_element.name, nodes_element.id)\n if nodes_element.has_child?\n nodes_element.children.all? { |child_frag|\n node << build_tree(child_frag)\n }\n end\n node\n end",
"def is_valid_tree(tree)\n\nend",
"def write_tree\n invoke(:write_tree)\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def build_tree\n index = 0\n @ignore_list.each do |attribute|\n #puts \"Attribute: #{attribute}\"\n #puts \"Result: #{@max_result_array[index]}\"\n #puts \"Count: #{@max_class_count_array[index]}\"\n\n @max_class_count_array[index].each do |label, count|\n isLeaf = false\n result = nil\n #puts \"Label: #{label}, Count: #{count}\"\n c1_count = count['<=50K.']\n c2_count = count['>50K.']\n ratio_a = c1_count.to_f / c2_count.to_f\n ratio_b = c2_count.to_f / c1_count.to_f\n #puts \"ratio_a: #{ratio_a} || ratio_b: #{ratio_b} || c1: #{c1_count} || c2: #{c2_count}\"\n if ratio_a >= 30 or ratio_b >= 30 then\n # Have a high ratio, thus we can declare a class\n if c1_count > c2_count\n # declare class 1\n #puts \"Ratio is HIGH, #{ratio_a}, declare any #{attribute} with a #{label} to be class <=50K.\"\n isLeaf = true\n result = '<=50k'\n else\n #puts \"Ratio B is HIGH, #{ratio_b}, declare any #{attribute} with a #{label} to be class >50K.\"\n isLeaf = true\n result = '>50k'\n end\n else\n #puts \"Ratio is too LOW for #{attribute} with label #{label}.\"\n end\n\n if index == 0 then parent = nil else parent = @ignore_list[index-1] end\n\n if isLeaf then\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => nil, 'parent' => parent]\n else\n @tree[label] = Hash['attribute' => attribute, 'label' => label, 'isLeaf' => isLeaf, 'result' => result, 'child' => @ignore_list[index+1], 'parent' => parent]\n end\n\n end\n index += 1\n end\n\n @tree.each { |node| puts node }\n end",
"def build_tree(elements)\n return if elements.empty?\n char = elements.shift\n node = BinaryTree.new(char)\n if char == \"I\"\n node.left = build_tree(elements)\n node.right = build_tree(elements)\n end\n return node\nend",
"def build_tree array\n\t\t@root = Node.new(array.shift)\n\t\tparent = @root\n\t\tarray.each do |el|\n\t\t\twhile true\n\t\t\t\tif el <= parent.value\n\t\t\t\t\tif parent.left_child.nil?\n\t\t\t\t\t\tparent.left_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.left_child\n\t\t\t\t\tend\n\t\t\t\telsif el > parent.value\n\t\t\t\t\tif parent.right_child.nil?\n\t\t\t\t\t\tparent.right_child = Node.new(el,parent)\n\t\t\t\t\t\tbreak\n\t\t\t\t\telse\n\t\t\t\t\t\tparent = parent.right_child\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def tree\r\n @rootNode\r\n end",
"def build_move_tree\n move_q = [@root]\n while move_q.length > 0\n children = new_move_positions(move_q[0].value)\n children.each do |kid|\n move_q[0].add_child(PolyTreeNode.new(kid))\n end\n move_q += move_q[0].children\n move_q.shift\n end\n nil\n end",
"def tree(path)\n root.tree(path)\n end",
"def initialize(tree={})\n tree.each do |k,v|\n @node_name = k\n @children = v.map {|sk,sv| Tree.new({sk => sv}) }\n end\n end",
"def build_move_tree\n self.root_node = PolyTreeNode.new(start_pos) #instance variable\n \n queue = [root_node]\n until queue.empty?\n #pop,queue\n cur_node = queue.shift\n move_list = new_move_positions(cur_node.value)\n move_list.each do |pos|\n child_node = PolyTreeNode.new(pos)\n cur_node.add_child(child_node)\n queue << child_node\n end\n end\n end",
"def tree\n\n h.updated_tree || h.original_tree\n end",
"def tree\n root = Node.new(1)\n root.left = Node.new(2)\n root.right = Node.new(3)\n root.left.left = Node.new(4)\n root.left.right = Node.new(5)\n root.right.left = Node.new(6)\n root.right.right = Node.new(7)\n root.right.right.right = Node.new(8)\n root\nend",
"def tree_results(word_data)\n #get the data ready for d3 view\n tree_data = {\"name\"=> (@topic.name), \"info\" => \"tst\", \"children\" => []}\n \n word_data.each do |text, v|\n tree_data[\"children\"].push({\"name\" => text.to_s, \"children\" => []})\n end\n \n tree_data[\"children\"][0][\"children\"] << Hash[\"name\", word_data[:word]]\n \n word_data[:definitions].each do |text|\n tree_data[\"children\"][1][\"children\"] << Hash[\"name\", text[\"text\"]]\n end\n \n word_data[:word_associations].each do |text|\n tree_data[\"children\"][2][\"children\"] << Hash[\"name\", text[\"relationshipType\"], \"children\", []]\n end \n if word_data[:reverse_definitions][\"results\"].nil? \n tree_data[\"children\"][3][\"children\"] << nil\n else\n word_data[:reverse_definitions][\"results\"].each do |result| \n tree_data[\"children\"][3][\"children\"] << Hash[\"name\", result[\"text\"]]\n end\n end\n i = 0\n word_data[:word_associations].each do |text|\n text[\"words\"].each do |word|\n tree_data[\"children\"][2][\"children\"][i][\"children\"] << Hash[\"name\", word]\n end\n i+=1\n end\n #reduce duplicates in word_association hash\n tree_data[\"children\"][3][\"children\"].uniq!\n tree_data[\"children\"][2][\"children\"].uniq!\n return tree_data\n end",
"def construct_tree(arr)\n root = TreeNode.new(arr.shift)\n xtd = [root]\n while !xtd.empty? && !arr.empty?\n cur_node = xtd.shift\n a, b = arr.shift(2) # doesn't matter if arr.size < 2. in this case, a, b might be nil\n cur_node.left = a.nil? ? nil : TreeNode.new(a)\n cur_node.right = b.nil? ? nil : TreeNode.new(b)\n xtd << cur_node.left unless cur_node.left.nil?\n xtd << cur_node.right unless cur_node.right.nil?\n end\n root\nend",
"def convert(tree, options = T.unsafe(nil)); end",
"def build_sub_tree( parent_id, path_names )\n path_name_tokens = path_names.split( \"|\" )\n zone = path_name_tokens[1] \n \n if db_request?( path_name_tokens ) \n sub_tree = build_db_tree( parent_id, zone )\n else\n db_name = path_name_tokens.last \n sub_tree = build_cltn_tree( parent_id, zone, db_name )\n end\n sub_tree\n end",
"def build_tree(model)\n # inflate the node id to test id wrap around edge cases\n ENV[\"NODES\"].to_i.times { model.create!.destroy } if ENV[\"NODES\"]\n\n n1 = model.create!\n n2 = model.create!(:parent => n1)\n n3 = model.create!(:parent => n2)\n n4 = model.create!(:parent => n2)\n n5 = model.create!(:parent => n1)\n n6 = model.create!(:parent => n5)\n\n puts \"create: #{n1.id}..#{n6.id}\" if ENV[\"NODES\"]\n [n1, n2, n3, n4, n5, n6]\n end",
"def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end",
"def structure_reform(curNode, addNode)\n # reset branches for reform\n @branches = []\n @branch_count = 0\n # puts 'before cleanup'\n # lNode.print_tree\n # rNode.print_tree\n # rNode.print_tree\n # remove_PH_node(lNode)\n # remove_PH_node(rNode)\n # remove_PH_node(curNode)\n # puts 'after cleanup'\n # curNode.print_tree\n # addNode.print_tree\n # rNode.print_tree\n curChildren = curNode.children.count == 0 ? [curNode] : curNode.children\n addChildren = addNode.children.count == 0 ? [addNode] : addNode.children\n count = 0\n # p 'lnode'\n # pp lChildren\n # p 'rnode'\n curChildren.each do |ln|\n curNode.remove!(ln)\n addChildren.each do |rn|\n # p '--------------'\n # p 'ln'\n # ln.print_tree\n # p 'rn'\n # rn.print_tree\n # binding.pry\n # phName=\"PH#{@branch_count}\"\n # ph =Tree::TreeNode.new(phName, '')\n ln_append = ln.detached_subtree_copy\n # p 'ln_append before'\n # ln_append.print_tree\n append_to_end(ln_append, rn)\n # p 'ln_append'\n # ln_append.print_tree\n # ph<<ln_append #unless curNode==newNode\n ln_append = add_branch(ln_append)\n # p 'ln_append after'\n # ln_append.print_tree\n curNode << ln_append\n # p 'ph'\n # ph.print_tree\n # p 'curNode'\n # curNode.print_tree\n end\n end\n end",
"def buildTree( prefixArray )\n return nil if prefixArray.empty?\n value = prefixArray.pop\n if( root.nil? )\n @root = TreeNode.new(value, nil, nil)\n # the right child comes before left since prefixArray \n # is really a _stack_\n @root.rightChild = buildTree( prefixArray )\n @root.leftChild = buildTree( prefixArray )\n elsif( isOp?(value) )\n newNode = TreeNode.new(value, nil, nil)\n newNode.rightChild = buildTree( prefixArray )\n newNode.leftChild = buildTree( prefixArray )\n return newNode\n else\n return TreeNode.new(value, nil, nil)\n end\n end",
"def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end",
"def build_tree(preorder, inorder)\n return nil if preorder.empty? && inorder.empty?\n\n array = []\n\n node = Node.new(preorder.first)\n\n array << preorder.first\n\n idx = inorder.index(preorder.first)\n\n left_inorder = inorder[0...idx]\n right_inorder = inorder[(idx+1)..-1]\n\n left_preorder = preorder & left_inorder\n right_preorder = preorder & right_inorder\n\n node.left = build_tree(left_preorder, left_inorder)\n node.right = build_tree(right_preorder, right_inorder)\n\n node\nend",
"def fetch_tree(klass, name, node_id = nil)\n tree = klass.new(name, {}, false)\n\n # FIXME: maybe here we would need instance_exec/eval instead\n yield(tree) if block_given?\n\n tree.reload!\n\n if node_id\n tree.x_get_child_nodes(node_id).to_json\n else\n tree.instance_variable_get(:@bs_tree)\n end\n end",
"def process_tree_with_renew\n @process_tree = nil\n process_tree\n end",
"def build_tree(data, parent = nil)\n return if data.size.zero?\n center = half(data)\n value = data[center]\n @depth_first << value\n\n # Recusion to split halves until zero then execute logic\n build_tree(l_half = data[0...center], value)\n build_tree(r_half = data[center + 1..-1], value)\n\n # Node creation and set node properties\n l_child = l_half[half(l_half)]\n r_child = r_half[half(r_half)]\n Node.new(value, parent, l_child, r_child)\n end",
"def initialize(arr)\n @value = arr.sort.uniq\n @root = build_tree(value)\n end",
"def build_tree(start, finish, node = Node.new(start), queue = [node])\n @root = node\n\n until queue.index { |n| n.value == finish }\n node = queue.shift\n node.children = generate_move_nodes(node.value, finish)\n node.children.each { |c| queue << c }\n end\n end",
"def generate_toc_tree(toc, type, attr); end",
"def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end",
"def build_tree_from_unsorted(arr)\n return nil if arr.empty?\n @root = Node.new(arr.shift)\n\n until arr.empty?\n child_node = Node.new(arr.shift)\n assign_children(@root, child_node)\n end\n end",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def build_tree( arr, first_index = 0, last_index = arr.length - 1 )\n return nil if first_index > last_index\n \n middle_of_array = (first_index + last_index)/2\n \n root = Node.new(arr[middle_of_array])\n \n root.left_child = build_tree(arr, first_index, middle_of_array - 1)\n root.right_child = build_tree(arr, middle_of_array + 1, last_index)\n \n return root \n end"
] | [
"0.80958796",
"0.76826626",
"0.73350346",
"0.72577316",
"0.71102494",
"0.7083005",
"0.7029116",
"0.6905179",
"0.68785703",
"0.68664896",
"0.68532866",
"0.6838869",
"0.68172544",
"0.6813181",
"0.6777184",
"0.67601293",
"0.6740358",
"0.67166764",
"0.67084575",
"0.6697673",
"0.6668583",
"0.66558856",
"0.664457",
"0.6642127",
"0.6631405",
"0.6572531",
"0.6562675",
"0.6553876",
"0.6550031",
"0.65452003",
"0.6541205",
"0.65292823",
"0.651774",
"0.6512723",
"0.65109086",
"0.65041023",
"0.64689666",
"0.6417088",
"0.63959163",
"0.63885367",
"0.6386854",
"0.6375469",
"0.6372971",
"0.6367559",
"0.6358012",
"0.63562393",
"0.6346447",
"0.63393",
"0.6314655",
"0.630803",
"0.630741",
"0.6301529",
"0.62953955",
"0.6268146",
"0.62670153",
"0.62657624",
"0.6259105",
"0.6256976",
"0.62376076",
"0.6234918",
"0.6230661",
"0.622841",
"0.62267643",
"0.62228143",
"0.622115",
"0.62136155",
"0.620417",
"0.62038255",
"0.6200203",
"0.61983675",
"0.6185768",
"0.61825424",
"0.6174084",
"0.61659545",
"0.6157666",
"0.6150785",
"0.61493796",
"0.6145778",
"0.6139925",
"0.6137434",
"0.61361164",
"0.6131528",
"0.6122211",
"0.6110792",
"0.6110571",
"0.6108989",
"0.60958767",
"0.60834193",
"0.6077321",
"0.60772634",
"0.6075319",
"0.60631424",
"0.6058996",
"0.60549444",
"0.6053916",
"0.6048128",
"0.6042622",
"0.6039136",
"0.6028439",
"0.6022544",
"0.60198426"
] | 0.0 | -1 |
Insert a value to the BBT, careful, this may unbalance the tree | def insert(value)
current_node = @root
until current_node.nil?
if current_node.data < value
if current_node.right_child.nil?
current_node.right_child = Node.new(value)
break
end
current_node = current_node.right_child
elsif current_node.data > value
if current_node.left_child.nil?
current_node.left_child = Node.new(value)
break
end
current_node = current_node.left_child
else
puts 'Input error'
break
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insertar(value)\n insert(Node.new(value, nil, nil))\n end",
"def insert(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value >= value \n\t\t\t@head = Node.new(value, current_node)\n\t\tend \n\t\tuntil current_node.next_node.value =< value \n\t\t\tbreak if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = Node.new(value, current_node.next_node)\n\tend",
"def insert(value)\n search_result = binary_search_internal(value)\n unless search_result[0]\n @inner.length.downto(search_result[1] + 1) { |i| @inner[i] = @inner[i - 1] }\n @inner[search_result[1]] = value\n end\n return search_result[1]\n end",
"def node_insert(node, value)\n if value < node.value\n if node.left\n node_insert(node.left, value)\n else\n node.left = BSTNode.new(value, node)\n end\n else\n if node.right\n node_insert(node.right, value)\n else\n node.right = BSTNode.new(value, node)\n end\n end\n end",
"def insert(value, node = root)\n return nil if value == node.data\n \n if value < node.data\n node.left.nil? ? node.left = Node.new(value) : insert(value, node.left)\n else\n node.right.nil? ? node.right = Node.new(value) : insert(value, node.right)\n end\n end",
"def insert(value)\n @size += 1\n if empty?\n @root = TreeNode.new(value)\n return\n end\n\n # Attempt to bring the new value to the top of the tree.\n splay(value)\n # If value is @root, it must already be in the tree\n return if not empty? and @root.value == value\n\n # Otherwise, we need to insert a new root.\n new_root = TreeNode.new(value)\n if empty?\n # This value will be the new root if the tree is empty.\n @root = new_root\n elsif new_root.value > @root.value\n # If the element is larger than the old root, @root becomes the left child of the new root.\n new_root.left = @root\n new_root.right = @root.right\n @root.right = nil\n else\n # Alternatively, @root becomes new_root's left child.\n new_root.right = @root\n new_root.left = @root.left\n @root.left = nil\n end\n @root = new_root\n end",
"def insert(value)\n current = self\n while true\n if current.value > value\n if current.left.nil?\n current.left = BST.new(value)\n break\n else\n current = current.left\n end\n else\n if current.right.nil?\n current.right= BST.new(value)\n break\n else\n current = current.right\n end\n end\n end\n end",
"def insert_after value\n node = Node.new value, @nxt, self\n @nxt.prv = node if @nxt\n @nxt = node\n end",
"def insert(key, value = nil)\n node = @root\n if node.full? \n @root = Btree::Node.new(@degree)\n @root.add_child(node)\n @root.split(@root.children.size - 1)\n #puts \"After split, root = #{@root.inspect}\"\n # split child(@root, 1)\n node = @root\n end\n node.insert(key, value)\n @size += 1\n return self\n end",
"def insert(value)\n node = @current\n @current = LinkNode.call(value, node, :after, self, &@match_value)\n self.head = @current if self.head.nil?\n self.tail = @current if self.tail.equal?(node)\n self.size += 1\n end",
"def insert node, value= nil\n\t\t\tif value < node.value\n\t\t\t\tnode.left.nil? ? node.left = Node.new(value, node) : insert(node.left, value)\n\t\t\telsif value >= node.value\n\t\t\t\tnode.right.nil? ? node.right = Node.new(value, node) : insert(node.right, value)\n\t\t\tend\t\t\n\tend",
"def insert(value)\n if empty?\n @root = Node.new(value)\n return\n end\n\n x = Node.new(value)\n\n # find right leaf to insert under\n temp = @root\n while !temp.nil? do\n # need to track parent so when we exit the loop,\n # we can still reference the leaf node found\n found_leaf = temp\n\n if temp.val > value\n temp = temp.left\n elsif temp.val < value\n temp = temp.right\n else\n puts DUPLICATE_VAL\n return\n end\n end\n\n if found_leaf.val > value\n found_leaf.left = x\n else\n found_leaf.right = x\n end\n end",
"def insert new_value\n if new_value <= @value\n @left.nil? ? @left = Node.new(new_value) : @left.insert(new_value)\n elsif new_value > @value\n @right.nil? ? @right = Node.new(new_value) : @right.insert(new_value)\n end\n end",
"def insert(new_value)\n if new_value > @value\n @right ? @right.insert(new_value) : (@right = Node.new(new_value))\n else\n @left ? @left.insert(new_value) : (@left = Node.new(new_value))\n end\n end",
"def insert_into_subtree(value, root)\n if (value <= root.value)\n if root.left\n root = root.left\n insert_into_subtree(value, root)\n else\n root.left = BSTNode.new(value, root)\n end\n else\n if root.right\n root = root.right\n insert_into_subtree(value, root)\n else\n root.right = BSTNode.new(value, root)\n end\n end\n end",
"def insert(value)\n puts \"Inserting: #{value.to_s}\"\n current_node = @root\n while nil != current_node\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value, nil, nil)\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value, nil, nil)\n elsif (value < current_node.value)\n current_node = current_node.left\n elsif (value > current_node.value)\n current_node = current_node.right\n else\n return\n end\n end\n end",
"def insert(value)\n inserted = false\n\n if @root.nil?\n @root = BSTNode.new(value)\n inserted = true\n end\n\n current_node = @root\n\n until inserted\n # p current_node.value\n # p value\n\n if value <= current_node.value && current_node.left.nil?\n # p \"inserted left\"\n current_node.left = BSTNode.new(value)\n inserted = true\n elsif value <= current_node.value\n # p \"switching to left child\"\n current_node = current_node.left\n next\n elsif value > current_node.value && current_node.right.nil?\n # p \"inserted right\"\n current_node.right = BSTNode.new(value)\n inserted = true\n elsif value > current_node.value\n # p \"switching to right child\"\n current_node = current_node.right\n next\n end\n end\n\n end",
"def insert(key, value)\n i = key.hash % @table.size\n node = @table[i]\n while node\n if key == node.key\n node.value = value\n return\n end\n node = node.next\n end\n @table[i] = Node.new(key, value, @table[i])\n @count += 1\n end",
"def insert(value, tree)\n if tree[:root] == nil\n tree[:root] = value\n return\n end\n if tree[:root] >= value\n insert_left(value, tree)\n return\n end\n insert_right(value, tree)\nend",
"def insert(value)\n new_node = Node.new(value)\n\n return @root = new_node if is_empty\n\n current = @root\n parent = nil\n\n while current != nil\n parent = current\n current = value <= current.value ? current.left : current.right\n end\n\n value <= parent.value ? parent.left = new_node : parent.right = new_node\n end",
"def insertion(value)\n insertion_recursion(value, @root)\n end",
"def insert(key, value, __level = nil)\n @mutex.synchronize do\n newlevel = __level || random_level\n x = node_first\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # rewrite existing key\n \t if node_compare(x, key) == 0\n \t node_set_value!(x, value)\n \t # insert in a middle\n \t else\n \t level = newlevel\n \t newx = new_node(newlevel, key, value)\n \t while level > 0\n \t level -= 1\n \t node_insert_after!(newx, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def insert(key, value, __level = nil)\n @mutex.synchronize do\n newlevel = __level || random_level\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # rewrite existing key\n \t if node_compare(x, key) == 0\n \t node_set_value!(x, value)\n \t # insert in a middle\n \t else\n \t level = newlevel\n \t newx = new_node(newlevel, key, value)\n \t while level > 0\n \t level -= 1\n \t node_insert_after!(newx, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def insert(key,value)\n tree = insert_help(key,value)\n if tree.kick?\n tree.to_tree\n else\n tree\n end\n end",
"def insert(value, current_node = @root)\n value = value.value if value.is_a? Node\n case value <=> current_node.value\n when 0 # Value already exists in the tree\n false\n when -1 # Left subtree\n if current_node.left.nil?\n current_node.left = Node.new(value)\n true\n else\n insert(value, current_node.left)\n end\n else # Right subtree\n if current_node.right.nil?\n current_node.right = Node.new(value)\n true\n else\n insert(value, current_node.right)\n end\n end\n end",
"def insert(value)\n current_node = @root\n while nil != current_node\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value,nil,nil)\n elsif (value < current_node.value)\n current_node = current_node.left\n elsif (value > current_node.value)\n current_node = current_node.right\n else\n return\n end\n end\n end",
"def insert(v)\n @stacks.shift until @stacks.first.right.nil?\n t = @stacks.first\n @stacks << TreeNode.new(v)\n if t.left.nil?\n t.left = @stacks.last\n else\n t.right = @stacks.last\n end\n t.val\n end",
"def insert(value)\n node = Node.new(value)\n current = @anchor.next_node\n while current != @anchor\n if @comparator.call(node.value, current.value)\n return node.insert_before(current)\n end\n current = current.next_node\n end\n node.insert_before(@anchor)\n end",
"def insert_before value\n node = Node.new value, self, @prv\n @prv.nxt = node if @prv\n @prv = node\n end",
"def insert_into_tree(root, new_value, index)\n if root.val == new_value\n return root\n elsif new_value < root.val\n if root.left\n insert_into_tree(root.left, new_value, index)\n else\n root.left = TreeNode.new(new_value, index )\n end\n else\n if root.right\n insert_into_tree(root.right, new_value, index)\n else\n root.right = TreeNode.new(new_value, index)\n end\n end\nend",
"def insert(value)\n new_node = Node.new(value)\n @head.prev = new_node if @head\n new_node.next = @head\n @tail = new_node unless @tail\n @head = new_node\n @count += 1\n end",
"def insert_at(value, index)\n prev = self.at(index - 1)\n next_node = prev.next_node\n prev.next_node = Node.new(value, next_node)\n end",
"def insert(node)\n if(node.value < @value)\n unless @left==nil\n @left.insert(node)\n else\n @left=node\n @left.root=self\n end\n elsif(node.value >@value)\n unless @right==nil\n @right.insert(node)\n else\n @right=node\n @right.root=self\n end\n else\n @value = node.value\n end\n end",
"def insert(value)\n self.heap.append(value)\n self.sift_up(self.heap.length-1, self.heap)\n end",
"def insert(index, value)\n if index == @size\n append(value)\n else\n assert_in_range(index)\n \n current, previous = get_node(index)\n inserted = LinkedListNode.new(:successor => current, :value => value)\n previous.successor = inserted if previous\n \n @head = inserted if current == @head \n @size += 1\n end\n end",
"def insert_into_tree(root_node, value)\n return BSTNode.new(value) if root_node.nil?\n\n if value <= root_node.value \n root_node.left = insert_into_tree(root_node.left, value)\n else\n root_node.right = insert_into_tree(root_node.right, value)\n end\n\n root_node\n end",
"def insert!(value, papa)\n if value <= papa.value && papa.left\n insert!(value, papa.left)\n elsif value <= papa.value\n papa.left = BSTNode.new(value)\n papa.left.papa = papa\n elsif value > papa.value && papa.right\n insert!(value, papa.right)\n else\n papa.right = BSTNode.new(value)\n papa.right.papa = papa\n end\n end",
"def insert_at(value, index)\n current = @head\n (index - 1).times do\n current = current.next_node\n end\n\n current.next_node = Node.new(value, current.next_node)\n \n end",
"def insert_into_tree(node, value)\n return BSTNode.new(value) if node.nil?\n\n if value <= node.value\n node.left = insert_into_tree(node.left, value)\n elsif value > node.value\n node.right = insert_into_tree(node.right, value)\n end\n\n node\n end",
"def insert(current_node = root, value)\n # compare nodes,decide if left or right \n return nil if value == current_node.value\n\n if value < current_node.value\n current_node.left.nil? ? current_node.left = Node.new(value) : insert(current_node.left, value)\n else\n current_node.right.nil? ? current_node.right = Node.new(value) : insert(current_node.right, value)\n end\n end",
"def insert_node(node, value)\n return BSTNode.new(value) if node.nil?\n if value <= node.value\n node.left = insert_node(node.left, value)\n else\n node.right = insert_node(node.right, value)\n end\n node\n end",
"def insert_after(value)\n node = Node(value)\n @next = node\n node\n end",
"def insert(value)\n if root.nil?\n self.root= BSTNode.new(value) #if root doesn't exist\n else\n root = self.root\n while(root)\n if value > root.value\n if root.right.nil?\n new_node = BSTNode.new(value)\n root.right = new_node\n root = root.right\n return root.right #return the newly added node\n else\n root = root.right #traverse\n end\n else\n if root.left.nil?\n new_node = BSTNode.new(value)\n root.left = new_node\n return root.left #return the newly added node\n else\n root = root.left #traverse\n end\n end\n end\n end\n root\n end",
"def insert(value, root = @root)\n node = Node.new(value)\n return (root == @root ? @root = node : node) if root.nil?\n\n return nil unless find(value).nil?\n\n if node < root\n root.left = insert(value, root.left)\n else\n root.right = insert(value, root.right)\n end\n root\n end",
"def insert_node(tree_node, value)\r\n\r\n # Base Case: Found a space\r\n if tree_node.nil?\r\n tree_node = Node.new(value)\r\n\r\n elsif tree_node.value == value\r\n tree_node.value = value\r\n elsif tree_node.value < value\r\n tree_node.right = insert_node(tree_node.right, value)\r\n else\r\n tree_node.left = insert_node(tree_node.left, value)\r\n end\r\n tree_node\r\n end",
"def push(value)\n insert(value)\n self\n end",
"def insert(value)\n @heap.append(value)\n self.sift_up(@heap.length - 1, @heap)\n end",
"def insert(value) # works according to VisualAlgo\n @values.push(value)\n index = @values.length - 1\n while index > 0 do\n parent_index = ((index-1)/2).to_i\n break if @values[parent_index] > @values[index]\n @values[index] = @values[parent_index]\n @values[parent_index] = value\n index = parent_index\n end\n return self\n end",
"def insert(value)\n store.push value\n swim(length)\n self\n end",
"def insert_tree_node(tree_node, value)\n return BSTNode.new(value) if tree_node.nil?\n\n if value <= tree_node.value\n tree_node.left = insert_tree_node(tree_node.left, value)\n elsif value > tree_node.value\n tree_node.right = insert_tree_node(tree_node.right, value)\n end\n\n tree_node\n end",
"def push(value)\n @data = LLNode.new(value, @data)\n end",
"def push(value)\n # IMPLEMENT ME!\n @data = Node.new(value, @data)\n end",
"def push (value)\n @top = Node.new(value, @top)\n end",
"def insert_into_tree(tree_node, val)\n\n return BSTNode.new(val) if tree_node.nil?\n if val < tree_node.value\n tree_node.left = insert_into_tree(tree_node.left, val)\n else\n tree_node.right = insert_into_tree(tree_node.right, val)\n end\n tree_node\n end",
"def insert(insert_val)\n\t\t\tcase value <=> insert_val\n\t\t\twhen 1 \n\t\t\t\tinsert_left insert_val\n\t\t\twhen -1\n\t\t\t insert_right insert_val\n\t\t\twhen 0\n\t\t\t false\n\t\t\tend\n\t\tend",
"def insert(value)\n puts \"Inserting :\" + value.to_s\n current_node = @root\n\n while nil != current_node\n\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n puts \"val is less\"\n\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value,nil,nil)\n puts \"val is more\"\n\n elsif (value < current_node.value)\n current_node = current_node.left\n puts \"doing this not nil left\"\n\n elsif (value > current_node.value)\n current_node = current_node.right\n puts \"doing this not nil right\"\n\n else\n return\n end\n end\n end",
"def insert(value, title)\n node = @root\n i = 0\n while node != nil\n parent_node = node\n node = value < node.value ? node.left : node.right\n i += 1\n end\n\n if has_root?\n parent_node.left = Node.new(value, title, parent_node, i) if value < parent_node.value\n parent_node.right = Node.new(value, title, parent_node, i) if value >= parent_node.value\n else\n @root = Node.new(value, title, nil, i)\n end\n i\n end",
"def insert_at(index, value)\n node = Node.new\n node.value = value\n counter = 0\n current_node = @head\n until counter == index\n previous_node = current_node\n current_node = current_node.next_node\n counter += 1\n end\n previous_node.next_node = node\n node.next_node = current_node\n end",
"def push(value)\r\n @head = Node.new(value, @head)\r\n end",
"def insert_by_begin(value)\n\t\tif @head.nil?\n\t\t\t@head = @Node.new(value, nil, nil)\n\t\t\t@tail = @head\n\t\telse\n\t\t\t@head[:prev] = @Node.new(value, @head, nil)\n\t\t\t@head = @head[:prev]\n\t\tend\n end",
"def insert(value) \n self.head.nil? ? insert_empty_list(value) : insert_on_end(value)\n\n print \"=> Result insertion: \"\n print_simple_list(self.last)\n end",
"def insert_at(value, index)\n if index == 0\n prepend(value)\n elsif index >= self.size\n append(value)\n else\n prev = nil\n cur = head\n i = 0\n until i == index\n prev = cur\n cur = cur.next_node\n i += 1\n end\n prev.next_node = Node.new(value, cur)\n end\n end",
"def insert(value, priority=value, subpriority=nil)\n loc = Locator.new(value, priority, subpriority)\n insert_locator(loc)\n end",
"def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n\n end",
"def insert_in_bst(root, data)\n if !root\n root = Node.new(data)\n elsif data < root.value\n root.left_child = insert_in_bst(root.left_child, data)\n else\n root.right_child = insert_in_bst(root.right_child, data)\n end\n root\nend",
"def test_insert_adds_node_at_root\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.root.value\n end",
"def insert(v)\n old_balance,higher_tree = @balance, false\n @value = v if empty?\n case @value <=> v\n when 1\n if @left.nil?\n @left = AVLTree.new(v)\n update_balance_left(old_balance)\n higher_tree = (old_balance == :even)\n else\n higher_tree = @left.insert(v) \n update_balance_left(old_balance) if higher_tree\n case @balance\n when :even\n higher_tree = false\n when :left\n higher_tree = balance_left_side! if higher_tree and old_balance == :left\n when :right\n higher_tree = false\n end\n end\n when -1\n if @right.nil?\n @right = AVLTree.new(v)\n update_balance_right(old_balance)\n higher_tree = (old_balance == :even)\n else\n higher_tree = @right.insert(v) \n update_balance_right(old_balance) if higher_tree\n case @balance\n when :even\n higher_tree = false\n when :right\n higher_tree = balance_right_side! if higher_tree and old_balance == :right\n when :left\n higher_tree = false\n end\n end\n end\n higher_tree\n end",
"def insert(value)\n node = @current\n @current = LinkNode.call(value, node, :circle_after, self, &@match_value)\n if self.size == 0 # only\n self.head = @current\n self.tail = @current\n elsif self.tail == node\n self.tail = @current\n @current.next = self.head\n self.head.prev = @current\n end\n self.size += 1\n end",
"def push(value)\n @head = Node.new(value, @head)\n end",
"def insert(value)\n @heap << value\n perc_up(@heap.length - 1)\n end",
"def insert_data(data)\n self.root = insert(data)\n end",
"def push(value)\n new_head = Node.new value, @head\n @head = new_head\n end",
"def insert(value, node = @root)\n if node.nil?\n return Node.new(value)\n end\n\n if value > node.value\n node.right_node = insert(value, node.right_node)\n elsif value < node.value\n node.left_node = insert(value, node.left_node)\n end\n\n return node\n end",
"def insert(node, value)\n if node.left.nil? && value < node.val\n return node.left = TreeNode.new(value)\n elsif node.right.nil? && value > node.val\n return node.right = TreeNode.new(value)\n end\n\n insert(node.left, value) if value < node.val\n insert(node.right, value) if value > node.val\n\n return node\nend",
"def insert(key)\n @root = insert_helper(@root, key)\n end",
"def insert_before(value)\n node = Node(value)\n node.next = self\n node\n end",
"def insert_at(index, node_value)\n if index == 0\n node = Node.new(node_value)\n node.next_node = @head\n @head = node\n else\n target = at(index)\n if target.nil?\n append(node_value)\n else\n node = Node.new(node_value)\n pre_target = at(index - 1)\n node.next_node = target\n pre_target.next_node = node\n end\n end\n\n node\n end",
"def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n node = find node\n node_after = node.next\n node_inserted = Node.new value\n node.next = node_inserted\n node_inserted.next = node_after\n node_inserted\n end",
"def insert(value)\n # YOUR WORK HERE\n end",
"def insert_at(value, index, current_index = 0, node = @head)\n return 'Not a valid index' if index > size || index.negative?\n return append(value) if index == size\n return prepend(value) if index.zero?\n\n if current_index + 1 == index\n new_node = Node.new(value)\n new_node.next_node = node.next_node\n node.next_node = new_node\n return\n end\n insert_at(value, index, current_index + 1, node.next_node)\n end",
"def insert(value, index)\n end",
"def push(value)\r\n @top_node = LinkedListNode.new(value, @top_node)\r\n end",
"def insert_head(value)\n if @head.nil?\n @head = Nodo.new(value, nil, nil)\n @tail = @head\n else\n @head[:prev] = Nodo.new(value, @head, nil)\n @head = @head[:prev]\n end\n end",
"def insert key, value\n begin\n db.putnr(key, value)\n rescue StandardError => e ; handle_error(\"Insert #{[key, value].inspect}\", e); end\n end",
"def insert(data)\n if data <= @data\n if @left.nil?\n @left = Bst.new(data)\n else\n @left.insert(data)\n end\n else\n if @right.nil?\n @right = Bst.new(data)\n else\n @right.insert(data)\n end\n end\n end",
"def push(value)\n\t\tlast_node = find_last\n\t\tlast_node.next_node = Node.new(value)\n\tend",
"def insert_after(value)\n node = DoublyLinkedListNode(value)\n\n # Need to implement this\n\n node\n end",
"def insertar_por_cabeza(value)\n\t\tnodo=Node.new(value,nil,nil)\n\t\tif(@head==nil)\n\t\t\t@tail=nodo\n\t\t\t@head=nodo\n\t\telse\n\t\t\tnodo.nest=@head\n\t\t\[email protected]=nodo\n\t\t\t@head=nodo\n\t\t\tnodo.prev=nil\n\t\tend\n\n\tend",
"def insert_at(value, index)\n node = Node.new\n node.value = value\n curr = head\n return (@head = node) if index.zero?\n\n index.downto(2) do |_|\n break if curr.next.nil?\n\n curr = curr.next\n end\n node.next = curr.next\n curr.next = node\n head\n end",
"def insert(node)\n case @value <=> node.value\n when 1\n # alphabetically greater than, insert to left\n insert_into(:left, node)\n when 0\n # same value, so increase count of `self` node\n @count += 1\n when -1\n # alphabetically less than, insert to right\n insert_into(:right, node)\n end\n end",
"def insert(value)\n if @tail\n @tail.next = Node.new(value, @tail)\n @tail = @tail.next\n else\n @head = Node.new(value)\n @tail = @head\n end\n @length += 1\n return @tail\n end",
"def insert_at_index(index, value)\n new_node = Node.new(value)\n if index.zero?\n new_node.next_node = first_node\n self.first_node = new_node\n else\n current_node = first_node\n current_index = 0\n while current_index < (index - 1)\n current_node = current_node.next_node\n current_index += 1\n end\n new_node.next_node = current_node.next_node\n current_node.next_node = new_node\n end\n end",
"def insert_right(value)\n right.insert(value) or self.right = Node.new(value, self)\n end",
"def insert(value)\n if @Max <= 15\n if @actual.nil?\n @actual = value\n @fin = value\n else\n value.next = @actual\n @actual.prev = value\n value.prev = nil\n @actual = value\n end\n @Max+= 1\n end\n end",
"def insert(key, value = key)\n raise ArgumentError, 'Heap keys must not be nil' unless key\n n = Hash[key: key, value: value]\n # 1. Append to end\n @nodes << n\n # We need to keep track of inserted node's index\n # so that when we bubble up we adjust it and not keep\n # looking for it\n ins_i = size - 1\n \n # 2. Satisfy the heap property (bubble-up):\n # Move the newly inserted node up the tree as long as\n # it is smaller than its parent\n unless size == 1\n while @compare_fn[@nodes[ins_i][:value], @nodes[parent(ins_i)][:value]]\n swap(parent(ins_i), ins_i)\n ins_i = parent(ins_i)\n break if ins_i == 0\n end\n end\n # Return the final index of the inserted element after re-ordering\n ins_i\n end",
"def insert(value)\n #YOUR WORK HERE\n end",
"def push(value)\n last.next_node = Node.new(value, nil)\n end",
"def insert_head(value)\n\n\t\tif empty()\n\t\t\t@head = Node.new(value,nil,nil)\n\t\t\t@tail = @head\n\t\telse\n\t\t\[email protected] = Node.new(value,@head,nil)\n\t\t\t@head = @head.prev;\n\t\tend\n\n\t\t@size = @size + 1\n\t\t\t\n\tend",
"def push(value)\n # IMPLEMENT ME!\n @top = LinkedListNode.new(value, @top)\n end",
"def push(value)\n @parent, @top = @top, value\n end"
] | [
"0.7541748",
"0.7393517",
"0.734367",
"0.73159623",
"0.72740924",
"0.726315",
"0.72594833",
"0.7250223",
"0.72144294",
"0.7192768",
"0.7141769",
"0.71271324",
"0.7125075",
"0.7121618",
"0.7113678",
"0.7075371",
"0.70482314",
"0.7030223",
"0.70174193",
"0.69876283",
"0.69875574",
"0.69805914",
"0.6979438",
"0.6977963",
"0.6968396",
"0.6963052",
"0.6950892",
"0.693335",
"0.69320023",
"0.69274443",
"0.69263923",
"0.69106656",
"0.6896718",
"0.6870356",
"0.6865578",
"0.68650025",
"0.6859559",
"0.6846207",
"0.6831334",
"0.6829916",
"0.6829546",
"0.68267614",
"0.67704976",
"0.6770362",
"0.67692477",
"0.6768401",
"0.6716568",
"0.6705333",
"0.669638",
"0.66931885",
"0.66807514",
"0.6680555",
"0.6666968",
"0.66572267",
"0.6635244",
"0.66322297",
"0.66309214",
"0.6611017",
"0.66101354",
"0.6588304",
"0.65876526",
"0.65873325",
"0.65869755",
"0.6581273",
"0.6576433",
"0.6574506",
"0.6567954",
"0.6564665",
"0.6564533",
"0.65567696",
"0.6547175",
"0.6545186",
"0.6536459",
"0.65361506",
"0.65295625",
"0.65289986",
"0.6522091",
"0.65191925",
"0.65165234",
"0.65154374",
"0.6512242",
"0.65095055",
"0.6509135",
"0.65042657",
"0.64982224",
"0.6497251",
"0.64941955",
"0.648598",
"0.64709306",
"0.6470435",
"0.6461728",
"0.6459614",
"0.64588374",
"0.6456088",
"0.6450952",
"0.64482045",
"0.6438677",
"0.64372665",
"0.6432015",
"0.642933"
] | 0.7042976 | 17 |
Delete a value from the BBT, careful, this may unbalance the tree | def delete(value)
current_node = @root
until current_node.nil?
if current_node.data < value
next_node = current_node.right_child
if next_node.data == value
current_node.right_child = delete_aux(next_node, value)
break
end
current_node = current_node.right_child
elsif current_node.data > value
next_node = current_node.left_child
if next_node.data == value
current_node.left_child = delete_aux(next_node, value)
break
end
current_node = current_node.left_child
elsif current_node.data == value
@root = build_tree(in_order_traversal(current_node) - [value])
break
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(value)\n find_node(value)&.delete\n end",
"def delete_value value\r\n #find the pointer to the wanted node using LIST-SEARCH(value)\r\n #then delete that node with LIST-DELETE-BY-NODE(node)\r\n delete_node(self.search(value))\r\n end",
"def delete_from(value)\n L.log '', \"Attempting to delete #{value} from BST\"\n outcome, new_root = @root_tree.delete_element(@root_tree, Node.new(value))\n @root_tree = new_root\n display_tree\n return outcome\n end",
"def delete(value)\n delete_node(find(value))\n end",
"def delete(value)\n return \"BST is empty\" if is_empty\n\n parent = nil\n current = @root\n\n while current && current.value != value\n parent = current\n current = current.value > value ? current.left : current.right\n end\n\n return \"Value to delete not found\" if current == nil\n\n if !current.left && !current.right\n parent.left = nil\n parent.right = nil\n end\n\n puts \"NOT COMPLETE\"\n end",
"def delete(value)\n @data.delete value\n value\n end",
"def delete(value)\n # Find the element to delete\n index = index(value)\n not_final = index < @heap.length - 1\n # Unless it's the final leaf, replace the value to be deleted with the final leaf\n @heap[index] = @heap[-1] if not_final\n # Delete the final leaf (either what we want to delete, or a duplicate now)\n @heap.pop\n # If necessary, bubble down\n bubble_down(index) if not_final\n end",
"def remove_value(value)\n @children['value'][:value].delete(value)\n end",
"def remove(value)\n connection.zrem(key_label, value)\n end",
"def delete(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value == value \n\t\t\t@head = current_node.next_node\n\t\tend \n\t\tuntil current_node.next_node.value == value \n\t\t\treturn false if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = current_node.next_node.next_node\n\tend",
"def delete(value, node = root)\n return node if node.nil?\n \n if value < node.data\n node.left = delete(value, node.left)\n elsif value > node.data\n node.right = delete(value, node.right)\n else\n # si el nodo tiene un o ningún hijo\n return node.right if node.left.nil?\n return node.left if node.right.nil?\n \n # si el nodo tiene 2 hijos\n leftmost_node = leftmost_leaf(node.right)\n node.data = leftmost_node.data\n node.right = delete(leftmost_node.data, node.right)\n end\n node\n end",
"def delete(value)\n end",
"def delete(value)\n end",
"def remove_thing(value)\n @children['thing'][:value].delete(value)\n end",
"def remove_thing(value)\n @children['thing'][:value].delete(value)\n end",
"def delete(value)\n current_node = @head\n\n if current_node.value == value\n @head = current_node.next\n else\n\n previous_node = current_node\n current_node = current_node.next\n\n loop do \n break if current_node.value == value\n previous_node = current_node\n current_node = current_node.next\n end\n\n previous_node.next = current_node.next\n end\n end",
"def delete_value(value, root = self)\n if root.nil?\n return\n elsif value > root.value\n root.right = delete_value(value, root.right)\n elsif value < root.value\n root.left = delete_value(value, root.left)\n else # i.e. value == root.value\n if root.left.nil? # also catches cases when both child nodes are empty\n root = root.right\n elsif root.right.nil?\n root = root.left\n else\n root = shift_values(root)\n end\n end\n root\n end",
"def delete(key)\n dummy = Pair.new(key,nil)\n pair = @tree.remove(dummy)\n return nil unless pair\n return pair.value\n end",
"def delete_node(node_value)\n current_node = @root_node\n if current_node.get_node_data() == node_value\n @root_node = @root_node.get_next()\n @root_node.set_prev(nil)\n current_node = nil\n else\n while current_node.has_next?()\n current_node = current_node.get_next()\n if current_node.get_node_data() == node_value\n current_node.get_prev().set_next(current_node.get_next())\n current_node.get_next().set_prev(current_node.get_prev())\n return\n end\n end\n end\n end",
"def remove_record(value)\n @children['record'][:value].delete(value)\n end",
"def remove_record(value)\n @children['record'][:value].delete(value)\n end",
"def remove(value)\n @client.execute_udf(@key, @PACKAGE_NAME, 'remove', [@bin_name, value], @policy)\n end",
"def delete_bin id\n @tree.delete_if {|k,v| v == id}\n end",
"def delete(value, node = @root)\n if node.nil?\n return node \n end\n\n if value < node.value\n node.left_node = delete(value, node.left_node)\n elsif value > node.value\n node.right_node = delete(value, node.right_node)\n else\n if node.left_node.nil? && node.right_node.nil?\n return nil\n elsif node.left_node.nil?\n return node.right_node\n elsif node.right_node.nil?\n return node.left_node\n end\n\n # Switches the current node's value with the child with the lowest value greater than\n # the current node, then delete the child.\n temp = min_node(node.right_node)\n node.value = temp.value\n node.right_node = delete(temp.value, node.right_node)\n end\n\n return node\n end",
"def delete(value)\n if @head == nil\n return\n end\n\n # account for case: node to delete is current head\n if @head.data == value\n @head = @head.next\n return\n end\n\n current = @head\n while current.next != nil\n if current.next.data == value\n current.next = current.next.next\n return\n end\n current = current.next\n end\n # value to be deleted was not found if the control flow reaches here\n end",
"def delete(value)\n if search(value)\n if value == @root.getData()#Descartamos la eliminacion de la raiz\n if @root.getLeft() == nil and @root.getRight() == nil#verificamos el caso\n @root = nil\n else\n temp_root = Node.new(-100000) #Asignamos nodo temporal\n @removeMethods.promote(@root,temp_root) #encontramos el mejor elemento\n @root = temp_root.getRight() #Asignamos nuevo nodo con remplazo ideal\n end\n startMethods() ##enviamos actualizacion de nodo\n return true\n else\n return @removeMethods.delete(value)\n end\n else\n return false\n end\n end",
"def delete(value)\n index = find(value)\n return false if index == -1\n @inner[index] = @inner[@inner.length - 1]\n @inner.delete_at(@inner.length - 1)\n return true\n end",
"def delete(value)\n\t \n if @root == nil \n return false\n end\n \n #Obtenemos el nodo a remover\n\t toRemove = selectElement(value,@root)\n \n ## Mandamos a buscar al padre del nodo\n father = getFather(value,@root,toRemove)\n \n if !isLeaft(toRemove,father) ## remueve elemento al encontrarlo y sea hoja\n promote(toRemove,father) ##Verificamos si es hijo unico\n end\n \n return true\n end",
"def delete(val)\n count = self.lrem(0, val)\n if count > 0\n val\n else\n nil\n end\n end",
"def delete(value)\n index = binary_search(value)\n return false if index == -1\n index.upto(@inner.length - 2) { |i| @inner[i] = @inner[i + 1] }\n @inner.delete_at(@inner.length - 1)\n return true\n end",
"def deleteNode node\n node.val = node.next.val\n node.next = node.next.next\nend",
"def delete(value)\r\n return nil if !@head\r\n if @head.data == value\r\n @head = @head.next \r\n return nil\r\n end \r\n cursor = @head\r\n while cursor.next && cursor.next.data != value\r\n cursor = cursor.next\r\n end\r\n cursor.next = cursor.next.next if cursor.next\r\n end",
"def delete(value)\n puts \"I want to delete #{value}\"\n\n bucket = compute_adjusted_bucket(value)\n puts \"It's in #{bucket} bucket if it's anywhere.\"\n\n contains_value = @table[bucket] == value\n puts \"It #{contains_value ? 'is' : 'isn\\'t'} there\"\n @table[bucket] = TOMBSTONE_MARKER if contains_value\n puts \"Put #{TOMBSTONE_MARKER}\"\n\n contains_value\n end",
"def delete(value)\n return nil if root.nil?\n\n parent = nil\n curr = root\n until value == curr.data\n parent = curr\n curr = (value < curr.data ? curr.left : curr.right)\n return nil if curr.nil? # value not present in BST\n end\n\n if curr == root\n if curr.left.nil? && curr.right.nil?\n @root = nil\n elsif curr.left.nil?\n @root = curr.right\n elsif curr.right.nil?\n @root = curr.left\n else\n # find the minimum node in right subtree\n node = copy_and_delete_min_in_right_subtree_of(curr)\n @root = node # replace deleted node with minimum node\n end\n return root\n end\n\n if parent.left == curr\n if curr.left.nil? && curr.right.nil?\n parent.left = nil\n elsif curr.left.nil?\n parent.left = curr.right\n elsif curr.right.nil?\n parent.left = curr.left\n else\n # find the minimum node in right subtree\n node = copy_and_delete_min_in_right_subtree_of(curr)\n parent.left = node # replace deleted node with minimum node\n end\n else\n if curr.left.nil? && curr.right.nil?\n parent.right = nil\n elsif curr.left.nil?\n parent.right = curr.right\n elsif curr.right.nil?\n parent.right = curr.left\n else\n # find the minimum node in right subtree\n node = copy_and_delete_min_in_right_subtree_of(curr)\n parent.right = node # replace deleted node with minimum node\n end\n end\n root\n end",
"def remove(value)\n\t\t\n\t\tnode = @head\n\t\twhile node.value.sal != value do\n\t\t\tnode = node.next\n\t\tend\n\t\t\n\t\tif node != nil\n\t\t\n\t\t\tif node != @head\n\t\t\t\tnode.prev.next = node.next\n\t\t\telse\n\t\t\t\t@head = node.next\n\t\t\tend\n\n\t\t\tif node != @tail\n\t\t\t\tnode.next.prev = node.prev\n\t\t\telse\n\t\t\t\t@tail = node.prev\n\t\t\tend\n\n\t\t\t@size-=1\n\t\tend\t\t\t\n\t\t\t\t\n\tend",
"def delete\n @prev_node.next_node = @next_node\n @next_node.prev_node = @prev_node\n @prev_node = @next_node = nil\n @value\n end",
"def delete(value)\n return nil if @head.nil?\n\n current = @head\n\n if current.data == value\n @head = current.next\n @head.previous = nil\n return\n end\n\n until current.next.nil?\n if current.next.data == value\n temp = current.next.next\n current.next = temp\n if temp\n temp.previous = current\n end\n return\n end\n current = current.next\n end\n end",
"def delete(value)\n @driver_instance.delete_list_value(@key, value)\n end",
"def delete(value)\n return nil if !@head\n if @head.data == value\n @head = @head.next\n @head.prev = nil\n return\n end \n cursor = @head\n while cursor && cursor.data != value\n cursor = cursor.next\n end\n\n if cursor\n cursor.prev.next = cursor.next\n cursor.next.prev = cursor.prev if cursor.next\n @tail = cursor.prev if cursor == @tail\n \n end\n end",
"def delete(value)\n node = find(value, @root)\n if node.left || node.right \n if node.left && node.right \n max = maximum(node.left)\n if max.left \n max.parent.right = max.left \n max.left = nil\n end\n node.left.parent = max \n node.right.parent = max\n if (node.value <= node.parent.value)\n node.parent.left = max\n else \n node.parent.right = max\n end \n else \n replacement_node = node.left ? node.left : node.right \n parent = node.parent\n if replacement_node.value <= parent.value \n parent.left = replacement_node\n else \n parent.right = replacement_node\n end \n end \n else \n if node.parent \n parent = node.parent \n if (node.value <= parent.value)\n parent.left = nil\n else \n parent.right = nil\n end\n else \n @root = nil \n nil\n end \n end \n end",
"def delete_aux(next_node, value)\n return nil if next_node.right_child.nil? && next_node.left_child.nil?\n\n return next_node.left_child if next_node.right_child.nil?\n\n return next_node.right_child if next_node.left_child.nil?\n\n build_tree(in_order_traversal(next_node) - [value])\n end",
"def test_delete_node_tree_r_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [8, 10]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def delete(value)\r\n \r\n current = @head\r\n \r\n # if list is empty\r\n if current.nil?\r\n return\r\n end\r\n \r\n # if value is at head\r\n if current.data == value\r\n @head = current.next\r\n end\r\n \r\n # traverse list for matching value. stop when we find a match or get past the final node\r\n until current.nil? || current.data == value\r\n # if value isn't in the list, stop\r\n if current.next.nil?\r\n return\r\n # if the value matches our target value, make previous node point to node after current node\r\n elsif current.next.data == value\r\n current.next = current.next.next\r\n end\r\n current = current.next\r\n end\r\n \r\n end",
"def delete(value, current_node = @root)\n # Base case: We did not find the node\n return current_node if current_node.nil?\n\n if value < current_node.value\n current_node.left = delete(value, current_node.left)\n elsif value > current_node.value\n current_node.right = delete(value, current_node.right)\n elsif current_node.left.nil? # equality\n temp = current_node.right\n current_node = nil\n return temp\n\n elsif current_node.right.nil?\n temp = current_node.left\n current_node = nil\n return temp\n\n else # Node has 2 children.\n successor = find_inorder_successor(current_node.right)\n current_node.value = successor.value\n\n current_node.right = delete(successor.value, current_node.right)\n end\n current_node\n end",
"def delete(root, data)\n\t\ttarget = find(root, data) unless data.nil?\n\n\t\tunless target.nil?\n\t\t\tbrmn = find_bottom_right_most_node(root)\n\n\t\t\tif brmn != target\n\t\t\t\ttarget.value = brmn.value\n\t\t\t\t\n\t\t\t\t# remove link to brmn from former parent\n\t\t\t\tunless brmn.parent.nil?\n\t\t\t\t\tif brmn.parent.right.value == brmn.value\n\t\t\t\t\t\tbrmn.parent.right = nil\n\t\t\t\t\telse\n\t\t\t\t\t\tbrmn.parent.left = nil\n\t\t\t\t\tend\n\n\t\t\t\t\tbrmn.parent = nil\n\t\t\t\tend\n\n\t\t\t\tunless target.parent.nil?\n\t\t\t\t\tparent_compare(target, target.parent)\n\t\t\t\tend\n\n\t\t\t\tchild_compare(target)\n\t\t\telse\n\t\t\t\tself.root = nil\n\t\t\tend\n\t\tend\n\tend",
"def delete_value(value)\n keys = @reverse[value]\n @reverse.delete value\n keys.each {|key| @hash.delete(key) }\n end",
"def delete(key)\n key = find(key) unless key.is_a? Node\n case child_count(key)\n when 2\n sub = key.right.data == nil ? max(key.left) : min(key.right)\n when 1\n sub = key.right.nil? ? key.left : key.right\n when 0\n sub = nil\n end\n modify(key, sub)\n end",
"def remove(value)\n if self.include?(value)\n if head.data == value\n remove_head(value, head)\n else\n remove_value(value, head)\n end\n else\n return nil\n end\n end",
"def remove_value(value, node)\n if node.left && value < node.data\n if node.left.data == value\n if node.left.left\n link = max_search(node.left.left)\n link.right = node.left.right\n node.left = node.left.left\n elsif node.left.right\n node.left = node.left.right\n else\n node.left = nil\n end\n else\n remove_value(value, node.left)\n end\n\n elsif node.right && value > node.data\n if node.right.data == value\n if node.right.left\n link = max_search(node.right.left)\n link.right = node.right.right\n node.right = node.right.left\n elsif node.right.right\n node.right = node.right.right\n else\n node.right = nil\n end\n else\n remove_value(value, node.right)\n end\n end\n end",
"def delete(value)\n raise NotImplementedError, \"Please implement delete\"\n end",
"def delete(key)\n @mutex.synchronize do\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # remove existing key\n \t if node_compare(x, key) == 0\n \t level = node_level(x)\n \t while level > 0\n \t level -= 1\n \t node_delete_after!(x, update[level], level)\n end\n \t end\n end\n \tself\n \tend",
"def delete(value)\n found_node = self.find(value)\n return nil if found_node.nil?\n\n if found_node == root\n self.root = nil\n return found_node\n end\n\n #first case, deleted node has no children\n right_empty = found_node.right.nil?\n left_empty = found_node.left.nil?\n\n if right_empty && left_empty #must take parent and delete its pointer to deleted node\n direct_parent = parent(found_node)\n if direct_parent.value < found_node.value\n direct_parent.right = nil\n else\n direct_parent.left = nil\n end\n elsif right_empty #deleted node has one child\n child = found_node.left\n direct_parent = parent(found_node)\n if direct_parent.value < found_node.value\n direct_parent.right = child\n else\n direct_parent.left = child\n end\n elsif left_empty #deleted node has one child\n child = found_node.right\n direct_parent = parent(found_node)\n if direct_parent.value < found_node.value\n direct_parent.right = child\n else\n direct_parent.left = child\n end\n else #deleted node has two children. I'm choosing the left side maximum\n #of the deleted node for a replacement.\n\n left_child = found_node.left\n right_child = found_node.right\n max = maximum(left_child)\n child_of_max = max.left #max's child will always be on the left!!!\n parent_of_max = parent(max)\n parent_of_deleted = parent(found_node)\n\n if parent_of_deleted.value < found_node.value\n parent_of_deleted.right = max\n else\n parent_of_deleted.left = max\n end\n\n parent_of_max.right = child_of_max #reconnecting the holes caused by extracting max\n max.left = left_child #replacing the deleted node with the max\n max.right = right_child #replacing the deleted node with the max\n end\n\n found_node\n end",
"def remove_token(value)\n @children['token'][:value].delete(value)\n end",
"def delete_ltree_column_value\n update!(ltree_path_column => nil)\n end",
"def remove\n # Can you delete any other node besides the root?\n return nil if @store.empty?\n\n swap(0, @store.length - 1)\n target = @store.pop\n\n heap_down(0)\n return target.value\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def delete_element(tree, item)\n verbose_delete = false\n x = nil # sub-tree object containing node to be deleted\n x_successor = nil # sub-tree object - in-order successor to x (or predecessor)\n parent = nil # sub-tree object - parent of x, or soon its successor\n subtree = nil # sub-tree object - subtree of x before deletion\n found = false\n\n found, x, parent = bst_search(tree, item)\n\n if L.debugging && verbose_delete\n puts \"Element to be deleted was found: #{found}\"\n puts \"Sub-tree whose node has to be deleted: #{x}\"\n puts \"\"\n puts \"Parent of sub-tree whose node has to be deleted: #{parent}\"\n puts \"\"\n end\n\n return [false, tree] if ! found # no point in going further\n\n if x.left_child && x.right_child\n if L.debugging && verbose_delete\n puts \"item to be deleted #{item.data} has 2 children\"\n puts \"left_child: #{x.left_child.node.data}\"\n puts \"right_child: #{x.right_child.node.data}\"\n puts \"\"\n end\n # item to be deleted has 2 children\n # find in-order successor (predecessor) and its parent\n # to do so as per book page 469 - start with right child of x\n # then descend left as far as possible\n x_successor = x.right_child\n parent = x\n if L.debugging && verbose_delete\n puts \"x_successor: #{x_successor.node.data}\"\n puts \"parent: #{parent.node.data}\"\n puts \"---- descending left ---\"\n end\n while x_successor.left_child # descending left until last left child\n parent = x_successor\n x_successor = x_successor.left_child\n if L.debugging && verbose_delete\n puts \"x_successor: #{x_successor.node.data}\"\n puts \"parent: #{parent.node.data}\"\n end\n end\n\n # move content of x_successor to x, and change x to point\n # to x_successor - which will be deleted after swap\n x.node.data = x_successor.node.data\n x = x_successor\n\n if L.debugging && verbose_delete\n puts \"x data updated: #{x.node.data}\"\n end\n end\n\n # now proceed with case as if we had 0 or 1 child - book p. 466\n subtree = x.left_child\n subtree ||= x.right_child # if left child is nil, use right child\n if L.debugging && verbose_delete\n puts \"subtree: #{subtree}\"\n puts \"\"\n end\n\n if parent == nil\n # root is being deleted, the subtree becomes root\n tree = subtree # changing root tree to be the subtree when returned\n tree.height = 1\n tree.parent = nil\n if L.debugging && verbose_delete\n puts \"root is being deleted subtree is new root(updated values): #{subtree}\"\n tree.show_me_descendants_traverse(tree, tree.node)\n end\n tree.descendants_traverse(tree, tree.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1 if t.parent\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n elsif parent.left_child == x\n parent.left_child = subtree\n if parent.left_child # the subtree could be nil\n parent.left_child.parent = parent\n parent.left_child.height = parent.height+1\n if L.debugging && verbose_delete\n puts \"parent left child gets the subtree(updated values): #{parent.left_child}\"\n parent.show_me_descendants_traverse(parent, parent.node)\n end\n parent.descendants_traverse(parent, parent.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n end\n else\n parent.right_child = subtree\n if parent.right_child # the subtree could be nil\n parent.right_child.parent = parent\n parent.right_child.height = parent.height+1\n if L.debugging && verbose_delete\n puts \"parent right child gets the subtree(updated values): #{parent.right_child}\"\n parent.show_me_descendants_traverse(parent, parent.node)\n end\n parent.descendants_traverse(parent, parent.node) do |t|\n if L.debugging && verbose_delete\n puts \"////\"\n puts \"inside tree: #{t.node.data}\"\n puts \"inside tree old height: #{t.height}\"\n end\n t.height = t.parent.height+1\n if L.debugging && verbose_delete\n puts \"inside tree new height: #{t.height}\"\n puts \"////\"\n end\n end\n end\n end\n\n x.right_child = nil\n x.left_child = nil\n x.parent = nil\n x.node = nil\n\n return [true, tree] # tree is always the Root tree, even after old root gets deleted\n end",
"def delete(value)\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.data == value \r\n if prev == nil\r\n @head = curr.next \r\n else \r\n prev.next = curr.next \r\n end\r\n return\r\n\r\n else\r\n prev = curr\r\n curr = curr.next\r\n end\r\n end\r\n\r\n # if u reached this point, then nothing matches, and no changes made to list\r\n end",
"def test_delete_node_tree_l_2_nodes\n # Prep\n tree = BST::Tree.new\n val = [10, 8]\n val.each {|v| tree.insert(v)}\n tree.delete(val.last)\n # Test\n _delete_node_tree_hlpr(val, tree)\n end",
"def del_access_node(node)\n puts \"Deleting Node with value: #{node.value} from the list\"\n if node.next != nil\n node.value = node.next.value\n node.next = node.next.next\n else\n node.value = nil\n end\n print\n end",
"def delete(key)\n return nil if @root.nil?\n deleted = nil\n splay(key)\n if (key <=> @root.key) == 0 # The key exists\n deleted = @root.value\n if @root.left.nil?\n @root = @root.right\n else\n x = @root.right\n @root = @root.left\n splay(key)\n @root.right = x\n end\n end\n deleted\n end",
"def remove_from_tree(item, node) \n return rebalance(super(item, node))\n end",
"def delete(val)\n node = find(val)\n\n if node == @root\n @root = nil\n return\n end\n\n parent = find_parent(@root, node)\n left = node.left\n right = node.right\n\n if left.nil? && right.nil?\n parent.right = nil if parent.value < val\n parent.left = nil if parent.value >= val\n elsif left.nil? ^ right.nil?\n if parent.left == node\n if left\n parent.left = left\n left.parent = parent\n else\n parent.left = right\n right.parent = parent\n end\n else\n if left\n parent.right = left\n left.parent = parent\n else\n parent.right = right\n right.parent = parent\n end\n end\n else\n max_node = maximum(left)\n max_node_parent = find_parent(@root, max_node)\n max_node_left_parent = find_parent(@root, max_node.left)\n\n if max_node.left\n max_node_parent.right = max_node.left\n max_node_left_parent = max_node_parent\n end\n\n if parent.left = node\n parent.left = max_node\n max_node_parent = parent\n max_node.left = left\n max_node.right = right\n else\n parent.right = max_node\n max_node_parent = parent\n max_node.left = left\n max_node.right = right\n end\n end\n end",
"def delete(node)\n remove_node(node)\n end",
"def delete(value)\n #get hashed value\n hash_value = hash_function(value)\n\n # check if value exists\n result = search(value)\n\n # if value exists\n if result\n # set value to nil\n @@collection[hash_value] = nil\n # return confirmation\n \"value deleted\"\n else\n # return error message\n \"value not found\"\n end\n\n\n end",
"def remove()\n return if @store.empty?\n \n # swap last item in heap with smallest value\n swap(0, -1)\n\n # remove smallest value\n removedNode = @store.pop\n\n # maintain heap structure\n heap_down() if @store.length > 1\n \n return removedNode.value\n end",
"def remove(k)\n #First we must find the node, after this we can delete it.\n remove_avl(@root, k);\n end",
"def remove()\n root = @store[0]\n new_root = @store[@store.length - 1]\n\n @store[@store.length - 1] = root\n @store[0] = new_root\n\n removed = @store.pop\n\n heap_down(0)\n return removed.value\n end",
"def delete_node(current_node)\n\nend",
"def delete(index_value)\n index.delete(index_value)\n end",
"def remove(value)\n if empty?\n puts EMPTY_TREE\n return\n end\n\n temp = @root\n parent = nil # track parent of current node visited for node reassignment\n\n while !temp.nil? do\n if temp.val > value\n if temp.left.nil?\n puts EMPTY_TREE\n break\n end\n\n parent = temp\n temp = temp.left\n elsif temp.val < value\n if temp.right.nil?\n puts EMPTY_TREE\n break\n end\n\n parent = temp\n temp = temp.right\n else\n # parent 50, temp 80\n # node found\n # 1: if x == leaf node, remove\n if !temp.left && !temp.right\n if !parent # deleting root node\n @root = nil\n elsif parent.left&.val == temp.val # temp is left child of parent\n parent.left = nil\n else # temp is right child of parent\n parent.right = nil\n end\n # 2: if x has one RIGHT child, child is now where x is, remove x\n elsif !temp.left\n if !parent # deleting root node\n @root = temp.right\n elsif parent.left&.val == temp.val # temp is left child of parent\n parent.left = temp.right # parent's new left node is the right child of temp\n else\n parent.right = temp.right\n end\n # 2: if x has one LEFT child, child is now where x is, remove x\n elsif !temp.right\n if !parent\n @root = temp.left\n elsif parent.left&.val == temp.val\n parent.left = temp.left\n else\n parent.right = temp.left\n end\n # 3: if x has two children, get min inorder value in the right subtree\n else\n successor_value = minInorderNode(temp.right)\n remove(successor_value)\n temp.val = successor_value\n end\n break\n end \n end\n end",
"def delete!\n values.delete!\n end",
"def del(path, value)\n\n # Figure out what to delete FROM. Only directories and arrays supported.\n path = Path.new(path) unless path.kind_of?(Path)\n mmap, cmap = dir_walk(path, DW_Fail)\n unless mmap.kind_of?(Hash) and (mmap[:dir] or mmap[:type] == Array)\n raise Error.new(Error::NoDelete, path)\n end\n hook = mmap[:on_change]\n\n # Item delete.\n if mmap[:dir]\n value = value.to_s\n raise Error.new(Error::IllegalName, value) if value.include?(?/)\n raise Error.new(Error::NoPath, path + value) unless mmap[value] and (ce = cmap[value])\n hook.call(HookDelete, cmap, value, ce) if hook\n [TypeItem, path, value, cmap.delete(value)]\n\n # Array delete.\n else\n hook.call(HookArrayDelete, cmap, value) if hook\n raise Error.new(Error::NoArrItem, path, value) unless (v = cmap.delete(value))\n [TypeArray, path, v, cmap]\n\n end\n end",
"def delete(key, child)\n\t\t\t\tif key\n\t\t\t\t\[email protected](key)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\[email protected](child)\n\t\t\tend",
"def remove(value)\n if head.value == value\n @head = head.next\n else\n current_node = head.next\n prev_node = head\n while current_node\n if current_node.value == value\n prev_node.next = current_node.next\n return\n else\n prev_node = current_node\n current_node = current_node.next\n end\n end\n nil\n end\n end",
"def remove(value)\n #YOUR WORK HERE\n end",
"def delete(value)\n @hash.delete(value) && @hash.send(:convert_key, value)\n end",
"def delete_node_improved(node)\n node.val = node.next.val\n node.next = node.next.next\nend",
"def test_delete_node_tree_mono_node\n # Prep\n tree = BST::Tree.new\n val = 10\n tree.insert(val)\n tree.delete(val)\n # Test\n exp_root, exp_count = nil, 0\n act_root, act_count = tree.root.val, tree.node_count\n #\n assert_equal exp_root, act_root\n assert_equal exp_count, act_count,\n \"deleting a node from a mono-node tree results in an empty tree, but got: #{act_count} node(s)\"\n end",
"def del(key)\n position = find(key)\n if position != nil\n # delete\n value = @values[position]\n @slots[position] = nil\n @values[position] = nil\n value\n else\n nil\n end\n end",
"def remove(v)\n return unless @root\n @count -= 1 if @root.remove(v)\n @root = @root.left if @root.type == 1\n end",
"def delete_node(node_to_delete)\n next_node = node_to_delete.next\n\n if next_node\n raise \"Can't delete the last node with this method!\"\n else\n node_to_delete.value = next_node.value\n node_to_delete.next = next_node.next\n end\nend",
"def remove(value)\n current = @head\n current = current.next while current && current.value != value\n return raise \"Value not found: #{value}\" if current.nil?\n\n if current == @head\n @head = @head.next\n @head.prev = nil unless @head.nil?\n @size -= 1\n return\n end\n if current == @tail\n @tail = @tail.prev\n @tail.next = nil unless @tail.nil?\n @size -= 1\n return\n end\n current.prev.next = current.next\n current.next.prev = current.prev\n @size -= 1\n end",
"def remove_child node, idx, opts={}\n no('no') unless node.children[idx]\n removed = node.children[idx]\n removed.parent_clear!\n tomb = Tombstone.build removed, opts\n node.children[idx] = tomb\n removed\n end",
"def delete_node(value)\n return false unless @head\n curr_node = @head\n\n if @head.value == value\n @head = @head.next\n return true\n end\n\n while curr_node.next\n if value == curr_node.next.value\n curr_node.next = curr_node.next.next\n return true\n else\n curr_node = curr_node.next\n end\n end\n end",
"def remove_node\n cspsearchpath.delete(@label)\n end",
"def remove() # removes the element at the first position (root) of the array\n return nil if @store.empty?\n last_index = @store.length - 1\n # First, swap the last leaf & the root node\n swap(0, last_index)\n\n # Delete the last leaf (last item in the array)\n result = @store.pop\n\n # Then heap-down the new root, to reestablish the heap property\n # start heap_down with the root (index 0)\n heap_down(0) \n return result.value\n end",
"def remove\n unless self.empty?\n swap(0, @store.length - 1)\n removed_node = @store.pop\n\n heap_down(0)\n\n return removed_node.value\n end\n end",
"def delete(root, data)\n\t\ttarget = find(root, data) unless data.nil?\n\t\tunless target.nil?\n\t\t\tbrmn = find_bottom_right_most_node(root)\n\n\t\t\tif brmn != target\n\t\t\t\ttarget.title = brmn.title\n\t\t\t\ttarget.rating = brmn.rating\n\t\t\t\t\n\t\t\t\t# remove link to brmn from former parent\n\t\t\t\tunless brmn.parent.nil?\n\t\t\t\t\tif brmn.parent.right.title == brmn.title\n\t\t\t\t\t\tbrmn.parent.right = nil\n\t\t\t\t\telse\n\t\t\t\t\t\tbrmn.parent.left = nil\n\t\t\t\t\tend\n\n\t\t\t\t\tbrmn.parent = nil\n\t\t\t\tend\n\n\t\t\t\tunless target.parent.nil?\n\t\t\t\t\tparent_compare(target, target.parent)\n\t\t\t\tend\n\n\t\t\t\tchild_compare(target)\n\t\t\telse\n\t\t\t\tself.root = nil\n\t\t\tend\n\t\tend\n\tend",
"def delete(key)\n\t\t\tret = self\n\t\t\tcase key <=> @key\n\t\t\twhen -1\n\t\t\t\tdeleted, left, rebalance = @left.delete(key)\n\t\t\t\tret = ret.with_left(left)\n\t\t\t\tif rebalance\n\t\t\t\t\tret, rebalance = ret.rebalance_for_left_delete\n\t\t\t\tend\n\t\t\twhen 0\n\t\t\t\tdeleted = self\n\t\t\t\tret, rebalance = delete_node\n\t\t\twhen 1\n\t\t\t\tdeleted, right, rebalance = @right.delete(key)\n\t\t\t\tret = ret.with_right(right)\n\t\t\t\tif rebalance\n\t\t\t\t\tret, rebalance = ret.rebalance_for_right_delete\n\t\t\t\tend\n\t\t\telse\n\t\t\t\traise TypeError, \"cannot compare #{key} and #{@key} with <=>\"\n\t\t\tend\n\t\t\t[deleted, ret, rebalance]\n\t\tend",
"def delete(value:)\n if @head.value == value\n if @head.next.nil?\n @head.value = nil\n return value\n else\n @head = @head.next\n return value\n end\n else\n prev = @head\n temp = @head.next\n\n while !temp.nil?\n if temp.value == value\n prev.next = temp.next\n return value\n end\n\n prev = temp\n temp = temp.next\n end\n end\n\n return false # Not great to return different types but this is for fun\n end",
"def delete_node(index)\n # find the index of the node and call the block in order to acess the properties\n # and parent required to keep the code DRY\n find(index) do |parent, to_be_deleted, property|\n if to_be_deleted.left_child.nil? and to_be_deleted.right_child.nil?\n # if both the nodes left and right child are nil then this means we can\n # simply remove the node without having to do any extra leg work\n set_replacement(parent, to_be_deleted, nil, property)\n elsif to_be_deleted.right_child.nil?\n # if just the right child is nil then all we have to do is move up the left_child \n replacement = to_be_deleted.left_child\n set_replacement(parent, to_be_deleted, replacement, property) \n elsif to_be_deleted.left_child.nil?\n # if jus the left child is nil then all we have to do is move up the right_child\n replacement = to_be_deleted.right_child\n set_replacement(parent, to_be_deleted, replacement, property) \n else\n # otherwise we need to locate the lowest left child of tree, we store it in a pointer \n # in memory and then delete it from the tree by calling the method again\n replacement = min_left_child(to_be_deleted.right_child)\n delete_node(replacement.key)\n\n # then we assing the node to be deleted left and right child values\n replacement.left_child = to_be_deleted.left_child \n replacement.right_child = to_be_deleted.right_child\n\n # once the replacement node has the correct values and has been removed from its previous\n # position we call the set replacement method on the node to be deleted parent in order\n # to remove it from refrence in the tree\n set_replacement(parent, to_be_deleted, replacement, property)\n end\n end\n end",
"def delete(key)\r\n if record = touch(key)\r\n @store.delete(key)\r\n @head = @tail = nil if @store.length.zero?\r\n record[:value]\r\n end\r\n end",
"def remove_group(value)\n @children['group'][:value].delete(value)\n end",
"def delete(root, data)\n # finds the data to be deleted and stores as element\n element = find(root, data)\n if element\n # if data was found\n # store what will be the new last index\n last_index = @tree.length - 1\n # store last_index's parent's index\n parent = last_index / 2\n # delete end of tree and store in last_element\n last_element = @tree.pop\n\n # determine if it was a left or right child\n popped_node_was_a_left_child = @tree[parent] && last_index % 2 == 0\n popped_node_was_a_right_child = @tree[parent] && last_index % 2 != 0\n\n # set appropriate child as nil\n if popped_node_was_a_left_child\n @tree[parent].left = nil\n elsif popped_node_was_a_right_child\n @tree[parent].right = nil\n end\n\n # re-set the 'deleted' element's title and rating,\n # effectively removing it and replacing it with what was the last node\n element.title = last_element.title\n element.rating = last_element.rating\n else\n # data was not found, return nil\n return nil\n end\n\n # filter the newly placed node up or down to where it should be in the heap\n filter_down(element)\n filter_up(element)\n end",
"def delete_node\n node.destroy if node\n end",
"def remove()\n return if @store.empty?\n\n swap(0, @store.length - 1)\n banished = @store.pop\n heap_down(0)\n\n return banished.value\n end",
"def delete?(value)\n value = RDF::Literal(value) if value.is_a? Symbol\n\n return nil if parent.query([rdf_subject, predicate, value]).nil?\n\n delete(value)\n value\n end",
"def delete_head_branch\n repository.delete_branch(commit_head)\n\n journalize_action(\n :property => 'attr',\n :prop_key => 'branch',\n :old_value => commit_head\n )\n end",
"def remove_package(value)\n @children['package'][:value].delete(value)\n end"
] | [
"0.80915844",
"0.7924976",
"0.7830004",
"0.7815752",
"0.7461815",
"0.7431895",
"0.7431645",
"0.73469865",
"0.72802377",
"0.72285813",
"0.7181502",
"0.71264124",
"0.71264124",
"0.70844907",
"0.70844907",
"0.7027486",
"0.7017461",
"0.70027834",
"0.70001626",
"0.69611734",
"0.69611734",
"0.69387805",
"0.692833",
"0.6926343",
"0.6914406",
"0.6913694",
"0.68936783",
"0.687482",
"0.6855102",
"0.68357867",
"0.68267995",
"0.6799363",
"0.6788016",
"0.6749141",
"0.6742489",
"0.672623",
"0.6724978",
"0.6718858",
"0.66658396",
"0.6663449",
"0.6654317",
"0.6628588",
"0.66003984",
"0.6589471",
"0.65891314",
"0.6586678",
"0.65642595",
"0.6516618",
"0.64961624",
"0.6454946",
"0.6454263",
"0.64529675",
"0.6451915",
"0.64506674",
"0.6431995",
"0.6423079",
"0.6403284",
"0.6402475",
"0.64016443",
"0.6393459",
"0.637644",
"0.637095",
"0.63450605",
"0.6334665",
"0.63208187",
"0.63196754",
"0.63098735",
"0.6292344",
"0.62876624",
"0.62835336",
"0.6283321",
"0.62764937",
"0.6274184",
"0.6263503",
"0.6244267",
"0.6227177",
"0.62232894",
"0.6197544",
"0.61860734",
"0.61825323",
"0.6171939",
"0.6166593",
"0.6160254",
"0.615748",
"0.6144483",
"0.6141797",
"0.61382014",
"0.6134851",
"0.61336815",
"0.6126515",
"0.6120518",
"0.61194915",
"0.61099964",
"0.61046815",
"0.6094313",
"0.60899514",
"0.6082032",
"0.6081618",
"0.6076776",
"0.6074305"
] | 0.74384767 | 5 |
Aux function to delete | def delete_aux(next_node, value)
return nil if next_node.right_child.nil? && next_node.left_child.nil?
return next_node.left_child if next_node.right_child.nil?
return next_node.right_child if next_node.left_child.nil?
build_tree(in_order_traversal(next_node) - [value])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n \n end",
"def delete\n \n end",
"def del\n delete\n end",
"def delete(obj) ; end",
"def destroy; delete end",
"def delete!\n delete( nil, true ) \n end",
"def del(*args); end",
"def delete(name); end",
"def delete(name); end",
"def delete\n end",
"def delete!\n clear!\n delete\n end",
"def delete(element); end",
"def delete(object); end",
"def remove!; end",
"def delete_operations; end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n\n end",
"def delete\n end",
"def delete!(*rest) end",
"def delete(o); removeObject o end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def delete_from_disk; end",
"def delete!\n delete_if { true }\n end",
"def delete!(defer = false)\n delete_logic( defer, false ) \n end",
"def delete(*rest) end",
"def delete(value)\n end",
"def delete(value)\n end",
"def _destroy_delete\n delete\n end",
"def _destroy_delete\n delete\n end",
"def destroy!; end",
"def delete\n\n\tend",
"def destroy\n \n end",
"def destroy\n \n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete_at(p0) end",
"def delete_front()\n \n end",
"def delete(name)\n\n end",
"def delete\n end",
"def delete(oid)\n end",
"def delete\n # TODO: implement delete\n 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 delete\n raise NotImplementedError\n end",
"def delete\n raise NotImplementedError\n end",
"def delete!\n delete(:force => true)\n nil\n end",
"def delete(key)\n\n end",
"def delete\n raise NotImplementedError\n end",
"def delete(name, options = T.unsafe(nil)); end",
"def delete\n raise NotImplementedError\n end",
"def delete_entry(aliaz)\n\n end",
"def delete(table, ids) # abstract\n end",
"def delete_at_index(index)\n \n end",
"def deleted(item)\n end",
"def delete\n CMark.node_unlink(@pointer)\n end",
"def delete(defer = false)\n delete_logic( defer )\n end",
"def delete!\n deleted\n save!\n end",
"def delete(*args, &block)\n map_method(:delete, args, &block)\n end",
"def delete_item\n\nend",
"def delete_last()\n \n end",
"def my_array_deletion_method(source, thing_to_delete)\n\t\nend",
"def delete\n trap_exception { delete! }\n end",
"def destroy \n \n end",
"def delete(attribute); end",
"def delete_element(element); end",
"def destroy \r\n\r\n end",
"def destroy\r\n\r\n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def destroy\r\n end",
"def destroy\r\n end",
"def delete(action, **args); end",
"def delete \n @data = {} \n end",
"def delete_record *rid\n db.delete_record rid\n end",
"def delete\n binding.pry\n DATABASE.execute(\"DELETE FROM contents WHERE id = #{id}\")\n end",
"def delete\n destroy\n end"
] | [
"0.8200665",
"0.7844601",
"0.7826577",
"0.77656096",
"0.7733488",
"0.77138853",
"0.7696122",
"0.7626925",
"0.7626925",
"0.76240575",
"0.76075155",
"0.7541425",
"0.751256",
"0.7487649",
"0.7487639",
"0.7482364",
"0.7482364",
"0.7482364",
"0.7482364",
"0.7482364",
"0.7482364",
"0.7482364",
"0.74705875",
"0.74547195",
"0.7436662",
"0.7436041",
"0.7432635",
"0.7432635",
"0.7432635",
"0.7432635",
"0.7420448",
"0.7362451",
"0.73270917",
"0.73172003",
"0.7299301",
"0.7299301",
"0.7286888",
"0.7286888",
"0.7282051",
"0.7267531",
"0.7266198",
"0.7266198",
"0.7249934",
"0.7249934",
"0.7249934",
"0.7249934",
"0.7249934",
"0.7230732",
"0.7228795",
"0.72257376",
"0.72124135",
"0.7209448",
"0.7205261",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.71509194",
"0.7104125",
"0.7104125",
"0.7080357",
"0.70776534",
"0.70741934",
"0.7060973",
"0.70474595",
"0.7040022",
"0.7032976",
"0.698738",
"0.6982554",
"0.6962251",
"0.6933622",
"0.692737",
"0.69236416",
"0.691082",
"0.690769",
"0.68859684",
"0.68791974",
"0.68716806",
"0.6862621",
"0.6847841",
"0.6841767",
"0.68389165",
"0.68384683",
"0.68384683",
"0.68384683",
"0.68384683",
"0.68384683",
"0.68384683",
"0.68384683",
"0.6825661",
"0.6825661",
"0.6825516",
"0.68206125",
"0.68181485",
"0.6814794",
"0.6807593"
] | 0.0 | -1 |
Consumes a value and return a Node if the value match the data in a Node | def find(value)
current_node = @root
until current_node.nil?
if current_node.data < value
current_node = current_node.right_child
elsif current_node.data > value
current_node = current_node.left_child
else
return current_node
end
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_node node, value\n return if ANY_VALUE != node &&\n (Array === value || Hash === value)\n\n if node.class == value.class\n node == value\n\n elsif Regexp === node\n match = node.match value.to_s\n return false unless match\n match = match.size > 1 ? match[1..-1] : match.to_a\n [true, match]\n\n elsif Range === node\n stat = node.include? value.to_i\n match = [value.to_i] if stat\n [stat, match]\n\n elsif ANY_VALUE == node\n [true, [value]]\n\n else\n value.to_s == node.to_s\n end\n end",
"def find(value)\n self.each {|node| return node if node.value == value}\n end",
"def find_node(value)\n return false if @head.nil?\n curr_node = @head\n match = false\n while curr_node\n break if match = (curr_node.value == value)\n curr_node = curr_node.next\n end\n\n match\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n met_resp = find_node_support(value)\n return nil if met_resp[:node].nil?\n\n met_resp[:node]\n end",
"def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == value\n current = current.next_node\n end\n end",
"def find(value)\n current_node = head\n while current_node != nil\n return current_node if current_node.value == value\n current_node = current_node.next\n end\n nil\n end",
"def Node(value)\n case value\n when Node\n value\n else\n Node.new(value)\n end\nend",
"def find(value)\n node = @head\n while node\n if node.value == value\n return node\n end\n node = node.next\n end\n\n return nil\n end",
"def find(value, node = root)\n return node if node.nil? || node.data == value\n \n value < node.data ? find(value, node.left) : find(value, node.right)\n end",
"def search(value, &block)\n work_list = [@root]\n\n while !work_list.empty?\n curr_node = yield(work_list)\n\n unless curr_node.value == value\n work_list << curr_node.left_child unless curr_node.left_child.nil?\n work_list << curr_node.right_child unless curr_node.right_child.nil?\n else\n return curr_node\n end\n end\n\n return nil\n end",
"def contains?(value)\n found = false\n current_node = @head\n while !node.nil? do\n if node.data == value\n found = true\n break\n end\n current_node = node.next\n end\n found\n end",
"def contains?(value, node = @head)\n return false if node.nil?\n return true if node.value == value\n\n contains?(value, node.next_node)\n end",
"def contains?(value)\n node = @head\n until node.nil?\n return true if node.value == value \n node = node.link\n end\n false\n end",
"def value_of_node(node_name)\n value_of_nodes(node_name).first\nend",
"def select_node(data,key,value)\n data.each_key do |k|\n if data[k].has_key?(key)\n if data[k][key] == value\n return k\n end\n end\n end\nend",
"def find(value)\n return nil if @head.nil?\n found = nil\n index = 0\n current_node = @head\n while !node.nil? do\n if node.data == value\n found = true\n break\n end\n index += 1\n current_node = node.next\n end\n found == true ? \"#{value} found at index #{index}!\" : nil\n end",
"def matches?(node); end",
"def find(value, current_node = root)\n return current_node if current_node.nil? || current_node.value == value\n value < current_node.value ? find(value, current_node.left) : find(value, current_node.right)\n\n end",
"def search(value)\n\t\t\treturn nil if self.empty?\n\t\t\telement = self.head\n\t\t\twhile element.value != value\n\t\t\t\tif element.next.nil?\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\telement = element.next\n\t\t\t\tend\n\t\t\tend\n\t\t\telement\n\t\tend",
"def find(value, node = @root)\n return nil if node.nil?\n return node if node.value.eql?(value)\n\n node.value > value ? find(value, node.left) : find(value, node.right)\n end",
"def find(needle)\n #return the Node object whose value == needle\n node = @head\n while node\n return node if node.value == needle\n node = node.next\n end\n #Return nil if cannot find it\n nil\n end",
"def search_recursive(root,target_value)\n\n return root if root.payload == target_value\n\n root.children.each do |child|\n node = search_recursive(child,target_value)\n return node if node\n end\n\n return nil\n\nend",
"def node_match?(pattern, value, state, flags)\n return false unless value['@id']\n\n node_object = state[:subjects][value['@id']]\n node_object && filter_subject(node_object, pattern, state, flags)\n end",
"def find(value, node = @root)\n if node.nil?\n return nil\n end\n\n if value < node.value\n return find(value, node.left_node)\n elsif value > node.value\n return find(value, node.right_node)\n else\n return node\n end\n end",
"def include?(value)\n return false if empty?\n splay(value)\n @root.value == value\n end",
"def contains?(value)\n current_node = @head\n while current_node.next != nil do\n current_node = current_node.next\n return true if current_node.data == value\n end\n return false\n end",
"def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end",
"def contains? (value)\n return false if @size == 0\n if @root.value == value\n \t\treturn true\n \tend\n \[email protected]_node\n while(node!=nil)\n if node.value == value\n \treturn true\n end\n node=node.next_node\n end\n return false\n end",
"def get_match(header, value, subtree=\"0\", actual_header='', cls='device')\n f = 0\n r = 0\n if cls == 'device'\n value = clean_str value\n else\n value = extra_clean_str value\n end\n treetag = \"#{header}#{subtree}\"\n\n return false if value.length < 4\n\n branch = get_branch treetag\n return false if branch.blank?\n if header == 'user-agent'\n # Sieve matching strategy\n branch.each do |order, filters|\n filters.each do |filter, matches|\n f += 1\n if value.include? filter\n matches.each do |match, node|\n r += 1\n if value.include? match\n @detected_rule_key[cls] = clean_str(header) + ':' + clean_str(filter) + ':' + clean_str(match)\n return node\n end\n end\n end\n end\n end\n else\n # Hash matching strategy\n unless branch[value].blank?\n node = branch[value]\n return node\n end\n end\n false\n end",
"def contains?(val,node=head)\n return nil if node.next == nil\n return true if node.data == val\n return contains?(val,node.next)\n end",
"def contains?(given_value)\n self.traverse_list do |node|\n if node.value == given_value\n return true\n else\n return false\n end\n end\n end",
"def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end",
"def node_value\n return @value\n end",
"def find(value, tree_node = @root)\n current_node = tree_node\n while (current_node)\n if value > current_node.value\n current_node = current_node.right\n elsif value < current_node.value\n current_node = current_node.left\n else\n return current_node\n end\n end\n nil\n end",
"def check_children(value, node)\n if value < node.value\n node.left\n else\n node.right\n end\n end",
"def scanned_node?(node); end",
"def contains?(value)\n current_node = @head\n until current_node.nil?\n return true if current_node.value == value\n\n current_node = current_node.next_node\n end\n false\n end",
"def find(needle) # returns the node with value=value or nil if not found\n next_node = @head\n while next_node && next_node.needle != needle\n next_node = next_node.next\n end\n next_node\n end",
"def depth_first(value_to_find)\r\n @children.each do |child|\r\n found_node = child.depth_first(value_to_find)\r\n if found_node != nil\r\n return found_node\r\n end\r\n end\r\n\r\n if payload == value_to_find\r\n return self\r\n else\r\n return nil\r\n end\r\n end",
"def make_node(value)\n klass = class_for_value(value)\n value = RDF::Node.new if value.nil?\n node = node_cache[value] if node_cache[value]\n node ||= klass.from_uri(value,parent)\n return nil if property_config[:class_name] && class_for_value(value) != class_for_property\n self.node_cache[value] ||= node\n node\n end",
"def selectElement(value, node)\n if node != nil\n lastElement = node\n comparacion = @compare.call(value,node)\n\n if comparacion == 0\n return lastElement\n end\n\n if comparacion > 0\n return selectElement(value, node.getRight())\n else\n return selectElement(value, node.getLeft())\n end \n end\n end",
"def find_by_value(value)\n return nil if value.nil? || self.size == 0\n stop_node = self.head\n target = stop_node\n while target && !target.match_by_value(value)\n target = target.next\n break if stop_node.equal?(target)\n end\n target = nil unless target && target.match_by_value(value)\n target\n end",
"def get_node(key); end",
"def returns_from(node); end",
"def returns_from(node); end",
"def find(value, current_node = @root)\n # Base case: We found the node or past a leaf node\n return current_node if current_node.nil? || current_node.value == value\n\n return find(value, current_node.left) if value < current_node.value\n\n find(value, current_node.right)\n end",
"def parse_value(nodes); end",
"def search(value)\r\n current = @head\r\n \r\n until current.nil? \r\n return true if current.data == value\r\n current = current.next\r\n end\r\n \r\n return false\r\n \r\n end",
"def getNode(*args)\n if(args.size == 1)\n return retNode(args[0])\n else\n if (@nodeValues.size > @INDEX)\n tmp = @nodeValues[@INDEX]\n #puts \"----------------\\nSearch For #{@node}\\n#{tmp}\\n--------------------------\"\n retStr = @xmlTool.searchForValue(tmp, @node)\n #puts \"----------------\\nSearch For #{@node}\\n#{retStr}\\n--------------------------\"\n return retStr\n else\n return \"\"\n end\n end\n end",
"def find(value,node=head)\n return 0 unless self.contains?(value)\n head\n loops = 0\n until @current_node.next == nil do\n if @current_node.data == value\n return loops\n end\n self.next_node\n loops += 1\n end\n return loops\n end",
"def get_node_value(node)\n node\n end",
"def nodeValue\n @value\n end",
"def contains?(value)\n return false if @head.nil?\n node = @head\n limit = size - 1\n limit.times do\n break if node.data == value\n node = node.next_node\n end\n if value == node.data \n true\n else\n false\n end\nend",
"def contains?(val)\n node = @head\n while !(node.nil?)\n return true if node.value == val\n node = node.next_node\n end\n return false\n end",
"def e32_find(node, input)\n while node.next != nil\n if node.value == input\n return true\n end\n node = node.next\n end\n return false\n end",
"def breadth_first(value_to_find)\r\n current_node = self\r\n queue = MyQueue.new \r\n\r\n while current_node != nil\r\n if current_node.payload == value_to_find\r\n return current_node\r\n end\r\n current_node.children.each do |child|\r\n queue.enqueue(child)\r\n end\r\n current_node = queue.dequeue\r\n end\r\n end",
"def find (data)\n current_node = @head\n\n while current_node\n return current_node if current_node.data == data\n current_node = current_node.next\n end\n\n return nil\n end",
"def find_node(op=nil)\n visit_nodes do |node|\n if !op || node.op == op\n if !block_given? || yield(node)\n return node\n end\n end\n end\n end",
"def [](value)\n node_data[value.to_s]\n end",
"def [](value)\n Placeholder.resolve(node_data[value.to_s])\n end",
"def value_exists?(value)\n\t\tcurrent_node = @head\n\t\tuntil current_node.value == value \n\t\t\treturn false if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\ttrue \n\tend",
"def next_node(example)\n if example[@feature].to_s == @value\n self.left\n else\n self.right\n end\n end",
"def contains?(value)\n temp = @head\n while temp\n return true if temp.value == value\n temp = temp.next_node\n end\n false\n end",
"def dfs_rec(cur_node, value)\n return nil if cur_node.nil?\n \n if cur_node.value == value\n\tcur_node\n else\n tgt_node = nil\n cur_node.children.each do |child| \n\t tgt_node = dfs_rec(child, value)\n\t break unless tgt_node.nil?\n\tend\n\ttgt_node\n end\nend",
"def find_before(value)\n node = @head\n return node if !node.next\n return node if node.next.data == value\n\n while (node = node.next)\n return node if node.next && node.next.data == value\n end\n end",
"def find(root, data)\n if @root != nil\n queue = Queue.new\n queue.enq(@root)\n result = nil\n while !queue.empty?\n node = queue.deq\n return node if node.title == data\n queue.enq(node.left) if node.left\n queue.enq(node.right) if node.right\n end\n end\n\n end",
"def from_node(node); end",
"def find(value)\n node = @head \n for i in 0..@size-1 \n return i if node.value == value\n node = node.link \n end\n return nil\n end",
"def match_node(node, *args)\n match_nodes([node], *args)\n end",
"def parse_value\n if String === peek_token\n ScopedSearch::QueryLanguage::AST::LeafNode.new(next_token)\n elsif ([:in, :notin].include? current_token)\n value = parse_multiple_values()\n ScopedSearch::QueryLanguage::AST::LeafNode.new(value)\n else\n raise ScopedSearch::QueryNotSupported, \"Value expected but found #{peek_token.inspect}\"\n end\n end",
"def contains?(value)\n node = list\n while node != nil\n return true if node.value == value\n node = node.nextNode\n end\n return false\n end",
"def search(value)\n current = @head\n while current != nil\n if current.data == value\n return true\n end\n current = current.next\n end\n\n return false\n end",
"def find_all(value)\n nodes = []\n self.each {|node| nodes << node if node.value == value}\n nodes\n end",
"def get_node(object)\n @nodes.each do |node|\n return node if node.object == object\n end\n end",
"def find(val)\n self.each {|n| return n if n.data == val }\n end",
"def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend",
"def value_of_nodes(node_name)\n ns = nodes(node_name)\n ns.map do |n|\n raise \"failed to find #{node_name.inspect} in #{subject.inspect}\" if n.nil?\n n.content\n end\nend",
"def LinkedListNode(value)\n case value\n when LinkedListNode\n value\n else\n LinkedListNode.new(value)\n end\nend",
"def node(node_name)\n nodes(node_name).first\nend",
"def find_node_for(str)\n c = str[0..0]\n return nil if @value==\"\" and [email protected]?(c)\n if @children.keys.include?(c)\n if( str.length<=1 )\n\t ret = @children[c]\n else\n ret = @children[c].find_node_for(str[1..100])\n end\n else\n ret = self\n end\n return ret\n end",
"def get_node_value (doc, node_name, embed_code)\n\n node_value = doc.get_elements(\"list/item/#{node_name}\")[0].get_text().value rescue nil\n \n if @log && @node_value == nil\n $LOG.info(\"Value not found for: #{node_name}, embed_code: #{embed_code}\") \n end\n\n return node_value\n end",
"def unique?(head, node_value)\n queue = []\n queue.push(head)\n if head.get_value == node_value\n return false\n end\n until queue.empty?\n if head.get_children == []\n return true\n end\n i = 0\n while i < queue[0].get_children_counter do\n if queue[0].get_children[i].get_value == node_value\n return false\n else\n queue.push(queue[0].get_children[i])\n i += 1\n end\n end\n queue.shift\n end\n return true\nend",
"def find_node(xpath, select_result_value=false)\n if self.feed_data_type != :xml\n raise \"The feed data type is not xml.\"\n end\n return FeedTools::XmlHelper.try_xpaths(self.channel_node, [xpath],\n :select_result_value => select_result_value)\n end",
"def find(value)\n current_node = @head\n counter = 0\n until current_node.nil?\n return counter if current_node.value == value\n\n current_node = current_node.next_node\n counter += 1\n end\n nil \n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def dfs_rec(value, node = Node.get_root_node)\n\n if !node.nil?\n puts \"Searching node #{node.value}\"\n if !node.value.nil?\n if node.value == value\n puts \"Found #{value} at node #{node}!\"\n return node\n end\n end\n else\n nil\n end\n\n left_child = node.left_child\n right_child = node.right_child\n\n if left_child.nil?\n puts \"No left child.\"\n else\n puts \"Left child is #{left_child.value}\"\n end\n\n if right_child.nil?\n puts \"No right child.\"\n else\n puts \"Right child is #{right_child.value}.\"\n end\n\n left_child.nil? ? nil : dfs_rec(value, left_child)\n right_child.nil? ? nil : dfs_rec(value, right_child)\nend",
"def create_node(value)\n Node.new(value)\n end",
"def search(value)\n return false if is_empty\n\n current = @root\n\n while current != nil\n if current.value == value\n return true\n else\n current = current.value < value ? current.right : current.left\n end\n end\n\n return false\n end",
"def find_value(value) \n find { |item| item.data == value }\n end",
"def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end",
"def bnode(value = nil)\n @bnode_cache ||= {}\n @bnode_cache[value.to_s] ||= RDF::Node.new(value)\n end",
"def bnode(value = nil)\n @bnode_cache ||= {}\n @bnode_cache[value.to_s] ||= RDF::Node.new(value)\n end",
"def bnode(value = nil)\n @bnode_cache ||= {}\n @bnode_cache[value.to_s] ||= RDF::Node.new(value)\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 contains?(val)\n return nil if @head == nil\n\n result = false\n\n node = @head\n until node.next_node.nil?\n if node.value == val\n result = true\n break\n end\n node = node.next_node\n end\n\n result\n end",
"def search(value)\n return 'not found' if @root.nil?\n return 'found' if @root.value == value\n\n if value < @root.value\n @root = root.left\n search(value)\n elsif value > @root.value\n @root = root.right\n search(value)\n end\n end",
"def operator_found(node, operator)\n return if node.nil?\n operator_found(node.left, operator)\n if !node.left.nil? || !node.left.nil?\n if node.value == operator\n print \"Yes! '#{node.value}' does appear! \"\n end\n end\n operator_found(node.right, operator)\nend",
"def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend",
"def getFather(value, node, toRemove) \n current = node ##asignamos variable para recorrido\n \n while(current != nil) do ##Recorremos hasta encontrar o no encontrarlo\n if toRemove.getData() > current.getData() #Decidimos direccion\n if current.getRight() == toRemove\n return current\n else\n current = current.getRight() #dezplazamiento a derecha\n end\n else \n if current.getLeft() == toRemove\n return current\n else \n current = current.getLeft()\n end\n end \n end \n \n return nil\n end"
] | [
"0.68579715",
"0.6826764",
"0.6746283",
"0.6733583",
"0.6733583",
"0.65911585",
"0.65357494",
"0.6441634",
"0.6334188",
"0.6299959",
"0.62202597",
"0.6112517",
"0.6096844",
"0.60942537",
"0.60339826",
"0.6003444",
"0.5993824",
"0.59850776",
"0.5950705",
"0.59453076",
"0.5917264",
"0.59008104",
"0.5892507",
"0.58857656",
"0.5879369",
"0.58616775",
"0.5844586",
"0.57986337",
"0.5769948",
"0.57676977",
"0.57592416",
"0.5746175",
"0.5737411",
"0.5717889",
"0.5717193",
"0.57143193",
"0.5711946",
"0.5710665",
"0.57052946",
"0.57007575",
"0.5700158",
"0.5690607",
"0.56776726",
"0.5675891",
"0.56659424",
"0.56659424",
"0.5630132",
"0.56275994",
"0.5618629",
"0.5614047",
"0.56064487",
"0.56060946",
"0.55864775",
"0.558354",
"0.55784154",
"0.5575678",
"0.55722016",
"0.5571011",
"0.5568043",
"0.55661803",
"0.55640906",
"0.5563974",
"0.5562727",
"0.5548643",
"0.5544834",
"0.5543995",
"0.5534198",
"0.5533121",
"0.5525006",
"0.55232",
"0.55218834",
"0.55065656",
"0.55014855",
"0.5496031",
"0.54928184",
"0.54919505",
"0.5482279",
"0.5456236",
"0.5448395",
"0.5448171",
"0.5446884",
"0.54388434",
"0.54288477",
"0.5423376",
"0.5415944",
"0.54154605",
"0.5413996",
"0.54128075",
"0.5409603",
"0.54060805",
"0.5392981",
"0.5390365",
"0.5390365",
"0.5390365",
"0.53851104",
"0.53832597",
"0.53621626",
"0.53611904",
"0.536068",
"0.53525424"
] | 0.57974684 | 28 |
traverse the BBT in width and returns the data in level order in an array | def level_order_traversal
array_to_be_string = []
queue = []
queue.push(@root)
until queue.empty?
current_node = queue.first
array_to_be_string.push(current_node.data)
queue.push(current_node.left_child) unless current_node.left_child.nil?
queue.push(current_node.right_child) unless current_node.right_child.nil?
queue.shift
end
array_to_be_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def bst_sequences(root)\n\nend",
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def setBredthLevels\n stack = []\n queue = []\n level = 0\n\n queue.push(@root)\n\n while(queue.size != 0)\n node = queue.shift\n\n stack.append([node.name, node.level])\n\n node.children.each_with_index do |child, i|\n level += 1 if i == 0\n child.level = level\n queue.push(child)\n end\n end\n\n return stack\n end",
"def level_order(root = @root)\n return if root.nil?\n array = []\n queue = []\n queue.unshift(root)\n until queue.empty?\n current = queue.last\n array << current.data\n queue.unshift current.left unless current.left.nil?\n queue.unshift current.right unless current.right.nil?\n queue.pop\n end\n return array\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def calc_tree\n tree = []\n n = 1\n while n <= @n\n result = []\n result = [[0, 1]] if n == 1\n tree.each do |row|\n line1 = []\n line2 = []\n row.each_with_index do |elem, i|\n line1 << \"#{elem}0\" if i.positive?\n line2 << \"#{elem}0\" if i.zero?\n line2 << \"#{elem}1\"\n end\n result << line1 unless row.count == 1\n result << line2\n end\n tree = result\n n += 1\n end\n tree\n end",
"def read_btree_node nth\n @last_node_no = nth\n node = read_node(nth)\n @last_btnode = btnode = BTNodeDescriptor.read(node)\n\n arr = BinData::Array.new(:type => :uint16be, :initial_length => btnode.numRecords)\n offsets = arr.read(node[-2*btnode.numRecords..-1])\n\n if btnode.kind == KBTHeaderNode\n header = BTHeaderRec.read(node[14..-1])\n maprec = node[offsets[-3]..-1]\n return KBTHeaderNode, [header, maprec]\n elsif btnode.kind == KBTIndexNode\n# recs = []\n# for i in (0...btnode.numRecords)\n# offset = offsets[btnode.numRecords-i-1]\n# key = @key_class.read(node[offset..-1])\n# offset += 2 + key.keyLength\n# key.childNode\n# end\n elsif btnode.kind == KBTLeafNode\n recs = []\n for i in (0...btnode.numRecords)\n offset = offsets[btnode.numRecords - i - 1]\n key = @key_class.read(node[offset..-1])\n offset += 2 + key.keyLength\n data = @data_class.read(node[offset..-1])\n #\n # [key, data] 이걸 루비 tuple로 어떻게 표현?\n # {key, value}\n #\n recs << [key, data]\n end\n\n return KBTLeafNode, recs\n else\n raise Excention, \"read_btree.node error\"\n end\n end",
"def tree_levels_text_array\n text_rows = []\n num_levels = num_tree_levels\n # set string size for spacing and \"nil\" nodes (with default if tree too big)\n max_length = (num_levels > 4) ? 2 : max_node_value_length\n blank_node = \"_\" * max_length # text for nil nodes\n cell_pad = \" \" * max_length # text for cell padding / spacing\n all_nodes = all_node_values_with_nil # array of all node values (breadth_first order)\n level = 0\n cur_node = 0 # Track position in array \"all_nodes\"\n # track each tree level\n while level < num_levels\n level_exponent = num_levels - level - 1 # sets exponent series range\n # inner_padding: num spacing cell-pads between nodes (not before 1st node)\n inner_padding = sum_base_to_exponent_series(2, 0, level_exponent)\n # outer_padding: num spacing cell-pads before first node\n outer_padding = inner_padding - 2**(level_exponent)\n row_string = \"\"\n row_string << cell_pad * outer_padding\n num_nodes_in_row = 2**level # all_nodes is a \"complete binary tree\"\n # \"counter\" avoids adding inner_padding after last node on each level\n counter = 1\n # track the node placement, from array \"all_nodes\"\n num_nodes_in_row.times do\n next_value = all_nodes[cur_node].nil? ? blank_node : all_nodes[cur_node].to_s\n row_string << next_value\n row_string << cell_pad * inner_padding unless counter == num_nodes_in_row\n cur_node += 1\n counter += 1\n end\n row_string << \" (Root)\" if level == 0\n text_rows.push(row_string)\n level += 1 # must adjust padding before incrementing level\n end\n # Add display note if tree is empty\n text_rows[0] = \"(Empty Tree: Root = nil)\" if text_rows.empty?\n return text_rows\n end",
"def data_shapes tree\n acc = Array.new(MAX_DIM + 1) { [] }\n min_level = MAX_DIM + 1\n max_level = 0\n minmax = [min_level, max_level]\n\n search max_level, tree, acc, minmax\n\n min_level = minmax[0]\n max_level = minmax[1]\n\n if acc[max_level] && acc[max_level].all? { |a| a.nil? }\n # min_level is not set in this special case. Hence the check.\n elsif min_level != max_level\n raise ValueError, \"unbalanced tree: min depth #{min_level} and max depth #{max_level}\"\n end\n\n data = acc[max_level]\n shapes = acc[0...max_level].reverse\n\n [data, shapes]\n end",
"def linked_list_per_depth\n list = Array.new(height)\n each_depth do |layer, depth|\n n = layer.size - 1\n list[depth] = (0..n).reduce(nil) do |acc, i|\n layer[n-i].nil? ? acc : LinkedList.new(layer[n-i].value, acc)\n end\n end\n list\n end",
"def _level_order(root, ary=[], lbd)\n ary, q = [], BST::MyQueue.new\n q.enqueue root\n loop do\n break if q.empty?\n node = q.dequeue\n ary << lbd.call(node.val)\n q.enqueue node.lnode if node.lnode \n q.enqueue node.rnode if node.rnode\n end\n ary \n end",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def sequence_hunter(head)\n\tarr_arrs = []\n\t\n\tarr_values = []\n\tarr_values.push(node.value)\n\n\t#nope, giving up after an hour\n\t#basically we need to generate an array of each level\n\t#but good fucking luck\nend",
"def find_bags(color)\n return 0 unless DATA[color]\n out = 0\n DATA[color].each do |q, sub_bag|\n out += q + q * find_bags(sub_bag)\n end\n out\nend",
"def bfs\n return [] if @root.nil?\n end",
"def traverse_df(node,level,&block)\n @children[node].sort_by {|a| length(a) }.reverse.each { |child| traverse_df(child, level+1, &block) }\n yield node, level if block_given?\n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def bars(bitmap, depth)\n s = bitmap.set?(0) ? \"|\" : \" \" \n\n (1...depth).each do |i|\n if bitmap.set?(i)\n s += bar(depth) \n else\n s += @spacenobar\n end\n end\n return s\n end",
"def level_order(root)\n return [] if root.nil?\n queue = [[root, 0]]\n response = []\n until queue.empty?\n # node is the current node, level is the number associated with it\n node, level = queue.pop\n # level acts as a index for the response array\n # if there's no element (array) with that index, we create it\n response[level] ||= []\n # if it exists, we add current node to it\n response[level] << node.val\n # then we add children to queue and increase the level by 1\n queue << [node.right, level + 1] if node.right\n queue << [node.left, level + 1] if node.left\n end\n response\nend",
"def gracify(data)\n data.map{|i| Belt.new(i[0], i[1])}\n end",
"def bag_list(node)\n node.children.flat_map do |child|\n [child.color] + bag_list(child)\n end\n end",
"def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end",
"def descendants_bfs(options={})\n desc_nodes = []\n each_level_nodes(options) do |nodes|\n desc_nodes += nodes\n end\n return desc_nodes\n end",
"def group_by_depth(arr)\n output = []\n\n nested = false\n arr.each do |x|\n\n if output.last\n\n last_line = output.last[-1]\n\n if line_depth(last_line) == line_depth(x)\n\n if x =~ /Features:/ && last_line =~ /Page: \\d/\n nested = true\n end\n\n if nested\n output.last << x\n else\n output << [x]\n end\n\n elsif line_depth(last_line) > line_depth(x)\n # we are outdenting\n nested = false\n output << [x]\n\n elsif line_depth(last_line) < line_depth(x)\n # we are indenting further\n nested = true\n output.last << x\n end\n else\n output << [x]\n end\n end\n\n output\n end",
"def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end",
"def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end",
"def sortByHeight(a)\n treeArray = Array.new\n \n b = a.sort\n b = b.select {|item| item != -1}\n \n for i in 0..(a.count-1)\n if a[i] != -1\n num = b.shift\n a[i] = num\n end\n end\n \n a\nend",
"def level_order_bottom(root)\n return [] unless root\n \n ordered = nil\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered = ordered ? ([vals] + ordered) : [vals]\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend",
"def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend",
"def print_BST_by_layer(root)\n puts \"print BST rooted at #{root.value} by layer\" if $debug\n print_queue = Array.new\n level_queue = Array.new\n print_queue.push root\n level_queue.push 1\n prev_level = 1\n while !print_queue.empty?\n bst_node = print_queue.first\n print_queue.delete_at 0\n cur_level = level_queue.first\n level_queue.delete_at 0\n print \"\\n\" if cur_level != prev_level\n print \"#{bst_node.value} \"\n prev_level = cur_level\n if !bst_node.left.nil?\n print_queue.push bst_node.left\n level_queue.push cur_level+1\n end\n if !bst_node.right.nil?\n print_queue.push bst_node.right\n level_queue.push cur_level+1\n end\n end\nend",
"def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end",
"def convert_1_level_deep(arr, result=[])\n arr.flatten.each_slice(3) { |ele| result.push(ele)}\n result\nend",
"def bfs_helper(node, list, level)\n return list if node.nil?\n \n # creating array of arrays for each level in tree\n list[level] = [] if list[level].nil?\n list[level] << {key: node.key, value: node.value}\n\n bfs_helper(node.left, list, level + 1)\n bfs_helper(node.right, list, level + 1)\n end",
"def level_order_bottom(root)\n res = []\n return res if root.nil?\n\n queue = [root]\n until queue.empty?\n cur = []\n\n queue.length.times do \n node = queue.shift()\n cur << node.val\n queue << node.left if node.left\n queue << node.right if node.right\n end\n res << cur\n end\n res.reverse!\nend",
"def children\n res = []\n @board.rows.each_with_index do |row, x|\n row.each_with_index { |item, y| res << [x,y] }\n end\n res\n end",
"def traverse(map, right, down)\n bottom = map.count\n x, y, level, trees = 0, 0, 1, 0\n\n while level < bottom do\n x += right\n y += down\n trees += 1 if map[y][x.remainder(map[0].size)] == \"#\"\n level += down\n end\n trees\nend",
"def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end",
"def levelled \n self.keys.reduce(Array.new) do |a,key| \n a << self.send(key) if self.send(key).rank > 0\n a\n end\n end",
"def level(num)\n result = []\n\n for node in @nodes\n if node.level == num\n result.push(node)\n end\n end\n\n return result\n end",
"def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end",
"def get_levels(page)\n levels = Array.new\n class_id = 0\n line_no = 1\n page.each do |line|\n if line.include? \"ic_class_wh24_box\"\n levels[class_id] = page[line_no] # This line contains a class level\n class_id += 1\n end\n line_no += 1\n end\n\n # Get rid of junk items\n levels.delete_at(0)\n levels.delete_at(0)\n levels.delete_at(9)\n levels.delete_at(12)\n\n # Get just the numbers\n levels.each_with_index { |val, index| levels[index] = val[5..6] }\n\n # If the number is a single digit, or non-existant, strip the extra character(s)\n levels.each_with_index do |val,index|\n levels[index] = val.gsub(/\\D/, \"\")\n end\n\n levels\n end",
"def get_levels(page)\n levels = Array.new\n class_id = 0\n line_no = 1\n page.each do |line|\n if line.include? \"ic_class_wh24_box\"\n levels[class_id] = page[line_no] # This line contains a class level\n class_id += 1\n end\n line_no += 1\n end\n\n # Get rid of junk items\n levels.delete_at(0)\n levels.delete_at(0)\n levels.delete_at(9)\n levels.delete_at(12)\n\n # Get just the numbers\n levels.each_with_index { |val, index| levels[index] = val[5..6] }\n\n # If the number is a single digit, or non-existant, strip the extra character(s)\n levels.each_with_index do |val,index|\n levels[index] = val.gsub(/\\D/, \"\")\n end\n\n levels\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def build_weight_array(nodes)\n weight_array = []\n gcd = nodes.map {|n| n.weight }.inject(0) {|r,w| r.gcd(w) }\n nodes.each {|n|\n (n.weight / gcd).times {\n weight_array << n\n }\n }\n weight_array\n end",
"def level_order_traversal(node)\n h = height(node)\n (1..h).each do |n|\n print_given_level(node, n)\n end\nend",
"def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end",
"def to_a\n return width, height, depth\n end",
"def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def level_order\n return nil if root.nil?\n\n q = [root] # queue for breath-first traversal\n level_order_array = []\n until q.empty?\n node = q.shift\n q.push(node.left) unless node.left.nil?\n q.push(node.right) unless node.right.nil?\n level_order_array.push(node)\n yield node if block_given?\n end\n level_order_array\n end",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def zigzag_level_order(root)\n return [] unless root\n\n zigzag_array = [[root.val]]\n\n traverse(root.left, zigzag_array, 1) && traverse(root.right, zigzag_array, 1)\nend",
"def nest_array(board)\n nested_board = []\n 9.times { nested_board << board.slice!(0..8)}\n return nested_board\nend",
"def each\n\t\[email protected] do |v|\n\t\t\tyield v & 0x0F #Bottom Nibble\n\t\t\tyield (v >> 4) & 0x0F #Top Nibble\n\t\tend\n\tend",
"def BFT_iterative(root)\n print '[\"I\", \"O\", \"H\", \"L\", \"R\", \"T\", \"M\", \"A\", \"G\"]' + \"\\n\"\n if root == nil\n return\n end\n q = Queue.new\n q.enqueue(root)\n\n while !q.empty?\n root = q.dequeue # I\n print(\"#{root.value}\\n\") \n if !root.left.nil?\n q.enqueue(root.left)\n end\n if !root.left.nil?\n q.enqueue(root.right)\n end\n end\n end",
"def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end",
"def depth; end",
"def flatten(data, level = 0)\n return [data] unless data.is_a?(Array) \n flat = []\n data.each do |ele|\n if ele.is_a?(Array)\n flat += flatten(ele, level + 1)\n else\n flat << ele\n end\n end\n flat\nend",
"def do_stuff1(arr)\n # d0 Heights array to store heights\n heights = []\n # d1 Iterate from last element of input array down to first element\n (arr.size - 1).downto(0).each do |i|\n # d2 push each height by running find_height with arr and current i as arguments\n heights.push(find_height(arr,i))\n end\n # puts heights[-1]\n print heights[-1]\n puts \"\\n\"\nend",
"def level_order(root)\n ordered = []\n return ordered unless root\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered << vals\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend",
"def gen_binomial_tree_prices\n u = udp[:u]\n d = udp[:d]\n tree = [[initial_per_share]]\n t = 0\n while t < duration - 1e-6\n t += dt\n this_arr = tree.last.collect { |s| s * d }\n this_arr << tree.last.last * u\n tree << this_arr\n end\n tree\n end",
"def right_side_view(root)\n return [] unless root\n queue = [[root, 0]]\n results_arr = []\n\n until queue.empty?\n current_node, current_depth = queue.shift\n queue.push([current_node.left, current_depth + 1]) if current_node.left\n queue.push([current_node.right, current_depth + 1]) if current_node.right\n\n # if queue.empty?\n # results_arr.push(current_node.val)\n # elsif queue[0][1] != current_depth\n # results_arr.push(current_node.val)\n # end\n results_arr[current_depth] = current_node.val\n end\n results_arr\nend",
"def rebuild_weight_array\n end",
"def nested_array\n curr = @nested\n @list.each do |num|\n r = rand(3)\n if r == 1\n curr << num\n elsif r == 2\n curr << []\n curr = curr[curr.length - 1]\n curr << num\n else\n curr = @nested\n curr << num\n end\n end\n @nested\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def breadth_first(value)\n\tend",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def hierarchies(array)\n count = 0\n array.reduce([]) { |acc, value| acc << array.slice(0, count += 1) }\n end",
"def bins\n Set.new @tree.values\n end",
"def build_tree(arr)\n\tend",
"def loadArray\n clearScreen\n @boxGoalCoord=[]\n @levelArr=[]\n\n lineCount=0\n #open the file and make each line an element in the 2d array @levelArr\n File.readlines(\"./levels/level#{@levelNo}.xsb\").each do |line|\n #initialize the subarray 'charArr'\n charArr=[]\n\n xCount=1\n line.each_char do |char|\n #push new element to the array subarray 'charArr'\n if char=='.'\n @boxGoalCoord.push(\"#{xCount},#{lineCount}\")\n end\n charArr.push(char)\n xCount+=1\n end\n #add the sub array 'charArr' to the whole file array 'fileArr'\n @levelArr.push(charArr)\n lineCount+=1\n end\nend",
"def bst_sequences(node)\n results = []\n\n # Nothing to do, return empty array\n if node.nil?\n results << []\n return results\n end\n\n # Recurse down to begin generating possible subsequences\n left = bst_sequences(node.left)\n right = bst_sequences(node.right)\n\n # Root nodes must come before children nodes, so save the prefix\n prefix = [node.data]\n\n # Each valid sequence of each child must be mixed with the other child\n left.each do |left_sequence|\n right.each do |right_sequence|\n results += mix_sequences(left_sequence, right_sequence, prefix)\n end\n end\n results\nend",
"def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend",
"def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend",
"def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end",
"def count_bags(color, data)\n data[color].to_a.map do |color, count|\n count + count * count_bags(color, data)\n end.sum\nend",
"def array_sort(level)\n\n\tarr = []\n\tdictfile = File.open(\"dict.txt\", 'r')\n\n\twhile !dictfile.eof?\n\t\tline = dictfile.readline\n\t\tarr.push(line.chomp)\n\tend\t\n\n\tsorted_arr = arr.sort {|x,y| x.length <=> y.length}\n sorted_arr_lengths = Hash.new()\n\n\tstart = 0\n\n\tsorted_arr.each_with_index do |item, index|\n\t\tif item.length != start \n\t\t sorted_arr_lengths[\"start_\"+item.length.to_s] = index\n\t\t if start > 0\n\t\t\tsorted_arr_lengths[\"end_\"+start.to_s] = index - 1\n\t end\n\t\t start = item.length\n\t\tend\n\tend\n\tsorted_arr_lengths[\"end_\"+start.to_s] = arr.length - 1\n\treturn [sorted_arr, sorted_arr_lengths]\nend",
"def sub_stack_list\n a = Array.[](\"ky\", \"khy\", \"gy\", \"py\", \"phy\", \"by\", \"my\",\n \"kr\", \"khr\", \"gr\", \"tr\", \"thr\", \"dr\", \"pr\", \"phr\", \"br\", \"mr\", \"shr\", \"sr\", \"hr\",\n \"kl\", \"gl\", \"bl\", \"zl\", \"rl\", \"sl\",\n \"kw\", \"khw\", \"gw\", \"cw\", \"nyw\", \"tw\", \"dw\", \"tsw\", \"tshw\", \"zhw\", \"zw\", \"rw\", \"lw\", \"shw\", \"sw\", \"hw\",\n \"t'\", \"h'\", \"a'\",\n \"grw\")\n return a\n end",
"def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end",
"def bfs\n return bfs_helper(@root, [])\n end",
"def bfs\n\n\n end",
"def bst_sequences(node)\n depth = Hash.new { |h, k| h[k] = [] }\n q = []\n q << node\n\n # use BFS to group nodes by depth\n until q.empty?\n current = q.shift\n depth[current.d] << current.v\n q << current.l if current.l\n q << current.r if current.r\n end\n depth = depth.map { |k, v| depth[k] = v.permutation.to_a }\n # return all the permutations of nodes\n solution = depth.first.first.product(*(depth[1..-1]))\n solution.map!(&:flatten)\nend",
"def java_tree_to_arrays(tree)\n # label just has to be unique. don't think we're using it for anything\n label = tree.label.value + '-' + tree.object_id.to_s\n root = Tree::TreeNode.new(label, tree.label.value)\n tree.children.each{|x|root << java_tree_to_arrays(x)}\n root\n end",
"def get_tree_height(d,cnt = 0 )\n \n if ( d['l'] == {} && d['r'] == {} )\n @depth = cnt if @depth < cnt\n else\n cnt = cnt + 1\n get_tree_height(d['l'],cnt) if d.key?('l')\n get_tree_height(d['r'],cnt) if d.key?('r')\n end\n \n return @depth\n \nend",
"def level_order_iter(only_vals: true)\n level_order_array = [@root]\n children_queue = [@root.left, @root.right]\n until children_queue.all?(&:nil?)\n # Dequeue the next child\n current_node = children_queue.shift\n next if current_node.nil?\n\n level_order_array << current_node\n # Queue up the left and rode nodes as children\n children_queue << current_node.left unless current_node.left.nil?\n\n children_queue << current_node.right unless current_node.right.nil?\n\n end\n\n # Return array of just the values if only_vals is true.\n only_vals ? level_order_array.map(&:value) : level_order_array\n end",
"def bfs\n\n end",
"def sorted_array\n result = []\n stack = [root]\n until stack.empty?\n current = stack.shift\n result << current.value unless current.value.nil?\n stack << current.left_child unless current.left_child.nil?\n stack << current.right_child unless current.right_child.nil?\n end\n result.sort\n end",
"def level_order\n explored = []\n queue = Queue.new\n explored.push(@root.value)\n queue << @root\n\n until queue.empty? do\n temp = queue.pop\n\n unless temp.left_node.nil? || explored.include?(temp.left_node.value)\n explored.push(temp.left_node.value)\n queue << temp.left_node\n end\n\n unless temp.right_node.nil? || explored.include?(temp.right_node.value)\n explored.push(temp.right_node.value)\n queue << temp.right_node\n end\n end\n\n return explored\n end",
"def levelOrderTraversal(current_node = @root)\n \treturn \"Tree is empty\" if !current_node\n \tlevel = 1\n \tqueue = Array.new\n \tqueue.push current_node\n \tqueue.push '$' # To identify end of level\n \tp \"Level = #{level}\"\n \twhile queue.size != 1\n \t\ttop_element = queue.shift\n \t\tif top_element != '$'\n\t \t\tp top_element.value\n\t \t\tqueue.push top_element.left if top_element.left\n\t \t\tqueue.push top_element.right if top_element.right\n\t \telse\n\t \t\tlevel += 1\n\t \t\tp \"Level = #{level}\"\n\t \t\tqueue.push top_element\n\t \tend\n \tend\n \treturn level\n end",
"def pp_dfs(tree)\n arr = []\n pp_dfs_helper(tree, arr)\n return arr.inspect\n end",
"def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend",
"def elems_in_level(index)\n\treturn (Math.sqrt(2*(index+1)-1)-0.5).to_i + 1\nend",
"def each_with_index\n\t\[email protected]_with_index do |v,i|\n\t\t\tyield v & 0x0F, i * 2 #Bottom Nibble\n\t\t\tyield (v >> 4) & 0x0F, i * 2 + 1#Top Nibble\n\t\tend\n\tend",
"def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend",
"def numberOfTree(op1, op2)\n width = 0;\n height = 0;\n\n File.open(\"input\").each do |line|\n width = (line.to_s.length) - 1\n height += 1\n end\n\n array_input = Array.new();\n\n File.open(\"input\").each do |line|\n i = 0\n nline = line.tr(\"\\n\",\"\").to_s * (1 + (height/(width/op2).to_i))\n #array_input << line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")+ line.tr(\"\\n\",\"\") + line.tr(\"\\n\",\"\")\n array_input << nline\n #puts nline\n end\n\n i = 0\n y = 0\n numberOfTree = Array.new\n while (i < height)\n numberOfTree[i] = array_input[i][y]\n p array_input[i][y]\n y+=op2\n i+=op1\n end\n hp=0\n numberOfTree.each do |p|\n if ( p == \"#\")\n hp +=1\n end\n end\n return hp\nend",
"def traverse_top_right_to_bottom\n num_row = @twod_arr.length\n num_col = @twod_arr[0].length\n top = 0\n bottom = num_row -1\n left = 0\n right = num_col -1\n dir = 0\n\n while top <= bottom && left <= right\n if dir == 0\n for i in top..bottom\n @result << @twod_arr[i][right]\n end\n right -= 1\n dir = 1\n elsif dir == 1\n for i in right.downto(left)\n @result << @twod_arr[bottom][i]\n end\n bottom -= 1\n dir = 2\n elsif dir == 2\n for i in bottom.downto(top)\n @result << @twod_arr[i][left]\n end\n left += 1\n dir = 3\n else\n for i in left..right\n @result << @twod_arr[top][i]\n end\n top += 1\n dir = 0\n end\n end\n @result\n end",
"def get_results(with_root = false)\n ret = []\n\n # Iterate over all occupied descendants and create chain data\n @occupied_descendants.each do |node|\n ret << [node.data, node.get_chain(with_root)]\n end\n\n # Return\n ret\n end"
] | [
"0.6412929",
"0.5843901",
"0.58246225",
"0.58194315",
"0.58133703",
"0.5744274",
"0.57283115",
"0.5682781",
"0.5664568",
"0.5653229",
"0.56401044",
"0.56221324",
"0.5542804",
"0.54595715",
"0.5408077",
"0.53806406",
"0.5379051",
"0.5352988",
"0.5339826",
"0.5332224",
"0.5322872",
"0.52903086",
"0.5273733",
"0.52548844",
"0.5253128",
"0.52529305",
"0.5241666",
"0.52387655",
"0.5217909",
"0.5215525",
"0.5212937",
"0.521026",
"0.5200564",
"0.51886237",
"0.5186583",
"0.5181623",
"0.51645297",
"0.51612025",
"0.51591426",
"0.5157369",
"0.5152429",
"0.5147496",
"0.5147496",
"0.51387936",
"0.51348364",
"0.5124328",
"0.5119989",
"0.5117746",
"0.51042455",
"0.5104015",
"0.50907207",
"0.5080665",
"0.5069989",
"0.5066987",
"0.5061403",
"0.5052213",
"0.504993",
"0.50476444",
"0.5046781",
"0.5035464",
"0.5034072",
"0.50245196",
"0.501867",
"0.5009616",
"0.50047505",
"0.5000491",
"0.49962988",
"0.4993345",
"0.4989638",
"0.4984561",
"0.49835023",
"0.49761483",
"0.4970429",
"0.49604774",
"0.49590695",
"0.49561828",
"0.49475634",
"0.4946189",
"0.49456683",
"0.4942614",
"0.4941617",
"0.4923183",
"0.49229318",
"0.49144164",
"0.49127018",
"0.49094886",
"0.49088955",
"0.49066347",
"0.48960108",
"0.48903",
"0.48875475",
"0.48812374",
"0.4874242",
"0.48723322",
"0.4871669",
"0.48710394",
"0.48650727",
"0.48627836",
"0.48584443",
"0.48572323"
] | 0.5628298 | 11 |
traverse the BBT in depth and returns the data in order in an array | def in_order_traversal(current_node = @root)
@accumulator = []
in_order_traversal_aux(current_node)
@accumulator
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def level_order(root = @root)\n return if root.nil?\n array = []\n queue = []\n queue.unshift(root)\n until queue.empty?\n current = queue.last\n array << current.data\n queue.unshift current.left unless current.left.nil?\n queue.unshift current.right unless current.right.nil?\n queue.pop\n end\n return array\n end",
"def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def _level_order(root, ary=[], lbd)\n ary, q = [], BST::MyQueue.new\n q.enqueue root\n loop do\n break if q.empty?\n node = q.dequeue\n ary << lbd.call(node.val)\n q.enqueue node.lnode if node.lnode \n q.enqueue node.rnode if node.rnode\n end\n ary \n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend",
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end",
"def postorder\n preordred_array = []\n if @root != nil\n postorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def postorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return postorder_helper(current_node, arr)\n end",
"def postorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.postorder(tree_array)\n return tree_array\n end\n end",
"def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend",
"def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end",
"def traverse; end",
"def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end",
"def level_order(root)\n return [] if root.nil?\n queue = [[root, 0]]\n response = []\n until queue.empty?\n # node is the current node, level is the number associated with it\n node, level = queue.pop\n # level acts as a index for the response array\n # if there's no element (array) with that index, we create it\n response[level] ||= []\n # if it exists, we add current node to it\n response[level] << node.val\n # then we add children to queue and increase the level by 1\n queue << [node.right, level + 1] if node.right\n queue << [node.left, level + 1] if node.left\n end\n response\nend",
"def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end",
"def read_btree_node nth\n @last_node_no = nth\n node = read_node(nth)\n @last_btnode = btnode = BTNodeDescriptor.read(node)\n\n arr = BinData::Array.new(:type => :uint16be, :initial_length => btnode.numRecords)\n offsets = arr.read(node[-2*btnode.numRecords..-1])\n\n if btnode.kind == KBTHeaderNode\n header = BTHeaderRec.read(node[14..-1])\n maprec = node[offsets[-3]..-1]\n return KBTHeaderNode, [header, maprec]\n elsif btnode.kind == KBTIndexNode\n# recs = []\n# for i in (0...btnode.numRecords)\n# offset = offsets[btnode.numRecords-i-1]\n# key = @key_class.read(node[offset..-1])\n# offset += 2 + key.keyLength\n# key.childNode\n# end\n elsif btnode.kind == KBTLeafNode\n recs = []\n for i in (0...btnode.numRecords)\n offset = offsets[btnode.numRecords - i - 1]\n key = @key_class.read(node[offset..-1])\n offset += 2 + key.keyLength\n data = @data_class.read(node[offset..-1])\n #\n # [key, data] 이걸 루비 tuple로 어떻게 표현?\n # {key, value}\n #\n recs << [key, data]\n end\n\n return KBTLeafNode, recs\n else\n raise Excention, \"read_btree.node error\"\n end\n end",
"def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend",
"def level_order\n return nil if root.nil?\n\n q = [root] # queue for breath-first traversal\n level_order_array = []\n until q.empty?\n node = q.shift\n q.push(node.left) unless node.left.nil?\n q.push(node.right) unless node.right.nil?\n level_order_array.push(node)\n yield node if block_given?\n end\n level_order_array\n end",
"def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end",
"def postorder\n return [] if @root == nil\n return postorder_helper(@root, [])\n end",
"def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end",
"def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend",
"def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end",
"def traverse_df(node,level,&block)\n @children[node].sort_by {|a| length(a) }.reverse.each { |child| traverse_df(child, level+1, &block) }\n yield node, level if block_given?\n end",
"def bfs\n return [] if @root.nil?\n end",
"def inorder_traverse(current_node = @root)\n inorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n inorder_array += inorder_traverse(current_node.left)\n inorder_array << current_node\n inorder_array += inorder_traverse(current_node.right)\n\n inorder_array\n end",
"def postorder\n if @root == nil\n return []\n else\n return postorder_helper(@root, [])\n end\n end",
"def inorder\n return [] if @root.nil?\n\n nodelets_array = []\n\n inorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def inorder node=@root, &block\n dataArray = []\n dataArray << inorder(node.left,&block) if node.left?\n block_given? ? yield(node) : dataArray << node.data\n dataArray << inorder(node.right,&block) if node.right?\n unless block_given?\n return dataArray.flatten\n end\n end",
"def bst_sequences(root)\n\nend",
"def postorder_traverse(current_node = @root)\n postorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n postorder_array += postorder_traverse(current_node.left)\n postorder_array += postorder_traverse(current_node.right)\n postorder_array << current_node\n\n postorder_array\n end",
"def descendants_bfs(options={})\n desc_nodes = []\n each_level_nodes(options) do |nodes|\n desc_nodes += nodes\n end\n return desc_nodes\n end",
"def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend",
"def traverse index_array\n\t\treturn self if index_array.size == 0\n\t\tchild = index_array.shift\n\t\treturn nil if child > @children.size\n\t\treturn @children[child - 1].traverse(index_array)\n\tend",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def postorder\n return [] if @root.nil?\n result = []\n return postorder_helper(@root, result)\n end",
"def postorder\n postorder_traversal(@root, [])\n end",
"def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end",
"def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end",
"def level_order(root)\n ordered = []\n return ordered unless root\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered << vals\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend",
"def descendents\n respond_to?(:values) ? values.map { |d| d.branch }.flatten : []\n end",
"def postorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return postorder_recursive(current, array)\n end",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def all_children_deep(flag=nil)\n\t\tarr = []\n\t\tall_children(flag).each do |c|\n\t\t\tarr << c\n\t\t\tc.all_children_deep(flag).each do |cc|\n\t\t\t\tarr << cc\n\t\t\tend\n\t\tend\t\t\t\n\t\tarr\n\tend",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def level_order_bottom(root)\n return [] unless root\n \n ordered = nil\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered = ordered ? ([vals] + ordered) : [vals]\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend",
"def inorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def zigzag_level_order(root)\n return [] unless root\n\n zigzag_array = [[root.val]]\n\n traverse(root.left, zigzag_array, 1) && traverse(root.right, zigzag_array, 1)\nend",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend",
"def to_a\n result = []\n fill_result = proc { |node_data| result << node_data }\n in_order_run_callable(@root, fill_result)\n result\n end",
"def in_order_traversal(tree_node = @root, arr = [])\n # left children, itself, right children\n if tree_node.left\n in_order_traversal(tree_node.left, arr)\n end\n\n arr.push(tree_node.value)\n\n if tree_node.right\n in_order_traversal(tree_node.right, arr)\n end\n\n arr\n end",
"def deep_branch_children\n if self.branch?\n arr = []\n children.each do |child|\n if child.branch?\n arr.concat child.deep_branch_children\n end\n end\n arr.push self\n arr\n else\n nil # caller shouldn't be asking for branch children anyway\n end\n end",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def preorder_array(node)\n return if node == nil\n #store visited node data\n @preorder_result << node.data\n preorder_array(node.left)\n preorder_array(node.right)\n end",
"def inorder\n ordered_array = []\n if @root != nil\n inorder_helper(@root, ordered_array)\n end\n return ordered_array\n end",
"def getXMLData( xpathObj) \n @variantArr = Array.new\n @file.xpath(xpathObj).each do |node| \n recursive_child(node) \n if !node.next_sibling.nil? && !node.next_sibling.blank?\n recursive_child(node.next_sibling)\n end \n return @mainArr \n end\n end",
"def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end",
"def expand_breadth(node) #:nodoc:\n cached_relations = []\n\n # 1. yield direct relations first\n relations_for(node).each do |rel|\n yield_node(rel)\n\n # memoize relation for next iteration\n cached_relations << rel unless @description.prune_node?(rel)\n end\n\n # 2. dig deeper\n cached_relations.each do |rel|\n expand_breadth(rel)\n end\n end",
"def tes_gettree\n tree = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree { |b| tree.push b.rev_index }\n }\n tree_d = []\n Accounts.matches_by_account_id(0).to_a.each { |a|\n a.get_tree_debug { |b| tree_d.push b.rev_index }\n }\n\n assert_equal 389, tree.count\n assert_equal 389, tree_d.count\n end",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def level_order_traversal\n nodes_to_visit = []\n visited_nodes = []\n \n nodes_to_visit.push(self)\n \n while !nodes_to_visit.empty?\n node_to_visit = nodes_to_visit.shift\n visited_nodes.push(node_to_visit.root_value)\n\n nodes_to_visit.push(node_to_visit.left) if node_to_visit.left\n nodes_to_visit.push(node_to_visit.right) if node_to_visit.right\n end\n\n visited_nodes\n end",
"def inorder\n tree_data = []\n tree_data = inorder_traverse(@root, tree_data)\n end",
"def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end",
"def level_order_iter(only_vals: true)\n level_order_array = [@root]\n children_queue = [@root.left, @root.right]\n until children_queue.all?(&:nil?)\n # Dequeue the next child\n current_node = children_queue.shift\n next if current_node.nil?\n\n level_order_array << current_node\n # Queue up the left and rode nodes as children\n children_queue << current_node.left unless current_node.left.nil?\n\n children_queue << current_node.right unless current_node.right.nil?\n\n end\n\n # Return array of just the values if only_vals is true.\n only_vals ? level_order_array.map(&:value) : level_order_array\n end",
"def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def to_array\n children.each_with_object( [ self ] ) { |child, memo|\n memo.concat( child.to_array )\n }.flatten\n end",
"def zigzag_level_order(root)\n ordered = []\n return ordered unless root\n queue = [[root]]\n zigzagged = false\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n queue << same_level unless same_level.empty?\n ordered << (zigzagged ? vals.reverse : vals)\n zigzagged = !zigzagged\n end\n\n ordered\nend",
"def bfs_helper(node, list, level)\n return list if node.nil?\n \n # creating array of arrays for each level in tree\n list[level] = [] if list[level].nil?\n list[level] << {key: node.key, value: node.value}\n\n bfs_helper(node.left, list, level + 1)\n bfs_helper(node.right, list, level + 1)\n end",
"def node_to_array(node)\n # Is this too clever?\n # { \"01\" => \"bar\", \"00\" => \"foo\", \"02\" => \"baz\" } # node_to_hash\n # [ [\"01\", \"bar\"], [\"00\", \"foo\"], [\"02\", \"baz\"] ] # to_a\n # [ [\"00\", \"foo\"], [\"01\", \"bar\"], [\"02\", \"baz\"] ] # sort\n # [ \"foo\", \"bar\", \"baz\" ] # map\n node_to_hash(node).to_a.sort.map(&:last)\n end",
"def post_order_traversal(tree=root, ordering=[])\n end",
"def produce_tree(ary); end",
"def traversal\n list_array = []\n curr_node = @head\n while curr_node do\n list_array << curr_node\n curr_node = curr_node.next\n end\n\n list_array\n end",
"def grab_children(father)\n local_list = []\n father.each_pair do |key, value| \n local_list.push(key)\n local_list.push(grab_children(value))\n end\n return local_list\nend",
"def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def traverse(tree_node = nil, arr)\n return [] if tree_node.nil?\n unless tree_node.left.nil?\n arr.push(tree_node.left.value)\n traverse(tree_node.left, arr)\n end\n\n unless tree_node.right.nil?\n arr.push(tree_node.right.value)\n traverse(tree_node.right, arr)\n end\n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def bfs(target_pos) #this is called on the root node \n tar_x, tar_y = target_pos \n\n arr = [self]\n\n until arr.empty?\n current_check = arr.shift \n return current_check if current_check.root_node == target_pos\n arr.concat(current_check.children)\n end\n nil\n end",
"def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end",
"def sorted_array\n result = []\n stack = [root]\n until stack.empty?\n current = stack.shift\n result << current.value unless current.value.nil?\n stack << current.left_child unless current.left_child.nil?\n stack << current.right_child unless current.right_child.nil?\n end\n result.sort\n end",
"def build_tree(arr)\n\tend",
"def bst_sequences(node)\n depth = Hash.new { |h, k| h[k] = [] }\n q = []\n q << node\n\n # use BFS to group nodes by depth\n until q.empty?\n current = q.shift\n depth[current.d] << current.v\n q << current.l if current.l\n q << current.r if current.r\n end\n depth = depth.map { |k, v| depth[k] = v.permutation.to_a }\n # return all the permutations of nodes\n solution = depth.first.first.product(*(depth[1..-1]))\n solution.map!(&:flatten)\nend",
"def level_order_traversal(root_node)\n queue = Queue.new\n queue.enq root_node\n while(!queue.empty?)\n magic_node = queue.deq\n\n puts magic_node.value\n\n queue.enq(magic_node.left) unless magic_node.left.nil?\n\n queue.enq(magic_node.right) unless magic_node.right.nil?\n end \n end",
"def in_order(node = root, array = [])\n return if node.nil?\n\n in_order(node.left, array) # traverse the whole left tree first\n array << node.data # then push the node into the array when it reaches the leaf node\n in_order(node.right, array) # then traverse the whole right tree\n array\n end",
"def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end"
] | [
"0.6668036",
"0.6569204",
"0.6509171",
"0.64585686",
"0.6368126",
"0.63543254",
"0.633515",
"0.6260548",
"0.625961",
"0.62510276",
"0.62374806",
"0.6093633",
"0.60844",
"0.60510457",
"0.6047733",
"0.6037672",
"0.60368687",
"0.60228395",
"0.601307",
"0.6008515",
"0.5998546",
"0.59978884",
"0.5994466",
"0.5991998",
"0.59913695",
"0.5988884",
"0.5975318",
"0.5972353",
"0.596484",
"0.5959259",
"0.5954536",
"0.595395",
"0.5947588",
"0.594603",
"0.59282416",
"0.59273845",
"0.59262437",
"0.5918273",
"0.59163076",
"0.5897199",
"0.5893851",
"0.5858887",
"0.58566463",
"0.5842916",
"0.584097",
"0.5836776",
"0.582801",
"0.5812599",
"0.58036244",
"0.57972074",
"0.5795772",
"0.57914484",
"0.57834166",
"0.57701665",
"0.5759497",
"0.5755357",
"0.5749018",
"0.57434183",
"0.5737395",
"0.57354033",
"0.57268196",
"0.57261044",
"0.5725534",
"0.5723193",
"0.57177186",
"0.57122946",
"0.57045364",
"0.5691988",
"0.5688186",
"0.5685371",
"0.56831443",
"0.56806207",
"0.5676925",
"0.56694824",
"0.56654865",
"0.56626743",
"0.5657714",
"0.5653708",
"0.56501716",
"0.5644007",
"0.56386536",
"0.5632376",
"0.5629315",
"0.56179196",
"0.5615994",
"0.5612761",
"0.5608612",
"0.5606002",
"0.5598832",
"0.55972564",
"0.55950284",
"0.559444",
"0.5593348",
"0.55892414",
"0.5588885",
"0.55824995",
"0.5573104",
"0.55718994",
"0.55665624",
"0.5561708",
"0.55616146"
] | 0.0 | -1 |
Aux function to in order traversal | def in_order_traversal_aux(current_node)
in_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?
@accumulator << current_node.data
in_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traverse; end",
"def in_order_traversal(tree=root, ordering=[])\n end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def traverse(&block)\n\t\t\t\treturn to_enum(:traverse) unless block_given?\n\t\t\t\t\n\t\t\t\ttraverse_recurse(@order-1, 0, 0, self.origin, self.size, &block)\n\t\t\tend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def inorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def in_order_traversal(current_node = @root)\n @accumulator = []\n in_order_traversal_aux(current_node)\n @accumulator\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def inorder_traversal (on_traverse) \n @left_child.inorder_traversal(on_traverse) if @left_child\n on_traverse.call(@key) \n @right_child.inorder_traversal(on_traverse) if @right_child\n end",
"def post_order_traversal(tree=root, ordering=[])\n end",
"def traverse(&block); end",
"def traverse(&block); end",
"def preorder_print(start, traversal)\n traversal\n end",
"def inorder(node)\n inorder node.left_node if node.left_node \n visit node\n build_inorder_traverse_list node\n inorder node.right_node if node.right_node\n end",
"def pre_order_traversal_aux(current_node)\n @accumulator << current_node.data\n pre_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?\n pre_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n\n\n end",
"def inorder\n # raise NotImplementedError\n return inorder_helper(@root, [])\n end",
"def inorder\n inorder_traversal(@root, [])\n end",
"def pre_order_traversal(current_node = @root)\n @accumulator = []\n pre_order_traversal_aux(current_node)\n @accumulator\n end",
"def inorder\n tree_data = []\n tree_data = inorder_traverse(@root, tree_data)\n end",
"def inorder_traverse(node, data)\n return data if node.nil?\n inorder_traverse(node.left_child, data)\n data << node.value\n inorder_traverse(node.right_child, data)\n end",
"def inorder\n inorder_helper(@root, [])\n end",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def in_order_traversal(tree_node, arr = [])\n return arr if tree_node == nil\n\n arr = in_order_traversal(tree_node.right, arr)\n arr << tree_node\n arr = in_order_traversal(tree_node.left, arr)\n\n arr\nend",
"def inOrderTraversal(node = @root)\n return if (node == nil)\n inOrderTraversal(node.left)\n puts node.value.to_s\n inOrderTraversal(node.right)\n end",
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def preorder_traversal(root)\n response = []\n traversal(root, response)\n return response\nend",
"def traversal(way=:post, lbd=@@id_fun)\n self.send(\"_#{way}_order\".to_sym, @root, lbd)\n end",
"def inOrderTraversal( rootNode )\n return if rootNode == nil\n inOrderTraversal( rootNode.leftChild )\n puts rootNode.data\n inOrderTraversal( rootNode.rightChild )\n end",
"def inorder\n return [] if @root.nil?\n result = []\n return inorder_helper(@root, result)\n end",
"def inorder_traverse(current_node = @root)\n inorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n inorder_array += inorder_traverse(current_node.left)\n inorder_array << current_node\n inorder_array += inorder_traverse(current_node.right)\n\n inorder_array\n end",
"def traverse(flag=nil,&op)\n\t\top.call(self)\n\t\tall_children_deep(flag).each do |c|\n\t\t\top.call(c)\n\t\tend\n\tend",
"def inorder\n return [] if @root == nil\n\n current = @root \n tree = []\n \n return inorder_helper(current, tree)\n end",
"def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end",
"def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend",
"def post_order_traversal(current_node = @root)\n @accumulator = []\n post_order_traversal_aux(current_node)\n @accumulator\n end",
"def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend",
"def inorder_iterator\n InorderIterator.new(@root)\n end",
"def traverse\n nodes = [self]\n until nodes.empty?\n node = nodes.pop\n yield node\n nodes += node.children.reverse unless node.children.empty?\n end\n end",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def inorder(root)\n if !root\n return []\n else\n result = []\n traverse = lambda do |node|\n traverse.call(node.left) if node.left\n result.push(node)\n traverse.call(node.right) if node.right\n end\n traverse.call(root)\n result\n end\nend",
"def inorder\n #Return an empty array if our root is nil\n return [] if @root == nil\n #Otherwise, call in reinforcements, and tell them where they can put the results\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_recursion(current = @root, tree = [])\n end",
"def inorder(node)\n if node.left_child\n inorder(node.left_child)\n end\n puts node.value\n if node.right_child\n inorder(node.right_child)\n end\nend",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n preorder_traversal(@root, [])\n end",
"def preorder_traverse node, &block\n block.call(node)\n if node.children.count > 0 then\n node.children.each do |child|\n preorder_traverse(child, &block)\n end\n end\n end",
"def travese_in_order(node = @root)\n return if node == nil\n\n travese_in_order(node.left_child)\n yield node if block_given?\n travese_in_order(node.right_child)\n end",
"def traverse(&block)\n\t\ttraverse(@current_node, &block)\n\tend",
"def inorder_traverse(root=@root)\n unless !root\n result = root.left ? \"#{inorder_traverse(root.left)}\" : \"\"\n result << root.data\n result << inorder_traverse(root.right) unless !root.right\n result\n end\n end",
"def in_order_traversal(root)\n result = []\n\n result << in_order_traversal(root.left) unless root.left.nil?\n result << root.val\n result << in_order_traversal(root.right) unless root.right.nil?\n\n result.flatten\nend",
"def postorder\n postorder_traversal(@root, [])\n end",
"def traverse_sort_and_add_nav_order_to_nodes(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\n\t\t\t node.children.items.each_with_index do |child|\n\t\t\t\t if child.nav_type == \"folder\" || child.nav_type == \"folder+markdown\"\n\t\t\t\t\t items = traverse_sort_and_add_nav_order_to_nodes(child)\n\t\t\t\t\t child.children.items = items if items and items.size > 0\n\t\t\t\t end\n\t\t\t end\n\t\t \n\t\tend\t \n\t\n\t\thas_navig_yml = File.exist?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\n\t\tif has_navig_yml and node.children and node.children.items?\n\t\n\t\telse\n\t\t\treturn nil\t\t\n\t\tend \n\t\n\t\tsorted_nav_items = nil\n\t\n\t\tif node.children? and node.children.items?\n\t\t\tsorted_nav_items = node.children.items\n\t\tend\n\t\n\t\tif File.exists?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\t\t# load aaaa-navigation.yml\n\t\t\tnaml = Map.new(YAML.load_file(\"#{node.source_path}/aaaa-navigation.yml\"))\t\t\n\t\n\t\t\t# iterate and re-order navigation.yml\n\t\t\tsorted_nav_items = node.children.items\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1000\n\t\t\tend\n\n\t\t\tnaml.nav_items.each_with_index do |naml_item, i|\n\t\t\t\tsorted_nav_items.each do |sni| \n\t\t\t\t\tsni.nav_order = i if sni.source == naml_item.source\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tsorted_nav_items.sort! { |x, y| x.nav_order <=> y.nav_order }\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1\n\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\tend\n\t\n\t\tsorted_nav_items\n\tend",
"def inorder\n return [] if @root.nil?\n\n nodelets_array = []\n\n inorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def inorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return inorder_helper(current_node, arr)\n end",
"def traverse(&block)\n @strategy ||= strategy || DEFAULT_TRAVERSE_STRATEGY\n @strategy.traverse(self, &block)\n end",
"def navigation_children\n sorted_children\n end",
"def in_order_traversal(node)\n\n while node\n\n #Left as far as possible\n while(node.left)\n node = node.left\n end\n\n print \"#{node.value} \"\n\n prev = node\n node = node.parent\n\n while node\n if node.left == prev\n print \"#{node.value} \"\n\n if node.right\n node = node.right\n break\n end\n end\n\n prev = node\n node = node.parent\n end\n\n end\nend",
"def traverse\n link = @remaining_links.first\n if link\n @remaining_links.shift\n yield link\n @links[link]\n else\n @father\n end\n end",
"def post_order_traversal_aux(current_node)\n post_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?\n post_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?\n @accumulator << current_node.data\n end",
"def preorder\n preorder_helper(@root, [])\n end",
"def inversed=(_arg0); end",
"def inorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return inorder_recursive(current, array)\n end",
"def inorder_traversal(node=@root)\n return if (node==nil)\n inorder_traversal(node.left)\n puts node.value.to_s\n inorder_traversal(node.right)\n end",
"def traverse_recurse(order, mask, value, origin, size, &block)\n\t\t\t\thalf_size = size.collect{|value| value * 0.5}.freeze\n\t\t\t\tprefix_mask = (1 << order) | mask\n\t\t\t\t\n\t\t\t\t(2**bit_width).times do |prefix|\n\t\t\t\t\t# These both do the same thing, not sure which one is faster:\n\t\t\t\t\tchild_value = (value << @dimensions.count) | prefix\n\t\t\t\t\tprefix = child_value << (order*bit_width)\n\t\t\t\t\t\n\t\t\t\t\tindex = HilbertIndex.from_integral(prefix, bit_width, @order).to_ordinal\n\t\t\t\t\t\n\t\t\t\t\tindex = index & prefix_mask\n\t\t\t\t\t\n\t\t\t\t\tchild_origin = @dimensions.unmap(index.axes).freeze\n\t\t\t\t\t\n\t\t\t\t\t# puts \"yield(#{child_origin}, #{half_size}, #{prefix}, #{order})\"\n\t\t\t\t\t# We avoid calling traverse_recurse simply to hit the callback on the leaf nodes:\n\t\t\t\t\tresult = yield child_origin, half_size, prefix, order\n\t\t\t\t\t\n\t\t\t\t\tif order > 0 and result != :skip\n\t\t\t\t\t\tself.traverse_recurse(order - 1, prefix_mask, child_value, child_origin, half_size, &block)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def inorder_traversal\n enum = Enumerator.new do |yielder|\n recursive_inorder_enum(current_node: @root, yielder: yielder)\n end\n\n if block_given?\n return enum.each { yield }\n else\n return enum\n end\n end",
"def next_in_chain\n @_next_in_chain ||= nil\n @_next_in_chain\n end",
"def inorder\n if @root.nil?\n return []\n end\n return inorder_helper(@root, [])\n end",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def traversal\n list_array = []\n curr_node = @head\n while curr_node do\n list_array << curr_node\n curr_node = curr_node.next\n end\n\n list_array\n end",
"def next\r\n # if the path is empty attempt create the first path element \r\n if @path.empty?\r\n ords = get_data @base\r\n if ords.empty?\r\n # if the base ordering has no related orderings to traverse\r\n # return false \r\n return nil\r\n else\r\n #otherwise create the path element \r\n @path << IteratorPathElement.new(ords[0])\r\n return ords[0] \r\n end \r\n else\r\n # The path is not empty, we have to advance to the next element\r\n cur_elem = @path[-1]\r\n # We use the depth-first algorithm, check whether we can deepen first\r\n ords = get_data(cur_elem.cur_ordering)\r\n unless ords.empty?\r\n # deepen the path\r\n @path << IteratorPathElement.new(ords[0])\r\n return ords[0]\r\n else\r\n # move to next element\r\n \r\n # remove path elements which have enumerated already all their children \r\n until cur_elem.has_more?\r\n @path.pop\r\n if @path.empty?\r\n return nil\r\n end\r\n cur_elem = @path[-1]\r\n end\r\n \r\n #actually move to the next sibling element\r\n return cur_element.next\r\n end\r\n end\r\n end",
"def traverse(parent, &block)\n\n end",
"def inorder(node)\n return if !node\n inorder(node.left_child)\n print node.value, \" \"\n inorder(node.right_child)\n end",
"def inorder\n ordered_array = []\n if @root != nil\n inorder_helper(@root, ordered_array)\n end\n return ordered_array\n end",
"def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end",
"def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend",
"def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end",
"def inorder_traversal(root, values = [])\n if root.left || root.right\n inorder_traversal(root.left, values) if root.left\n values << root.value\n inorder_traversal(root.right, values) if root.right\n else\n values << root.value\n end\n\n values\nend",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def in_order_traversal\n nodes = []\n nodes += @left.in_order_traversal if @left\n nodes.push(@root_value)\n nodes += @right.in_order_traversal if @right\n nodes\n end",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def inorder\n # left -> current node -> right\n return inorder_helper(@root, [])\n end",
"def inorder_trav(node=@root, &block)\n return if node.nil?\n\n inorder_trav(node.left, &block)\n yield node\n inorder_trav(node.right, &block)\n end",
"def deserialize_inorder(list)\n val = list.shift\n return nil if val.nil?\n \n left = Node.new(val)\n right = deserialize_inorder(list[1..-1])\n\n\n \nend",
"def preceding(node); end"
] | [
"0.7623163",
"0.7067999",
"0.6992783",
"0.69893193",
"0.69087136",
"0.68776727",
"0.6839546",
"0.6832996",
"0.66784036",
"0.66678447",
"0.66663486",
"0.6644006",
"0.6644006",
"0.6643007",
"0.6622308",
"0.65833986",
"0.65818155",
"0.65818155",
"0.65818155",
"0.65818155",
"0.65818155",
"0.65818155",
"0.65818155",
"0.65774316",
"0.65584743",
"0.6558246",
"0.65564036",
"0.6540357",
"0.6533109",
"0.65148723",
"0.65130603",
"0.65055156",
"0.64703393",
"0.64540035",
"0.6413769",
"0.64106214",
"0.6405764",
"0.6391928",
"0.63838404",
"0.63671845",
"0.63666314",
"0.6363494",
"0.63509333",
"0.63060534",
"0.62937343",
"0.6283747",
"0.6257186",
"0.62498087",
"0.6247765",
"0.62397236",
"0.62347317",
"0.62180495",
"0.6206471",
"0.61997515",
"0.61997515",
"0.61997515",
"0.61997515",
"0.61997515",
"0.61997515",
"0.61997515",
"0.616072",
"0.6131505",
"0.6123696",
"0.6117168",
"0.6112609",
"0.61067396",
"0.610319",
"0.6090934",
"0.6090015",
"0.6089061",
"0.60876286",
"0.6077941",
"0.6074642",
"0.6074567",
"0.60735905",
"0.60542196",
"0.604209",
"0.60417724",
"0.60398835",
"0.6026762",
"0.600962",
"0.6005359",
"0.6005324",
"0.5999956",
"0.5994715",
"0.598363",
"0.59745586",
"0.59640443",
"0.5938614",
"0.5937613",
"0.59332436",
"0.59216505",
"0.59179056",
"0.590541",
"0.58972335",
"0.5888865",
"0.5887058",
"0.58775234",
"0.58713794",
"0.58697146"
] | 0.64637655 | 33 |
traverse the BBT in depth and returns the data in pre order in an array | def pre_order_traversal(current_node = @root)
@accumulator = []
pre_order_traversal_aux(current_node)
@accumulator
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def preorder_array(node)\n return if node == nil\n #store visited node data\n @preorder_result << node.data\n preorder_array(node.left)\n preorder_array(node.right)\n end",
"def postorder\n preordred_array = []\n if @root != nil\n postorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def level_order(root = @root)\n return if root.nil?\n array = []\n queue = []\n queue.unshift(root)\n until queue.empty?\n current = queue.last\n array << current.data\n queue.unshift current.left unless current.left.nil?\n queue.unshift current.right unless current.right.nil?\n queue.pop\n end\n return array\n end",
"def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end",
"def preorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return preorder_helper(current_node, arr)\n end",
"def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end",
"def preorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.preorder(tree_array)\n return tree_array\n end\n end",
"def pre_order_array(tree)\n output = tree.nil? || tree.data == 0 ? \"\" : tree.data.to_s + \" \"\n left = tree.left.nil? ? \"\" : pre_order_array(tree.left)\n right = tree.right.nil? ? \"\" : pre_order_array(tree.right)\n output + left + right\nend",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def preorder\n return [] if @root.nil?\n result = []\n return preorder_helper(@root, result)\n end",
"def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def preorder_traverse(root=@root)\n unless !root\n result = \"#{root.data}\"\n result << preorder_traverse(root.left) unless !root.left\n result << preorder_traverse(root.right) unless !root.right\n result\n end\n end",
"def postorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return postorder_helper(current_node, arr)\n end",
"def pre_order(root=@root, arr=[])\n return root if root.nil?\n arr << root.value\n pre_order(root.left_child, arr)\n pre_order(root.right_child, arr)\n arr\n end",
"def postorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.postorder(tree_array)\n return tree_array\n end\n end",
"def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end",
"def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end",
"def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend",
"def preorder\n preorder_traversal(@root, [])\n end",
"def preorder\n return [] if @root == nil\n\n current = @root \n tree = []\n \n return preorder_helper(current, tree)\n end",
"def preorder_traversal(root)\n response = []\n traversal(root, response)\n return response\nend",
"def preorder\n if @root.nil?\n return []\n else\n return preorder_helper(@root, [])\n end\n end",
"def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end",
"def pre_order(node = root, array = [])\n return if node.nil?\n\n array << node.data\n pre_order(node.left, array)\n pre_order(node.right, array)\n array\n end",
"def _level_order(root, ary=[], lbd)\n ary, q = [], BST::MyQueue.new\n q.enqueue root\n loop do\n break if q.empty?\n node = q.dequeue\n ary << lbd.call(node.val)\n q.enqueue node.lnode if node.lnode \n q.enqueue node.rnode if node.rnode\n end\n ary \n end",
"def bst_sequences(root)\n\nend",
"def postorder\n return [] if @root == nil\n return postorder_helper(@root, [])\n end",
"def _pre_order(root, ary=[], lbd)\n return ary if root.nil?\n #\n s, h = [], 1 \n s.push [root, h]\n ary = [ h ] if lbd.nil?\n loop do\n break if s.empty?\n node, h = s.pop\n if lbd \n ary << lbd.call(node.val)\n elsif ary.first < h\n ary[0] = h\n end\n s.push [node.rnode, h+1] if node.rnode\n s.push [node.lnode, h+1] if node.lnode\n end\n ary \n end",
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def postorder\n if @root == nil\n return []\n else\n return postorder_helper(@root, [])\n end\n end",
"def preorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return preorder_recursive(current, array)\n end",
"def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end",
"def DFT_pre_order_iterative(root)\n print '[\"I\", \"O\", \"L\", \"A\", \"G\", \"R\", \"H\", \"T\", \"M\"]' + \"\\n\"\n st = Stack.new\n if root == nil\n return\n end\n st.push(root)\n while !st.empty?\n root = st.pop\n print \"#{root.value}\\n\"\n if root.right\n st.push(root.right)\n end\n if root.left\n st.push(root.left)\n end\n end\n end",
"def traverse; end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend",
"def postorder_traverse(current_node = @root)\n postorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n postorder_array += postorder_traverse(current_node.left)\n postorder_array += postorder_traverse(current_node.right)\n postorder_array << current_node\n\n postorder_array\n end",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end",
"def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end",
"def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end",
"def preorder_traversal(root)\n stack = [root]\n result = []\n while stack.any?\n result << stack.pop\n stack.push(result[-1].right) if !result[-1].right.nil?\n stack.push(result[-1].left) if !result[-1].left.nil?\n end\n \n result.map { |x| x.val }\nend",
"def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend",
"def read_btree_node nth\n @last_node_no = nth\n node = read_node(nth)\n @last_btnode = btnode = BTNodeDescriptor.read(node)\n\n arr = BinData::Array.new(:type => :uint16be, :initial_length => btnode.numRecords)\n offsets = arr.read(node[-2*btnode.numRecords..-1])\n\n if btnode.kind == KBTHeaderNode\n header = BTHeaderRec.read(node[14..-1])\n maprec = node[offsets[-3]..-1]\n return KBTHeaderNode, [header, maprec]\n elsif btnode.kind == KBTIndexNode\n# recs = []\n# for i in (0...btnode.numRecords)\n# offset = offsets[btnode.numRecords-i-1]\n# key = @key_class.read(node[offset..-1])\n# offset += 2 + key.keyLength\n# key.childNode\n# end\n elsif btnode.kind == KBTLeafNode\n recs = []\n for i in (0...btnode.numRecords)\n offset = offsets[btnode.numRecords - i - 1]\n key = @key_class.read(node[offset..-1])\n offset += 2 + key.keyLength\n data = @data_class.read(node[offset..-1])\n #\n # [key, data] 이걸 루비 tuple로 어떻게 표현?\n # {key, value}\n #\n recs << [key, data]\n end\n\n return KBTLeafNode, recs\n else\n raise Excention, \"read_btree.node error\"\n end\n end",
"def postorder\n return [] if @root.nil?\n result = []\n return postorder_helper(@root, result)\n end",
"def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end",
"def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end",
"def inorder_traverse(current_node = @root)\n inorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n inorder_array += inorder_traverse(current_node.left)\n inorder_array << current_node\n inorder_array += inorder_traverse(current_node.right)\n\n inorder_array\n end",
"def postorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return postorder_recursive(current, array)\n end",
"def bfs\n return [] if @root.nil?\n end",
"def preOrder(node = root, arr = [])\n return nil unless node.is_a? Node\n arr << node.data\n preOrder(node.left, arr) if !node.left.nil?\n preOrder(node.right, arr) if !node.right.nil?\n arr\n end",
"def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end",
"def postorder\n postorder_traversal(@root, [])\n end",
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def inorder node=@root, &block\n dataArray = []\n dataArray << inorder(node.left,&block) if node.left?\n block_given? ? yield(node) : dataArray << node.data\n dataArray << inorder(node.right,&block) if node.right?\n unless block_given?\n return dataArray.flatten\n end\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder_traversal(root, vals=[])\n # recursive base case\n return [] if root.nil?\n\n # perform the operation on the current node\n vals << root.val\n\n # recursively perform operation on left child\n preorder_traversal(root.left, vals)\n\n # recursively perform operation on left child\n preorder_traversal(root.right, vals)\n\n # to satisfy requirement that initial invocation return array of vals in preorder order\n vals\nend",
"def sequence_hunter(head)\n\tarr_arrs = []\n\t\n\tarr_values = []\n\tarr_values.push(node.value)\n\n\t#nope, giving up after an hour\n\t#basically we need to generate an array of each level\n\t#but good fucking luck\nend",
"def inorder\n return [] if @root.nil?\n\n nodelets_array = []\n\n inorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend",
"def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend",
"def level_order(root)\n return [] if root.nil?\n queue = [[root, 0]]\n response = []\n until queue.empty?\n # node is the current node, level is the number associated with it\n node, level = queue.pop\n # level acts as a index for the response array\n # if there's no element (array) with that index, we create it\n response[level] ||= []\n # if it exists, we add current node to it\n response[level] << node.val\n # then we add children to queue and increase the level by 1\n queue << [node.right, level + 1] if node.right\n queue << [node.left, level + 1] if node.left\n end\n response\nend",
"def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend",
"def preorder(current = @root, array = [])\n # visit the current node\n # traverse the left subtree\n # traverse the right subtree\n return array if current.nil?\n array << { key: current.key, value: current.value }\n preorder(current.left, array)\n preorder(current.right, array) \n end",
"def breadcrumb current\n return [] if current.nil?\n result = Array.new\n result << current\n while current = current.parent\n result << current\n end\n return result.reverse\n end",
"def build_tree_unsorted(array)\n array.each_index{ |index|\n\n }\nend",
"def bst_sequences(node)\n results = []\n\n # Nothing to do, return empty array\n if node.nil?\n results << []\n return results\n end\n\n # Recurse down to begin generating possible subsequences\n left = bst_sequences(node.left)\n right = bst_sequences(node.right)\n\n # Root nodes must come before children nodes, so save the prefix\n prefix = [node.data]\n\n # Each valid sequence of each child must be mixed with the other child\n left.each do |left_sequence|\n right.each do |right_sequence|\n results += mix_sequences(left_sequence, right_sequence, prefix)\n end\n end\n results\nend",
"def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end",
"def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end",
"def expand_breadth(node) #:nodoc:\n cached_relations = []\n\n # 1. yield direct relations first\n relations_for(node).each do |rel|\n yield_node(rel)\n\n # memoize relation for next iteration\n cached_relations << rel unless @description.prune_node?(rel)\n end\n\n # 2. dig deeper\n cached_relations.each do |rel|\n expand_breadth(rel)\n end\n end",
"def produce_tree(ary); end",
"def level_order\n return nil if root.nil?\n\n q = [root] # queue for breath-first traversal\n level_order_array = []\n until q.empty?\n node = q.shift\n q.push(node.left) unless node.left.nil?\n q.push(node.right) unless node.right.nil?\n level_order_array.push(node)\n yield node if block_given?\n end\n level_order_array\n end",
"def to_a #preorder\n @root.to_a\n end",
"def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end",
"def preceding_entries\n return [] if index.zero? # first entry\n\n tree.all_data[0..(index - 1)]\n end"
] | [
"0.6736897",
"0.6625045",
"0.64283854",
"0.64212704",
"0.6389139",
"0.6383696",
"0.63626343",
"0.63306254",
"0.63287085",
"0.629724",
"0.6288771",
"0.6228669",
"0.6201915",
"0.6201731",
"0.6176722",
"0.61671686",
"0.6133982",
"0.6122791",
"0.61184794",
"0.6105733",
"0.6103688",
"0.60726374",
"0.60665846",
"0.6065022",
"0.6046285",
"0.60461676",
"0.60458994",
"0.60362643",
"0.60263807",
"0.6016861",
"0.60141057",
"0.60130334",
"0.59954596",
"0.5995395",
"0.5984095",
"0.5969997",
"0.59664154",
"0.59567213",
"0.595458",
"0.5951326",
"0.5949643",
"0.59448373",
"0.59441227",
"0.592527",
"0.5924779",
"0.5923887",
"0.5916487",
"0.59143007",
"0.59117305",
"0.5903836",
"0.5903504",
"0.5902936",
"0.59007686",
"0.5894282",
"0.5885774",
"0.58809763",
"0.587292",
"0.58723885",
"0.58538634",
"0.58531076",
"0.58321714",
"0.58212656",
"0.58184844",
"0.5816994",
"0.5799904",
"0.5796362",
"0.57883114",
"0.5788097",
"0.5776481",
"0.576616",
"0.57503283",
"0.57469213",
"0.57461643",
"0.57103467",
"0.5705082",
"0.5705082",
"0.5705082",
"0.5705082",
"0.5705082",
"0.5705082",
"0.5705082",
"0.5688868",
"0.56875527",
"0.56724656",
"0.56700164",
"0.56654316",
"0.56354547",
"0.5627507",
"0.5625306",
"0.5624508",
"0.5609341",
"0.5597361",
"0.5593511",
"0.55871344",
"0.5580496",
"0.5574193",
"0.5568053",
"0.55673677",
"0.5565801",
"0.5563465"
] | 0.5580638 | 94 |
Aux function to pre order traversal | def pre_order_traversal_aux(current_node)
@accumulator << current_node.data
pre_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?
pre_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def preorder\n preorder_traversal(@root, [])\n end",
"def pre_order_traversal(current_node = @root)\n @accumulator = []\n pre_order_traversal_aux(current_node)\n @accumulator\n end",
"def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end",
"def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def preorder_traversal(root)\n response = []\n traversal(root, response)\n return response\nend",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n preorder_helper(@root, [])\n end",
"def _pre_order(root, ary=[], lbd)\n return ary if root.nil?\n #\n s, h = [], 1 \n s.push [root, h]\n ary = [ h ] if lbd.nil?\n loop do\n break if s.empty?\n node, h = s.pop\n if lbd \n ary << lbd.call(node.val)\n elsif ary.first < h\n ary[0] = h\n end\n s.push [node.rnode, h+1] if node.rnode\n s.push [node.lnode, h+1] if node.lnode\n end\n ary \n end",
"def post_order_traversal(tree=root, ordering=[])\n end",
"def in_order_traversal(tree=root, ordering=[])\n end",
"def preorder\n return [] if @root.nil?\n result = []\n return preorder_helper(@root, result)\n end",
"def preorder_traverse node, &block\n block.call(node)\n if node.children.count > 0 then\n node.children.each do |child|\n preorder_traverse(child, &block)\n end\n end\n end",
"def preorder_print(start, traversal)\n traversal\n end",
"def preorder\n return [] if @root == nil\n\n current = @root \n tree = []\n \n return preorder_helper(current, tree)\n end",
"def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_recursion(current = @root, tree = [])\n end",
"def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def preorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return preorder_helper(current_node, arr)\n end",
"def preorder(node)\n p node.value if node.value \n preorder(node.left) if node.left\n preorder(node.right) if node.right\nend",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def preorder\n return preorder_helper(@root)\n end",
"def preorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return preorder_recursive(current, array)\n end",
"def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend",
"def pre_order(root=@root, arr=[])\n return root if root.nil?\n arr << root.value\n pre_order(root.left_child, arr)\n pre_order(root.right_child, arr)\n arr\n end",
"def traverse; end",
"def preorder\n yield self\n each do |child|\n unless pre_terminal?\n child.preorder {|c| yield c}\n else\n each {|c| yield c}\n end\n end\n end",
"def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end",
"def preorder_traverse(root=@root)\n unless !root\n result = \"#{root.data}\"\n result << preorder_traverse(root.left) unless !root.left\n result << preorder_traverse(root.right) unless !root.right\n result\n end\n end",
"def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def preorder_traversal(root, vals=[])\n # recursive base case\n return [] if root.nil?\n\n # perform the operation on the current node\n vals << root.val\n\n # recursively perform operation on left child\n preorder_traversal(root.left, vals)\n\n # recursively perform operation on left child\n preorder_traversal(root.right, vals)\n\n # to satisfy requirement that initial invocation return array of vals in preorder order\n vals\nend",
"def each_preorder(proc)\n proc.call(@value1)\n proc.call(@value2) if @type == 3\n @left.each_preorder(proc) if @left\n @mid.each_preorder(proc) if @mid\n @right.each_preorder(proc) if @type == 3 && @right\n end",
"def preorder(&block)\n yield item\n @left_subtree.preorder(&block) if @left_subtree != nil\n @right_subtree.preorder(&block) if @right_subtree != nil\n end",
"def preorder_helper(current_node, list)\n return list if current_node.nil?\n\n list << {key: current_node.key, value: current_node.value}\n preorder_helper(current_node.left, list) if current_node.left\n preorder_helper(current_node.right, list) if current_node.right\n \n return list\n end",
"def preorder\n if @root.nil?\n return []\n else\n return preorder_helper(@root, [])\n end\n end",
"def _pre_order_rec(root, ary=[], lbd)\n if root.nil?\n ary\n else\n ary << lbd.call(root.val)\n _pre_order_rec(root.lnode, ary, lbd)\n _pre_order_rec(root.rnode, ary, lbd)\n end\n end",
"def preorder(node)\n visit node \n left = preorder node.left_node if node.left_node \n right = preorder node.right_node if node.right_node\n p left ? left.value : nil \n p right ? right.value : nil\n p node.value\n puts '----'\n node\n end",
"def preorder_helper(current_node, list)\n if current_node.nil?\n return list \n end\n\n list << {key: current_node.key, value: current_node.value}\n preorder_helper(current_node.left, list)\n preorder_helper(current_node.right, list)\n \n return list\n end",
"def pre_order(node=@root, &block)\n return if node.nil?\n yield node\n in_order(node.left, &block)\n in_order(node.right, &block)\n end",
"def preorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.preorder(tree_array)\n return tree_array\n end\n end",
"def preorder_helper(current_node, list)\n return list if current_node.nil?\n # middle node\n list << { key: current_node.key, value: current_node.value }\n # left side\n preorder_helper(current_node.left, list)\n # right side\n preorder_helper(current_node.right, list)\n \n return list\n end",
"def preorder_traversal(root, values = [])\n current_node = root\n\n if current_node.left || current_node.right\n values << current_node.value\n values = preorder_traversal(current_node.left, values) if current_node.left\n preorder_traversal(current_node.right, values) if current_node.right\n else\n values << current_node.value\n end\n\n values\nend",
"def preorder_traversal(root)\n stack = [root]\n result = []\n while stack.any?\n result << stack.pop\n stack.push(result[-1].right) if !result[-1].right.nil?\n stack.push(result[-1].left) if !result[-1].left.nil?\n end\n \n result.map { |x| x.val }\nend",
"def check_preorder(node, exp)\n exp.map!{|n| [n]}\n\n out = yields(:preorder, node, node)\n assert_equal_yields exp, out\n\n out = yields(:reverse_postorder, node, node)\n exp.reverse!\n assert_equal_yields exp, out\n end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def inorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def preorder_traversal(node=@root)\n return if (node == nil)\n preorder_traversal(node.left)\n preorder_traversal(node.right)\n puts node.value.to_s\n end",
"def preorder(node)\n # 1->2->4->5->3->6\n if node\n print node.value.to_s + '->'\n preorder(node.left_child)\n preorder(node.right_child)\n end\n end",
"def preorder(current_node = root)\n return if current_node.nil?\n print \"#{current_node.value} \"\n inorder(current_node.left)\n inorder(current_node.right)\n end",
"def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend",
"def preorder_helper(current_node, list)\n return list if current_node.nil?\n\n # middle node\n list << { key: current_node.key, value: current_node.value }\n\n # left side\n preorder_helper(current_node.left, list)\n\n # right side\n preorder_helper(current_node.right, list)\n\n return list\n end",
"def inorder\n tree_data = []\n tree_data = inorder_traverse(@root, tree_data)\n end",
"def preorder_helper(node, list) \n if node.nil?\n return list \n end\n\n #push key,value \n list.push({key: node.key, value: node.value})\n preorder_helper(node.left, list)\n preorder_helper(node.right, list)\n end",
"def test_preordered_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j, f, a, d, h, k, z]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n result_array = []\n j.preordered_each { |node| result_array << node.detached_copy}\n\n expected_array.each_index do |i|\n # Match only the names.\n assert_equal(expected_array[i].name, result_array[i].name)\n end\n end",
"def pre_order(node = root, array = [])\n return if node.nil?\n\n array << node.data\n pre_order(node.left, array)\n pre_order(node.right, array)\n array\n end",
"def in_order_traversal(current_node = @root)\n @accumulator = []\n in_order_traversal_aux(current_node)\n @accumulator\n end",
"def preorder_recursion(current, traverse_array)\n return if current.nil?\n\n traverse_array << { key: current.key, value: current.value }\n preorder_recursion(current.left, traverse_array)\n preorder_recursion(current.right, traverse_array)\n end",
"def preOrder(node = root, arr = [])\n return nil unless node.is_a? Node\n arr << node.data\n preOrder(node.left, arr) if !node.left.nil?\n preOrder(node.right, arr) if !node.right.nil?\n arr\n end",
"def pre_order_values(root, order = \"\")\n if root.nil?\n order.concat(\"X\") #placeholder to maintain tree structure\n return\n else\n order.concat(root.val.to_s)\n end\n pre_order_values(root.left, order)\n pre_order_values(root.right, order)\n\n order\nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def preorder(current = @root, out = [])\n return out unless current\n\n out << { key: current.key, value: current.value }\n preorder(current.left, out)\n preorder(current.right, out)\n end",
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def inorder\n return inorder_helper(@root, [])\n end",
"def preOrderTraversal(root)\n return nil if root == nil\n\n stack = [root]\n while !stack.empty?\n node = stack.pop\n print \" #{node.value}\"\n if node.right != nil\n stack.push(node.right)\n end\n if node.left != nil\n stack.push(node.left)\n end\n end\nend",
"def each order=:preorder, &block\n # I know, I know. SGF is only preorder. Well, it's implemented, ain't it?\n # Stop complaining.\n case order\n when :preorder\n preorder @root, &block\n end\n end",
"def inorder\n inorder_traversal(@root, [])\n end",
"def inorder\n #Return an empty array if our root is nil\n return [] if @root == nil\n #Otherwise, call in reinforcements, and tell them where they can put the results\n return inorder_helper(@root, [])\n end",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def inorder\n # raise NotImplementedError\n return inorder_helper(@root, [])\n end",
"def preorder(current = @root, array = [])\n if current == nil\n return array\n else\n array << { key: current.key, value: current.value }\n preorder(current.left, array)\n preorder(current.right, array)\n end\n end",
"def DFT_pre_order_iterative(root)\n print '[\"I\", \"O\", \"L\", \"A\", \"G\", \"R\", \"H\", \"T\", \"M\"]' + \"\\n\"\n st = Stack.new\n if root == nil\n return\n end\n st.push(root)\n while !st.empty?\n root = st.pop\n print \"#{root.value}\\n\"\n if root.right\n st.push(root.right)\n end\n if root.left\n st.push(root.left)\n end\n end\n end",
"def inorder\n inorder_helper(@root, [])\n end",
"def inorder(node)\n inorder node.left_node if node.left_node \n visit node\n build_inorder_traverse_list node\n inorder node.right_node if node.right_node\n end",
"def preorder(current = @root, array = [])\n # visit the current node\n # traverse the left subtree\n # traverse the right subtree\n return array if current.nil?\n array << { key: current.key, value: current.value }\n preorder(current.left, array)\n preorder(current.right, array) \n end",
"def inorder\n return [] if @root.nil?\n result = []\n return inorder_helper(@root, result)\n end",
"def traverse(&block)\n\t\t\t\treturn to_enum(:traverse) unless block_given?\n\t\t\t\t\n\t\t\t\ttraverse_recurse(@order-1, 0, 0, self.origin, self.size, &block)\n\t\t\tend",
"def preorder(root, i)\n return if root.nil?\n @hash[i] = true\n preorder(root.left, i * 2)\n preorder(root.right, i * 2 + 1)\nend",
"def post_order_traversal(current_node = @root)\n @accumulator = []\n post_order_traversal_aux(current_node)\n @accumulator\n end",
"def inorder\n return [] if @root == nil\n\n current = @root \n tree = []\n \n return inorder_helper(current, tree)\n end",
"def preorder_transversal(root)\n\treturn if root.nil?\n\n\tp root.value\n\n\tpreorder_transversal(root.left)\n\tpreorder_transversal(root.right)\nend",
"def preorder(node)\n return if !node\n print node.value, \" \"\n preorder(node.left_child)\n preorder(node.right_child)\n end",
"def inorder(root)\n if !root\n return []\n else\n result = []\n traverse = lambda do |node|\n traverse.call(node.left) if node.left\n result.push(node)\n traverse.call(node.right) if node.right\n end\n traverse.call(root)\n result\n end\nend",
"def preorder(only_vals: true)\n preorder_array = preorder_traverse\n # Return only values or array of node objects.\n only_vals ? preorder_array.map(&:value) : preorder_array\n end",
"def DFT_pre_order_recursive(root)\n if root == nil\n return\n end\n print \"#{root.value}\\n\"\n DFT_pre_order_recursive(root.left)\n DFT_pre_order_recursive(root.right)\n end",
"def inorder_traversal (on_traverse) \n @left_child.inorder_traversal(on_traverse) if @left_child\n on_traverse.call(@key) \n @right_child.inorder_traversal(on_traverse) if @right_child\n end"
] | [
"0.8055941",
"0.7493848",
"0.74795413",
"0.7446758",
"0.7366498",
"0.7343609",
"0.7336576",
"0.73146737",
"0.72807556",
"0.72807556",
"0.72807556",
"0.72807556",
"0.72807556",
"0.72807556",
"0.72807556",
"0.71900535",
"0.7176545",
"0.71700424",
"0.7133009",
"0.7060804",
"0.704656",
"0.7024849",
"0.7022454",
"0.699332",
"0.6976524",
"0.6963923",
"0.69481343",
"0.6935761",
"0.69351524",
"0.6907994",
"0.6898744",
"0.6896634",
"0.68904644",
"0.68890685",
"0.6888822",
"0.68704784",
"0.6862079",
"0.68191653",
"0.68160313",
"0.6800636",
"0.67996365",
"0.6780422",
"0.6768628",
"0.67637163",
"0.6760594",
"0.67581445",
"0.67515475",
"0.6734534",
"0.673224",
"0.6721681",
"0.6694506",
"0.66829926",
"0.6681152",
"0.6666274",
"0.6663865",
"0.66623956",
"0.662984",
"0.6628742",
"0.6618157",
"0.6608476",
"0.6600852",
"0.6595918",
"0.6587676",
"0.65819436",
"0.65719944",
"0.6569623",
"0.6566479",
"0.6565196",
"0.65646344",
"0.6552495",
"0.6528904",
"0.65217465",
"0.65217465",
"0.65217465",
"0.65217465",
"0.65217465",
"0.65217465",
"0.65217465",
"0.651987",
"0.651812",
"0.6503745",
"0.6498153",
"0.6481881",
"0.6477744",
"0.64669716",
"0.6457178",
"0.6456511",
"0.6450651",
"0.6440634",
"0.64401525",
"0.64385456",
"0.64360684",
"0.64145243",
"0.640403",
"0.63989526",
"0.6394726",
"0.6392605",
"0.6386421",
"0.63763654",
"0.6351917"
] | 0.7180809 | 16 |
traverse the BBT in depth and returns the data in post order in an array | def post_order_traversal(current_node = @root)
@accumulator = []
post_order_traversal_aux(current_node)
@accumulator
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def postorder\n preordred_array = []\n if @root != nil\n postorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end",
"def postorder\n return [] if @root == nil\n return postorder_helper(@root, [])\n end",
"def postorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.postorder(tree_array)\n return tree_array\n end\n end",
"def postorder\n if @root == nil\n return []\n else\n return postorder_helper(@root, [])\n end\n end",
"def postorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return postorder_helper(current_node, arr)\n end",
"def postorder_traverse(current_node = @root)\n postorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n postorder_array += postorder_traverse(current_node.left)\n postorder_array += postorder_traverse(current_node.right)\n postorder_array << current_node\n\n postorder_array\n end",
"def postorder\n return [] if @root.nil?\n result = []\n return postorder_helper(@root, result)\n end",
"def test_breadth_each\n j = Tree::TreeNode.new(\"j\")\n f = Tree::TreeNode.new(\"f\")\n k = Tree::TreeNode.new(\"k\")\n a = Tree::TreeNode.new(\"a\")\n d = Tree::TreeNode.new(\"d\")\n h = Tree::TreeNode.new(\"h\")\n z = Tree::TreeNode.new(\"z\")\n\n # The expected order of response\n expected_array = [j,\n f, k,\n a, h, z,\n d]\n\n # Create the following Tree\n # j <-- level 0 (Root)\n # / \\\n # f k <-- level 1\n # / \\ \\\n # a h z <-- level 2\n # \\\n # d <-- level 3\n j << f << a << d\n f << h\n j << k << z\n\n # Create the response\n result_array = Array.new\n j.breadth_each { |node| result_array << node.detached_copy }\n\n expected_array.each_index do |i|\n assert_equal(expected_array[i].name, result_array[i].name) # Match only the names.\n end\n end",
"def postorder\n postorder_traversal(@root, [])\n end",
"def postorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return postorder_recursive(current, array)\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def tree_to_array(node)\n h = height(node)\n tree_arr = []\n (1..h).each do |n|\n tree_arr << node_at_a_level(node, n)\n end\n tree_arr\nend",
"def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end",
"def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend",
"def post_order(root=@root, arr=[])\n return root if root.nil?\n post_order(root.left_child, arr)\n post_order(root.right_child, arr)\n arr << root.value\n arr\n end",
"def post_order_traversal(tree=root, ordering=[])\n end",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end",
"def postorder_traverse(root=@root)\n unless !root\n result = root.left ? \"#{postorder_traverse(root.left)}\" : \"\"\n result << postorder_traverse(root.right) unless !root.right\n result << root.data\n result\n end\n end",
"def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end",
"def traverse; end",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend",
"def deep_branch_children\n if self.branch?\n arr = []\n children.each do |child|\n if child.branch?\n arr.concat child.deep_branch_children\n end\n end\n arr.push self\n arr\n else\n nil # caller shouldn't be asking for branch children anyway\n end\n end",
"def bfs\n return [] if @root.nil?\n end",
"def read_btree_node nth\n @last_node_no = nth\n node = read_node(nth)\n @last_btnode = btnode = BTNodeDescriptor.read(node)\n\n arr = BinData::Array.new(:type => :uint16be, :initial_length => btnode.numRecords)\n offsets = arr.read(node[-2*btnode.numRecords..-1])\n\n if btnode.kind == KBTHeaderNode\n header = BTHeaderRec.read(node[14..-1])\n maprec = node[offsets[-3]..-1]\n return KBTHeaderNode, [header, maprec]\n elsif btnode.kind == KBTIndexNode\n# recs = []\n# for i in (0...btnode.numRecords)\n# offset = offsets[btnode.numRecords-i-1]\n# key = @key_class.read(node[offset..-1])\n# offset += 2 + key.keyLength\n# key.childNode\n# end\n elsif btnode.kind == KBTLeafNode\n recs = []\n for i in (0...btnode.numRecords)\n offset = offsets[btnode.numRecords - i - 1]\n key = @key_class.read(node[offset..-1])\n offset += 2 + key.keyLength\n data = @data_class.read(node[offset..-1])\n #\n # [key, data] 이걸 루비 tuple로 어떻게 표현?\n # {key, value}\n #\n recs << [key, data]\n end\n\n return KBTLeafNode, recs\n else\n raise Excention, \"read_btree.node error\"\n end\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def traverse_postorder(brick=\"root\", &lambdaF)\n raise \"Brick node: #{brick} does not exist can't traverse.\" unless @tree.has_key?(brick)\n\n @tree[brick]['children'].each {|bc| traverse_postorder(bc, &lambdaF) }\n\n # We pass the brick into the closure associated with the function call\n yield(@tree[brick])\n end",
"def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end",
"def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end",
"def _level_order(root, ary=[], lbd)\n ary, q = [], BST::MyQueue.new\n q.enqueue root\n loop do\n break if q.empty?\n node = q.dequeue\n ary << lbd.call(node.val)\n q.enqueue node.lnode if node.lnode \n q.enqueue node.rnode if node.rnode\n end\n ary \n end",
"def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end",
"def level_order(root = @root)\n return if root.nil?\n array = []\n queue = []\n queue.unshift(root)\n until queue.empty?\n current = queue.last\n array << current.data\n queue.unshift current.left unless current.left.nil?\n queue.unshift current.right unless current.right.nil?\n queue.pop\n end\n return array\n end",
"def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end",
"def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end",
"def getXMLData( xpathObj) \n @variantArr = Array.new\n @file.xpath(xpathObj).each do |node| \n recursive_child(node) \n if !node.next_sibling.nil? && !node.next_sibling.blank?\n recursive_child(node.next_sibling)\n end \n return @mainArr \n end\n end",
"def print_children(index)\n\t\tfor i in (0..(@binder_file_tree_array[index].length-1))\n\n\t\t\tnode = @binder_file_tree_array[index][i]\n\n\t\t\t\t@retarray << [\tnode.id.to_s,\n\t\t\t\t\t\t\t\tnode.title,\n\t\t\t\t\t\t\t\tindex,\n\t\t\t\t\t\t\t\tnode.format.to_i,\n\t\t\t\t\t\t\t\tnode.versions]\n\n\t\t\tif @binder_parent_id_array.include? @binder_file_tree_array[index][i].id.to_s\n\t\t\t\t@retarray += print_children(index + 1)\n\t\t\tend\n\t\tend\n\t\treturn @retarray.uniq\n\tend",
"def _post_order(root, ary=[], lbd)\n if root.nil?\n ary\n else\n _post_order(root.lnode, ary, lbd)\n _post_order(root.rnode, ary, lbd)\n ary << lbd.call(root.val)\n end\n end",
"def post_order(node = root, array = [])\n return if node.nil?\n\n post_order(node.left, array)\n post_order(node.right, array)\n array << node.data\n end",
"def get_tag_tree_posts(tag_tree, tags)\n tag_walk = generate_tag_walk(tags)\n if tag_walk.nil?\n return nil\n end\n\n posts = Array.new\n\n # Typical breadth-first search using the\n # existence of a branch in the tag_walk to\n # determine whether a node is traversed.\n\n queue = [tag_tree]\n\n # Consulted with @thatwasawesome for this efficient algorithm.\n while queue.length > 0\n node = queue.shift\n\n # We return every touched node's post, if\n # it has one.\n if node.has_key?(TAG_TREE_POST_KEY)\n posts.push(node[TAG_TREE_POST_KEY])\n end\n\n tag_walk.each do |tag|\n if node.has_key?(tag)\n queue.push(node[tag])\n end\n end\n\n end\n\n return posts\n end",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def traverse index_array\n\t\treturn self if index_array.size == 0\n\t\tchild = index_array.shift\n\t\treturn nil if child > @children.size\n\t\treturn @children[child - 1].traverse(index_array)\n\tend",
"def handle_nodes exp\n exp.each do |node|\n if node.is_a? Array\n @bike.handle_node(node)\n handle_nodes(node)\n end\n end\n end",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end",
"def postorder(current = @root, array = [])\n # traverse the left subtree\n # traverse the right subtree\n # visit the current node\n return array if current.nil?\n postorder(current.left, array)\n postorder(current.right, array)\n array << { key: current.key, value: current.value } \n end",
"def preorder_array(node)\n return if node == nil\n #store visited node data\n @preorder_result << node.data\n preorder_array(node.left)\n preorder_array(node.right)\n end",
"def descendents\n respond_to?(:values) ? values.map { |d| d.branch }.flatten : []\n end",
"def inorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def bfs_helper(node, list, level)\n return list if node.nil?\n \n # creating array of arrays for each level in tree\n list[level] = [] if list[level].nil?\n list[level] << {key: node.key, value: node.value}\n\n bfs_helper(node.left, list, level + 1)\n bfs_helper(node.right, list, level + 1)\n end",
"def preorder_traversal(root)\n response = []\n traversal(root, response)\n return response\nend",
"def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend",
"def preorder_traverse(current_node = @root)\n preorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n preorder_array << current_node\n preorder_array += preorder_traverse(current_node.left)\n preorder_array += preorder_traverse(current_node.right)\n\n preorder_array\n end",
"def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end",
"def inorder_traversal(root)\n #Base: when root is at the end\n return [] if root.nil?\n #Declare empty array\n result = []\n #push recursive call of root.left\n result.concat(inorder_traversal(root.left))\n #push root vale itself\n result << root.val\n #push recursive call of root.right\n result.concat(inorder_traversal(root.right))\n # return result \n result\nend",
"def level_order(root)\n return [] if root.nil?\n queue = [[root, 0]]\n response = []\n until queue.empty?\n # node is the current node, level is the number associated with it\n node, level = queue.pop\n # level acts as a index for the response array\n # if there's no element (array) with that index, we create it\n response[level] ||= []\n # if it exists, we add current node to it\n response[level] << node.val\n # then we add children to queue and increase the level by 1\n queue << [node.right, level + 1] if node.right\n queue << [node.left, level + 1] if node.left\n end\n response\nend",
"def traverse_df(node,level,&block)\n @children[node].sort_by {|a| length(a) }.reverse.each { |child| traverse_df(child, level+1, &block) }\n yield node, level if block_given?\n end",
"def build_tree(arr)\n\tend",
"def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end",
"def postorder\n postorder_helper(@root, [])\n end",
"def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def get_values_for_verification\n \t@intermediate_nodes = self.get_intermediate_nodes\n @array = []\n\n @intermediate_nodes.each do |node|\n @array << node.sha.to_s\n if node.is_right_child\n @array << \"rchild\"\n else\n @array << \"lchild\"\n end\n end\n\n \t@array << Node.get_root_node.sha.to_s\n @array << \"root\"\n\n \treturn @array\n #return @intermediate_nodes\n end",
"def to_a\n collect { |node| node.data }\n end",
"def produce_tree(ary); end",
"def postorder(only_vals: true)\n postorder_array = postorder_traverse\n # Return only values or array of node objects.\n only_vals ? postorder_array.map(&:value) : postorder_array\n end",
"def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end",
"def bfs\n return bfs_helper(@root, [])\n end",
"def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end",
"def optimize_depth_array()\n\n @root = @all_depths[0].first[1]\n\n # for each depth in tree\n @all_depths[1..@all_depths.length-1].each do |depth|\n # for each item in depth (could be node or array of nodes)\n depth.each do |sec_id, item|\n if (item.class == Node)\n node = item\n parent = get_parent(node.path)\n parent.add_child(node)\n else # item is array of nodes\n item.each do |node|\n parent = get_parent(node.path)\n parent.add_child(node)\n end\n end\n end\n end\n\n end",
"def bst_sequences(root)\n\nend",
"def pp_dfs(tree)\n arr = []\n pp_dfs_helper(tree, arr)\n return arr.inspect\n end",
"def dump\n # from collections import deque\n\n bit_array = [1, 0] # [1, 0] indicates the 0th node\n labels = ['']\n indices = []\n\n #dumps by Breadth-first search\n queue = []\n queue.push @tree\n\n until queue.empty?\n node = queue.shift\n labels.push node.value\n # indices.push \n\n bit_array += [1] * node.children.size + [0]\n\n node.children.each do |child|\n child.visited = true\n queue.push child\n end\n end\n [bit_array, labels, indices]\n end",
"def build_transaction_trace_payload(depth = 6)\n root = []\n fanout = depth\n fanout.times do |i|\n node = [\n i * rand(10),\n i * rand(10),\n \"This/Is/The/Name/Of/A/Transaction/Trace/Node/Depth/#{depth}/#{i}\",\n {\n 'sql' => \"SELECT #{(0..100).to_a.join(',')}\"\n },\n []\n ]\n node[-1] = build_transaction_trace_payload(depth - 1) if depth > 0\n root << node\n end\n root\n end",
"def all_children_deep(flag=nil)\n\t\tarr = []\n\t\tall_children(flag).each do |c|\n\t\t\tarr << c\n\t\t\tc.all_children_deep(flag).each do |cc|\n\t\t\t\tarr << cc\n\t\t\tend\n\t\tend\t\t\t\n\t\tarr\n\tend",
"def grab_children(father)\n local_list = []\n father.each_pair do |key, value| \n local_list.push(key)\n local_list.push(grab_children(value))\n end\n return local_list\nend",
"def traverse(tree_node = nil, arr)\n return [] if tree_node.nil?\n unless tree_node.left.nil?\n arr.push(tree_node.left.value)\n traverse(tree_node.left, arr)\n end\n\n unless tree_node.right.nil?\n arr.push(tree_node.right.value)\n traverse(tree_node.right, arr)\n end\n end",
"def descendants_bfs(options={})\n desc_nodes = []\n each_level_nodes(options) do |nodes|\n desc_nodes += nodes\n end\n return desc_nodes\n end",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def to_a #preorder\n @root.to_a\n end",
"def DFT_post_order_iterative(root)\n print '[\"A\", \"G\", \"L\", \"R\", \"O\", \"T\", \"M\", \"H\", \"I\"]' + \"\\n\"\n st1 = Stack.new\n st2 = Stack.new\n\n st1.push(root)\n while !st1.empty?\n root = st1.pop\n st2.push(root)\n if !root.left.nil?\n st1.push(root.left)\n end\n if !root.right.nil?\n st1.push(root.right)\n end\n end\n while !st2.empty?\n print \"#{st2.pop.value}\\n\"\n end\n end",
"def postorder_traversal(root)\n return [] unless root\n node = root\n stack = []\n visited = []\n\n while !stack.empty? || node\n if node\n stack << node\n visited << node.val\n node = node.right\n else\n node = stack.pop.left\n end\n end\n visited.reverse\nend",
"def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend",
"def getTags node\n array = [] #array to hold working collection\n \n node.children.each do |child|\n array << Hash[child.name,child.inner_text] unless child.name == 'text' #text \n end\n \n return array\n end",
"def in_order_traversal(tree_node = @root, arr = [])\n # left children, itself, right children\n if tree_node.left\n in_order_traversal(tree_node.left, arr)\n end\n\n arr.push(tree_node.value)\n\n if tree_node.right\n in_order_traversal(tree_node.right, arr)\n end\n\n arr\n end",
"def to_array\n parents = []\n\n top_array = [self]\n c_arr = top_array\n\n self.class.base_class.each_with_level(descendants.includes(:link => :linkable)) do |menu, level|\n case level <=> parents.count\n when 0 # same level\n # set current array as new sibling array containing menu\n c_arr = [menu] \n\n # and push current array (the new sibling array) to current parent\n parents.last[1] << c_arr \n\n when 1 # descend\n # push a child array if the current level does no thave one\n c_arr << [] if c_arr.length == 1\n \n # and push the sibling array into that array\n c_arr[1] << [menu]\n\n # push the current array to be the current parent\n parents << c_arr\n\n # and reset the current as the new child array\n c_arr = c_arr[1].last\n\n when -1 # ascend\n # pop parents up to the parent of the new menu\n parents.pop while parents.count > level\n\n # and proceed to add new sibling as though level had been 0\n c_arr = [menu]\n parents.last[1] << c_arr\n end\n end\n\n top_array\n end"
] | [
"0.6622121",
"0.6546339",
"0.65049946",
"0.64781773",
"0.6472456",
"0.6360617",
"0.6342862",
"0.6328196",
"0.6315669",
"0.6308888",
"0.63047093",
"0.62743026",
"0.6181229",
"0.6135139",
"0.6069553",
"0.6027046",
"0.6025853",
"0.5942014",
"0.58201873",
"0.58060455",
"0.5804864",
"0.5796053",
"0.57769847",
"0.57682925",
"0.57513416",
"0.5738517",
"0.5730255",
"0.5729598",
"0.5715291",
"0.5691526",
"0.56823176",
"0.56817704",
"0.56817704",
"0.56817704",
"0.56817704",
"0.56817704",
"0.56817704",
"0.56817704",
"0.56817704",
"0.5676751",
"0.5671698",
"0.5662184",
"0.56374764",
"0.5634404",
"0.56296957",
"0.5627193",
"0.5618024",
"0.5603894",
"0.5596399",
"0.5573834",
"0.5566094",
"0.55641484",
"0.55515975",
"0.55506",
"0.554586",
"0.55444217",
"0.55349255",
"0.5520985",
"0.54995364",
"0.5499094",
"0.5497733",
"0.5495527",
"0.54857296",
"0.54726267",
"0.5468348",
"0.54655457",
"0.54582363",
"0.5455064",
"0.54486984",
"0.5441384",
"0.54387325",
"0.5437942",
"0.54304516",
"0.54283184",
"0.5425374",
"0.5424097",
"0.54179895",
"0.54120684",
"0.54117393",
"0.54077715",
"0.5397093",
"0.5395353",
"0.5391047",
"0.5387142",
"0.5378399",
"0.53668535",
"0.53655195",
"0.5356408",
"0.53329855",
"0.5329609",
"0.5326359",
"0.53156537",
"0.53096485",
"0.5308499",
"0.5302987",
"0.5299146",
"0.528899",
"0.5286884",
"0.528551",
"0.52819276"
] | 0.5475283 | 63 |
Aux function to post order traversal | def post_order_traversal_aux(current_node)
post_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?
post_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?
@accumulator << current_node.data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_order_traversal(tree=root, ordering=[])\n end",
"def postorder\n postorder_traversal(@root, [])\n end",
"def post_order_traversal(current_node = @root)\n @accumulator = []\n post_order_traversal_aux(current_node)\n @accumulator\n end",
"def postorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def post_order_traverse(tree, array)\n if !tree.nil?\n post_order_traverse(tree.left, array)\n post_order_traverse(tree.right, array)\n array.append(tree.value)\n end\n \n return array\n\nend",
"def postorder\n return [] if @root == nil\n\n current = @root \n array = []\n \n return postorder_helper(current, array)\n end",
"def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end",
"def postorder(node)\n postorder node.left_node if node.left_node \n postorder node.right_node if node.right_node \n visit node\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n return postorder_helper(@root, [])\n end",
"def postorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return postorder_recursive(current, array)\n end",
"def postorder\n return postorder_recursion(current = @root, tree = [])\n end",
"def postorder\n # left -> right -> root\n return postorder_helper(@root)\n end",
"def postorder_traverse node, &block\n if node.children.count > 0 then\n node.children.each do |child|\n postorder_traverse(child, &block)\n end\n end\n block.call(node)\n end",
"def postorder\n postorder_helper(@root, [])\n end",
"def postorder\n arr = []\n if @root.nil?\n return arr\n end \n current_node = @root\n return postorder_helper(current_node, arr)\n end",
"def traverse; end",
"def postorder_traverse(current_node = @root)\n postorder_array = []\n\n # Base case: reached child of a leaf node (nil)\n return [] if current_node.nil?\n\n postorder_array += postorder_traverse(current_node.left)\n postorder_array += postorder_traverse(current_node.right)\n postorder_array << current_node\n\n postorder_array\n end",
"def postorder\n return [] if @root.nil?\n result = []\n return postorder_helper(@root, result)\n end",
"def postorder\n return [] if @root == nil\n return postorder_helper(@root, [])\n end",
"def postorder\n preordred_array = []\n if @root != nil\n postorder_helper(@root, preordred_array)\n end\n return preordred_array\n end",
"def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end",
"def _post_order(root, ary=[], lbd)\n if root.nil?\n ary\n else\n _post_order(root.lnode, ary, lbd)\n _post_order(root.rnode, ary, lbd)\n ary << lbd.call(root.val)\n end\n end",
"def postorder\n if @root == nil\n return []\n else\n return postorder_helper(@root, [])\n end\n end",
"def postorder\n tree_array = []\n if root.nil?\n return tree_array\n else\n root.postorder(tree_array)\n return tree_array\n end\n end",
"def postorder_helper(node, list)\n if node.nil?\n return list\n end\n\n list << {key: node.key, value: node.value}\n postorder_helper(node.left, list)\n postorder_helper(node.right, list)\n \n end",
"def each_postorder(proc)\n @left.each_postorder(proc) if @left\n @mid.each_postorder(proc) if @mid\n @right.each_postorder(proc) if @type == 3 && @right\n proc.call(@value1)\n proc.call(@value2) if @type == 3\n end",
"def post_order(root=@root, arr=[])\n return root if root.nil?\n post_order(root.left_child, arr)\n post_order(root.right_child, arr)\n arr << root.value\n arr\n end",
"def postorder_traverse(root=@root)\n unless !root\n result = root.left ? \"#{postorder_traverse(root.left)}\" : \"\"\n result << postorder_traverse(root.right) unless !root.right\n result << root.data\n result\n end\n end",
"def postorder_traversal(node=@root)\n return if (node == nil)\n puts node.value.to_s\n postorder_traversal(node.left)\n postorder_traversal(node.right)\n end",
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def postorder(node)\n return if !node\n postorder(node.left_child)\n postorder(node.right_child)\n print node.value, \" \"\n end",
"def postorder(&block)\n @left_subtree.postorder(&block) if @left_subtree != nil\n @right_subtree.postorder(&block) if @right_subtree != nil\n yield item\n end",
"def postorder\n each do |child|\n unless pre_terminal?\n child.postorder {|c| yield c}\n else\n each {|c| yield c}\n end\n end\n yield self\n end",
"def traverse_postorder(brick=\"root\", &lambdaF)\n raise \"Brick node: #{brick} does not exist can't traverse.\" unless @tree.has_key?(brick)\n\n @tree[brick]['children'].each {|bc| traverse_postorder(bc, &lambdaF) }\n\n # We pass the brick into the closure associated with the function call\n yield(@tree[brick])\n end",
"def traversal(way=:post, lbd=@@id_fun)\n self.send(\"_#{way}_order\".to_sym, @root, lbd)\n end",
"def postorder(current = @root, out = [])\n return out unless current\n\n postorder(current.left, out)\n postorder(current.right, out)\n out << { key: current.key, value: current.value }\n end",
"def postorder_recursion(current, traverse_array)\n return if current.nil?\n\n postorder_recursion(current.left, traverse_array)\n postorder_recursion(current.right, traverse_array)\n traverse_array << { key: current.key, value: current.value }\n end",
"def pre_order_traversal_aux(current_node)\n @accumulator << current_node.data\n pre_order_traversal_aux(current_node.left_child) unless current_node.left_child.nil?\n pre_order_traversal_aux(current_node.right_child) unless current_node.right_child.nil?\n end",
"def post_order(node=@root, &block)\n return if node.nil?\n in_order(node.left, &block)\n in_order(node.right, &block)\n yield node\n end",
"def postorder_helper(current_node, list)\n if current_node.nil?\n return list \n end\n \n postorder_helper(current_node.left, list)\n postorder_helper(current_node.right, list)\n list << {key: current_node.key, value: current_node.value}\n \n return list\n end",
"def postorder_helper(current_node, list)\n return list if current_node.nil?\n\n postorder_helper(current_node.left, list) if current_node.left\n postorder_helper(current_node.right, list) if current_node.right\n list << {key: current_node.key, value: current_node.value}\n \n return list\n end",
"def preorder\n # raise NotImplementedError\n return preorder_helper(@root, [])\n end",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def test_traversal_post_2x_each_entry\n expected = [ 1, 4, 7, 6, 3, 12, 14, 10, 8 ].map {|x| x * 2}\n actual = @tree.traversal(:post, ->(x) { x * 2 })\n assert_equal expected,\n actual,\n \"actual: #{actual.inspect} should be #{expected.inspect}\"\n end",
"def postorder_helper(current_node, list = [])\n return list if !current_node\n postorder_helper(current_node.left, list)\n postorder_helper(current_node.right, list)\n list << {key: current_node.key, value: current_node.value}\n return list\n end",
"def traverse(&block)\n\t\t\t\treturn to_enum(:traverse) unless block_given?\n\t\t\t\t\n\t\t\t\ttraverse_recurse(@order-1, 0, 0, self.origin, self.size, &block)\n\t\t\tend",
"def postorder_tree_walk(x)\n unless x.nil?\n postorder_tree_walk(x.left)\n postorder_tree_walk(x.right)\n p x.key\n end\n end",
"def post_order(node = root, array = [])\n return if node.nil?\n\n post_order(node.left, array)\n post_order(node.right, array)\n array << node.data\n end",
"def postorder(current_node = root)\n return if current_node.nil?\n inorder(current_node.left)\n inorder(current_node.right)\n print \"#{current_node.value} \"\n end",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def postOrder(root)\n return nil if root == nil\n\n postOrder(root.left)\n postOrder(root.right)\n print \" #{root.value}\"\nend",
"def postorder(current = @root, array = [])\n # traverse the left subtree\n # traverse the right subtree\n # visit the current node\n return array if current.nil?\n postorder(current.left, array)\n postorder(current.right, array)\n array << { key: current.key, value: current.value } \n end",
"def postorder(current = @root, array = [])\n if current == nil\n return array\n else\n postorder(current.left, array)\n postorder(current.right, array)\n array << { key: current.key, value: current.value }\n end\n end",
"def postorder_helper(current_node, list)\n return list if current_node.nil?\n # left side\n postorder_helper(current_node.left, list)\n # right side\n postorder_helper(current_node.right, list)\n # middle node\n list << { key: current_node.key, value: current_node.value }\n \n return list\n end",
"def help_postorder(current)\n result = []\n return [] if current.nil? \n result += help_postorder(current.left)\n result += help_postorder(current.right)\n result.push({:key=>current.key, :value => current.value})\n return result\n end",
"def preorder\n preorder_traversal(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def preorder\n return preorder_helper(@root, [])\n end",
"def pre_order_traversal(current_node = @root)\n @accumulator = []\n pre_order_traversal_aux(current_node)\n @accumulator\n end",
"def in_order_traversal(tree=root, ordering=[])\n end",
"def postorder_helper(current_node, list)\n return list if current_node.nil?\n\n # left side\n postorder_helper(current_node.left, list)\n\n # right side\n postorder_helper(current_node.right, list)\n\n # middle node\n list << { key: current_node.key, value: current_node.value }\n\n return list\n end",
"def postorder_trav(node=@root, &block)\n return if node.nil?\n\n postorder_trav(node.left, &block)\n postorder_trav(node.right, &block)\n yield node\n end",
"def check_preorder(node, exp)\n exp.map!{|n| [n]}\n\n out = yields(:preorder, node, node)\n assert_equal_yields exp, out\n\n out = yields(:reverse_postorder, node, node)\n exp.reverse!\n assert_equal_yields exp, out\n end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def preorder\n preorder_helper(@root, [])\n end",
"def in_order_traverse(tree, array)\n if !tree.nil?\n in_order_traverse(tree.left, array)\n array.append(tree.value)\n in_order_traverse(tree.right, array)\n end\n return array\n\n\nend",
"def preorder_traversal(root)\n response = []\n traversal(root, response)\n return response\nend",
"def dfs_tree_postorder(start, edges)\n require 'set'\n queue = [[start,nil]]\n visited = Set[start]\n bq = []\n while queue.size > 0\n f = queue.pop\n bq << f\n ts = edges[f[0]].keys.reject{ |t| visited.member?(t) }\n ts.each{ |t| visited << t; queue << [t,f[0]] }\n end\n bq.reverse_each{ |f| yield(*f) }\nend",
"def postorder_lambda_traversal(root)\n values = []\n\n traverse = lambda do |start_node|\n return unless start_node\n traverse.call(start_node.left)\n traverse.call(start_node.right)\n values << start_node.value\n end\n\n traverse.call(root)\n values\nend",
"def DFT_post_order_recursive(root)\n if root == nil\n return\n end\n \n DFT_post_order_recursive(root.left)\n DFT_post_order_recursive(root.right)\n print \"#{root.value}\\n\"\n \n end",
"def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend",
"def postorder(only_vals: true)\n postorder_array = postorder_traverse\n # Return only values or array of node objects.\n only_vals ? postorder_array.map(&:value) : postorder_array\n end",
"def postorder_traversal(root)\n return [] unless root\n node = root\n stack = []\n visited = []\n\n while !stack.empty? || node\n if node\n stack << node\n visited << node.val\n node = node.right\n else\n node = stack.pop.left\n end\n end\n visited.reverse\nend",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def DFT_post_order_iterative(root)\n print '[\"A\", \"G\", \"L\", \"R\", \"O\", \"T\", \"M\", \"H\", \"I\"]' + \"\\n\"\n st1 = Stack.new\n st2 = Stack.new\n\n st1.push(root)\n while !st1.empty?\n root = st1.pop\n st2.push(root)\n if !root.left.nil?\n st1.push(root.left)\n end\n if !root.right.nil?\n st1.push(root.right)\n end\n end\n while !st2.empty?\n print \"#{st2.pop.value}\\n\"\n end\n end",
"def inorder_traversal(root)\n response = []\n traverse(root, response)\n return response\nend",
"def postorder (root = self, array = [])\n postorder(root.left, array) unless root.left.nil?\n postorder(root.right, array) unless root.right.nil?\n array << root.value\n array\n end",
"def postorder(node = root, array = [], &block)\n return nil if root.nil?\n\n postorder(node.left, array, &block) unless node.left.nil?\n postorder(node.right, array, &block) unless node.right.nil?\n yield node if block_given?\n array << node\n end",
"def build_tree_rec(inorder, postorder)\n if inorder.length != 0\n original = postorder.pop\n ind = inorder.index(original)\n root = TreeNode.new(inorder[ind])\n root.right = build_tree(inorder[ind + 1..-1], postorder)\n root.left = build_tree(inorder[0...ind], postorder)\n root\n end\nend",
"def preorder(node)\n p node.value if node.value \n preorder(node.left) if node.left\n preorder(node.right) if node.right\nend",
"def nodes_postorder(node = self.root, &block)\n nodes_postorder(node.left_child, &block) if node.has_left_child?\n nodes_postorder(node.right_child, &block) if node.has_right_child?\n yield( node ) if block_given?\n end",
"def post_order(node, attribute, node_list)\n unless node.nil?\n post_order(node.left, attribute, node_list)\n post_order(node.right, attribute, node_list)\n node_list << (attribute ? node.data.send(attribute) : node.data)\n end\n return node_list\n end",
"def preorder_print(start, traversal)\n traversal\n end",
"def postorder(node = @root, &block)\n return unless node\n\n postorder(node.left, &block)\n postorder(node.right, &block)\n yield node\n end",
"def preorder\n return preorder_helper(@root)\n end",
"def traverse(&block); end",
"def traverse(&block); end"
] | [
"0.7940628",
"0.75571615",
"0.74823767",
"0.74067074",
"0.73935467",
"0.73537165",
"0.7140463",
"0.7047513",
"0.7042344",
"0.69973093",
"0.69973093",
"0.69973093",
"0.69973093",
"0.69973093",
"0.69973093",
"0.69973093",
"0.69973093",
"0.6993667",
"0.6986625",
"0.69726586",
"0.6964269",
"0.6955685",
"0.6954502",
"0.69466585",
"0.6910339",
"0.6909574",
"0.6857544",
"0.6842069",
"0.68402296",
"0.6780735",
"0.67533517",
"0.6747652",
"0.67117876",
"0.66795766",
"0.6621852",
"0.66123205",
"0.6606117",
"0.65994775",
"0.65966696",
"0.6587889",
"0.65573657",
"0.654812",
"0.65464425",
"0.6520283",
"0.650604",
"0.6505411",
"0.6485351",
"0.64752865",
"0.6470485",
"0.64696956",
"0.6428657",
"0.64227885",
"0.6412033",
"0.63977844",
"0.639756",
"0.6387939",
"0.6373369",
"0.63701296",
"0.63569325",
"0.63375217",
"0.6330274",
"0.6324322",
"0.6319418",
"0.63161254",
"0.63153267",
"0.63153267",
"0.63153267",
"0.63153267",
"0.63153267",
"0.63153267",
"0.63153267",
"0.6255919",
"0.6242757",
"0.6238744",
"0.623746",
"0.62035143",
"0.62004256",
"0.6171145",
"0.6165677",
"0.61641306",
"0.616413",
"0.6150345",
"0.6143158",
"0.6137832",
"0.61334825",
"0.6130295",
"0.6105186",
"0.6098196",
"0.60798043",
"0.602439",
"0.6010145",
"0.5994814",
"0.5986451",
"0.59780544",
"0.5973637",
"0.5972586",
"0.5971398",
"0.596043",
"0.5946053",
"0.5946053"
] | 0.6958984 | 21 |
pretty print a BT | def pretty_print(node = @root, prefix = '', is_left = true)
pretty_print(node.right_child, "#{prefix}#{is_left ? '│ ' : ' '}", false) if node.right_child
puts "#{prefix}#{is_left ? '└── ' : '┌── '}#{node.data}"
pretty_print(node.left_child, "#{prefix}#{is_left ? ' ' : '│ '}", true) if node.left_child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_pretty\n to_s(:prettyprint => true)\n end",
"def pretty_print(pp)\n pp.text \"#{task.name}.#{name}\"\n pp.nest(2) do\n pp.breakable\n pp.text \"tracked = #{@tracked}\"\n pp.breakable\n pp.text \"readers = #{@readers.size}\"\n pp.breakable\n pp.text \"filtered = #{(@filter!=nil).to_s}\"\n @connections.each do |connection|\n pp.breakable\n if connection.is_a?(OutputPort::Connection)\n pp.text \"connected to #{connection.port.task.name}.#{connection.port.name} (filtered = #{(connection.filter!=nil).to_s})\"\n end\n if connection.is_a?(OutputPort::CodeBlockConnection)\n pp.text \"connected to code block\"\n end\n end\n end\n end",
"def print()\n puts @node_data.to_s\n end",
"def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)",
"def pretty\n \" Size: #{size} Blocks: #{blocks} IO Block: #{blksize} Type: #{rdev}\\n\"\\\n \"Device: #{dev} Inode: #{ino} Links: #{nlink}\\n\"\\\n \" Mode: #{prettymode}\\n\"\\\n \" Uid: #{uid} Gid: #{gid}\\n\"\\\n \"Access: #{atime}\\n\"\\\n \"Modify: #{mtime}\\n\"\\\n \"Change: #{ctime}\\n\"\n end",
"def printer\n puts \" \" + @bio\n end",
"def dump(depth = 0)\n print ' ' * depth * 2\n print \"// #{self.to_s}\\n\"\n end",
"def show()\n printed = \"IPv4 Tree\\n---------\\n\"\n list4 = dump_children(@v4_root)\n list6 = dump_children(@v6_root)\n\n list4.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc}\\n\"\n end\n\n printed << \"\\n\\nIPv6 Tree\\n---------\\n\" if (list6.length != 0)\n\n list6.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def show()\n printed = \"\"\n list = dump_children(@root)\n\n list.each do |entry|\n cidr = entry[:NetStruct].cidr\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def to_s\n Printer.instance.print(self)\n end",
"def print_wallet\n\t\tputs \"\\n\\n\\n\"\n\t\tputs \"Your balance: #{@balance.round(2)}\"\n\tend",
"def inspect\n self.each_pair do |k, v|\n print \"%-40s\" % k.to_s.yellow unless k == :mbr\n case k\n when :crc, :version then puts \"0x%08x\" % v\n when :mbr\n v.each_pair do |i, j|\n next if i == :reserved\n print \"%-40s\" % i.to_s.yellow unless i == :part\n case i\n when :part\n puts \"Partitions:\".light_blue\n c = 'a'\n j.each do |p|\n break if p.name.empty?\n print \"%-40s\" % p.name.yellow\n puts \"(nand%s) @ 0x%08x [% 5d MB] [0x%08x]\" % [c,\n p.address_low, p.lenlo/2048, p.keydata]\n c.next!\n end\n else\n puts \"#{j}\"\n end\n end\n else\n puts \"#{v}\"\n end\n end\n end",
"def to_s\n print \"[ \"\n\n each do |node|\n print \"#{node.data}\"\n print \", \" unless node.next_node == nil\n end\n\n print \" ]\\n\"\n end",
"def to_s\n print \"[ \"\n\n each do |node|\n print \"#{node.data}\"\n print \", \" unless node.next_node == nil\n end\n\n print \" ]\\n\"\n end",
"def _dump(depth)\n inject(\"\") { |str, node| str << node.dump_node << self.class.node_sep }\n end",
"def print\n node = root\n \n print_node(node, \"> \")\n end",
"def show_balance(header = \"NODE BALANCE\")\n\n puts \"\\n#{header}\"\n puts \"=\" * header.length\n\n @weights.each do |node,providers|\n puts \"#{node}\"\n providers.each do |label,detail|\n printf \" %-12s weight = %2d | serve_mode = %-8s | status = %-4s | address = %s\\n\",\n label, detail['weight'], detail['serve_mode'], detail['status'], detail['address']\n end\n end\n\n puts \"\"\n end",
"def to_s\r\n pretty_output\r\n end",
"def print\n puts to_s\n end",
"def dump(depth = 0)\n attr = ''\n @attr.each do |a| ## self.attributes do |a|\n attr += a.to_s + \", \"\n end if @attr\n attr.chop!\n attr.chop!\n print ' ' * depth * 2\n print \"#{@name}(#{attr})\\n\"\n @children.each do |child|\n child.dump(depth + 1)\n end if @children\n end",
"def print_temp\n print to_string\n end",
"def print_tree\n ''\n end",
"def print\n print_node(@head)\n end",
"def to_text\n (@head.fetch + [''] + @txns.fetch.map(&:to_text)).join(\"\\n\")\n end",
"def print\n str = \"\"\n current = self.head\n while current != nil do\n str = \"#{str}#{current.data}\"\n current = current.next\n if current != nil\n str += \"\\n\"\n end\n end\n puts str\n end",
"def pretty_inspect\n self.inspect\n end",
"def pretty_print(pp)\n pp.text \"Frames: #{available_frames.to_a.sort.join(\", \")}\"\n\n pp.breakable\n pp.text \"Needed Transformations:\"\n transforms = each_transformation.map { |tr| [tr.from, tr.to] }.sort\n if !transforms.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(transforms) do |tr|\n pp.text \"%s => %s\" % tr\n end\n end\n end\n\n pp.breakable\n pp.text \"Frame/Port Associations:\"\n associations = each_annotated_port.map { |port, frame| [port.name, frame] }.sort\n if !associations.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(associations) do |portdef|\n pp.text \"data of %s is in frame %s\" % portdef\n end\n end\n end\n\n pp.breakable\n pp.text \"Transform Inputs and Outputs:\"\n ports = each_transform_port.map { |port, transform| [port.name, transform.from, transform.to] }.sort\n if !ports.empty?\n pp.nest(2) do\n pp.breakable\n pp.seplist(ports) do |portdef|\n pp.text \"%s: %s => %s\" % portdef\n end\n end\n end\n end",
"def generate_print (node)\n\tchild = node.children[0]\n\n\t# string symbol\n\tif child.symbol != nil and child.symbol.type == \"string\"\n\t\t\tputs \"Generating a nice print with a string symbol...\"\n\n\t\tldx(\"02\")\n\t\tldy($static_table.get(child.symbol).address)\n\t\tsys\n\t# normal string\n\telsif child.token != nil and child.token.type == \"T_STRING\" and child.symbol == nil\n\t\t\tputs \"Generating a nice print with a string...\"\n\n\t\taddress = $code.add_string(child.name)\n\t\tlda(hex_converter(address, 2))\n\t\tsta\n\t\tldx(\"02\")\n\t\tldy\n\t\tsys\n\telse\n\t\tputs \"Generating a nice print with a non-string...\"\n\n\t\tgenerate(child)\n\t\tldx(\"01\")\n\t\tsta\n\t\tldy\n\t\tsys\n\t\t\n\tend\n\nend",
"def pretty_print(depth = 0)\n depth.times { STDERR.print ' *' }\n STDERR.print ' '\n STDERR.puts \"#{@name} (#{@id})\"\n @contents.each { |obj| obj.pretty_print(depth + 1) }\n end",
"def to_s\n\t\t puts \"Bank Account:\\t#{name}\\n\"\n\t\t puts \"Your current balance is:\\t#{sprintf(\"%0.2f\", balance)} USD\" \n\tend",
"def fprint(object, depth = 0)\n #puts \"%10s\" % [\"foo\"]\n puts \"%10s\" % [object.to_s]\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n \n pp nds\n puts nds \nend",
"def pretty_text_pokemon(pokemon_ins)\n puts \"#{pokemon_ins.name.capitalize}\\n\"\n print \"Type: #{pokemon_ins.types_array[0].name.capitalize}\" \n print \"/#{pokemon_ins.types_array[1].name.capitalize}\" if pokemon_ins.types_array[1] \n puts \"\"\n puts \"\\n#{pokemon_ins.pokedex_entry}\"\n puts \"\\nHeight: #{(pokemon_ins.height * 3.937).round(2)} in / #{(pokemon_ins.height * 0.1).round(2)} m\"\n puts \"Weight: #{(pokemon_ins.weight / 4.536).round(1)} lb / #{(pokemon_ins.weight * 0.1).round(2)} kg\"\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 to_s\n\t\t puts \"\\nEnding balance:\\nBank Account Name:\\t#{name}\\nBalance:\\t#{balance}\"\n\tend",
"def pretty \n @pretty = true \n end",
"def pretty \n @pretty = true \n end",
"def _dump(depth)\n \"\"\n end",
"def _dump(depth)\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 to_s\r\n dump\r\n end",
"def print\n return nil if @head.nil?\n print_string = \"\"\n current = @head\n print_string.concat(current.data + \"\\n\")\n until current.next.nil?\n current = current.next\n print_string.concat(current.data + \"\\n\")\n end\n puts print_string\n end",
"def print\n placeholder = @head\n list = \"\"\n while placeholder.next\n list += placeholder.data + \"\\n\"\n placeholder = placeholder.next\n end\n list += placeholder.data + \"\\n\" # the plus \"\\n\" added because of the way the spec is written.\n printf list\n end",
"def to_s\n node = @head\n until node.nil?\n print \"#{node.value} -> \" \n node = node.link\n end\n end",
"def dump() end",
"def to_pretty_s\n \"#{type}:#{name} is #{state}\"\n end",
"def print\r\n puts \"------ AlphabetGraph is ------\"\r\n edges = \"\"\r\n @edges.each do |edge|\r\n edges << edge.to_s << \", \"\r\n end\r\n puts \"edges : #{edges}\"\r\n vertices = \"\"\r\n @charNodes.each do |node|\r\n vertices << node.to_s << \", \"\r\n end\r\n puts \"vertices : #{vertices}\"\r\n end",
"def print\n output = \"\"\n current_node = self.head\n\n until current_node.nil?\n output += current_node.data + \"\\n\"\n current_node = current_node.next\n end\n\n puts output\n end",
"def print_tree(out = $stdout)\n out.puts \" #{long_value} -> #{value}\"\n end",
"def pretty_print_nds(nds)\n pp nds\nend",
"def pretty_print_nds(nds)\n pp nds\nend",
"def pretty\n\t\tmacocts = []\n\t\tmac_addr.each_byte { |o| macocts << o }\n\t\tmacocts += [0] * (6 - macocts.size) if macocts.size < 6\n\t\treturn sprintf(\n\t\t\t\t\"#{mac_name}\\n\" +\n\t\t\t\t\"Hardware MAC: %02x:%02x:%02x:%02x:%02x:%02x\\n\" +\n\t\t\t\t\"IP Address : %s\\n\" +\n\t\t\t\t\"Netmask : %s\\n\" +\n\t\t\t\t\"\\n\", \n\t\t\t\tmacocts[0], macocts[1], macocts[2], macocts[3], \n\t\t\t\tmacocts[4], macocts[5], ip, netmask)\n\tend",
"def dump_bytes(label:, data:, per_line: 16, format: '$%02X')\n print \"#{label}:\"\n puts data.each_slice(per_line).map { |line|\n \"\\t.byte \" +\n line.map {|byte| format % byte }.join(',')\n }.join \"\\n\"\n print \"\\n\"\n end",
"def debug(object)\n puts \"<pre>\"\n puts object.pretty_inspect.gsub('<', '<').gsub('>', '>')\n puts \"</pre>\"\nend",
"def print\n output = \"\"\n temp = self.head\n while temp\n output << temp.data << \"\\n\"\n temp = temp.next\n end\n puts output\n end",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n #binding.pry\n pp nds\nend",
"def dump(depth = 0)\n print ' ' * depth * 2\n print \"<?#{@value.inspect}?>\\n\"\n end",
"def pretty(object)\n PP.pp(object, out)\n end",
"def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end",
"def dump(obj, io)\n io.puts obj.send(inspect_method)\n end",
"def print\n retval = \"[\"\n node = self.head\n until node == nil do\n retval += \"#{node.value}\"\n node = node.next\n if node != nil\n retval += \", \"\n end\n end\n retval += \"]\"\n puts retval\n end",
"def to_s()\n prettify()\n end",
"def print_register\n\t\tputs \"#{name}'s Bank Account\"\n\t\tputs \"-\" * 40\n\n\t\t#prints the description and amount of each transaction in the transaction hash.\n\t\t#applies left formatting and right formatting (ljust(x)/rjust(x))\n\t\tputs \"Description\".ljust(30) + \"Amount\".rjust(10)\n\t\[email protected] do |transaction|\n\t\t\tputs transaction[:description].ljust(30) + sprintf(\"%0.2f\", transaction[:amount]).rjust(10)\n\t\tend\n\n\t\t#prints ending balance after all transactions calculated\n\t\tputs \"-\" * 40\n\t\tputs \"Balance:\".ljust(30) + sprintf(\"%0.2f\", balance).rjust(10)\n\t\tputs \"-\" * 40\n\tend",
"def print_register\n puts \"#{name}'s' Bank Account\"\n puts \"/\" * 40\n\n puts \"Description\".ljust(30) + \"Amount\".rjust(10)\n puts \"/\" * 40\n @transactions.each do |transaction|\n puts transaction[:description].ljust(30) + sprintf(\"%0.2f\", transaction[:amount]).rjust(10)\n end\n\n puts \"-\" * 40\n\n puts \"Ending Balance:\".ljust(30) + sprintf(\"%0.2f\", balance).rjust(10)\n puts \"-\" * 40\n end",
"def pretty_print_nds(nds)\n pp nds\n end",
"def pretty_to_s\n left_str = child_to_s(:left)\n right_str = child_to_s(:right)\n \"| \" * self.level + \"#{@feature} = #{@value}:\" + left_str + right_str\n end",
"def pretty_print(pp) # :nodoc:\n if !node_models.empty?\n pp.text \" Node Models\"\n pp.nest(4) do\n pp.breakable\n pp.seplist(node_models.values.sort_by(&:name)) do |t|\n t.pretty_print(pp)\n end\n end\n end\n end",
"def pretty_print\n puts `ruby -r pp -e 'pp(#{@template.inspect})'`\n end",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\npp nds\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n nil\nend",
"def kit_to_console(kit, indent_level=0)\n unless kit.is_a?(Kit)\n raise ArgumentError.new \"Passed a different object into a Kit presenter\"\n end\n\n # Print the first 3 fields before families.\n [:id, :name, :domains].each do |attr| \n indented_puts \"#{attr.to_s}: #{kit.send(attr)}\", indent_level \n end\n\n # Families have to be handled specially.\n indented_puts \"families:\", indent_level\n kit.families.each_with_index do |f, index|\n indented_puts \"family ##{index + 1}:\", indent_level + 1\n font_family_to_console(f, indent_level + 2)\n end\n\n # Print the remaining field.\n indented_puts \"optimize_performance: #{kit.optimize_performance}\", indent_level\n end",
"def printCard\n \"#{@color[0]}#{@fillType[0]}#{@shapeType[0]}#{@numberOfSymbols[0]}\"\n end",
"def pretty_print_me\n sio = PP.pp(self, \"\")\n\n # aber bitte ohne die ids und ohne @\n sio.gsub(/0x[^\\s]*/,'').gsub(/@/,'')\n end",
"def print_tree(out = $stdout)\n out.puts \"### LookupTable: #{name}\"\n out.puts \" Resource: #{resource_id}\"\n out.puts \" Required: #{table_fragment['Required']}\"\n out.puts \" Searchable: #{ table_fragment[\"Searchable\"] }\"\n out.puts \" Units: #{ table_fragment[\"Units\"] }\"\n out.puts \" ShortName: #{ table_fragment[\"ShortName\"] }\"\n out.puts \" LongName: #{ long_name }\"\n out.puts \" StandardName: #{ table_fragment[\"StandardName\"] }\"\n out.puts \"#### Types:\"\n\n lookup_types.each do |lookup_type|\n lookup_type.print_tree(out)\n end\n end",
"def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\nend",
"def pretty_to_s\n left_str = child_to_s(:left)\n right_str = child_to_s(:right)\n \"| \" * self.level + \"#{@feature} <= #{@value} :\" + left_str + \"\\n\" +\n \"| \" * self.level + \"#{@feature} > #{@value} :\" + right_str\n end",
"def display_attributes\n puts\n puts @str.tr(NULL, \"!\")\n bit = 1\n 16.times do |bno|\n line = \"\"\n @str.length.times do |i|\n if (@attrs[i] & bit) == 0\n line << \" \"\n else\n if bno.zero?\n line << \"S\"\n else\n line << (\"%d\" % (bno+1))\n end\n end\n end\n puts(line) unless line =~ /^ *$/\n bit <<= 1\n end\n end",
"def trail_printer(trail_instance)\n trail_instance.print_info\n 15.times {print \"*\"}\n print \"\\n\"\n end",
"def nodes_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name})\\n\"\n end\n string\n end",
"def pretty_print_nds(nds)\n pp nds \n # Change the code below to pretty print the nds with pp\n nil\nend",
"def dump(vt, to: $stderr)\n to.puts \" .\" + ('-' * (vt.cols)) + \".\"\n (1 .. vt.rows).each do |row|\n to.puts \" |#{vt.row_plaintext(row)}|\"\n end\n to.puts \" '\" + ('-' * (vt.cols)) + \"'\"\nend",
"def pretty_print(io = STDOUT, level = 0, indent = ' ')\n io.puts(indent * level + self.to_s)\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 pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds \n \n nil\nend",
"def pretty_print(result)\n result.each_with_index do |line, index|\n puts \"#{index+1}:\\t #{type_to_sym(line[:type])}\\t#{line[:value]}\"\n end\n end",
"def statement\n @printer.print(@transactions)\n end",
"def inspect\n pretty.uncolor\n end",
"def print\n Kernel.print(self)\n end",
"def to_s\n nodes.map do |_key, node|\n node.to_s\n end.join(\"\\n\")\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\npp 'nds'\nend",
"def pretty_print(pp)\n Yadriggy::simpler_pretty_print(pp, self, '@parent')\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n require 'pp' \n pp nds\n nil\nend",
"def to_s\n object_identifier = \"#<#{self.class.to_s}:0x#{'%x' % (self.object_id << 1)}\\n\"\n close_object = \">\\n\"\n \n case self\n when RubyBBCode::BBTree\n object_identifier + \"Children: #{count_child_nodes}\\n\" + self.to_v + close_object\n when RubyBBCode::TagNode # when inspecting TagNodes, it's better not to show the tree display\n if self[:is_tag]\n object_identifier + \"Tag: #{self[:tag].to_s}, Children: #{count_child_nodes}\\n\" + close_object\n else\n object_identifier + '\"' + self[:text].to_s + \"\\\"\\n\" + close_object\n end\n end\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp\nend",
"def to_s\n NodePrinter.new(@root).to_s\n end",
"def pretty_balance\n puts \"You have $#{balance} in the bank\"\n end",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp nds\nend"
] | [
"0.64626485",
"0.6351177",
"0.6222819",
"0.6217678",
"0.61975056",
"0.61331207",
"0.61038876",
"0.6074433",
"0.6007125",
"0.5995448",
"0.59572077",
"0.59484774",
"0.59323484",
"0.59323484",
"0.590655",
"0.59032434",
"0.58905196",
"0.5885599",
"0.5881111",
"0.58686805",
"0.5854779",
"0.58174354",
"0.5812286",
"0.5811957",
"0.5809887",
"0.57818323",
"0.57748455",
"0.5753058",
"0.57483214",
"0.57473975",
"0.5742538",
"0.5723328",
"0.57192504",
"0.5705025",
"0.5691787",
"0.56880486",
"0.56880486",
"0.5679263",
"0.5679263",
"0.5672842",
"0.5669161",
"0.56445706",
"0.5644033",
"0.56434083",
"0.56407446",
"0.56363845",
"0.5624599",
"0.562376",
"0.56158864",
"0.5614255",
"0.5614255",
"0.56058085",
"0.5603817",
"0.5597171",
"0.55948544",
"0.55892503",
"0.5583357",
"0.5581688",
"0.5580236",
"0.557836",
"0.5576339",
"0.55686826",
"0.55575824",
"0.55573815",
"0.5555984",
"0.55559075",
"0.5554343",
"0.5547407",
"0.55470544",
"0.5542905",
"0.5542905",
"0.5542905",
"0.5537866",
"0.5536562",
"0.5528003",
"0.55245167",
"0.55230767",
"0.5512625",
"0.5511651",
"0.55101466",
"0.55079603",
"0.55063796",
"0.5499837",
"0.5494112",
"0.54902655",
"0.5490237",
"0.54821724",
"0.54821724",
"0.54819745",
"0.54816943",
"0.5480298",
"0.5478801",
"0.547439",
"0.54731685",
"0.54693466",
"0.5466004",
"0.5465209",
"0.546491",
"0.5463892",
"0.5459471",
"0.5457833"
] | 0.0 | -1 |
Checks if a BT is balanced | def balanced?
difference_left_right = @root.left_child.depth - @root.right_child.depth
difference_left_right.between?(-1, 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_balanced?\n diff = (self.left.depth - self.right.depth).abs\n if diff <= 1\n true\n else\n false\n end\n end",
"def balances?(tk); end",
"def balanced?\n # tree is balanced if the difference between left and right depths is within 1\n (Tree.depth(root.left) - Tree.depth(root.right)).abs <= 1\n end",
"def balanced?(current_node = root)\n depth(current_node) == -1 ? false : true\n end",
"def balanced?\n left = height(@root.left_node)\n right = height(@root.right_node)\n\n if (left - right).abs <= 1\n return true\n end\n\n return false\n end",
"def balanced?(v) true; end",
"def is_balanced(root)\n # 1) empty trees are balanced.\n return true if root.nil?\n\n # 2) find left and right depth\n left_bal = depth(root.left)\n right_bal = depth(root.right)\n\n #\n (left_bal - right_bal).abs <= 1 &&\n is_balanced(root.left) &&\n is_balanced(root.right)\nend",
"def is_balanced?(tree_node = @root)\n left_depth = depth(tree_node.left)\n right_depth = depth(tree_node.right)\n\n return left_depth == right_depth\n\n end",
"def balanced?\n (height(@root.left) - height(root.right)).between?(-1, 1)\n end",
"def balanced?\n height do |left_height, right_height|\n if (left_height - right_height).abs > 1\n return false\n end\n end\n\n return true\n end",
"def is_balanced(tree, index = 0)\n return true if tree[index].nil? || tree[index] == 0\n (find_height(tree, 2*index + 1) - find_height(tree, 2*index + 2)).abs <= 1 && is_balanced(tree, 2*index + 1) && is_balanced(tree, 2*index +2)\nend",
"def is_balanced_binary_tree?(root)\n is_balanced_rec(root) != -1\nend",
"def is_balanced(root)\n return true if root.nil?\n\n depth_diff = max_depth(root.left) - max_depth(root.right)\n\n return depth_diff.abs <= 1 && is_balanced(root.left) && is_balanced(root.right)\nend",
"def balanced?(node = root)\n return true if node.nil?\n\n left_height = height(node.left)\n right_height = height(node.right)\n\n return true if (left_height - right_height).abs <= 1 && balanced?(node.left) && balanced?(node.right)\n\n false\n end",
"def is_balanced(root)\n return true if root.nil?\n left_height = depth(root.left)\n right_height = depth(root.right)\n result = (left_height - right_height).abs\n return false if result > 1\n return is_balanced(root.left) && is_balanced(root.right)\nend",
"def is_balanced(tree_root)\n depths = [] # we short-circuit as soon as we find more than 2\n \n # we'll treat this array as a stack that will store pairs [node, depth]\n nodes = []\n nodes.push([tree_root, 0])\n \n while !nodes.empty?\n # pop a node and its depth from top of stack\n node, depth = nodes.pop\n \n # case: we found a leaf\n if !node.left && !node.right\n \n # we only care if it's a new depth\n if !depths.include? depth\n depths.push(depth)\n \n # two ways we might now have an unbalanced tree\n # 1. more than 2 different leaf depths\n # 2. 2 leaf depths that are more than 1 apart\n if (depths.length > 2) || \\\n (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n end\n # case: this isn't a leaf - keep stepping down\n else\n if node.left\n nodes.push([node.left, depth + 1])\n end\n if node.right\n nodes.push([node.right, depth + 1])\n end\n end\n end\n return true\n \nend",
"def is_balanced?(tree_node = @root)\n # byebug\n return true if tree_node.nil?\n left_depth = tree_node.left ? depth(tree_node.left) : -1 \n right_depth = tree_node.right ? depth(tree_node.right) : -1\n if ((left_depth - right_depth).abs <=1) && is_balanced?(tree_node.left) && is_balanced?(tree_node.right)\n return true \n end \n false\n end",
"def is_balanced(root)\n Struct.new(\"BalancedStatus\", :balanced, :height)\n check_balanced(root).balanced\nend",
"def balanced?(tree_root)\n return true unless tree_root\n depths = []\n nodes = []\n nodes << [tree_root, 0]\n until nodes.empty?\n node, depth = nodes.pop\n if !node.left && !node.right\n unless depths.include?(depth)\n depths.push(depth)\n if depths.length > 2 || depths.length == 2 && (depths[0] - depths[1]).abs > 1\n return false\n end\n end\n else\n nodes << [node.left, depth + 1] if node.left\n nodes << [node.right, depth + 1] if node.right\n end\n end\n true\nend",
"def test_check_balances_empty\n assert_equal(false, @bv.check_balances?(1))\n end",
"def low_balance?\n balance < low_balance_threshold\n end",
"def is_check_balanced?(job, facility = nil)\n facility ||= job.batch.facility if job\n total_paid_amount = total_paid_amount(facility)\n total_paid_amount -= get_total_payment_of_interest_eob\n balance = (check_amount.to_f.round(2)) - (total_paid_amount.to_f.round(2))\n if balance.zero? || !job.parent_job_id.blank?\n true\n else\n false\n end\n end",
"def balanced?(str)\n balance = 0\n balanced = true\n str.scan(/[\\(\\)]/).each do |para|\n para == '(' ? balance += 1 : balance -= 1\n balanced = false if balance < 0\n end\n balanced = false if balance != 0\n balanced \nend",
"def balanced?(str)\n tracker = 0\n str.chars.each do |elem|\n tracker += 1 if elem == '('\n tracker -= 1 if elem == ')'\n return false if tracker < 0\n end\n tracker.zero?\nend",
"def source_account_has_enough_balance?\n return true if @source_account.blank?\n\n transfer_amount = transaction_params[:amount]\n final_balance = @source_account.current_balance - transfer_amount\n final_balance >= 0\n end",
"def check_balances(num)\n @balance.each do |key, value|\n if value.negative?\n puts \"Line #{@blocks[num].block_number}: Invalid block, address #{key} has #{value} billcoins!\"\n return false\n end\n end\n true\n end",
"def hasEnoughFunds?\n \t puts \"Checking for available MTurk balance...\"\n \t available = @mturk.availableFunds\n \t puts \"Got account balance: %.2f\" % available\n \t return available > 0.055\n \tend",
"def height_balanced(root)\n return true if root.nil?\n\n left, right = root.left, root.right\n left_depth, right_depth = max_depth(left), max_depth(right)\n\n (left_depth - right_depth) <= 1 &&\n height_balanced(left) &&\n height_balanced(right)\nend",
"def bst?(node)\n result = true\n hopefully_sorted = inorder_traversal_node(node)\n hopefully_sorted.each_with_index do |item, index|\n break if hopefully_sorted[index + 1].nil?\n if hopefully_sorted[index] > hopefully_sorted[index + 1]\n return false\n end\n end\n true\nend",
"def superbalanced?(root)\n terminating_levels = []\n\n nodes_to_check = []\n\n nodes_to_check << [root, 0]\n\n until nodes_to_check.empty?\n current_node, current_level = nodes_to_check[0].first, nodes_to_check.shift.last\n\n if current_node.left || current_node.right\n nodes_to_check << [current_node.left, current_level + 1] if current_node.left\n nodes_to_check << [current_node.right, current_level + 1] if current_node.right\n else\n # if we have found a terminating node, then we must check certain things:\n # if the terminating levels already has 2 elements and\n # this terminating node's current level is distinct, then we short circuit and return false\n # else just continue\n # check whether the current level and the element inside has difference greater than 1\n # if yes, then short circuit and return false\n # else, shovel the current level in and continue\n\n if terminating_levels.length == 2\n return false if !terminating_levels.include?(current_level)\n else\n return false if terminating_levels.length == 1 && !(terminating_levels.first - current_level).between?(-1, 1)\n terminating_levels << current_level if terminating_levels.first != current_level\n end\n end\n end\n\n true\nend",
"def can_afford_to_bet?(amount)\n (self.balance >= amount)\n end",
"def super_balanced(tree)\n if !tree\n return true\n end\n \n depths = []\n nodes = []\n nodes.push([tree, 0])\n \n while !nodes.empty?\n node, depth = nodes.pop\n \n if !node.left && !node.right\n if !depths.include? depth\n depths.push(depth)\n \n if (depths.length > 2) || (depths.length == 2 && (depths[0] - depths[1]).abs > 1)\n return false\n end\n \n end\n else\n if node.left\n nodes.push([node.left, depth+1])\n end\n if node.right\n nodes.push([node.right, depth+1])\n end\n end\n end\n \n return true \nend",
"def balanced?(str)\n diff = 0\n str.chars.each do |chr|\n diff += case chr\n when '(' then 1\n when ')' then -1\n else 0\n end\n return false if diff < 0\n end\n diff == 0\nend",
"def greater_balance_than?(other)\n @cleared_balance > other.cleared_balance\n end",
"def balanced?(string)\n parens = 0\n curly_braces = 0\n square_brackets = 0\n single_quotes = 0\n double_quotes = 0\n\n string.each_char do |char|\n parens += 1 if char == '('\n parens -= 1 if char == ')'\n curly_braces += 1 if char == '{'\n curly_braces -= 1 if char == '}'\n square_brackets += 1 if char == '['\n square_brackets -= 1 if char == ']'\n single_quotes += 1 if char == \"'\"\n double_quotes += 1 if char == '\"'\n\n break if (parens < 0 || curly_braces < 0 || square_brackets < 0) \n end\n\n parens.zero? && curly_braces.zero? && square_brackets.zero? && single_quotes.even?\\\n && double_quotes.even?\n\nend",
"def payment_outstanding?\n balance > BigDecimal(0)\n end",
"def full?\n bike_count >= capacity\n end",
"def greater_balance_than?(other)\r\n\t\t@cleared_balance > other.cleared_balance\r\n\tend",
"def backer?\n bounties.count > 0\n end",
"def check_balance\n return @balance\n end",
"def valid? \n balance > 0 && status == 'open'\n end",
"def balanced?(string)\n brackets = 0\n string.chars.each do |char|\n brackets += 1 if char == '('\n brackets -= 1 if char == ')'\n break if brackets < 0\n end\n brackets == 0 ? true : false\nend",
"def balanced?(text)\n parens = 0\n text.each_char do |char|\n parens += 1 if char == '('\n parens -= 1 if char == ')'\n\n break if parens == -1\n end\n\n parens.zero?\nend",
"def check_items_balances\n details.select(&:marked_for_destruction?)\n .all?(&:valid_for_destruction?)\n end",
"def startup_has_balance?\n AccountTransaction.sufficient_funds?(self.startup.account, self.total_price)\n end",
"def balanced_num(number)\n number = number.digits\n if number.length % 2 == 0\n first_half = number[0, number.length/2 - 1]\n else\n first_half = number[0, number.length/2]\n end\n\n second_half = number[number.length/2 + 1, number.length]\n\n first_half.sum == second_half.sum ? \"Balanced\" : \"Not Balanced\"\nend",
"def valid?\n balance > 0 && status == \"open\"\n end",
"def balanced?(str)\n open_count, close_count = [0, 0]\n str.chars.each do |char|\n open_count += 1 if char == '('\n close_count += 1 if char == ')'\n break if close_count > open_count\n end\n open_count == close_count ? true: false \nend",
"def balance?\n to_model.balance > 0\n end",
"def isBalanced(s)\n puts \"\"\n puts \"Initial Array: #{s}\"\n puts \"\"\n \n # sting to array \n print\n s_array = s.chars\n # elemen count\n\n # ele_count = []\n # s.chars.each do |var, i|\n # p i\n # p var\n # # ele_count[i].include?( ) ? ele_count << var\n # end\n\n left = 0\n right = 0\n left_squared = 0\n right_squared = 0\n left_curly = 0\n right_curly = 0\n\n\n \"s_array size: #{s_array.size} \"\n \"s_array 1/2 : #{s_array.size / 2} \"\n\n bytes_array = []\n\n s_array.each do |char|\n case char\n when \"(\"\n left += 1\n bytes_array << 40\n when \")\"\n right += 1\n bytes_array << 41\n when \"[\"\n left_squared += 1\n bytes_array << 91\n when \"]\"\n right_squared += 1\n bytes_array << 93\n when \"{\"\n left_curly += 1\n bytes_array << 123\n else\n right_curly += 1\n bytes_array << 125\n end\n end\n \"( #{left}\"\n \") #{right}\"\n \"[ #{left_squared}\"\n \"] #{right_squared}\"\n \"{ #{left_curly}\"\n \"} #{right_curly}\"\n\n bytes_array\n\n diff = left - right\n diff_squared = left_squared - right_squared\n diff_curly = left_curly - right_curly\n\n # the number of each of the elements is balanced\n condition1 = diff == 0 && diff_squared == 0 && diff_curly == 0\n condition1\n\n if condition1\n \"the number of elements is balanced? || for each open there is a close ? : YES\"\n \"is the opening and closing balanced ?\"\n else\n \"the number of elements is NOT balanced \"\n end\n\n puts \"first half: #{s_arriba = s_array.slice(0, s_array.size / 2)}\"\n puts \"first half bytes : #{bytes_array1 = bytes_array.slice(0, s_array.size / 2)}\"\n\n # how to check if the position is balanced ?\n\n puts \"second half #{s_abajo = s_array.slice((s_array.size / 2), s_array.size).reverse}\"\n puts \"second half bytes : #{bytes_array2 = bytes_array.slice((bytes_array.size / 2), bytes_array.size).reverse}\"\n\n bytes_array1\n bytes_array2\n\n pos_balanced = 0\n igual = [81, 184, 248]\n ((bytes_array.size) / 2).times do |i|\n pos_comparison = bytes_array1[i] + bytes_array2[i]\n\n if igual.include?(pos_comparison)\n pos_balanced = pos_balanced + 0\n else\n pos_balanced = pos_balanced + 1\n end\n end\n pos_balanced == 0 ? condition2 = true : condition2 = false\n\n if condition1 && condition2\n puts \"YES\"\n else\n puts \"YES\"\n end\nend",
"def balanced?(str)\n count = 0\n str.chars.each do |c|\n count += 1 if c == '('\n count -= 1 if c == ')'\n return false if count == -1\n end\n count == 0\nend",
"def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end",
"def valid?\n @balance > 0 && @status == \"open\"\n end",
"def bt_safe?\n @bt_safe\n end",
"def balanced?(str)\n opening = 0\n closing = 0\n str.chars.each do |char|\n opening += 1 if char == '('\n closing += 1 if char == ')'\n return false if closing > opening\n end\n closing == opening\nend",
"def exceed_top_up?(amount, balance)\n (balance += amount) > MAX_TOP_UP\n end",
"def balanced?(str)\n paren_num = 0\n str.each_char do |char|\n paren_num += 1 if char == '('\n paren_num -= 1 if char == ')'\n return false if paren_num < 0\n end\n paren_num == 0\nend",
"def balanced?(string)\n parens = 0\n string.each_char do |char|\n parens += 1 if char =~ /[({\\[\\\"\\']/\n parens -= 1 if char =~ /[)}\\]\\\"\\']/\n break if parens < 0\n end\n\n parens.zero?\nend",
"def balanced?(string)\n string.gsub!(/[^\\(\\)]/, '')\n total = 0\n string.chars.each do |paranthese|\n if paranthese == '('\n total += 1\n elsif paranthese == ')'\n total -= 1\n end\n return false if total < 0\n end\n total == 0\nend",
"def balanced?(string)\n parens = 0\n string.each_char do |char|\n parens += 1 if char == '('\n parens -= 0 if char == ')'\n break if parens < 0\n end\n\n parens.zero?\nend",
"def balanced?(string)\n count = 0\n string.each_char do |char|\n count += 1 if char == '('\n count -= 1 if char == ')'\n break if count < 0\n end\n\n count.zero?\nend",
"def balanced?(str)\n arr = str.chars.select { |char| char == '(' || char == ')' }\n return false if arr.first == ')' || arr.last == '('\n return true if arr.count('(') == arr.count(')')\n false\nend",
"def balanced?(string)\n parens = 0\n string.each_char do |char|\n parens += 1 if char == '('\n parens -= 1 if char == ')'\n break if parens < 0\n end\n\n parens.zero?\nend",
"def balanced?(string)\n parens = 0\n string.each_char do |char|\n parens += 1 if char == '('\n parens -= 1 if char == ')'\n break if parens < 0\n end\n\n parens.zero?\nend",
"def valid?\n @status == 'open' && @balance > 0\n end",
"def hasEnoughFunds?\n available = @mturk.availableFunds\n puts \"Got account balance: %.2f\" % available\n return available > 0.055\nend",
"def balanced?(string)\n open_parens = string.count('(')\n closed_parens = string.count(')')\n first_open = string.index('(')\n first_closed = string.index(')')\n last_open = string.reverse.index('(')\n last_closed = string.reverse.index(')')\n\n if open_parens == closed_parens &&\n (first_open == first_closed || first_open < first_closed) &&\n (last_open == last_closed || last_open > last_closed)\n return true\n else\n return false\n end\nend",
"def balanced?(str)\n return false if str.count('(') != str.count(')')\n \n idx = 0\n str.chars.each do |char|\n if char == '('\n idx += 1\n elsif char == ')'\n idx -= 1\n end\n break if idx < 0\n end\n idx == 0 ? true : false\nend",
"def balanced?(string)\n open_counter = 0\n \n string.chars.each do |char|\n return false if open_counter < 0\n\n case char\n when '(' then open_counter += 1\n when ')' then open_counter -= 1\n end\n\n end\n\n open_counter == 0\nend",
"def balanced?(string)\n counter = 0\n string.each_char do |char|\n counter += 1 if char == '('\n counter -= 1 if char == ')'\n break if counter < 0\n end\n counter == 0\nend",
"def on_balance? balance_type\n return !@off_balance_timer.values.find{|v| v} if balance_type == :all\n !@off_balance_timer[balance_type]\n end",
"def balanced?(string)\n first_found = string.match(/[(|)]/).to_s\n if first_found == ')'\n return false\n end\n left = string.count('(')\n right = string.count(')')\n last_left_index = string.rindex('(')\n last_right_index = string.rindex(')')\n if last_left_index != nil && last_right_index != nil\n if last_left_index > last_right_index\n return false\n end\n end\n\n if left == right\n return true\n else\n return false\n end\nend",
"def balanced?(string)\n counter = 0\n string.each_char do |char|\n counter += 1 if char == '('\n counter -= 1 if char == ')'\n return false if counter < 0\n end\n\n counter == 0\nend",
"def balanced?(string)\n paren_counter = 0\n string.chars.each do |element|\n return false if paren_counter < 0 \n paren_counter += 1 if element == '('\n paren_counter -= 1 if element == ')'\n end\n return true if paren_counter == 0\n false\nend",
"def had_funds?\n balance_at = self.get_address.balance(self.currency_id, before_time: self.tx_date)\n balance_at >= amount\n end",
"def balanced?(string)\n counter = 0\n\n string.each_char do |char|\n if counter < 0\n return false\n elsif char == \"(\"\n counter += 1\n elsif char == \")\"\n counter -= 1\n end\n end\n\n counter == 0 \n\nend",
"def balanced?(string)\n parens = 0\n curly = 0\n brackets = 0\n string.each_char do |char|\n parens += 1 if char == '('\n parens -= 1 if char == ')'\n curly += 1 if char == '{'\n curly -= 1 if char == '}'\n brackets += 1 if char == '['\n brackets -= 1 if char == ']'\n break if parens < 0 || curly\n end\n\n parens.zero?\nend",
"def balances?(tk)\n unless [TkALIAS, TkDEF].include?(@last_ns_tk.class) || @before_last_ns_tk.class == TkALIAS\n if [TkLPAREN, TkLBRACK, TkLBRACE, TkDO, TkBEGIN].include?(tk.class)\n @level += 1\n elsif OPEN_BLOCK_TOKENS.include?(tk.class)\n @level += 1 unless tk.class == TkELSIF\n elsif [TkRPAREN, TkRBRACK, TkRBRACE, TkEND].include?(tk.class) && @level > 0\n @level -= 1\n end\n end\n\n @level == 0\n end",
"def balanced?(string)\n parens_order = []\n string.chars.each do |char|\n parens_order << char if ['(', ')'].include?(char)\n return false if parens_order.count(\")\") > parens_order.count(\"(\")\n end\n\n parens_order.count(\"(\") != parens_order.count(\")\") ? false : true\nend",
"def valid?\n if @status == \"open\" && @balance > 0\n return true\n else\n return false\n end\n end",
"def balanced?(string)\n counter = 0\n string.chars do |char|\n counter += 1 if char == '('\n counter -=1 if char == ')'\n if counter < 0\n return false\n end \n end \n counter.zero?\nend",
"def can_deliver?(cur, amount)\n amount > 0.01 && amount <= available_balance(cur)\n end",
"def balanced?(str)\n pars = str.chars.select { |char| ['(', ')'].include?(char) }\n pars.length.even? && pars.index('(') < pars.index(')')\nend",
"def balanced?(str)\n stack = []\n str.chars.each do |char|\n if char == ')' && stack.empty?\n return false\n elsif char == '('\n stack << char\n elsif stack.include?('(') && char == ')'\n stack.pop\n end\n end\n stack.empty?\nend",
"def balanced?(str)\n #str.count(')') == str.count('(')\n array = str.chars\n\n count = 0\n array.each do |char|\n count += 1 if char == '('\n count -= 1 if char == ')'\n end\n return false if count < 0\n end",
"def balanced?(str)\n parens = 0\n str.chars.each do |char|\n if char == \"(\" && parens >=0\n parens +=1\n end\n if char == \")\"\n parens -=1\n end\n end\n parens == 0\nend",
"def can_balance(list)\n i = 0\n list.each do |a|\n left = 0\n right = 0\n i2 = 0\n list.each do |b|\n if i2 <= i\n left += b\n else\n right += b\n end\n i2 += 1\n if left == right\n return true\n end\n end\n i += 1\n end\n return false\nend",
"def balanced?(string)\n parentheses = string.chars.select do |char|\n char == \"(\" || char == \")\"\n end\n \n p_first_half = parentheses[0..parentheses.size/2.0-1]\n p_sec_half = parentheses[parentheses.size/2.0.ceil..parentheses.size-1]\n if parentheses.size.odd? || parentheses[0] == \")\"\n return false\n else\n p_first_half.reverse.join(\"\").gsub(/[()]/, \"(\" => \")\", \")\" => \"(\") == p_sec_half.join(\"\")\n end \nend",
"def balanced(string)\n # hashes to track braces\n close_to_open = {'}' => '{', ')' => '(', ']' => '['}\n open_to_close = {'{' => '}', '(' => ')', '[' => ']'}\n # brace stack\n stack = Stack.new\n\n string.each_char do |c| # this automatically iterates in order i think\n if open_to_close[c]\n stack.push(c)\n elsif close_to_open[c]\n get_top = stack.pop\n return false if close_to_open[c] != get_top # must match brace\n end \n end\n\n return stack.empty?\nend",
"def valid?\n if status != \"open\" || balance == 0\n false\n else\n true\n end\n end",
"def balanced?(str)\n left_count = 0\n right_count = 0\n\n str.each_char do |char|\n left_count += 1 if char == '('\n right_count += 1 if char == ')'\n return false if left_count < right_count # can also break\n end\n \n left_count == right_count\nend",
"def bastard?\n end",
"def is_a_winner?(bid_amount)\n bid_amount >= self.minimal_allowed_bid\n end",
"def test_check_balances_false\n @bv.balances[\"Joe\"] = 90\n @bv.balances[\"John\"] = -25\n assert_equal(false, @bv.check_balances?(1))\n end",
"def funds_available?\n if self.num_shares * Stock.find(self.stock_id).quote > Account.find_by(investor_id: self.investor_id).balance\n self.status = \"canceled\"\n self.bought_sold = \"Funds to execute trade were unavailable.\"\n puts \"Your account does not have the funds available to execute this trade.\"\n return false\n else\n true\n end\n end",
"def balanced?(str)\n parentheses = ['(', ')']\n paren_ary = str.chars.select {|char| char if parentheses.include?(char)}\n index = 0\n loop do\n break if index == paren_ary.size\n # paren_ary.each do |char|\n p paren_ary\n if paren_ary[index] == '('\n if paren_ary.include?(')')\n paren_ary.slice!(paren_ary.index(')'))\n paren_ary.slice!(paren_ary.index('('))\n else\n return false\n end\n else\n return false\n end\n end\n paren_ary.empty? #|| paren_ary == parentheses\nend",
"def valid?\n @status == \"open\" && @balance > 0 \n end",
"def balance_adequate_for_transaction?(amount)\n if self.satisfaction_rating > amount\n return true\n else\n return false\n end\n end",
"def btc_arrived?\n item = read\n item['active'] && item['active'] == 2\n end",
"def bst?(node)\n min = -Float::INFINITY\n traverse_in_order(node) do |n|\n return false if n.val < min\n\n min = n.val\n end\n true\nend"
] | [
"0.7397917",
"0.7177619",
"0.716193",
"0.7135442",
"0.7102492",
"0.7034965",
"0.70281976",
"0.7004631",
"0.6984082",
"0.6981011",
"0.6910093",
"0.69051784",
"0.6878196",
"0.6853529",
"0.67641383",
"0.6749212",
"0.67465234",
"0.6678913",
"0.659758",
"0.64845747",
"0.6467659",
"0.6388583",
"0.6335909",
"0.6297462",
"0.6245087",
"0.62435454",
"0.61948866",
"0.61777705",
"0.6142499",
"0.61217606",
"0.609615",
"0.60878336",
"0.6084326",
"0.6027356",
"0.5994971",
"0.5987303",
"0.59769636",
"0.59735763",
"0.5969131",
"0.5954438",
"0.5944193",
"0.5929478",
"0.5928177",
"0.59141827",
"0.5911096",
"0.590932",
"0.58950603",
"0.5888338",
"0.5883607",
"0.5880776",
"0.5866713",
"0.58666664",
"0.58661324",
"0.5863254",
"0.58492154",
"0.58487546",
"0.5839985",
"0.5829981",
"0.5825131",
"0.58237",
"0.58201736",
"0.5818643",
"0.5816967",
"0.5816967",
"0.58156514",
"0.58139604",
"0.5807313",
"0.58052105",
"0.57906693",
"0.5785134",
"0.5777268",
"0.5774556",
"0.57660633",
"0.5765651",
"0.57577634",
"0.5752552",
"0.5735196",
"0.5727631",
"0.5721728",
"0.57129014",
"0.57128894",
"0.5711148",
"0.5699439",
"0.5698997",
"0.5693143",
"0.5690612",
"0.56872994",
"0.56632537",
"0.56621325",
"0.5657716",
"0.56300294",
"0.5624582",
"0.5616666",
"0.5610749",
"0.56106156",
"0.56047255",
"0.5604366",
"0.55945486",
"0.55735576",
"0.5572865"
] | 0.694673 | 10 |
Consumes a BT an returns a BBT | def rebalance
@root = build_tree(self.level_order_traversal) if !self.balanced?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bt\n @queue << \"bt\"\n end",
"def bsb_test\n bsb = BSB.new\n bsb.read(\"!Copyright 1999, Maptech Inc. All Rights Reserved.\nCRR/CERTIFICATE OF AUTHENTICITY\n This electronic chart was produced under the authority of the National\n Oceanic and Atmospheric Administration (NOAA). NOAA is the hydrographic\n office for the United States of America. The digital data provided by NOAA\n from which this electronic chart was produced has been certified by NOAA\n for navigation. 'NOAA' and the NOAA emblem are registered trademarks of\n the National Oceanic and Atmospheric Administration. 'Maptech' and the\n Maptech emblem are registered trademarks of Maptech, Inc. Copyright 1999\n Maptech, Inc. All rights reserved.\nCHT/NA=CHESAPEAKE BAY ENTRANCE,NU=12221\nCHF/COASTAL\nCED/SE=70,RE=01,ED=09/12/1998\nNTM/NE=70.00,ND=10/30/1999,BF=ON,BD=10/26/1999\nVER/3.0\nCHK/1,558\nCGD/5\nORG/USA-NOAA/NOS\nMFR/MAPTECH\nRGN/4,6\nK01/NA=CHESAPEAKE BAY ENTRANCE,NU=558,TY=BASE,FN=12221_1.KAP\")\n \n puts bsb\nend",
"def read_btree_node nth\n @last_node_no = nth\n node = read_node(nth)\n @last_btnode = btnode = BTNodeDescriptor.read(node)\n\n arr = BinData::Array.new(:type => :uint16be, :initial_length => btnode.numRecords)\n offsets = arr.read(node[-2*btnode.numRecords..-1])\n\n if btnode.kind == KBTHeaderNode\n header = BTHeaderRec.read(node[14..-1])\n maprec = node[offsets[-3]..-1]\n return KBTHeaderNode, [header, maprec]\n elsif btnode.kind == KBTIndexNode\n# recs = []\n# for i in (0...btnode.numRecords)\n# offset = offsets[btnode.numRecords-i-1]\n# key = @key_class.read(node[offset..-1])\n# offset += 2 + key.keyLength\n# key.childNode\n# end\n elsif btnode.kind == KBTLeafNode\n recs = []\n for i in (0...btnode.numRecords)\n offset = offsets[btnode.numRecords - i - 1]\n key = @key_class.read(node[offset..-1])\n offset += 2 + key.keyLength\n data = @data_class.read(node[offset..-1])\n #\n # [key, data] 이걸 루비 tuple로 어떻게 표현?\n # {key, value}\n #\n recs << [key, data]\n end\n\n return KBTLeafNode, recs\n else\n raise Excention, \"read_btree.node error\"\n end\n end",
"def event( id, msg, t, content)\n\n if msg == 'order2' \\\n && content['url'] == 'http://data.bter.com/api/1/depth/btsx_btc'\n begin\n orderbook = content['data']\n\n orderbook['bids'] = orderbook['bids'].sort { |a,b| b[0] <=> a[0] } # largest value first\n orderbook['asks'] = orderbook['asks'].sort { |a,b| a[0] <=> b[0] } # smallest value first\n\n# top_bid = orderbook['bids'].first[0]\n top_ask = orderbook['asks'].first[0]\n\n\n\n bids_sum = sum_book( orderbook['bids'])\n asks_sum = sum_book( orderbook['asks'])\n total_sum = bids_sum + asks_sum\n\n bids = myfunction( orderbook['bids'], total_sum )\n asks = myfunction( orderbook['asks'], total_sum )\n\n bids_percent = bids_sum / total_sum * 100 # of total book, not asks\n\n #puts \"bid_sum #{bid_sum}, ask_sum #{ask_sum}\"\n\n# puts \"top_bid #{top_bid} top_ask #{top_ask} \"\n## puts \"\\n\\n\"\n#\n elt = {\n 'id' => @count,\n 'time' => t,\n\n 'ask_30' => asks[:price_30],\n 'ask_10' => asks[:price_10],\n 'top_ask' => asks[:price_0],\n 'top_bid' => bids[:price_0],\n 'bid_10' => bids[:price_10],\n 'bid_30' => bids[:price_30],\n 'bids_percent' => bids_percent\n }\n\n #puts elt\n\n @model_['data'] << elt\n\n @count += 1\n rescue\n @log.info( \"Failed to decode orderbook error: #{$!}\" )\n end\n end\n end",
"def create\n @bluetooth = Bluetooth.new(params[:bluetooth])\n\n respond_to do |format|\n if @bluetooth.save\n format.html { redirect_to @bluetooth, :notice => 'Bluetooth was successfully created.' }\n format.json { render :json => @bluetooth, :status => :created, :location => @bluetooth }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @bluetooth.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send_and_receive\n url = to_s\n raw_response = HTTPClient.new.get(url).body\n parsed_response = BEncode::Parser.new(StringIO.new(raw_response))\n parsed_response.parse!\n end",
"def read_ber(syntax = nil)\n # TODO: clean this up so it works properly with partial packets coming\n # from streams that don't block when we ask for more data (like\n # StringIOs). At it is, this can throw TypeErrors and other nasties.\n\n id = getbyte or return nil # don't trash this value, we'll use it later\n content_length = read_ber_length\n\n yield id, content_length if block_given?\n\n if -1 == content_length\n raise Net::BER::BerError, \"Indeterminite BER content length not implemented.\"\n else\n data = read(content_length)\n end\n\n parse_ber_object(syntax, id, data)\n end",
"def get_b\n n = self.get_i32\n OSC::Blob.new(self.get_data(n))\n end",
"def insert_hwb\n type = OrderType.find_by_name(\"hwb\")\n \n res = RResponse.new\n\n Order.transaction do\n begin\n data = params[\"order\"]\n\n # hack created by for now\n data[\"created_by\"] = current_user.account\n data[\"order_type_id\"] = type.id\n \n \n data[\"bill_number\"] = (params[\"is_quote\"] == 'false') ? type.generate_bill_number(self.get_config_param(:hwb_offset)) : nil\n \n data[\"dim_factor\"] = 194\n \n if (params[\"multiple_pickup\"] != nil && params[\"multiple_pickup\"] == \"on\") \n data[\"pickup_locations\"] = JSON::parse(params[\"locations\"])\n end\n \n # read bill_to bill_third_party checkbox: if on, bill third-party. otherwise, bill shipper.\n if (params[\"bill_third_party\"].nil? || params[\"bill_third_party\"] != 'on')\n data[\"bill_to_id\"] = params[\"shipper\"][\"company_id\"]\n end\n \n ##############################################################################################\n # HACK order[billing_method_id] -- might need this in order since it's defined company-wide\n ##############################################################################################\n data[\"billing_method_id\"] = 1\n ##############################################################################################\n \n # super can handle it from here...\n order = Order.create(data)\n\n # get OrderTypeEntity list\n entities = order.type.entities(:include => [:domain])\n entities.each do |e|\n if (e.name != 'consignee' || (e.name == 'consignee' && params[\"has_consignee\"] != nil && params[\"has_consignee\"] == 'on') )\n data = params[e.name]\n data[:order_id] = order.id\n data[:order_type_entity_id] = e.id\n oe = OrderEntity.create(data)\n end\n end\n \n # apply markup & fuel_surcharge from order's bill_to to the order.\n types = SystemRevenuType.find(:all)\n revenus = SystemRevenu.find(:all)\n revenus.each do |sr|\n \n field = order.bill_to.domain.fields.find_by_name(sr.name) \n raise RException.new(\"Create HWB -- Could not locate company's revenu-field '#{sr.name}'\") if field.nil?\n \n # first get default value \n value = field.config[:value] \n \n # if the bill_to company has this Revenu field explicitly defined, apply that instead.\n if (!order.bill_to.domain_values.nil? && !order.bill_to.domain_values[field.id].nil?)\n value = order.bill_to.domain_values[field.id] \n end \n \n # apply insurance only if declared_value was defined\n if (sr.name != 'insurance' || !order.declared_value.nil?)\n # apply multiplier type to insurance only -- all other revenus (markup, fuel-surcharge) get percentage\n type = (sr.name != 'insurance') ? types.find { |t| (t.name == 'percentage') ? true : false} : types.find { |t| (t.name == 'multiplier') ? true : false} \n OrderRevenu.create(\n :order_id => order.id,\n :system_revenu_id => sr.id,\n :system_revenu_type_id => type.id,\n :value => value,\n :config => field.config #<-- this column contains Ext.form.Field config\n ) \n end \n end\n # log order-creation\n OrderLog.create(\n :order_id => order.id,\n :account_id => current_user.account.id,\n :order_log_type_id => OrderLogType.find_by_name('status').id,\n :subject => 'Order created',\n :msg => 'New ' + type.name\n )\n res.data[:order] = {\n :id => order.id,\n :bill_number => order.bill_number\n }\n res.success = true\n res.msg = 'Created order #' + order.bill_number.to_s\n end \n end\n\n respond(res)\n end",
"def btInfoHash\n result = nil\n @params['xt'].each do |topic|\n if topic =~ /urn:btih:(.*)/\n hash = $1\n if hash.length == 40\n # Hex-encoded info hash. Convert to binary.\n result = [hash].pack \"H*\" \n else\n # Base32 encoded\n result = Base32.decode hash\n end\n break\n end\n end\n result\n end",
"def get_balance(address, tag: 'latest')\n validate_address(address)\n validate_block_tag(tag)\n\n resp = conn.post do |req|\n req.headers['Content-Type'] = 'application/json'\n req.body = json_rpc(method: 'eth_getBalance', params: [address, tag]).to_json\n end\n resp_body = JSON.parse(resp.body)\n\n if resp_body['error']\n raise InfuraCallError.new(\n \"Error (#{resp_body['error']['code']}): Infura API call \"\\\n \"eth_getBalance gave message: '#{resp_body['error']['message']}'\"\n )\n else\n wei_amount_hex_string = resp_body['result']\n wei_amount_hex_string.to_i(16)\n end\n end",
"def smb_cmd_trans2(c, buff)\n smb = @state[c]\n pkt = CONST::SMB_TRANS2_PKT.make_struct\n pkt.from_s(buff)\n\n data_trans2 = CONST::SMB_DATA_TRANS2.make_struct\n data_trans2.from_s(pkt['Payload'].v['SetupData'])\n\n sub_command = data_trans2.v['SubCommand']\n parameters = data_trans2.v['Parameters'].gsub(/^[\\x00]*/, '') #delete padding\n\n case sub_command\n when CONST::TRANS2_QUERY_FILE_INFO\n return smb_cmd_trans2_query_file_information(c, parameters)\n when CONST::TRANS2_QUERY_PATH_INFO\n return smb_cmd_trans2_query_path_information(c, parameters)\n when CONST::TRANS2_FIND_FIRST2\n return smb_cmd_trans2_find_first2(c, parameters)\n else\n vprint_status(\"SMB Share - #{smb[:ip]} Unknown SMB_COM_TRANSACTION2 subcommand: #{sub_command.to_s(16)}\")\n return smb_error(CONST::SMB_COM_TRANSACTION2, c, CONST::SMB_NT_STATUS_NOT_FOUND, true)\n end\n end",
"def make_butterfly symbol, expiry, right, *strikes\n raise 'No Connection!' unless @ib && @ib.connected?\n\n legs = strikes.zip([1, -2, 1]).map do |strike, weight|\n # Create contract\n contract = IB::Option.new :symbol => symbol,\n :expiry => expiry,\n :right => right,\n :strike => strike\n # Find out contract's con_id\n @ib.clear_received :ContractData, :ContractDataEnd\n @ib.send_message :RequestContractData, :id => strike, :contract => contract\n @ib.wait_for :ContractDataEnd, 3\n con_id = @ib.received[:ContractData].last.contract.con_id\n\n # Create Comboleg from con_id and weight\n IB::ComboLeg.new :con_id => con_id, :weight => weight\n end\n\n # Create new Combo contract\n IB::Bag.new :symbol => symbol,\n :currency => \"USD\", # Only US options in combo Contracts\n :exchange => \"SMART\",\n :legs => legs\n end",
"def b_rdt_send message\n puts 'B Sending Data Unreliably...'\n packet = Packet.new\n packet.payload = message.data\n b_udt_send packet\nend",
"def to_xmlbif\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!\n xml.comment! <<-EOS\n \n Bayesian network in XMLBIF v0.3 (BayesNet Interchange Format)\n Produced by SBN (Simple Bayesian Network library)\n Output created #{Time.now}\n EOS\n xml.text! \"\\n\"\n xml.comment! \"DTD for the XMLBIF 0.3 format\"\n xml.declare! :DOCTYPE, :bif do\n xml.declare! :ELEMENT, :bif, :\"(network)*\"\n xml.declare! :ATTLIST, :bif, :version, :CDATA, :\"#REQUIRED\"\n xml.declare! :ELEMENT, :\"network (name, (property | variable | definition)*)\"\n xml.declare! :ELEMENT, :name, :\"(#PCDATA)\"\n xml.declare! :ELEMENT, :\"variable (name, (outcome | property)*)\"\n xml.declare! :ATTLIST, :\"variable type (nature | decision | utility) \\\"nature\\\"\"\n xml.declare! :ELEMENT, :outcome, :\"(#PCDATA)\"\n xml.declare! :ELEMENT, :definition, :\"(for | given | table | property)*\"\n xml.declare! :ELEMENT, :for, :\"(#PCDATA)\"\n xml.declare! :ELEMENT, :given, :\"(#PCDATA)\"\n xml.declare! :ELEMENT, :table, :\"(#PCDATA)\"\n xml.declare! :ELEMENT, :property, :\"(#PCDATA)\"\n end\n xml.bif :version => 0.3 do\n xml.network do\n xml.name(@name.to_s)\n xml.text! \"\\n\"\n xml.comment! \"Variables\"\n @variables.each {|name, variable| variable.to_xmlbif_variable(xml) }\n xml.text! \"\\n\"\n xml.comment! \"Probability distributions\"\n @variables.each {|name, variable| variable.to_xmlbif_definition(xml) }\n end\n end\n end",
"def br!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n type = BR\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 349:7: 'br'\n match( \"br\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n end",
"def push(b)\n \n timeNow = Time.now\n \n if (@time - timeNow) > @tio\n @state = :idle \n end\n \n @time = timeNow\n \n case @state\n when :idle\n \n if b == Frame::FRAME_CHAR\n @state = :fsize_b1\n @rx = \"\"\n @info = \"\"\n end\n \n when :fsize_b1\n \n checksum_init\n checksum_next(b)\n @rx << b\n \n if (b & 0xf0) != 0xa0\n \n if b != FRAME::FRAME_CHAR\n\n log_error \"first byte of frame is invalid\"\n @state = :start_frame;\n \n end\n \n else\n \n @frame_size = ( (b & 0x7) << 8 )\n @segment = ( ((b & 0x8) == 0x8) ? true : false )\n @state = :fsize_b2\n \n end\n \n when :fsize_b2\n\n checksum_next(b)\n @rx << b\n\n @frame_size |= b \n\n if @frame_size < 6\n log_error \"frame will be too short\"\n @state = :start_frame\n else\n @state = :dest_b1\n end\n \n when :dest_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = OneByte.new(b >> 1)\n @state = :src_b1\n else\n @state = :dest_b2\n end\n \n when :dest_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @dest = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :src_b1\n else\n @state = :dest_b3\n end\n \n when :dest_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :dest_b4\n end\n \n when :dest_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @dest = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :src_b1\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :src_b1\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = OneByte.new(b >> 1)\n @state = :control\n else\n @state = :src_b2\n end\n \n when :src_b2\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1\n @src = TwoByte.new(@rx[-2].to_i >> 1, b >> 1)\n @state = :control\n else\n @state = :src_b3\n end\n \n when :src_b3\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n log_error \"invalid address length\"\n @state = :idle\n else\n @state = :src_b4\n end\n \n when :src_b4\n \n checksum_next(b)\n @rx << b\n \n if (b & 1) == 1 \n @src = FourByte.new((@rx[-4].to_i << 8) | @rx[-3].to_i, (@rx[-2].to_i << 8) | b)\n @state = :control\n else\n log_error \"invalid address length\"\n @state = :idle\n end\n \n when :control\n \n checksum_next(b)\n @rx << b\n @control = b\n @state = :hcs_b1\n \n when :hcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :hcs_b2\n \n when :hcs_b2\n \n checksum_next(b)\n @rx << b \n \n if @fcs != 0xf0b8\n \n log_error \"invalid HCS\"\n @state = :start_frame\n \n elsif @frame_size == @rx.size\n \n @state = :end_frame\n \n else\n \n @state = :info\n \n end\n \n when :info\n \n checksum_next(b)\n @rx << b \n @info << b \n \n if @rx.size == (@frame_size - 2)\n \n @state = :fcs_b1\n \n end\n \n when :fcs_b1\n \n checksum_next(b)\n @rx << b \n @state = :fcs_b2\n \n when :fcs_b2\n \n checksum_next(b)\n @rx << b \n @state = :end_frame\n \n when :end_frame\n \n if b == Frame::FRAME_CHAR\n \n if @fcs == 0xf0b8\n \n begin\n \n f = Frame.from_decoder(self)\n \n # todo enforce rules for which frames are allowed certain fields\n \n yield(f) if block_given?\n \n rescue => e\n log_error \"#{e.exception}: #{e.message}\"\n log_error e.backtrace.join(\"\\n\")\n end\n \n else\n \n log_error \"invalid fcs\"\n \n end\n \n else\n \n log_error \"expecting end of frame\"\n \n end\n \n @state = :idle\n \n end\n \n self\n \n end",
"def get_next_btcmd\r\n @game_cmd_bt_list.each do |bt|\r\n if bt[:status] == :not_used\r\n bt[:status] = :used \r\n return bt\r\n end \r\n end\r\n nil\r\n end",
"def read_berp\n length = @socket.read(4).unpack('N').first\n data = @socket.read(length)\n @encoding ? BERT.decode(data, @encoding) : BERT.decode(data)\n end",
"def new\n @bluetooth = Bluetooth.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bluetooth }\n end\n end",
"def get_account_balance\n submit GetAccountBalance.new\n end",
"def read_berp\n length = socket.read(4).unpack('N')[0]\n data = socket.read(length)\n BERT.decode(data)\n end",
"def receiving(data); end",
"def receiving(data); end",
"def bitcoin\n @bitcoin || BlockrIo.new\n end",
"def deserialize(value = Balance.new)\n if (buffer.offset + @_model.fbe_offset) > buffer.size\n [Balance.new, 0]\n end\n\n fbe_struct_size = read_uint32(@_model.fbe_offset - 8)\n fbe_struct_type = read_uint32(@_model.fbe_offset - 4)\n if (fbe_struct_size <= 0) || (fbe_struct_type != fbe_type)\n [Balance.new, 8]\n end\n\n fbe_result = @_model.get(value)\n [fbe_result[0], (8 + fbe_result[1])]\n end",
"def ban\n ban = Ban.new\n ban.steamid = params[:id]\n ban.ts = params[:ts]\n ban.sign = params[:sign]\n ban.expiry = DateTime.now.ago(-(params[:len].to_i*60))\n ban.addr = params[:addr]\n ban.reason = params[:reason]\n ban.ban_type = Ban::TYPE_SERVER\n ban.save!\n\n render :text => \"Ok\"\n end",
"def balance\n parse_balance(post('/api/1/generic/info'))\n end",
"def create_bitcoin_payment_from_tx(tx, latest_height, out, technical_bitcoin_payment = false)\n return if out['addr'] != self.checkout_wallet.destination_address\n inputs = tx['inputs']\n tx_height = tx['block_height']\n \n related_input_tx = inputs.select {|x| x['prev_out']['n'] == out['n']}.first['prev_out']\n input_transaction_hash = related_input_tx['addr']\n input_address = related_input_tx['addr'] # input_address = checkout_wallet_address # this would be safer...\n \n value = out['value']\n confirmations = latest_height - tx_height\n transaction_hash = tx['hash']\n destination_address = out['addr']\n sale_id = self.id\n\n bp_hash = { user_id: self.user.id, input_address: input_address, value: value, confirmations: confirmations, \n transaction_hash: transaction_hash, destination_address: destination_address, \n input_transaction_hash: input_transaction_hash, sale_id: sale_id, destination_address: out['addr'] }\n \n bp = BitcoinPayment.find_by_transaction_hash(transaction_hash)\n \n if bp.nil?\n BitcoinPayment.create(bp_hash)\n else\n bp.update_attributes(bp_hash)\n end\n end",
"def from_bencode\n BEncode.load(self)\n end",
"def create_b2bua_request(session, orig_request=session.irequest, rip=SipperConfigurator[:DefaultRIP], \n rp=SipperConfigurator[:DefaultRP])\n peer_session = get_or_create_peer_session(session, rip, rp)\n if peer_session.initial_state?\n r = peer_session.create_initial_request(orig_request.method, orig_request.uri)\n r.copy_from(orig_request, :from, :to, :route, :content, :content_type, :path, :service_route, :privacy, :referred_by, :p_asserted_identity)\n r.from.tag = \"3\"\n else\n if(orig_request.method == \"CANCEL\")\n r = peer_session.create_cancel\n elsif(orig_request.method == \"ACK\")\n r = peer_session.create_ack\n else\n r = peer_session.create_subsequent_request(orig_request.method)\n end \n r.copy_from(orig_request, :content, :content_type)\n end \n return r\n end",
"def consume\n end",
"def push(_hex)\n raise Sibit::NotSupportedError, 'Btc.com doesn\\'t provide payment gateway'\n end",
"def get_ber(msg)\n ber = client.railgun.memread(msg[2],60).unpack('V*')\n\n # BER Pointer is different between x86 and x64\n if client.arch == ARCH_X64\n ber_data = client.railgun.memread(ber[4], ber[0])\n else\n ber_data = client.railgun.memread(ber[3], ber[0])\n end\n\n return ber_data\n end",
"def decode_tx_to_btc_tx(tx)\n hash = {\n 'version' => tx['version'],\n 'lock_time' => tx['locktime'],\n 'hex' => tx['hex'],\n 'txid' => tx['txid'],\n 'blockhash' => tx['blockhash'],\n 'confirmations' => tx['confirmations'],\n 'time' => tx['time'],\n 'blocktime' => tx['blocktime'],\n 'in' => tx['vin'].map{|input|\n {'output_index' => input['vout'], 'previous_transaction_hash' => input['txid'], 'coinbase' => input['coinbase'],\n 'scriptSig' => input['scriptSig']['asm'], 'sequence' => input['sequence']}},\n 'out' => tx['vout'].map{|out|\n {'amount' => out['value'], 'scriptPubKey' => out['scriptPubKey']['asm']}\n }\n }\n Bitcoin::Protocol::Tx.from_hash(hash)\n end",
"def bid\n BigDecimal Fyb.public.ticker.perform.parse['bid'], 2\n end",
"def receive(node)\n Blather.logger.debug \"RECEIVING (#{node.element_name}) #{node}\"\n @client.receive_data @node.to_stanza\n end",
"def bs_order(o)\n tkr = o[:tkr]\n half_at_2R = o[:half_at_2R]\n return if not active_ticker?(tkr)\n #orders[tkr] |= {}\n size = (o[:pos_risk].to_f / (o[:stop_px].to_f-o[:stop_ex].to_f)).to_i\n return if invalid_size?(size)\n debug \"stage order to buy #{size} #{o[:tkr]} @#{o[:stop_px]}, risking #{o[:pos_risk]}\"\n unless o[:stop_px].to_f > 0\n warn \"must input valid entry stop price!\"\n return\n end\n stop_price = (o[:stop_px].to_f).round(2)\n stop_loss = (o[:stop_ex].to_f).round(2)\n limit_price = ((stop_price > 10) ? stop_price+0.38 : stop_price+0.12).round(2)\n #limit_price = 0\n profit_price = o[:tgt_price].to_f.round(2) || (o[:pos_risk].to_f * 4 / size + stop_price).round(2)\n\n debug \"stop_price = #{stop_price}\"\n debug \"stop_loss = #{stop_loss}\"\n debug \"limit_price = #{limit_price}\"\n debug \"profit_price = #{profit_price}\"\n\n #-- Parent Order --\n #buy_limit(tkr,size,limit_price)\n debug \"send parent order\"\n debug \"IB::Order.new :total_quantity => #{size},\"\n debug \" :limit_price => #{limit_price},\"\n debug \" :aux_price => #{stop_price},\"\n debug \" :action => 'BUY',\"\n debug \" :order_type => 'STP',\"\n debug \" :algo_strategy => '',\"\n debug \" #:account => account_code,\"\n debug \" :transmit => true\"\n buy_order = IB::Order.new :total_quantity => size,\n :limit_price => limit_price,\n :aux_price => stop_price,\n :action => 'BUY',\n :tif => 'GTC',\n :order_type => 'STPLMT',\n :algo_strategy => '',\n #:account => account_code,\n :transmit => true\n #ib.wait_for :NextValidId\n place_order buy_order, @contracts[tkr]\n \n #-- Child STOP --\n puts \"send stop order\"\n debug \"IB::Order.new :total_quantity => #{size},\"\n debug \" :limit_price => 0,\"\n debug \" :aux_price => #{stop_loss},\"\n debug \" :action => 'SELL',\"\n debug \" :order_type => 'STP',\"\n #puts \" :account => account_code,\"\n debug \" :parent_id => #{buy_order.local_id},\"\n debug \" :transmit => true\"\n stop_order = IB::Order.new :total_quantity => size,\n :limit_price => 0,\n :aux_price => stop_loss,\n :action => 'SELL',\n :tif => 'GTC',\n :order_type => 'STP',\n #:account => account_code,\n :parent_id => buy_order.local_id,\n :transmit => true\n ib.wait_for :NextValidId\n place_order stop_order, @contracts[tkr]\n \n #-- BreakEven LMT\n tgt_1 = (stop_price + 2*(stop_price - stop_loss)).round(2)\n size_1 = (size/2).round(0)\n size_2 = size - size_1\n if half_at_2R && profit_price > tgt_1\n size = size_2\n debug \"breakeven_order = IB::Order.new :total_quantity => #{size_1},\"\n debug \" :limit_price => #{tgt_1},\"\n debug \" :action => 'SELL',\"\n debug \" :tif => 'GTC',\"\n debug \" :order_type => 'LMT',\"\n #debug \" :parent_id => #{buy_order.local_id},\"\n debug \" :transmit => true\"\n \n breakeven_order = IB::Order.new :total_quantity => size_1,\n :limit_price => tgt_1,\n :action => 'SELL',\n :tif => 'GTC',\n :order_type => 'LMT',\n #:parent_id => buy_order.local_id,\n :transmit => true\n place_order breakeven_order, @contracts[tkr]\n end \n #-- Profit LMT\n #puts \"profit_order = IB::Order.new :total_quantity => #{size},\"\n #puts \" :limit_price => #{profit_price},\"\n #puts \" :action => 'SELL',\"\n #puts \" :tif => 'GTC',\"\n #puts \" :order_type => 'LMT',\"\n #puts \" :parent_id => #{buy_order.local_id},\"\n #puts \" :transmit => true\"\n \n #profit_order = IB::Order.new :total_quantity => size,\n # :limit_price => profit_price,\n # :action => 'SELL',\n # :tif => 'GTC',\n # :order_type => 'LMT',\n # #:account => account_code,\n # :parent_id => buy_order.local_id,\n # :transmit => true\n #place_order profit_order, @contracts[tkr]\n end",
"def new_brb_out_request(meth, *args, &blck)\r\n Thread.current[:brb_nb_out] ||= 0\r\n Thread.current[:brb_nb_out] += 1\r\n\r\n raise BrBCallbackWithBlockingMethodException.new if is_brb_request_blocking?(meth) and block_given?\r\n\r\n block = (is_brb_request_blocking?(meth) or block_given?) ? Thread.current.to_s.to_sym : nil\r\n if block\r\n args << block \r\n args << Thread.current[:brb_nb_out]\r\n end\r\n \r\n if block_given?\r\n # Simulate a method with _block in order to make BrB send the answer\r\n meth = \"#{meth}_block\".to_sym\r\n end\r\n\r\n args.size > 0 ? brb_send([MessageRequestCode, meth, args]) : brb_send([MessageRequestCode, meth])\r\n\r\n if block_given?\r\n # Declare the callback\r\n declare_callback(block, Thread.current[:brb_nb_out], &blck)\r\n\r\n elsif block # Block until the request return\r\n\r\n #TimeMonitor.instance.watch_thread!(@timeout_rcv_value || 45)\r\n begin\r\n r = recv(block, Thread.current[:brb_nb_out], &blck)\r\n rescue Exception => e\r\n raise e\r\n ensure\r\n #TimeMonitor.instance.remove_thread!\r\n end\r\n if r.kind_of? Exception\r\n raise r\r\n end\r\n return r\r\n end\r\n\r\n nil\r\n end",
"def b!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 14 )\n\n type = B\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 339:4: 'b'\n match( 0x62 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 14 )\n\n end",
"def import_bien b\n\n\t\t# Category & Transaction type \n\t\t# duplication because of strange 'can't modify frozen string' error\n\t\tfoundType \t\t\t= b.name.dup\n\t\tcat \t\t\t\t= BienType.find_or_create foundType.up_first\n\t\ttransaction_type \t= BienTransaction.where(:nom => b.xpath('./TypeTransaction').text.up_first).first\n\t\t\n\t\tLogger.send(\"warn\", \"[Emulis] Bien transaction: #{b.xpath('./TypeTransaction').text.up_first}, bien transaction found: #{transaction_type.nom}\")\n\t\treturn if transaction_type.nil?\n\n\t\tLogger.send(\"warn\",\"[Emulis] starting to import bien with ref: #{b.xpath('./RefSIA').text}\")\n\t\t\t\t\n\t\t\n\t\t# Good location\n\t\tgood_address = {}\n\t\tloc \t\t= BienEmplacement.new\n\t\tloc.pays \t= \"France\"\n\t\tif b.xpath('./Immeuble')\n\t\t\tloc.code_postal = b.xpath('./Immeuble/CodePostal').text\n\t\t\tloc.ville \t\t= b.xpath('./Immeuble/NomLocalite').text\n\t\telse\n\t\t\tloc.code_postal = b.xpath('./CodePostal').text\n\t\t\tloc.ville \t\t= b.xpath('./NomLocalite').text\n\t\tend\n\n\n\t\t# find if good already exist, unless create it\n\t\tref = b.xpath('./RefSIA').text \n\t\tnb \t= Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\tnb \t= Bien.new if nb.nil?\n\n\t\tnb.is_accueil \t\t= false\n\t\t#nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\n\t\n\t\t# update attributes\n\t\tnb.passerelle \t\t= @passerelle\n\t\tnb.reference \t\t= ref\n\t\tnb.bien_type \t\t= cat\n\t\tnb.bien_transaction = transaction_type\n\t\tnb.bien_emplacement = loc\n\n\t\tnb.nb_piece \t\t= b.xpath('./NbPieces').text.to_i\n\t\tnb.nb_chambre \t\t= b.xpath('./NbChambres').text.to_i\n\t\tnb.surface\t\t\t= b.xpath('./SurfaceTotale').text.to_i\n\t\tnb.surface_terrain\t= b.xpath('./SurfaceTerrain').text.to_i\n\t\t\n\t\tnb.titre \t\t\t= b.xpath('./TitreAnnonce').text\n\n\t\tnb.prix \t\t\t= b.xpath('./PrixCommissionComprise').text.to_i\n\t\tnb.description \t\t= b.xpath('./DescriptionBien').text\n\t\t\n\t\tnb.valeur_ges \t\t= b.xpath('./GES_bien').text.to_i\n\t\tnb.class_ges\t\t= nb.classe_ges\n\t\tnb.statut \t\t\t= 'new'\n\t\tnb.save!\n\n\t\t\n\t\t# If new images : Drop old images, add current images\n\t\tpl\t= b.xpath('./Photo')\n\t\tif pl\n\t\t\t# un-attach old\n\t\t\tnb.bien_photos.each{ |photo|\n\t\t\t\t photo.bien = nil\n\t\t\t\t photo.save!\n\t\t\t}\n\t\t\t\n\t\t\tnumber \t= 0\n\t\t\tpl.each { |p| \n\t\t\t\t#Logger.send(\"warn\", \"starting to import photo url: #{p.xpath('./url').text}, title: #{p.xpath('./Titre').text}\")\n\t\t\t\timport_remote_media(p.xpath('./url').text, (number+=1), nb) \n\t\t\t}\n\t\tend\n\t\tnb.save!\n\n\treturn true\n\n\treturn\n\tend",
"def accept_incoming\n request = ProtoRINA.flow_read(name: Name)\n end",
"def receive\n parse(recv)\n end",
"def bread_params\n if !params[:bread].nil?\n params.require(:bread).permit(:name, :kind)\n end\n end",
"def base_transaction_to_transaction(bt)\n bt[:transfer_transaction_id].nil? ? category_id = bt[:category_id] : 0\n transaction = {\n amount: amount_float_int(bt[:amount], bt[:currency]),\n direction: bt[:direction],\n description: bt[:description],\n account_id: bt[:account].id,\n timezone: bt[:timezone],\n currency: bt[:currency],\n account_currency_amount: get_account_currency_amount(bt),\n category_id: category_id,\n local_datetime: bt[:local_datetime],\n transfer_account_id: bt[:transfer_account_id],\n user_currency_amount: get_user_currency_amount(bt),\n transfer_transaction_id: bt[:transfer_transaction_id],\n schedule_id: bt[:schedule_id],\n is_scheduled: bt[:is_scheduled],\n queue_scheduled: bt[:queue_scheduled],\n schedule_period_id: bt[:schedule_period_id],\n scheduled_transaction_id: bt[:scheduled_transaction_id],\n scheduled_date: bt[:scheduled_date]\n }\n end",
"def retrogress_bbtree\n if @tags_list[-1].definition[:self_closable]\n # It is possible that the next (self_closable) tag is on the next line\n # Remove newline of current tag and parent tag as they are (probably) not intented as an actual newline here but as tag separator\n @tags_list[-1][:nodes][0][:text]&.chomp!\n @tags_list[-2][:nodes][0][:text].chomp! unless (@tags_list.length < 2) || @tags_list[-2][:nodes][0][:text].nil?\n end\n\n @tags_list.pop # remove latest tag in tags_list since it's closed now...\n # The parsed data manifests in @bbtree.current_node.children << TagNode.new(element) which I think is more confusing than needed\n\n @current_node = if within_open_tag?\n @tags_list[-1]\n else\n # we're still at the root of the BBTree or have returned back to the root via encountering closing tags...\n TagNode.new(nodes: nodes)\n end\n end",
"def buy(command)\n action = \"Bought\"\n description = command[1]\n value = \"(#{command[2]})\"\n timestamp = Time.now.to_s\n @t.say(\"Got your purchase: #{action}, #{description}, #{value}\")\n \n ledger_push(action, value, description, timestamp)\n \nend",
"def import_bien b\n\n\t# Category & Transaction type\n\tref \t\t\t= b[1]\n\treturn if ref.nil? or ref.empty?\n\t\n\treturn if b[2].nil?\n\ttransaction_type = BienTransaction.where(:nom => b[2].up_first).first\n\treturn if transaction_type.nil?\n\tb[3] = \"Commerces / Autre\" if b[3].nil? || b[3].empty?\n\tcat = BienType.find_or_create b[3]\n \n\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n nb = Bien.new if nb.nil?\n\t\n\tnb.is_accueil \t\t= false\n\t# nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\t\t# Good location\n\tgood_address \t\t= {}\n\tloc \t\t\t\t= BienEmplacement.new\n\tloc.pays \t\t\t= b[6]\n\tloc.code_postal \t= b[4]\n\tloc.ville \t\t\t= b[5]\n\n\tnb.passerelle \t\t= @passerelle\n\tnb.reference \t\t= ref\n\tnb.bien_type \t\t= cat\n\tnb.bien_transaction = transaction_type\n\tnb.bien_emplacement = loc\n\tnb.nb_piece \t\t= b[17].to_i\n\tnb.nb_chambre \t\t= b[18].to_i\n\tnb.surface \t\t\t= b[15].to_i\n\tnb.surface_terrain \t= b[16].to_i\n\tnb.titre \t\t\t= b[3].to_s\n\t\n\tif((transaction_type.nom =~ /Location/) && (b[12] =~ /non/i))\n\t\tnb.prix_hors_charges \t\t= b[10].to_i\n\t\tnb.prix_charges_comprises \t= b[10].to_i + b[22].to_i \n\telse\n\t\tnb.prix_charges_comprises\t= b[10].to_i\n\tend\n\tnb.prix\t\t\t\t\t= nb.prix_charges_comprises\t\n\tnb.honoraires_agence\t= b[14].to_i\n\n\tnb.description \t\t= b[20]\n\n\tnb.statut = 'new'\n\tnb.save!\n\n\tnb.valeur_dpe \t\t= b[175].to_i\n\tnb.valeur_ges \t\t= b[177].to_i\n\tnb.classe_dpe \t\t= b[176].to_s\n\tnb.class_ges\t\t= b[178].to_s\n\n\t# If new images : Drop old images, add current images\n\timages \t\t\t\t= b[84..92]\n\timages \t\t\t\t= [] if images.nil?\n\timages \t\t\t\t= images.select{ |p| !p.nil? && !p.empty? }\n if !images.empty?\n\t\t# un-attach old\n\t\tnb.bien_photos.each{ |photo|\n\t\t\tphoto.bien = nil\n\t\t\tphoto.save!\n\t\t}\n\t\t# Map photo-hashes to medias, filter out failures, and add medias to good\n\t\tnumber = 0\n\t\tcounter = 0\n \n\t\timages.map { |p| import_local_media(p.to_s,(counter+=1),nb,p.to_s) }\n end\n\t\n nb.save!\n\n return\n\tend",
"def transmission; end",
"def action_card_bd(input)\n utoken = params[:xml][:FromUserName]\n card_info = Card.where(:utoken=>utoken).order('updated_at desc').first\n return build_response_text_temp {|msg|\n msg.Content=t(:notbindinghelp)\n } if card_info.nil?\n card_info[:isbinded]=true\n card_info.save\n #persist user request\n log_use_request {|request|\n request.lastaction = RequestAction::ACTION_JF_BIND\n }\n return build_response_text_temp {|msg|\n msg.Content = t(:bindingsuccess)\n }\n end",
"def buy(amount)\n ether = amount.to_f\n\n @ether_reserve += ether\n new_token_reserve = @konst / @ether_reserve\n\n tokens_bought = @token_reserve - new_token_reserve\n price = sprintf(\"%0.4f\", ether / tokens_bought)\n log \"You get #{tokens_bought} tokens for #{ether} ether, price #{price}\" # this is where we would transfer tokens to the buyer\n\n @token_reserve = new_token_reserve\n output\n\n return tokens_bought\n end",
"def consume; end",
"def consume; end",
"def consume; end",
"def import_bien b\n\t\tref \t\t\t\t= b['refClient']\n\t\tnb \t\t\t\t\t= Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\tif(nb.nil?)\n\t\t\tif((b['flag'] == \"A\") || (b['flag'] == \"U\"))\n\t\t\t\tnb = Bien.new\n\t\t\telse\n\t\t\t\treturn\n\t\t\tend\n\t\telse\n\t\t\tif(b['flag'] == \"D\")\n\t\t\t\tmark_for_destruction nb\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t\n\t\tcat_s \t\t\t\t= CAT_CODE_MATCHING[b['typeBien']]\n\t\tnb.bien_type \t\t= BienType.find_or_create cat_s.up_first\n\t\t\n\t\ttransaction\t\t\t= TRANSACTION_MATCHING[b['typeVente']]\n\t\tnb.bien_transaction = BienTransaction.where(:nom => transaction.up_first).first\n\t\tif nb.bien_transaction.nil?\n\t\t\tLogger.send(\"warn\",\"[Ubiflow] Type de transaction nul pour le bien ref : #{ref}\")\n\t\t\t@result[:description] << \"[Ubiflow] Type de transaction nul pour le bien ref : #{ref}\"\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Good location\n\t\tgood_address \t\t= {}\n\t\tloc \t\t\t\t= BienEmplacement.new\n\t\tloc.pays \t\t\t= \"France\"\n\t\tloc.ville \t\t\t= b['ville']\n\t\tloc.code_postal \t= b['code_postal']\n\n\t\t# find if good already exist, unless create it\n\t\t#nb \t\t\t\t\t= Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\t#nb \t\t\t\t\t= Bien.new if nb.nil?\n\n\t\tnb.is_accueil \t\t= false\n\t\n\t\t# bien common attributes\n\t\tnb.passerelle \t\t= @passerelle\n\t\tnb.reference \t\t= ref\n\t\tnb.bien_emplacement = loc\n\n\t\tnb.nb_piece \t\t= b.xpath('./NbrePiece').text.to_i\n\t\tnb.nb_chambre \t\t= b.xpath('./NbreChambres').text.to_i\n\t\tnb.surface\t\t\t= b.xpath('./SurfaceHabitable').text.to_i\n\t\tnb.surface_terrain\t= b.xpath('./SurfaceTerrain').text.to_i\n\t\t\n\t\tnb.titre \t\t\t= b.xpath('./Designation').text\n\n\t\tif (transaction == \"Location\")\n\t\t\tif NEGOCIATION_MATCHING[b['modeNego']]\n\t\t\t\tnb.prix_charges_comprises \t= b.xpath('./PVB').text.to_i\n\t\t\telse\n\t\t\t\tnb.prix_hors_charges \t\t= b.xpath('./PNV').text.to_i\n\t\t\t\tnb.prix_charges_comprises \t= b.xpath('./PNB').text.to_i\n\t\t\tend\n\n\t\t\tnb.prix \t\t\t= nb.prix_charges_comprises\n\t\telse\n\t\t\tif NEGOCIATION_MATCHING[b['modeNego']]\n\t\t\t\tnb.prix \t\t= b.xpath('./PVB').text.to_i\n\t\t\telse\n\t\t\t\tnb.prix \t\t= b.xpath('./PNV').text.to_i + b.xpath('./fraisNego').text.to_i\n\t\t\tend\n\t\tend\n\t\tnb.prix \t\t\t= b.xpath('./PVB').text.to_i\n\t\tnb.description \t\t= b.xpath('./Annonce').text\n\t\t\n\t\tnb.valeur_dpe \t\t= b.xpath('./dpeNrj').text.to_i\n\t\tnb.classe_dpe\t\t= nb.classe_energie\n\t\tnb.valeur_ges \t\t= b.xpath('./dpeGes').text.to_i\n\t\tnb.class_ges\t\t= nb.classe_ges\n\t\tnb.statut \t\t\t= 'new'\n\t\tnb.save!\n\t\t\n\t\t# If new images : Drop old images, add current images\t\t\n\t\tphotos = b.xpath('./Photo')\n\t\tif photos && !photos.empty?\n\t\t\t# Logger.send(\"warn\", \"[Transim] re import bien photo\")\n\t\t\t\n\t\t\t# un-attach old\n\t\t\tnb.bien_photos.each{ |photo|\n\t\t\t\tphoto.bien = nil\n\t\t\t\tphoto.save!\n\t\t\t}\n\t\t\t\n\t\t\tnumber \t= 0\n\t\t\tphotos.each { |entry| \n\t\t\t\tp = import_local_media(entry.text, entry[\"id\"].to_i, nb, entry.text)\n\t\t\t}\n\t\t\tnb.save!\n\t\tend\n\n\treturn\n\tend",
"def getB\r\n return @b\r\n end",
"def to_raw_tx\n connection.request self.class.to_create_request, to_params\n end",
"def create\n @fbt = Fbt.new(fbt_params)\n\n respond_to do |format|\n if @fbt.save\n format.html { redirect_to @fbt, notice: \"Fbt was successfully created.\" }\n format.json { render :show, status: :created, location: @fbt }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @fbt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def receive(data); end",
"def deserialize(value = Balance.new)\n if (buffer.offset + @_model.fbe_offset - 4) > buffer.size\n [Balance.new, 0]\n end\n\n fbe_full_size = read_uint32(@_model.fbe_offset - 4)\n if fbe_full_size < @_model.fbe_size\n [Balance.new, 0]\n end\n\n @_model.get(value)\n [value, fbe_full_size]\n end",
"def consume\n \n end",
"def gets_buffer(*a)\n @device.buffer\n end",
"def add_bank_account\n\n get_balanced_key\n\n account_uri = params[:account_uri]\n company_name = \"Mindfire Solutions\"\n\n ##You can set your customer business / company name here \n customer = Balanced::Customer.new({name: company_name}).save\n customer_uri = customer.href\n get_customer = Balanced::Customer.fetch(customer_uri)\n \n bank_account = Balanced::BankAccount.fetch(account_uri)\n bank_account.associate_to_customer(customer_uri)\n \n ##befor debiting your customer you need to verify their bank account as per balanced payment\n bank_account = Balanced::BankAccount.fetch(account_uri)\n verify_bank_account = bank_account.verify\n verification = Balanced::BankAccountVerification.fetch(verify_bank_account.href)\n verification.confirm(\n amount_1 = 1,\n amount_2 = 1\n )\n \n amount_in_dollars = params[:amount].to_i\n #amount_in_dollars * 100 convert into cents\n debit = bank_account.debit(:amount => amount_in_dollars * 100, appears_on_statement_as: \"Debit Amount\")\n \n ##You can save the response in your db for future use\n #debit.transaction_number\n #debit.amount\n #debit.statusdebit.created_at\n \n #get your balanced marketplace\n marketplace = Balanced::Marketplace.my_marketplace\n \n credit = get_marketplace_bank_account.credit(:amount => debit.amount, appears_on_statement_as: \"Credit Amount\")\n\n \n return render json: {success: [\"Debit Transaction:: #{debit.attributes}\", \"Credit Transaction:: #{credit.attributes}\"] }\n\n end",
"def get_bin(op:, input_name:)\n op.input(input_name).item.get(:bin)\n end",
"def new_brb_in_request(meth, *args)\r\n\r\n if is_brb_request_blocking?(meth)\r\n\r\n m = meth.to_s\r\n m = m[0, m.size - 6].to_sym\r\n\r\n idrequest = args.pop\r\n thread = args.pop\r\n begin\r\n r = ((args.size > 0) ? @object.send(m, *args) : @object.send(m))\r\n brb_send([ReturnCode, r, thread, idrequest])\r\n rescue Exception => e\r\n brb_send([ReturnCode, e, thread, idrequest])\r\n BrB.logger.error e.to_s\r\n BrB.logger.error e.backtrace.join(\"\\n\")\r\n #raise e\r\n end\r\n else\r\n\r\n begin\r\n (args.size > 0) ? @object.send(meth, *args) : @object.send(meth)\r\n rescue Exception => e\r\n BrB.logger.error \"#{e.to_s} => By calling #{meth} on #{@object.class} with args : #{args.inspect}\"\r\n BrB.logger.error e.backtrace.join(\"\\n\")\r\n raise e\r\n end\r\n\r\n end\r\n\r\n end",
"def as_received\n raw_data\n end",
"def banks_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: BanksApi#banks_get ...\"\n end\n \n # resource path\n path = \"/banks\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\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/x-www-form-urlencoded']\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 = ['khipu']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'BanksResponse')\n if Configuration.debugging\n Configuration.logger.debug \"API called: BanksApi#banks_get. Result: #{result.inspect}\"\n end\n return result\n end",
"def show\n @bluetooth = Bluetooth.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bluetooth }\n end\n end",
"def do_recv()\n data = super()\n message = Hurricane::Message.new()\n message.type = data.data[0].name\n message.destination = data.data[1]\n message.tag = data.data[2]\n message.data = data.data[3]\n message\n end",
"def getBin\n case @binDataType\n when 'B'\n bin = Bin.new('information', BytesValue.new(randString(@binDataSize)))\n when 'S'\n bin = Bin.new('information', StringValue.new(randString(@binDataSize)))\n else\n bin = Bin.new('information', IntegerValue.new(2**63))\n end\n\n bin\nend",
"def proccess\n # data = get_data\n separate_bets\n end",
"def to_buffer\n validate_binary_operations\n @request.perform(binary: true)\n end",
"def received\n end",
"def write_berp(obj)\n socket.write(Client.create_berp(obj))\n end",
"def receive(node)\n Blather.logger.debug \"RECEIVING (#{node.element_name}) #{node}\"\n @node = node\n\n if @node.namespace && @node.namespace.prefix == 'stream'\n case @node.element_name\n when 'stream'\n @state = :ready if @state == :stopped\n return\n when 'error'\n handle_stream_error\n return\n when 'end'\n stop\n return\n when 'features'\n @state = :negotiating\n @receiver = Features.new(\n self,\n proc { ready! },\n proc { |err| @error = err; stop }\n )\n end\n end\n @receiver.receive_data @node.to_stanza\n end",
"def handle_transfer(resp_body)\n params = {\n id: resp_body[:id],\n from: resp_body[:from],\n to: resp_body[:to],\n by: resp_body[:by],\n from_amount: Amount.new(\n currency: resp_body[:fromAmount][:currency],\n value: resp_body[:fromAmount][:value]\n ),\n to_amount: Amount.new(\n currency: resp_body[:fromAmount][:currency],\n value: resp_body[:fromAmount][:value]\n ),\n banking_id: resp_body[:banking_id],\n memo: resp_body[:memo],\n type: Utils.parse_enum(resp_body[:type]),\n status: Utils.parse_enum(resp_body[:status]),\n refund: Refund.new(resp_body[:refund]),\n created_at: Utils.parse_epoch(resp_body[:created])\n }\n TransferItem.new(@member_account, params)\n end",
"def estimate_fee(amount, bin = nil)\n raise \"invalid bin\" if bin.starts_with?('9')\n unless bin && bin.length >= 6\n # fee_str = card_fee_str(amount)\n fee_str = fee_range_str(amount)\n #fee_range(amount) # note, returns an array with low/high range when params are missing\n return {fee_str: fee_str}\n end\n\n bin = bin[0..5] if bin.length > 6 # trim just in case we were given a full number\n\n binbase = Binbase.find_by(bin: bin)\n puts \"binbase: #{binbase}\"\n base = 0.30\n percent = 2.9\n message = nil\n\n amount = BigDecimal(amount)\n\n # return {error: 'BIN not found'} unless binbase\n unless binbase\n # placeholder default fee calculation\n # fee = apply_rate(amount, INTERCHAGNE_DEFAULT_BASE, INTERCHANGE_DEFAULT_PERCENT)\n\n # if unable to match bin, assume lowest fee. (don't want to overcharge)\n # todo: figure out best way to message this\n # todo: log non-matched bins for later investigation / stats\n fee = fee_range_low(amount)\n return {estimated_fee: fee, fee_str: \"unknown\"}\n end\n\n if binbase.card_brand == 'AMEX'\n base = 0.30\n percent = 3.5\n message = \"Tip: AMEX has the highest fees!\"\n end\n\n if binbase.card_brand == 'VISA' || binbase.card_brand == 'MASTERCARD'\n if binbase.card_type == 'DEBIT'\n base = 0.22\n if binbase.is_regulated\n percent = 0.05\n message = \"Good choice, Debit Cards have the lowest fees!\"\n else\n percent = 0.80\n message = \"Good choice, Debit Cards have lower fees.\"\n end\n else\n base = 0.12\n message = \"Tip: Debit Cards generally have lower fees than Credit Cards\"\n if binbase.card_category == 'PLATINUM' || binbase.card_category == 'BUSINESS'\n percent = 2.9\n message += \", and Rewards Cards have the highest fees.\"\n elsif binbase.card_category == 'GOLD'\n percent = 2.2\n message += \", and Rewards Cards have higher fees.\"\n else\n percent = 1.8\n end\n end\n end\n if amount < 20\n message = \"\"\n end\n\n fee = apply_rate(amount, base, percent)\n\n fee_str = \"$#{format_amount(fee)}\"\n fee_str += \" (#{message})\" if message.present?\n\n puts \"calcfee - #{bin}, base: #{base}, %: #{percent} = #{fee} - tip: #{message}\"\n {\n estimated_fee: fee,\n fee_tip: message,\n fee_str: fee_str, # combined and formatted string\n card_brand: binbase.card_brand,\n issuing_org: binbase.issuing_org,\n card_type: binbase.card_type,\n card_category: binbase.card_category,\n is_regulated: binbase.is_regulated,\n }\n end",
"def accepted_bid\n accepted_response.present? ? accepted_response.bid : nil\n end",
"def get_bankrupt\n bankrupt=@bankrupt\n return bankrupt\n end",
"def to_b\r\n return self\r\n end",
"def bdecode\n BEncode.load(self)\n end",
"def call_infoblox(action, ref, content_type, return_type, body = nil, return_fields = nil)\n # set url\n if return_fields.nil?\n url = \"#{@base_url}\" + \"#{ref}\"\n else\n url = \"#{@base_url}\" + \"#{ref}\" + \"\\?_return_fields\"\n end\n \n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => {\n :content_type => content_type,\n :accept => return_type,\n :authorization => \"Basic #{Base64.strict_encode64(\"#{@username}:#{@password}\")}\"\n }\n }\n \n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"Calling -> Infoblox: #{url} action: #{action} payload: #{params[:payload]}\")\n response = RestClient::Request.new(params).execute\n raise \"Failure <- Infoblox Response: #{response.code}\" unless response.code == 200 || response.code == 201\n return response\n end",
"def call_infoblox(action, ref, content_type, return_type, body = nil, return_fields = nil)\n # set url\n if return_fields.nil?\n url = \"#{@base_url}\" + \"#{ref}\"\n else\n url = \"#{@base_url}\" + \"#{ref}\" + '?_return_fields='\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => {\n :content_type => content_type,\n :accept => return_type,\n :authorization => \"Basic #{Base64.strict_encode64(\"#{@username}:#{@password}\")}\"\n }\n }\n\n # generate payload data\n content_type == :json ? (params[:payload] = JSON.generate(body) if body) : (params[:payload] = body if body)\n log(:info, \"Calling -> Infoblox: #{url} action: #{action} payload: #{params[:payload]}\")\n response = RestClient::Request.new(params).execute\n raise \"Failure <- Infoblox Response: #{response.code}\" unless response.code == 200 || response.code == 201\n return response\n end",
"def get_balance(address)\n #res = get(\"addr/\"+address+\"?noCache=1\")\n #(res['balance'] + res['unconfirmedBalance']).to_BTCFloat\n get(\"addr/\"+address+\"?noCache=1\")['balance'].to_BTCFloat\n end",
"def handle_getblocks\n @node.connections.sample.send_getblocks\n {:state => \"Sending getblocks...\"}\n end",
"def parse_body(buffer)\n @id = shift_short(buffer)\n while(buffer.bytesize>0)\n @return_codes << shift_byte(buffer)\n end\n # puts \"subacks #{@return_codes.inspect}\"\n end",
"def transfer; end",
"def transfer; end",
"def get_balance (opts={})\n query_param_keys = []\n headerParams = {}\n\n \n \n # set default values and merge with input\n options = {\n \n }.merge(opts)\n\n #resource path\n path = \"/get-balance.json\".sub('{format}','json')\n \n # pull querystring keys from options\n queryopts = options.select do |key,value|\n query_param_keys.include? key\n end\n\n # header parameters\n headers = {}\n\n _header_accept = 'application/json'\n if _header_accept != ''\n headerParams['Accept'] = _header_accept\n end \n _header_content_type = ['application/x-www-form-urlencoded']\n headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'\n\n \n \n headers[:'Authorization'] = @api_key_secret\n\n # http body (model)\n post_body = nil\n \n # form parameters\n form_parameter_hash = {}\n \n \n \n Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make\n \n \n end",
"def tag\n #ban = true\n puts \"entro\"\n\n port_str = \"/dev/ttyACM0\" #may be different for you\n baud_rate = 115200\n data_bits = 8\n stop_bits = 1\n parity = SerialPort::NONE\n\n sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)\n # while ban do\n while (i = sp.gets.chomp) do\n \ti.slice!(\"Tag is not NDEF formatted.\")\n \ttagUID = i\n \tputs \"el while\"\n puts tagUID\n if tagUID.empty?\n\t ban= true\n\t else\n return tagUID\n\t end\n\n\n\n end\n #end\n #sp.closes\n end",
"def parse(type, io, shb)\n block = guess_block_type(type).new(endian: shb.endian)\n classify_block shb, block\n block.read(io)\n end",
"def read_packet; end",
"def bank_balance_report\n doc = Hpricot::XML(request.raw_post)\n doc = doc.to_s.gsub(\"&\",\"&\") \n doc = Hpricot::XML(doc) \n # xml = %{\n # <criteria> \n # <str1></str1> \n # <str2>zzzz</str2> \n # <str3></str3> \n # <str4>zzzzzzz</str4> \n # <str5>a</str5> \n # <str6>b</str6> \n # <str7></str7>\n # <str8>zzz</str8> \n # <dt2>2025-12-25</dt2>\n # <str10>zzz</str10> \n # <multiselect1></multiselect1>\n # <multiselect4></multiselect4>\n # <str12>zzz</str12>\n # <str14>z</str14>\n # <str16>zzz</str16>\n # <user_id>1</user_id>\n # <default_request>N</default_request>\n # </criteria> \n # }\n # doc = Hpricot::XML(xml)\n @bank_transactions = GeneralLedger::BankTransactionReport.bank_balance_report(doc)\n # respond_to_action('bank_balance_report') \n render :xml=>'<encoded>'+Base64.encode64(Zlib::Deflate.deflate(@bank_transactions[0]['xmlcol']))+'</encoded>'\n end",
"def get_bank_transaction(bank_transaction_id)\n request_params = {}\n url = \"#{@xero_url}/BankTransactions/#{CGI.escape(bank_transaction_id)}\"\n response_xml = http_get(@client, url, request_params)\n parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/BankTransaction'})\n end",
"def receive_transaction\n end",
"def receive_transaction\n end",
"def read_byte; end",
"def to_base58\n h = to_payload.bth\n hex = h + Bitcoin.calc_checksum(h)\n Base58.encode(hex)\n end",
"def to_base58\n h = to_payload.bth\n hex = h + Bitcoin.calc_checksum(h)\n Base58.encode(hex)\n end",
"def bcctx\n return ByteCodes.new, Context.new\nend",
"def getblockchaininfo\n @api.request 'getblockchaininfo'\n end"
] | [
"0.5633212",
"0.5510109",
"0.5359136",
"0.53279406",
"0.5150156",
"0.5144604",
"0.5139233",
"0.50056314",
"0.49942097",
"0.49818766",
"0.4961851",
"0.49156207",
"0.49090236",
"0.4898425",
"0.48741075",
"0.48733762",
"0.48618728",
"0.48542228",
"0.4837664",
"0.48141629",
"0.4798762",
"0.47883716",
"0.47748774",
"0.47748774",
"0.47525263",
"0.4751963",
"0.4724185",
"0.47053805",
"0.47024137",
"0.47017777",
"0.46972197",
"0.4692853",
"0.46922904",
"0.46728984",
"0.4672244",
"0.46709237",
"0.46683988",
"0.46550384",
"0.4654548",
"0.46460173",
"0.46432415",
"0.4629116",
"0.46061754",
"0.46032706",
"0.4602817",
"0.46023288",
"0.4598606",
"0.4587306",
"0.45864615",
"0.4574716",
"0.45669615",
"0.45656833",
"0.45656833",
"0.45656833",
"0.45603392",
"0.45593446",
"0.4540727",
"0.45383602",
"0.45280957",
"0.4523137",
"0.45196924",
"0.45169485",
"0.45153806",
"0.45124146",
"0.45031124",
"0.45006564",
"0.44993168",
"0.44987",
"0.44979697",
"0.44893664",
"0.44723275",
"0.44610325",
"0.44588616",
"0.44541484",
"0.44534236",
"0.44515997",
"0.44502434",
"0.44497988",
"0.4447523",
"0.4447399",
"0.44458088",
"0.44457334",
"0.44434112",
"0.44429153",
"0.44385353",
"0.44384277",
"0.4435435",
"0.4435435",
"0.44342288",
"0.44338366",
"0.44192228",
"0.4417155",
"0.44114274",
"0.44102886",
"0.44047976",
"0.44047976",
"0.4403036",
"0.4397284",
"0.4397284",
"0.43961462",
"0.4392994"
] | 0.0 | -1 |
GET /barks or /barks.json | def index
@barks = Bark.all.order('created_at DESC')
@bark = Bark.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kbs }\n end\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def show\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @barrack }\n end\n end",
"def get_banks\n HTTParty.get(BASE_URI + 'bank?country=ghana',\n headers: HEADERS).parsed_response\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend",
"def banks_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: BanksApi#banks_get ...\"\n end\n \n # resource path\n path = \"/banks\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\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/x-www-form-urlencoded']\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 = ['khipu']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'BanksResponse')\n if Configuration.debugging\n Configuration.logger.debug \"API called: BanksApi#banks_get. Result: #{result.inspect}\"\n end\n return result\n end",
"def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n @bikes = current_user.bikes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bikes }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @barns = current_user.barns\n\n set_page_title\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @barns }\n end\n end",
"def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end",
"def index\n if current_authkey.authkey.eql?(\"#fl0wk27er\")\n @batons = Baton.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batons }\n end\n elsif current_authkey.authkey.eql?(\"#daneld2130\")\n redirect_to daniel_batons_path\n elsif current_authkey.authkey.eql?(\"#cassaj0105\")\n redirect_to casa_batons_path\n elsif current_authkey.authkey.eql?(\"#hulkh2051\")\n redirect_to hulk_batons_path\n elsif current_authkey.authkey.eql?(\"#genllt5055\")\n redirect_to think_batons_path\n else\n redirect_to root_path\n end\n end",
"def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end",
"def index\n @non_smoking_bars = NonSmokingBar.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @non_smoking_bars }\n end\n end",
"def drugbank_get(route, params)\n url = $drugbank_api + route\n res = HTTParty.get(url, :query => params, :headers => $drugbank_headers)\n return res\nend",
"def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end",
"def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def index\n # Retrieve kpis templates from impac api.\n # TODO: improve request params to work for strong parameters\n attrs = params.slice('metadata', 'opts')\n auth = { username: MnoEnterprise.tenant_id, password: MnoEnterprise.tenant_key }\n\n response = begin\n MnoEnterprise::ImpacClient.send_get('/api/v2/kpis', attrs, basic_auth: auth)\n rescue => e\n return render json: { message: \"Unable to retrieve kpis from Impac API | Error #{e}\" }\n end\n\n # customise available kpis\n kpis = (response['kpis'] || []).map do |kpi|\n kpi = kpi.with_indifferent_access\n kpi[:watchables].map do |watchable|\n kpi.merge(\n name: \"#{kpi[:name]} #{watchable.capitalize unless kpi[:name].downcase.index(watchable)}\".strip,\n watchables: [watchable],\n target_placeholders: {watchable => kpi[:target_placeholders][watchable]},\n )\n end\n end\n .flatten\n\n render json: { kpis: kpis }\n end",
"def index\n @boks = Bok.all\n end",
"def search\n @google = Rails.application.secrets.google_api_key\n puts query[\"query\"]\n @response = HTTParty.get(\"https://www.googleapis.com/books/v1/volumes?q=#{query[\"query\"]}&key=#{@google}\")\n render json: {data: @response}\n end",
"def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end",
"def banks_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.banks_get ...'\n end\n # resource path\n local_var_path = '/banks'\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2008')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#banks_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n respond_with BracketGolfer.all\n end",
"def index\n @barns = Barn.all\n end",
"def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def index # returns all bikes within a certain radius\n ## TODO: use coordinates later, when more campuses and bikes.\n # # defaults radius to half mile, and coordinate to requesting ip address\n # radius = params[:radius] ? params[:radius] : 0.5\n # coordinates = params[:coordinates] ? params[:coordinates] : request.location\n # puts coordinates\n # @bikes = Coordinate.near(coordinates, radius).joins(:bikes)\n @bikes = Bike.available\n render json: @bikes\n end",
"def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end",
"def show\n @bar = Bar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bar }\n end\n end",
"def index\n @abuckets = @account.abuckets\n @help = \"Bucket List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @abuckets }\n end\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def do_GET(request, response)\n status = 200\n content_type = \"text/html\"\n body = \"bender version #{BENDER_VERSION}\"\n body += \"\\n\"\n\n response.status = status\n response['Content-Type'] = content_type\n response.body = body\n response.body = body\n end",
"def show\n @bruger = Bruger.find_by_id(current_user.id)\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onske }\n end\n end",
"def index\n @loadbalancers = getmydata(\"Loadbalancer\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @loadbalancers }\n end\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def index\n @user=current_user\n\t @bars = @user.bars\n\t bar_num = @user.bars.count\n\t logger.error \"Bar Num: #{bar_num}\"\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bars }\n\tend\n end",
"def get(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :get,\n :url => \"#{self.uri}#{path}\",\n :headers => {\n :params => params\n },\n :verify_ssl=> @ssl_verify )\n end",
"def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end",
"def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend",
"def make_request(search_term)\n JSON.parse(RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"))\nend",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @breeding_pairs = current_user.breeding_pairs.all\n\n respond_to do |format|\n format.json { render json: @breeding_pairs }\n end\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def index\n @barn_configurations = BarnConfiguration.all\n set_page_title\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @barn_configurations }\n end\n end",
"def get(path, query={})\n request_json :get, path, query\n end",
"def show\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bloom }\n end\n end",
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def list\n get('/')\n end",
"def index\n @barrios = Barrio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @barrios }\n end\n end",
"def make_request(search_term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\")\n final_response = JSON.parse(response)\nend",
"def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def bars_results\n # params = {\n # \"Beer Country\"=>[\"Hong Kong\"],\n # \"controller\"=>\"api/vendors\",\n # \"action\"=>\"bars_results\",\n # \"format\"=>\"json\"\n # }\n puts \">>>>>>>\"\n puts \"[#{params[\"Beer Country\"]}]\"\n puts \"[#{params[\"HK Location\"]}]\"\n puts \"[#{params[\"Beer Style\"]}]\"\n puts \"[#{params[\"Brewery Name\"]}]\"\n puts \"[#{params[\"Beer Name\"]}]\"\n puts \"<<<<<<<\"\n\n #@bars = Vendor.joins(:beers).where(\"beers.country = ? AND vendors.district = ? AND beers.simpstyle = ? AND beers.brewery = ? AND beers.name = ?\", params[\"Beer Country\"], params[\"HK Location\"], params[\"Beer Style\"], params[\"Brewery Name\"], params[\"Beer Name\"]).uniq\n\n search_terms = {}\n search_terms['beers.country'] = params[\"Beer Country\"] unless params[\"Beer Country\"].nil?\n search_terms['vendors.district'] = params[\"HK Location\"] unless params[\"HK Location\"].nil?\n search_terms['beers.simpstyle'] = params[\"Beer Style\"] unless params[\"Beer Style\"].nil?\n search_terms['beers.brewery'] = params[\"Brewery Name\"] unless params[\"Brewery Name\"].nil?\n search_terms['beers.name'] = params[\"Beer Name\"] unless params[\"Beer Name\"].nil?\n\n @user_id = current_user ? current_user.id : nil\n @bars = Vendor.joins(:beers).joins(:vendor_types).where(search_terms).where('vendor_types.vendor_type': 'Bar').uniq\n\n #@bars = Vendor.joins(:beers).where({\n # 'beers.country': params[\"Beer Country\"],\n # 'vendors.district': params[\"HK Location\"],\n # 'beers.simpstyle': params[\"Beer Style\"],\n # 'beers.brewery': params[\"Brewery Name\"],\n # 'beers.name': params[\"Beer Name\"]\n #}).uniq\n\n # @bars = Vendor.joins(:beers).where(\"beers.country = ? AND district = ?\", \"USA\", \"Sheung Wan\").uniq\n # @bars = VendorType.includes(:vendor).where(vendor_type: 'Bar').map(&:vendor) # returns just bars\n\n if @bars.nil?\n render json: { message: \"Cannot find bars\" }, status: :not_found\n else\n @bars\n end\n end",
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def index\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @bookings = prep_bookings\n render json: @bookings, status: :ok\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def index\n @bobs = Bob.paginate(:page => params[:page], :order => 'created_at DESC',:per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bobs }\n end\n end",
"def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end",
"def search_for_google_books(search_term)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"\n response = RestClient.get(url)\n hash = JSON.parse(response)\n hash[\"items\"]\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 index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end",
"def index\n @bbhks = Bbhk.all\n end",
"def index\n get('')\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def show\n begin\n @response = Booking.get_booking(params[:id])\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n end",
"def show\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @barrio }\n end\n end",
"def get_book(search)\n\trequest_string = \"https://www.googleapis.com/books/v1/volumes?q=#{search.gsub(\" \",\"+\")}\"\n\t\n\tsample_uri = URI(request_string) #opens a portal to the data at that link\n\tsample_response = Net::HTTP.get(sample_uri) #go grab the data in the portal\n\tsample_parsedResponse = JSON.parse(sample_response) #makes data easy to read\n\tsample_parsedResponse[\"items\"]\nend",
"def index \n local = params[:local]\n \n if (local.to_s.empty?)\n render json: 'Not found', status: 404 \n else\n params = {:query => local, :access_key => \"f613d33c4f74fc5b648685dc3428d345\"}\n conn = Faraday.get(\"http://api.weatherstack.com/current\", params) do |req|\n req.headers['Content-Type'] = 'application/json'\n end\n render json: conn.body \n end\n end",
"def index\n @brands = Brand.all\n if params[:name]\n \t@brand = Brand.find_by_name(params[:name])\n end\n\n respond_to do |format|\n \tif @brand\n \t\tformat.html { redirect_to @brand }\n \t\tformat.json { render json: @brand }\n \telse\n\t format.html # index.html.erb\n \tformat.json { render json: @brands }\n end\n end\n end",
"def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def show\n @title = @header = @boat_type.catalog_name \n \n #@data = is_control? ? {boat_type: @boat_type.hash_view(current_site, cur_locale.to_s), trademarks: @trademarks, boat_series: @boat_series} : {boat_type: @boat_type}\n respond_to do |format|\n format.html \n format.json { render json: @data}\n end\n end",
"def all\n api_get(path)\n end",
"def get(path, params={}, options={})\n request(:get, api_path(path), params, options)\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def index\n @bids = Bid.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bids }\n end\n end",
"def api_keys; rest_query(:api_key); end",
"def api_keys; rest_query(:api_key); end",
"def show\n @non_smoking_bar = NonSmokingBar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @non_smoking_bar }\n end\n end",
"def show\n # Let's make sure someone is logged in. If not, send them to the user homepage\n if not session[:user_id] and not session[:bar_id]\n redirect_to '/userhome'\n return\n end\n \n # Fetch the bar being requested\n begin\n @bar = Bar.find(params[:id])\n rescue\n flash[:notice] = 'The requested bar does not exist.'\n redirect_to '/userhome'\n return\n end\n \n # Fetch the favorites \n @favorite = Favorite.where('user_id = ? and bar_id = ?', session[:user_id], @bar.id)\n \n # Fetch the events\n @events = BarEvent.where('bar_id = ?', @bar.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bar }\n end\n end",
"def index\n respond_with Biblebook.all\n end",
"def show\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @barrio }\n end\n end",
"def show\n render json: @bike #serializer: Web::V1::BikeSerializer\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def get(api)\n\t\t\tvalidate_api(api)\n\t\t\tparams = set_default_params(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend",
"def index\n @bemaps = Bemap.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bemaps }\n end\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def index\n @baz42s = Baz42.all\n end",
"def allergies\n raise UserNotAuthenticated unless access_token\n\n get('records/allergies')\n end",
"def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end",
"def index\n @cat_bloks = params[:q] ? CatBlok.search_for(params[:q]) : CatBlok.all \n end",
"def index\n @banners = Banner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @banners }\n end\n end",
"def index\n @batting_lines = BattingLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batting_lines }\n end\n end"
] | [
"0.6698829",
"0.6591819",
"0.63576835",
"0.62608725",
"0.62539774",
"0.6245141",
"0.61578286",
"0.61014587",
"0.60914284",
"0.6090552",
"0.6056627",
"0.5987603",
"0.59819996",
"0.5978963",
"0.58918744",
"0.58896375",
"0.58797693",
"0.58732694",
"0.5860237",
"0.5845424",
"0.58280766",
"0.5825921",
"0.579477",
"0.5780389",
"0.578032",
"0.57730913",
"0.5769367",
"0.57392687",
"0.57375515",
"0.5725613",
"0.5703366",
"0.56944996",
"0.5690452",
"0.56791353",
"0.5674852",
"0.5673026",
"0.5670169",
"0.5664806",
"0.56640416",
"0.5650725",
"0.56459165",
"0.5638413",
"0.56337035",
"0.5628734",
"0.5614137",
"0.5604041",
"0.55907977",
"0.5582667",
"0.5574215",
"0.5574215",
"0.5568334",
"0.55682606",
"0.5567566",
"0.55653685",
"0.5558869",
"0.5557496",
"0.55562335",
"0.55508393",
"0.55503285",
"0.5547019",
"0.554264",
"0.55399764",
"0.55338925",
"0.55338925",
"0.5532554",
"0.5525858",
"0.55237496",
"0.5518312",
"0.5499142",
"0.5494943",
"0.5489488",
"0.54892945",
"0.5487799",
"0.5485505",
"0.54822874",
"0.54819584",
"0.54769063",
"0.54756093",
"0.54695195",
"0.5467067",
"0.54669416",
"0.54576886",
"0.54529655",
"0.5452771",
"0.5451394",
"0.5451394",
"0.54508966",
"0.54498845",
"0.5449184",
"0.54476315",
"0.544618",
"0.5445529",
"0.5443808",
"0.54424155",
"0.5438774",
"0.54350334",
"0.54307526",
"0.5429018",
"0.54285055",
"0.5426369",
"0.54241604"
] | 0.0 | -1 |
GET /barks/1 or /barks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @barrack }\n end\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def show\n @kb = Kb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kb }\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend",
"def show\n @bar = Bar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bar }\n end\n end",
"def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end",
"def index\n @kbs = Kb.search(params[:q]).page(params[:page]).order(\"id desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kbs }\n end\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end",
"def banks_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: BanksApi#banks_get ...\"\n end\n \n # resource path\n path = \"/banks\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\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/x-www-form-urlencoded']\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 = ['khipu']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'BanksResponse')\n if Configuration.debugging\n Configuration.logger.debug \"API called: BanksApi#banks_get. Result: #{result.inspect}\"\n end\n return result\n end",
"def show\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @barrio }\n end\n end",
"def show\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bloom }\n end\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def api_get(path, params = {})\n api_request(:get, path, :params => params)\n end",
"def get_banks\n HTTParty.get(BASE_URI + 'bank?country=ghana',\n headers: HEADERS).parsed_response\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def show\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @barrio }\n end\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def get(path, query={})\n request_json :get, path, query\n end",
"def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end",
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def get(path)\n # TODO: do more hardening on the path\n if path.include?('covid19')\n request = Net::HTTP::Get.new(path, @headers)\n else\n request = Net::HTTP::Get.new('/v2' + path, @headers)\n end\n send_request(request)\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def index\n @shop_section = ShopSection.find_by_short_url(\"brands\")\n @brands = Brand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brands }\n end\n end",
"def get(path)\n request = Net::HTTP::Get.new @uri.path+'/'+path\n request.basic_auth @api_key, ''\n request['User-Agent'] = USER_AGENT\n response = @https.request request\n JSON.parse response.body\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\n end",
"def get_response(resource, query_string)\n config = YAML.load(File.read(\"giantbomb.yaml\"))\n api_key = config['api_key']\n api_base = config['api_base']\n return HTTParty.get(\"#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}\")\nend",
"def index\n if current_authkey.authkey.eql?(\"#fl0wk27er\")\n @batons = Baton.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batons }\n end\n elsif current_authkey.authkey.eql?(\"#daneld2130\")\n redirect_to daniel_batons_path\n elsif current_authkey.authkey.eql?(\"#cassaj0105\")\n redirect_to casa_batons_path\n elsif current_authkey.authkey.eql?(\"#hulkh2051\")\n redirect_to hulk_batons_path\n elsif current_authkey.authkey.eql?(\"#genllt5055\")\n redirect_to think_batons_path\n else\n redirect_to root_path\n end\n end",
"def show\n @bruger = Bruger.find_by_id(current_user.id)\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onske }\n end\n end",
"def show\n begin\n @response = Booking.get_booking(params[:id])\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def get(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :get,\n :url => \"#{self.uri}#{path}\",\n :headers => {\n :params => params\n },\n :verify_ssl=> @ssl_verify )\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end",
"def json_get(path, params={})\n json_request(:get, path, params)\n end",
"def index\n @bikes = current_user.bikes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bikes }\n end\n end",
"def drugbank_get(route, params)\n url = $drugbank_api + route\n res = HTTParty.get(url, :query => params, :headers => $drugbank_headers)\n return res\nend",
"def show\n @non_smoking_bar = NonSmokingBar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @non_smoking_bar }\n end\n end",
"def index\n @barns = current_user.barns\n\n set_page_title\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @barns }\n end\n end",
"def show\n @kazoku = Kazoku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kazoku }\n end\n end",
"def show\n if @bird\n respond_to do |format|\n format.json { render json: {required: @bird, properties: @bird.properties, families: @bird.families, title: \"POST /birds [request]\", description: \"Get bird by id\",:status => OK }}\n end\n else\n respond_to do |format|\n format.json { render json: {:status => NOT_FOUND} }\n end\n end\n end",
"def show\n @bico = Bico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bico }\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 serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end",
"def do_GET(request, response)\n status = 200\n content_type = \"text/html\"\n body = \"bender version #{BENDER_VERSION}\"\n body += \"\\n\"\n\n response.status = status\n response['Content-Type'] = content_type\n response.body = body\n response.body = body\n end",
"def index\n @birds = Bird.all.to_a\n begin\n respond_to do |format|\n format.json { render json: {items: @birds, description: \"List all visible birds in the registry\", additionalProperties: false, title: \"POST /birds [request]\",:status => OK } }\n end\n rescue => e\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end",
"def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end",
"def show\n @baggage = Baggage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @baggage }\n end\n end",
"def index\n @non_smoking_bars = NonSmokingBar.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @non_smoking_bars }\n end\n end",
"def get(path, **args); end",
"def index\n @user=current_user\n\t @bars = @user.bars\n\t bar_num = @user.bars.count\n\t logger.error \"Bar Num: #{bar_num}\"\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bars }\n\tend\n end",
"def show\n @apk_bin = ApkBin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apk_bin }\n end\n end",
"def banks_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConnectionsApi.banks_get ...'\n end\n # resource path\n local_var_path = '/banks'\n\n # query parameters\n query_params = {}\n query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse2008')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConnectionsApi#banks_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @barrios = Barrio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @barrios }\n end\n end",
"def show\n @title = @header = @boat_type.catalog_name \n \n #@data = is_control? ? {boat_type: @boat_type.hash_view(current_site, cur_locale.to_s), trademarks: @trademarks, boat_series: @boat_series} : {boat_type: @boat_type}\n respond_to do |format|\n format.html \n format.json { render json: @data}\n end\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end",
"def show\n @brewery = Brewery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brewery }\n end\n end",
"def query_api(path)\n with_http_error_handling do\n res = RestClient.get(endpoint + path)\n h = Hash.from_xml(res.body)\n h[\"response\"]\n end\n end",
"def index\n get('')\n end",
"def get(path, params={}, options={})\n request(:get, api_path(path), params, options)\n end",
"def get(path, params={})\n RestClient.get request_base+path, {params: params}\n end",
"def get(path, params = {})\n path = File.join(@prefix, path)\n JSON.parse @conn.get(path, params).body\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def index\n @loadbalancers = getmydata(\"Loadbalancer\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @loadbalancers }\n end\n end",
"def show\n @api_haiku = Api::Haiku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_haiku }\n end\n end",
"def get(path, busca=nil)\n @client.get(path, busca)\n end",
"def show\n render json: @bike #serializer: Web::V1::BikeSerializer\n end",
"def search\n @google = Rails.application.secrets.google_api_key\n puts query[\"query\"]\n @response = HTTParty.get(\"https://www.googleapis.com/books/v1/volumes?q=#{query[\"query\"]}&key=#{@google}\")\n render json: {data: @response}\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get_books(response)\n response[\"items\"]\nend",
"def show\n @basketball = Basketball.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basketball }\n end\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def get(path)\n request(:get, path, {})\n end",
"def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end",
"def show\n bike = Bike.find(params[:id]);\n render json: {status: 'SUCCESS', message:'Loaded bike', data:bike}, status: :ok\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def show\n @bagtype = Bagtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bagtype }\n end\n end",
"def search_for_google_books(search_term)\n url = \"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"\n response = RestClient.get(url)\n hash = JSON.parse(response)\n hash[\"items\"]\nend",
"def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end",
"def get(path, params)\n parse_response @client[path].get(:params => params)\n end",
"def make_request(search_term)\n JSON.parse(RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{search_term}\"))\nend",
"def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def show\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climb }\n end\n end",
"def show\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @koti }\n end\n end",
"def get; end",
"def get(path)\n request 'GET', path\n end",
"def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end",
"def show\n @boat = Boat.find(params[:id])\n @dockyard_spot = DockyardSpot.find_by_boat_id(@boat.id)\n @dockyard = Dockyard.find(@dockyard_spot.dockyard_id) unless @dockyard_spot.nil?\n @berth = Berth.where(:boat_id => @boat.id).first\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boat }\n end\n end",
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def index\n @boks = Bok.all\n end",
"def show\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kit }\n end\n end",
"def show\n @blast = Blast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blast }\n end\n end",
"def index\n @brands = Brand.all\n if params[:name]\n \t@brand = Brand.find_by_name(params[:name])\n end\n\n respond_to do |format|\n \tif @brand\n \t\tformat.html { redirect_to @brand }\n \t\tformat.json { render json: @brand }\n \telse\n\t format.html # index.html.erb\n \tformat.json { render json: @brands }\n end\n end\n end",
"def index\n @batting_lines = BattingLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batting_lines }\n end\n end"
] | [
"0.6599254",
"0.65854555",
"0.648414",
"0.64804435",
"0.6153299",
"0.6146643",
"0.61453545",
"0.61275506",
"0.60958946",
"0.6081435",
"0.60410964",
"0.6034058",
"0.5954818",
"0.5939912",
"0.5936391",
"0.59286743",
"0.591732",
"0.59138465",
"0.59123826",
"0.59052783",
"0.5899364",
"0.58770466",
"0.58598864",
"0.58509475",
"0.5836152",
"0.58288956",
"0.58232176",
"0.5784968",
"0.5783688",
"0.57812816",
"0.5767081",
"0.5764645",
"0.5764314",
"0.5756911",
"0.57547224",
"0.57498187",
"0.5738336",
"0.5738336",
"0.5734235",
"0.57248324",
"0.57194036",
"0.5715966",
"0.56965595",
"0.56953144",
"0.5690188",
"0.5681798",
"0.56782156",
"0.5676069",
"0.5671536",
"0.5670885",
"0.56702965",
"0.56688327",
"0.56669927",
"0.5664952",
"0.5663601",
"0.56565523",
"0.5651034",
"0.56401956",
"0.563209",
"0.5630307",
"0.56290555",
"0.5627099",
"0.5611643",
"0.5610847",
"0.56084853",
"0.56025684",
"0.55984783",
"0.559841",
"0.5595395",
"0.5593741",
"0.5583748",
"0.5582981",
"0.5581561",
"0.5580723",
"0.5580081",
"0.5580081",
"0.55782783",
"0.55762875",
"0.5575861",
"0.5574463",
"0.557139",
"0.5568412",
"0.5565608",
"0.5565038",
"0.55630285",
"0.55605006",
"0.55592835",
"0.55588573",
"0.55579233",
"0.5553905",
"0.5548192",
"0.5548164",
"0.554292",
"0.5542313",
"0.55347556",
"0.5534177",
"0.55258924",
"0.5523682",
"0.5515809",
"0.5515184",
"0.5512845"
] | 0.0 | -1 |
POST /barks or /barks.json | def create
@bark = current_user.barks.build(bark_params)
respond_to do |format|
if @bark.save
format.html { redirect_to root_path, notice: "Bark was successfully created." }
format.json { render :show, status: :created, location: @bark }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @bark.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @barrack = Barrack.new(params[:barrack])\n\n respond_to do |format|\n if @barrack.save\n format.html { redirect_to @barrack, notice: 'Barrack was successfully created.' }\n format.json { render json: @barrack, status: :created, location: @barrack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bark_params\n params.require(:bark).permit(:bark)\n end",
"def create\n @barn = Barn.new(barn_params)\n\n respond_to do |format|\n if @barn.save\n format.html { redirect_to @barn, notice: 'Barn was successfully created.' }\n format.json { render :show, status: :created, location: @barn }\n else\n format.html { render :new }\n format.json { render json: @barn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @barrack = Barrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @barrack }\n end\n end",
"def create\n @bok = Bok.new(bok_params)\n\n respond_to do |format|\n if @bok.save\n format.html { redirect_to @bok, notice: 'Bok was successfully created.' }\n format.json { render :show, status: :created, location: @bok }\n else\n format.html { render :new }\n format.json { render json: @bok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @non_smoking_bar = NonSmokingBar.new(params[:non_smoking_bar])\n\n respond_to do |format|\n if @non_smoking_bar.save\n format.html { redirect_to root_url, notice: 'Successfully created.' }\n format.json { render json: @non_smoking_bar, status: :created, location: @non_smoking_bar }\n else\n format.html { render action: \"new\" }\n format.json { render json: @non_smoking_bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kb = Kb.new(params[:kb])\n\n respond_to do |format|\n if @kb.save\n format.html { redirect_to @kb, :notice => 'Kb was successfully created.' }\n format.json { render :json => @kb, :status => :created, :location => @kb }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bbhk = Bbhk.new(bbhk_params)\n\n respond_to do |format|\n if @bbhk.save\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bbhk }\n else\n format.html { render action: 'new' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bark.update(bark_params)\n format.html { redirect_to @bark, notice: \"Bark was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bark }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar42 = Bar42.new(bar42_params)\n\n respond_to do |format|\n if @bar42.save\n format.html { redirect_to @bar42, notice: \"Bar42 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar42 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar42.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar = Bar.new(bar_params)\n\n respond_to do |format|\n if @bar.save\n format.html { redirect_to @bar, notice: 'Bar was successfully created.' }\n format.json { render :show, status: :created, location: @bar }\n else\n format.html { render :new }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar82 = Bar82.new(bar82_params)\n\n respond_to do |format|\n if @bar82.save\n format.html { redirect_to @bar82, notice: \"Bar82 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar82 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar82.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barn = Barn.new(params[:barn])\n\n respond_to do |format|\n if @barn.save\n BarnConfiguration.create_default(@barn)\n format.html { redirect_to '/barns/'[email protected]_s+'/controller_admins/new' }\n format.json { render json: @barn, status: :created, location: @barn }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end",
"def bar_params\n params.require(:bar).permit(:widget, :sprocket, :crank)\n end",
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def create\n @kingsizeb = Kingsizeb.new(kingsizeb_params)\n\n respond_to do |format|\n if @kingsizeb.save\n format.html { redirect_to @kingsizeb, notice: 'Kingsizeb was successfully created.' }\n format.json { render :show, status: :created, location: @kingsizeb }\n else\n format.html { render :new }\n format.json { render json: @kingsizeb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barco = Barco.new(barco_params)\n\n respond_to do |format|\n if @barco.save\n format.html { redirect_to @barco, notice: 'Barco was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barco }\n else\n format.html { render action: 'new' }\n format.json { render json: @barco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bike_rack = BikeRack.new(bike_rack_params)\n\n respond_to do |format|\n if @bike_rack.save\n flash[:success] = 'Bike rack was successfully created.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :created, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem with creating Bike rack.'\n format.html { render :new }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @baz42 = Baz42.new(baz42_params)\n\n respond_to do |format|\n if @baz42.save\n format.html { redirect_to @baz42, notice: \"Baz42 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz42 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz42.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bark\n @bark = Bark.find(params[:id])\n end",
"def create\n @bar8 = Bar8.new(bar8_params)\n\n respond_to do |format|\n if @bar8.save\n format.html { redirect_to @bar8, notice: \"Bar8 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar8 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar8.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar18 = Bar18.new(bar18_params)\n\n respond_to do |format|\n if @bar18.save\n format.html { redirect_to @bar18, notice: \"Bar18 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar18 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar18.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end",
"def create\n @baz94 = Baz94.new(baz94_params)\n\n respond_to do |format|\n if @baz94.save\n format.html { redirect_to @baz94, notice: \"Baz94 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz94 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz94.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boook = Boook.new(boook_params)\n\n respond_to do |format|\n if @boook.save\n format.html { redirect_to @boook, notice: 'Boook was successfully created.' }\n format.json { render :show, status: :created, location: @boook }\n else\n format.html { render :new }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @brave_burst = BraveBurst.new(brave_burst_params)\n\n respond_to do |format|\n if @brave_burst.save\n format.html { redirect_to @brave_burst, notice: 'Brave burst was successfully created.' }\n format.json { render action: 'show', status: :created, location: @brave_burst }\n else\n format.html { render action: 'new' }\n format.json { render json: @brave_burst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar84 = Bar84.new(bar84_params)\n\n respond_to do |format|\n if @bar84.save\n format.html { redirect_to @bar84, notice: \"Bar84 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar84 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar84.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar30 = Bar30.new(bar30_params)\n\n respond_to do |format|\n if @bar30.save\n format.html { redirect_to @bar30, notice: \"Bar30 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar30 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar30.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar36 = Bar36.new(bar36_params)\n\n respond_to do |format|\n if @bar36.save\n format.html { redirect_to @bar36, notice: \"Bar36 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar36 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar36.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar22 = Bar22.new(bar22_params)\n\n respond_to do |format|\n if @bar22.save\n format.html { redirect_to @bar22, notice: \"Bar22 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar22 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar22.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :post,\n :url => \"#{self.uri}#{path}\",\n :headers=> {},\n :payload=> params,\n :verify_ssl=> @ssl_verify )\n end",
"def create\n @bar97 = Bar97.new(bar97_params)\n\n respond_to do |format|\n if @bar97.save\n format.html { redirect_to @bar97, notice: \"Bar97 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar97 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar97.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar80 = Bar80.new(bar80_params)\n\n respond_to do |format|\n if @bar80.save\n format.html { redirect_to @bar80, notice: \"Bar80 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar80 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar80.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n RestClient.post request_base+path, params\n end",
"def create\n @bunker = Bunker.new(params[:bunker])\n\n respond_to do |format|\n if @bunker.save\n flash[:notice] = 'Bunker was successfully created.'\n format.html { redirect_to(@bunker) }\n format.xml { render :xml => @bunker, :status => :created, :location => @bunker }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bunker.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, 'rack.input' => rack_input\nend",
"def create\n @bar50 = Bar50.new(bar50_params)\n\n respond_to do |format|\n if @bar50.save\n format.html { redirect_to @bar50, notice: \"Bar50 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar50 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar50.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end",
"def create\n @stationary_batteries_battery_bank = StationaryBatteriesBatteryBank.new(stationary_batteries_battery_bank_params)\n\n respond_to do |format|\n if @stationary_batteries_battery_bank.save\n format.html { redirect_to @stationary_batteries_battery_bank, notice: 'Stationary batteries battery bank was successfully created.' }\n format.json { render :show, status: :created, location: @stationary_batteries_battery_bank }\n else\n format.html { render :new }\n format.json { render json: @stationary_batteries_battery_bank.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar52 = Bar52.new(bar52_params)\n\n respond_to do |format|\n if @bar52.save\n format.html { redirect_to @bar52, notice: \"Bar52 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar52 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar52.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params)\n time(\"POST #{path}\") { Cloudflarer.new.post(path, params) }\n end",
"def post_api(path, params={}, headers={})\n headers.merge!('CONTENT_TYPE' => \"application/json\")\n post path, params, headers\nend",
"def api_gateway_post(path, params)\n api_gateway_body_fwd = params.to_json\n rack_input = StringIO.new(api_gateway_body_fwd)\n\n post path, real_params = {}, {\"rack.input\" => rack_input}\nend",
"def create\n @barn_configuration = BarnConfiguration.new(params[:barn_configuration])\n\n respond_to do |format|\n if @barn_configuration.save\n format.html { redirect_to @barn_configuration, notice: 'Barn configuration was successfully created.' }\n format.json { render json: @barn_configuration, status: :created, barn: @barn_configuration }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barn_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar47 = Bar47.new(bar47_params)\n\n respond_to do |format|\n if @bar47.save\n format.html { redirect_to @bar47, notice: \"Bar47 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar47 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar47.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar81 = Bar81.new(bar81_params)\n\n respond_to do |format|\n if @bar81.save\n format.html { redirect_to @bar81, notice: \"Bar81 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar81 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar81.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cat_blok = CatBlok.new(cat_blok_params)\n\n respond_to do |format|\n if @cat_blok.save\n format.html { redirect_to cat_bloks_url, notice: 'Cat blok was successfully created.' }\n format.json { render :show, status: :created, location: @cat_blok }\n else\n format.html { render :new }\n format.json { render json: @cat_blok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @baz8 = Baz8.new(baz8_params)\n\n respond_to do |format|\n if @baz8.save\n format.html { redirect_to @baz8, notice: \"Baz8 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz8 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz8.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barcart = Barcart.new(barcart_params)\n\n respond_to do |format|\n if @barcart.save\n format.html { redirect_to @barcart, notice: 'Barcart was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barcart }\n else\n format.html { render action: 'new' }\n format.json { render json: @barcart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={}, options={})\n request(:post, api_path(path), params, options)\n end",
"def create\n @batter = Batter.new(batter_params)\n\n respond_to do |format|\n if @batter.save\n format.html { redirect_to @batter, notice: 'Batter was successfully created.' }\n format.json { render :show, status: :created, location: @batter }\n else\n format.html { render :new }\n format.json { render json: @batter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def create\n @baz27 = Baz27.new(baz27_params)\n\n respond_to do |format|\n if @baz27.save\n format.html { redirect_to @baz27, notice: \"Baz27 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz27 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz27.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params = nil)\n response = @connection.post do |req|\n req.headers = generate_headers\n req.url path\n req.body = params.to_json\n end\n Arke::Log.fatal(build_error(response)) if response.env.status != 201\n response\n end",
"def create\n @bar76 = Bar76.new(bar76_params)\n\n respond_to do |format|\n if @bar76.save\n format.html { redirect_to @bar76, notice: \"Bar76 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar76 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar76.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @baz39 = Baz39.new(baz39_params)\n\n respond_to do |format|\n if @baz39.save\n format.html { redirect_to @baz39, notice: \"Baz39 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz39 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz39.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar_item = BarItem.new(bar_item_params)\n\n respond_to do |format|\n if @bar_item.save\n format.html { redirect_to @bar_item, notice: 'Bar item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bar_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @bar_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params={})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def post(path, params = {})\n request(:post, path, params)\n end",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def create\n @baz80 = Baz80.new(baz80_params)\n\n respond_to do |format|\n if @baz80.save\n format.html { redirect_to @baz80, notice: \"Baz80 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz80 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz80.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @battery_bank = BatteryBank.new(battery_bank_params)\n\n respond_to do |format|\n if @battery_bank.save\n format.html { redirect_to @battery_bank, notice: 'Battery bank was successfully created.' }\n format.json { render :show, status: :created, location: @battery_bank }\n else\n format.html { render :new }\n format.json { render json: @battery_bank.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @brainfart = Brainfart.new(brainfart_params)\n\n respond_to do |format|\n if @brainfart.save\n format.html { redirect_to @brainfart, notice: 'Brainfart was successfully created.' }\n format.json { render :show, status: :created, location: @brainfart }\n else\n format.html { render :new }\n format.json { render json: @brainfart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @baz35 = Baz35.new(baz35_params)\n\n respond_to do |format|\n if @baz35.save\n format.html { redirect_to @baz35, notice: \"Baz35 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz35 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz35.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, options = {})\n nonce, signature = generate_signature\n options = options.merge(key: @api_key, nonce: nonce, signature: signature)\n result = @connection.post(\"#{path}/\", options).body\n JSON.parse(result)\n end",
"def create\n @bar90 = Bar90.new(bar90_params)\n\n respond_to do |format|\n if @bar90.save\n format.html { redirect_to @bar90, notice: \"Bar90 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar90 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar90.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kazoku = Kazoku.new(params[:kazoku])\n\n respond_to do |format|\n if @kazoku.save\n format.html { redirect_to @kazoku, :notice => 'Kazoku was successfully created.' }\n format.json { render :json => @kazoku, :status => :created, :location => @kazoku }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @kazoku.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def new\n @kb = Kb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @kb }\n end\n end",
"def post(path, params = {})\n\t\trequest(path, :post, params)\n\tend",
"def create\n @baz23 = Baz23.new(baz23_params)\n\n respond_to do |format|\n if @baz23.save\n format.html { redirect_to @baz23, notice: \"Baz23 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz23 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz23.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barrel = Barrel.new(barrel_params)\n\n respond_to do |format|\n if @barrel.save\n format.html { redirect_to @barrel, notice: 'Barrel was successfully created.' }\n format.json { render :show, status: :created, location: @barrel }\n else\n format.html { render :new }\n format.json { render json: @barrel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, **args); end",
"def create\n @baggage = Baggage.new(params[:baggage])\n\n respond_to do |format|\n if @baggage.save\n format.html { redirect_to @baggage, notice: 'Baggage was successfully created.' }\n format.json { render json: @baggage, status: :created, location: @baggage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baggage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @bar = Bar.new\n @button_text = \"Sign up!\"\n @show_tos = true\n @show_password_explanation = false\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bar }\n end\n end",
"def create\n @bar74 = Bar74.new(bar74_params)\n\n respond_to do |format|\n if @bar74.save\n format.html { redirect_to @bar74, notice: \"Bar74 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar74 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar74.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n @bar34 = Bar34.new(bar34_params)\n\n respond_to do |format|\n if @bar34.save\n format.html { redirect_to @bar34, notice: \"Bar34 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar34 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar34.errors, status: :unprocessable_entity }\n end\n end\n end",
"def call method, args = {}\n unless args.is_a? Hash\n raise ArgumentError.new \"argument must be a Hash\"\n end\n\n args.each_key do |key|\n if args[key].is_a?(Array) || args[key].is_a?(Hash)\n args[key] = JSON.dump(args[key])\n end\n end\n\n @faraday.post method, args\n end",
"def create\n @baz62 = Baz62.new(baz62_params)\n\n respond_to do |format|\n if @baz62.save\n format.html { redirect_to @baz62, notice: \"Baz62 was successfully created.\" }\n format.json { render :show, status: :created, location: @baz62 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @baz62.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barrio = Barrio.new(params[:barrio])\n\n respond_to do |format|\n if @barrio.save\n format.html { redirect_to @barrio, notice: 'Barrio was successfully created.' }\n format.json { render json: @barrio, status: :created, location: @barrio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barrio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @bark.destroy\n respond_to do |format|\n format.html { redirect_to barks_url, notice: \"Bark was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def barn_params\n params.require(:barn).permit(:barn_cleandate, :user_id, :equipment_issing, :descrption)\n end",
"def create\n @bar_graph = BarGraph.new(bar_graph_params)\n\n respond_to do |format|\n if @bar_graph.save\n format.html { redirect_to edit_bar_graph_path(@bar_graph), notice: 'Bar graph was successfully created.' }\n format.json { render :edit, status: :created, location: @bar_graph }\n else\n format.html { render :new }\n format.json { render json: @bar_graph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end",
"def post(path, data={})\n request(:post, path, data)\n end",
"def create\n @bowler = Bowler.new(bowler_params)\n @bowler.save\n respond_with(@bowler)\n end",
"def index\n if params[:name].present?\n @json = Punk::API.beers_name!(params[:name])\n elsif params[:abv_gt].present?\n @json = Punk::API.beers_abv_gt!(params[:abv_gt])\n elsif params[:abv_lt].present?\n @json = Punk::API.beers_abv_lt!(params[:abv_lt])\n else\n @json = Punk::API.all_beers!(params)\n end\n\n render json: {\n beers: @json\n }\n create(@json)\n end",
"def create\n @boc = Boc.new(boc_params)\n\n respond_to do |format|\n if @boc.save\n format.html { redirect_to new_boc_path, notice: 'Boc was successfully created.' }\n format.json { render :show, status: :created, location: @boc }\n else\n format.html { render :new }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.64246625",
"0.6424445",
"0.6054478",
"0.5923874",
"0.5910778",
"0.59107625",
"0.5903337",
"0.5902356",
"0.5887644",
"0.5884899",
"0.585661",
"0.58294487",
"0.5823725",
"0.57541114",
"0.5738117",
"0.57277936",
"0.5719391",
"0.56941056",
"0.5692517",
"0.5685203",
"0.56814486",
"0.5677195",
"0.56604195",
"0.5653917",
"0.56491333",
"0.56197983",
"0.5599463",
"0.5594438",
"0.5589474",
"0.5580617",
"0.5568845",
"0.5556245",
"0.5553472",
"0.5551586",
"0.55511844",
"0.55502725",
"0.5546129",
"0.55453277",
"0.5504946",
"0.550377",
"0.54986155",
"0.5490495",
"0.5490468",
"0.5484007",
"0.5483606",
"0.5480355",
"0.5479763",
"0.54778975",
"0.54738367",
"0.54652655",
"0.5462574",
"0.54595435",
"0.54568535",
"0.545645",
"0.54532194",
"0.54498196",
"0.54429686",
"0.5435499",
"0.54342437",
"0.54333615",
"0.54329914",
"0.5429941",
"0.5429941",
"0.5429941",
"0.542922",
"0.542922",
"0.542922",
"0.542922",
"0.542922",
"0.5425149",
"0.5423607",
"0.54104203",
"0.5405174",
"0.5401392",
"0.5394818",
"0.5394465",
"0.5386592",
"0.5384898",
"0.538015",
"0.53774726",
"0.5372295",
"0.5366524",
"0.5363536",
"0.5363431",
"0.5355962",
"0.53548545",
"0.5352388",
"0.5350467",
"0.5350086",
"0.5349161",
"0.5345047",
"0.5344931",
"0.533613",
"0.5333134",
"0.5332106",
"0.5323913",
"0.5322034",
"0.5321055",
"0.5315353",
"0.5312649"
] | 0.68822765 | 0 |
PATCH/PUT /barks/1 or /barks/1.json | def update
respond_to do |format|
if @bark.update(bark_params)
format.html { redirect_to @bark, notice: "Bark was successfully updated." }
format.json { render :show, status: :ok, location: @bark }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @bark.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n if @barrack.update_attributes(params[:barrack])\n format.html { redirect_to @barrack, notice: 'Barrack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar42.update(bar42_params)\n format.html { redirect_to @bar42, notice: \"Bar42 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar42 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar42.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 respond_to do |format|\n if @bar.update(bar_params)\n format.html { redirect_to @bar, notice: 'Bar was successfully updated.' }\n format.json { render :show, status: :ok, location: @bar }\n else\n format.html { render :edit }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar22.update(bar22_params)\n format.html { redirect_to @bar22, notice: \"Bar22 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar22 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar22.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz42.update(baz42_params)\n format.html { redirect_to @baz42, notice: \"Baz42 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz42 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz42.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barco.update(barco_params)\n format.html { redirect_to @barco, notice: 'Barco was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @barco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar18.update(bar18_params)\n format.html { redirect_to @bar18, notice: \"Bar18 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar18 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar18.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar8.update(bar8_params)\n format.html { redirect_to @bar8, notice: \"Bar8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar8.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baristum.update(baristum_params)\n format.html { redirect_to @baristum, notice: 'Baristum was successfully updated.' }\n format.json { render :show, status: :ok, location: @baristum }\n else\n format.html { render :edit }\n format.json { render json: @baristum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bar34.update(bar34_params)\n format.html { redirect_to @bar34, notice: \"Bar34 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar34 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar34.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar77.update(bar77_params)\n format.html { redirect_to @bar77, notice: \"Bar77 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar77 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar77.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boook.update(boook_params)\n format.html { redirect_to @boook, notice: 'Boook was successfully updated.' }\n format.json { render :show, status: :ok, location: @boook }\n else\n format.html { render :edit }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @foobar = Foobar.find(params[:id])\n\n respond_to do |format|\n if @foobar.update_attributes(params[:foobar])\n format.html { redirect_to @foobar, notice: 'Foobar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foobar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz1.update(baz1_params)\n format.html { redirect_to @baz1, notice: \"Baz1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar76.update(bar76_params)\n format.html { redirect_to @bar76, notice: \"Bar76 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar76 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar76.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar74.update(bar74_params)\n format.html { redirect_to @bar74, notice: \"Bar74 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar74 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar74.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to do |format|\n if @bar81.update(bar81_params)\n format.html { redirect_to @bar81, notice: \"Bar81 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar81 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar81.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar90.update(bar90_params)\n format.html { redirect_to @bar90, notice: \"Bar90 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar90 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar90.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar84.update(bar84_params)\n format.html { redirect_to @bar84, notice: \"Bar84 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar84 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar84.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foobar.update(foobar_params)\n format.html { redirect_to @foobar, notice: 'Foobar was successfully updated.' }\n format.json { render :show, status: :ok, location: @foobar }\n else\n format.html { render :edit }\n format.json { render json: @foobar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar80.update(bar80_params)\n format.html { redirect_to @bar80, notice: \"Bar80 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar80 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar80.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar30.update(bar30_params)\n format.html { redirect_to @bar30, notice: \"Bar30 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar30 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar30.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 # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @baz8.update(baz8_params)\n format.html { redirect_to @baz8, notice: \"Baz8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz8.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 @kb = Kb.find(params[:id])\n\n respond_to do |format|\n if @kb.update_attributes(params[:kb])\n format.html { redirect_to @kb, :notice => 'Kb was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar82.update(bar82_params)\n format.html { redirect_to @bar82, notice: \"Bar82 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar82 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar82.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar50.update(bar50_params)\n format.html { redirect_to @bar50, notice: \"Bar50 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar50 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar50.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar52.update(bar52_params)\n format.html { redirect_to @bar52, notice: \"Bar52 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar52 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar52.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz41.update(baz41_params)\n format.html { redirect_to @baz41, notice: \"Baz41 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz41 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz41.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar36.update(bar36_params)\n format.html { redirect_to @bar36, notice: \"Bar36 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar36 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar36.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar.update(bar_params)\n format.html { redirect_to @bar, notice: 'Bar was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barn.update(barn_params)\n format.html { redirect_to @barn, notice: 'Barn was successfully updated.' }\n format.json { render :show, status: :ok, location: @barn }\n else\n format.html { render :edit }\n format.json { render json: @barn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cat_blok.update(cat_blok_params)\n format.html { redirect_to cat_bloks_url, notice: 'Cat blok was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_blok }\n else\n format.html { render :edit }\n format.json { render json: @cat_blok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @baz55.update(baz55_params)\n format.html { redirect_to @baz55, notice: \"Baz55 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz55 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz55.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @batter.update(batter_params)\n format.html { redirect_to @batter, notice: 'Batter was successfully updated.' }\n format.json { render :show, status: :ok, location: @batter }\n else\n format.html { render :edit }\n format.json { render json: @batter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar_item.update(bar_item_params)\n format.html { redirect_to @bar_item, notice: 'Bar item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bar_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz23.update(baz23_params)\n format.html { redirect_to @baz23, notice: \"Baz23 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz23 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz23.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bok.update(bok_params)\n format.html { redirect_to @bok, notice: 'Bok was successfully updated.' }\n format.json { render :show, status: :ok, location: @bok }\n else\n format.html { render :edit }\n format.json { render json: @bok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barrel.update(barrel_params)\n format.html { redirect_to @barrel, notice: 'Barrel was successfully updated.' }\n format.json { render :show, status: :ok, location: @barrel }\n else\n format.html { render :edit }\n format.json { render json: @barrel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barcart.update(barcart_params)\n format.html { redirect_to @barcart, notice: 'Barcart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @barcart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz35.update(baz35_params)\n format.html { redirect_to @baz35, notice: \"Baz35 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz35 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz35.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar71.update(bar71_params)\n format.html { redirect_to @bar71, notice: \"Bar71 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar71 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar71.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz2.update(baz2_params)\n format.html { redirect_to @baz2, notice: \"Baz2 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz2 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz2.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @non_smoking_bar = NonSmokingBar.find(params[:id])\n\n respond_to do |format|\n if @non_smoking_bar.update_attributes(params[:non_smoking_bar])\n format.html { redirect_to root_url, notice: 'Successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @non_smoking_bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz43.update(baz43_params)\n format.html { redirect_to @baz43, notice: \"Baz43 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz43 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz43.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @baz94.update(baz94_params)\n format.html { redirect_to @baz94, notice: \"Baz94 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz94 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz94.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bucket_bloc.update(bucket_bloc_params)\n format.html { redirect_to @bucket_bloc, notice: 'Bucket bloc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bucket_bloc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n if @barrio.update_attributes(params[:barrio])\n format.html { redirect_to @barrio, notice: 'Barrio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @barrio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo1.update(foo1_params)\n format.html { redirect_to @foo1, notice: \"Foo1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"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 @bar13.update(bar13_params)\n format.html { redirect_to @bar13, notice: \"Bar13 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar13 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar13.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @baz83.update(baz83_params)\n format.html { redirect_to @baz83, notice: \"Baz83 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz83 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz83.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bbhk.update(bbhk_params)\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar97.update(bar97_params)\n format.html { redirect_to @bar97, notice: \"Bar97 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar97 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar97.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo8.update(foo8_params)\n format.html { redirect_to @foo8, notice: \"Foo8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo8.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz80.update(baz80_params)\n format.html { redirect_to @baz80, notice: \"Baz80 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz80 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz80.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boc.update(boc_params)\n format.html { redirect_to @boc, notice: 'Boc was successfully updated.' }\n format.json { render :show, status: :ok, location: @boc }\n else\n format.html { render :edit }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@title = @header = \"Изменение торговой марки\"\n respond_to do |format|\n if @boat_series.update(boat_series_params)\n #format.html { redirect_to @boat_series, notice: 'Торговая марка успешно изменена' }\n format.json { render json: @boat_series.to_json }\n else\n #format.html { render :edit }\n format.json { render json: @boat_series.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar47.update(bar47_params)\n format.html { redirect_to @bar47, notice: \"Bar47 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar47 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar47.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @blar.update(blar_params)\n format.html { redirect_to @blar, notice: 'Blar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @blar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz62.update(baz62_params)\n format.html { redirect_to @baz62, notice: \"Baz62 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz62 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz62.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz72.update(baz72_params)\n format.html { redirect_to @baz72, notice: \"Baz72 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz72 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz72.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @barrio = Barrio.find(params[:id])\n\n respond_to do |format|\n if @barrio.update_attributes(params[:barrio])\n format.html { redirect_to @barrio, :notice => 'Barrio ha sido actualizado.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @barrio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo88.update(foo88_params)\n format.html { redirect_to @foo88, notice: \"Foo88 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo88 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo88.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz81.update(baz81_params)\n format.html { redirect_to @baz81, notice: \"Baz81 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz81 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz81.errors, status: :unprocessable_entity }\n end\n end\n end",
"def restobooking\n @buchung = Buchung.find(params[:id])\n @buchung.status='B' \n \n respond_to do |format|\n if @buchung.update_attributes(params[:buchung])\n format.html { redirect_to @buchung, notice: 'Buchung wurde erfolgreich geaendert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @buchung.errors, status: :unprocessable_entity }\n end\n end \n end",
"def update\n respond_to do |format|\n if @baz27.update(baz27_params)\n format.html { redirect_to @baz27, notice: \"Baz27 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz27 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz27.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def patch(path, **args); 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 @bike_rack.update(bike_rack_params)\n flash[:success] = 'Bike rack was successfully updated.'\n format.html { redirect_to @bike_rack }\n format.json { render :show, status: :ok, location: @bike_rack }\n else\n flash[:danger] = 'There was a problem editing Bike rack.'\n format.html { render :edit }\n format.json { render json: @bike_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n\n respond_to do |format|\n params[:bundle][:category] = params[:bundle][:category].strip.downcase\n params[:bundle][:style] = params[:bundle][:style].strip.downcase\n params[:bundle][:color] = params[:bundle][:color].strip.downcase\n params[:bundle][:brand] = params[:bundle][:brand].strip.downcase\n params[:bundle][:make] = params[:bundle][:make].strip.downcase\n params[:bundle][:location] = params[:bundle][:location].strip.downcase\n\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boolio.update( boolio_params )\n format.html { redirect_to @boolio, notice: 'Boolio was successfully updated.' }\n format.json { render :show, status: :ok, location: @boolio }\n else\n format.html { render :edit }\n format.json { render json: @boolio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz54.update(baz54_params)\n format.html { redirect_to @baz54, notice: \"Baz54 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz54 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz54.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bunny.update(bunny_params)\n format.html { redirect_to @bunny, notice: 'Bunny was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bunny.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo10.update(foo10_params)\n format.html { redirect_to @foo10, notice: \"Foo10 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo10 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo10.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update\n respond_to do |format|\n if @foo19.update(foo19_params)\n format.html { redirect_to @foo19, notice: \"Foo19 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo19 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo19.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 @foo56.update(foo56_params)\n format.html { redirect_to @foo56, notice: \"Foo56 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo56 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo56.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @baz32.update(baz32_params)\n format.html { redirect_to @baz32, notice: \"Baz32 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @baz32 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @baz32.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @branch = Branch.friendly.find(params[:id])\n respond_to do |format|\n if @branch.update(branch_params)\n format.html { redirect_to @branch, notice: 'Branch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @branch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @abucket.update_attributes(params[:abucket])\n flash[:notice] = 'Bucket was successfully updated.'\n format.html { redirect_to(account_abuckets_path(@account)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @abucket.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.66103864",
"0.6525338",
"0.6412469",
"0.63037306",
"0.6233765",
"0.62271506",
"0.62136483",
"0.62129813",
"0.61933815",
"0.61432594",
"0.6134164",
"0.61065763",
"0.6066356",
"0.6062231",
"0.6054456",
"0.60389256",
"0.6028534",
"0.6025036",
"0.6017557",
"0.60162574",
"0.6016005",
"0.6011613",
"0.6004887",
"0.6000888",
"0.5990169",
"0.59900934",
"0.597294",
"0.5972894",
"0.5959705",
"0.59548146",
"0.5952663",
"0.5952077",
"0.59479463",
"0.59478915",
"0.5943177",
"0.594222",
"0.5938131",
"0.5931569",
"0.59226435",
"0.5920869",
"0.5913553",
"0.5911277",
"0.59085155",
"0.59037375",
"0.5894576",
"0.58882207",
"0.5886099",
"0.5884679",
"0.5883165",
"0.5876324",
"0.58740944",
"0.5870182",
"0.58633274",
"0.5856057",
"0.585389",
"0.58538204",
"0.5850649",
"0.58497906",
"0.58404243",
"0.5835956",
"0.58225507",
"0.58225507",
"0.5818344",
"0.5810997",
"0.5805517",
"0.58051544",
"0.5801522",
"0.5799081",
"0.57988083",
"0.5783297",
"0.57757354",
"0.5775104",
"0.5768896",
"0.576874",
"0.57681954",
"0.57677203",
"0.57661253",
"0.57611835",
"0.57429576",
"0.5741092",
"0.5739317",
"0.573901",
"0.5735641",
"0.57316",
"0.5726675",
"0.57238597",
"0.5723521",
"0.5722707",
"0.57223535",
"0.5716968",
"0.57168025",
"0.5714409",
"0.57121277",
"0.57111377",
"0.57100105",
"0.5708447",
"0.5701224",
"0.56961036",
"0.56876254",
"0.56871754"
] | 0.67966646 | 0 |
DELETE /barks/1 or /barks/1.json | def destroy
@bark.destroy
respond_to do |format|
format.html { redirect_to barks_url, notice: "Bark was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @barrack = Barrack.find(params[:id])\n @barrack.destroy\n\n respond_to do |format|\n format.html { redirect_to barracks_url }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def delete(*rest) end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @bar42.destroy\n respond_to do |format|\n format.html { redirect_to bar42s_url, notice: \"Bar42 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @barn = Barn.find(params[:id])\n @barn.destroy\n\n respond_to do |format|\n format.html { redirect_to barns_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def 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 # Make sure the request came from an admin\n unless session[:admin_id]\n redirect_to_home\n return\n end\n \n @bar = Bar.find(params[:id])\n @bar.destroy\n\n respond_to do |format|\n format.html { redirect_to bars_url }\n format.json { head :no_content }\n end\n end",
"def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end",
"def delete(args)\n args = {:path => args} unless args.is_a?(Hash)\n assert_supported_keys(args, [:path, :version, :callback, :context])\n assert_required_keys(args, [:path])\n args[:version] ||= -1\n\n if args[:callback] ## asynchronous\n raise KeeperException::BadArguments unless args[:callback].kind_of?(VoidCallback)\n return zoo_adelete(@zk_handle, args[:path], args[:version], args[:callback].proc, YAML.dump(args[:context]))\n end\n\n ## synchronous\n rc = zoo_delete(@zk_handle, args[:path], args[:version])\n raise KeeperException.by_code(rc), ZooKeeperFFI::zerror(rc) unless rc == ZOK\n return rc\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @baz42.destroy\n respond_to do |format|\n format.html { redirect_to baz42s_url, notice: \"Baz42 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @baz1.destroy\n respond_to do |format|\n format.html { redirect_to baz1s_url, notice: \"Baz1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def delete\n api(\"Delete\")\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @foobar = Foobar.find(params[:id])\n @foobar.destroy\n\n respond_to do |format|\n format.html { redirect_to foobars_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def b2_delete_file(file)\n\n if parse_files_json(file) == {}\n\n puts \"File not present\"\n\n else\n \n result_hash = convert_json(b2_delete_file_version(file))\n\n if result_hash[\"fileName\"] == file\n puts \"File deleted successfully\"\n else\n puts \"Error deleting file\"\n end\n\n end\n\nend",
"def destroy\n @bar47.destroy\n respond_to do |format|\n format.html { redirect_to bar47s_url, notice: \"Bar47 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar_item.destroy\n respond_to do |format|\n format.html { redirect_to bar_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar18.destroy\n respond_to do |format|\n format.html { redirect_to bar18s_url, notice: \"Bar18 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar22.destroy\n respond_to do |format|\n format.html { redirect_to bar22s_url, notice: \"Bar22 was successfully destroyed.\" }\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 @bbhk.destroy\n respond_to do |format|\n format.html { redirect_to bbhks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar74.destroy\n respond_to do |format|\n format.html { redirect_to bar74s_url, notice: \"Bar74 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar84.destroy\n respond_to do |format|\n format.html { redirect_to bar84s_url, notice: \"Bar84 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy\n @baz72.destroy\n respond_to do |format|\n format.html { redirect_to baz72s_url, notice: \"Baz72 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baz41.destroy\n respond_to do |format|\n format.html { redirect_to baz41s_url, notice: \"Baz41 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baz94.destroy\n respond_to do |format|\n format.html { redirect_to baz94s_url, notice: \"Baz94 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bread.destroy\n respond_to do |format|\n format.html { redirect_to breads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar52.destroy\n respond_to do |format|\n format.html { redirect_to bar52s_url, notice: \"Bar52 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end",
"def destroy\n @bar34.destroy\n respond_to do |format|\n format.html { redirect_to bar34s_url, notice: \"Bar34 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(major,minor)\n major = major.to_sym\n if minor\n delete_hash = minor\n else\n if storage.hash_exists?(major)\n delete_hash = storage.find(major)\n else\n puts 'Delete hash not found in storage.'\n puts 'Use: imgurr delete <id> <delete_hash>'\n return\n end\n end\n if ImgurAPI.delete(delete_hash)\n puts 'Successfully deleted image from Imgur'\n storage.delete(major)\n storage.save\n else\n puts 'Unauthorized Access. Wrong delete hash?'\n end\n end",
"def destroy\n @baz55.destroy\n respond_to do |format|\n format.html { redirect_to baz55s_url, notice: \"Baz55 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @kb = Kb.find(params[:id])\n @kb.destroy\n\n respond_to do |format|\n format.html { redirect_to kbs_url }\n format.json { head :ok }\n end\n end",
"def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end",
"def delete_api subpath, category=nil, &block\n\t\t\t@request_queue.delete \"/api/#{api_key}#{subpath}\", category, &block\n\t\tend",
"def destroy\n @bar8.destroy\n respond_to do |format|\n format.html { redirect_to bar8s_url, notice: \"Bar8 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baz8.destroy\n respond_to do |format|\n format.html { redirect_to baz8s_url, notice: \"Baz8 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar97.destroy\n respond_to do |format|\n format.html { redirect_to bar97s_url, notice: \"Bar97 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @baristum.destroy\n respond_to do |format|\n format.html { redirect_to barista_url, notice: 'Baristum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\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 @bar90.destroy\n respond_to do |format|\n format.html { redirect_to bar90s_url, notice: \"Bar90 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(name); end",
"def delete(name); end",
"def delete(path)\n path = format_path(path)\n bucket_path = get_bucket_path(path)\n date = gmtdate\n headers = {\n 'Host' => @aliyun_upload_host,\n 'Date' => date,\n 'Authorization' => sign('DELETE', bucket_path, '', '', date)\n }\n url = path_to_url(path)\n response = RestClient.delete(url, headers)\n response.code == 204 ? url : nil\n end",
"def destroy\n @bok.destroy\n respond_to do |format|\n format.html { redirect_to boks_url, notice: 'Bok was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def destroy\n @bar71.destroy\n respond_to do |format|\n format.html { redirect_to bar71s_url, notice: \"Bar71 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar77.destroy\n respond_to do |format|\n format.html { redirect_to bar77s_url, notice: \"Bar77 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @baz35.destroy\n respond_to do |format|\n format.html { redirect_to baz35s_url, notice: \"Baz35 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar36.destroy\n respond_to do |format|\n format.html { redirect_to bar36s_url, notice: \"Bar36 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @baz62.destroy\n respond_to do |format|\n format.html { redirect_to baz62s_url, notice: \"Baz62 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete(path, opts = {})\n request(:delete, path, opts).body\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @baz54.destroy\n respond_to do |format|\n format.html { redirect_to baz54s_url, notice: \"Baz54 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baz43.destroy\n respond_to do |format|\n format.html { redirect_to baz43s_url, notice: \"Baz43 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @barrio = Barrio.find(params[:id])\n @barrio.destroy\n\n respond_to do |format|\n format.html { redirect_to barrios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @barrio = Barrio.find(params[:id])\n @barrio.destroy\n\n respond_to do |format|\n format.html { redirect_to barrios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar76.destroy\n respond_to do |format|\n format.html { redirect_to bar76s_url, notice: \"Bar76 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar81.destroy\n respond_to do |format|\n format.html { redirect_to bar81s_url, notice: \"Bar81 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brew.destroy\n respond_to do |format|\n format.html { redirect_to brews_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar.destroy\n respond_to do |format|\n format.html { redirect_to bars_url, notice: 'Bar was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bar.destroy\n respond_to do |format|\n format.html { redirect_to bars_url, notice: 'Bar was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @bar80.destroy\n respond_to do |format|\n format.html { redirect_to bar80s_url, notice: \"Bar80 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"
] | [
"0.6676001",
"0.6607538",
"0.6607472",
"0.66072315",
"0.65900487",
"0.65897286",
"0.6547464",
"0.64660424",
"0.64660424",
"0.6464393",
"0.6458845",
"0.64166373",
"0.64010286",
"0.6387053",
"0.63831455",
"0.63682324",
"0.63682324",
"0.63682324",
"0.63682324",
"0.6350965",
"0.6339732",
"0.6337527",
"0.63166183",
"0.6314271",
"0.63074565",
"0.63041705",
"0.6302873",
"0.63024986",
"0.63024986",
"0.6300894",
"0.6298201",
"0.62830096",
"0.6282226",
"0.6275545",
"0.6258526",
"0.625498",
"0.6254887",
"0.6249541",
"0.6246444",
"0.6245196",
"0.6245142",
"0.62416226",
"0.6239597",
"0.62290585",
"0.622341",
"0.6222347",
"0.62154377",
"0.6215371",
"0.6211385",
"0.62047017",
"0.6202716",
"0.6195874",
"0.6195142",
"0.61940837",
"0.6190656",
"0.61888254",
"0.6188673",
"0.6188565",
"0.6184025",
"0.61832106",
"0.6182221",
"0.6182089",
"0.61813104",
"0.6179912",
"0.6178214",
"0.61777705",
"0.6176573",
"0.61748886",
"0.6174605",
"0.6173651",
"0.6173444",
"0.6173444",
"0.6171731",
"0.61714524",
"0.6170977",
"0.61695933",
"0.61680627",
"0.61676294",
"0.616689",
"0.6164051",
"0.6154632",
"0.6153778",
"0.61530864",
"0.61529523",
"0.6147262",
"0.61397624",
"0.61388993",
"0.6136961",
"0.61366975",
"0.61355436",
"0.6134704",
"0.6132964",
"0.6132531",
"0.61325026",
"0.6128101",
"0.611823",
"0.61168855",
"0.61168855",
"0.6112134",
"0.6106937"
] | 0.63406587 | 20 |
Use callbacks to share common setup or constraints between actions. | def set_bark
@bark = Bark.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 |
Only allow a list of trusted parameters through. | def bark_params
params.require(:bark).permit(:bark)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
End Class Methods Instance Methods | def moderator_of?(forum)
moderatorships.where('forum_id = ?', (forum.is_a?(Forum) ? forum.id : forum)).count == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end\n end",
"def end; end",
"def end; end",
"def end; end",
"def methods() end",
"def private; end",
"def end\n end",
"def end\n end",
"def end\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def class() end",
"def instance; end",
"def instance; end",
"def instance; end",
"def celebration; end",
"def end() end",
"def implementation; end",
"def implementation; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def finalized; end",
"def final; end",
"def ending\n abstract!\n end",
"def end_point; end",
"def instance_variables() end",
"def cls; end",
"def class; end",
"def class; end",
"def initialize\n \n end",
"def internal; end",
"def private_method\n end",
"def +@\n self\n end",
"def +@\n self\n end",
"def instance_variables; end",
"def initialize\n \n end",
"def _end!; end",
"def class_variables() end",
"def deter\n \n end",
"def refutal()\n end",
"def finish()\n #This is a stub, used for indexing\n end",
"def instances; end",
"def instances; end",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def public; end",
"def public; end",
"def suivre; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def initialize\n\t\t\n\tend",
"def operations; end",
"def operations; end",
"def schubert; end",
"def returns; end",
"def initialize()\r\n\r\n end",
"def instance_methods; end",
"def incomplete\r\n\r\n end",
"def probers; end",
"def initialize\r\n\r\n end",
"def class_variables; end",
"def verdi; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def custom; end",
"def custom; end",
"def main\n super\n return self\n end",
"def initialize() end",
"def close\n # this method may be left unimplemented if that is applicable\n end",
"def main_end ; end",
"def end\n j_instance.getEnd\n end",
"def superclass() end",
"def initialize\n\n end",
"def initialize\n\n end",
"def initialize; end"
] | [
"0.710527",
"0.7079218",
"0.7079218",
"0.7079218",
"0.707783",
"0.7053696",
"0.69864154",
"0.69365126",
"0.69365126",
"0.692868",
"0.692868",
"0.692868",
"0.692868",
"0.69109607",
"0.6808825",
"0.6808825",
"0.6808825",
"0.66090584",
"0.65659946",
"0.6538463",
"0.6538463",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.64453775",
"0.6378259",
"0.63577646",
"0.6303956",
"0.6278777",
"0.62556446",
"0.62411404",
"0.6220589",
"0.6220589",
"0.62151617",
"0.6191297",
"0.61908644",
"0.613184",
"0.613184",
"0.61027294",
"0.60954875",
"0.60919625",
"0.6078642",
"0.60616815",
"0.60414636",
"0.60365766",
"0.60247636",
"0.60247636",
"0.60241884",
"0.602222",
"0.602222",
"0.60092473",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5996726",
"0.5987806",
"0.59655106",
"0.59655106",
"0.5939001",
"0.59318817",
"0.5926622",
"0.5921502",
"0.59172696",
"0.5909783",
"0.59081125",
"0.58921367",
"0.58883303",
"0.58847463",
"0.58847463",
"0.58847463",
"0.58847463",
"0.58694476",
"0.58694476",
"0.58688205",
"0.58566356",
"0.5851021",
"0.5847564",
"0.5831341",
"0.58230186",
"0.58112574",
"0.58112574",
"0.5810792"
] | 0.0 | -1 |
should only be called after best guess is known! not enforced to allow non heuristic based csp search | def assignment_intialize
if(@puret and @puref)
return false
end
if(@num_negative == 0 or @puret)
@assignments = [1]
elsif(@num_positive == 0 or @puref)
@assignments = [-1]
elsif(@best_guess <0)
@assignments = [-1,1]
else
@assignments = [1,-1]
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heuristics\n raise NotImplementedError, \"not implemented in #{self}\"\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 compute_best\n best = @population.max_by { |x| x.fitness(@target) }\n @finished = true if best.fitness(@target) == @perfect_score\n best.phrase\n end",
"def compute_best\n best = @population.max_by { |x| x.fitness(@target) }\n @finished = true if best.fitness(@target) == @perfect_score\n best.phrase\n end",
"def most_likely_play\n @must_learn = true\n best_move = nil\n max = 0\n\n search_space = SearchSpace.new(@board, @most_alike_board, @color)\n search_space.each do |move|\n prob = probability_of(move)\n return move if prob >= Config::PROBS_THRESHOLD\n if max < prob\n max = prob\n best_move = move\n end\n end\n\n best_move\n end",
"def look_ahead(board, current_hand, ai_hand)\n #n = NegamaxAgent.new(board, current_hand, ai_hand)\n #n_suggested_move = n.invoke\n #n_suggested_card = n_suggested_move.first\n #n_x = n_suggested_move[1]\n #n_y = n_suggested_move[2]\n #n_s = n_suggested_move[3]\n\n #puts \"DEBUG: negamax suggested #{@player_hand.key(n_suggested_card)} @ #{n_x + 1}, #{n_y + 1} with score of #{n_s}\"\n #return\n\n available_cards = current_hand.values.compact\n available_spaces = board.open_spaces\n possible_moves = available_cards.product(available_spaces)\n\n best_moves = []\n value_of_best_move = -10\n\n possible_moves.each do |card, space|\n x, y = space\n value = board.next_state(card, x, y).score\n if value > value_of_best_move\n best_moves = [[card, x, y]]\n value_of_best_move = value\n elsif value == value_of_best_move\n \tbest_moves << [card, x, y]\n end\n end\n\n chosen_move = best_moves.sample\n card, x, y = chosen_move\n\n puts \"HINT: placing #{current_hand.key(card).rstrip} at #{x+1}, #{y+1} gives a good score of #{value_of_best_move}\"\n end",
"def hill_climbing(location)\n best = @fqueryObj\n score = @fqueryObj.score\n loc = location.to_s\n parseTree = @fqueryObj.parseTree\n\n # create stat table\n @tqueryObj.create_stats_tbl\n # rst = parseTree.constr_jsonpath_to_location(location)\n # last=rst.count-1\n # rst.delete_at(last)\n\n # predicatePath = '$..'+rst.map{|x| \"'#{x}'\"}.join('.')\n # predicatePath = parseTree.get_jsonpath_from_location(location)\n # predicate = JsonPath.new(predicatePath).on(parseTree)\n\n # generate_candiateList(predicate)\n # generate_candidateConstList()\n # @tabuList=[]\n\n i = 0\n while (i <= @max_iter) && score[loc].to_i > 0\n # neighbor = generate_neighbor_program(parseTree,predicatePath)\n neighbor = @fqueryObj.generate_neighbor_program(location, 1)\n if neighbor.nil?\n puts 'no candidates available! '\n break\n end\n # neighbor.table='evl_tbl'\n evaluate_query(neighbor, @tqueryObj)\n s = neighbor.score\n\n if s[loc].to_i < score[loc].to_i\n score = s\n best = neighbor\n end\n puts \"iteration: #{i}\"\n puts'current best query'\n puts best.query\n i += 1\n end\n end",
"def optimize_kevin_bacon_search\n\t\t# winning_attempts = []\n\t\t# find_kevin_bacon_2(winning_attempts)\n\t\t# if winning_attempts.count > 0\n\t\t\t# winning_attempts.each do |attempt|\n\t\t\t\t# compare with a neighbor, shorter one wins\n\t\t\t\t# there will be lots of ties we skip over\n\t\t# else\n\t\t\t# returns nil\n\t\t# end\n\t\twinning_attempts = []\n\t\tfind_save_kevin_bacon(start_node, winning_attempts)\n\t\twinning_attempts.compact!\n\t\tif winning_attempts.count == 0\n\t\t\tputs 'no bacon :('\n\t\telse\n\t\t\twinning_attempts.index do |i|\n\t\t\t\tif i != 0\n\t\t\t\t\tif winning_attempts[i - 1] < winning_attempts[i]\n\t\t\t\t\t\twinning_attempts.delete_at(i)\n\t\t\t\t\telse\n\t\t\t\t\t\twinning_attempts.delete_at(i - 1)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\twinning_attempts\n\tend",
"def prepare_preferred_algorithms!; end",
"def brute_force_optimal(tg,faulty,replacements,n)\n if tg[1].size == 0 # special case if there are no edges(all replacements are equal)\n return get_mappings(faulty,replacements)[0] # return the first mapping\n end\n get_mappings(faulty,replacements).min_by do |a|\n euclidean_distance(tg,a,n) \n end\nend",
"def hureistic_search (board) #open useful in finding min conflicts\n end",
"def first_guess\n unmatched_pos || random_guess\n end",
"def search\n prepare_search\n catch :success do\n # Main iteration loop\n @max_iterations.times do |iteration|\n begin # RuntimeError rescue block\n # At the start of each iteration\n prepare_each_run\n if @banned_points.has_key?(path.last) && path.size == 1\n throw :success\n end\n debug_each_iteration iteration\n going = catch :keep_going do\n message = catch :jump_back do\n # cost_vector is a list of all adjacent points with their \n # respective costs\n candidate_list = get_candidate_list\n begin # IndexError rescue block\n # If we've run out of all possible points, step back and keep \n # trying. Only works when candidate_list#size is the largest\n # dimension, i.e., for a normal Array of NArrays. For NArray, \n # #size gives the total number of elements.\n if @interval_index >= candidate_list.size \n throw :jump_back, \"index #{@interval_index} is out of range\"\n end\n # Load up the candidate from the cost_vector\n candidate = candidate_list[@interval_index]\n candidate_cost = get_cost candidate\n # Skip all candidates that are banned, are already in the path, \n # or don't get us any closer.\n while (@banned_points.has_key? candidate.hash) || (@path.include? candidate) || (candidate_cost >= @current_cost)\n @interval_index += 1\n # If we've exhausted all possible intervals, jump back\n if @interval_index >= candidate_list.size\n @banned_points[candidate.hash] = 1\n throw :jump_back, \"index #{@interval_index} is out of range\"\n end\n # Get the movement that is at the current index\n candidate = candidate_list[@interval_index]\n candidate_cost = get_cost candidate\n end\n # Add it to the path!\n @path << candidate\n @current_cost = candidate_cost\n rescue IndexError => er\n puts \"\\nIndexError: #{er.message}\"\n print er.backtrace.join(\"\\n\")\n throw :jump_back\n rescue RangeError => er\n # If handle_range_error has not been defined in a subclass, any \n # call will just re-raise the exception\n handle_range_error er\n end\n # Judge success\n if @current_cost < @epsilon\n @current_point = @path.last\n prepare_result\n throw :success\n else\n @initial_run = true\n throw :keep_going, true\n end\n end # catch :jump_back\n if @debug_level > 1\n puts message\n end\n jump_back\n end # catch :keep_going\n if going\n keep_going\n going = false\n end\n rescue RuntimeError => er\n puts \"\\n#{er.message}\"\n print er.backtrace.join(\"\\n\")\n print \"\\n\\nPath: #{@path.to_a}\\n\"\n break\n end #RuntimeError block\n end # main iteration loop\n end # catch :success\n debug_final_report\n prepare_data\n @data\n end",
"def exec_search_nCOP_heruistic\n # select a starting node\n s_gene = get_start_gene\n \n # initialize cover and other variables\n cover, cov_pat, $explored = [], Set.new, Set.new\n cover << s_gene and cov_pat.merge $genes[s_gene]\n start_cost = cost_func cover, cov_pat.size\n \n # run nCOP greedy heuristic\n nCOP_heuristic(cover, cov_pat, start_cost)\n \n # learn which genes are bad starting nodes\n if cover.size < 3\n $bad_starting_genes << s_gene\n end\n \n # return the cover found\n cover\nend",
"def heuristic_score\n 0\n end",
"def evaluate\n\t\tif !empty?\n\t\t\tpossible_suggestion = PossibleSuggestion.new( trim_lastfm_track(@similar_tracks.shift) )\n\t\t\t#see if track is already in pool; see method 'return_suggestion_with_traits' in Blackboard class\n\t\t\tres = get_suggestion_from_pool_with_traits( possible_suggestion )\n\t\t\tif res\n\t\t\t\t#if we have seen this suggestion before, add the related assumption to the existing track\n\t\t\t\ttrack_recommended_more_than_once = Assumption.new( self, Constants::TRACK_RECOMMENDED_MORE_THAN_ONCE, res )\n\t\t\t\tres.add_affirmation( Affirmation.new(track_recommended_more_than_once) )\n\t\t\t\tputs \"SimilarTracks KS added positive assumption for #{res.get_artist}, #{res.get_track}\"\n\t\t\telsif !reject_pool_contains_suggestion?( possible_suggestion )\n\t\t\t\[email protected]( possible_suggestion )\n\t\t\tend\n\t\telse\n\t\t\tputs \"SimilarTracks KS ran out of suggestions!\"\n\t\t\tConstants::NO_REMAINING_SUGGESTIONS\n\t\tend\n\tend",
"def local_search(problem, max_iterations, max_unimprove_iterations, max_time, \n max_unimprove_time, mut_rate, report_time_interval = 2)\n best = greedy_solve(problem)[:solution]\n best_find_time = 0\n iter = 1\n unimprove_iter = 1\n unimprove_start_time = Time.now\n last_improve_time = Time.now\n start_time = Time.now\n last_rep_time = Time.now\n while ((!max_iterations || iter <= max_iterations) and \n (!max_unimprove_iterations || unimprove_iter <= max_unimprove_iterations) and\n (!max_time || (Time.now - start_time).to_i <= max_time) and \n (!max_unimprove_time || (Time.now - last_improve_time).to_i <= max_unimprove_time)) do\n nxt = mutate(best, problem.path_funcs.length, mut_rate) \n if objective_function(nxt, problem.path_funcs) > objective_function(best, problem.path_funcs) \n unimprove_start_time = Time.now\n last_improve_time = Time.now\n unimprove_iter = 1\n best = nxt\n best_find_time = Time.now - start_time\n else\n unimprove_iter += 1\n end\n iter += 1\n if (Time.now - last_rep_time).to_i >= report_time_interval\n msg = \"Iteration = #{iter}, Obj = #{objective_function(best, problem.path_funcs)}, \"\n msg += \"Elapsed Time = #{Time.now - start_time}\"\n puts msg\n last_rep_time = Time.now\n end\n end\n {:solution => best, :objective_func => objective_function(best, problem.path_funcs), \n :elapsed_time => Time.now - start_time, :best_find_time => best_find_time}\n end",
"def make_guess(secret_code)\n if guess == [0, 0, 0, 0]\n first_guess\n return guess\n end\n reduce_solution_set(secret_code)\n update_guess\n guess\n end",
"def heuristic_solving_possible\n prev_item = nil\n items.each do |item|\n if prev_item.present?\n if item[:c] < prev_item[:c]\n # \"The absolute cost of a heavier item (cost #{item[:c]} with weight #{item[:w]}) is lower than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]})\"\n return false\n elsif (item[:c].to_f / item[:w].to_f) > (prev_item[:c].to_f / prev_item[:w].to_f)\n # \"The relative cost of a heavier item (cost #{item[:c]} with weight #{item[:w]} having a relative cost of #{item[:c].to_f/item[:w].to_f}) is higher than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]} having a relative cost of #{prev_item[:c].to_f/prev_item[:w].to_f})\"\n return false\n end\n end\n prev_item = item\n end\n true\n end",
"def build_candidates\n doc = Nokogiri::HTML(open(\"http://www.google.com/search?q=#{query}&num=30\"))\n doc.xpath('//div/cite').each do |node|\n @candidates << Sanitize.clean(node)\n end\n\n @candidates = @candidates.collect{|c| c if c.include?(\"http\") && (c.include?(\"youtube.com\") || c.include?(\"soundcloud.com\") || c.include?(\"bandcamp.com\")) }.compact\n\n #replace each with url, score, and title\n set = []\n\n @candidates.each do |c|\n if c.include?(\"youtube\")\n set << get_youtube(c)\n elsif c.include?(\"soundcloud\")\n set << get_soundcloud(c)\n elsif c.include?(\"bandcamp\")\n set << get_bandcamp(c)\n end\n end\n\n @candidates = set\n @candidates.sort!{|x,y| y[:score] <=> x[:score]}\n puts @candidates.count\n end",
"def find_candidate_for_guessing\n unassigned_cells.sort_by { |cell|\n [cell.available_values.size, to_s]\n }.first\n end",
"def find_pair\n before = self.entropy\n reduce_pair_line\n reduce_pair_col\n reduce_pair_grid\n reduce_solved if before > self.entropy\n self\n end",
"def ceeb_code_guess(name_value = self.name.gsub(\"-\",\" \").gsub(\"Campus\",\"\"), try_again_on_failure = true)\n uri = Addressable::URI.parse(\"http://sat.collegeboard.org/register/sat-code-search-schools\")\n uri.query_values = {\n \"decorator\" => \"none\",\n \"submissionMode\" => \"ajax\",\n \"pageId\" => \"registerCodeSearch\",\n \"codeType\" => \"college-code\",\n \"country\" => \"US\",\n \"state\" => self.state,\n \"collegeScholorshipName\" => name_value.strip\n }\n url = uri.normalize.to_s\n puts \"Fetching CEEB code results from #{url}\"\n response = open(url).read\n document = Nokogiri::HTML(response)\n results = nil\n if document.xpath(\"//h3\").text == \"No Results\"\n results = self.ceeb_code_guess(self.f1sysnam, false) if try_again_on_failure\n return results\n else\n results = {}\n codes = document.xpath(\"//tr[@class!='headerRow']/td[@class='codeResultCell']\").collect(&:text).collect(&:to_i)\n names = document.xpath(\"//tr[@class!='headerRow']/td[@class='schoolResultCell']\").collect(&:text)\n codes.each_with_index do |code, i|\n results[codes[i]] = names[i].strip\n end\n if results.empty?\n return nil\n elsif results.size == 1\n return results.keys.first\n else\n return results\n end\n end\n end",
"def best_solution\n # Sort existing solutions by expected makespan.\n @solutions.sort_by!(&:expected_makespan)\n # First solution is the best one.\n @solutions.first\n end",
"def generate_best_pairings(state)\n teams = state.teams\n\n state.matches = state.driver.matches_hash\n\n state.score_range = state.scores.values.max - state.scores.values.min\n state.average_score_difference = state.score_range / teams.length.to_f\n\n state.team_index_map = teams.map.with_index.to_h\n\n Algorithm::Matching.minimum_weight_perfect_matching(teams) do |home_team, away_team|\n cost_function(state, home_team, away_team)\n end\n end",
"def ceeb_code_guess(name_value = self.name, try_again_on_failure = false)\n uri = Addressable::URI.parse(\"http://sat.collegeboard.org/register/sat-code-search-schools\")\n uri.query_values = {\n \"decorator\" => \"none\",\n \"submissionMode\" => \"ajax\",\n \"pageId\" => \"registerCodeSearch\",\n \"codeType\" => \"high-school-code\",\n \"country\" => \"US\",\n \"state\" => self.state || \"WA\",\n \"city\" => self.city\n }\n url = uri.normalize.to_s\n puts \"Fetching CEEB code results from #{url}\"\n response = open(url).read\n document = Nokogiri::HTML(response)\n results = nil\n if document.xpath(\"//h3\").text == \"No Results\"\n results = self.ceeb_code_guess(self.f1sysnam, false) if try_again_on_failure\n return results\n else\n results = {}\n codes = document.xpath(\"//tr[@class!='headerRow']/td[@class='codeResultCell']\").collect(&:text).collect(&:to_i)\n names = document.xpath(\"//tr[@class!='headerRow']/td[@class='schoolResultCell']\").collect(&:text)\n codes.each_with_index do |code, i|\n results[codes[i]] = names[i].strip\n end\n if results.empty?\n return nil\n elsif results.size == 1\n return results\n else\n return results\n end\n end\n end",
"def a_star pitch, start, goal\n\t\t# The set of nodes already evaluated.\n\t\tclosedset = []\n\t\t# The set of tentative nodes to be evaluated.\n\t\topenset = []\n\t\t# Visited nodes\n\t\tfrontier = []\n\t\topenset << start\n\t\t# The map of navigated nodes.\n\t\tcame_from = { }\n\t\t# Distance from start along optimal path.\n\t\tg_score, h_score, f_score = { }, { }, { }\n\t\tg_score[start] = 0\n\t\th_score[start] = dist start, goal, :manhattan\n\t\t# Estimated total distance from start to goal through y.\n\t\tf_score[start] = h_score[start]\n\n\t\t# Main loop\n\t\twhile not openset.empty?\n\t\t\t# Fetching the node among openset with the least f_score\n\t\t\tx, _value = [], 1_000_000\n\t\t\topenset.each do |key|\n\t\t\t\tx, _value = key, f_score[key] if f_score[key] < _value\n\t\t\tend\n\n\t\t\tbreak if x == goal # We reached target point and thus finished looking for it !!\n\n\t\t\t# Moving x from openset to closedset\n\t\t\topenset.delete x\n\t\t\tclosedset << x\n\n\t\t\t(-1..1).each do |i|\n\t\t\t\t(-1..1).each do |j|\n\t\t\t\t\ty = [x[0] + i, x[1] + j]\n\t\t\t\t\tunless i == 0 and y == 0\n\t\t\t\t\t\tif pitch[y].nil? # We only want to explore neighbours\n\t\t\t\t\t\t\tnext if closedset.include? y # If already in closedset, we skip it\n\n\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\th = dist x, y, :manhattan\n\t\t\t\t\t\t\tg = g_score[x] + h\n\n\t\t\t\t\t\t\tif not openset.include? y then\n\t\t\t\t\t\t\t\treturn [] if frontier.include? y\n\t\t\t\t\t\t\t\tfrontier << y\n\t\t\t\t\t\t\t\topenset << y # Adding current neighbours to openset\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telsif g < g_score[y]\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Updating what needs to be\n\t\t\t\t\t\t\tif better then\n\t\t\t\t\t\t\t\tcame_from[y] = x\n\t\t\t\t\t\t\t\tg_score[y] = g\n\t\t\t\t\t\t\t\th_score[y] = dist y, goal, :manhattan # heuristic estimate of distance (y, coords)\n\t\t\t\t\t\t\t\tf_score[y] = g_score[y] + h_score[y]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# Finally assembling path and returning it\n\t\tpath = []\n\t\t_cur = goal\n\t\twhile _cur != start do\n\t\t\tpath << _cur\n\t\t\t_cur = came_from[_cur]\n\t\tend\n\n\t\treturn path.reverse\n\tend",
"def master_mind(solution, guess)\n hits = hit(solution, guess)\n pseudo_hits = psuedo_hit(solution, guess)\n \"hits: #{hits}\\n pseudo hits: #{pseudo_hits}\"\nend",
"def best_guess_at_country\n return self.country if !self.country.nil?\n\n extension_possibilities = []\n extension_possibilities << \".#{self.uri.to_s.gsub(/^.+organisations\\/.+\\-/, '')}\"\n extension_possibilities << self.uri.to_s.gsub(/^.+organisations\\/[A-z]+/, '').gsub(/\\-/, '.')\n extension_possibilities << self.uri.to_s.match(/\\-[A-z]+\\-[A-z]+$/)[0].gsub(/\\-/, '.') rescue ''\n mapping = ArtsAPI::COUNTRIES_MAPPING\n\n result = nil\n extension_possibilities.each { |ex| result = mapping[ex] if mapping.has_key?(ex) }\n\n if !result.nil?\n self.country = result\n self.save\n end\n\n result\n end",
"def prepare_search\n # puts \"prepare_search called\"\n @current_point = @start_vector\n @interval_index = 0\n @path = [@start_vector]\n @initial_run = true\n \n @current_cost = get_cost @current_point\n end",
"def prepare_result\n\t\t\tsuper\n\t\t\t@lowest_old = MM.get_lowest_old(@current_point, @start_vector, @hd_config, false, @tuning_range)\n if @lowest_old[0] == nil\n\t\t\t\t@initial_run = true\n\t\t\t\tthrow :jump_back\n\t\t\tend\n\t\tend",
"def update_best\n if @best_price < @ep.max\n @best_price = @ep.max\n res_i = @ep.index(@best_price)\n @best_weight = @bw[res_i]\n @best_baggage = in_bag(@cg[res_i])\n end\n end",
"def best_move\n find_at_risk_square(mark) ||\n find_at_risk_square(@human.mark) ||\n center_square ||\n corner_play ||\n board.unmarked_keys.sample\n end",
"def make_guess\n\tputs \"#{ @name } is thinking...\"\n\tif @first_guess==[]\n\t return make_first_guess\n\telse\n\t # update the last guess, get a random sample from the set of available codes\n\t sleep 1\n\t @last_guess = @set_of_codes.sample \n\t return @last_guess\n\tend\n end",
"def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end",
"def analyze\n @hits.times do\n @guesses << @last_guess unless @guesses.length == 4\n end\n end",
"def greedy strategy\n closed = []\n fringe = initialize_fringe\n\n loop do\n return nil if fringe.empty? # No solution\n current = fringe.delete(strategy.next(fringe)) # Pick next using heuristic\n city = current[:city]\n return current if done? city # Found solution?\n unless closed.include? city # Only expand new cities\n closed.push city\n fringe = fringe + expand(current)\n end\n end\n end",
"def solve\n solution_candidate(intersections.next_people_with_similar_tastes)\n end",
"def suggest_prereqs; suggest_with_score(prereqs).last; end",
"def final_suggestion\n longest_substring = 0\n best_suggestion = nil\n\n self.possible_suggestions.each do |suggestion|\n if suggestion.common_substring_length > longest_substring\n best_suggestion = suggestion.possible_word\n longest_substring = suggestion.common_substring_length\n end\n end\n\n best_suggestion\n end",
"def scan_for_personal_best!\n create_sql_diff_header(\"Scanning swimmer #{@swimmer.get_full_name} [#{@swimmer.id}] for personal bests\")\n reset_all_personal_bests!\n EventsByPoolType.not_relays.each do |event_by_pool_type|\n set_personal_best!(event_by_pool_type, false)\n end\n create_sql_diff_footer(\"Swimmer #{@swimmer.get_full_name}: #{@swimmer.meeting_individual_results.is_personal_best.count} personal bests found\")\n @swimmer.meeting_individual_results.is_personal_best.count\n end",
"def identify_best_state\n best = EightQueens::NullState.new\n found_best_state = false\n\n @state.generate_successors do |successor|\n best = successor if best.friendly_pairs < successor.friendly_pairs\n found_best_state = true\n end\n\n found_best_state ? best : @state\n end",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def next_unattempted\n fewest_potential_pairs(unattempted_people)\n end",
"def best_candidate\n self.by_quality.first\n end",
"def computer_places_piece(brd)\n square = nil\n # offense first choice\n WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, COMPUTER_MARKER)\n break if square\n end\n # defense second choice\n if !square\n WINNING_LINES.each do |line|\n square = find_at_risk_square(line, brd, PLAYER_MARKER)\n break if square\n end\n end\n # pick square #5 if available, third choice\n if !square\n square = 5 if brd[5] == INITIAL_MARKER\n end\n # just pick a square last choice\n if !square\n square = empty_squares(brd).sample\n end\n\n brd[square] = COMPUTER_MARKER\nend",
"def best_guess(graph, interest)\n search(graph, interest).sort do |a,b|\n if a[:audience].to_i > 0 || b[:audience].to_i > 0\n a[:audience].to_i <=> b[:audience].to_i\n else\n b[:interest].length <=> a[:interest].length\n end\n end.last\n end",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def auto_suggest(input,sports_reg_exp)\n similarity = 0\n sport_suggestion = \"\"\n # iterates through each regular expression option\n\n return \"\" if input == \" \" || input == \"\"\n sports_reg_exp.each do |sport, reg_exp|\n #hashmap to numerize the similarity\n count = Hash.new 0\n # hits on matches and adds to hash the size of the match\n input.scan(reg_exp).each {|elm| count[elm.length] += 1}\n temp_similarity = 0;\n count.each do |k,v|\n # longer matches are given more weight in the sum\n count[k] = k ** v\n temp_similarity += count[k]\n end\n # identifies the most similar spot\n if temp_similarity > similarity\n sport_suggestion = sport\n similarity = temp_similarity\n elsif temp_similarity == similarity\n # returns different sports for mistyped input\n sport_suggestion = sport if rand(0..1) == 1\n end\n end\n # returns empty string if not similar enough\n sport_suggestion = \"\" if (similarity == 1 || (similarity <= 3 && sport_suggestion.length > 15))\n sport_suggestion\nend",
"def update_p_best\r\n return unless @fitness > p_best_fitness\r\n\r\n @p_best_fitness = @fitness\r\n @p_best_position = @position\r\n end",
"def deduce\n while true\n stuck, guess, count = true, nil, 0\n # fill in any spots determined by direct conflicts\n allowed = board.allowed_numbers\n (0..80).each do |index|\n if board.board[index].nil?\n numbers = bits_to_numbers(allowed[index])\n if numbers.size == 0\n return [] # Return nothing if no possibilitie E\n elsif numbers.size == 1\n board.board[index] = numbers[0]\n stuck = false\n break\n elsif stuck\n new_guesses = numbers.map { |n| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n\n if !stuck\n allowed = board.allowed_numbers\n end\n needed = board.needed_numbers\n\n # fill in any spots determined by elimination of other locations.\n # For any given column, find which numbers it is missing,\n # And figure out which positions allow those numbers - if only\n # one position allows it, the number goes there.\n #\n # If more than one spot is available, add to the guesses.\n board.coordinate_systems.each do |axis|\n (0..8).each do |x|\n numbers = bits_to_numbers(needed[axis_index(x, axis)])\n numbers.each do |n|\n bit = 1 << n\n # spots =for this number & col, all positions that allow the needed\n # numbers\n spots = []\n\n (0..8).each do |y|\n index = board.index_for(x, y, axis)\n # if this position allows the needed number, add it to spots\n if allowed[index] & bit\n spots << index\n end\n end\n\n if spots.length == 0\n return []\n elsif spots.length == 1\n board.board[spots[0]] = n\n stuck = False\n break\n elsif stuck\n new_guesses = spots.map { |index| [index, n] }\n guess, count = pickbetter(guess, count, new_guesses)\n end\n end\n end\n end\n\n if stuck\n guess.shuffle! unless guess.nil?\n return guess\n end\n end\n end",
"def guess_limit\n\t\tguesses \n\tend",
"def pick_suggestion\n strategy_class.new(@pattern).pick_suggestions\n end",
"def generate_guess\n feedback = @board.generate_feedback_key(convert_num_to_guess(@guess))\n\n @candidates = @candidates.select do |c|\n get_feedback(convert_num_to_guess(@guess), convert_num_to_guess(c)) == feedback\n end\n\n @guess = @candidates[0]\n end",
"def get_guess(secret_code_to_compare_guess)\n if @guess_count == 0\n @guess = [1,1,2,2]\n @set.delete([1,1,2,2])\n #if theres one possibility left, that is the answer\n elsif @set.length == 1\n @guess = @set[0]\n else\n @feedback_to_evaluation = evaluate(@guess, secret_code_to_compare_guess)\n @guess = minmax_technique\n end\n @guess_count += 1\n puts \"The Computer guesses: #{@guess.join(\"\")}\"\n return @guess\n end",
"def guess\n letters = @possible_letters.collect {|letter| [ score_for(letter),letter ]}\n letter = letters.min {|letter1,letter2| letter1 <=> letter2 }\n letter[1]\n end",
"def find_one_closest_point(reference_point, guess, geometric_resolution)\n do_find_one_closest_point(reference_point.to_a, guess, geometric_resolution)\n end",
"def best_strategy(state)\n build_best(state.pile_size)\n puts \"Good states=#{@good_states}\"\n tgts = targets(state.pile_size)\n tgts.each do |tg|\n op = state.op_to(tg, @ops) \n return op if op\n end\n nil\n end",
"def minmax_technique\n possible_solutions = []\n @set.each { |solution|\n possible_solutions << solution if evaluate(@guess, solution) == @feedback_to_evaluation\n }\n @set = possible_solutions\n @guess = @set.sample\n @set.delete(@guess)\n return @guess\n end",
"def update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0][email protected](@last_guess,x)[1])\r\n }\r\n\r\n end",
"def compare_for_near_match(guess_index)\n (0..3).each do |code_index|\n next unless guess[guess_index] == code[code_index]\n\n key.push(\"O\")\n code[code_index] = 0\n break\n end\n end",
"def is_greedy?(location)\n !@fixed_cost.include? location\n end",
"def quality_of guesses\n pcnt = Hash.new 0 # tracks number of times a peg tallies\n\n # Look for exact matches first.\n guesses.zip(@pegs).each {|guess,peg| pcnt[peg] += 1 if peg == guess}\n exactly = pcnt.values.reduce(:+) || 0 # use stuff we learnt\n\n # Now count close matches.\n guesses.each {|peg| pcnt[peg] += 1 if (@pegs.include? peg) &&\n (pcnt[peg] < @pmax[peg])}\n nearly = pcnt.length == 0? 0 : pcnt.values.reduce(:+) - exactly\n\n [exactly, nearly]\n end",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def get_bests_to_be_ignored\n @bests_to_be_ignored\n end",
"def negotiate_best_deal?\n nil\n end",
"def best_guess(guessed_list)\n bestguess = guessed_list[0]\n guessed_list.each_index do |i|\n if(guessed_list[i].scan(/\\(([^\\)]+)\\)/).last.last.to_i < bestguess.scan(/\\(([^\\)]+)\\)/).last.last.to_i)\n bestguess = guessed_list[i]\n end\n end\n bestguess\n end",
"def find_single_hidden\n before = self.entropy\n reduce_hidden_single_line\n reduce_hidden_single_col\n reduce_hidden_single_grid\n reduce_solved if before > self.entropy\n end",
"def findorsuggest()\n \n end",
"def best_taken_card(take_it)\r\n @log.debug(\"calculate best_taken_card\") \r\n w_cards = []\r\n take_it.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n curr_w = 0\r\n curr_w += 200 if card_s[2] == @briscola.to_s[2]\r\n # check if it is an asso or 3\r\n curr_w += 0 if card_s[1] == \"A\"[0]\r\n curr_w += 5 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 70 + lisc_val\r\n end\r\n curr_w += 40 if card_s[1] == \"F\"[0]\r\n # mariazza is possible?, horse and king has a different value\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 290\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 300\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Best card to play on best_taken_card is #{min_list[0]}, w_cards = #{w_cards.to_s}\")\r\n return min_list\r\n end",
"def manhattan_heuristic(open_squares)\n smallest_f = nil\n smallest_f_point = nil\n open_squares.each do |neighbor|\n g_score = calculate_g(neighbor)\n h_score = calculate_h(neighbor)\n f_score = h_score + g_score\n if smallest_f.nil? || f_score < smallest_f\n smallest_f = f_score\n smallest_f_point = neighbor\n end\n end\n smallest_f_point\n end",
"def match_position_by_sad\n # SAD = \"sum of absolute differences\"\n best_sad = 1_000_000\n\n search_rows.times do |y|\n search_cols.times do |x|\n puts \"Checking search image at #{x}, #{y}\" if @verbose\n sad = 0.0\n\n template_image.rows.times do |j|\n template_image.columns.times do |i|\n s_pixel = search_image.pixel_color(x+i,y+j)\n t_pixel = template_image.pixel_color(i,j)\n\n # Could use pixel hue\n # #to_hsla returns [hue, saturation, lightness, alpha]\n # sad += (s_pixel.to_hsla[0] - t_pixel.to_hsla[0]).abs\n \n # Or pixel \"intensity\" which is computed as:\n # (0.299*R) + (0.587*G) + (0.114*B)\n sad += (s_pixel.intensity - t_pixel.intensity).abs\n \n end\n end\n\n # save if this is best position (least difference) so far\n if sad < best_sad\n puts \"New best at #{x}, #{y}: #{sad}\" if @verbose\n best_sad = sad\n self.match_result = x, y\n end\n\n end\n end\n\n return match_result\n\n end",
"def discover\n discover_places = [\n \"Experimental Cocktail Club Paris\",\n \"Le Connetable\",\n \"Le Baron Rouge\",\n \"Le Bistrot des Dames\",\n \"Aux Folies\",\n \"UDO Bar\"\n ]\n params_hash = {\n q: discover_places.sample\n }\n call(params_hash)\n end",
"def near_match\n (0..3).each do |guess_index|\n compare_for_near_match(guess_index)\n end\n end",
"def best_move(state)\n best_score = -999\n best_move = nil\n dot = (@max_tries / 10).floor\n # Run allowed number of simulations\n print \"Thinking\"\n (1..@max_tries).each_with_index do |try, i|\n print \".\" if i % dot == 0\n simulate(state)\n end\n show_scores(state)\n high_score_move(state)\n end",
"def run\n solve\n { price: @best_price, config: @best_config }\n end",
"def geocode_best_possible\n\n return unless addressable_type == 'Company'\n\n # don't Geocode if we're doing development or testing AND\n # we already have lat and long and nothing has changed\n return if dev_or_test_and_have_geo_unchanged?\n\n specificity_order = address_array\n\n most_specific = 0\n least_specific = specificity_order.size - 1\n\n geo_result = nil\n\n until most_specific > least_specific || geo_result.present?\n geocode_address = specificity_order[most_specific..least_specific].compact.join(', ')\n geo_result = Geocoder.search(geocode_address)\n most_specific += 1\n end\n\n unless geo_result.nil?\n self.latitude = geo_result[0].latitude\n self.longitude = geo_result[0].longitude\n end\n\n end",
"def greedy(tg,faulty,replacements,n)\n result = Hash.new\n repl = Array.new(replacements.size) {|i| replacements[i]}\n # sort tg by # successors\n sort_by_subtree_size!(tg)\n\n # sort faulty by # successors\n faulty.sort_by!{|a| tg[0].index(lookup_task(tg,a))}\n \n faulty.each do |fault|\n # pick the replacement which minimizes starting time of fault\n choice = repl.min_by{|a| euclidean_distance(tg,result.merge({fault=>a}),n)}\n # add the mapping to the solution\n result[fault] = choice\n # remove the replacement from the set\n repl.delete(choice)\n end\n return result\nend",
"def guess(guess)\n \t@guess = guess\n \treturn :correct if solved?\n \t@guess > @answer ? :high : :low\n end",
"def check_guess\n reset_guess\n check_number_and_position\n check_number_only\n fill_result\n @result\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 resolve(instance)\n if(instance.fragments.count == 0)\n #return no solution result\n ResultInstance.new\n else\n #sort fragments by \"left\" attribute\n fragments = instance.fragments.sort\n result = ResultInstance.new\n #set initial limit to 0 and best fragment to nil\n limit = 0\n bestFragment = nil\n #for each fragment...\n fragments.each do |fragment|\n \n #if current fragments \"left\" is greater than current limit, then ...\n if(fragment.left > limit)\n #if best fragment is set ...\n #puts \"bestFragment != nil: #{bestFragment != nil}\"\n if(bestFragment != nil)\n #increase limit to best fragments right\n limit = bestFragment.right\n #add the best fragment to the result (its union with already used fragments will be a single interval)\n result.addFragment(bestFragment)\n\n #set best fragment back to nil\n bestFragment = nil\n #and if the current limit is greater or equal to required \"m\" value, then the solution is found (it is current result)\n if(limit >= instance.m)\n return result\n end\n #if best fragment is not set, current instance has no solution (current set of used fragments covers smaller section of X-axis than required and there is no fragment, that would extend it)\n else\n\n result.clear\n return result\n end\n end\n \n \n if(bestFragment != nil)\n #improve best fragment if it covers greater interval from the current limit\n bestFragment = fragment if(fragment.right > limit && fragment.right > bestFragment.right)\n else\n #set current fragment as best fragment only if its \"left\" is less or equal to current limit and \"right\" is greater than current limit\n bestFragment = fragment if(fragment.left <= limit && fragment.right > limit)\n end\n \n end\n if(bestFragment != nil)\n result.addFragment(bestFragment)\n if(bestFragment.right < instance.m)\n result.clear\n end\n else\n result.clear\n end\n result\n end\n end",
"def prepare_suggested_searches\n @suggested_searches = [\n # { label_key: 'search_suggestion_whale_mass',\n # params: {\n # sort: 'desc',\n # min: 10000,\n # taxon_concept_id: 7649,\n # attribute: 'http://purl.obolibrary.org/obo/VT_0001259',\n # unit: 'http://purl.obolibrary.org/obo/UO_0000009' }},\n # { label_key: 'search_suggestion_cavity_nests',\n # params: {\n # q: 'cavity',\n # attribute: 'http://eol.org/schema/terms/NestType' }},\n { label_key: 'search_suggestion_diatom_shape',\n params: {\n attribute: 'http://purl.obolibrary.org/obo/OBA_0000052',\n taxon_concept_id: 3685 }} #,\n # { label_key: 'search_suggestion_blue_flowers',\n # params: {\n # q: 'http://purl.obolibrary.org/obo/PATO_0000318',\n # attribute: 'http://purl.obolibrary.org/obo/TO_0000537' }}\n ]\n end",
"def bestCand(voterOpinion, candList)\r\n\ttopCands = Array.new # []\r\n\ttopScore = nil\r\n\t\r\n\t# for each element in the candList array, calling the current element cand.\r\n\t#\tthe {/} are the same as the do/end shown in the Main section. \r\n\t#\tIncluded here to show the availabailty for different style choices\r\n\tcandList.each { |cand| \r\n\t\t\t\t\tcurrScore = getCandScore(voterOpinion,cand.drop(1))\r\n\t\t\t\t\tif topScore.nil? then\r\n\t\t\t\t\t\ttopScore = currScore\r\n\t\t\t\t\tend\r\n\t\t\t\t\tunless currScore < topScore # essentially if !(currScore < topScore)\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif currScore == topScore\r\n\t\t\t\t\t\t\ttopCands.push(cand[0])\r\n\t\t\t\t\t\telse # must be greater\r\n\t\t\t\t\t\t\ttopScore = currScore\r\n\t\t\t\t\t\t\ttopCands = [cand[0]]\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\treturn topCands\r\nend",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\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 best_problem\n return nil if @pb_list.empty?\n @pb_list[0]\n end",
"def best_position_v2(buffer: 1, fringe_size: default_fringe_size )\n current = sample_position(\n @bots.map(&:x).sum / @bots.length,\n @bots.map(&:y).sum / @bots.length,\n @bots.map(&:z).sum / @bots.length,\n )\n\n fringes = [fringe_size * 4, fringe_size, 0, -fringe_size, fringe_size * -4]\n best_sample = current\n\n log \"initializing best position with buffer, and fringe size\", buffer, fringe_size\n log \"starting sample position\", current\n\n while true\n log \"current positioning / range\", current do\n # first test around the current position\n (-buffer..buffer).each do |dx|\n (-buffer..buffer).each do |dy|\n (-buffer..buffer).each do |dz|\n next if dx == 0 && dy == 0 && dz == 0 # ignore self\n test_sample = sample_position(current.coord.x + dx, current.coord.y + dy, current.coord.z + dz)\n best_sample = test_sample if test_sample.better?(best_sample)\n end\n end\n end\n\n # then take a random sampling on the fringes\n fringes.each do |dx|\n fringes.each do |dy|\n fringes.each do |dz|\n next if dx == 0 && dy == 0 && dz == 0 # ignore self\n test_sample = sample_position(current.coord.x + dx, current.coord.y + dy, current.coord.z + dz)\n best_sample = test_sample if test_sample.better?(best_sample)\n end\n end\n end\n\n log(\"new best sample set\", best_sample) if best_sample != current\n end\n\n break if best_sample == current\n current = best_sample\n end\n\n log \"found best position\", current\n current\n end",
"def optimize_for_location(params)\n flight_floor = params[:flight_floor] || 5000 #meters\n flight_ceiling = params[:flight_ceiling] || 60000 #meters\n\n #verify parameters\n params = params.with_indifferent_access\n\n raise 'No start altitude (params[:start][:altitude])' unless params[:start][:altitude].present?\n raise 'No start latitude (params[:start][:lat])' unless params[:start][:lat].present?\n raise 'No start longitude (params[:start][:lon])' unless params[:start][:lon].present?\n raise 'No start time (params[:start][:time])' unless params[:start][:time].present?\n\n raise 'No finish latitude (params[:finish][:lat])' unless params[:finish][:lat].present?\n raise 'No finish longitude (params[:finish][:lon])' unless params[:finish][:lon].present?\n\n # creates a filter lambda to check that any path passes certain conditions\n filter = lambda {|node, previous|\n node.altitude < flight_ceiling &&\n node.altitude > flight_floor &&\n # (!x || y) checks y only if x is true\n (!params[:use_faa] || node.faa_zones_approx(previous)) && #no restricted zones\n (!params[:check_countries] || node.countries(previous))\n }\n\n #run the search with the provided start, duration, and performance factor\n greedy_search({\n start: Node.from_pos(\n params[:start][:lat].to_f, params[:start][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n finish: Node.from_pos(\n params[:finish][:lat].to_f, params[:finish][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n movement_cost: lambda {|current|\n #vent / ballast costs are proportional to the square of the altitude change\n (current.parent.altitude - current.altitude).abs/1200000.0\n },\n heuristic: lambda {|current|\n ((current.parent.lon - current.lon) / Prediction::time_variance)\n },\n neighbors: lambda {|current|\n current.neighbors(filter)\n },\n build_from_finish: lambda{|finish|\n finish.build_chain\n },\n timeout: params[:timeout],\n performance: params[:performance]\n })\n\n end",
"def give_hint()\n \n sleep(2)\n puts \"hint...\"\n sleep(1)\n\n correct_colors = []\n correct_place = 0\n\n #count matching colors\n $computer[\"code\"].map { |value| if $player[\"code\"].include?(value)\n if !correct_colors.include?(value)\n correct_colors.push(value) \n end\n end }\n\n #update object\n $computer[\"correct_colors\"] = correct_colors\n\n #report matching colors \n if correct_colors.length() > 0\n puts \"#{correct_colors.length()} of the colors that the computer chose are accurate...\"\n end \n \n #count matching placement of matching colors\n correct_colors.map { |value| $computer[\"code\"].index(value) == $player[\"code\"].index(value) }.map { |value| if value == true\n correct_place += 1\n end}\n\n #update object\n $computer[\"correct_place\"] = correct_place\n\n puts \"... and #{correct_place} in the correct place\" \n \n sleep(3)\n\n end",
"def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\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 make_guess\n\t\tbegin\n\t\t\thighest_letter_left = freq_hash\n\t\t\t\t.sort_by{|k, v| v}\n\t\t\t\t.reverse\n\t\t\t\t.map{|char, freq| char}\n\t\t\t\t.detect{|char| !@guessed_letters.include?(char)}\n\n\t\t\traise \"Aw, damn! Got nothin' left. Let's start a new game.\" unless highest_letter_left\n\t\trescue Exception => e\n\t\t\tputs e.message\n\t\t\texit\n\t\telse\n\t\t\t@guessed_letters << highest_letter_left\n\t\t\thighest_letter_left\n\t\tend\n\tend",
"def bad_guess_count()\r\n\t\t# TODO: fill in method body\r\n\t\treturn -1\r\n\tend",
"def guess(str)\n ::NKF::guess(str)\n end",
"def get_hint(board)\n usp = get_unsolved_positions(board) # Unsolved positions for the board\n usp_s = usp.shuffle() # Randomized\n if usp_s.length() > 0\n the_position = usp_s[0] # Get the position that will be solved.\n row = the_position[0]\n col = the_position[1]\n solved_board = solve(board)\n if(solved_board == false)\n return false\n end\n correct_value = solved_board[row][col]\n return [row, col, correct_value]\n else\n return false\n end\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 closest_match(new_model, crucial_params, match_params)\n best_matches = []\n # for an increasing number of parameters, look for matches with all combinations of that number of match params\n # looks for the match fitting the highest number of parameters and chooses that one\n # TODO: can be optimized since certain possibilities can be nipped out of future iterations if their descendants did not have matches\n 1.upto(match_params.count - 1) do |count|\n match_found = false\n CombinatorialIterator.new(count, match_params).mapCombinations do |params|\n cur_params = crucial_params.merge(params)\n matches = new_model.class.where(cur_params)\n # logger.info \"found #{matches.count} matches for cur_params: #{cur_params.keys}\"\n if matches.any?\n match_found = true\n # logger.info \"new_model: #{new_model.inspect}\\nmatch: #{matches.first.inspect}\"\n best_matches = matches\n end\n end\n break unless match_found # stop the iteration is no matches were found for this humber of parameters\n end\n best_matches.first\n end",
"def choose_guess(turn)\r\n @guess = []\r\n if turn == 0\r\n @best_available_guess = []\r\n @guess = [\"red\", \"red\", \"blue\", \"blue\"]\r\n else\r\n @guess = @next_guess\r\n end\r\n end",
"def search(threshold)\r\n until @population.contains_an_individual_with_fitness_as_good_as?(threshold)\r\n # DEBUG CODE\r\n puts \"Reproducing... #{@population.size}\"\r\n new_population = @population.class.new\r\n (@population.size/2).times do\r\n x = @population.random_selection\r\n y = @population.random_selection\r\n children = @population.first.class.reproduce(x, y)\r\n children.each do |child|\r\n child.mutate if rand() <= mutation_rate\r\n end\r\n children.each {|child| new_population.push(child)}\r\n end\r\n @population = new_population\r\n end\r\n return @population.best_individual\r\n end",
"def run\n solve(0)\n { price: @best_price, config: @best_config }\n end"
] | [
"0.6333796",
"0.6231165",
"0.6195267",
"0.6195267",
"0.61370957",
"0.60599285",
"0.6014038",
"0.60125136",
"0.59513736",
"0.59121877",
"0.5883356",
"0.585162",
"0.57922685",
"0.57830924",
"0.5769511",
"0.57068855",
"0.56865275",
"0.56728035",
"0.56535906",
"0.56470627",
"0.56465614",
"0.5640275",
"0.5633366",
"0.5607087",
"0.55915856",
"0.5582962",
"0.55740285",
"0.55713725",
"0.5560881",
"0.55582047",
"0.5532592",
"0.5530126",
"0.5527383",
"0.5525911",
"0.5516835",
"0.5516835",
"0.5510607",
"0.5495666",
"0.5490677",
"0.5484278",
"0.5484225",
"0.54815084",
"0.5480803",
"0.5470527",
"0.5460818",
"0.54587495",
"0.5457769",
"0.5455534",
"0.5434125",
"0.54287404",
"0.5414022",
"0.54104984",
"0.5389499",
"0.53776485",
"0.53762615",
"0.53545356",
"0.5348788",
"0.5340671",
"0.5337212",
"0.53223157",
"0.53191423",
"0.53181696",
"0.5312384",
"0.5308119",
"0.530665",
"0.5288592",
"0.52823514",
"0.5281417",
"0.5279207",
"0.5278643",
"0.52781147",
"0.52692795",
"0.52690256",
"0.52633953",
"0.5262629",
"0.5262317",
"0.52563417",
"0.52557135",
"0.5250157",
"0.5248153",
"0.5246345",
"0.52412957",
"0.52410996",
"0.52407485",
"0.524002",
"0.5233833",
"0.5233789",
"0.52283484",
"0.522539",
"0.52202207",
"0.52194166",
"0.5205132",
"0.52040225",
"0.520361",
"0.5198835",
"0.5191387",
"0.5191336",
"0.5182684",
"0.5182398",
"0.51822764",
"0.51786745"
] | 0.0 | -1 |
takes a string preposistion and turns it into a 2d array ands of ors with id numbers + depending on negation | def string_to_internal(preposition)
temp_kb =Array.new
#string input of format literal_name LOGICAL_PREPOSISTION
preposition_array = preposition.split
next_negated = false
sentence = []
preposition_array.each do |word|
#####################################3
# puts " word: " + word
#don't need to handle "or" as long as it is in right format, will look to "and" and the end as limiters
if (word == "AND" || word == "and")
temp_kb << sentence
sentence = []
elsif(word == "NOT" || word == "not")
next_negated = true
elsif(word == "OR" || word =="or")
else
temp = @name_hash[word]
#add variable if doesnt exist
if(temp == nil)
temp_var = Literalzs.new(word,@total_variables)
@id_array.push(temp_var)
@name_hash[word] = @total_variables
temp = @total_variables
@total_variables+=1
end
if(next_negated)
temp = temp.to_i * -1
#########################################################3333
#puts " temp negated, now is: " + temp.to_s
next_negated = false
end
sentence << temp
end
end
#need to grab last sentence since it wont be ended with and
temp_kb << sentence
return temp_kb
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contain_all_rots(strng, arr)\n array = strng.chars\n number = 0\n result = []\n (array.size - 1).times do \n array.rotate!\n result << array\n end\n result.map! {|y| y.join(\"\")}\n # result.all?{|x| arr.include?(x)}\nend",
"def convert_to_ar(str)\n bgn = 0\n cur = str[bgn]\n ar = []\n unless str.empty?\n str.length.times do |ind|\n next unless str[ind] != cur\n\n ar.append(str[bgn, ind - bgn])\n bgn = ind\n cur = str[ind]\n end\n ar.append(str[bgn, str.length])\n end\n ar\n end",
"def solution(str)\n str.scan(/.{1,2}/).map { |e| e[1].nil? ? e + '_' : e }\nend",
"def mask_array\n @mask.split('')\n end",
"def create_non_redundant_array(polyAs0,condition0,polyAs1,condition1,polyAs2,condition2,polyAs3,condition3)\n old_polyAs = (polyAs0 + polyAs1 + polyAs2 + polyAs3).uniq!\n polyAs = []\n for old_polyA in old_polyAs\n polyA = old_polyA + \"conditions=\"\n polyA = polyA + condition0 + \",\" if polyAs0.include?(old_polyA)\n polyA = polyA + condition1 + \",\" if polyAs1.include?(old_polyA)\n polyA = polyA + condition2 + \",\" if polyAs2.include?(old_polyA)\n polyA = polyA + condition3 + \",\" if polyAs3.include?(old_polyA)\n polyA.chomp!(\",\")\n polyAs << polyA\n end\n return polyAs\nend",
"def pig_it(string)\n string2 = string.split.map{|e|e == '!' || e == '?' ? e : e.to_s << (e[0]) }.join(' ')\n\n string3 = string2.split.map{|e|e == '!' || e == '?' ? e : e.to_s << 'ay'}.join(' ')\n\n string3.split.map{|e| e == '!' || e == '?' ? e : e = e[1..-1]}.join(' ')\nend",
"def word_to_coordinates(row_name, word)\n coordinates = []\n 5.times do |i|\n coordinates << \"#{row_name}#{i+1}\" if (word & (1 << i)) > 0\n end\n\n coordinates\n end",
"def get_and_or_not_of str\n # @param str is a string (not normalized!)\n # ie. ['big','OR','middle','OR','large','sandwich','NOT','cheese']\n # @returns and_phrases -- list of normalized words\n # @returns or_phrases -- list of lists of normalized words\n # @returns not_phrases -- list of normalized words\n # actually and_phrases is the same to or_phrases but in and_phrases\n # single words have replaced or-sublists\n \n r = str.split\n \n # returns or-words and indexes of already analyzed words\n def getOr_ r\n or_= []; del_ = []; cur = []\n status = :start\n x = 0\n while x < r.length do\n if r[x] == OR_OPERATOR\n if status == :start\n cur = [r[x-1]]\n status = :cont\n del_.push x-1\n end\n cur.push r[x+1]\n del_ += [x, x+1]\n x += 2\n else\n if status == :cont\n status = :start\n or_.push cur\n cur = []\n end\n x += 1\n end\n end\n if not cur.empty?\n or_.push cur\n end\n return or_, del_\n end\n \n def getAndNot_ r, skip\n and_ = []; not_ = []\n r.length.times do |x|\n if not skip.include?(x)\n # if previous or last (if x = 0) in array is NOT\n if r[x-1] == NOT_OPERATOR\n not_ |= [r[x]]\n elsif r[x] != NOT_OPERATOR\n and_ |= [r[x]]\n end\n end\n end\n return and_, not_\n end\n \n or_phrases, skip = getOr_ r\n and_phrases, not_phrases = getAndNot_ r, skip\n \n return normalize_list(and_phrases), normalize_list(or_phrases), normalize_list(not_phrases)\n end",
"def make_pyramid_array(str)\n str.split(\"\\n\").map { |line| line.split(' ').map { |ch| ch.to_i } }.reverse\nend",
"def contain_all_rots(strng, arr)\n i = 0\n empty = []\n\n if strng.length == 0\n return true\n elsif strng.length > 0\n array = strng.split('')\n\n (0...strng.length).each {|num|\n rotate = array.rotate(num)\n joined_string = rotate.join('')\n\n i += 1 if arr.include?(joined_string)\n }\n end\n\n if i == strng.length\n return true\n else\n return false\n end\nend",
"def croon (string)\n second = []\n array = string.split.each { |i|\n second.push(i.split(//).join(\"-\"))\n }\n second.join(\" \")\nend",
"def toptag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n([A-Za-z\\/\\*])/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def canolical(palabra)\n#convierte string a array y ordena las letras alfabeticamente\n palabra.split('').sort.join\nend",
"def split_input (input)\n return false if input == ''\n array_input = input.split('')\n row_input = convert_input(array_input[0].downcase)\n column_input = (array_input[1].to_i) - 1 if (/[\\d]/ === array_input[1])\n coordinate = Array.new([row_input, column_input])\n return coordinate\n end",
"def parse_mask(mask)\n and_mask = mask.gsub(\"X\", \"1\").to_i(2)\n or_mask = mask.gsub(\"X\", \"0\").to_i(2)\n\n [and_mask, or_mask]\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 pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n string_size = s.size\n matrix = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n matrix << []\n\n i = 0\n while i <= pi do\n matrix[pi] << s_chars[i..pi].join.ljust(string_size)\n i += 1\n end\n\n matrix[pi] = matrix[pi].join(' | ')\n end\n\n puts matrix\n\n sizes\nend",
"def pig_it(str)\r\n str.split.map { |w| w =~ /[a-z]/i ? w[1..-1] + w[0] + 'ay' : w }.join(' ')\r\nend",
"def string_to_matrix(string)\n to_nums(string.split(\"\\n\").map { |row| row.strip.split })\n end",
"def croon(string)\n arr = string.split(\" \")\n arr = arr.map do |word|\n \tword = word.split(\"\").join(\"-\")\n p word\n end\n arr.join(\" \")\n end",
"def array_from_string string\n # takes the string found when params tries to return an array, and reconstruct the array.\n array = string.split(/[^Q1234567890]+/)\n array.delete(\"\")\n array\n end",
"def experimental_layout(string, matrix)\n matrix.each_with_index do |row, idx|\n if row.include? string\n matrix = matrix[idx..(idx + 8)] \n # Removing rows and columns from 96 well format\n arr = matrix[1..matrix.length].map do |row|\n if string == 'sample_id_mat'\n row[1..row.length].map {|i| i.to_i}\n else\n row[1..row.length].map {|i| i}\n end\n end\n return arr\n end\n end\n end",
"def convert(s, num_rows)\n return s if num_rows == 1\n result = Array.new(num_rows) {Array.new}\n forward = false\n i = 0\n\n s.chars.each do |el|\n result[i] << el\n forward = !forward if i == num_rows - 1 || i == 0\n i += 1 if forward\n i -= 1 unless forward\n end\n\n result.flatten.join\nend",
"def get_letter_mask(array, valid_array)\n array = array.split(/[ ,\\.:;\\-+]/) if array.class != Array\n \n str = ''\n array.each do |word|\n word.upcase!\n next if word == 'AND'\n str += word[0].chr if valid_array.include? word[0].chr\n end\n return str\n end",
"def sentence_to_array (string)\n string_split = string.split('.')\n string_split.map! do |words|\n words.split('!') \n end\n string_split.flatten!\n\n string_split.map! do |words|\n words.split('?') \n end\n string_split.flatten\nend",
"def chess_coords_to_indices(coord_string)\n if m = coord_string.match(/(\\w)(\\d)/)\n col = m[1]\n row = m[2]\n\n columns = { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7 }\n\n if ('a'..'h').include?(col) && (1..8).include?(row.to_i)\n [row.to_i - 1, columns[col.to_sym]]\n else\n false\n end\n else\n false\n end\n end",
"def array_from_rows(str)\n str.split(\"\\n\").map { |x| x.split(' ').map { |y| y.to_i } }\n end",
"def prediction_to_array(string)\n segments = []\n string.scan(/[io](\\d+)-(\\d+)/) do |m1, m2|\n segments << { :start => m1.to_i, :stop => m2.to_i }\n end\n segments\n end",
"def listify(str)\n str.split(/(~\\[\\w*\\])/).inject(List.new) do |list, s|\n if @cfg.nonterm s then\n list << s\n else\n # This also handles the s.empty? case.\n s.split('').each { |c| list << c }\n end\n list\n end\n end",
"def droppre s\n if s.select{|i|i=~/^# *!intermediate/}.size>0\n flag=false\n s.map{|i|\n i=~/^# *!intermediate/\n flag=true if $&\n flag ? i : nil\n }-[nil]\n else\n s\n end\n 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 to_ship(s)\n arr = s.split('')[0,3].map {|x| x.to_i} \n s[3] == 'A' ? arr << :across : arr << :down\n end",
"def solution(str)\n str.scan(/.{1,2}/).map{ |str| str.size == 1 ? str + \"_\" : str }\nend",
"def create_arr_arrays(arr_strings)\n\tarr_strings.map do |row| \n\t\trow.split(\",\").map { |word| word.strip }\n\t\tend\nend",
"def board_to_array(board_string)\n return board_string.split(\"\").map! { |value| value.to_i }\n\nend",
"def formatAnswerFromArray( answerString )\n answerRows = answerString.split(\"~\")\n answerArr = Array.new()\n answerRows.each { |ans|\n row = \"\"\n ansarr = ans.split(\",\")\n ansarr.each { |a|\n row += a unless a == \",\"\n }\n answerArr.push(row)\n } \n answerArr\n end",
"def pirates_say_arrrrrrrrr(string)\n\n\tarr = string.split(//)\n\n output = []\n arr.each_cons(2) { |a,b| output << b if a == \"r\" || a == \"R\" }\n output.join\n\nend",
"def pig_it text\n text.split(' ').map do |word|\n if word == \"?\" || word == \"!\" || word == \".\" || word == \",\"\n word\n else\n (word[1..(word.length-1)] + word[0] + \"ay\")\n end\n end.join(' ')\nend",
"def equation_analyzer(str)\n equation_array = []\n result_array = []\n open_parenth = 0\n closed_parenth = 0\n str.each_char do |character|\n open_parenth += 1 if character == '('\n closed_parenth += 1 if character == ')'\n equation_array << character\n if open_parenth == closed_parenth \n result_array << equation_array.join\n open_parenth = 0\n closed_parenth = 0\n equation_array = []\n end\n end\n result_array.delete(' ')\n result_array\nend",
"def isbn13_arr(num)\n if num == false\n return false\n end\n stopgap = num.split('')\n stopgap\nend",
"def preProcess(s)\n n = s.length().to_i\n if n==0\n return \"^$\"\n end\n ret = \"^\"\n (0..n-1).each do |re|\n ret += ('#' + s[re].to_s)\n end\n ret += '#$'\n return ret\nend",
"def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n if pi == 0\n sizes << size\n next \n end\n\n substrings = [s_chars[0..pi]]\n\n while !substrings.empty? do\n sub = substrings.pop\n\n sequence = to_sequence(sub) # X\n\n # for every sequence, N-1 must exists and we only check if we can add the last bit\n pos = graph\n sequence[0..-2].each do |bit|\n pos = pos[bit]\n end\n \n next unless pos[sequence.last].nil?\n\n pos[sequence.last] = {}\n size += 1\n\n substrings << sub[1..-1] \n end\n\n sizes << size\n end\n\n sizes\nend",
"def convert_array(str)\n return \"*invalid input*\" if (str.length < 3) || (str.length % 3 != 0)\n\n set = str.length / 3 # determines number of iterations for a full set\n ary = str.split('')\n\n n = str.length / 3 # track the number of chars remaining in the sets\n a = 0\n i = 0\n\n for i in (1...set)\n ## insert method puts char BEFORE current index\n ## i represents the number of sets that have been itterated\n b = a + n\n b_value = ary.slice!(b)\n ary.insert(a + 1, b_value)\n\n c = b + n\n c_value = ary.slice!(c)\n ary.insert(a + 2, c_value)\n\n n -= 1 # all sets reduced by 1\n a += 3\n end\n\n ary.join\n\nend",
"def resume_to_array(text)\n result = text\n result.gsub!(\",\",\"\")\n result.gsub!(\"(\",\"\")\n result.gsub!(\")\",\"\")\n result.gsub!(\"[\",\"\")\n result.gsub!(\"]\",\"\")\n result.downcase!\n return result.split\nend",
"def solution(str)\n str+=\"_\" if str.length.odd?\n res = []\n index = 0\n while index < str.length\n res << str[index .. index+1]\n index+=2\n end\n res\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 pig_it_ms_two(str)\n pig = []\n str.split.each do |w|\n pig << w.chars.rotate.join + \"ay\" if w =~ /\\w/\n pig << w if w =~ /\\W/\n end\n pig.join(\" \")\nend",
"def pig_latin_word(string)\n array_of_char = string.downcase.split(//)\n\n if [\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"].include?(array_of_char[0])\n array_of_char.push(\"ay\")\n elsif !([\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"].include?(array_of_char[0]))\n consonant = array_of_char.delete_at(0)\n array_of_char.push(consonant, \"ay\")\n end\n\n return array_of_char.join\n\nend",
"def reformat(s)\n return s if s.size == 1\n \n num_arrays = ('0'..'9').to_a\n alphabetical_array = ('a'..'z').to_a\n \n numbers_array = []\n alpha_array = []\n \n char_hash = Hash.new(0)\n \n s.each_char do |char|\n numbers_array << char if num_arrays.include?(char)\n alpha_array << char if alphabetical_array.include?(char)\n end\n \n str = ''\n \n while !numbers_array.empty? && !alpha_array.empty?\n str << numbers_array.pop\n str << alpha_array.pop\n end\n \n if alpha_array.size > 0\n if num_arrays.include?(str[str.size - 1])\n str << alpha_array.pop\n elsif num_arrays.include?(str[0])\n str.prepend(alpha_array.pop)\n end\n elsif numbers_array.size > 0\n if alphabetical_array.include?(str[str.size - 1])\n str << numbers_array.pop\n elsif alphabetical_array.include?(str[0])\n str.prepend(numbers_array.pop)\n end\n end\n \n str\nend",
"def remove_negations\n\n logger(\"Removing negations in #{@prefix.compact.join(\" \").to_s}\")\n\n prefix_array_reduced = @prefix.compact.join(\" \").to_s.gsub(/[\\/\\*]\\s0\\s[A-Za-z1-9]+|-\\s((([1-9][0-9]*\\.?[0-9]*)|(\\.[0-9]+)|[A-Za-z]+))\\s\\1|[\\+-\\/\\*]\\s0\\s0|[\\/\\*]\\s[A-Za-z0-9]+\\s0/,\"0\").gsub(/\\/\\s([A-Za-z1-9])\\s\\1/,\"1\")\n\n logger(\"Reduced to #{prefix_array_reduced}\")\n\n @prefix = prefix_array_reduced.split\n prefix_array_reduced = prefix_array_reduced.split.join(\" \")\n\n if !/\\/\\s([A-Za-z1-9])\\s\\1|[\\/\\*]\\s0\\s[A-Za-z1-9]+|-\\s((([1-9][0-9]*\\.?[0-9]*)|(\\.[0-9]+)|[A-Za-z]+))\\s\\2|[\\+-\\/\\*]\\s0\\s0|[\\/\\*]\\s[A-Za-z0-9]+\\s0/.match(prefix_array_reduced).nil?\n remove_negations\n else\n if !/^-\\s[\\/\\*\\+-].*0$/.match(prefix_array_reduced).nil?\n prefix_array_reduced.slice!(0..1)\n prefix_array_reduced.slice!((prefix_array_reduced.length-2)..(prefix_array_reduced.length-1))\n end\n return prefix_array_reduced\n end\n\n end",
"def decode(string)\n string.split(' ').map do |word|\n word.split('|').map { |char| MORSE.detect { |k, v| v == char}[0] }.join\n end.join(' ')\nend",
"def pig_it text\n arr = []\n text.split.map do |x|\n split_word = x.split('')\n unless /[[:punct:]]/.match(x)\n first_letter = split_word.first\n split_word.shift\n split_word << \"#{first_letter + 'ay'}\"\n end\n arr << split_word.join\n end\n arr.join(' ')\nend",
"def split_author_role_codes(str)\n # we're restrictive in our matching of role codes because\n # there's all kinds of crap inside parens in these strings\n author = str\n roles = []\n if str.present?\n ROLE_CODES.each do |code|\n # sometimes there's a period.\n author_portion = author.gsub(\"(#{code})\", \"\").gsub(\"(#{code}.)\", \"\")\n if author != author_portion\n author = author_portion.strip\n roles << code\n end\n end\n end\n return [author, roles]\n end",
"def maskify(cc)\n characters = cc.to_s.length - 4\n\n array = cc.to_s.split('')\n values = array.values_at(-4, -3, -2, -1)\n joint_values = values.join('')\n\n result = (\"#\" * characters) + joint_values\n return result\nend",
"def parse(string)\n\toperation = string.match(/ [-,+] /)[0]\n\tneg_op = string.match(/- /)\n\tcoeff_reg = string.match(/^-.?/)\n\n\tbinomial = string.split(operation)\n\n\tbinomial.delete \"\"\n\n\tbinomial.each_with_index do |s, index|\n\t\tnew_s = s.strip\n\t\tbinomial[index] = new_s\n\tend\n\n\tunless coeff_reg\n\t\tbinomial[0].prepend \"+\"\n\tend\n\n\tif neg_op\n\t\tbinomial[1].prepend \"-\"\n\telse\n\t\tbinomial[1].prepend \"+\"\n\tend\n\n\treturn binomial\nend",
"def vogal(str)\n vogals = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n cons = [\"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n# splitting the string given into arrays \n str = str.chars\n str_new = str.map do |char|\n#looping the string into the next letter\n if vogals.include?(char)\n vogals.rotate(1)[vogals.index(char)]\n else cons.include?(char)\n cons.rotate(1)[cons.index(char)]\n end\n end\n#joining the strings back\n str_new.join\nend",
"def pirates_say_arrrrrrrrr(string)\n \n arr = string.downcase.split('') # turning into an array and making lowercase\n \n index_no = arr.each_index.select { |r| arr[r] == 'r' } # finding the index no of each r\n \n new_index_no = index_no.map {|n| n + 1} # adding 1 to each index no\n \n p new_index_no.map {|i| arr[i] }.join # mapping the index no to the original arr and chaning to a str\n \nend",
"def pirates_say_arrrrrrrrr(string)\n resultArr = []\n\n string.split(\"\").each_index do |x|\n if (string[x].downcase === \"r\" && string[x+1] != nil)\n resultArr.push(string[x+1])\n end\n end\n\n return resultArr.join(\"\")\n\n\nend",
"def subtag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n(\\s{1,#{@tagsize-1}}\\S)/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def translate(string)\n initial_consonants =Regexp.new(/^(sch|scr|shr|sph|spl|spr|squ|str|thr|bl|br|ch|cl|cr|dr|dw|fl|fr|gl|gr|pl|pr|qu\\\n|sc|sk|sl|sm|sn|sp|st|sw|th|tr|tw|b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z)/)\n array = string.split(' ')\n new_array = []\n array.each do |element|\n if initial_consonants.match(element)\n position = ((initial_consonants.match(element)).to_s.length)\n new_string = element[position..element.length]+element[0...position] + 'ay'\n else\n new_string = element + 'ay'\n end\n new_array << new_string\n end\n new_array.join(' ')\nend",
"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 pig_latin(string)\n # Your code goes here\n arr = string.split(\" \")\n\n pig_latin = []\n arr.map do |x|\n if arr.length == 1\n return x[0] + \"ay\"\n else\n \n word = x[1..-1] + x[0] + \"ay\"\n pig_latin.push(word)\n end\n \n end\n return pig_latin.join(\" \")\nend",
"def fix_start(string)\n char_array = string.split(\"\")\n first_char = string[0]\n new_array = Array.new\n\n char_array.each do |i|\n if i == \"b\"\n new_array.push(\"*\")\n else\n new_array.push(i)\n end\n end\n\n new_array[0] = first_char\n puts new_array\nend",
"def odds_and_evens(string, return_odds)\n new_array= string.split(\"\")\nanother_array = []\nif return_odds\nnew_array.each.with_index {|char, index| another_array << char if index.odd?}\nanother_array.join\nelse \nnew_array.each.with_index {|char, index| another_array << char if index.even?}\nanother_array.join\nend\nend",
"def odds_and_evens(string, return_odds)\n string = string.split(\"\")\n empty_array = []\n string.each_with_index do |character,index|\n if return_odds && index.odd?\n empty_array << character #empty_array.push(char)\n elsif !return_odds && index.even?\n empty_array << character #empty_array.push(char)\n end\n end\n empty_array.join\nend",
"def not_zero(string)\n string.scan(/\\b\\w/).uniq.sort\n end",
"def expand_square(strings)\n # look for [...]\n out = [] \n strings.each do |string| \n string.match(/(.*)\\[([\\w\\d]*)\\](.*)/)\n\n pre = $1\n mid = $2\n post = $3\n\n if mid\n mid.split('').each do |opt|\n out.push \"#{pre || ''}#{opt}#{post}\"\n end\n end\n end\n\n out\n end",
"def create_pattern(piece)\n Array.new(4,piece).join\n end",
"def pig_latin_txt(string)\n arr=[]\n arr = string.split.map!{|x| pig_latin(x)}\n arr.join(' ')\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 stresses(string)\n p = phrase(string)\n .do(:tokenize)\n .map(&:value)\n .reject{ |t| /[[:punct:]]/.match(t) }\n .map{ |t| token_stress(t) }\n first, *rest = *p\n return [] unless first\n combinations = first\n .product(*rest)\n .map(&:join)\n .map{ |t| t.gsub(/\\D/, '') }\n .map{ |t| t.gsub(/2/, '1') }\n end",
"def detect_st( str, matrix )\n matrix.map do |combination|\n detect_single str, combination\n end\n end",
"def make_array\n @phrase_string.downcase.split(WORD_SPLIT).reject(&:empty?)\n end",
"def pirates_say_arrrrrrrrr(string)\n arr = string.downcase.split(\"\")\n r_array = []\n arr.each_with_index do |elem, index|\n if elem == \"r\"\n r_array << index + 1\n end\n end\n final = []\n r_array.each {|x| final << arr[x]}\n return final.join(\"\")\nend",
"def make_matrix(str1, str2)\n matrix = Array.new(str1.length + 1) { Array.new(str2.length + 1, 0) }\n\n str1.chars.each_with_index do |el1, idx1|\n str2.chars.each_with_index do |el2, idx2|\n if el1 == el2\n matrix[idx1 + 1][idx2 + 1] = matrix[idx1][idx2] + 1\n else\n matrix[idx1 + 1][idx2 + 1] = 0\n end\n end\n end\n\n matrix\nend",
"def make_matrix(str1, str2)\n matrix = Array.new(str1.length + 1) { Array.new(str2.length + 1, 0) }\n\n str1.chars.each_with_index do |el1, idx1|\n str2.chars.each_with_index do |el2, idx2|\n if el1 == el2\n matrix[idx1 + 1][idx2 + 1] = matrix[idx1][idx2] + 1\n else\n matrix[idx1 + 1][idx2 + 1] = 0\n end\n end\n end\n\n matrix\nend",
"def make_matrix(str1, str2)\n matrix = Array.new(str1.length + 1) { Array.new(str2.length + 1, 0) }\n\n str1.chars.each_with_index do |el1, idx1|\n str2.chars.each_with_index do |el2, idx2|\n if el1 == el2\n matrix[idx1 + 1][idx2 + 1] = matrix[idx1][idx2] + 1\n else\n matrix[idx1 + 1][idx2 + 1] = 0\n end\n end\n end\n\n matrix\nend",
"def name_2_id( a_string ) \n return a_string.gsub(\"[\",\"_\").gsub(\"]\",\"\");\n end",
"def pirates_say_arrrrrrrrr(string)\n a = string.split(\"\")\n return_string = Array.new\n\n a.length.times { |x| return_string.push(a[x + 1]) if a[x] == \"r\" || a[x] == \"R\" }\n\n return_string.join(\"\")\nend",
"def rotations(string)\n #array = string.split(//)\n #array2 = array.map {|element| }\n\n return (0...string.length).map { |i| (string * 2)[i, string.length] }\n\nend",
"def pig_latin(string)\n words_array = string.split(\" \")\n modified_words_array = \"\"\n words_array.map do |word|\n \n if word =~ /\\A[aeiou]/\n word += \"ay\"\n modified_words_array << word + \" \"\n \n # regex to grab three consonants took from http://stackoverflow.com/questions/18406509/using-regexp-to-check-whether-a-string-starts-with-a-consonant\n # word starts with three consonants or \"[const.]qu\" ie. \"square\", \"squat\"\n elsif ( word =~ /\\A(?i:(?![aeiou])[a-z]){3}/ ) || ( word =~ (/\\b[^aeiou]+qu/) ) # word =~ /\\A[^aeiou]+qu{3}/ )\n without_first_three = word[3..-1]\n without_first_three += word[0..2] + \"ay\"\n if word[0] == word[0].upcase\n without_first_three.capitalize!\n end\n modified_words_array << without_first_three + \" \"\n \n # word starts with two consonants or \"qu\" ie. \"quake\", \"quart\" \n elsif ( word =~ /\\A(?i:(?![aeiou])[a-z]){2}/ ) || ( word =~ /\\A[qu]{2}/ )\n without_first_two = word[2..-1]\n without_first_two += word[0..1] + \"ay\"\n if word[0] == word[0].upcase\n without_first_two.capitalize!\n end\n modified_words_array << without_first_two + \" \"\n \n # word starts with consonant \n elsif word =~ /\\A[^aeiou]/\n without_first = word[1..-1]\n without_first += word[0] + \"ay\"\n if word[0] == word[0].upcase\n without_first.capitalize!\n end\n modified_words_array << without_first + \" \"\n end\n \n end\n modified_words_array.chomp(\" \")\nend",
"def repeated_chars(word)\n finalArray = []\n array = word.split(\"\")\n boolean = false\n array.each_with_index do |element, index|\n array.each_with_index do |element2, index2|\n if index + 1 == index2 && element == element2 && boolean == false\n finalArray.push(element)\n boolean = true\n elsif index + 1 == index2 && element != element2\n boolean = false\n end\n end\n end\n return finalArray\n \nend",
"def string2logic(str)\n # Remove the spaces\n str = str.gsub(/\\s+/, \"\")\n # Parse the string\n return Transform.new.apply(Parser.new.parse(str))\n end",
"def pig_it(string)\n words = string.split\n\n words.map do |word|\n if word.match(/[a-z]/i)\n word[1..word.size] << word[0] << 'ay'\n else\n word\n end\n end.join(' ')\nend",
"def pig_it(str)\n \twords_from_sentence = str.split\n \twords_from_sentence.map! do |word|\n \t\tif word.length == 1\n \t\t\tif word.match? (/[^\\w]/)\n \t\t\t\tword\n \t\t\telse\n \t\t\t\tword << 'ay'\n \t\t\tend\n \t\telsif word[-1].match? (/[^\\w]/)\n \t\t\tlast_letter = word.slice!(-1)\n \t\t\tword << word.slice!(0) << 'ay' << last_letter\n \t\telse\n \t\t\tword << word.slice!(0) << 'ay'\n \t\tend\n \tend\n \twords_from_sentence.join(' ')\nend",
"def pirates_say_arrrrrrrrr(string)\n after_arr = \"\"\n arr = string.split('')\n for i in (0...arr.length)\n if arr[i] == \"r\" or arr[i] == \"R\"\n after_arr << arr[i+1]\n end\n end\n puts after_arr\nend",
"def id_and_name_from(string)\n string =~ /[^0-9a-f]/i ? [nil, string] : [string, nil]\n end",
"def pirates_say_arrrrrrrrr(string)\n r_indexes = []\n string.split(\"\").each_with_index{|letter, index| r_indexes << index if letter.downcase == \"r\"}\n plusoneindex = r_indexes.map{|index| index + 1}\n answer = \"\"\n plusoneindex.map{|index| string.split(\"\")[index]}.join\n\nend",
"def translate(string)\n newArr = []\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n \n # * Split it into words\n words = string.split()\n\n # * For every word in the sentence...\n words.each do |word|\n # * If the word has 'qu'\n if word[1..2].downcase == \"qu\"\n newArr << word[3..-1] + word[0..2] + \"ay\"\n\n elsif word[0..1].downcase == \"qu\"\n newArr << word[2..-1] + word[0..1] + \"ay\"\n\n # * If it starts with a vowel\n elsif vowels.include?(word[0].downcase)\n newArr << word + \"ay\"\n\n # * If the first three consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1]) and not vowels.include?(word[2])\n newArr << word[3..-1] + word[0..2] + \"ay\" \n # * ...or if the first two consonants aren't vowels\n elsif not vowels.include?(word[0].downcase) and not vowels.include?(word[1])\n newArr << word[2..-1] + word[0..1] + \"ay\" \n \n # * After all that, if it starts with one consonant\n else\n newArr << word[1..-1] + word[0] + \"ay\"\n end\n end\n\n newArr.join(\" \")\nend",
"def pig_it text\n answer = text.split(' ')\n answer.each_with_index do |str, index|\n if (!str.match(/[-!$%^&*()_+|~=`{}\\[\\]:\";'<>?,.\\/]/))\n firstLetter = str[0]\n str[0] = str[0].delete(str[0])\n answer[index] = str.concat(firstLetter) + \"ay\"\n end\n end \n answer.join(' ')\nend",
"def filter_repeated_character_strings(arr)\nend",
"def pirates_say_arrrrrrrrr(string)\n\n string = string.split(\"\")\n empty_array = []\n\n string.each_with_index do |letter, index|\n if letter == \"r\" || letter == \"R\"\n empty_array << string[index + 1]\n end\n end\n empty_array.join\nend",
"def pirates_say_arrrrrrrrr(string)\n\t#string_array = string.split(\"\")\n\t#string_array.each { |string| \"r\" +1}\n\t#puts string_array \n\n\tstring_array = string.split(\"\")\n\tnew_array = []\n\tstring_array.each_index do |x| \n\t\tunless x - 1 < 0\n\t\tif string_array.fetch(x - 1) == 'r'\n\t\t\tnew_array << string_array.fetch(x) \n\t\telsif string_array.fetch(x - 1) == 'R' \n\t\t\tnew_array << string_array.fetch(x) \n\t\tend\n\tend\n\tend\n\tnew_array.join\nend",
"def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend",
"def pseudoIsomorphicSubstrings(s)\n \n # Generate prefixs S'\n prefixs = []\n (s.size).times.each do |i|\n prefixs << s[0..i]\n end\n puts prefixs\n\n # For every i,j where i < j, the substrings of Si' (Sbi), are a subset of Sbj\n # and Sbj - Sbi are the substring that includes the last char of Sj'\n subsets = prefixs.map do |prefix|\n s = []\n\n (prefix.size).times.each do |i|\n s << prefix[i..-1]\n end\n \n s\n end\n puts subsets\n\n # Transform the substring to a sequence of numbers to compare values\n subsets.each do |subs|\n subs.map! { |sub| to_sequence(sub) }\n end\n puts subsets\n\n # For every i,j, such that 0 <= i < j, and a function ISO that generate\n # a set such that no two strings inside S' are pseudo-isomorphic to each other,\n # SUM(ISO(Si')) < ISO(Sj')\n puts \"=\"*50\n isosets = []\n subsets.each_with_index do |subs, i|\n if i == 0\n isosets << Set.new(subs)\n next\n end\n\n isosets << Set.new(subs).merge(isosets[i - 1])\n end\n puts isosets\n\n # Get sizes\n isosets.map { |iso| iso.size } \nend",
"def dna_string(string)\n letters = string.upcase.split('')\n return_arr = []\n letters.each do |i|\n if i == 'G'\n arr = []\n arr.push('G','C')\n return_arr.push(arr)\n elsif i == 'C'\n arr = []\n arr.push('C','G')\n return_arr.push(arr)\n elsif i == 'A'\n arr = []\n arr.push('A','T')\n return_arr.push(arr)\n elsif i == 'T'\n arr = []\n arr.push('T','A')\n return_arr.push(arr)\n end\n end\n p return_arr\nend",
"def translate(str)\n\tvowel=%w[a e i o u]\n\tcons=[*'a'..'z']-vowel\n\n\ta_str=str.split(\" \")\n\n\tfor i in 0..a_str.length-1\n\t\tif vowel.include?a_str[i][0]\n\t\t\tpig_l = a_str[i] + \"ay\"\n\t\t\treturn pig_l.split(\",\").join(\"\")\n\t\telsif cons.include?a_str[i][0]\n\t\t\tif cons.include?a_str[i][1]\n\t\t\t\tz=a_str[i].slice!(0..1)\n\t\t\telse\n\t\t\t\tz=a_str[i].slice!(0)\n\t\t\tend\n\t\t\tpig_l=a_str[i] + z+ \"ay\"\n\t\t\treturn pig_l.split(\",\").join(\"\")\n\t\tend\n\tend\nend",
"def tokenize_roles(string_to_split)\n string_to_split.split(/_or_/)\n end",
"def mapping(stringToSplit)\n arrSplit = stringToSplit.scan /\\w/\n return arrSplit.map { |n| n.ord }\nend",
"def applyMask(str, mask)\n newStr = \"\"\n (0...(str.length)).each do |i|\n if mask[i] == \"1\" \n newStr += str[i].upcase\n else\n newStr += str[i]\n end\n end\n return newStr\nend"
] | [
"0.5680787",
"0.5576906",
"0.5546782",
"0.554677",
"0.5517356",
"0.5515137",
"0.54760414",
"0.54503244",
"0.5427184",
"0.5394476",
"0.53865373",
"0.53825337",
"0.53650457",
"0.536414",
"0.53584665",
"0.53492194",
"0.5336559",
"0.5335094",
"0.5331078",
"0.53201073",
"0.5318915",
"0.5296759",
"0.52913076",
"0.52871895",
"0.5281065",
"0.5280245",
"0.5264741",
"0.52628434",
"0.52623194",
"0.52582175",
"0.5256492",
"0.52541757",
"0.5249464",
"0.5247766",
"0.5241504",
"0.52341276",
"0.5221075",
"0.5214296",
"0.52088535",
"0.5189746",
"0.5189414",
"0.51799613",
"0.51692784",
"0.5161967",
"0.5152643",
"0.5139515",
"0.5139369",
"0.51348954",
"0.5119356",
"0.51133126",
"0.511314",
"0.51127195",
"0.51033086",
"0.5094209",
"0.5088872",
"0.5085958",
"0.50743306",
"0.5073074",
"0.5071736",
"0.50641555",
"0.50603724",
"0.50448626",
"0.5036041",
"0.50276357",
"0.50268847",
"0.50258654",
"0.50209343",
"0.50158906",
"0.50099033",
"0.5007744",
"0.50044316",
"0.5002724",
"0.4994288",
"0.4992491",
"0.49922732",
"0.49922732",
"0.49922732",
"0.49825794",
"0.49811324",
"0.49808532",
"0.4980157",
"0.496825",
"0.49620944",
"0.49592862",
"0.4958034",
"0.4954142",
"0.4950708",
"0.49486548",
"0.49459648",
"0.49458873",
"0.49442682",
"0.49431545",
"0.49420255",
"0.49379957",
"0.49333343",
"0.493276",
"0.4931533",
"0.49290866",
"0.49279678",
"0.49272415"
] | 0.613412 | 0 |
private function to read input, called in intialize in creation of knowledge base and when adding to knowledge base | def input(prepositions)
@kb = string_to_internal(prepositions)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_input; end",
"def read_input\n end",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def parse_input (input_file)\nend",
"def input; end",
"def input; end",
"def input; end",
"def parse_input(params, resource); end",
"def input; @input; end",
"def input; @input; end",
"def input\n @input ||= File.read(inputDocument)\n end",
"def input\n @input ||= reader.read\n end",
"def input_lines; end",
"def get_input;\t@input \t\tend",
"def parse input\n c_doc = []\n while line = input.gets\n l = line.chomp.split(',')\n c_record = {\n :key => l[0],\n :volume => l[1],\n :path => l[2],\n :break => l[3],\n :empty1 => l[4],\n :empty2 => l[5],\n :pages => l[6],\n }\n new_doc if c_record[:break] && $. >1\n @doc.push c_record\n end\n new_doc\n Loadfile::Opticon.new @docs\n end",
"def intuit_values input\n readme = input\n .lines\n .chunk { |l| l[/^(?:=+|#+)/] || \"\" }\n .map(&:last)\n .each_slice(2)\n .to_h { |k, v|\n kp = k.map { |s|\n s.strip.chomp(\":\").sub(/(?:=+|#+)\\s*/, '').downcase\n }.join(\"\\n\")\n\n [kp, v.join.strip]\n }\n\n unless readme.empty? then\n desc = readme.values_at(*description_sections).join(\"\\n\\n\")\n summ = desc.split(/\\.\\s+/).first(summary_sentences).join(\". \")\n\n self.urls ||= parse_urls(readme.values.first)\n self.description ||= desc\n self.summary ||= summ\n else\n missing readme_file\n end\n\n self.changes ||= begin\n h = File.read_utf(history_file)\n h.split(/^(={2,}|\\#{2,})/)[1..2].join.strip\n rescue\n missing history_file\n \"\"\n end\n end",
"def input\n @input ||= STDIN.readlines\nend",
"def input\n RDF::Util::File.open_file(inputDocument)\n end",
"def read_input(prompt, save_hist = T.unsafe(nil)); end",
"def input_string; end",
"def parse_input (input_string)\n lines = input_string.split(/\\n/)\n\n state = :reading_map\n\n rover_x_start = 0\n rover_y_start = 0\n rover_facing_start = 0\n\n lines.each do |line|\n # drop empty lines\n next unless /(\\w)+/ =~ line\n\n case state\n when :reading_map\n match = /^\\s*(\\d+)\\s+(\\d+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid map data >>#{line}<<\") unless match\n\n x_size = $1.to_i\n y_size = $2.to_i\n\n # the format is not the size, it's the greatest valid index\n init_map(x_size,y_size)\n\n state = :reading_rover_init\n\n when :reading_rover_init\n match = /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/.match(line)\n # match = line.match /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_x_start = $1.to_i\n rover_y_start = $2.to_i\n rover_facing_start = $3\n\n state = :reading_rover_instructions\n when :reading_rover_instructions\n match = /^\\s*([LRM]+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_instructions = $1\n\n add_rover(rover_x_start,rover_y_start,rover_facing_start,rover_instructions)\n\n state = :reading_rover_init\n end\n end\n\n end",
"def read_object\n\t\t\t\tJSON.parse @input.readline\n\t\t\tend",
"def initialize\n @input = STDIN.readlines.join\n @input.strip!\n end",
"def read_input(input)\n YAML.load_file(input)\nrescue => e\n raise \"Unable to open #{input}: #{e.message}\"\nend",
"def preprocess(input); end",
"def preprocess_input(input)\nend",
"def input \n @input ||= JSON.parse(File.read(ARGV[0]));\nend",
"def initialize(input)\n super()\n @io = input\n @eof = false\n @lineno = 0\n @fields = nil\n @separator = ';'\n parse!\n end",
"def initialize(input)\n @input = input\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read_input_line line_in, line_number\n\t\tinput_params = line_in.split(\" \")\n\t\tunless input_params.empty? \n\t\t\tbegin\t \n\t\t\t\tcase input_params[0]\n\t\t\t\twhen \"Driver\"\n\t\t\t\t\tself.handle_driver_command input_params\t\t\n\t\t\t\twhen \"Trip\"\n\t\t\t\t\tself.handle_trip_command input_params\t\t\n\t\t\t\telse\n\t\t\t\t\tputs \"#{input_params[0]} id not a supported command\"\n\t\t\t\tend\n\t\t\trescue => err\n\t\t\t puts \"line #{line_number} not parsed, Incorrect input format #{line_in} - #{err}\"\n\t\t\t err\n\t\t\tend\t\t\t\n\t\tend\n\tend",
"def source=(input); end",
"def read(*args, **kwd); end",
"def initialize(input_file)\n\t\tsuper(input_file)\n\t\t\n\tend",
"def prepare_to_parse(input)\n @input = input\n @input_length = input.length\n reset_index\n @node_cache = Hash.new {|hash, key| hash[key] = Hash.new}\n @terminal_failures = []\n @regexps = {}\n @max_terminal_failure_index = 0\n end",
"def read\n \n end",
"def text_input; end",
"def read\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n begin\n # at line 908:3: ( iread | fread | cread )\n alt_30 = 3\n case look_30 = @input.peek( 1 )\n when T__49 then alt_30 = 1\n when T__50 then alt_30 = 2\n when T__51 then alt_30 = 3\n else\n raise NoViableAlternative( \"\", 30, 0 )\n end\n case alt_30\n when 1\n # at line 909:5: iread\n @state.following.push( TOKENS_FOLLOWING_iread_IN_read_1471 )\n iread\n @state.following.pop\n\n when 2\n # at line 910:7: fread\n @state.following.push( TOKENS_FOLLOWING_fread_IN_read_1479 )\n fread\n @state.following.pop\n\n when 3\n # at line 911:7: cread\n @state.following.push( TOKENS_FOLLOWING_cread_IN_read_1487 )\n cread\n @state.following.pop\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return \n end",
"def prepare\n self[:in].read\n end",
"def readline\n end",
"def call_input_data\n if creates && input\n input[/a165627a7a72305820\\w{64}0029(\\w*)/,1]\n elsif input && input.length>10\n input[10..input.length]\n else\n []\n end\n end",
"def call_input_data\n if creates && input\n input[/a165627a7a72305820\\w{64}0029(\\w*)/,1]\n elsif input && input.length>10\n input[10..input.length]\n else\n []\n end\n end",
"def parse_input(line)\n pieces = line.split(' ')\n a = pieces[1]\n b = pieces[7]\n @step_map.add_node(a, b)\n end",
"def input\n @input ||= RDF::Util::File.open_file(action) {|f| f.read}\n end",
"def input\n @input ||= RDF::Util::File.open_file(action) {|f| f.read}\n end",
"def parse(input = nil, options = 0)\n end",
"def initialize\n self.consume_all_input = true\n end",
"def input=(_arg0); end",
"def initialize\n puts 'GitHub Archiver Challenge'\n # get_input\n get_data\n end",
"def read_user_input\n if ARGV.size < 2\n puts \"Insufficient inputs provided.\"\n exit\n \n elsif ARGV.size == 2\n $network = ARGV[0]\n $dataMut = ARGV[1]\n $weights_file = \"none\"\n $alpha = nil\n $cancer = \"nCOP_out\"\n \n elsif ARGV.size > 2\n $network = ARGV[0]\n $dataMut = ARGV[1]\n $weights_file = \"none\"\n $alpha = nil\n $cancer = \"nCOP_out\"\n \n (2..(ARGV.size - 1)).each do |i|\n index = ARGV[i].index(\"=\")\n\n if index.nil?\n puts \"Illegal input format. Please use param=value without white spaces if adding any non-required parameters, i.e alpha=0.4\"\n exit\n end\n \n param = ARGV[i][0..(index - 1)]\n value = ARGV[i][(index+1)..-1]\n \n case param\n when \"alpha\"\n $alpha = value.to_f\n when \"weights\"\n $weights_file = value\n when \"output_prefix\"\n $cancer = value\n else\n puts \"Wrong parameter specified. Please use one of the alpha=, weights=, or output_prefix=.\"\n exit\n end\n end\n end\nend",
"def initialize(input)\n @input = input\n end",
"def initialize(input)\n @input = input\n end",
"def initialize(input)\n @input = input\n end",
"def reading(var, var_type) #method\n user_input = $stdin.gets.chomp\n user_input_type = get_type(user_input)\n user_input_class = user_input_type.class\n type = digest_type(var_type, user_input)\n if user_input_class.to_s == type\n @current_context[var] = user_input_type\n else\n puts \"Fatal Error: semantic cube error, expected #{var_type} and got #{user_input_class}.\"\n exit\n end\n end",
"def input!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n\n\n\n type = INPUT\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 42:8: 'traer'\n match( \"traer\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 21 )\n\n\n end",
"def parseInput(args)\n\t# in case it is a full path, get only the filename part\n\targstr = File.basename(args.join(\" \").strip())\n\t# remove filename extensions\n\twhile argstr.sub!(/\\.[a-zA-Z2]{1,5}/,''); end\n\t# Case 1: LC control number\n\tif argstr.start_with?('lccn:') then\n\t\treturn {'lccn' => argstr.sub!('lccn:','')}\n\tend\n\t# Case 2: worldcat query string\n\ttokens = argstr.split(/\\b(author|isbn|keyword|title)=/).drop(1)\n\tif tokens.length > 1 then\n\t\treturn Hash[*tokens]\n\tend\n\t# Case 3: ISBN10 or ISBN13\n\tfor i in 0..(argstr.length - 13) do\n\t\treturn {'isbn' => argstr[i..(i+12)]} if isbn13?(argstr[i..(i+12)])\n\tend\n\tfor i in 0..(argstr.length - 10) do\n\t\treturn {'isbn' => argstr[i..(i+9)]} if isbn10?(argstr[i..(i+9)])\n\tend\n\t# Case 4: Semicolon-separated pieces (probably filename without extension)\n\ttokens = argstr.split(\";\")\n\tret = {}\n\tif tokens.length == 3 then # fulltitle;authors;year\n\t\tret['fulltitle'] = tokens[0].gsub(/[-_]/, ' ')\n\t\tret['year'] = tokens[2].gsub(/[^\\d]/,'')\n\t\tif tokens[1] =~ /^([a-zA-Z]+-)?(.*)$/ then\n\t\t\tret['author'] = $2 if $2.length > 0\n\t\tend\n\telsif tokens.length > 1 then\n\t\tret['fulltitle'] = tokens.shift.gsub(/[-_]/, ' ')\n\t\tauthor = tokens.drop_while{|x| x =~ /[^a-zA-Z\\s]/}.first\n\t\tret['author'] = author unless author.nil?\n\telse\n\t\tret['fulltitle'] = argstr.gsub(/[-_]/, ' ')\n\tend\n\tret['fulltitle'] = ret['fulltitle'].gsub(/\\(.*\\)/,'').gsub(/ +/,' ').strip\n\tret['fulltitle'].match(/\\b(\\d+)e$/) { |m|\n\t\tret['edition'] = m[1]\n\t\tret['fulltitle'].sub!(/\\b\\s*\\d+e$/,'')\n\t}\n\tret['title'] = ret['fulltitle'].sub(/\\..*$/,'').strip()\n\treturn ret\nend",
"def prepare_input(prompt)\n line = readline(prompt)\n return unless line\n\n last_if_empty(line)\n end",
"def input?; @input; end",
"def input\n STDIN.read.split(\"\\n\")\nend",
"def reader; end",
"def get_input\n @input = gets.strip\n end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def process_input_file\n\t\t\tinput_file = File.open(@params[:input_file], 'r')\n\t\t\tfile_terms = convert_contents_to_search_string(input_file.read)\n\t\t\tadd_terms(file_terms)\n\t\tend",
"def read_input(file_name)\n\n all_inputs = Array.new\n file = File.open(file_name)\n input_data = file.read\n input_data.each_line do |line|\n #next if line.start_with?('#')\n #next if line.chomp.empty?\n input = line.chomp.strip\n all_inputs << input\n end\n return all_inputs[0]\nend",
"def read_and_execute(inp)\n args = inp.split(' ') # Split the input by space\n cmd_name = args[0] # First argument of the command name\n cmd_args = args[1..inp.length] # Second argument is the argument of the commands\n @commands_available[cmd_name].execute(cmd_args)\n end",
"def get_input\n @input = gets.chomp\n end",
"def preprocess_input(input)\n input\nend",
"def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end",
"def read_parameters\n params = read_stdin\n return_error(\"Parameter 'target' contains illegal characters\") unless safe_string?(params['target'])\n params\nend",
"def read_thing(thing)\n print input_prompt(thing[:text], thing[:default])\n validate_input(read_input, thing[:default], thing[:test])\n end",
"def parse_entry(io)\n # Read INSDC or RefSeq entry\n Bio::FlatFile.auto(io).each do |entry|\n @entry = entry\n @features = entry.features\n @source = @features.shift\n parse_sequence\n parse_source\n #parse_genes\n parse_features\n end\n end",
"def read(input)\n # wrap strings in stringIO\n input = StringIO.new(input) if input.kind_of? ::String\n\n @offset = input.pos\n @values.each {|field|\n field.read_io(input)\n }\n @size = input.pos - @offset\n end",
"def load_inp(filename,runner = nil)\n BTAP::runner_register(\"Info\", \"loading file:\" + filename, runner)\n #Open the file.\n #puts filename\n iter = 0\n\n\n File.exist?(filename)\n f = File.open(filename, \"r\")\n\n\n\n\n #Read the file into an array, line by line.\n lines = f.readlines\n #Set up the temp string.\n command_string =\"\"\n #iterate through the file.\n parents = Array.new()\n children = Array.new()\n lines.each do|line|\n iter = iter.next\n #line.forced_encoding(\"US-ASCII\")\n #Ignore comments (To do!...strip from file as well as in-line comments.\n if (!line.match(/\\$.*/) )\n\n if (myarray = line.match(/(.*?)\\.\\./) )\n #Add the last part of the command to the newline...may be blank.\"\n command_string = command_string + myarray[1]\n #Determine correct command class to create, then populates it.\"\n command = DOECommandFactory.command_factory(command_string, self)\n #Push the command into the command array.\"\n @commands.push(command)\n command_string = \"\"\n else\n myarray = line.match(/(.*)/)\n command_string = command_string + myarray[1]\n end\n end\n end\n \n organize_data()\n BTAP::runner_register(\"Info\",\"INP model contains:\", runner)\n #report number of things read in. \n [\"SPACE\",\"ZONE\",\"EXTERIOR-WALL\",\"ROOF\",\"INTERIOR-WALL\",\"UNDERGROUND-WALL\",\"WINDOW\",\"DOOR\",\"MATERIAL\",\"CONSTRUCTION\"].each do |item|\n items = self.find_all_commands(item)\n message = \"\\t#{item} = #{items.size}\"\n BTAP::runner_register(\"Info\",message, runner)\n end\n BTAP::runner_register(\"Info\", \"\\tFinished Loading File:\" + filename,runner)\n end",
"def initialize(input)\n # Set the input document attribute\n @input_document = REXML::Document.new(input)\n \n # Initialize the handler and pre-load form definitions using the credentials\n # supplied by the task info items.\n preinitialize_on_first_load(\n @input_document,\n ['KS_SRV_CustomerSurvey']\n )\n\n # Determine if debug logging is enabled.\n @debug_logging_enabled = get_info_value(@input_document, 'enable_debug_logging') == 'Yes'\n puts(\"Logging enabled.\") if @debug_logging_enabled\n\t\n\t@taskVersion = get_info_value(@input_document, 'taskVersion')\n\n \t# Store parameters in the node.xml in a hash attribute named @parameters.\n @parameters = {}\n REXML::XPath.match(@input_document, '/handler/parameters/parameter').each do |node|\n @parameters[node.attribute('name').value] = node.text\n end\n puts(format_hash(\"Handler Parameters:\", @parameters)) if @debug_logging_enabled\n\n end",
"def read() end",
"def input\n @all[:input]\n end",
"def read_stdin()\n # Purpose: import data out of STDIN\n # Input : none\n # Output : Array of inbound scores, array ouf outbound scores\n # Remarks: Empty values are mapped to nil, non-integer values are mapped to 0\n \n vprint \"Starting to read STDIN\"\n\n def map_data(data,nils,stats)\n if data == \"-\" or data == \"\"\n nils = nils + 1\n else\n stats << data.to_i\n end\n return nils, stats\n end\n\n stats_in = Array.new()\n stats_out = Array.new()\n nils_in = 0 \n nils_out = 0 \n \n n = 0\n formatcheck_ok = false\n\n STDIN.each do |line| # we checked for STDIN in check parameter phase\n n = n + 1\n dprint \"Processing line ##{n}: #{line.chomp}\"\n begin\n in_data, out_data = line.chomp.split(\";\")\n unless formatcheck_ok\n if in_data != in_data.to_i.to_s\n \t puts_error(\"Input's first line indicates, input is not in CSV format as\")\n\t puts_error(\"explained by help text. This is fatal. Aborting.\")\n\t exit 1\n else\n formatcheck_ok = true\n end\n end\n nils_in, stats_in = map_data(in_data, nils_in, stats_in)\n nils_out, stats_out = map_data(out_data, nils_out, stats_out)\n rescue => detail\n puts_error(\"Could not read line ##{n}: \\\"#{line.chomp}\\\". Ignoring.\")\n end\n\n end\n\n 1.upto($params[:baseline]) do\n\t stats_in << 0\n\t stats_out << 0\n end\n\n vprint \"Done reading STDIN (imported #{n} lines of data)\"\n\n return nils_in, stats_in, nils_out, stats_out\n\nend",
"def readInput\r\n puts 'Please enter a valid Temperature: '\r\n input = gets.to_s\r\n anArray = input.split(' ')\r\n self.myDegrees = anArray[0].to_f\r\n self.myScale = anArray[1].upcase\r\n checkIfValid(self.myDegrees, self.myScale)\r\n end",
"def parse_input(input)\n input.split(\"\\n\").map{|name| parse_name(name) }\nend",
"def prepare_input(prompt); end",
"def get_input\n story = gets.chomp\nend",
"def load_input(maze)\n puts \"Enter the input string\"\n print PROMPT\n input = $stdin.gets.chomp.downcase\n maze.load(input) if(validate_string(input))\n puts \"Here is the graph of the maze\" if(maze.valid == true)\n maze.display if(maze.valid == true)\n end",
"def input \n\t@plaintext = File.read(ARGV[0]).split(//)\n\t@key = ARGV[1].to_i\n\t@file_out = ARGV[2]\nend",
"def read_input(prompt, save_hist = true)\n line = prepare_input(prompt)\n return unless line\n\n history.push(line) if save_hist\n\n command_queue.concat(split_commands(line))\n command_queue.shift\n end",
"def read(_lines)\n raise NotImplementedError\n end",
"def readline(*rest) end",
"def readline(*rest) end",
"def manual_input # {{{\n\n # Convenience shorthand \n yellow = Proc.new { |m| @log.colorize( \"Yellow\", m.to_s ) }\n\n STDOUT.flush\n #$/ = '\\r\\n'\n\n # Aquire data\n puts yellow.call( \"\\n>> Please type your [[ JOKE ]] here and after you are finished hit CTRL+D twice\\n\" )\n\n # The method over the re-def over $/ = \"END\" works too, but mangles later STDIN.gets somehow - why?\n joke = \"\"\n while true\n begin\n input = STDIN.sysread(1)\n joke += input\n rescue EOFError\n break\n end\n end\n\n puts yellow.call( \">> TITLE of this joke: \" )\n title = STDIN.readline.chomp\n\n puts yellow.call( \">> URL where you found this joke (Press enter to accept previous URL: #{@_prev_url.to_s}): \" )\n url = STDIN.readline\n if( url =~ %r{^\\n$} )\n puts yellow.call( \">> Using previous URL ( #{@_prev_url.to_s} )\" )\n url = @_prev_url \n else\n url = url.chomp\n end\n\n @_prev_url = url\n\n puts yellow.call( \">> Who posted or authored this joke: \" )\n author = STDIN.readline.chomp\n\n new = Joke.new\n new.content = joke.chomp\n new.title = title\n new.url = url\n new.author = author\n\n puts \"\"\n puts \"-\"*30\n puts \"Joke object:\"\n puts \"\"\n p new\n puts \"-\"*30\n answer = get_choice_from_bipolar( \"Do you want to store this joke to Database? \" )\n\n if( answer ) \n res = new.save!\n answer = ( res ) ? ( \"Success !\" ) : ( \"Failure !\" )\n puts yellow.call( answer )\n end\n\n new\n end",
"def input\n @input ||= Input.new\n end"
] | [
"0.7333816",
"0.7254152",
"0.6922051",
"0.6922051",
"0.6890028",
"0.67104304",
"0.67104304",
"0.67104304",
"0.65179425",
"0.64887583",
"0.64887583",
"0.64805466",
"0.63677293",
"0.63103247",
"0.62835985",
"0.62647754",
"0.62050456",
"0.6169425",
"0.6022659",
"0.5993443",
"0.5981683",
"0.5878488",
"0.5863403",
"0.58608466",
"0.58543855",
"0.5845716",
"0.5837122",
"0.58363575",
"0.5828348",
"0.580016",
"0.58000416",
"0.58000416",
"0.58000416",
"0.58000416",
"0.58000416",
"0.57987815",
"0.5797236",
"0.57803476",
"0.5779235",
"0.57648665",
"0.57637435",
"0.5755668",
"0.57251996",
"0.57205296",
"0.5713704",
"0.57089275",
"0.57089275",
"0.57046807",
"0.569985",
"0.569985",
"0.569957",
"0.56930935",
"0.5688329",
"0.56837106",
"0.5681913",
"0.567142",
"0.567142",
"0.567142",
"0.56713015",
"0.56680864",
"0.5660937",
"0.5653501",
"0.56513125",
"0.564848",
"0.5639875",
"0.56330705",
"0.56276673",
"0.56276673",
"0.56276673",
"0.56276673",
"0.56276673",
"0.56276673",
"0.56276673",
"0.56198615",
"0.56131405",
"0.56131065",
"0.56007487",
"0.5600647",
"0.5590415",
"0.5577456",
"0.55774117",
"0.55756986",
"0.5572401",
"0.5552485",
"0.5542548",
"0.5541458",
"0.55404633",
"0.5539222",
"0.55380607",
"0.55266446",
"0.5525356",
"0.55241954",
"0.55205584",
"0.5516807",
"0.5514977",
"0.5511698",
"0.55084634",
"0.55084634",
"0.5488583",
"0.5475047"
] | 0.5792584 | 37 |
calls in sequence, could add logic to remove instead, but rather not make it public | def find_remove(preposistion)
remove(find(preposition))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove!; end",
"def method_removed(*) end",
"def remove\n __flag__ :remove\n end",
"def remove_item\n\n end",
"def remove(val)\n\nend",
"def prepareForReuse; end",
"def discard; end",
"def discard; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def delete_front()\n \n end",
"def remove(*)\n super.tap do\n __debug_sim('USER initiates removal of existing entries.')\n end\n end",
"def cleanup\n super\n end",
"def delete_operations; end",
"def finalized; end",
"def recall; end",
"def remove(value)\n #YOUR WORK HERE\n end",
"def cleanup\n super\n end",
"def remove(entry); end",
"def reap; end",
"def private; end",
"def after_clear\n end",
"def remove_via_api!\n QA::Runtime::Logger.debug(\"#{self.class.name} - deferring removal until after suite\")\n end",
"def pre_process_batch_remove(docs, method)\n docs.map do |doc|\n self.path = doc.atomic_path unless path\n execute_callback :before_remove, doc\n unless _assigning?\n doc.apply_destroy_dependencies!\n doc.run_before_callbacks(:destroy) if method == :destroy\n end\n _target.delete_one(doc)\n _unscoped.delete_one(doc)\n unbind_one(doc)\n execute_callback :after_remove, doc\n doc.send(:as_attributes)\n end\n end",
"def remove(*)\n super.tap do\n submission.set_simulation(__method__) if simulating\n end\n end",
"def run_on_removal(paths)\n super\n end",
"def remove(type); end",
"def done_adding(*) end",
"def cleanup!; end",
"def cleanup!; end",
"def reconsume; end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def remove!\n self.class.removed(item)\n end",
"def cleanup\r\n end",
"def cleanup!\n # This method may be left unimplemented if that is applicable\n end",
"def pausable; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def _remove_method\n :\"_remove_#{self[:name].to_s.singularize}\"\n end",
"def after_soft_delete; end",
"def post_process_batch_remove(docs, method)\n docs.each do |doc|\n doc.run_after_callbacks(:destroy) if method == :destroy\n doc.freeze\n doc.destroyed = true\n end\n end",
"def del(*args); end",
"def pop\r\n # IMPLEMENT ME\r\n end",
"def pop\n # IMPLEMENT ME\n end",
"def cleanup\n # override and do something appropriate\n end",
"def retire\n\n end",
"def unwatch; end",
"def unwatch; end",
"def cleanup\n\tend",
"def cleanup\n\tend",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def reset; end",
"def remaining; end",
"def method_removed(id)\n\t\t\t\t\treset_routing_cache\n\t\t\t\tend",
"def unquiesce \n raise NotImplementedError.new\n end",
"def delelte\n\n end",
"def remove_player\n add_remove_player :remove\n end",
"def cleanup_hook; end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def clean_up\n end",
"def clean_up\n end",
"def method_removed(id)\n\t\t\t\treset_routing_cache\n\t\t\tend",
"def clear!; end",
"def clear!; end",
"def clear!; end",
"def remove\n\n removed = true\n self.sections.each do |section|\n removed = section.remove\n break if !removed\n end\n\n return removed && self.destroy\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end"
] | [
"0.7608687",
"0.7608687",
"0.7608687",
"0.7608687",
"0.7302225",
"0.66224986",
"0.65020186",
"0.6396098",
"0.634207",
"0.63171536",
"0.6278926",
"0.6278926",
"0.62548035",
"0.62548035",
"0.62548035",
"0.62548035",
"0.62173784",
"0.61737305",
"0.6172877",
"0.6160341",
"0.61378884",
"0.6136327",
"0.6122789",
"0.61208665",
"0.60848594",
"0.6076738",
"0.6060945",
"0.60522133",
"0.60444844",
"0.5990335",
"0.5975092",
"0.5973599",
"0.5949763",
"0.59355634",
"0.5921372",
"0.5921372",
"0.5904518",
"0.5896887",
"0.5896887",
"0.5896887",
"0.5842068",
"0.5838432",
"0.5832061",
"0.58302134",
"0.5813868",
"0.5813868",
"0.5813868",
"0.5813868",
"0.5813868",
"0.5813868",
"0.5813868",
"0.58076406",
"0.58042896",
"0.57949847",
"0.57937497",
"0.57848364",
"0.5760538",
"0.5746881",
"0.5744819",
"0.5740192",
"0.5740192",
"0.57348317",
"0.57348317",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.5721888",
"0.57154053",
"0.5709378",
"0.570931",
"0.57008165",
"0.56974226",
"0.56902015",
"0.5688424",
"0.5688424",
"0.5688424",
"0.5688424",
"0.5686682",
"0.5686682",
"0.5685994",
"0.56741446",
"0.56741446",
"0.56741446",
"0.5656881",
"0.5653878",
"0.5653878",
"0.5653878"
] | 0.0 | -1 |
removes the last logical statement added, returns false on failure, else true | def remove_last()
temp = @kb.pop
return !temp.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_statement?\n false\n end",
"def semact?; false; end",
"def end?\r\n\t\tif(@allLines.empty?)\r\n\t\t\treturn true\r\n\t\telse\r\n\t\t\treturn false\r\n\t\tend\r\n\tend",
"def halted?\n @current >= (@size - 1)\n end",
"def can_redo?; @last_done < (@actions.size - 1); end",
"def delete_next?\n inside_blank_pair?\n end",
"def can_undo?; @last_done >= 0; end",
"def triple_expression?; false; end",
"def finished?\n !board[1..-1].include?(false)\n end",
"def previously_existed?\n true\n end",
"def conditionally_false\n\t\t!self\n\tend",
"def to_exp?\n @statement_list.each do |s|\n return false if s.to_exp? == false\n end\n return true\n end",
"def game_end (board)\n (horizontal_line(board) || vertical_line(board) ||\n diagonal_line(board) || full_board(board)) ? true : false\n end",
"def check_ending(_result)\n end",
"def finish_step?\n return !goto_true && !goto_false\n end",
"def new_line?\n ary = insertion_point\n ary.empty? || ary.all? {|stmt| stmt.type == :code }\n end",
"def finished?\n !@operations or @operations.empty?\n end",
"def done?\n @possibles.all? do |ops_modifiers, count|\n count.zero? || !all_ops_modifiers_qualify?(ops_modifiers, count)\n end\n end",
"def last?\n not last.nil?\n end",
"def delete_last()\n if @queue.size > 0\n @queue.pop\n return true\n end\n false\n end",
"def last_command_successful?\n $?.exitstatus == 0\n end",
"def final?\n self.winner || self.moves.empty?\n end",
"def non_complex_expression?(condition); end",
"def execute?(cmd)\n execution_result = execute(cmd)\n !execution_result.nil? && execution_result\n end",
"def next?()\n !end?\n end",
"def isAtEnd\n return @index >= (@actions.size - 1)\n end",
"def truth\n\t\t\t\"You can't handle the truth\" ; true\n\t\tend",
"def remove?\n remove && remove != \"\" && remove !~ /\\A0|false$\\z/\n end",
"def ok?\n skip? || @result\n end",
"def end_workup?(l)\n\t\tstart_treatment?(l)\n\tend",
"def last_move?\n @moves[-1]\n end",
"def last?\n !right_sibling\n end",
"def success?() end",
"def remaining?\n cleanup\n return false if count >= max_operations\n true\n end",
"def empty?\n @statements.empty?\n end",
"def undoEmpty?\n return @undoStack.empty? \n end",
"def end?\n\t\twin?(\"x\") || win?(\"o\") || @board.count(\"-\") == 0\n\tend",
"def done_or_not(board)\n\n\tprintBoard(board)\n\trowBoard = board.transpose\n\t\n\tif evaluate(board) == false or evaluate(rowBoard) == false or divBoard(board) == false\n\t\treturn false\n\tend\n\t\nend",
"def unfinished?\n !finished?\n end",
"def evaluate?\n false\n end",
"def evaluate?\n false\n end",
"def remove_should_check_existing?\n false\n end",
"def first?\n result = @first[-1]\n @first[-1] = false\n result\n end",
"def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end",
"def switching_to_new_control?(control)\n @last_control && @last_control != control\n end",
"def hook?(sentence, clause)\n\tarr1 = sentence\n\tarr2 = sentence\n\tarr2.delete_at(arr2.length - 1)\n\tarr3 = clause\n\tputs arr1\n\tputs arr2\n\tputs arr3\n\treturn (arr1.last == arr3[1] and arr2.last == arr3[0])\nend",
"def evaluate_next_step_on_change?\n false\n end",
"def recording?\n @decision != Decision::DROP\n end",
"def has_winner?\n (@last_insert_x > 0) ? (check_column || check_row) : false\n \n end",
"def test_or_implies(stmt)\n l = eval_side(stmt.left)\n r = eval_side(stmt.right)\n if !l.nil? && !l\n set_truth(stmt.right.left) if stmt.right.type == :terminal\n elsif !r.nil? && !r\n set_truth(stmt.left.left) if stmt.left.type == :terminal\n end\n end",
"def has_next_state?\n return @operation != :nop\n end",
"def process_statement_end(tk)\n # Whitespace means that we keep the same value of @new_statement as last token\n return if tk.class == TkSPACE\n\n return unless\n # We might be coming after a statement-ending token...\n (@last_tk && [TkSEMICOLON, TkNL, TkEND_OF_SCRIPT].include?(tk.class)) ||\n # Or we might be at the beginning of an argument list\n (@current_block == TkDEF && tk.class == TkRPAREN)\n\n # Continue line ending on . or ::\n return if @last_tk && [EXPR_DOT].include?(@last_tk.lex_state)\n\n # Continue a possible existing new statement unless we just finished an expression...\n return unless (@last_tk && [EXPR_END, EXPR_ARG].include?(@last_tk.lex_state)) ||\n # Or we've opened a block and are ready to move into the body\n (@current_block && [TkNL, TkSEMICOLON].include?(tk.class) &&\n # Handle the case where the block statement's expression is on the next line\n #\n # while\n # foo\n # end\n @last_ns_tk.class != @current_block &&\n # And the case where part of the expression is on the next line\n #\n # while foo ||\n # bar\n # end\n @last_tk.lex_state != EXPR_BEG)\n\n # Continue with the statement if we've hit a comma in a def\n return if @current_block == TkDEF && peek_no_space.class == TkCOMMA\n\n if [TkEND_OF_SCRIPT, TkNL, TkSEMICOLON].include?(tk.class) && @state == :block_statement &&\n [TkRBRACE, TkEND].include?(@last_ns_tk.class) && @level == 0\n @current_block = nil\n end\n\n unless @current_block\n @done = true\n return\n end\n\n @state = :pre_block\n @level += 1\n @block_num += 1\n unless @block\n @block = TokenList.new\n @statement << TkStatementEnd.new(tk.line_no, tk.char_no)\n end\n end",
"def last?\n\t\treturn @iteration == @items.length - 1\n\tend",
"def any?\n raise \"#{self.class}: instance not prepared before doing any move\" unless @prepared\n\n @total_rows_number > 0\n end",
"def tombstone?\n !! @tombstone\n end",
"def tombstone?\n !! @tombstone\n end",
"def eof?\n @stmt.done?\n end",
"def _false\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"false\")\n unless _tmp\n self.pos = _save\n break\n end\n _save1 = self.pos\n _tmp = apply(:_utfw)\n _tmp = _tmp ? nil : true\n self.pos = _save1\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_false unless _tmp\n return _tmp\n end",
"def committed?()\n return nil\n end",
"def straight_flush?()\n return self.straight? && self.flush? \n end",
"def final_decision?\n final_decision\n end",
"def verifyLastOperation(operationType, node)\n if(!$oldOperation.nil?)\n if ($oldOperation.operationElement.eql? node.operationElement and $oldOperation.operation.eql? operationType and $oldOperation.operationId != node.operationId)\n $failed = true\n end\n end\nend",
"def ensure_not_last_option\n return false if good.options.count == 1\n end",
"def multi_arged?\n false\n end",
"def kill_line(*)\n if current_buffer[current_buffer.point] == \"\\n\"\n current_buffer.slice!(current_buffer.point)\n return true\n end\n\n line_end = current_buffer.index(/$/, current_buffer.point)\n current_buffer.slice!(current_buffer.point, line_end - current_buffer.point)\n true\nend",
"def passing?\n return false if self.test_executions.empty?\n \n most_recent_execution = self.ordered_executions.first\n return !most_recent_execution.nil? && most_recent_execution.passing?\n end",
"def is_finished?\n @board.each do |row|\n row_str = row.join.delete(' ')\n if row_str.length < @board.size\n return false\n end\n end\n\n true\n end",
"def returns_one?\n rule != :each\n end",
"def halt?\n @halt\n end",
"def termination?\n false\n end",
"def collapsing?\n self.begin(0) == self.end(0)\n end",
"def final_state?(curr_state = nil, **)\n next_state(curr_state).blank?\n end",
"def red?\n failed? || deleting?\n end",
"def end_conditions?\n #checks winner\n if @board.win_conditions?\n if @current_player\n puts \"Congratulations! Player 1 wins!!\"\n else\n puts \"Congratulations! Player 2 wins!!\"\n end\n @board.render\n return true\n end\n #return true if game over\n if @board.grid_full?\n puts \"It's a draw! GAME OVER.\"\n @board.render\n return true\n end\n false\n end",
"def _statements\n\n _save = self.pos\n begin # sequence\n _tmp = apply(:_statement)\n break unless _tmp\n # optional\n\n _save1 = self.pos\n begin # sequence\n _tmp = apply(:__hyphen_)\n break unless _tmp\n _tmp = apply(:_statements)\n end while false\n unless _tmp\n self.pos = _save1\n end # end sequence\n\n _tmp = true # end optional\n end while false\n unless _tmp\n self.pos = _save\n end # end sequence\n\n set_failed_rule :_statements unless _tmp\n return _tmp\n end",
"def last?\n index == size - 1\n end",
"def last?\n index == size - 1\n end",
"def failure?; terminal_flag == :failure end",
"def failure?; terminal_flag == :failure end",
"def last_phase?\n @finishing\n end",
"def post_execute(environment)\n if keep\n # The (temporary) result of this command should be kept on the GPU. Store a\n # pointer to the result in global memory in an instance variable.\n\n begin\n @gpu_result_pointer = environment[(\"prev_\" + unique_id.to_s).to_sym].to_i\n Log.info(\"Kept pointer for result of command #{unique_id.to_s}: #{@gpu_result_pointer}\")\n return true \n rescue ArgumentError\n # No pointer saved for this command. This can happen if the result of this\n # command was already cached earlier and the cached result of a\n # computation based on this command was used now. \n Log.info(\"No pointer kept for result of command #{unique_id.to_s}.\")\n return false\n end\n end\n\n return false\n end",
"def new_record?\n !rev\n end",
"def left_optimizable?\n !left.equal?(operation.left)\n end",
"def undone?\n !done?\n end",
"def exclude_end?() end",
"def terminal?\n ([email protected]).all? {|ix| get_actions(ix).empty?}\n end",
"def noop?\n return @ops.length == 0 || (@ops.length == 1 && retain_op?(@ops[0]))\n end",
"def be_truthful\n 42\n true # The last expression is always the one that gets returned\nend",
"def void_command?\n (command? && !keep_retval?) || retval == CommandContext::VOID_VALUE\n end",
"def end_game?\n not @previous_deal.valat? and @result_points.to_hash.values.any? { |points| points >= 151 }\n end",
"def final_situation?(sit)\n (super(sit) and sit.stack.empty?) ? true : false\n end",
"def check_execute\n unless executed?\n execute\n end\n end",
"def en_passant?(y)\r\n y_distance = (y - @ycoordinate).abs\r\n #condition?(y) ? (if statement is true run this code) : (if statement is false run this code)\r\n first_move?(y) ? (y_diff == 1 || y_diff == 2) : false \r\n end",
"def hasMoreCommands\n result = true\n if ((@location + 1) > @commandArray.length)\n result = false\n end\n return result\n end",
"def finished?\n !new? && !processing?\n end",
"def exclude_end?\n false\n end",
"def not_if(command)\n if command.kind_of?(Proc)\n res = command.call\n if res\n return false\n end\n else \n status = run_command(:command => command, :ignore_failure => true)\n if status.exitstatus == 0\n return false\n end\n end\n true\n end",
"def last?\n @last\n end",
"def last?\n @last\n end",
"def last?\n position == bottom\n end"
] | [
"0.64031285",
"0.61769944",
"0.59375757",
"0.582834",
"0.5811565",
"0.57776767",
"0.57702106",
"0.57599515",
"0.5692707",
"0.565337",
"0.56469125",
"0.56464064",
"0.56345326",
"0.5630337",
"0.56045985",
"0.5585154",
"0.55791086",
"0.5567264",
"0.55550313",
"0.55268115",
"0.5511795",
"0.55063653",
"0.54934883",
"0.54547465",
"0.54440486",
"0.5434712",
"0.5424289",
"0.54229695",
"0.54182816",
"0.54130155",
"0.54011226",
"0.5388414",
"0.5387172",
"0.537818",
"0.53710747",
"0.5369868",
"0.5368471",
"0.53670526",
"0.53652227",
"0.53460026",
"0.53460026",
"0.53428555",
"0.53385675",
"0.5338313",
"0.5335634",
"0.532967",
"0.53249085",
"0.5324228",
"0.5319284",
"0.531347",
"0.53115463",
"0.53091246",
"0.5305885",
"0.5301713",
"0.5299995",
"0.5299995",
"0.5291293",
"0.528731",
"0.52850795",
"0.5281152",
"0.5276973",
"0.5266971",
"0.5266068",
"0.52615577",
"0.5260704",
"0.5254657",
"0.5247289",
"0.5241299",
"0.52383584",
"0.52267295",
"0.5225273",
"0.5223175",
"0.52212375",
"0.5215667",
"0.5214674",
"0.5209317",
"0.5209317",
"0.5209116",
"0.5209116",
"0.5207924",
"0.5207331",
"0.52064973",
"0.5199073",
"0.5197168",
"0.5192764",
"0.5190691",
"0.51901305",
"0.51895607",
"0.5188216",
"0.51853764",
"0.5183737",
"0.5176737",
"0.51763517",
"0.5176019",
"0.51735234",
"0.51694334",
"0.51668257",
"0.51648104",
"0.51648104",
"0.5163042"
] | 0.55839723 | 16 |
finds only the first instance | def find(prepostion)
partial_search_kb = string_to_internal(preposition)
partial_search_kb.each do |sentence|
ind = @kb.index(sentence)
end
return ind
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first() end",
"def find_first(*args)\n id = get_range(:count => 1, *args).first\n id && find_one(id, *args)\n end",
"def first!\n first or raise RecordNotFound\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first(*args)\n find(:first, *args)\n end",
"def first!\n fail_not_found_if_nil(first)\n end",
"def first!\n first || raise_record_not_found_exception!\n end",
"def find_first(selector={}, options={})\n h = options.dup\n h[:limit] = 1\n cursor = find(selector, h)\n cursor.next_object # don't need to explicitly close b/c of limit\n end",
"def first\n\n wi(fetch_all({}).first)\n end",
"def first\n find.limit(1).next_document\n end",
"def find\n super.first\n end",
"def first; self.objects.first end",
"def first\n result ? all.first : limit(1).all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def find_first(name)\n find_all(name).first\n end",
"def first(options={})\r\n find(:first, options)\r\n end",
"def one\n if size == 0\n raise \"Could not find any records\"\n elsif size > 1\n raise \"Search returned multiple records when only one was expected\"\n else\n first\n end\n end",
"def first_instance\n params(limit: 1).all.first\n end",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def first\n matches.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\n all.first\n end",
"def first\r\n\t\[email protected]\r\n\tend",
"def first\n response = query(:per_page => 1, :page => 1).get!\n response[:results].first\n end",
"def find_first(name)\n object = build(name)\n object.retrieve\n end",
"def first\n all.first\n end",
"def first\n self.take(1)[0]\n end",
"def one(*args)\n find(:one, *args)\n end",
"def first\n results.first\n end",
"def first\n enumerator(:limit => 1).first \n end",
"def first\n self.all.first\n end",
"def first\n @cursor_instance.jump( nil )\n return current\n end",
"def first\n limit(1).to_a.first\n end",
"def first\n self.all.first\n end",
"def find_one(&block)\r\n copy_and_return(@records.find(&block))\r\n end",
"def find_first(options = {})\n construct_scope(options).first\n end",
"def first(name=nil)\n name.nil? ? matches.first : find(name, false).first\n end",
"def first?; end",
"def first\n all[0]\n end",
"def find(*args)\n find_all(*args).first\n end",
"def first_object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length > 0 ? objs[0] : nil\n end",
"def find_first(value,start,stop)\n return start if time_at(start) > value\n find(:first,value,start,stop)\n end",
"def caar; first.first end",
"def select_first!\n limit(1).select!.first\n end",
"def first\n self[0]\n end",
"def first\n self[0]\n end",
"def first; end",
"def first; end",
"def first\r\n self[0]\r\n end",
"def first\n end",
"def first\n to_a.first\n end",
"def beer_search_first(arg)\n beer_search(arg).find {|beer|beer}\nend",
"def first_one(conditions={}, &block)\n all.detect { |item| match_one(item, conditions, &block) }\n end",
"def first\n\t\trow = connection.get_first_row <<-SQL\n\t\t\tSELECT #{columns.join \",\"} FROM #{table}\n\t\t\tORDER BY id ASC LIMIT 1;\n\t\tSQL\n\t\tinit_object_from_row(row)\n\tend",
"def first ; list.first ; end",
"def first(*args)\n find_first_or_last(:first, *args)\n end",
"def first\n @enumerable.first\n end",
"def first(*args)\n if args.any?\n if args.first.kind_of?(Integer) ||\n (loaded? && !args.first.kind_of?(Hash))\n to_a.first(*args)\n else\n apply_finder_options(args.first).first\n end\n else\n find_first\n end\nend",
"def first\n if @prv\n @prv.first\n else\n self\n end\n end",
"def first\n self.class.where(:id => rid).order('lower(validity)').first\n end",
"def first\n self[0]\n end",
"def find; end",
"def first\n check_corrupted\n cache_ele if @eles.empty?\n return @eles.first\n end",
"def first(options = {})\n all(options).first\n end",
"def first_set\n match_sets.first\n end",
"def first(opts={})\n ::Kernel.Veneer(find_first(::Hashie::Mash.new(opts)))\n end",
"def find_first\n Period.order(\"begins_at ASC\").first\n end",
"def first\n return sync { @first }\n end",
"def get_first_port\n flist = Fiberstrand.where(\"connection_id = \" + self.id.to_s)\n \n fportid=0\n # binding.pry\n flist.each do |fiber|\n fport = Devport.find_by_id(fiber.porta)\n fportid=fport.id\n break if (fport.fiber_in_id==0)\n fportid=0\n end\n \n fportid\n \n end",
"def find_first(*paths)\n xpath(*paths).first\n end",
"def find_one(options = {})\n @find_one ||=\n if primary_key_set?\n without_collection_params { super() }\n else\n klass.new_collection_from_result(limit(1).fetch(options)).first\n end\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def first!(spec)\n first(spec) || raise(CouchPotato::NotFound)\n end",
"def find_first(conditions = nil, orderings = nil)\n sql = \"SELECT * FROM #{table_name} \"\n add_conditions!(sql, conditions)\n sql << \"ORDER BY #{orderings} \" unless orderings.nil?\n sql << \"LIMIT 1\"\n \n record = connection.select_one(sql, \"#{name} Load First\")\n instantiate(record) unless record.nil?\n end",
"def find_by(**args)\n where(**args).first\n end",
"def next\n Expression.where('id > ? AND collection_id = ?', self.id, self.collection_id).order('id ASC').limit(1).first\n end",
"def first?\n\t locate == 1\n\tend",
"def first\n graph.first_object(subject: first_subject, predicate: RDF.first)\n end",
"def find_first_awesome_person\n collection.detect{|person| person[:awesome] == true}\n end",
"def find_one(spec)\n doc = collection.find(spec.is_a?(Hash) ? spec : {}.merge('_id' => spec)).first\n new(doc) if doc\n end",
"def first(extra_parameters = {})\n klass.first(params(extra_parameters))\n end",
"def first_member\n return unless resource.try(:member_ids)&.first\n @first_member ||= query_service.find_by(id: resource.member_ids.first)\n end",
"def first(*args)\n all.send(:first, *args)\n end",
"def first\n @adapter.first(collection)\n end",
"def find_one_by(opts = {})\n list_all_products(opts)[0]\n end",
"def find_single(scope)\n path = element_path(scope)\n self.new(connection.get(path))\n end",
"def initial_entry()\n return sets[0].first\n end",
"def initial_entry()\n return sets[0].first\n end",
"def first\n @model_class.first\n end",
"def first\n @model_class.first\n end",
"def first\n @items.first\n end",
"def sole\n found, undesired = first(2)\n\n if found.nil?\n raise_record_not_found_exception!\n elsif undesired.present?\n raise ActiveRecord::SoleRecordExceeded.new(self)\n else\n found\n end\n end",
"def afirst(selector={}, opts={}, &blk)\n opts[:limit] = 1\n afind(selector, opts) do |res|\n yield res.first\n end\n end",
"def first(options = {})\n search(options.merge(:limit => true))\n end",
"def find_first &predicate\n\t\treturn nil unless block_given?\n\n\t\tcurrent = self.head\n\t\twhile current\n\t\t\treturn current if predicate.call(current)\n\t\t\tcurrent = current.next\n\t\tend\n\tend",
"def first_ele(class_name)\n ele_index class_name, 1\n end",
"def first\n self.class.where(id: rid).chronological.first\n end"
] | [
"0.76388025",
"0.7529196",
"0.75099707",
"0.74916905",
"0.74916905",
"0.7488185",
"0.7477368",
"0.74085915",
"0.73815966",
"0.73810834",
"0.73281676",
"0.7303974",
"0.7296113",
"0.72872245",
"0.72059315",
"0.72059315",
"0.72059315",
"0.72059315",
"0.719647",
"0.7193925",
"0.7175143",
"0.7163299",
"0.71617913",
"0.7142883",
"0.7113903",
"0.7113903",
"0.7113903",
"0.70899487",
"0.70850533",
"0.7083811",
"0.70675814",
"0.7047959",
"0.7044891",
"0.70415205",
"0.7006924",
"0.6960662",
"0.6955373",
"0.69419515",
"0.6932227",
"0.6931351",
"0.6919406",
"0.6917682",
"0.68638134",
"0.6861756",
"0.6854513",
"0.68498397",
"0.683436",
"0.6814777",
"0.6804612",
"0.673876",
"0.673876",
"0.6698212",
"0.6698212",
"0.66899776",
"0.6663082",
"0.66282654",
"0.66231287",
"0.6618335",
"0.66064525",
"0.6592642",
"0.6587286",
"0.65671796",
"0.65454805",
"0.6526145",
"0.65165514",
"0.65011346",
"0.6498886",
"0.64885265",
"0.6478804",
"0.64690155",
"0.64641935",
"0.6453388",
"0.6439801",
"0.6422303",
"0.6417064",
"0.63940626",
"0.6385015",
"0.63659185",
"0.6363418",
"0.63582826",
"0.6354836",
"0.6352231",
"0.6325482",
"0.63203984",
"0.63170797",
"0.63103443",
"0.6308252",
"0.630009",
"0.6299551",
"0.6290508",
"0.6288556",
"0.6288556",
"0.6276982",
"0.6276982",
"0.6275247",
"0.62506855",
"0.6242353",
"0.6240496",
"0.6238243",
"0.6237627",
"0.62370867"
] | 0.0 | -1 |
a modifier that uses an internal identifier, so it is private | def remove(prep_id)
@kb.delete_at(prep_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modifier; end",
"def private=(_); end",
"def modifier(member)\n\n\n\n # 357:5: ( PRIVATE | PUBLIC | PROTECTED | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP )*\n # 357:5: ( PRIVATE | PUBLIC | PROTECTED | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP )*\n while true\n alt48 = 12\n # ()* loopback of 357:5: ( PRIVATE | PUBLIC | PROTECTED | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP )*\n case look_ahead(1)\n when :PRIVATE\n alt48 = 1\n when :PUBLIC\n alt48 = 2\n when :PROTECTED\n alt48 = 3\n when :STATIC\n alt48 = 4\n when :ABSTRACT\n alt48 = 5\n when :FINAL\n alt48 = 6\n when :NATIVE\n alt48 = 7\n when :SYNCHRONIZED\n alt48 = 8\n when :TRANSIENT\n alt48 = 9\n when :VOLATILE\n alt48 = 10\n when :STRICTFP\n alt48 = 11\n end\n case alt48\n when 1\n # 357:7: PRIVATE\n match(:PRIVATE)\n member.add_modifier('private') \n when 2\n # 358:7: PUBLIC\n match(:PUBLIC)\n member.add_modifier('public') \n when 3\n # 359:7: PROTECTED\n match(:PROTECTED)\n member.add_modifier('protected') \n when 4\n # 360:7: STATIC\n match(:STATIC)\n member.add_modifier('static') \n when 5\n # 361:7: ABSTRACT\n match(:ABSTRACT)\n member.add_modifier('abstract') \n when 6\n # 362:7: FINAL\n match(:FINAL)\n member.add_modifier('final') \n when 7\n # 363:7: NATIVE\n match(:NATIVE)\n member.add_modifier('native') \n when 8\n # 364:7: SYNCHRONIZED\n match(:SYNCHRONIZED)\n member.add_modifier('synchronized') \n when 9\n # 365:7: TRANSIENT\n match(:TRANSIENT)\n member.add_modifier('transient') \n when 10\n # 366:7: VOLATILE\n match(:VOLATILE)\n member.add_modifier('volatile') \n when 11\n # 367:7: STRICTFP\n match(:STRICTFP)\n member.add_modifier('strictfp') \n else\n break\n end\n end\n\n\n\n end",
"def private_method; end",
"def a_private_method\n\tend",
"def t__77!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 22)\n\n type = T__77\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 28:9: 'private'\n match(\"private\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 22)\n\n end",
"def private(*syms) end",
"def modifier(name)\n modifiers.extend(name)\n end",
"def modifier(module_name)\n warn [\n \"NOTE: Loading modifiers via grammar class methods is deprecated.\",\n \"Alternative API TBD. For now this method still works.\"\n ].join\n registry.modifier(module_name)\n end",
"def m2\n# private def m2 ## chamar private in line com def.\n p \"Metodo 2\"\n end",
"def private_method\n\tend",
"def private_method\n\tend",
"def private; end",
"def a_private_method\n end",
"def accessibility; end",
"def private_method\n end",
"def protected(*syms) end",
"def private_notes\n end",
"def specialty; end",
"def private_notes\n \n end",
"def private_method\n end",
"def how_private(x)\n return(\"ich bin how_private\")\n end",
"def internal; end",
"def t__76!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 21)\n\n type = T__76\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 27:9: 'public'\n match(\"public\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 21)\n\n end",
"def t__75!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 20)\n\n type = T__75\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 26:9: 'protected'\n match(\"protected\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 20)\n\n end",
"def modifier(modifier)\n\t\t\t\t@modifier = modifier\n\t\t\tend",
"def edit_modifier\n\n\tend",
"def _; end",
"def accessible_name; end",
"def method3 # will be 'private'\n #...\n end",
"def method3 # will be 'private'\n #...\n end",
"def expose=(_arg0); end",
"def consume_name; end",
"def underscore!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 42 )\n\n type = UNDERSCORE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 178:4: '_'\n match( 0x5f )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 42 )\n\n end",
"def public_method; end",
"def method3 # will be 'private'\r\n\t\t# ...\r\n\tend",
"def public; end",
"def public; end",
"def alias_of; end",
"def name(_)\n\n end",
"def ud_function\n f = :dolly\n case @modifiers\n when CONSTRAIN_MODIFIER_MASK\n f = :pedestal\n when COPY_MODIFIER_MASK\n f = :tilt\n end\n f\nend",
"def lr_function\n f = :pan\n case @modifiers\n when CONSTRAIN_MODIFIER_MASK\n f = :truck\n when COPY_MODIFIER_MASK\n f = :pan\n end\n f\nend",
"def private_vs_protected_argument_method(scope)\n\t\t\"Protected method of passed object says: \" + scope.protected_method_string\n\t\t#The below line will result in an error, as we cannot call another instances\n\t\t#protected methods.\n\t\t#\"Private method of pass object: \" + scope.private_method_string\n\tend",
"def private(name)\n if entry = @method_table.lookup(name)\n entry.visibility = :private\n end\n end",
"def private _args\n \"private _args;\" \n end",
"def reserved=(_arg0); end",
"def not_private\n !self.private\n end",
"def secret_method_2 # :nodoc:\n end",
"def _here_\n 'here'\nend",
"def attr_reader(*)\n end",
"def method4 # and this will be 'public'\r\n\t\t#...\r\n\tend",
"def identifier; end",
"def identifier; end",
"def consume_ident; end",
"def only_name(mod); end",
"def m2\n puts \"m2 private\"\n end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def name=(_); end",
"def reserved_words=(_arg0); end",
"def m5\n p \"Metodo 5 protected\"\n end",
"def method3 # will be 'private'\n \"method3\"\n end",
"def protected_method\n\tend",
"def k_modificador!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 59 )\n\n\n\n type = K_MODIFICADOR\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 489:4: ( 'static' | 'abstract' | 'constant' | 'final' | 'virtual' )\n # at line 489:4: ( 'static' | 'abstract' | 'constant' | 'final' | 'virtual' )\n alt_18 = 5\n case look_18 = @input.peek( 1 )\n when 0x73 then alt_18 = 1\n when 0x61 then alt_18 = 2\n when 0x63 then alt_18 = 3\n when 0x66 then alt_18 = 4\n when 0x76 then alt_18 = 5\n else\n raise NoViableAlternative( \"\", 18, 0 )\n\n end\n case alt_18\n when 1\n # at line 489:5: 'static'\n match( \"static\" )\n\n\n when 2\n # at line 489:14: 'abstract'\n match( \"abstract\" )\n\n\n when 3\n # at line 489:25: 'constant'\n match( \"constant\" )\n\n\n when 4\n # at line 489:36: 'final'\n match( \"final\" )\n\n\n when 5\n # at line 489:44: 'virtual'\n match( \"virtual\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 59 )\n\n\n end",
"def expose; end",
"def reserved; end",
"def escaper=(_); end",
"def hidden_apis=(_arg0); end",
"def association_module_private_def(name, opts=OPTS, &block)\n association_module_def(name, opts, &block)\n association_module(opts).send(:private, name)\n end",
"def get_private()\n res = super(self)\n return res\n end",
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end",
"def read_documentation_modifiers context, allowed\n skip_tkspace_without_nl\n directive, value = read_directive allowed\n\n return unless directive\n\n @preprocess.handle_directive '', directive, value, context do |dir, param|\n if %w[notnew not_new not-new].include? dir then\n context.dont_rename_initialize = true\n\n true\n end\n end\n end",
"def secret_method #:nodoc:\n end",
"def identifier\n to_be_overridden\n end",
"def protected(name)\n if entry = @method_table.lookup(name)\n entry.visibility = :protected\n end\n end",
"def method4 # and this will be 'public'\n #...\n end",
"def identifier_method_name #:nodoc:\n short_identifier.gsub(/[^a-z0-9_]/, '_')\n end",
"def attr_writer(sym, *more) end",
"def private_methods(all=true) end",
"def expanded_name; end",
"def method4 # and this will be 'public'\n #...\n end",
"def protected_method\n end",
"def member; end",
"def member; end",
"def member; end",
"def member; end",
"def member; end",
"def remainder_mark=(_arg0); end",
"def internal_methods; end",
"def lex_en_regexp_modifiers=(_arg0); end",
"def lex_en_regexp_modifiers=(_arg0); end",
"def lex_en_regexp_modifiers=(_arg0); end",
"def get_private_self\n self.private_attribute\n end",
"def decorators(key); end",
"def decorators(key); end",
"def qe_modifiers\n end"
] | [
"0.7698321",
"0.67642546",
"0.66385704",
"0.6516947",
"0.650884",
"0.64818573",
"0.64492565",
"0.6448046",
"0.63793576",
"0.6345228",
"0.6258631",
"0.6258631",
"0.6199132",
"0.61429554",
"0.6129914",
"0.6115473",
"0.60738283",
"0.60573876",
"0.6055713",
"0.60252565",
"0.60214317",
"0.6016989",
"0.59846395",
"0.59701645",
"0.5965566",
"0.596555",
"0.5952307",
"0.59443694",
"0.5924103",
"0.58942837",
"0.58917683",
"0.58654356",
"0.5836341",
"0.5822818",
"0.5803631",
"0.5800482",
"0.5779134",
"0.5779134",
"0.57761604",
"0.5764256",
"0.5759596",
"0.57480466",
"0.57311285",
"0.5695785",
"0.5686522",
"0.56749463",
"0.5668228",
"0.5650945",
"0.5648253",
"0.5647756",
"0.56438303",
"0.5633236",
"0.5633236",
"0.56299853",
"0.55932903",
"0.55819595",
"0.5581707",
"0.5581707",
"0.5581707",
"0.5581707",
"0.5581707",
"0.5581707",
"0.5581707",
"0.5581707",
"0.55778146",
"0.5560392",
"0.5558837",
"0.555549",
"0.5540743",
"0.55289286",
"0.5517605",
"0.55160785",
"0.5510842",
"0.550699",
"0.5505486",
"0.55049026",
"0.5499849",
"0.5492747",
"0.5481474",
"0.5480057",
"0.5479821",
"0.54610574",
"0.5451477",
"0.54438484",
"0.54438347",
"0.54409975",
"0.5428094",
"0.54200584",
"0.54200584",
"0.54200584",
"0.54200584",
"0.54200584",
"0.5401863",
"0.53986824",
"0.53968453",
"0.53968453",
"0.53968453",
"0.5385089",
"0.5382781",
"0.5382781",
"0.53798103"
] | 0.0 | -1 |
turns the propositions to CNF(if needed) | def toCNF
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cnf\n r = []\n @table.each {|inputs, output|\n return output.to_s if inputs.empty?\n next if output\n term = []\n each_input(inputs) {|name, input|\n if input\n term << \"!#{name}\"\n else\n term << name\n end\n }\n if term.length == 1\n r << term.join('|')\n else\n r << \"(#{term.join('|')})\"\n end\n }\n return \"true\" if r.empty?\n r.join(' & ')\n end",
"def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end",
"def doProduction(lhs)\n if lhs == BNF.void\n progress(\"\\nvoid\")\n return\n end\n if lhs == BNF.eof\n progress( \"\\nEOF\")\n return\n end\n if lhs.is_a?(RDF::Literal)\n literalTerminals[lhs.value()] = 1\n return\n end\n\n branchDict = {}\n\n rhs = graph.first_object(:subject => lhs, :predicate => BNF.matches)\n if rhs\n chatty(\"\\nToken #{lhs} matches regexp #{rhs}\")\n tokenRegexps[lhs] = rhs.value\n\n cc = graph.query(:subject => lhs, :predicate => BNF.canStartWith)\n progress(recordError(\"No record of what token #{lhs} can start with\")) if cc.empty?\n cc.each {|statement| chatty(\" Can start with: #{statement.object}\")}\n return\n end\n \n rhs = graph.first_object(:subject => lhs, :predicate => BNF.mustBeOneSequence)\n unless rhs\n progress(recordError(\"No definition of #{lhs}\"))\n # raise RuntimeError(\"No definition of %s in\\n %s\" %(`lhs`, `g`))\n return\n end\n\n options = rhs\n progress(\"\\nProduction #{lhs} :: #{options}\")\n graph.query(:subject => lhs, :predicate => BNF.canPrecede) do |statement|\n chatty(\" Can precede '#{statement.object}'\")\n end\n\n graph.query(:subject => lhs, :predicate => BNF.branch) do |statement|\n branch = statement.object\n sequence = graph.first_object(:subject => statement.object, :predicate => BNF.sequence)\n option = RDF::List.new(sequence, graph).to_a\n progress(\" option: #{option}\")\n \n option.each do |part|\n agenda << part unless already.include?(part) || agenda.include?(part)\n end\n \n conditions = graph.query(:subject => branch, :predicate => BNF.condition).map(&:object)\n if conditions.empty?\n progress(recordError(\"NO SELECTOR for #{lhs} option #{option}\"))\n if option.empty?\n # Void case - the tricky one\n graph.pattern(:subject => lhs, :predicate => BNF.canPrecede) do |st|\n progress(\" Can precede #{st.object}\")\n end\n end\n end\n \n progress(\" Conditions: #{conditions.to_a.map(&:to_s)}\")\n conditions.each do |str1|\n if branchDict.has_key?(str1)\n progress(\n \"Conflict: #{str1} is also the condition for #{branchDict[str1]}\")\n end\n branchDict[str1] = option\n end\n end\n \n branchDict.keys.each do |str1|\n branchDict.keys.each do |str2|\n s1, s2 = str1.to_s, str2.to_s\n if (s1.index(s2) == 0 || s2.index(s1) == 0) && branchDict[str1] != branchDict[str2]\n progress(\"WARNING: for #{lhs}, #{str1} indicates #{branchDict[str1]}, but #{str2} indicates #{branchDict[str2]}\")\n end\n end\n end\n \n branchTable[lhs] = branchDict\n end",
"def to_peg\n new_rules = []\n\n # Look for rules containing sub-sequences\n if expr.any? {|e| e.is_a?(Array) && e.first.is_a?(Symbol)}\n # duplicate ourselves for rewriting\n this = dup\n new_rules << this\n\n expr.each_with_index do |e, index|\n next unless e.is_a?(Array) && e.first.is_a?(Symbol)\n new_rule = build(e)\n this.expr[index] = new_rule.sym\n new_rules << new_rule\n end\n\n # Return new rules after recursively applying #to_bnf\n new_rules = new_rules.map {|r| r.to_peg}.flatten\n elsif expr.first == :diff && !terminal?\n this = dup\n new_rule = build([:not, expr[2]])\n this.expr = [:seq, new_rule.sym, expr[1]]\n new_rules << this\n new_rules << new_rule\n elsif [:hex, :istr, :range].include?(expr.first)\n # This rules are fine, they just need to be terminals\n raise \"Encountered #{expr.first.inspect}, which is a #{self.kind}, not :terminal\" unless self.terminal?\n new_rules << self\n else\n new_rules << self\n end\n \n return new_rules.map {|r| r.extend(EBNF::PEG::Rule)}\n end",
"def coma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n\n\n type = COMA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 289:3: ','\n match( 0x2c )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n\n end",
"def to_bnf\n result = []\n last_symbol = nil\n productions.sort.each do |production|\n if production.symbol != last_symbol\n result << \"\"\n result << \"#{production.symbol.name.inspect} :\"\n last_symbol = production.symbol\n end\n result << \" | #{production.expansion.collect{|symbol| symbol.name.inspect}.join(' ')}\"\n end\n result.join(\"\\n\")\n end",
"def parse_grammar \n\t\tnormalize\n\n\t\t@grammar_string.each do |line|\n\t\t\tlhs, placeholder, rhs = line.partition \"->\"\n\t\t\t# get rid of extra white space\n\t\t\tlhs.strip!\n\t\t\trhs.strip!\n\n\t\t\t# catch line with goal symbol\n\t\t\t@goal = lhs if rhs.include? \"$\"\n\n\t\t\trhs.split(\"|\").each do |rule|\n\t\t\t\t@production_rules[lhs] ||= []\n\t\t\t\t@production_rules[lhs] << rule.split(\" \")\n\t\t\tend\n\t\tend\n\tend",
"def to_s\n\t\tmap { |k,v|\n\t\t\tv.to_s + \" ::= \" + v.rules.map { |r| r.map{|e| e.inspect}.join(\" \") }.join(\" | \")\n\t\t}.join(\"\\n\")\n\tend",
"def condicion\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n\n return_value = CondicionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __OP_REL114__ = nil\n valor113 = nil\n valor115 = nil\n\n\n tree_for_OP_REL114 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 123:4: valor OP_REL valor\n @state.following.push( TOKENS_FOLLOWING_valor_IN_condicion_545 )\n valor113 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor113.tree )\n end\n\n __OP_REL114__ = match( OP_REL, TOKENS_FOLLOWING_OP_REL_IN_condicion_547 )\n if @state.backtracking == 0\n tree_for_OP_REL114 = @adaptor.create_with_payload( __OP_REL114__ )\n @adaptor.add_child( root_0, tree_for_OP_REL114 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_condicion_549 )\n valor115 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor115.tree )\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n\n end\n\n return return_value\n end",
"def to_bnf\n return [self] unless rule?\n new_rules = []\n\n # Look for rules containing recursive definition and rewrite to multiple rules. If `expr` contains elements which are in array form, where the first element of that array is a symbol, create a new rule for it.\n if expr.any? {|e| e.is_a?(Array) && (BNF_OPS + TERM_OPS).include?(e.first)}\n # * Transform (a [n] rule (op1 (op2))) into two rules:\n # (a.1 [n.1] rule (op1 a.2))\n # (a.2 [n.2] rule (op2))\n # duplicate ourselves for rewriting\n this = dup\n new_rules << this\n\n expr.each_with_index do |e, index|\n next unless e.is_a?(Array) && e.first.is_a?(Symbol)\n new_rule = build(e)\n this.expr[index] = new_rule.sym\n new_rules << new_rule\n end\n\n # Return new rules after recursively applying #to_bnf\n new_rules = new_rules.map {|r| r.to_bnf}.flatten\n elsif expr.first == :opt\n this = dup\n # * Transform (rule a (opt b)) into (rule a (alt _empty b))\n this.expr = [:alt, :_empty, expr.last]\n this.cleanup = :opt\n new_rules = this.to_bnf\n elsif expr.first == :star\n # * Transform (rule a (star b)) into (rule a (alt _empty (seq b a)))\n this = dup\n this.cleanup = :star\n new_rule = this.build([:seq, expr.last, this.sym], cleanup: :merge)\n this.expr = [:alt, :_empty, new_rule.sym]\n new_rules = [this] + new_rule.to_bnf\n elsif expr.first == :plus\n # * Transform (rule a (plus b)) into (rule a (seq b (star b)\n this = dup\n this.cleanup = :plus\n this.expr = [:seq, expr.last, [:star, expr.last]]\n new_rules = this.to_bnf\n elsif [:alt, :seq].include?(expr.first)\n # Otherwise, no further transformation necessary\n new_rules << self\n elsif [:diff, :hex, :range].include?(expr.first)\n # This rules are fine, they just need to be terminals\n raise \"Encountered #{expr.first.inspect}, which is a #{self.kind}, not :terminal\" unless self.terminal?\n new_rules << self\n else\n # Some case we didn't think of\n raise \"Error trying to transform #{expr.inspect} to BNF\"\n end\n \n return new_rules\n end",
"def corder!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n\n\n type = CORDER\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 297:3: ']'\n match( 0x5d )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n\n end",
"def pour\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n pour_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 297:7: ( 'P' | 'p' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' )\n if @input.peek( 1 ).between?( T__12, T__13 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__18, T__19 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__20, T__21 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n memoize( __method__, pour_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end",
"def simplification_rules_for_conjunction\n if is_formula_and_formula?\n copy @left_sentence\n update\n elsif is_formula_and_not_formula?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:bottom])\n elsif is_formula_and_up?\n if @left_sentence.is_constant?\n copy @right_sentence\n else\n copy @left_sentence\n end\n update\n elsif is_formula_and_bottom?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:bottom])\n end\n end",
"def to_prolog\n prolog_clauses = []\n words = {} \n sentence_number = 1\n\n prolog_clauses << \"%% Unique tags in the corpus:\\n\"\n tags.map { |t,| prolog_clauses << \"brown_tag(#{t.to_prolog}).\" }\n\n @sentences.each do |s|\n prolog_clauses << \"brown_sentence(#{sentence_number},#{s.to_prolog}).\\n\"\n s.each { |e| words[\"brown_word(#{e[0].to_prolog}).\"] = true }\n sentence_number += 1\n end\n\n prolog_clauses << \"%% Unique words in the corpus\"\n words.map { |w,| prolog_clauses << w }\n\n (parse_tag_descriptions + prolog_clauses).join(\"\\n\")\n end",
"def pcdata!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 50 )\n\n type = PCDATA\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 406:9: {...}? => (~ '<' )+\n raise FailedPredicate( \"PCDATA\", \" !@tagMode \" ) unless ( ( !@tagMode ) )\n # at file 406:25: (~ '<' )+\n match_count_8 = 0\n while true\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0.between?( 0x0, 0x3b ) || look_8_0.between?( 0x3d, 0xffff ) )\n alt_8 = 1\n\n end\n case alt_8\n when 1\n # at line 406:26: ~ '<'\n if @input.peek( 1 ).between?( 0x0, 0x3b ) || @input.peek( 1 ).between?( 0x3d, 0xff )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_8 > 0 and break\n eee = EarlyExit(8)\n\n\n raise eee\n end\n match_count_8 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 50 )\n\n end",
"def comilla!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 16 )\n\n\n\n type = COMILLA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 317:3: '\\\\''\n match( 0x27 )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 16 )\n\n\n end",
"def ciclos\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 19 )\n\n\n return_value = CiclosReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n ciclo_times92 = nil\n ciclo_each93 = nil\n\n\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 107:4: ( ciclo_times | ciclo_each )\n # at line 107:4: ( ciclo_times | ciclo_each )\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == DecimalLiteral )\n alt_12 = 1\n elsif ( look_12_0 == DOUBLEDOT || look_12_0 == Identificador )\n alt_12 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 12, 0 )\n\n end\n case alt_12\n when 1\n # at line 107:5: ciclo_times\n @state.following.push( TOKENS_FOLLOWING_ciclo_times_IN_ciclos_461 )\n ciclo_times92 = ciclo_times\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, ciclo_times92.tree )\n end\n\n\n when 2\n # at line 107:17: ciclo_each\n @state.following.push( TOKENS_FOLLOWING_ciclo_each_IN_ciclos_463 )\n ciclo_each93 = ciclo_each\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, ciclo_each93.tree )\n end\n\n\n end\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 19 )\n\n\n end\n\n return return_value\n end",
"def transformation_into_apnf\n self.simplification\n unless @operator.nil?\n old_left = ( @left_sentence ? Sentence.new(@left_sentence) : nil )\n old_right = ( @right_sentence ? Sentence.new(@right_sentence) : nil )\n\n if @operator.is_negation?\n unless @right_sentence.operator.nil?\n case @right_sentence.operator.type\n when :implication\n apnf_rules_for_negated_implication\n\n # ******* NEW APNF RULES FOR NEGATED IMPLICATION FORMULA CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_apnf_rules_for_negated_implication()\n\n when :conjunction\n apnf_rules_for_negated_conjunction\n\n # ******* NEW APNF RULES FOR NEGATED CONJUNCTION FORMULA CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_apnf_rules_for_negated_conjunction()\n\n when :disjunction\n apnf_rules_for_negated_disjunction\n\n # ******* NEW APNF RULES FOR NEGATED DISJUNCTION FORMULA CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_apnf_rules_for_negated_disjunction()\n\n when :new_operator\n # ******* OR A NEW OPERATOR NOT USED BEFORE CAN BE ADDED IN THE SIMPLIFICATION - LIKE NEGATION FOR EXAMPLE *******\n\n # ******* AND A NEW SIMPLIFICATION RULE CAN BE ADDED TO THIS OPERATOR *******\n # ******* FOR EXAMPLE: *******\n apnf_rules_for_negated_new_operator()\n end\n @left_sentence.transformation_into_apnf if @left_sentence\n @right_sentence.transformation_into_apnf if @right_sentence\n end\n else\n case @operator.type\n when :implication\n apnf_rules_for_implication\n\n # ******* NEW APNF RULES FOR IMPLICATION CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_apnf_rules_for_implication()\n\n # ******* OR NEW RULES FOR CONJUNCTION AND DISJUNCTION CAN BE ADDED TOO, IN A NEW OPTION FOR THE CASE\n # ******* FOR EXAMPLE:\n when :conjunction\n new_apnf_rules_for_conjunction()\n\n when :disjunction\n new_apnf_rules_for_disjunction()\n\n when :new_operator\n # ******* OR A NEW OPERATOR NOT USED BEFORE CAN BE ADDED IN THE SIMPLIFICATION - LIKE NEGATION FOR EXAMPLE *******\n\n # ******* AND A NEW SIMPLIFICATION RULE CAN BE ADDED TO THIS OPERATOR *******\n # ******* FOR EXAMPLE: *******\n apnf_rules_for_new_operator()\n\n end\n @left_sentence.transformation_into_apnf if @left_sentence\n @right_sentence.transformation_into_apnf if @right_sentence\n end\n\n unless Sentence.equals?(old_left, @left_sentence) && Sentence.equals?(old_right, @right_sentence)\n update\n end\n end\n self.simplification\n end",
"def cfparsedformula(io)\n cce = io.read(2).unpack('v').first\n io.read(cce)\n\n {\n cce: cce, # cce (2 bytes): An unsigned integer that specifies the length of rgce in bytes.\n rgce: :not_implemented # rgce (variable): An Rgce that specifies the sequence of Ptg structures for the formula.\n }\n end",
"def gen_requirements\n @parser.requirements.each do |name, value|\n editor = ModelEditor.new(name.snake_case)\n editor.insert(AFTER_RELATIONSHIPS, value.collect{|v| \" # #{v}\"}.join(\"\\n\"))\n end\n end",
"def process(problem)\n @id = 0\n problem.constraints.each do |c|\n puts print_expression(c.expression)\n puts \"\\n\\n\"\n end\n problem\n end",
"def to_PLParser(startSym)\n\n thePLP = TextRect.new\n\n @ntIndex.each do |nt, s|\n\n theNT = TextRect.new(\"#{nt.name} ::= \")\n before = ' '\n\n s[:rules].each do |i|\n rhs = @ruleTable[i][:rule].rhs\n rhs.each { |sym| before << sym.name << ' ' }\n theNT.below!(before)\n before = ' | '\n end\n\n theNT.below!(' ;')\n thePLP.below!(theNT)\n\n end\n\n thePLP.below!('&G')\n\n end",
"def condicional\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n\n return_value = CondicionalReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __LLAIZQ80__ = nil\n __LLADER82__ = nil\n __K_IF83__ = nil\n __LPAR84__ = nil\n __RPAR86__ = nil\n bodyexp81 = nil\n condicion_exp85 = nil\n elseb87 = nil\n\n\n tree_for_LLAIZQ80 = nil\n tree_for_LLADER82 = nil\n tree_for_K_IF83 = nil\n tree_for_LPAR84 = nil\n tree_for_RPAR86 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 99:4: LLAIZQ bodyexp LLADER K_IF LPAR condicion_exp RPAR ( elseb )?\n __LLAIZQ80__ = match( LLAIZQ, TOKENS_FOLLOWING_LLAIZQ_IN_condicional_415 )\n if @state.backtracking == 0\n tree_for_LLAIZQ80 = @adaptor.create_with_payload( __LLAIZQ80__ )\n @adaptor.add_child( root_0, tree_for_LLAIZQ80 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_bodyexp_IN_condicional_417 )\n bodyexp81 = bodyexp\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, bodyexp81.tree )\n end\n\n __LLADER82__ = match( LLADER, TOKENS_FOLLOWING_LLADER_IN_condicional_419 )\n if @state.backtracking == 0\n tree_for_LLADER82 = @adaptor.create_with_payload( __LLADER82__ )\n @adaptor.add_child( root_0, tree_for_LLADER82 )\n\n end\n\n __K_IF83__ = match( K_IF, TOKENS_FOLLOWING_K_IF_IN_condicional_421 )\n if @state.backtracking == 0\n tree_for_K_IF83 = @adaptor.create_with_payload( __K_IF83__ )\n @adaptor.add_child( root_0, tree_for_K_IF83 )\n\n end\n\n __LPAR84__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_condicional_423 )\n if @state.backtracking == 0\n tree_for_LPAR84 = @adaptor.create_with_payload( __LPAR84__ )\n @adaptor.add_child( root_0, tree_for_LPAR84 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_condicion_exp_IN_condicional_425 )\n condicion_exp85 = condicion_exp\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, condicion_exp85.tree )\n end\n\n __RPAR86__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_condicional_427 )\n if @state.backtracking == 0\n tree_for_RPAR86 = @adaptor.create_with_payload( __RPAR86__ )\n @adaptor.add_child( root_0, tree_for_RPAR86 )\n\n end\n\n # at line 99:55: ( elseb )?\n alt_10 = 2\n look_10_0 = @input.peek( 1 )\n\n if ( look_10_0 == K_ELSE )\n alt_10 = 1\n end\n case alt_10\n when 1\n # at line 99:55: elseb\n @state.following.push( TOKENS_FOLLOWING_elseb_IN_condicional_429 )\n elseb87 = elseb\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, elseb87.tree )\n end\n\n\n end\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n\n end\n\n return return_value\n end",
"def condicion_exp\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n return_value = CondicionExpReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __OP_LOG111__ = nil\n condicion110 = nil\n condicion112 = nil\n\n\n tree_for_OP_LOG111 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 119:4: condicion ( OP_LOG condicion )*\n @state.following.push( TOKENS_FOLLOWING_condicion_IN_condicion_exp_527 )\n condicion110 = condicion\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, condicion110.tree )\n end\n\n # at line 119:14: ( OP_LOG condicion )*\n while true # decision 14\n alt_14 = 2\n look_14_0 = @input.peek( 1 )\n\n if ( look_14_0 == OP_LOG )\n alt_14 = 1\n\n end\n case alt_14\n when 1\n # at line 119:15: OP_LOG condicion\n __OP_LOG111__ = match( OP_LOG, TOKENS_FOLLOWING_OP_LOG_IN_condicion_exp_530 )\n if @state.backtracking == 0\n tree_for_OP_LOG111 = @adaptor.create_with_payload( __OP_LOG111__ )\n @adaptor.add_child( root_0, tree_for_OP_LOG111 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_condicion_IN_condicion_exp_532 )\n condicion112 = condicion\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, condicion112.tree )\n end\n\n\n else\n break # out of loop for decision 14\n end\n end # loop for decision 14\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n\n end\n\n return return_value\n end",
"def find_parents(t)\n # puts \"Inside find_parents.. text #{t}\"\n tp = TextPreprocessing.new \n unTaggedString = t.split(\" \")\n parents = Array.new\n # t = text[i]\n t = StanfordCoreNLP::Text.new(t) #the same variable has to be passed into the Textx.new method\n @pipeline.annotate(t)\n #for each sentence identify theparsed form of the sentence\n sentence = t.get(:sentences).toArray\n parsed_sentence = sentence[0].get(:collapsed_c_c_processed_dependencies)\n #puts \"parsed sentence #{parsed_sentence}\" \n #iterating through the set of tokens and identifying each token's parent\n #puts \"unTaggedString.length #{unTaggedString.length}\"\n for j in (0..unTaggedString.length - 1)\n #puts \"unTaggedString[#{j}] #{unTaggedString[j]}\"\n if(tp.is_punct(unTaggedString[j]))\n next\n end\n if(tp.contains_punct(unTaggedString[j]))\n unTaggedString[j] = tp.contains_punct(unTaggedString[j])\n # puts \"unTaggedString #{unTaggedString[j]} and #{tp.contains_punct_bool(unTaggedString[j])}\"\n end\n if(!unTaggedString[j].nil? and !tp.contains_punct_bool(unTaggedString[j]))\n pat = parsed_sentence.getAllNodesByWordPattern(unTaggedString[j])\n pat = pat.toArray\n parent = parsed_sentence.getParents(pat[0]).toArray\n end\n #puts \"parent of #{unTaggedString[j]} is #{parent[0]}\"\n if(!parent.nil? and !parent[0].nil?)\n parents[j] = (parent[0].to_s)[0..(parent[0].to_s).index(\"-\")-1]#extracting the name of the parent (since it is in the foramt-> \"name-POS\")\n #puts \"parents[#{j}] = #{parents[j]}\"\n else\n parents[j] = nil\n end\n end\n return parents\nend",
"def verbalise\n \"Constellation over #{vocabulary.name}:\\n\" +\n vocabulary.object_type.keys.sort.map do |object_type|\n klass = vocabulary.const_get(object_type)\n\n single_roles, multiple_roles = klass.all_role.\n partition do |n, r|\n r.unique && # Show only single-valued roles\n !r.is_identifying && # Unless identifying\n (r.unary? || !r.counterpart.is_identifying) # Or identifies a counterpart\n end.\n map do |rs|\n rs.map{|n, r| n}.\n sort_by(&:to_s)\n end\n\n instances = send(object_type.to_sym)\n next nil unless instances.size > 0\n \"\\tEvery #{object_type}:\\n\" +\n instances.map do |key, instance|\n s = \"\\t\\t\" + instance.verbalise\n if (single_roles.size > 0)\n role_values = \n single_roles.map do |role_name|\n #p klass, klass.all_role.keys; exit\n next nil if klass.all_role(role_name).fact_type.is_a?(TypeInheritanceFactType)\n value =\n if instance.respond_to?(role_name)\n value = instance.send(role_name)\n else\n instance.class.all_role(role_name) # This role has not yet been realised\n end\n [ role_name.to_s.camelcase, value ]\n end.compact.select do |role_name, value|\n value\n end.map do |role_name, value|\n \"#{role_name} = #{value ? value.verbalise : \"nil\"}\"\n end\n s += \" where \" + role_values*\", \" if role_values.size > 0\n end\n s\n end * \"\\n\"\n end.compact*\"\\n\"\n end",
"def paquete\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n\n return_value = PaqueteReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_PACKAGE4__ = nil\n __EOL6__ = nil\n qualified_name5 = nil\n\n\n tree_for_K_PACKAGE4 = nil\n tree_for_EOL6 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 14:4: K_PACKAGE qualified_name EOL\n __K_PACKAGE4__ = match( K_PACKAGE, TOKENS_FOLLOWING_K_PACKAGE_IN_paquete_57 )\n if @state.backtracking == 0\n tree_for_K_PACKAGE4 = @adaptor.create_with_payload( __K_PACKAGE4__ )\n @adaptor.add_child( root_0, tree_for_K_PACKAGE4 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_qualified_name_IN_paquete_59 )\n qualified_name5 = qualified_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, qualified_name5.tree )\n end\n\n __EOL6__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_paquete_61 )\n if @state.backtracking == 0\n tree_for_EOL6 = @adaptor.create_with_payload( __EOL6__ )\n @adaptor.add_child( root_0, tree_for_EOL6 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n\n end\n\n return return_value\n end",
"def make_cnf_formula(encoding)\r\n cnf_formula = []\r\n \r\n # First create a generic formula which isn't specific to our board\r\n #\r\n case encoding\r\n when :minimal\r\n cnf_formula = SudokuSolver.minimal_encoding_formula\r\n when :extended\r\n cnf_formula = SudokuSolver.extended_encoding_formula\r\n else\r\n fail \"Unknown encoding #{encoding}\"\r\n end\r\n \r\n # Now add the unit clauses that result from the assigned cells in our board\r\n #\r\n (0 .. 8).each do |row|\r\n (0 .. 8).each do |col|\r\n if board[row][col] > 0\r\n cnf_formula.unshift([SudokuSolver.cell2variable(row, col, board[row][col])])\r\n end\r\n end\r\n end\r\n \r\n cnf_formula \r\n end",
"def parametros\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n return_value = ParametrosReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __COMA135__ = nil\n valor134 = nil\n valor136 = nil\n\n\n tree_for_COMA135 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 143:4: valor ( COMA valor )*\n @state.following.push( TOKENS_FOLLOWING_valor_IN_parametros_634 )\n valor134 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor134.tree )\n end\n\n # at line 143:10: ( COMA valor )*\n while true # decision 17\n alt_17 = 2\n look_17_0 = @input.peek( 1 )\n\n if ( look_17_0 == COMA )\n alt_17 = 1\n\n end\n case alt_17\n when 1\n # at line 143:11: COMA valor\n __COMA135__ = match( COMA, TOKENS_FOLLOWING_COMA_IN_parametros_637 )\n if @state.backtracking == 0\n tree_for_COMA135 = @adaptor.create_with_payload( __COMA135__ )\n @adaptor.add_child( root_0, tree_for_COMA135 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_parametros_639 )\n valor136 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor136.tree )\n end\n\n\n else\n break # out of loop for decision 17\n end\n end # loop for decision 17\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end\n\n return return_value\n end",
"def extract_bnf_grammar_from_yacc_spec(yaccFile)\r\n bnfg = \"\"\r\n File.open(yaccFile, \"r\") do |f|\r\n lines = f.readlines\r\n line = lines.shift while line !~ /^%%/\r\n paren_level = 0 # > 0 when in C code\r\n outside_string = true # false iff in a string\r\n while lines.first !~ /^%%/\r\n lines.shift.each_byte do |c|\r\n\toutside_string = !outside_string if paren_level == 0 && c == ?' #'\r\n\tparen_level += 1 if outside_string && c == ?{\r\n\tbnfg << c.chr if paren_level == 0\r\n\tparen_level -= 1 if outside_string && c == ?}\r\n\traise \"oops\" if paren_level < 0\r\n end\r\n end\r\n end\r\n bnfg\r\nend",
"def conjugate(ppl)\n first_pp = ppl.first_principal_part\n full_conjugation = []\n ppl.each do |ppart|\n next unless @principal_part_num == ppart.part_num\n next if @tense == 'a' && ppart.is_second_aorist? # skip 1st aorist when appropr.\n next if @tense == '2' && ppart.is_first_aorist? # skip 1st aorist when appropr.\n @endings.each do |form_info|\n number, g_case, person_ending, ap = form_info\n form = add_ending(ppart.unaugmented_stem, person_ending, ap)\n form = ppart.is_rough? ? Breathing.rough(form) : Breathing.smooth(form)\n @voices.each do |voice|\n code = \"vp#{g_case}#{number}#{@gender}#{@tense}#{voice}\"\n english_conjugations = EnglishConjugator.conjugate(code, ppl.english_principal_parts)\n full_conjugation << [code, form, ppl.aspirated_accented_first_pp, english_conjugations]\n end\n end\n end\n return full_conjugation\n end",
"def to_citrus # :nodoc:\n rules.map {|r| r.to_embedded_s }.join(' | ')\n end",
"def group\n index = 1\n if is_primitive_sentence?\n @left_sentence = Sentence.new(@classified[index].value,@level)\n @operator = @classified[index + 1]\n @right_sentence = Sentence.new(@classified[index + 2].value,@level)\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_negated_sentence?\n @operator = @classified[index]\n #Exemplo: (~a) ou (~1)\n if @classified[index+1].instance_of?(Proposition) or @classified[index+1].instance_of?(Constant)\n @right_sentence = Sentence.new(@classified[index+1].value,@level)\n @right_sentence.father = self\n else\n #Exemplo: #(~(a & b)) ou (~(~a))\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index+1..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @right_sentence.father = self\n end\n\n elsif is_left_derivative?\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @left_sentence = Sentence.new(aux,@level+1).group\n @operator = @classified[index_closed_parenthesis + 1]\n @right_sentence = Sentence.new(@classified[index_closed_parenthesis + 2].value,@level)\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_right_derivative?\n @left_sentence = Sentence.new(@classified[index].value,@level)\n @operator = @classified[index + 1]\n index_closed_parenthesis = index_closed_parenthesis(@level+1,index)\n aux = @classified[(index+2)..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @left_sentence.father, @right_sentence.father = self, self\n\n elsif is_both_derivative?\n index_closed_parenthesis = index_closed_parenthesis(@level+1)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @left_sentence = Sentence.new(aux,@level+1).group\n @operator = @classified[index_closed_parenthesis + 1]\n index = index_closed_parenthesis + 2\n index_closed_parenthesis = index_closed_parenthesis(@level+1,index)\n aux = @classified[index..index_closed_parenthesis].map{|el|el.value}*\"\"\n @right_sentence = Sentence.new(aux,@level+1).group\n @left_sentence.father, @right_sentence.father = self, self\n end\n self\n end",
"def precedences &blk\n PrecedenceBuilder.new(self).instance_eval(&blk)\n end",
"def to_citrus # :nodoc:\n rules.map {|r| r.to_embedded_s }.join(' ')\n end",
"def applyNps\r\n currentIdx = 0\r\n \r\n @sentences.each do |sentence|\r\n \r\n #right now we're just going to select the first NP per sentence... this will need to be fixed later\r\n sentence.npModels.each do |npModel|\r\n if npModel.coref\r\n \r\n #just moving on for right now...\r\n npModel.findBestMatch(currentIdx, @sentences)\r\n\r\n #handle if we have a \"they\" in there\r\n\t #TODO: could probably try reordering these rules and see\r\n\t #if we can get greater accuracy\r\n #if(Rules.findItAnt(npModel, currentIdx, @sentences))\r\n #elsif(Rules.findTheyAnt(npModel, currentIdx, @sentences))\r\n #elsif(Rules.matchPlurality(npModel, currentIdx, @sentences))\r\n #elsif(Rules.findSimilarName(npModel, currentIdx, @sentences))\r\n #else\r\n #Rules.findCorrectAnt(npModel, currentIdx, @sentences)\r\n #end\r\n end\r\n end\r\n currentIdx = currentIdx + 1\r\n end\r\n end",
"def tipo!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 43 )\n\n\n\n type = TIPO\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 425:4: ( 'bool' | 'byte' | 'bit' | 'char' | 'double' | 'int' | 'string' | 'float' | 'vector' | 'time' | 'date' | 'point' )\n # at line 425:4: ( 'bool' | 'byte' | 'bit' | 'char' | 'double' | 'int' | 'string' | 'float' | 'vector' | 'time' | 'date' | 'point' )\n alt_11 = 12\n case look_11 = @input.peek( 1 )\n when 0x62 then case look_11 = @input.peek( 2 )\n when 0x6f then alt_11 = 1\n when 0x79 then alt_11 = 2\n when 0x69 then alt_11 = 3\n else\n raise NoViableAlternative( \"\", 11, 1 )\n\n end\n when 0x63 then alt_11 = 4\n when 0x64 then look_11_3 = @input.peek( 2 )\n\n if ( look_11_3 == 0x6f )\n alt_11 = 5\n elsif ( look_11_3 == 0x61 )\n alt_11 = 11\n else\n raise NoViableAlternative( \"\", 11, 3 )\n\n end\n when 0x69 then alt_11 = 6\n when 0x73 then alt_11 = 7\n when 0x66 then alt_11 = 8\n when 0x76 then alt_11 = 9\n when 0x74 then alt_11 = 10\n when 0x70 then alt_11 = 12\n else\n raise NoViableAlternative( \"\", 11, 0 )\n\n end\n case alt_11\n when 1\n # at line 425:5: 'bool'\n match( \"bool\" )\n\n\n when 2\n # at line 425:12: 'byte'\n match( \"byte\" )\n\n\n when 3\n # at line 425:19: 'bit'\n match( \"bit\" )\n\n\n when 4\n # at line 425:25: 'char'\n match( \"char\" )\n\n\n when 5\n # at line 425:32: 'double'\n match( \"double\" )\n\n\n when 6\n # at line 425:41: 'int'\n match( \"int\" )\n\n\n when 7\n # at line 425:47: 'string'\n match( \"string\" )\n\n\n when 8\n # at line 425:56: 'float'\n match( \"float\" )\n\n\n when 9\n # at line 425:64: 'vector'\n match( \"vector\" )\n\n\n when 10\n # at line 425:73: 'time'\n match( \"time\" )\n\n\n when 11\n # at line 425:80: 'date'\n match( \"date\" )\n\n\n when 12\n # at line 425:87: 'point'\n match( \"point\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 43 )\n\n\n end",
"def process(problem)\n @problem = problem\n problem.constraints.each do |constraint|\n process_constraint(constraint)\n end\n problem.constraints = @constraints\n\n if allquantors_inside?(problem)\n @constraints = []\n problem = YarplFlattener.new.process(problem)\n end\n\n problem.constraints.each do |constraint|\n expand_count_all(constraint.expression,problem)\n end\n\n remove_invalid_constraints(problem)\n end",
"def construct_rules or_clauses_pos=nil, or_clauses_neg=nil\n \n or_clauses_pos = @or_clauses_pos unless or_clauses_pos.nil?\n or_clauses_neg = @or_clauses_neg unless or_clauses_neg.nil?\n\n #or_clauses_pos = translate_OR_clauses or_clauses_pos\n #or_clauses_neg = translate_OR_clauses or_clauses_neg\n \n\n puts \"Negation clauses: #{@or_clauses_neg.length}\"\n #Negations as PT ORed list.\n \n #Generate ORed negation string, surrounded by parentheses.\n negation_clauses = '\"snow inte\" OR \"snow nicht\" OR \"dj snow\" OR \"snow nights\" OR \"social snow\" OR \"snow repair\" OR snow dinner OR \"snow barista\"'\n puts \"Negations require #{negation_clauses.length} characters.\"\n\n puts \"Positive clauses: #{@or_clauses_pos.length}\"\n \n puts \"OK< build rules \"\n\n #Look at *negative* clauses first since they need to be in each rule.\n if !or_clauses_neg.nil? then\n\n if or_clauses_neg.length > @negative_limit and @negative_limit != -1 then\n puts 'More negation clauses then currently supported!'\n return\n end\n\n pt_clauses_neg = or_clauses_neg.join(' OR ')\n pt_clauses_neg = \"-(#{pt_clauses_neg})\"\n @negation_buffer = pt_clauses_neg.length\n if @negation_buffer > (0.9 * @length_limit) then\n puts 'Warning: only 10% of rule length available for positive clauses!'\n end\n end\n\n #Handle *positive* clauses.\n\n positive_length = @length_limit - @negation_buffer - 1 #Allocating a space inbetween pos/neg clauses.\n\n pt_rule_clauses = []\n pt_rules_pos = []\n clauses = 0\n pt_rule = ''\n\n or_clauses_pos.each do |clause|\n\n number_of_clauses = count_clauses(clause)\n #puts \"#{clause}: with #{number_of_clauses} clauses\"\n\n #TODO: this loop logic is likely orphaning the last few clauses...\n #And is hardcoded to standard rules.\n if clauses < (@positive_limit - number_of_clauses) and pt_rule.length < (positive_length - clause.length) then\n pt_rule_clauses << clause\n clauses = clauses + number_of_clauses\n pt_rule = pt_rule_clauses.join(' OR ')\n else #Reached a limit, so write positive portion of rule.\n pt_rule_clauses << clause\n pt_rule = pt_rule_clauses.join(' OR ')\n #puts pt_rule\n pt_rules_pos << pt_rule\n #Initialize.\n pt_rule_clauses = []\n pt_rule = ''\n clauses = 0\n end\n end\n\n pt_rules_pos.each do |pt_rule_pos|\n pt_rule = pt_rule_pos + ' ' + pt_clauses_neg\n @pt_rules << pt_rule\n puts pt_rule\n end\n\n end",
"def string_to_internal(preposition)\n\t\ttemp_kb =Array.new\n\t\t#string input of format literal_name LOGICAL_PREPOSISTION\n\t\tpreposition_array = preposition.split\n\t\n\t\tnext_negated = false\n\n\t\tsentence = []\n\t\tpreposition_array.each do |word|\n#####################################3\t\n\t\t#\tputs \" word: \" + word\n\t\t\t#don't need to handle \"or\" as long as it is in right format, will look to \"and\" and the end as limiters\n\t\t\tif (word == \"AND\" || word == \"and\")\n\t\t\t\ttemp_kb << sentence\n\t\t\t\tsentence = []\n\t\t\telsif(word == \"NOT\" || word == \"not\")\n\t\t\t\tnext_negated = true\n\t\t\telsif(word == \"OR\" || word ==\"or\")\n\n\t\t\telse\n\t\t\t\ttemp = @name_hash[word]\n\t\n\t\t\t\t#add variable if doesnt exist\n\t\t\t\tif(temp == nil)\n\t\t\t\t\ttemp_var = Literalzs.new(word,@total_variables)\n\t\t\t\t\t@id_array.push(temp_var)\n\t\t\t\t\t@name_hash[word] = @total_variables\n\t\t\t\t\ttemp = @total_variables\t\n\t\t\t\t\t@total_variables+=1\n\t\t\t\t end\n\t\t\n\t\t\t\tif(next_negated)\n\t\t\t\ttemp = temp.to_i * -1\n#########################################################3333\t\t\t\t\n\t\t\t\t#puts \" temp negated, now is: \" + temp.to_s\n\t\t\t\t\n\t\t\t\tnext_negated = false\n\t\t\t\tend\n\t\t\t\tsentence << temp\n\t\t\tend\n\t\tend\n\t\t#need to grab last sentence since it wont be ended with and\n\t\ttemp_kb << sentence\n\t\treturn temp_kb\n\tend",
"def clean\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n clean_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 308:8: ( 'C' | 'c' ) ( 'L' | 'l' ) ( 'E' | 'e' ) ( 'A' | 'a' ) ( 'N' | 'n' )\n if @input.peek( 1 ).between?( T__46, T__47 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__22, T__23 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__28, T__29 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__48, T__49 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__34, T__35 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n memoize( __method__, clean_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end",
"def body_propiedad\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 51 )\n\n\n return_value = BodyPropiedadReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n get278 = nil\n set279 = nil\n\n\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 236:6: get ( set )?\n @state.following.push( TOKENS_FOLLOWING_get_IN_body_propiedad_1174 )\n get278 = get\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, get278.tree )\n end\n\n # at line 236:10: ( set )?\n alt_38 = 2\n look_38_0 = @input.peek( 1 )\n\n if ( look_38_0 == K_SET )\n alt_38 = 1\n end\n case alt_38\n when 1\n # at line 236:10: set\n @state.following.push( TOKENS_FOLLOWING_set_IN_body_propiedad_1176 )\n set279 = set\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, set279.tree )\n end\n\n\n end\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 51 )\n\n\n end\n\n return return_value\n end",
"def string\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 60 )\n\n\n return_value = StringReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __COMILLA324__ = nil\n set325 = nil\n __COMILLA326__ = nil\n\n\n tree_for_COMILLA324 = nil\n tree_for_set325 = nil\n tree_for_COMILLA326 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 573:9: COMILLA ( EscapeSequence |~ ( '\\\\'' | '\\\\\\\\' ) )* COMILLA\n __COMILLA324__ = match( COMILLA, TOKENS_FOLLOWING_COMILLA_IN_string_2819 )\n if @state.backtracking == 0\n tree_for_COMILLA324 = @adaptor.create_with_payload( __COMILLA324__ )\n @adaptor.add_child( root_0, tree_for_COMILLA324 )\n\n end\n\n # at line 573:17: ( EscapeSequence |~ ( '\\\\'' | '\\\\\\\\' ) )*\n while true # decision 44\n alt_44 = 2\n look_44_0 = @input.peek( 1 )\n\n if ( look_44_0.between?( ASIGNACION, COMA ) || look_44_0.between?( CORDER, WS ) || look_44_0.between?( T__81, T__82 ) )\n alt_44 = 1\n\n end\n case alt_44\n when 1\n # at line \n set325 = @input.look\n\n if @input.peek( 1 ).between?( ASIGNACION, COMA ) || @input.peek( 1 ).between?( CORDER, WS ) || @input.peek( 1 ).between?( T__81, T__82 )\n @input.consume\n if @state.backtracking == 0\n @adaptor.add_child( root_0, @adaptor.create_with_payload( set325 ) )\n end\n\n @state.error_recovery = false\n\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n mse = MismatchedSet( nil )\n raise mse\n\n end\n\n\n\n else\n break # out of loop for decision 44\n end\n end # loop for decision 44\n\n __COMILLA326__ = match( COMILLA, TOKENS_FOLLOWING_COMILLA_IN_string_2837 )\n if @state.backtracking == 0\n tree_for_COMILLA326 = @adaptor.create_with_payload( __COMILLA326__ )\n @adaptor.add_child( root_0, tree_for_COMILLA326 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 60 )\n\n\n end\n\n return return_value\n end",
"def to_sentences(paragraph)\n\n#---------------- Step 1: Break up paragraph into pieces based on punctuation. \n\n\told_sentences = paragraph.split(/(?<=\\.\"|\\.\\)|\\.)(?<!\\.\\s\\.|\\.\\s\\.\"|\\.\\s\\.\\))\\s(?!\\.)|(?<=\\.\\s\\.\\s\\.\\s\\.\"|\\.\\s\\.\\s\\.\\s\\.\\)|\\.\\s\\.\\s\\.\\s\\.)\\s/)\n\t\t\t\t\t\t\t\t\t\t# splits on space in two cases: 1. if preceded by exactly one dot, possibly followed by ) or \"\n\t\t\t\t\t\t\t\t\t\t# 2. if preceded by four dots, possibly followed by ) or \" \n\t\t\t\t\t\t\t\t\t\t# (exactly one dot before SPLIT no dot after) OR (four dots before SPLIT)\n\n\t\n#---------------- Step 2: Re-join some pieces so that embedded quotes and parenthetical remarks aren't broken.\n\n \tnew_sentences = []\n\told_count = 0\t\t\t\t\t\t# position in old array built in Step 1\n\tnew_count = 0\t\t\t\t\t\t# position in new array built now in Step 2\n\t\t\n\twhile old_count < old_sentences.length\n\t\t\t\t\t\t\t\t\t\t# each step in outer while loop adds a new element to new_sentences\n\t\tskip = 0\t\t\t\t\t\t# skip keeps track of how many elements of old_sentences are used\n\t\tnew_sentences[new_count] = old_sentences[old_count]\n\n\t\twhile old_count + skip < old_sentences.length and (new_sentences[new_count].count('\"')%2 == 1 or new_sentences[new_count].count('(') != new_sentences[new_count].count(')'))\n\t\t\t\t\t\t\t\t\t\t# each step in inner while loop checks last element of new_sentences for mismatched quotes or parentheses, ...\t\t\t\t\t\t\t\t\t\t\n\n\t\t\tif new_sentences[new_count].count(')') > new_sentences[new_count].count('(')\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\)/, \"\")\n\t\t\t\tbreak\n\t\t\tend\t\t\t\t\t\t\t# ... if there's a mismatched right parenthesis, deletes it, ...\n\n\t\t\tif old_count + skip + 1 == old_sentences.length and (new_sentences[new_count].count('(') > new_sentences[new_count].count(')'))\n\t\t\t\told_sentences[old_count] = old_sentences[old_count].sub!(/\\(/, \"\")\n\t\t\t\tskip = -1\n\t\t\t\tnew_count -= 1\n\t\t\t\tbreak\t\t\t\t\t# ... if there's a mismatched left parenthesis or quote,\n\t\t\tend\t\t\t\t\t\t\t# joins next element of old_sentences to current new_sentence, unless\n\t\t\t\t\t\t\t\t\t\t# reach end of paragraph with mismatch; then deletes mismatched ( or ',\n\t\t\t\t\t\t\t\t\t\t# not joining subsequent elements of old_sentences to current new_sentence.\n\t\t\tskip += 1\n\t\t\tnew_sentences[new_count] = new_sentences[new_count] + \" \" + old_sentences[old_count + skip]\t\t\t\n\t\tend\n\n\t\tnew_count += 1\t\t\n\t\told_count += skip + 1\n\tend\n\n\n#---------------- Step 3: Make sure each piece starts and ends with a single quote.\n\n\tsentences_with_quotes = []\n\tnew_sentences.each do |x|\n\t\tx = x.chomp\n\t\tx = \"'\"+x if x[0] != \"'\"\n\t\tx = x+\"'\" if x[x.length-1] != \"'\"\n\t\tsentences_with_quotes << x\n\tend\n\n\treturn sentences_with_quotes\n\nend",
"def to_citrus # :nodoc:\n rules.map {|r| r.to_embedded_s }.join(' | ')\n end",
"def simplification_rules_for_disjunction\n if is_formula_or_formula?\n copy @left_sentence\n update\n elsif is_formula_or_not_formula?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:up])\n elsif is_formula_or_up?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:up])\n elsif is_formula_or_bottom?\n if @left_sentence.is_constant?\n copy @right_sentence\n else\n copy @left_sentence\n end\n update\n end\n end",
"def compose\n # On demande d'abord de construire le code des portées pour pouvoir\n # détecter les commandes-raccourcis qu'il faudra ajouter, par exemple\n # la variable \\circle\n bloc_score\n\n @code_final = []\n @code_final << definitions_preliminaires\n @code_final << paper_definition\n @code_final << lp_header\n @code_final << commandes_raccourcis\n @code_final << header\n @code_final << bloc_score\n @code_final = @code_final.join(\"\\n\")\n end",
"def ruby_bnf_grammar_parser\r\n parser = nil\r\n time_and_puts(\"Generating parser for Ruby BNF grammar\") do\r\n begin\r\n parser = Parse.generate_parser <<-'EOG'\r\nGrammar BnfGrammars\r\n Tokens\r\n Blank = /\\s+/ [:Skip]\r\n EpsilonComment = /\\/\\* none \\*\\//\r\n Nonterm = /[a-z][a-z_\\d]*/ \r\n Keyword = /k\\w+/\r\n Token = /t[A-Z_\\d]+/\r\n String = /'[^']*'/\r\n Productions\r\n BnfGrammar -> Prod+ [: productions]\r\n Prod -> Nonterm ':' list(Alt, '|') [: nonterm,_,alts]\r\n Alt -> Element* [: elements]\r\n Element -> (Nonterm | Keyword | Token | \r\n String | EpsilonComment) [^]\r\nEOG\r\n rescue Exception => e\r\n puts e.inspect\r\n exit -1\r\n end\r\n end\r\n parser\r\nend",
"def fix_conditions(rule)\n if rule[:precondition] == nil then rule[:precondition] = \"\"\n elsif rule[:precondition][\"1\"][\"const_value\"] == nil then rule[:precondition] = \"\"\n elsif rule[:precondition][\"1\"][\"variable\"][\"1\"][\"complete\"] == nil or rule[:precondition][\"1\"][\"variable\"][\"1\"][\"complete\"].length == 0 then rule[:precondition] = \"\" end\n \n rule[:condition] = Marshal.dump(rule[:condition])\n rule[:precondition] = Marshal.dump(rule[:precondition])\n return rule\n end",
"def p!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = P\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 335:6: 'p'\n match( 0x70 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end",
"def rcb!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 41 )\n\n type = RCB\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 366:7: '}'\n match( 0x7d )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 41 )\n\n end",
"def required_positionals; end",
"def read_CNF(filename)\n raw_data = IO.read(DIR + filename).split(\"\\n\")\n\n dataset = []\n\n raw_data.each do |subset|\n dataset << subset.split(\" \")\n end\n # Return values:\n # 0 Number of clauses\n # 1 Number of variables\n # 2 Array of clauses, formula\n [dataset[0][2].to_i, dataset[0][3].to_i, dataset[1..-1]]\nend",
"def dclrG\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n a = nil\n b = nil\n\n begin\n # at line 47:11: b= type a= ID ( '=' comp )?\n @state.following.push( TOKENS_FOLLOWING_type_IN_dclrG_392 )\n b = type\n @state.following.pop\n a = match( ID, TOKENS_FOLLOWING_ID_IN_dclrG_396 )\n # --> action\n agc_1(a,b,true,false,false,true)\n # <-- action\n # at line 47:58: ( '=' comp )?\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0 == EQLS )\n alt_11 = 1\n end\n case alt_11\n when 1\n # at line 47:59: '=' comp\n match( EQLS, TOKENS_FOLLOWING_EQLS_IN_dclrG_401 )\n # --> action\n agc_2('=')\n # <-- action\n @state.following.push( TOKENS_FOLLOWING_comp_IN_dclrG_406 )\n comp\n @state.following.pop\n # --> action\n agc_3('=')\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end\n \n return \n end",
"def preprocess(input); end",
"def k_asignacion!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n\n\n type = K_ASIGNACION\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n # at line 381:3: ( 'add' | 'div' | 'mul' | 'sub' | 'pot' | 'sqrt' | 'copy' | 'del' | 'porcent' )\n alt_7 = 9\n case look_7 = @input.peek( 1 )\n when 0x61 then alt_7 = 1\n when 0x64 then look_7_2 = @input.peek( 2 )\n\n if ( look_7_2 == 0x69 )\n alt_7 = 2\n elsif ( look_7_2 == 0x65 )\n alt_7 = 8\n else\n raise NoViableAlternative( \"\", 7, 2 )\n\n end\n when 0x6d then alt_7 = 3\n when 0x73 then look_7_4 = @input.peek( 2 )\n\n if ( look_7_4 == 0x75 )\n alt_7 = 4\n elsif ( look_7_4 == 0x71 )\n alt_7 = 6\n else\n raise NoViableAlternative( \"\", 7, 4 )\n\n end\n when 0x70 then look_7_5 = @input.peek( 2 )\n\n if ( look_7_5 == 0x6f )\n look_7_11 = @input.peek( 3 )\n\n if ( look_7_11 == 0x74 )\n alt_7 = 5\n elsif ( look_7_11 == 0x72 )\n alt_7 = 9\n else\n raise NoViableAlternative( \"\", 7, 11 )\n\n end\n else\n raise NoViableAlternative( \"\", 7, 5 )\n\n end\n when 0x63 then alt_7 = 7\n else\n raise NoViableAlternative( \"\", 7, 0 )\n\n end\n case alt_7\n when 1\n # at line 381:4: 'add'\n match( \"add\" )\n\n\n when 2\n # at line 381:10: 'div'\n match( \"div\" )\n\n\n when 3\n # at line 381:16: 'mul'\n match( \"mul\" )\n\n\n when 4\n # at line 381:22: 'sub'\n match( \"sub\" )\n\n\n when 5\n # at line 381:28: 'pot'\n match( \"pot\" )\n\n\n when 6\n # at line 381:34: 'sqrt'\n match( \"sqrt\" )\n\n\n when 7\n # at line 381:41: 'copy'\n match( \"copy\" )\n\n\n when 8\n # at line 381:48: 'del'\n match( \"del\" )\n\n\n when 9\n # at line 381:54: 'porcent'\n match( \"porcent\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n\n end",
"def simplification\n changed = true\n while changed\n changed = false\n unless @operator.nil?\n old_left = ( @left_sentence ? Sentence.new(@left_sentence) : nil )\n old_right = ( @right_sentence ? Sentence.new(@right_sentence) : nil )\n case @operator.type\n when :conjunction\n simplification_rules_for_conjunction\n\n # ******* NEW APNF RULES FOR NEGATED IMPLICATION FORMULA CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_simplification_rules_for_conjunction()\n\n when :disjunction\n simplification_rules_for_disjunction\n\n # ******* NEW APNF RULES FOR NEGATED IMPLICATION FORMULA CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_simplification_rules_for_disjunction()\n\n when :negation\n simplification_rules_for_negation\n\n # ******* NEW SIMPLIFICATION RULES FOR NEGATION CAN BE ADDED HERE AS A METHOD JUST LIKE THE METHOD ABOVE *******\n # ******* FOR EXAMPLE:\n new_simplification_rules_for_negation()\n\n when :new_operator\n # ******* OR A NEW OPERATOR NOT USED BEFORE CAN BE ADDED IN THE SIMPLIFICATION - LIKE IMPLICATION FOR EXAMPLE *******\n\n # ******* AND A NEW SIMPLIFICATION RULE CAN BE ADDED TO THIS OPERATOR *******\n # ******* FOR EXAMPLE: *******\n simplification_rules_for_new_operator()\n\n end\n\n @left_sentence.simplification unless @left_sentence.nil?\n @right_sentence.simplification unless @right_sentence.nil?\n\n unless Sentence.equals?(old_left, @left_sentence) && Sentence.equals?(old_right, @right_sentence)\n changed = true\n update\n end\n end\n end\n self\n end",
"def corizq!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n\n\n\n type = CORIZQ\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 301:3: '['\n match( 0x5b )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 12 )\n\n\n end",
"def compute!\n class_def = /^\\[[\\w;\\?|=!]*?\\]$/\n inheritance = /\\[(.*?)\\]\\^\\[(.*?)\\]/\n association = /\\[.*\\]-.*>\\[.*\\]/\n\n @statements.sort! do |x, y|\n\n if x =~ class_def and y =~ inheritance\n -1\n elsif x =~ class_def and y =~ association\n -1\n elsif x =~ inheritance and y =~ association\n -1\n elsif x =~ class_def and y =~ class_def\n 0\n elsif x =~ inheritance and y =~ inheritance\n 0\n elsif x =~ association and y =~ association\n 0\n else\n 1\n end\n\n end\n end",
"def to_prolog(repository)\n variables = []\n functors = []\n patterns.each do |p|\n # Extract any new variables we see in the query.\n variables.concat(p.variables.values)\n functors << convert_to_functor(p).to_prolog(repository)\n end\n \"(select (#{variables.uniq.join(\" \")})\\n #{functors.join(\"\\n \")})\"\n end",
"def pronunciations(input)\n list = 1\n input.body.each do |pronuciation|\n current_pronunciation = pronuciation['raw']\n puts \"#{list}. #{current_pronunciation}\"\n list += 1\n end\n end",
"def nd!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 50 )\n\n type = ND\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n d = nil\n\n\n \n # - - - - main rule block - - - -\n # at line 349:5: d= ( ( DIGIT )* ) '2' ( 'N' | 'n' ) ( 'D' | 'd' )\n # at line 349:7: ( ( DIGIT )* )\n # at line 349:8: ( DIGIT )*\n # at line 349:8: ( DIGIT )*\n while true # decision 2\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == 0x32 )\n look_2_1 = @input.peek( 2 )\n\n if ( look_2_1.between?( 0x30, 0x39 ) )\n alt_2 = 1\n\n end\n elsif ( look_2_0.between?( 0x30, 0x31 ) || look_2_0.between?( 0x33, 0x39 ) )\n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 349:8: DIGIT\n digit!\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n\n match( 0x32 )\n if @input.peek(1) == 0x4e || @input.peek(1) == 0x6e\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n if @input.peek(1) == 0x44 || @input.peek(1) == 0x64\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 50 )\n\n end",
"def dnf\n r = []\n @table.each {|inputs, output|\n return output.to_s if inputs.empty?\n next if !output\n term = []\n each_input(inputs) {|name, input|\n if input\n term << name\n else\n term << \"!#{name}\"\n end\n }\n r << term.join('&')\n }\n return \"false\" if r.empty?\n r.join(' | ')\n end",
"def initialize\n @irregulars = {}\n @single_terminal_consonants = []\n @copulars = {}\n end",
"def pipe_asgn!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 81 )\n\n type = PIPE_ASGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 202:13: '|='\n match( \"|=\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 81 )\n\n end",
"def k_propiedad!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 61 )\n\n\n\n type = K_PROPIEDAD\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 497:4: 'property'\n match( \"property\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 61 )\n\n\n end",
"def to_cfg(rule)\n rules = [rule]\n nonterminals = { rule.token => true }\n\n rules.inject(CFG.new(@nonterm)) do |cfg, rule|\n cfg[rule.token] = rule.inject(List.new) do |list, node|\n symbol = node.value\n\n if not symbol.rule.nil? and not nonterminals[symbol.token]\n rules << symbol.rule\n nonterminals[symbol.token] = true\n end\n\n list << symbol.token\n end\n cfg\n end\n end",
"def definir_propiedad\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 50 )\n\n\n return_value = DefinirPropiedadReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_DEF269__ = nil\n __K_PROPIEDAD270__ = nil\n __Identificador271__ = nil\n __LPAR272__ = nil\n __Identificador273__ = nil\n __RPAR274__ = nil\n __LLAIZQ275__ = nil\n __LLADER277__ = nil\n body_propiedad276 = nil\n\n\n tree_for_K_DEF269 = nil\n tree_for_K_PROPIEDAD270 = nil\n tree_for_Identificador271 = nil\n tree_for_LPAR272 = nil\n tree_for_Identificador273 = nil\n tree_for_RPAR274 = nil\n tree_for_LLAIZQ275 = nil\n tree_for_LLADER277 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 232:4: K_DEF K_PROPIEDAD Identificador LPAR Identificador RPAR LLAIZQ body_propiedad LLADER\n __K_DEF269__ = match( K_DEF, TOKENS_FOLLOWING_K_DEF_IN_definir_propiedad_1145 )\n if @state.backtracking == 0\n tree_for_K_DEF269 = @adaptor.create_with_payload( __K_DEF269__ )\n @adaptor.add_child( root_0, tree_for_K_DEF269 )\n\n end\n\n __K_PROPIEDAD270__ = match( K_PROPIEDAD, TOKENS_FOLLOWING_K_PROPIEDAD_IN_definir_propiedad_1147 )\n if @state.backtracking == 0\n tree_for_K_PROPIEDAD270 = @adaptor.create_with_payload( __K_PROPIEDAD270__ )\n @adaptor.add_child( root_0, tree_for_K_PROPIEDAD270 )\n\n end\n\n __Identificador271__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_definir_propiedad_1149 )\n if @state.backtracking == 0\n tree_for_Identificador271 = @adaptor.create_with_payload( __Identificador271__ )\n @adaptor.add_child( root_0, tree_for_Identificador271 )\n\n end\n\n __LPAR272__ = match( LPAR, TOKENS_FOLLOWING_LPAR_IN_definir_propiedad_1151 )\n if @state.backtracking == 0\n tree_for_LPAR272 = @adaptor.create_with_payload( __LPAR272__ )\n @adaptor.add_child( root_0, tree_for_LPAR272 )\n\n end\n\n __Identificador273__ = match( Identificador, TOKENS_FOLLOWING_Identificador_IN_definir_propiedad_1153 )\n if @state.backtracking == 0\n tree_for_Identificador273 = @adaptor.create_with_payload( __Identificador273__ )\n @adaptor.add_child( root_0, tree_for_Identificador273 )\n\n end\n\n __RPAR274__ = match( RPAR, TOKENS_FOLLOWING_RPAR_IN_definir_propiedad_1155 )\n if @state.backtracking == 0\n tree_for_RPAR274 = @adaptor.create_with_payload( __RPAR274__ )\n @adaptor.add_child( root_0, tree_for_RPAR274 )\n\n end\n\n __LLAIZQ275__ = match( LLAIZQ, TOKENS_FOLLOWING_LLAIZQ_IN_definir_propiedad_1157 )\n if @state.backtracking == 0\n tree_for_LLAIZQ275 = @adaptor.create_with_payload( __LLAIZQ275__ )\n @adaptor.add_child( root_0, tree_for_LLAIZQ275 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_body_propiedad_IN_definir_propiedad_1159 )\n body_propiedad276 = body_propiedad\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, body_propiedad276.tree )\n end\n\n __LLADER277__ = match( LLADER, TOKENS_FOLLOWING_LLADER_IN_definir_propiedad_1161 )\n if @state.backtracking == 0\n tree_for_LLADER277 = @adaptor.create_with_payload( __LLADER277__ )\n @adaptor.add_child( root_0, tree_for_LLADER277 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 50 )\n\n\n end\n\n return return_value\n end",
"def t__13!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n type = T__13\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 18:9: 'p'\n match( 0x70 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n end",
"def initialize(title, premises, conclusion)\n @title = title\n @premises = premises.map { |p| Proposition.new p }\n @conclusion = Proposition.new conclusion\n end",
"def relation\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n value = nil\n\n\n type = nil\n a = nil\n b = nil\n\n\n begin\n # at line 178:5: a= add (type= ( '==' | '!=' | '<' | '<=' | '>=' | '>' ) b= relation )?\n @state.following.push( TOKENS_FOLLOWING_add_IN_relation_1322 )\n a = add\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = a \n # <-- action\n end\n\n # at line 179:3: (type= ( '==' | '!=' | '<' | '<=' | '>=' | '>' ) b= relation )?\n alt_44 = 2\n look_44_0 = @input.peek( 1 )\n\n if ( look_44_0 == T__31 || look_44_0.between?( T__47, T__48 ) || look_44_0.between?( T__50, T__52 ) )\n alt_44 = 1\n end\n case alt_44\n when 1\n # at line 179:6: type= ( '==' | '!=' | '<' | '<=' | '>=' | '>' ) b= relation\n type = @input.look\n\n if @input.peek(1) == T__31 || @input.peek( 1 ).between?( T__47, T__48 ) || @input.peek( 1 ).between?( T__50, T__52 )\n @input.consume\n @state.error_recovery = false\n\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n mse = MismatchedSet( nil )\n raise mse\n\n end\n\n\n @state.following.push( TOKENS_FOLLOWING_relation_IN_relation_1359 )\n b = relation\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = DoubleOperandExpressionEval.new(type.text, a, b) \n # <-- action\n end\n\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end\n\n return value\n end",
"def prove(state, query)\n # Envia para o prolog o estado atual\n @@prolog.assert(state)\n\n values = []\n if query.is_a? String\n values = @@prolog.send(query + \".\\n\")\n else\n query.each do |term|\n answer = @@prolog.send(term + \".\\n\")\n values << unify(term, answer)\n end\n end\n\n # Remove o estado atual\n @@prolog.retract(state)\n\n if values.is_a? Array\n return values.flatten\n else \n return values\n end\n end",
"def modify_grammar gm\n def cleanup_entry token, entry\n return {} if entry.nil?\n return entry.map { |subentry| cleanup_entry token, subentry } if entry.is_a?(Array)\n # Convert a reference to a Seeker class to the class itself\n return entry.constantize if entry.is_a?(String) && entry.match(/Seeker$/)\n return entry unless entry.is_a?(Hash)\n # Syntactic sugar: these flags may specify the actual match. Make this explicit\n [\n :checklist, # All elements must be matched, but the order is unimportant\n :or, # The list is taken as an ordered set of alternatives, any of which will match the list\n :repeating, # The spec will be matched repeatedly until the end of input\n :orlist, # The item will be repeatedly matched in the form of a comma-separated, 'and'/'or' terminated list\n # :accumulate, # Accumulate matches serially in a single child\n :optional # Failure to match is not a failure\n ].each do |flag|\n if entry[flag] && entry[flag] != true\n entry[:match], entry[flag] = entry[flag], true\n end\n end\n entry[:match] = cleanup_entry :match, entry[:match] if entry[:match]\n keys = entry.keys.map &:to_sym # Ensure all keys are symbols\n [\n %i{ bound terminus }, # :bound and :terminus are exclusive options\n %i{ atline inline }, # :atline and :inline are exclusive options\n %i{ in_css_match at_css_match after_css_match } # :in_css_match, :at_css_match and :after_css_match are exclusive options\n ].each do |flagset|\n # At most one of the flags in the flagset can be non-nil\n setflags = (entry.slice *flagset).compact # Eliminating the nil flags\n if setflags.count > 1\n wrongstring = ':' + setflags.keys.map(&:to_s).join(', :')\n flagstring = ':' + flagset.map(&:to_s).join(', :')\n raise \"Error: grammar entry for #{token} has #{wrongstring} flags. (Only one of #{flagstring} allowed).\"\n end\n end\n entry\n end # cleanup_entry\n # Do \n def merge_entries original, mod\n return original unless mod && mod != {}\n return mod unless original&.is_a?(Hash)\n mod.each do |key, value|\n if value.nil?\n original.delete key\n else\n original[key] = value.is_a?(Hash) ? merge_entries(original[key], value) : value\n end\n end\n original\n end\n @grammar.keys.each do |key|\n key = key.to_sym\n entry = cleanup_entry key, @grammar[key]\n mod = cleanup_entry key, gm[key]\n @grammar[key] = merge_entries entry, mod # Allows elements to be removed\n end\n end",
"def consolidate_classes(original_line, list_of_classes)\n record = {\n :original_ocr => original_line,\n :attributes_parsed => {\n :subject =>\n [\n #{:value => \"Curran Sarah\", :type => \"primary\", :occupation => \"widowed\"},\n #{:value => \"Richard\", :type => \"widower of primary\"}\n ],\n :location =>\n [\n #{:value => \"7 Sixth\", :position => \"rear\", :type => \"home\"}\n ]\n }\n }\n\n list_of_classes.each_with_index do |classed_token, index|\n parsed_class = classed_token[1][0]\n value = classed_token[0]\n if index == 0 && parsed_class == :name_component\n record[:attributes_parsed][:subject] << {:value => value, :type => 'primary'}\n end\n if index > 0\n case parsed_class\n when :job_component\n unless record[:attributes_parsed][:subject].count < 1\n record[:attributes_parsed][:subject][0][:occupation] = value\n end\n when :predicate\n case value\n when \"wid\"\n unless record[:attributes_parsed][:subject].count < 1\n record[:attributes_parsed][:subject][0][:occupation] = 'widow'\n end\n deceased_name = look_for_name_of_deceased(list_of_classes,index)\n unless deceased_name.nil?\n record[:attributes_parsed][:subject] << {:value => deceased_name, :type => 'deceased spouse of primary'}\n end\n #attach_to_next(list_of_classes, index, :name_component, [{:type => 'deceased spouse of primary'}])\n when \"h\"\n attach_to_next(list_of_classes, index, :address_component, [{:type => 'home'}])\n when \"r\"\n attach_to_next(list_of_classes, index, :address_component, [{:position => 'rear'}])\n else\n end\n ## inner case\n when :address_component\n loc = {:value => value}\n classed_token[2..-1].each do |xtra_attr| ## add in any additional attributes from predicates\n xtra_attr.each do |k, v|\n loc[k] = v\n end\n end\n unless merge_if_directly_subsequent_is_alike(list_of_classes, index, classed_token)\n record[:attributes_parsed][:location] << loc\n end\n else\n end\n end ## indices after 0\n end ## loop of classes\n\n return record\nend",
"def formula\n input_names = all_names\n input_names_ary = sort_names(input_names.keys)\n tbl = {}\n @table.each {|inputs, output|\n return output.to_s if inputs.empty?\n inputs2 = [:x] * input_names.length\n inputs.each {|name, input|\n inputs2[input_names[name]] = input ? 1 : 0\n }\n tbl[inputs2] = output ? 1 : 0\n }\n qm = QM.qm(tbl)\n r = []\n qm.each {|term|\n t = []\n num_dontcare = 0\n term.each_with_index {|v, i|\n if v == false\n t << (\"!\" + input_names_ary[i])\n elsif v == true\n t << input_names_ary[i]\n else # :x\n num_dontcare += 1\n end\n }\n if num_dontcare == term.length\n r << 'true'\n else\n r << t.join('&')\n end\n }\n return \"false\" if r.empty?\n r.join(' | ')\n end",
"def preprocess_statement(statement)\n #add_debug {\"preprocess: #{statement.inspect}\"}\n return unless statement.context == graph_name\n bump_reference(statement.subject)\n bump_reference(statement.object)\n @subjects[statement.subject] = true\n get_curie(statement.subject)\n get_curie(statement.predicate)\n get_curie(statement.object)\n get_curie(statement.object.datatype) if statement.object.literal? && statement.object.has_datatype?\n end",
"def prt\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n begin\n # at line 43:9: ( ( OUT LPAR ( comp )? RPAR ) | ( OUTS LPAR ( comp )? RPAR ) )\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0 == OUT )\n alt_7 = 1\n elsif ( look_7_0 == OUTS )\n alt_7 = 2\n else\n raise NoViableAlternative( \"\", 7, 0 )\n end\n case alt_7\n when 1\n # at line 43:11: ( OUT LPAR ( comp )? RPAR )\n # at line 43:11: ( OUT LPAR ( comp )? RPAR )\n # at line 43:12: OUT LPAR ( comp )? RPAR\n match( OUT, TOKENS_FOLLOWING_OUT_IN_prt_261 )\n match( LPAR, TOKENS_FOLLOWING_LPAR_IN_prt_263 )\n # at line 43:21: ( comp )?\n alt_5 = 2\n look_5_0 = @input.peek( 1 )\n\n if ( look_5_0 == MINUS || look_5_0 == LPAR || look_5_0.between?( ID, STRING ) )\n alt_5 = 1\n end\n case alt_5\n when 1\n # at line 43:21: comp\n @state.following.push( TOKENS_FOLLOWING_comp_IN_prt_265 )\n comp\n @state.following.pop\n\n end\n match( RPAR, TOKENS_FOLLOWING_RPAR_IN_prt_268 )\n # --> action\n agc_3('out')\n # <-- action\n\n\n when 2\n # at line 43:48: ( OUTS LPAR ( comp )? RPAR )\n # at line 43:48: ( OUTS LPAR ( comp )? RPAR )\n # at line 43:49: OUTS LPAR ( comp )? RPAR\n match( OUTS, TOKENS_FOLLOWING_OUTS_IN_prt_274 )\n match( LPAR, TOKENS_FOLLOWING_LPAR_IN_prt_276 )\n # at line 43:59: ( comp )?\n alt_6 = 2\n look_6_0 = @input.peek( 1 )\n\n if ( look_6_0 == MINUS || look_6_0 == LPAR || look_6_0.between?( ID, STRING ) )\n alt_6 = 1\n end\n case alt_6\n when 1\n # at line 43:59: comp\n @state.following.push( TOKENS_FOLLOWING_comp_IN_prt_278 )\n comp\n @state.following.pop\n\n end\n match( RPAR, TOKENS_FOLLOWING_RPAR_IN_prt_281 )\n # --> action\n agc_3('outln')\n # <-- action\n\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end\n \n return \n end",
"def parse_pgn(pgn)\n @parser.parse(pgn)\n end",
"def iterate(pots, start_pot, rules)\n\n# print \"incoming pots #{pots}\\n\"\n \n count_end_empty_pots = 0\n i = pots.length - 1\n while pots[i] == '.'\n count_end_empty_pots += 1\n i -= 1\n end\n\n if count_end_empty_pots < 3\n add_pots = 3 - count_end_empty_pots\n# print \"Adding #{add_pots} pots at end\\n\"\n pots += \".\" * add_pots\n end\n\n# print \"after add right pots #{pots}\\n\"\n\n count_start_empty_pots = 0\n i = 0\n while pots[i] == '.'\n count_start_empty_pots += 1\n i += 1\n end\n \n if count_start_empty_pots < 3\n add_pots = 3 - count_end_empty_pots\n pots = \".\" * add_pots + pots\n start_pot += add_pots\n# print \"Adding #{add_pots} pots at start. First pot now at #{start_pot}\\n\"\n end\n\n# print \"after add left pots #{pots}\\n\"\n \n # Now find a matching rule and apply it\n # So as not to modify the plants before the rules have all been\n # applied we'll keep a hash of plant states to modify and\n # apply them at the end of the rule application\n\n plant_changes = []\n rules.each do |rule|\n search_pos = 0\n found = true\n while found do\n match = pots.match(Regexp.escape(rule[0]), search_pos)\n\n found = false if match.nil?\n\n if found\n# printf \"#{rule[0]} matches so #{rule[1]} is new state of pot at index #{match.begin(0) + 2}\\n\"\n plant_changes << [rule[1], match.begin(0) + 2]\n search_pos = match.begin(0) + 1\n end\n end\n end\n\n #binding.pry\n\n pots = '.' * pots.length \n \n # # Apply plant births and deaths\n plant_changes.each do |change|\n pots[change[1]] = change[0]\n end\n \n# print \"after apply changes #{pots}\\n\"\n \n [pots, start_pot]\nend",
"def spellout_rules = rbnf(:spellout_rules)",
"def to_s\n\t\t[\n\t\t\t\"Terminals: #{terminals.join(', ')}\",\n\t\t\t\"Non-terminals: #{non_terminals.join(', ')}\",\n\t\t\t\"\\nGrammar Rules\",\n\t\t\t\tprint_rules,\n\t\t\t\t\"\\nGrammar Start Symbol: #{@goal}\",\n\t\t\t\"\\nDerives to lambda: #{print_lambda}\",\n\t\t\t\"\\nFirst sets:\",\n\t\t\t\tprint_firsts,\n\t\t\t\t\"\\nFollow sets:\",\n\t\t\t\tprint_follows,\n\t\t\t\t\"\\nPredict sets:\",\n\t\t\t\tprint_predicts\n\n\t\t].join(\"\\n\")\n\tend",
"def cpf_cnpj\n\t\t\t\treturn \"\" unless @cpf_cnpj.present?\n\t\t\t\tBrBoleto::Helper::CpfCnpj.new(@cpf_cnpj).sem_formatacao\n\t\t\tend",
"def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n return_value = ExpressionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n member220 = nil\n assignment_op221 = nil\n expression222 = nil\n conditional223 = nil\n\n\n begin\n # at line 556:3: ( ( member assignment_op )=> member assignment_op expression | conditional )\n alt_50 = 2\n alt_50 = @dfa50.predict( @input )\n case alt_50\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 556:5: ( member assignment_op )=> member assignment_op expression\n @state.following.push( TOKENS_FOLLOWING_member_IN_expression_3699 )\n member220 = member\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, member220.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_assignment_op_IN_expression_3701 )\n assignment_op221 = assignment_op\n @state.following.pop\n if @state.backtracking == 0\n root_0 = @adaptor.become_root( assignment_op221.tree, root_0 )\n end\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_3704 )\n expression222 = expression\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, expression222.tree )\n end\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 557:5: conditional\n @state.following.push( TOKENS_FOLLOWING_conditional_IN_expression_3710 )\n conditional223 = conditional\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, conditional223.tree )\n end\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n end\n \n return return_value\n end",
"def tidy_up!\n antecedence.each_key do |entry|\n antecedence[entry].uniq!\n end\n end",
"def calculate\n candidates = []\n\n generalized_cause = NLU::Generalization.new(symbols: @symbols).generalize(@cause)\n\n #ap \"sentence: #{cause_sentence}\"\n #ap \"learned: #{@learned.inspect}\"\n\n # We go through everything that was learned before\n @learned.each do |function_name, criteria|\n criteria[:generalizations].each do |generalization|\n\n # We generate a pre-candidate for this generalization. It starts\n # with score zero because we don't know yet whether this criteria\n # fits the sentence or not.\n local_candidate = {\n fn: function_name,\n attrs: { },\n score: 0.0\n }\n\n #ap \"generalized_cause #{generalized_cause}\"\n\n # We then generalize the cause sentence and go through it.\n # We will match *each* learned generalization against the cause\n # generalization.\n generalized_cause.each_with_index do |cause_rule, cause_index|\n\n\n # Wildcard\n #\n # Matches these:\n #\n # > i want a [type:wildcard:some_name_for_this_wildcard]\n # > i want a ford\n #\n wildcard = \"[#{NLU::Generalization::RESERVED_TYPES[:wildcard]}]\"\n #ap \"wildcard: #{wildcard}\"\n wildcard_regex = Regexp.escape(wildcard)\n if generalization =~ /wildcard/i\n wildcard_generalization = generalization\n .gsub(/\\[(type:wildcard)(.+)\\]/i, '[\\1]')\n end\n #ap \"wildcard_generalization(#{wildcard_generalization}) =~ cause_rule(#{wildcard_regex})\"\n if wildcard_generalization.to_s =~ Regexp.new(wildcard_regex, Regexp::IGNORECASE)\n #ap \"true -> #{wildcard_generalization} =~ /#{Regexp.new(wildcard_regex, Regexp::IGNORECASE)}/i\"\n\n rule = wildcard_generalization.gsub(\"#{wildcard}\", \"(.+)\")\n #ap \"rule #{rule}\"\n #binding.pry\n if value = cause_sentence.join(\" \").match(Regexp.new(rule, Regexp::IGNORECASE))\n value = value[-1]\n prop = attr_name_from_type_param(generalization)\n\n local_candidate = local_candidate.merge({\n attrs: {\n prop => value\n },\n score: 0.75\n })\n end\n\n # If we find a learned generalization that matches the generalized\n # sentence, we will save it.\n elsif generalization == cause_rule\n cause_rule.split(\" \").each_with_index do |typed_string, index|\n\n # If the learned generalization has a type anywhere, we will\n # check what is the corresponding word in the cause sentence.\n #\n # For example, consider the following sentence:\n #\n # [type:subject] want a [type:make]\n #\n # and the sentence\n #\n # I want a ford\n #\n # Finding `[type:make]` at position 3 of the array, we will\n # get `ford` at the position 3 of the cause sentence. With\n # that we can come up with `{make: 'ford'}`.\n #\n if typed_string =~ /\\[type/i\n local_candidate[:score] += 1\n type = attr_name_from_type_param(typed_string)\n prop = type_properties(type)\n type_token_length = prop[:token_length]\n\n # In `i want a car`, this will get the `i`. If the type\n # says instead that it's formed by two symbols (e.g\n # `i want`), then it will take `i want`.\n #\n # The -1 in the brackets is because otherwise it would be\n # translated to the following if the type had 1 symbol\n #\n # cause_sentence[1..1+1]\n #\n # That would take 2 words (`[1..2]`). We want one word, so\n #\n # cause_sentence[1..1+1-1]\n #\n word_for_type = cause_sentence[index..index+(type_token_length-1)]\n #ap \"> type: #{type} - #{index} #{cause_sentence[index..index+type_token_length]}\"\n\n local_candidate[:attrs][type] = word_for_type.join(\" \")\n\n # When it's just the same sentence as one seen before, no\n # generalizations\n else\n local_candidate[:score] = 1\n end\n end\n\n end\n end\n\n if local_candidate[:score] > 0\n candidates << local_candidate\n end\n end\n end\n\n # TODO - normalization is taking out some elements that are good.\n #candidates = normalize_scores(candidates)\n candidates = pick_candidates(candidates)\n candidates = merge_attributes(candidates)\n\n candidates\n end",
"def punto!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n\n\n\n type = PUNTO\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 293:3: '.'\n match( 0x2e )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n\n end",
"def circuit_definitions\n split_lines.map do |line|\n input_definition, wire_id = line.split('->').map(&:strip)\n\n input_type, input_1, input_2 = if input_definition =~ /^\\d+$/\n ['SIGNAL', input_definition, nil]\n elsif input_definition =~ /^[a-z]{2}$/\n ['WIRE', input_definition, nil]\n else\n if input_definition.start_with?('NOT')\n input_definition.split(' ')\n else\n left_input_name, op_name, right_input_name = input_definition.split(' ')\n [op_name, left_input_name, right_input_name]\n end\n end\n\n [wire_id, input_type, input_1, input_2]\n end\n end",
"def direct_nullable\n nullables = Set.new\n # Direct nullable nonterminals correspond to empty productions\n rules.each do |prod|\n next unless prod.empty?\n\n prod.lhs.nullable = true\n nullables << prod.lhs\n end\n\n nullables\n end",
"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 pa\n return VasmGrammar.new, VasmTransform.new\nend",
"def comp\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 12 )\n\n begin\n # at line 50:11: ( expr ) ( ( ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR ) ) ( expr ) )*\n # at line 50:11: ( expr )\n # at line 50:12: expr\n @state.following.push( TOKENS_FOLLOWING_expr_IN_comp_475 )\n expr\n @state.following.pop\n # --> action\n agc_3(['<','>','>=','<=','==','&','|'])\n # <-- action\n\n # at line 51:11: ( ( ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR ) ) ( expr ) )*\n while true # decision 14\n alt_14 = 2\n look_14_0 = @input.peek( 1 )\n\n if ( look_14_0.between?( GRTH, OR ) )\n alt_14 = 1\n\n end\n case alt_14\n when 1\n # at line 51:12: ( ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR ) ) ( expr )\n # at line 51:12: ( ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR ) )\n # at line 51:13: ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR )\n # at line 51:13: ( LSTHE | GRTHE | LSTH | GRTH | EXEQ | AND | OR )\n alt_13 = 7\n case look_13 = @input.peek( 1 )\n when LSTHE then alt_13 = 1\n when GRTHE then alt_13 = 2\n when LSTH then alt_13 = 3\n when GRTH then alt_13 = 4\n when EXEQ then alt_13 = 5\n when AND then alt_13 = 6\n when OR then alt_13 = 7\n else\n raise NoViableAlternative( \"\", 13, 0 )\n end\n case alt_13\n when 1\n # at line 51:14: LSTHE\n match( LSTHE, TOKENS_FOLLOWING_LSTHE_IN_comp_492 )\n # --> action\n agc_2('<=')\n # <-- action\n\n when 2\n # at line 51:34: GRTHE\n match( GRTHE, TOKENS_FOLLOWING_GRTHE_IN_comp_496 )\n # --> action\n agc_2('>=')\n # <-- action\n\n when 3\n # at line 51:53: LSTH\n match( LSTH, TOKENS_FOLLOWING_LSTH_IN_comp_499 )\n # --> action\n agc_2('<')\n # <-- action\n\n when 4\n # at line 51:70: GRTH\n match( GRTH, TOKENS_FOLLOWING_GRTH_IN_comp_502 )\n # --> action\n agc_2('>')\n # <-- action\n\n when 5\n # at line 51:87: EXEQ\n match( EXEQ, TOKENS_FOLLOWING_EXEQ_IN_comp_505 )\n # --> action\n agc_2('==')\n # <-- action\n\n when 6\n # at line 51:105: AND\n match( AND, TOKENS_FOLLOWING_AND_IN_comp_508 )\n # --> action\n agc_2('&')\n # <-- action\n\n when 7\n # at line 51:121: OR\n match( OR, TOKENS_FOLLOWING_OR_IN_comp_511 )\n # --> action\n agc_2('|')\n # <-- action\n\n end\n\n # at line 52:11: ( expr )\n # at line 52:12: expr\n @state.following.push( TOKENS_FOLLOWING_expr_IN_comp_527 )\n expr\n @state.following.pop\n # --> action\n agc_3(['<','>','>=','<=','==','&','|'])\n # <-- action\n\n\n else\n break # out of loop for decision 14\n end\n end # loop for decision 14\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 12 )\n\n end\n \n return \n end",
"def parametros_tipos\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 55 )\n\n\n return_value = ParametrosTiposReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __TIPO296__ = nil\n __COMA298__ = nil\n __TIPO299__ = nil\n valor297 = nil\n valor300 = nil\n\n\n tree_for_TIPO296 = nil\n tree_for_COMA298 = nil\n tree_for_TIPO299 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 251:4: TIPO valor ( COMA TIPO valor )*\n __TIPO296__ = match( TIPO, TOKENS_FOLLOWING_TIPO_IN_parametros_tipos_1244 )\n if @state.backtracking == 0\n tree_for_TIPO296 = @adaptor.create_with_payload( __TIPO296__ )\n @adaptor.add_child( root_0, tree_for_TIPO296 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_parametros_tipos_1246 )\n valor297 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor297.tree )\n end\n\n # at line 251:15: ( COMA TIPO valor )*\n while true # decision 40\n alt_40 = 2\n look_40_0 = @input.peek( 1 )\n\n if ( look_40_0 == COMA )\n alt_40 = 1\n\n end\n case alt_40\n when 1\n # at line 251:16: COMA TIPO valor\n __COMA298__ = match( COMA, TOKENS_FOLLOWING_COMA_IN_parametros_tipos_1249 )\n if @state.backtracking == 0\n tree_for_COMA298 = @adaptor.create_with_payload( __COMA298__ )\n @adaptor.add_child( root_0, tree_for_COMA298 )\n\n end\n\n __TIPO299__ = match( TIPO, TOKENS_FOLLOWING_TIPO_IN_parametros_tipos_1251 )\n if @state.backtracking == 0\n tree_for_TIPO299 = @adaptor.create_with_payload( __TIPO299__ )\n @adaptor.add_child( root_0, tree_for_TIPO299 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_parametros_tipos_1253 )\n valor300 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor300.tree )\n end\n\n\n else\n break # out of loop for decision 40\n end\n end # loop for decision 40\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 55 )\n\n\n end\n\n return return_value\n end",
"def exp_arreglo\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 49 )\n\n\n return_value = ExpArregloReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __COMA267__ = nil\n valor266 = nil\n valor268 = nil\n\n\n tree_for_COMA267 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 228:4: valor ( COMA valor )*\n @state.following.push( TOKENS_FOLLOWING_valor_IN_exp_arreglo_1127 )\n valor266 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor266.tree )\n end\n\n # at line 228:10: ( COMA valor )*\n while true # decision 37\n alt_37 = 2\n look_37_0 = @input.peek( 1 )\n\n if ( look_37_0 == COMA )\n alt_37 = 1\n\n end\n case alt_37\n when 1\n # at line 228:11: COMA valor\n __COMA267__ = match( COMA, TOKENS_FOLLOWING_COMA_IN_exp_arreglo_1130 )\n if @state.backtracking == 0\n tree_for_COMA267 = @adaptor.create_with_payload( __COMA267__ )\n @adaptor.add_child( root_0, tree_for_COMA267 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_exp_arreglo_1132 )\n valor268 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor268.tree )\n end\n\n\n else\n break # out of loop for decision 37\n end\n end # loop for decision 37\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 49 )\n\n\n end\n\n return return_value\n end",
"def k_matematica!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n\n\n type = K_MATEMATICA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 437:3: ( 'sin' | 'cos' | 'cot' | 'tan' | 'asin' | 'acos' | 'atan' | 'log' | 'loge' | 'logn' | 'fac' | 'avg' | 'abs' | 'fraction' | 'max' | 'min' | 'count' | 'res' )\n # at line 437:3: ( 'sin' | 'cos' | 'cot' | 'tan' | 'asin' | 'acos' | 'atan' | 'log' | 'loge' | 'logn' | 'fac' | 'avg' | 'abs' | 'fraction' | 'max' | 'min' | 'count' | 'res' )\n alt_13 = 18\n case look_13 = @input.peek( 1 )\n when 0x73 then alt_13 = 1\n when 0x63 then look_13_2 = @input.peek( 2 )\n\n if ( look_13_2 == 0x6f )\n case look_13 = @input.peek( 3 )\n when 0x73 then alt_13 = 2\n when 0x74 then alt_13 = 3\n when 0x75 then alt_13 = 17\n else\n raise NoViableAlternative( \"\", 13, 9 )\n\n end\n else\n raise NoViableAlternative( \"\", 13, 2 )\n\n end\n when 0x74 then alt_13 = 4\n when 0x61 then case look_13 = @input.peek( 2 )\n when 0x73 then alt_13 = 5\n when 0x63 then alt_13 = 6\n when 0x74 then alt_13 = 7\n when 0x76 then alt_13 = 12\n when 0x62 then alt_13 = 13\n else\n raise NoViableAlternative( \"\", 13, 4 )\n\n end\n when 0x6c then look_13_5 = @input.peek( 2 )\n\n if ( look_13_5 == 0x6f )\n look_13_15 = @input.peek( 3 )\n\n if ( look_13_15 == 0x67 )\n case look_13 = @input.peek( 4 )\n when 0x65 then alt_13 = 9\n when 0x6e then alt_13 = 10\n else\n alt_13 = 8\n\n end\n else\n raise NoViableAlternative( \"\", 13, 15 )\n\n end\n else\n raise NoViableAlternative( \"\", 13, 5 )\n\n end\n when 0x66 then look_13_6 = @input.peek( 2 )\n\n if ( look_13_6 == 0x61 )\n alt_13 = 11\n elsif ( look_13_6 == 0x72 )\n alt_13 = 14\n else\n raise NoViableAlternative( \"\", 13, 6 )\n\n end\n when 0x6d then look_13_7 = @input.peek( 2 )\n\n if ( look_13_7 == 0x61 )\n alt_13 = 15\n elsif ( look_13_7 == 0x69 )\n alt_13 = 16\n else\n raise NoViableAlternative( \"\", 13, 7 )\n\n end\n when 0x72 then alt_13 = 18\n else\n raise NoViableAlternative( \"\", 13, 0 )\n\n end\n case alt_13\n when 1\n # at line 437:4: 'sin'\n match( \"sin\" )\n\n\n when 2\n # at line 437:10: 'cos'\n match( \"cos\" )\n\n\n when 3\n # at line 437:16: 'cot'\n match( \"cot\" )\n\n\n when 4\n # at line 437:22: 'tan'\n match( \"tan\" )\n\n\n when 5\n # at line 437:28: 'asin'\n match( \"asin\" )\n\n\n when 6\n # at line 437:35: 'acos'\n match( \"acos\" )\n\n\n when 7\n # at line 437:42: 'atan'\n match( \"atan\" )\n\n\n when 8\n # at line 437:49: 'log'\n match( \"log\" )\n\n\n when 9\n # at line 437:55: 'loge'\n match( \"loge\" )\n\n\n when 10\n # at line 437:62: 'logn'\n match( \"logn\" )\n\n\n when 11\n # at line 437:69: 'fac'\n match( \"fac\" )\n\n\n when 12\n # at line 437:75: 'avg'\n match( \"avg\" )\n\n\n when 13\n # at line 437:81: 'abs'\n match( \"abs\" )\n\n\n when 14\n # at line 437:87: 'fraction'\n match( \"fraction\" )\n\n\n when 15\n # at line 437:98: 'max'\n match( \"max\" )\n\n\n when 16\n # at line 437:104: 'min'\n match( \"min\" )\n\n\n when 17\n # at line 437:110: 'count'\n match( \"count\" )\n\n\n when 18\n # at line 437:118: 'res'\n match( \"res\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n\n end",
"def print_rules\n\t\tqueue = [@goal]\n\t\tvisited = []\n\t\tcount = 0\n\t\trule_string = \"\"\n\t\tterm = non_terminals\n\n\t\tuntil queue.empty?\n\t\t\tprod = queue.pop\n\t\t\tvisited.push prod\n\n\t\t\t@production_rules[prod].each do |rule|\n\t\t\t\tcount += 1\n\n\t\t\t\trule_string += \"(#{count}) #{prod} -> #{rule.join(\" \")}\\n\"\n\t\t\t\trule.each { |r| queue.push r if term.include? r and not visited.include? r }\n\t\t\tend\n\t\t\tqueue.uniq!\n\t\tend\n\t\trule_string.strip!\n\t\treturn rule_string\n\tend",
"def to_clp\n val = self.gsub(/[\"]/,\"\\\"\\\"\")\n #val = val.gsub(/[~]/,\"\")\n end",
"def generateAndPrintConcordance(inputLines)\n # Generate Concordance\n words = Hash.new\n index = 0\n # read each line\n for i in 0...inputLines.size\n # read each sentence\n inputLines[i].to_s.split(/\\.|\\?|\\!/).each do |sentence|\n index +=1\n # read each word\n sentence.split(/\\W|\\s/).each do |word|\n # per output sample requirement only adds words\n if word != \"\"\n # per output sample requirement makes all words lower case\n word=word.downcase\n # add words to a hash table as key\n words[word]=words[word]||[0,[]]\n # add word number of occurrences\n words[word][0]+=1\n # add the sentence number where the word occurs\n words[word][1]<<index\n end\n end\n end\n end\n # per output sample requirement sorts hash table key alphabetically\n words = words.sort_by { |key| key }.to_h\n # Print Concordance\n words.each_pair {|key,v| puts \"#{key}: {#{v[0]}:#{v[1].to_s.delete('[]')}}\"}\nend",
"def synpred231_Instructions\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 287 )\n\n # at line 344:24: ~ EOL\n if @input.peek(1) == WS || @input.peek( 1 ).between?( DIGIT, T__59 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 287 )\n\n end",
"def dclr\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 10 )\n a = nil\n b = nil\n\n begin\n # at line 48:11: b= type a= ID ( '=' comp )?\n @state.following.push( TOKENS_FOLLOWING_type_IN_dclr_423 )\n b = type\n @state.following.pop\n a = match( ID, TOKENS_FOLLOWING_ID_IN_dclr_427 )\n # --> action\n agc_1(a,b,true)\n # <-- action\n # at line 48:41: ( '=' comp )?\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == EQLS )\n alt_12 = 1\n end\n case alt_12\n when 1\n # at line 48:42: '=' comp\n match( EQLS, TOKENS_FOLLOWING_EQLS_IN_dclr_432 )\n # --> action\n agc_2('=')\n # <-- action\n @state.following.push( TOKENS_FOLLOWING_comp_IN_dclr_437 )\n comp\n @state.following.pop\n # --> action\n agc_3('=')\n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 10 )\n\n end\n \n return \n end",
"def test_CC_alternative_products\n# CC -!- ALTERNATIVE PRODUCTS:\n# CC Event=Event(, Event)*; Named isoforms=Number_of_isoforms;\n# (CC Comment=Free_text;)?\n# (CC Name=Isoform_name;( Synonyms=Synonym(, Synonym)*;)?\n# CC IsoId=Isoform_identifier(, Isoform_identifer)*;\n# CC Sequence=(Displayed|External|Not described|Feature_identifier(, Feature_identifier)*);\n# (CC Note=Free_text;)?)+\n# Note: Variable values are represented in italics. Perl-style multipliers indicate whether a pattern (as delimited by parentheses) is optional (?), may occur 0 or more times (*), or 1 or more times (+). Alternative values are separated by a pipe symbol (|).\n\n data = \"CC -!- ALTERNATIVE PRODUCTS:\nCC Event=Alternative splicing, Alternative initiation; Named isoforms=3;\nCC Comment=Isoform 1 and isoform 2 arise due to the use of two\nCC alternative first exons joined to a common exon 2 at the same\nCC acceptor site but in different reading frames, resulting in two\nCC completely different isoforms;\nCC Name=1; Synonyms=p16INK4a;\nCC IsoId=O77617-1; Sequence=Displayed;\nCC Name=3;\nCC IsoId=O77617-2; Sequence=VSP_004099;\nCC Note=Produced by alternative initiation at Met-35 of isoform 1;\nCC Name=2; Synonyms=p19ARF;\nCC IsoId=O77618-1; Sequence=External;\nFT VAR_SEQ 1 34 Missing (in isoform 3).\nFT /FTId=VSP_004099.\"\n sp = SPTR.new(data)\n assert_equal({\"Comment\" => \"Isoform 1 and isoform 2 arise due to the use of two alternative first exons joined to a common exon 2 at the same acceptor site but in different reading frames, resulting in two completely different isoforms\", \n \"Named isoforms\" => \"3\",\n \"Variants\" => [{\"IsoId\" => [\"O77617-1\"], \n \"Name\" => \"1\",\n \"Synonyms\" => [\"p16INK4a\"],\n \"Sequence\" => [\"Displayed\"]},\n {\"IsoId\" => [\"O77617-2\"], \n \"Name\" => \"3\",\n \"Synonyms\" => [],\n \"Sequence\" => [\"VSP_004099\"]},\n {\"IsoId\" => [\"O77618-1\"],\n \"Name\" => \"2\",\n \"Synonyms\" => [\"p19ARF\"],\n \"Sequence\" => [\"External\"]}],\n \"Event\" => [\"Alternative splicing\", \"Alternative initiation\"]},\n sp.cc(\"ALTERNATIVE PRODUCTS\"))\n assert_equal([{\"From\" => 1, \n \"To\" => 34,\n \"Description\"=>\"Missing (in isoform 3).\",\n \"FTId\" => \"VSP_004099\",\n \"diff\" => [\"\", nil],\n \"original\"=> [\"VAR_SEQ\", \"1\", \"34\", \n \"Missing (in isoform 3).\", \"/FTId=VSP_004099.\"]}],\n sp.ft(\"VAR_SEQ\"))\n end"
] | [
"0.57956314",
"0.54493576",
"0.5425205",
"0.5412952",
"0.5344363",
"0.52897114",
"0.5277667",
"0.5216268",
"0.5154754",
"0.5138244",
"0.5109283",
"0.5085626",
"0.50761646",
"0.5060717",
"0.5031964",
"0.5017147",
"0.49444252",
"0.49179173",
"0.4911493",
"0.48964894",
"0.48754942",
"0.4860348",
"0.4847871",
"0.48474824",
"0.48320502",
"0.48202837",
"0.4816069",
"0.48128167",
"0.48060885",
"0.47791862",
"0.47768345",
"0.47697434",
"0.47568882",
"0.47551093",
"0.4753016",
"0.4749082",
"0.47476572",
"0.47473362",
"0.47459137",
"0.47186324",
"0.47043836",
"0.46980977",
"0.46960914",
"0.46958357",
"0.46837068",
"0.4677799",
"0.46766013",
"0.46741578",
"0.46653578",
"0.46650133",
"0.46281663",
"0.4617383",
"0.4614154",
"0.46034116",
"0.4580894",
"0.45806187",
"0.45730606",
"0.45707557",
"0.4569372",
"0.456599",
"0.45553908",
"0.4554237",
"0.4547764",
"0.45436856",
"0.45400816",
"0.45375708",
"0.45370692",
"0.45288223",
"0.45131987",
"0.45015198",
"0.44977334",
"0.44933313",
"0.4491011",
"0.44868642",
"0.44863325",
"0.44835114",
"0.44799832",
"0.4471137",
"0.44700536",
"0.44673946",
"0.44600046",
"0.44599247",
"0.44553095",
"0.44508862",
"0.4447868",
"0.4445432",
"0.4437917",
"0.44339126",
"0.44322914",
"0.44234124",
"0.44171152",
"0.4415752",
"0.44052583",
"0.4402728",
"0.44025818",
"0.44023722",
"0.44013372",
"0.44003254",
"0.43994746",
"0.43988693"
] | 0.60784334 | 0 |
public wrapper for the various satisfiability solvers and techniques | def isSatisfiable?()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve\n end",
"def solve!\n end",
"def hook_solution?(a); end",
"def solver_for(_actuals, ctx)\n # Important: every `solver_for` call will result in a distinct Context.\n DuckFiber.new(-> { ctx.succeeded! })\n end",
"def solve\n BruteForceSolver.new(self).solve\n end",
"def solve\n delegatee.solve\n end",
"def process_solutions\n raise NotImplementedError, 'You must implement this'\n end",
"def solve!\n solve\n self\n end",
"def solve(x0)\n raise RuntimeError, \"This method is not implemented!\"\n end",
"def alternatives; end",
"def solved(ans)\n\n end",
"def solver discount\n FiniteMDP::Solver.new(FiniteMDP::HashModel.new(self.to_hash), discount)\n end",
"def prepare_preferred_algorithms!; end",
"def achieve(ctx)\n relation.solver_for(actuals, ctx)\n end",
"def solved_check\n ->() { true }\n end",
"def test_DP_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1995, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2623, p.dynamic)\n\n\n\n end",
"def test_HEURISTIC_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1979, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2516, p.heuristic)\n\n\n\n end",
"def solver\n if checkrule(0)\n puts \"Success!!!\"\n else\n puts \"No solution found\"\n end\n end",
"def calculate_solution\n Solve.it!(\n GraphBuilder.graph_from_cache(@cache, @options),\n resolver.constraints\n )\n end",
"def solution\n solve unless solved?\n @solution\n end",
"def solved?\n end",
"def solvable?\n find_solution > 0\n end",
"def set_solution\r\n @solutions = true\r\n end",
"def resolveEZCLAP;\r\n raise \"METHOD HAS NOT BEEN IMPLEMENTED.\";\r\n end",
"def compute_solver_engine(berksfile)\n if berksfile.required_solver\n begin\n Solve.engine = berksfile.required_solver\n rescue Solve::Errors::InvalidEngine => e\n raise ArgumentError, e.message\n end\n elsif berksfile.preferred_solver\n begin\n Solve.engine = berksfile.preferred_solver\n rescue\n # We should log this, but Berkshelf.log.warn and Berkshelf.formatter.warn\n # both seem inappropriate here.\n # \" Preferred solver ':#{berksfile.preferred_solver}' unavailable\"\n end\n end\n # We should log this, but Berkshelf.log.info and Berkshelf.formatter.msg\n # both seem inappropriate here.\n # \" Selected dependency solver engine ':#{Solve.engine}'\"\n end",
"def solve!\n validate!\n\n @logger.info(\"Running Phase I\")\n PhaseIRunner.new(alpha_preferences, beta_preferences, logger: @logger).run\n\n build_solution\n end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def solve(vector)\n @b = vector\n decompose if @lu_m.nil?\n eval_z\n eval_answer\n end",
"def solutions\n return nil unless self.result\n result = RDF::URI(self.result)\n\n # Use alternate results for RDF 1.1\n file_11 = result.to_s.\n sub(BASE_URI_10, BASE_DIRECTORY).\n sub(BASE_URI_11, BASE_DIRECTORY).\n sub(/\\.(\\w+)$/, '_11.\\1')\n result = RDF::URI(file_11) if File.exist?(file_11)\n\n case form\n when :select, :ask\n case File.extname(result.path)\n when '.srx'\n SPARQL::Client.parse_xml_bindings(RDF::Util::File.open_file(result, &:read))\n when '.srj'\n SPARQL::Client.parse_json_bindings(RDF::Util::File.open_file(result, &:read))\n when '.csv'\n SPARQL::Client.parse_csv_bindings(RDF::Util::File.open_file(result, &:read))\n when '.tsv'\n SPARQL::Client.parse_tsv_bindings(RDF::Util::File.open_file(result, &:read))\n else\n if form == :select\n parse_rdf_bindings(RDF::Graph.load(result))\n else\n RDF::Graph.load(result).objects.detect {|o| o.literal?}\n end\n end\n when :describe, :create, :construct\n RDF::Repository.load(result, base_uri: result, format: :ttl)\n end\n end",
"def initialize(solution)\n @solution = solution\n end",
"def check_for_requirements; end",
"def requirements=(_arg0); end",
"def requirements=(_arg0); end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume\n end",
"def test_check_solution\n Dir.mktmpdir('testbase') do |testbase|\n tpkg = Tpkg.new(:base => testbase, :sources => @pkgfiles)\n\n solution = nil\n requirements = [{:name => 'c', :minimum_version => '1.3', :type => :tpkg}, {:name => 'd', :minimum_version => '1.3', :type => :tpkg}]\n packages = {:tpkg => {}, :native => {}}\n requirements.each do |req|\n packages[req[:type]][req[:name]] = tpkg.available_packages_that_meet_requirement(req)\n end\n core_packages = ['c']\n number_of_possible_solutions_checked = 0\n\n result = nil\n # Check a valid solution\n solution = {:pkgs => packages[:tpkg].values.flatten}\n assert_nothing_raised { result = tpkg.check_solution(solution, requirements, packages, core_packages, number_of_possible_solutions_checked) }\n assert(result.has_key?(:solution))\n assert_equal(packages[:tpkg].values.flatten, result[:solution])\n\n # Check an invalid solution\n xpkgfile = make_package(:output_directory => @tempoutdir, :change => { 'name' => 'x' }, :dependencies => {'y' => {}}, :remove => ['operatingsystem', 'architecture'])\n metadata = Tpkg::metadata_from_package(xpkgfile)\n xpkg = {:metadata => metadata}\n solution[:pkgs] << xpkg\n assert_nothing_raised { result = tpkg.check_solution(solution, requirements, packages, core_packages, number_of_possible_solutions_checked) }\n assert(!result.has_key?(:solution))\n assert(result.has_key?(:number_of_possible_solutions_checked))\n assert(result[:number_of_possible_solutions_checked] > 0)\n FileUtils.rm_f(xpkgfile)\n end\n end",
"def valid_solution2 co_support\n # Randomgenerator\n rnd = Random.new\n\n # current plan to slove\n plan = SemesterPlan.find(params[:id])\n\n # prioritys for slots and user\n # sorts slots by user availability\n # sorts user by slot availibiluity\n slot_priority_origin = plan.get_slot_priority\n user_priority_origin = plan.get_user_priority\n\n\n # empty slots to empty solution_slots at each itteration begin\n empty_slots = []\n if co_support\n empty_slots = eval(plan.solution)\n else\n 20.times do |n|\n empty_slots << {index: n, user: nil, co: nil, slot: nil}\n end\n end\n\n # break variable\n done = false\n\n # availabilty which will be max accepted\n if co_support\n availability = 2\n else\n availability = 1\n end\n\n # saves itterations\n i = 0\n\n # iteration border for availibility to increase to 2\n i_av_2 = 400\n\n # iteration_border for interrupt\n i_max = 800\n\n # saves the solution\n solution_slots = []\n\n # until all slots are valid taken\n start = Time.now\n begin\n # counter for open slots\n slots = 20\n\n # clear solution\n solution_slots = empty_slots.clone\n\n # clone prioritys and shift-plans\n slot_priority = slot_priority_origin.clone\n user_priority = user_priority_origin.clone\n shifts = User.supporter_amount_of_shifts(20, User.where(planable: true, inactive: false))\n\n # set break variable to false\n done = false\n\n # repeat until plan invalid or complete plan valid\n while slot_priority.length != 0 && !done\n\n # random wheel for all slot prioritys\n roulette = calc_roulette slot_priority\n\n\n # random float\n random = rnd.rand\n slot = nil\n\n # take random slot\n roulette.each do |roul|\n if roul[:value] > random\n slot = slot_priority[roul[:index]]\n break\n end\n end\n\n # saves the found user\n found_user = nil\n # return all user with given availbility in current slot\n users = TimeSlot.find(slot[:slot]).get_users availability\n\n # if at least 1 user found\n if users.length != 0\n\n # break conditions\n found = false\n nothing = true\n\n # tests all slots\n user_priority.each do |pr_user|\n if !found\n\n # tests all available users\n users.each do |slot_user|\n\n # if user is found and in earlier iterations no user was found for this slot\n if (pr_user[:user] == slot_user && !found) &&(co_support && solution_slots.detect {|s| s[:index] == slot[:index]}[:user] !=slot_user || !co_support)\n\n\n # saves user for slot\n if co_support\n solution_slots.detect {|s| s[:index] == slot[:index]}[:co] = slot_user\n solution_slots.detect {|s| s[:index] == slot[:index]}[:slot] = slot[:slot]\n else\n solution_slots.detect {|s| s[:index] == slot[:index]}[:user] = slot_user\n solution_slots.detect {|s| s[:index] == slot[:index]}[:slot] = slot[:slot]\n end\n\n\n\n # set\n found = true\n found_user = pr_user\n\n # update shifts\n shifts = User.reduce_shifts found_user[:user], shifts\n\n # remove user from slot_priority and delete user from user_priority\n # if all shifts are given\n shifts.each do |s|\n if s[:user] == found_user[:user]\n if s[:shifts] == 0\n slot_priority = SemesterPlan.kill_user_in_slot_priority found_user[:user], slot_priority\n user_priority.delete(found_user)\n end\n end\n end\n\n # delete slot and sort\n slot_priority.delete(slot)\n slot_priority.sort_by! {|item|\n item[:priority] * -1\n }\n # removes slot from user_priority and sort\n user_priority = SemesterPlan.kill_slot_in_user_priority slot[:slot], user_priority\n user_priority.sort_by! {|item|\n item[:priority] * -1\n }\n\n # decrement slots and set nothing to false for next iteration\n slots -= 1\n nothing = false\n break\n end\n end\n end\n end\n\n # break if no slot was found\n if nothing == true\n done = true\n end\n # break if no user was found\n else\n done = true\n end\n end\n # break if iteration max is reached\n if Time.now - start > 10\n done = true\n\n # increment aǘailbility\n elsif Time.now - start > 2\n if availability != 2\n availability = 2\n else\n #availability = 1\n end\n end\n\n # increment iteration\n i += 1\n end while slots > 0 && Time.now - start <=10\n\n # update solution and return it additionally (r)\n solution_slots\n\n end",
"def solve(type = HumanSolver)\n type.solve(@input)\n end",
"def solve\n init_signature\n compute_hashes\n compute_signature\n recommendations\n end",
"def solve\n loop { break if !shift }\n return @solutions\n end",
"def solution(&lambda)\n self.solution_lambda = lambda\n end",
"def solve(arg1, arg2)\n solver = subject.solver_for([arg1, arg2], ctx)\n solver.resume(ctx)\n end",
"def solve(puzzle)\n raise NotImplementedError, \"Subclass must implement this method.\"\n end",
"def run_efficient_frontier(real_risk_free_rate)\n\n # Grab the names and number of securities:\n names = @con.eval(\"names(Data)\").to_ruby\n no_of_securities = names.size\n\n constraints_command = %q{Constraints <- c(\"LongOnly\")}\n # You can't do \"LongOnly\", and specify weights. Have to do a minW[1:18]=0.0\n # %q{<- c(\"minW[1:nAssets]=0\", \"maxsumW[1:2Assets]=13.63\")}\n # \"maxW[1:18]=0.9\"\n # \"Constraints <- c('maxW[1:#{no_of_securities}] = rep( 0.9, times = #{no_of_securities})')\"\n # Constraints = \"minW=c(0.74,0,0,0)\" #### this is a long -only\n\n frontier_points = 20\n\n @con.eval(\"forced_return_data = forec(Data, implied_returns);#{constraints_command};Spec = portfolioSpec();setRiskFreeRate(Spec) = #{real_risk_free_rate};setEstimator(Spec) = 'covMcdEstimator';setNFrontierPoints(Spec) = #{frontier_points};frontier = portfolioFrontier(forced_return_data, Spec, Constraints);weights = frontier@portfolio@portfolio[['weights']]\")\n weights = get_r_variable(\"weights\")\n\n if weights.respond_to?(:row_vectors)\n # For some reason, you sometimes get a matrix, and others just a plain array\n vectors = weights.row_vectors\n else\n vectors = [weights]\n end\n\n # Grab the list of variable names to make the return thing into a useful\n # hash. Do it from the R variable in case the order changed for some reason\n # from the ruby ones.\n vectors.map! {|vector| vector.to_a}\n portfolio_weights = []\n vectors.each do |weights_set|\n hash = {}\n weights_set.each_with_index do |weight, index|\n hash[names[index].upcase.to_sym] = weight\n end\n portfolio_weights << hash\n end\n\n return portfolio_weights\n end",
"def solution1(input)\n return \"Not implemented!\"\nend",
"def solve!(type = HumanSolver)\n @input = type.solve(@input)\n end",
"def initialize\n super\n @equation_solver_class = SolitonProject::KDeVEquationSolver\n end",
"def eurocentric_institutions!\n warn \"Experimental code #{__method__}. Do not enable in release. #{__FILE__}:#{__LINE__}\"\n\n # Nerf dev pushing just slightly, to prevent AI Ming/Korea spawning Renaissance really early\n # 5->4\n #\n # Even more experimentally, just turn it off lol\n soft_patch_defines_lua!(\"fun_and_balance_ai_aggressiveness\",\n [\"NCountry.INSTITUTION_BONUS_FROM_IMP_DEVELOPMENT\", 5, 0],\n )\n\n # Free institutions for East Africa are not helping\n # Remove it from tier-1\n # Frontload global bonuses instead, so it's still useful\n # Tier 2-3 same as before\n patch_mod_file!(\"common/great_projects/01_monuments.txt\") do |node|\n node[\"harar_jugol\"][\"tier_1\"][\"province_modifiers\"] = PropertyList[]\n node[\"harar_jugol\"][\"tier_1\"][\"country_modifiers\"] = PropertyList[\n \"stability_cost_modifier\", -0.1,\n \"prestige_per_development_from_conversion\", 0.2,\n ]\n end\n\n # Korean Triptaka breaks the game too\n patch_mod_file!(\"common/event_modifiers/00_event_modifiers.txt\") do |node|\n node[\"tripitaka_koreana\"].delete! \"institution_growth\"\n end\n\n # Now core institution list\n patch_mod_file!(\"common/institutions/00_Core.txt\") do |node|\n factors = {}\n node.each do |name, institution|\n institution[\"embracement_speed\"].each do |_, mod|\n tooltip = mod[\"custom_trigger_tooltip\"]&.[](\"tooltip\")\n factors[[name, tooltip || rand]] = mod # if tooltip\n end\n end\n\n # First, slow down all passive spread\n [\n [\"feudalism\", \"FRIENDLY_NEIGHBOR_OR_COAST_PROVINCE_HAS_EMBRACED\"],\n [\"feudalism\", \"NEIGHBOR_NOT_OWNED_IS_FEUDAL\"],\n [\"feudalism\", \"tooltip_feudalism_embraced\"],\n\n [\"renaissance\", \"tooltip_any_friendly_coast_border_province_has_embraced_renaissance\"],\n [\"renaissance\", \"tooltip_any_neighbor_has_embraced_renaissance\"],\n [\"renaissance\", \"tooltip_renaissance_embraced\"],\n\n [\"new_world_i\", \"tooltip_any_friendly_coast_border_province_has_embraced_colonialism\"],\n [\"new_world_i\", \"tooltip_neighbor_port_province_new_world\"],\n [\"new_world_i\", \"tooltip_new_world_i_embraced\"],\n\n [\"printing_press\", \"tooltip_any_friendly_coast_border_province_has_embraced_printing_press\"],\n [\"printing_press\", \"tooltip_any_neighbor_has_embraced_printing_press\"],\n [\"printing_press\", \"tooltip_printing_press_embraced\"],\n\n [\"global_trade\", \"tooltip_neighbor_non_port_province_global_trade\"],\n [\"global_trade\", \"tooltip_neighbor_port_province_global_trade\"],\n [\"global_trade\", \"tooltip_global_trade_embraced\"],\n [\"global_trade\", \"tooltip_global_trade_embraced_other_continent\"],\n\n [\"manufactories\", \"tooltip_any_friendly_coast_border_province_has_embraced_manufactories\"],\n [\"manufactories\", \"tooltip_any_neighbor_has_embraced_manufactories\"],\n [\"manufactories\", \"tooltip_manufactories_embraced\"],\n [\"manufactories\", \"tooltip_manufactories_embraced_other_continent\"],\n\n [\"enlightenment\", \"tooltip_any_friendly_coast_border_province_has_embraced_enlightenment\"],\n [\"enlightenment\", \"tooltip_any_neighbor_has_embraced_enlightenment\"],\n [\"enlightenment\", \"tooltip_enlightenment_embraced\"],\n [\"enlightenment\", \"tooltip_enlightenment_embraced_other_continent\"],\n\n [\"industrialization\", \"tooltip_any_friendly_coast_border_province_has_embraced_industrialization\"],\n [\"industrialization\", \"tooltip_any_neighbor_has_embraced_industrialization\"],\n [\"industrialization\", \"tooltip_industrialization_embraced\"],\n [\"industrialization\", \"tooltip_industrialization_embraced_other_continent\"],\n ].each do |key|\n factors[key][\"factor\"] *= 0.5\n end\n\n # Colonialism - can only start in Europe\n node[\"new_world_i\"][\"can_start\"].add! Property[\"continent\", \"europe\"]\n\n # Gate every institution behind previous one, this prevents easy catch-up\n node[\"new_world_i\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"renaissance\"]]\n node[\"printing_press\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"new_world_i\"]]\n node[\"global_trade\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"printing_press\"]]\n node[\"manufactories\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"global_trade\"]]\n node[\"enlightenment\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"manufactories\"]]\n node[\"industrialization\"][\"can_embrace\"] = PropertyList[\"owner\", PropertyList[\"has_institution\", \"enlightenment\"]]\n end\n end",
"def strategy; end",
"def run\n solve\n { price: @best_price, config: @best_config }\n end",
"def satisfiable?\n raise NotImplementedError, 'Subclasses must implement a #satisfiable? method.'\n end",
"def main\n \n # make Resuspended Library items\n operations.make\n \n # get quantities before resuspending\n operations.each { |op| op.temporary[:pmole] = op.input(POOL).item.get(:pmole) }\n no_pmole=operations.select { |op| op.temporary[:pmole].nil? }\n if(no_pmole.any?)\n data = show {\n title \"Verify Lyopholized #{OLIGO_POOL} Quantities\"\n note \"The following libraries have no parameters specified. Please enter manually:\"\n table no_pmole.start_table\n .input_item(POOL)\n .get(:pmole, type: 'number', heading: \"Quantity (pmole)\", default: DEFAULT_PMOLE) \n .end_table\n }\n end\n operations.each { |op| \n op.input(POOL).item.associate :pmole, op.temporary[:pmole].to_f \n op.output(OUT_HIGH).item.associate :concentration, TARGET_CONC_NG_PER_UL\n op.output(OUT_LOW).item.associate :concentration, LOW_CONC_NG_PER_UL\n }\n \n # get sublib parameters\n operations.each { |op|\n min_tot=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).map {|x| x.to_f}.sum\n max_tot=op.input(POOL).item.sample.properties.fetch(MAX_LENGTH).map {|x| x.to_f}.sum\n variants_tot=op.input(POOL).item.sample.properties.fetch(VARIANTS).map {|x| x.to_f}.sum\n num_sublibs=op.input(POOL).item.sample.properties.fetch(MIN_LENGTH).length\n op.temporary[:variants]=variants_tot\n op.temporary[:length]=(0.5*(max_tot+min_tot)/num_sublibs).round\n op.temporary[:sublibs]=num_sublibs\n }\n \n # show user the info for the library BEFORE resuspending\n show {\n title \"Check #{OLIGO_POOL} Parameters before resuspension\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"mean length (nt)\") { |op| op.temporary[:length] }\n .custom_column(heading: \"variants\") { |op| op.temporary[:variants] }\n .custom_column(heading: \"number of sublibraries\") { |op| op.temporary[:sublibs] }\n .custom_column(heading: \"quantity (pmole)\") { |op| {content: op.temporary[:pmole], check: true} }\n .end_table\n warning \"Quantity (pmole) determines the resuspension volume!\"\n }\n \n # resuspend\n show {\n title \"Resuspend Lyopholized #{OLIGO_POOL}s\"\n check \"Spin down all lyopholized oligo pools at #{SPIN[:qty]} #{SPIN[:units]} for #{SPIN_TIME[:qty]} #{SPIN_TIME[:units]}\"\n note \"Add #{WATER[:name]} from a <b>NEW</b> aliquot directly to the lyopholized oligo pool, according to the following:\"\n table operations.start_table\n .input_item(POOL)\n .custom_column(heading: \"Oligo Pool name\") { |op| op.input(POOL).item.sample.name }\n .custom_column(heading: \"Oligo Library ID\") { |op| op.input(POOL).item.sample.properties.fetch(\"Oligo Library ID\") }\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| \n (op.input(POOL).item.get(:pmole).to_f*op.temporary[:length]*DNA_NG_PER_NT_PER_PICOMOLE/TARGET_CONC_NG_PER_UL).round(2) }\n .output_item(OUT_HIGH) \n .end_table\n check \"Vortex well and spin down\"\n check \"Leave on bench for #{WAIT[:qty]} #{WAIT[:units]}\"\n check \"Vortex well and spin down\"\n check \"Relabel original tubes, without covering any manufacturer information, according to the final column of the table (above).\"\n }\n \n # dilute\n fac=(TARGET_CONC_NG_PER_UL.to_f/LOW_CONC_NG_PER_UL)-1\n lib_volume=(DILUTION_VOL[:qty].to_f/fac).round(2)\n show {\n title \"Dilute Resuspended #{OLIGO_POOL}s\"\n check \"Label #{operations.length} #{TUBE}s: #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence}\"\n note \"Add #{WATER[:name]} and resuspended library volumes according to the following:\"\n table operations.start_table\n .output_item(OUT_LOW)\n .custom_column(heading: \"#{WATER[:name]} (#{WATER[:units]})\") { |op| {content: DILUTION_VOL[:qty], check: true} }\n .custom_column(heading: \"Resuspended Oligo Pool\") { |op| \"#{op.output(OUT_HIGH).item}\" }\n .custom_column(heading: \"Oligo Pool volume (#{DILUTION_VOL[:units]})\") { |op| {content: lib_volume, check: true} }\n .end_table\n check \"Vortex #{TUBE}s #{operations.map{ |op| op.output(OUT_LOW).item}.to_sentence} and spin down\"\n }\n \n # create sublibraries (DNA Library **Samples**)\n tab=[]\n tab[0]=[\"#{OLIGO_POOL}\",\"#{DNA_LIB}\"]\n ind=1\n operations.each { |op| \n props=op.input(POOL).item.sample.properties\n props.fetch(NAMES).each_with_index { |name, i|\n s=Sample.find_by_name(name) # check if already created\n if(s.nil?) # create if needed\n create_DNA_Library(name, \"created #{Time.zone.now.to_date}\", PROJECT, op.plan.user.id)\n check = Sample.find_by_name(name) # check if valid Sample \n if(check.nil?) # no valid Sample created\n show { note \"Problem creating Sample #{name}, please check!\"} \n else\n tab[ind]=[op.input(POOL).item.sample.name, name]\n ind=ind+1\n end\n else\n show { note \"Sample #{name} already exists, please check!\"} \n end\n }\n }\n if(ind > 1) # have new Samples to display \n show {\n title \"DNA Library Samples Created\"\n note \"The following #{DNA_LIB} Samples were created for the #{OLIGO_POOL}s:\"\n table tab\n note \"Please check that no DNA Library Samples are missing!\"\n }\n end\n \n # delete lyopholized stuff\n operations.each { |op| \n op.input(POOL).item.mark_as_deleted\n }\n \n # store resuspended stuff \n operations.store\n \n return {}\n \n end",
"def soln\n @soln ||= preprocess_hash(solve)\n end",
"def satisfied_by(versions, constraints)\n satisfied = []\n # versions.select {|version| self::satisfies?(version, constraints) }\n versions.map do |version|\n if self::satisfies?(version, constraints)\n satisfied << version\n end\n end\n satisfied\n end",
"def requirements(requirements); end",
"def run_tests\n check_solution(1, [6, 29, 18, 2, 72, 19, 18, 10, 37], 18, 2)\n check_solution(2, [6, 29, 18, 2, 72, 19, 18, 10, 37], 9, -1)\nend",
"def business_decision_support \n end",
"def call(ctx)\n evaluate(solve(ctx))\n end",
"def solve\n # If the puzzle has already been solved, don't solve it again, just return.\n return self if solved?\n\n # If the puzzle is not valid, we'll error out.\n @algorithm.solve(self) if valid?\n\n self\n # Catch puzzle validity errors\n rescue => e\n puts \"Error: #{e.message}\"\n exit\n end",
"def heuristics\n raise NotImplementedError, \"not implemented in #{self}\"\n end",
"def resolve\n abstract\n end",
"def solve(a, b, driver:\"gen\", uplo:'U')\n case driver.to_s\n when /^gen?(sv)?$/i\n # returns lu, x, ipiv, info\n Lapack.call(:gesv, a, b)[1]\n when /^(sym?|her?|pos?)(sv)?$/i\n func = driver[0..1].downcase+\"sv\"\n Lapack.call(func, a, b, uplo:uplo)[1]\n else\n raise ArgumentError, \"invalid driver: #{driver}\"\n end\n end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def strategy=(_arg0); end",
"def implementation; end",
"def implementation; end",
"def apply(name)\n load_knowledge_base if @checks.nil?\n return false if @checks.empty?\n\n @checks.each do |check|\n if check.name == name\n unless ((check.kind == Codesake::Dawn::KnowledgeBase::PATTERN_MATCH_CHECK || check.kind == Codesake::Dawn::KnowledgeBase::COMBO_CHECK ) && @name == \"Gemfile.lock\")\n debug_me \"applying check #{check.name}\" \n @applied_checks += 1\n @applied << { :name=>name }\n check.ruby_version = @ruby_version[:version]\n check.detected_ruby = @ruby_version if check.kind == Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK\n check.dependencies = self.connected_gems if check.kind == Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK\n check.root_dir = self.target if check.kind == Codesake::Dawn::KnowledgeBase::PATTERN_MATCH_CHECK\n check.options = {:detected_ruby => self.ruby_version, :dependencies => self.connected_gems, :root_dir => self.target } if check.kind == Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n check_vuln = check.vuln?\n\n @vulnerabilities << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>nil} if check_vuln && check.kind != Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n @vulnerabilities << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>check.vulnerable_checks} if check_vuln && check.kind == Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n @mitigated_issues << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>nil} if check.mitigated?\n return true\n else\n debug_me \"skipping check #{check.name}\"\n @skipped_checks += 1\n end\n end\n end\n\n false\n end",
"def current_solution\n raise NotImplementedError, \"solver subclasses must implement #current_solution\"\n end",
"def facility; end",
"def conscientious_require; end",
"def scientist; end",
"def satisfy_all(constraints, versions)\n constraints = Array(constraints).collect do |con|\n con.is_a?(Gem::Requirement) ? con : Gem::Requirement.new(con.to_s)\n end.uniq\n\n versions = Array(versions).collect do |ver|\n ver.is_a?(Gem::Version) ? ver : Gem::Version.new(ver.to_s)\n end.uniq\n\n versions.select do |ver|\n constraints.all? { |constraint| constraint.satisfied_by?(ver) }\n end\n end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def resolve!\n raise \"resolve! must be implemented for class #{self.class}\"\n end",
"def retrieve_fixity\n alg = replication.fixity_algorithm.to_sym\n replication.fixity_value = bagit.fixity(alg)\n end",
"def resolution(*args); end",
"def apply(name)\n load_knowledge_base if @checks.nil?\n return false if @checks.empty?\n\n @checks.each do |check|\n if check.name == name\n @applied << { :name=>name }\n check.ruby_version = @ruby_version[:version]\n check.detected_ruby = @ruby_version if check.kind == Codesake::Dawn::KnowledgeBase::RUBY_VERSION_CHECK\n check.dependencies = self.connected_gems if check.kind == Codesake::Dawn::KnowledgeBase::DEPENDENCY_CHECK\n check.root_dir = self.target if check.kind == Codesake::Dawn::KnowledgeBase::PATTERN_MATCH_CHECK\n check.options = {:detected_ruby => self.ruby_version, :dependencies => self.connected_gems, :root_dir => self.target } if check.kind == Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n check_vuln = check.vuln?\n\n @vulnerabilities << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>nil} if check_vuln && check.kind != Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n @vulnerabilities << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>check.vulnerable_checks} if check_vuln && check.kind == Codesake::Dawn::KnowledgeBase::COMBO_CHECK\n\n @mitigated_issues << {:name=> check.name, :message=>check.message, :remediation=>check.remediation, :evidences=>check.evidences, :vulnerable_checks=>nil} if check.mitigated?\n return true\n end\n end\n\n false\n end",
"def solution\n throw 'No Solution yet' unless @cs\n lambda do |x|\n res = 0;\n @cs.each.with_index do |c,i|\n res += c*phi(i,x)\n end\n res\n end\n end",
"def refinement\n raise NotImplementedError\n end",
"def solveMeFirst(a, b) {\n a+b;\nend",
"def solve\n answer_vector = Vector.float(@stiff_matrix.size)\n current_residuum = @force.clone\n current_z_vector = @force.clone.mul! @precondition_vector\n p_vector = @force.clone.mul! @precondition_vector\n\n while current_residuum.max_by{|n| n.abs}.abs > 0.001\n last_residuum = current_residuum.clone\n last_z_vector = current_z_vector.clone\n product_of_stiff_matrix_and_p_vector = @stiff_matrix.product(p_vector)\n alpha_val = last_residuum * last_z_vector / (p_vector * product_of_stiff_matrix_and_p_vector)\n answer_vector += alpha_val * p_vector\n current_residuum = last_residuum - alpha_val * product_of_stiff_matrix_and_p_vector\n #loop can be broken here if residuum is small enough\n current_z_vector = current_residuum.clone.mul! @precondition_vector\n p_vector = current_z_vector + p_vector * (current_z_vector * current_residuum / (last_z_vector * last_residuum))\n end\n\n return answer_vector\n end",
"def resolve\n end",
"def evaluate_package(course_title, question, answer)\n Course::Assessment::ProgrammingCodaveriEvaluationService.execute(course_title, question, answer)\n end",
"def isp; end",
"def isp; end",
"def solve!\n mapping = [4, 7, 9]\n @matrix[0..2].each { |row| mapping.each { |idx| raise 'invalid equations system' unless (1 - row.fetch(idx)).zero_eps? }}\n\n first = @matrix.fetch(0)\n second = @matrix.fetch(1)\n third = @matrix.fetch(2)\n\n @matrix[1..2].each { |row| row.subtract!(first) }\n second.normalize_term!(2)\n third.normalize_term!(2).subtract!(second) unless third.fetch(2).zero_eps?\n third.normalize_term!(3)\n second.normalize_term!(3).subtract!(third).normalize_term!(2) unless second.fetch(3).zero_eps?\n\n mapping = [4, 1, 0]\n {1 => 7, 2 => 9}.each do |ri, ci|\n row = @matrix.fetch(ri)\n mapping.zip(sum_square(row.fetch(1), row.fetch(0))).each do |idx, val|\n first[idx] += val\n end\n first[ci] -= 1.0\n end\n\n first.normalize_term!(2).subtract!(second) unless first.fetch(2).zero_eps?\n first.normalize_term!(3).subtract!(third) unless first.fetch(3).zero_eps?\n first.normalize_term!(4)\n\n coefs = mapping.map { |idx| first.fetch(idx) }\n mapping = Set.new(mapping)\n first.each_with_index { |val, idx| raise 'calculating error' unless mapping.include?(idx) || val.zero_eps? }\n delta = coefs[1] ** 2 - 4 * coefs[0] * coefs[2]\n raise 'negative or zero discriminant' if delta <= 0 || delta.zero_eps?\n delta = Math.sqrt(delta)\n\n root_x = ->(delta_sqrt) { (delta_sqrt - coefs[1]) / (2 * coefs[0]) }\n root_yz = ->(x, row) { -(row.fetch(0) + x * row.fetch(1)) }\n @roots = [delta, -delta].map do |x|\n x = root_x.call(x)\n [x, root_yz.call(x, second), root_yz.call(x, third)]\n end\n end",
"def satisfy(&block)\n satisfy(nil, block:block)\n end",
"def test_solve_empty_3x3\n square = MagicSquare.new(3)\n square.solve\n assert square.solved?\n assert_equal @@solutions.first, square.solution\n end",
"def rebuild_satisfiability_graph(_course)\n # TODO: Replace with the job for building the satisfiability graph\n end",
"def matches_requirement?(query, option, requirement); end"
] | [
"0.66706353",
"0.66283953",
"0.6239612",
"0.60651714",
"0.60209996",
"0.594654",
"0.58924836",
"0.5852371",
"0.5849326",
"0.5737718",
"0.57127976",
"0.5696004",
"0.56845933",
"0.5649134",
"0.5628463",
"0.5624024",
"0.5589592",
"0.5544175",
"0.55179447",
"0.55131024",
"0.5513091",
"0.5506797",
"0.546467",
"0.54635304",
"0.5459817",
"0.5449794",
"0.54418427",
"0.54418427",
"0.54418427",
"0.54418427",
"0.54195154",
"0.5385676",
"0.5348881",
"0.53451824",
"0.5341738",
"0.5341738",
"0.5323431",
"0.5323431",
"0.5319424",
"0.52765346",
"0.52642816",
"0.52607524",
"0.52344745",
"0.5222567",
"0.52132297",
"0.51997745",
"0.5196714",
"0.5188597",
"0.5183955",
"0.51710474",
"0.516946",
"0.51535165",
"0.5146253",
"0.5142851",
"0.5140487",
"0.5136857",
"0.51353943",
"0.5134867",
"0.51243186",
"0.511731",
"0.5099352",
"0.5089984",
"0.50790924",
"0.5068558",
"0.50594753",
"0.505152",
"0.505152",
"0.505152",
"0.505152",
"0.5045729",
"0.5040736",
"0.5040736",
"0.5036263",
"0.502089",
"0.50112134",
"0.4981305",
"0.4979011",
"0.49770695",
"0.49744505",
"0.49744505",
"0.49744505",
"0.49744505",
"0.49744505",
"0.49726713",
"0.49676487",
"0.49594715",
"0.49541882",
"0.49516502",
"0.49448436",
"0.49430713",
"0.49391946",
"0.49329713",
"0.49323437",
"0.4931323",
"0.4931323",
"0.49313042",
"0.4929147",
"0.49285886",
"0.49205807",
"0.49190202"
] | 0.5087591 | 62 |
edit to make it recalculate the heuristic? or slower... | def dpll
#need to count degree, best_guess, assignments and such heuristic stuff somewhere... makes sense to do it here
#should make a version without heuristics aswell
##############################################3
# puts "the kb : " + @kb.to_s
@kb.each do |sente|
##########################################################333
# puts " the sentences: " + sente.to_s
if(sente.size==1)
index=sente[0]
if(index > 0)
@id_array[index-1].pos_increment
@id_array[index-1].puret=true
else
index*=-1
@id_array[index-1].neg_increment
@id_array[index-1].puref = true
end
else
sente.each do |atome|
#############################################################
# puts "the individual atoms: " + atome.to_s
if(atome > 0)
index = atome-1
@id_array[index].pos_increment
else
index = -1*atome-1
@id_array[index].neg_increment
end
end
end
end
@id_array.each do |var|
if(!var.assignment_intialize)
return false
end
end
#intialization stuff
##########heuristic sort!
var_list = @id_array
var_list.sort!
depth=0
assignment = Array.new
satisfiable = false
stack = []
#make parallel array assignment
id_array.map { assignment << 0}
#insert root
(var_list[depth].assignments).map do |child|
stack.push(Assign_Stack_Object.new(child,depth))
end
#start depth-first search
while(stack.size()>0)
temp = stack.pop
#comparing depth to make sure assignment variables reassigned if popping up the tree
while(depth>temp.depth)
assignment[depth] = 0
depth -=1
end
#add it to the assignment evaluation list (depth doubles as index through var_list)
assignment[var_list[temp.depth].id - 1] = temp.value
#Evaluate the assignment list
if(satisfiable_assignment?(assignment)==1)
##########################################################################333
puts "the kb is: " + @kb.to_s
puts "the assignment that evaluates to true: "
puts assignment.to_s
#############################################################################
return true
end
#add children
depth+=1
#if not bottumed out, add more children based on values from the var
if(depth<var_list.size())
(var_list[depth].assignments).map do |child|
stack.push(Assign_Stack_Object.new(child,depth))
end
else
#reset to bottom value
depth =var_list.size-1
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heuristic(current:, target:)\n d = (current[0].real - target[0].real).abs + (current[0].imag - target[0].imag).abs\n d += 7 if d <= 8 && current[1] != target[1]\n\n d\nend",
"def heuristic_score\n 0\n end",
"def heuristic(map, there, here)\n there_val = map.at(*there)\n here_val = map.at(*here)\n there_val > (here_val + 1) ? 10_000 : Point.new(*there).manhattan_distance(Point.new(*here)) # 1\n end",
"def heuristics\n raise NotImplementedError, \"not implemented in #{self}\"\n end",
"def heuristic_solving_possible\n prev_item = nil\n items.each do |item|\n if prev_item.present?\n if item[:c] < prev_item[:c]\n # \"The absolute cost of a heavier item (cost #{item[:c]} with weight #{item[:w]}) is lower than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]})\"\n return false\n elsif (item[:c].to_f / item[:w].to_f) > (prev_item[:c].to_f / prev_item[:w].to_f)\n # \"The relative cost of a heavier item (cost #{item[:c]} with weight #{item[:w]} having a relative cost of #{item[:c].to_f/item[:w].to_f}) is higher than the cost of another item (cost #{prev_item[:c]} with weight #{prev_item[:w]} having a relative cost of #{prev_item[:c].to_f/prev_item[:w].to_f})\"\n return false\n end\n end\n prev_item = item\n end\n true\n end",
"def a_star pitch, start, goal\n\t\t# The set of nodes already evaluated.\n\t\tclosedset = []\n\t\t# The set of tentative nodes to be evaluated.\n\t\topenset = []\n\t\t# Visited nodes\n\t\tfrontier = []\n\t\topenset << start\n\t\t# The map of navigated nodes.\n\t\tcame_from = { }\n\t\t# Distance from start along optimal path.\n\t\tg_score, h_score, f_score = { }, { }, { }\n\t\tg_score[start] = 0\n\t\th_score[start] = dist start, goal, :manhattan\n\t\t# Estimated total distance from start to goal through y.\n\t\tf_score[start] = h_score[start]\n\n\t\t# Main loop\n\t\twhile not openset.empty?\n\t\t\t# Fetching the node among openset with the least f_score\n\t\t\tx, _value = [], 1_000_000\n\t\t\topenset.each do |key|\n\t\t\t\tx, _value = key, f_score[key] if f_score[key] < _value\n\t\t\tend\n\n\t\t\tbreak if x == goal # We reached target point and thus finished looking for it !!\n\n\t\t\t# Moving x from openset to closedset\n\t\t\topenset.delete x\n\t\t\tclosedset << x\n\n\t\t\t(-1..1).each do |i|\n\t\t\t\t(-1..1).each do |j|\n\t\t\t\t\ty = [x[0] + i, x[1] + j]\n\t\t\t\t\tunless i == 0 and y == 0\n\t\t\t\t\t\tif pitch[y].nil? # We only want to explore neighbours\n\t\t\t\t\t\t\tnext if closedset.include? y # If already in closedset, we skip it\n\n\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\th = dist x, y, :manhattan\n\t\t\t\t\t\t\tg = g_score[x] + h\n\n\t\t\t\t\t\t\tif not openset.include? y then\n\t\t\t\t\t\t\t\treturn [] if frontier.include? y\n\t\t\t\t\t\t\t\tfrontier << y\n\t\t\t\t\t\t\t\topenset << y # Adding current neighbours to openset\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telsif g < g_score[y]\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Updating what needs to be\n\t\t\t\t\t\t\tif better then\n\t\t\t\t\t\t\t\tcame_from[y] = x\n\t\t\t\t\t\t\t\tg_score[y] = g\n\t\t\t\t\t\t\t\th_score[y] = dist y, goal, :manhattan # heuristic estimate of distance (y, coords)\n\t\t\t\t\t\t\t\tf_score[y] = g_score[y] + h_score[y]\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# Finally assembling path and returning it\n\t\tpath = []\n\t\t_cur = goal\n\t\twhile _cur != start do\n\t\t\tpath << _cur\n\t\t\t_cur = came_from[_cur]\n\t\tend\n\n\t\treturn path.reverse\n\tend",
"def eval_res_distances\n self.greater_than_twenty_away = (self.position_one - self.position_two).abs > 20\n self.greater_than_50_away = (self.position_one - self.position_two).abs > 50\n self.greater_than_100_away = (self.position_one - self.position_two).abs > 100\n self.greater_than_200_away = (self.position_one - self.position_two).abs > 200\n self.greater_than_300_away = (self.position_one - self.position_two).abs > 300\n self.greater_than_400_away = (self.position_one - self.position_two).abs > 400\n self.greater_than_500_away = (self.position_one - self.position_two).abs > 500\n self.greater_than_600_away = (self.position_one - self.position_two).abs > 600\n self.greater_than_700_away = (self.position_one - self.position_two).abs > 700\n self.greater_than_800_away = (self.position_one - self.position_two).abs > 800\n self.greater_than_900_away = (self.position_one - self.position_two).abs > 900\n self.greater_than_1000_away = (self.position_one - self.position_two).abs > 1000\n self.greater_than_1100_away = (self.position_one - self.position_two).abs > 1100\n self.greater_than_1200_away = (self.position_one - self.position_two).abs > 1200\n self.greater_than_1300_away = (self.position_one - self.position_two).abs > 1300\n self.greater_than_1400_away = (self.position_one - self.position_two).abs > 1400\n self.greater_than_1500_away = (self.position_one - self.position_two).abs > 1500\n self.greater_than_1600_away = (self.position_one - self.position_two).abs > 1600\n self.greater_than_1700_away = (self.position_one - self.position_two).abs > 1700\n self.greater_than_1800_away = (self.position_one - self.position_two).abs > 1800\n self.greater_than_1900_away = (self.position_one - self.position_two).abs > 1900\n self.greater_than_2000_away = (self.position_one - self.position_two).abs > 2000\n self.greater_than_2100_away = (self.position_one - self.position_two).abs > 2100\n self.greater_than_2200_away = (self.position_one - self.position_two).abs > 2200\n self.greater_than_2300_away = (self.position_one - self.position_two).abs > 2300\n self.greater_than_2400_away = (self.position_one - self.position_two).abs > 2400\n self.greater_than_2500_away = (self.position_one - self.position_two).abs > 2500\n self.save\n end",
"def brute_force_optimal(tg,faulty,replacements,n)\n if tg[1].size == 0 # special case if there are no edges(all replacements are equal)\n return get_mappings(faulty,replacements)[0] # return the first mapping\n end\n get_mappings(faulty,replacements).min_by do |a|\n euclidean_distance(tg,a,n) \n end\nend",
"def astar_search(origin:, target:)\n costs = {}\n seen = {}\n path = {}\n initial_estimate = heuristic(current: origin, target: target)\n costs[origin] = 0\n\n pq = PriorityQueue.new\n\n pq.push(origin, initial_estimate)\n\n loop do\n current = pq.delete_min_return_key\n\n # made it\n return path if current == target\n\n seen[current] = true\n\n # get moves and estimate costs\n moves(current).each do |move|\n move_pair = move[0]\n cost = move[1]\n\n next if seen[move_pair]\n\n new_cost = costs[current] + cost\n\n # skip if more costly\n next if pq.has_key?(move_pair) && !costs[move_pair].nil? && new_cost >= costs[move_pair]\n\n path[move_pair] = current\n costs[move_pair] = new_cost\n estimate = new_cost + heuristic(current: move_pair, target: target)\n\n if pq.has_key?(move_pair)\n pq.change_priority(move_pair, estimate)\n else\n pq.push(move_pair, estimate)\n end\n end\n end\nend",
"def aStar(tx = @player.x/@TILESIZE, ty = @player.y/@TILESIZE, x = @x/@TILESIZE, y = @y/@TILESIZE)\n #exit conditions\n if tx > @map.WIDTH or ty > @map.HEIGHT or tx < 0 or ty < 0\n return Node.new(x, y, nil, 0)\n end\n start = Time.now\n evald = Array.new #nodes that have already been evaluated\n queue = [Node.new(x, y, 0)]#the last element is the g value\n until queue.empty?\n #queue.each{ |q| print q.toArray, \"...\"}\n #print \"\\n\" #for debugging\n current = queue[0]#finds the node in queue with the lowest f value\n queue.each do |q|\n current = q if q.f(tx, ty) < current.f(tx, ty)\n end\n evald.push(current)#move current from 'queue' to 'evald'\n queue.delete(current)\n #direction from the second node aka the one after the one the ghost is at\n if current.x == tx and current.y == ty\n current.trim\n return current\n #print \"the ghost is confused\\n\" # for debugging\n end\n @map.getSurrounding(current.x, current.y, false).each{ |n|\n node = Node.toNode(n)\n node.g= current.g + 1\n node.parent= current\n nodeInEvald = false\n evald.each{ |evNode|\n if(evNode.coords == node.coords)\n if(evNode.g > node.g)\n evNode.g = node.g\n evvNode.dir = node.dir\n end\n nodeInEvald = true\n break\n end\n }\n if !nodeInEvald\n queue.push(node) \n end\n }\n #just gives up if it's been trying to find a path for more than 5 seconds\n if Time.now - start > 5\n current.trim\n current.timeOut = true;\n return current\n end\n end\n nil\n end",
"def solution_proximity_heuristic(amount,comb,coins)\n (amount-comb.sum)*min_size_heuristic(amount,comb,coins)\nend",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def heuristic(node, start, goal)\n raise NotImplementedError\n end",
"def solve(minemap, miner, exit, answer = [])\n# this block sets variables for dimension max indexes\n# declares variables for the current miner position\n# declares variables for the exit position\n# I did this for easier manipulation of the values\n# than referring to and changing a hash constantly\n# it also sets up an array possible values the map\n# can take on, with the direction a miner should travel\n# replacing true, which signals to the miner that he\n# should not return to that position (probably not necessary\n# because false would work just as well unless two branches\n# are both valid, but right, left, up, down could probably\n# be eliminated\n\n x_max = minemap.size - 1\n y_max = minemap[0].size - 1\n x = miner['x']\n y = miner['y']\n ex = exit['x']\n ey = exit['y']\n walls = %w(right left up down branch)\n walls.push(false)\n\n# copying the map so it can be manipulated (again, probably\n# not necessary and, even if it is, my copy_array should be\n# expanded to multi dimensional arrays)\n\n copy = Array.new(x_max+1){Array.new(y_max+1)}\n (0..x_max).each do |x|\n (0..y_max).each do |y|\n copy[x][y] = minemap[x][y]\n end\n end\n\n# loops while not at exit\n\n while x != ex || y != ey\n\n# sets a boolean array to 4 trues, then checks\n# each possible move to false if unavailable\n\n rlud = [true, true, true, true]\n rlud[0] = false if x == x_max || walls.include?(copy[x+1][y])\n rlud[1] = false if x == 0 || walls.include?(copy[x-1][y])\n rlud[2] = false if y == 0 || walls.include?(copy[x][y-1])\n rlud[3] = false if y == y_max || walls.include?(copy[x][y+1])\n\n# if there is nowhere to turn, the answer array is set to an array \n# of size equal to thenumber of elements in the map, because this \n# number is more than the possible number of steps the miner could\n# take in an actual solution, then returns this array as answer\n# this signals the previous call of solve that the branch was a \n# dead end (this will not happen on the first iteration by if\n# the initial conditions are valid)\n\n answer = Array.new((x_max + 1) * (y_max + 1)) if rlud.count(true) == 0 \n return answer if rlud.count(true) == 0\n\n# if there is only one path (only one true in the boolean array)\n# then the position is updated, the step is pushed to the answer\n# array and the copy of the original position is set to a string\n# indicating the miner must travel\n\n if rlud.count(true) == 1 \n if rlud[0] == true\n copy[x][y] = \"right\" \n answer.push('right')\n x += 1\n elsif rlud[1] == true\n copy[x][y] = \"left\" \n answer.push('left')\n x -= 1\n elsif rlud[2] == true\n copy[x][y] = \"up\" \n answer.push('up')\n y -= 1\n else\n copy[x][y] = \"down\"\n answer.push('down')\n y += 1 \n end \n\n# if there is more than one possible move, this section\n# calls the branch explore with the direction to explore\n# as one parameter and a copy of the answer to be appended \n# to in case a valid path is found, if a dead end is reached\n# branch_explore will mark the initial branch position as false\n\n else\n copy[x][y] = false\n if rlud[0] == true\n r = copy_array(answer)\n r = branch_explore(copy, 'right', exit, r, x, y, x_max, y_max)\n end \n if rlud[1] == true\n l = copy_array(answer)\n l = branch_explore(copy, 'left', exit, l, x, y, x_max, y_max)\n end\n if rlud[2] == true\n u = copy_array(answer) \n u = branch_explore(copy, 'up', exit, u, x, y, x_max, y_max)\n end\n if rlud[3] == true\n d = copy_array(answer)\n d = branch_explore(copy, 'down', exit, d, x, y, x_max, y_max)\n end\n\n# this section pushes the answer arrays that are valid paths to\n# a branch array \n\n branch_array = [] \n branch_array.push(r.size) if x != x_max && copy[x+1][y].to_s == \"branch\"\n branch_array.push(l.size) if x != 0 && copy[x-1][y].to_s == \"branch\"\n branch_array.push(u.size) if y != 0 && copy[x][y-1].to_s == \"branch\"\n branch_array.push(d.size) if y != y_max && copy[x][y+1].to_s == \"branch\"\n\n# this determines which of the potential valid paths is shorts and \n# set the answer to that array\n \n min = branch_array.min\n answer = copy_array(r) if r != nil && r.size == min\n answer = copy_array(l) if l != nil && l.size == min\n answer = copy_array(u) if u != nil && u.size == min\n answer = copy_array(d) if d != nil && d.size == min\n end\n end\n\n# return the answer\n\n answer\nend",
"def heuristic_breaker(n=8)\n worst_example = []\n interval = 0\n 10.times do\n an_opt = get_opt(n).first\n# apx = an_opt.improved_heuristic\n apx = an_opt.sort.find_apx_interval4\n o = diff(an_opt.find_interval)\n a = diff( apx.find_interval)\n \n if a.to_f / o > interval\n interval = a.to_f / o\n worst_example = [an_opt, apx, interval]\n end\n end\n worst_example\nend",
"def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end",
"def manhattan_heuristic(open_squares)\n smallest_f = nil\n smallest_f_point = nil\n open_squares.each do |neighbor|\n g_score = calculate_g(neighbor)\n h_score = calculate_h(neighbor)\n f_score = h_score + g_score\n if smallest_f.nil? || f_score < smallest_f\n smallest_f = f_score\n smallest_f_point = neighbor\n end\n end\n smallest_f_point\n end",
"def estimate_hits\n nodes = @driver.neighbors\n authority_prime = 0.0\n hub_prime = 0.0\n square_sum_authority_prime = 0.0\n square_sum_hub_prime = 0.0\n # Compute the sum\n nodes.each do |p|\n authority_prime += p.hub\n hub_prime += p.authority\n square_sum_authority_prime += p.authority_prime**2\n square_sum_hub_prime += p.hub_prime**2\n end\n square_sum_authority_prime += authority_prime**2\n square_sum_hub_prime += hub_prime**2\n # Normalize\n authority = authority_prime**2/square_sum_authority_prime\n hub = hub_prime**2/square_sum_hub_prime\n\n # Update routing\n new_routing = @driver.update_routing do |routing|\n routing.authority = authority\n routing.hub = hub\n routing.authority_prime = authority_prime\n routing.hub_prime = hub_prime\n routing.last_update = DateTime.now\n end\n\n new_routing\n end",
"def solve(file)\r\n x, y = Integer($sx), Integer($sy)\r\n visited = []\r\n discovered = []\r\n value = $table[\"#{x} #{y}\"]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n discovered.push(\"#{x} #{y}\")\r\n \r\n while discovered.size != 0\r\n current = discovered.pop\r\n x, y = current.split(/\\s/)\r\n x = Integer(x)\r\n y = Integer(y)\r\n value = $table[current]\r\n value = value.to_s\r\n direction, weight = value.split(/\\s/,2)\r\n \r\n if visited.include?(current) == false\r\n visited.push(current)\r\n direction = direction.split(//)\r\n \r\n i = 0\r\n while i < direction.size\r\n case direction[i]\r\n when \"u\"\r\n y = y - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y + 1\r\n when \"d\"\r\n y = y + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n y = y - 1\r\n when \"l\"\r\n x = x - 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x + 1\r\n when \"r\"\r\n x = x + 1\r\n if visited.include?(\"#{x} #{y}\") == false\r\n discovered.push(\"#{x} #{y}\")\r\n if \"#{x} #{y}\" == \"#{$ex} #{$ey}\"\r\n result = true\r\n end\r\n end\r\n x = x - 1\r\n end\r\n i = i + 1\r\n end\r\n end\r\n end\r\n puts discovered\r\n if result == true\r\n puts result\r\n else\r\n puts false\r\n end\r\n end",
"def calc_dijkstra\n # The initial values for the Dijkstra search\n dijkstra_search.frontier << [state.star, 0]\n dijkstra_search.came_from[state.star] = nil\n dijkstra_search.cost_so_far[state.star] = 0\n\n # Until their are no more cells to be explored\n until dijkstra_search.frontier.empty?\n # Get the next cell to be explored from\n # We get the first element of the array which is the cell. The second element is the priority.\n current = dijkstra_search.frontier.shift[0]\n\n # Stop the search if we found the target\n return if current == state.target\n\n # For each of the neighbors\n adjacent_neighbors(current).each do | neighbor |\n # Unless this cell is a wall or has already been explored.\n unless dijkstra_search.came_from.key?(neighbor) or state.walls.key?(neighbor)\n # Calculate the movement cost of getting to this cell and memo\n new_cost = dijkstra_search.cost_so_far[current] + cost(neighbor)\n dijkstra_search.cost_so_far[neighbor] = new_cost\n\n # Add this neighbor to the cells too be explored\n dijkstra_search.frontier << [neighbor, new_cost]\n dijkstra_search.came_from[neighbor] = current\n end\n end\n\n # Sort the frontier so exploration occurs that have a low cost so far.\n # My implementation of a priority queue\n dijkstra_search.frontier = dijkstra_search.frontier.sort_by {|cell, priority| priority}\n end\n end",
"def fully_extend_all reps=nil\n dist.branches.times do |i|\n hits = mapee(i).hits\n len = mapee(i).length\n mapee(i).clear_hits\n reps = (@len.to_f / len).round if reps.nil?\n mapee(i).length = @len\n reps.times do |j|\n new_hits = HitSq.new\n new_hits << hits\n new_hits * (1.0/reps)\n new_hits + (j.to_f / reps)\n# puts new_hits.hits.inspect\n mapee(i) << new_hits\n end\n# puts mapee(i).hits.hits.inspect\n end\n end",
"def heuristic_for_player(player)\n # for each row, col, diag:\n # +100 for a win, 10 for two (with 1 empty), 1 for single (with 2 empty)\n # above negated for other player, subtracting 1/10th because it is not their turn (assume it is player's turn)\n # , summed\n heuristic_proc = proc do |acc, row|\n is_player_proc = proc { |c| c == player.to_s }\n acc += 100 if row.all?(&is_player_proc)\n acc += 10 if row.select(&is_player_proc).size == 2 && row.any?(&:nil?)\n acc += 1 if row.select(&is_player_proc).size == 1 && row.select(&:nil?).size == 2\n\n is_other_player_proc = proc { |c| !c.nil? && c != player.to_s}\n acc -= 90 if row.all?(&is_other_player_proc)\n acc -= 9 if row.select(&is_other_player_proc).size == 2 && row.any?(&:nil?)\n acc -= 0.9 if row.select(&is_other_player_proc).size == 1 && row.select(&:nil?).size == 2\n\n acc\n end\n\n rows.reduce(0, &heuristic_proc) + columns.reduce(0, &heuristic_proc) + diagonals.reduce(0, &heuristic_proc)\n end",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def skill_heuristic_calculation(launcher, target, skill, index)\n ::BattleEngine._load_ia_state\n #> Récupération des combattants\n @enemies = ::BattleEngine.get_enemies\n @actors = ::BattleEngine.get_actors\n\n launcher = get_pokemon(launcher)\n target = get_pokemon(target)\n @IA_Info.clear\n @IA_Info[:launcher] = launcher\n @IA_Info[:target] = target\n @IA_Info[:damage] = 0\n @IA_Info[:recoil] = 0\n @IA_Info[:symbol] = skill.symbol\n @IA_Info[:failure] = false\n @IA_Info[:skill] = skill\n heuristic = {:value => 0}\n heuristic[:skill] = index\n heuristic[:skill_data] = skill\n heuristic[:target] = -target.position-1\n heuristic[:faster] = launcher.spd >= target.spd\n BattleEngine::use_skill(launcher, [target], skill) unless special_skill(launcher, target, skill)\n enemy = target.position >= 0 \n enemy = true if seviper_zangoose_detect(launcher, target)\n if @IA_Info[:damage] > 0\n hp_scale = target.hp\n if (hp_scale / launcher.max_hp) > 2\n hp_scale = launcher.hp\n end\n value = @IA_Info[:damage] / hp_scale.to_f - @IA_Info[:recoil] / launcher.hp.to_f\n value *= -1 unless enemy\n heuristic[:value] += value\n end\n if @IA_Info[:other_factor]\n heuristic[:value] += @IA_Info[:other_factor]\n end\n if @IA_Info[:status_factor]\n value = @IA_Info[:status_chance] ? @IA_Info[:status_chance] : 1\n heuristic[:value] += @IA_Info[:status_factor] * value\n end\n if @IA_Info[:randomness]\n heuristic[:value] *= @IA_Info[:randomness]\n end\n heuristic[:damage] = @IA_Info[:damage]\n pc skill.name\n pc heuristic[:value]\n return heuristic\n end",
"def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\nend",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def calc\n # If the searches have not started\n if breadth_first_search.visited.empty?\n # Calculate the two searches\n calc_breadth_first\n calc_dijkstra\n end\n end",
"def get_route(curr_pos, end_time, pmap, tws, twe) \n ans = []\n starting_tuple = curr_pos << 0 # 0 is the waiting time\n ans << starting_tuple # [y, x, time unit]\n \n\t\n\t\n max_y = pmap.length - 1 \n max_x = pmap[0].length - 1\n \n highest_score = 0.0\n \n\ttime_for_score = 0.0\n\ttime_for_get_ans = 0.0\n\t\n\ttemp = -1\n\ttemp1 = 0\n\tfor y in 0..max_y\n\t\ttemp1 = pmap[y].count(temp)+ temp1 \n\tend\n\t\n\tno_of_pokemon = (pmap.length*pmap[0].length - temp1)\n\t\n\tnumber_of_loops = 0.7541*Math.log(no_of_pokemon,E) + 0.9829\n\t\n\n\t\n\t\n for h in 0...number_of_loops\n pmap1 = Marshal.load(Marshal.dump(pmap))\n tws1 = Marshal.load(Marshal.dump(tws))\n twe1 = Marshal.load(Marshal.dump(twe))\n\t\t\n time_taken = Time.now\n sortedArrayByRatioDistStart1 = []\n ans1 = []\n ans1 = getArrayResultsWithStartingPokemon(starting_tuple, pmap1, tws1, twe1, sortedArrayByRatioDistStart1, end_time, h)\n\t\ttime_for_get_ans = Time.now - time_taken + time_for_get_ans\n\t\t\n\t\tpmap1 = Marshal.load(Marshal.dump(pmap))\n tws1 = Marshal.load(Marshal.dump(tws))\n twe1 = Marshal.load(Marshal.dump(twe))\n\t\t\n\t\ttime_taken = Time.now\n score_time1 = get_score(ans1, pmap1, tws1, twe1)\n route_score1 = score_time1[0].round\n route_time1 = score_time1[1].round(3)\n time_for_score = Time.now - time_taken + time_for_score\n\t\t\n if highest_score <= route_score1\n final_ans = ans1\n highest_score = route_score1\n end\n\t\t\n\t\t\n end\n \n\n return final_ans\nend",
"def solve\n a = Time.new\n for i in 0..@itemsSize - 1\n @table[0][i] = 0\n end\n \n for i in 1..@itemsSize - 1\n price = @problem.prices[i-1]\n weight = @problem.weights[i-1]\n for w in 1..@weights - 1\n if weight <= w\n if (price + @table[w - weight][i - 1]) > @table[w][i -1]\n @table [w][i]= price + @table[w - weight][i - 1]\n else\n @table[w][i] = @table[w][i - 1]\n end\n else\n @table[w][i] = @table[w][i - 1]\n end\n end\n end\n \n \n prev_item = 0\n for i in 1..@itemsSize - 1\n curr_item = @table[@weights - 1][i]\n if prev_item < curr_item\n @best_configuration.push(1)\n else\n @best_configuration.push(0)\n end\n prev_item = curr_item\n end\n \n @best_fitness = @table[@weights - 1][@itemsSize - 1]\n \n b = Time.new\n @time = b-a\n end",
"def recalc\n\n\t\t# Precalculate as much as possible\n\n\t\t@dist = @row.abs + @col.abs\n\n\t\t@attack_dir = calc_attack_dir \n\n\t\tradius = @row*@row + @col*@col\n\t\t#$logger.info \"radius: #{ radius }\"\n\t\t@in_view = ( radius <= @@ai.viewradius2 )\n\t\t@in_attack_range = ( radius <= @@ai.attackradius2 )\n\t\t@in_peril = ( radius <= @@peril_radius2 )\n\t\t@in_danger = ( radius <= @@danger_radius2 )\n\n\n\t\tdist = nil\n\t\tif @row.abs > @col.abs\n\t\t\tdist = row\n\t\telse\n\t\t\tdist = col\n\t\tend\n\t\t@longest_dist = dist\n\t\n\t\t@shortest_dir = calc_shortest_dir\n\tend",
"def alg; end",
"def find_pair\n before = self.entropy\n reduce_pair_line\n reduce_pair_col\n reduce_pair_grid\n reduce_solved if before > self.entropy\n self\n end",
"def a_star_search(tiles_order)\n tree = []\n leaves = []\n solution = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n leaf = build_leaf(tiles_order, {tiles_order: nil, branch: []})\n\n i = 0\n while i < 6000 && leaf[:tiles_order] != solution\n i += 1\n tree << leaf[:tiles_order]\n new_buds = neighbor_boards(leaf[:tiles_order])\n new_buds.each do |bud|\n leaves << build_leaf(bud, leaf) unless tree.include? bud\n end\n leaf = pop_cheapest_leaf(leaves)\n\n p \"iterations = #{i}\"\n p \"depth = #{leaf[:branch].length}\"\n p \"manhattan distance = #{leaf[:m_distance]}\"\n p \"tiles_order = #{leaf[:tiles_order]}\"\n\n return leaf[:branch] if leaf[:tiles_order] == solution\n end\n end",
"def get_pokestops(pop_map, cost_map)\n\n # returns number_of_stops poke stops randomly within the map\n # this is a non-deterministic working solution, but produces a lousy (high) \n # quality score for obvious reasons\n \n time = Time.now\n answer = []\n max_y = pop_map.length-1 # y should not go beyond this boundary\n max_x = pop_map[0].length-1 # x should not go beyond this boundary\n \n #uses formula to identify the best midpoint to start from\n number_of_stops = 1\n total_pop = 0\n total_cost = 0\n total_cost_array = []\n \n for y in 0..max_y #initializes total population and total cost\n\tfor x in 0..max_x\n\t\ttotal_pop = total_pop + pop_map[y][x]\n\t\ttotal_cost = total_cost + cost_map[y][x]\n\t\ttotal_cost_array << cost_map[y][x]\n\tend\n end\n\t\n\tno_of_cells = max_x*max_y\n\t\n avg_cost = total_cost/(max_y*max_x)\n total_cost_array.sort!\n count = 0\n test_hash = Hash.new\n \n for y in 0..max_y #equation to figure out margins\n\tfor x in 0..max_x\n\t\tscore = number_of_stops* total_cost_array[count] + total_pop*max_x*max_y*0.25/(2**(number_of_stops*3000/(no_of_cells**1.3)))\n\t\t#puts \"#{number_of_stops} Stops: #{score}\"\n\t\ttest_hash[number_of_stops] = score\n\t\tcount = count + 1\n\t\tnumber_of_stops = number_of_stops + 1\n\tend\n end\n \n test_hash = test_hash.sort_by {|key,value|value}\n equation_no = test_hash[0][0]\n \n \n \n \n margin = 0.025*(max_x*max_y)\n lower = equation_no - margin\n upper = equation_no + margin\n lowest = false\n mid = (lower+upper)/2\n difference = max_x*max_y/500\n difference_interval = max_x*max_y/1000\n if difference_interval == 0\n\tdifference_interval = 1\n end\n difference_limit = difference + 3*difference_interval\n test_hash = Hash.new\n \n #for testing\n # for i in lower.round..upper.round\n\t# number_of_stops = i\n\t# answer = get_pokestops_with_stops(pop_map, number_of_stops,cost_map)\n\t# temp = calculate_score_for_map(pop_map, cost_map, answer, false)\n\t# puts \"Number of Stops: #{number_of_stops}, Score: #{temp}\"\n\t# test_hash[number_of_stops] = temp\n # end\n # test_hash = test_hash.sort_by {|key,value|value}\n # real_no = test_hash[0][0]\n # puts \"Real Number of Stops: #{real_no}\"\n # margin_req = (equation_no - real_no)*100.0/(max_x*max_y)\n # puts \"Margin required: #{margin_req}%\"\n \n\n \n \n if difference == 0 \n\tdifference = 1\n\tend\n\twent_lower = 0\n\twent_upper = 0\n\tstayed = 0\n\tcount = 0\n\tlowestScore = 0\n if ((mid-difference)>0 && (mid+difference)<(pop_map.length*pop_map[0].length)+1) == false\n\t\n\t\tfor i in 1...(0.4*no_of_cells).round\n\t\t\ttest_answer = []\n\t\t\tnumber_of_stops = i\n\t\t\tlowestScore = 0\n\t\t\ttemp_array = get_pokestops_with_stops(pop_map, number_of_stops,cost_map)\n\t\t\tfor i in 0...temp_array.length-2\n\t\t\t\t\ttest_answer << temp_array[i][0]\n\t\t\tend\n\t\t\t\n\t\t\ttemp = calculate_score_for_map(pop_map, cost_map, test_answer, false)\n\t\t\tif i == 1 \n\t\t\t\tlowestScore = temp\n\t\t\t\tanswer = test_answer\n\t\t\telsif lowestScore > temp\n\t\t\t\tanswer = test_answer\n\t\t\t\tlowestScore = temp\n\t\t\tend\n\t\t\t\n\t\tend\n\t\n\telse\n\t\t#puts \"inside here\"\n\t\t#puts \"difference: #{difference}, Limit : #{difference_limit}\"\n\t while difference != difference_limit \n\t\tcount = count +1\n\t\t#mid\n\t\tif count == 10\n\t\t\t\tbreak\n\t\tend\n\t\t\n\t\tmid = (lower+upper)/2\n\t\n\t\t\n\t\tif stayed == 1 \n\t\t\tanswer1 = answer\n\t\t\ttemp1 = lowestScore\n\t\telse\n\t\t\n\t\t\tmap1 = Marshal.load(Marshal.dump(pop_map)) \n\t\t\ttemp_array = get_pokestops_with_stops(map1, mid,cost_map) # answer in format | [y,x] (stop coor), (area_no)| last element are the area coordinates array\n\t\t\tanswer1 = []\n\t\t\ttemp_area_no = Hash.new\n\t\t\t\n\t\t\t\n\t\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\t\tfor i in 0...temp_array.length-2\n\t\t\t\tanswer1 << temp_array[i][0]\n\t\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\t\tend\n\t\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\t\ttemp1 = calculate_score_for_map_search(map1,cost_map,answer1,temp_area_no,area_coordinates, x_areas)\n\t\tend\n\t\t\n\t\tstayed = 0\n\t\tupper1 = mid\n\t\tlower1 = mid\n\t\t\n\t\t# difference before mid\n\t\t\t\n\t\tmap2 = Marshal.load(Marshal.dump(pop_map)) \n\t\ttemp_array = get_pokestops_with_stops(map2, mid-difference,cost_map) # array\n\t\tanswer2 = []\n\t\ttemp_area_no = Hash.new\n\t\t\n\t\t\n\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\tfor i in 0...temp_array.length-2\n\t\t\tanswer2 << temp_array[i][0]\n\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\tend\n\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\ttemp2 = calculate_score_for_map_search(map2,cost_map,answer2,temp_area_no,area_coordinates, x_areas)\n\t\t\n\t\t# difference after mid\n\t\tmap3 = Marshal.load(Marshal.dump(pop_map)) \n\t\ttemp_array = get_pokestops_with_stops(map3, mid+difference,cost_map) # array\n\t\tanswer3 = []\n\t\ttemp_area_no = Hash.new\n\t\t\n\t\t\n\t\tarea_coordinates = temp_array[(temp_array.length-1)]\n\t\tx_areas = temp_array[(temp_array.length-2)]\n\t\tfor i in 0...temp_array.length-2\n\t\t\tanswer3 << temp_array[i][0]\n\t\t\ttemp_area_no[temp_array[i][1]] = temp_array[i][0]\n\t\tend\n\t\t#puts \"Stops to area hash : #{temp_area_no}\"\n\t\ttemp3 = calculate_score_for_map_search(map3,cost_map,answer3,temp_area_no,area_coordinates, x_areas)\n\t\t\n\t\t\n\t\n\t\tif (temp2 < temp1) && (temp3 > temp2) #the one BEFORE mid is smaller\n\t\t\tlowestScore = temp2\n\t\t\tanswer = answer2\n\t\t\tupper = upper1\n\t\t\t\n\t\telsif (temp3 < temp2) && (temp3 < temp1) # the one AFTER mid is smaller\n\t\t\tlowestScore = temp3\n\t\t\tanswer = answer3\n\t\t\tlower = lower1\n\t\t\t\n\t\telse # both are higher; mid is smallest\n\t\t\tlowestScore = temp1\n\t\t\tanswer = answer1\n\t\t\tstayed = 1\n\t\t\tdifference = difference + difference_interval\n\t\t\tif difference > difference_limit\n\t\t\t\tdifference = difference_limit\n\t\t\tend\n\t\tend\n\t end\n end\n\n \n return answer\nend",
"def look_ahead(board, current_hand, ai_hand)\n #n = NegamaxAgent.new(board, current_hand, ai_hand)\n #n_suggested_move = n.invoke\n #n_suggested_card = n_suggested_move.first\n #n_x = n_suggested_move[1]\n #n_y = n_suggested_move[2]\n #n_s = n_suggested_move[3]\n\n #puts \"DEBUG: negamax suggested #{@player_hand.key(n_suggested_card)} @ #{n_x + 1}, #{n_y + 1} with score of #{n_s}\"\n #return\n\n available_cards = current_hand.values.compact\n available_spaces = board.open_spaces\n possible_moves = available_cards.product(available_spaces)\n\n best_moves = []\n value_of_best_move = -10\n\n possible_moves.each do |card, space|\n x, y = space\n value = board.next_state(card, x, y).score\n if value > value_of_best_move\n best_moves = [[card, x, y]]\n value_of_best_move = value\n elsif value == value_of_best_move\n \tbest_moves << [card, x, y]\n end\n end\n\n chosen_move = best_moves.sample\n card, x, y = chosen_move\n\n puts \"HINT: placing #{current_hand.key(card).rstrip} at #{x+1}, #{y+1} gives a good score of #{value_of_best_move}\"\n end",
"def greedy1_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n # Test each site ...\n src_partition.sites.each do |site|\n\n simulation_result_below_bound = {}\n simulation_result_above_bound = {}\n # ... in each bin ...\n self.each_with_index do |bin, bin_index|\n target_partition = bin.list[src_partition.name]\n if target_partition.nil?\n # Creating a new partition is more costly than the worst case\n operations = @operations_worst_case + 1\n else\n # Simulate insertion of site into existing partition of current bin\n operations = target_partition.incr_add_sites!([site], simulate = true)\n end\n # Check if bin.size is smaller than lower_bound. Save simulation_result accordingly to prefer addition below lower_bound.\n if bin.update_size!.size < @operations_lower_bound\n simulation_result_below_bound.merge!({operations => bin_index})\n else\n simulation_result_above_bound.merge!({operations => bin_index})\n end\n\n end\n\n # Insert at lowest operation cost\n best = if simulation_result_below_bound.empty?\n simulation_result_above_bound.min_by { |operations, bin_index| operations }\n else\n simulation_result_below_bound.min_by { |operations, bin_index| operations }\n end\n target_partition = @list[best[1]].list[src_partition.name]\n if target_partition.nil?\n @list[best[1]].add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\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 optimize_kevin_bacon_search\n\t\t# winning_attempts = []\n\t\t# find_kevin_bacon_2(winning_attempts)\n\t\t# if winning_attempts.count > 0\n\t\t\t# winning_attempts.each do |attempt|\n\t\t\t\t# compare with a neighbor, shorter one wins\n\t\t\t\t# there will be lots of ties we skip over\n\t\t# else\n\t\t\t# returns nil\n\t\t# end\n\t\twinning_attempts = []\n\t\tfind_save_kevin_bacon(start_node, winning_attempts)\n\t\twinning_attempts.compact!\n\t\tif winning_attempts.count == 0\n\t\t\tputs 'no bacon :('\n\t\telse\n\t\t\twinning_attempts.index do |i|\n\t\t\t\tif i != 0\n\t\t\t\t\tif winning_attempts[i - 1] < winning_attempts[i]\n\t\t\t\t\t\twinning_attempts.delete_at(i)\n\t\t\t\t\telse\n\t\t\t\t\t\twinning_attempts.delete_at(i - 1)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\twinning_attempts\n\tend",
"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 update_possible!()\r\n\r\n #falls es keine Hits gibt, werden ale Tipps geloescht, die eine der Ziffern enthalten\r\n if (@last_hits == [0,0])\r\n @digits.times do |i|\r\n\r\n @left.delete_if{ |x|\r\n x.include?(@last_guess[i])\r\n }\r\n\r\n end\r\n\r\n end\r\n\r\n #falls es keine Black Hits gibt, werden alle Tipps mit einer identischen Stelle geloescht\r\n if @last_hits[0]==0\r\n\r\n @digits.times do |i|\r\n\r\n @left.delete_if { |x|\r\n x[i]==@last_guess[i]\r\n }\r\n end\r\n\r\n end\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Black Hits entspricht\r\n @left.delete_if { |x|\r\n @last_hits[0] != @mastermind.hits(@last_guess,x)[0]\r\n }\r\n\r\n #loescht alle, deren Uebereinstimmung mit dem letzten Tipp nicht den Total Hits entspricht\r\n @left.delete_if { |x|\r\n (@last_hits[0] + @last_hits[1]) != (@mastermind.hits(@last_guess,x)[0][email protected](@last_guess,x)[1])\r\n }\r\n\r\n end",
"def optimize(weight)\r\n return 0 if weight <= 0\r\n\r\n best = nil\r\n $items.each do |item|\r\n c = optimize(weight - item.weight) + item.cost\r\n best = c if best.nil? || c < best\r\n end\r\n best\r\nend",
"def optimize3(weight, cost=0, items = $items)\r\n return cost if weight <= 0 || items.empty?\r\n # puts \"#{weight}\\t#{cost}\\t#{items.collect{|i| i.weight}.join(' ')}\"\r\n same_ratio = items.find_all { |i| i.ratio == items[0].ratio }\r\n global_best = nil\r\n same_ratio.size.times do |x|\r\n if weight % items[x].weight == 0\r\n return items[x].cost * (weight / items[x].weight) + cost\r\n end\r\n \r\n best = (x == 0) ? items[x].cost * (weight / items[x].weight + 1) + cost : nil\r\n \r\n (items - [items[x]]).each do |item|\r\n if x == 0\r\n c = optimize3(weight % items[x].weight, items[x].cost * (weight / items[x].weight) + cost, items - [items[x]])\r\n else\r\n c = optimize3(weight - items[x].weight, items[x].cost + cost, items)\r\n end\r\n best = c if (best.nil? || c < best)\r\n end\r\n global_best = best if best && (global_best.nil? || best < global_best)\r\n end\r\n global_best\r\nend",
"def update_map\n @win_flag = false\n @lose_flag = false\n @eliminate_flag = false\n @my_planets = {}\n @max_rearness = 0\n\n nil_planets_ratio = @info['holds'].select { |h| h[0].nil? }.size\n nil_planets_ratio /= @info['holds'].size.to_f\n if nil_planets_ratio > 0.618\n @aggresion = AGGRESSION_START\n puts \"Aggression: #@aggresion\"\n else\n @aggresion = AGGRESSION_MID\n end\n\n @map['planets'].each_with_index do | p, ind |\n # Check whether it is owned by me\n if @info['holds'][ind][0] == @me['seq']\n # my_planet:\n # - targets: enemy planet candidates to attack if a front line planet, or next planet of the shortest path to the nearest front line planet if a rear planet\n # - rearness: how far away from the front line, 0 for planet on the front line\n my_planet = {}\n\n # Check whether on the front line\n targets = p['neighbors'].select { |n| @info['holds'][n[0]][0] != @me['seq'] }\n if targets.size > 0 # On the front line\n my_planet[:targets] = targets\n my_planet[:rearness] = 0\n end\n\n my_neighbors = p['neighbors'].select { |n| @info['holds'][n[0]][0] == @me['seq'] }\n my_planet[:my_neighbors] = my_neighbors\n\n @my_planets[ind] = my_planet\n end\n end\n\n # Compute rearness and path of my rear planets iteratively\n my_planets = @my_planets\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n\n if @my_planets.empty?\n @lose_flag = true\n puts \"We lose! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n return\n elsif left_planets.size == @my_planets.size\n # Check whether moving enemies exist\n moving_enemies = @info['moves'].select { |m| m[0] != @me['seq'] }\n if ! moving_enemies.empty?\n puts \"Eliminating left enemies! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n @eliminate_flag = true\n moving_enemies.each do |m|\n @my_planets[m[2]][:rearness] = 0\n @my_planets[m[2]][:targets] = []\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n end\n else\n @win_flag = true\n puts \"We win! (planets #: #{left_planets.size} / #{@my_planets.size})\"\n return\n end\n end\n\n while ! left_planets.empty?\n left_planets.each do |id, p|\n neighbors = @map['planets'][id]['neighbors'].reject { |n| my_planets[n[0]][:rearness].nil? }\n next if neighbors.empty? # Very important! Used to be a bug!!!\n nearest_neighbor = neighbors.map { |n| [ n[0], my_planets[n[0]][:rearness] + n[1] ] }.min_by { |n| n[1] }\n @my_planets[id][:targets] = nearest_neighbor[0]\n @my_planets[id][:rearness] = nearest_neighbor[1]\n @max_rearness = [@max_rearness, nearest_neighbor[1]].max\n end\n\n my_planets = @my_planets\n left_planets = @my_planets.select { |id, p| p[:rearness].nil? }\n # puts \"# of my planets: #{left_planets.size} / #{@my_planets.size}\"\n end\n end",
"def cost_estimate\n @cost_estimate ||= @base_cost + @maze.furthest_key_distance(@at, @subset_mask)\n end",
"def greedy_solve problem\n start_time = Time.now\n items = problem.item_footprints.sort\n current = []\n items.each do |footprint|\n cands = (0..problem.path_funcs.length - 1).to_a.map do |path|\n c = current.map{|i| i.clone}\n c << Item.new(footprint, path)\n c\n end.map{|s| {:solution => s, :objective_func => objective_function(s, problem.path_funcs)}}\n current = cands.reduce{|x,y| x[:objective_func] > y[:objective_func] ? x : y}[:solution]\n end\n {:solution => current, :objective_func => objective_function(current, problem.path_funcs), \n :elapsed_time => Time.now - start_time}\n end",
"def a_star(start,goal)\n\t\treturn false # TODO make this actually work\n\t\t###########################################\n\t\tchecked = []\n\t\toptions = [start]\n\t\tpath = []\n\t\tg_score = Array.new($dimensions[:y], Array.new($dimensions[:x], Infinity))\n\t\th_score = Array.new($dimensions[:y], Array.new($dimensions[:x], Infinity))\n\t\tf_score = Array.new($dimensions[:y], Array.new($dimensions[:x], Infinity))\n\t\tg_score[start[:y]][start[:x]] = 0\n\t\th_score[start[:y]][start[:x]] = distance(start, goal, :diagonal)\n\t\tf_score[start[:y]][start[:x]] = h_score[start[:y]][start[:x]]\n\t\tuntil options.empty?\n\t\t\toption_scores = options.map{|o| f_score[o[:y]][o[:x]]}\n\t\t\tcurr = options.delete_at option_scores.index(option_scores.min)\n\t\t\tputs curr\n\t\t\treturn false if curr == goal\n\t\t\tchecked << curr\n\t\t\tcollect_adjacent_points(curr).each do |neighbor|\n\t\t\t\tnext if checked.include? neighbor\n\t\t\t\ttentative_g_score = g_score[curr[:y]][curr[:x]] + 1 # 1 == dist_between(curr,neighbor)\n\t\t\t\tif !options.include? neighbor\n\t\t\t\t\toptions << neighbor\n\t\t\t\t\ttentative_is_better = true\n\t\t\t\telsif tentative_g_score < g_score[neighbor[:y]][neighbor[:x]]\n\t\t\t\t\ttentative_is_better = true\n\t\t\t\telse\n\t\t\t\t\ttentative_is_better = false\n\t\t\t\tend\n\t\t\t\tif tentative_is_better\n\t\t\t\t\tg_score[neighbor[:y]][neighbor[:x]] = tentative_g_score\n\t\t\t\t\th_score[neighbor[:y]][neighbor[:x]] = distance(neighbor, goal)\n\t\t\t\t\tf_score[neighbor[:y]][neighbor[:x]] = g_score[neighbor[:y]][neighbor[:x]] + h_score[neighbor[:y]][neighbor[:x]]\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\ttrue\n\tend",
"def manhattan_heuristic(queue)\n queue.inject do |chosen_point, point|\n old_f = find_manhattan_estimate(chosen_point)\n new_f = find_manhattan_estimate(point)\n old_f > new_f ? point : chosen_point\n end\n end",
"def calcFitness(game_sim)\r\n\t\t@heuristic[0] = game_sim.snek.weights[0]*game_sim.distance_from_food\r\n\t\t@heuristic[1] = game_sim.snek.weights[1]*game_sim.squareness\r\n\t\t@heuristic[2] = game_sim.snek.weights[2]*game_sim.compactness\r\n\t\t@heuristic[3] = game_sim.snek.weights[3]*game_sim.score\r\n\t\t@heuristic[4] = game_sim.snek.weights[4]*game_sim.connectivity\r\n\t\t@heuristic[5] = game_sim.snek.weights[5]*game_sim.dead_end\r\n\t\treturn @heuristic.sum # sum of heuristics = fitness\r\n\tend",
"def greedy(tg,faulty,replacements,n)\n result = Hash.new\n repl = Array.new(replacements.size) {|i| replacements[i]}\n # sort tg by # successors\n sort_by_subtree_size!(tg)\n\n # sort faulty by # successors\n faulty.sort_by!{|a| tg[0].index(lookup_task(tg,a))}\n \n faulty.each do |fault|\n # pick the replacement which minimizes starting time of fault\n choice = repl.min_by{|a| euclidean_distance(tg,result.merge({fault=>a}),n)}\n # add the mapping to the solution\n result[fault] = choice\n # remove the replacement from the set\n repl.delete(choice)\n end\n return result\nend",
"def optimize_for_location(params)\n flight_floor = params[:flight_floor] || 5000 #meters\n flight_ceiling = params[:flight_ceiling] || 60000 #meters\n\n #verify parameters\n params = params.with_indifferent_access\n\n raise 'No start altitude (params[:start][:altitude])' unless params[:start][:altitude].present?\n raise 'No start latitude (params[:start][:lat])' unless params[:start][:lat].present?\n raise 'No start longitude (params[:start][:lon])' unless params[:start][:lon].present?\n raise 'No start time (params[:start][:time])' unless params[:start][:time].present?\n\n raise 'No finish latitude (params[:finish][:lat])' unless params[:finish][:lat].present?\n raise 'No finish longitude (params[:finish][:lon])' unless params[:finish][:lon].present?\n\n # creates a filter lambda to check that any path passes certain conditions\n filter = lambda {|node, previous|\n node.altitude < flight_ceiling &&\n node.altitude > flight_floor &&\n # (!x || y) checks y only if x is true\n (!params[:use_faa] || node.faa_zones_approx(previous)) && #no restricted zones\n (!params[:check_countries] || node.countries(previous))\n }\n\n #run the search with the provided start, duration, and performance factor\n greedy_search({\n start: Node.from_pos(\n params[:start][:lat].to_f, params[:start][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n finish: Node.from_pos(\n params[:finish][:lat].to_f, params[:finish][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n movement_cost: lambda {|current|\n #vent / ballast costs are proportional to the square of the altitude change\n (current.parent.altitude - current.altitude).abs/1200000.0\n },\n heuristic: lambda {|current|\n ((current.parent.lon - current.lon) / Prediction::time_variance)\n },\n neighbors: lambda {|current|\n current.neighbors(filter)\n },\n build_from_finish: lambda{|finish|\n finish.build_chain\n },\n timeout: params[:timeout],\n performance: params[:performance]\n })\n\n end",
"def findMaximum(weights)\n\t\n\tputs \"Weights\" if DEBUG_OUTPUT\n\tprintMatrix(weights) if DEBUG_OUTPUT\n\t# l(x) == l[x]\n\t\t\n\teq = EqualityGraph.new(weights)\n\teq.generateLabelFunctions()\n\t\n\t#Generate equality graph\n\t\n\teq.generateEqualityGraph()\n\t\n\t#Pick an abitrary matching in the equality subgraph\n\t\n\teq_match = MatchGraph.new(eq.x_vertices, eq.y_vertices)\n\t\n\teq.initialMatch(eq_match)\t\n\t\n\tputs \"Equality Match\\n#{eq_match.to_s}\" if DEBUG_OUTPUT\n\t\n\t#puts \"Is Equality Match perfect? #{eq_match.isPerfectMatch}\" if DEBUG_OUTPUT\n\t\t\t\n\tuntil(eq_match.isPerfectMatch)\n\t\t#Pick a free vertex in X\n\t\tfreeX = eq_match.get_free_x_vertex\n\t\t\n\t\teq_match.alt_tree_x_nodes.push(freeX)\n\t\t\t\n\t\tputs \"\\nMAJOR STEP Picked a free X: #{freeX}\" if DEBUG_OUTPUT\n\t\t\n\t\ts_vertices = [ freeX ]\n\t\tt_vertices = Array.new\n\t\t\n\t\t#Though sets s and t should be enough, will keep track of the alternating paths \n\t\t#originating at freeX\n\t\t\n\t\t\n\t\ts_neighbors = eq.get_neighbors_of_x_vertices(s_vertices).to_set\n\t\t\n\t\ts_neighbors_not_in_t = s_neighbors.to_a\n\t\t\n\t\tuntil(false)\n\t\t\tputs \"S = #{s_vertices.to_a} N(S) = #{s_neighbors.to_a} T= #{t_vertices.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\n\t\t\tif s_neighbors.size == t_vertices.size\n\t\t\t\tputs \"\\nSTEP No more s_neighbors to process, growing eq\" if DEBUG_OUTPUT\n\t\t\t\told_size = s_neighbors.size\n\t\t\t\t\n\t\t\t\teq.growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t)\n\t\t\t\t\n\t\t\t\traise \"s neighbors did not increase\" if s_neighbors.size <= old_size\t\t\t\t\t\t\n\t\t\telse\n\t\t\t\tputs \"\\nSTEP Picking a new Y not yet in T from S neighbors\" if DEBUG_OUTPUT\n\t\t\t\t#pick y\n\t\t\t\ty = s_neighbors_not_in_t.pop #(s_neighbors - t_vertices).find { true } \n\t\t\t\tif eq_match.is_y_vertex_free(y)\n\t\t\t\t\t#Reset S and T\n\t\t\t\t\traise \"T and S are out of wack\" if s_vertices.size != t_vertices.size + 1\t\t\t\t\t\n\t\t\t\t\teq_match = growMatch(y, eq_match, eq, freeX)\n\t\t\t\t\tputs \"Grew match Equality Graph was #{eq}\" if DEBUG_OUTPUT\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tputs \"y[#{y}] is matched\" if DEBUG_OUTPUT\n\t\t\t\t\tnew_s_node = growTree(s_vertices, t_vertices, y, eq, eq_match)\n\t\t\t\t\t\n\t\t\t\t\tnew_s_neighbors = eq.get_neighbors_of_x_vertices( [new_s_node] )# - t_vertices\n\t\t\t\t\ts_neighbors.merge( new_s_neighbors )\n\t\t\t\t\t#new_s_neighbors could intesect with t\n\t\t\t\t\ts_neighbors_not_in_t = (s_neighbors - t_vertices).to_a\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\tend\n\t\n\tputs \"Sum is #{eq_match.sumEdgeWeights(weights)}\" if DEBUG_OUTPUT\n\t\n\treturn eq_match.sumEdgeWeights(weights)\nend",
"def exec_search_nCOP_heruistic\n # select a starting node\n s_gene = get_start_gene\n \n # initialize cover and other variables\n cover, cov_pat, $explored = [], Set.new, Set.new\n cover << s_gene and cov_pat.merge $genes[s_gene]\n start_cost = cost_func cover, cov_pat.size\n \n # run nCOP greedy heuristic\n nCOP_heuristic(cover, cov_pat, start_cost)\n \n # learn which genes are bad starting nodes\n if cover.size < 3\n $bad_starting_genes << s_gene\n end\n \n # return the cover found\n cover\nend",
"def calculate\n roundtrips = []\n\n if !@exit_nodes.empty?\n closest_to_all = closest_nodes_to_all(@graph.vertices, @exit_nodes, 666)\n roundtrips << find_roundtrip(Array.new(@exit_nodes))\n roundtrips << find_roundtrip(Array.new(@exit_nodes), true)\n roundtrips << find_roundtrip(Array.new(@exit_nodes) + closest_to_all)\n roundtrips << find_roundtrip(Array.new(@exit_nodes) + closest_to_all, true)\n else\n # No exit nodes - component is probably a loop. Need to consider all nodes and try to find two furthest ones.\n roundtrips << find_roundtrip(@graph.to_undirected.furthest_pair_of_nodes(@graph.vertices))\n end\n\n @@log.debug \" roundtrips = #{roundtrips}\"\n @roundtrip = select_best_roundtrip(roundtrips)\n @@log.debug \" best_roundtrip = #{@roundtrip}\"\n end",
"def test_HEURISTIC_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1979, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.heuristic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2516, p.heuristic)\n\n\n\n end",
"def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend",
"def search( grid, init , deltas, cost, goal , delta_names)\n # ----------------------------------------\n # insert code here and make sure it returns the appropriate result\n # ----------------------------------------\n closed = copy_array_dimensions grid\n expand = copy_array_dimensions grid #, -1\n action = copy_array_dimensions grid, -1\n\t#initalize starting location \n\tclosed[init[0]][init[1]] =1\n\n\tx = init[0]\n\ty = init[1]\n\tg = 0 \n\t\n\topen = [[g,x,y]]\n\tputss 'open', open\n\tputss closed\n\tprint_array expand\n\t#flags\n\tfound = false\n\tresign = false \n\t\n\twhile ( found == false && resign == false )\n\t\t\n\t\tif open.size == 0 \n\t\t\tresign = true \n\t\t\tputs 'fail'\n\t\t\tclosed.each do | row | \n\t\t\t\tputs row.inspect\n\t\t\tend\n\t\telse\n\t\t\topen.sort()\n\t\t\topen.reverse()\n\t\t\tnext_ = open.pop() #use unshift\n\t\t\tputss 'next', next_[0], next_[1]\n\t\t\tx = next_[1] \n\t\t\ty = next_[2]\n\t\t\tg = next_[0] \n\t\t\t\n\t\t\tif x == goal[0] && y == goal[1]\n\t\t\t\tfound = true \n\t\t\t\tputss 'done', next_\n\t\t\telse\n\t\t\t\t#apply action , nod eexpantion\n\t\t\t\tdeltas.each_with_index do | delta, i | \n\t\t\t\t\tx2 = x + delta[0]\n\t\t\t\t\ty2 = y + delta[1]\n\t\t\t\t\tif x2 >= 0 && x2 < grid.size &&\n\t\t\t\t\t\ty2 >= 0 && y2 < grid[0].size\n\t\t\t\t\t\t#putss 'add to open list', [ x2, y2]\n\t\t\t\t\t\t#if not closed and natvigable \n\t\t\t\t\t\tif closed[x2][y2] == 0 && grid[x2][y2] == 0 \n\t\t\t\t\t\t\tg2 = g + cost\n\t\t\t\t\t\t\topen << [g2, x2, y2]\n\t\t\t\t\t\t\texpand[x2][y2] = g2\n\t\t\t\t\t\t\t#putss 'add to open list', [ x2, y2]\n\t\t\t\t\t\t\tclosed[x2][y2] = 1\n\t\t\t\t\t\t\taction[x2][y2] = i\n\t\t\t\t\t\tend\n\t\t\t\t\t\tif grid[x2][y2] != 0 \n\t\t\t\t\t\t\texpand[x2][y2] = -1\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\t\n\t\n\t#\n\tpolicy = copy_array_dimensions grid, ' '\n\tx = goal[0]\n\ty = goal[1]\n\tpolicy[x][y] = '*'\n\t\n\tprint_array action\n\tputss init, x, y\n\t#return\n\tif resign != true\n\t\twhile ( x != init[0] && y != init[1] )\n\t\t\t#apply inverse action \n\t\t\tx2 = x - deltas[action[x][y]][0]\n\t\t\ty2 = y - deltas[action[x][y]][1]\n\t\t\tpolicy[x][y] = delta_names[action[x][y]]\n\t\t\tx = x2\n\t\t\ty = y2\n\t\tend\n\t\t\n\t\tprint_array policy\n\tend\n\texpand\nend",
"def minimize\n# create a new one, or modify the current one in place,\n# and return it\nfa = FiniteAutomaton.new\nkeys = @state.keys.sort\np0, p1 = [], []\nkeys.each{|k|\nif is_final?(k)\np0 = p0.push(k)\nelsif\np1 = p1.push(k)\nend\n}\nnewfa = {}\nrstate = []\nif p0 != nil then rstate.push(p0) end\nif p1 != nil then rstate.push(p1) end\npstate = []\nwhile pstate != rstate\npstate = []\nrstate.each{|r| pstate.push(r)}\nrstate = []\npstate.each{|p|\np = p.sort\nresult = split(p, pstate)\np0 = result[0]\np1 = result[1]\nresult.each{|r|\nif r != []\nr = r.sort\nrstate = rstate.push(r)\nend\n}\n}\nend\nstart = []\nfinal = []\nrstate.each{|r| newfa[r] = fa.new_state}\nlist = newfa.keys\nlist.each{|l|\nl.each{|k|\nif k == @start\nstart.push(l)\nend\nif is_final?(k)\nfinal.push(l)\nend\n}\n}\nif start != []\nstart.each{|s| if newfa[s] then fa.set_start(newfa[s]) end}\nend\nif final != []\nfinal.each{|f| fa.set_final(newfa[f], true)}\nend\nrstate.each{|r0|\nr0.each{|r1|\[email protected]{|a|\nif get_transition(r1, a) != nil\nrstate.each{|r|\nif r.include?(get_transition(r1, a)[0])\nif !(fa.get_transition(newfa[r0], a))\nfa.add_transition(newfa[r0], newfa[r], a)\nif fa.get_alpha.include?(a) == false\nfa.get_alpha.push(a)\nend\nend\nend\n}\nend\n}\n}\n}\nfa\nend",
"def solve(begX, begY, endX, endY)\n #first create two points object as starting point and destination\n start = Point.new(begX,begY)\n @final = Point.new(endX,endY)\n #first initialize these objects in case that there are\n #data left after last iteration of solve\n @tnode = nil\n @traceSet = Set.new\n @traceArray = Array.new\n if start.isEqual(@final)\n @tnode = start\n true\n else\n @traceSet.add(start.to_S)\n @traceArray.push(start)\n\n #start sloving\n newp = @traceArray.shift\n #we don't stop until all the possible pathes are tested\n\n while newp != nil && @tnode == nil do\n #test each route and if we reach the destination, immediately break\n #the while loop\n\n #test if we can move upward\n move(2*newp.x+1,2*newp.y,newp.x,newp.y-1,newp)\n\n #test if we can move downward\n move(2*newp.x+1,2*newp.y+2,newp.x,newp.y+1,newp)\n\n #test if we can move leftward\n move(2*newp.x,2*newp.y+1,newp.x-1,newp.y,newp)\n\n #test if we can move rightward\n move(2*newp.x+2,2*newp.y+1,newp.x+1,newp.y,newp)\n\n #move to the next cell\n newp = @traceArray.shift\n end\n\n #if the current cell is nil, it means we have no solution for this maze puzzle\n if newp == nil\n false\n else #else return true\n true\n end\n end\n end",
"def identify_neighbours\n @x.times{ |r|\n @y.times{|c| \n #+1,+1 0,+1 +1,0\n @mat[r][c].add_neighbour @mat[r+1][c+1] unless @mat[r+1].nil? || @mat[r+1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r][c+1] unless @mat[r].nil? || @mat[r][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c] unless @mat[r+1].nil? || @mat[r+1][c].nil?\n \n #-1,-1 0,-1 -1,0\n @mat[r][c].add_neighbour @mat[r-1][c-1] unless @mat[r-1].nil? || @mat[r-1][c-1].nil?\n @mat[r][c].add_neighbour @mat[r-1][c] unless @mat[r-1].nil? || @mat[r-1][c].nil?\n @mat[r][c].add_neighbour @mat[r][c-1] unless @mat[r].nil? || @mat[r][c-1].nil?\n \n #+1,-1 -1,+1\n @mat[r][c].add_neighbour @mat[r-1][c+1] unless @mat[r-1].nil? || @mat[r-1][c+1].nil?\n @mat[r][c].add_neighbour @mat[r+1][c-1] unless @mat[r+1].nil? || @mat[r+1][c-1].nil?\n \n }\n \n } \n end",
"def enum_moves\n @scratch = dup_maze(@maze)\n @locs.each_with_index do |loc, robot|\n @cost = 1\n leading_edge = [loc]\n loop do\n next_edge = []\n leading_edge.each do |x, y|\n next_edge.concat search_from(x, y, robot)\n end\n break if next_edge.empty?\n leading_edge = next_edge\n @cost += 1\n end\n end\n\n @moves\n end",
"def calculate_hcost(p)\n\t\tdistance = (@end_pos[0] - p[0]).abs + (@end_pos[1] - p[1]).abs\n\t\tdistance * COST_ORT\n\tend",
"def cost_function(state, home_team, away_team)\n match_set = Set[home_team, away_team]\n cost = 0\n\n # Reduce score distance between teams\n cost += ((state.scores[home_team] || 0) - (state.scores[away_team] || 0)).abs\n\n # The cost of a duplicate is the score range + 1\n cost += (state.score_range + 1) * state.matches[match_set] unless state.allow_duplicates\n\n # Add cost for bye matches not on the preferred side\n push_byes_to = state.push_byes_to\n if match_set.include?(nil) && push_byes_to != :none\n index = state.team_index_map[home_team || away_team]\n\n if (push_byes_to == :bottom_half && index < state.teams.length / 2) ||\n (push_byes_to == :top_half && index > state.teams.length / 2)\n cost += state.score_range\n elsif push_byes_to == :lowest_score\n cost += state.score_range * (state.teams.length - index)**2\n end\n end\n\n cost\n end",
"def minimize; end",
"def dij(linkPackageMap, native)\nputs \"start dij\"\ndist = Hash.new();\nprevNode = Hash.new();\ntraversed = Array.new;\nallNodes = linkPackageMap.keys;\n#for i in 0..allNodes.length - 1\n#\tdist[allNodes[i]] = -1;\n#\tprevNode[allNodes[i]] = nil;\n#end\ndist[native] = 0;\nprevNode[native] = native;\n#q = PriorityQueue.new\n#q[native] = 0;\n\nq = Pqueue.new();\nq.push(native, 0);\n\n\nuntil q.isEmpty()\n\tu, distance = q.pop();\n\ttraversed.push(u);\n\t#puts u;\n\t#puts distance;\n\tuNeighborMap = linkPackageMap[u].map();\n\t#puts uNeighborMap.keys;\n\tuNeighbors = uNeighborMap.keys\n\tfor i in 0..uNeighbors.length - 1\n\t\t#puts uNeighbors[i]\n\t\tif !traversed.include?(uNeighbors[i]) then\n\t\t\tnewDistance = dist[u].to_i + uNeighborMap[uNeighbors[i]].to_i;\n\t\t\tif dist[uNeighbors[i]] == nil then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\telse \n\t\t\t\tif newDistance < dist[uNeighbors[i]] then\n\t\t\t\tdist[uNeighbors[i]] = newDistance\n\t\t\t\tprevNode[uNeighbors[i]] = u;\n\t\t\t\tend\n\t\t\tend\n\t\t\tq.push(uNeighbors[i], dist[uNeighbors[i]].to_i);\n\t\t\t#q[uNeighbors[i]] = dist[uNeighbors[i]].to_i;\n\t\tend\n\t\t\t\n\tend\n\nend\n\n\n\nnodes = prevNode.keys;\n#puts nodes;\nnativeNeighbor = linkPackageMap[native].map();\n#nativeNeighbor.each{|key, value| puts \"key : #{key} value : #{value}\"}\nfor i in 0 .. nodes.length - 1\n\tif prevNode[nodes[i]] == native then\n\t\tprevNode[nodes[i]] = nodes[i];\n\telse\n\t\twhile(!nativeNeighbor.include?(prevNode[nodes[i]]) )\n\t\t\tprevNode[nodes[i]] = prevNode[prevNode[nodes[i]]];\n\t\tend\t\n\tend\nend\n\nreturn dist, prevNode;\nend",
"def rule2\n c = V::ZERO\n\n hits = 0\n\n nearby.each do |b|\n next if self == b\n diff = b.position - self.position\n next unless diff.magnitude.abs < TOO_CLOSE\n hits += 1\n c -= diff if diff.magnitude.abs < TOO_CLOSE\n end\n\n c /= hits unless hits == 0 # average it out so they don't overdo it\n\n c / 8\n end",
"def problem_107\n if false\n net = [ \"-,16,12,21,-,-,-\", \"16,-,-,17,20,-,-\", \"12,-,-,28,-,31,-\",\n \"21,17,28,-,18,19,23\", \"-,20,-,18,-,-,11\", \"-,-,31,19,-,-,27\",\n \"-,-,-,23,11,27,-\" ]\n net.map! {|line| line.split(/,/).map {|i| i == '-' ? nil : i.to_i}}\n else\n net = []\n open(\"network.txt\").each do |line|\n net << line.chomp.split(/,/).map {|i| i == '-' ? nil : i.to_i}\n end\n end\n\n # Reformat into an array of nodes, with the their connections\n nodes = Hash.new {|h,k| h[k] = Hash.new }\n net.each_with_index do |row,i| # Each nodes is connected to...\n row.each_index do |col| # For each possible connection....\n # Add the node we are connected to and the cost\n nodes[i][col] = row[col] if row[col]\n end\n end\n\n initial = nodes.reduce(0) do |a,row|\n row[1].reduce(a) {|aa,p| aa + p[1] }\n end / 2\n # add to the 'borg' that is node0\n node0,node0_links = nodes.shift\n ans = []\n node0_contains = Hash.new\n node0_contains[node0] = true\n\n # What we do select the lowest link, the 'merge' it into node0, repeat\n while nodes.length > 0\n n,v = node0_links.min {|a,b| a[1] <=> b[1]}\n ans << [n,v] # Save the link for the answer\n node0_contains[n] = true # add to the 'borg' that is node0\n nodes[n].each_pair do |k,a| # Now merge in new poin, update vertexs\n next if node0_contains[k]\n node0_links[k] = [a, node0_links[k] || 1_000_000].min\n end\n nodes.delete(n) # Remove from free nodes\n node0_links.delete(n) # Remove from vertexes to resolve\n end\n\n now = ans.reduce(0) {|a,v| a + v[1]}\n puts \"initial = #{initial}\"\n puts \"now = #{now}\"\n initial - now\nend",
"def derive_moves_metadata(s)\n # puts \"Deriving move metadata...\" #NICE TO HAVE\n known_moves = Array.new(s[:num_moves]) {|e| e = {x: -1, y: -1}}\n unknown_moves = [*1..s[:num_moves]]\n for y in 0...s[:moves].length do\n row = s[:moves][y]\n for x in 0...row.length do\n if s[:moves][y][x] > 0\n known_moves[s[:moves][y][x]-1] = {x: x, y: y}\n unknown_moves = unknown_moves - [s[:moves][y][x]]\n end\n end\n end\n m = -1\n if not unknown_moves.empty?\n m = unknown_moves[0]\n end\n next_highest_known_m = -1\n for i in m...known_moves.length do\n if known_moves[i][:x] != -1\n next_highest_known_m = i\n break\n end\n end\n next_highest_unknown_m = -1\n unknown_moves.each do |unknown_move|\n if unknown_move >= m\n next_highest_unknown_m = unknown_move\n break\n end\n end\n # I'm really bothered by this part, but as stated up top, this is being done\n # for the sake of simplicity for now, and will be refactored later...\n r_known_cells = Array.new(s[:r_num_cells].length) {|e| e = Array.new()}\n r_free_cells = s[:r_num_cells].clone\n for i in 0...known_moves.length do\n next if known_moves[i][:x] == -1\n r = s[:regions][known_moves[i][:y]][known_moves[i][:x]]\n r_free_cells[r] -= 1\n r_known_cells[r].push(i+1)\n end\n s[:m] = m\n s[:known_moves] = known_moves\n s[:unknown_moves] = unknown_moves\n s[:next_highest_known_m] = next_highest_known_m\n s[:next_highest_unknown_m] = next_highest_unknown_m\n s[:r_known_cells] = r_known_cells\n s[:r_free_cells] = r_free_cells\nend",
"def heuristic_score(state)\n pieces = state[:pieces]\n player = state[:player]\n total_value(pieces[player]) - total_value(pieces[opponent(player)])\n end",
"def generate_best_pairings(state)\n teams = state.teams\n\n state.matches = state.driver.matches_hash\n\n state.score_range = state.scores.values.max - state.scores.values.min\n state.average_score_difference = state.score_range / teams.length.to_f\n\n state.team_index_map = teams.map.with_index.to_h\n\n Algorithm::Matching.minimum_weight_perfect_matching(teams) do |home_team, away_team|\n cost_function(state, home_team, away_team)\n end\n end",
"def hill_climbing(location)\n best = @fqueryObj\n score = @fqueryObj.score\n loc = location.to_s\n parseTree = @fqueryObj.parseTree\n\n # create stat table\n @tqueryObj.create_stats_tbl\n # rst = parseTree.constr_jsonpath_to_location(location)\n # last=rst.count-1\n # rst.delete_at(last)\n\n # predicatePath = '$..'+rst.map{|x| \"'#{x}'\"}.join('.')\n # predicatePath = parseTree.get_jsonpath_from_location(location)\n # predicate = JsonPath.new(predicatePath).on(parseTree)\n\n # generate_candiateList(predicate)\n # generate_candidateConstList()\n # @tabuList=[]\n\n i = 0\n while (i <= @max_iter) && score[loc].to_i > 0\n # neighbor = generate_neighbor_program(parseTree,predicatePath)\n neighbor = @fqueryObj.generate_neighbor_program(location, 1)\n if neighbor.nil?\n puts 'no candidates available! '\n break\n end\n # neighbor.table='evl_tbl'\n evaluate_query(neighbor, @tqueryObj)\n s = neighbor.score\n\n if s[loc].to_i < score[loc].to_i\n score = s\n best = neighbor\n end\n puts \"iteration: #{i}\"\n puts'current best query'\n puts best.query\n i += 1\n end\n end",
"def search(path, final_point)\n\n current = path.first\n puts \"current.center = #{current.center}\"\n puts \"final_point.center = #{final_point.center}\"\n puts \"path.size = #{path.size}\"\n puts \"path = #{path.map{ |p| [p.center,p.wp_visited?].flatten }}\"\n puts \"current.wp_visited? = #{current.wp_visited?}\"\n\nbinding.pry # => debugger\n\n if wp_distance2(current, final_point) < 1.0\n puts \"found\"\n return path.reverse\n end\n\n wp_adjacents = sort_and_filter(current.wp_adjacents, final_point)\n\n wp_adjacents.each do |wp|\n search(path.unshift(wp), final_point)\nbinding.pry # => debugger\n wp.wp_mark\n end\n end",
"def calc_fitness\n raise \"target phrase is not yet set\" unless $target_phrase\n count = 0.0\n $target_phrase.length.times do |position|\n if @data[position] == $target_phrase[position]\n count += 1.0\n end\n end\n\n @fitness = count / $target_phrase.length\n\n if @fitness == 1.0\n data_copy = @data.dup\n data_copy.slice! $target_phrase\n if data_copy.empty?\n $finished = true\n return true\n else\n data_copy.each_char do\n @fitness -= 1.0 / $target_phrase.length\n end\n end\n end\n return @fitness\n end",
"def find_best_way(xx,yy)\n pf = Pathfinder.new($map)\n pf.ignore_obs_target = true # permit to calculate a path to a case with an ennemy on it\n path = pf.find([x,y],[xx,yy])\n end",
"def rank_by_weight(file)\n file.rewind;\n line = file.gets\n if line == nil then return end\n \n # read 1st line, must be maze header\n sz, sx, sy, ex, ey = line.split(/\\s/)\n maze = Maze.new(sz,sx,sy,ex,ey)\n maze.initMaze(file)\n array = Array.new;\n file.rewind;\n #storing the paths' information into the array \n while line = file.gets do\n if (line[0...4] == \"path\") \n p, name, x, y, ds = line.split(/\\s/);\n startS = maze.grid[Integer(x)][Integer(y)]\n element = Path.new(name,startS,ds,0.0)\n array.push(element)\n end\n end\n # puts array.to_s \n \nif array.size < 1 then return (puts \"None\") end\n index = 0;\n #iterates through each of the the paths in array \n while index < array.size do\n direction = array[index].direction;\n direction.each_char{ |ch|\n array[index].totalW += Float(array[index].startSec.dir[ch])\n case ch\n when \"u\"\n x = array[index].startSec.x;\n y = array[index].startSec.y;\n y -= 1;\n startS = maze.grid[Integer(x)][Integer(y)]\n array[index].startSec = startS;\n when \"d\"\n x = array[index].startSec.x;\n y = array[index].startSec.y;\n y += 1;\n startS = maze.grid[Integer(x)][Integer(y)]\n array[index].startSec = startS; \n when \"l\"\n x = array[index].startSec.x;\n y = array[index].startSec.y;\n x -= 1;\n startS = maze.grid[Integer(x)][Integer(y)]\n array[index].startSec = startS;\n when \"r\"\n \n x = array[index].startSec.x;\n y = array[index].startSec.y;\n x += 1;\n startS = maze.grid[Integer(x)][Integer(y)]\n array[index].startSec = startS;\n \n end \n }\n index += 1\n end \n array.sort!{|p1, p2| p1.totalW <=> p1.totalW}\n list = \"\"\n array.each{ |path|\n list += \"#{path.name}, \"\n }\n list.chomp!(\", \")\n puts list\nend",
"def greedy_salesman (cities)\n path = []\n not_visited = cities\n path.push(not_visited.shift)\n loop do\n current = path.last\n # for testing, only prints if PRINT_STEPS is set to true at the top of the file\n puts \"current: \" + current.name + \" (\" + current.x.round(2).to_s + \",\" + current.y.round(2).to_s + \")\" if PRINT_STEPS\n next_city = nearest_possible_neighbor(current,not_visited)\n path.push(not_visited.delete(next_city))\n break if not_visited.empty?\n end\n path\nend",
"def one_level\n improvement = false\n nb_passes = 0\n cur_mod = @graph.modularity\n new_mod = cur_mod\n begin\n cur_mod = new_mod\n nb_moves = 0\n nb_passes += 1\n @graph.nodes.shuffle.each do |node|\n orig_community = @graph.get_community node\n\n neighbour_communities = @graph.get_neighbour_comms node\n\n @graph.remove_node node, orig_community\n\n\n best_community = orig_community\n max_gain = 0.0\n\n neighbour_communities.each do |comm|\n mod_gain = @graph.modularity_gain node, comm\n if mod_gain > max_gain\n max_gain = mod_gain\n best_community = comm\n end\n end\n if best_community != orig_community\n nb_moves += 1\n improvement = true\n end\n\n @graph.insert_node node, best_community\n\n @graph.garbage_collect orig_community\n\n end\n new_mod = @graph.modularity\n end while nb_moves > 0 and new_mod - cur_mod >= MIN_INCREASE\n return improvement\n end",
"def fruchterman_reingold(max_iters=100, width=@width, height=@height, nodeset=@nodes, edgeset=@edges, adjacency=@adjacency)\n puts \"beginning fruchterman_reingold @ \"+Time.now.to_s\n iterations = max_iters\n area = width*height\n k = nodeset.length > 0 ? Math.sqrt(area/nodeset.length) : 1 #multiply this by .75 to slow it down?\n k2 = k**2\n temperature = width/10\n for i in (1..iterations) do\n nodeset.each_value do |v| #calc repulsive forces\n if !v.static\n v.d = Vector[0.0,0.0]\n nodeset.each_value do |u|\n if u!=v\n dist = v.location - u.location\n distlen = dist.r.to_f\n #v.d += distlen != 0.0 ? (dist/distlen)*(k2/distlen) : Vector[(-0.5+rand())*0.1,(-0.5+rand())*0.1]\n if distlen != 0.0\n v.d += (dist/distlen)*(k2/distlen)\n else #at the same spot, so just splut them apart a little this run\n v.d += Vector[0.01,0]\n u.d += Vector[-0.01,0]\n end\n end\n end\n end\n end\n for e in edgeset.values do #calc attractive forces\n #only changes 1/conn (assuming 1 edge each direction)\n # if e.a.id < e.b.id or adjacency[[e.a.id,e.b.id]]+adjacency[[e.b.id,e.a.id]] < 2\n dist = e.a.location - e.b.location\n distlen = dist.r.to_f\n fa = distlen**2/k\n delta = (dist/distlen)*fa\n e.a.d -= delta if !e.a.static\n e.b.d += delta if !e.b.static\n # end\n end\n #puts nodeset\n nodeset.each_value do |v| #move nodes\n #added in attraction to center\n if !v.static\n dist_center = v.location - Vector[width/2, height/2]\n distlen = dist_center.r.to_f\n fa = distlen**2/k\n v.d -= (dist_center/distlen)*fa\n dlen = v.d.r.to_f\n if dlen > 0.0 #if we have a distance to move\n v.location += (v.d/dlen)*[dlen,temperature].min\n nx = [[v.location[0],0].max, width].min #don't let outside of bounds (50px border)\n ny = [[v.location[1],0].max, height].min\n v.location = Vector[nx,ny]\n end\n end\n end\n temperature *= (1 - i/iterations.to_f) #cooling function from http://goo.gl/xcbXR\n #puts \"finished iter \"+i.to_s+\" @ \"+Time.now.to_s\n end\n puts \"finished fruchterman_reingold @ \"+Time.now.to_s\n end",
"def a_star\n open_set = [@start]\n came_from = {}\n g_score = {}\n f_score = {}\n @grid.each_node do |node|\n g_score[node] = Float::INFINITY\n f_score[node] = Float::INFINITY\n end\n g_score[@start] = 0\n f_score[@start] = h(@start)\n\n until open_set.empty?\n current = open_set[0]\n open_set.each do |node|\n current = node if f_score[node] < f_score[current]\n end\n\n if current == @end\n reconstruct_path(came_from, current)\n @message = 'Path found! Press SUPPR to clear the window.'\n return true\n end\n\n current = open_set.delete_at(open_set.index(current))\n\n current.neighbors.each do |neighbor|\n tentative_g_score = g_score[current] + 1\n next if tentative_g_score >= g_score[neighbor]\n\n came_from[neighbor] = current\n g_score[neighbor] = tentative_g_score\n f_score[neighbor] = g_score[neighbor] + h(neighbor)\n unless open_set.include?(neighbor)\n open_set << neighbor\n neighbor.open!\n end\n end\n\n current.closed! if current != @start\n end\n @message = 'No path found! Press SUPPR to clear the window.'\n false\n end",
"def smoothing; end",
"def kamada_kawai(width=@width, height=@height, nodeset=@nodes, edgeset=@edges, adjacency=@adjacency)\n puts \"beginning kamada_kawai @ \"+Time.now.to_s\n\n #calculate shortest path distance (Floyd-Warshall); could be sped up using Johnson's Algorithm (if needed)\n @path_distance = Hash.new(0)\n edgeset.values.each {|e| @path_distance[[e.a.id,e.b.id]] = @path_distance[[e.b.id,e.a.id]] = 1} #fill with L1 dist (non-directional)\n for k,nk in nodeset\n for i,ni in nodeset\n for j,nj in nodeset\n # if not same node AND subpaths exist AND (not yet ij path OR ikj path is shorter)\n if (i!=j) and (@path_distance[[i,k]]*@path_distance[[k,j]] != 0) and \n (@path_distance[[i,j]]==0 or @path_distance[[i,k]]+@path_distance[[k,j]] < @path_distance[[i,j]])\n @path_distance[[i,j]] = @path_distance[[i,k]]+@path_distance[[k,j]]\n end\n end\n end\n #puts k.to_s + \" \"+Time.now.to_s\n end\n puts \"(found path distances) @ \"+Time.now.to_s\n\n ## stuff for maybe doing kamada with the current dist functions\n # distances = @graph.get_all_pairs_paths_distances\n # #puts distances\n # k = 1.0 #spring constant\n # tolerance = 0.001 #epsilon for energy\n # maxlen = 0\n # inf = 1.0/0\n # distances.values.each {|h| h.values.each {|v| maxlen = [maxlen, v].max if v != inf}} #clean this up?\n # l0 = [width,height].min/maxlen #optimal average length\n # ideal_length = Hash.new(0)\n # spring_strength = Hash.new(0)\n # distances.each do |k1,d|\n # d.each do |k2,val|\n # if val != inf\n # ideal_length[[k1,k2]] = l0*val\n # spring_strength[[k1,k2]] = k/(val*val)\n # end\n # end\n # end\n # \n # puts maxlen\n # #puts ideal_length\n \n k = 1.0 #spring constant\n tolerance = 0.001 #epsilon for energy\n l0 = [width,height].min/@path_distance.values.max #optimal average length\n ideal_length = Hash[@path_distance.map {|key,val| [key,l0*val]}]\n ideal_length.default = 0\n spring_strength = Hash[@path_distance.map {|key,val| [key,k/(val*val)]}] #can be undefined? v!=0 ? k/(v*v) : 0\n spring_strength.default = 0\n \n #puts compute_partial_derivatives(2335, nodeset, spring_strength, ideal_length) #test call\n \n delta_p = p = 0\n partial_derivatives = Hash.new(0)#Array.new(nodeset.length)\n nodeset.each_key do |i| #go through every person; computer partial deriv affect on them\n if !nodeset[i].static\n deriv = compute_partial_derivatives(i, nodeset, spring_strength, ideal_length)\n partial_derivatives[i] = deriv\n delta = Math.sqrt(deriv[0]*deriv[0]+deriv[1]*deriv[1])\n p, delta_p = i, delta if delta > delta_p\n end\n end\n \n last_energy = 1.0/0 \n begin #computing movement based on a particular node p\n\n p_partials = Hash.new(0)\n nodeset.each_key {|i| p_partials[i] = compute_partial_derivative(i, p, nodeset, spring_strength, ideal_length)}\n\n last_local_energy = 1.0/0\n begin\n if !nodeset[p].static\n # compute jacobian; copied code basically\n dE_dx_dx = dE_dx_dy = dE_dy_dx = dE_dy_dy = 0.0\n nodeset.each_key do |i|\n if i!=p\n dx = nodeset[p].location[0] - nodeset[i].location[0]\n dy = nodeset[p].location[1] - nodeset[i].location[1]\n dist = Math.sqrt(dx*dx+dy*dy)\n dist_cubed = dist**3\n k_mi = spring_strength[[p,i]]\n l_mi = ideal_length[[p,i]]\n dE_dx_dx += k_mi * (1 - (l_mi * dy * dy) / dist_cubed)\n dE_dx_dy += k_mi * l_mi * dy * dx / dist_cubed\n dE_dy_dx += k_mi * l_mi * dy * dx / dist_cubed\n dE_dy_dy += k_mi * (1 - (l_mi * dx * dx) / dist_cubed)\n end\n end\n \n # calculate dv (amount we should move)\n dE_dx = partial_derivatives[p][0]\n dE_dy = partial_derivatives[p][1]\n \n dv = Vector[(dE_dx_dy * dE_dy - dE_dy_dy * dE_dx) / (dE_dx_dx * dE_dy_dy - dE_dx_dy * dE_dy_dx),\n (dE_dx_dx * dE_dy - dE_dy_dx * dE_dx) / (dE_dy_dx * dE_dx_dy - dE_dx_dx * dE_dy_dy)]\n\n # if for some reason our dv ends up being infinite (divide by 0), just set to 0??\n # and why in gods name is assignment a private function?! And why doesn't rails say so?!\n dv = Vector[0.0,dv[1]] if dv[0].infinite?\n dv = Vector[dv[0],0.0] if dv[1].infinite?\n\n # move vertex\n nodeset[p].location += dv\n # recompute partial derivates and delta_p based on new location\n deriv = compute_partial_derivatives(p, nodeset, spring_strength, ideal_length)\n partial_derivatives[p] = deriv\n delta_p = Math.sqrt(deriv[0]*deriv[0]+deriv[1]*deriv[1])\n\n #check local energy if we should be done--I feel like this could be done with a cleaner conditional\n #repeat until delta is 0 or energy change falls bellow tolerance \n local_done = false\n if last_local_energy == 1.0/0 #round 1\n local_done = (delta_p == 0)\n else\n local_done = (delta_p == 0) || ((last_local_energy - delta_p)/last_local_energy < tolerance)\n end\n last_local_energy = delta_p #in either case, set our local energy to the last change\n #puts \"local energy=\"+last_local_energy.to_s\n end\n end while !local_done #local energy is still too high\n \n #update partial derivatives and select new p\n old_p = p\n nodeset.each_key do |i|\n if !nodeset[i].static\n old_deriv_p = p_partials[i]\n old_p_partial = compute_partial_derivative(i,old_p, nodeset, spring_strength, ideal_length) #don't we have this already?\n deriv = partial_derivatives[i]\n deriv[0] += old_p_partial[0] - old_deriv_p[0]\n deriv[1] += old_p_partial[1] - old_deriv_p[1]\n partial_derivatives[i] = deriv\n \n delta = Math.sqrt(deriv[0]*deriv[0]+deriv[1]*deriv[1])\n if delta > delta_p\n p = i\n delta_p = delta\n end\n end\n end\n\n #calc global energy to see if we're done\n #repeat until delta is 0 or energy change falls bellow tolerance \n global_done = false\n if last_energy != 1.0/0 #make sure we have a value to divide\n global_done = (delta_p == 0) || ((last_energy - delta_p).abs/last_energy < tolerance)\n end\n last_energy = delta_p\n #puts \"global energy=\"+last_energy.to_s\n end while !global_done #global energy is still too high\n puts \"finished kamada_kawai @ \"+Time.now.to_s\n puts \"end of kamada\"\n end",
"def reduce_solved\n before = 9*9*9\n after = entropy\n while before > after\n before = after\n reduce_line\n reduce_col\n reduce_grid\n after = entropy\n end\n self\n end",
"def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end",
"def check_for_optimal_move(mark_value)\n @board.all_valid_moves.each do |valid_move|\n @board.mark_square(valid_move[0],valid_move[1],mark_value)\n marked_square=[valid_move[0],valid_move[1]]\n if @board.winner?\n return mark_value\n elsif @board.tie?\n return 0\n else\n check_for_optimal_move(mark_value = -mark_value)\n end\n end\nend",
"def calculate_choices(cities, last_city, exclude, pheromone, c_heur, c_hist)\n #Checa todas as possibildiades para se escolher a proxima cidade.\n choices = []\n #passa por todas as cidades. coord pega as coordenadas de uma dada cidade, i a posicao dela no array de cidades. o i identifica qual cidade no array � \n cities.each_with_index do |coord, i|\n #checa se a cidade ja foi visitada. as cidades visitadas esta em exclude. A cidade analisada estar no vetor exclude? Se sim, sai dessa intera��o\n\tnext if exclude.include?(i)\n \n\t#Indentifica qual cidade esta sendo analisada\n\tprob = {:city=>i}\n \n #calcula o fator historico. O c hist mostra o quanto voce considera o historico. Historico o quanto que passaram naquela cidade, e se mede isso coma matriz de pheronio. Se passaram muito por ali de maniera frequente, maior o fator de historico pois o pheromonio ali estar� muito alto\n\tprob[:history] = pheromone[last_city][i] ** c_hist\n\t# Considera o vetor distancia \n\tprob[:distance] = euc_2d(cities[last_city], coord)\n # Calcula o faotr heuristico, isso e, o quanto que a distancia vai influir nessa decisao. Quanto maior a distancia, menor a chance de se escolher\n\tprob[:heuristic] = (1.0/prob[:distance]) ** c_heur\n # Calcula a probabilidade da escolha ser escolhida. Multiplica o fator de distancia e o fator heuristico\t\n\tprob[:prob] = prob[:history] * prob[:heuristic]\n # Adiciona a escolha no vetor de escolha\n\tchoices << prob\n end\n choices\nend",
"def test_find\n @search.adjacent_points_function = ->(current) {[-0.1, 0.1].map {|x| current + x}}\n @search.cost_function = ->(x){x - 0.1}\n assert_in_delta 0.1, @search.find\n end",
"def walk(grid, x, y)\n [N, S, E, W].shuffle.each do |dir|\n nx, ny = x + DX[dir], y + DY[dir]\n if nx >= 0 && ny >= 0 && ny < grid.length && nx < grid[ny].length && grid[ny][nx] == 0\n grid[y][x] |= dir\n grid[ny][nx] |= OPPOSITE[dir]\n \n return [nx, ny]\n end\n end\n \n nil\nend",
"def branch_explore(copy_of_map_arr, direction, exit_hash, copy_of_answer_array, x, y, x_max, y_max)\n x += 1 if direction == 'right'\n x -= 1 if direction == 'left'\n y -= 1 if direction == 'up'\n y += 1 if direction == 'down'\n temp_miner = {'x' => x, 'y' => y}\n copy_of_answer_array = solve(copy_of_map_arr, temp_miner, exit_hash, copy_of_answer_array)\n if copy_of_answer_array.size == ((x_max + 1) * (y_max + 1)) \n copy_of_map_arr[x][y] = false \n else\n copy_of_map_arr[x][y] == \"branch\"\n end\n x -= 1 if direction == 'right'\n x += 1 if direction == 'left'\n y += 1 if direction == 'up'\n y -= 1 if direction == 'down'\n copy_of_answer_array\nend",
"def bellman_ford(graph, s)\n paths = Hash.new\n\n # initialization\n graph.each do |vertex, _|\n paths[vertex] = Hash.new\n paths[vertex][:distance] = Float::INFINITY\n paths[vertex][:parent] = nil\n end\n\n paths[s][:distance] = 0\n\n # Even though there are three nested loops, it only takes (V - 1)(E) time\n (1...graph.length).each do # iterating (V - 1) times\n graph.each do |vertex, _|\n graph[vertex].each do |neighbor|\n # technique of relaxation - for an edge (u, v), compare v.distance > (u.distance + weight(u, v))\n if paths[neighbor[0]][:distance] > (paths[vertex][:distance] + neighbor[1])\n paths[neighbor[0]][:distance] = paths[vertex][:distance] + neighbor[1]\n paths[neighbor[0]][:parent] = vertex\n end\n end\n end\n end\n\n graph.each do |vertex, _|\n graph[vertex].each do |neighbor|\n if paths[neighbor[0]][:distance] > (paths[vertex][:distance] + neighbor[1])\n return false\n end\n end\n end\n\n paths\n\nend",
"def generate_hints\n @field.each_with_index do |row, x|\n row.each_with_index do |h, y|\n getsq(x,y)[:hint] = get_nearby_mines(x,y)\n end\n end\n end",
"def find_shortest(rootCode,goalCode)\n\tself.findHops(rootCode, goalCode, lambda{|flight,oldweight| oldweight+1})\nend",
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"def addPartialScore(likelyscores, mainteamnumber, bHigh) #bHigh: whether or not this is the high goal\n\tscorethismatch = 0.0\n\tfuelthismatch = 0.0\n\theatMapHits = {} #heatMapHits: {endtime: fuel} .. to be used in calculating accuracy\n\tlikelyscores.each do |time, teamshash|\n\t\tendtime = teamshash[mainteamnumber] #for heat map\n\t\tfuelScoreRatio = (bHigh ? 1.0 : 3.0) #ratio of fuel to score. autonomous: 1/high 3/low, tele: 3/high 9/low\n\t\tfuelScoreRatio *= 3.0 if (time < 16000)\n\t\tcase teamshash.length\n\t\twhen 0 \n\t\t\tputs \"WARNING: For some reason we have a teamsthatscored key with no value\"\n\t\twhen 1\n\t\t\tif teamshash.has_key?(mainteamnumber) #The team scored alone - cool!\n\t\t\t\tscoretoadd = 1 #They get credit for scoring 1 point with high fuel\n\t\t\t\tfueltoadd = (1 * fuelScoreRatio)\n\t\t\tend #We don't care to record what the other teams are doing, only the one we're analyzing\n\t\twhen 2\n\t\t\tif teamshash.has_key?(mainteamnumber) #The team was one of 2 to be shooting high at this time\n\t\t\t\tscoretoadd = 0.5\n\t\t\t\tfueltoadd = (0.5 * fuelScoreRatio)\n\t\t\tend\n\t\twhen 3\n\t\t\tif teamshash.has_key?(mainteamnumber) #One of 3\n\t\t\t\tscoretoadd = 1.to_f / 3.to_f\n\t\t\t\tfueltoadd = ((1.to_f / 3.to_f) * fuelScoreRatio)\n\t\t\tend\n\t\telse\n\t\t\tputs \"WARNING: Unknown error in likelyscores.each having to do wth the case switch\"\n\t\tend\n\t\theatMapHits[endtime] = fueltoadd \n\t\tscorethismatch += scoretoadd\n\t\tfuelthismatch += fueltoadd\n\tend\n\treturn [scorethismatch, fuelthismatch, heatMapHits]\nend",
"def on_the_offensive(brd)\n attack = []\n WINNING_LINES.each do |line|\n current_line = brd.values_at(*line)\n if current_line.count(COMPUTER_MARKER) == 2\n attack = line\n end\n attack # returns array that is the best attack vector\nend\n\ndef determine_threat(brd)\n threat_line = []\n WINNING_LINES.each do |line|\n current_line = brd.values_at(*line)\n if current_line.any?(COMPUTER_MARKER)\n next\n elsif current_line.count(PLAYER_MARKER) == 2\n threat_line = line\n end\n end\n threat_line\nend",
"def target_calculation (result_grid, target_string = '', dice_string)\n #Find the starting point for iterating over the grid arrays: the point where the target has been met\n target_success = target_string.count('S') - target_string.count('F')\n target_advantage = target_string.count('A') - target_string.count('T')\n # Failure and threat: Since you have to deal with 0 F/T targets as well as higher,\n # the failure target might have to chance, since 0-1 is -1 and that's terrible.\n target_failure = (0 > (target_success.abs - 1) ? 0 : (target_success.abs - 1))\n target_threat = (0 > (target_advantage.abs - 1) ? 0 : (target_advantage.abs - 1))\n target_triumph = target_string.count('R')\n target_despair = target_string.count('D')\n \n success_max, advantage_max, threat_max, failure_max, triumph_max, despair_max = dice_string_interpolation dice_string\n target_probability = 0\n \n if target_success >= 0\n result_grid[target_success..success_max].each do |result_success_line|\n if target_advantage >= 0\n result_success_line[target_advantage..advantage_max].each do |result_advantage_line|\n result_advantage_line[target_triumph..triumph_max].each do |result_triumph_line|\n result_triumph_line[target_despair..despair_max].each do |result_cell|\n #Success, Advantage Probability\n target_probability += result_cell\n end\n end\n end\n end\n # To make sure you don't double dip\n next if (threat_max == 0)\n if target_advantage <= 0\n result_success_line.reverse[target_threat..threat_max - 1].each do |result_threat_line|\n result_threat_line[target_triumph..triumph_max].each do |result_triumph_line|\n result_triumph_line[target_despair..despair_max].each do |result_cell|\n #Success, Threat Probability\n target_probability += result_cell\n end\n end\n end\n end\n end\n end\n if target_success <= 0\n result_grid.reverse[target_failure..failure_max - 1].each do |result_failure_line|\n # Making sure you don't double dip: Failure Version! Fence Posting.\n break if failure_max == 0\n if target_advantage >= 0\n result_failure_line[target_advantage..advantage_max].each do |result_advantage_line|\n result_advantage_line[target_triumph..triumph_max].each do |result_triumph_line|\n result_triumph_line[target_despair..despair_max].each do |result_cell|\n target_probability += result_cell\n end\n end\n end\n end\n # Threat\n next if threat_max == 0\n if target_advantage <= 0\n result_failure_line.reverse[target_threat..threat_max - 1].each do |result_threat_line|\n result_threat_line[target_triumph..triumph_max].each do |result_triumph_line|\n result_triumph_line[target_despair..despair_max].each do |result_cell|\n target_probability += result_cell\n end\n end\n end\n end\n end\n end\n return target_probability\nend",
"def ukp5(ukpi, return_used_items = false)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n max_w = items.max_by { | i | i[:w] }[:w]\n g = Array.new(c+max_w+1, 0)\n d = Array.new(c+max_w+1, n-1)\n sort_items_by_profitability!(items)\n\n last_y_where_nonbest_item_was_used = 0\n items.each_with_index do | it, ix |\n wi = it[:w]\n pi = it[:p]\n if g[wi] < pi then\n g[wi] = pi\n d[wi] = ix\n last_y_where_nonbest_item_was_used = wi if wi > last_y_where_nonbest_item_was_used && ix != 0\n end\n end\n\n opt = 0\n (1..(c-1)).each do | y |\n next if g[y] <= opt\n break if last_y_where_nonbest_item_was_used < y\n\n opt = gy = g[y]\n dy = d[y]\n\n # this block is a copy-past of the loop bellow only for the best item\n bi = items[0]\n pb = bi[:p]\n wb = bi[:w]\n next_y = y + wb\n old_gny = g[next_y]\n new_gny = gy + pb\n if old_gny < new_gny then\n g[next_y] = new_gny\n d[next_y] = 0\n end\n\n (1..dy).each do | ix |\n it = items[ix]\n pi = it[:p]\n wi = it[:w]\n ny = y + wi\n ogny = g[ny]\n ngny = gy + pi\n if ogny < ngny then\n g[ny] = ngny\n d[ny] = ix\n last_y_where_nonbest_item_was_used = ny if ny > last_y_where_nonbest_item_was_used\n end\n end\n end\n\n if last_y_where_nonbest_item_was_used < c-1 then\n y_ = last_y_where_nonbest_item_was_used\n while d[y_] != 0 do\n y_ += 1\n end\n# puts \"Periodicity used - c: #{c}; last_y: #{y_}\"\n\n extra_capacity = c - y_\n c1, a1 = items[0][:p], items[0][:w]\n qt_best_item_used = Rational(extra_capacity, a1).ceil\n space_used_by_best_item = qt_best_item_used*a1\n profit_generated_by_best_item = qt_best_item_used*c1\n\n opt_y = get_opt_y(c-space_used_by_best_item, items, g, d)\n g[c] = g[opt_y] + profit_generated_by_best_item\n end\n\n opt = g[c] if opt < g[c]\n\n if return_used_items then\n g.slice!(c+1, max_w)\n d.slice!(c+1, max_w)\n opt_y = get_opt_y(c, items, g, d)\n get_used_items_for_y(opt_y, items, g, d)\n else\n opt\n end\nend",
"def cost_to_visit(pos, prev_pos, gem)\n cost = (pos[0] - gem[0]).abs + (pos[1] - gem[1]).abs\n cost += 2 if opposite_direction(pos, prev_pos, gem)\n cost\nend",
"def main(points) # array with all the points\n #copy of the array by an especific cordinate\n #nlogn\n # This is a primitive, aka operations that are costless compared to the\n # total complexity we are aming for\n px = sort_by_cordinate(points, 0)\n py = sort_by_cordinate(points, 1)\n\n result = closest_pair(px, py)\nend",
"def prepare_preferred_algorithms!; end",
"def solve(minemap, miner, stop)\n target = stop.values\n path = explore([miner.values], minemap, miner['x'], miner['y'], target)\n moves = (1...path.length).each_with_object([]) do |idx , obj|\n obj << case path[idx][0] - path[idx - 1][0]\n when 1 then 'right'\n when -1 then 'left'\n when 0 then case path[idx][1] - path[idx - 1][1]\n when 1 then 'down'\n when -1 then 'up'\n end\n end\n end\nend",
"def gettrys(tcoords)\n # Indexa coordenadas de las lineas con menor incognitas\n p \"hmiss............\"\n p tcoords[:hmiss]\n hlower_c = lowerabsent(tcoords[:hmiss]) # [{:hindex=>x, :coords=> [[]]\n vlower_c = lowerabsent(tcoords[:vmiss],\"v\") # [{:vindex=>x, :coords=>[[]]\n slower_c = lowerabsent(tcoords[:smiss],\"s\") # [{:sindex=>x, :coords=>[[]]\n\n # combierte las coordenadas en numeros -> contiene menor incognitas\n hlower_n = hlower_c.collect {|line| missto_n(line[:hindex])} # [{:hindex=>0, :numbers=>[3, 4]}, x]\n vlower_n = vlower_c.collect {|line| missto_n(line[:vindex],tcoords[:vwhole], \"v\")} # [{:vindex=>0, :numbers=>[3, 4]}, x]\n #slower_n = slower_c.collect {|line| missto_n(line[:sindex], tcoords[:swhole], \"s\")} # [{:sindex=>2, :numbers=>[4, 6, 8]}, x]\n p \"****** H vs V *******\"\n p hlower_c.length < vlower_c.length ? \"h < v\" : \"h > v\"\n # cantidad de incognitas decide si se usa h o v\n p lower_c = hlower_c.length < vlower_c.length ? hlower_c : vlower_c\n lower_n = lower_c[0].keys[0][0] == \"h\" ? hlower_n : vlower_n\n # le pone cuadro a cada coord y separa coordenadas, una por linea\n hvindex_sindex_coords = locatecoord_onsquere(lower_c, tcoords[:swhole])\n sqr_n = hvindex_sindex_coords.collect {|item| missto_n(item[:sindex], tcoords[:swhole],\"s\")}\n # buscar que sqr tiene menos coincidencias\n hvindex_sindex_coords.collect { |main|\n main[:sqr_options] = sqr_n.collect {|numbers| numbers[:numbers] if main[:sindex] == numbers[:sindex] }.compact.flatten\n main[:options] = lower_n.collect {|numbers| numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]] }.compact.flatten\n main[:reduce] = main[:options] - ([1,2,3,4,5,6,7,8,9] - main[:sqr_options])\n\n }\n # numbers[:numbers] if main[main.keys[0]] == numbers[numbers.keys[0]]\n result = hvindex_sindex_coords.group_by {|g| g[:reduce].length}\n\n p \"*******start Result\"\n reduce_index = result.collect {|x,y| x }.min\n result[reduce_index].map {|e| p e} # inspect\n result[reduce_index].map do |item|\n\n case item.keys[0][0]\n when \"h\"\n if item[:reduce].length == 1\n x = item[:coord][0]\n y = item[:coord][1]\n @tbls[:notformated][x][y] = item[:reduce][0]\n @tbls[:formated][x][y] = formato(@tbls[:notformated][x][y].to_s,:red, :yellow)\n elsif item[:reduce].length > 1\n # Pregunta en linea vertical\n end\n when \"v\"\n p \"################## - caso vertical pendiente - ###################\"; exit\n end\n\n end\n\n end"
] | [
"0.7292886",
"0.7058845",
"0.6743463",
"0.6661915",
"0.66364956",
"0.6624951",
"0.6314571",
"0.6269569",
"0.6204419",
"0.61874884",
"0.6128044",
"0.608693",
"0.60858166",
"0.6062857",
"0.60444415",
"0.6017084",
"0.6012665",
"0.5989448",
"0.59759694",
"0.5963527",
"0.5963407",
"0.59617335",
"0.59535056",
"0.59503806",
"0.5924077",
"0.5896459",
"0.58893085",
"0.5886492",
"0.5855342",
"0.58344793",
"0.58173925",
"0.579931",
"0.5775467",
"0.57362527",
"0.57201946",
"0.57137656",
"0.5706114",
"0.5697854",
"0.5696398",
"0.5692638",
"0.5690854",
"0.5688379",
"0.56786793",
"0.5677439",
"0.5666481",
"0.56632257",
"0.56539434",
"0.5641632",
"0.5639726",
"0.5620886",
"0.5616441",
"0.56162685",
"0.5613983",
"0.56008774",
"0.55956525",
"0.55946004",
"0.5594492",
"0.55909866",
"0.55792326",
"0.55614144",
"0.5551117",
"0.55432004",
"0.55385",
"0.5529623",
"0.5518211",
"0.55181336",
"0.55167055",
"0.5509454",
"0.5488498",
"0.5481319",
"0.5473577",
"0.54733956",
"0.5472652",
"0.5470355",
"0.54669005",
"0.5464363",
"0.54636",
"0.54601294",
"0.54533154",
"0.5449282",
"0.5442125",
"0.5441474",
"0.5439196",
"0.5425185",
"0.54239035",
"0.5421682",
"0.5411253",
"0.54091376",
"0.5399056",
"0.5398377",
"0.53958124",
"0.53934884",
"0.5391848",
"0.53886896",
"0.53858566",
"0.53821075",
"0.53774124",
"0.5375856",
"0.5373352",
"0.53636307",
"0.53516895"
] | 0.0 | -1 |
the way this is designed, it short circuts. so sometimes when it should say false it will say indeterminant for the whole knowledgebase returns false, true, or indetermninant as 1,1,0 (in current encoding) alike with the assignment list and literal class assignment must be parallel array to id nums (may want to use hashes instead) | def satisfiable_assignment?(assignment)
sentence_eval = 1
index = 0
while(sentence_eval == 1 && index < @kb.size)
sentence_eval = 0
all_false = true
##############################################3
# puts "kb is: " + @kb.to_s
# puts "the assignments are : " + assignment.to_s
@kb[index].each do |id|
################################################33
# puts " the atom to check : " + id.to_s
temp_id = id
if(temp_id >0)
assign = assignment[temp_id - 1]
###################################################
# puts "the atom is : " + id.to_s
# puts "the variable is assigned to: " + assignment[temp_id-1].to_s
# puts "which evaluates to: " + assign.to_s
else
assign = assignment[temp_id*-1 -1].to_i * -1
###################################################
# puts "the atom is : " + id.to_s
# puts "the variable is assigned to: " + (assignment[temp_id*-1 - 1] - 1).to_s
# puts "which evaluates to: " + assign.to_s
end
if(assign==1)
sentence_eval = 1
all_false = false
break
elsif(assign == 0)
all_false = false
end
end
if(all_false)
sentence_eval = -1
end
index+=1
end
return sentence_eval
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assignment_intialize\n\t\tif(@puret and @puref)\n\t\t\treturn false\n\t\tend\n\t\tif(@num_negative == 0 or @puret)\n\t\t\t@assignments = [1]\n\t\telsif(@num_positive == 0 or @puref)\n\t\t\t@assignments = [-1]\n\t\telsif(@best_guess <0)\n\t\t\t@assignments = [-1,1]\n\t\telse\n\t\t\t@assignments = [1,-1]\n\t\tend\n\t\treturn true\n\tend",
"def determine_literalism(literalism_data)\n\tcase literalism_data\n\twhen 1\n\t\t:yes\n\twhen 2\n\t\t:no\n\telse\n\t\t:unknown\n\tend\nend",
"def exercise_1111 (bool_values)\n end",
"def ismn; end",
"def intensifier; end",
"def check_disjunctive_assignment(node); end",
"def primordial; end",
"def assignment?(node); end",
"def assignment?(node); end",
"def assignment?(node); end",
"def false_true\n alternatives false, true\n end",
"def prologify\n \"false\"\n end",
"def is_fixed?\n self.assignment_type_id == 2\n end",
"def is_primitive_sentence?\n index = 1\n if @classified[index].instance_of?(Proposition) || @classified[index].instance_of?(Constant)\n if @classified[index + 1].instance_of?(LogicalOperator)\n if @classified[index + 2].instance_of?(Proposition) || @classified[index + 2].instance_of?(Constant)\n return true\n end\n end\n end\n false\n end",
"def cardinal; end",
"def define_question_code(klass, position) \r\n \"is_a?(#{name}) && (!number || number==@value)\"\r\n end",
"def boolify(val)\n\nend",
"def test_compound_branch_w_3_terms_t_t_assign\n assert interpret('var=0; true && true || var=99; :var').zero?\n end",
"def abundant?(num)\n\nend",
"def abundant?(num)\n\nend",
"def first_assignment?(node); end",
"def _reduce_5(val, _values)\n AST::True.new true \nend",
"def is_amicable(n)\n a = d(n)\n a == n ? false : n == d(a)\nend",
"def calculate_truth_table\r\n false_s = @char_set[0]\r\n truth_s = @char_set[1]\r\n @table_array.each do |x|\r\n trues = x.count(truth_s)\r\n trues == @size ? x.push(truth_s) : x.push(false_s)\r\n trues > 0 ? x.push(truth_s) : x.push(false_s)\r\n trues.odd? ? x.push(truth_s) : x.push(false_s) \r\n end\r\n end",
"def initialize\n @set = BitSet.new\n @endOf = Sym::NoSym\n @ctx = false\n @correct = true\n end",
"def abundant?(num)\nend",
"def evalIdentifierINT_BOOL(expr)\n\tidentif = expr.get_value\n\t# evalua en la tabla que el identificador corresponda con entero o \n\t# booleano, o que simplemente no se encuentre en la tabla\n\ttype = $tables.lookup(identif)\n\tif type[0] == :INTEGER\n\t\tprint \"Introduzca un numero entero: \"\n\t\tinput = $stdin.readline\n\t\tcase input\n\t\twhen /^[0-9][0-9]*/ \n\t\t\tinput = input.to_i\n\t\t\tif input > 2147483647 || input < -2147483647\n\t\t\t\tputs \"ERROR: overflow entrada de numero de 32 bits erroneo\"\n\t\t\t\t$error = true\n\t\t\telsif input < 2147483647 && input > -2147483647\n\t\t\t\t$tables.update(type[0],identif,input)\n\t\t\tend\n\t\telse\n\t\t\tputs \"ERROR: entrada incorrecta se espera un INTEGER\"\n\t\t\t$error = true\n\t\tend\n\n\telsif type[0] == :BOOLEAN\n\t\tprint \"Introduzca un booleano true or false: \"\n\t\tinput = $stdin.readline\n\t\tif input.downcase == \"true\\n\"\n\t\t\t$tables.update(type[0],identif,true) \n\t\telsif input.downcase == \"false\\n\"\n\t\t\t$tables.update(type[0],identif,false)\n\t\telse\n\t\t\tputs \"ERROR: entrada incorrecta se espera un #{type[0]}\"\n\t\t\t$error = true\n\t\tend\n\tend\nend",
"def assignment?(node)\n [:lvasgn, :ivasgn, :gvasgn, :cvasgn, :casgn].include?(node.type)\n end",
"def assignment?(node)\n [:lvasgn, :ivasgn, :gvasgn, :cvasgn, :casgn].include?(node.type)\n end",
"def synpred8_Jejune\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 94 )\n\n # at line 556:7: member assignment_op\n @state.following.push( TOKENS_FOLLOWING_member_IN_synpred8_Jejune_3692 )\n member\n @state.following.pop\n @state.following.push( TOKENS_FOLLOWING_assignment_op_IN_synpred8_Jejune_3694 )\n assignment_op\n @state.following.pop\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 94 )\n\n end",
"def assign_singular?\n !returns_array?\n end",
"def dense?; return stype == :dense; end",
"def boolean!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = BOOLEAN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 193:8: ( 'true' | 'false' )\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == 0x74 )\n alt_2 = 1\n elsif ( look_2_0 == 0x66 )\n alt_2 = 2\n else\n raise NoViableAlternative( \"\", 2, 0 )\n\n end\n case alt_2\n when 1\n # at line 193:10: 'true'\n match( \"true\" )\n\n\n when 2\n # at line 193:19: 'false'\n match( \"false\" )\n\n\n end\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end",
"def dpll\n\t\t#need to count degree, best_guess, assignments and such heuristic stuff somewhere... makes sense to do it here\n\t\t#should make a version without heuristics aswell\n##############################################3\n#\t\tputs \"the kb : \" + @kb.to_s\n\n\t\[email protected] do |sente|\n##########################################################333\n#\t\t\tputs \" the sentences: \" + sente.to_s\n\n\t\t\tif(sente.size==1)\n\t\t\t\tindex=sente[0]\n\t\t\t\tif(index > 0)\n\t\t\t\t\t@id_array[index-1].pos_increment\n\t\t\t\t\t@id_array[index-1].puret=true\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tindex*=-1\n\t\t\t\t\t@id_array[index-1].neg_increment\n\t\t\t\t\t@id_array[index-1].puref = true\n\t\t\t\tend\t\n\t\t\telse\t\n\t\t\t\tsente.each do |atome|\n#############################################################\n#\t\t\t\t\tputs \"the individual atoms: \" + atome.to_s\n\t\t\t\t\tif(atome > 0)\n\t\t\t\t\t\tindex = atome-1\n\t\t\t\t\t\t@id_array[index].pos_increment\n\t\t\t\t\telse\n\t\t\t\t\t\tindex = -1*atome-1\n\t\t\t\t\t\t@id_array[index].neg_increment\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\t\n\t\tend\n\t\t@id_array.each do |var|\n\t\t\tif(!var.assignment_intialize)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\t\n\t\t#intialization stuff\n\t\t##########heuristic sort!\n\t\tvar_list = @id_array\n\t\tvar_list.sort!\n\t\t\n\t\tdepth=0\n\t\tassignment = Array.new\n\t\tsatisfiable = false\n\t\tstack = []\n\t\n\t\t#make parallel array assignment\n\t\tid_array.map { assignment << 0}\n\t\t\n\n\t\t#insert root\n\t\t(var_list[depth].assignments).map do |child|\n\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\tend\n\t\t\n\t\t#start depth-first search\n\t\twhile(stack.size()>0)\n\t\n\t\t\ttemp = stack.pop\n\t\t\n\t\t\t#comparing depth to make sure assignment variables reassigned if popping up the tree\n\t\t\twhile(depth>temp.depth)\n\t\t\t\tassignment[depth] = 0\n\t\t\t\tdepth -=1\n\t\t\tend\t\n\t\t\t#add it to the assignment evaluation list (depth doubles as index through var_list)\n\t\t\tassignment[var_list[temp.depth].id - 1] = temp.value\n\t\t\n\t\t\t#Evaluate the assignment list\n\t\t\tif(satisfiable_assignment?(assignment)==1)\n##########################################################################333\n\t\t\t\tputs \"the kb is: \" + @kb.to_s \n\t\t\t\tputs \"the assignment that evaluates to true: \"\n\t\t\t\tputs assignment.to_s\n#############################################################################\n\t\t\t\t\n\t\t\t\treturn true\n\t\t\tend\n\t\n\t\t\t#add children\n\t\t\tdepth+=1\t\n\t\n\t\t\t#if not bottumed out, add more children based on values from the var\n\t\t\tif(depth<var_list.size())\n\t\t\t\t(var_list[depth].assignments).map do |child|\n\t\t\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\t\t\tend\t \n\t\t\telse\n\t\t#reset to bottom value\n\t\t\t\tdepth =var_list.size-1\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def save_answers(user1,variable_arr)\n\n #Loop through the variable array defined in the questions window\n for a in 0..3\n #If the value is \"!\", it will change the value to boolean true\n if variable_arr[a] == 1\n variable_arr[a] = true\n else\n #If the value is \"0\", it will change the value to boolean false\n variable_arr[a]=false\n end\n end\n\n\n #pass the value of the given variables into the user1 class variables\n user1.cuisine = variable_arr[0]\n user1.healthy = variable_arr[1]\n user1.halal = variable_arr[2]\n user1.price = variable_arr[3]\nend",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def _lex_indicies; end",
"def is_flex?\n self.assignment_type_id == 3\n end",
"def new_apnf_rules_for_negated_implication\n end",
"def igual (mat)\n end",
"def is_decision\n return (@index == 89)\n end",
"def lit?\n @lit\n end",
"def identity?\n [1, 2, 3, 5, 6, 7].all? { |i| self[i] == 0 } && [0, 4, 8].all? { |i| self[i] == 1 }\n end",
"def test_object_codes\n narr = narratives(:first)\n assert narr.clinical_objects == []\n narr = narratives(:second)\n objs = narr.clinical_objects(true)\n assert objs[0].name == \"risperidone 2mg tab\"\n assert objs[0].code_class == Drug\n assert objs[1].name == \"yellow fever\"\n assert objs[1].code_class == Diagnosis\n end",
"def true_comparitons\n ['be','is','are','were','=','>','>=','==','<=','<','=<','gt','lt','eq','bigger','greater','equals','identical to',\n 'smaller','less','equal to','more','less','the same as','same as','similar']\n end",
"def pred_s\n a_s(@pred)\n end",
"def convert_boolean_strings\n %i{ambiguous_ref_bases use_all_contigs include_low_hmes polyploidy}.each do | symbol |\n if @options.key?(symbol)\n @options[symbol] = @options[symbol] == 'false' ? false : true\n end\n end\n end",
"def check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n if count_copies > 0 #resetting review_array only when plagiarism was found\n auto_metareview.review_array = rev_array\n\n\n if count_copies == scores.length\n return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0\n else\n return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics\n end\n end\nend",
"def map_boolean(ident, &block) ; map_primitive(:boolean, ident, &block) ; end",
"def unangenehm?(in_temp)\n\tcheck_pre((in_temp.int?))\n\tnot angenehm?(in_temp)\nend",
"def test_lung_cancer\n @answers[0] = true\n @answers[2] = true\n assert_equal(Diagnosis.diagnose(@answers),\"Lung Cancer\")\n end",
"def is_plex?(); @type == GRT_PLEX; end",
"def _anc\n @_p_nz = @_a &= @data\n @_p_c = @_p_nz >> 7\n end",
"def rhs\n expect :attrasgn, :safe_attrasgn, *ASSIGNMENT_BOOL\n\n if self.node_type == :attrasgn or self.node_type == :safe_attrasgn\n if self[2] == :[]=\n self[4]\n else\n self[3]\n end\n else\n self[2]\n end\n end",
"def _lex_indicies=(_arg0); end",
"def _lex_indicies=(_arg0); end",
"def _lex_indicies=(_arg0); end",
"def _lex_indicies=(_arg0); end",
"def unlabeled?() @positive.nil? end",
"def classification=(value)\n case value\n when \"\"\n value = \"admitted\"\n when \"认可的\", \"допустимый\", \"admitido\"\n value = \"admitted\"\n when \"首选的\", \"suositettava\", \"suositeltava\", \"рекомендуемый\", \"preferente\"\n value = \"preferred\"\n when %w(preferred admitted deprecated)\n # do nothing\n end\n @classification = value\n end",
"def compute!\n class_def = /^\\[[\\w;\\?|=!]*?\\]$/\n inheritance = /\\[(.*?)\\]\\^\\[(.*?)\\]/\n association = /\\[.*\\]-.*>\\[.*\\]/\n\n @statements.sort! do |x, y|\n\n if x =~ class_def and y =~ inheritance\n -1\n elsif x =~ class_def and y =~ association\n -1\n elsif x =~ inheritance and y =~ association\n -1\n elsif x =~ class_def and y =~ class_def\n 0\n elsif x =~ inheritance and y =~ inheritance\n 0\n elsif x =~ association and y =~ association\n 0\n else\n 1\n end\n\n end\n end",
"def c1= c; @c1 = (c == 1) ? 1 : 0; end",
"def single_variable(x)\n [\n ## conjunction\n # identity\n x ^ Truth > x,\n\n # annihilator\n x ^ Falsity > Falsity,\n\n # idempotence\n x ^ x > x,\n\n ## disjunction\n # identity\n x | Falsity > x,\n\n # annihilator\n x | Truth > Truth,\n\n # idempotence\n x | x > x,\n\n ## complementation\n # involution\n --x > x,\n\n # 'resolution'\n x ^ -x > Falsity,\n x | -x > Truth,\n\n # self-implication\n x > x > Truth,\n\n ]\n end",
"def valid_primitive?\n # \n return m > n && (m - n) % 2 == 1 \n end",
"def assign?\n\t\ttrue\n\tend",
"def alternatives; end",
"def type\n\t\tCOND_NUM_ATTENDING\n\tend",
"def id!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = ID\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 49:5: ( 'a' .. 'z' | 'A' .. 'Z' ) ( ( 'a' .. 'z' | 'A' .. 'Z' ) | '_' | ( '0' .. '9' ) )*\n if @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n # at line 49:33: ( ( 'a' .. 'z' | 'A' .. 'Z' ) | '_' | ( '0' .. '9' ) )*\n while true # decision 8\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0.between?( 0x30, 0x39 ) || look_8_0.between?( 0x41, 0x5a ) || look_8_0 == 0x5f || look_8_0.between?( 0x61, 0x7a ) )\n alt_8 = 1\n\n end\n case alt_8\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x5a ) || @input.peek(1) == 0x5f || @input.peek( 1 ).between?( 0x61, 0x7a )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n\n end\n\n\n\n else\n break # out of loop for decision 8\n end\n end # loop for decision 8\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end",
"def ndp_lla=(i); typecast i; end",
"def bool!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 27 )\n\n\n\n type = BOOL\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 48:7: ( 'verdadero' | 'falso' )\n # at line 48:7: ( 'verdadero' | 'falso' )\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0 == 0x76 )\n alt_7 = 1\n elsif ( look_7_0 == 0x66 )\n alt_7 = 2\n else\n raise NoViableAlternative( \"\", 7, 0 )\n\n end\n case alt_7\n when 1\n # at line 48:9: 'verdadero'\n match( \"verdadero\" )\n\n\n when 2\n # at line 48:23: 'falso'\n match( \"falso\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 27 )\n\n\n end",
"def lhs\n expect(*ASSIGNMENT_BOOL)\n self[1]\n end",
"def nucleotide_score\n {\n A: 0,\n C: 0,\n G: 0,\n T: 0\n }\nend",
"def nucleotide_score\n {\n A: 0,\n C: 0,\n G: 0,\n T: 0\n }\nend",
"def lhsassignment\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 15 )\n __IDENTIFIER7__ = nil\n __IDENTIFIER8__ = nil\n\n begin\n # at line 542:2: ( arrayaccess | IDENTIFIER '.' IDENTIFIER | 'this' '.' IDENTIFIER | IDENTIFIER )\n alt_19 = 4\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == IDENTIFIER )\n case look_19 = @input.peek( 2 )\n when T__32 then alt_19 = 1\n when T__40 then alt_19 = 2\n when T__39 then alt_19 = 4\n else\n raise NoViableAlternative( \"\", 19, 1 )\n end\n elsif ( look_19_0 == T__41 )\n alt_19 = 3\n else\n raise NoViableAlternative( \"\", 19, 0 )\n end\n case alt_19\n when 1\n # at line 542:5: arrayaccess\n @state.following.push( TOKENS_FOLLOWING_arrayaccess_IN_lhsassignment_695 )\n arrayaccess\n @state.following.pop\n\n when 2\n # at line 543:5: IDENTIFIER '.' IDENTIFIER\n match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_lhsassignment_701 )\n match( T__40, TOKENS_FOLLOWING_T__40_IN_lhsassignment_703 )\n match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_lhsassignment_705 )\n\n when 3\n # at line 544:5: 'this' '.' IDENTIFIER\n match( T__41, TOKENS_FOLLOWING_T__41_IN_lhsassignment_712 )\n match( T__40, TOKENS_FOLLOWING_T__40_IN_lhsassignment_714 )\n __IDENTIFIER7__ = match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_lhsassignment_716 )\n # --> action\n\n \t\t if( not @current_class.instance_variables[__IDENTIFIER7__.text].nil?)\n \t\t\t \t@stack_operands.push(@current_class.instance_variables[__IDENTIFIER7__.text].address)\n \t\t\t \t@stack_types.push(@current_class.instance_variables[__IDENTIFIER7__.text].type)\n \t\t\t else\n \t\t\t raise \"Variable #{__IDENTIFIER7__.text} not declared as instance of #{@current_class.name}\"\n \t\t\t end\n \t\t \n # <-- action\n\n when 4\n # at line 553:5: IDENTIFIER\n __IDENTIFIER8__ = match( IDENTIFIER, TOKENS_FOLLOWING_IDENTIFIER_IN_lhsassignment_728 )\n # --> action\n\n \t # Verificar que exista en algun scope y meterlo en pila de operandos\n \t\t\t if(not @current_method.nil?)\n \t\t\t if(not @current_method.local_variables[__IDENTIFIER8__.text].nil?)\n \t\t\t @stack_operands.push(@current_method.local_variables[__IDENTIFIER8__.text].address)\n \t\t\t @stack_types.push(@current_method.local_variables[__IDENTIFIER8__.text].type)\n \t\t\t elsif( not @current_class.instance_variables[__IDENTIFIER8__.text].nil?)\n \t\t\t @stack_operands.push(@current_class.instance_variables[__IDENTIFIER8__.text].address)\n \t\t\t @stack_types.push(@current_class.instance_variables[__IDENTIFIER8__.text].type)\n \t\t\t else\n \t\t\t raise \"Variable #{__IDENTIFIER8__.text} not declared neither in #{@current_class.name} or its method #{@current_method.name}\"\n \t\t\t end\n \t\t\t else\n \t\t\t \tif( not @current_class.instance_variables[__IDENTIFIER8__.text].nil?)\n \t\t\t \t @stack_operands.push(@current_class.instance_variables[__IDENTIFIER8__.text].address)\n \t\t\t \t @stack_types.push(@current_class.instance_variables[__IDENTIFIER8__.text].type)\n \t\t\t else\n \t\t\t raise \"Variable #{__IDENTIFIER8__.text} not declared as instance of #{@current_class.name}\"\n \t\t\t end\n \t\t\t end\n \t \n # <-- action\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 15 )\n\n end\n \n return \n end",
"def gen_boolean\n [true, false].sample\n end",
"def assignments; end",
"def undetermined?\n undetermined == 'true'\n end",
"def assignment_for_identity(request)\n identity = identity()\n if filter_visitor?(request, identity)\n default\n else\n index = connection.ab_showing(@id, identity) || connection.ab_assigned(@id, identity)\n unless index\n index = alternative_for(identity).to_i\n save_assignment(identity, index, request) unless @playground.using_js?\n end\n alternatives[index.to_i]\n end\n end",
"def boolean_rule_test_sets\n {\n 'not set': 'fail',\n 'set': 'pass'\n }\nend",
"def negation\n attr_val('./@inversionInd') == \"true\"\n end",
"def angenehm?(in_temp)\n\tcheck_pre((in_temp.int?))\n#\tANGENEHM_RANGE === in_temp\n in_temp.in?(ANGENEHM_RANGE)\nend",
"def assignment?\n index_assignment? || attribute_assignment?\n end",
"def syntactic_determinants_for( symbols, into = nil, trail_marker = nil )\n if symbols.is_an?(Array) then\n trail_marker = Util::TrailMarker.new() if trail_marker.nil?\n determinants = into.nil? ? {} : into\n \n symbols.each do |symbol|\n syntactic_determinants_for( symbol, determinants, trail_marker )\n end\n \n return into.nil? ? determinants.keys : into\n \n \n else\n symbol = symbols\n name = symbol.name\n \n if @syntactic_determinants.member?(name) then\n if into.nil? then\n return @syntactic_determinants[name]\n else\n into.update(@syntactic_determinants[name].to_hash())\n return into\n end\n end\n\n trail_marker = Util::TrailMarker.new() if trail_marker.nil?\n determinants = {}\n complete = false\n \n if @group_members.member?(name) then\n group = @group_members[name]\n complete = trail_marker.enter(group.object_id) do\n group.each do |member|\n if member.refers_to_token? then\n determinants[member] = true\n else\n syntactic_determinants_for(member, determinants, trail_marker) if trail_marker.mark(member.name)\n end\n end\n end\n elsif @syntactic_production_sets.member?(name) then\n production_set = @syntactic_production_sets[name]\n complete = trail_marker.enter(production_set.object_id) do\n production_set.each do |production|\n leader = production.symbols[0]\n if leader.refers_to_token? then\n determinants[leader] = true\n else\n syntactic_determinants_for(leader, determinants, trail_marker) if trail_marker.mark(leader.name)\n end\n end\n end\n elsif name.character_range?() then\n determinants[name.name] = true\n else\n determinants[Plan::Symbol.new(name, :token)] = true\n end\n \n into.update( determinants ) unless into.nil?\n\n\n #\n # Cache the answer and return.\n \n @syntactic_determinants[name] = determinants.keys if complete\n return into.nil? ? determinants.keys : into\n end\n end",
"def match_maker(criteria, *sets)\n #go through each of the sets, in bulk of two\n score = []\n i = 0\n\n while i < sets.length do\n score << false if criteria == true and !!sets[i] == !!sets[i+1]\n score << true if criteria == false and !!sets[i] == !!sets[i+1]\n score << true if criteria == true and !!sets[i] != !!sets[i+1]\n score << false if criteria == false and !!sets[i]!= !!sets[i+1]\n i += 2\n end\n return score\nend",
"def to_bool() true end",
"def trueish?\n %w(1 t).include? self\n end",
"def boolean\n map ->(primitive) { primitive.to_bool }\n end",
"def check_for_tautology\n counter = 0\n random_decision = Decider.new(@propositional_statement, @random_truth_values).evaluate_expression\n if random_decision == false\n what_simulator_tells = \"False\"\n elsif random_decision == true\n @possible_truth_tables.each do |possible_truth_table|\n counter += 1\n decision = Decider.new(@propositional_statement, possible_truth_table).evaluate_expression\n if decision == false\n what_simulator_tells = \"False\"\n break\n elsif decision == true && counter == @max_truth_tables\n what_simulator_tells = \"True\"\n break\n end\n end\n end\n what_simulator_tells\n end",
"def prime_mutation_determination(roll)\n case roll\n when 1..9\n @@primary_mutations << \"Acid Blood\"\n @@attacks << {:attack_mode => \"Acid blood spray\", :SV => 20, :rate => 1, :range => 2, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"automatic on melee or point-blank puncturing attack\"}\n\n when 10..20\n @@primary_mutations << \"Acid Spit\"\n @@attacks << {:attack_mode => \"Acid Spit\", :SV => 6, :rate => 1, :range => 6, :damage => \"d6 + 2 per dround for d6 rounds\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"does same damage to ropes, bars, locks, etc.\"}\n when 21..32\n @@primary_mutations << \"Advanced Mind\"\n @@intelligence += (d(10 + d(10) + d(10)))\n @@character_notes << \"character gains two hazard checks against insanity and mental attacks that require hazard checks\"\n\n when 33..36\n @@primary_mutations << \"Agony Sphere\"\n @@attacks << {:attack_mode => \"Agony Sphere\", :SV => \"auto\", :rate => 1, :range => (@@willpower/2), :damage => \"d6 + +10DV to targets\", :ammo => \"1/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"requires 3 full rounds of concentration to unleash; can be sustained for 1 rd/willpower point\"}\n\n when 37..44\n @@primary_mutations << \"Amphibian\"\n @@character_notes << \"Can breathe as well in water as air\"\n @@character_notes << \"Suffers d3 dmg per day in arid environments\"\n\n when 45..52\n @@primary_mutations << \"Amplification\"\n @@character_notes << \"Doubles daily/rank-based rate of limited-use mutations\"\n\n when 53..59\n @@primary_mutations << \"Aquatic Adaptation\"\n @@character_notes << \"Webbed hands and feet\"\n @@character_notes << \"Withstands cold 2x vs. humans\"\n @@character_notes << \"Must be fully immersed in water 1hr per day or suffer d3 dmg; d6 in desert areas\"\n\n when 60..71\n @@primary_mutations << \"Arid Adaptation\"\n @@dv -= 3\n @@appearance = [@@appearance - d(8), 1].max\n @@character_notes << \"Needs 1/10th as much water as pure stock human\"\n @@character_notes << \"Specialized organ holds 2 liters drinking water (can yak up in 250 or 500ml portions)\"\n\n when 72..79\n @@primary_mutations << \"Asphyxiation Zone\"\n @@attacks << {:attack_mode => \"Asphyxiation Zone\", :SV => \"auto\", :rate => 1, :range => (@@willpower * 2), :damage => \"d10\", :ammo => \"2/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"lasts 2 rounds per rank\"}\n\n when 80..89\n @@primary_mutations << \"Aura of Protection\"\n @@character_notes << \"2 uses / rank / day; DV -10 + 10 pt force field dmg soak per round; duration willpower rounds; 2 rounds to activate\"\n\n when 90..102\n @@primary_mutations << \"Ballistic Hide\"\n @@dv -= 4\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Additional -20DV vs. blunt/crushing attacks including non-AP bullets\"\n\n when 103..109\n @@primary_mutations << \"Beak\"\n @@appearance = [@@appearance - (d(6) + d(6)), 1].max\n @@attacks << {:attack_mode => \"Beak\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n @@character_notes << \"Character cannot speak clearly\"\n\n when 110..127\n @@primary_mutations << \"Beam Eyes\"\n @@attacks << {:attack_mode => \"Beam Eyes\", :SV => 15, :rate => 1, :range => (@@willpower + @@perception), :damage => \"10 + d6/rank\", :ammo => \"2 / rank / day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n\n when 128..134\n @@primary_mutations << \"Berserker Rage\"\n @@character_notes << \"Berserker Rage: 2/day/rank usage; duration 1 battle; -5DV, +10SV, +10dmg (melee weapons only); +20 strength; can fight on for d6 rounds after suffering fatal damage\"\n when 135..144\n @@primary_mutations << \"Bladed Limbs\"\n def bladed_limbs_location(roll)\n case roll\n when 1 then result = \"Shoulder\"\n when 2 then result = \"Back\"\n when 3 then result = \"Chest\"\n when 4 then result = \"Side\"\n when 5 then result = \"Hip\"\n when 6 then result = \"Abdomen\"\n end\n end\n\n d(4).times do\n bladed_limbs_location(d(6))\n @@character_notes << \"Sword-like bone blade protruding from #{result}\"\n @@appearance = [@@appearance - 2, 1].max\n @@character_weight += 5\n end\n\n @@attacks << {:attack_mode => \"Bladed limb(s)\", :SV => 5, :rate => \"1 per bladed limb\", :range => 0, :damage => \"d12 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n\n\n when 145..149\n @@primary_mutations << \"Blurred Movement\"\n @@character_notes << \"Blurred Movement: -20DV; willpower rounds/day; can be used to blur entire body or only parts\"\n\n when 150..179\n @@character_notes << \"Due to body disporportion, no relic shell armor can be worn, but other types can be modified to fit\"\n def body_disproportion_location(roll)\n case roll\n when 1\n @@primary_mutations << \"Body Disproportion: Dominant arm is massive!\"\n @@character_notes << \"Dominant arm has strength of #{(@@strength + @@strength + d(20) + d(20))} which applies to all 1- and 2-handed melee weapons character wields\"\n @@appearance = [@@appearance - d(4), 1].max\n @@move -= 0.5\n @@character_weight += (20 + d(20))\n when 2\n @@primary_mutations << \"Body Disproportion: Character's head is massive!\"\n @@intelligence += (d(20) + 20)\n @@move -= 1\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"TWO intelligence-based hazard checks, when called for\"\n @@character_weight += (20 + d(10))\n when 3\n @@primary_mutations << \"Body Disproportion: Upper body incredibly over-muscled!\"\n @@strength += (20 + d(20))\n @@endurance += (20 + d(20))\n @@move -= 1\n @@agility = [@@agility - d(10), 1].max\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_weight += (20 + d(20) + d(20))\n when 4\n @@primary_mutations << \"Body Disproportion: hips and legs are twice normal length!\"\n @@move += @@move\n @@character_height += 100\n @@appearance = [@@appearance - d(4), 1].max\n @@attacks << {:attack_mode => \"Wicked kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_weight += (30 + d(20) + d(20))\n when 5\n @@primary_mutations << \"Body Disproportion: comically giant hands and feet!\"\n @@attacks << {:attack_mode => \"Punch or kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_notes << \"Weapons with triggers, keyboards, or other items requiring normal human hands are unusable without modifying item.\"\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@character_weight += (d(6) + d(6) + d(6) + d(6))\n when 6\n @@primary_mutations << \"Body Disproportion: extra long arms!\"\n @@character_notes << \"+5 SV in melee combat\"\n @@character_notes << \"+5 thrown weapon DMG\"\n @@appearance = [@@appearance - (d(4) + 1), 1].max\n when 7\n @@primary_mutations << \"Body Disproportion: greatly elongated torso!\"\n @@character_notes << \"If pregnant, gives birth to a litter of d4 + 1 offspring.\"\n @@endurance += (d(10) + d(10))\n @@appearance = [@@appearance - d(6), 1].max\n @@character_height += (20 + d(20))\n @@character_weight += (10 + d(20))\n def elongated_torso_bonus(roll1, roll2, roll3, roll4) # need to add actual mutation results via primary_mutations_roll(xx)\n case roll1\n when 1..50\n @@primary_mutations << \"Reserve heart\"\n end\n case roll2\n when 1..65\n @@primary_mutations << \"Radiation absorption\"\n end\n case roll3\n when 1..37\n @@primary_mutations << \"Breath holding\"\n end\n case roll4\n when 1..72\n @@primary_mutations << \"Nutriment cache\"\n end\n\n end\n elongated_torso_bonus(d(100),d(100),d(100),d(100))\n when 8\n 2.times do\n elongated_torso_bonus(d(7))\n end\n end\n\n end\n body_disproportion_location(d(8))\n\n when 180..195\n def body_regeneration_rate(roll)\n case roll\n when 1..12\n @@endurance_healing_rate += 4\n when 13..32\n @@endurance_healing_rate += 7\n when 33..40\n @@endurance_healing_rate += 10\n when 41..64\n @@endurance_healing_rate = 15\n when 65..87\n @@endurance_healing_rate = \"1 pt per hour\"\n when 88..93\n @@endurance_healing_rate = \"2 pts per hour\"\n when 94..96\n @@endurance_healing_rate = \"4 pts per hour\"\n when 97..98\n @@endurance_healing_rate = \"6 pts per hour\"\n when 99\n @@endurance_healing_rate = \"10 pts per hour\"\n when 100\n @@endurance_healing_rate = \"1 pt per round\"\n end\n end\n body_regeneration_rate(d(100))\n @@primary_mutations << \"Body Regeneration: #{@@endurance_healing_rate} healing rate bonus\"\n\n when 196..201\n @@primary_mutations << \"Breath Holding: triple base endurance rate + regular breath holding rate (Hub Rules p. 122)\"\n when 202..224\n @@primary_mutations << \"Claws: don’t hinder her from using bows, crossbows, or weapons that use a trigger, but disallow her from using keyboards or doing fne electronics work\"\n @@attacks << {:attack_mode => \"Claw\", :SV => 7, :rate => \"1 per hand\", :range => 0, :damage => \"d12 each\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62-63\", :notes => \"\"}\n @@character_notes << \"Thanks to claws, character climbs as though she has 2 points in Climbing skill\"\n when 225..230\n @@primary_mutations << \"Climbing Suckers: like a gecko, character can climb on anything at 1/2 move\"\n @@character_notes << \"When falling, type A agility based hazard check to catch side of building/pit and stop fall\"\n when 231..239\n @@primary_mutations << \"Coma Inducement\"\n @@attacks << {:attack_mode => \"Coma inducement\", :SV => 0, :rate => \"\", :range => @@willpower + @@willpower, :damage => \"coma\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"victim gets tybe B willpower based hazard check; see p. 63 for details\"}\n when 240..253\n number_of_pincers = 0\n arms_too = \"True\"\n pincer_size = \"Small\"\n def pincer_formation_on_mutant(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Crab Pincers: 1 pincer replacing 1 arm\"\n number_of_pincers += 1\n @@character_weight -= 15\n when 3..6\n @@primary_mutations << \"Crab Pincers: 2 pincers replacing both human arms\"\n number_of_pincers += 2\n @@character_weight -= 30\n when 7\n @@primary_mutations << \"Crab Pincers: 1 pincer growing from shoulder, both human arms intact\"\n number_of_pincers += 1\n when 8..9\n @@primary_mutations << \"Crab Pincers: 2 pincers in addition to human arms\"\n number_of_pincers += 2\n when 10\n number_of_pincers = (2 + d(2))\n def arms_too(roll)\n case roll\n when 79..100\n arms_too = \"False\"\n @@character_weight -= 30\n end\n end\n @@primary_mutations << \"Crab Pincers: #{number_of_pincers} total\"\n arms_too(d(100))\n end\n end\n def pincer_size(roll)\n case roll\n when 1..3\n pincer_size = \"Small\"\n @@character_weight += (number_of_pincers * 15)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 2, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d10 + 1\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 4..6\n pincer_size = \"Medium\"\n @@movement_rate_base -= (0.25 * number_of_pincers)\n @@character_weight += (number_of_pincers * 20)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 4, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d12 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 7..9\n pincer_size = \"Large\"\n @@movement_rate_base -= (0.5 * number_of_pincers)\n @@character_weight += (number_of_pincers * 35)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 7, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 10\n pincer_size = \"Massive\"\n @@movement_rate_base -= (0.75 * number_of_pincers)\n @@character_weight += (number_of_pincers * 50)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 10, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n end\n end\n\n pincer_formation_on_mutant(d(10))\n pincer_size(d(10))\n @@primary_mutations << \"Pincers: #{number_of_pincers} of #{pincer_size} size\"\n if arms_too == \"False\"\n @@appearance = [@@appearance - (number_of_pincers * d(4) + 2), 1].max\n @@character_notes << \"No human arms - character cannot use triggers, keyboards, or complex items\"\n elsif arms_too == \"True\"\n @@appearance = [@@appearance - (number_of_pincers * d(4)), 1].max\n end\n\n\n when 254..292\n def deviant_skin_structure(roll)\n case roll\n when 1..3\n @@primary_mutations << \"Fire-proof skin\"\n @@character_notes << \"No damage from fire for 10 rounds; 1/2 damage after\"\n @@character_notes << \"1/2 damage from explosions\"\n when 4..5\n @@primary_mutations << \"Reflective skin\"\n @@character_notes << \"1/2 damage from beam weapons when clothed; 70 percent resistance to beam weapons vs. bare skin\"\n @@appearance += d(6)\n when 6..7\n @@primary_mutations << \"Alkaline skin\"\n @@character_notes << \"Character totally immune to acid attacks (which still ruin character's gear)\"\n when 8..10\n @@primary_mutations << \"Weather sensitive skin\"\n @@character_notes << \"Sense weather changes in 20km radius; can sense open bodies of water within 2 km\"\n when 11\n @@primary_mutations << \"Glow in the dark skin\"\n @@character_notes << \"3m radius green glow; visible up to 12km away - character can't turn off glow\"\n when 12\n @@primary_mutations << \"Photosynthetic skin\"\n @@character_notes << \"4 hrs in sunlight = 1 meal; 1 hr in sunlight = 3 pts healing (in addition to normal resting healing)\"\n end\n end\n deviant_skin_structure(d(12))\n\n when 293..298\n @@primary_mutations << \"Devastator Pulse\"\n @@attacks << {:attack_mode => \"Devastator Pulse\", :SV => (@@accuracy + @@willpower), :rate => \"4 rounds to charge, release on 5th\", :range => @@willpower, :damage => \"3d20 / d100 + 40 vs. machines\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"\"}\n\n when 299..300\n @@primary_mutations << \"Displacement\"\n @@character_notes << \"Displacement: #{@@willpower} rounds per day, DV -30\"\n when 301..305\n @@primary_mutations << \"Doom Sphere\"\n @@attacks << {:attack_mode => \"Doom Sphere\", :SV => \"01-95\", :rate => \"1/10 days\", :range => (@@willpower * 10), :damage => \"3d20 vs organics; 6d20 vs electronics\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"User must make intelligence type B hazard check or go insane for 1 hour (p. 126)\"}\n when 306..314\n @@primary_mutations << \"Dread Zone\"\n @@attacks << {:attack_mode => \"Dread Zone\", :SV => \"01-95\", :rate => 1, :range => @@intelligence, :damage => \"tybe B hazard check vs. intelligence or +10SV to attack\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Duration: rank in rounds; does not affect inorganic beings or creatures with morale = n/a\"}\n when 315..322\n @@primary_mutations << \"Earth Thump\"\n @@attacks << {:attack_mode => \"Earth Thump\", :SV => (@@willpower + 30), :rate => \"3 rounds to generate\", :range => @@willpower, :damage => \"d10/user rank\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Targets 1 human-sized enemy per rank of user (assuming multiple targets close together)\"}\n when 323..341\n @@primary_mutations << \"Electrical Charge\"\n @@attacks << {:attack_mode => \"Electrical Charge\", :SV => 20, :rate => \"1\", :range => 0, :damage => \"d20 + HC\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Victim makes END-based tybe B hazard check or stunned for d3 rounds\"}\n @@character_notes << \"Four Electrical Charge jolts are suffcient to fully re-charge a standard power cell.\"\n when 342..349\n @@primary_mutations << \"Electrical Pulse\"\n @@attacks << {:attack_mode => \"Electrical Pulse\", :SV => 20, :rate => 1, :range => (@@willpower), :damage => \"d20 / 3d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"Can be used to start fires as well\"}\n when 350..355\n @@primary_mutations << \"Electro Magnetic Pulse\"\n @@attacks << {:attack_mode => \"Electro Magnetic Pulse\", :SV => 30, :rate => 1, :range => @@willpower, :damage => \"d10/d100 vs electronics\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"\"}\n when 356..376\n @@primary_mutations << \"Empathy\"\n @@character_notes << \"Empathy: #{@@willpower} range. Unlimited uses. The subject is allowed a type C, intelligence based hazard check. If failed, mutant knows victim's emotions. Alternately, emotions can be projected.\"\n when 377..388\n @@primary_mutations << \"Energy Blade\"\n def energy_blade_type(roll) # table Hub Rules p. 65\n case roll\n when 1..20\n @@attacks << {:attack_mode => \"Energy Blade: Blue\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 21..40\n @@attacks << {:attack_mode => \"Energy Blade: Green\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 41..65\n @@attacks << {:attack_mode => \"Energy Blade: Red\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 66..85\n @@attacks << {:attack_mode => \"Energy Blade: Orange\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 86..97\n @@attacks << {:attack_mode => \"Energy Blade: Purple\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 98..99\n @@attacks << {:attack_mode => \"Energy Blade: White\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 100\n @@attacks << {:attack_mode => \"Energy Blade: Gold\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n end\n end\n if @@primary_mutations.include? \"Energy Blade\" # Note: NO duplication -- reroll if this result comes up twice.\n @@primary_mutations_rolls += 1\n else\n energy_blade_type(d(100))\n end\n\n when 389..401\n @@primary_mutations << \"Extreme Size Decrease\"\n @@character_height = (22 + d(20) + d(20)) # NOTE: should be dependent on GENDER, ignored that.\n 3.times @@skills << \"Stealth\"\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Cannot wield two-handed weapons. Normal one-handed weapons including pistols must be employed with both hands (except knifes and daggers, which are considered swords for this mutant)\"\n @@character_notes << \"Relic armor cannot be worn except scrap relic.\"\n def extreme_size_decrease(height) # Hub Rules p. 65\n case height\n when 22..27\n @@character_weight = (15 + d(10))\n @@agility += 20\n @@movement_rate_base == 4.5\n @@strength = [@@strength - 15, 1].max\n @@endurance = [@@endurance - 10, 1].max\n when 28..35\n @@character_weight = (20 + d(12))\n @@agility += 15\n @@movement_rate_base = 5\n @@strength = [@@strength - 10, 1].max\n @@endurance = [@@endurance - 7, 1].max\n when 36..45\n @@character_weight = (25 + d(20))\n @@agility += 10\n @@movement_rate_base = 5.5\n @@strength = [@@strength - 5, 1].max\n @@endurance = [@@endurance - 5, 1].max\n when 46..65\n @@character_weight = (30 + d(20) + d(20))\n @@agility += 7\n @@movement_rate_base = 6\n @@strength = [@@strength - 3, 1].max\n @@endurance = [@@endurance - 3, 1].max\n end\n end\n\n extreme_size_decrease(@@character_height)\n\n when 402..419\n def fang_size(roll) # Hub rules p. 65\n case roll\n when 1..3\n sizeoffangs = \"Small\"\n fangsv = 2\n fangdmg = \"d6\"\n @@appearance = [@@appearance - 1, 1].max\n when 4..8\n sizeoffangs = \"Medium\"\n fangsv = 4\n fangdmg = \"d10\"\n @@appearance = [@@appearance - (1 + d(2)), 1].max\n when 9..10\n sizeoffangs = \"Huge\"\n fangsv = 6\n fangdmg = \"d20\"\n @@appearance = [@@appearance - (d(3) + 2), 1].max\n @@character_notes << \"Ability to speak clearly greatly reduced\"\n end\n @@attacks << {:attack_mode => \"Fangs\", :SV => fangsv, :rate => 1, :range => 0, :damage => fangdmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"This attack can only be employed as a supplemental melee attack if involved in close fighting\"}\n @@primary_mutations << \"Fanged: #{sizeoffangs} size\"\n end\n\n fang_size(d(10))\n\n when 420..427\n @@primary_mutations << \"Flame Breath\"\n @@attacks << {:attack_mode => \"Flame Breath\", :SV => 10, :rate => 1, :range => \"3/rank\", :damage => \"d6/rd for 2d6 rds\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66\", :notes => \"Up to 3 man sized targets can be attacked at once if close together\"}\n when 428..438\n def force_field_strength(roll) # Hub rules p. 66\n case roll\n when 1..10\n force_field = d(10)\n when 11..24\n force_field = (d(10) + 3)\n when 25..53\n force_field = (d(10) + 5)\n when 54..78\n force_field = (d(10) + 10)\n when 79..94\n force_field = (d(10) + 12)\n when 95\n force_field = (d(10) + 15)\n when 96\n force_field = (d(10) + 17)\n when 97\n force_field = (d(10) + 20)\n when 98\n force_field = (d(10) + 23)\n when 99\n force_field = (d(10) + 26)\n when 100\n force_field = (d(10) + 30)\n end\n @@primary_mutations << \"Force Field: 2 uses/rank/day; #{willpower} rounds duration; absorbs #{force_field} dmg/round\"\n end\n force_field_strength(d(100))\n\n when 439..445\n @@primary_mutations << \"Foul Flesh\"\n @@character_notes << \"Will not eat mutant: all mammals, all humanoids except moaners, horrlify, all amphibians, fsh, birds except black vultures, reptilius, all reptiles, except alligators and crocodilians.\"\n when 446..453\n def furred_mutation(roll)\n case roll\n when 1..3\n fur_type = \"Fine, cat-like\"\n fur_dv = -3\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - d(3), 1].max\n when 4..5\n fur_type = \"Wool, sheep-like\"\n fur_dv = -6\n fur_cold = \"Triple normal human cold resistance\"\n @@appearance = [@@appearance - (1 + d(4)), 1].max\n when 6..7\n fur_type = \"Thick, sheep-like wool\"\n fur_dv = -9\n fur_cold = \"Quadruple normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + 2), 1].max\n when 8..9\n fur_type = \"Badger-like bristles\"\n fur_dv = -11\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 2), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n when 10\n fur_type = \"Porcupine-like quills\"\n fur_dv = -13\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 3), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n end\n @@primary_mutations << \"Furred: #{fur_type}, #{fur_cold} cold resistance. #{fur_dv} DV bonus\"\n @@dv += fur_dv\n end\n furred_mutation(d(10))\n when 454..459\n\n def gaseous_discharge(roll) # Hub Rules p. 67\n case roll\n when 1..2\n gas_type = \"Sleep\"\n gas_effect = \"All must make an Endurance-based type A hazard check or pass out for d100 rounds.\"\n when 3..4\n gas_type = \"Blindness\"\n gas_effect = \"All must make an Endurance-based type A hazard check or go blind for d6 days.\"\n when 5\n gas_type = \"Stink\"\n gas_effect = \"All must make an Endurance-based type C hazard check or spend 2 rounds vomiting, becoming +30 to strike, with their own SV being reduced to half, rounded down.\"\n when 6\n gas_type = \"Corrosive\"\n gas_effect = \"All must make an Endurance-based type B hazard check suffer d6 damage/rd from corrosive acids. Those who succeed vs. hazard check take 1 dmg/rd.\"\n when 7\n gas_type = \"Hallucinogenic\"\n gas_effect = \"All must make an Intelligence-based tybe B hazard check or hallucinate, +30SV to strike and -30SV to retaliate. Animals must make a morale check or flee immediately.\"\n when 8\n gas_type = \"Poison\"\n gas_effect = \"All must make an Endurance-based type A hazard check or drop unconscious for 10 rounds. Their breathing ceases on the 11th round and if not resuscitated by artifcial respiration, will die on the 14th round.\"\n end\n @@primary_mutations << \"Gaseous Discharge: #{gas_type}\"\n @@attacks << {:attack_mode => \"Gaseous Discharge: #{gas_type}\", :SV => \"Auto\", :rate => 1, :range => \"10 m radius\", :damage => \"Special\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66-67\", :notes => \"#{gas_effect} Gas dissipates in 2 rounds outdoors or lingers 2d10 + 4 rounds in enclosed areas.\"}\n @@character_notes << \"Character immune to #{gas_type}\"\n end\n\n gaseous_discharge(d(8))\n\n when 460..472\n def gaping_maw(roll) #Hub Rules p. 67\n case roll\n when 1..5\n maw_size = \"Large\"\n maw_sv = 4\n maw_damage = \"d12\"\n maw_mv_mod = 0\n maw_added_weight = 15\n @@appearance = [@@appearance - (d(4) + d(4) + 2), 1].max\n when 6..7\n maw_size = \"Huge\"\n maw_sv = 7\n maw_damage = \"d20\"\n maw_mv_mod -= 0.25\n maw_added_weight = 30\n @@appearance = [@@appearance - (d(4) + d(4) + 4), 1].max\n when 8..9\n maw_size = \"Massive\"\n maw_sv = 12\n maw_damage = \"2d20\"\n maw_mv_mod -= 0.5\n maw_added_weight = 70\n @@appearance = [@@appearance - (d(6) + d(6) + 5), 1].max\n when 10\n maw_size = \"Colossal\"\n maw_sv = 20\n maw_damage = \"3d20\"\n maw_mv_mod -= 1\n maw_added_weight = 120\n @@appearance = [@@appearance - (d(6) + d(6) + 8), 1].max\n end\n @@primary_mutations << \"Gaping Maw: #{maw_size} in size\"\n @@attacks << {:attack_mode => \"Gaping Maw\", :SV => maw_sv, :rate => 1, :range => 0, :damage => maw_damage, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"Can be employed as a supplemental melee attack \"}\n @@character_notes << \"Almost totally carnivorous diet. Mutant drools and spits when speaking in a low, gruff voice difficult for strangers to understand.\"\n @@character_weight += maw_added_weight\n @@movement_rate_base -= maw_mv_mod\n end\n\n gaping_maw(d(10))\n\n\n when 473..497\n def heal_touch(willpower)\n case willpower\n when 1..6\n healrate = \"d8\"\n when 7..14\n healrate = \"d12\"\n when 15..34\n healrate = \"d20\"\n when 35..64\n healrate = \"d20 + 10\"\n when 65..84\n healrate = \"d20 + 20\"\n when 85..105\n healrate = \"d20 + 30\"\n when 106..200\n healrate = \"d20 + 40\"\n end\n @@primary_mutations << \"Heal Touch: 2/day/rank, #{healrate} trait points healed. Diseases healed if victim makes Type B willpower based hazard check.\"\n end\n\n heal_touch(@@willpower)\n\n @@primary_mutations << \"Heal Touch\"\n when 498..511\n def heat_pulse(willpower) # Hub Rules p. 67\n case willpower\n when 1..6\n heat_pulse_sv = -5\n heat_pulse_dmg = \"d6\"\n heat_pulse_range = 5\n when 7..14\n heat_pulse_sv = 0\n heat_pulse_dmg = \"d10\"\n heat_pulse_range = 10\n when 15..34\n heat_pulse_sv = 4\n heat_pulse_dmg = \"d20\"\n heat_pulse_range = @@willpower\n when 35..64\n heat_pulse_sv = 6\n heat_pulse_dmg = \"d20 + 10\"\n heat_pulse_range = (@@willpower * 2)\n when 65..84\n heat_pulse_sv = 9\n heat_pulse_dmg = \"d20 + 20\"\n heat_pulse_range = (@@willpower * 3)\n when 85..105\n heat_pulse_sv = 12\n heat_pulse_dmg = \"d20 + 30\"\n heat_pulse_range = (@@willpower * 4)\n when 106..200\n heat_pulse_sv = 15\n heat_pulse_dmg = \"d20 + 40\"\n heat_pulse_range = (@@willpower * 5)\n end\n @@primary_mutations << \"Heat Pulse\"\n @@attacks << {:attack_mode => \"Heat Pulse\", :SV => heat_pulse_sv, :rate => 1, :range => heat_pulse_range, :damage => heat_pulse_dmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"\"}\n end\n\n heat_pulse(@@willpower)\n\n\n when 512..556\n\n def heightened_attributes(roll) # Hub Rules p. 68\n case roll\n when 1\n heightened_attributes_type = \"Cat Balance\"\n @@agility += (d(20) + 20)\n @@accuracy += (d(10) + d(10))\n @@perception += (d(20) + d(20))\n @@appearance += d(10)\n 2.times @@skills << \"Stealth\"\n @@character_notes << \"Due to cat balance, character always gets two hazard checks when agility or accuracy are involved.\"\n when 2\n heightened_attributes_type = \"Eagle Eyes\"\n @@accuracy += (d(10) + d(10))\n @@perception += (d(10) + d(10) + d(10))\n @@character_notes << \"Due to eagle eyes, character sees 10x better than typical human, including at night.\"\n when 3..4\n heightened_attributes_type = \"Strength\"\n @@strength += (d(20) + 30)\n @@appearance += (d(10) + d(10))\n @@character_notes << \"Due to heightened strength, character always gets two hazard checks when strength involved.\"\n when 5..6\n heightened_attributes_type = \"Endurance\"\n @@endurance += (d(20) + 30)\n @@character_notes << \"Due to heightened endurance, character always gets two hazard checks when endurance involved (eg, poison).\"\n when 7\n heightened_attributes_type = \"Hand-Eye Coordination\"\n @@accuracy += (d(20) + 20)\n @@character_notes << \"Due to superior hand-eye coordination, character always gets two hazard checks when accuracy involved.\"\n when 8\n heightened_attributes_type = \"Beauty\"\n @@appearance += (d(20) + 30)\n @@agility += d(6)\n @@accuracy += d(6)\n @@strength += d(6)\n @@character_notes << \"Due to heightened beauty, character always gets two hazard checks when appearance involved.\"\n when 9\n heightened_attributes_type = \"Auditory\"\n @@dv -= 5\n @@character_notes << \"+2 initiative when operating alone or more than 10m from companions.\"\n @@character_notes << \"Sonic attacks do double damage, while crying babies, crowded pubs, and other intense noises are painful.\"\n @@character_notes << \"Due to heightened hearing, character receives 4 attempts on hazard checks related to listening/hearing.\"\n when 10\n heightened_attributes_type = \"Olfactory\"\n (d(2) + 1).times @@skills << \"Tracking\"\n @@character_notes << \"Due to heightened sense of smell, character gets no hazard checks vs. stink-based attacks.\"\n @@character_notes << \"Character cannot be fooled by illusions at less than 10m\"\n @@character_notes << \"Bloodhound-like tracking abilities; however, after 12 hours, or rain, sand storms, or crossing water, all result in lost trails.\"\n when 11\n heightened_attributes_type = \"Willpower\"\n @@willpower += (d(20) + 30)\n @@character_notes << \"Due to heightened willpower, character always gets two hazard checks when willpower involved.\"\n when 12\n heightened_attributes_type = \"Intelligence\"\n @@intelligence += (d(20) + 30)\n @@character_notes << \"Due to heightened intelligence, character always gets two hazard checks when intelligence involved.\"\n end\n @@primary_mutations << \"Heightened Attributes: #{heightened_attributes_type}\"\n end\n\n heightened_attributes(d(12))\n\n\n when 557..566\n number_of_horns = d(4)\n @@primary_mutations << \"Horns: #{number_of_horns} on head\"\n @@character_weight += (2 * number_of_horns)\n @@attacks << {:attack_mode => \"Horns\", :SV => (3 * number_of_horns), :rate => 1, :range => 0, :damage => \"#{number_of_horns}d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"68\", :notes => \"This attack can be employed as a supplemental melee attack\"}\n @@character_notes << \"Due to horns, character can't wear relic helmets or shell-class armor unless horns permanently removed.\"\n when 567..571\n @@primary_mutations << \"Image Multiplication: #{@@willpower} duration, 2 uses/day/rank. Up to #{@@willpower/10.floor} images of mutant's self created. Hub Rules p. 68\"\n when 572..578\n def image_projection(intelligence)\n case intelligence\n when 1..9\n image_projection_range = \"1 km\"\n image_projection_duration = \"d4 rounds\"\n when 10..34\n image_projection_range = \"#{@@intelligence/2} km\"\n image_projection_duration = \"2d4 rounds\"\n when 35..54\n image_projection_range = \"#{@@intelligence} km\"\n image_projection_duration = \"10 + d10 rounds\"\n when 55..74\n image_projection_range = \"#{@@intelligence * 2} km\"\n image_projection_duration = \"20 + d20 rounds\"\n when 75..94\n image_projection_range = \"#{@@intelligence * 100} km\"\n image_projection_duration = \"100 + d100 rounds\"\n when 95..200\n image_projection_range = \"anywhere within solar system\"\n image_projection_duration = \"200 + 2d100 rounds\"\n end\n @@primary_mutations << \"Image Projection: #{image_projection_range} range, #{image_projection_duration} duration. 1/rank/day. Illusion can repeat 2 words/round. Creatures with 35+ intelligence can make a type B intelligence based hazard check to recognize projection as an illusion. Hub Rules p. 69\"\n end\n\n image_projection(@@intelligence)\n\n when 579..603\n def immunity_mutation(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Poison immunity: totally immune to all forms of poison. Also, cannot get drunk.\"\n when 3..4\n @@primary_mutations << \"Disease immunity: All forms of infection, disease, sickness, parasites, etc. don't affect character. Immune to parasites as well.\"\n when 5..6\n @@primary_mutations << \"Radiation immunity: unaffected by all forms of radiation.\"\n end\n end\n\n immunity_mutation(d(6))\n\n when 605..613\n @@primary_mutations << \"Increased Cellular Activity\"\n @@endurance_healing_rate = (@@endurance_healing_rate * 3)\n @@character_notes << \"Character suffers no ill effects from aging (only benefits) and will live forever if not killed in combat, disease, poison, or accident.\"\n when 614..617\n @@primary_mutations << \"Light Burst: 10m radius, 2/day/rank\"\n @@attacks << {:attack_mode => \"Light Burst\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Type C agility HC or blinded for 2d5 rounds. Blindness: -2 MV, -20 SV, +20 SV to be struck.\"}\n when 618..624\n @@primary_mutations << \"Limb Regeneration: see Hub Rules p. 69 for regeneration rates.\"\n when 625..630\n def mandibles_mutation(roll)\n case roll\n when 1..2\n mandibles_size = \"Small\"\n mandibles_sv = 3\n mandibles_dmg = \"d10\"\n mandibles_weight = 5\n mandibles_appearance = -(d(4) + 3)\n when 3..5\n mandibles_size = \"Medium\"\n mandibles_sv = 5\n mandibles_dmg = \"d12\"\n mandibles_weight = 15\n mandibles_appearance = -(d(6) + 4)\n when 6..7\n mandibles_size = \"Large\"\n mandibles_sv = 8\n mandibles_dmg = \"d20\"\n mandibles_weight = 20\n mandibles_appearance = -(d(8) + 6)\n @@movement_rate_base -= 0.25\n when 8..9\n mandibles_size = \"Huge\"\n mandibles_sv = 11\n mandibles_dmg = \"d20 + 5\"\n mandibles_weight = 30\n mandibles_appearance = -(d(6) + d(6) + 5)\n @@movement_rate_base -= 0.5\n when 10\n mandibles_size = \"Massive\"\n mandibles_sv = 15\n mandibles_dmg = \"d20 + 10\"\n mandibles_weight = 40\n mandibles_appearance = -(d(6) + d(6) + d(6) + 6)\n @@movement_rate_base -= 1\n\n end\n\n @@attacks << {:attack_mode => \"Mandibles\", :SV => mandibles_sv, :rate => 1, :range => 0, :damage => mandibles_dmg, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Can be employed as a supplemental melee attack\"}\n @@character_weight += mandibles_weight\n @@appearance += mandibles_appearance #due to implementation method no protection here from =< 0...\n @@primary_mutations << \"Mandibles: #{mandibles_size} size\"\n end\n\n mandibles_mutation(d(10))\n\n when 631..641\n @@primary_mutations << \"Mental Mine\"\n when 642..655\n @@primary_mutations << \"Mental Screen\"\n when 656..687\n @@primary_mutations << \"Mind Crush\"\n when 688..693\n @@primary_mutations << \"Mind Waste\"\n when 694..699\n @@primary_mutations << \"Monstrous Morph\"\n when 700..718\n def multi_arm_mutation(roll) # Hub Rules p. 71\n case roll\n when 1..10\n additional_arms = 1\n when 11..85\n additional_arms = 2\n when 86..90\n additional_arms = 3\n when 91..97\n additional_arms = 4\n when 98\n additional_arms = 5\n when 99\n additional_arms = 6\n when 100\n additional_arms = (d(6) +6)\n end\n if additional_arms % 2 == 1\n def odd_arm_side(roll)\n case roll\n when 1\n odd_arm = \"right\"\n when 2\n odd_arm = \"left\"\n end\n end\n odd_arm_side(d(2))\n @@character_notes << \"Odd arm is on the #{odd_arm_side} side.\"\n end\n\n @@primary_mutations << \"Multi-Arm: #{additional_arms} additional arms\"\n end\n\n multi_arm_mutation(d(100))\n\n when 719..728\n def multi_head_mutation(roll)\n case roll\n when 1..70\n additional_heads = 1\n multi_head_appearance = -d(4)\n multi_head_mv = 0\n multi_head_initiative = 1\n when 71..88\n additional_heads = 2\n multi_head_appearance = -(d(4) + 1 )\n multi_head_mv = 0.25\n multi_head_initiative = 1\n when 89..95\n additional_heads = 3\n multi_head_appearance = -(d(6) + 2)\n multi_head_mv = 0.5\n multi_head_initiative = 2\n when 96..97\n additional_heads = 4\n multi_head_appearance = -(d(6) + 4)\n multi_head_mv = 0.75\n multi_head_initiative = 2\n when 98..99\n additional_heads = 5\n multi_head_appearance = -(d(6) + 6)\n multi_head_mv = 1\n multi_head_initiative = 3\n when 100\n additional_heads = 6\n multi_head_appearance = -(d(6) + 8)\n multi_head_mv = 1.25\n multi_head_initiative = 4\n end\n\n @@primary_mutations << \"Multi-Head: #{additional_heads} additional heads.\"\n @@appearance += multi_head_appearance\n @@movement_rate_base -= multi_head_mv\n @@initiative += multi_head_initiative\n @@character_notes << \"Heads tend to sleep at different times, with wakeful heads acting as lookout.\"\n\n while extra_heads > 0 do\n intelligence = attributes_roll(d100)\n wisdom = attributes_roll(d100)\n puts \"Extra head no. #{extra_heads} has INT of #{intelligence} and WIS of #{wisdom}\"\n def extra_head_mutations(roll2)\n case roll2\n when 1..62\n extra_head_mutation = ghost_mutations(d(100))\n @@primary_mutations << extra_head_mutation\n @@character_notes << \"Extra head no. #{extra_heads} has the mental mutation #{extra_head_mutation}\" # HOW to pick just the name of the mental mutation??\n end\n end\n end\n additional_heads -= 1\n end\n multi_head_mutation(d(100))\n\n when 729..738\n @@primary_mutations << \"Night Vision: can see as well at night as a typical human can in daylight (at least starlight must be present).\"\n when 739..745\n @@primary_mutations << \"Peeling Radius\"\n @@attacks << {:attack_mode => \"Peeling Radius\", :SV => 0, :rate => 1, :range => 10, :damage => \"d6/rd\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"10m radius. Automatic hit. Duration: 3 rds/rank\"}\n when 746..754\n def poison_bite_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Bite: #{poison_bite_type} venom, strength #{poison_bite_strength}, 4/day. Sufficient to coat 4 arrows/darts or 1 blade per injection's worth of poison.\"\n @@attacks << {:attack_mode => \"Poison Bite\", :SV => 0, :rate => 1, :range => 0, :damage => \"d6 plus poison\", :ammo => \"4/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"#{poison_bite_type} venom, #{poison_bite_strength} strength.\"}\n end\n\n poison_bite_mutation(d(100),d(10))\n\n\n when 755..760\n\n def poison_blood_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Blood: #{poison_bite_type} venom, #{poison_bite_strength} strength. Any creature biting mutant poisoned.\"\n\n end\n\n poison_blood_mutation(d(100),d(10))\n\n when 761..767\n paralysis_tendrils = d(6)\n @@primary_mutations << \"Paralysis Tendrils: #{paralysis_tendrils} 3m length grow from mutant's chest\"\n @@appearance = [@@appearance - (4 * paralysis_tendrils), 1].max\n @@attacks << {:attack_mode => \"Paralysis Tendrils\", :SV => 10, :rate => 1, :range => 3, :damage => \"d12 stun, 2d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"#{paralysis_tendrils} tendrils, each capable of attack 3/day/rank.\"}\n\n\n when 768..773\n @@primary_mutations << \"Radiation Absorption: mutant immune to radioactivity, except for radioactive weapons, which do half damage.\"\n when 774..780\n @@primary_mutations << \"Radiation Detection: automatically senses the presence of radiation within a twenty meter radius, including those rare sources found in special radiation using robots, relic weapons and life forms.\"\n when 781..786\n @@primary_mutations << \"Radioactive Pulse\"\n @@attacks << {:attack_mode => \"Radioactive Pulse\", :SV => 10, :rate => 1, :range => @@willpower, :damage => \"d20 plus radiation\", :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Victim makes type B endurance hazard check or suffer medium exposure; then type A hazard check or suffer strong exposure.\"}\n when 787..794\n @@primary_mutations << \"Reserve Heart: If character deemed to be killed by poison or electricity, or a critical hit which specifcally states a piercing of the heart, she will appear to be quite dead for 2d20+10 rounds. After this comatose period without a pulse or heartbeat, her back up heart will suddenly kick in and induce 2d10 endurance of healing, bringing the character slowly back to life.\"\n when 795..802\n @@primary_mutations << \"Reserve Mind: back-up brain takes over in case of brain damage, unconsciousness, insanity, or lethal damage. Hub Rules p. 72\"\n when 803..809\n @@primary_mutations << \"Scaled Skin\"\n @@dv -= 8\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Scaled skin: immune to damage from sunburn, sand storms, insect bites, and topical irritants.\"\n when 810..814\n @@primary_mutations << \"Serpentine Body: +4 mv on land or swimming\"\n @@dv -= 5\n serpent_body_length = d(3) + 1\n @@character_weight += (40 * serpent_body_length)\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@movement_rate_base += 4\n @@movement_rate_swimming += 4\n @@character_notes << \"Unable to wear relic shell class armor\"\n @@attacks << {:attack_mode => \"Serpentine Body Strike\", :SV => 0, :rate => 1, :range => serpent_body_length, :damage => \"d20 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Constrict for d10 lethal dmg/rd after successful strike.\"}\n\n when 815..839\n def shell_mutation(roll) # Hub Rules p. 73\n case roll\n when 1..4\n shell_rating = \"Light\"\n shell_defense_value = 10\n shell_movement_penalty = 0.5\n shell_appearance_penalty = (d(4) + 1)\n shell_weight = 20\n when 5..7\n shell_rating = \"Medium\"\n shell_defense_value = 20\n shell_movement_penalty = 1\n shell_appearance_penalty = (d(6) + 2)\n shell_weight = 30\n when 8..9\n shell_rating = \"Heavy\"\n shell_defense_value = 30\n shell_movement_penalty = 1.5\n shell_appearance_penalty = (d(6) + 4)\n shell_weight = 40\n when 10\n shell_rating = \"Extra Heavy\"\n shell_defense_value = 40\n shell_movement_penalty = 2\n shell_appearance_penalty = (d(6) + 6)\n shell_weight = 50\n end\n @@primary_mutations << \"#{shell_rating} Shell: #{shell_defense_value} DV, -#{shell_movement_penalty} MV\"\n @@appearance = [@@appearance - shell_appearance_penalty, 1].max\n @@dv -= shell_defense_value\n @@movement_rate_base -= shell_movement_penalty\n @@character_weight += shell_weight\n @@character_notes << \"Due to Shell mutation, punches, kicks, head-butts etc. deal 2d6 dmg instead of typical d6.\"\n @@character_notes << \"Shell mutation: no relic armor OTHER than ballistic, riot, and bomb squad armor can be worn. Combat armor can be modified, d6+1 days.\"\n end\n\n shell_mutation(d(10))\n\n when 840..849\n def size_decrease_mutation(height)\n case height\n when 61..95\n @@agility += (d(8) + d(8))\n @@strength = [@@strength - d(10), 1].max\n @@endurance = [@@endurance - (d(6) + d(6)), 1].max\n 4.times @@skills << \"Stealth\"\n when 66..90\n @@agility += (d(6) + d(6))\n @@strength = [@@strength - d(8), 1].max\n @@endurance = [@@endurance - (d(4) + d(4)), 1].max\n 3.times @@skills << \"Stealth\"\n when 91..110\n @@agility += (d(4) + d(4))\n @@strength = [@@strength - d(6), 1].max\n @@endurance = [@@endurance - d(6), 1].max\n 2.times @@skills << \"Stealth\"\n when 111..130\n @@agility += d(6)\n @@strength = [@@strength - d(4), 1].max\n @@endurance = [@@endurance - d(4), 1].max\n 2.times @@skills << \"Stealth\"\n when 131..140\n @@agility += d(6)\n @@strength = [@@strength - d(3), 1].max\n @@endurance = [@@endurance - 2, 1].max\n @@skills << \"Stealth\"\n when 141..159\n @@agility += d(4)\n @@skills << \"Stealth\"\n when 160..199\n @@agility += d(3)\n @@skills << \"Stealth\"\n end\n end\n\n @@character_height -= d(100)\n size_decrease_mutation(@@character_height)\n @@primary_mutations << \"Size Decrease\"\n when 850..860\n @@primary_mutations << \"Size Increase\"\n @@character_height += (d(100) + d(100) + d(100) + d(100))\n\n def size_increase_mutation(height) # Hub Rules p. 73\n case height\n when 164..184\n @@strength += d(10)\n @@endurance && @@character_weight += (d(10) + 5)\n when 185..199\n @@movement_rate_base += 0.25\n @@strength += (d(10) + 5)\n @@endurance && @@character_weight += (d(10) + 10)\n when 200..250\n @@movement_rate_base += 0.5\n @@strength += (d(10) + 10)\n @@endurance && @@character_weight += (d(20) + 15)\n when 251..299\n @@movement_rate_base += 0.75\n @@strength += (d(20) + 15)\n @@endurance && @@character_weight += (d(20) + 20)\n when 300..350\n @@movement_rate_base += 1\n @@strength += (d(20) + 20)\n @@endurance && @@character_weight += (d(20) + 30)\n when 351..399\n @@movement_rate_base += 1.25\n @@strength += (d(20) + 30)\n @@endurance && @@character_weight += (d(20) + 40)\n when 400..425\n @@movement_rate_base += 1.5\n @@strength += (d(20) + 40)\n @@endurance && @@character_weight += (d(20) + 50)\n when 426..450\n @@movement_rate_base += 1.75\n @@strength += (d(20) + 50)\n @@endurance && @@character_weight += (d(20) + 60)\n when 451..475\n @@movement_rate_base += 2\n @@strength += (d(20) + 60)\n @@endurance && @@character_weight += (d(20) + 75)\n when 476..499\n @@movement_rate_base += 3\n @@strength += (d(20) + 75)\n @@endurance && @@character_weight += (d(20) + 88)\n when 500..525\n @@movement_rate_base += 4\n @@strength += (d(20) + 88)\n @@endurance && @@character_weight += (d(20) + 100)\n when 526..560\n @@movement_rate_base += 5\n @@strength += (d(20) + 100)\n @@endurance && @@character_weight += (d(20) + 130)\n when 561..580\n @@movement_rate_base += 6\n @@strength += (d(20) + 130)\n @@endurance && @@character_weight += (d(20) + 160)\n end\n end\n\n size_increase_mutation(@@character_height)\n\n when 861..869\n def sonic_wave_radius_mutation(willpower) # Hub Rules p. 73\n case willpower\n when 1..9\n attack_radius = 1\n damage = \"d4\"\n deafness_duration = \"1 minute\"\n when 10..23\n attack_radius = 2\n damage = \"d6\"\n deafness_duration = \"5 minutes\"\n when 24..34\n attack_radius = 4\n damage = \"d8\"\n deafness_duration = \"10 minutes\"\n when 35..60\n attack_radius = 5\n damage = \"d10\"\n deafness_duration = \"30 minutes\"\n when 61..70\n attack_radius = 7\n damage = \"d12\"\n deafness_duration = \"1 hour\"\n when 71..80\n attack_radius = 9\n damage = \"d20\"\n deafness_duration = \"2d4 hours\"\n when 81..90\n attack_radius = 15\n damage = \"d20 + 5\"\n deafness_duration = \"3d6 hours\"\n when 91..100\n attack_radius = 20\n damage = \"d20 + 10\"\n deafness_duration = \"d6 days\"\n when 101..110\n attack_radius = 25\n damage = \"d20 + 15\"\n deafness_duration = \"2d4 days\"\n when 111..120\n attack_radius = 30\n damage = \"d20 + 20\"\n deafness_duration = \"3d6 days\"\n when 121..130\n attack_radius = 40\n damage = \"d20 + 30\"\n deafness_duration = \"3d6 + 10 days\"\n when 131..140\n attack_radius = 50\n damage = \"d20 + 40\"\n deafness_duration = \"3d6 + 20 days\"\n when 141..150\n attack_radius = 60\n damage = \"d20 + 50\"\n deafness_duration = \"3d6 + 30 days\"\n end\n\n @@primary_mutations << \"Sonic Wave Radius: 2/day/rank, #{attack_radius} radius, #{damage} damage, #{deafness_duration} deafness.\"\n @@attacks << {:attack_mode => \"Sonic Wave Radius\", :SV => 100, :rate => 1, :range => attack_radius, :damage => damage, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"73\", :notes => \"#{deafness_duration} deafness\"}\n end\n\n sonic_wave_radius_mutation(@@willpower)\n\n\n when 870..876\n @@primary_mutations << \"Spines: #{d(10) + 10} cm length, + d6 dmg to punch/kick\"\n @@dv -= (d(20) + 10)\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"Unable to wear relic armor unless spines are sawed off monthly.\"\n when 877..880\n @@primary_mutations << \"Sprint: 2/day/rank, duration 2d10 + rank rounds. -20DV (-20SV with misslie weapons) while sprinting OR double melee attack rate.\"\n when 881..886\n def stalked_eyes_mutation(roll)\n case roll\n when 1..67\n eye_stalks = (d(4) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long instead of typical eyes.\"\n when 68..100\n eye_stalks = (d(3) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long in addition to typical eyes.\"\n end\n\n @@dv -= (eye_stalks * 3)\n @@initiative += 2\n @@appearance = [@@appearance - (eye_stalks * d(6)), 1].max\n end\n\n stalked_eyes_mutation(d(100))\n\n when 887..892\n def stench_spray_location(roll) # Hub Rules p. 74\n case roll\n when 1..2\n location = \"Groin\"\n when 3..4\n location = \"Stomach\"\n when 5..6\n location = \"Chest\"\n when 7\n location = \"Left armpit\"\n when 8\n location = \"Right armpit\"\n when 9\n location = \"Back\"\n when 10\n location = \"Butt\"\n end\n\n stench_spray_app = (6 + d(6))\n @@primary_mutations << \"Stench Spray: #{20 + d(20) + d(20)} cm organ located on character's #{location}\"\n @@attacks << {:attack_mode => \"Stench Spray\", :SV => 10, :rate => 1, :range => (@@strength / 2), :damage => \"Special\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Endurance-based type B hazard check or d6 + 1 rds vomiting, +30SV to strike, -30SV to attack others.\"}\n @@character_notes << \"Character's appearance -#{stench_spray_app} penalty after stench organ seen.\"\n\n end\n\n stench_spray_location(d(10))\n\n when 893..901\n @@primary_mutations << \"Strength Burst: 2/rank/day, 4 rds/rank duration, character's strength 4x regular amount. Contributes to strength-based hazard checks, melee damage, etc.\"\n when 902..909\n def stun_ray_launcher(roll)\n case roll\n when 1..17\n stun_location = \"eyes\"\n when 18..59\n stun_location = \"left hand\"\n when 60..101\n stun_location = \"right hand\"\n end\n\n @@primary_mutations << \"Stun Ray fired from #{stun_location}.\"\n @@attacks << {:attack_mode => \"Stun Ray\", :SV => 10, :rate => 1, :range => (@@willpower * 2), :damage => \"2d20 stun, x2 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Stun damage fades after 1 hour.\"}\n end\n\n stun_ray_launcher(d(101))\n\n when 910..924\n def tail_mutation(roll) # Hub Rules p. 74\n case roll\n when 1..2\n tail_type = \"Club\"\n tail_length = 1.5\n tail_agility_bonus = d(4)\n tail_move = -1\n tail_sv = 6\n tail_attack_dmg = \"d12 + 2 lethal or stun\"\n when 3\n tail_type = \"Crocodile\"\n tail_length = 1.7\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 5\n tail_attack_dmg = \"d12 stun\"\n when 4\n tail_type = \"Dolphin\"\n tail_length = 1.5\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 6\n tail_sv = 4\n tail_attack_dmg = \"d12 stun\"\n when 5\n tail_type = \"Eagle\"\n tail_length = 1\n tail_agility_bonus = d(6)\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n when 6\n tail_type = \"Fish\"\n tail_length = 1.3\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 5\n tail_sv = 4\n tail_attack_dmg = \"d10 stun\"\n when 7\n tail_type = \"Fox\"\n tail_length = 1.25\n tail_agility_bonus = (d(6) + d(6))\n tail_move = 1.5\n tail_sv = 0\n tail_attack_dmg = nil\n when 8\n tail_type = \"Cat\"\n tail_length = 1.5\n tail_agility_bonus = (d(8) + d(8))\n tail_move = 2\n tail_sv = 0\n tail_attack_dmg = nil\n when 9\n tail_type = \"Whip\"\n tail_length = (3 + d(4))\n tail_agility_bonus = d(6)\n tail_move = -0.25\n tail_sv = 4\n tail_attack_dmg = \"d8\"\n @@character_notes << \"Whip tail can be used as #{tail_length} rope.\"\n when 10..13\n tail_type = \"Prehensile (monkey)\"\n tail_length = 3\n tail_agility_bonus = (d(4) + d(4))\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Prehensile tail can wield dagger or knife for additional melee attack.\"\n when 14\n tail_type = \"Newt\"\n tail_length = 1.5\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 3\n tail_attack_dmg = \"d10 stun\"\n when 15\n tail_type = \"Porcupine\"\n tail_length = 0.75\n tail_agility_bonus = 0\n tail_move = -1\n tail_sv = 5\n tail_attack_dmg = \"d12 + 1\"\n when 16..17\n tail_type = \"Rat\"\n tail_length = 1.8\n tail_agility_bonus = d(6)\n tail_move = 0.5\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Rat tail can wield dagger or knife for additional melee attack.\"\n when 18\n tail_type = \"Scorpion\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 8\n tail_attack_dmg = \"d12 + Type A poison\"\n when 19\n tail_type = \"Spiked\"\n tail_length = 1.75\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d12 + 3\"\n when 20\n tail_type = \"Bladed\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d20\"\n end\n\n @@primary_mutations << \"Tailed: #{tail_type} tail of #{tail_length} m length.\"\n @@appearance += tail_agility_bonus\n @@movement_rate_base += tail_move\n @@movement_rate_swimming += tail_move_water\n if tail_attack_dmg != nil\n @@attacks << {:attack_mode => \"#{tail_type} tail strike\", :SV => tail_sv, :rate => 1, :range => tail_length, :damage => \"#{tail_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"\"}\n end\n end\n\n tail_mutation(d(20))\n\n when 925..936\n @@primary_mutations << \"Telekinesis\"\n when 937..961\n @@primary_mutations << \"Telepathy\"\n when 962..967\n def tentacle_mutation(roll)\n case roll\n when 1..28\n number_of_tentacles = (d(4) + d(4) + 2)\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} instead of arms.\"\n when 29..100\n number_of_tentacles = (d(4) + d(4))\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} in addition to arms.\"\n end\n\n @@appearance = [@@appearance - (number_of_tentacles * 2), 1].max\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Tentacles add #{number_of_tentacles * 0.5} m to character's climbing & swimming move rates.\"\n @@character_notes << \"Tentacles can wield simple melee weapons but lack the dexterity needed to operate a keyboard, stringed, or triggered weapon.\"\n @@attacks << {:attack_mode => \"Tentacle strike\", :SV => 5, :rate => number_of_tentacles, :range => 0, :damage => \"d8 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"75\", :notes => \"Tentacles gain unarmed combat modifiers, too.\"}\n end\n\n tentacle_mutation(d(100))\n\n when 968..975\n @@primary_mutations << \"Throwing Quills: fire 1/rd, up to 20/day\"\n @@dv -= 18\n @@character_notes << \"Due to quills, mutant cannot wear relic armor (except specially-designed junk or scrap relic armor)\"\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@attacks << {:attack_mode => \"Throwing Quill\", :SV => 6, :rate => 1, :range => (@@strength / 2), :damage => \"d10\", :ammo => \"20/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"incl. strength and wpn expert skill modifiers\"}\n\n when 976..982\n def thrust_spike_mutation(roll)\n case roll\n when 1\n poison = \"type A death poison\"\n when 2..10\n poison = \"None\"\n end\n thrust_spike_length = (d(4) + d(4))\n @@primary_mutations << \"Thrust Spike #{thrust_spike_length} long.\"\n @@character_notes << \"After seeing thrust spike mutant's appearance score reduced for witness by d1- + 10.\" #obvious typo here\n if poison == \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack.\"}\n elsif poison != \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack. Also: #{poison}\"}\n end\n end\n\n thrust_spike_mutation(d(10))\n\n\n when 983..986\n @@primary_mutations << \"Tusks\"\n @@attacks << {:attack_mode => \"Tusk bite\", :SV => 6, :rate => 1, :range => 0, :damage => \"2d8 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"Additional melee attack/rd.\"}\n @@appearance = [@@appearance - (d(8) + 2), 1].max\n when 987..992\n @@primary_mutations << \"Webbed Hands: character nearly impossible to drown & can hold breath 2x normal. Double swim speed.\"\n @@movement_rate_swimming += @@movement_rate_swimming\n\n when 993..1000\n def wings_mutation(roll1,roll2) # Hub Rules p. 76\n case roll1\n when 1\n wing_type = \"Bird\"\n air_speed += 6\n @@character_notes << \"Bird wings are fragile - this character suffers double damage from fire and burst radius explosives like grenades and bombs.\"\n when 2\n wing_type = \"Insect\"\n air_speed += 3\n @@character_notes << \"Due to insect wings, character has -2 MV in enclosed spaces.\"\n when 3..6\n wing_type = \"Bat\"\n end\n\n case roll2\n when 1\n wing_size = \"Tiny\"\n flight_mode = \"Glide only\"\n air_speed += (d(6) + 10)\n flying_dv = -5\n wing_attack_dmg = nil\n wing_weight = 6\n when 2\n wing_size = \"Small\"\n flight_mode = \"Flies poorly\"\n air_speed += (d(6) + 12)\n flying_dv = -10\n wing_attack_dmg = \"d4 stun\"\n wing_weight = 12\n when 3..4\n wing_size = \"Medium\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 15)\n flying_dv = -14\n wing_attack_dmg = \"d6 stun\"\n wing_weight = 20\n when 5\n wing_size = \"Large\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 20)\n flying_dv = -20\n wing_attack_dmg = \"d8 stun\"\n wing_weight = 30\n when 6\n wing_size = \"Vast\"\n flight_mode = \"Flies excellently\"\n air_speed += (d(10) + 25)\n flying_dv = -25\n wing_attack_dmg = \"d10 stun\"\n wing_weight = 40\n end\n\n @@primary_mutations << \"Wings: #{wing_size} #{wing_type} wings. Mutant #{flight_mode} at #{air_speed} MV and #{flying_dv} DV when airborne.\"\n @@movement_rate_flying += air_speed\n\n if wing_attack_dmg != nil\n @@attacks << {:attack_mode => \"Wing bash\", :SV => 0, :rate => 2, :range => 0, :damage => \"#{wing_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"\"}\n end\n\n @@character_notes << \"Character able to fly at full air speed with full gear, arms, and armor. See Hub Rules p. 76 for more.\"\n @@character_notes << \"Due to wings, standard and relic armor must be modified and fitted to this character.\"\n\n\n end\n\n wings_mutation(d(6),d(6))\n\n end\nend",
"def state\n iden = nil\n op = nil\n if @tokens[@i].type == :iden\n iden = Caly::Iden.new(@tokens[@i])\n @i += 1\n op = @tokens[@i]\n @i += 1\n end\n val2 = expr\n @i += 1 # eol\n\n if iden.nil?\n val2\n else\n Caly::Binary.new(iden, op, val2)\n end\n end",
"def ident_viol_candidates?\n @ident_viol_candidates\n end",
"def boolval \n\n\t$cst.add_branch(\"boolval\")\n\n\tmatch_token(\"T_BOOLEAN\", $tokens[$index])\n\t\n\t$cst.ascend\n\nend",
"def label() @positive end",
"def c2= c; @c2 = (c == 1) ? 1 : 0; end",
"def enable_exam=(state)\n @enable_exam = ActiveRecord::Type::Boolean.new.cast(state)\n end",
"def noun_articles_correct? set\n ((set & NOUNS).count >= 1) || ((set & ARTICLES).count >= 2)\n end",
"def eligible?(n)\n true\n end",
"def assignments?\n assignments.length > 0\n end"
] | [
"0.6625051",
"0.6095803",
"0.5790214",
"0.56934625",
"0.56818473",
"0.55996346",
"0.55899537",
"0.5428367",
"0.5428367",
"0.5428367",
"0.5427513",
"0.53843915",
"0.5354882",
"0.5267769",
"0.5261744",
"0.52563506",
"0.52499795",
"0.5246493",
"0.5193265",
"0.5193265",
"0.5179648",
"0.51507825",
"0.514845",
"0.51440495",
"0.51241696",
"0.51204103",
"0.5117597",
"0.51154333",
"0.51152456",
"0.5111607",
"0.51016444",
"0.50675714",
"0.5066101",
"0.5063181",
"0.50508386",
"0.5034409",
"0.5034409",
"0.5034409",
"0.5034409",
"0.50324214",
"0.5012235",
"0.50044256",
"0.4994953",
"0.49561855",
"0.49526694",
"0.4946996",
"0.49459347",
"0.4932235",
"0.49315313",
"0.4924179",
"0.492198",
"0.49153775",
"0.49082142",
"0.4905909",
"0.4894287",
"0.4892566",
"0.48894864",
"0.48894864",
"0.48894864",
"0.48894864",
"0.4881497",
"0.48761418",
"0.4874944",
"0.48660725",
"0.48640528",
"0.48629558",
"0.48612332",
"0.48579782",
"0.48514017",
"0.4848469",
"0.48474196",
"0.48470533",
"0.4846709",
"0.48442695",
"0.48442695",
"0.48365167",
"0.48350978",
"0.48332664",
"0.48254243",
"0.4814571",
"0.48141682",
"0.4813282",
"0.4810417",
"0.48083562",
"0.47986704",
"0.4796763",
"0.47916013",
"0.4790481",
"0.47878143",
"0.47854617",
"0.47823086",
"0.47756255",
"0.476882",
"0.4767403",
"0.47617987",
"0.4760551",
"0.4760328",
"0.47572047",
"0.4756024",
"0.47534904"
] | 0.631583 | 1 |
Gets the operating system | def os
app = app_with_comments
return app.comment[0] if app && app.comment[0]
app = detect_product(DARWIN)
[IOS, OperatingSystems::Darwin::IOS[app.version.to_s]].compact.join(' ') if app
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def os\n return `uname -s`.chomp\n end",
"def get_os_name\n\t\t\t\treturn SystemDetector.get_os_name\n\t\t\tend",
"def get_os\n line = Cocaine::CommandLine.new('uname')\n output = line.run\n\n output.chomp.downcase.intern\n end",
"def os\n os_parser.os\n end",
"def osver\n return `uname -r`.chomp\n end",
"def sys\n return `uname -n`.chomp\n end",
"def os\n if !@os\n @os = \"#{os_name}-#{os_version}\"\n end\n @os.dup\n end",
"def os_platform\n return @parsed_ua.os ? @parsed_ua.os : 'Unknown'\n end",
"def platform\n osver[0]\n end",
"def os\n app = app_with_comments\n return unless app\n\n OperatingSystems.normalize_os(app.comment[2]) if app.comment[2]\n end",
"def arch\n return `uname -m`.chomp\n end",
"def os\n return @os if @os\n raw_os = RbConfig::CONFIG['target_os']\n match = raw_os.match(/([a-z]+)/)\n if match\n @os = match[1]\n else\n @os = raw_os\n end\n end",
"def os\n Facter.value(:operatingsystem)\n end",
"def os(platform: self.platform)\n platform = self.platform unless fetch_all('computer.platform').include?(platform)\n fetch(\"computer.os.#{platform.downcase}\")\n end",
"def platform\n System::get_property('platform')\n end",
"def host_os\n @os ||= (\n case RbConfig::CONFIG['host_os']\n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n :windows\n when /darwin|mac os/\n :macosx\n when /linux/\n :linux\n when /solaris|bsd/\n :unix\n else\n raise \"Unknown os: #{RbConfig::CONFIG['host_os']}\"\n end\n )\n end",
"def os\n Agent.os_for_user_agent string\n end",
"def os_name\n if (os_name = @host.at('tag[name=operating-system]'))\n os_name.inner_text\n end\n end",
"def host_os\n name = `uname`.split(' ').first.downcase.to_sym\n case name\n when :linux\n :linux\n when :darwin\n :macosx\n else\n :unknown\n end\n end",
"def operating_system_version\n return @operating_system_version\n end",
"def operating_system_version\n return @operating_system_version\n end",
"def detect_os\r\n user_agent = request.env['HTTP_USER_AGENT']\r\n if user_agent =~ /(Windows|Mac)/\r\n return $1\r\n end\r\n return 'Unknow OS'\r\n end",
"def user_os_simple\r\n ua = request.env['HTTP_USER_AGENT'].downcase\r\n return \"Windows\" if ua.index('win')\r\n return \"Linux\" if ua.index('Linux')\r\n return \"Macintosh\" if ua.index('Macintosh')\r\n return \"unknown\"\r\n end",
"def get_os\n system=`/usr/bin/sw_vers -productVersion`.chomp.split(\".\").slice(1).to_i\n if system==4 then\n return \"tiger\"\n else\n return \"leo\"\n end\nend",
"def ruby_platform_osname\n return unless Object.const_defined? :RUBY_PLATFORM\n\n case RUBY_PLATFORM\n when /darwin/ # macOS\n :macos\n when /linux/\n :linux\n when /mingw/\n :windows\n when /openbsd/\n :openbsd\n end\n end",
"def platform\n type = os_type(:nice)\n type = case type\n when /Linux/i then linux_type\n else type\n end\n \n # Grab the Solaris version; turns '5.9' into '9', for example. (Solaris has a really\n # bizarre numbering scheme.)\n #\n # FIXME: This should include patchlevel.\n if type =~ /Solaris/i\n if @solaris_version.nil?\n @solaris_version = @platform.exec(\"uname\", \"-r\").strip\n @solaris_version = $2 if @solaris_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+)\\s*$/i\n end\n \n type += @solaris_version\n end\n \n # Grab the OS X version by looking at the Darwin kernel version.\n #\n # FIXME: This should include minor version, too (e.g., 10.4.7).\n if type =~ /OSX/i\n if @osx_version.nil?\n @osx_version = @platform.exec(\"uname\", \"-r\").strip\n if @osx_version =~ /^\\s*(\\d+)\\s*\\.\\s*(\\d+).*$/i\n minor_version = [ $1.to_i - 4, 0 ].max # i.e., Darwin 8.x => OS X 10.4, 7.x => OS X 10.3, etc.\n @osx_version = \"10.%d\" % minor_version\n else\n @osx_version = '-unknown-%s' % @osx_version\n end\n end\n \n type += @osx_version\n end\n \n # Grab the Windows version by System.getProperty\n if type =~ /Windows/i\n os_name = JavaSystem.getProperty('os.name');\n sun_os_patch_level = JavaSystem.getProperty('sun.os.patch.level');\n if @windows_version.nil?\n @windows_version = case os_name \n when /Windows 2003/i: \"win2k3\"\n when /Windows XP/i: \"winxp\"\n else os_name.gsub(/ /, '_')\n end\n unless sun_os_patch_level == \"unknown\"\n patch = ''\n sun_os_patch_level.split(/ /).each do |t|\n patch = \"#{patch}#{t[0..0]}\"\n end\n @windows_version += '-' + patch\n end \n end\n \n type = @windows_version\n end\n \n \"%s-%s\" % [ type.downcase, processor_type.downcase ]\n end",
"def get_os\n if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/\n return :Windows\n elsif RbConfig::CONFIG['host_os'] =~ /darwin/\n return :Mac\n elsif RbConfig::CONFIG['host_os'] =~ /linux/\n return :Linux\n elsif RbConfig::CONFIG['host_os'] =~ /bsd/\n return :BSD\n else\n return :unknown_os\n end\nend",
"def platform\n kernel.platform\n end",
"def os\n if app = detect_product(IOS)\n [IOS, app.version].compact.join(' ') if app.version\n elsif app = detect_product(DARWIN)\n [IOS, OperatingSystems::Darwin::IOS[app.version.to_s]].compact.join(' ') if app.version\n elsif app = app_with_comments\n comments = app.comment.join\n if WINDOWS_NT_REGEX.match?(app.comment[0])\n OperatingSystems.normalize_os(app.comment[0])\n elsif ANDROID_REGEX.match?(comments)\n if comments.start_with?(LINUX)\n OperatingSystems.normalize_os(comments)\n elsif comments.start_with?(ANDROID) && matches = ANDROID_SDK_REGEX.match(comments)\n [ANDROID, OperatingSystems::Android::SDK[matches[:sdk]]].compact.join(' ') if matches[:sdk]\n end\n elsif app.comment[1]\n OperatingSystems.normalize_os(app.comment[1])\n end\n end\n end",
"def detect_platform\r\n\t\tprint_status(\"Attempting to automatically detect the platform\")\r\n\t\tres = send_serialized_request(\"osname.bin\")\r\n\r\n\t\tif (res.body =~ /(Linux|FreeBSD|Windows)/i)\r\n\t\t\tos = $1\r\n\t\t\tif (os =~ /Linux/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /FreeBSD/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /Windows/i)\r\n\t\t\t\treturn 'win'\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def sys_uname_osname\n uname = `uname`\n if uname.include? 'Darwin' # macOS\n :macos\n elsif uname.include? 'Linux'\n :linux\n elsif uname.include? 'MINGW'\n :windows\n elsif uname.include? 'OpenBSD'\n :openbsd\n end\n end",
"def os\n @os ||= (\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n :windows\n when /darwin|mac os/\n :macosx\n when /linux/\n :linux\n when /solaris|bsd/\n :unix\n else\n raise Error::WebDriverError, \"unknown os: #{host_os.inspect}\"\n end\n )\nend",
"def os_family\n os_parser.family.os\n end",
"def os_family\n case os_type(:nice)\n when /Linux|Solaris|OSX/i then 'Generic'\n when /Windows/i then 'Windows'\n else 'Unknown'\n end\n end",
"def os \n @os ||= (\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n when /mswin|msys|mingw|bccwin|wince/\n :windows\n when /darwin|mac os|linux|solaris|bsd/\n :nix\n else\n raise Error::WebDriverError, \"unknown os: #{host_os.inspect}\"\n end\n)\nend",
"def determine_os\n @os = 'linux'\n end",
"def my_os\n Application.my_os\n end",
"def determine_os\n @os = \"linux\"\n end",
"def define_os\n @os ||= (\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n :windows\n when /darwin|mac os/\n :macosx\n when /linux/\n :linux\n when /solaris|bsd/\n :unix\n else\n raise GetMeSubsError.new(\"Unknown os: #{host_os.inspect}\")\n end\n )\n end",
"def host_os; end",
"def host_os; end",
"def os\n app = app_with_comments\n if app\n if IDEVICES.include?(app.comment[0]) && app.comment[1]\n return OperatingSystems.normalize_os(app.comment[1])\n elsif matches = OSX_VERSION_REGEX.match(app.comment[0])\n return [MAC_OS, matches[:version]].compact.join(' ') if matches[:version]\n end\n end\n\n app = detect_product(DARWIN)\n if app\n if X86_64_REGEX.match?(to_s)\n [MAC_OS, OperatingSystems::Darwin::MAC_OS[app.version.to_s]].compact.join(' ')\n else\n [IOS, OperatingSystems::Darwin::IOS[app.version.to_s]].compact.join(' ')\n end\n end\n end",
"def os\n if application && c = application.comment.detect { |c| OperatingSystems::ANDROID_VERSION_REGEX.match?(c) }\n OperatingSystems.normalize_os(c)\n end\n end",
"def platform_version\n osver[1]\n end",
"def platform\n @_platform ||= begin\n os = []\n os << :windows if OS.windows?\n os << :linux if OS.linux?\n os << :osx if OS.osx?\n os << :posix if OS.posix?\n unless OS.windows? || OS.osx?\n os << :ubuntu if command_exists?(\"apt-get\")\n os << :arch if command_exists?(\"pacman\")\n os << :red_hat if command_exists?(\"yum\")\n end\n\n [\n *os,\n *os.map { |x| (x.to_s + OS.bits.to_s).to_sym }\n ]\n end\n end",
"def os\n @os ||= (\n host_os = RbConfig::CONFIG['host_os']\n case host_os\n when /darwin|mac os/\n :macosx\n when /linux/\n :linux\n when /solaris|bsd/\n :unix\n else\n raise Error::WebDriverError, \"Non supported os: #{host_os.inspect}\"\n end\n )\nend",
"def arch\n if windows? && windows_arch_i386?\n \"i386\"\n elsif solaris?\n if intel?\n \"i386\"\n elsif sparc?\n \"sparc\"\n end\n else\n Ohai[\"kernel\"][\"machine\"]\n end\n end",
"def minimum_supported_operating_system\n return @minimum_supported_operating_system\n end",
"def platform\n \"win\"\n end",
"def os\n @host\n end",
"def myOs\n if OS.windows?\n \"Windows\"\n elsif OS.linux?\n \"Linux\"\n elsif OS.mac?\n \"Osx\"\n else\n \"Não consegui indentificar!\"\n end\nend",
"def os_type\n\n if @ostype\n return @ostype\n end\n\n res = :invalid\n\n Rouster.os_files.each_pair do |os, f|\n [ f ].flatten.each do |candidate|\n if self.is_file?(candidate)\n next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS detection\n @logger.debug(sprintf('determined OS to be[%s] via[%s]', os, candidate))\n res = os\n end\n end\n break unless res.eql?(:invalid)\n end\n\n @logger.error(sprintf('unable to determine OS, looking for[%s]', Rouster.os_files)) if res.eql?(:invalid)\n\n @ostype = res\n res\n end",
"def kernel_hardware\n uname('-m')\n end",
"def os\n app = app_with_comments\n app.comment[1] if app.comment[1]\n end",
"def my_os\n if ENV['LAUNCHY_HOST_OS'] then\n Launchy.log \"#{self.name} : Using LAUNCHY_HOST_OS override of '#{ENV['LAUNCHY_HOST_OS']}'\"\n return ENV['LAUNCHY_HOST_OS']\n else\n ::Config::CONFIG['host_os']\n end\n end",
"def platform\n RUBY_PLATFORM\n end",
"def os\n @header.os\n end",
"def user_os_simple\n @user_os_simple ||= begin\n ua = ''\n ua = request.env['HTTP_USER_AGENT'].downcase if request.env['HTTP_USER_AGENT']\n if ua.index('win')\n \"Windows\"\n elsif ua.index('linux')\n \"Linux\"\n elsif ua.index('macintosh')\n \"Macintosh\"\n elsif ua.index('ipod') # iPod Touch\n \"iPod\"\n elsif ua.index('iphone')\n \"iPhone\"\n elsif ua.index('ipad')\n \"iPad\"\n else\n \"unknown\"\n end\n end\n end",
"def os_version\n if !@os_version\n if Facter['operatingsystemrelease'] &&\n Facter['operatingsystemrelease'].value &&\n !Facter['operatingsystemrelease'].value.empty?\n @os_version = Facter['operatingsystemrelease'].value\n else\n raise \"Unable to determine proper OS value on this platform\"\n end\n end\n @os_version.dup\n end",
"def os_name # rubocop:disable Lint/DuplicateMethods\n @os_name ||= @name.match(PLATFORM_REGEX)[1]\n end",
"def platform\n fetch('device.platform')\n end",
"def os\n app = app_with_comments\n return if app.nil?\n\n if (os_string = app.comment.detect { |c| ANDROID_REGEX.match?(c) })\n OperatingSystems.normalize_os(os_string)\n end\n end",
"def os\n @values.fetch('os') { \n @values['os'] = nil\n }\n end",
"def host_os_family; end",
"def uname\n `uname -a`\n end",
"def get_os_value\n Facter.value( @fact ) unless @fact.nil?\n end",
"def platform\n window.execute_script('navigator.platform')\n end",
"def determine_os\n scp(:source => Provision::Bootstrapper.determine_os_script, :destination => \"/tmp\")\n o = run(\"chmod +x /tmp/determine_os.sh; /bin/sh /tmp/determine_os.sh\").chomp\n o.empty? ? :ubuntu : o\n end",
"def get_platform\n rpc_get_fact_direct('kernel')\n end",
"def detect_os\n os = RUBY_PLATFORM.split('-')\n @class_name = if os.size == 2\n if os[1] == 'mingw32'\n 1\n else\n 0\n end\n else\n 0\n end\n end",
"def os\n app = detect_product(DARWIN)\n return [IOS, UserAgent::OperatingSystems::Darwin::IOS[app.version.to_s]].compact.join(' ') if app\n\n app = app_with_comments\n return OperatingSystems.normalize_os(app.comment.join) if app\n end",
"def pdb_get_os(facts)\n if facts.is_a?(Hash) && !facts['operatingsystem'].nil? && !facts['operatingsystem']['value'].nil?\n os = facts['operatingsystem']['value']\n Puppet.info(\"#{log_prefix} puppet os for node is: os=#{os}\")\n if os.downcase == 'windows'\n os = 'Windows'\n elsif os.downcase == 'centos'\n os = 'CentOS'\n end\n\n Puppet.info(\"#{log_prefix} fiendly puppet os for node is: os=#{os}\")\n os\n else\n \"Unknown\"\n end\n end",
"def os\n return nil unless length >= 4\n\n # comment[0] = 'Linux'\n # comment[1] = 'U'\n # comment[2] = 'Android x.y.z' except when there are only 3 tokens, then we don't know the version\n if (self[3].product == 'Dalvik' || self[3].product == 'Mozilla') && self[3].comment.length > 3\n self[3].comment[2]\n elsif (self[3].product == 'Dalvik' || self[3].product == 'Mozilla') && self[3].comment.length == 3\n 'Android'\n else\n nil\n end\n end",
"def os\n darwin = detect_product(DARWIN)\n version = if darwin\n UserAgent::OperatingSystems::Darwin::WATCH_OS[darwin.version.to_s]\n else\n match = detect_comment_match(/watchOS\\s(?<version>[\\.\\d]+)/)\n match.named_captures['version'] if match\n end\n\n [WATCH_OS, version].compact.join(' ')\n end",
"def architecture\n `uname -m`.strip\n end",
"def architecture\n `uname -m`.strip\n end",
"def device_operating_system_summary\n return @device_operating_system_summary\n end",
"def detect_os(compare_os = nil)\n return case request.user_agent.downcase\n when /windows/i\n :windows\n when /macintosh/i\n :mac\n else\n :unknown\n end\n end",
"def processor_type\n if @processor_type.nil?\n if os_family == 'Windows' && ENV['PROCESSOR_ARCHITECTURE']\n @processor_type = ENV['PROCESSOR_ARCHITECTURE']\n else\n @processor_type = @platform.exec(\"uname\", (os_type(:nice) =~ /Windows|HP-UX/ ? '-m' : '-p')).strip\n end\n end\n \n @processor_type\n end",
"def os_value\n if @value_os.nil?\n @value_os = get_os_value\n end\n @value_os\n end",
"def platform\n return @platform\n end",
"def detect_platform()\r\n\t\tprint_status(\"Attempting to automatically detect the platform...\")\r\n\r\n\t\tpath = datastore['PATH'] + '/HtmlAdaptor?action=inspectMBean&name=jboss.system:type=ServerInfo'\r\n\t\tres = send_request_raw(\r\n\t\t\t{\r\n\t\t\t\t'uri' => path\r\n\t\t\t}, 20)\r\n\r\n\t\tif (not res) or (res.code != 200)\r\n\t\t\tprint_error(\"Failed: Error requesting #{path}\")\r\n\t\t\treturn nil\r\n\t\tend\r\n\r\n\t\tif (res.body =~ /<td.*?OSName.*?(Linux|Windows).*?<\\/td>/m)\r\n\t\t\tos = $1\r\n\t\t\tif (os =~ /Linux/i)\r\n\t\t\t\treturn 'linux'\r\n\t\t\telsif (os =~ /Windows/i)\r\n\t\t\t\treturn 'win'\r\n\t\t\tend\r\n\t\tend\r\n\t\tnil\r\n\tend",
"def osfamily\n return @osfamily if @osfamily\n @osfamily = Facter.value 'osfamily'\n end",
"def name\n RUBY_PLATFORM\n end",
"def get_uname\n `uname -a`\n end",
"def osx_name\n return exec('sysctl -n machdep.cpu.brand_string')\n end",
"def os_type\n vm.storage_profile.os_disk.os_type\n end",
"def get_platform(platform = nil)\n platform ||= RUBY_PLATFORM\n case platform\n when /darwin/ then :MACOS\n when /cygwin|mswin|mingw|bccwin|wince|emx/ then :WINDOWS\n else :LINUX\n end\n end",
"def platform; RUBY_PLATFORM; end",
"def os\n @values.fetch('ai.device.os') { \n @values['ai.device.os'] = nil\n }\n end",
"def os_type\n FFI::Libvirt.virDomainGetOSType(self)\n end",
"def get_platform(host_os)\n return :osx if host_os =~ /darwin/\n return :linux if host_os =~ /linux/\n return :windows if host_os =~ /mingw32|mswin32/\n return :unknown\n end",
"def platform\n Ohai.platform\n end",
"def get_windows_info()\n sysname = \"\"\n processor = \"\"\n os_info = \"\"\n\n require 'win32/registry'\n\n Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion') do |reg|\n type, sysname = reg.read('ProductName')\n end\n\n Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment') do |reg|\n type, processor = reg.read('PROCESSOR_ARCHITECTURE')\n end\n\n os_info = sysname + \" \" + processor\n os_info\nend",
"def browser_os\n if ENV['BROWSER_OS']\n raise \"You must also specify the variable GRID_HUB on the command line to use this option.\" if selenium_grid_hub.nil?\n raise \"Unrecognized BROWSER_OS value: #{ENV['BROWSER_OS']}.\" unless ENV['BROWSER_OS'] =~ /^windows|mac|linux$/i\n ENV['BROWSER_OS'].downcase.to_sym\n else\n nil\n end\n end",
"def architecture\n @architecture ||= `uname -m`\n end",
"def get_os_value\n `ip route show 2>/dev/null` =~ /default\\s*via\\s*(.*)\\s*dev/\n (($1 && $1.strip) || nil)\n end",
"def os_version\n @os_version ||= begin\n version = nil\n wql = service.run_wql('select version from Win32_OperatingSystem')\n if wql[:xml_fragment]\n version = wql[:xml_fragment].first[:version] if wql[:xml_fragment].first[:version]\n end\n fail ::WinRM::WinRMError, 'Unable to determine endpoint os version' if version.nil?\n Gem::Version.new(version)\n end\n end",
"def os_version # rubocop:disable Lint/DuplicateMethods\n @os_version ||= @name.match(PLATFORM_REGEX)[2]\n end",
"def ruby_platform\n RUBY_PLATFORM\n end"
] | [
"0.8720404",
"0.82192767",
"0.8136886",
"0.8127003",
"0.8118536",
"0.8097448",
"0.80247927",
"0.7985938",
"0.7979931",
"0.79103154",
"0.79080313",
"0.7896797",
"0.7837198",
"0.7825617",
"0.7769707",
"0.7754323",
"0.7751218",
"0.77491677",
"0.7665985",
"0.76521593",
"0.76521593",
"0.7612592",
"0.75968784",
"0.754492",
"0.75353974",
"0.7524415",
"0.74997944",
"0.7454599",
"0.74514323",
"0.7444192",
"0.7444155",
"0.7439708",
"0.7430763",
"0.7412188",
"0.74044794",
"0.74006295",
"0.7381368",
"0.73626983",
"0.73373187",
"0.73251253",
"0.73251253",
"0.7314403",
"0.7304418",
"0.72973275",
"0.7297208",
"0.7278146",
"0.72762364",
"0.7268557",
"0.7268331",
"0.7265141",
"0.7261046",
"0.72564924",
"0.72507405",
"0.7231964",
"0.72235787",
"0.72119033",
"0.71976185",
"0.7177039",
"0.7170971",
"0.71521366",
"0.71433175",
"0.71349424",
"0.71103555",
"0.7084173",
"0.70796543",
"0.7071664",
"0.70715123",
"0.7057896",
"0.7055814",
"0.7051341",
"0.7049823",
"0.70351875",
"0.7034211",
"0.702909",
"0.702544",
"0.702544",
"0.7002783",
"0.6989609",
"0.698535",
"0.6982894",
"0.6971792",
"0.69684154",
"0.6928762",
"0.6928453",
"0.6925733",
"0.6916572",
"0.6912469",
"0.6907747",
"0.6905029",
"0.6891622",
"0.68851817",
"0.68821704",
"0.6877067",
"0.686367",
"0.6853246",
"0.6849392",
"0.68464714",
"0.68042666",
"0.68037546",
"0.67911816"
] | 0.72384113 | 53 |
Public Create file start cookbook String cookbook name Returns nil | def create
tmpl = ERB.new(load_erb_file('metadata.erb'))
@cookbook = @opts[:cookbook]
@maintainer = @opts[:souschef][:maintainer]
@maintainer_email = @opts[:souschef][:maintainer_email]
@license = @opts[:souschef][:license]
data = tmpl.result(binding)
info 'Updating metadata.rb'
write_file(cookbook_file_path('metadata.rb'), data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file(filename)\n cookbook_file '/var/opt/dynatrace-managed/sources/' + filename do\n source '' + filename\n owner node['dynatrace-quickstart-gcp']['user']\n group node['dynatrace-quickstart-gcp']['user']\n mode '644'\n action :create\n end\nend",
"def build_cookbook(cookbook)\n berksfile = Berkshelf::Berksfile.from_file(File.join(cookbook[:path], \"Berksfile\"))\n berksfile.vendor(\"berks-cookbooks\")\n\n File.open(\"berks-cookbooks/Berksfile\", 'w') { |file|\n file.write(\"source \\\"https://supermarket.chef.io\\\"\\n\\n\")\n file.write(\"cookbook \\\"#{cookbook[:name]}\\\", path: \\\"./#{cookbook[:name]}\\\"\")\n }\n\n if cookbook[:cookbook_filename].end_with? \".zip\"\n zf = ZipFileGenerator.new(\"berks-cookbooks\", cookbook[:cookbook_filename])\n zf.write\n elsif cookbook[:cookbook_filename].end_with? \".tar.gz\"\n system(\"tar -czvf #{cookbook[:cookbook_filename]} -C berks-cookbooks . > /dev/null 2>&1\")\n end\n end",
"def create_cookbook(name, type, tmp)\n target = File.join(tmp, name)\n template_org = locate_config_value(\"github_template_org\")\n if template_org.nil? || template_org.empty?\n Chef::Log.fatal(\"Cannot find github_template_org within your configuration\")\n else\n\n github_url = @github_url.gsub('http://', 'git://') if @github_url =~ /^http:\\/\\/.*$/\n github_url = @github_url if @github_url =~ /^https:\\/\\/.*$/\n\n template_path = File.join(github_url, template_org, \"chef_template_#{type}.git\")\n shell_out!(\"git clone #{template_path} #{target}\") # , :cwd => cookbook_path)\n end\n end",
"def cookbook_file(*args, &block)\n Log.instance << \"About to cook the file: #{args[0]}\"\n @@chef_orig_cookbook_file.bind(self).call(args, &block)\n Log.instance << \"Hoora the file: #{args[0]} has been cooked\"\n end",
"def cp_this_cookbook\n info(\"Preparing current project directory as a cookbook\")\n debug(\"Using metadata.rb from #{metadata_rb}\")\n\n cb_name = MetadataChopper.extract(metadata_rb).first || raise(UserError,\n \"The metadata.rb does not define the 'name' key.\" \\\n \" Please add: `name '<cookbook_name>'` to metadata.rb and retry\")\n\n cb_path = File.join(tmpbooks_dir, cb_name)\n\n glob = Util.list_directory(config[:kitchen_root])\n\n FileUtils.mkdir_p(cb_path)\n FileUtils.cp_r(glob, cb_path)\n end",
"def make_fake_cookbook\n info(\"Berksfile, Cheffile, cookbooks/, or metadata.rb not found \" \\\n \"so Chef will run with effectively no cookbooks. Is this intended?\")\n name = File.basename(config[:kitchen_root])\n fake_cb = File.join(tmpbooks_dir, name)\n FileUtils.mkdir_p(fake_cb)\n File.open(File.join(fake_cb, \"metadata.rb\"), \"wb\") do |file|\n file.write(%{name \"#{name}\"\\n})\n end\n end",
"def cookbook_upload()\n # Git meuk should not be uploaded use chefignore file instead\n # FileUtils.remove_entry(\"#{@github_tmp}/git/#{@cookbook_name}/.git\")\n\t\t args = ['cookbook', 'upload', @cookbook_name ]\n if config[:final]\n args.push \"--freeze\"\n end\n upload = Chef::Knife::CookbookUpload.new(args)\n # upload.config[:cookbook_path] = \"#{@github_tmp}/git\"\n # plugin will throw its own errors\n upload.run\n end",
"def add(name)\n @cookbook.add_recipe(name)\n end",
"def create\n name = @view.ask_user_for_info(\"name\")\n description = @view.ask_user_for_info(\"description\")\n prep_time = @view.ask_user_for_attribute(\"prep_time\")\n difficulty = @view.ask_user_for_attribute(\"difficulty\")\n recipe = Recipe.new(name: name, description: description, prep_time: prep_time, difficulty: difficulty)\n @cookbook.add_recipe(recipe)\n end",
"def init\n create_file options[:inventory_config] do\n<<-YML\n# sources:\n# - \"https://supermarket.getchef.com\"\n# cookbooks:\n# cookbook-name:\n# versions:\n# - \"~> 4.0.2\"\n# - \"> 5.0.0\"\n# git:\n# location: url | path\n# branches:\n# - a_branch_name\n# refs:\n# - SHA\n\nYML\n end\n end",
"def initialize(file_name)\n create(file_name)\n end",
"def local_cookbook(name, path=nil)\n if path\n cookbook name, path: \"#{path}/#{name}\"\n else\n cookbook name, path: \"#{ENV['CHEF_REPO']}/cookbooks/#{name}\"\n end\nend",
"def verify_cookbook_creation\n fail 'You need to specify the cookbook name' if @opts[:cookbook].nil?\n end",
"def create_file(type, resource)\n Chef::Log.info(\"date : #{resource.date}\")\n\n date = ''\n temporary_filename = ''\n\n if platform_family?('windows')\n temporary_filename = \"C:/Windows/Temp/#{resource.reference}\"\n\n # Formatted date for the request\"\n ruby_block 'date-windows' do\n block do\n # Get date\n date = powershell_out('get-date -Format \"yyyy/%M/%d HHHH:mmmm:ssss\"').stdout.chop\n end\n action :create\n end\n\n else\n temporary_filename = \"/tmp/#{resource.reference}\"\n\n # Formatted date for the request\"\n ruby_block 'date-linux' do\n block do\n # Get date\n date = shell_out('date +\"%Y/%m/%d %T\"').stdout.chop\n end\n action :create\n end\n end\n\n Chef::Log.debug(\"temporary_filename : #{temporary_filename}\")\n\n template temporary_filename.to_s do\n source 'cyberark_request.erb'\n variables(\n version: resource.version,\n date: resource.date,\n type: type.to_s,\n reference: resource.reference,\n hostname: resource.hostname,\n ip: resource.ip,\n fqdn: resource.fqdn,\n platform: resource.platform,\n location: resource.location,\n geographic_code: resource.geographic_code,\n username: resource.username,\n password: resource.password\n )\n end\n\n ruby_block 'create-file' do\n block do\n if platform_family?('windows')\n hash = powershell_out(\"$(Get-FileHash #{temporary_filename} -Algorithm MD5).hash\").stdout.chop\n date_short = powershell_out('get-date -Format \"yyyyMMddHHmmss\"').stdout.chop\n else\n hash = shell_out(\"md5sum #{temporary_filename} | cut -f1 -d ' '\").stdout.chop\n date_short = shell_out('date +\"%Y%m%d%H%M\"').stdout.chop\n end\n\n filename = \"#{date_short}_#{type}_#{resource.reference}_#{hash}\"\n Chef::Log.debug(\"date_short : #{date_short}\")\n Chef::Log.debug(\"filename : #{filename}\")\n Chef::Log.debug(\"mv #{temporary_filename} /tmp/#{filename}.tmp\")\n node.default['cyberark']['filename'] = filename.to_s\n\n if platform_family?('windows')\n powershell_out(\"mv #{temporary_filename} C:/Windows/Temp/#{filename}.tmp\")\n else\n shell_out(\"mv #{temporary_filename} /opt/IBM/#{filename}.tmp\")\n end\n end\n action :create\n end\nend",
"def process\n ChefObject.register(filename, :recipe, statement.file)\n end",
"def manage_file(file_name, contents, path)\n if contents.class == Hash && contents.empty? == false\n file = Chef::Resource::Template.new(\"#{path}/#{file_name}\", run_context)\n file.cookbook('cerner_splunk')\n file.source('generic.conf.erb')\n file.variables(stanzas: contents)\n else\n file = Chef::Resource::File.new(\"#{path}/#{file_name}\", run_context)\n file.content(contents)\n end\n file.path(\"#{path}/#{file_name}\")\n file.owner(node[:splunk][:user])\n file.group(node[:splunk][:group])\n file.mode('0600')\n if contents.empty?\n file.run_action(:delete)\n else\n file.run_action(:create)\n end\n new_resource.updated_by_last_action(file.updated_by_last_action?)\n end",
"def create_file(type)\n cb_file, source_file = get_locations(type)\n\n File.open(cb_file, 'w') { |f| f.write(process_template(source_file)) }\n\n if @opts[:verbose]\n Souschef::Print.info \"Creating Testkitchen #{type} configuration\"\n end\n rescue TypeError\n Souschef::Print.error 'SKipping'\n end",
"def upload_cookbook(cookbook)\n execute \"Upload Cookbook => #{cookbook}\" do\n command \"knife cookbook upload #{cookbook} --cookbook-path #{Chef::Config[:cookbook_path]}\"\n environment(\n 'KNIFE_HOME' => cluster_data_dir\n )\n not_if \"knife cookbook show #{cookbook}\"\n end\n end",
"def cookbook(name, options = {})\n @name = name\n @options = manipulate(options)\n end",
"def initialize(nod, c)\n\t\t\t\t\n\t\tsplitDirectory(nod)\n\t\t\n\t\tself.content = c\n\t\tself.description = \"-Creating a file: '#{name_of_subject}'\"\n\n\tend",
"def create_from_file\n end",
"def create\n file = Tempfile.new(\"oneimage-#{resource[:name]}\")\n File.chmod(0644, file.path)\n\n template = ERB.new <<-EOF\nNAME = \"<%= resource[:name] %>\"\n<% if resource[:description] %>DESCRIPTION = \"<%= resource[:description] %>\"<% end%>\n<% if resource[:type] %>TYPE = <%= resource[:type].upcase %><% end%>\n<% if resource[:persistent] %>PERSISTENT = <%= resource[:persistent] %><% end%>\n<% if resource[:dev_prefix] %>DEV_PREFIX = \"<%= resource[:dev_prefix] %>\"<% end%>\n<% if resource[:driver] %>DRIVER = \"<%= resource[:driver] %>\"<% end %>\n<% if resource[:path] %>PATH = <%= resource[:path] %><% end%>\n<% if resource[:source] %>SOURCE = <%= resource[:source] %><% end%>\n<% if resource[:fstype] %>FSTYPE = <%= resource[:fstype] %><% end%>\n<% if resource[:size] %>SIZE = <%= resource[:size] %><% end%>\nEOF\n\n tempfile = template.result(binding)\n self.debug \"Creating image using tempfile: #{tempfile}\"\n file.write(tempfile)\n file.close\n output = \"oneimage create -d #{resource[:datastore]} #{file.path} \", self.class.login\n `#{output}`\n end",
"def initialize(type: nil, name: nil, created_at: nil, params: nil, run_context: nil, cookbook_name: nil, recipe_name: nil, enclosing_provider: nil)\nsuper if defined?(::Chef::ResourceBuilder)\n @type = type\n @name = name\n @created_at = created_at\n @params = params\n @run_context = run_context\n @cookbook_name = cookbook_name\n @recipe_name = recipe_name\n @enclosing_provider = enclosing_provider\n end",
"def cookbook_name\n @cookbook_name ||= begin\n metadata = Ridley::Chef::Cookbook::Metadata.from_file(target.join('metadata.rb').to_s)\n metadata.name.empty? ? File.basename(target) : metadata.name\n rescue CookbookNotFound, IOError\n File.basename(target)\n end\n end",
"def cookbook(arg = nil)\n set_or_return(:cookbook,\n arg,\n kind_of: [String, NilClass],\n default: nil)\n end",
"def create\n dir = Pathname.new(path)\n\n unless dir.exist?\n dir.mkdir\n syscmd(\"mount --bind \\\"#{dir}\\\" \\\"#{dir}\\\"\")\n syscmd(\"mount --make-rshared \\\"#{dir}\\\"\")\n end\n\n create_readme unless File.exist?(readme_path)\n end",
"def create\n if @resource[:grow_fs] == :true\n fstabentry\n growfs\n mountfs\n else\n createfs()\n fstabentry\n mountfs\n end\n end",
"def install(source, cookbook)\n cookbooks[cookbook.name] ||= {}\n cookbooks[cookbook.name][:version] = cookbook.version\n\n unless source.default?\n cookbooks[cookbook.name][:api_source] = source.uri\n cookbooks[cookbook.name][:location_path] = cookbook.location_path\n end\n end",
"def create_recipe(rcp_file, keyword, *args, &block)\n keyword = keyword.to_s.to_sym unless Symbol === keyword\n if recipe_types.has_key?(keyword)\n return recipe_types[keyword].new(rcp_file, *args, &block)\n end\n\n nil\n end",
"def cookbook_name(file)\n raise ArgumentError, 'File cannot be nil or empty' if file.to_s.empty?\n until (file.split(File::SEPARATOR) & standard_cookbook_subdirs).empty? do\n file = File.absolute_path(File.dirname(file.to_s))\n end\n file = File.dirname(file) unless File.extname(file).empty?\n md_path = File.join(file, 'metadata.rb')\n if File.exists?(md_path)\n name = read_ast(md_path).xpath(\"//stmts_add/\n command[ident/@value='name']/descendant::tstring_content/@value\").to_s\n return name unless name.empty?\n end\n File.basename(file)\n end",
"def create(filename, text); end",
"def create_file(file, name, requires_edit=false)\n FileUtils.cp(file + '.example', file)\n\n if requires_edit\n puts \"Update #{file} and run `bundle exec rake setup` to continue\".color(:red)\n system(ENV['EDITOR'], file) unless ENV['EDITOR'].blank?\n exit\n end\n end",
"def release_step\n super\n puts @source_git_parent_path\n pem_path = File.expand_path('~/client.pem')\n knife_path = File.expand_path('~/knife.rb')\n\n unless @config.chef_supermarket_username || @config.chef_supermarket_key\n fail CapsuleCD::Error::ReleaseCredentialsMissing, 'cannot deploy cookbook to supermarket, credentials missing'\n end\n\n # knife is really sensitive to folder names. The cookbook name MUST match the folder name otherwise knife throws up\n # when doing a knife cookbook share. So we're going to make a new tmp directory, create a subdirectory with the EXACT\n # cookbook name, and then copy the cookbook contents into it. Yeah yeah, its pretty nasty, but blame Chef.\n metadata_str = CapsuleCD::Chef::ChefHelper.read_repo_metadata(@source_git_local_path)\n chef_metadata = CapsuleCD::Chef::ChefHelper.parse_metadata(metadata_str)\n\n Dir.mktmpdir {|tmp_parent_path|\n # create cookbook folder\n tmp_local_path = File.join(tmp_parent_path, chef_metadata.name)\n FileUtils.mkdir_p(tmp_local_path)\n FileUtils.copy_entry(@source_git_local_path, tmp_local_path)\n\n # write the knife.rb config jfile.\n File.open(knife_path, 'w+') do |file|\n file.write(<<-EOT.gsub(/^\\s+/, '')\n node_name \"#{@config.chef_supermarket_username }\" # Replace with the login name you use to login to the Supermarket.\n client_key \"#{pem_path}\" # Define the path to wherever your client.pem file lives. This is the key you generated when you signed up for a Chef account.\n cookbook_path [ '#{tmp_parent_path}' ] # Directory where the cookbook you're uploading resides.\n EOT\n )\n end\n\n File.open(pem_path, 'w+') do |file|\n file.write(@config.chef_supermarket_key)\n end\n\n command = \"knife cookbook site share #{chef_metadata.name} #{@config.chef_supermarket_type} -c #{knife_path}\"\n Open3.popen3(command) do |_stdin, stdout, stderr, external|\n { stdout: stdout, stderr: stderr }. each do |name, stream_buffer|\n Thread.new do\n until (line = stream_buffer.gets).nil?\n puts \"#{name} -> #{line}\"\n end\n end\n end\n # wait for process\n external.join\n unless external.value.success?\n fail CapsuleCD::Error::ReleasePackageError, 'knife cookbook upload to supermarket failed'\n end\n end\n }\n end",
"def start_stop_script(attributes)\n [:user, :cwd, :name, :pidfile, :daemon].each do |key|\n raise \"#{key} not set\" if !attributes.has_key?(key)\n end\n\n template \"/etc/init.d/#{attributes[:name]}\" do\n source \"start_stop_script.erb\"\n cookbook \"base\"\n variables(attributes)\n mode \"755\"\n end\nend",
"def create\n recipe_name = @view.ask_name\n recipe_description = @view.ask_description\n recipe = Recipe.new(recipe_name, recipe_description)\n @cookbook.add_recipe(recipe)\n @view.listing\n end",
"def cookbook\n @cookbook ||= CachedCookbook.from_path(path, name: name)\n end",
"def create_service_files(current_resource, new_resource)\n service_name = get_service_name(new_resource)\n\n template_variables = ({\n \"dashboard_name\" => get_dashboard_name(new_resource),\n \"dashboard_path\" => new_resource.path,\n \"dashboard_port\" => new_resource.port,\n \"service_name\" => service_name,\n \"ruby_version\" => node[\"dashing\"][\"ruby_version\"]\n })\n\n # If the resource's service_type is changing, then delete the old script.\n if get_service_script_name(current_resource) != nil\n file get_service_script_name(current_resource) do\n action :delete\n only_if {current_resource.service_type != new_resource.service_type}\n end\n end\n\n # Create the new startup script.\n case new_resource.service_type\n when \"upstart\"\n template \"/etc/init/#{service_name}.conf\" do\n cookbook \"dashing\"\n source \"upstart-dashboard.conf.erb\"\n mode 0644\n owner \"root\"\n group \"root\"\n variables template_variables\n notifies :enable, \"service[#{service_name}]\"\n notifies :restart, \"service[#{service_name}]\"\n end\n when \"init.d\"\n template \"/etc/init.d/#{service_name}\" do\n cookbook \"dashing\"\n source node['dashing']['init_source']\n mode 0755\n owner \"root\"\n group \"root\"\n variables template_variables\n notifies :enable, \"service[#{service_name}]\"\n notifies :restart, \"service[#{service_name}]\"\n end\n else\n raise \"dashing: Unknown service_type '#{rnew_resource.service_type}'\"\n end\nend",
"def create(filename)\n input = self.read('templates/codeml.ctl.erb')\n\n # Using ERB templates\n output = ERB.new(input).result(binding)\n\n # Create a blank file then put the contents of the output in\n self.create_file(\"#{filename}\", output)\n end",
"def generate_temp_cookbook(cli_arguments)\n temp_cookbook = TempCookbook.new\n if recipe_strategy?(cli_arguments)\n recipe_specifier = cli_arguments.shift\n ChefCLI::Log.debug(\"Beginning to look for recipe specified as #{recipe_specifier}\")\n if File.file?(recipe_specifier)\n ChefCLI::Log.debug(\"#{recipe_specifier} is a valid path to a recipe\")\n recipe_path = recipe_specifier\n else\n rl = RecipeLookup.new(config[:cookbook_repo_paths])\n cookbook_path_or_name, optional_recipe_name = rl.split(recipe_specifier)\n cookbook = rl.load_cookbook(cookbook_path_or_name)\n recipe_path = rl.find_recipe(cookbook, optional_recipe_name)\n end\n temp_cookbook.from_existing_recipe(recipe_path)\n initial_status_msg = TS.converge.converging_recipe(recipe_specifier)\n else\n resource_type = cli_arguments.shift\n resource_name = cli_arguments.shift\n temp_cookbook.from_resource(resource_type, resource_name, format_properties(cli_arguments))\n full_rs_name = \"#{resource_type}[#{resource_name}]\"\n ChefCLI::Log.debug(\"Converging resource #{full_rs_name} on target\")\n initial_status_msg = TS.converge.converging_resource(full_rs_name)\n end\n\n [temp_cookbook, initial_status_msg]\n end",
"def createFile (pathFile,extension,nameFile, erb)\r\n FileUtils.mkdir_p(pathFile)\r\n fileName = pathFile+nameFile+extension\r\n newFile = File.open(fileName,\"w\")\r\n newFile.print erb\r\n newFile.close\r\n end",
"def create_file (file_path)\n \"touch '#{file_path}'\"\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end",
"def run\n Souschef::Print.header \"Using Souschef profile: #{opts[:profile]}\"\n\n if @opts[:scaffold]\n Souschef::Scaffold.new(@opts).start\n elsif @opts[:configure]\n verify_configure_input\n Souschef::Configure::Yaml.new(@opts)\n else\n Souschef::Print.header \"Starting cookbook creation...\\n\"\n cookbook_runlist\n end\n end",
"def create\n spec_dir = File.join(@path, 'spec')\n\n tmpl = ERB.new(load_erb_file('chefspec/spec_helper.rb'))\n data = tmpl.result(binding)\n\n create_spec_dir(spec_dir) unless File.directory?(spec_dir)\n\n info 'Creating Chefspec helper'\n write_file(cookbook_file_path('spec/spec_helper.rb'), data)\n end",
"def create_file\n\tfile = File.new\"hello_from_ruby.txt\",\"w\"\n\tputs \"-------------------------------------------\"\n\tputs \"Successfully created 'hello_from_ruby.txt'!\"\n\tputs \"-------------------------------------------\"\nend",
"def cookbook_clean_start\n end",
"def user_file_create\n course = notey_notey_params['course']\n file = notey_notey_params['file']\n username = notey_notey_params['username']\n\n uri = \"/notebooks/#{username}_#{course}_#{file}\"\n base_file = \"/notebooks/#{course}_#{file}\"\n\n if File.exist?(base_file)\n File.open(base_file, 'rb') do |input|\n File.open(uri, 'wb') do |output|\n while (buff = input.read(4096))\n output.write(buff)\n end\n end\n end\n else\n render json: { result: false }\n end\n render json: { result: true }\n end",
"def config_creates_file(_new_resource)\n return 'Makefile'\n end",
"def config_creates_file(_new_resource)\n return 'Makefile'\n end",
"def generate_temp_cookbook(cli_arguments)\n temp_cookbook = TempCookbook.new\n if recipe_strategy?(cli_arguments)\n recipe_specifier = cli_arguments.shift\n ChefRun::Log.debug(\"Beginning to look for recipe specified as #{recipe_specifier}\")\n if File.file?(recipe_specifier)\n ChefRun::Log.debug(\"#{recipe_specifier} is a valid path to a recipe\")\n recipe_path = recipe_specifier\n else\n rl = RecipeLookup.new(parsed_options[:cookbook_repo_paths])\n cookbook_path_or_name, optional_recipe_name = rl.split(recipe_specifier)\n cookbook = rl.load_cookbook(cookbook_path_or_name)\n recipe_path = rl.find_recipe(cookbook, optional_recipe_name)\n end\n temp_cookbook.from_existing_recipe(recipe_path)\n initial_status_msg = TS.converge.converging_recipe(recipe_specifier)\n else\n resource_type = cli_arguments.shift\n resource_name = cli_arguments.shift\n temp_cookbook.from_resource(resource_type, resource_name, format_properties(cli_arguments))\n full_rs_name = \"#{resource_type}[#{resource_name}]\"\n ChefRun::Log.debug(\"Converging resource #{full_rs_name} on target\")\n initial_status_msg = TS.converge.converging_resource(full_rs_name)\n end\n\n [temp_cookbook, initial_status_msg]\n end",
"def start file_path\n\t\tfileExist? file_path\n\tend",
"def _create_chef_node(&block)\n step(\" creating chef node\", :green)\n @chef_node = Chef::Node.new\n @chef_node.name(fullname)\n set_chef_node_attributes\n set_chef_node_environment\n sync_ipconfig_attribute\n sync_volume_attributes\n chef_api_server_as_client.post_rest('nodes', @chef_node)\n end",
"def render_defaults\n template '/etc/default/haproxy' do\n cookbook 'consul-haproxy'\n source 'haproxy_defaults.erb'\n mode '0644'\n action :create\n end\nend",
"def company_cookbook(name, version = '>= 0.0.0', options = {})\n cookbook(name, version, { git: \"https://github.com/EagleGenomics-cookbooks/#{name}.git\" }.merge(options))\nend",
"def touch\n FileUtils.touch FILE\n bootstrap\n end",
"def run\n Execution.block 'Creating a custom file', @target, 'root' do |b|\n b.always_run true\n b.run \"mkdir -p #{::File.dirname(@target)}\"\n ::File.open(@target, 'w+') { |file| file.write @content }\n b.run \"chown #{@owner}:#{@owner} #{::File.dirname(@target)}\"\n b.run \"chown #{@owner}:#{@owner} #{@target}\"\n b.run \"chmod #{unix_mode} #{@target}\"\n end\n end",
"def create(name)\n package = Package.new(name)\n package.name = name\n package.version = '1.0.0'\n empty_directory(name)\n empty_directory(File.join(name, 'operations'))\n empty_directory(File.join(name, 'resources'))\n template('metadata.rb.erb', File.join(name, 'metadata.rb'))\n\n if options[:vagrant]\n template('Vagrantfile.erb', File.join(name, 'Vagrantfile'))\n end\n\n if options[:docker]\n template('Dockerfile.erb.erb', File.join(name, 'Dockerfile.erb'))\n end\n end",
"def populate_chef_secure_path\n chef_secure_path.run_action(:create)\n\n unless new_resource.encrypted_data_bag_secret.nil?\n r = Chef::Resource::File.new(::File.join(new_resource.chef_secure_path, 'encrypted_data_bag_secret'), run_context)\n r.content(new_resource.encrypted_data_bag_secret)\n r.sensitive(true)\n r.run_action(:create)\n end\n\n unless chef_client_valid(chef_server_url, new_resource.service_name, client_key_file)\n r = Chef::Resource::File.new(client_key_file, run_context)\n r.sensitive(true)\n r.run_action(:delete)\n end\n\n unless ::File.exists?(client_key_file) or new_resource.validation_key.nil?\n r = Chef::Resource::File.new(::File.join(new_resource.chef_secure_path, 'validation.pem'), run_context)\n r.content(new_resource.validation_key)\n r.sensitive(true)\n r.run_action(:create)\n end\n\n unless new_resource.data_bags.empty?\n write_data_bags(new_resource.data_bags(new_resource.chef_secure_path, 'data_bags'))\n end\n end",
"def create\n bootstrap unless File.exist?(file)\n load_attributes\n end",
"def initialize(line, cookbook, options = {})\n Strainer.ui.debug \"Created new command from '#{line}'\"\n @label, @command = line.split(':', 2).map(&:strip)\n Strainer.ui.debug \" Label: #{@label.inspect}\"\n Strainer.ui.debug \" Command: #{@command.inspect}\"\n @cookbook = cookbook\n end",
"def create_file(file_name, asset_path, update_source)\n response_name = \"#{response_name}\"\n # * 1) BASE URL\n base_url = 'https://dev-cascade.chapman.edu/api/v1/'.to_s\n\n # * 2) REST API ACTION\n # https://wimops.chapman.edu/wiki/WWW#Key_Links\n # https://www.hannonhill.com/cascadecms/latest/developing-in-cascade/rest-api/index.html\n rest_action = 'create/'.to_s # ! KEEP TRAILING SLASH\n\n # * 3) ASSET TYPE\n # this is easy to find in cascade's edit/preview url.\n # ie https://dev-cascade.chapman.edu/entity/open.act?id=7f74b81ec04d744c7345a74906ded22a&type=page\n asset_type = 'file/' # ! KEEP TRAILING SLASH\n\n # * 4) ASSET PATH OR ID\n # you can also use its path (ie \"Chapman.edu/_cascade/formats/modular/widgets/1-column\")... but.. whitespace.\n asset_path = \"#{asset_path}\" # ! NO TRAILING SLASH\n\n # * 5) SECRETS\n # set these in environment_variables.yml\n cascade_username = '?u=' + ENV['CASCADE_USERNAME']\n cascade_password = '&p=' + ENV['CASCADE_PASSWORD']\n cascade_api_key = '?apiKey=' + ENV['CASCADE_API_KEY']\n\n update_source = \"#{update_source}\"\n\n data = File.read(update_source)\n p data\n\n response_body = data\n\n url_post =\n base_url + rest_action + asset_type + asset_path + cascade_api_key\n\n # 👹Editing assets unfortunately requires PATH, SITENAME, ID. This can be obtained by reading the asset's response.body 👆\n # HTTParty.post(url_post, body: { asset: { xmlBlock: { xml: data, path: \"_cascade/blocks/html/0-write-test\", parentFolderId: parent_folder_id, siteName: \"Chapman.edu\", id: \"365ae5dec0a81e8a20b1d746fd3e0778\" } } }.to_json)\n\n p HTTParty.post(\n url_post,\n body: {\n \"asset\": {\n \"file\": {\n \"text\": data,\n \"rewriteLinks\": false,\n \"maintainAbsoluteLinks\": false,\n \"shouldBePublished\": true,\n \"shouldBeIndexed\": true,\n # \"lastPublishedDate\": \"Jul 15, 2020, 12:56:28 AM\",\n \"lastPublishedBy\": \"cbryant\",\n \"expirationFolderRecycled\": false,\n \"metadataSetId\": \"6fef14a3c04d744c610b81da9d165a27\",\n \"metadataSetPath\": \"Default\",\n \"metadata\": {},\n \"reviewOnSchedule\": false,\n \"reviewEvery\": 180,\n # \"parentFolderId\": \"fd5121b0c04d744c42ab23aa0aba0ba8\",\n \"parentFolderPath\": \"_assets\",\n # \"lastModifiedDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"lastModifiedBy\": \"mthomas\",\n # \"createdDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"createdBy\": \"mthomas\",\n # \"path\": \"#{asset_path}#{file_name}\",\n # \"siteId\": \"6fef14a3c04d744c610b81dac0a8d082\",\n \"siteName\": \"Chapman.edu\",\n \"tags\": [],\n \"name\": file_name,\n # \"id\": \"2ba09c01c0a81e4b0015d01bfd25ea78\"\n }\n },\n \"success\": true\n }.to_json\n )\n # p \"🎉 View changes at https://dev-cascade.chapman.edu/entity/open.act?id=#{\n # asset_id\n # }&type=#{asset_type}\".chomp('/')\nend",
"def declare_berksfile\n @flavor.class.do_declare_resources do\n # :nocov:\n lazy_vars = Chef::DelayedEvaluator.new do\n { sources: berks_sources }\n end\n # :nocov:\n add_templates(%w(Berksfile), :create, variables: lazy_vars)\n end\n end",
"def generate\n #debug 'generate'\n\n #return nil\n path = self[:path]\n if path == nil\n path = self[:name]\n end\n existing_file_res = catalog.resource(:file, path)\n if !existing_file_res\n #_ensure = self[:ensure] == :present ? :file : :absent\n _ensure = self[:ensure]\n filetype = Puppet::Type.type(:file)\n fileparams = {:name => path, \n :ensure => _ensure,\n :backup => false,\n :checksum => :none\n }\n if self[:mode]\n fileparams[:mode] = self[:mode]\n end\n if self[:owner]\n fileparams[:owner] = self[:owner]\n end\n if self[:group]\n fileparams[:group] = self[:group]\n end\n file_res = filetype.new(fileparams)\n #debug \"resource file does not exist yet -> generate it with #{_ensure.to_s}\"\n #debug 'generated: ' + file_res.inspect\n result = [file_res]\n else\n #debug 'resource file already exists'\n result = nil\n end\n result\n end",
"def install_lazyk(prefix)\n cookbook_file \"#{Chef::Config[:file_cache_path]}/lazy.cpp\" do\n user 'root'\n group 'root'\n mode '0644'\n not_if \"test -e #{prefix}/bin/lazyk\"\n end\n\n bash \"install-lazyk\" do\n user 'root'\n cwd Chef::Config[:file_cache_path]\n code <<-EOH\n set -ex\n mkdir -p #{prefix}/bin\n g++ lazy.cpp -o #{prefix}/bin/lazyk\n EOH\n not_if \"test -e #{prefix}/bin/lazyk\"\n end\nend",
"def make_new_file\n\t\tmetadata_file_data = \"\"\n\t\tmetadata_file_data << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?><cp:coreProperties\"\n\t\tmetadata_file_data << \" xmlns:cp=\\\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\\\" \"\n\t\tmetadata_file_data << \"xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\" xmlns:dcterms=\\\"http://purl.org/dc/terms/\\\" \"\n\t\tmetadata_file_data << \"xmlns:dcmitype=\\\"http://purl.org/dc/dcmitype/\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\">\"\n\t\tmetadata_file_data << \"<dc:creator>#{datastore['DOCAUTHOR']}</dc:creator><cp:lastModifiedBy>#{datastore['DOCAUTHOR']}\"\n\t\tmetadata_file_data << \"</cp:lastModifiedBy><cp:revision>1</cp:revision><dcterms:created xsi:type=\\\"dcterms:W3CDTF\\\">\"\n\t\tmetadata_file_data << \"2013-01-08T14:14:00Z</dcterms:created><dcterms:modified xsi:type=\\\"dcterms:W3CDTF\\\">\"\n\t\tmetadata_file_data << \"2013-01-08T14:14:00Z</dcterms:modified></cp:coreProperties>\"\n\n\t\t#where to find the skeleton files required for creating an empty document\n\t\tdata_dir = File.join(Msf::Config.install_root, \"data\", \"exploits\", \"docx\")\n\n\t\t#making the actual docx\n\t\tdocx = Rex::Zip::Archive.new\n\t\t#add skeleton files\n\t\tvprint_status(\"Adding skeleton files from #{data_dir}\")\n\t\tDir[\"#{data_dir}/**/**\"].each do |file|\n\t\t\tif not File.directory?(file)\n\t\t\t\tdocx.add_file(file.sub(data_dir,''), File.read(file))\n\t\t\tend\n\t\tend\n\t\t#add on-the-fly created documents\n\t\tvprint_status(\"Adding injected files\")\n\t\tdocx.add_file(\"docProps/core.xml\", metadata_file_data)\n\t\tdocx.add_file(\"word/_rels/settings.xml.rels\", @rels_file_data)\n\t\t#add the otherwise skipped \"hidden\" file\n\t\tfile = \"#{data_dir}/_rels/.rels\"\n\t\tdocx.add_file(file.sub(data_dir,''), File.read(file))\n\t\t#and lets create the file\n\t\tfile_create(docx.pack)\n\tend",
"def create!(path, _args_)\n return usage if /\\?/ =~ path || /--help/ =~ path\n main_file = File.basename(path, '.rb') # allow uneeded extension input\n # Check to make sure that the main file doesn't exist already\n already_exist(path)\n @name = main_file.camelize\n writer = SketchWriter.new(main_file)\n template = inner_class_template\n writer.save(template)\n end",
"def run\n \n #Get Arguments\n if @name_args.size != 1\n ui.info(\"Please specify a tarPath\")\n show_usage\n exit 1\n end\n \n tar_file = Chef::TarFile.new(@name_args.first, true)\n CookbookTarDownload.download_cookbooks tar_file\n tar_file.save\n \n end",
"def create\n execute ['cmd', '/c', INSTALLUTIL, @resource[:arguments], @resource[:path]].flatten.compact.join(' ')\n end",
"def new\n cookbook_id = current_user.create_cookbook\n if cookbook_id\n @cookbook = Cookbook.find cookbook_id\n load_user_cookbook @cookbook\n redirect_to templates_path, notice: \"A new cookbook was created for you.\"\n else\n redirect_to upgrade_account_path(current_user.id), alert: \"You must have a paid membership to work on your own cookbooks\"\n end\n end",
"def chef_init(file)\n self.file = file\n self.source = IO.read(File.expand_path(file))\n self.header = find_header_in(source)\n self.docstring = find_description_in(header)\n end",
"def berks_upload\n puts 'Running berks upload'\n command = ['berks upload']\n command << \"#{cookbook.name}\" unless recursive\n command << \"-b #{@config.workspace}/Berksfile\"\n command << '--no-freeze' unless freeze\n puts `#{command.join(' ')}`\n fail 'Failed to upload cookbook' unless process_last_status.success?\n end",
"def initialize(name)\n self.original_filename = name\n self.root_dir = controll_root\n clean_tmpdir\n #creo una nuova cartella per il file attuale\n self.tmp_dir = \"#{self.root_dir.path}/#{Time.now.to_f}\"\n Dir.mkdir(self.tmp_dir)\n ext = File.extname(name)\n name = [File.basename(name), ext] unless ext.blank?\n\n @tmp_file = Tempfile.create(name, self.tmp_dir)\n\n self.unique_filename= File.basename(self.path)\n end",
"def updated_cookbook_file(cookbook_name, path)\n end",
"def create(*args)\n # since we don't care about the inputs, just glob args\n rc, new_path = czk.create(*args)\n [rc, @req_registry.strip_chroot_from(new_path)]\n end",
"def add_to_cookbook(recipe)\n @cookbook.push(recipe)\n end",
"def createNewBook(path)\n puts \"Create New Book\"\n\n #1 Call encryptor\n runEncryptor(path+\"output/ihtml/\",@book_prod_folder)\n \n #2 Copy searchDB.sql to root path\n copyFile(path+\"output/searchDB.sql\", @book_prod_folder)\n \n #3 Copy info.plist to root path\n copyFile(path+\"info.plist\", @book_prod_folder)\n \n #4 Update time stamp\n changeTimestamp(@book_prod_folder,@new_book_timestamp)\n \n #5 Create Zip\n createZip(@book_prod_folder,@book_prod_final_zip_folder+@book_full_name+\".zip\")\nend",
"def create\n @cookbook = Cookbook.new(cookbook_params)\n\n respond_to do |format|\n if @cookbook.save\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cookbook }\n else\n format.html { render action: 'new' }\n format.json { render json: @cookbook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def install_fpc(source, file, build_dir, prefix, installer)\n remote_file \"#{Chef::Config[:file_cache_path]}/#{file}\" do\n source source + file\n mode '0644'\n action :create_if_missing\n not_if \"test -e #{prefix}/bin/fpc\"\n end\n\n bash \"extract-#{build_dir}\" do\n user 'root'\n cwd Chef::Config[:file_cache_path]\n\n code <<-EOH\n set -e\n tar -xf #{file}\n EOH\n not_if \"test -e #{prefix}/bin/fpc\"\n end\n\n cookbook_file \"#{Chef::Config[:file_cache_path]}/#{build_dir}/#{installer}\" do\n user 'root'\n group 'root'\n mode '0755'\n not_if \"test -e #{prefix}/bin/fpc\"\n end\n\n bash \"install-#{build_dir}\" do\n user 'root'\n cwd Chef::Config[:file_cache_path]\n\n code <<-EOH\n set -e\n tar -xf #{file}\n cd #{build_dir}\n ./#{installer} #{prefix}\n EOH\n not_if \"test -e #{prefix}/bin/fpc\"\n end\nend",
"def action_create\n if current_resource.exists? && correct_config?\n Chef::Log.debug(\"#{new_resource} exists - skipping\")\n else\n converge_by(\"Create #{new_resource}\") do\n executor.groovy! <<-EOH.gsub(/ ^{12}/, '')\n import hudson.model.*\n import hudson.slaves.*\n import jenkins.model.*\n import jenkins.slaves.*\n\n props = []\n availability = #{convert_to_groovy(new_resource.availability)}\n usage_mode = #{convert_to_groovy(new_resource.usage_mode)}\n env_map = #{convert_to_groovy(new_resource.environment)}\n labels = #{convert_to_groovy(new_resource.labels.sort.join(\"\\s\"))}\n\n // Compute the usage mode\n if (usage_mode == 'normal') {\n mode = Node.Mode.NORMAL\n } else {\n mode = Node.Mode.EXCLUSIVE\n }\n\n // Compute the retention strategy\n if (availability == 'demand') {\n retention_strategy =\n new RetentionStrategy.Demand(\n #{new_resource.in_demand_delay},\n #{new_resource.idle_delay}\n )\n } else if (availability == 'always') {\n retention_strategy = new RetentionStrategy.Always()\n } else {\n retention_strategy = RetentionStrategy.NOOP\n }\n\n // Create an entry in the prop list for all env vars\n if (env_map != null) {\n env_vars = new hudson.EnvVars(env_map)\n entries = env_vars.collect {\n k,v -> new EnvironmentVariablesNodeProperty.Entry(k,v)\n }\n props << new EnvironmentVariablesNodeProperty(entries)\n }\n\n // Launcher\n #{launcher_groovy}\n\n // Build the slave object\n slave = new DumbSlave(\n #{convert_to_groovy(new_resource.name)},\n #{convert_to_groovy(new_resource.description)},\n #{convert_to_groovy(new_resource.remote_fs)},\n #{convert_to_groovy(new_resource.executors.to_s)},\n mode,\n labels,\n launcher,\n retention_strategy,\n props\n )\n\n // Create or update the slave in the Jenkins instance\n nodes = new ArrayList(Jenkins.instance.getNodes())\n ix = nodes.indexOf(slave)\n (ix >= 0) ? nodes.set(ix, slave) : nodes.add(slave)\n Jenkins.instance.setNodes(nodes)\n EOH\n end\n end\n end",
"def upload_cookbooks(args) \n begin\n run_cmd(Chef::Knife::TopoCookbookUpload, args)\n rescue Exception => e\n raise if Chef::Config[:verbosity] == 2\n end \n end",
"def init_key_with_cookbook_name(key, files)\n self[key] = {}\n self['cookbook'] ||= {}\n path_name_regex = BOOKWORM_KEYS[key]['path_name_regex']\n files.each do |path, ast|\n m = path.match(%r{/?([\\w-]+)/#{path_name_regex}})\n cookbook_name = m[1]\n file_name = m[2]\n self['cookbook'][cookbook_name] ||= {}\n self[key][\"#{cookbook_name}::#{file_name}\"] =\n { 'path' => path, 'cookbook' => cookbook_name, 'ast' => ast }\n end\n end",
"def initialize_container_file\n container_file.create true if container_file && !container_file.exists?\n end",
"def synchronized_cookbook(cookbook_name)\n puts \" - #{cookbook_name}\"\n end",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def response_file\n t = Chef::Resource::Template.new(new_resource.response_file, run_context)\n t.source 'empty.erb'\n t.cookbook 'websphere'\n t.owner new_resource.owner\n t.group new_resource.group\n t.mode 00644\n t.variables data: XML.generate(new_resource)\n t.not_if {\n @current_resource.installed || new_resource.install_from == :files\n }\n t.run_action(:create)\n new_resource.response_file\n end",
"def create\n\t type = @params[0].split('.')\n\n\t if type[1]\n\n\t if @params[1]\n\t FileUtils.touch(@params[1]+'/'+@params[0])\n\t else\n\t FileUtils.touch(@params[0])\n\t end\n\t else\n\t if @params[1]\n\t FileUtils::mkdir_p @params[1]+'/'+@params[0]\n\t else\n\t FileUtils::mkdir_p @params[0]\n\t end\n\t end\n\t end",
"def verify_key\n Chef::Log.info('Check for RSA key and download key ')\n\n if ::File.exist?('/opt/IBM/SCM_id_rsa')\n Chef::Log.info('Key already exist..........')\n else\n Chef::Log.info('Downloading the key.........')\n # copy the ssh key for TSCM to /opt/IBM/\n cookbook_file node['tscm']['key'].to_s do\n source node['tscm']['key_name'].to_s\n owner 'root'\n mode '400'\n action :create_if_missing\n end\n Chef::Log.info('Finished downloading RSA key...............')\n end\nend",
"def new\n @chef = Chef.new\n end",
"def base_file_create\n course = notey_notey_params['course']\n file = notey_notey_params['file']\n data = notey_notey_params['data']\n\n uri = \"/notebooks/#{course}_#{file}\"\n File.open(uri, 'wb') do |f|\n f.write(data)\n end\n render json: { result: true }\n end",
"def create_template(source_template, path, notify)\n\n if notify\n service 'nscp' do\n action :start\n end\n template path do\n source source_template\n notifies :restart, 'service[nscp]', :immediately\n end\n else\n template path do\n source source_template\n end\n end\nend",
"def upload_recipe\n # Write the raw recipe contents to a tempfile and upload\n Tempfile.open([\"vagrant-chef-apply\", \".rb\"]) do |f|\n f.binmode\n f.write(config.recipe)\n f.fsync\n f.close\n\n # Upload the tempfile to the guest\n @machine.communicate.upload(f.path, target_recipe_path)\n end\n end",
"def init_file; end",
"def generate_temp_cookbook(arguments, reporter)\n opts = if arguments.length == 1\n { recipe_spec: arguments.shift,\n cookbook_repo_paths: parsed_options[:cookbook_repo_paths] }\n else\n { resource_type: arguments.shift,\n resource_name: arguments.shift,\n resource_properties: properties_from_string(arguments) }\n end\n action = ChefApply::Action::GenerateTempCookbook.from_options(opts)\n action.run do |event, data|\n case event\n when :generating\n reporter.update(TS.generate_temp_cookbook.generating)\n when :success\n reporter.success(TS.generate_temp_cookbook.success)\n else\n handle_message(event, data, reporter)\n end\n end\n action.generated_cookbook\n end",
"def create_test_file(host, file_rel_path, file_content, options)\n\n # set default options\n options[:mkdirs] ||= false\n options[:owner] ||= \"root\"\n options[:group] ||= \"puppet\"\n options[:mode] ||= \"755\"\n\n file_path = get_test_file_path(host, file_rel_path)\n\n mkdirs(host, File.dirname(file_path)) if (options[:mkdirs] == true)\n create_remote_file(host, file_path, file_content)\n\n#\n# NOTE: we need these chown/chmod calls because the acceptance framework connects to the nodes as \"root\", but\n# puppet 'master' runs as user 'puppet'. Therefore, in order for puppet master to be able to read any files\n# that we've created, we have to carefully set their permissions\n#\n\n chown(host, options[:owner], options[:group], file_path)\n chmod(host, options[:mode], file_path)\n\nend",
"def create_test_file(host, file_rel_path, file_content, options)\n\n # set default options\n options[:mkdirs] ||= false\n options[:owner] ||= \"root\"\n options[:group] ||= \"puppet\"\n options[:mode] ||= \"755\"\n\n file_path = get_test_file_path(host, file_rel_path)\n\n mkdirs(host, File.dirname(file_path)) if (options[:mkdirs] == true)\n create_remote_file(host, file_path, file_content)\n\n#\n# NOTE: we need these chown/chmod calls because the acceptance framework connects to the nodes as \"root\", but\n# puppet 'master' runs as user 'puppet'. Therefore, in order for puppet master to be able to read any files\n# that we've created, we have to carefully set their permissions\n#\n\n chown(host, options[:owner], options[:group], file_path)\n chmod(host, options[:mode], file_path)\n\nend",
"def create(filename = nil)\n filename = @doing_file if filename.nil?\n return if File.exist?(filename) && File.stat(filename).size.positive?\n\n FileUtils.mkdir_p(File.dirname(filename)) unless File.directory?(File.dirname(filename))\n\n File.open(filename, 'w+') do |f|\n f.puts \"#{Doing.setting('current_section')}:\"\n end\n end",
"def get_cookbook_name(path)\n metadata = Chef::Cookbook::Metadata.new\n if File.exist?(File.join(path, 'metadata.json'))\n metadata.from_json_file(File.join(path, 'metadata.json'))\n else\n metadata.from_file(File.join(path, 'metadata.rb'))\n end\n metadata.name\n end",
"def create_node_manifest(manifest_path, master_certname, node_def_name='default')\n manifest = File.read(manifest_path)\n\n site_pp = <<-MANIFEST\nfilebucket { 'main':\n server => '#{master_certname}',\n path => false,\n}\n\nFile { backup => 'main' }\n\nnode default {\n\n#{manifest}\n}\nMANIFEST\n\n return site_pp\nend",
"def action_create\n if (dir_exists?(@path))\n Chef::Log::info(\"Directory #{ @path } exits; create action not taken\")\n else\n converge_by(\"Create #{ @new_resource }\") do\n @client.mkdir(@path,'permission' => @mode)\n end\n new_resource.updated_by_last_action(true)\n end\n end",
"def create!\n new_file = \"#{next_number}-#{strip_title}.md\"\n @path = File.join(@dir, new_file)\n File.open(@path, 'w') do |file|\n file.write initial_content\n end\n\n new_file\n end"
] | [
"0.69162536",
"0.6542696",
"0.6535739",
"0.64973015",
"0.6352324",
"0.6298342",
"0.6279494",
"0.6213824",
"0.6194064",
"0.60995734",
"0.6022786",
"0.60210294",
"0.596972",
"0.5944844",
"0.5932327",
"0.5911238",
"0.5911039",
"0.5854371",
"0.5838811",
"0.575114",
"0.570897",
"0.57078195",
"0.5705491",
"0.5694019",
"0.5674278",
"0.5661906",
"0.5653745",
"0.56238014",
"0.56131613",
"0.56089807",
"0.5607756",
"0.5603172",
"0.5599511",
"0.5576271",
"0.55730516",
"0.5568502",
"0.55653566",
"0.5563576",
"0.5561887",
"0.55596554",
"0.5556134",
"0.5532163",
"0.5528364",
"0.5519538",
"0.5519133",
"0.55158263",
"0.55140465",
"0.55044174",
"0.55044174",
"0.5497084",
"0.5493423",
"0.5466917",
"0.5466732",
"0.54659325",
"0.54608434",
"0.54599595",
"0.54568106",
"0.5456198",
"0.54486454",
"0.54452294",
"0.54368806",
"0.5426381",
"0.54229337",
"0.54167867",
"0.5410412",
"0.54103833",
"0.53836405",
"0.53796166",
"0.5377045",
"0.5375641",
"0.53621644",
"0.53603196",
"0.53487396",
"0.5332348",
"0.53321177",
"0.5332078",
"0.53307974",
"0.5329895",
"0.53195584",
"0.5315349",
"0.53146905",
"0.5311419",
"0.530478",
"0.530381",
"0.53036636",
"0.5301479",
"0.5300352",
"0.52976495",
"0.52967364",
"0.5284293",
"0.52681434",
"0.5263693",
"0.52635795",
"0.5260886",
"0.5260886",
"0.5250032",
"0.52496606",
"0.52471316",
"0.52451265",
"0.52429813"
] | 0.61204183 | 9 |
Create a function with two arguments that will return a list of length (n) with multiples of (x). Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array (or list in Python or Haskell.) Examples: count_by(1,10) should return [1,2,3,4,5,6,7,8,9,10] count_by(2,5) should return [2,4,6,8,10] | def count_by(x, n)
a=[]
y=0
n.times {y+=x; a<<y}
a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_by(x, n)\n (1..n).map{|i| i*x}\nend",
"def counts(n)\n divisors = Array.new\n (1..n).each do |n|\n single_divisors = count n\n divisors.push(single_divisors)\n end\n divisors\n end",
"def multiples_of( x, xmax )\n ct = x\n nums = []\n while ct <= xmax\n nums << ct\n ct += x\n end\n return nums\nend",
"def count_to (n)\n array = []\n count = 0\n while count <= n\n count += 1\n array.push(count.round)\n end\nend",
"def count_by_x (num1, num2)\n array = (num1..num1 * num2).to_a\n\n array.select do |num|\n num % num1 == 0\n end\nend",
"def factor_count(x)\n range = 2..Math.sqrt(x)\n count = range.count { |i| x % i == 0 }\n count * 2\nend",
"def monkey_count(n)\n [*1..n]\nend",
"def sum_of_multiples(x, n)\n multiples_count = n/x\n x * ((n/x) * ((n/x)+1)/2)\nend",
"def multiples(x)\n array = []\n while x > 0\n x = x - 1\n if (x % 3 == 0) || (x % 5 == 0)\n array << x\n end\n end\n return array.inject{|sum,x| sum + x }\nend",
"def count_to(n)\n arr = []\n if n>=0\n n = n.floor\n 0.upto(n) do |x|\n arr << x\n end\n else\n n = -(-n).floor\n 0.downto(n) do |x|\n arr << x\n end\n end\n arr\n end",
"def count(n,ar)\r\n result = Array.new(100){|x| x = 0}\r\n ar.each { |x| result[x] = result[x]+1 }\r\n return result\r\nend",
"def divisors(n)\n count = 0\n (1..n).each { |div| count += 1 if n % div == 0 }\n return count\nend",
"def counting(limit) # this method receives an integer argument and returns an array\n numbers = []\n if limit.is_a?(Integer)\n count = 0\n while count < limit\n numbers << count\n count += 1\n end\n end \n numbers\nend",
"def multiples_of(number, upTo)\n result = Array.new\n (0..upTo).step(number) do |n|\n result << n\n end\n puts result.inspect\n result\nend",
"def multiples_x(number, multiple)\n current_multiple = multiple\n multiples = []\n\n while current_multiple <= number\n multiples << current_multiple\n current_multiple += multiple\n end\n\n multiples\nend",
"def multisum(num)\n count = 0\n (1..num).each { |idx| count += idx if (idx % 3).zero? || (idx % 5).zero? }\n count\nend",
"def find_multiples(number)\n sum_of_multiples = (3...number).each_with_object([]) do |element, list|\n list << element if element % 3 == 0 || element % 5 == 0\n end.sum\nend",
"def simber_count(n)\n lower_range = 10**(n - 1)\n upper_range = (10**n) - 1\n count = 0\n (lower_range..upper_range).each do |i|\n count += 1 if simber_check(i)\n end\n count\nend",
"def factorialize(n)\n return 0 if n.zero?\n\n number_array = []\n\n n.times do |number|\n number_array << number + 1\n end\n\n number_array.reduce(:*)\nend",
"def collect_multiples(number)\n \n numbers = Array.new(number - 1, 0)\n count = 0\n while count < numbers.length \n numbers[count] = count + 1\n count += 1\n end\n\n numbers.select do |element|\n element % 3 == 0 || element % 5 == 0\n end\n\nend",
"def count(n)\n sum = 1\n n.prime_division.each do |x|\n sum *= (x[1] + 1)\n end\n sum\n end",
"def numDivisors(n)\n exponents = []\n remaining = n\n\n return 1 if n == 1\n\n for i in [email protected]\n\n if remaining == 1 then\n return exponents.inject(:*)\n end\n\n if remaining % @primes[i] == 0 then\n exponent_count = 0\n while remaining % @primes[i] == 0 do\n remaining /= @primes[i]\n\n exponent_count += 1\n end\n exponents.push(exponent_count + 1)\n end\n end\n return 1\nend",
"def multisum(num)\n counter = 1\n arr = []\n while counter <= num\n if counter % 3 == 0 || counter % 5 == 0\n arr << counter\n end\n counter += 1\n end\n arr.sum\nend",
"def at_least_n_factors(numbers, n)\n\n arr = []\n numbers.each do |x|\n arr << x if num_factors(x) >= n\n end\n\n arr\nend",
"def multisum(num)\n # 2. Next, since I know I have to store all multiples of 3 and 5, I want to create an empty array\n multiples = []\n # 3. Now I can run the each method on the range of 1 to num\n (1..num).each do |number|\n # 4. If the number is evenly divisible by 3 or 5 I want to store it in the multiples array\n if number % 3 == 0 || number % 5 == 0\n multiples << number\n end\n end\n # 5. Now I simply return the sum of the multiples array\n multiples.sum\nend",
"def monkey_count(n)\n Array.new(n) {|x| x + 1 }#your code here\nend",
"def get_sums(total, count)\n ([1]*total).group_by.with_index {|_, i| i % count}.values.map {|a| a.inject(0, &:+)}\nend",
"def series_up(n) # given n, return a list that goes [1,1,2,1,2,3... n]\n n_list = []\n (n+1).times do |m|\n m.times do |val|\n n_list.push(val+1)\n end\n end\n return n_list\nend",
"def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.sum\nend",
"def count_them_while(n)\n count = 0 \n x = 1 \n while x <= n \n count += x \n x += 1 \n end \n count\nend",
"def at_least_n_factors(numbers, n)\n arr = []\n numbers.each {|number| arr.push(number) if num_factors(number) >= n}\n arr\nend",
"def divisor_count_of(number)\n # Count the divisors by computing the prime factorization of the number and\n # multiplying PF exponents. 1 is added to the exponents since each base can\n # be raised to the 0 power, which is still a divisor of the given number.\n prime_factorization = prime_factorization_of(number)\n exponents = prime_factorization.values\n result = exponents.inject(1) {|accum, val| accum * (val + 1)}\n\n return result\nend",
"def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.inject(:+)\nend",
"def number_of_factors(n)\n # bruteforce, simplest\n # least efficient way\n count = 0\n\n (1..n).each do |i|\n if n % i == 0\n count += 1\n end\n end\n\n count\nend",
"def numbers_of_multiple (number)\n divisors = []\n (1..20).each do |divisor|\n if number % divisor ==0\n divisors.push divisor\n end\n end\n #if divisors.length == 20\n # return true\n #else\n # puts divisors.length\n # return false\n #end\n return divisors.length\nend",
"def count_to(num)\n # takes in a number\n # returns an array containing every integer from 0 to n\n # counts up or down\n # rounds off decimals\n arr=[]\n if num ==0\n return [0]\n end\n n = num\n n = num.÷floor\n if !num.integer? && num < 0\n n = num.floor + 1\n end\n\n if n < 0\n 0.downto(n) { |i| arr.push(i) }\n else\n 0.upto(n) { |i| arr.push(i) }\n end\n arr\nend",
"def divisor_count_of(number)\n divisors = divisors_of(number)\n\n return divisors.length\n end",
"def divisors(n)\n divs = []\n # NOT INCLUDING ITSELF\n (1...n).each do |i|\n if n % i == 0\n divs << i\n end\n end\n divs\nend",
"def num_of_divisors(n)\n count = 1\n 1.upto(n/2+1) do |i|\n if n % i == 0\n count += 1\n end\n end\n count\nend",
"def select_every_n arr, n=1\n ans = []\n arr.each_with_index do |item, i|\n ans.push item if i%n == 0\n end\n ans\nend",
"def solution(number)\r\n (3...number).each_with_object([]) { |n, arr| arr << n if (n % 3).zero? || (n % 5).zero? }.uniq.sum\r\nend",
"def divisors(num)\n count = []\n factors = Prime.prime_division(num)\n #prime_division returns nested array of [[prime, #of times],[prime, #oftimes]]\n #just want the second value of each subarray\n factors.flatten.each_with_index do |value, i|\n if i%2 != 0\n count << value\n end\n end\n #add one to each and multiply \n num_of_divisors = count.collect{|m| m+1}.inject(:*)\n end",
"def multiples(num)\n\tresult = []\n\tsum = 0\n\ti = 1\n\twhile i < num\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tresult << i\n\t\tend\n\t\ti += 1\n\tend\n\tresult.each do |digit|\n\t\tsum += digit\n\tend\n\tsum\t\nend",
"def multiples num1, num2, divisor\n x = []\n (num1...num2).each do |i|\n if is_divisible i, divisor\n x << i\n end\n end\n x\n end",
"def count(list, number)\n c = 0\n list.each do |n|\n if n == number\n c += 1\n end\n end\n return c\nend",
"def factors_of(n)\n result = []\n (1..n/2).each do |x|\n quotient, remainder = n.divmod x\n if remainder.zero?\n result << quotient\n result << x\n end\n end\n result.uniq\nend",
"def multisum(num)\n arr = [*1..num]\n multiples_3_5 = arr.select{ |ele| ele % 3 == 0 || ele % 5 == 0}\n multiples_3_5.sum\nend",
"def set_mod_list(k, s)\n arr = []\n k.times do |i|\n arr.push(s.count { |a| a % k == i })\n end\n arr\nend",
"def count_primes(n)\n primes = (0..n).to_a\n primes[0] = nil\n primes[1] = nil\n\n primes.each do |current_num|\n next if current_num == nil\n break if current_num > Math.sqrt(n)\n (current_num**2).step(n, current_num) { |interval| primes[interval] = nil }\n end\n\n primes.compact.take_while { |num| num < n }.size\nend",
"def sequence(count, num)\n arr = []\n count.times{ |i| arr << (i+1) * num }\n arr\nend",
"def count_bits(n)\n # TODO: Program me\n result_arr = []\n\n while n > 0 do \n result_arr << n % 2\n n /= 2\n end\n result_arr.select { |i| i == 1 }.count\nend",
"def multisum(num)\n multiples = []\n 1.upto(num) do |x| \n if x % 3 == 0 || x % 5 == 0\n multiples << x\n end\n end\n multiples.inject(:+)\nend",
"def multisum(num)\n divisables = []\n 1.upto(num) {|num| num % 3 == 0 || num % 5 == 0 ? divisables << num : next}\n divisables.sum\nend",
"def multisum(num)\n arr = []\n (1..num).map do |n|\n if n % 3 == 0 || n % 5 == 0\n arr << n\n end\n end\n arr.inject { |n, sum| n + sum }\nend",
"def sequence(count, starting_num)\n result_arr = []\n 1.upto(count) { |num| result_arr << starting_num * num }\n result_arr\nend",
"def countIt(n)\n\n vals = {0=>1, 1=>0, 2=>0, 3=>0, 4=>0, 5=>0,\n 6=>1, 7=>0, 8=>2, 9=>1}\n\n n.to_s.chars.map(&:to_i).collect{|v| vals[v]}.inject(0){|x, sum| x + sum }\n\nend",
"def factors (n)\r\n factors = Array.new(n) { |index| index+=1 }\r\n return factors.select { |x| n%x == 0}\r\nend",
"def multiples(n)\n (1...n).select do |num|\n num if (num % 3).zero? || (num % 5).zero?\n end.reduce(:+)\nend",
"def series_up(n)\n list = []\n (n+1).times do |a|\n a.times do |b|\n list.push(b+1)\n end \n end\n return list\nend",
"def divisible_count(array, factor)\n counts = 0\n\n i = 0\n while i < array.length\n if array[i] % factor == 0\n counts += 1\n end\n\n i += 1\n end\n\n return counts\nend",
"def multisum(num)\n (1..num).to_a.select { |n| n % 3 == 0 || n % 5 == 0 }.sum\nend",
"def fact(n)\n 1.upto(n).inject(:*)\nend",
"def count_to n\n n = n.to_i\n n >= 0 ? (0..n).to_a : 0.downto(n).to_a\n end",
"def arrPrimeFactors (n)\n result = Array.new\n while n != 1\n (2 .. n).each do |i|\n if n % i == 0\n result.push i\n n /= i\n break\n end\n end\n end\n result\nend",
"def count_to(num)\n arr = []\n num = num.to_int\n num > 0 ? 0.upto(num){|i| arr.push(i)} : 0.upto(-num){|i| arr.push(-i)}\n return arr\n end",
"def multisum(num)\n numbers = (1..num).to_a\n multiples = numbers.select { |element| element % 3 == 0 || element % 5 == 0 }\n multiples.inject(:+)\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def multisum(integer)\n multiples = []\n 1.upto(integer) do |index|\n multiples << index if index % 3 == 0 || index % 5 == 0\n end\n multiples.sum\nend",
"def divisors(num)\n divisors = []\n (1..num).each do |div|\n divisors << div if (num % div).zero?\n end\n return divisors\nend",
"def factors(n)\n\n\t#create an Array\n\tarray = []\n\t\n\t(1..n).each do |num|\n\t\tif (n % num) == 0\n\t\t\tarray.push(num)\n\t\tend\n\tend\n\treturn array\nend",
"def multisum(limit)\n multiples = []\n\n for num in 1..limit\n multiples << num if num % 3 == 0 || num % 5 == 0\n end\n\n multiples.inject(:+)\nend",
"def sequence(count, num)\n multiples = []\n count.times { |i| multiples.push(num * (i + 1)) }\n multiples\n # (1..count).map { |idx| idx * num }\nend",
"def get_divisors(number)\n\tresult = []\n\n \tfor counter in 1..number / 2\n \tresult.push(counter) if number % counter == 0\n \tend\n\n \tresult.push(number)\n \tresult\nend",
"def factors(number)\n # TODO: can optimise by only going up to the square of the number\n (1..number).select { |x| number % x == 0 }.count\nend",
"def sequence(count, number)\n sequence_arr = []\n 1.upto(count) do |n|\n sequence_arr << number * n\n end\n sequence_arr\nend",
"def multiples_of_three_and_five(limit)\n arr = []\n i = 1\n\n while i < limit do\n if i % 5 == 0 || i % 3 == 0\n arr << i\n i += 1\n else\n i += 1\n end\n # puts $arr.inspect\n end\n\n arr_size = arr.count\n # puts arr_size\n total = 0\n i = 0\n\n while i < arr_size do\n total += arr[i]\n i += 1\n end\n\n return total\nend",
"def multiples(x)\n (2..6).map { |i| i*x }\nend",
"def count_divisors(num)\n\n (1..num).count {|n| num % n == 0}\n\nend",
"def sum_divisors(n)\r\n (1...n).select { |x| (n % x).zero? }.sum - 1\r\nend",
"def factorial n\n arr = []\n while n >= 1\n arr.push n\n n -=1\n end\n arr.reduce(:*)\nend",
"def multisum(limit)\n nums = []\n 1.upto(limit) { |num| nums << num if (num % 3 == 0 || num % 5 == 0)}\n nums.sum\nend",
"def collect_multiples(limit)\n array = []\n (1...limit).each do |num|\n array << num if (num % 3 == 0) || (num % 5 == 0)\n end\n array\nend",
"def multiple_of(n, x)\n x.modulo(n).zero?\n end",
"def number_of_divisors(num)\r\n\tprime_array = num.prime_division\r\n\tnum_of_divisors = 1\r\n\t(0..prime_array.length - 1).each do |x|\r\n\t\tnum_of_divisors *= (prime_array[x][1] + 1)\r\n\tend\r\n\treturn num_of_divisors\r\nend",
"def multisum(number)\n multiples = (1..number).select { |x| (x % 3 == 0) || (x % 5 == 0) }\n multiples.reduce(:+)\nend",
"def count_up(number)\n (1..number).to_a\nend",
"def divisor(n)\n count = 0\n (1..n).each do |d|\n if n % d == 0\n count += 1\n end \n end \n count \nend",
"def find_factors(n, possible_factors)\n factors = []\n\n possible_factors.each do |possible_factor|\n factors << possible_factor if n % possible_factor == 0\n end\n\n factors\nend",
"def sequence(count, num)\n seq_arr = []\n 1.upto(count) { |n| seq_arr << num * n }\n seq_arr\nend",
"def factors(number)\n answer = []\n count = 1\n while count < (number + 1)\n result = number % count\n answer << count if result == 0\n count += 1\n end\n puts answer\nend",
"def find(n)\r\n result = []\r\n n = group(n)\r\n\r\n n.each { |element| result << [element, element.length]}\r\n\r\n result\r\nend",
"def listFactorialsOf(n)\n list = []\n while n > 0\n list.push n\n n -= 1\n end\n list\nend",
"def nontrivial_divisors_of number, options={}\n default_options = {upper_limit: number - 1}\n # Merge in default options because default options in the argument list will\n # be ignored/missed if a partial option hash is passed in\n options = default_options.merge options\n\n upper_limit = options[:upper_limit]\n\n divisors = []\n (2..upper_limit).each do |val|\n if number % val == 0\n divisors.push val\n end\n end\n divisors\nend",
"def divisor_counter(n)\n i, count = 1, 0\n\n until i * i > n\n if n % i == 0\n count += 1\n count += 1 if i * i != n\n end\n i += 1\n end\n\n count\nend",
"def sum_of_multiples\n list_of_multiples = [ ]\n 1000.times do |number| \n list_of_multiples << number if number % 3 == 0 || number % 5 == 0\n end\n list_of_multiples.inject(&:+)\nend",
"def factors n\n 1.upto(Math.sqrt(n)).select{ |x| (n % x).zero?}.inject([]) do |arr,x|\n arr << x\n arr << n/x unless x == n/x\n arr.sort\n end\nend",
"def prime_factorization(n)\n new_arr = []\n (2...n).each do |i|\n if n % i == 0\n dividend = n / i\n return [*prime_factorization(i), *prime_factorization(dividend)]\n end\n end\n new_arr << n\nend",
"def count_num_times(arr, k)\n # base case:\n return 0 if arr.empty?\n\n count_num_times(arr, k - arr.first) +\n count_num_times(arr.shift, k)\nend",
"def n_times( input )\n\treturn lambda{|n| n * input}\nend",
"def proper_divs(num)\n puts num\n divs = []\n (1...num).each do |x|\n divs << x if num%x == 0\n end\n return divs\nend"
] | [
"0.8004699",
"0.70162845",
"0.6892011",
"0.68776846",
"0.6769908",
"0.67528325",
"0.6590494",
"0.6569084",
"0.65532243",
"0.6551252",
"0.65417355",
"0.64793026",
"0.6461403",
"0.64416224",
"0.6372089",
"0.6347995",
"0.6330729",
"0.63219327",
"0.6292802",
"0.6268252",
"0.62589306",
"0.6225369",
"0.62002367",
"0.6196773",
"0.61897844",
"0.6170912",
"0.6158201",
"0.6156859",
"0.61515623",
"0.61426324",
"0.6136017",
"0.6135569",
"0.6124617",
"0.61174005",
"0.6114419",
"0.6112895",
"0.6074446",
"0.60732925",
"0.6063315",
"0.60578716",
"0.60569584",
"0.60507405",
"0.6047932",
"0.6043825",
"0.60386276",
"0.60292923",
"0.6019165",
"0.600996",
"0.59931517",
"0.59925216",
"0.599194",
"0.5991176",
"0.5990726",
"0.5985924",
"0.59810615",
"0.59751254",
"0.5972379",
"0.59667975",
"0.59623593",
"0.59451646",
"0.59447294",
"0.5939882",
"0.5939348",
"0.5937986",
"0.59374404",
"0.59317416",
"0.5928578",
"0.5921515",
"0.59184295",
"0.59161407",
"0.5909628",
"0.59091836",
"0.5908974",
"0.5900153",
"0.5898599",
"0.58949554",
"0.5890914",
"0.58835894",
"0.58738637",
"0.58734185",
"0.58701026",
"0.58677775",
"0.58583605",
"0.5857428",
"0.58500546",
"0.5849438",
"0.5849214",
"0.5844368",
"0.5840491",
"0.5835239",
"0.58351785",
"0.5834049",
"0.5831819",
"0.5831622",
"0.5824924",
"0.5823624",
"0.5821817",
"0.58127487",
"0.5806037",
"0.5801136"
] | 0.7754079 | 1 |
GET /tipocuenta GET /tipocuenta.json | def index
@tipocuenta = Tipocuentum.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @tipocliente }\n end\n end",
"def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipomedalla }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def show\n @articulo = Articulo.find(params[:id])\n @noticias = Articulo.where(\"tipo = 'noticia'\").order(\"created_at desc\")\n @title = @articulo.titulo\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end",
"def show\n @tipp = Tipp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipp }\n end\n end",
"def show\n @telefononegocio = Telefononegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @telefononegocio }\n end\n end",
"def index\n tips = Tip.all\n json_response(tips)\n end",
"def index\n @itemtipos = Itemtipo.all\n\n render json: @itemtipos\n end",
"def index\n @tiposervicos = Tiposervico.all\n end",
"def show\n @noto = Noto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @noto }\n end\n end",
"def index\n @tipovestuarios = Tipovestuario.all\n end",
"def show\n @tip = Tip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip }\n end\n end",
"def index\n @tipos_contatos = TiposContato.all\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end",
"def show\n json_response(@tip)\n end",
"def show\n @tarefa = Tarefa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tarefa }\n end\n end",
"def index\n @tipos = Tipo.all\n end",
"def index\n @tipos = Tipo.all\n end",
"def show\n @torso = Torso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torso }\n end\n end",
"def show\n @tipo_atendimento = TipoAtendimento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_atendimento }\n end\n end",
"def index\n @tipoplatos = Tipoplato.all\n end",
"def show\n @torneo = Torneo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torneo }\n end\n end",
"def show\n @trnodo = Trnodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trnodo }\n end\n end",
"def show\n @etnia = Etnia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etnia }\n end\n end",
"def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end",
"def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end",
"def index\n @tipoveiculos = Tipoveiculo.all\n end",
"def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end",
"def show\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def index\n @tipoclientes = Tipocliente.paginate(:page => params[:numero_hoja], :per_page => 18)\n if params[:numero_hoja].nil?\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @tipoclientes }\n end\n else\n respond_to do |format|\n format.html { render :layout => \"application_paginate\"}# index.html.erb\n #format.json { render json: @impuestos }\n end\n end\n end",
"def index\n @tacos = Taco.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render @tacos }\n end\n end",
"def index\n @tiposveiculos = Tiposveiculo.all\n end",
"def index\n @solicitacao_tipos = SolicitacaoTipo.all\n end",
"def new\n @tip_so = TipSo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end",
"def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end",
"def show\n @trabalho = Trabalho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trabalho }\n end\n end",
"def new\n @tipomedalla = Tipomedalla.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipomedalla }\n end\n end",
"def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def index\n @tipos_datos = TiposDato.all\n end",
"def show\n @tiposcontrato = Tiposcontrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tiposcontrato }\n end\n end",
"def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n \t\t\trender json: @usuario.pedidos.find(@pedido.id)\n \t\telse\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n \t\t\trender json: @negocio.pedidos.find(@pedido.id)\n \t\tend\n \tend",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def index\n @ventas = Venta.order(\"fecha desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contato_produto }\n end\n end",
"def index\n @tipotermos = Tipotermo.all\n end",
"def show\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def show\n @puestos_entidad = PuestosEntidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puestos_entidad }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def show\n @tipo_tel = TipoTel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_tel }\n end\n end",
"def show\n @asiento = Asiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asiento }\n end\n end",
"def tipospolen\n\n @info_polens = InfoPolen.collection.aggregate(\n { \"$group\" => { \"_id\" => \"$TIPOS_POLINICOS\" } },\n { \"$sort\" => {\"_id\" => 1} }\n )\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end",
"def index\n @tipos_personas = TipoPersona.all\n end",
"def show\n @tetramod = Tetramod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tetramod }\n end\n end",
"def index\n @tipics = Tipic.all\n end",
"def index\n @pontos = Ponto.all\n end",
"def index\n @articulos = Articulo.where(\"tipo = 'articulo'\").order(\"created_at desc\") \n @noticias = Articulo.where(\"tipo = 'noticia' and mostrar_carrusel='1'\").order(\"created_at desc\").limit(3)\n @articulos = @articulos.page(params[:page]).per_page(5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articulos }\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 show\n @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_product }\n end\n end",
"def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def show\n @ativo_outro = AtivoOutro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ativo_outro }\n end\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def show\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_actividad }\n end\n end",
"def show\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @oferta }\n end\n end",
"def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end",
"def show\n @titulacionesdoctipo = Titulacionesdoctipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @titulacionesdoctipo }\n end\n end",
"def index\n @tipomovifinanceiros = Tipomovifinanceiro.all\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @peso }\n end\n end",
"def show\n @datoscontacto = Datoscontacto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datoscontacto }\n end\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def show\n @tema = Tema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tema }\n end\n end",
"def show\n @core_nota = Core::Nota.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_nota }\n end\n end",
"def show\n @lista_contato = ListaContato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lista_contato }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def show\n @tipo_convenio = TipoConvenio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_convenio }\n end\n end",
"def show\n @apunte = Apunte.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apunte }\n end\n end",
"def show\n @line = ReportingForms::Tanimoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\n end\n end",
"def show\n @utente = Utente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @utente }\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 @trabajo = Trabajo.find(params[:trabajo_id])\n @presupuestos = @trabajo.presupuestos.order(\"aprobado DESC, rechazado ASC\")\n\n add_breadcrumb @trabajo.proposito, trabajo_path(@trabajo)\n add_breadcrumb \"Presupuestos\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @presupuestos }\n end\n end",
"def show\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end",
"def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end",
"def create\n @tipos_contato = TiposContato.new(tipos_contato_params)\n\n respond_to do |format|\n if @tipos_contato.save\n format.html { redirect_to @tipos_contato, notice: 'Tipos contato was successfully created.' }\n format.json { render :show, status: :created, location: @tipos_contato }\n else\n format.html { render :new }\n format.json { render json: @tipos_contato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @atracao = Atracao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @atracao }\n end\n end",
"def donizetti\n fetch('opera.italian.by_gaetano_donizetti')\n end",
"def set_tipos_contato\n @tipos_contato = TiposContato.find(params[:id])\n end",
"def index\n\t\texecutar_acoes\n\t\t@pontos = PontoInteresse.all.order(\"enable DESC, denuncias_count DESC, created_at DESC\").page(params[:page])\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @pontos }\n\t\tend\n\tend"
] | [
"0.70758057",
"0.6861703",
"0.6858581",
"0.6765908",
"0.6765908",
"0.66960454",
"0.6654463",
"0.6627065",
"0.6605445",
"0.6594997",
"0.6522421",
"0.6487479",
"0.648541",
"0.64729357",
"0.64467347",
"0.6401073",
"0.63894105",
"0.63742113",
"0.6358471",
"0.63532233",
"0.63532233",
"0.632994",
"0.6316672",
"0.6313972",
"0.63037205",
"0.6290894",
"0.62833524",
"0.6265929",
"0.6264889",
"0.6256925",
"0.6254109",
"0.6246415",
"0.6246415",
"0.6210473",
"0.6205895",
"0.6204231",
"0.6177587",
"0.61760104",
"0.6152494",
"0.6145134",
"0.6143215",
"0.613942",
"0.6129109",
"0.6127552",
"0.6113312",
"0.6111113",
"0.61046255",
"0.60982317",
"0.6094349",
"0.60896975",
"0.608903",
"0.608903",
"0.60863614",
"0.60826963",
"0.6067",
"0.6061753",
"0.6059577",
"0.6045857",
"0.60447097",
"0.60380167",
"0.60375994",
"0.6023952",
"0.60228777",
"0.6014495",
"0.6009043",
"0.5998751",
"0.5997943",
"0.5995532",
"0.5994385",
"0.59892064",
"0.59883225",
"0.5981354",
"0.5981354",
"0.59728396",
"0.5969142",
"0.59690887",
"0.5964333",
"0.59637123",
"0.5962707",
"0.5956439",
"0.5950924",
"0.5950112",
"0.5942581",
"0.59419835",
"0.5937084",
"0.59346616",
"0.59342134",
"0.5933187",
"0.5932534",
"0.5931886",
"0.59206194",
"0.59182453",
"0.59159863",
"0.59154606",
"0.59152555",
"0.59114134",
"0.59065896",
"0.5903786",
"0.5902561",
"0.5895458"
] | 0.6875919 | 1 |
GET /tipocuenta/1 GET /tipocuenta/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @tipocliente }\n end\n end",
"def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipomedalla }\n end\n end",
"def show\n @tipp = Tipp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipp }\n end\n end",
"def index\n @tipocuenta = Tipocuentum.all\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tip = Tip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def show\n @articulo = Articulo.find(params[:id])\n @noticias = Articulo.where(\"tipo = 'noticia'\").order(\"created_at desc\")\n @title = @articulo.titulo\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articulo }\n end\n end",
"def index\n tips = Tip.all\n json_response(tips)\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end",
"def show\n @telefononegocio = Telefononegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @telefononegocio }\n end\n end",
"def index\n @itemtipos = Itemtipo.all\n\n render json: @itemtipos\n end",
"def index\n @tiposervicos = Tiposervico.all\n end",
"def show\n @noto = Noto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @noto }\n end\n end",
"def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end",
"def show\n json_response(@tip)\n end",
"def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end",
"def show\n @tipo_atendimento = TipoAtendimento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_atendimento }\n end\n end",
"def index\n @tipos_contatos = TiposContato.all\n end",
"def index\n @tipovestuarios = Tipovestuario.all\n end",
"def index\n @tipos = Tipo.all\n end",
"def index\n @tipos = Tipo.all\n end",
"def index\n @tipoplatos = Tipoplato.all\n end",
"def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end",
"def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def show\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def show\n @trnodo = Trnodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trnodo }\n end\n end",
"def show\n @tarefa = Tarefa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tarefa }\n end\n end",
"def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @tiposcontrato = Tiposcontrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tiposcontrato }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def index\n @tipoveiculos = Tipoveiculo.all\n end",
"def show\n @torso = Torso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torso }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def new\n @tip_so = TipSo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end",
"def show\n @trabalho = Trabalho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trabalho }\n end\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @peso }\n end\n end",
"def show\n @etnia = Etnia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @etnia }\n end\n end",
"def show\n @tipo_tel = TipoTel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_tel }\n end\n end",
"def index\n @tiposveiculos = Tiposveiculo.all\n end",
"def show\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contato_produto }\n end\n end",
"def new\n @tipomedalla = Tipomedalla.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipomedalla }\n end\n end",
"def show\n @torneo = Torneo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torneo }\n end\n end",
"def show\n @tipo_product = TipoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_product }\n end\n end",
"def index\n @tipoclientes = Tipocliente.paginate(:page => params[:numero_hoja], :per_page => 18)\n if params[:numero_hoja].nil?\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @tipoclientes }\n end\n else\n respond_to do |format|\n format.html { render :layout => \"application_paginate\"}# index.html.erb\n #format.json { render json: @impuestos }\n end\n end\n end",
"def index\n @tipics = Tipic.all\n end",
"def set_tipos_contato\n @tipos_contato = TiposContato.find(params[:id])\n end",
"def show\n @tipo_convenio = TipoConvenio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_convenio }\n end\n end",
"def show\n @puestos_entidad = PuestosEntidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puestos_entidad }\n end\n end",
"def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end",
"def show\n @troop = Troop.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @troop }\n end\n end",
"def index\n @tipotermos = Tipotermo.all\n end",
"def show\n @line = ReportingForms::Tanimoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\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 show\n @tetramod = Tetramod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tetramod }\n end\n end",
"def show\n @tip = Tip.find(params[:id])\n end",
"def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produto }\n end\n end",
"def index\n @solicitacao_tipos = SolicitacaoTipo.all\n end",
"def tipospolen\n\n @info_polens = InfoPolen.collection.aggregate(\n { \"$group\" => { \"_id\" => \"$TIPOS_POLINICOS\" } },\n { \"$sort\" => {\"_id\" => 1} }\n )\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end",
"def show\n @tipo_item = TipoItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_item }\n end\n end",
"def index\n @tipos_datos = TiposDato.all\n end",
"def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end",
"def set_tipoplato\n @tipoplato = Tipoplato.find(params[:id])\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def show\n @titulacionesdoctipo = Titulacionesdoctipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @titulacionesdoctipo }\n end\n end",
"def show\n @tipo_actividad = TipoActividad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_actividad }\n end\n end",
"def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end",
"def index\n @tipos_personas = TipoPersona.all\n end",
"def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end",
"def show\n @core_nota = Core::Nota.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @core_nota }\n end\n end",
"def show\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @denuncia_tipo }\n end\n end",
"def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end",
"def show\n @lista_contato = ListaContato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lista_contato }\n end\n end",
"def show\n @tema = Tema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tema }\n end\n end",
"def show\n @tipos_pagamento = TiposPagamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipos_pagamento }\n end\n end",
"def show\n @patrocinio = Patrocinio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patrocinio }\n end\n end",
"def show\n @odontologia1 = Odontologia1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @odontologia1 }\n end\n end",
"def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def show\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @oferta }\n end\n end",
"def index\n @tipomovifinanceiros = Tipomovifinanceiro.all\n end",
"def index\n @pontos = Ponto.all\n end",
"def show\n @apunte = Apunte.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apunte }\n end\n end",
"def show\n @datoscontacto = Datoscontacto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datoscontacto }\n end\n end",
"def show\n @utente = Utente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @utente }\n end\n end",
"def show\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solicitud_servicio }\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 show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end",
"def show\n @telefone = Telefone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @telefone }\n end\n end"
] | [
"0.7264182",
"0.71376866",
"0.7094846",
"0.70151764",
"0.68708414",
"0.68690723",
"0.68690723",
"0.68183523",
"0.6795829",
"0.6777179",
"0.6712439",
"0.67072284",
"0.6665166",
"0.6611626",
"0.6582963",
"0.6549734",
"0.6534824",
"0.65198547",
"0.65116423",
"0.64699715",
"0.646284",
"0.6460877",
"0.64590216",
"0.64590216",
"0.645705",
"0.64569694",
"0.64567345",
"0.64534557",
"0.64317435",
"0.6427045",
"0.64227057",
"0.63838625",
"0.63838625",
"0.63663495",
"0.6358873",
"0.6356952",
"0.6356792",
"0.63501614",
"0.63501614",
"0.63493776",
"0.6341003",
"0.63318694",
"0.6317871",
"0.6310749",
"0.62977666",
"0.6291704",
"0.6291465",
"0.62819874",
"0.62705415",
"0.6268129",
"0.626623",
"0.6260733",
"0.62506485",
"0.62410164",
"0.6229616",
"0.622932",
"0.61930186",
"0.6192416",
"0.6191069",
"0.61801434",
"0.61798143",
"0.61781937",
"0.6177893",
"0.61746275",
"0.6173657",
"0.61687595",
"0.6158268",
"0.6155169",
"0.6148921",
"0.6140232",
"0.6134699",
"0.6133883",
"0.61327064",
"0.61327064",
"0.6131768",
"0.61189437",
"0.6116551",
"0.61108965",
"0.61001307",
"0.60982126",
"0.6097142",
"0.6096005",
"0.60930324",
"0.6090808",
"0.60863835",
"0.6078543",
"0.6077594",
"0.6074176",
"0.6072336",
"0.60688573",
"0.60688394",
"0.60665125",
"0.606604",
"0.60529834",
"0.60525453",
"0.60498726",
"0.604913",
"0.60441476",
"0.6044109",
"0.60332155",
"0.60328376"
] | 0.0 | -1 |
POST /tipocuenta POST /tipocuenta.json | def create
@tipocuentum = Tipocuentum.new(tipocuentum_params)
respond_to do |format|
if @tipocuentum.save
format.html { redirect_to @tipocuentum, notice: 'Tipocuentum was successfully created.' }
format.json { render :show, status: :created, location: @tipocuentum }
else
format.html { render :new }
format.json { render json: @tipocuentum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @tipos_contato = TiposContato.new(tipos_contato_params)\n\n respond_to do |format|\n if @tipos_contato.save\n format.html { redirect_to @tipos_contato, notice: 'Tipos contato was successfully created.' }\n format.json { render :show, status: :created, location: @tipos_contato }\n else\n format.html { render :new }\n format.json { render json: @tipos_contato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipovestuario = Tipovestuario.new(tipovestuario_params)\n\n respond_to do |format|\n if @tipovestuario.save\n format.html { redirect_to @tipovestuario, notice: 'Tipovestuario was successfully created.' }\n format.json { render :show, status: :created, location: @tipovestuario }\n else\n format.html { render :new }\n format.json { render json: @tipovestuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tiposervico = Tiposervico.new(tiposervico_params)\n\n respond_to do |format|\n if @tiposervico.save\n format.html { redirect_to @tiposervico, notice: 'Tiposervico was successfully created.' }\n format.json { render :show, status: :created, location: @tiposervico }\n else\n format.html { render :new }\n format.json { render json: @tiposervico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipoplato = Tipoplato.new(tipoplato_params)\n\n respond_to do |format|\n if @tipoplato.save\n format.html { redirect_to @tipoplato, notice: 'Tipoplato was successfully created.' }\n format.json { render :show, status: :created, location: @tipoplato }\n else\n format.html { render :new }\n format.json { render json: @tipoplato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipocliente = Tipocliente.new(params[:tipocliente])\n\n respond_to do |format|\n if @tipocliente.save\n format.html { redirect_to @tipocliente, :notice => 'Tipocliente was successfully created.' }\n format.json { render json: @tipocliente, status: :created }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @tipocliente.errors }\n end\n end\n end",
"def create\n @tipos_dato = TiposDato.new(tipos_dato_params)\n\n respond_to do |format|\n if @tipos_dato.save\n format.html { redirect_to @tipos_dato, notice: 'Tipos dato was successfully created.' }\n format.json { render :show, status: :created, location: @tipos_dato }\n else\n format.html { render :new }\n format.json { render json: @tipos_dato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipomedalla = Tipomedalla.new(params[:tipomedalla])\n\n respond_to do |format|\n if @tipomedalla.save\n format.html { redirect_to @tipomedalla, notice: 'Tipomedalla was successfully created.' }\n format.json { render json: @tipomedalla, status: :created, location: @tipomedalla }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipomedalla.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipotermo = Tipotermo.new(tipotermo_params)\n\n respond_to do |format|\n if @tipotermo.save\n format.html { redirect_to @tipotermo, notice: 'Tipotermo was successfully created.' }\n format.json { render :show, status: :created, location: @tipotermo }\n else\n format.html { render :new }\n format.json { render json: @tipotermo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tiposveiculo = Tiposveiculo.new(tiposveiculo_params)\n\n respond_to do |format|\n if @tiposveiculo.save\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo criado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipoveiculo = Tipoveiculo.new(tipoveiculo_params)\n\n respond_to do |format|\n if @tipoveiculo.save\n format.html { redirect_to @tipoveiculo, notice: 'Tipoveiculo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipoveiculo }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipoveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tiponovedad = Tiponovedad.new(tiponovedad_params)\n\n respond_to do |format|\n if @tiponovedad.save\n format.html { redirect_to @tiponovedad, notice: 'Tiponovedad was successfully created.' }\n format.json { render :show, status: :created, location: @tiponovedad }\n else\n format.html { render :new }\n format.json { render json: @tiponovedad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipos_encuestum = TiposEncuestum.new(tipos_encuestum_params)\n\n respond_to do |format|\n if @tipos_encuestum.save\n format.html { redirect_to @tipos_encuestum, notice: 'Tipos encuestum was successfully created.' }\n format.json { render :show, status: :created, location: @tipos_encuestum }\n else\n format.html { render :new }\n format.json { render json: @tipos_encuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully created.' }\n format.json { render :json => @tecnico, :status => :created, :location => @tecnico }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tip_so = TipSo.new(params[:tip_so])\n\n respond_to do |format|\n if @tip_so.save\n format.html { redirect_to @tip_so, notice: 'Tip so was successfully created.' }\n format.json { render json: @tip_so, status: :created, location: @tip_so }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tip_so.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipomovifinanceiro = Tipomovifinanceiro.new(tipomovifinanceiro_params)\n\n respond_to do |format|\n if @tipomovifinanceiro.save\n format.html { redirect_to @tipomovifinanceiro, notice: 'Tipomovifinanceiro was successfully created.' }\n format.json { render :show, status: :created, location: @tipomovifinanceiro }\n else\n format.html { render :new }\n format.json { render json: @tipomovifinanceiro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipus_indicador = TipusIndicador.new(tipus_indicador_params)\n\n respond_to do |format|\n if @tipus_indicador.save\n format.html { redirect_to @tipus_indicador, notice: 'Tipus indicador was successfully created.' }\n format.json { render :show, status: :created, location: @tipus_indicador }\n else\n format.html { render :new }\n format.json { render json: @tipus_indicador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_aposta = TipoAposta.new(tipo_aposta_params)\n\n respond_to do |format|\n if @tipo_aposta.save\n format.html { redirect_to @tipo_aposta, notice: 'Tipo aposta was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_aposta }\n else\n format.html { render :new }\n format.json { render json: @tipo_aposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n #@tipos_usuario = TiposUsuario.new(tipos_usuario_params)\r\n\r\n respond_to do |format|\r\n if @tipos_usuario.save\r\n format.html { redirect_to @tipos_usuario, notice: 'Se añadió un nombre de tipo de usuario correctamente.' }\r\n format.json { render :show, status: :created, location: @tipos_usuario }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @tipos_usuario.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def tipocuentum_params\n params.require(:tipocuentum).permit(:nombretipocuenta, :fechaingresotipocuenta)\n end",
"def create\n @pocetna = Pocetna.new(pocetna_params)\n\n respond_to do |format|\n if @pocetna.save\n format.html { redirect_to @pocetna, notice: \"Pocetna was successfully created.\" }\n format.json { render :show, status: :created, location: @pocetna }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @pocetna.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Tecnico criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tapioca = Tapioca.new(tapioca_params)\n\n respond_to do |format|\n if @tapioca.save\n format.html { redirect_to @tapioca, notice: 'Tapioca was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tapioca }\n else\n format.html { render action: 'new' }\n format.json { render json: @tapioca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tiponovedad_params\n params.require(:tiponovedad).permit(:nombre)\n end",
"def create\n @telefononegocio = Telefononegocio.new(params[:telefononegocio])\n\n respond_to do |format|\n if @telefononegocio.save\n format.html { redirect_to @telefononegocio, notice: 'Telefononegocio was successfully created.' }\n format.json { render json: @telefononegocio, status: :created, location: @telefononegocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @telefononegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @taco = Taco.new(taco_params)\n\n respond_to do |format|\n if @taco.save\n format.html { redirect_to @taco, notice: 'Taco was successfully created.' }\n format.json { render :show, status: :created, location: @taco }\n else\n format.html { render :new }\n format.json { render json: @taco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n tip = Tip.new(tips_params)\n tip.created_by_id = @current_user.id\n \n if tip.save\n json_response(tip)\n else\n json_response({ message: tip.errors }, :unprocessable_entity)\n end\n end",
"def create\n @tecido = Tecido.new(tecido_params)\n\n respond_to do |format|\n if @tecido.save\n format.html { redirect_to @tecido, notice: 'Tecido was successfully created.' }\n format.json { render :show, status: :created, location: @tecido }\n else\n format.html { render :new }\n format.json { render json: @tecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipopago_params\n params.require(:tipopago).permit(:nombre, :monto)\n end",
"def create\n @tiposcontrato = Tiposcontrato.new(params[:tiposcontrato])\n\n respond_to do |format|\n if @tiposcontrato.save\n flash[:notice] = 'Tiposcontrato was successfully created.'\n format.html { redirect_to(@tiposcontrato) }\n format.xml { render :xml => @tiposcontrato, :status => :created, :location => @tiposcontrato }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tiposcontrato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ponto = Ponto.new(ponto_params)\n @ponto.user = current_user\n\n respond_to do |format|\n if @ponto.save\n format.html { redirect_to @ponto, notice: 'Ponto was successfully created.' }\n format.json { render :show, status: :created, location: @ponto }\n else\n format.html { render :new }\n format.json { render json: @ponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @etnia = Etnia.new(params[:etnia])\n\n respond_to do |format|\n if @etnia.save\n format.html { redirect_to @etnia, notice: 'Etnia was successfully created.' }\n format.json { render json: @etnia, status: :created, location: @etnia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @etnia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tangazo = Tangazo.new(tangazo_params)\n\n respond_to do |format|\n if @tangazo.save\n format.html { redirect_to @tangazo, notice: 'Tangazo was successfully created.' }\n format.json { render :show, status: :created, location: @tangazo }\n else\n format.html { render :new }\n format.json { render json: @tangazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n\t\t@tienda_cliente = @cliente.tiendas_clientes.build(tienda_cliente_params)\n\n respond_to do |format|\n if @tienda_cliente.save\n format.html { redirect_to @tienda_cliente, notice: 'La tienda se creó exitosamente.' }\n format.json { render :show, status: :created, location: @tienda_cliente }\n else\n format.html { render :new }\n format.json { render json: @tienda_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tecnico = Tecnico.new(params[:tecnico])\n @tecnico.user = current_user\n\n respond_to do |format|\n if @tecnico.save\n format.html { redirect_to @tecnico, notice: 'Técnico foi criado com sucesso.' }\n format.json { render json: @tecnico, status: :created, location: @tecnico }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tenni = Tenni.new(params[:tenni])\n\n respond_to do |format|\n if @tenni.save\n format.html { redirect_to @tenni, notice: 'Tenni was successfully created.' }\n format.json { render json: @tenni, status: :created, location: @tenni }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tenni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tip = Tip.new(params[:tip])\n\n respond_to do |format|\n if @tip.save\n format.html { redirect_to @tip, notice: 'Tip was successfully created.' }\n format.json { render json: @tip, status: :created, location: @tip }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tiempo = Tiempo.new(tiempo_params)\n\n respond_to do |format|\n if @tiempo.save\n format.html { redirect_to @tiempo, notice: 'Tiempo was successfully created.' }\n format.json { render :show, status: :created, location: @tiempo }\n else\n format.html { render :new }\n format.json { render json: @tiempo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ponto = Ponto.new(ponto_params)\n\n respond_to do |format|\n if @ponto.save\n format.html { redirect_to @ponto, notice: 'Ponto foi Adicionado.' }\n format.json { render :show, status: :created, location: @ponto }\n else\n format.html { render :new }\n format.json { render json: @ponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tip = Tip.new(tip_params)\n respond_to do |format|\n if @tip.save\n format.html { redirect_to @tip, notice: 'Tip was successfully created.' }\n format.json { render :show, status: :created, location: @tip }\n else\n format.html { render :new }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipos_contato_params\n params.require(:tipos_contato).permit(:descricao)\n end",
"def nota_tecnica_params\n params.require(:nota_tecnica).permit(:data_nota, :numero_nota, :numero_processo, :status, :nome_do_analista, :area)\n end",
"def tipoplato_params\n params.require(:tipoplato).permit(:name, :description)\n end",
"def create\n @cuenta = Cuenta.new(cuenta_params)\n\n respond_to do |format|\n if @cuenta.save\n format.html { redirect_to @cuenta, notice: 'Cuenta was successfully created.' }\n format.json { render :show, status: :created, location: @cuenta }\n else\n format.html { render :new }\n format.json { render json: @cuenta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipic = Tipic.new(tipic_params)\n\n respond_to do |format|\n if @tipic.save\n format.html { redirect_to @tipic, notice: 'Tipic was successfully created.' }\n format.json { render :show, status: :created, location: @tipic }\n else\n format.html { render :new }\n format.json { render json: @tipic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipomaquinat = Tipomaquinat.new(tipomaquinat_params)\n #@tipomaquinat = Tipomaquinat.new\n #@tipomaquinat.id=401\n #@tipomaquinat.tipomaquina = \"KLK\" #params.require(:tipomaquinat).permit(:tipomaquina)\n #@tipomaquinat.descripcion = \"YOOOO\" #params.require(:tipomaquinat).permit(:descripcion)\n #descripcion\n\n # params.require(:tipomaquinat).permit(:tipomaquina, :descripcion,\n\n respond_to do |format|\n if @tipomaquinat.save\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully created.' }\n format.json { render :show, status: :created, location: @tipomaquinat }\n else\n format.html { render :new }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @treino = Treino.new(treino_params)\n\n respond_to do |format|\n if @treino.save\n format.html { redirect_to @treino, notice: 'Treino was successfully created.' }\n format.json { render :show, status: :created, location: @treino }\n else\n format.html { render :new }\n format.json { render json: @treino.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tiposveiculo_params\n params.require(:tiposveiculo).permit(:nome)\n end",
"def create\n @tipo_entidade = TipoEntidade.new(tipo_entidade_params)\n\n respond_to do |format|\n if @tipo_entidade.save\n format.html { redirect_to @tipo_entidade, notice: 'Tipo entidade was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_entidade }\n else\n format.html { render :new }\n format.json { render json: @tipo_entidade.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trnodo = Trnodo.new(params[:trnodo])\n\n respond_to do |format|\n if @trnodo.save\n format.html { redirect_to @trnodo, notice: 'Trnodo was successfully created.' }\n format.json { render json: @trnodo, status: :created, location: @trnodo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trnodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipovestuario_params\n params.require(:tipovestuario).permit(:nombre, :descripcion)\n end",
"def create\n @os_tarefa = OsTarefa.new(os_tarefa_params)\n\n respond_to do |format|\n if @os_tarefa.save\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 criado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_tarefa, notice: 'A Tarefa foi criado(a)' }\n format.json { render :show, status: :created, location: @os_tarefa }\n end\n else\n format.html { render :new }\n format.json { render json: @os_tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @empresa = Empresa.find(params[:empresa_id])\n\n @tipo_de_imposto = TipoDeImposto.new(tipo_de_imposto_params)\n @tipo_de_imposto.empresa_id = @empresa.id\n\n respond_to do |format|\n if @tipo_de_imposto.save\n format.html { redirect_to @empresa, notice: 'Tipo de imposto adicionado com sucesso.' }\n format.json { render :show, status: :created, location: @tipo_de_imposto }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_imposto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pagto_taxa = PagtoTaxa.new(pagto_taxa_params)\n\n respond_to do |format|\n if @pagto_taxa.save\n format.html { redirect_to @pagto_taxa, notice: 'Pagto taxa was successfully created.' }\n format.json { render action: 'show', status: :created, location: @pagto_taxa }\n else\n format.html { render action: 'new' }\n format.json { render json: @pagto_taxa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @intranet_financeiro_tipos_cobanca = Intranet::FinanceiroTiposCobanca.new(intranet_financeiro_tipos_cobanca_params)\n\n respond_to do |format|\n if @intranet_financeiro_tipos_cobanca.save\n format.html { redirect_to @intranet_financeiro_tipos_cobanca, notice: \"Financeiro tipos cobanca was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_financeiro_tipos_cobanca }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_financeiro_tipos_cobanca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @noto = Noto.new(params[:noto])\n\n respond_to do |format|\n if @noto.save\n format.html { redirect_to @noto, :notice => 'Noto was successfully created.' }\n format.json { render :json => @noto, :status => :created, :location => @noto }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @noto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @venta = Venta.new(venta_params)\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render :show, status: :created, location: @venta }\n else\n format.html { render :new }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n log(\"Se ha creado la nomina #{@lt}\", 0)\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: 'La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trabajo = Trabajo.new(trabajo_params)\n @cliente = Cliente.find(params[:cliente_id])\n @trabajo.cliente = @cliente\n\n respond_to do |format|\n if @trabajo.save\n TrabajoMailer.detalle_trabajo(current_user, @cliente, @trabajo).deliver\n\n format.html { redirect_to cliente_path(@cliente), notice: 'Trabajo was successfully created.' }\n format.json { render :show, status: :created, location: @trabajo }\n else\n format.html { render :new }\n format.json { render json: @trabajo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @titulacionesdoctipo = Titulacionesdoctipo.new(params[:titulacionesdoctipo])\n\n respond_to do |format|\n if @titulacionesdoctipo.save\n format.html { redirect_to(@titulacionesdoctipo, :notice => 'Titulacionesdoctipo was successfully created.') }\n format.xml { render :xml => @titulacionesdoctipo, :status => :created, :location => @titulacionesdoctipo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @titulacionesdoctipo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @venta = Venta.new(params[:venta])\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render json: @venta, status: :created, location: @venta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tareas = Tarea.all\n @tareapositivas = Tarea.where(listo: true)\n @tarea = Tarea.new(tarea_params)\n\n respond_to do |format|\n if @tarea.save\n format.html { redirect_to @tarea, notice: 'Tarea was successfully created.' }\n format.json { render :show, status: :created, location: @tarea }\n else\n format.html { render :new }\n format.json { render json: @tarea.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ponto = Ponto.new(params[:ponto])\n @orgao = @lotacao.orgao\n @ponto.usuario = current_user\n respond_to do |format|\n if @ponto.save\n format.html { redirect_to(pessoa_funcionario_lotacao_pontos_path(@pessoa,@funcionario,@lotacao), :notice => 'Ponto cadastrado com sucesso.') }\n format.xml { render :xml => @ponto, :status => :created, :location => @ponto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ponto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_atendimento = TipoAtendimento.new(params[:tipo_atendimento])\n\n respond_to do |format|\n if @tipo_atendimento.save\n format.html { redirect_to @tipo_atendimento, notice: \"Tipo de atendimento: #{@tipo_atendimento.descricao}, foi criado com sucesso,\" }\n format.json { render json: @tipo_atendimento, status: :created, location: @tipo_atendimento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_atendimento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tarefa = Tarefa.new(params[:tarefa])\n\n respond_to do |format|\n if @tarefa.save\n format.html { redirect_to @tarefa, notice: 'Tarefa was successfully created.' }\n format.json { render json: @tarefa, status: :created, location: @tarefa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipocosto = Tipocosto.new(tipocosto_params)\n\n respond_to do |format|\n if @tipocosto.save\n format.html { redirect_to @tipocosto, notice: 'Tipocosto was successfully created.' }\n format.json { render :show, status: :created, location: @tipocosto }\n else\n format.html { render :new }\n format.json { render json: @tipocosto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipotermo_params\n params.require(:tipotermo).permit(:nome_tipotermo, :desc_tipotermo)\n end",
"def create\n @tipo_de_servicio = TipoDeServicio.new(tipo_de_servicio_params)\n\n respond_to do |format|\n if @tipo_de_servicio.save\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_de_servicio }\n else\n format.html { render :new }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pto = Pto.new(params[:pto])\n\n respond_to do |format|\n if @pto.save\n format.html { redirect_to \"/thanks.html\", notice: 'Pto was successfully created.' }\n format.json { render json: @pto, status: :created, location: @pto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @toko = Toko.new(toko_params)\n @toko.user = current_user\n\n respond_to do |format|\n if @toko.save\n format.html { redirect_to '/finish', notice: 'Toko telah dibuat.' }\n format.json { render :show, status: :created, location: @toko }\n else\n format.html { render :new }\n format.json { render json: @toko.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @servico_pacote = Servico::Pacote.new(servico_pacote_params)\n\n respond_to do |format|\n if @servico_pacote.save\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully created.' }\n format.json { render action: 'show', status: :created, location: @servico_pacote }\n else\n format.html { render action: 'new' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipocambio = Tipocambio.new(tipocambio_params)\n\n respond_to do |format|\n if @tipocambio.save\n format.html { redirect_to @tipocambio, notice: 'Tipocambio was successfully created.' }\n format.json { render :show, status: :created, location: @tipocambio }\n else\n format.html { render :new }\n format.json { render json: @tipocambio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tiposervico_params\n params.require(:tiposervico).permit(:descricao)\n end",
"def create\n @tatoo = Tatoo.new(tatoo_params)\n\n respond_to do |format|\n if @tatoo.save\n format.html { redirect_to @tatoo, notice: 'Tatoo was successfully created.' }\n format.json { render :show, status: :created, location: @tatoo }\n else\n format.html { render :new }\n format.json { render json: @tatoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ponto_params\n params.require(:ponto).permit(:data, :entrada, :saida)\n end",
"def create\n @tipoapreensao = Tipoapreensao.new(tipoapreensao_params)\n\n respond_to do |format|\n if @tipoapreensao.save\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipoapreensao }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paciente = Paciente.new(params[:paciente])\n\n paciente = @paciente\n respond_to do |format|\n if @paciente.save\n\n enviar_correo_nuevo_paciente paciente\n\n format.html { redirect_to @paciente, notice: 'Paciente was successfully created.' }\n format.json { render json: @paciente, status: :created, location: @paciente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n\n\n\n end",
"def create\n @titulacao = Titulacao.new(titulacao_params)\n\n respond_to do |format|\n if @titulacao.save\n format.html { redirect_to titulacaos_path, notice: 'Titulo criado com successo.' }\n format.json { render :index, status: :created, location: titulacaos_path }\n else\n format.html { render :new }\n format.json { render json: @titulacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tipos_usuario_params\r\n params.require(:tipos_usuario).permit(:tipo)\r\n end",
"def create\n @telefone_cliente = TelefoneCliente.new(telefone_cliente_params)\n\n respond_to do |format|\n if @telefone_cliente.save\n format.html { redirect_to @telefone_cliente, notice: 'Telefone cliente was successfully created.' }\n format.json { render :show, status: :created, location: @telefone_cliente }\n else\n format.html { render :new }\n format.json { render json: @telefone_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tempografico = Tempografico.new(tempografico_params)\n\n respond_to do |format|\n if @tempografico.save\n format.html { redirect_to @tempografico, notice: 'Tempografico was successfully created.' }\n format.json { render :show, status: :created, location: @tempografico }\n else\n format.html { render :new }\n format.json { render json: @tempografico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tienda_cliente_params\n params.require(:tienda_cliente).permit(:nombre, :direccion, :telefono)\n end",
"def tarefa_params\n params.require(:tarefa).permit(:missao_id, :usuario_curso_id, :nome, :descricao)\n end",
"def create\n @nota_trab = NotaTrab.new(nota_trab_params)\n\n respond_to do |format|\n if @nota_trab.save\n format.html { redirect_to @nota_trab, notice: 'Nota trab was successfully created.' }\n format.json { render :show, status: :created, location: @nota_trab }\n else\n format.html { render :new }\n format.json { render json: @nota_trab.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @troca_produto = TrocaProduto.new(troca_produto_params)\n\n respond_to do |format|\n if @troca_produto.save\n format.html { redirect_to @troca_produto, notice: \"Troca produto was successfully created.\" }\n format.json { render :show, status: :created, location: @troca_produto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @troca_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Tipo\n @tipo = Tipo.new(tipo_params)\n\n\n respond_to do |format|\n if @tipo.save\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> La nómina fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @tipo }\n else\n format.html { render :new }\n format.json { render json: @tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @toto = Toto.new(toto_params)\n\n respond_to do |format|\n if @toto.save\n format.html { redirect_to @toto, notice: 'Toto was successfully created.' }\n format.json { render :show, status: :created, location: @toto }\n else\n format.html { render :new }\n format.json { render json: @toto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipos_pagamento = TiposPagamento.new(params[:tipos_pagamento])\n\n respond_to do |format|\n if @tipos_pagamento.save\n flash[:notice] = 'TiposPagamento was successfully created.'\n format.html { redirect_to(@tipos_pagamento) }\n format.xml { render :xml => @tipos_pagamento, :status => :created, :location => @tipos_pagamento }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tipos_pagamento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @nota_aluno = NotaAluno.new(nota_aluno_params)\n\n respond_to do |format|\n if @nota_aluno.save\n format.html { redirect_to @nota_aluno, notice: 'Nota aluno was successfully created.' }\n format.json { render :show, status: :created, location: @nota_aluno }\n else\n format.html { render :new }\n format.json { render json: @nota_aluno.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipo_orden = TipoOrden.new(tipo_orden_params)\n\n respond_to do |format|\n if @tipo_orden.save\n format.html { redirect_to @tipo_orden, notice: 'Tipo orden was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_orden }\n else\n format.html { render :new }\n format.json { render json: @tipo_orden.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objeto = Cita.new(cita_params)\n\n respond_to do |format|\n if @objeto.save\n format.html { redirect_to @objeto, notice: \"Cita was successfully created.\" }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ponte = Ponte.new(ponte_params)\n\n respond_to do |format|\n if @ponte.save\n format.html { redirect_to pontes_url, notice: 'Ponte criada com sucesso.' }\n format.json { render :show, status: :created, location: @ponte }\n else\n format.html { render :new }\n format.json { render json: @ponte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @denuncia_tipo = DenunciaTipo.new(params[:denuncia_tipo])\n\n respond_to do |format|\n if @denuncia_tipo.save\n format.html { redirect_to @denuncia_tipo, notice: 'Denuncia tipo was successfully created.' }\n format.json { render json: @denuncia_tipo, status: :created, location: @denuncia_tipo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @denuncia_tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @asiento = Asiento.new(params[:asiento])\n\n respond_to do |format|\n if @asiento.save\n format.html { redirect_to @asiento, :notice => 'El apunte fue creado.' }\n format.json { render :json => @asiento, :status => :created, :location => @asiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @torso = Torso.new(params[:torso])\n\n respond_to do |format|\n if @torso.save\n format.html { redirect_to @torso, notice: 'Torso was successfully created.' }\n format.json { render json: @torso, status: :created, location: @torso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @torso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trip_todo = TripTodo.new(trip_todo_params)\n\n respond_to do |format|\n if @trip_todo.save\n format.html { redirect_to @trip_todo, notice: 'Trip todo was successfully created.' }\n format.json { render :show, status: :created, location: @trip_todo }\n else\n format.html { render :new }\n format.json { render json: @trip_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trabajo_params\n params.require(:trabajo).permit(:nombre, :precio)\n end",
"def create\r\n session[:empresa_id] = current_empressa.try(:empresa_id)\r\n \r\n @oportunidade = Oportunidade.new(oportunidade_params)\r\n \r\n respond_to do |format|\r\n if @oportunidade.save\r\n ahoy.track \"Oportunidade Criada\", {language: \"Ruby\", curso: @oportunidade.curso, created_at: @oportunidade.created_at}\r\n format.html { redirect_to oportunidades_path(@oportunidade, empresa_id: @oportunidade.empresa_id), notice: 'Oportunidade criada com sucesso.' }\r\n format.json { render oportunidades_path, status: :created, location: @oportunidade }\r\n else\r\n session[:pidioma][email protected]\r\n session[:ptipo][email protected]\r\n format.html { render :new, locals: { pidioma: @oportunidade.pidioma, ptipo: @oportunidade.ptipo}}\r\n format.json { render json: @oportunidade.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @todoroute = Todoroute.new(todoroute_params)\n\n respond_to do |format|\n if @todoroute.save\n format.html { redirect_to @todoroute, notice: 'Todoroute was successfully created.' }\n format.json { render :show, status: :created, location: @todoroute }\n else\n format.html { render :new }\n format.json { render json: @todoroute.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7226958",
"0.7016861",
"0.69697654",
"0.6966347",
"0.6885372",
"0.68441194",
"0.6790598",
"0.67653495",
"0.6759658",
"0.6750996",
"0.6744425",
"0.67255884",
"0.6723875",
"0.67209226",
"0.66504896",
"0.66443026",
"0.6604963",
"0.65778124",
"0.65702933",
"0.6559782",
"0.65570176",
"0.6556005",
"0.6533457",
"0.6532735",
"0.65274733",
"0.65171814",
"0.64809185",
"0.6466934",
"0.6457916",
"0.64466816",
"0.6420705",
"0.6419259",
"0.6390324",
"0.638704",
"0.6379439",
"0.63790584",
"0.6373659",
"0.6365594",
"0.63645965",
"0.6357864",
"0.63484967",
"0.6309728",
"0.6309308",
"0.6305483",
"0.6283822",
"0.62824214",
"0.62745756",
"0.62721074",
"0.62709075",
"0.62644243",
"0.62431395",
"0.6241748",
"0.62338376",
"0.622759",
"0.62223935",
"0.62064993",
"0.62063295",
"0.6204298",
"0.61937255",
"0.6191129",
"0.6176723",
"0.61701465",
"0.61669505",
"0.6164021",
"0.61530715",
"0.6150317",
"0.61495185",
"0.6138419",
"0.61361337",
"0.61321694",
"0.61317956",
"0.61309075",
"0.6127665",
"0.6125292",
"0.6121196",
"0.6112736",
"0.6105711",
"0.6100707",
"0.6099475",
"0.6095918",
"0.6093866",
"0.6093209",
"0.6091411",
"0.60907155",
"0.60896796",
"0.60884833",
"0.6083999",
"0.60770124",
"0.6070032",
"0.6067572",
"0.60670173",
"0.6066674",
"0.6061251",
"0.60542613",
"0.6053988",
"0.6052917",
"0.6051788",
"0.6050866",
"0.60472363",
"0.60470825"
] | 0.6943472 | 4 |
PATCH/PUT /tipocuenta/1 PATCH/PUT /tipocuenta/1.json | def update
respond_to do |format|
if @tipocuentum.update(tipocuentum_params)
format.html { redirect_to @tipocuentum, notice: 'Tipocuentum was successfully updated.' }
format.json { render :show, status: :ok, location: @tipocuentum }
else
format.html { render :edit }
format.json { render json: @tipocuentum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @tipos_contato.update(tipos_contato_params)\n format.html { redirect_to @tipos_contato, notice: 'Tipos contato was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipos_contato }\n else\n format.html { render :edit }\n format.json { render json: @tipos_contato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiposervico.update(tiposervico_params)\n format.html { redirect_to @tiposervico, notice: 'Tiposervico was successfully updated.' }\n format.json { render :show, status: :ok, location: @tiposervico }\n else\n format.html { render :edit }\n format.json { render json: @tiposervico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoplato.update(tipoplato_params)\n format.html { redirect_to @tipoplato, notice: 'Tipoplato was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipoplato }\n else\n format.html { render :edit }\n format.json { render json: @tipoplato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n if @tipocliente.update_attributes(params[:tipocliente])\n format.html { redirect_to @tipocliente, :notice => 'Tipocliente was successfully updated.' }\n format.json { render json: @tipocliente }\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @tipocliente.errors }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n if @tip_so.update_attributes(params[:tip_so])\n format.html { redirect_to @tip_so, notice: 'Tip so was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tip_so.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoveiculo.update(tipoveiculo_params)\n format.html { redirect_to @tipoveiculo, notice: 'Tipoveiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoveiculo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n if @tipomedalla.update_attributes(params[:tipomedalla])\n format.html { redirect_to @tipomedalla, notice: 'Tipomedalla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipomedalla.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tapioca.update(tapioca_params)\n format.html { redirect_to @tapioca, notice: 'Tapioca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tapioca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipovestuario.update(tipovestuario_params)\n format.html { redirect_to @tipovestuario, notice: 'Tipovestuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipovestuario }\n else\n format.html { render :edit }\n format.json { render json: @tipovestuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tip = Tip.find(params[:id])\n\n respond_to do |format|\n if @tip.update_attributes(params[:tip])\n format.html { redirect_to @tip, notice: 'Tip was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Tecnico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tip.update!(tip_params)\n format.html { redirect_to @tip, notice: \"#{@tip.name} tip has been updated.\" }\n format.json { render :show, status: :ok, location: @tip }\n else\n format.html { render :edit }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipotermo.update(tipotermo_params)\n format.html { redirect_to @tipotermo, notice: 'Tipotermo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipotermo }\n else\n format.html { render :edit }\n format.json { render json: @tipotermo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipomaquinat.update(tipomaquinat_params)\n format.html { redirect_to @tipomaquinat, notice: 'Tipomaquinat was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipomaquinat }\n else\n format.html { render :edit }\n format.json { render json: @tipomaquinat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipos_dato.update(tipos_dato_params)\n format.html { redirect_to @tipos_dato, notice: 'Tipos dato was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipos_dato }\n else\n format.html { render :edit }\n format.json { render json: @tipos_dato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @telefononegocio = Telefononegocio.find(params[:id])\n\n respond_to do |format|\n if @telefononegocio.update_attributes(params[:telefononegocio])\n format.html { redirect_to @telefononegocio, notice: 'Telefononegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @telefononegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tiposcontrato = Tiposcontrato.find(params[:id])\n\n respond_to do |format|\n if @tiposcontrato.update_attributes(params[:tiposcontrato])\n flash[:notice] = 'Tiposcontrato was successfully updated.'\n format.html { redirect_to(@tiposcontrato) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tiposcontrato.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tip.update(tip_params)\n format.html { redirect_to @tip, notice: 'Tip was successfully updated.' }\n format.json { render :show, status: :ok, location: @tip }\n else\n format.html { render :edit }\n format.json { render json: @tip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipomovifinanceiro.update(tipomovifinanceiro_params)\n format.html { redirect_to @tipomovifinanceiro, notice: 'Tipomovifinanceiro was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipomovifinanceiro }\n else\n format.html { render :edit }\n format.json { render json: @tipomovifinanceiro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @taco.update(taco_params)\n format.html { redirect_to @taco, notice: 'Taco was successfully updated.' }\n format.json { render :show, status: :ok, location: @taco }\n else\n format.html { render :edit }\n format.json { render json: @taco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tip.update(tips_params)\n json_response(@tip)\n end",
"def update\n respond_to do |format|\n if @tatoo.update(tatoo_params)\n format.html { redirect_to tatoos_path, notice: 'Tatoo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tatoo }\n else\n format.html { render :edit }\n format.json { render json: @tatoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tecido.update(tecido_params)\n format.html { redirect_to @tecido, notice: 'Tecido was successfully updated.' }\n format.json { render :show, status: :ok, location: @tecido }\n else\n format.html { render :edit }\n format.json { render json: @tecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n format.html { redirect_to tipos_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n if @tipo_negocio.update_attributes(params[:tipo_negocio])\n format.html { redirect_to @tipo_negocio, notice: 'Tipo negocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipic.update(tipic_params)\n format.html { redirect_to @tipic, notice: 'Tipic was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipic }\n else\n format.html { render :edit }\n format.json { render json: @tipic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topico.update(topico_params)\n format.html { redirect_to set_path, notice: 'Tópico atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_nota = TipoNota.find(params[:id])\n\n respond_to do |format|\n if @tipo_nota.update_attributes(params[:tipo_nota])\n format.html { redirect_to(@tipo_nota, :notice => 'TipoNota was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_nota.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n if @tipo_contrato.update_attributes(params[:tipo_contrato])\n format.html { redirect_to tipo_contratos_path, notice: 'Tipo de contrato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_contrato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @noto = Noto.find(params[:id])\n\n respond_to do |format|\n if @noto.update_attributes(params[:noto])\n format.html { redirect_to @noto, :notice => 'Noto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @noto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pocetna.update(pocetna_params)\n format.html { redirect_to @pocetna, notice: \"Pocetna was successfully updated.\" }\n format.json { render :show, status: :ok, location: @pocetna }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @pocetna.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tecnico = Tecnico.find(params[:id])\n @tecnico.user = current_user\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, notice: 'Técnico foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tecnico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiempo.update(tiempo_params)\n format.html { redirect_to @tiempo, notice: 'Tiempo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tiempo }\n else\n format.html { render :edit }\n format.json { render json: @tiempo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipus_indicador.update(tipus_indicador_params)\n format.html { redirect_to @tipus_indicador, notice: 'Tipus indicador was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipus_indicador }\n else\n format.html { render :edit }\n format.json { render json: @tipus_indicador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_telefone = TipoTelefone.find(params[:id])\n\n respond_to do |format|\n if @tipo_telefone.update_attributes(params[:tipo_telefone])\n flash[:notice] = 'TipoTelefone was successfully updated.'\n format.html { redirect_to(@tipo_telefone) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipo_telefone.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @venta = Venta.find(params[:id])\n\n respond_to do |format|\n if @venta.update_attributes(params[:venta])\n format.html { redirect_to @venta, notice: 'Venta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nota_tecnica.update(nota_tecnica_params)\n format.html { redirect_to @nota_tecnica, notice: 'Nota tecnica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nota_tecnica.errors, status: :unprocessable_entity }\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\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_aposta.update(tipo_aposta_params)\n format.html { redirect_to @tipo_aposta, notice: 'Tipo aposta was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_aposta }\n else\n format.html { render :edit }\n format.json { render json: @tipo_aposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipos_encuestum.update(tipos_encuestum_params)\n format.html { redirect_to @tipos_encuestum, notice: 'Tipos encuestum was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipos_encuestum }\n else\n format.html { render :edit }\n format.json { render json: @tipos_encuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trnodo = Trnodo.find(params[:id])\n\n respond_to do |format|\n if @trnodo.update_attributes(params[:trnodo])\n format.html { redirect_to @trnodo, notice: 'Trnodo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trnodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tarefa = Tarefa.find(params[:id])\n\n respond_to do |format|\n if @tarefa.update_attributes(params[:tarefa])\n format.html { redirect_to @tarefa, notice: 'Tarefa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tienda_cliente.update(tienda_cliente_params)\n format.html { redirect_to @tienda_cliente, notice: 'La tienda se actualizó exitosamente.' }\n format.json { render :show, status: :ok, location: @tienda_cliente }\n else\n format.html { render :edit }\n format.json { render json: @tienda_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipomensaje = Tipomensaje.find(params[:id])\n\n respond_to do |format|\n if @tipomensaje.update_attributes(params[:tipomensaje])\n flash[:notice] = 'Tipomensaje was successfully updated.'\n format.html { redirect_to(@tipomensaje) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipomensaje.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n pai = params[:pai] ? Conta.find_by_id(params[:pai]): nil\n \n respond_to do |format|\n if @conta.update(nome: conta_params[:nome], status: conta_params[:status], pai: pai) \n #format.json { render :show, status: :ok, location: @conta }\n format.json { render json: @conta.to_json, status: :ok }\n else \n format.json { render json: @conta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitacao_tipo.update(solicitacao_tipo_params)\n format.html { redirect_to @solicitacao_tipo, notice: 'Solicitacao tipo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @solicitacao_tipo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tarefa.update(tarefa_params)\n format.html { redirect_to @tarefa, notice: 'Tarefa editada com sucesso.' }\n format.json { render :show, status: :ok, location: @tarefa }\n else\n format.html { render :edit }\n format.json { render json: @tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipp = Tipp.find(params[:id])\n deny_access!('Zugriff verweigert! Es ist verboten die Tipps anderer Spieler zu manipulieren!') if ! current_user.id == @tipp.user_id and ! current_user.is_superuser?\n @tipp.errors.add(:base, 'Bei einem KO Spiel kann nicht auf unentschieden getippt werden!') if @tipp.spiel.ko && @tipp.team_a_result == @tipp.team_b_result\n # deny_access! unless current_user.id == @tipp.user_id and ! current_user.is_superuser?\n \n respond_to do |format|\n if ! @tipp.too_late? && @tipp.errors.empty? && @tipp.update_attributes(params[:tipp])\n format.html { redirect_to @tipp.spiel, notice: 'Tipp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @toto.update(toto_params)\n format.html { redirect_to @toto, notice: 'Toto was successfully updated.' }\n format.json { render :show, status: :ok, location: @toto }\n else\n format.html { render :edit }\n format.json { render json: @toto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @persona = Persona.find(params[:persona_id])\n respond_to do |format|\n if @persona.info_extra_pacientes.update(info_extra_paciente_params)\n format.html { redirect_to @info_extra_paciente, notice: 'Info extra actualizada.' }\n format.json { render :show, status: :ok, location: @info_extra_paciente }\n else\n format.html { render :edit }\n format.json { render json: @info_extra_paciente.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 respond_to do |format|\n if @todoa.update(todoa_params)\n format.html { redirect_to todoas_url }\n format.json { render :show, status: :ok, location: @todoa }\n else\n format.html { render :edit }\n format.json { render json: @todoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tenni = Tenni.find(params[:id])\n\n respond_to do |format|\n if @tenni.update_attributes(params[:tenni])\n format.html { redirect_to @tenni, notice: 'Tenni was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n if @solicitud_servicio.update_attributes(params[:solicitud_servicio])\n format.html { redirect_to @solicitud_servicio, notice: 'Solicitud servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitud_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @telefon = Telefon.find(params[:id])\n @telefon.update_attributes(params[:telefon])\n respond_with(@telefon)\n end",
"def update\n respond_to do |format|\n if @tipo_de_servicio.update(tipo_de_servicio_params)\n format.html { redirect_to @tipo_de_servicio, notice: 'Tipo de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tipo_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @tipos_usuario.update(tipos_usuario_params)\r\n format.html { redirect_to @tipos_usuario, notice: 'La actualización del nombre del tipo de usuario se realizó correctamente.' }\r\n format.json { render :show, status: :ok, location: @tipos_usuario }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @tipos_usuario.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @tb_servicio.update(tb_servicio_params)\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tb_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n if @pto.update_attributes(params[:pto])\n format.html { redirect_to @pto, notice: 'Pto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ponto.update(ponto_params)\n format.html { redirect_to @ponto, notice: 'Ponto was successfully updated.' }\n format.json { render :show, status: :ok, location: @ponto }\n else\n format.html { render :edit }\n format.json { render json: @ponto.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 update\n respond_to do |format|\n if @trip_todo.update(trip_todo_params)\n format.html { redirect_to @trip_todo, notice: 'Trip todo was successfully updated.' }\n format.json { render :show, status: :ok, location: @trip_todo }\n else\n format.html { render :edit }\n format.json { render json: @trip_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @venta.update(venta_params)\n format.html { redirect_to @venta, notice: 'Venta was successfully updated.' }\n format.json { render :show, status: :ok, location: @venta }\n else\n format.html { render :edit }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n if @tipo_usuario.update_attributes(params[:tipo_usuario])\n format.html { redirect_to @tipo_usuario, notice: 'Tipo usuario fue actualizado existosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(cita_params)\n format.html { redirect_to @objeto, notice: \"Cita was successfully updated.\" }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @treinamento_ti.update(treinamento_ti_params)\n format.html { redirect_to @treinamento_ti, notice: 'Treinamento de TI atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @treinamento_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipocosto.update(tipocosto_params)\n format.html { redirect_to @tipocosto, notice: 'Tipocosto was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipocosto }\n else\n format.html { render :edit }\n format.json { render json: @tipocosto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taux_tva = TauxTva.find(params[:id])\n\n respond_to do |format|\n if @taux_tva.update_attributes(params[:taux_tva])\n format.html { redirect_to(@taux_tva, :notice => 'Taux tva was successfully updated.') }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>@taux_tva}}\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @taux_tva.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @treino.update(treino_params)\n format.html { redirect_to @treino, notice: 'Treino was successfully updated.' }\n format.json { render :show, status: :ok, location: @treino }\n else\n format.html { render :edit }\n format.json { render json: @treino.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n if @tipo_pensum.update_attributes(params[:tipo_pensum])\n format.html { redirect_to @tipo_pensum, notice: 'Tipo pensum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_pensum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n format.html { redirect_to pessoas_path, notice: 'Pessoa atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trabajo.update(trabajo_params)\n format.html { redirect_to cliente_path(@cliente), notice: 'Trabajo was successfully updated.' }\n format.json { render :show, status: :ok, location: cliente_trabajo_path(@cliente, @trabajo) }\n else\n format.html { render :edit }\n format.json { render json: @trabajo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @tarefa.update(tarefa_params)\n format.html { redirect_to @tarefa, notice: 'Tarefa atualizada com sucesso!' }\n format.json { render :show, status: :ok, location: @tarefa }\n else\n format.html { render :edit , @current_usuario => current_usuario}\n format.json { render json: @tarefa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @tangazo.update(tangazo_params)\n format.html { redirect_to @tangazo, notice: 'Tangazo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tangazo }\n else\n format.html { render :edit }\n format.json { render json: @tangazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @titulacao.update(titulacao_params)\n format.html { redirect_to titulacaos_path, notice: 'Titulo atualizado com successo.' }\n format.json { render titulacaos_path, status: :ok, location: titulacaos_path }\n else\n format.html { render :edit }\n format.json { render json: @titulacao.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 @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n if @paciente.update_attributes(params[:paciente])\n format.html { redirect_to @paciente, notice: 'Paciente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipp = Tipp.find(params[:id])\n\[email protected] = current_user.name\n respond_to do |format|\n if @tipp.update_attributes(params[:tipp])\n #format.html { redirect_to(@tipp, :notice => 'Tipp was successfully updated.') }\n format.html { redirect_to(tipps_url)}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tipp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @persona_tipo = PersonaTipo.find(params[:id])\n\n respond_to do |format|\n if @persona_tipo.update_attributes(params[:persona_tipo])\n format.html { redirect_to @persona_tipo, notice: 'Tipo de participante actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona_tipo.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 @core_nota = Core::Nota.find(params[:id])\n\n respond_to do |format|\n if @core_nota.update_attributes(params[:core_nota])\n format.html { redirect_to @core_nota, notice: 'Nota was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @core_nota.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiponovedad.update(tiponovedad_params)\n format.html { redirect_to @tiponovedad, notice: 'Tiponovedad was successfully updated.' }\n format.json { render :show, status: :ok, location: @tiponovedad }\n else\n format.html { render :edit }\n format.json { render json: @tiponovedad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @telefone = Telefone.find(params[:id])\n\n respond_to do |format|\n if @telefone.update_attributes(params[:telefone])\n format.html { redirect_to @telefone, :notice => 'Telefone foi salvo com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @telefone.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prato.update(prato_params)\n format.html { redirect_to @prato, notice: 'Prato was successfully updated.' }\n format.json { render :show, status: :ok, location: @prato }\n else\n format.html { render :edit }\n format.json { render json: @prato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipocambio.update(tipocambio_params)\n format.html { redirect_to @tipocambio, notice: 'Tipocambio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipocambio }\n else\n format.html { render :edit }\n format.json { render json: @tipocambio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\trespond_to do |format|\n\tif @precio_boleto.update(precio_boleto_params)\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n\t\tformat.json { head :no_content }\n\telse\n\t\tformat.html { render action: 'edit' }\n\t\tformat.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n\tend\n\tend\nend",
"def update\n @titulacionesdoctipo = Titulacionesdoctipo.find(params[:id])\n\n respond_to do |format|\n if @titulacionesdoctipo.update_attributes(params[:titulacionesdoctipo])\n format.html { redirect_to(@titulacionesdoctipo, :notice => 'Titulacionesdoctipo was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @titulacionesdoctipo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @telefone_cliente.update(telefone_cliente_params)\n format.html { redirect_to @telefone_cliente, notice: 'Telefone cliente was successfully updated.' }\n format.json { render :show, status: :ok, location: @telefone_cliente }\n else\n format.html { render :edit }\n format.json { render json: @telefone_cliente.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7096629",
"0.69910496",
"0.6948625",
"0.68949896",
"0.6883719",
"0.6840661",
"0.67996186",
"0.6739658",
"0.6681233",
"0.6657945",
"0.6625662",
"0.661959",
"0.65987736",
"0.659808",
"0.65840715",
"0.6574071",
"0.6560793",
"0.65463454",
"0.65428406",
"0.65234953",
"0.65110844",
"0.6498169",
"0.64957637",
"0.6490001",
"0.6487309",
"0.64705133",
"0.6468405",
"0.64484656",
"0.6418033",
"0.6410134",
"0.6399813",
"0.6398303",
"0.6391316",
"0.6370096",
"0.63618773",
"0.63576305",
"0.63571256",
"0.6354509",
"0.6352414",
"0.63511544",
"0.63458747",
"0.6340474",
"0.63309056",
"0.633058",
"0.6314834",
"0.62849736",
"0.6278806",
"0.6269138",
"0.62550914",
"0.62492067",
"0.6243269",
"0.6242152",
"0.6238781",
"0.6237425",
"0.6236394",
"0.6235904",
"0.62326443",
"0.62286884",
"0.62193555",
"0.6218595",
"0.621688",
"0.62154657",
"0.6214128",
"0.6213648",
"0.6213179",
"0.6212993",
"0.6210566",
"0.6208987",
"0.62051004",
"0.6204457",
"0.6202641",
"0.6199338",
"0.6198653",
"0.61708325",
"0.61639595",
"0.6154328",
"0.6152172",
"0.6146296",
"0.6142298",
"0.6141745",
"0.6141737",
"0.6141645",
"0.6137751",
"0.6136161",
"0.6135995",
"0.6135551",
"0.61335635",
"0.61334336",
"0.613257",
"0.6132246",
"0.6132133",
"0.6129718",
"0.6127933",
"0.6126943",
"0.6126801",
"0.61264193",
"0.61252713",
"0.61248946",
"0.6123788",
"0.6123184"
] | 0.6584238 | 14 |
DELETE /tipocuenta/1 DELETE /tipocuenta/1.json | def destroy
@tipocuentum.destroy
respond_to do |format|
format.html { redirect_to tipocuenta_url, notice: 'Tipocuentum was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tipoveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tipoveiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipocliente = Tipocliente.find(params[:id])\n @tipocliente.destroy\n\n respond_to do |format|\n format.html { redirect_to tipoclientes_url }\n #format.json { head :ok }\n end\n end",
"def destroy\n @tipos_contato.destroy\n respond_to do |format|\n format.html { redirect_to tipos_contatos_url, notice: 'Tipos contato was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiposveiculo.destroy\n respond_to do |format|\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipomedalla = Tipomedalla.find(params[:id])\n @tipomedalla.destroy\n\n respond_to do |format|\n format.html { redirect_to tipomedallas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipovestuario.destroy\n respond_to do |format|\n format.html { redirect_to tipovestuarios_url, notice: 'Tipovestuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tip_so = TipSo.find(params[:id])\n @tip_so.destroy\n\n respond_to do |format|\n format.html { redirect_to tip_sos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiposervico.destroy\n respond_to do |format|\n format.html { redirect_to tiposervicos_url, notice: 'Tiposervico was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @tapioca.destroy\n respond_to do |format|\n format.html { redirect_to tapiocas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitacao_tipo.destroy\n respond_to do |format|\n format.html { redirect_to solicitacao_tipos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecnico = Tecnico.find(params[:id])\n @tecnico.destroy\n\n respond_to do |format|\n format.html { redirect_to tecnicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nota_tecnica.destroy\n respond_to do |format|\n format.html { redirect_to nota_tecnicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipus_indicador.destroy\n respond_to do |format|\n format.html { redirect_to tipus_indicadors_url, notice: 'Tipus indicador was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiposcontrato = Tiposcontrato.find(params[:id])\n @tiposcontrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(tiposcontratos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @telefononegocio = Telefononegocio.find(params[:id])\n @telefononegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to telefononegocios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipos_encuestum.destroy\n respond_to do |format|\n format.html { redirect_to tipos_encuesta_url, notice: 'Tipos encuestum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipoplato.destroy\n respond_to do |format|\n format.html { redirect_to tipoplatos_url, notice: 'Tipoplato was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipos_dato.destroy\n respond_to do |format|\n format.html { redirect_to tipos_datos_url, notice: 'Tipos dato was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @denuncia_tipo = DenunciaTipo.find(params[:id])\n @denuncia_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to denuncia_tipos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipomovifinanceiro.destroy\n respond_to do |format|\n format.html { redirect_to tipomovifinanceiros_url, notice: 'Tipomovifinanceiro was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trnodo = Trnodo.find(params[:id])\n @trnodo.destroy\n\n respond_to do |format|\n format.html { redirect_to trnodos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipomaquinat.destroy\n respond_to do |format|\n format.html { redirect_to tipomaquinats_url, notice: 'Tipomaquinat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecido.destroy\n respond_to do |format|\n format.html { redirect_to tecidos_url, notice: 'Tecido was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_aposta.destroy\n respond_to do |format|\n format.html { redirect_to tipo_apostas_url, notice: 'Tipo aposta was successfully destroyed.' }\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",
"def destroy\r\n @tipos_usuario.destroy\r\n respond_to do |format|\r\n format.html { redirect_to tipos_usuarios_url, notice: 'El nombre del tipo de usuario se eliminó corrctamente.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @etnia = Etnia.find(params[:id])\n @etnia.destroy\n\n respond_to do |format|\n format.html { redirect_to etnias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipotermo.destroy\n respond_to do |format|\n format.html { redirect_to tipotermos_url, notice: 'Tipotermo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taco.destroy\n respond_to do |format|\n format.html { redirect_to tacos_url, notice: 'Taco was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @persona_tipo = PersonaTipo.find(params[:id])\n @persona_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to persona_tipos_url }\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 @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tangazo.destroy\n respond_to do |format|\n format.html { redirect_to tangazos_url, notice: 'Tangazo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ponto.destroy\n respond_to do |format|\n format.html { redirect_to pontos_url, notice: 'Ponto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_negocio = TipoNegocio.find(params[:id])\n @tipo_negocio.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_negocios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipocosto.destroy\n respond_to do |format|\n format.html { redirect_to tipocostos_url, notice: 'Tipocosto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tatoo.destroy\n respond_to do |format|\n format.html { head :no_content }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trabajo.destroy\n respond_to do |format|\n format.html { redirect_to cliente_url(@cliente), notice: 'Trabajo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_alerta = TipoAlerta.find(params[:id])\n @tipo_alerta.destroy\n\n respond_to do |format|\n format.html { redirect_to tipos_alertas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_persona.destroy\n respond_to do |format|\n format.html { redirect_to tipos_personas_url, notice: 'Tipo persona was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intranet_financeiro_tipos_cobanca.destroy\n respond_to do |format|\n format.html { redirect_to intranet_financeiro_tipos_cobancas_url, notice: \"Financeiro tipos cobanca was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ponto = Ponto.find(params[:id])\n @ponto.destroy\n\n respond_to do |format|\n format.html { redirect_to(pontos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_vehiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @anteproyecto_observacion.destroy\n respond_to do |format|\n format.html { redirect_to anteproyecto_observaciones_url, notice: 'Anteproyecto observacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n @solicitud_servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to solicitudes_servicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @todoroute.destroy\n respond_to do |format|\n format.html { redirect_to todoroutes_url, notice: 'Todoroute was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_de_imposto.destroy\n respond_to do |format|\n format.html { redirect_to @empresa, notice: 'Tipo de imposto removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taxi = Taxi.find(params[:id])\n @taxi.destroy\n\n respond_to do |format|\n format.html { redirect_to taxis_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tipoapreensao.destroy\n respond_to do |format|\n format.html { redirect_to tipoapreensoes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipos_contratos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tipo_de_servicio.destroy\n respond_to do |format|\n format.html { redirect_to tipo_de_servicios_url, notice: 'Tipo de servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tarefa.destroy\n respond_to do |format|\n format.html { redirect_to tarefas_url, notice: 'Tarefa deletada com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ponto.destroy\n respond_to do |format|\n format.html { redirect_to pontos_url, notice: 'Ponto foi Removido.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tip = Tip.find(params[:id])\n @tip.destroy\n\n respond_to do |format|\n format.html { redirect_to tips_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tipo_ventum.destroy\n respond_to do |format|\n format.html { redirect_to tipo_venta_url, notice: 'Tipo ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end",
"def destroy\n @tipomensaje = Tipomensaje.find(params[:id])\n @tipomensaje.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipomensajes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @paciente = Paciente.find(params[:id])\n @paciente.destroy\n\n respond_to do |format|\n format.html { redirect_to paciente_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to tipo_referencia_bases_url, notice: \"Tipo referencia base was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @titulacionesdoctipo = Titulacionesdoctipo.find(params[:id])\n @titulacionesdoctipo.destroy\n\n respond_to do |format|\n format.html { redirect_to(titulacionesdoctipos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lixotodo.destroy\n respond_to do |format|\n format.html {redirect_to lixotodos_url, notice: 'Registro excluído com sucesso.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @asociado = Asociado.find(params[:id])\n @asociado.destroy\n\n respond_to do |format|\n format.html { redirect_to asociados_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @trabalho = Trabalho.find(params[:id])\n @trabalho.destroy\n\n respond_to do |format|\n format.html { redirect_to trabalhos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_nota = TipoNota.find(params[:id])\n @tipo_nota.destroy\n\n respond_to do |format|\n format.html { redirect_to(tipo_notas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @treinamento_ti.destroy\n respond_to do |format|\n format.html { redirect_to treinamentos_ti_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tarefa = Tarefa.find(params[:id])\n @tarefa.destroy\n\n respond_to do |format|\n format.html { redirect_to tarefas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiponovedad.destroy\n respond_to do |format|\n format.html { redirect_to tiponovedads_url, notice: 'Tiponovedad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirect_to solicitudes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 @atracao = Atracao.find(params[:id])\n @atracao.destroy\n\n respond_to do |format|\n format.html { redirect_to atracaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaurantes_proximo.destroy\n respond_to do |format|\n format.html { redirect_to restaurantes_proximos_url, notice: 'Restaurantes proximo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @evolucao_tipo.destroy\n respond_to do |format|\n format.html { redirect_to evolucao_tipos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tattoo = Tattoo.find(params[:id])\n @tattoo.destroy\n\n respond_to do |format|\n format.html { redirect_to tattoos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @treino.destroy\n respond_to do |format|\n format.html { redirect_to treinos_url, notice: 'Treino was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tetramod = Tetramod.find(params[:id])\n @tetramod.destroy\n\n respond_to do |format|\n format.html { redirect_to tetramods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troop_detail.destroy\n respond_to do |format|\n format.html { redirect_to troop_details_url, notice: 'Detalle tropa exitosamente borrado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @telefone_cliente.destroy\n respond_to do |format|\n format.html { redirect_to telefone_clientes_url, notice: 'Telefone cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apunte = Apunte.find(params[:id])\n @apunte.destroy\n\n respond_to do |format|\n format.html { redirect_to apuntes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tiempo.destroy\n respond_to do |format|\n format.html { redirect_to tiempos_url, notice: 'Tiempo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @antecedente = Antecedente.find(params[:id])\n @antecedente.destroy\n\n respond_to do |format|\n format.html { redirect_to antecedentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_convenio = TipoConvenio.find(params[:id])\n @tipo_convenio.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_convenios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @noto = Noto.find(params[:id])\n @noto.destroy\n\n respond_to do |format|\n format.html { redirect_to notos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_actividad = TipoActividad.find(params[:id])\n @tipo_actividad.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_actividads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_distribucion.destroy\n respond_to do |format|\n format.html { redirect_to tipos_distribuciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_unidad.destroy\n respond_to do |format|\n format.html { redirect_to tipo_unidads_url, notice: 'Tipo unidad was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.74846035",
"0.7438317",
"0.7416803",
"0.73901147",
"0.73758835",
"0.7353602",
"0.7284259",
"0.72161543",
"0.7206195",
"0.7172122",
"0.7170672",
"0.7169681",
"0.7169681",
"0.7169681",
"0.7168835",
"0.7161455",
"0.71610135",
"0.71517104",
"0.714395",
"0.714276",
"0.7141049",
"0.7112751",
"0.7110453",
"0.71020955",
"0.71017206",
"0.70841557",
"0.7061676",
"0.7038532",
"0.70295477",
"0.702921",
"0.7028827",
"0.7018611",
"0.7010669",
"0.7007957",
"0.70057666",
"0.7003555",
"0.70018154",
"0.6992781",
"0.69921446",
"0.69913036",
"0.69908",
"0.69780654",
"0.6965146",
"0.69634676",
"0.6962356",
"0.69598603",
"0.6958211",
"0.6954763",
"0.6952311",
"0.69428265",
"0.6942639",
"0.6937696",
"0.6936169",
"0.6930365",
"0.6929557",
"0.6928826",
"0.6926457",
"0.69263744",
"0.6924756",
"0.69238937",
"0.6921913",
"0.6921167",
"0.6920963",
"0.692023",
"0.69195014",
"0.6919259",
"0.6917908",
"0.6916359",
"0.6914333",
"0.69115406",
"0.69112444",
"0.69103885",
"0.6906172",
"0.690582",
"0.69040585",
"0.6897919",
"0.68969524",
"0.68965125",
"0.6894833",
"0.6894448",
"0.68939525",
"0.68908995",
"0.68895733",
"0.68895453",
"0.68893576",
"0.68864834",
"0.6886435",
"0.6885971",
"0.68851",
"0.6883362",
"0.68829566",
"0.68824196",
"0.68802315",
"0.6876448",
"0.6876417",
"0.6874834",
"0.68731433",
"0.686376",
"0.6863383",
"0.68629694"
] | 0.73677945 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_tipocuentum
@tipocuentum = Tipocuentum.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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\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 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\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\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 init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def 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 setup\n #implement in subclass;\n end",
"def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; 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 setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def 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 call\n setup_context\n super\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.5330087",
"0.5311993",
"0.5297402",
"0.5296789",
"0.52957207",
"0.52596015",
"0.5245442",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5235431",
"0.5231888",
"0.5226663",
"0.52220625",
"0.5217086",
"0.52137345",
"0.5208314",
"0.5205469",
"0.5175606",
"0.5174914",
"0.5173361",
"0.51662856",
"0.5161792",
"0.51572216",
"0.5153063",
"0.5152982",
"0.5152632",
"0.51435786",
"0.5139829",
"0.51346594",
"0.511372",
"0.511372",
"0.51136476",
"0.51083213",
"0.5108011",
"0.5091935",
"0.5089297",
"0.5081576",
"0.50807106",
"0.50656676",
"0.50548106",
"0.50537366",
"0.505074",
"0.505074",
"0.5033361",
"0.5025158",
"0.5020441",
"0.5015611",
"0.50142473",
"0.5000281",
"0.50001067",
"0.49989453",
"0.4989465",
"0.4989465",
"0.4985425",
"0.49805096",
"0.49795893",
"0.49783278",
"0.49676263",
"0.49656346",
"0.49579078",
"0.4955427",
"0.49554235",
"0.49536413",
"0.49523768",
"0.49457142",
"0.49433607",
"0.4933641",
"0.49320185",
"0.49265638",
"0.49262375",
"0.49259067",
"0.4922456",
"0.49201223",
"0.49165115",
"0.49158815",
"0.49151883",
"0.49149552",
"0.4914386"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tipocuentum_params
params.require(:tipocuentum).permit(:nombretipocuenta, :fechaingresotipocuenta)
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 |
A customize uploads path for ActiveStorage GET /uplaods/:id?s= send file Reference implementation | def show
send_file_by_disk_key @blob, content_type: @blob.content_type
rescue ActionController::MissingFile, ActiveStorage::FileNotFoundError
head :not_found
rescue ActiveStorage::IntegrityError
head :unprocessable_entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file_url\n \"file://#{upload_full_path}\"\n end",
"def path\n \"/#{UPLOAD_DIR}/#{filename}\"\n end",
"def uploaded_file_path\n FileServices::Uploader.perform(@file, upload_path)\n end",
"def file_path\n storage.file_path(self.class, @id)\n end",
"def photo_path\n\"/photo_store/#{id}.#{extension}\"\nend",
"def upload_full_path\n @upload_full_path ||= File.join(@upload_file_path, name)\n end",
"def photo_path\n \"/photo_store/#{id}.#{extension}\"\n end",
"def generate_storage_path\n update_column(:file, File.join(File.dirname(request.file),\n \"#{id}-response.xml\"))\n end",
"def file_path\n Merb::Config[:upload_dir] / self.hash[0..1] / (self.hash[2..-1] + '-' + self.size.to_s )\n end",
"def upload_path picture\n entity = picture.class.name.sub('Picture','').upcase\n \"PICTURE_#{entity}_PATH\".constantize\n end",
"def photo_path\n \"/photo_store/people/#{id}.#{extension}\"\n end",
"def file_uploads; end",
"def storage_path\n File.join(organization.storage_path, url_part)\n end",
"def photo_path\n \t\"/photo_store/#{id}.#{extension}\"\n end",
"def storage_path\n File.join(department.institution.storage_path, url_part)\n end",
"def upload_url\n _get(\"/files/upload_url\") { |json| json }\n end",
"def path\n '/c/document_library/get_file?folderId=%i&name=%s' % [self.folderid, self.name]\n end",
"def upload_path\n Rails.root.join('file_uploads', 'csv_keywords', \"user_#{@user.id}\")\n end",
"def storage_location(request)\n root = Rails.application.config.upload['storage_path']\n File.join root, request.bag_id\n end",
"def files\n redirect_to(ContentServer.uploaded_content_url(params[:id], '.' + params[:ext].to_s))#params[:id].to_s.gsub(\".\")[1]))\n end",
"def files\n redirect_to(ContentServer.uploaded_content_url(params[:id], '.' + params[:ext].to_s))#params[:id].to_s.gsub(\".\")[1]))\n end",
"def base_path\n [attachment_options[:path_prefix], attachment_path_id].join(\"/\")\n end",
"def ext_path\n path = \"/#{@bucket_name}\"\n path += \"/#{String(@file_name)}\" if @file_name && !@file_name.empty?\n Addressable::URI.escape path\n end",
"def full_virtual_path\n '/uploads'\n end",
"def path_for(id)\n debugger if $debug\n File.join(options[:base_path], options[:path_prefix], Storage.partitioned_path(id))\n end",
"def ext_path\n \"/#{@file.bucket}/#{@file.name}\"\n end",
"def upload_simple\r\n \r\n end",
"def file_path_for(file)\n ActiveStorage::Blob.service.send(:path_for, file.key)\n end",
"def upload_file\n #TODO\n end",
"def full_file_path\n Rails.root.join('uploads', filepath).to_s\n end",
"def path\n file.url\n end",
"def path\n \"#{RAILS_ROOT}/photos/#{self.visit.user_id}/#{self.visit_id}\"\n \n# \"#{RAILS_ROOT}/public/images/#{self.class.to_s.underscore.pluralize}\"\n end",
"def storage_path\n File.join(\n SystemConfiguration.first.storage_path,\n url_part)\n end",
"def store_dir\n \"uploads/#{model.request_id}\"\n end",
"def image_path\n \"/image_store/#{id}.#{extension}\"\n end",
"def upload_path_value\n Figgy.config[\"ingest_folder_path\"]\n end",
"def base_path(prefix_class = self, &escape)\n escape ||= lambda { |path| path }\n File.join( *[ prefix_class.attachment_options[:path_prefix].to_s,\n *partitioned_id ].map(&escape) )\n end",
"def path\n self.file.to_s\n end",
"def remote_storage_base_path\n File.join(self.class.model_path_segment(model), dynamic_segment)\n end",
"def public_id\n \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n end",
"def paperclip_path\n \":rails_root/public/spree/products/:id/:style/:basename.:extension\"\n end",
"def upload\r\n \r\n end",
"def file_path\n \"invoices/#{ self.structure.slug }/subscriptions/#{ self.id }.pdf\"\n end",
"def set_upload\n @upload = Upload.friendly.find(params[:id])\n end",
"def file_link\n return \"#{SITE_URL}system/ufiles/#{id}/original/#{ufile_file_name}\"\n end",
"def paperclip_path\n \"dev/assets/products/:id/:style/:basename.:extension\"\n end",
"def base_path\n File.join(attachment_options[:path_prefix], attachment_path_id)\n end",
"def file_path\n end",
"def upload\n\n\t\t@uploads = Idea.find(params[:id]).uploads\n\t\t@idea = params[:id]\n\t\t@idea_obj = Idea.find(@idea)\n\n\t\t# allows user to delete files\n\t\t@delete = true\n\n\t\t@path = [link_to_ideas, link_to_idea_uploads(@idea_obj)]\n\t\t@subnavigation = [active_link_to_idea_uploads(@idea_obj), link_to_idea(@idea_obj), link_to_show_all_ideas(\"Alle Ideen\", \"title\", \"ASC\", \"\", 0, 30)]\n\tend",
"def file_path_import(params)\n raise unless params[:model]\n raise unless params[:id]\n raise unless params[:file_name]\n src = File.join(RAILS_ROOT, params[:file_name].to_s)\n dst = File.join(RAILS_ROOT, 'public', 'uploaded_files', RAILS_ENV, params[:model].to_s, params[:id].to_s, 'medium')\n\t\tFileUtils.mkdir_p(dst)\n FileUtils.ln_s(src, dst+'/'+params[:file_name].split('/').last, :force => true) unless File.exists?(dst+'/'+params[:file_name].split('/').last)\n return params[:file_name].split('/').last\nend",
"def file_path; end",
"def set_upload \n @upload = LibraryUpload.friendly.find(params[:id])\n end",
"def path\n \"/content/#{id}\"\n end",
"def file_system_path\n path_prefix = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s\n [path_prefix, self.parent_type.underscore, attachment_path_id.to_s, self.id.to_s] + partitioned_path(thumbnail_name_for(thumbnail))\n end",
"def store_dir\n \"uploads/#{model.id}\"\n end",
"def upload\n end",
"def upload\n end",
"def get\n # first find the upload within own uploads\n upload = current_user.uploads.find_by_id(params[:id])\n \n #if not found in own uploads, check if the current_user has share access to the parent folder of the file\n upload ||= Upload.find(params[:id]) if current_user.has_share_access?(Upload.find_by_id(params[:id]).folder)\n \n if upload\n send_file upload.uploaded_file.path, :type => upload.uploaded_file_content_type\n else\n flash[:error] = \"You have no permissions to access this area!!\"\n redirect_to uploads_path\n end\n \n end",
"def url\n # HACK: Revisit and make configurable separate from the connection options.\n \"http://#{@uploader.sftp_host}/#{path}\"\n end",
"def document_attachment\n \"#{Rails.root}/uploads/#{document.url}\"\n end",
"def file_name\n uploaded_file_file_name\n end",
"def object_path(id)\n \"#{path}/objects/#{id[0...2]}/#{id[2..39]}\"\n end",
"def to_jq_upload\n {\n name: read_attribute(:asset_path),\n size: asset_path.size,\n url: asset_path.url,\n delete_path: cms_asset_path(id)\n }\n end",
"def path\n @file.path\n end",
"def unit_path\n \"u_\" + image_path\n end",
"def fs(path)\n OodAppkit.files.url(path: path).to_s\n end",
"def file_url\n end",
"def store_dir\n \"uploads/#{model.Mid}\"\n end",
"def get_file_path(v1_url)\n store.get(table_key + '_path', v1_url)\n end",
"def upload_url\n return unless @data['image']\n # Isn't actually displayed in-app without this set\n return unless image['property'] == 'image'\n file(@data['image'])\n end",
"def api(path)\n OodAppkit.files.api(path: path).to_s\n end",
"def path\n @file\n end",
"def photo__path\r\nif !@photo_cache.blank? && !@photo_cache[:path].blank?\r\n @photo_cache[:path]\r\nelse\r\n File.join(FILES_DEST_PHOTO, \"#{self.id}_#{self.photo__name}\")\r\nend\r\nend",
"def multipart_upload\n end",
"def url(id, **options)\n id = [*@storage.prefix, id].join(\"/\") if @include_prefix\n\n client.path(id).to_url(**options)\n end",
"def store_dir\n \"uploads/images/spot/#{@@spot_id}\"\n end",
"def set_path_based_on_parent!\n if self.class_type == 'variant'\n \":rails_root/public/assets/upload/variants/:id/:style/:basename.:extension\"\n elsif self.class_type == 'banner'\n \":rails_root/public/assets/upload/banner/:style/:basename.:extension\"\n elsif self.class_type == 'logo'\n \":rails_root/public/assets/upload/logo/:style/:basename.:extension\"\n end\n end",
"def set_upload\n\n\n @upload = Upload.find(params[:id])\n\n \n \n end",
"def path\n [name]\n end",
"def file_path\n File.join device.path, id.to_s(16)\n end",
"def get_file_path\n @path\n end",
"def full_path; end",
"def upload_url\n return @upload_url\n end",
"def path\n name + extension\n end",
"def url(**options)\n if uploaded_file = get\n uploaded_file.url(**options)\n else\n default_url(**options)\n end\n end",
"def store_dir\n \"uploads/imports/\"\n end",
"def url\n Rails.application.routes.url_helpers.nfs_store_download_path(id)\n end",
"def uploaded_file\n initalize_breadcrumb(\"Uploaded File(s)\", uploadedfile_datauploaders_path)\n currentUser = current_user.id\n @uploadedFiles = UserFileMapping.where(:user_id =>currentUser )\n respond_with(@uploadedFiles)\n end",
"def file_path_proc\n return @attachment_options[:dropbox_options][:path] if @attachment_options[:dropbox_options][:path]\n\n if @attachment_options[:dropbox_options][:unique_filename]\n eval %(proc { |style| \"\\#{ActiveModel::Naming.param_key(self.class)}_\\#{id}_\\#{#{@attachment.name}.name}\" })\n else\n eval %(proc { |style| #{@attachment.name}.original_filename })\n end\n end",
"def url\n [\"http://\" + @uploader.couch_host + \":\" + @uploader.couch_port, model.database.name , model.id, @path].join(\"/\")\n end",
"def path\n if auditable_type.include? 'Asset'\n \"inventory_path(:id => '#{auditable.object_key}')\"\n else\n \"#{auditable_type.underscore}_path(:id => '#{auditable.object_key}')\"\n end\n\tend",
"def get_upload_url\n url_service = UploadUrlFetcher.new(@context, unsafe_params[:id])\n\n result = url_service.fetch_url(unsafe_params)\n\n render json: result\n end",
"def file\n\n content_upload_id = params[:id]\n\n raise \"content upload without id\" if content_upload_id.blank?\n\n # if the id is not numeric, assume it's a link name\n if content_upload_id.to_i == 0\n content_upload = ContentUpload.find_by_link_name(content_upload_id)\n else # assume the id passed is numeric and find it by ID\n content_upload = ContentUpload.find_by_id(content_upload_id)\n end\n\n raise \"content upload not found\" if content_upload.blank?\n\n # send them to the file on the content server\n redirect_to(content_upload.content_server_url)\n\n end",
"def set_path\n @file_path = @s3_local_object.body.path\n end",
"def path\n @filename\n end",
"def full_path\n path\n end",
"def path\n @path\n end",
"def path\n @path\n end",
"def url_for_file_column(object_name, method, suffix=nil, object = nil)\n object = instance_variable_get(\"@#{object_name.to_s}\") if object.nil?\n relative_path = object.send(\"#{method}_relative_path\", suffix)\n return nil unless relative_path\n url = \"\"\n url << ActionController::Base.relative_url_root.to_s << \"/\"\n url << object.send(\"#{method}_options\")[:base_url] << \"/\"\n url << relative_path\n end",
"def file\n\n content_upload_id = params[:id]\n\n raise \"content upload without id\" if content_upload_id.blank?\n\n # if the id is not numeric, assume it's a link name\n if content_upload_id.to_i == 0\n content_upload = ContentUpload.find_by_link_name(content_upload_id)\n else # assume the id passed is numeric and find it by ID\n content_upload = ContentUpload.find_by_id(content_upload_id)\n end\n\n raise \"content upload not found\" if content_upload.blank?\n\n # send them to the file on the content server\n redirect_to(content_upload.content_server_url, status: :moved_permanently)\n\n end",
"def imagen_path\n\t\t\"../perfumes/#{id}.#{imagen}\"\n\t\t# \"../perfumes/#{imagen}\"\n\tend"
] | [
"0.69769955",
"0.6915078",
"0.6832691",
"0.66786593",
"0.6669179",
"0.6657174",
"0.65731835",
"0.6566756",
"0.65632176",
"0.65505815",
"0.6512887",
"0.6466021",
"0.6436854",
"0.6435343",
"0.6419599",
"0.63772887",
"0.63717026",
"0.63077205",
"0.6276352",
"0.62615764",
"0.62615764",
"0.6245516",
"0.6244067",
"0.6209684",
"0.61918664",
"0.6182311",
"0.61774254",
"0.61535627",
"0.6135156",
"0.6123026",
"0.61223024",
"0.61157215",
"0.61000526",
"0.609465",
"0.6083471",
"0.60776377",
"0.6068997",
"0.6062034",
"0.60580814",
"0.60519516",
"0.6029543",
"0.6023071",
"0.6020559",
"0.60190034",
"0.60188514",
"0.601559",
"0.6015105",
"0.6007857",
"0.6000106",
"0.5996572",
"0.59863716",
"0.59828305",
"0.5965698",
"0.5962677",
"0.5960258",
"0.5955928",
"0.5955928",
"0.5955809",
"0.59537965",
"0.5949383",
"0.59365314",
"0.59347016",
"0.5931374",
"0.59304196",
"0.59275556",
"0.59235257",
"0.591244",
"0.5896871",
"0.5889354",
"0.5874686",
"0.5864916",
"0.5861482",
"0.5859178",
"0.5856965",
"0.58553743",
"0.5848827",
"0.5846813",
"0.5835861",
"0.58276314",
"0.5821016",
"0.58161557",
"0.58026737",
"0.5799287",
"0.57933736",
"0.57902616",
"0.5785186",
"0.5782807",
"0.5782627",
"0.57647884",
"0.5759466",
"0.5755083",
"0.57506853",
"0.574965",
"0.57484996",
"0.5742085",
"0.5740149",
"0.573937",
"0.573937",
"0.5735206",
"0.5733244",
"0.5724834"
] | 0.0 | -1 |
maybe admin user from session or clientapi user from params[:user_id] | def get_user_name(user_id)
if self.is_api then
user = begin
HuiMain.plugin_data.find_one("_id" => BSON::ObjectId(user_id))
rescue BSON::InvalidObjectId
nil
end
if user then
user["name"]
else
nil
end
else # not api
session[:current_user_name]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_user\n if session[:user_id] and session[:position]\n @admin_user = AdminUser.find_by_id(session[:user_id])\n end\n end",
"def correct_or_admin_user\n @user = User.find(params[:id]) \n unless current_user?(@user) || admin_user?\n redirect_to(login_url)\n end\n end",
"def correct_user\n \t@user = User.where(id: params[:id]).to_a[0]\n\tunless current_user?(@user) or current_user.admin?\n\t\tredirect_to root_path, notice: \"You are not allowed to do that.\"\n\tend\n end",
"def find_review_user\n if params[:user_id] && @current_user_roles.include?('admin')\n @current_api_user = Spree.user_class.find(params[:user_id])\n end\n end",
"def user_from_session\n Admin::User.find(session[:user_id]) if session[:user_id]\n end",
"def actual_user\n User.find_by_id(session[:user_id])\n end",
"def session_user\n if admin_controller?\n admin_user\n else\n current_user\n end\n end",
"def correct_user\n @admin = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@admin)\n end",
"def correct_user_id_or_admin\n @user = Domain.find(params[:id]).user_id\n redirect_to(root_url) unless current_user.admin? || current_user.id == @user\n end",
"def ownerOrAdmin\n if not signed_in? && (Greenroof.find_by_id(params[:id]).user_id == current_user.id || current_user.admin?)\n redirect_to root_url\n end\n end",
"def correct_user\n if current_user\n @user = User.find(params[:id]) if params[:id]\n unless current_user?(@user) || current_user.admin?\n redirect_to user_path(current_user) \n end\n else\n redirect_to login_path\n end\n end",
"def user_admin?\n \t@admin_user = Usuario.find(session[:user_id]).admin\n end",
"def user_id\n @logged_in_user = User.find_by(id: params[:id])\n @user_id = @logged_in_user.id\n end",
"def admin_required\n session[:user_id] && (user = User.find(session[:user_id])) && user.is_admin\n end",
"def admin_auth\n user = User.find_by(id: params[:user_id])\n if ! user\n \trender json: {\n \"error\" => \"Unauthorized\"\n }, status: 401\n return\n end \n if user.is? :admin\n render json: {}, status: 201\n else\n render json: {\n \"error\" => \"Unauthorized\"\n }, status: 401\n end \n end",
"def correct_user\n @user = User.find_by_id(params[:id])\n unless @user == current_user || admin?\n flash[:danger]= t 'h.sessions.permisiondenied'\n redirect_to(root_url) \n end\n end",
"def correct_user\n \t\t@user = User.find(params[:id])\n \t\tredirect_to(root_url) unless current_user?(@user) || current_user.admin?\n \tend",
"def find_user\n if !current_user.nil?\n @user=User.find(current_user.id)\n session[:admin_id][email protected]\n elsif !current_member.nil?\n @user=Member.find(current_member.id)\n session[:admin_id][email protected]_id\n end\n end",
"def current_user\n User.find_by_id(session[:user_id]) if session[:user_id] \n end",
"def admin_user?\n session[:user][:uid] == APP_CONFIG[:admin]\n end",
"def current_user\n session[:admin]\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)|| current_user.admin?\n end",
"def correct_user\n @user = User.find(params[:id])\n if not ( current_user?(@user) || current_user.admin? ) \n redirect_to(root_url) \n end\n end",
"def user\n find_user params._id\n end",
"def correct_user\n\t\t\t@user = User.find(params[:id])\n\t\t\tredirect_to(root_url) unless current_user?(@user) || current_user.admin?\n\t end",
"def correct_user_or_admin\n @user = KuUser.find(params[:id])\n redirect_to(current_user) unless current_user?(@user) || current_user.admin?\n end",
"def correct_user\n @jogtime = Jogtime.find(params[:id])\n redirect_to(root_url) unless (current_user.id == @jogtime.user_id) || current_user.admin?\n end",
"def load_user_and_authorization\n @owner_user = User.find( params[:user_id] )\n @current_user_is_owner = ( current_user_id == params[:user_id].to_i )\n end",
"def current_user\n @current_user ||= Admin.find_by(id: session[:admin_id]) #Lay session id cho nhung trang tiep theo\n end",
"def user?(admin)\n admin&.id == self.admin_id\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) or current_user.admin?\n end",
"def authenticate_current_user\n unless current_user.admin == true\n unless current_user == User.find(params[:id]) \n flash[:danger] = \"Impossible d'aller sur cette page.\"\n redirect_to root_path\n end\n end\n end",
"def correct_user\n#puts \"authentication_helper correct_user: params=#{params}\"\n return unless params[:id]\n @user = User.find(params[:id])\n#puts \">> @user=#{@user.id}, current_user?(@user)=#{current_user?(@user)}\"\n if current_user?(@user) || current_user.admin?\n return true\n else \n redirect_to(root_path) \n return false \n end \n end",
"def correct_user\n @user = User.find(params[:id])\n # The current_user? boolean is defined in\n # app/helpers/sessions_helper.rb\n redirect_to(root_path) unless current_user?(@user) || current_user.try(:admin?)\n end",
"def admin_or_correct_user\n if current_user.nil?\n redirect_to root_url\n else\n @user_application = current_user.user_applications.find_by(id: params[:id])\n unless current_user.admin?\n redirect_to root_url if @user_application.nil?\n end\n end\n end",
"def current_user\n User.find_by_id(session[:user_id]) if session[:user_id].present?\n end",
"def current_user(id = session[:user_id])\n User.get_one id\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user) || current_user.admin?\n flash[:danger] = \"It is not possible to access other users diaries\"\n redirect_to(root_url) \n end \n \n end",
"def get_user_to_act_on\n @user = session[:user]\n end",
"def get_user_to_act_on\n @user = session[:user]\n end",
"def correсt_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless (current_user?(@user) or is_admin?)\n\n end",
"def current_user\n session[:usr_id]\n end",
"def correct_user\n user_id = params[:user_id] || params[:id] || session[:user_id]\n @user = User.find_by(id: user_id)\n unless @user.nil?\n unless current_user?(@user) || current_user.administrator?\n flash[:danger] = \"Only the account owner or an adminstrator to do that.\"\n redirect_to(root_path)\n end\n else\n nonexistent_user_error\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_path) unless (current_user.admin? == true || current_user?(@user)) \n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def correct_user_or_admin\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) || current_user.admin?\n end",
"def current_admin_user\n @current_admin_user ||= AdminUser.find_by(id: session[:admin_user_id])\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) || current_user.admin?\n end",
"def show\n if @user.admin?\n @user = User.find(params[:id])\n end\n end",
"def user\n session[AutoAdmin::AutoAdminConfiguration.admin_model_id] ? AutoAdmin::AutoAdminConfiguration.admin_model.find(session[AutoAdmin::AutoAdminConfiguration.admin_model_id]) : nil\n end",
"def correct_user\n @user = User.find(session[:user_id])\n redirect_to(root_url) unless current_user == @user || current_user.is_admin?\n end",
"def show\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n \t@user = User.find(params[:id])\n else \n redirect_to '/'\n end\n end",
"def own_user_or_admin_required\n if current_user\n if (current_user.id == params[:id]) || current_user.admin\n return\n end\n end\n redirect_to \"/login\", notice: 'Logga in som denna användare för att ändra uppgifter.'\n end",
"def identify_the_user\n \t@current_user = User.find_by_id(session[\"user_id\"])\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless (current_user?(@user) || current_user.admin?)\n end",
"def current_or_guest_user(params)\n if current_user\n if cookies[:uuid]\n unless current_user.guest?\n cookies.delete :uuid\n end\n end\n current_user\n else\n guest_user(params)\n end\n end",
"def current_user\n User.where(id: session[:user_id]).first\n end",
"def correct_user_or_admin\n user = TempOrder.find(params[:id]).user\n unless current_user?(user) || admin_user?\n flash[:danger] = \"Uncorrect user.\"\n redirect_to root_url\n end\n end",
"def is_admin?(user_id)\n\t\treturn admin == user_id\n\tend",
"def user_id\n raise \"Implement in Client or Advocate\"\n end",
"def request_user(id)\n\t\t\t@admin = false\n\t\t\tif check_admin\n\t\t\t\t@admin = true\n\t\t\tend\n\n\t\t\tbegin\n\t\t\t\t@user = User.find(params[:id])\n\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\tredirect_to '/public/404.html', status: 404\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def show\n if @oeuser.id.to_i == params[:id].to_i\n @user = User.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n else\n flash[:error] = \"Restricted Access, You need to be Admin\"\n redirect_to root_url\n end\n end",
"def correct_user\n @user = User.find(params[:id])\n unless user_signed_in? && (current_user == @user || current_user.role == \"site_admin\")\n redirect_to(root_url)\n flash[:warning] = \"You can't access that!\"\n end\n\n end",
"def correct_user\n @user = User.find(params[:user_id])\n unless current_user?(@user) || current_user.admin?\n flash[:danger] = \"It is not possible to access other users diaries\"\n redirect_to(root_url) \n end \n \n end",
"def auth_user_id\n session[:current_user_id] unless session[:current_user_id].nil?\n end",
"def correct_user\n @user = User.find(params[:id])\n\n if current_user?(@user) || current_user.admin?\n return true\n else\n flash[:danger] = \"You do not have permission to do that. wwjd?\"\n redirect_to(root_path)\n end\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by(id: session[:user_id])\n end",
"def show\n @user = User.find(params[:id])\n unless current_user.admin?\n unless @user == current_user\n redirect_to :back, :alert => \"Access denied.\"\n end\n end\n end",
"def correct_user\n @user = User.friendly.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) || current_user.admin? || admin?(current_user)\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user) #checks if current_user == @user\n #current_user? defined in session helper\n end",
"def correct_user\n @user = User.find(params[:id])\n unless current_user?(@user) || current_user.admin\n flash[:danger] = \"Некорректный пользователь\"\n redirect_to(root_url) \n end\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to(root_url) unless current_user?(@user)\n flash[:danger] = \"Admin Access Only.\"\n end",
"def authorize_user_by_id\n\t\trender_unauthorized_msg unless current_user && current_user.id == params[:id].to_i\n\tend",
"def user\n user_id.get_object\n end",
"def current_user\n User.find session[:id] if session[:id]\n end",
"def correct_user\n @user = User.find(params[:id])\n redirect_to '/' unless @user == current_user || current_user.isadmin?\n end",
"def set_admin_user\n @user = User.find(params[:id])\n end",
"def client_side_current_user\n if session[:user_id]\n User.select([:first_name, :last_name, :email]).find session[:user_id]\n end\n end",
"def set_user\n @user = @current_user.admin ? User.find(params['id']) : @current_user\n end",
"def current_user\n User.find_by(id: session[:user_id])\nend",
"def correct_user\n\t\t\t#checks params hash for the user id storing that user into a variable\n\t\t\t@user = User.find(params[:id])\n\t\t\t#compares that user created above to the currently logged in user\n\t\t\tunless current_user?(@user) || is_admin?(current_user) #|| is_doctor?(current_user)\n\t\t\t\tredirect_to(root_url) \n\t\t\tend\n\t\tend",
"def verify_admin\n unless current_user.admin? or params[:id].to_i == current_user.id\n redirect_to users_path, :alert => 'You are unauthorized to do that.'\n end\n end",
"def show \n find_user\n # if !session[:user_id] == params[:id]\n # flash[:message] = \"Restricted Access!!!\"\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n end\nend",
"def require_admin_or_correct_user\n @user = User.find(params[:id])\n flash[:error] = \"Access Denied\"\n redirect_to(root_url) unless (current_user.id == @user.id || is_admin?)\n end",
"def current_user\n user = User.find_by(id: session[:user_id])\n end",
"def current_user\n User.find_by_id(session[:user_id])\n end",
"def find_user\n if !current_user.nil?\n @user=User.find(current_user.id)\n session[:admin_id][email protected]\n elsif !current_member.nil?\n @user=Member.find(current_member.id)\n session[:admin_id][email protected]_id\n end\n return @user\n end",
"def get_user_id\n if current_user\n @user = User.find(current_user.id)\n end\nend",
"def correct_user\n @user = User.find(params[:id])\n # TODO: Consider returning a 403 or 404 instead of redirecting to root.\n redirect_to(root_url) unless (current_user?(@user) || current_user.admin?)\n end",
"def correct_user\n #@user = User.find(params[:id])\n @user ||= User.find_by(id: session[:user_id])\n redirect_to(root_url) unless current_user?(@current_user)\n end"
] | [
"0.735896",
"0.7357242",
"0.73302084",
"0.7321911",
"0.7316402",
"0.7281784",
"0.71649903",
"0.71170217",
"0.7105338",
"0.708646",
"0.70781726",
"0.70715773",
"0.70343584",
"0.70318",
"0.70238256",
"0.70221776",
"0.7012857",
"0.6992297",
"0.6989097",
"0.6975193",
"0.6963761",
"0.69465226",
"0.69415945",
"0.6941347",
"0.69367343",
"0.69277537",
"0.6924484",
"0.69115365",
"0.6901661",
"0.68947935",
"0.6885153",
"0.68790644",
"0.68726003",
"0.6872118",
"0.685689",
"0.68538976",
"0.6853317",
"0.6848981",
"0.68487424",
"0.68487424",
"0.68480104",
"0.6843872",
"0.68427235",
"0.6838976",
"0.683764",
"0.683764",
"0.6835575",
"0.68338656",
"0.6830237",
"0.6824709",
"0.68215346",
"0.6818686",
"0.6807322",
"0.680534",
"0.6804576",
"0.68020827",
"0.68017685",
"0.6801313",
"0.68001753",
"0.6795578",
"0.6774176",
"0.6764161",
"0.6763722",
"0.675658",
"0.6754109",
"0.6751549",
"0.6749348",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.674347",
"0.6741044",
"0.6731577",
"0.673093",
"0.6730656",
"0.6730638",
"0.6725683",
"0.6724166",
"0.6724103",
"0.6716419",
"0.67094153",
"0.6708308",
"0.67055523",
"0.67053896",
"0.67004704",
"0.66968673",
"0.6695812",
"0.66929317",
"0.668985",
"0.6689115",
"0.6679994",
"0.66792876",
"0.6671121",
"0.66705537",
"0.6665678"
] | 0.0 | -1 |
Calls mattermost using the default Mattermost URL from the configuration data is a hash containing the data to send. Note that channel, username, and icon_url are reserved url is the Mattermost URL defined above. This can be overridden for debugging header is the default headers. This shouldn't need modified, but it's nice to have | def call_mattermost (data = {}, url = [Config['Mattermost']['url'], 'hooks', Config['Mattermost']['webhook_code']].join('/'), header = {content_type: :json, accept: :json})
if !data.has_key?(:login_id)
payload = data.merge(Config['DefaultPayload'])
else
payload = data
end
# Just in case, though we may not need text
unless payload.has_key?(:text) or payload.has_key?(:attachments)
payload['text'] = 'This was triggered on: ' + Time.now.strftime("%d/%m/%Y %H:%M") #Feel free to change this
end
response = RestClient.post url, payload.to_json, {content_type: :json, accept: :json}
return response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_data(push_params)\n # Push URI\n push_uri = URI.parse(\"#{$tipboard_base_uri}/#{$apikey}/push\")\n\n # Post to API to set up tile\n push_response = Net::HTTP.post_form(push_uri, push_params)\nend",
"def send_message(mes,token,user_id)\n #Open a direct message\n options = {\n token: token,\n user: user_id\n }\n channel_id = post('https://slack.com/api/im.open', options).channel.id\n\n #Send the message\n options = {\n token: token,\n channel: channel_id,\n text: mes\n }\n post('https://slack.com/api/chat.postMessage', options)\nend",
"def send\n generate_url\n end",
"def send\n generate_url\n end",
"def send_post(post)\n title = CGI.unescapeHTML(post['title'])\n author = post['author']\n url = post['url']\n time = post['created']\n link = 'https://reddit.com' + post['permalink']\n preview = post['thumbnail']\n # Create an Embed\n Bot.channel(Config['channel']).send_embed do |emb|\n emb.color = '3498db'\n emb.author = { name: title, url: link}\n emb.image = { url: preview }\n emb.url = link\n emb.add_field name: 'Link:', value: url, inline: false\n emb.footer = { text: \"Posted by /u/#{author} @ #{Time.at(time).strftime('%a, %d %b %H:%M')}\", icon_url: Bot.profile.avatar_url }\n end\nend",
"def send(data: {}, headers: {})\n `#@native.open(#{method}, #{url})`\n @data = data\n self.headers = headers\n\n if method == :get || method == :delete\n `#@native.send()`\n elsif Hash === data\n `#@native.send(#{JSON.generate data})`\n elsif `!!data['native']`\n `#@native.send(data['native'])`\n else\n `#@native.send(data)`\n end\n\n self\n end",
"def setup_for_posting(extra = {})\n @params = { \n :destination => :tumblr, \n :post_url => 'http://www.domain.com/example/post/',\n :site_url => 'http://www.domain.com/',\n :email => '[email protected]',\n :password => 's3kr17'\n }\n @params = @params.merge(extra)\n @sender = BotSender.new(@params)\nend",
"def postMultipackAdminLogo( multipack_id, filedata)\n params = Hash.new\n params['multipack_id'] = multipack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/multipack/adminLogo\",params)\n end",
"def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end",
"def postMultipackLogo( multipack_id, filedata)\n params = Hash.new\n params['multipack_id'] = multipack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/multipack/logo\",params)\n end",
"def push_tileconfig(tile_name, tileconfig_params)\n # Tileconfig URI\n tileconfig_uri = URI.parse(\"#{$tipboard_base_uri}/#{$apikey}/tileconfig/\" + tile_name)\n\n # Post to API to set up tileconfig\n tileconfig_response = Net::HTTP.post_form(tileconfig_uri, tileconfig_params)\nend",
"def post(title, target, message, color)\n a_message_note = {\n 'color' => color,\n 'fields' => [\n {\n 'title' => 'Message',\n 'value' => message,\n 'short' => false\n },\n {\n 'title' => 'Archive Name',\n 'value' => target,\n 'short' => true\n },\n {\n 'title' => 'Status',\n 'value' => color,\n 'short' => false\n }\n ]\n }\n\n notify_user = ENV['SLACK_USER'] || 'notifier'\n notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK'], :username => notify_user\n notifier.ping title, 'icon_emoji' => ENV['SLACK_ICON_EMOJI'], 'attachments' => [a_message_note]\nend",
"def uri\n sprintf(\"%s/%s?token=%s\", API_ENDPOINT, COMMAND, config.slack_bot_token)\n end",
"def http_post(curl, data, url)\n\n # Define the post data\n data2 = ''\n\n # Loop through the data[\"post_data\"] passed in to build up the post data string\n data[\"post_data\"].each do |key, value|\n if (data2 != '') then\n data2 = data2 + '&'\n end\n # If the value is null we don't just want it to look like: item=\n if (value.nil?) then\n data2 = data2 + CGI::escape(key.to_s) + '='\n else\n data2 = data2 + CGI::escape(key.to_s) + '=' + CGI::escape(value.to_s)\n end\n end\n\n # Define the url we want to hit\n curl.url = url\n # Specify the headers we want to hit\n curl.headers = data['header']\n\n # perform the call\n curl.post(data2)\n\n curl.headers = nil\n\n # Set headers to nil so none get reused elsewhere\n curl.headers = nil\n\n # return the curl object\n return curl\n\nend",
"def send_command(parms=nil)\n #logger.debug \"AQUIII ESTOOOY \"\n\n\n url = URI.parse(@control_url)\n #logger.debug \"URL #{@control_url}\"\n req = Net::HTTP::Get.new(url.path)\n\n\n #logger.debug \"URLpath #{url.path}\"\n if parms\n\t\t#logger.debug \"sent data #{parms.to_json}\"\n end\n \n\n req.basic_auth @username, @password if @username\n if parms\n\t\treq.set_form_data(parms)\n end\n \n \n res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }\n res.use_ssl = true if @control_url =~ /^https/\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n #logger.debug \"REspuesta #{res}\"\n return res.body\n else\n res.error!\n end\n end",
"def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-lh-version\" => KAKAOCERT_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n apiServerTime = @linkhub.getTime(@useStaticIP, @useGAIP)\n\n hmacTarget = \"POST\\n\"\n hmacTarget += Base64.strict_encode64(Digest::SHA256.digest(postData)) + \"\\n\"\n hmacTarget += apiServerTime + \"\\n\"\n\n hmacTarget += KAKAOCERT_APIVersion + \"\\n\"\n\n key = Base64.decode64(@linkhub._secretKey)\n\n data = hmacTarget\n digest = OpenSSL::Digest.new(\"sha256\")\n hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, key, data))\n\n headers[\"x-kc-auth\"] = @linkhub._linkID+' '+hmac\n headers[\"x-lh-date\"] = apiServerTime\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise KakaocertException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end",
"def post_message(\n access_token:,\n channel_id:,\n attachments: nil,\n blocks: nil,\n text: nil,\n link_names: true,\n markdown: true,\n parse: 'full',\n reply_broadcast: false,\n thread_ts: nil,\n unfurl_links: true,\n unfurl_media: true\n )\n return if attachments.blank? && blocks.blank? && text.blank?\n params = {\n channel: channel_id,\n attachments: attachments,\n blocks: blocks,\n text: text,\n link_names: link_names,\n mrkdwn: markdown,\n parse: parse,\n reply_broadcast: reply_broadcast,\n thread_ts: thread_ts,\n unfurl_links: unfurl_links,\n unfurl_media: unfurl_media\n }.compact\n response = HTTParty.post(\"https://slack.com/api/chat.postMessage\",\n body: params.to_json,\n headers: { 'Authorization': \"Bearer #{access_token}\", 'Content-Type': 'application/json' })\n JSON.parse(response.body, symbolize_names: true)\n end",
"def pm(content = nil)\n if content\n # Recursively call pm to get the channel, then send a message to it\n channel = pm\n channel.send_message(content)\n else\n # If no message was specified, return the PM channel\n @bot.pm_channel(@id)\n end\n end",
"def uri\n \"mcp://#{@options[:url]}\"\n end",
"def push\n cfm.send_to_remote if do_push?\n end",
"def post_messages!(hash)\n Net::HTTP.post_form(URI.parse(@target), {'data'=>hash.to_json})\n end",
"def set_mst_url(mst, rmt_id)\n url=\"http://#{$settings['redmine_host']}:#{$settings['redmine_port']}/issues/#{rmt_id}\"\n mst.HyperlinkAddress = url\n return url\nend",
"def post_to_slack\n system(\"curl -X POST --data-urlencode 'payload={\\\"channel\\\": \\\"#hedgehogs\\\", \\\"username\\\": \\\"Toto, Min and Fumi\\\", \\\"text\\\": \\\"現在、小屋の気温は #{@temparature.round(1)}℃です\\\"}' https://hooks.slack.com/services/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\")\n end",
"def post(message, params = {})\n return if options[:quiet]\n ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]\n Socialcast::CommandLine::Message.configure_from_credentials\n response = Socialcast::CommandLine::Message.create params.merge(:body => message)\n say \"Message has been posted: #{response.permalink_url}\"\n end",
"def set_whats_new_url(args = {}) \n put(\"/globalsettings.json/news/url\", args)\nend",
"def perform\n Kublog.facebook_client.link! :link => @url, :message => @message\n end",
"def curl_form_data(uri, form_data=[], options={})\n curl = Pkg::Util::Tool.find_tool(\"curl\") or fail \"Couldn't find curl. Curl is required for posting jenkins to trigger a build. Please install curl and try again.\"\n #\n # Begin constructing the post string.\n # First, assemble the form_data arguments\n #\n post_string = \"-i \"\n form_data.each do |param|\n post_string << \"#{param} \"\n end\n\n # Add the uri\n post_string << \"#{uri}\"\n\n # If this is quiet, we're going to silence all output\n if options[:quiet]\n post_string << \" >/dev/null 2>&1\"\n end\n\n %x{#{curl} #{post_string}}\n return $?.success?\nend",
"def dm(message)\n raise \"Could not send message because of invalid options #{options}\" unless NOTIFICARE_SETTINGS\n recipients = NOTIFICARE_SETTINGS[\"recipients\"].split(/\\s*,\\s*/)\n username = NOTIFICARE_SETTINGS[\"username\"]\n password = NOTIFICARE_SETTINGS[\"password\"]\n recipients.each do |recipient|\n uri = \"http://#{username}:#{password}@twitter.com/direct_messages/new.json\"\n yell \"Sending #{recipient}: #{message}\"\n Net::HTTP.post_form(URI.parse(uri), {'user' => recipient, 'text' => message})\n end \nend",
"def send_data\n request = Collector::Request.\n new(self.api_location,\n :user => config[:htpasswd_user],\n :pass => config[:htpasswd_pass])\n\n # convert the array of object to a hash\n server = {\n websites: @websites.map{ |w| w.to_hash(@version).merge({server: config[:client_name].underscore }) }.map{ |w| w[:website] },\n name: config[:client_name].underscore\n }\n\n request.send(server)\n\n end",
"def post_with_curl\n url = @settings.webhook_url\n `curl -is -X POST -H \"Content-Type:application/json\" -d '#{get_body}' '#{url}'`\n end",
"def send_request\n \t\taz = @args[:authorization] and az = \"Authorization: #{az}\\r\\n\"\n body = @args.delete(:body)\n headers = @args.delete(:headers)\n body.strip! if body\n content_type = @args[:content_type]\n \t\tr = [\n \t\t \t\"#{@args[:verb]} #{@args[:uri]} HTTP/#{@args[:version] || \"1.1\"}\\r\\n\",\n \t\t\t\"Host: #{@args[:host_header] || \"_\"}\\r\\n\",\n \t\t\taz || \"\",\n \t\t\t\"Content-Length: #{body.nil? ? 0 : body.size}\\r\\n\",\n \t\t\t\"Date: #{Time.now.httpdate}\\r\\n\",\n \t\t\tcontent_type.nil? ? \"\" : \"Content-Type: #{content_type}\\r\\n\"\n \t] + \n (headers.nil? ? [] : headers.keys.map{|key| \"#{key}: #{headers[key]}\\r\\n\"}) +\n [\"\\r\\n\", body]\n \n \t\[email protected]_data(r.join)\n \tend",
"def run(text,\n channel: DEFAULT_CHANNEL,\n username: DEFAULT_USERNAME,\n icon_url: DEFAULT_ICON_URL,\n icon_emoji: DEFAULT_ICON_EMOJI)\n\n payload = build_payload(text, channel, username, icon_url, icon_emoji)\n\n send_payload(payload)\n end",
"def post_message(token, channel, text, username)\n uri = URI.parse(URL[\"post_msg\"])\n params = { :token => token,\n :channel => channel,\n :text => text,\n :username => username,\n :as_user => true }\n uri.query = URI.encode_www_form( params )\n return JSON.parse( uri.open.read )\n end",
"def send_to_slack(token, channel_id, report_data) \n Slack.configure do |config|\n config.token = token\n end\n\n client = Slack::Web::Client.new\n client.auth_test\n\n message_title = \"Standup Report\"\n\n send_message_to_channel(client, channel_id, message_title, report_data)\nend",
"def send(content)\n @comm.send({method: \"custom\", content: content})\n end",
"def submit!(payload, metadata)\n username, password = basic_auth(metadata[:topic])\n @conn.basic_auth(username, password || \"x\")\n resp = @conn.post do |r|\n path = dynamic_path(metadata[:topic])\n r.url(path) if path\n\n r.body = payload\n r.headers[\"X-MagicPipe-Sent-At\"] = metadata[:time]\n r.headers[\"X-MagicPipe-Topic\"] = metadata[:topic]\n r.headers[\"X-MagicPipe-Producer\"] = metadata[:producer]\n end\n\n unless resp.success?\n msg = %Q{HTTP response: status=#{resp.status} body=\"#{resp.body}\"}\n raise SubmitFailedError.new(self.class, msg)\n end\n end",
"def send_email(resource,metric_info,dimension_info,url,metric_type)\n @user = resource \n @info = metric_info\n @dimension_info = dimension_info\n @url = url\n @metric_type = metric_type\n mail(:to => resource.email, :subject => \"Databot Websites Data\",:from => \"[email protected]\")\n end",
"def send(api_key, channel, message, items, code)\n client(api_key).chat_postMessage(\n channel: \"#\" + channel,\n as_user: true,\n attachments: [\n {\n fallback: \"#{message}\\n\\n\",\n pretext: \"#{message}\\n\\n\",\n title: items.select{|i| i[:title]}.try(:first)[:title],\n title_link: items.select{|i| i[:title_link]}.try(:first)[:title_link],\n color: Speko::Slack.enabled_configs[:codes][code],\n fields: generate_message(items),\n footer: items.select{|i| i[:user]}.try(:first)[:user] || 'unknown user?',\n ts: DateTime.now.to_i\n }\n ]\n )\n rescue\n Rails.logger.debug \"Could not post to Slack Channel: #{channel}\"\n false\n end",
"def mpim_open(options={})\n throw ArgumentError.new(\"Required arguments :users missing\") if options[:users].nil?\n options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]\n post(\"mpim.open\", options)\n end",
"def reply_to_thread(username, thread_id, params = {})\n $LOG.i \"running \" + __method__.to_s\n @client.post '/mc/v1/threads/' + username + '/' + thread_id, params\n end",
"def send_image(url, name, image_info = {})\n client.api.send_content(id, url, name, 'm.image', extra_information: image_info)\n end",
"def post\n uri = URI.parse(self.url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.open_timeout = 10\n http.read_timeout = 10\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n data = self.params.collect { |k, v| \"#{k}=#{CGI.escape(v.to_s)}\" }.join(\"&\")\n Freemium.log_test_msg(\"POST\\n url: #{self.url}\\n query: #{data}\")\n http.post(uri.request_uri, data).body\n end",
"def message(channel, data)\n\t\t\tmessage = {:channel => channel, :data => {:channel => channel}, :ext => {:private_pub_token => config[:secret_token]}}\n\t\t\tif data.kind_of? String\n\t\t\t\tmessage[:data][:eval] = data\n\t\t\telse\n\t\t\t\tmessage[:data][:data] = data\n\t\t\tend\n\t\t\tmessage\n\t\tend",
"def post_data(action, parameters = {})\n post = {}\n post[:action] = action\n post[:usepost] = 1\n post[:acctid] = @options[:test] ? 'TEST0' : @options[:login]\n post[:merchantpin] = @options[:password] if @options[:password] && !@options[:test]\n\n request = post.merge(parameters).map {|key,value| \"#{key}=#{CGI.escape(value.to_s)}\"}.join(\"&\")\n request\n end",
"def send_message(params)\n uri = URI.parse(@uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n parameters = \"\"\n params.each do |k,v|\n if parameters.empty?\n parameters = \"#{k}=#{v}\"\n else\n parameters += \"&#{k}=#{v}\"\n end\n end\n sig = generate_signature(params)\n parameters += \"&signature=#{sig}\"\n puts parameters \n response = http.post(\"/api/2/apps/#{@key}/messages.json\", \"#{URI.escape(parameters)}\")\n puts response\n return response.body\n end",
"def metum_params\n params.require(:metum).permit(:content_id, :data, :user_id, :approval_id, :post_id, :feed_id, :presenter_id, :friendship_id)\n end",
"def club_member_post_url(a,b,args={});user_post_url(a,b,args);end",
"def send(destination, contents, payload)\n request = Net::HTTP::Post.new(\"/#{destination}\")\n request.body = \"#{contents}=#{CGI.escape(payload.to_json)}\"\n uri = URI.parse(@settings[:url])\n if @settings[:basic_auth]\n request.basic_auth(@settings[:username], @settings[:password])\n end\n result = {:error => true}\n begin\n response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request(request) }\n if response.code == \"200\"\n result.merge!({\n :error => false,\n :message => \"iP Relay #{destination} #{contents} successfully sent\"\n })\n else\n result[:message] = \"iP Relay #{destination} #{contents} failure, response code was #{response.code}\"\n end\n rescue Exception => e\n result[:message] = \"iP Relay #{destination} #{contents} failure, exception was #{e}\"\n end\n\n puts result[:message]\n result\n end",
"def send_incoming_webhook(key, feature, channel_id)\n payload = $redis.get(\"payload:#{key}\")\n if payload.nil?\n payload = {\n :text => \"\"\n }\n attachments = []\n attachments << build_attachment(key, feature)\n payload[:attachments] = attachments\n $redis.setex(\"payload:#{key}\", 60*60*24, payload.to_json)\n else\n payload = JSON.parse(payload)\n end\n payload[:channel] = channel_id\n HTTParty.post(ENV[\"INCOMING_WEBHOOK_URL\"], :body => payload.to_json)\nend",
"def post_with_app(url, payload = '')\n github_api_conn.post do |request|\n request.url url\n\n request.headers['Authorization'] = \"Token #{access_token}\"\n request.headers['Accept'] = accept_header\n request.body = payload\n end\n end",
"def send(users, content, options = {})\n body = {\n channels: channels(users),\n expiration_time: Time.zone.now + 15.minutes,\n data: {\n title: 'Pill Reminder from MIST System',\n alert: content\n }\n }\n\n HTTParty.post @api, headers: @headers, body: body.to_json\n end",
"def message(channel, data)\n {channel: channel, data: data, ext: { private_pub_token: config[:secret_token] } }\n end",
"def send_message(text, channel)\n uri = URI('https://slack.com/api/chat.postMessage')\n params = {\n token: ENV['BOT_OAUTH_TOKEN'],\n text: text,\n channel: channel\n }\n uri.query = URI.encode_www_form(params)\n\n Net::HTTP.get_response(uri)\n end",
"def post\n messages.each do |message|\n Flowdock::Client.new(flow_token: @token).post_to_thread(message)\n end\n end",
"def postSales_logSyndication( action_type, syndication_type, publisher_id, expiry_date, entity_id, group_id, seed_masheryid, supplier_masheryid, country, reseller_masheryid)\n params = Hash.new\n params['action_type'] = action_type\n params['syndication_type'] = syndication_type\n params['publisher_id'] = publisher_id\n params['expiry_date'] = expiry_date\n params['entity_id'] = entity_id\n params['group_id'] = group_id\n params['seed_masheryid'] = seed_masheryid\n params['supplier_masheryid'] = supplier_masheryid\n params['country'] = country\n params['reseller_masheryid'] = reseller_masheryid\n return doCurl(\"post\",\"/sales_log/syndication\",params)\n end",
"def notify_slack(message,author,msg_link='',body,color)\n slack_headers = {\n content_type: :json,\n accept: :json\n }\n attachment = [\n {\n author_name: author,\n fallback: message,\n title: message,\n title_link: msg_link,\n text: body,\n color: color\n }\n ]\n payload = {\n username: 'Chef CI',\n attachments: attachment\n }\n RestClient.post(\n @slack_url,\n payload.to_json,\n slack_headers\n ) if defined?(settings.slack_url)\n end",
"def permalink(mobile=false)\n if mobile\n \"http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/mobile/post/#{reply_to}\"\n else\n \"http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/p/#{reply_to}?comment_id#{id}\"\n end\n end",
"def method_missing(symbol,*args)\n if args.length >= 1\n link_only = false\n if symbol == :link_for\n symbol = args.shift\n link_only = true\n end\n @logger.debug(\"Executing a #{symbol} against gliffy for url #{args[0]}\")\n\n # exposing this for testing\n protocol = determine_protocol(args[1])\n @full_url_no_params = protocol + \"://\" + @api_root + replace_url(args[0])\n url = SignedURL.new(@credentials,@full_url_no_params,symbol == :GET ? 'GET' : 'POST')\n url.logger = @logger\n url.params = args[1] if !args[1].nil?\n url[:protocol_override] = nil\n url[:action] = symbol\n\n # These can be override for testing purposes\n timestamp = args[2] if args[2]\n nonce = args[3] if args[3]\n\n full_url = url.full_url(timestamp,nonce)\n if link_only\n return full_url\n else\n response = @http.post(full_url)\n return response\n end\n else\n super(symbol,args)\n end\n end",
"def push(data)\n raise Geckoboard::Push::Error.new(\"Api key not configured.\") if Geckoboard::Push.api_key.nil? || Geckoboard::Push.api_key.empty?\n result = JSON.parse(self.class.post(\"/#{Geckoboard::Push.api_version || 'v1'}/send/#{@widget_key}\", {:body => {:api_key => Geckoboard::Push.api_key, :data => data}.to_json}).body)\n raise Geckoboard::Push::Error.new(result[\"error\"]) unless result[\"success\"]\n result[\"success\"]\n end",
"def postFlatpackAdminSmallLogo( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/adminSmallLogo\",params)\n end",
"def speak_messenger_old(msg, url, options)\n url ||= RedmineMessenger.settings[:messenger_url]\n return if url.blank? #|| channels.blank?\n params = { text: msg, link_names: 1 }\n username = textfield_for_project(options[:project], :messenger_username)\n params[:username] = username if username.present?\n params[:attachments] = options[:attachment]&.any? ? [options[:attachment]] : []\n icon = textfield_for_project options[:project], :messenger_icon\n if icon.present?\n if icon.start_with? ':'\n params[:icon_emoji] = icon\n else\n params[:icon_url] = icon\n end\n end\n\n #channels.each do |channel|\n uri = URI(url)\n #params[:channel] = channel\n http_options = { use_ssl: uri.scheme == 'https' }\n http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless RedmineMessenger.setting?(:messenger_verify_ssl)\n begin\n req = Net::HTTP::Post.new uri\n req.set_form_data payload: params.to_json\n Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|\n response = http.request req\n Rails.logger.warn(response.inspect) unless [Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPOK].include? response\n end\n rescue StandardError => e\n Rails.logger.warn \"cannot connect to #{url}\"\n Rails.logger.warn e\n end\n end",
"def postFlatpackAdminLargeLogo( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/adminLargeLogo\",params)\n end",
"def wechat_api api_name, wat, data\n apiURLs={\n :sendTemplateMessage => \"cgi-bin/message/template/send?access_token=#{wat}\",\n :sendTextMessage => \"cgi-bin/message/custom/send?access_token=#{wat}\"\n }\n base = 'https://api.weixin.qq.com/'\n url = base + apiURLs[api_name]\n\n res = RestClient.post url, data.to_json\n return JSON.parse res.body\nend",
"def ssh_send_url_ruby(host, username, command, content_url)\n content_url = URI.parse(URI.encode(content_url.to_s))\n ssh_ruby(host, username, command) do |channel|\n HTTPClient.new.get_content(content_url) do |chunk|\n channel.send_data chunk\n end\n end\n end",
"def formatted_link\n host = ENV['HEROKU_APP_NAME'] ? \"#{ENV['HEROKU_APP_NAME']}.herokuapp.com\" : 'localhost:3000'\n \"<#{Rails.application.routes.url_helpers.thread_url(id, host: host, format: :json)}|this thread>\"\n end",
"def feed_url\n client_url = 'https://kitsu.io'\n # Direct to user notifications list when more than one action\n return \"#{client_url}/notifications\" if activities.length > 1\n\n model_type, model_id = activity['foreign_id'].split(':')\n path = ''\n case model_type\n when 'Follow'\n path = \"/users/#{actor_id}\"\n when 'Post'\n path = \"/posts/#{model_id}\"\n when 'Comment'\n path = \"/comments/#{model_id}\"\n when 'PostLike'\n target_id = activity['target'].split(':').last\n path = \"/posts/#{target_id}\"\n when 'CommentLike'\n target_id = activity['target'].split(':').last\n path = \"/comments/#{target_id}\"\n when 'GroupInvite'\n path = \"/group-invite/#{model_id}\"\n end\n\n \"#{client_url}#{path}\"\n end",
"def post_haiku(line_1,line_2,line_3)\n url = ENV[\"SLACK_URL\"]\n payload = {username: \"haiku-bot\", icon_url: \"christmas-haiku.jpg\", text: line_1+\"\\n\"+line_2+\"\\n\"+line_3, channel: \"#random\"}\n RestClient.post(url, payload.to_json, accept: :json)\n end",
"def chat_postMessage(options = {})\n raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?\n raise ArgumentError, 'At least one of :attachments, :blocks, :text is required' if options[:attachments].nil? && options[:blocks].nil? && options[:text].nil?\n options = encode_options_as_json(options, %i[attachments blocks metadata])\n post('chat.postMessage', options)\n end",
"def send_dm(current_user , next_user)\n text_to_send = generate_message(current_user[:id], next_user.slack_id)\n open_channel = open_im_channel(BOT_TOKEN, next_user.slack_id)\n if open_channel[\"ok\"] then\n post_msg = post_message(BOT_TOKEN, open_channel[\"channel\"][\"id\"], text_to_send, BOT_USERNAME)\n if post_msg[\"ok\"] then\n close_channel = close_im_channel(BOT_TOKEN, open_channel[\"channel\"][\"id\"])\n return close_channel\n end\n end\n end",
"def init\n home_url = \"https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN&token=#{@token}\"\n headers = {\n host: 'mp.weixin.qq.com',\n referer: 'https://mp.weixin.qq.com/'\n }\n\n @cookies = {\n data_bizuin: URI.unescape(cookies['data_bizuin']),\n data_ticket: URI.unescape(cookies['data_ticket']),\n slave_user: URI.unescape(cookies['slave_user']),\n slave_sid: URI.unescape(cookies['slave_sid']),\n bizuin: URI.unescape(cookies['bizuin'])\n }\n\n msg_send_url = 'https://mp.weixin.qq.com/cgi-bin/masssendpage'\\\n \"?t=mass/send&token=#{@token}&lang=zh_CN\"\n msg_send_page = RestClient.get msg_send_url, cookies: @cookies\n\n ticket_reg = /.*ticket\\s*:\\s*\\\"(\\w+)\\\".*user_name\\s*:\\s*\\\"(.*)\\\",.*nick_name\\s*:\\s*\\\"(.*)\\\".*/m\n operation_seq_reg = /.*operation_seq\\s*:\\s*\\\"(\\d+)\\\".*/\n @operation_seq = $1 if operation_seq_reg =~ msg_send_page.to_s\n if ticket_reg =~ msg_send_page.to_s\n @ticket = $1\n @user_name = @ticket_id= $2\n true\n else\n false\n end\n end",
"def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:)\n @client.post(@webhook_url) do |request|\n request.headers['Content-Type'] = 'application/json'\n request.body = {\n channel: channel,\n username: username,\n icon_url: icon_url,\n attachments: attachments,\n link_names: link_names\n }.to_json\n end\n end",
"def notify msg, channel \n if @slack_url == '' \n puts \"No slack webhook url specified\"\n return\n end\n \n hash = {:text => msg, :channel => channel}\n json = JSON.generate(hash)\n payload = \"payload=#{json}\"\n\n `curl -X POST --data-urlencode '#{payload}' #{@slack_url}`\n end",
"def web\n Minimart::Commands::Web.new(options).execute!\n\n rescue Minimart::Error::BaseError => e\n Minimart::Error.handle_exception(e)\n end",
"def mpim_replies(options = {})\n throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?\n throw ArgumentError.new('Required arguments :thread_ts missing') if options[:thread_ts].nil?\n options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]\n post('mpim.replies', options)\n end",
"def publish(command, options)\n if command == 'request'\n options = {:uri => '', :method => 'GET', :source => ''}.merge(options)\n options[:content_type] = 'vnd.spotify/mercury-mget-request' if options[:payload].is_a?(Schema::Mercury::MercuryMultiGetRequest)\n payload = options.delete(:payload)\n\n # Generate arguments for the request\n args = [\n METHODS[options[:method]] || 0,\n Base64.encode64(Schema::Mercury::MercuryRequest.new(options).encode)\n ]\n args << Base64.encode64(payload.encode) if payload\n\n # Update the command to what Spotify expects\n command = 'sp/hm_b64'\n else\n args = options\n end\n\n message = {\n :id => next_message_id,\n :name => command,\n :args => args || []\n }\n\n logger.debug \"Message sent: #{message.inspect}\"\n @socket.send(message.to_json)\n\n # Add timeout handler\n EventMachine.add_timer(@timeout) do\n dispatch('id' => message[:id], 'command' => 'response_received', 'error' => 'timed out')\n end if @timeout\n\n message[:id]\n end",
"def mpim_history(options={})\n throw ArgumentError.new(\"Required arguments :channel missing\") if options[:channel].nil?\n options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]\n post(\"mpim.history\", options)\n end",
"def post_single_url(url,serv,q,variable_name,usr,pass)\n\n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse serv \n# req = Net::HTTP::Post.new(u.request_uri,{'User-Agent' => useragent})\n puts \"posting to #{serv} variable_name #{variable_name}\"\n if (u.query)\n req = Net::HTTP::Post.new(u.path+ '?' + u.query,{'User-Agent' => useragent})\n else\n req = Net::HTTP::Post.new(u.path,{'User-Agent' => useragent})\n end\n if(variable_name)\n req.set_form_data({variable_name=>q}, ';')\n else\n req.set_form_data({'url'=>url}, ';')\n end\n req.basic_auth usr,pass\n\n begin \n res2 = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n end\n\n r = \"\"\n begin\n r = res2.body\n rescue OpenURI::HTTPError=>e\n case e.to_s \n when /^404/\n raise 'Not Found'\n when /^304/\n raise 'No Info'\n end\n end\n return r\nend",
"def connect options={}\n\n Thread.current[\"GopDataTrust/Api/@token\"] = (options[:token] || self.default_token)\n if options[:production].eql?(true) || (options[:production].nil? && self.default_production?)\n Thread.current[\"GopDataTrust/Api/@base_url\"] = \"https://www.gopdatatrust.com/v2/api/\"\n else\n Thread.current[\"GopDataTrust/Api/@base_url\"] = \"https://lincoln.gopdatatrust.com/v2/api/\"\n end\n\n\n nil\n end",
"def send(message)\n\t\turl_arg = @params\n\t\turl_arg[\"input\"] = message\n\t\turl_arg_str = URI.encode_www_form(url_arg)\n\n\t\theaders = {\n\t\t\t'User-Agent' => 'cleverbotrb https://github.com/d0p1s4m4/cleverbotrb',\n\t\t}\n\n\t\treq = Net::HTTP.new(HOST, 80)\n\t\tresp = req.get(@endpoint + url_arg_str, headers)\n\t\tif resp.code != \"200\"\n\t\t\treturn nil\n\t\tend\n\t\tresponse = JSON.parse(resp.body)\n\t\t@params['cs'] = response['cs']\n\t\treturn response['output']\n\tend",
"def post(opts = {})\n return ':data argument not provided' unless opts[:data]\n \n type = opts[:type] || Names::AtomEntryMediaType\n @invoker = Poster.new(@uri, @authent)\n @invoker['Slug'] = opts[:slug] if opts[:slug]\n \n if @invoker.post(type, opts[:data]) \n @invoker.entry \n else\n @invoker.last_error \n end\n end",
"def send_team_chat\n data = {display_name: params[:display_name],\n avatar: params[:avatar],\n chat_text: params[:chat]}\n Pusher.trigger(params[:channel], 'chat_message', data)\n end",
"def send\n post_params = {}\n self.parameters.each { |key, value|\n if value.is_a? Array\n i = 0\n value.each { |value_value|\n post_params[key.to_s + '[' + i.to_s + ']'] = value_value.to_s\n i += 1\n }\n elsif value.is_a? Hash\n value.each { |value_key, value_value|\n post_params[key.to_s + '[' + value_key.to_s + ']'] = value_value.to_s\n }\n else\n post_params[key.to_s] = value.to_s\n end\n }\n\n url = URI.parse(@@API_URL)\n http_request = Net::HTTP::Post.new(url.path)\n http_request.form_data = post_params\n http_request.basic_auth url.user, url.password if url.user\n\n response = Spree::PAYONE::Proxy::Response.new\n connection = Net::HTTP.new(url.host, url.port)\n load_ca_file connection\n connection.use_ssl = true\n connection.start { |http|\n http_response = http.request(http_request)\n response.response_body= http_response.body\n }\n\n response\n end",
"def method_missing(m, *args)\n # note that 'href' method is not defined on this class; use 'path' instead.\n client.send(:do_post, [ path, m.to_s ].join('/'), *args)\n end",
"def push(asset, account, content, channel = @default_send_channel)\n begin\n PUNK.start('push','pushing msg ...')\n\n msg = user_api.mdi.dialog.create_new_message({\n 'meta' => {\n 'account' => account\n },\n 'payload' => {\n 'id' => CC.indigen_next_id(asset),\n 'type' => 'message',\n 'sender' => '@@server@@',\n 'recipient' => asset,\n 'channel' => channel,\n 'payload' => content,\n 'asset' => asset\n }\n })\n if RAGENT.running_env_name == 'sdk-vm'\n TestsHelper.message_sent(msg)\n end\n user_api.mdi.tools.protogen.protogen_encode(msg).each {|message| message.push}\n # success !\n PUNK.end('push','ok','out',\"SERVER -> MSG[#{crop_ref(msg.id,4)}]\")\n\n\n SDK_STATS.stats['agents'][user_api.user_class.agent_name]['push_sent_to_device'] += 1\n SDK_STATS.stats['agents'][user_api.user_class.agent_name]['total_sent'] += 1\n return true\n rescue Exception => e\n user_api.mdi.tools.log.error(\"Error on push\")\n user_api.mdi.tools.print_ruby_exception(e)\n PUNK.end('push','ko','out',\"SERVER -> MSG\")\n # stats:\n SDK_STATS.stats['agents'][user_api.user_class.agent_name]['err_on_push'] += 1\n SDK_STATS.stats['agents'][user_api.user_class.agent_name]['total_error'] += 1\n return false\n end\n end",
"def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend",
"def post_message(params = {}, opts = {})\n retries = 1\n begin\n log.info { \"out_slack: post_message #{params.dup.tap {|p| p[:token] = '[FILTERED]' if p[:token] }}\" }\n post(post_message_endpoint, params)\n rescue ChannelNotFoundError => e\n if opts[:auto_channels_create]\n log.warn \"out_slack: channel \\\"#{params[:channel]}\\\" is not found. try to create the channel, and then retry to post the message.\"\n channels_create({name: params[:channel], token: params[:token]})\n retry if (retries -= 1) >= 0 # one time retry\n else\n raise e\n end\n end\n end",
"def send_message_to_channel(client, channel_id, title, message)\n client.chat_postMessage(\n channel: channel_id, \n as_user: true,\n text: \"*\" + title + \"*\",\n attachments: [\n text: message,\n color: \"warning\"\n ]\n )\nend",
"def postFlatpackLogo( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/logo\",params)\n end",
"def send_magic_link(email, redirect_url = '', life_time = 24)\n data = {\n email: email,\n redirectUrl: redirect_url,\n lifeTime: life_time\n }\n @client.raw('post', '/users/magic-link', nil, { data: data }, '/api/v1')\n end",
"def send(options={})\n end",
"def send_log(message, token, dimensions, application_type = nil)\n request(message, token, dimensions, application_type)\n @log.debug(\"Successfully sent log=#{message}, with token=#{token} and dimensions=#{dimensions} to monasca-log-api\")\n rescue => e\n @log.warn('Sending message to monasca-log-api threw exception', exceptionew: e)\n end",
"def send_request(options)\n\n # construct our RESTful request URI\n uri = \"#{Base.base_uri}/api/#{options[:target]}\"\n uri += \"/#{options[:id]}\" if options.has_key?(:id)\n uri += \"/#{options[:what]}\" if options.has_key?(:what)\n uri += \".#{options[:how]}\" if options[:method] == \"get\"\n puts \"|--------------------- SEND_REQUEST ---------------------|\"\n puts \"| URI\"\n puts \"| #{uri}\"\n puts \"| Params\"\n puts \"| id => #{options[:id]}\"\n puts \"| what => #{options[:what]}\"\n puts \"| how => #{options[:how]}\"\n puts \"|--------------------- ------------ ---------------------|\"\n \n if @access_token.nil? \n return self.class.send(options[:method] || \"get\", uri, options)\n else\n return @access_token.send(options[:method] || \"get\", uri, options).body\n end\n \n end",
"def call_remote \n def method_missing(*args)\n method, path = args\n if [:get, :post, :delete].index(method)\n sh \"\\ncurl -w '\\\\n' -X #{method.to_s.upcase} http://ec262discovery.herokuapp.com#{path}\"\n end\n end\n\n yield\n end",
"def to(phone, content, options)\n send_with_block do\n res = Net::HTTP.post_form(URI.parse(URL),\n userCode: options[:username],\n userPass: options[:password],\n DesNo: phone,\n Msg: content,\n Channel: 0)\n result res.body\n end\n end",
"def post_message\n\t\tdata = {\n\t\t\t:name => \"test_name_#{rand(256)}\",\n\t\t\t:message => \"test_name_#{rand(256)}\"\n\t\t}\n\t\tpost '/', data\n\t\t# Refering to the data variable in the last line of the code block\n\t\t# will cause data to be the return value.\n\t\tdata\n\tend",
"def send(key)\n HTTParty.post(@add_url, {\n :headers => {\n \"Content-Type\" => \"application/json; charset=UTF8\",\n \"X-Accept\" => \"application/json\"\n },\n :body => {\n #:url => formatted[:url],\n :url => \"https://www.engadget.com/2016/10/09/more-galaxy-note-7-replacement-fires/\",\n #:tags => formatted[:tags],\n :consumer_key => ENV['POCKET_CONSUMER_KEY'],\n :access_token => key\n }.to_json\n })\n end",
"def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end",
"def send_message!(params = {})\n call_api(\"directmessage/#{secret}/#{token}\",params)\n end",
"def post_content(post, options = {})\n circle = list_circles['items'].detect { |item| item['displayName'] == 'Private' }\n insert_activity(nil, {\n 'object' => {'content' => post.message },\n 'access' => {'items' => [{\n 'type' => 'circle',\n 'id' => circle['id']\n }]}\n })\n end",
"def send! data\n send_output_io! data if @output_io || host\n send_log_io! data if log_io\n self\n end"
] | [
"0.5465588",
"0.542814",
"0.53797555",
"0.53797555",
"0.53348374",
"0.51957387",
"0.49491575",
"0.48877075",
"0.4883532",
"0.48634773",
"0.4846544",
"0.48428428",
"0.48361412",
"0.48356918",
"0.48224252",
"0.4820484",
"0.48077616",
"0.47950903",
"0.4787078",
"0.47738805",
"0.47655332",
"0.47643667",
"0.47575295",
"0.47519317",
"0.4742383",
"0.47423056",
"0.47212768",
"0.47177228",
"0.4717629",
"0.4694455",
"0.46922037",
"0.4684527",
"0.4682668",
"0.4677014",
"0.46661872",
"0.46644184",
"0.46599028",
"0.46298906",
"0.4626048",
"0.4620728",
"0.46191585",
"0.46137702",
"0.46118498",
"0.45849955",
"0.45818636",
"0.45786944",
"0.4577482",
"0.4571534",
"0.456316",
"0.4555145",
"0.45488808",
"0.4542476",
"0.4539216",
"0.45326987",
"0.45312646",
"0.45301104",
"0.45262405",
"0.45207548",
"0.45207343",
"0.45148188",
"0.4513292",
"0.45107684",
"0.45096982",
"0.44984445",
"0.44982088",
"0.44944364",
"0.44880292",
"0.44823283",
"0.4478672",
"0.44741252",
"0.44741124",
"0.44687822",
"0.44642484",
"0.44630918",
"0.446209",
"0.44577786",
"0.44563863",
"0.44522792",
"0.44458613",
"0.44442642",
"0.44440976",
"0.44425735",
"0.44388178",
"0.4437516",
"0.4434299",
"0.44280973",
"0.44275993",
"0.44224134",
"0.44223934",
"0.44197917",
"0.44162828",
"0.44077697",
"0.44035485",
"0.44024193",
"0.44019908",
"0.44005498",
"0.43994927",
"0.4396444",
"0.43954223",
"0.43894178"
] | 0.72075117 | 0 |
upload_file moves the file to the webserver from the config file filename: The full path of the image file video_filename: Used to generate a unique MD5 hash for each image file | def upload_file (filename, video_filename)
# new filename is the md5 of the old filename, plus "jpg"
new_filename = Digest::MD5.hexdigest video_filename
new_filename += '.jpg'
FileUtils.mv(filename, [Config['WebServer']['webroot'], Config['WebServer']['preview_dir'], new_filename].join('/'))
return [Config['WebServer']['url'], Config['WebServer']['preview_dir'], new_filename].join('/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload(file)\n logger.info 'Downloading video...'\n path = file.download.path\n movie = FFMPEG::Movie.new(path)\n @mp4_path = encode('mp4', movie, '-vcodec libx264 -strict -2')\n @webm_path = encode('webm', movie, '-vcodec libvpx -acodec libvorbis -f webm -deadline realtime -s 640x480')\n end",
"def file_upload\n tmp = params[:configfile]\n file = File.join(\"public\", \"uploads\", params[:configfile].original_filename)\n FileUtils.cp tmp.path, file\n puts \"File uploaded to: public/uploads\"\n # Put up file load success alert?\n redirect_to(\"/dashboard/manage\", :notice => \"File #{params[:configfile].original_filename} uploaded\")\n end",
"def img_upload(file)\n\t \t# puts \"++++ #{file.inspect} ++++\"\n\t \tpath=File.dirname(__FILE__) + '/public/uploads/' + file[:filename]\n\t \t# puts \"///////\"\n\t \t# puts path\n\t \tFile.open(path, \"w\") do |upload|\n\t \t\tupload.write(file[:tempfile].read)\n\t end\n\t return file[:filename]\n\t end",
"def create\n @video = Video.new(params[:video])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://10.10.140.70:5000/files/\"+Utils.upload(video_file, videoid)\n @video.video_id = videoid\n end\n if img_file != nil\n @video.video_img =\"http://10.10.140.70:5000/files/\"+Utils.upload(img_file, nil)\n end\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to today_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def upload_video_at_s3(filename, filepath) \n\t\tbegin\n\t\t\ts3 = Aws::S3::Resource.new\n\t\t\tobj = s3.bucket(ENV['AWS_S3_BUCKET'] || 'tv-guide-s3-bucket').object(filename)\n\t\t\tif obj.upload_file(filepath)\n\t\t\t\tself.update(video_filename: filename) \n\n\t\t\t\tFile.delete(filepath) \n\t\t\tend\n\t\trescue StandardError => e\n\t \tRails.logger.info \"================================================upload_video_at_s3:69\"\n\t \tRails.logger.info e\n\t\tend\n\tend",
"def upload_file\n #TODO\n end",
"def update\n @video = Video.find(params[:id])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://10.10.140.70:5000/files/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://10.10.140.70:5000/files/\"+Utils.upload(img_file, nil)\n end\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to today_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def savevid\n tmp = params[:vids][:video].tempfile\n #require 'ftools'\n file = File.join(\"app/assets/videos\", params[:vids][:video].original_filename) # use public if you want\n FileUtils.cp tmp.path, file\n\n redirect_to \"/admin\"\nend",
"def process_uploaded_video_file\n if @video_file.present?\n video_file_stream = if @video_file.respond_to?(:path, true)\n File.open(@video_file.path)\n else\n @video_file\n end\n @uploaded_video_token = local_or_global_kaltura_client.\n media_service.upload(video_file_stream)\n raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?\n end\n end",
"def update\n @video = Video.find(params[:id])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://#{Constants::UPLOAD_IP}/files/videos/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://#{Constants::UPLOAD_IP}/files/images/\"+Utils.upload(img_file, nil)\n end\n\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to channel_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def file_upload(file)\n file[\"//\"] = \"/\"\n file = ENV['RED5_HOME'] + \"/webapps/encrev1/#{file}\"\n request_url = \"#{@url}/file/demo\"\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Request filename : #{request_url}\"\n response = RestClient.put request_url, \"\"\n $log.info \"--> Got reponse : #{response}\"\n file_name = JSON.parse(response.to_str)['result']\n if file_name\n $log.info \"--> Got filename : #{file_name}\"\n request_url = \"#{@url}/file/demo/\"\n request_url += file_name\n request_url += \"?uid=#{@conf.uid}&sid=#{@conf.sid}\"\n $log.info \"Upload (#{file}) to Encre : #{request_url}\"\n response = RestClient.put request_url, File.read(file), :content_type => 'application/x-shockwave-flash'\n $log.info \"Delete #{file} ...\"\n file = File.delete(file)\n else\n file_name = nil\n end\n rescue\n file_name = nil\n $log.info \"... failed ! (check exception below)\"\n $log.info $!\n end",
"def upload_file\n full_path = file_path.join(file_name)\n File.open(full_path, 'wb') do |file|\n file.write(@file.read)\n end\n\n full_path.sub(Rails.root.to_s, '')\n end",
"def create\n @channel = params[:forminfo]\n @video = Video.new(params[:video])\n video_file = params[:video_file]\n img_file = params[:img_file]\n @video.video_type = params[:video_type]\n @video.video_id = Utils.videoid\n\n if video_file != nil\n @video.video_url = \"http://#{Constants::UPLOAD_IP}/files/videos/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://#{Constants::UPLOAD_IP}/files/images/\"+Utils.upload(img_file, nil)\n end\n @video.cid = @channel\n respond_to do |format|\n if @video.save\n format.html { redirect_to channel_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def uploadFile(localFilePath, destFilePath, maxAge = 172800) # 2 Days = 1,72,800 seconds \n ext = File.extname(localFilePath).downcase\n msgContentType = \"\"\n cacheControl = \"max-age=#{maxAge}, must-revalidate\"\n if (ext == \"\")\n contentType = 'text/html'\n msgContentType = \"No file-ext: \"\n elsif (Fh5::Config.instance.contentTypes && Fh5::Config.instance.contentTypes.has_key?(ext))\n contentType = Fh5::Config.instance.contentTypes[ext]\n msgContentType = \"Override for '#{ext}':\"\n else \n contentType = MimeMagic.by_path(destFilePath).type\n end\n @log.info(@logPrefix) {\"Upload: '#{destFilePath}' (#{msgContentType}#{contentType}) (#{cacheControl})\"}\n begin\n File.open(localFilePath) do |f|\n content = f.read\n @bucketAdmin.defaultBucket.put(destFilePath, content, {}, 'public-read', \n {'Content-Type' => contentType, 'Cache-Control' => cacheControl})\n end\n rescue\n @log.errorException($!, @logPrefix) {\"Failed to upload to: '#{destFilePath}'\"}\n\n return nil\n end\n \n # comment out stuff related to public links which doesn't seem to work for website bucket.\n # publicLink = @bucketAdmin.endpointBucket.key(destFilePath).public_link\n # @log.debug(@logPrefix) {\"Public link: '#{publicLink}' for file: '#{destFilePath}'\"}\n # return publicLink \n end",
"def upload_file(file)\n file_path = file.path\n\n @size = File.size(file_path)\n @filename = File.basename(file_path)\n @io = File.open(file_path)\n io.binmode\n Rails.logger.debug \"filename of file to upload: #{filename} filepath: #{file_path}\"\n upload_io(io, size, filename).tap do\n io.close\n end\n end",
"def create\n\n @video_object = params[:video][:video_file] \n @video = Video.new(video_params)\n @video.competition = @competition \n @video.video_original_filename = @video_object.original_filename.to_s\n @video.video_content_type = @video_object.content_type.to_s\n\n respond_to do |format|\n if @video.save\n upload_file(@video.id, @video_object, \"original-videos\")\n send_msg_to_queue(@video.id.to_s)\n format.html { redirect_to @video.competition, success: 'Hemos recibido tu video y lo estamos procesando para que sea publicado. Tan pronto el video quede publicado en la página del concurso te notificaremos por email. Gracias.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fileupload(filename)\n unless filename &&\n (tempfile = filename[:tempfile]) &&\n (name = filename[:filename])\n @error = \"No file selected\"\n return false\n end\n p filename\n fileextension = filename[\"filename\"]\n if File.extname(\"#{fileextension}\") == \".png\" or File.extname(\"#{fileextension}\") == \".jpg\" or File.extname(\"#{fileextension}\") == \".jpeg\" or File.extname(\"#{fileextension}\") == \".gif\"\n puts \"Uploading file, original name #{name.inspect}\"\n target = \"public/img/#{name}\"\n slimroute = \"img/#{name}\"\n files = {target: target, slimroute: slimroute, tempfile: tempfile}\n return files\n else\n return false\n end\nend",
"def create\n\n #動画基本情報\n @video = Video.new(video_params)\n @video.user_id = get_user_id\n\n upload_file = params[:file]\n\n # ファイル必須\n if upload_file.nil?\n @video.errors.add(:file, \"は最低1つアップしてください。\")\n end\n\n respond_to do |format|\n if !upload_file.nil? && @video.save\n UpfileManageService.save(upload_file, @video)\n format.html { redirect_to videos_url, notice: '動画情報を登録しました。' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def videos_upload\n\n file_extname = File.extname self.file_upload.original_filename\n new_file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}#{self[:employee_id]}#{file_extname}\"\n folder_path = \"/videos/#{Time.now.strftime(\"%Y\") }/#{Time.now.strftime(\"%m\") }/#{Time.now.strftime(\"%d\") }/\"\n url_path = folder_path + new_file_name\n full_folder_path = \"#{Rails.root.to_s}/public#{folder_path}\"\n new_file_path = \"#{Rails.root.to_s}/public#{url_path}\"\n unless File.exist? full_folder_path\n `mkdir -p #{full_folder_path}`\n end\n\n Dir.mkdir(full_folder_path) unless File.exists?(full_folder_path)\n\n if !self.file_upload.original_filename.empty?\n self.status = Document::ENCODE_PROCESS\n self.original = url_path\n #`touch #{new_file_path}`\n File.open(new_file_path, \"wb\") do |f|\n f.write(self.file_upload.read)\n f.close\n end\n self.save!\n # async encoding video files\n begin\n Backburner.enqueue Document, \"#{Rails.root.to_s}/public\", url_path, self.id\n rescue => ex\n puts 'async task fail'\n puts ex\n self.status = Document::ENCODE_FAILED\n self.save\n end\n end\n\n end",
"def upload_file(f)\n # grabs the compiled asset from public_path\n full_file_path = File.join(File.dirname(@manifest.dir), f)\n one_year = 31557600\n mime = Rack::Mime.mime_type(File.extname(f)) \n file = {\n :key => f,\n :public => true,\n :content_type => mime,\n :cache_control => \"public, max-age=#{one_year}\",\n :expires => CGI.rfc1123_date(Time.now + one_year) \n }\n\n gzipped = \"#{full_file_path}.gz\" \n\n if File.exists?(gzipped)\n original_size = File.size(full_file_path)\n gzipped_size = File.size(gzipped)\n\n if gzipped_size < original_size\n file.merge!({\n :body => File.open(gzipped),\n :content_encoding => 'gzip'\n })\n log \"Uploading #{gzipped} in place of #{f}\"\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Gzip exists but has larger file size, uploading #{f}\"\n end\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Uploading #{f}\"\n end\n # put in reduced redundancy option here later if desired\n\n file = bucket.files.create( file )\n end",
"def upload_file\n if !params['upload_file'].nil?\n file = params['upload_file']\n file_upload(file)\n else\n p \"filename is empty!!!\"\n end\n end",
"def upload_file(file, destination)\n body = IO.open(file).read\n image_cache_dir.create(key: destination, body: body, public: true)\n end",
"def path\n \"/#{UPLOAD_DIR}/#{filename}\"\n end",
"def upload\n if File.exists?(file_path = \"/home/redroid/motion_detection_images/#{params[:img]}.jpg\")\n send_403_forbidden\n else\n File.open(file_path, 'wb') { |file| file.write(request.raw_post)}\n send_200_ok\n end\nend",
"def upload\r\n \r\n end",
"def Upload file\n \n APICall(path: \"uploads.json?filename=#{file.split('/').last}\",method: 'POST',payload: File.read(file))\n \n end",
"def upload_file\n upload_thumb if Rails.configuration.thumbnails_enabled\n file_s3_obj.write(@file.tempfile.open, content_type: @file.content_type)\n end",
"def upload\n end",
"def upload\n end",
"def upload(config={})\n\n\t\tfile_name = config.delete(:file_name)\n\t\tpath_to_s3_folder = config.delete(:path_to_s3_folder)\n\n\t\tif file_name.nil? || file_name.empty?\n\t\t\traise ArgumentError, \"file_names is either empty or contains no values\"\n\t\telsif file_name==''\n\t\t\traise ArgumentError, \"File Names is passed as empty string. Pass appropriate values\"\n\t\tend\n\n\t\tfile_names = Array.new\n\t\tfile_names = file_name if file_name.is_a? Array\n\n\t\tfile_names.push(file_name) if file_name.is_a? String\n\t\tfile_names.each {|file|\n\t\t\t#raise ArgumentError, \"File name does not exist in the main directory\" if File.exists?(file)==false\n\t\t\tfinal_file_path = path_to_s3_folder + file\n\t\t\[email protected][@bucket_name].objects[final_file_path].write(:file => file)\n\t\t\tputs \"#{file} successfully uploaded\"\n\t\t} unless file_names.nil?\n\tend",
"def upload\n uploaded_io = params[:file]\n File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n file.write(uploaded_io.original_filename) \n end\n end",
"def create\r\n flash[:notice] = ''\r\n\r\n if params.has_key?(:file)\r\n register_device params[:device_id]\r\n\r\n @video = Video.new(:video => params[:file],\r\n :upload_password => params[:upload_password],\r\n :device_id => params[:device_id],\r\n :timestamp => params[:timestamp],\r\n :annotation => params[:annotation]\r\n )\r\n else\r\n @video = Video.new(params[:upload])\r\n @video.timestamp = DateTime.now.to_i\r\n end\r\n\r\n respond_to do |format|\r\n if @video.save\r\n format.html { redirect_to :action => 'index' }\r\n format.xml { render :xml => @video, :status => :created, :location => @video }\r\n else\r\n format.html do\r\n flash[:notice] = 'Upload Error.'\r\n redirect_to :action => \"index\"\r\n end\r\n format.xml { render :xml => @video.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end",
"def upload_file(file_upload, owner)\n image = MiniMagick::Image.open(file_upload.tempfile.path)\n image.resize \"500x500>\"\n image.format \"jpeg\"\n\n tempfile = Tempfile.new \"item_picture\"\n image.write(tempfile)\n\n owner = \"#{current_user.id}/#{owner}\"\n\n upload = Upload.find_by(owner: owner) || Upload.new(owner: owner)\n\n upload.mime_type = \"image/jpeg\"\n upload.extension = \".jpeg\"\n upload.body = tempfile.read\n\n if upload.save\n StoreUploadToCloudJob.perform_later upload\n\n upload\n end\n end",
"def upload_file(deployment_id, id, local_file, destination, params={})\n if destination.empty? || destination == \"/\" || destination == \".\" || destination.include?(\"../\")\n raise \"#{self.class}.upload_file() passed a bad destination: '#{destination}'\"\n end\n # url = \"#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files\"\n url = \"#{base_path}/#{deployment_id}/versions/#{id}/files\"\n if !destination.to_s.empty?\n url += \"/#{destination}\"\n end\n # use URI to escape path\n uri = URI.parse(url)\n url = uri.path\n # params[:filename] = File.basename(destination)\n if !local_file.kind_of?(File)\n local_file = File.new(local_file, 'rb')\n end\n payload = local_file\n headers = {'Content-Type' => 'application/octet-stream'}\n headers['Content-Length'] = local_file.size # File.size(local_file)\n execute(method: :post, url: url, headers: headers, payload: payload, params: params, timeout: 172800)\n end",
"def create_from_file\n\n\t\t@user = current_user\n\n\t\tif current_user.is_bot?\n\t\t\tcurrent_user = User.bots.sample\n\t\telse\n\t\t\t# idk why this is necessary but without it current_user becomes nil\n\t\t\tcurrent_user = @user\n\t\tend\n\n\t\t@video = Video.new\n\t\[email protected] = current_user\n\t\[email protected] = Component.find_by_id(params[:component_id])\n\t\[email protected]_key = params[:s3_key]\n\t\[email protected] = true\n\t\[email protected] = \"vimeo\"\n\t\[email protected]\n\t\[email protected] # starts the bg task (uploads to vimeo)\n\n\t\tflash[:blue] = \"Your video has been uploaded! Please allow some time for processing.\"\n\n\t\trender :type => \"text/javascript\", :text => \"#{@video.id}\"\n\t\t\n end",
"def create\n \n if params[:upload].nil?\n flash[:error] = \"Please select a file\"\n redirect_to new_admin_video_path\n else\n if params[:upload][:datafile].nil? or params[:upload][:thumbnail].nil? or params[:video][:title]==\"\" or params[:video][:description]==\"\"\n flash[:error] = \"Please Fill all the fields\"\n redirect_to new_admin_video_path\n else\n post = Video.uploadvideo(params[:upload])\n if post\n post = Video.uploadthumb(params[:upload])\n if post\n \n # for associating the video with the user\n @videos = current_user.videos.new(user_params)\n @videos.update_attributes(:video_name => params[:upload][:datafile].original_filename,:thumb_name => params[:upload][:thumbnail].original_filename ) \n @videos.save\n redirect_to admin_videos_path\n end\n else\n flash[:error] = \"Please select a valid file\"\n redirect_to new_admin_video_path\n end\n end\n end\n end",
"def upload_file(dir_name, file, filename = File.basename(file.to_path))\n file = nil\n\n # Upload\n dir = @connection.directories.get(dir_name)\n if dir then\n file = dir.files.create(:key => filename, :body => file) \n else\n @logger.info \"\\nWarning: #{dir_name} does not exist.\\n\"\n end \n file\n end",
"def save_uploaded( filename )\n print system( \"cp -pv '#{filename}' '#{@upload_dir}/'\" )\n end",
"def upload_file(file_dir, orig_filename, aip_filename, type)\n @log.info 'Uploading file ' + orig_filename\n @log.info \"Renaming #{type} #{aip_filename} -> #{orig_filename}\"\n\n File.rename(file_dir + '/' + aip_filename,\n file_dir + '/' + orig_filename)\n file = File.open(file_dir + '/' + orig_filename)\n\n uploaded_file = Hyrax::UploadedFile.create(file: file)\n uploaded_file.save\n\n file.close\n\n uploaded_file\nend",
"def upload_file(upload, user, client_name)\n if upload != nil\n if user.link_picture != nil\n File.delete('public/images/' << user.link_picture)\n end\n name = upload['img'].original_filename\n directory = 'public/images/' + client_name + '/users/' + user.username\n path = File.join(directory, name)\n File.open(path, 'wb') { |f| f.write(upload['img'].read) }\n path_img = client_name + '/users/' + user.username + '/' + name\n User.where(:id => user.id).update_all(link_picture: path_img)\n end\n end",
"def create\n # This comment part specifies how to perform server side uploading\n # http://cloudinary.com/documentation/rails_video_upload#rails_video_upload_examples\n # http://cloudinary.com/documentation/upload_videos\n # http://cloudinary.com/documentation/video_management\n # http://cloudinary.com/documentation/rails_video_manipulation\n \n # video_public_id = \"video_#{SecureRandom.urlsafe_base64}\"\n # response = Cloudinary::Uploader.upload(params[:video][:target_file], :resource_type => :video, :public_id => video_public_id)\n # Cloudinary::Uploader.upload_large(params[:video][:target_file], :resource_type => :video, :public_id => \"my_folder/my_sub_folder/myvideo1\", :eager => [{:width => 300, :height => 300, :crop => :pad}], :eager_async => true, :eager_notification_url => \"http://c45a1454.ngrok.io/videos/transform_notification\")\n begin\n @active_page = \"videos\"\n if params[:id].blank?\n @video = Video.new(video_params)\n else\n @video = Video.find(params[:id])\n @video.update_attributes(video_params)\n end\n @video.save\n rescue Exception => e\n log_error(e, \"Error occured in Create action of VideosController\")\n flash_error(t('videos.create_page_error'))\n ensure\n redirect_to \"/videos\"\n end\n end",
"def upload(video, user)\r\n self.connect(user) unless user.token?\r\n uri = URI(HOST + 'feeds/api/users/default/uploads')\r\n post = Net::HTTP::Post.new uri.path\r\n post.body_stream, post.content_type = Multipart::Post.prepare_query(\"atom\" => video.atom, \"Video\" => video.file)\r\n post.add_field('Slug', video.name)\r\n post.content_type = \"multipart/related;\"\r\n post.\r\n post.body video.atom\r\n post.\r\n _http_post(uri, post, user)\r\n end",
"def upload(file_path)\n file_name = File.basename(file_path)\n object = @bucket.objects[file_name]\n object.write(:file => file_path)\n object.public_url\n end",
"def file_upload_wip()\n logger.debug \"\\r\\n\\r\\n!! ------ in upload/file_upload -----\"\n logger.debug params[:datafile].original_filename\n logger.debug params\n logger.debug \"\\r\\n!! ===========================\\r\\n\"\n is_successful = true\n\n if params[:datafile]\n tmp = params[:datafile].tempfile\n file = File.join( \"public/uploads\", params[:datafile].original_filename )\n FileUtils.cp tmp.path, file\n# \n # name = params[:datafile].original_filename\n # directory = \"public/uploads\"\n # path = File.join(directory, name)\n # File.open(path, \"wb\") { |f|\n # f.write( params[:datafile].read )\n # }\n else\n is_successful = false\n end\n\n redirect_to upload_path()\n end",
"def create\n @video = Video.new(video_params)\n video_file = params[:video][:video_file]\n errors = Hash.new\n if video_file.nil?\n ext = false\n errors[:file] = \"can't be null.\"\n else\n ext = File.extname(video_file.original_filename).downcase\n end\n\n if ext\n if ['.mp4','.flv','.mov'].include?(ext)\n @video.name = @video.name + ext\n bucket = $S3.buckets['tubeyou.video']\n obj = bucket.objects.create(@video.name, :file => video_file)\n obj.acl = :public_read\n @video.url = URI::encode(ENV['cf_http_url'] + @video.name)\n else\n errors[:file] = \"must be a video.\"\n end\n end\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render action: 'show', status: :created, location: @video }\n else\n errors.each do |k, v|\n @video.errors.add(k, v)\n end\n format.html { render action: 'new' }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_file(upload)\n return false if upload.blank?\n name = self.id.to_s + \".\" + upload.original_filename\n\n self.aws_connect()\n \n # store the file to Amazon S3\n AWS::S3::S3Object.store(name, upload, 'assetmngr', :access => :public_read)\n self.filename = name\n self.save\n end",
"def upload_file_url\n \"file://#{upload_full_path}\"\n end",
"def upload_video(path, title = \"\", description = \"\", profile = \"\", transcoding = nil)\n # Get signature\n sig = signature\n @logger.debug \"Uploading...\" \n # Upload to S3\n res = upload_to_s3 sig.acl, sig.bucket, sig.policy, sig.aws_access_key,\n sig.signature, sig.key, path\n if res\n @logger.debug \"Upload complete\"\n # And process in vzaar\n process_video :guid => sig.guid, :title => title,\n :description => description, :profile => profile,\n :transcoding => transcoding\n else\n @logger.debug \"Upload to s3 failed\"\n return nil\n end\n end",
"def upload_file\n file = google_session.upload_from_file(file_params[:file].tempfile,\n file_params[:file].original_filename)\n collection.add(file)\n google_session.root_collection.remove(file)\n render json: 'Upload Successful'\n end",
"def create\n if !params[:video][:video].nil?\n videoName = params[:video][:video].original_filename.gsub(/\\s/,'_') \n @video = Video.new({:title => params[:video][:title], :video => \"/worshipvideos/#{videoName}\"})\n else\n @video = Video.new({:title => params[:video][:title]})\n end\n\n if !params[:video][:video].nil?\n tmp = params[:video][:video].tempfile\n file = File.join(\"public/worshipvideos\", videoName)\n FileUtils.cp tmp.path, file\n FileUtils.rm tmp\n end\n\n respond_to do |format|\n if @video.save\n if !params[:video][:video].nil?\n #logger.debug \"./createVideoPics.sh '#{videoName}'\"\n #fork do\n #system(\"./createVideoPics.sh '#{videoName}'\")\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\"\n #end\n\n @video.update_attribute(\"pic1\", \"worship_pics/#{videoName}_1.jpg\")\n @video.update_attribute(\"pic2\", \"worship_pics/#{videoName}_2.jpg\")\n @video.update_attribute(\"pic3\", \"worship_pics/#{videoName}_3.jpg\")\n end\n\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload(file)\n file = File.expand_path(file)\n\n abort \"#{file} does not exist!\" unless File.exist?(file)\n\n dest = dropbox_resolve_file(File.join(destination_directory, File.basename(file)))\n\n if remote_file = dropbox_upload_file(file, dest)\n url(remote_file, method: :create, retries: 0)\n else\n abort \"Couldn't upload file #{file}\"\n end\n rescue APIError => e\n abort e.message\n end",
"def uploaded_file_path\n FileServices::Uploader.perform(@file, upload_path)\n end",
"def upload(file, someone)\n end",
"def upload_file=(file_name)\n self.file_field(:id=>\"multifile_upload\").set(File.expand_path(File.dirname(__FILE__)) + \"/../../data/sakai-oae/\" + file_name)\n end",
"def inject_file(filename, element_id, api_route)\n filename = File.basename(filename)\n # Load and XHR the image file\n file = File.new(File.join(@asset_filepath, filename))\n if file.nil?\n raise \"Invalid file or path #{filename}, default path is #{@asset_filepath}\"\n end\n response = put_file api_route, file\n raise \"Unable to put #{filename} to #{api_route} route\" unless response\n\n input_filename = JSON.parse(response)[\"name\"]\n page.execute_script \"$('input[name=#{element_id}]')\"+\n \".val('#{input_filename}')\"\n # Return path of uploaded file\n input_filename\n end",
"def create(file_path, params = {})\n return unless file_path\n upload = Vimeo::Advanced::Upload.new(@api_key, @api_secret, @token_hash)\n\n upload.get_quota\n ticket = upload.get_ticket\n puts ticket.inspect\n puts \"ticket---------------\"\n return unless ticket[\"stat\"]==\"ok\" \n ticket_id = ticket[\"ticket\"][\"id\"]\n end_point = ticket[\"ticket\"][\"endpoint\"]\n\n upload_res = upload.upload(file_path, ticket_id, end_point)\n puts JSON.parse(upload_res).inspect\n puts \"upload_res----------\"\n # manifest = upload.verify_manifest(ticket_id, upload_res)\n # puts manifest.inspect\n puts \"manifest----------------\"\n confirm = upload.confirm(ticket_id)\n puts confirm.inspect\n puts \"confirm------------\"\n video_id = confirm[\"ticket\"][\"video_id\"]\n vimeo_video = Vimeo::Advanced::Video.new(@api_key, @api_secret, @token_hash)\n vimeo_video.set_description(video_id, params[:description]) if params[:description]\n vimeo_video.set_title(video_id, params[:title]) if params[:title]\n vimeo_video.add_tags(video_id, params[:tags]) if params[:tags]\n video_id\n rescue exception_block\n end",
"def upload_file(uploadURL, uploadFile, progressUrl, config={})\n raise ::IOError, \"#{uploadFile} not found.\" unless File.exists?(uploadFile)\n\n # Set chunksize to 10M if not specified otherwise\n chunkSize = (config[:chunksize] || 10485760)\n\n # Set progress bar to default format if not specified otherwise\n progressBarFormat = (config[:progressbar_format] || \"%e <%B> %p%% %t\")\n\n # Set progress bar length to 120 if not specified otherwise\n progressBarLength = (config[:progressbar_length] || 120)\n\n # Open our file for upload\n uploadFileHandle = File.new(uploadFile, \"rb\" )\n fileName = File.basename(uploadFileHandle)\n\n progressBarTitle = \"Uploading: \" + uploadFile.to_s\n\n # Create a progressbar object if progress bar is enabled\n if config[:progressbar_enable] == true && uploadFileHandle.size.to_i > chunkSize\n progressbar = ProgressBar.create(\n :title => progressBarTitle,\n :starting_at => 0,\n :total => uploadFileHandle.size.to_i,\n :length => progressBarLength,\n :format => progressBarFormat\n )\n else\n @logger.info progressBarTitle\n end\n # Create a new HTTP client\n clnt = HTTPClient.new\n\n # Disable SSL cert verification\n clnt.ssl_config.verify_mode=(OpenSSL::SSL::VERIFY_NONE)\n\n # Suppress SSL depth message\n clnt.ssl_config.verify_callback=proc{ |ok, ctx|; true };\n\n # Perform ranged upload until the file reaches its end\n until uploadFileHandle.eof?\n\n # Create ranges for this chunk upload\n rangeStart = uploadFileHandle.pos\n rangeStop = uploadFileHandle.pos.to_i + chunkSize\n\n # Read current chunk\n fileContent = uploadFileHandle.read(chunkSize)\n\n # If statement to handle last chunk transfer if is > than filesize\n if rangeStop.to_i > uploadFileHandle.size.to_i\n contentRange = \"bytes #{rangeStart.to_s}-#{uploadFileHandle.size.to_s}/#{uploadFileHandle.size.to_s}\"\n rangeLen = uploadFileHandle.size.to_i - rangeStart.to_i\n else\n contentRange = \"bytes #{rangeStart.to_s}-#{rangeStop.to_s}/#{uploadFileHandle.size.to_s}\"\n rangeLen = rangeStop.to_i - rangeStart.to_i\n end\n\n # Build headers\n extheader = {\n 'x-vcloud-authorization' => @auth_key,\n 'Content-Range' => contentRange,\n 'Content-Length' => rangeLen.to_s\n }\n\n begin\n uploadRequest = \"#{@host_url}#{uploadURL}\"\n connection = clnt.request('PUT', uploadRequest, nil, fileContent, extheader)\n\n if config[:progressbar_enable] == true && uploadFileHandle.size.to_i > chunkSize\n params = {\n 'method' => :get,\n 'command' => progressUrl\n }\n response, headers = send_request(params)\n\n response.css(\"Files File [name='#{fileName}']\").each do |file|\n progressbar.progress=file[:bytesTransferred].to_i\n end\n end\n rescue\n retryTime = (config[:retry_time] || 5)\n @logger.warn \"Range #{contentRange} failed to upload, retrying the chunk in #{retryTime.to_s} seconds, to stop the action press CTRL+C.\"\n sleep retryTime.to_i\n retry\n end\n end\n uploadFileHandle.close\n end",
"def create_file_to_upload\n file_path = $redis.get(\"tempfile_path_#{self.id}\")\n tempfile = File.open(file_path,'r')\n\n file = ActionDispatch::Http::UploadedFile.new({\n :tempfile => File.new(tempfile)\n })\n file.original_filename = File.basename(file_path).split(\"_\", 2).last\n file.content_type = \"application/#{File.basename(file_path).split('.').last}\" \n file\n end",
"def upload_process\n # アップロードファイルを取得\n file = params[:upfile]\n\n # ファイルのベース名(パスを除いた部分)を取得\n name = file.original_filename\n\n # 許可する拡張子を定義\n permits = ['.jpg', '.jpeg', '.gif', '.png']\n\n # 配列 permits にアップロードファイルの拡張子に合致するものがあるか\n if ! permits.include?(File.extname(name).downcase)\n render :text => \"アップロードできるのは画像ファイルのみ( \" + permits.join(', ') + \" )です。\"\n elsif file.size > 1.megabyte\n render :text => 'ファイルサイズは1MBまでです。'\n else\n # utf8 to sjis\n name = name.kconv(Kconv::SJIS, Kconv::UTF8)\n\n # /public/doc フォルダ配下にアップロードファイルを保存\n File.open(\"public/docs/#{name}\", 'wb') { |f| f.write(file.read) }\n render :text => \"#{name.toutf8}をアップロードしました。\"\n end\n end",
"def uploaded_file=(file); write_attribute(:uploaded_file, file); end",
"def migrate_user url, user\n \n # make sure the url contains file stack\n return unless url.start_with? 'https://cdn.filepicker.io'\n\n open('migrated.jpg', 'wb') do |file|\n \n file << open(url).read\n \n #upload the file to the user\n attachment = ActionDispatch::Http::UploadedFile.new(tempfile: file, filename: \"migrated\", type: \"image/jpg\")\n user.avatar_src = attachment\n user.save!\t\n end\nend",
"def attach_image\n\n @video = ProjectVideo.find_by_id(params[:video_id])\n @project = Project.user_readable(current_user, @video.project)\n\n if @project\n\n\n #for plupload rename \"file\" to expected \"video[data]\"\n if(params[:file])\n params[:project_video_image] = params[:file]\n end\n\n\n\n\n begin\n\n if @video.update(:image=>params[:project_video_image])\n\n respond_to do |format|\n format.json { render :json => [video_gallery_item_id: @video.id,\n refresh_photo_url: @video.image.url(:medium)\n #video_gallery_item: view_context.video_gallery_item(@video)],\n ],\n :status => :ok\n }\n end\n\n else\n respond_to do |format|\n #format.html { redirect_to(edit_profile_url(@profile), :notice => 'There was an issue with video upload. Please try again') }\n format.json { render :json => [:error_message => 'Wrong filetype, please upload JPG or PNG only.'], :status => :ok }\n end\n\n end\n\n rescue Paperclip::Errors::NotIdentifiedByImageMagickError\n respond_to do |format|\n #format.html { redirect_to(edit_profile_url(@profile), :notice => 'There was an issue with video upload. Please try again') }\n format.json { render :json => [:error_message => 'Wrong filetype, please upload JPG or PNG only.'], :status => :ok }\n end\n end\n\n\n else\n not_authorized\n end\n\n\n end",
"def upload_file(filename, file_path=\"\")\n frm.file_field(:id=>\"upload\").set(file_path + filename)\n if frm.div(:class=>\"alertMessage\").exist?\n sleep 2\n upload_file(filename)\n end\n end",
"def upload(filename, folderid=nil, unzip=true, overwrite=false, details=nil) #filename must include the extension\n end",
"def attach_video\n\n @video = ProjectVideo.find_by_id(params[:video_id])\n @project = Project.user_readable(current_user, @video.project)\n\n\n if @project\n\n #for plupload rename \"file\" to expected \"video[data]\"\n\n if(params[:file])\n params[:project_video_file] = params[:file]\n end\n\n ########################################################\n # find the current video and remove if exists\n ########################################################\n @video = @project.videos.find(params[:video_id]) || @project.videos.new\n @video.video = nil\n @video.save\n\n ########################################################\n # save new attachment details\n ########################################################\n @video[:video_file_name] = params[:project_video_file][:name]\n @video[:video_content_type] = params[:project_video_file][:content_type]\n @video[:video_file_size] = params[:project_video_file][:size]\n @video[:video_updated_at] = DateTime.now\n\n\n if @video.save\n respond_to do |format|\n format.json { render :json => [video_gallery_item_id: @video.id,\n video_player_url: @video.url(:mp4)\n ],\n :status => :ok }\n end\n\n else\n respond_to do |format|\n #format.html { redirect_to(edit_profile_url(@profile), :notice => 'There was an issue with video upload. Please try again') }\n format.json { render :json => @video.errors, :status => :unprocessable_entity }\n end\n end\n\n else\n not_authorized\n end\n\n\n\n\n end",
"def filename_for_image_upload\n random_token = Digest::SHA2.hexdigest(\"#{Time.now.utc}--#{current_user.id.to_s}\").first(15)\n \"temp_upload_#{random_token}\"\n end",
"def filename_for_image_upload\n random_token = Digest::SHA2.hexdigest(\"#{Time.now.utc}--#{current_user.id.to_s}\").first(15)\n \"temp_upload_#{random_token}\"\n end",
"def upload_media_file( wikipath, filename, raw )\n p filename\n headers = {\n 'Content-Type' => 'application/octet-stream',\n 'X-File-Name' => filename\n }\n url = upload_url( wikipath, filename )\n p url\n wait_second\n pp @agent.post( url, raw, headers )\n save_uploaded( filename )\n end",
"def upload_file( id_object, file_to_upload, folder_on_s3 )\n \n file_name = id_object.to_s + \"-\" + file_to_upload.original_filename.to_s\n path_uploaded_files = Rails.root.join('public','uploaded-files')\n uploaded_file = path_uploaded_files.to_s + \"/\" + file_name\n\n unless Dir.exist?(path_uploaded_files)\n FileUtils.mkdir_p(path_uploaded_files)\n end\n\n File.open(uploaded_file, 'wb') do |file|\n file.write(file_to_upload.read)\n end \n\n file_on_s3 = folder_on_s3 + \"/\" + file_name\n upload_file_to_aws_s3(uploaded_file, file_on_s3)\n\n FileUtils.rm(uploaded_file.to_s)\n\n end",
"def upload_schedule\n uploaded_file = params[:schedule_file]\n path = \"#{Dir.tmpdir}/#{uploaded_file.original_filename}\"\n File.open(path, \"wb\") do |f|\n f.print(uploaded_file.read)\n end\n\n Schedule::Schedule.import(path)\n expire_cache\n flash[:notice] = \"Uploaded schedule from #{uploaded_file.original_filename}\"\n\n redirect_to(admin_events_path)\n end",
"def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.file = data\n end",
"def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.file = data\n end",
"def upload_xml_file(file_name, xml)\n # Creates directory if it doesn't exist\n create_upload_dir\n # Save file to server's uploads dir\n file_to_upload = File.open(Rails.root.join('public', 'uploads', file_name), \"wb\")\n file_to_upload.write(xml)\n file_to_upload.close()\n end",
"def create\n @file = vid_params['file'].tempfile\n type = vid_params['file'].content_type\n client = YouTubeIt::Client.new(:username => ENV['GMAIL'], :password => ENV['GMAIL_PASSWORD'], :dev_key => ENV[\"YOUTUBE_API_KEY\"])\n res = client.video_upload(@file, title: vid_params['title'], description: vid_params['description'], category: 'People', :keywords => ['darity', 'dare', 'charity'])\n @video = Video.new(url: res.player_url, uid: res.player_url.gsub(/&.*/, \"\").gsub(/.*=/, \"\"), description: vid_params[\"description\"], title: vid_params['title'], dare_id: params[:dare_id])\n if @video.save\n redirect_to current_user\n else\n render html: \"Error\"\n end\n end",
"def upload_file(filename, file)\n\tpath = \"#{AVATAR_DIR}/#{filename}\"\n\treturn false if File.exists? path\n\tFile.open(path, \"wb\") { |f| f.write(file.read) }\n\ttrue\nend",
"def upload_file( wikipath, filename )\n p filename\n raw = File.read( filename )\n return if uploaded?( filename, raw )\n\n case filename\n when /[.]#{EXTENSION}$/\n upload_wiki_file( wikipath, filename )\n else\n upload_media_file( wikipath, filename, raw )\n end\n end",
"def upload_file\n \n # remember the filename\n tempfile = params[\"file_to_upload\"]\n \n # wenn ich keinen string bekommen habe und auch ueberhaupt was ankam (kein tag_edit)\n unless tempfile.nil?\n \n # if just a string arrived\n if tempfile.instance_of?(String)\n flash[:notice] = \"please select a valid file\"\n redirect_to :action => \"index\"\n \n # when a file arrived\n elsif tempfile.instance_of?(Tempfile)\n \n # delete file if too big\n if File.size?(tempfile) > MAX_FILESIZE\n File.delete(tempfile.local_path)\n flash[:notice] = \"File too large (maximal 10 MB allowed)\"\n redirect_to :action => \"index\"\n\n # if it is a valid mp3\n else\n # save variable for view\n @original_name = tempfile.original_filename\n # read id3 information\n @tag = ID3Lib::Tag.new(tempfile.local_path)\n # copy the file to the upload directory\n FileUtils.copy(params[:file_to_upload].local_path, tmp_filename)\n logger.info(\"new file from #{current_user.login} copied to : #{tmp_filename}\")\n\n flash[:notice] = \"File Uploaded\"\n end\n end\n else\n \n # hier komme ich hin, wenn nichts hochgeladen wurde, sondern der tag editiert\n \n if params[\"original_name\"].nil?\n flash[:notice] = \"No File selected (depp)\"\n redirect_to :action => \"index\"\n else \n @original_name = params[\"original_name\"]\n @tag = ID3Lib::Tag.new(tmp_filename)\n end\n end\n end",
"def upload_file(remote_filepath, remote_filename, local_filedata = null)\r\n magic_code = \"\\xdd\\xdd\"\r\n opcode = [6].pack('L')\r\n\r\n # We create the filepath for the upload, for execution it should be \\windows\\system32\\wbem\\mof\\<file with extension mof!\r\n file = \"..\\\\..\\\\\" << remote_filepath << remote_filename << \"\\x00\"\r\n pkt_size = local_filedata.size() + file.size() + (0x108 - file.size()) + 4\r\n\r\n # Magic_code + packing + size\r\n pkt = magic_code << \"AAAAAAAAAAAA\" << [pkt_size].pack('L')\r\n\r\n tmp_pkt = opcode << file\r\n tmp_pkt += \"\\x00\"*(0x108 - tmp_pkt.size) << [local_filedata.size].pack('L') << local_filedata\r\n pkt << tmp_pkt\r\n\r\n print_status(\"Starting upload of file #{remote_filename}\")\r\n connect\r\n sock.put(pkt)\r\n disconnect\r\n\r\n print_status(\"File uploaded\")\r\n end",
"def uploadicon=(file)\n unless( file.blank? )\n logger.info(\"original_filename: \" + file.original_filename )\n self.content_type = file.content_type.chomp\n logger.info(\"content_type: \" + self.content_type )\n filename = base_part_of( file.original_filename ) \n \n if(file.length < 300000 )\n @uploadfile = file \n self.was_upload_successful = true\n else\n self.was_upload_successful = false\n end\n \n end\n end",
"def fast_asset=(file)\n if file && file.respond_to?('[]')\n self.tmp_upload_dir = \"#{file['filepath']}_1\"\n tmp_file_path = \"#{self.tmp_upload_dir}/#{file['original_name']}\"\n FileUtils.mkdir_p(self.tmp_upload_dir)\n FileUtils.mv(file['filepath'], tmp_file_path)\n self.asset = File.new(tmp_file_path)\n end\n end",
"def save_file(upload)\n\t\t\tfilename = upload[0].original_filename\n\t\t\tfilepath = Rails.root.join('public', 'img', filename)\n\n\t\t\tFile.open(filepath, 'wb') do |file|\n\t\t\t\tfile.write(upload[0].read)\n\t\t\tend\n\t\tend",
"def upload_full_path\n @upload_full_path ||= File.join(@upload_file_path, name)\n end",
"def upload_file(upload_url, filename_or_stream, content_type, filename = nil)\n handle_error do\n fileserver_connection(upload_url).post do |req|\n req.body = { file: UploadIO.new(filename_or_stream, content_type, filename) }\n end\n end\n end",
"def swfupload_file=(data)\n data.content_type = MIME::Types.type_for(data.original_filename).to_s\n self.ufile = data\n end",
"def upload_session_image\n max_width = params[:width] || 120\n max_height = params[:height] || 120\n begin\n file = params[\"uploaded_file_#{params[:name]}\".to_sym]\n logger.debug \"file = #{file.inspect}\"\n original_tmpfile = tmp_file_path(file.original_filename)\n File.open(original_tmpfile,\"wb\") do |f|\n f.write(file.read)\n end\n # Validate the original file\n @image_errors = []\n validate_image_type(original_tmpfile, params[:name])\n \n image_attached_class = eval(self.class.image_attached_class_name)\n validate_method_name = \"validate_image_as_#{params[:name].singularize}\".to_sym\n if image_attached_class.respond_to?(validate_method_name)\n errors = image_attached_class.send(validate_method_name, original_tmpfile)\n @image_errors.concat(errors) if errors.kind_of?(Array)\n end\n # TODO: deprecated.\n validate_image(original_tmpfile) if self.respond_to?(:validate_image)\n unless @image_errors.empty?\n File.delete(original_tmpfile)\n responds_to_parent do\n render :update do |page|\n page << \"#{main_object_name(params[:name])}.refresh();\"\n page.alert(@image_errors.join('\\n'))\n end\n end\n return\n end\n\n modified_tmpfile = tmp_file_path(file.original_filename)\n if !resize_and_write_image(original_tmpfile, modified_tmpfile)\n modified_tmpfile = original_tmpfile\n end\n original_tmpname = cut_path(original_tmpfile) # file name\n modified_tmpname = cut_path(modified_tmpfile) # file name\n display_size, original_width, original_height, mime_type = ImageResize.use_image_size(modified_tmpfile) do |i|\n [ImageResize.get_reduction_size(i, max_width, max_height), i.get_width, i.get_height, i.mime_type]\n end\n uploaded_files_on_session(params[:name]) << {\n :filename => modified_tmpfile,\n :original_filename => file.original_filename,\n :session => true,\n :width => display_size[:width],\n :height => display_size[:height],\n :original_width => original_width,\n :original_height => original_height,\n :original_tmp_filename => original_tmpfile,\n :modified_angle => 0,\n :mime_type => mime_type\n }\n responds_to_parent do\n render :update do |page|\n image = {\n :original_filename => file.original_filename,\n :image_uri => url_for(:action => 'session_image', :file_name => modified_tmpname),\n :name => modified_tmpname,\n :session => true,\n :width => display_size[:width],\n :height => display_size[:height],\n :original_width => original_width,\n :original_height => original_height,\n :mime_type => mime_type\n }\n page << \"#{main_object_name(params[:name])}.onUploaded(#{image.to_json});\"\n end\n end\n rescue => e\n logger.error e\n logger.error e.backtrace.join(\"\\n\")\n responds_to_parent do \n render :text => e.to_s\n end\n end\n end",
"def put_file(destination, file)\n href = self.class.get_href(destination)\n @rest_logger.info \"#{__method__.to_s.upcase}\\t#{href}\"\n response = @file_uploader.upload(href, file, @cookies)\n response\n end",
"def set_upload_file_to_server\n @upload_file_to_server = UploadFileToServer.find(params[:id])\n end",
"def create\n @project = Project.new(project_params)\n @project.user_id = current_user.id\n @project.views = 1\n @project.hidden = false\n\n if project_params[:video] != nil\n file = project_params[:video].tempfile.open\n json = Cloudinary::Uploader.upload_large(file, \n :resource_type => :video, :chunk_size => 6_000_000, :public_id => @project.title)\n\n @project.video = json['url']\n \n end\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user=User.find(params[:user_id])\n @file_upload = @user.file_uploads.new(file_upload_params)\n\n respond_to do |format|\n if @file_upload.save\n format.html { redirect_to user_file_upload_path(@user,@file_upload), notice: 'File was successfully uploaded.' }\n format.json { render :show, status: :created, location: @file_upload }\n @md5 = Digest::MD5.file(@file_upload.attachment.path).hexdigest \n @file_upload[:hash_val]=@md5\n @file_upload.save\n\n else\n format.html { render :new }\n format.json { render json: @file_upload.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload(bucket, file); end",
"def uploadPictureToFTP(id,name, image, max_pic)\n errors = {}\n logger.info \"[INFO] Establishing connection with FTP Server\"\n # FTP connection\n ftp = Net::FTP.new(FTP_HOST)\n ftp.passive = true\n begin\n login = ftp.login(FTP_USERNAME, FTP_PASSWORD)\n rescue Net::FTPPermError\n logger.debug \"[ERROR] User cannot be logged in\"\n errors[:error] = \"User cannot be logged in\"\n return errors\n end\n if login\n logger.info \"[INFO] Login Done\"\n # Cheking routes existence\n folders = ftp.nlst\n if !folders.any?{|s| s.include? 'profile_pictures'}\n if !ftp.mkdir(\"#{PATH_TO_WEB_FILE}\")\n logger.debug \"[ERROR] Cannot create #{PATH_TO_WEB_FILE} directory\"\n errors[:error] = \"Cannot create #{PATH_TO_WEB_FILE} directory\"\n ftp.close\n return errors\n end\n end\n # Access to /profile_pictures\n ftp.chdir(PATH_TO_WEB_FILE)\n folders = ftp.nlst\n # Creating user folder if doesn't exist.\n if !folders.any?{|s| s.include? \"user_#{id}\"}\n if !ftp.mkdir(\"#{PATH_TO_WEB_FILE}/user_#{id}\")\n logger.debug \"[ERROR] Cannot create #{PATH_TO_WEB_FILE}/user_#{id} directory\"\n errors[:error] = \"Cannot create #{PATH_TO_WEB_FILE}/user_#{id} directory\"\n ftp.close\n return errors\n end\n end\n\n # Access to /profile_pictures/user_1\n ftp.chdir(\"#{PATH_TO_WEB_FILE}/user_#{id}\")\n\n # Checking if this file exists to add or not an extension e.g. (1)\n file_name = \"#{PATH_TO_WEB_FILE}/user_#{id}/#{name}\"\n files = ftp.nlst\n if files.length >= max_pic+ PREDEFINED_FILES\n logger.debug \"[ERROR] Picture can't be uploaded because excedeed maximum size\"\n errors[:error] = \"Picture can't be uploaded because excedeed maximum size\"\n ftp.close\n return errors\n end\n\n # Getting name and extension file.\n file_without_extension = name.split('.')[0]\n file_extension = name.split('.')[1]\n\n # Iterating over files to check for file name.\n # If it exists, we add a (1) at the end.\n # if it exists with some (\\d) pattern, get the number and add 1.\n # else we add the file with original name.\n pattern = /#{file_without_extension}\\(\\d\\).#{file_extension}/\n files.each do |s|\n if s.match(/#{name}/) != nil\n name = \"#{file_without_extension}(1).#{file_extension}\"\n else\n name_str = s.match(pattern)\n if name_str!= nil\n n_str = name_str[0]\n file_count = n_str[/\\((.*?)\\)/m,1]\n file_count = file_count.to_i\n file_count += 1\n name = \"#{file_without_extension}(#{file_count}).#{file_extension}\"\n end\n end\n end\n # Send string image\n ftp.puttextcontent(image, name)\n logger.info \"[INFO] Sending content to FTP Server\"\n\n # Finish ftp connection\n if ftp.last_response_code == OK\n logger.info \"[INFO] Image sended\"\n ftp.close\n return errors\n end\n end\n\n ftp.close\n return errors\n end",
"def perform(video_id)\n video = Video.get(video_id)\n flv_video = FFMPEG::Movie.new(video.flv)\n options = {\n resolution: flv_video.resolution,\n video_bitrate: flv_video.video_bitrate,\n audio_bitrate: flv_video.audio_bitrate\n }\n mp4_video = flv_video.transcode('uploads/' + video.id.to_s + '.mp4', options)\n video.update(mp4: mp4_video.path)\n end",
"def video_content_ready_for_upload( video_content )\n\t\t# schedule an upload\n\t\tCDNLimelightCoreStorageUploadVideoContentFileTask.make_task( video_content )\n\tend",
"def upload\n self._create params[:upfile], params[:pictitle]\n end",
"def file_name\n uploaded_file_file_name\n end",
"def file_path\n Merb::Config[:upload_dir] / self.hash[0..1] / (self.hash[2..-1] + '-' + self.size.to_s )\n end",
"def upload(file, identifier, copy = true)\n return \"/images/no_image.gif\" if file.nil?\n\n filename = \"#{identifier.to_s}_#{file[:filename]}\"\n full_path = File.join(self.root, self.path)\n\n if copy\n FileUtils.mkdir_p(full_path)\n FileUtils::cp(file[:tempfile].path, File.join(full_path, filename))\n end\n\n File.join(self.path, filename)\n end",
"def uploadImage\n post = DataFile.save(params[:upload], \"\")\n \n f = Family.where(turn: -1).first\n if f.nil?\n f = Family.new\n f.turn = -1\n f.save\n end\n \n f.name = post.to_s\n f.save\n \n # render :text => \"File has been uploaded successfully\"\n redirect_to :back\n end",
"def upload\n file = params[:file].original_filename\n activity = file.sub(/\\..*$/,'')\n path = RAILS_ROOT + \"/public/data/\" + activity\n Dir.mkdir path\n datapath = path + \"/data/\"\n Dir.mkdir datapath\n basename = datapath + activity\n smi = File.open(\"#{basename}.smi\",\"w\")\n cl = File.open(\"#{basename}.class\",\"w\")\n params[:file].read.each do |line|\n items = line.split(/\\s+/)\n smi.puts \"#{items[0]}\\t#{items[1]}\"\n cl.puts \"#{items[0]}\\t#{activity}\\t#{items[2]}\"\n end\n if LazarCategory.find_by_name(\"Uploads\").blank?\n cat = LazarCategory.create(:name => \"Uploads\")\n else\n cat = LazarCategory.find_by_name(\"Uploads\")\n end\n LazarModule.create(:endpoint => activity, :directory => path, :lazar_category => cat)\n redirect_to :action => :search\n end",
"def attach_video(filename, element_id: , put_video_path: , model_attribute: 'video_url')\n injected_file = inject_file filename, element_id, put_video_path\n\n page.execute_script 'video = window.Dashboard.router.pageView.model.video;'\n page.execute_script \"video.attributes['#{model_attribute}']='#{injected_file}'\"\n page.execute_script '$(\".video textarea[required]\").attr(\"required\", false)'+\n '.attr(\"disabled\", true);'\n end"
] | [
"0.70270765",
"0.6648143",
"0.6634276",
"0.65686625",
"0.63425255",
"0.6336181",
"0.631758",
"0.62717307",
"0.6266716",
"0.61908865",
"0.61814225",
"0.61228365",
"0.6119716",
"0.6118708",
"0.6082119",
"0.60702676",
"0.60483265",
"0.60462517",
"0.60237974",
"0.59999603",
"0.598259",
"0.5972955",
"0.59452266",
"0.59430027",
"0.59214246",
"0.5912566",
"0.58796656",
"0.58680457",
"0.58680457",
"0.58568245",
"0.58383185",
"0.58334816",
"0.5817488",
"0.58146435",
"0.58065975",
"0.57920015",
"0.5787122",
"0.5784071",
"0.57807595",
"0.57801926",
"0.57733595",
"0.5764067",
"0.576075",
"0.57558835",
"0.57526153",
"0.574431",
"0.5740583",
"0.5740012",
"0.5728165",
"0.57165",
"0.57009834",
"0.5692079",
"0.56832784",
"0.56799775",
"0.5674862",
"0.56748235",
"0.5670383",
"0.5661185",
"0.5657973",
"0.5655837",
"0.5643692",
"0.5636449",
"0.563363",
"0.5633222",
"0.56228805",
"0.56205714",
"0.56205714",
"0.5608033",
"0.56010497",
"0.5600077",
"0.5591665",
"0.5591665",
"0.5590282",
"0.5582264",
"0.55744493",
"0.55742824",
"0.55507153",
"0.55445606",
"0.5541218",
"0.5539618",
"0.5528239",
"0.55205977",
"0.5516948",
"0.5510102",
"0.5500668",
"0.54940736",
"0.54928637",
"0.54927224",
"0.54900193",
"0.54878134",
"0.54826444",
"0.5482133",
"0.5479157",
"0.5474443",
"0.546621",
"0.54562163",
"0.54521215",
"0.54510206",
"0.5441477",
"0.5439616"
] | 0.8131492 | 0 |
Generates previews for each movie file in the transcode directory filename: The full path of the video file to output options: allows you to pass the following values for configuration. If not set they'll be pulled from your config framegrab_grid: (string) Something like '5x6' or '2x4' to specify the size of the grid framegrab_interval: (integer) The interval at which to grab frames in seconds. If set to zero it will determine it based on grid size and duration framegrab_height: (integer) The height of the generated frames in pixels. | def generate_previews(filename, options = {})
framegrab_grid = options['framegrab_grid'] || Config['PreviewSettings']['default_grid']
framegrab_interval = options['framegrab_interval'] || Config['PreviewSettings']['default_interval']
framegrab_height = options['framegrab_height'] || Config['PreviewSettings']['default_height']
base_filename = File.basename(filename)
filesize = File.size(filename)
file_info = Mediainfo.new filename
if framegrab_interval.to_i == 0
total_images = 1
framegrab_grid.split('x').each do |x|
total_images *= x.to_i
end
framegrab_interval = file_info.duration / total_images
end
count = 0
units = ['bytes', 'KB', 'MB', 'GB', 'TB']
loop do
break if filesize < 1024.0
count += 1
filesize /= 1024.0
end
pretty_filesize = filesize.round(2).to_s + ' ' + units[count]
duration = file_info.duration
remainder = 0
count = 0
units = ['sec','min','h']
loop do
break if duration < 60
count += 1
remainder = duration % 60
duration /= 60
end
pretty_duration = duration.round(0).to_s + ' ' + units[count]
if remainder > 0
pretty_duration += ' ' + remainder.round(0).to_s + ' ' + units[count-1]
end
command = "ffmpeg -loglevel panic -y -i \"#{filename}\" -frames 1 -q:v 1 -vf \"select='isnan(prev_selected_t)+gte(t-prev_selected_t\," + framegrab_interval.to_s + ")',scale=-1:" + framegrab_height.to_s + ",tile=" + framegrab_grid + "\" '/tmp/video_preview.jpg'"
# puts command
if system(command)
# # Now that the preview is generated, post it to Mattermost
if !(uploaded_file_url = upload_file('/tmp/video_preview.jpg', base_filename))
call_mattermost({:text => "We ran into a problem uploading the file. Have someone look at this!"})
else
message = "\n\n"
message+= "|#{base_filename}|[(preview)](#{uploaded_file_url})|\n"
message+= "|-|-:|\n"
message+= "|File Size| **#{pretty_filesize}**|\n"
message+= "|Duration| **#{pretty_duration}**|\n"
message+= "|Format| **#{file_info.format}**|"
actions = Config['FileOperations']
attachments_actions = []
actions.keys.each do |key|
action_hash = {
'name': key,
'integration': {
'url': [Config['Webhook']['url'], 'run-command'].join('/'),
'context': {
'command': key,
'filename': File.realpath(filename)
}
}
}
attachments_actions.push(action_hash)
end
attachments = [
{
"text": message,
"actions": attachments_actions
}]
payload = {:attachments => attachments}
call_mattermost(payload)
end
else
Log.error "There was an error running the command: #{command}"
call_mattermost({:text => "### DANGER WILL ROBINSON\nERROR"})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_compilation\n puts \"Generating compilation\"\n get_selected_vines\n pathArray = [];\n @selected_vines.each do |vid|\n vine = Vine.find(vid)\n pathArray.push vine.path\n end\n if pathArray.count > 0\n return outputFile = execute_ffmpeg(pathArray)\n end\n end",
"def gen_highlights_for_multi_sessions(session_count, video_dir, txt_dir, dst_video)\n mpg_videos = []\n seg_filenames = []\n k = 1\n (1..session_count).each do |i|\n src_video = File.join(video_dir, \"session#{i}.mp4\")\n txt_file = File.join(txt_dir, \"session#{i}.txt\")\n pairs = get_time_pairs(txt_file)\n pairs.each do |pair|\n outmp4 = File.join($tmp_folder, \"#{k}.mp4\")\n outmpg = File.join($tmp_folder, \"#{k}.mpg\")\n seg_filenames << outmpg\n cmd_str = \"#{$ffmpeg} -ss #{pair[0]} -t #{pair[1] - pair[0] + 2} -i \\\"#{src_video}\\\" #{outmp4}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmp4\n cmd_str = \"#{$ffmpeg} -i #{outmp4} -qscale:v 1 #{outmpg}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmpg\n k = k + 1\n end\n end\n all_segs = seg_filenames.join('|')\n mpg_all = File.join($tmp_folder, 'all.mpg')\n cmd_str = \"#{$ffmpeg} -i \\\"concat:#{all_segs}\\\" -c copy #{mpg_all}\"\n p cmd_str\n system(cmd_str) unless File.exists? mpg_all\n cmd_str = \"#{$ffmpeg} -i #{mpg_all} -qscale:v 1 #{dst_video}\"\n p cmd_str\n system(cmd_str)\nend",
"def generate_black_video(movie, visual)\n #Render an image and create a video file from it\n @generated_videos += 1\n filename = movie.project.trimmed + \"/generated-#{@generated_videos}.avi\"\n cmd = @settings['still_video'].dup\n length = visual.end_point - visual.start_point\n cmd.sub!('<frames>', length.to_frames(25).to_s)\n cmd.sub!('<source>', VREConfig.instance.vre_root + \"resources/black_box.png\")\n cmd.sub!('<resolution>', movie.resolution)\n cmd.sub!('<target>', filename)\n system(cmd)\n filename\n end",
"def create_black_video(movie, visual)\n #Render an image and create a video file from it\n @generated_videos += 1\n filename = movie.project.trimmed + \"/generated-#{@generated_videos}.avi\"\n cmd = @settings['still_video'].dup\n length = visual.end_point - visual.start_point\n cmd.sub!('<frames>', length.to_frames(25).to_s)\n cmd.sub!('<source>', VREConfig.instance.vre_root + \"resources/black_box.png\")\n cmd.sub!('<resolution>', movie.resolution)\n cmd.sub!('<target>', filename)\n system(cmd)\n visual.file = filename\n visual.type = \"video\"\n visual.mute = true\n filename\n end",
"def screenshots(num_thumbnail_imgs)\n puts \"transcoded_movie thumbnail generation\"\n\t puts \"number of thumbnails #{num_thumbnail_imgs}\"\n\t \n\t \n\t #skipping some frames from begining and ending to take screenshots\n\t init_time = 15\n seek_t = ($transcoded_movie.duration - init_time*2) / num_thumbnail_imgs.to_i\n \t \n\t \n\t i = 0\n\t \n\t while i < num_thumbnail_imgs.to_i do\n filename = \"thumbnail_#{i}.jpg\"\n \n \t #, preserve_aspect_ratio: :width\n # keeping 160x90 to preserve aspect ratio 16:9 \n\t\t \n\t\t puts \"generating #{filename}\"\n \n\t\t $transcoded_movie.screenshot(filename, seek_time: (init_time + seek_t * i), resolution: '160x90')\n\t\t i += 1\n end #end while\t \n end",
"def run_loop(file_name)\n\n if @defaults[:ignore_files]\n MmMovieIgnoreList.shared_ignore_list.add(path: file_name)\n output(\"Note: added #{file_name} to the list of files to be ignored.\")\n elsif @defaults[:unignore_files]\n MmMovieIgnoreList.shared_ignore_list.remove(path: file_name)\n output(\"Note: removed #{file_name} to the list of files to be ignored.\")\n else\n @file_count[:processed] = @file_count[:processed] + 1\n movie = MmMovie.new(with_file: file_name)\n a = movie.interesting? # already interesting if low-quality, but separate quality check made for logic, below.\n b = MmMovieIgnoreList.shared_ignore_list.include?(file_name)\n c = movie.meets_minimum_quality?\n s = @defaults[:scan_type]&.to_sym\n\n if (s == :normal && a && !b && c) ||\n (s == :all && !b) ||\n (s == :flagged && b) ||\n (s == :quality && !c ) ||\n (s == :force)\n\n @file_count[:displayed] = @file_count[:displayed] + 1\n output(file_name)\n output(movie.format_table)\n output(movie.stream_table)\n if @defaults[:shell_commands]\n output(\"echo \\\"#{File.basename(file_name)}\\\" ; \\\\\", true)\n output(\"#{movie.command_rename} ; \\\\\", true)\n output(\"#{movie.command_transcode} ; \\\\\", true)\n output(movie.command_review_post, true)\n end\n output(\"\\n\\n\", true)\n end\n end # if\n end",
"def encode_movie(m)\r\n\tmovie_path = m[0..(m.length-2)].join('\\\\')\r\n\tmovie_folder = m[m.length-1]\r\n\r\n\tprint movie_folder + \", path:\" +movie_path+ \"\\n\"\r\n\r\n\tmovie_data_path = movie_path + \"\\\\\" + movie_folder + \"\\\\Pos0\\\\\"\r\n\tout_file = movie_data_path + \"..\\\\\" + movie_folder\r\n\tffmpeg_cmd = \"ffmpeg32 -framerate 30 -threads 2 -report -i \\\"#{movie_data_path}\\\\img_%09d_Default_000.tif\\\" -pix_fmt yuv420p \\\"#{out_file}.m4v\\\"\"\r\n\tprint \"#{ffmpeg_cmd}\\n=>\\n\"\r\n\t`#{ffmpeg_cmd}`\r\n\treturn [movie_path, \"#{out_file}.m4v\", movie_folder]\r\nend",
"def outputs\n VIDEO_PRESETS.map do |variant, preset_id|\n {\n key: \"#{name}-#{variant}\",\n thumbnail_pattern: \"#{name}-#{variant}-{count}\",\n preset_id: preset_id,\n segment_duration: SEGMENT_DURATION\n }\n end\n end",
"def mux(options={})\n if File.file?(options[:output])\n File.delete(options[:output])\n end\n\n create do |mp4creator|\n mp4creator.create = options[:audio]\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.create = options[:video]\n mp4creator.rate = options[:frame_rate].to_f\n mp4creator.file = options[:output]\n end\n\n if options[:hint]\n create do |mp4creator|\n mp4creator.hint = 1\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.hint = 2\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.optimize = true\n mp4creator.file = options[:output]\n end\n end\n end",
"def video(filename, opts = {})\n n = input(filename, opts)\n @videos << n\n n\n end",
"def generateVideos()\n #GENERATE AN INTERMEDIARY DIRECTORY WHERE WE'D STORE THE VIDEO FRAGMENTS\n pathToIntermediates=\"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n puts \"generating intermediate videos in #{pathToIntermediates}\"\n createDirectoryIfNotExists(pathToIntermediates)\n \n dsPath=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/deskshare\"\n presentationPath=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/presentation\"\n \n #Scale to optimal resolution\n maxW=0\n maxH=0\n if Dir.exist?dsPath then\n maxW, maxH = getMaxResolution(dsPath)\n else \n maxW, maxH = getMaxResolution()\n end\n\n\n @objects.each_with_index{\n |val, index|\n puts \"Generating a #{val.class} video in interval [#{val.start_timestamp}, #{val.stop_timestamp}]\"\n val.generateVideo(pathToIntermediates, index, maxW, maxH)\n } \n end",
"def timelapse\n raise NoSnapshotError if Dir.glob(saving_path+'/*.jpg').count.zero?\n\n puts \"Generate video...\"\n MovieMaker.build\n puts \"Video is ready.\"\n end",
"def split_movie(file_path)\n OSX.require_framework(\"QTKit\")\n splitted_files = Array.new\n movie, error = OSX::QTMovie.movieWithFile_error(file_path) # Load in the original movie\n if(error != nil || movie == nil) # Check if we can load the movie\n $stderr.puts \"Could not open #{file_path}, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # a QTTime structure has a timeValue and timeScale we need\n # to dived the timeValue by the timeScale to get the time\n # in seconds. If we devide that by 60 we get the time in\n # minutes\n time_scale = movie.duration.timeScale\n total_time = (movie.duration.timeValue / time_scale) / 60\n \n # If the total time is below 10 minutes we don't have to\n # split the movie\n if(total_time < 10)\n splitted_files.push(file_path)\n return splitted_files\n end\n \n # If the totol time is above 10 minutes we have to calculate\n # how many parts we need to make. No part can be over 10 minutes.\n parts = total_time.to_i / 10\n \n if(total_time.modulo(10) != 0)\n parts = parts + 1\n end\n \n # Parts are always 10 minutes long (or shorter)\n part_duration = OSX::QTMakeTime(600 * time_scale, time_scale)\n temp_dir = Dir.tmpdir()\n attributes = OSX::NSDictionary.dictionaryWithObjectsAndKeys(OSX::NSNumber.numberWithBool(true), \"QTMovieFlatten\", nil)\n movies = Array.new\n \n # For every part we extract the time selection out of the original movie\n # and write it out to a new, temporary file. We store the paths to the\n # temporary files\n parts.times do |i|\n begin_time = OSX::QTMakeTime(i * 600 * time_scale, time_scale)\n range = OSX::QTMakeTimeRange(begin_time, part_duration)\n movie_part, error = movie.movieWithTimeRange_error(range)\n \n if(error != nil || movie_part == nil)\n $stderr.puts \"Could not generate subclip, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # Writing out the temporary file and storing the path in the movies array\n temp_file_path = temp_dir + \"/\" + File.basename(file_path, File.extname(file_path)) + \"-\" + i.to_s + \".mov\"\n movie_part.writeToFile_withAttributes(temp_file_path, attributes)\n movies.push(temp_file_path)\n end\n return movies \n end",
"def video_gen(slide)\n term = slide['term']\n kind = slide['kind']\n index = slide['index']\n audio = slide['audio']\n image = slide['image']\n raise \"audio is required fof #{term}\" unless audio\n raise \"image is required fof #{term}\" unless image\n file_name = file_name_gen(slide, \".mpg\")\n audio = command_arg(slide['audio'])\n image = command_arg(slide['image'])\n video = command_arg(file_name)\n `ffmpeg -loop 1 -y -i #{image} -i #{audio} -acodec libmp3lame -vcodec mpeg4 -shortest -qscale:v 1 #{video}`\n slide['video'] = file_name\nend",
"def run\n\n @options = @video.convert_options\n @output_file = \"#{generate_path @video.name}/#{@video.name}#{@options[:postfix]}.#{@options[:extension]}\"\n\n command = \"#{CONFIG[:ffmpeg_binary]} -y -i '#{@video.path}' #{@options} '#{@output_file}'\"\n output = \"\"\n convert_error = true\n\n # before convert callbacks\n Hook.exec :before_convert, @video, command\n\n # process video\n Open3.popen3(command) do |stdin, stdout, stderr|\n stderr.each \"r\" do |line|\n VTools.fix_encoding line\n output << line\n\n # we know, that all is not so bad, if \"time=\" at least once met\n if line.include? \"time=\"\n\n convert_error = false # that is why, we say \"generally it's OK\"\n\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n elsif line =~ /time=(\\d+.\\d+)/ # ffmpeg 0.7 and below style\n time = $1.to_f\n else # in case of unexpected output\n time = 0.0\n end\n progress = time / @video.duration\n Hook.exec :in_convert, @video, progress # callbacks\n end\n end\n end\n\n raise ProcessError, output.split(\"\\n\").last if convert_error # exit on error\n\n # callbacks\n unless error = encoding_invalid?\n Hook.exec :convert_success, @video, @output_file\n else\n Hook.exec :convert_error, @video, error, output\n raise ProcessError, error # raise exception in error\n end\n\n encoded\n end",
"def transcode_movie\n @command = \"#{FFMPEG.ffmpeg_binary} -y -i #{Shellwords.escape(@movie.path)} #{@raw_options} #{Shellwords.escape(@output_file)}\"\n FFMPEG.logger.info(\"Running transcoding...\\n#{@command}\\n\")\n @output = ''\n\n Open3.popen3(@command) do |_stdin, _stdout, stderr, wait_thr|\n begin\n yield(0.0) if block_given?\n\n next_line = proc do |line|\n fix_encoding(line)\n @output << line\n\n # frame= 1253 fps=249 q=0.0 size=N/A time=00:00:23.90 bitrate=N/A speed=4.75x\n if line.include?('time=')\n time = 0.0\n if line =~ /time=(?<hours>\\d+):(?<minutes>\\d+):(?<seconds>\\d+\\.\\d+)/ # ffmpeg 0.8 and above style\n time = (Regexp.last_match(:hours).to_i * 3600) + (Regexp.last_match(:minutes).to_i * 60) + Regexp.last_match(:seconds).to_f\n end\n progress = time / @movie.duration\n\n yield(progress) if block_given?\n end\n end\n\n if self.class.timeout\n stderr.each_with_timeout(wait_thr.pid, self.class.timeout, 'size=', &next_line)\n else\n stderr.each('size=', &next_line)\n end\n rescue Timeout::Error => e\n FFMPEG.logger.error \"Process hung... #{e.message}\\n@command\\n#{@command}\\nOutput\\n#{@output}\\n\"\n raise Error, \"Process hung. Full output: #{@output}\"\n end\n end\n end",
"def run\n @files.each do |file|\n generate_tracklist(file)\n end\n end",
"def ffmpeg_libvpx_cmd(input_path, output_path, bitrate, output_size, force=false)\n replace = force ? \"-y\" : \"\"\n return [\n \"ffmpeg -i '#{input_path}' -threads 8\",\n \"-c:v libvpx -pix_fmt yuv420p -crf 10 -b:v #{bitrate} -s #{output_size} -movflags +faststart -r 29.97 -c:a libvorbis -aq 5 #{replace} '#{output_path}'\"\n ]\nend",
"def process_previews!\n source = Magick::ImageList.new(preview_path).first\n\n previews.each do |name, blk|\n path = File.join(@dir, \"#{name}_preview.jpg\")\n\n copy = source.copy\n blk.call(copy)\n copy.write(path)\n\n @paths << path\n end\n\n @paths\n end",
"def ffmpeg_libx264_cmd(input_path, output_path, bitrate, output_size, force=false)\n crf = case bitrate\n when \"10M\" then 20\n when \"2M\" then 20\n when \"500k\" then 21\n else 21\n end\n replace = force ? \"-y\" : \"\"\n return [\n \"ffmpeg -i '#{input_path}' -threads 8\",\n \"-c:v libx264 -profile:v main -pix_fmt yuv420p -tune film -crf #{crf} -s #{output_size} -movflags +faststart -r 29.97 -c:a libfdk_aac -b:a 48k #{replace} '#{output_path}'\"\n ]\nend",
"def video(*sources)\n options = sources.extract_options!.symbolize_keys\n sources = sources.shift if sources.size == 1\n\n if options[:poster]\n options[:poster] = asset_path(options[:poster])\n end\n\n if size = options.delete(:size)\n options[:width], options[:height] = size =~ /^\\d+x\\d+$/ ? size.split('x') : size\n end\n\n if sources.is_a?(Array)\n content_tag(:video, options) do\n sources.collect { |source| tag(:source, src: asset_path(source)) }.join(\"\\n\")\n end\n else\n tag(:video, options.reverse_merge(src: asset_path(sources)))\n end\n end",
"def convert(file_info)\n input_name = Shellwords.escape(file_info[:filename])\n input_suffix = File.extname input_name\n output_name = File.basename input_name, input_suffix\n output_suffix = \"mp4\"\n command = [ \"ffmpeg\", \"-y\", \"-i #{input_name}\", \"-max_muxing_queue_size 9999\", \"-map_chapters -1\" ]\n\n if (file_info[:video].empty? && !file_info[:audio].empty?) || input_suffix == '.flac' || input_suffix == '.mp3' || input_suffix == '.aiff'\n #\n # Audio-only files are converted to either ALAC if the source was FLAC, or\n # AAC for all other formats.\n #\n stream = file_info[:audio][0]\n case stream[:codec]\n when \"alac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a copy\"\n when \"flac\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n when \"mp3\"\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a alac\"\n else\n command << \"-map 0:a:#{stream[:index]}\" << \"-codec:a aac\" << \"-ar:a:0 48k\" << \"-ab:a 256k\"\n end\n output_suffix = \"m4a\"\n elsif !file_info[:video].empty? && !file_info[:audio].empty?\n # Removes all of the default metadata that junks up the final file.\n command << \"-map_metadata -1\"\n \n # Maps the video track\n command << \"-map 0:v:0\" << \"-metadata:s:v:0 language=und\" << \"-metadata:s:v:0 title='Video Track'\"\n\n #\n # The video track is copied if the codec is h265 (hevc) and a video tag\n # is added so that Apple products understand the format. Otherwise, the\n # video track is copied if it's in h264 format and the frame size is\n # to remain the same, or it's converted to h264 using high-quality\n # settings.\n #\n if \"hevc\" == file_info[:video][:codec]\n command << \"-codec:v copy -vtag hvc1\"\n elsif \"h264\" == file_info[:video][:codec] && !Options.options[:P480] && !Options.options[:P720]\n command << \"-codec:v copy\"\n else\n # This converts the video using settings that provide nearly visual\n # lossless results.\n output_suffix = \"mp4\"\n command << \"-codec:v libx265\" << \"-vtag hvc1\" << \"-preset:v slow\" << \"-profile:v main\" << \"-crf:v 18\" << \"-threads:v 0\"\n\n # Converts HD video to wide-screen 720P if necessary.\n command << \"-vf:v scale=1280:-1\" if Options.options[:P720]\n\n # Converts HD video to wide-screen 480P if necessary.\n command << \"-vf:v scale=854:-1\" if Options.options[:P480]\n end\n\n # Convert all of the audio tracks to AAC (stereo) and AC3 (multi-channel)\n index = 0\n file_info[:audio].each do |stream|\n index, c = convert_audio(stream, index)\n command << c\n end\n\n if file_info.key?(:subtitle) && !file_info[:subtitle].nil? && !file_info[:subtitle].empty?\n command << \"-map 0:s:#{file_info[:subtitle][:index]}\" << \"-metadata:s:s:0 language=eng\" << \"-metadata:s:s:0 title='Subtitle Track'\"\n command << ('dvd_subtitle' == file_info[:subtitle][:codec] ? \"-codec:s:0 copy\" : \"-codec:s:0 mov_text\")\n end\n\n end\n\n command << \"#{output_name}.#{output_suffix}\"\n\n if Options.options[:dump]\n puts command.join(' ')\n exit\n end\n\n #\n # Starts the transcoding process.\n #\n puts file_info[:filename]\n progress = ProgressBar.create(:format => \"%t |%B| %e\",\n :total => file_info[:duration] + 1,\n :title => \"Encoding Progress\")\n execute(command, true) do |line|\n begin\n line.match /time=(\\d\\d):(\\d\\d):(\\d\\d)/ do |match|\n if match.length == 4\n time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_i\n progress.progress = time\n end\n end\n rescue\n # Some UTF-8 characters can cause match to throw, but these characters are not used by this script.\n end\n end\n progress.finish\nend",
"def run\n file = \"english.srt\"\n times = parse_times file\n build_ffmpeg times, file\nend",
"def test03()\n sourceMovie = File.join($directory, \"images/604_sd_clip.mov\") # 576x360\n width = 576\n height = 360\n movieLength = 300.0 # seconds.\n borderWidth = 32\n bitmapWidth = (3.0 * width.to_f * 0.5 + (3+1) * borderWidth).to_i\n bitmapHeight = (4.0 * height.to_f * 0.5 + (4+1) * borderWidth).to_i\n bitmapSize = MIShapes.make_size(bitmapWidth, bitmapHeight)\n baseFileName = \"coversheet\"\n begin\n # 1. Create the list of commands object, ready to have commands added to it.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 2. Create movie importer and assign to list of commands.\n # Basically after the first block of commands is run, the movie importer\n # is closed automatically in the cleanup commands.\n movieImporterName = SecureRandom.uuid\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName)\n \n # 3. Create the process movie frames command and configure.\n imageIdentifier = SecureRandom.uuid\n\n processFramesCommand = ProcessFramesCommand.new(movieObject)\n processFramesCommand.create_localcontext = false\n processFramesCommand.imageidentifier = imageIdentifier\n\n track_id = MovieTrackIdentifier.make_movietrackid_from_mediatype(\n mediatype: :vide, trackindex: 0)\n \n processFramesCommand.videotracks = [ track_id ]\n\n # 4. Make a pre-process command list.\n preProcessCommands = []\n \n # 5. Make a create a bitmap context command.\n bitmapName = SecureRandom.uuid\n createBitmapCommand = CommandModule.make_createbitmapcontext(\n name: bitmapName, size: bitmapSize)\n\n bitmapObject = SmigIDHash.make_objectid(objecttype: :bitmapcontext,\n objectname: bitmapName)\n\n # 6. Add the create bitmap context object command to the pre-process list.\n preProcessCommands.push(createBitmapCommand.commandhash)\n\n # 7. Make a create exporter object command and add it to the pre-process list\n exporterName = SecureRandom.uuid\n createExporterCommand = CommandModule.make_createexporter(\n \"~/placeholder.jpg\", export_type: 'public.jpeg', name: exporterName)\n preProcessCommands.push(createExporterCommand.commandhash)\n exporterObject = SmigIDHash.make_objectid(objecttype: :imageexporter,\n objectname: exporterName)\n\n # 8. Assign the pre-process commands to the process movie frames command.\n processFramesCommand.preprocesscommands = preProcessCommands\n \n # 9. Add a close bitmap object command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_closeobject(bitmapObject)\n \n # 10. Add a close exporter object command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_closeobject(exporterObject)\n\n # 11. Add a remove image from collection command to cleanup commands.\n processFramesCommand.add_tocleanupcommands_removeimage(imageIdentifier)\n\n # 12. Prepare and start looping for creating process frame instrutions.\n numFrames = 24\n framesPerPage = 12 # 3 x 4\n frameDuration = movieLength / (numFrames - 1)\n pageNumber = 0\n x = 0\n y = 0\n halfWidth = width / 2\n halfHeight = height / 2\n drawnFrameSize = MIShapes.make_size(halfWidth, halfHeight)\n textBoxSize = MIShapes.make_size(halfWidth, borderWidth * 3 / 4)\n filesToCompare = []\n numFrames.times do |i|\n # 13. Create a ProcessMovieFrameInstruction object\n frameInstructions = ProcessMovieFrameInstructions.new\n \n # 14. Calculate the frame time and assign it.\n time = i.to_f * frameDuration\n frameTime = MovieTime.make_movietime_fromseconds(time)\n frameInstructions.frametime = frameTime\n \n # 15. Determine the frame number on the page & destination rectangle.\n frameNumber = i % framesPerPage\n x = frameNumber % 3\n y = 3 - (frameNumber / 3)\n xloc = x * halfWidth + (x + 1) * borderWidth\n yloc = y * halfHeight + (y + 1) * borderWidth\n origin = MIShapes.make_point(xloc, yloc)\n drawnFrameRect = MIShapes.make_rectangle(size: drawnFrameSize,\n origin: origin)\n \n # 16. Create the draw image element to draw the frame onto the bitmap.\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.destinationrectangle = drawnFrameRect\n drawImageElement.set_imagecollection_imagesource(identifier: imageIdentifier)\n \n # 17. Create the draw image command and add it to the frame instructions.\n drawImageCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: drawImageElement, createimage: false)\n frameInstructions.add_command(drawImageCommand)\n \n # 18. Prepare drawing the text with the time.\n timeString = \"Frame time: %.3f secs\" % time\n drawStringElement = MIDrawBasicStringElement.new()\n drawStringElement.stringtext = timeString\n drawStringElement.userinterfacefont = \"kCTFontUIFontLabel\"\n drawStringElement.textalignment = \"kCTTextAlignmentCenter\"\n drawStringElement.fillcolor = MIColor.make_rgbacolor(0.0, 0.0, 0.0)\n boxOrigin = MIShapes.make_point(xloc, yloc - borderWidth)\n boundingBox = MIShapes.make_rectangle(size: textBoxSize, origin: boxOrigin)\n drawStringElement.boundingbox = boundingBox\n drawTextCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: drawStringElement, createimage: false)\n frameInstructions.add_command(drawTextCommand)\n\n # 19. If this was the last frame to be drawn then export the page.\n if (frameNumber == framesPerPage - 1) || i == numFrames - 1\n addImageCommand = CommandModule.make_addimage(exporterObject, bitmapObject)\n frameInstructions.add_command(addImageCommand)\n pageNum = (i / 12).to_s.rjust(3, '0')\n fileName = baseFileName + pageNum + \".jpg\"\n filesToCompare.push(fileName)\n# filePath = File.join($compareImageDir, fileName)\n filePath = File.join(Dir.tmpdir(), fileName)\n setExportPathCommand = CommandModule.make_set_objectproperty(\n exporterObject,\n propertykey: :file,\n propertyvalue: filePath)\n frameInstructions.add_command(setExportPathCommand)\n exportCommand = CommandModule.make_export(exporterObject)\n frameInstructions.add_command(exportCommand)\n # 20. Now redraw the bitmap context with a white rectangle.\n redrawBitmapElement = MIDrawElement.new(:fillrectangle)\n redrawBitmapElement.fillcolor = MIColor.make_rgbacolor(1.0, 1.0, 1.0)\n redrawBitmapElement.rectangle = MIShapes.make_rectangle(size: bitmapSize)\n redrawCommand = CommandModule.make_drawelement(bitmapObject,\n drawinstructions: redrawBitmapElement)\n frameInstructions.add_command(redrawCommand)\n end\n # 21. Set the frame processing intructions to the process frames command.\n processFramesCommand.add_processinstruction(frameInstructions)\n end\n \n # 22. Add the process frames command to the list of commands.\n theCommands.add_command(processFramesCommand)\n Smig.perform_commands(theCommands)\n\n filesToCompare.each do |fileName|\n origFile = File.join($compareImageDir, fileName)\n tempFile = File.join(Dir.tmpdir(), fileName)\n# tempFile = File.join($compareImageDir, fileName)\n compareResult = AreImageFilesSame(origFile, tempFile, 0)\n FileUtils.rm_f(tempFile)\n # FileUtils.mv(tempFile, origFile)\n unless compareResult\n # 2. Report if different.\n raise \"Different image files: \" + origFile + \" and \" + tempFile\n end\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n end\nend",
"def build(filename, frames)\n frames = normalize_depth frames, to: 3 # frames are rows of pixels\n pixel_args = frames.flat_map.with_index do |rows, z|\n width, height = frames.first.first.length, frames.first.length\n [ '(',\n '-size', \"#{width}x#{height}\", 'xc:none',\n '-frame', z.to_s,\n *rows.flat_map.with_index { |pixels, y|\n pixels.flat_map.with_index do |pixel, x|\n color = if pixel[:transparent]\n ['-alpha', 'Transparent']\n else\n [\"-fill\", \"RGB(#{pixel.fetch :red},#{pixel.fetch :green},#{pixel.fetch :blue})\",\n \"-draw\", \"point #{x},#{y}\"\n ]\n end\n end\n },\n ')',\n ]\n end\n\n if File.exist? filename\n puts \"skipping #{filename}\"\n else\n program = 'convert', '-coalesce', *pixel_args, filename\n puts program.join ' '\n system *program\n end\nend",
"def callback\n base_dir = \"#{RAILS_ROOT}/../../../source/\"\n\n a = Asset.find_by_zencoder_output_id(params['output']['id'])\n\n file_extension = \"mp4\"\n\n case a.description\n when \"1280x720\"\n size = \"-large\"\n when \"640x360\"\n size = \"-small\"\n else\n size = \"\"\n file_extension=\"mp3\"\n end\n\n file = \"#{a.video.to_param}#{size}.#{file_extension}\"\n # pick a random thumbnail as the preview image\n image_file = \"#{a.video.to_param}-thumb_#{rand(5).to_s.rjust(4,\"0\")}.png\"\n\n a.data = File.new(\"#{base_dir}zencoder/#{file}\")\n a.save\n\n a.populate_metadata\n a.zencoder_job_complete = true\n a.save\n\n if size == \"-small\"\n v = a.video\n v.streaming_asset_id = a.id\n v.available = true\n v.post_date = Date.today\n v.image = File.new(\"#{base_dir}zencoder/#{image_file}\")\n v.save\n end\n\n # TODO add code to set the primary asset to complete if all assets\n # generated by that one are complete.\n all_done = true\n a.video.assets.each do |as|\n unless as.generated_by_asset_id == 0 && as.generated_by_asset_id.nil?\n unless as.zencoder_job_complete == true\n all_done = false\n end\n end\n end\n\n if all_done\n generated_by_asset = Asset.find(a.generated_by_asset_id)\n generated_by_asset.zencoder_job_complete = true\n generated_by_asset.save\n end\n\n respond_to do |format|\n format.js {\n render :text => \"ok\".to_json\n }\n end\n end",
"def checkForTranscode(path, filename)\n pathToFile = File.join(path, filename)\n outputPathToFile = File.join(TMP_PATH, pathToFile)\n\n if ($doNotConvertVideosAgain && File.exists?(outputPathToFile))\n BigBlueButton.logger.info( \"Converted video for #{pathToFile} already exists, skipping...\")\n return path\n end\n\n # Gather possible commands\n transcodeCommands = []\n movie = FFMPEG::Movie.new(pathToFile)\n unless (movie.width % 2 == 0 && movie.height % 2 == 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} requires cropping to be DivBy2\")\n transcodeCommands.push(%w(-y -r 30 -vf crop=trunc(iw/2)*2:trunc(ih/2)*2))\n end\n if (movie.duration <= 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} requires transcoding due to missing duration\")\n transcodeCommands.push(%w(-y -c copy))\n end\n\n # Run gathered commands\n if(transcodeCommands.length == 0)\n BigBlueButton.logger.info( \"Video #{pathToFile} is fine\")\n return path\n else\n # Create path to save conversion to\n outputPath = File.join(TMP_PATH, path)\n unless File.directory?(outputPath)\n FileUtils.mkdir_p(outputPath)\n end\n\n BigBlueButton.logger.info( \"Start converting #{pathToFile} ...\")\n transcodeCommands.each do | command |\n BigBlueButton.logger.info( \"Running ffmpeg with options: #{command}\")\n movie.transcode(outputPath + 'tmp' + filename, command)\n FileUtils.mv(outputPath + 'tmp' + filename, outputPathToFile)\n movie = FFMPEG::Movie.new(outputPathToFile) # Further transcoding should happen on the new file\n end\n\n BigBlueButton.logger.info( \"Done converting #{pathToFile}\")\n return outputPath\n end\nend",
"def run\n begin\n prepare_for_conversion\n\n Queue.run *FORMATS.map{ |format| proc{ convert_to(format) } }, close_connection_before_execution: true\n \n mp4_file_info = Info.new output_path(:mp4)\n webm_file_info = Info.new output_path(:webm)\n \n unless similar_durations?(mp4_file_info.duration, webm_file_info.duration) \n raise Error.new( 'output videos have different duration', \n model_id: model_id, mp4_duration: mp4_file_info.duration, webm_duration: webm_file_info.duration )\n end\n \n cover_path = File.join output_folder, COVER_FORMAT % output_filename_without_extension\n extract_cover output_path(:mp4), cover_path, mp4_file_info.duration\n \n thumb_path = File.join output_folder, THUMB_FORMAT % output_filename_without_extension\n extract_thumb cover_path, thumb_path, *THUMB_SIZES\n \n rescue StandardError => e\n FileUtils.rm_rf output_folder\n \n input_path = \n if File.exists? temp_path\n temp_path\n elsif File.exists? uploaded_path\n uploaded_path\n end\n FileUtils.cp input_path, create_log_folder if input_path\n\n if model.present? and model.user_id.present?\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.failed.title'),\n I18n.t('notifications.video.upload.failed.message', :item => model.title),\n ''\n )\n model.destroyable_even_if_not_converted = true\n model.destroy\n end\n\n raise e\n end\n \n model.converted = true\n model.rename_media = true\n model.mp4_duration = mp4_file_info.duration\n model.webm_duration = webm_file_info.duration\n model.media = output_filename_without_extension\n model[:media] = output_filename_without_extension\n model.save!\n\n #FileUtils.rm temp_path\n FileUtils.rm_r temp_folder\n\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.ok.title'),\n I18n.t('notifications.video.upload.ok.message', :item => model.title),\n ''\n )\n end",
"def each &block\n if block_given?\n Tempfile.open('temp', binmode: true) do |newmovi|\n @avi.process_movi do |indices, movi|\n newindices = indices.select do |m|\n movi.pos = m[:offset] + 8 # 8 for id and size\n frame = Frame.new(movi.read(m[:size]), m[:id], m[:flag])\n block.call frame\n unless frame.data.nil?\n m[:offset] = newmovi.pos\n m[:size] = frame.data.size\n m[:flag] = frame.flag\n m[:id] = frame.id\n newmovi.print m[:id]\n newmovi.print [frame.data.size].pack('V')\n newmovi.print frame.data\n newmovi.print \"\\0\" if frame.data.size % 2 == 1\n true\n else\n false\n end\n end\n [newindices, newmovi]\n end\n end\n else\n self.enum_for :each\n end\n end",
"def videostab(path_to_video, width, height, crop, tracking_mode)\n\t# from true/false to 1/0\n\ttracking_mode = tracking_mode && 1 || 0\n\tpython_output = `python #{PYNAME} #{path_to_video} #{width} #{height} #{crop} #{tracking_mode}`\n\tputs \"The output from #{PYNAME} is: #{python_output}\"\nend",
"def transcode_movie\n @command = \"#{@movie.ffmpeg_command} -y #{@raw_options} #{Shellwords.escape(@output_file)}\"\n\n FFMPEG.logger.info(\"Running transcoding...\\n#{@command}\\n\")\n @output = \"\"\n\n Open3.popen3(@command) do |stdin, stdout, stderr, wait_thr|\n begin\n yield(0.0) if block_given?\n next_line = Proc.new do |line|\n fix_encoding(line)\n @output << line\n if line.include?(\"time=\")\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n else # better make sure it wont blow up in case of unexpected output\n time = 0.0\n end\n progress = time / @movie.duration\n yield(progress) if block_given?\n end\n end\n\n if @@timeout\n stderr.each_with_timeout(wait_thr.pid, @@timeout, 'size=', &next_line)\n else\n stderr.each('size=', &next_line)\n end\n\n rescue Timeout::Error => e\n FFMPEG.logger.error \"Process hung...\\n@command\\n#{@command}\\nOutput\\n#{@output}\\n\"\n raise Error, \"Process hung. Full output: #{@output}\"\n end\n end\n end",
"def create_locally\n write_file(@video_file, @video_name)\n write_file(@poster_file, @poster_name)\n end",
"def build!\n test_git!\n\n file_list = Dir.glob(\"#{@source}*\").sort # Pull the file list before creating the target directory\n\n setup_target\n\n add_runner\n\n file_list.each do |infile_name|\n rewrite_animation_frame infile_name\n create_commit infile_name\n end\n end",
"def process(opts={})\n\n # Process each access file\n @sip.access.each do |a|\n ev = self.ingest(@sip.base, a, \"access\", {:format=>\"h264\"} )\n ev.generation = \"Copy: access\"\n ev.datastreams[\"descMetadata\"].insert_next(@sip.next_access(a).to_s) if @sip.next_access(a)\n ev.datastreams[\"descMetadata\"].insert_previous(@sip.previous_access(a).to_s) if @sip.previous_access(a)\n ev.save\n end\n\n # Process each preservation file\n @sip.preservation.each do |p|\n ev = self.ingest(@sip.base, p, \"preservation\", {:format=>\"original\"} )\n ev.generation = \"original\"\n ev.datastreams[\"descMetadata\"].insert_next(@sip.next_preservation(p).to_s) if @sip.next_preservation(p)\n ev.datastreams[\"descMetadata\"].insert_previous(@sip.previous_preservation(p).to_s) if @sip.previous_preservation(p)\n ev.save\n end\n\n # add a thumbnail\n if generate_video_thumbnail(File.join(RH_CONFIG[\"location\"], @sip.base, \"data\", @sip.access.first))\n @parent.save if @parent.add_thumbnail File.new(\"tmp/thumb.jpg\") \n end\n end",
"def convertSlidesToVideo(presentationSlidesStart)\n presentationSlidesStart.each do |item|\n # Path to original svg\n originalLocation = File.join(item[\"filepath\"], item[\"filename\"])\n # Save conversion with similar path in tmp\n dirname = File.join(TMP_PATH, item[\"presentationName\"], \"svgs\")\n finalLocation = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"mp4\"))\n\n if (!File.exists?(finalLocation))\n # Create path to save conversion to\n unless File.directory?(dirname)\n FileUtils.mkdir_p(dirname)\n end\n\n # Convert to png\n image = MiniMagick::Image.open(originalLocation)\n image.format 'png'\n pathToImage = File.join(dirname, changeFileExtensionTo(item[\"filename\"], \"png\"))\n image.write pathToImage\n\n # Convert to video\n # Scales the output to be divisible by 2\n system \"ffmpeg -loglevel quiet -nostdin -nostats -y -r 30 -i #{pathToImage} -vf crop='trunc(iw/2)*2:trunc(ih/2)*2' #{finalLocation}\"\n end\n\n item[\"filepath\"] = dirname\n item[\"filename\"] = finalLocation.split('/').last\n end\n\n return presentationSlidesStart\nend",
"def video_previews_in_all_languages\n previews = []\n (videos[:list][:es] + [videos[:featured][:es]]).compact.each do |video|\n filename = video.sub(/#{Pathname.new(video).extname}$/, '')\n video_filename_without_extension = filename.gsub(/_(#{Document::LANGUAGES.join('|')})$/, '')\n previews << \"#{class_multimedia_path}#{video_filename_without_extension}.jpg\"\n Document::LANGUAGES.each do |l|\n previews<< \"#{class_multimedia_path}#{video_filename_without_extension}_#{l}.jpg\"\n end\n end\n return previews\n end",
"def thumbnail(options={})\n image = File.expand_path(options[:image])\n\n encode do |ffmpeg|\n ffmpeg.input = options[:video]\n ffmpeg.record_start_time = options[:start]\n ffmpeg.record_for = options[:length]\n ffmpeg.video_frames = options[:frames]\n ffmpeg.fps = (options[:fps] || 1)\n ffmpeg.video_frame_size = \"#{options[:width]}x#{options[:height]}\"\n ffmpeg.disable_audio = true\n ffmpeg.overwrite_output_files = true\n ffmpeg.output = image\n end\n\n image_search = image.split('%d').map { |part|\n Regexp.escape(part)\n }.join('*')\n\n return Dir[image_search]\n end",
"def combine_video(presentation)\n term = presentation['term']\n args = []\n for slide in presentation['slides']\n args.push command_arg(slide['video'])\n end\n args = args.join(' ')\n combined_arg = command_arg(\"#{BUILD_DIR}/#{term}/#{term}-combined.mpg\")\n final = \"#{DIST_DIR}/#{term}/#{term}.avi\"\n final_arg = command_arg(final)\n `cat #{args} > #{combined_arg}`\n `ffmpeg -y -i #{combined_arg} -r 25 -qscale:v 1 #{final_arg}`\n presentation['video'] = final\nend",
"def encode(file=\"output.avi\")\n puts \"encoding video #{file}\"\n MEncoder.encode do |mencoder|\n mencoder.input = \"mf://#{@frames_dir.file_list(@date, @hour, @length, @frame_type).join(',')}\"\n mencoder.mf.fps = 2\n mencoder.mf.type = \"jpg\"\n mencoder.output_video_codec = :lavc\n mencoder.lavc.vcodec = \"mpeg4\"\n mencoder.lavc.mbd = 2\n mencoder.lavc.trell = true\n mencoder.output_audio_codec = 'copy'\n mencoder.output = file\n end\n end",
"def extract_all_previews(path, file_name)\n raise NotImplementedError.new 'This is only a function body for documentation'\n end",
"def combine_video(movie)\n \n trimmed_visuals = \"\"\n contents = movie.visual_sequence.visuals\n contents.each{|visual|\n trimmed_visuals += \" #{visual.file}\"\n }\n video_file = movie.project.final + \"/videotrack.avi\"\n cmd = @settings['video_combine'].dup\n cmd.sub!('<source>', trimmed_visuals)\n cmd.sub!('<target>', video_file)\n puts \"Combining videos\"\n puts cmd\n system(cmd)\n return video_file\n end",
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end",
"def run\n command = \"#{FFMPEG.ffmpeg_binary} -y #{@input_options} -i #{Shellwords.escape(@movie.path)} #{@encoding_options}\"\n FFMPEG.logger.info(\"Running transcoding...\\n#{command}\\n\")\n output = \"\"\n Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|\n begin\n yield(0.0) if block_given?\n next_line = Proc.new do |line|\n fix_encoding(line)\n output << line\n if line.include?(\"time=\")\n if line =~ /time=(\\d+):(\\d+):(\\d+.\\d+)/ # ffmpeg 0.8 and above style\n time = ($1.to_i * 3600) + ($2.to_i * 60) + $3.to_f\n else # better make sure it wont blow up in case of unexpected output\n time = 0.0\n end\n progress = time / @movie.duration\n yield(progress) if block_given?\n end\n end\n\n if @@timeout\n stderr.each_with_timeout(wait_thr.pid, @@timeout, 'size=', &next_line)\n else\n stderr.each('size=', &next_line)\n end\n\n rescue Timeout::Error => e\n FFMPEG.logger.error \"Process hung...\\nCommand\\n#{command}\\nOutput\\n#{output}\\n\"\n raise Error, \"Process hung. Full output: #{output}\"\n end\n end\n\n if encoding_succeeded?\n yield(1.0) if block_given?\n FFMPEG.logger.info \"Transcoding of #{@movie.path} to #{@output_file} succeeded\\n\"\n else\n errors = \"Errors: #{@errors.join(\", \")}. \"\n FFMPEG.logger.error \"Failed encoding...\\n#{command}\\n\\n#{output}\\n#{errors}\\n\"\n raise Error, \"Failed encoding.#{errors}Full output: #{output}\"\n end\n encoded\n end",
"def make\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n \n\n parameters = []\n \n # Add source\n parameters << @convert_options[:input].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \"-f --quiet :source\"\n parameters << @convert_options[:output].map { |k,v| \"-#{k.to_s} #{v} \"}\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n \n Paperclip.log(\"[lame] #{parameters}\")\n begin\n success = Paperclip.run(\"lame\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end",
"def convert_command\n\t\t\tflv = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.flv\")\n\t\t\tmpeg4 = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.mp4\")\n\t\t\tFile.open(flv, 'w')\n\t\t\tFile.open(mpeg4, 'w')\n\t\t\t#command = \"cd log/ && ffmpeg -i #{ self.video.path } -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ flv }; ffmpeg -i #{ self.video.path } -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 1024k -bt 1024k -threads 0 -y #{ mpeg4 }\"\n\t\t\tcommand = \"cd log/ && ffmpeg -i '#{ self.video.path }' -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y '#{ flv }'; ffmpeg -threads 4 -i '#{ self.video.path }' -r 29.97 -vcodec libx264 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -subq 5 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -sc_threshold 40 -i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 '#{ mpeg4 }'\"\n\n\t\t\tcommand.gsub!(/\\s+/, \" \")\n\t\t\tlogger.debug command\n\t\tend",
"def screencast(duration: 6, scale: 1, window: true)\n \n fileout = @file_out.sub(/\\.\\w+$/,'%d.png')\n \n puts 'fileout: ' + fileout if @debug\n \n x4ss = X4ss.new fileout, mouse: true, window: true\n mode = window ? :window : :screen\n sleep 2; x4ss.record duration: duration, mode: mode\n x4ss.save\n \n fileout2 = fileout.sub(/(?=%)/,'b')\n EasyImgUtils.new(fileout, fileout2).scale(scale) unless scale == 1\n EasyImgUtils.new(fileout2, @file_out).animate\n \n end",
"def create\n if !params[:video][:video].nil?\n videoName = params[:video][:video].original_filename.gsub(/\\s/,'_') \n @video = Video.new({:title => params[:video][:title], :video => \"/worshipvideos/#{videoName}\"})\n else\n @video = Video.new({:title => params[:video][:title]})\n end\n\n if !params[:video][:video].nil?\n tmp = params[:video][:video].tempfile\n file = File.join(\"public/worshipvideos\", videoName)\n FileUtils.cp tmp.path, file\n FileUtils.rm tmp\n end\n\n respond_to do |format|\n if @video.save\n if !params[:video][:video].nil?\n #logger.debug \"./createVideoPics.sh '#{videoName}'\"\n #fork do\n #system(\"./createVideoPics.sh '#{videoName}'\")\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\"\n #end\n\n @video.update_attribute(\"pic1\", \"worship_pics/#{videoName}_1.jpg\")\n @video.update_attribute(\"pic2\", \"worship_pics/#{videoName}_2.jpg\")\n @video.update_attribute(\"pic3\", \"worship_pics/#{videoName}_3.jpg\")\n end\n\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def do_video_job(*inputs)\n puts \"Creating output movie: #{@output}\"\n do_system(\"cp\", inputs.first, @output) # FIXME\n # TODO: http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files\n # do_system\n # dir & .work -> output to: @output\n end",
"def combine_files files\n tempfile = Tempfile.new(\"video\")\n path = tempfile.path\n tempfile.close\n `cat #{files.join(\" \")} > #{path}.avi`\n path\n end",
"def enhance(video:, output_dir: append_enhanced(File.join(video.base_dir, video.name_no_ext)),\n make_content_frames: false,\n output_content_dir: append_content(File.join(video.base_dir, video.name_no_ext)))\n frames = get_frames(video.frame_dir)\n frame_dir_setup(output_dir)\n frame_dir_setup(output_content_dir) if make_content_frames\n output_content_dir = nil unless make_content_frames\n frames.each_slice(num_procs).with_index(1) do |elements, i|\n elements.each do |frame|\n fork do\n combined_file = Pathname.new('').join(output_dir, File.basename(frame))\n content_file = Pathname.new('').join(output_content_dir, File.basename(frame))\n enhance_frame(frame: frame, footer_height: video.footer_height,\n content_file: content_file, combined_file: combined_file)\n end\n end\n Process.waitall\n print \"\\tEnhancing frames from #{video.name}: #{(i * elements.size / frames.size.to_f * 100).truncate(1)}%\\r\"\n end\n puts\n output_name = append_enhanced(video.name_no_ext) + video.extension\n output_content_name = append_enhanced(video.name_no_ext) + '_content' + video.extension\n video.class.frames_to_video(frame_dir: output_dir, duration: video.duration, name: output_name)\n video.class.frames_to_video(frame_dir: output_content_dir, duration: video.duration, name: output_content_name)\n # TODO: Return both SEMVideo objects\n end",
"def process!\n process_previews! if self.class.preview?\n\n versions.each do |name, blk|\n path = File.join(@dir, \"#{name}_#{@filename}\")\n process_version!(path, &blk)\n @paths << path\n end\n\n @paths\n end",
"def run\n outputs = nil\n \n in_tmp_dir do\n image = tmp_path 'text_to_image.jpg'\n Image::Editing::Cmd::TextToImage.new(text, image, @options).run!\n\n outputs = ImageToVideo.new(image, @output_without_extension, duration, @log_folder).run\n end\n\n outputs\n end",
"def perform(url = nil)\n # 以此影片為範例,出處: Videvo\n url = 'https://cdn.videvo.net/videvo_files/video/free/2013-05/originalContent/DigitalCountdownTimerVidevo.mov'\n video_name = parse_video_name(url)\n video_file_path(video_name)\n download_video(url)\n converter\n rescue StandardError => e\n logger.error \"[Video::HandleVideoWorker] ERROR:\\n #{e.inspect}\\n #{e.backtrace}\"\n end",
"def play()\n @files.shuffle.each do |file|\n play_file(file)\n end\n end",
"def create\n\n @video = Video.new(video_params)\n file = @video.video.tempfile\n\n video = Panda::Video.create(:file => file)\n # binding.pry\n video.encodings['h264'].reload\n\n until video.encodings['h264'].status == 'success'\n video.encodings['h264'].reload\n end\n\n video.encodings['h264'].encoding_progress\n @video.video = video.encodings['h264'].url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def detect_face_and_timestamps(filename)\n create_faces_directory\n cmd = detect_command filename\n logger.info cmd\n puts cmd\n success = system(cmd + \" > #{Rails.root}/log/detection.log\")\n if success && $?.exitstatus == 0\n parse_xml_add_tagees_and_timesegments(get_timestamps_xml_file_name)\n File.delete get_timestamps_xml_file_name\n logger.info \"----- setting video_thumbnail to \" + thumb_path_big\n self.video_thumbnail = File.open(thumb_path_big)\n File.delete(thumb_path_big) if File.exist?(thumb_path_big)\n File.delete(thumb_path_small) if File.exist?(thumb_path_small)\n else\n self.failed!\n end\n end",
"def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end",
"def process_video(options = {})\n vzaar_video_id = nil\n request_xml = %{\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <vzaar-api>\n <video>\n <guid>#{options[:guid]}</guid>\n <title>#{options[:title]}</title>\n <description>#{options[:description]}</description>\n <profile>#{options[:profile]}</profile>\n }\n if !options[:transcoding].nil?\n request_xml += %{\n <transcoding>#{options[:transcoding]}</transcoding>\n }\n end\n request_xml += %{ \n </video>\n </vzaar-api>\n }\n auth_connection HTTP_POST, '/api/videos', request_xml do |response_body|\n vzaar_video_id = get_video_id_from_response_body(response_body)\n end\n vzaar_video_id\n end",
"def video_background_with_features(slides, options={})\n default_options = { hide_for_small: true, hide_arrow: false, pattern_overlay: true }\n options = default_options.merge options\n\n hide_for_small = (options[:hide_for_small]) ? \"hide-for-small\" : \"\"\n ret = \"\"\n\n if slides.size > 0\n if slides.pluck(:slide_file_name).find{|f| /^(.*)\\.webm|mp4$/ =~ f}\n fname = $1\n\n video_sources = \"\"\n if webm = slides.find{|f| /webm/i =~ f.slide_content_type && /^#{fname}\\./ =~ f.slide_file_name }\n video_sources += \"<source src='#{ webm.slide.url }' type='#{ webm.slide_content_type }'/>\"\n end\n\n if ogv = slides.find{|f| /ogv/i =~ f.slide_content_type && /^#{fname}\\./ =~ f.slide_file_name }\n video_sources += \"<source src='#{ ogv.slide.url }' type='video/ogg ogv' codecs='theora, vorbis'/>\"\n end\n\n if mp4 = slides.find{|f| /mp4/i =~ f.slide_content_type && /^#{fname}\\./ =~ f.slide_file_name }\n video_sources += \"<source src='#{ mp4.slide.url }' type='#{ mp4.slide_content_type }'/>\"\n end\n poster = slides.find{|f| /jpg|jpeg|png/i =~ f.slide_content_type && /^#{fname}\\./ =~ f.slide_file_name }\n\n ret += content_tag(:video, video_sources.html_safe,\n poster: (poster) ? poster.slide.url : '',\n id: \"video_background\",\n preload: \"auto\",\n autoplay: \"true\",\n loop: \"loop\",\n muted: \"true\",\n volume: 0)\n\n if options[:pattern_overlay]\n ret += content_tag(:div, \"\", id: \"video_pattern\")\n end\n\n if anim = slides.find{|f| /gif/i =~ f.slide_content_type && /^#{fname}\\./ =~ f.slide_file_name }\n ret += content_tag(:div, class: \"bg-gif\") do\n image_tag( anim.slide.url, lazy: false )\n end\n elsif poster\n ret += content_tag(:div, class: \"bg-gif\") do\n image_tag( poster.slide.url, lazy: false )\n end\n end\n\n if website.homepage_headline\n if website.homepage_headline_product_id\n headline_slide = content_tag(:h1, website.homepage_headline)\n product = Product.find(website.homepage_headline_product_id)\n if product.name.match(/^\\d*$/)\n headline_slide += content_tag(:p, \"#{product.name} #{product.short_description_1}\")\n else\n headline_slide += content_tag(:p, product.name)\n end\n headline_slide += link_to(\"Learn More\", product, class: \"secondary button\")\n if product.in_production?\n headline_slide += buy_it_now_link(product, html_button: true)\n end\n elsif website.homepage_headline_product_family_id\n product_family = ProductFamily.find(website.homepage_headline_product_family_id)\n headline_slide = content_tag(:h1, product_family.name.titleize)\n headline_slide += content_tag(:p, website.homepage_headline)\n headline_slide += link_to(\"Learn More\", product_family, class: \"button\")\n else\n headline_slide = content_tag(:h1, website.homepage_headline)\n end\n headline_class = website.homepage_headline_overlay_class || \"large-6 small-12 columns\"\n ret += content_tag(:div, class: 'row headline_slide') do\n content_tag(:div, headline_slide, class: headline_class )\n end\n else\n ret += content_tag(:div, class: \"container\", id: \"feature_spacer\") do\n if options[:tagline]\n content_tag(:h1, website.tagline, id: \"tagline\")\n end\n end\n end\n\n ret = content_tag(:div, ret.html_safe, id: \"video-container\", class: hide_for_small)\n ret += content_tag(:div, \"\", class: \"bouncing-arrow\") unless options[:hide_arrow]\n @leftover_slides = slides.reject{|f| /^#{fname}\\./ =~ f.slide_file_name }\n\n else\n\n ret += content_tag(:div, class: \"row\") do\n content_tag(:div, class: \"large-12 #{ hide_for_small } columns\") do\n orbit_slideshow(slides: slides, duration: 6000, navigation_arrows: false, transition: \"fade\")\n end\n end\n\n end\n end\n\n raw(ret)\n end",
"def show_results(generated_files: true)\n @end_time = Time.now\n tree = if generated_files\n [' ',\n \"Generated files: #{@out_dir}\",\n ' ',\n TTY::Tree.new(@out_dir).render]\n else\n ''\n end\n puts\n puts TTY::Box.frame(\"Start : #{@start_time}\",\n \"End : #{@end_time}\",\n \"Time : #{@end_time - @start_time} sec\",\n *tree,\n title: { top_left: \" #{self.class.name} \" },\n width: TTY::Screen.width, padding: 1)\n end",
"def index\n \n unless params[:run]\n #@runs = Run.find(:all, :conditions => {:showvideos => true})\n\n # INIT\n\n @today = Date.today\n @year = (params[:year].to_s.to_i > 0 ? @year = params[:year].to_i : @year = @today.year)\n @runs = Run.find(:all, :conditions => [\"showvideos = 1 and year(eventday) = ?\", @year], :order => \"eventday desc\")\n\n # PAST RUNS\n\n @pr_ar = []\n\n @runs.each do |run|\n\n actual_month = run.eventday.month\n @pr_ar[actual_month] ||= [] # INIT if necesarry\n @pr_ar[actual_month] << run\n\n end\n\n @pr_ar.reverse!.compact!\n\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @videos }\n end\n end\n \n if params[:run] && params[:run].to_i > 0\n @run = Run.find(params[:run].to_i)\n @video = Video.find(:first, :conditions => {:run_id => @run.id}, :order => \"name desc\")\n \n redirect_to(:controller => :videos, :action => :show, :id => @video.id)\n \n end\n \n end",
"def initialize(dir, filename, hue = 0)\r\n @frames = []\r\n @currentFrame = 0\r\n @framecount = 0\r\n panorama = RPG::Cache.load_bitmap(dir, filename, hue)\r\n if filename[/^\\[(\\d+)(?:,(\\d+))?\\]/] # Starts with 1 or 2 numbers in brackets\r\n # File has a frame count\r\n numFrames = $1.to_i\r\n delay = $2.to_i\r\n delay = 10 if delay == 0\r\n raise \"Invalid frame count in #{filename}\" if numFrames <= 0\r\n raise \"Invalid frame delay in #{filename}\" if delay <= 0\r\n if panorama.width % numFrames != 0\r\n raise \"Bitmap's width (#{panorama.width}) is not divisible by frame count: #{filename}\"\r\n end\r\n @frameDelay = delay\r\n subWidth = panorama.width / numFrames\r\n for i in 0...numFrames\r\n subBitmap = BitmapWrapper.new(subWidth, panorama.height)\r\n subBitmap.blt(0, 0, panorama, Rect.new(subWidth * i, 0, subWidth, panorama.height))\r\n @frames.push(subBitmap)\r\n end\r\n panorama.dispose\r\n else\r\n @frames = [panorama]\r\n end\r\n end",
"def options\n {\n # audio_sample_rate: 44100,\n # audio_channels: 2,\n audio_bitrate: AUDIO_BITRATE,\n video_max_bitrate: new_bitrate,\n buffer_size: new_bitrate,\n # video_bitrate: new_bitrate,\n # FIXME: `-fs` doesn't work as inteded. it just stops encoding when file got bigger.\n # http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2141\n # custom: \"-fs #{FILESIZE_BOUND}\"\n }\n end",
"def mergeVideos()\n pathToIntermediates=\"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n vidList=\"#{pathToIntermediates}/vidList.txt\"\n # Create a txt file with the lists of all videos to concatenate\n system \"echo >#{vidList}\"\n ([email protected]).each do |e|\n system \"echo file \\'#{pathToIntermediates}/vid-#{e}.mp4\\' >> #{vidList}\" \n end\n # Concatenate videos from the txt file\n system \"ffmpeg -f concat -safe 0 -i #{vidList} -c copy #{pathToIntermediates}/output.mp4 -loglevel quiet\"\n end",
"def with_cycle(cycle_number = nil)\n @frame = nil\n\n # Loop until we get a (perspective corrected) frame from the map.\n while !@frame do\n @camera.set(CAMERA_OPTIONS) if @live\n @frame = @map.frame\n end\n\n # We only count processing times as soon as we get the map. Seen as\n # this is a really fast operation (and most of the time is spent on\n # background subtration).\n cycle_start = Time.now\n\n next_cycle!\n\n Log4r::NDC.push(\"##{ @cycle }\") if cycle_number\n\n @delta = @bg_subtractor.subtract(@frame, LEARNING_RATE)\n\n # Resize the frames\n [@frame, @delta].map do |img|\n img.resize!(Size.new(Map::A0_HEIGHT, Map::A0_WIDTH))\n end\n\n # Turn all pixels until 128.0 to 0.0.\n @delta.threshold! 128.0, 255.0\n\n # Contract shapes.\n @delta.erode!(EROSION_AMOUNT)\n\n # Save stuff\n if @debug\n @frame.write \"#{ Theia.tmp_path }/#{ \"%04i\" % @cycle }-frame.png\"\n @delta.write \"#{ Theia.tmp_path }/#{ \"%04i\" % @cycle }-delta.png\"\n end\n\n yield @frame, @delta\n\n cycle_finish = Time.now\n msecs = (cycle_finish - cycle_start)\n\n # After measuring how long it took to process the frame, add it to\n # processing times, make sure we only account for the last 10\n # measurements, average them out and divide them by 1 (sec). This\n # gives us the FPS.\n @processing_times << msecs\n @processing_times.shift if @processing_times.length > 10\n @fps = 1.0 / @processing_times.mean\n ensure\n Log4r::NDC.pop if cycle_number\n end",
"def make\n return @file unless @streaming\n\n src = @file\n dst = Tempfile.new([@basename, @format ? \".#{@format}\" : ''])\n dst.binmode\n\n parameters = []\n # Add source\n parameters << \":source\"\n # Add destination\n parameters << \":dest\"\n\n parameters = parameters.flatten.compact.join(\" \").strip.squeeze(\" \")\n\n Paperclip.log(\"[qtfaststart] #{parameters}\")\n begin\n success = Paperclip.run(\"qtfaststart\", parameters, :source => \"#{File.expand_path(src.path)}\", :dest => File.expand_path(dst.path))\n rescue Cocaine::ExitStatusError => e\n raise PaperclipError, \"error while processing video for #{@basename}: #{e}\" if @whiny\n end\n\n dst\n end",
"def take\n check\n `adb pull /dev/graphics/fb0 fb0`\n `dd bs=1920 count=800 if=fb0 of=fb0b`\n `ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 480x800 -i fb0 -f image2 -vcodec png #{@destination_folder}/#{@prefix}#{@no}.png`\n `rm fb0b`\n end",
"def run\n create_log_folder\n \n in_tmp_dir do\n start_frame = tmp_path START_FRAME\n extract_start_transition_frame(start_frame) # 1.\n \n end_frame = tmp_path END_FRAME\n extract_end_transition_frame(end_frame) # 2.\n \n transitions = tmp_path TRANSITIONS\n Cmd::GenerateTransitionFrames.new(start_frame, end_frame, transitions, INNER_FRAMES_AMOUNT).run! *logs('3_generate_transition_frames') # 3.\n \n Queue.run *FORMATS.map{ |format| proc{ transition(format) } }, close_connection_before_execution: true # 4.\n end\n \n outputs\n end",
"def video\n \"#{self.video_file_name}\"\n end",
"def add_titles_to_video\n\n\t@durations_array = @sentences_to_extract.map{|s| convert_to_duration(s.start_at + (CARD_LENGTH*1000))}\n\n\tp @durations_array\n\t# @durations_array.each |duration|\n\n\t# end\nend",
"def quick_transcode(input, options={})\n quality = options[:quality] || 19\n log = options[:log]\n output = input.gsub(/\\.[^.]*$/, '.m4v')\n\n # TODO Next time this is needed, make the options below detect its use.\n pcm_input = nil\n # extract the audio to PCM with ffmpeg first because sometimes HandBrakeCLI has problems\n # pcm_input = \"#{input}-temp.avi\"\n # command = <<-EOS\n # nice -n 19 ffmpeg -i \"#{input}\" -acodec adpcm_ms -vcodec copy \"#{pcm_input}\"\n # EOS\n # input = pcm_input # we no longer care about the original.\n # command = command.strip\n # # log.info \"Extracting audio to PCM with ffmpeg...\"\n # puts \"Prepping with ffmpeg using: #{command}\"\n # system(command)\n\n # x264opts will be passed to the '-x' argument of HandBrakeCLI\n # I took these from the advanced tab of the HandBrake 0.9.5 x86_64 (2011010300) GUI for the AppleTV preset\n x264opts = {\n :'cabac' => '0',\n :'ref' => '2',\n :'me' => 'umh',\n :'b-pyramid' => 'none',\n :'b-adapt' => '2',\n :'weightb' => '0',\n :'trellis' => '0',\n :'weightp' => '0',\n :'vbv-maxrate' => '9500',\n :'vbv-bufsize' => '9500' }\n\n options = {\n :'-i' => %{\"#{input}\"},\n :'-o' => %{\"#{output}\"},\n :'--crop' => '0:0:0:0',\n :'-X' => '1280',\n :'-Y' => '720',\n :'-e' => 'x264',\n :'-q' => quality,\n :'--loose-anamorphic' => nil,\n :'--markers' => nil, # chapter markers\n :'-x' => x264opts.map{|k,v| \"#{k}=#{v}\"}.join(':') }\n\n # Now transcode the video and re-mux / transcode in the audio extracted by ffmpeg\n command = \"nice -n 19 HandBrakeCLI #{options.map{|k,v| \"#{k} #{v}\"}.join(\" \")}\"\n command = command.gsub(/ +/, ' ').strip\n # puts \"doing it!: #{command}\"\n system(command) # backticks wont work here.\n\n # if we're using the intermediate pcm-audio step, clean up after ourselves.\n if pcm_input\n # log.info \"Cleaning up ffmpeg intermediate step...\"\n File.delete(pcm_input)\n end\n\n if options[:source_type] == \"mkv\"\n mkv_options = []\n mkvoptions[:log] = log if log\n mkv_file = MkvFile.new(source_file, mkv_options)\n ##### TODO extract any chapter info and import it\n\n if mkv_file.subtitles?\n srt_file = mkv_file.export_subtitles_as_srt\n\n ##### Mux the M4V and SRT files\n log.info \"Muxing subtitles into .M4V file '#{m4v_file}' ...\" if log\n `SublerCLI -i \"#{m4v_file}\" -s \"#{srt_file}\"`\n\n mkv_file.cleanup_subtitle_files\n end\n end\nend",
"def generate(destination)\n destination = Pathname(destination).expand_path\n # First, we find all of the renderable files in the project and iterate over that list.\n #\n # Next, we create a [Page](./soundwave/page.html) object for each file and write it to\n # the destination path.\n find_paths.each do |path|\n page = Page.new(self, path)\n page.write(destination.join(page.output_path))\n end\n end",
"def generate_options(filename, code); end",
"def generate_options(filename, code); end",
"def videos_test\n end",
"def initialize\n\tiso_array = []\n\tshutterspeed_array = []\n\tn = 0\n\ti = 0\n\t\n\n\n\tputs #simply for readability\n\tputs\n\tputs\n\t\n\tputs \"Set Camera to Manual Setting.\"\n\tgets\n\tputs \"Set Camera to Capture RAW only.\"\n\tgets\n\tputs \"Set Camera to Manual focus.\"\n\tgets\n\n##This is how we determine what extension to add to the filename\n\twhile i == 0\n\t puts \"What kind of Camera is this?\"\n\t puts \"1. Canon\"\n\t puts \"2. Nikon\"\n\t puts \"3. Other\"\n\t n = gets.chomp\n\t\tif n == \"1\"\n\t\t\textension = \"CR2\"\n\t\t\tmanu = \"Canon\"\n\t\t\ti = 1\n\t\telsif n == \"2\"\n\t\t\textension = \"NEF\"\n\t\t\tmanu = \"Nikon\"\n\t\t\ti = 1\n\t\telsif n == \"3\"\n\t\t\tputs \"Enter a file extension:\"\n\t\t\textension = gets.chomp\n\t\t\tputs \"Do you want to use .#{extension}? Y/N\"\n\t\t\tanswer = gets.chomp\n\t\t\tif answer.downcase == \"y\"\n\t\t\t\ti = 1\n\t\t\telsif answer.downcase == \"n\"\n\t\t\t\ti = 0\n\t\t\telse\n\t\t\t\ti = 0\n\t\t\tend\n\t\telse\n\t\t\tputs \"Please enter a number.\"\n\t\t\ti = 0\n\t\tend\n\t\tputs #simply for readability\n\t\tputs\n\t\tputs\n\tend\n\t\n\t#build destination folder\n\t#Dir.chdir(\"desktop/darkframes\")\n\t`mkdir #{manu}`\n\tDir.chdir(manu)\n\t`mkdir darkframes`\n\tDir.chdir(\"darkframes\")\n\t\t\t\n\t#prepare camera to be interfaced with\n\t`killall PTPCamera`\n\t \n\t#detect camera and name\n\tputs `gphoto2 --auto-detect`\n\n\n\n#-------------------------------------\n# ISO SETTINGS\n#-------------------------------------\n\t#obtain available ISOs\n\tholder = `gphoto2 --get-config=iso`\n\t#write the ISOs to an array splitting at the spaces\n\t#this will require further formatting to clear \n\t#the values other than ISOs\n\tiso_array = holder.split(' ')\n\tiso_array.delete_if { |a| a == \"Choice:\" || a == \"Label:\" || a == \"ISO\" || a == \"Type:\" || a == \"Speed\" || a == \"RADIO\" || a == \"Current:\" }\n\tiso_array.shift #this removes the first iso which is the \"current iso\"\n\tiso_array.keep_if {|v| iso_array.index(v).odd?}\n\tiso_array.map! { |e| e.to_i }\n\tiso_array.delete_if { |z| z.to_i == 0}\n\n\n#-------------------------------------\n# SHUTTERSPEED SETTINGS\n#-------------------------------------\n\t#obtain available shutterspeeds\n\tholder = `gphoto2 --get-config=shutterspeed`\n\t#write the shutter speeds to an array, splitting at the spaces\n\t#this will require further formatting to clear \n\t#the values other than shutter speeds\n\tshutterspeed_array = holder.split(' ')\n\tshutterspeed_array.delete_if { |a| a == \"Choice:\" || a == \"Label:\" || a == \"Type:\" || a == \"Speed\" || a == \"RADIO\" || a == \"Current:\" || a == \"Shutter\" }\n\tshutterspeed_array.shift #removes \"current shutter speed\"\n\t#shutterspeed_array.pop # TODO if above certain number of seconds, remove Bulb limiter\n\tshutterspeed_array.keep_if {|v| shutterspeed_array.index(v).odd?}\n\t#shutterspeed_array.map! {|e| e.delete('s').to_frac}\n\tshutterspeed_array.keep_if {|v| v.delete('s').to_frac <= 120.0} #maximum shutterspeed is 2minutes\n#end\n\n#-------------------------------------\n# RUNNING THE TEST\n#-------------------------------------\n\n#def darkframes\n\t#the purpose of darkframes is to run\n\t#every shutterspeed at every ISO.\n\n\tiso_array.each do |iso_holder|\n\t\t#set the ISO on the camera\n\t\t`gphoto2 --set-config iso=#{iso_holder}`\n\n\t\tshutterspeed_array.each do |shutterspeed_holder|\n\t\t\tif File.file?(\"iso#{iso_holder}_ss#{shutterspeed_holder}sec.#{extension}\") != true\n\t\t\t\t#set the shutterspeed on the camera\n\t\t\t\t`gphoto2 --set-config shutterspeed=#{shutterspeed_holder}`\n\n\t\t\t\t#take the picture\n\t\t\t\tputs \"iso: #{iso_holder} shutterspeed: #{shutterspeed_holder}\"\n\t\t\t\t`gphoto2 --capture-image-and-download --folder /darkframes --filename=iso#{iso_holder}_ss#{shutterspeed_holder}sec.#{extension}`\n\t\t\telse\n\t\t\t\tputs \"iso: #{iso_holder} shutterspeed: #{shutterspeed_holder} exists\"\n\t\t\tend #if\n\t\tend #shutterspeed_array.each\n\tend #iso_array.each\n\nend",
"def remove_encoded_videos\n video_files.each do |videofile|\n \n unless videofile.url.blank?\n \n# AWS::S3::Base.establish_connection!(\n# :access_key_id => zencoder_setting[\"s3_output\"][\"access_key_id\"],\n# :secret_access_key => zencoder_setting[\"s3_output\"][\"secret_access_key\"]\n# )\n# AWS::S3::S3Object.delete(File.basename(output_url), zencoder_setting[\"s3_output\"][\"bucket\"])\n # there is no real concept of folders in S3, they are just labels, essentially\n# AWS::S3::S3Object.delete(\"/thumbnails_#{self.id}/frame_0000.png\", zencoder_setting[\"s3_output\"][\"bucket\"])\n \n #XXX TODO remove transcoded files!\n \n end\n \n end\n end",
"def capture_command \n cmd = \"#{@cutycapt_path} --url='#{@url}'\"\n cmd += \" --out='#{@folder}/#{@filename}'\"\n cmd += \" --max-wait=#{@max_wait}\"\n cmd += \" --delay=#{@delay}\" if @delay\n cmd += \" --user-agent='#{@user_agent}'\"\n cmd += \" --min-width='#{@min_width}'\"\n cmd += \" --min-height='#{@min_height}'\"\n\n \n if determine_os == :linux and check_xvfb\n xvfb = 'xvfb-run --server-args=\"-screen 0, 1024x768x24\" '\n xvfb.concat(cmd)\n else\n cmd\n end \n end",
"def collectFileInformation(tracks, flavor, startTimes, real_start_time)\n startTimes.each do |file|\n pathToFile = File.join(file[\"filepath\"], file[\"filename\"])\n\n BigBlueButton.logger.info( \"PathToFile: #{pathToFile}\")\n\n if (File.exists?(pathToFile))\n # File Integrity check\n if (!FFMPEG::Movie.new(pathToFile).valid?)\n BigBlueButton.logger.info( \"The file #{pathToFile} is ffmpeg-invalid and won't be ingested\")\n next\n end\n\n tracks.push( { \"flavor\": flavor,\n \"startTime\": file[\"timestamp\"] - real_start_time,\n \"path\": pathToFile\n } )\n end\n end\n\n return tracks\nend",
"def _preprocess\n @slices = {}\n @options[:slices] = @slices\n \n @@generation = @@generation + 1\n files = @files.values\n @file_list = []\n\n files.each {|f| _include_file(f) }\n\n @file_list.map {|file|\n # The parser accepts single files that contain many files. As such,\n # its method of determing the current file name is a marker in the\n # file. We may want to consider changing this to a parser option\n # now that we don't need this feature so much, but this works for now.\n content = \"@_chance_file \" + @files.invert[file[:path]] + \";\\n\"\n content += \"$theme: '\" + @options[:theme] + \"';\"\n content += file[:content]\n \n parser = Chance::Parser.new(content, @options)\n parser.parse\n file[:parsed_css] = parser.css\n \n # NO IMPORTERS FOR NOW\n #if Chance::SUPPORTS_IMPORTERS\n # css = \"@import \\\"\" + file [:path] + \".scss\\\";\"\n #else\n\n path_hash = Digest::MD5.hexdigest(file[:path])\n tmp_path = \"./tmp/chance/#{path_hash}.scss\"\n FileUtils.mkdir_p(File.dirname(tmp_path))\n \n f = File.new(tmp_path, \"w\")\n f.write(parser.css)\n f.close\n \n css = \"@import \\\"\" + tmp_path + \"\\\";\"\n # end\n \n css\n }.join(\"\\n\")\n end",
"def rasterise \r\n @frames.each do |frame|\r\n printf '.';\r\n canvas = Canvas.new(@width, @height);\r\n @canvases.push(canvas);\r\n if frame.pixmaps.length == 0 then next; end;\r\n frame.pixmaps.each do |pixmap|\r\n img = pixmap.sprite.getImage(pixmap.frame);\r\n pixmap.frame = (pixmap.frame + 1) % (pixmap.sprite.images.length);\r\n canvas.add(img, pixmap.x, pixmap.y);\r\n end\r\n end \r\n end",
"def produce_moments_files(seconds,src_path,out_path,htmlfilename,resizewidth)\n c = 0\n moments = create_pics_moments(seconds,src_path)\n make_output_dir(out_path)\n File.open(\"#{out_path}/#{htmlfilename}\", 'a') do |htmlfile| # creates and writes html file\n #htmlfile << %&header\\n& # insert here html code before pictures\n while c < moments.size\n dir = \"#{out_path}/#{c}\" # path to output subdirectory\n rdir = dir + '/resized' # path to subdirectory with resized pictures\n make_output_dir(dir) # making output subdir\n make_output_dir(rdir) # making resized subdir\n htmlfile << %&<div class=\"images\" id=\"set#{c}\">\\n& # opening pictures set div\n moments[c].each do |pic| \n #copy_pic(pic,dir)\n resize_pic(pic,900,dir) # instead of copy_pic\n puts 'copied: ' + pic\n resize_pic(pic,resizewidth,rdir)\n htmlfile << %& <a target=\"_blank\" href=\"../_images/#{c}/#{File.basename(pic)}\"><img src=\"../_images/#{c}/resized/#{File.basename(pic)}\" alt=\"#{File.basename(pic)}\"></a>\\n& # main html\n end\n c +=1\n htmlfile << %&</div>\\n& # closing pictures set div\n end\n #htmlfile << %&footer\\n& #insert here html code after pictures\n end\nend",
"def genres\n MusicImporter.new(path).print_genres\n end",
"def extract_cover!(offset=0.0)\n random_name = (0...8).map { (65 + rand(26)).chr }.join\n tmp_file = \"tmp/#{random_name}.jpg\"\n\n `ffmpeg -itsoffset -#{offset} -i '#{video_file.path}' -vframes 1 -an #{tmp_file}`\n\n # Attach output image as cover image\n File.open(tmp_file) do |f|\n self.cover_image = f\n save\n end\n end",
"def build_movie(movie_file)\n extension = File.extname(movie_file)\n \n if(extension == \".xml\")\n return build_from_xml(movie_file)\n elsif(extension == \".json\")\n update_all(\"MovieBuilder\", \"Creating movie from JSON\")\n json_builder = JSONBuilder.new\n return json_builder.build_movie(movie_file)\n else\n update_all(\"MovieBuilder\", \"Unknown extension. See documentation for supported formats and markups\")\n end\n return nil\n end",
"def setup_frames\n @frames ||=\n begin\n frames = 10.times.map {|i| Frame.new(i+1,0,0,0,nil)}\n # link frames\n (0...9).each {|i| frames[i].next_frame = frames[i+1]}\n frames\n end\n end",
"def initialize(file_index, filename)\n super(0, 56 + file_index % 4 * 90, 544, 90)\n @file_index = file_index\n @filename = filename\n load_gamedata\n refresh\n @selected = false\n end",
"def processVideoAttachmentMessage(attachmentName, outputFileName)\r\n html = \"<video controls=\\\"\\\">\\n\"\r\n html << \"<source src=\\\"#{outputFileName}\\\">\\n\"\r\n html << \"<a href=\\\"#{outputFileName}\\\">#{outputFileName}</a>\\n\"\r\n html << \"</video>\\n\"\r\n return html\r\n end",
"def command_line(options = {})\n if options.empty? || options.keys == [:output_path]\n # when there are no clip options, the source file can just be copied\n # over to the output file path without using ffmpeg\n populate_output_path(options)\n \"cp #{@source_path} #{@path.to_s}\"\n else\n formatted_opts = options_formatted(options)\n\n modules_with_args = MODULES.select { |mod| mod.respond_to?(:args) }\n modules_with_filters = MODULES.select { |mod| mod.respond_to?(:filter_args) }\n\n module_args = modules_with_args.map { |mod| mod.args(formatted_opts) }.compact\n module_filters = modules_with_filters.map { |mod| mod.filter_args(formatted_opts) }.compact\n\n module_arg_string = module_args.join(\" \")\n unless module_filters.empty?\n module_arg_string += \" -vf '#{module_filters.join(\",\")}'\"\n end\n\n populate_output_path(formatted_opts)\n \"ffmpeg -i #{@source_path} #{options[:flags]} #{module_arg_string} #{@path.to_s}\"\n end\n end",
"def test01()\n sourceMovie = File.join($directory, \"images/418_clip5_SD.m4v\")\n begin \n # Create the list of commands object, ready to have commands added to it.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 1. Create movie importer and assign frame to image collection.\n # Basically after the first block of commands is run, the movie importer\n # is closed automatically in the cleanup commands.\n movieImporterName = SecureRandom.uuid\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName)\n\n frameTime = MovieTime.make_movietime(timescale: 600, timevalue: 900)\n trackID = MovieTrackIdentifier.make_movietrackid_from_mediatype(\n mediatype: :vide, trackindex: 0)\n \n imageId = SecureRandom.uuid\n assignFrameCommand = CommandModule.make_assignimage_frommovie_tocollection(\n movieObject, frametime: frameTime, tracks: [trackID], identifier: imageId)\n theCommands.add_command(assignFrameCommand)\n \n # 2. Create the window context\n winRect = MIShapes.make_rectangle(origin: { x: 100, y: 50 },\n size: { width: 400, height: 252 })\n windowObject = theCommands.make_createwindowcontext(rect: winRect,\n addtocleanup: false)\n \n # 3. Draw the image in the image collection to the window context.\n drawImageElement = MIDrawImageElement.new()\n drawImageElement.set_imagecollection_imagesource(identifier: imageId)\n drawImageElement.destinationrectangle = MIShapes.make_rectangle(width: 400,\n height: 252)\n drawElementCommand = CommandModule.make_drawelement(\n windowObject, drawinstructions: drawImageElement, createimage: false)\n theCommands.add_command(drawElementCommand)\n Smig.perform_commands(theCommands)\n \n # The first lot of commands to be run have run. I've split up the performing\n # of commands so that we get to see the content actually drawn to the window.\n # 4. Create the new command list.\n theCommands = SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n \n # 5. Draw the image in image collection to the window context\n theCommands.add_command(drawElementCommand)\n \n # 6. Remove the image from the image collection\n removeCommand = CommandModule.make_removeimage_fromcollection(imageId)\n theCommands.add_command(removeCommand)\n Smig.perform_commands(theCommands)\n \n # 7. Now attempt to draw the image again.\n begin\n Smig.perform_command(drawElementCommand)\n puts \"We shouldn't get here as perform command should have an exception\"\n puts \"File: #{$filename}, Line: #{__LINE__}\"\n rescue\n end\n \n # 8. Now close the window context.\n Smig.close_object(windowObject)\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n end\nend",
"def make\n\n src = @file\n dst = Tempfile.new([@basename, @output_ext].compact.join(\".\"))\n\n # build gpsbabel option string\n opt = %{ -i #{@input_format} }\n opt << %{ -f \"#{ File.expand_path(src.path) }\" }\n opt << @filters\n opt << %{ -o #{@gpsbabel_format} -F \"#{ File.expand_path(dst.path) }\" }\n \n begin\n success = Paperclip.run(\"gpsbabel\", opt.gsub(/\\s+/, \" \"))\n rescue PaperclipCommandLineError\n raise PaperclipError, \"There was an error processing the GPS file #{@basename}\" if @whiny\n end\n\n dst\n end",
"def saveAllVideos(directory, useDescription=false)\n\t\tprefix = \"video\"\n\t\tvideos = getVideos\n\t\tmakeDirectory(directory)\n\n\t\tfor i in 0...videos.size\n\t\t\tif useDescription and videos[i].info[\"description\"] != \"\"\n vid = videos[i].info[\"description\"] + \".mp4\"\n else\n vid = prefix + i.to_s + \".mp4\"\n end\n videos[i].saveVideo(File.join(directory, vid))\n\t\tend\n\n\tend",
"def run\n _image_files = image_files\n\n specified_camera = @roll.camera\n camera = @config.cameras.find { |camera| camera.tag == specified_camera }\n raise \"Camera #{specified_camera} not found in config.yml\" unless camera\n\n @roll.frames.each_with_index do |frame, i|\n break if i >= _image_files.count\n\n specified_lens = frame.lens || @roll.lens\n lens = camera.lenses.find { |lens| lens.tag == specified_lens }\n raise \"Lens #{specified_lens} not found for frame #{frame.number}\" unless lens\n\n relative_path = _image_files[i].gsub(%r(^#{Dir.pwd}/), \"\")\n puts \"Processing frame #{frame.number}\\n #{relative_path}\" unless @silent\n\n ExifToolImage.new(_image_files[i]).tap do |exif|\n exif[\"Artist\"] = @roll.artist || @config.artist\n exif[\"Copyright\"] = template_copyright(@config, @roll, frame)\n exif[\"DateTimeOriginal\"] = frame.date_captured || @roll.date_captured\n exif[\"CreateDate\"] = frame.date_scanned || @roll.date_scanned\n exif[\"Make\"] = camera.make\n exif[\"Model\"] = camera.model\n exif[\"LensModel\"] = lens.model\n exif[\"ISO\"] = @roll.iso\n exif[\"ExposureTime\"] = frame.shutter || @roll.shutter\n exif[\"FNumber\"] = frame.aperture || @roll.aperture\n exif[\"FocalLength\"] = frame.focal_length || lens.focal_length || @roll.focal_length\n exif[\"Flash\"] = frame.flash ? 1 : 0\n exif[\"Orientation\"] = frame.orientation || 1\n\n exif.save\n end\n end\n end",
"def get_player_rendered_videos(gamertag, page = 0)\n gamertag = gamertag.gsub(' ', '%20')\n uri = ENDPOINT + \"file/videos/#{key}/#{gamertag}/#{page}\"\n data = JSON.parse(self.class.get(uri).body, :symbolize_names => true)\n Reach::Helper::convert_keys(data)\n end",
"def convert\n\t\tif self.video.file?\n\t\t\tself.convert!\n\n\t\t\tsuccess = system(convert_command)\n\t\t\tif success && $?.exitstatus == 0\n\t\t\t\tself.converted!\n\t\t\telse\n\t\t\t\tself.failed!\n\t\t\tend\n\t\tend\n\tend",
"def transcode!(options = {})\n destination = options[:destination] || RakeMKV.config.destination\n title_id = options[:title_id] || titles.longest.id\n command.mkv(title_id, destination)\n end",
"def create\n @store = Store.new(params[:store])\n @store.save\n unless params[:image].nil?\n params[:image].each_value do |image|\n unless image.nil? || image[:photo].nil?\n @picture = Image.new\n @picture.source_file_name = image[:photo].original_filename\n @picture.source_content_type = image[:photo].original_filename.split(\".\").last\n #@picture.source_file_size = File.size(params[:image][:photo])\n @picture.source_updated_at =Time.now\n\n @picture.photo = image[:photo]\n @picture.save\n\n @asset=Asset.new\n @asset.assetable_id = @picture.id\n @asset.assetable_type = \"image\"\n @asset.price = image[:price][:price]\n @asset.store_id = @store.id\n @asset.save!\n end\n end\n end\n\n unless params[:video].nil?\n params[:video].each_value do |video|\n unless video.nil? || video[:file].nil?\n file = video[:file]\n @movie=Video.new\n name= video[:file].original_filename\n dir= RAILS_ROOT + \"/public/movies\"\n Dir.mkdir(dir) unless File.directory?(dir)\n path=File.join(dir,name)\n if File.extname(path) == \".swf\" || File.extname(path) == \".mpeg\" || File.extname(path) == \".wmv\" || File.extname(path) == \".flv\" || File.extname(path) == \".mpeg4\" || File.extname(path) == \".mpg\" || File.extname(path) == \".avi\"\n parse_file = File.open(path, \"wb\") { |f| f.write(file.read) }\n\n @video=Video.new(:source_file_name => name, :source_file_size => File.new(path).size, :source_updated_at => Time.now, :source_content_type => File.extname(path))\n @video.title = video[:title]\n @video.description = video[:description]\n @video.save!\n @video.category_videos.create(:category_id => video[:category][:category_id].to_i)\n set_video_search(@video.id,video[:title], video[:description])\n image_file=video[:image][:photo]\n @image=VideoImage.new\n dir=RAILS_ROOT + \"/public/video_image\"\n name= video[:image][:photo].original_filename\n path=File.join(dir,name)\n Dir.mkdir(dir) unless File.directory?(dir)\n parse_file = File.open(path, \"wb\") { |f| f.write(image_file.read) }\n system(\"convert #{path} -resize 400x225\\! #{path}\")\n @image.source_file_name = video[:image][:photo].original_filename\n @image.source_content_type = video[:image][:photo].original_filename.split(\".\").last\n @image.photo = video[:image][:photo]\n # @image.source_file_size = File.size(video[:image][:photo])\n @image.source_updated_at =Time.now\n @image.video_id = @video.id\n @image.save!\n\n @asset = Asset.new\n @asset.assetable_id = @video.id\n @asset.assetable_type = \"video\"\n @asset.store_id = @store.id\n @asset.price = video[:price][:price]\n @asset.save!\n end\n end\n end\n end\n respond_to do |format|\n format.html { redirect_to stores_path }\n format.xml { render :xml => @store, :status => :created, :location => @store }\n end\n end",
"def upload(file)\n logger.info 'Downloading video...'\n path = file.download.path\n movie = FFMPEG::Movie.new(path)\n @mp4_path = encode('mp4', movie, '-vcodec libx264 -strict -2')\n @webm_path = encode('webm', movie, '-vcodec libvpx -acodec libvorbis -f webm -deadline realtime -s 640x480')\n end",
"def video_convert_to_mp4_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VideoApi.video_convert_to_mp4 ...'\n end\n # resource path\n local_var_path = '/video/convert/to/mp4'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n header_params[:'fileUrl'] = opts[:'file_url'] if !opts[:'file_url'].nil?\n header_params[:'maxWidth'] = opts[:'max_width'] if !opts[:'max_width'].nil?\n header_params[:'maxHeight'] = opts[:'max_height'] if !opts[:'max_height'].nil?\n header_params[:'preserveAspectRatio'] = opts[:'preserve_aspect_ratio'] if !opts[:'preserve_aspect_ratio'].nil?\n header_params[:'frameRate'] = opts[:'frame_rate'] if !opts[:'frame_rate'].nil?\n header_params[:'quality'] = opts[:'quality'] if !opts[:'quality'].nil?\n\n # form parameters\n form_params = {}\n form_params['inputFile'] = opts[:'input_file'] if !opts[:'input_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VideoApi#video_convert_to_mp4\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | [
"0.60002273",
"0.58840054",
"0.58810204",
"0.57090247",
"0.5693331",
"0.5655191",
"0.5628516",
"0.56282556",
"0.5576697",
"0.5517942",
"0.54917055",
"0.5438951",
"0.54197395",
"0.54037774",
"0.5365946",
"0.5324334",
"0.52558136",
"0.52532005",
"0.5248448",
"0.5240166",
"0.52176946",
"0.5175818",
"0.5145332",
"0.51349515",
"0.5126838",
"0.50947404",
"0.5089553",
"0.50661373",
"0.5047335",
"0.50470924",
"0.5036038",
"0.5012958",
"0.49896047",
"0.49651852",
"0.49646756",
"0.49645907",
"0.49365214",
"0.4923221",
"0.49186194",
"0.4889953",
"0.48883146",
"0.48807502",
"0.48807502",
"0.4869293",
"0.48523045",
"0.48519325",
"0.48379397",
"0.48321044",
"0.47843865",
"0.478369",
"0.4770462",
"0.4754045",
"0.4727689",
"0.4701754",
"0.47017434",
"0.4691261",
"0.4690212",
"0.46886295",
"0.4676421",
"0.467338",
"0.46671212",
"0.46649083",
"0.46635133",
"0.4662763",
"0.4662105",
"0.4655062",
"0.46321937",
"0.46268287",
"0.46239483",
"0.4604752",
"0.46008018",
"0.45803812",
"0.4580062",
"0.45774612",
"0.45774612",
"0.45511407",
"0.45499313",
"0.4548583",
"0.45385656",
"0.45378554",
"0.45377702",
"0.4536841",
"0.45367867",
"0.45291933",
"0.45236623",
"0.45182064",
"0.45130295",
"0.45109373",
"0.45049366",
"0.44866756",
"0.44812992",
"0.44799152",
"0.4479857",
"0.44797724",
"0.44795918",
"0.44750032",
"0.44723994",
"0.447055",
"0.44701785",
"0.44675657"
] | 0.80225223 | 0 |
Runs the command defined in the config file input_filename: The full path of the file you want to run the command on file_operation: One of the defined file operations in the config file | def run_command(input_filename, file_operation)
Log.info "Inside run_command"
if !Config['FileOperations'].key?(file_operation)
return "#{file_operation} isn't a valid preset"
end
transcode_settings = Config['FileOperations'][file_operation]
Log.info transcode_settings.to_s
begin
if !transcode_settings.key?('command')
return "#{file_operation} doesn't have a command"
end
command_template = transcode_settings['command']
filename = File.basename(input_filename)
base_filename = File.basename(input_filename, File.extname(input_filename))
if transcode_settings.key?('location')
output_filename = [transcode_settings['location'], base_filename].join('/')
else
output_filename = [Config['WebServer']['webroot'], Config['WebServer']['transcode_dir'], base_filename].join('/')
end
command = command_template % {input_filename:input_filename, output_filename: output_filename}
Log.info command
# Update the channel to let them know what's happening
call_mattermost({:text => "Running command #{file_operation} on file #{filename}"})
if system(command)
if transcode_settings.key?('text')
output_text = transcode_settings['text'] % {input_filename:input_filename, output_filename: output_filename}
else
output_text = "Finished running command #{file_operation} on file #{filename}"
end
call_mattermost({:text => output_text})
else
call_mattermost({:text => "ERROR: Could not run command #{file_operation} on file #{filename}"})
end
rescue Exception => e
Log.error e.to_s
return 'There was an error'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_file( filename )\n text = File.read(filename)\n execute(text)\n end",
"def run(filename, options) end",
"def run(config_file)\n load_options_from_file(config_file)\n check_options\n output = %x[ #{@binary} #{config_file} ]\n output\n end",
"def run_file(filename, preloading = false)\n begin\n result = RSpec::Core::CommandLine.new([\"-f\", \"p\", filename]).run(io, io)\n rescue LoadError => e\n io << \"\\nCould not load file #{filename}: #{e.message}\\n\\n\"\n result = 1\n rescue Exception => e\n io << \"Exception when running #{filename}: #{e.message}\"\n io << e.backtrace[0..7].join(\"\\n\")\n result = 1\n end\n\n if preloading\n puts io.string\n else\n channel.write(\"command\" => \"result\", \"filename\" => filename, \"return_code\" => result.to_i, \"text\" => io.string, \"worker_number\" => worker_number)\n end\n end",
"def process_command_file\n gather_command\n create_command_structure\n end",
"def run_rules(input_file)\n\t\tcommand = \"#{@base_command} \\\"#{input_file}\\\"\"\n\t\t#output = Helpers.run_command(command,true,File.dirname(@rule_directory))\n\t\toutput = Helpers.run_command(command,true,@rule_directory)\n\t\treturn output\n\tend",
"def perform(filepath)\n\n end",
"def runner_command input_path, output_path\n # run as either local or hadoop\n case run_mode\n when 'local'\n $stderr.puts \" Reading STDIN / Writing STDOUT\"\n command = local_command input_path, output_path\n when 'hadoop', 'mapred'\n $stderr.puts \" Launching hadoop as\"\n command = hadoop_command input_path, output_path\n else\n raise \"Need to use --run=local or --run=hadoop; or to use the :default_run_mode in config.yaml just say --run \"\n end\n end",
"def file filename, options = {}\n if options[:as] and Dir.glob(File.join(Builder.config.base_path, filename)).length > 1\n raise NSIS::BadParameterError.new(\"NSIS::Script::file() may only accept a single source if :as is specified.\")\n end\n \n command = [\"File\"]\n \n # non-fatal, if no match is found, a warning rather than error will be issued.\n command << \"/nonfatal\" if options[:nonfatal]\n \n # recursive\n command << \"/r\" if options[:recurse]\n \n # preserve attributes\n command << \"/a\" if options[:with_attributes]\n\n # excluded files\n command << [options[:not]].flatten.collect{|n| \"/x #{n}\"}.join(' ') if options[:not]\n \n # rename or straight\n command << (options[:as] ? \"/oname=\\\"#{options[:as]}\\\" #{filename}\" : filename)\n \n append_instruction command\n end",
"def add_std_file_opt(inkey)\n @oparse.on(\"-f\", \"--file FILENAME\", \"Input from FILENAME\") do |f|\n @opts[inkey] = do_file_read(f)\n end\n return @oparse\n end",
"def 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 execute\n run_command current_or_selected_files\nend",
"def dc_op input='input.cir', output=self.dc_file_name\n puts \"Execute DCOP analysis: #{ltspice_path()} -b #{input}\"\n execute '-ascii -b', input # note: execute is a defined method\n\n check_log(log_name())\n\n rawfile = input.sub(File.extname(input),'') +'.raw'\n File.rename rawfile, 'op.raw' if File.exist? rawfile\n dc_op_conv 'op.raw', output\n end",
"def run(file, line)\n system *command_for(file, line)\n end",
"def run\n handle_options()\n execute_operation()\n end",
"def test_run_file_input\n workflow = File.open(WKF_PASS, \"r\")\n\n T2Server::Run.create($uri, WKF_PASS, $creds, $conn_params) do |run|\n\n assert_nothing_raised(T2Server::AttributeNotFoundError) do\n run.input_port(\"IN\").file = FILE_INPUT\n run.generate_provenance\n run.generate_provenance(false)\n end\n refute run.generate_provenance?\n\n run.start\n assert(run.running?)\n assert_nothing_raised(T2Server::RunStateError) { run.wait }\n assert_equal(run.output_port(\"OUT\").value, \"Hello, World!\")\n\n assert_raise(T2Server::AccessForbiddenError) do\n run.provenance\n end\n\n assert(run.delete)\n end\n\n workflow.close\n end",
"def build filetask,system_config,platform\n cmd_file=command_file(filetask.name,system_config,platform)\n if File.exists?(cmd_file)\n config=system_config.platform_config(platform)\n if cmd_file.end_with?('.library')\n cmdline = librarian(cmd_file,config)\n else\n cmdline = linker(cmd_file,config)\n end\n sh(cmdline.join(' '))\n else\n raise GaudiError, \"Missing command file for #{filetask.name}\"\n end\n end",
"def run_file(filename, preloading = false)\n @cuke_runtime ||= ::Cucumber::ResetableRuntime.new # This runtime gets reused, this is important as it's the part that loads the steps...\n begin\n result = 1\n cuke_config = ::Cucumber::Cli::Configuration.new(io, io)\n cuke_config.parse!([\"--no-color\", \"--require\", \"features\", filename])\n @cuke_runtime.configure(cuke_config)\n @cuke_runtime.run!\n result = 0 unless @cuke_runtime.results.failure?\n rescue LoadError => e\n io << \"\\nCould not load file #{filename}: #{e.message}\\n\\n\"\n rescue Exception => e\n io << \"Exception when running #{filename}: #{e.message}\"\n io << e.backtrace[0..7].join(\"\\n\")\n end\n\n if preloading\n puts(io.string)\n else\n channel.write(\"command\" => \"result\", \"filename\" => filename, \"return_code\" => result.to_i, \"text\" => io.string, \"worker_number\" => worker_number)\n end\n end",
"def execute\n Tools.public_send(command, options.configuration_path)\n end",
"def run(config, content = nil)\n # init content as default table if available\n if content != nil\n settable_cmd(\"default\", content)\n end\n\n return if config == \"---\\n\"\n\n # process each command in order\n read_config(config) do | cmd, args |\n if cmd == \"read\" or cmd == \"create\"\n self.send(\"#{cmd}_cmd\", *args)\n else\n # dynamically call method based on command name\n args = set_table_refs(cmd, args)\n if args.class == DataFile # only one arg\n args.send(\"#{cmd}_cmd\", *args[1..-1])\n elsif args[0].class == DataFile # single datafile\n args[0].send(\"#{cmd}_cmd\", *args[1..-1])\n else # mult datafiles\n args[0][0].send(\"#{cmd}_cmd\", *args)\n end\n end\n end\n end",
"def process_command_line(test, mediainfo, src_file, filename)\n\n command = test.command\n\n needs_scaling = mediainfo[:needs_scaling]\n scaling_option = needs_scaling ? test.scaling_option : ''\n\n interlaced = mediainfo[:interlaced]\n interlaced_option = interlaced ? test.interlaced_option : ''\n\n params = {'INPUT_FILE' => src_file.to_s, 'OUTPUT_FILE' => filename, 'INTERLACED_OPTION' => interlaced_option, 'SCALING_OPTION' => scaling_option}\n\n params.each do |key, value|\n command = command.gsub(key, value)\n end\n\n command\nend",
"def run\n if @options['file']\n execute_script @options['file']\n elsif @options['command']\n execute @options['command']\n else\n interactive_shell\n puts \n end\n end",
"def main\n\n if ARGV[0].nil?\n STDOUT.write(\"\\nERROR! Missing input file!\\nUsage: create_HHpred_job.rb A3M-FILE\\n\")\n return\n end\n \n infilename = ARGV[0]\n # chec\n if !File.exist?(File.join(infilename))\n STDOUT.write(\"\\nERROR! No inputfile #{infilename}!\\n\") \n return\n end\n\n create_toolkit_job( infilename )\n\nend",
"def dataflow\n arg = args.first\n basename = File.basename(arg.to_s, '.rb')\n\n case\n when settings[:run] then settings[:run]\n when arg && File.exist?(arg) then basename\n else arg\n end\n end",
"def run_command f\n files=nil\n case f\n when Array\n # escape the contents and create a string\n files = Shellwords.join(f)\n when String\n files = Shellwords.escape(f)\n end\n begin\n # TODO put all this get_line stuff into field history\n command = get_line \"Run a command on #{files}: \"\n return if command.size == 0\n command2 = get_line \"Second part of command: \"\n # FIXME we may need to go into cooked mode and all that for this\n # cat and most mess with the output using system\n c_system \"#{command} #{files} #{command2}\"\n rescue Exception => ex\n perror \"Canceled command, (#{ex}) press a key\"\n return\n end\n\n c_refresh\n push_used_dirs Dir.pwd\nend",
"def run_cmd(input); end",
"def run_from_file_command(command)\n if logger.debug?\n debug(\"Creating exec script for #{instance_name} (#{exec_script_file})\")\n debug(\"Executing #{exec_script_file}\")\n end\n File.open(exec_script_file, \"wb\") { |file| file.write(command) }\n %{powershell -file \"#{exec_script_file}\"}\n end",
"def file(context: nil, ignore_deletions: false)\n differ = \"git diff#{cmd}\"\n differ << \" --unified=#{context}\" if context\n differ << \" --diff-filter=d\" if ignore_deletions\n run(differ)\n end",
"def exec(cmd, options = {})\n Git.invoke :before_read\n\n options = {\n '-f' => @file\n }.merge(options)\n\n params = ''\n options.each do |key, val|\n params << \" #{key} #{Escape.shell_single_word(val)}\"\n end\n\n command = \"#{bin} #{params} #{cmd}\"\n\n `#{command}`.rstrip\n end",
"def initialize filename, options = {}\n @files = []\n @options = CommandLineOptions.new.merge options\n @filename = filename\n end",
"def exec_file(file)\n exec \"#{file}\"\n end",
"def run(src_file, directory, original = nil)\n out_file = target directory, extension(src_file) if modifies?\n log_data = operation src_file, out_file, original\n [out_file, success(log_data)]\n rescue StandardError => e\n FileUtils.rm out_file if out_file && File.exist?(out_file)\n [out_file, failure(e)]\n end",
"def compile filetask,system_config,platform\n cmd_file=command_file(filetask.name,system_config,platform)\n if File.exists?(cmd_file)\n mkdir_p(File.dirname(filetask.name),:verbose=>false)\n config=system_config.platform_config(platform)\n if is_assembly?(filetask.prerequisites.first)\n cmdline = assembler(cmd_file,config)\n else\n cmdline = compiler(cmd_file,config)\n end\n sh(cmdline.join(' '))\n else\n raise GaudiError, \"Missing command file for #{filetask.name}\"\n end\n end",
"def command_file prompt, *command\n pauseyn = command.shift\n command = command.join \" \"\n print \"[#{prompt}] Choose a file [#{$view[$cursor]}]: \"\n file = ask_hint $view[$cursor]\n #print \"#{prompt} :: Enter file shortcut: \"\n #file = ask_hint\n perror \"Command Cancelled\" unless file\n return unless file\n file = File.expand_path(file)\n if File.exists? file\n file = Shellwords.escape(file)\n pbold \"#{command} #{file} (#{pauseyn})\"\n system \"#{command} #{file}\"\n pause if pauseyn == \"y\"\n refresh\n else\n perror \"File #{file} not found\"\n end\nend",
"def file_target_opt(target_fn)\n \"--file=#{target_fn}\"\n end",
"def run(file, cmd, *args)\n env = Environment.load(source: file)\n exec env, cmd, *args\n end",
"def process_command(command)\n model = generate_model_from_text_file(command[:filename])\n case command[:command]\n when 'list'\n list_todos(model)\n when 'add'\n add_one_todo(model, command[:modifier])\n when 'remove'\n remove_one_todo(model, command[:modifier])\n when 'complete'\n mark_todo_complete(model, command[:modifier])\n end\n save_model_to_text_file(command[:filename], model)\n end",
"def read_and_execute(inp)\n args = inp.split(' ') # Split the input by space\n cmd_name = args[0] # First argument of the command name\n cmd_args = args[1..inp.length] # Second argument is the argument of the commands\n @commands_available[cmd_name].execute(cmd_args)\n end",
"def command_file prompt, *command\n pauseyn = command.shift\n command = command.join \" \"\n #print \"[#{prompt}] Choose a file [#{$view[$cursor]}]: \"\n t = \"[#{prompt}] Choose a file [#{$view[$cursor]}]: \"\n file = ask_hint t, $view[$cursor]\n #print \"#{prompt} :: Enter file shortcut: \"\n #file = ask_hint\n perror \"Command Cancelled\" unless file\n return unless file\n file = File.expand_path(file)\n if File.exists? file\n file = Shellwords.escape(file)\n pbold \"#{command} #{file} (press a key)\"\n c_system \"#{command} #{file}\"\n pause if pauseyn == \"y\"\n c_refresh\n else\n perror \"File #{file} not found\"\n end\nend",
"def parse_input (input_file)\nend",
"def eval_file; end",
"def command_file prompt, *command\n pauseyn = command.shift\n command = command.join ' '\n clear_last_line\n print \"[#{prompt}] Choose a file [#{@view[@cursor]}]: \"\n file = ask_hint @view[@cursor]\n # print \"#{prompt} :: Enter file shortcut: \"\n # file = ask_hint\n perror 'Command Cancelled' unless file\n return unless file\n\n file = expand_path(file)\n if File.exist? file\n file = Shellwords.escape(file)\n pbold \"#{command} #{file} (#{pauseyn})\"\n system \"#{command} #{file}\"\n setup_terminal\n pause if pauseyn == 'y'\n refresh\n else\n perror \"File #{file} not found\"\n end\nend",
"def process_input(file)\n if file == '-'\n read_stdin\n else\n call_write(\n process_input_file(load_data(Pathname.new(file)).split(\"\\n\"))\n )\n end\n end",
"def run\n \n if parsed_options?\n \n process_command\n end\n \n end",
"def generate_input_file\n\t\t\t#FileUtils.touch(\"#@run_name.mat\")\n\t\t\t#cronos.new_file\n\t\t\t#eputs \"Make sure you save the file as #@run_name.mat... overwrite the existing empty place holder. When you have saved the file press enter.\"\n\t\t\tif @duplicate_id\n\t\t\t\told = @runner.run_list[@duplicate_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telsif @restart_id\n\t\t\t\told = @runner.run_list[@restart_id]\n\t\t\t\tsystem \"cp #{old.directory}/#{old.run_name}_resultat.mat #@directory/#@run_name.mat\"\n\t\t\t\tload\n\t\t\telse\n\t\t\t\tsz = Terminal.terminal_size[1]\n\t\t\t\teputs((str = \"When you have created the file press enter. Don't save it (CodeRunner will automatically save it in the right place. You can edit parameters later as well. CodeRunner will not submit the file... submit it manually using a batch or interactive run.\"; [\"-\"*sz, str, \"-\"*sz]))\n\t\t\t\tcronos.puts(\"zuicreate\")\n\t\t\t\tSTDIN.gets\n\t\t\tend\n\t\t\tcronos.puts(\"param.gene.origine = '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.gene.file = '#@directory/#{@run_name}_resultat.mat'\")\n\t\t\tcronos.puts(\"param.gene.rapsauve = '#@directory/#{@run_name}_resultat'\")\n\t\t\tcronos.puts(\"param.edit.currentfile= '#@directory/#@run_name.mat'\")\n\t\t\tcronos.puts(\"param.from.creation.com = '#@comment'\")\n\t\t\tcronos.puts(\"zuisavedata('force')\")\n\t\t\t#cronos.eval(\"zuicreate\")\n\t\t\trefresh_gui\n\t\t\t\n\t\tend",
"def exec(*operations)\n package = Package.new(options[:path])\n say \"Executing #{package.full_name}...\", :yellow\n package.load!\n package.run!(operations)\n end",
"def run\n if @files.empty?\n @commander.Process(STDIN)\n else\n @files.each do |filename|\n File.open(filename) { |f| @commander.Process(f) }\n end \n end\n end",
"def start(file = '')\n case @path \n when 0 # Command Mode\n while true\n command = gets().strip # Get the input command\n break if command == 'exit' #exit to stop\n read_and_execute(command)\n end\n when 1 #file mode\n commands = File.readlines(file) # Read file contents\n commands.each {|command| read_and_execute(command.strip)}\n else # Unknown Input Mode\n puts 'Unknown Input Mode!'\n end\n end",
"def run_commands_from_file(commands)\n\t\tcommands.each do |command|\n\t\t\trun_command(command)\n\t\tend\n\n\tend",
"def run(input)\n language = language(input)\n conf = ConfigurationCreator.new(\n language,\n options[:domain],\n options[:resource_path]\n )\n\n stdout, stderr, process = capture(conf.config_file_path, input)\n\n conf.close_config\n\n raise stderr unless process.success?\n\n return stdout\n end",
"def config_file(filename)\n if filename =~ /^\\//\n @@config_file = filename\n else\n @@config_file = File.join(File.expand_path('~'),filename)\n end\n commands[:initconfig] = InitConfig.new(@@config_file)\n @@config_file\n end",
"def build_convert_command(input_file, output_file)\n builder = CommandBuilder.new([Sox::File.new(input_file)], Sox::File.new(output_file))\n builder.effects = {:channels => @options[:channels], :rate => @options[:rate]}\n builder.build\n end",
"def write_input_file\n File.open(@run_name + \".trin\", 'w'){|file| file.puts input_file_text}\n end",
"def run file_name\n\t\tapplication = select_app file_name\n\t\tsystem \"#{application} #{file_name}\"\n\tend",
"def main\n operations.each { |op|\n template = [['sample: Sample Name', '', '', '', ''],['title: Title 1', 'title 1\\'s step 1', 'title 1\\'s step 2','title: Title n', '...'],['Ingredient 1', 'Ingredient 1\\'s quantity', 'Ingredient k', 'Ingredient k\\'s quantity', '...']]\n show {\n title \"File format (csv)\"\n table template\n }\n \n ups = upload_file\n if ups.nil?\n show { note \"No files found...\"}\n return\n end\n\n file = ups[0]\n data = read_url(file)\n \n # Remove nils from the data array.\n remove_data_nils data\n \n if(data.empty?)\n show { note \"no data, returning...\" } \n return\n end\n \n # Look through data for duplicates\n create_samples data\n \n }\n end",
"def fileinput(file)\n\n if File.exist?(file) == false\n return false\n end\n\n IO.foreach(file) do |line|\n @robot.run(line)\n\n case @robot.command\n when \"PLACE\" then @robot.place\n when \"MOVE\" then @robot.move\n when \"LEFT\" || \"RIGHT\" then @robot.rotate\n when \"REPORT\" then @output = @robot.report\n end\n end\n\n return @output\n end",
"def file(glob, target, options = nil)\n end",
"def exec_file(file)\n\t\t\tcurrent_dir = @variables['__DIR__' ]\n\t\t\tcurrent_file = @variables['__FILE__']\n\t\t\tcurrent_line = @variables['__LINE__']\n\n\t\t\[email protected](file) do |action, args, text, file, line|\n\t\t\t\t@variables['__DIR__'] = File.absolute_path(File.dirname(file))\n\t\t\t\t@variables['__FILE__'] = file\n\t\t\t\t@variables['__LINE__'] = line\n\t\t\t\tbreak if exec_parsed_action(action, args, true, text) == :break\n\t\t\tend\n\n\t\t\t@variables['__DIR__' ] = current_dir\n\t\t\t@variables['__FILE__'] = current_file\n\t\t\t@variables['__LINE__'] = current_line\n\t\tend",
"def indentify_commands\n\t\tif is_file_input?(ARGV)\n\t\t\tcommands = extract_commands_from_input_file(ARGV)\n\t\t\tinitiate_parking(commands.shift)\n\t\t\trun_commands_from_file(commands) if @@lot\n\t\telse\n\t\t\tread_command_from_console_and_extract\n\t\tend\n\tend",
"def get_input_file(input_file)\n puts \"-------------- Entering get_input_file() Method\"\n if File.exist?(input_file)\n input_file = File.open(File.join(File.dirname('__FILE__'),input_file),\"r\")\n puts \"Got the input file with read mode\"\n else\n puts \"Please check the input file exists\"\n raise \"Error in reading the input file\"\n end\n\n puts \"--------------- Exiting get_input_file() Method\"\n input_file\nend",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def event_file_create_command(id, index, event_src)\n disk.file_create_command(event_filename(id, index), event_src)\n end",
"def processFile(filename, options)\n\tputs \"Processing #{filename}\"\n\n\t# Either upload the file to DocumentCloud and get the resulting URL, \n\t# or if not uploaded 8we just make a file:// URL\n\t# NB: we make the UID here, using the URL if uploaded but the *relative* filename if local\n\t# Otherwise saved tag files would never be portable between computers\n\turl = nil\n\tdigest = nil\t\n\tif options.upload\n\t\tresult = DC.upload(options.username, options.password, filename, options.project)\n\t\turl = result[\"canonical_url\"]\n\t\t#puts url\n\t\tdigest = Digest::MD5.hexdigest(url)\n\telse\n\t\tif File.extname(filename) != \".txt\"\n\t\t\turl = \"file://\" + File.expand_path(filename)\n\t\tend\n\t\tdigest = Digest::MD5.hexdigest(filename)\n\tend\n\t\n\tif options.overviewCSVfilename\n\t\t# extract file text, append to Overview csv\n\t\ttext = extractTextFromFile(filename)\n\t\tif url != nil\n\t\t\toptions.csv << [text, digest, url]\n\t\telse\n\t\t\toptions.csv << [text, digest]\n\t\tend\n\tend\nend",
"def run file_name\n application = select_app file_name\n system \"#{application} #{file_name}\"\n end",
"def run file_name\n application = select_app file_name\n system \"#{application} #{file_name}\"\n end",
"def command_to_merge_files(tool, input)\n p \"#{ tool } #{ input }\"\nend",
"def run_script(file, out = handler.interface, verbose=false)\n interface = ScriptInterface.new(File.expand_path(file), out)\n processor = ControlCommandProcessor.new(interface)\n processor.process_commands(verbose)\n end",
"def run_script(file, out = handler.interface, verbose=false)\n interface = ScriptInterface.new(File.expand_path(file), out)\n processor = ControlCommandProcessor.new(interface)\n processor.process_commands(verbose)\n end",
"def run_script(file, out = handler.interface, verbose=false)\n interface = ScriptInterface.new(File.expand_path(file), out)\n processor = ControlCommandProcessor.new(interface)\n processor.process_commands(verbose)\n end",
"def before_perform\n @outdir = job.job_dir.to_s\n @basename = File.join(job.job_dir, job.jobid)\n @infile = @basename+\".in\" \n # still has to be generated\n @outfile = @basename+\".frags\"\n params_to_file(@infile, 'sequence_input', 'sequence_file')\n @informat = params['informat'] ? params['informat'] : 'fas'\n @predict_ta = params['ta']\n reformat(@informat, \"fas\", @infile)\n @commands = []\n \n \n end",
"def edit(filename)\n file_path = Path.new(filename)\n command \"edit #{file_path}\"\n self\n end",
"def execute\n warn 'executing fpm app spec task, but there are no input files [fpm_app_spec::task#execute]' if\n @opts.get(:files).empty?\n\n fpm_package @opts.get(:out), @opts.get(:files)\n end",
"def run_cmd(command_class, args) \n command = command_class.new(args)\n command.config[:config_file] = config[:config_file]\n command.configure_chef\n command.run\n \n command\n end",
"def select_operation(input)\n # input_array = input.split(\" \")\n # operation = input_array.first\n # file_name = input_array.last\n\nend",
"def generate_options filename, code\r\n args = ['-f', 'j', filename]\r\n base_options = RuboCop::Options.new\r\n options, paths = base_options.parse(args)\r\n options[:stdin] = code\r\n [options, paths]\r\n end",
"def run( file_name )\n application = select_app( file_name )\n system( \"#{application} #{file_name}\" )\n end",
"def execute(filename=\"stdio\", line_number=0)\n command, *args = @line.shellsplit\n COMMANDS.fetch(command.to_sym).call(args)\n rescue KeyError => err\n log_error(filename, line_number, \"Invalid command #{command}\")\n rescue => err\n log_error(filename, line_number, err.message)\n end",
"def run\n @input_files = @scenario.to_tmpfiles\n\n @logger.info \"Preparing to run SIPp command: #{command}\"\n\n execute_with_redirected_streams\n\n wait unless @options[:async]\n ensure\n cleanup_input_files unless @options[:async]\n end",
"def file_mode\n\t\tinput_file = File.open(input_path, 'r')\n\t\t\n\t\tinput_file.each_line do |line|\n\t\t\t@input = line\n\t\t\tparse_user_input\n\t\tend\n\tend",
"def run_file(in_file, root)\n root.accept(self)\n end",
"def pipe_in_file(file_name)\n file_name = expand_path(file_name)\n\n File.open(file_name, 'r').each_line do |line|\n last_command_started.write(line)\n end\n end",
"def pipe_in_file(file_name)\n file_name = expand_path(file_name)\n\n File.open(file_name, \"r\").each_line do |line|\n last_command_started.write(line)\n end\n end",
"def run_command f\n files = Shellwords.join(f)\n count = f.count\n text = if count > 1\n \"#{count} files\"\n else\n files[0..40]\n end\n begin\n command = readline \"Run a command on #{text}: \"\n return if command.empty?\n\n # command2 = gets().chomp\n command2 = readline 'Second part of command: '\n pause \"#{command} #{files} #{command2}\"\n\n reset_terminal\n system \"#{command} #{files} #{command2}\"\n setup_terminal\n rescue StandardError => ex\n perror \"Canceled or failed command, (#{ex}) press a key.\"\n @log.warn \"RUNCOMMAND: #{ex}\"\n return\n end\n\n refresh\n push_used_dirs Dir.pwd\n # should we clear selection also ?\nend",
"def execute(filename, command, error)\n # Execute Command\n @result[:_task] = filename\n @result[:_timestamp]= Time.now.to_i\n # @result[:_date]\n unless @params[\"_target\"][\"remote\"].nil?\n begin \n stdout, stderr, status = Open3.capture3(*command)\n rescue Exception => e\n default_error = { \n msg: e.message,\n kind: \"test::#{filename}\",\n details: { class: e.class.to_s,\n backtrace: e.backtrace }, \n }\n @result[:_error] = default_error.merge(error)\n\n end\n @result[:_stdout] = stdout\n @result[:_sterr] = stderr\n @result[:_status] = status\n @result\n else\n @result[:_timestamp]= Time.now\n @result[:_command_start_time] = Time.now\n begin \n $results = command.call()\n @result[:_command_end_time] = Time.now\n rescue Exception => e\n @result[:_command_end_time] = Time.now\n default_error = { \n msg: e.message,\n kind: \"test::#{filename}\",\n details: { class: e.class.to_s,\n backtrace: e.backtrace }, \n }\n @result[:_error] = default_error.merge(error)\n #puts @result\n end\n # makes sure the results are at the top level of the return object\n unless $results.nil?\n $results.each do |key, value|\n @result[key] = value\n end\n end\n end\n @result\n end",
"def run file_name \n\t\tapplication = select_app file_name \n\t\tsystem \"#{application} #{file_name}\" \n\tend",
"def execute\n settings = read_settings\n input, remove_regexp, output = get_in_out_removes(settings)\n create_output_dir(output)\n Dir.glob(input).each do |file|\n input_src = get_input(file)\n replaced = remove_head(input_src.encode('UTF-16BE', 'UTF-8', invalid: :replace, undef: :replace, replace: '?').encode('UTF-8'), remove_regexp)\n output_file(file, replaced, output)\n end\n end",
"def call(filepath, linenum) # should separate to a class?\n command = (@command || detect_command()) % [linenum, filepath] # or [filepath, linenum]\n log(command)\n `#{command.untaint}`\n end",
"def load filename\n unless filename && File.exist?(filename)\n raise MiniExiftool::Error.new(\"File '#{filename}' does not exist.\")\n end\n if File.directory?(filename)\n raise MiniExiftool::Error.new(\"'#{filename}' is a directory.\")\n end\n @filename = filename\n @values.clear\n @tag_names.clear\n @changed_values.clear\n opt_params = ''\n opt_params << (@numerical ? '-n ' : '')\n opt_params << (@composite ? '' : '-e ')\n opt_params << (@convert_encoding ? '-L ' : '')\n cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} \"#{filename}\")\n if run(cmd)\n parse_output\n else\n raise MiniExiftool::Error.new(@error_text)\n end\n self\n end",
"def run file_name \n application = select_app file_name \n system \"#{application} #{file_name}\" \n end",
"def build_mogrify_command(file_path)\n\t\t\t\t\"mogrify #{options_to_str(@command_options)} #{file_path}\"\n\t\t\tend",
"def execute_file(full_path, args)\n if File.extname(full_path) == '.rb'\n Rex::Script::Shell.new(self, full_path).run(args)\n else\n load_resource(full_path)\n end\n end",
"def set_files(input = \"./sample1.txt\",output = './dest1.txt')\n @input_file = input\n @output_file = output\n @extract = load_file(@input_file,PATTERNS)\n end",
"def run\r\n #check input format, either a file or standard input\r\n if @inputFile == STDIN\r\n f = STDIN\r\n else\r\n f = File.open(@inputFile, \"r\")\r\n end\r\n #flag to mark whether read the first instruction and be used to check lines before any instruction\r\n mark = false\r\n #process instructiions line by line\r\n f.each do |line|\r\n #skip comments\r\n next if line =~ /^\\/\\//\r\n #skip an empty line before any instruction\r\n next if mark == false and line =~ /^[\\s]*$/\r\n opts = format_input(line)\r\n mark = true if mark == false\r\n out_put = @tm.read(opts)\r\n unless out_put.nil?\r\n if @outputFile == STDOUT or @outputFile.nil?\r\n STDOUT.puts out_put\r\n else\r\n File.open(@outputFile, \"a\") do |log|\r\n log.puts out_put\r\n end\r\n end\r\n end\r\n end\r\n #add a time step for TM\r\n out_put = @tm.read([[\"advance\"]])\r\n unless out_put.nil?\r\n if @outputFile == STDOUT or @outputFile.nil?\r\n STDOUT.puts out_put\r\n else\r\n File.open(@outputFile, \"a\") do |log|\r\n log.puts out_put\r\n end\r\n end\r\n end\r\n\r\n f.close\r\n\r\n end",
"def check_file(filename)\n # set output format to 'simple' (easier to parse) and\n # include rubocop configuration file\n rubocop_res = `rubocop -f simple -c #{@options[:config]} #{filename}`\n results = parse_rubocop_output(rubocop_res)\n unless (results[:C].empty? &&\n results[:E].empty? &&\n results[:F].empty? &&\n results[:W].empty?) ||\n @options[:quiet]\n puts\n @options[:jenkins] ?\n puts(\"=== #{filename} ===\") :\n puts(\"=== #{filename} ===\".bold)\n print_offenses(results)\n end\n # Report results in a json file\n report_results(filename, results, 'coding_style') if @options[:report]\n # Return code\n (results[:C].empty? && results[:E].empty? && results[:F].empty?) ? 0 : 1\n end",
"def extract_commands_from_input_file(args)\n\t\tcommands = []\n\t\tFile.open(args[0], \"r\").each do | line |\n\t\t\tcommands << extract_command_from_line(line)\n\t\tend\n\t\tcommands\n\tend",
"def in_file(filename); end",
"def run\n # prepare log and read command line arguments\n prepare_log\n process_args\n\n # load graph - action depends on last suffix\n #@highway_attributes = ['residential', 'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'unclassified']\n @highway_attributes = ['residential', 'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'unclassified']\n #@highway_attributes = ['residential']\n if file_type(@map_file) == \"osm\" or file_type(@map_file) == \"xml\" then\n load_graph\n elsif file_type(@map_file) == \"dot\" or file_type(@map_file) == \"gv\" then\n import_graph\n else\n puts \"Input file type not recognized!\"\n usage\n end\n\n if @load_cmd == '--load-comp'\n get_component\n end\n\n\n # perform the operation\n case @operation\n when '--export'\n @visual_graph.export_graphviz(@out_file)\n return\n when '--show-nodes'\n if @out_file == nil\n run_interface\n elsif @id_start != nil\n run_with_ids\n elsif @lon_start != nil\n run_with_lon_and_lat\n end\n return\n when '--midist'\n midist\n else\n usage\n exit 1\n end\n\n end",
"def events_file_create_command(id, event0_src)\n disk.file_create_command(events_filename(id), event0_src)\n end",
"def manipulate\n\n procname = @commandline.argument('first') || ''\n filename = @commandline.argument('second') || ''\n\n procname = Kpse.found(procname)\n\n if procname.empty? || ! FileTest.file?(procname) then\n report('provide valid manipulator file')\n elsif filename.empty? || ! FileTest.file?(filename) then\n report('provide valid resource log file')\n else\n begin\n data = REXML::Document.new(File.new(filename))\n rescue\n report('provide valid resource log file (xml error)')\n return\n end\n begin\n proc = REXML::Document.new(File.new(procname))\n rescue\n report('provide valid manipulator file (xml error)')\n return\n end\n report(\"manipulator file: #{procname}\")\n report(\"resourcelog file: #{filename}\")\n begin\n nofrecords, nofdone = 0, 0\n REXML::XPath.each(data.root,\"/rl:library/rl:usage\") do |usage|\n nofrecords += 1\n variables = Hash.new\n usage.elements.each do |e|\n variables[e.name] = e.text.to_s\n end\n report(\"processing record #{nofrecords} (#{variables['file'] || 'noname'}: #{variables.size} entries)\")\n if conversion = variables['conversion'] then\n report(\"testing for conversion #{conversion}\")\n if suffix = variables['suffix'] then\n suffix.downcase!\n if ! suffix.empty? && variables['file'] && variables['file'] !~ /\\.([a-z]+)$/i then\n variables['file'] += \".#{suffix}\"\n end\n if file = variables['file'] then\n report(\"conversion #{conversion} for suffix #{suffix} for file #{file}\")\n else\n report(\"conversion #{conversion} for suffix #{suffix}\")\n end\n pattern = \"@name='#{conversion}' and @suffix='#{suffix}'\"\n if steps = REXML::XPath.first(proc.root,\"/rl:manipulators/rl:manipulator[#{pattern}]\") then\n localsteps = steps.deep_clone\n ['rl:old','rl:new'].each do |tag|\n REXML::XPath.each(localsteps,tag) do |extras|\n REXML::XPath.each(extras,\"rl:value\") do |value|\n if name = value.attributes['name'] then\n substititute(value,variables[name.to_s] || '')\n end\n end\n end\n end\n old = REXML::XPath.first(localsteps,\"rl:old\")\n new = REXML::XPath.first(localsteps,\"rl:new\")\n if old && new then\n old, new = justtext(old.to_s), justtext(new.to_s)\n variables['old'], variables['new'] = old, new\n begin\n [old,new].each do |d|\n File.makedirs(File.dirname(d))\n end\n rescue\n report(\"error during path creation\")\n end\n report(\"old file #{old}\")\n report(\"new file #{new}\")\n level = if File.needsupdate(old,new) then 2 else 0 end\n else\n level = 1\n end\n if level>0 then\n REXML::XPath.each(localsteps,\"rl:step\") do |command|\n REXML::XPath.each(command,\"rl:old\") do |value|\n replace(value,old)\n end\n REXML::XPath.each(command,\"rl:new\") do |value|\n replace(value,new)\n end\n REXML::XPath.each(command,\"rl:value\") do |value|\n if name = value.attributes['name'] then\n substititute(value,variables[name.to_s])\n end\n end\n str = justtext(command.to_s)\n # str.gsub!(/(\\.\\/)+/io, '')\n report(\"command #{str}\")\n System.run(str) unless @commandline.option('test')\n report(\"synchronizing #{old} and #{new}\")\n File.syncmtimes(old,new) if level > 1\n nofdone += 1\n end\n else\n report(\"no need for a manipulation\")\n end\n else\n report(\"no manipulator found\")\n end\n else\n report(\"no suffix specified\")\n end\n else\n report(\"no conversion needed\")\n end\n end\n if nofdone > 0 then\n jobname = filename.gsub(/\\.(.*?)$/,'') # not 'tuo' here\n tuoname = jobname + '.tuo'\n if FileTest.file?(tuoname) && (f = File.open(tuoname,'a')) then\n f.puts(\"%\\n% number of rlx manipulations: #{nofdone}\\n\")\n f.close\n end\n end\n rescue\n report(\"error in manipulating files: #{$!}\")\n end\n begin\n logname = \"#{filename}.log\"\n File.delete(logname) if FileTest.file?(logname)\n File.copy(filename,logname)\n rescue\n end\n end\n\n end"
] | [
"0.6529169",
"0.6030414",
"0.5856169",
"0.5741992",
"0.5705901",
"0.5705548",
"0.56950265",
"0.55987614",
"0.558795",
"0.5523257",
"0.54516935",
"0.5441318",
"0.53969586",
"0.5386397",
"0.53860337",
"0.5376245",
"0.53733194",
"0.53602606",
"0.5351467",
"0.5345632",
"0.5338001",
"0.53312737",
"0.5313932",
"0.53078854",
"0.5281579",
"0.5236375",
"0.52308345",
"0.5185359",
"0.5175441",
"0.51737946",
"0.51716053",
"0.5154813",
"0.5139421",
"0.5132097",
"0.5130164",
"0.51177686",
"0.51163495",
"0.5112629",
"0.5090836",
"0.50903076",
"0.5081923",
"0.5081663",
"0.5079344",
"0.5071358",
"0.5066608",
"0.5065784",
"0.5062422",
"0.50465935",
"0.5026649",
"0.5017205",
"0.5015417",
"0.50119114",
"0.50081044",
"0.500783",
"0.49896085",
"0.49874437",
"0.4971756",
"0.4967427",
"0.49598923",
"0.49539733",
"0.49481133",
"0.49481133",
"0.4941051",
"0.49369797",
"0.49336663",
"0.49336663",
"0.4916052",
"0.49114427",
"0.49114427",
"0.49114427",
"0.49085832",
"0.4902849",
"0.48955926",
"0.4893455",
"0.489335",
"0.4889108",
"0.48884645",
"0.48829997",
"0.48818788",
"0.48785335",
"0.48774108",
"0.4872545",
"0.48703936",
"0.48625186",
"0.4851038",
"0.4847505",
"0.4844057",
"0.48431194",
"0.4842848",
"0.48426574",
"0.4831938",
"0.4828167",
"0.48169947",
"0.48110053",
"0.48104388",
"0.48092803",
"0.48078114",
"0.48033145",
"0.4802343",
"0.48012224"
] | 0.73074967 | 0 |
The position of the data dictionary header within the page. | def pos_data_dictionary_header
pos_page_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_header\n @position - 2\n end",
"def header_position\n C.archive_read_header_position archive\n end",
"def pos_index_header\n pos_page_body\n end",
"def offset\n fil_header[:offset]\n end",
"def local_header_offset; end",
"def pos_partial_page_header\n pos_fil_header + 4\n end",
"def pos_fil_header\n 0\n end",
"def pos_fseg_header\n pos_index_header + size_index_header\n end",
"def page_header\n @page_header ||= cursor(pos_index_header).name(\"index\") do |c|\n index = PageHeader.new(\n n_dir_slots: c.name(\"n_dir_slots\") { c.read_uint16 },\n heap_top: c.name(\"heap_top\") { c.read_uint16 },\n n_heap_format: c.name(\"n_heap_format\") { c.read_uint16 },\n garbage_offset: c.name(\"garbage_offset\") { c.read_uint16 },\n garbage_size: c.name(\"garbage_size\") { c.read_uint16 },\n last_insert_offset: c.name(\"last_insert_offset\") { c.read_uint16 },\n direction: c.name(\"direction\") { PAGE_DIRECTION[c.read_uint16] },\n n_direction: c.name(\"n_direction\") { c.read_uint16 },\n n_recs: c.name(\"n_recs\") { c.read_uint16 },\n max_trx_id: c.name(\"max_trx_id\") { c.read_uint64 },\n level: c.name(\"level\") { c.read_uint16 },\n index_id: c.name(\"index_id\") { c.read_uint64 }\n )\n\n index.n_heap = index.n_heap_format & ((2**15) - 1)\n index.format = (index.n_heap_format & (1 << 15)).zero? ? :redundant : :compact\n\n index\n end\n end",
"def position\n _response_word.fetch(\"position\", nil)\n end",
"def data_dictionary_header\n cursor(pos_data_dictionary_header).name(\"data_dictionary_header\") do |c|\n Header.new(\n max_row_id: c.name(\"max_row_id\") { c.read_uint64 },\n max_table_id: c.name(\"max_table_id\") { c.read_uint64 },\n max_index_id: c.name(\"max_index_id\") { c.read_uint64 },\n max_space_id: c.name(\"max_space_id\") { c.read_uint32 },\n unused_mix_id_low: c.name(\"unused_mix_id_low\") { c.read_uint32 },\n indexes: c.name(\"indexes\") do\n {\n SYS_TABLES: c.name(\"SYS_TABLES\") do\n {\n PRIMARY: c.name(\"PRIMARY\") { c.read_uint32 },\n ID: c.name(\"ID\") { c.read_uint32 },\n }\n end,\n SYS_COLUMNS: c.name(\"SYS_COLUMNS\") do\n {\n PRIMARY: c.name(\"PRIMARY\") { c.read_uint32 },\n }\n end,\n SYS_INDEXES: c.name(\"SYS_INDEXES\") do\n {\n PRIMARY: c.name(\"PRIMARY\") { c.read_uint32 },\n }\n end,\n SYS_FIELDS: c.name(\"SYS_FIELDS\") do\n {\n PRIMARY: c.name(\"PRIMARY\") { c.read_uint32 },\n }\n end,\n }\n end,\n unused_space: c.name(\"unused_space\") { c.read_bytes(4) },\n fseg: c.name(\"fseg\") { Innodb::FsegEntry.get_inode(@space, c) }\n )\n end\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def local_header_offset=(_arg0); end",
"def page_fsp_hdr\n 0\n end",
"def position\n return @position\n end",
"def position\n return @position\n end",
"def fil_header\n @fil_header ||= cursor(pos_fil_header).name(\"fil_header\") do |c|\n {\n :checksum => c.name(\"checksum\") { c.get_uint32 },\n :offset => c.name(\"offset\") { c.get_uint32 },\n :prev => c.name(\"prev\") {\n Innodb::Page.maybe_undefined(c.get_uint32)\n },\n :next => c.name(\"next\") {\n Innodb::Page.maybe_undefined(c.get_uint32)\n },\n :lsn => c.name(\"lsn\") { c.get_uint64 },\n :type => c.name(\"type\") { PAGE_TYPE_BY_VALUE[c.get_uint16] },\n :flush_lsn => c.name(\"flush_lsn\") { c.get_uint64 },\n :space_id => c.name(\"space_id\") { c.get_uint32 },\n }\n end\n end",
"def position\n @entry.position\n end",
"def offset\n Array.new(headers.length, '')\n end",
"def pos\n @layout[@pos - 1]\n end",
"def position\n @position\n end",
"def first\n header_data\n end",
"def size_data_dictionary_header\n ((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE)\n end",
"def pos_rseg_header\n pos_page_body\n end",
"def position\n @position ||= begin\n row, column = filename_with_position.split(':').slice(1..2)\n Parsing::Location.new(row: row.to_i, column: column.to_i)\n end\n end",
"def show_section_h_offset\n\t\t\tputs \" Start of section headers: #{@elf_section_h_offset} (bytes into file)\"\n\t\tend",
"def size_index_header\n 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 8 + 2 + 8\n end",
"def offset\n @offset ||= raw_response['response']['start']\n end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def position; end",
"def actual_header\n data.lines.first.chomp\n end",
"def pos()\n #This is a stub, used for indexing\n end",
"def pos()\n #This is a stub, used for indexing\n end",
"def pos\n io.pos\n end",
"def header\n @version, @flags, @numStrikes = @bytes[0, 8].unpack('nnN')\n\n @strikeOffset = (0...@numStrikes).map do |n|\n start = 8 + n * 4\n @bytes[start, 4].unpack('N')[0]\n end\n end",
"def pos_fsp_header\n pos_fil_header + size_fil_header\n end",
"def offset\n\t\t\t@position + @offset\n\t\tend",
"def entry_start_pos\n @splitter.entry_start_pos\n end",
"def pos_page_body\n pos_fil_header + size_fil_header\n end",
"def offset\n 1\n end",
"def front\n header_data\n end",
"def header\n return @header\n end",
"def position\r\n self.line.ordered_samples.to_a.index(self)\r\n end",
"def header_row_index\n index(header)\n end",
"def pos_records\n size_fil_header +\n size_index_header +\n size_fseg_header\n end",
"def pos\n @pos\n end",
"def tell\n @offset\n end",
"def offset; end",
"def offset; end",
"def offset; end",
"def position\n end",
"def offset()\n @offset__\n end",
"def pos\n @pos ||= node.attr('pos')\n end",
"def header_space\n # The end of the supremum system record is the beginning of the space\n # available for user records.\n pos_user_records\n end",
"def pos\n @pos || uninitialized!\n end",
"def position\n attributes.fetch(:position)\n end",
"def header\n @result['_header']\n end",
"def pos\n @stream.pos\n end",
"def pos\n file.pos\n end",
"def read_header\n @height = next_uint16 + 1\n puts \"Height: #{@height}\" if @verbose\n\n @width = next_uint16 + 1\n puts \"Width: #{@width}\" if @verbose\n\n @yoffset = next_uint16\n @xoffset = next_uint16\n puts \"Offsets: #{@xoffset}, #{@yoffset}\" if @verbose\n\n @xstart = next_int32\n @ystart = next_int32\n puts \"Start: #{@xstart}, #{@ystart}\" if @verbose\n\n @xend = next_int32\n @yend = next_int32\n\n puts \"End: #{@xend}, #{@yend}\" if @verbose\n end",
"def position\n first.position\n end",
"def position\n @state[\"position\"]\n end",
"def pos\n @io.pos - @buffer.size\n end",
"def b_offset\n @last_4[1].to_i\n end",
"def position\n return [@x, @y, @heading]\n end",
"def data\n @data ||= section.elf.section_at(header.st_shndx).data[header.st_value, header.st_size]\n end",
"def position\n if offset <= 0\n d\n\n elsif offset > dn_index\n dn_position\n\n else\n d_range[offset]\n\n end\n end",
"def get_offset\n @offset\n end",
"def offset\n (page - 1) * PER_PAGE\n end",
"def Header\r\n\t\tif @page == 1\r\n\t\t\tfirst_page_header\r\n\t\telse\r\n\t\t\tpage_header\t\r\n\t\tend\r\n\tend",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def offset\n (current_page * size) - size\n end",
"def header\n @sfntVersion, @numTables, *rest = @bytes[0, 4 + 2 + 2 + 2 + 2].unpack('Nnnnn')\n end",
"def pos()\n #This is a stub, used for indexing\n end",
"def starting_position; end",
"def lines_offset\n @starting_line - 1\n end",
"def metadata_start\n 2\n end",
"def parse_position(content)\n return content.lstrip.rstrip.to_i\n end",
"def text_position\n end",
"def offset\n @offset ||= (position.unitless? || position.unit_str == \"px\") ? position.value : 0\n end",
"def cur_heading\n $HEADINGS[0]\nend",
"def first_offset; end",
"def first_offset; end",
"def pos\n (stream[:total_out_hi32] << 32) + stream[:total_out_lo32]\n end",
"def header_index_of(value)\n header_cell_values.index(value)\n end",
"def pos\n @read\n end",
"def d_position\n pos = if offset <= 0\n d\n\n elsif offset > dn_index\n dn_position\n\n else\n d_range[offset]\n\n end\n\n pos = pos < bd ? bd : pos\n pos = pos > bdn ? bdn : pos\n pos\n end",
"def required_pos\n :unknown\n end",
"def required_pos\n :unknown\n end"
] | [
"0.77962977",
"0.7534069",
"0.71625656",
"0.69582975",
"0.69355947",
"0.6839482",
"0.659235",
"0.6557365",
"0.6500078",
"0.64648426",
"0.6379584",
"0.6372833",
"0.6348647",
"0.6330062",
"0.62297636",
"0.62297636",
"0.61918914",
"0.61702305",
"0.61660814",
"0.6159254",
"0.6136642",
"0.61319226",
"0.61213577",
"0.61179847",
"0.60851556",
"0.6080514",
"0.60672873",
"0.60529965",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6047397",
"0.6036322",
"0.60333073",
"0.60333073",
"0.60287815",
"0.60094136",
"0.5999608",
"0.59965247",
"0.59902656",
"0.59773296",
"0.5968872",
"0.59646297",
"0.59154654",
"0.591331",
"0.5911189",
"0.59093267",
"0.5908476",
"0.5875404",
"0.5871606",
"0.5871606",
"0.5871606",
"0.5870697",
"0.5864707",
"0.5862765",
"0.58617026",
"0.58459884",
"0.5845898",
"0.58360434",
"0.5829433",
"0.58174145",
"0.58151656",
"0.58146065",
"0.5811009",
"0.58044946",
"0.57920766",
"0.575664",
"0.57383627",
"0.57280636",
"0.5723733",
"0.5723662",
"0.5723388",
"0.56886184",
"0.56886184",
"0.56886184",
"0.56886184",
"0.56886184",
"0.56886184",
"0.56872624",
"0.5681379",
"0.5679204",
"0.5677261",
"0.56748575",
"0.56575227",
"0.5653616",
"0.56508285",
"0.5609267",
"0.5609174",
"0.5596852",
"0.5596852",
"0.5595034",
"0.559377",
"0.55910474",
"0.5584377",
"0.5583873",
"0.5583873"
] | 0.80084866 | 0 |
The size of the data dictionary header. | def size_data_dictionary_header
((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_size\n TYPE_SIZE\n end",
"def d_size\n uint64(header, 'size') / @blockSize\n end",
"def size\n @data ? @data.size : header.sh_size\n end",
"def header_size\n 12\n end",
"def size\n self.data.keys.size\n end",
"def size\n @data.bytesize\n end",
"def size\n self.data.length + 4\n end",
"def header_size\n FFI::Type::ULONG.size + FFI::Type::USHORT.size + FFI::Type::USHORT.size\n end",
"def header_length size\n size.to_s(16).length +\n CHUNK_SIGNATURE_HEADER.length +\n SIGNATURE_LENGTH +\n CLRF.length +\n size +\n CLRF.length\n end",
"def uncompressed_size\n @header.size\n end",
"def size\n stats[:dataSize]\n end",
"def size\n stats[:dataSize]\n end",
"def header_size(header)\n header.unpack(\"N\").first\n end",
"def byte_size(); @data.byte_size + 4; end",
"def size ; data['size'] ; end",
"def size\n @data.size\n end",
"def size\n @data.size\n end",
"def size\n @data.size\n end",
"def header_size\n 0\n end",
"def size\n return @data.size\n end",
"def size\n headers[:content_length].to_i\n end",
"def size\n headers[\"content-length\"].to_i\n end",
"def size\r\n self.data.length\r\n end",
"def size\n data.values.inject(0){|m,v| m+=v.size}\n end",
"def size\n @data.size\n end",
"def size\n @data.size\n end",
"def size\n return @data.size\n end",
"def size_fil_header\n 4 + 4 + 4 + 4 + 8 + 2 + 8 + 4\n end",
"def size\n\n self.to_h.size\n end",
"def header_len\n (@binhdr[12, 1].unpack(\"C\").pop >> 4) << 2\n end",
"def data_size\n @iplimage_struct.image_size\n end",
"def header_length\n @header_length ||= DBF_HEADER_SIZE + columns.size * 32 + 1\n end",
"def bLength\n self[:bLength]\n end",
"def data_len_bytes()\n 1\n end",
"def size\n return self.body_data.size\n end",
"def d_size\n @desc[:size].to_i\n end",
"def show_elf_h_size\n\t\t\tputs \" Size of this header: #{@elf_h_size} (bytes)\"\n\t\tend",
"def size_record_header\n case page_header[:format]\n when :compact\n RECORD_NEXT_SIZE + RECORD_COMPACT_BITS_SIZE\n when :redundant\n RECORD_NEXT_SIZE + RECORD_REDUNDANT_BITS_SIZE\n end\n end",
"def size\n return @hash.length\n end",
"def size\n @info[:size]\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def msg_size; @msg_size ||= PackedHeader.new(4, 'N'); end",
"def data_size\n File.size(file_path)\n end",
"def data_size\n File.size(file_path)\n end",
"def size_header\n 2 + 2 + 1\n end",
"def size\n self[:size]\n end",
"def size\n Integer(metadata[\"size\"]) if metadata[\"size\"]\n end",
"def data_len_bytes()\n 2\n end",
"def data_len_bytes()\n 2\n end",
"def data_len_bytes()\n 2\n end",
"def length\n @internal_hash.length\n end",
"def header_length() 3 end",
"def size\n @structure.size\n end",
"def byte_size()\n @value.length * 4\n end",
"def byte_size()\n @value.length * 4\n end",
"def size\r\n @pack.size\r\n end",
"def size\n @data_items.size\n end",
"def size_in_byte\n return @size_in_byte\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def preamble_size\n # Find size from position of data for first shard\n words.at(content_offset + File::Frozen::Descriptor.offset + 7).to_i\n end",
"def byte_size()\n if @record and RECORD_INFO[@record.type].size > 0 then\n RECORD_INFO[@record.type].size * @value.length\n else\n sum = 0\n @value.each do |val|\n sum += (val.length % 2 == 0) ? val.length : val.length + 1\n end\n sum\n end\n end",
"def size\n @hash.size + @converted.size\n end",
"def part_size_in_bytes\n data.part_size_in_bytes\n end",
"def size\n @size ||= @request[FSIZE].to_i\n end",
"def length\n metadata[:length]\n end",
"def size\n info[\"size\"]\n end",
"def size\n @heads['content-length'] || @size.to_s\n end",
"def header_length\n self[:ip_vhl] & 0x0f\n end",
"def size_in_bytes\n to_i description['SizeInBytes']\n end",
"def size\n to_payload.bytesize\n end",
"def num_bytes\n return @num_bytes\n end",
"def content_length\n\t\treturn 0 unless self.header.member?( :content_length )\n\t\treturn Integer( self.header.content_length )\n\tend",
"def get_size\n\t\tend",
"def size\n @hash_table.keys.length\n end",
"def size\n return @usrData.size\n end",
"def size\n read.bytesize\n end",
"def size\n self.dna_hash.size\n end",
"def size\n self.dna_hash.size\n end",
"def size\n return @args[:data].length\n end",
"def key_size server, key\n server\n .debug(:object, key)\n .scan(/serializedlength:([0-9]+)/)\n .flatten.first.to_i\n end",
"def size\n @buffer.size\n end",
"def size\n @buffer.size\n end",
"def size\n @buffer.size\n end",
"def size\n @gapi[\"size\"]\n end",
"def size\n serializable_values = @serializable.serializable_hash(@options)\n self.start_address = @options[:start_address] || 0\n\n current_address = 0.0 # Dirección en bytes\n\n @serializable.attr_config.each do |attr_options|\n var = attr_options[:coder].new(attr_options.merge(parent: @serializable))\n\n align_data(attr_options, var) if @options[:align]\n\n self.current_address += var.size\n end\n self.current_address-self.start_address\n end",
"def len_header\n return @len_header unless @len_header.nil?\n _pos = @_io.pos\n @_io.seek(88)\n @len_header = @_io.read_u8le\n @_io.seek(_pos)\n @len_header\n end",
"def current_size\n @data.size\n end",
"def size_index_header\n 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 8 + 2 + 8\n end",
"def size\n @content.bytesize\n end",
"def show_section_h_size\n\t\t\tputs \" Size of section headers: #{@elf_section_h_size} (bytes)\"\n\t\tend",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @info.size\n end",
"def size\n @info.size\n end",
"def size\n @info.size\n end",
"def size\n @size \n end"
] | [
"0.8326364",
"0.8231278",
"0.821332",
"0.7950296",
"0.7906167",
"0.7841435",
"0.77830505",
"0.77472657",
"0.7738898",
"0.77322656",
"0.772482",
"0.772482",
"0.7649034",
"0.7637968",
"0.7603028",
"0.7592744",
"0.7592744",
"0.7592744",
"0.75760883",
"0.7490768",
"0.7485302",
"0.746882",
"0.7463521",
"0.74046946",
"0.7357788",
"0.7357788",
"0.7346511",
"0.7327596",
"0.7322446",
"0.7313257",
"0.7303959",
"0.7297104",
"0.72138333",
"0.7207204",
"0.71914595",
"0.71900016",
"0.71861017",
"0.71631837",
"0.7160847",
"0.71464443",
"0.71451914",
"0.71451914",
"0.71451914",
"0.7120078",
"0.71185243",
"0.71185243",
"0.7099039",
"0.7073749",
"0.70703",
"0.7049172",
"0.7049172",
"0.7048686",
"0.7025711",
"0.70171094",
"0.6970474",
"0.6961815",
"0.6961815",
"0.69577885",
"0.6955471",
"0.695343",
"0.6951055",
"0.6951055",
"0.69400185",
"0.6934806",
"0.6921326",
"0.6920197",
"0.6913885",
"0.6908687",
"0.68972373",
"0.6891036",
"0.68836313",
"0.685661",
"0.68532413",
"0.6851547",
"0.6849113",
"0.6848676",
"0.6844649",
"0.68410504",
"0.68389",
"0.6829015",
"0.6829015",
"0.682328",
"0.6797689",
"0.6791209",
"0.6791209",
"0.6791209",
"0.6790311",
"0.6785636",
"0.6783941",
"0.67822576",
"0.67797554",
"0.67760944",
"0.6759144",
"0.6755742",
"0.6755742",
"0.6755742",
"0.67441475",
"0.67441475",
"0.67441475",
"0.6739868"
] | 0.87241167 | 0 |
Parse the data dictionary header from the page. | def data_dictionary_header
cursor(pos_data_dictionary_header).name("data_dictionary_header") do |c|
Header.new(
max_row_id: c.name("max_row_id") { c.read_uint64 },
max_table_id: c.name("max_table_id") { c.read_uint64 },
max_index_id: c.name("max_index_id") { c.read_uint64 },
max_space_id: c.name("max_space_id") { c.read_uint32 },
unused_mix_id_low: c.name("unused_mix_id_low") { c.read_uint32 },
indexes: c.name("indexes") do
{
SYS_TABLES: c.name("SYS_TABLES") do
{
PRIMARY: c.name("PRIMARY") { c.read_uint32 },
ID: c.name("ID") { c.read_uint32 },
}
end,
SYS_COLUMNS: c.name("SYS_COLUMNS") do
{
PRIMARY: c.name("PRIMARY") { c.read_uint32 },
}
end,
SYS_INDEXES: c.name("SYS_INDEXES") do
{
PRIMARY: c.name("PRIMARY") { c.read_uint32 },
}
end,
SYS_FIELDS: c.name("SYS_FIELDS") do
{
PRIMARY: c.name("PRIMARY") { c.read_uint32 },
}
end,
}
end,
unused_space: c.name("unused_space") { c.read_bytes(4) },
fseg: c.name("fseg") { Innodb::FsegEntry.get_inode(@space, c) }
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse\n read_header\n parse_text_segment\n parse_data_segment\n @data = nil\n end",
"def parse_header_contents; end",
"def pos_data_dictionary_header\n pos_page_body\n end",
"def read_headers(page_content)\n format = page_content.split(\"---\")\n if format.size > 0\n return YAML.load(format[1])\n else\n return nil\n end\n end",
"def parse!\n if /^(?<key>.*?):(?<value>.*)/m =~ @raw\n @key = key.strip\n @value = value.strip\n else\n raise \"Unable to parse Header: #{@raw}\"\n end\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def parseHeaders(request) \n headers = {};\n\n # Loop through headers\n request.lines[1..-1].each do |line|\n # If we are moving to the next line, return what we currently have\n return headers if line == \"\\r\\n\"\n\n # Structure data\n header, value = line.split\n header = header.gsub(\":\", \"\").downcase.to_sym\n headers[header] = value\n end\nend",
"def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header[k] = v.lstrip\n end\n end\n header\n end",
"def parse_header(header_line)\n check_element_size(header_line.length)\n\n @name = header_line[0]\n @domain_x = DataDomain.new(header_line[1], header_line[2], \\\n header_line[3], header_line[4])\n @domain_y = DataDomain.new(header_line[5], header_line[6], \\\n header_line[7], header_line[8])\n\n check_and_create_third_domain(header_line)\n end",
"def parse_header(io)\n\t variable_name = nil\n\t parse_pairs io do |code, value|\n\t\tcase code\n\t\t when '0' then next\n\t\t when '9'\n\t\t\tvariable_name = value\n\t\t else\n\t\t\theader[variable_name] = value\n\t\tend\n\t end\n\tend",
"def cgi_parse_header(line); end",
"def cgi_parse_header(line)\n parts = _cgi_parseparam(';' + line)\n key = parts.next\n pdict = {}\n\n begin\n while p = parts.next\n i = p.index('=')\n if i\n name = p[0...i].strip.downcase\n value = p[i+1..-1].strip\n if value.length >= 2 && value[0] == '\"' && value[-1] == '\"'\n value = value[1...-1]\n value = value.gsub('\\\\\\\\', '\\\\').gsub('\\\\\"', '\"')\n end\n pdict[name] = value\n end\n end\n rescue StopIteration\n end\n\n [key, pdict]\n end",
"def extract_header_data(response)\n header_type = get_full_type_signature(:SoapResponseHeader)\n headers = response.header[:response_header].dup\n process_attributes(headers, false)\n result = headers.inject({}) do |result, (key, v)|\n normalize_output_field(headers, header_type[:fields], key)\n result[key] = headers[key]\n result\n end\n return result\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def meta\n @meta ||= begin\n arr = @header_str.split(/\\r?\\n/)\n arr.shift\n arr.inject({}) do |hash, hdr|\n key, val = hdr.split(/:\\s+/, 2)\n hash[key.downcase] = val\n hash\n end\n end\n end",
"def parse_response(data)\n response = {}\n CGI.parse(data).each do |key, value|\n if value.length == 1\n value = value[0]\n end\n response[key.to_sym] = value\n end\n response\n end",
"def parse_header( data )\n k,v = data.split(\"\\0\", 2)\n return [k, v.delete(\"\\0\")]\n end",
"def parse_atx_header; end",
"def parse_header(header_line)\n entries = delete_special_chars(header_line)\n # switch entries for geo coordinates since latitude comes before longitude\n geo_coordinate = Entity::Coordinate.new(entries[6].to_f, entries[5].to_f)\n @grid_data = Entity::GridPoint.new(entries[8].to_f, entries[9].to_f,\n entries[12].to_f, entries[11].to_f)\n # special case for multi word locations\n station_name = entries[0].sub(\"_\", \" \")\n @station = Entity::Station.new(station_name, entries[3], entries[13].to_f,\n geo_coordinate)\n nil\n end",
"def parse_response(data)\n doc = REXML::Document.new(data)\n\n values = {}\n\n elements = doc.elements[\"/OPS_envelope/body/data_block/dt_assoc\"].select { |item|\n item.is_a? REXML::Element\n }\n\n build_xml_hash(elements)\n end",
"def extract_data( page )\n strip_tags page[:content]\n\n #extract_concepts( page[:title] , page , LOC_TITLE ) if page[:title] && page[:title] !=~ PTN_EMPTY\n if page[:tag] && page[:tag] !=~ PTN_EMPTY\n page[:tag] = page[:tag].split(SEP_TAG).map{|e|\"[[\"+e+\"]]\"}.join(\";\")\n extract_concepts( page[:tag] , page , LOC_TAG )\n end\n\n extract_concepts( page[:title] , page , LOC_TITLE)\n extract_concepts( page[:content] , page )\n extract_resources( page[:content] , page )\n end",
"def actual_header\n data.lines.first.chomp\n end",
"def first\n header_data\n end",
"def import_page_data\n page_json = RestClient.get(@page_url)\n hash = JSON.parse(page_json)\n hash\n end",
"def parse_from_summary(data)\n {} # nothing for college\n end",
"def parse_header(line)\n if (match = line.match(/^(.+?):\\s*(.+)#{@nl}$/))\n key = match[1].downcase\n set_header_special_values(key, match[2])\n parse_normal_header(line, key, match[1], match[2])\n elsif (match = line.match(/^HTTP\\/([\\d\\.]+)\\s+(\\d+)\\s+(.+)$/))\n @response.code = match[2]\n @response.http_version = match[1]\n @http2.on_content_call(@args, line)\n else\n raise \"Could not understand header string: '#{line}'.\"\n end\n end",
"def parse(data); end",
"def parse_header(string)\n {\n # identificação do registro header (conteúdo 0)\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # código da empresa no bradesco\n :codigo_empresa => string[26..45].strip,\n # razão social da empresa\n :razao_social => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => convert_date(string[94..99]),\n # brancos\n #:brancos1 => string[100..107],\n # número aviso bancário\n :numero_aviso_bancario => string[108..112],\n # brancos\n #:brancos2 => string[113..378],\n # data de crédito dos lançamentos\n :data_credito => convert_date(string[379..384]),\n # brancos\n #:brancos3 => string[385..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def parse_header_lines\n if @parsed_values[\"\"].nil? || @parsed_values[\"\"][1].nil?\n @parsed_values[\"\"] = {}\n return\n end\n\n headers = {}\n # Heading lines may have escaped newlines in them\n @parsed_values[\"\"][1].split(/\\\\n/).each do |line|\n next if line.size == 0\n\n if line =~ /(.*?):(.*)/\n key, value = $1, $2\n if headers[key] && headers[key].size > 0\n @errors << [\"Duplicate header line: #{line}\"]\n elsif key =~ /#-#-#-#-#/\n @errors << [\"Marker in header line: #{line}\"]\n else\n headers[key] = value\n end\n else\n @errors << [\"Malformed header #{line}\"]\n end\n end\n\n @parsed_values[\"\"] = headers\n end",
"def test_parse_response_body_returns_expected_format\n response_body_to_json = @data_parser.parse_response_body(@page)\n assert_equal Hash, response_body_to_json.class\n end",
"def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = normalize(header)\n headers[header] = value\n end\n \n return headers\n end",
"def data\n @data ||= section.elf.section_at(header.st_shndx).data[header.st_value, header.st_size]\n end",
"def parse_header_contents\n text = @src[\"contents\"]\n text.rstrip!\n id_match = HEADER_ID.match(text)\n if id_match\n id = id_match[\"id\"]\n text = text[0...-id_match[0].length]\n text.rstrip!\n end\n [text, id]\n end",
"def parse_header(line)\n case line\n when /^#%checkm/\n match = /^#%checkm_(\\d+)\\.(\\d+)/.match line\n @version = \"#{match[1]}.#{match[2]}\" if match\n when /^#%eof/\n @eof = true\n when /^#%fields/\n list = line.split('|')\n list.shift\n @fields = list.map { |v| v.strip.downcase }\n when /^#%prefix/, /^#%profile/\n # do nothing\n end\n end",
"def _extract_headers(str)\n \n asa = str.split(AMP)\n @headers = {}\n esa = nil\n hv = nil\n asa.each do |hdr|\n esa = hdr.split(EQL)\n hname = SipperUtil.methodize(esa[0])\n if esa[1]\n \n if esa[1] =~ DQ\n hv = esa[1][1...-1]\n else\n hv = esa[1]\n end\n hv = CGI.unescape(hv)\n @headers[hname] = SipperUtil.find_parser_and_parse(hname, hv, true)\n end \n end \n end",
"def parse_setext_header; end",
"def test_data_headers(string)\n\n\t\theaders = test_data_response(string).headers\n\n\tend",
"def parse_header\n @snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(\" \") \n @type = @type.to_sym\n if @in\n @in = @in.to_sym == :exon \n else\n @exon = false\n end\n\n if @polymorphism.to_sym == :homoeologous\n @homoeologous = true\n else\n @homoeologous = false\n end\n @parsed = true\n @orientation = @orientation.to_sym\n end",
"def parse_date\n # must access headers via @headers. Using h() would case a stack overflow\n # because parsing isn't yet complete, the page is still 'fresh'.\n if @headers[:date] \n @date = Chronic.parse(@headers[:date])\n elsif @title =~ /:/ && @date.nil?\n plausible_date = @title.split(':').first\n @date = Chronic.parse(plausible_date)\n unless @date\n date_regexp = /\\s*(\\d\\d?)-([a-zA-Z]{3})\\s*/\n match = date_regexp.match(plausible_date)\n @date = Chronic.parse(\"#{match[2]} #{match[1]}\") if match\n end\n if @date\n @title.sub!(/^[^:]*:/, '')\n end\n end\n end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def read_data_block_header\n DataBlockHeader.parse(\n read_payload(Format::Current::DATA_BLOCK_HEADER_SIZE)\n )\n end",
"def parse_header(raw)\n header = {}\n field = nil\n\n raw.each_line do |line|\n case line\n when /^([A-Za-z0-9!\\#$%&'*+\\-.^_`|~]+):\\s*(.*?)\\s*\\z/om\n field, value = $1, $2\n header[field] = value\n when /^\\s+(.*?)\\s*\\z/om\n value = $1\n fail \"bad header '#{line}'.\" unless field\n\n header[field][-1] << ' ' << value\n else\n fail \"bad header '#{line}'.\"\n end\n end\n\n header.each do |key, value|\n value.strip!\n value.gsub!(/\\s+/, ' ')\n end\n\n header\n end",
"def html_parse_hash(headers, size, headers_size)\n headers_index = headers.find_index { |x| x.count == headers_size }\n order = headers[headers_index]\n order_index = order.count - size\n order = order[order_index..-1]\n indice = headers[headers_index+1..-1].flatten\n indice = nil if indice.to_a.empty?\n [order, indice]\n end",
"def parse_a_page(ctx, page_text)\n return nil if ctx.nil? \n return nil if page_text.nil? \n\n perf_cal = JSON.parse(page_text, :symbolize_names => true)\n\n perfs = []\n perf_cal[:weeks].each do |perfs_of_week|\n perfs_of_week.each do |perfs_of_day|\n\n perfs_of_day[:performances].each do |perf|\n perfs << {\n :DATETIME => perf[:date] + ' ' + perf[:time],\n :TITLE => perf[:title],\n :HALL => (perf[:hall] == '1' ? 'C' : 'R'),\n :DETAILS => (perf[:is_available_detail] ? \n BASE_URL_OF_DETAILS + perf[:detail_link_uri] : nil)\n }\n end\n end\n end\n\n return perfs\nend",
"def parse_a_page(ctx, page_text)\n return nil if ctx.nil? \n return nil if page_text.nil? \n\n perf_cal = JSON.parse(page_text, :symbolize_names => true)\n\n perfs = []\n perf_cal[:weeks].each do |perfs_of_week|\n perfs_of_week.each do |perfs_of_day|\n\n perfs_of_day[:performances].each do |perf|\n perfs << {\n :DATETIME => perf[:date] + ' ' + perf[:time],\n :TITLE => perf[:title],\n :HALL => (perf[:hall] == '1' ? 'C' : 'R'),\n :DETAILS => (perf[:is_available_detail] ? \n BASE_URL_OF_DETAILS + perf[:detail_link_uri] : nil)\n }\n end\n end\n end\n\n return perfs\nend",
"def scrape_header_row(row)\n header = row.text.match(/\\d+\\.\\s+(?<title>.+)\\s\\(?(?<site>[\\w.]+)?\\)?/)\n\n { title: header[:title], site: header[:site] }\n end",
"def hash\n @hash ||= opts[:parser].parse(data.to_s.gsub(/\\<!\\[CDATA\\[([^\\]]+)\\]\\]\\>/) {$1})\n end",
"def parse_data(metadata)\n data=Hash.new\n data['hostname'][email protected]\n\n [email protected]\n data['name']=metricname\n\n data['spoof'][email protected]\n data['format'][email protected]\n\n metrictype=name_to_type(metricname,metadata)\n\n if metrictype.nil?\n # Probably we got a data packet before a metadata packet\n #puts \"Received datapacket without metadata packet\"\n return nil\n end\n\n data['val']=parse_value(metrictype)\n\n # If we received a packet, last update was 0 time ago\n data['tn']=0\n return data\n end",
"def parse_response_headers\n return {} if response_headers.empty?\n\n lines = response_headers.split(\"\\n\")\n\n lines = lines[1..(lines.size - 1)] # Remove Status-Line and trailing whitespace.\n\n # Find only well-behaved HTTP headers.\n lines.map do |line|\n header = line.split(':', 2)\n header.size != 2 ? nil : header\n end.compact.to_h\n end",
"def parse(text)\n text.split(\"\\n\").each do |line|\n if line =~ /^.*\\:.*$/\n s = line.split(\":\")\n \n key = s[0].strip\n value = s[1].strip\n \n @headers[key] = value\n else\n s = line.split\n \n @http_version = s[0]\n @status = s[1].to_i\n @response_text = s[2]\n end\n end\n end",
"def load_headers\n @headers = @rows[COLUMNS_ROW].xpath('td').map(&:text).pop\n end",
"def parse_metadata(metadata)\n\t{\n :name => metadata[:name],\n :url => metadata[:href],\n :catalog_name => \"utah.gov\",\n :catalog_url => @base_uri,\n :org_type => \"governmental\",\n :organization => { :name => \"Utah\" },\n\n\t}\n end",
"def parse_for_header\n expect(:KW_FOR)\n expect(:L_PARANTH)\n header = parse_for_condition\n expect(:R_PARANTH)\n\n header\n end",
"def data\n data = Jhead.call(@match, @pattern).split(\"\\n\\n\").map { |p| p.split(\"\\n\") }\n data.map! do |p|\n h = Hash.new\n p.each do |l|\n #OPTIMIZE for the moment, ignore line:\n # \"======= IPTC data: =======\" and its following lines.\n break if l == \"======= IPTC data: =======\"\n if l =~ /(.+?)\\s*:\\s*(.+)/\n h[parse_tag $1] = parse_value $2\n end\n end\n h\n end\n\n data.size == 1 ? data.first : data\n end",
"def parse(data)\n new_data = {}\n\n unless data =~ /\\n/\n log \"Received response as a single-line String. Discarding.\"\n log \"Bad response looked like:\\n#{data}\"\n return new_data\n end\n\n data.each_line do |line|\n line =~ /(\\S*):(.*)/\n\n unless $1.nil?\n key = $1\n value = $2\n key = key.gsub('-', '_').downcase.to_sym\n new_data[key] = value.strip\n end\n end\n\n new_data\n end",
"def gml_header\n # Rails.logger.debug \"Tag #{id}: gml_header\"\n # doc = self.class.read_gml_header(self.gml)\n doc = gml_document\n\n if doc.nil? || (doc/'header').nil?\n Rails.logger.error \"Tag#gml_header: NIL OR NO HEADER DOC\"\n return {}\n end\n\n attrs = {}\n attrs[:filename] = (doc/'header'/'filename')[0].text rescue nil\n\n # whitelist approach -- explicitly name things\n client = (doc/'header'/'client')[0] rescue nil\n attrs[:gml_application] = (client/'name').text rescue nil\n attrs[:gml_username] = (client/'username').text rescue nil\n attrs[:gml_keywords] = (client/'keywords').text rescue nil\n attrs[:gml_uniquekey] = (client/'uniqueKey').text rescue nil\n\n # Non-gml_ prefixed fields...\n attrs[:location] = (client/'location').text rescue nil # this could also be in <drawing>\n\n # encode the uniquekey with SHA-1 immediately\n # FIXME this slows this method down significantly -- denormalize whole hash to the model on save...?\n attrs[:gml_uniquekey_hash] = self.class.hash_uniquekey(attrs[:gml_uniquekey]) unless attrs[:gml_uniquekey].blank?\n\n return attrs\n end",
"def page_body\n JSON.parse(page.body, symbolize_names: true)\n end",
"def parse_metadata_body(body)\n body.lines.each_with_object({}) do |line, hsh|\n k, v = line.strip.split\n hsh[k.to_sym] = v\n end\n end",
"def parse\n @file_data.each {|line|\n h = {}\n data_elements = line.split('|').collect(&:strip)\n #LastName | FirstName | MiddleInitial | Gender | FavoriteColor | DateOfBirth\n @data_collection << {:last_name => data_elements[0], :first_name => data_elements[1], :middle_initial => data_elements[2], :gender => (data_elements[3] == 'M') ? 'Male' : 'Female', :favorite_color => data_elements[4], :dob => data_elements[5].gsub('-', '/'), :dob_year => data_elements[5][-4,4]}\n }\n end",
"def parse_data_packet(packet)\n { :data => packet.read_string }\n end",
"def parse_heading(heading)\n captures = { \"version\" => nil, \"url\" => nil, \"date\" => nil }\n\n @heading_structures.each do |regexp|\n matches = Regexp.new(regexp).match(heading)\n if matches\n captures.merge!(Hash[matches.names.zip(matches.captures)])\n break\n end\n end\n\n captures\n end",
"def parse( data )\n Hashie::Mash.new( \n Hash.from_xml( data ) )\n end",
"def parse_header(row)\r\n @first_month = 0 # January.\r\n row.each do |col|\r\n next unless col.nil?\r\n index = Date::MONTHNAMES.index(col.strip)\r\n unless index.nil?\r\n @first_month = index\r\n break\r\n end\r\n end\r\n @header_parsed = true\r\n end",
"def parse_header(string)\n {\n # identificação do registro header\n :tipo_registro => string[0..0].to_i,\n # identificação do arquivo retorno\n :codigo_retorno => string[1..1],\n # identificação por extenso do tipo de movimento\n :literal_retorno => string[2..8],\n # identificação do tipo de serviço\n :codigo_servico => string[9..10],\n # identificação por extenso do tipo de serviço\n :literal_servico => string[11..25],\n # agência mantenedora da conta\n :agencia => string[26..29],\n # complemento de registro\n :zeros => string[30..31],\n # número da conta corrente da empresa\n :conta => string[32..36],\n # dígito de auto-conferência ag/conta empresa\n :dac => string[37..37],\n # complemento do registro\n #:brancos1 => string[38..45],\n # nome por extenso da \"empresa mãe\"\n :nome_empresa => string[46..75],\n # número do banco na câmara de compensação\n :codigo_banco => string[76..78],\n # nome por extenso do banco cobrador\n :nome_banco => string[79..93].strip,\n # data de geração do arquivo\n :data_geracao => string[94..99],\n # unidade de densidade\n :densidade => string[100..104],\n # densidade de gravação do arquivo\n :unidade_densidade => string[105..107],\n # número sequencial do arquivo retorno\n :numero_sequencial_arquivo_retorno => string[108..112],\n # data de crédito dos lançamentos\n :data_credito => string[113..118],\n # complemento do registro\n #:brancos2 => string[119..393],\n # número sequencial do registro no arquivo\n :numero_sequencial => string[394..399]\n }\n end",
"def parse(data)\n\t\t\t\tif @finished # Header finished, can only be some more body\n\t\t\t\t\t@body << data\n\t\t\t\telse # Parse more header using the super parser\n\t\t\t\t\t@data << data\n\t\t\t\t\tif data =~ /\\r?\\n\\r?\\n/\n\t\t\t\t\t\theaders, @body = @data.split(/\\r?\\n\\r?\\n/,2)\n\t\t\t\t\t\theaders = headers.split(/\\r?\\n/)\n\t\t\t\t\t\trequest = headers.shift\n\t\t\t\t\t\theaders.each do |h|\n\t\t\t\t\t\t\tk,v=h.split(/:\\s*/,2);\n\t\t\t\t\t\t\tk = k.upcase.gsub(/\\-/,'_')\n\t\t\t\t\t\t\t@headers[k] = v\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@headers['CONTENT_LENGTH'] = (@headers['CONTENT_LENGTH']) ? @headers['CONTENT_LENGTH'].to_i : 0\n\t\t\t\t\t\t@verb, @fullpath, @httpver = request.split(/ /)\n @uri = URI.parse(@fullpath)\n if @uri.query\n @query_hash = Hash[*@uri.query.split(/&/).map {|x| x.split(/=/,2)}.flatten]\n end\n\t\t\t\t\t\t@finished = true\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif finished? # Check if header and body are complete\n\t\t\t\t\t@data = nil\n\t\t\t\t\ttrue # Request is fully parsed\n\t\t\t\telse\n\t\t\t\t\tfalse # Not finished, need more data\n\t\t\t\tend\n\t\t\tend",
"def parse( page )\n { }.tap do |result|\n sections_for( page ).each do |title, table|\n result[ format.title title ] = format.table table\n end\n end\n end",
"def parse_page_file\n raise \"File not found: #{@pointer['realpath']}\" unless File.exist?(@pointer['realpath'])\n\n page = File.open(@pointer['realpath'], 'r:UTF-8') {|f| f.read }\n\n begin\n front_matter = page.match(FMregex)\n rescue => e\n raise \"Error trying to read meta-data from #{@pointer['realpath']}.\" +\n \" Check your folder configuration. Error details: #{e}\"\n end\n \n data = front_matter ?\n (YAML.load(front_matter[0].gsub(/---\\n/, \"\")) || {}) :\n {}\n\n result = {\n \"data\" => data,\n \"content\" => page.gsub(FMregex, '')\n }\n\n # variable cache\n @data = data\n @content = result['content']\n\n result\n rescue Psych::SyntaxError => e\n Ruhoh.log.error(\"Psych::SyntaxError while parsing top YAML Metadata in #{ @pointer['realpath'] }\\n\" +\n \"#{ e.message }\\n\" +\n \"Try validating the YAML metadata using http://yamllint.com\"\n )\n nil\n end",
"def parse_content\n entries = []\n headers = Hash.new(0)\n\n # TODO: Use kramdown auto ids\n @doc.css(toc_headings).each do |node|\n text = node.text\n id = text.downcase\n id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation\n id.gsub!(' ', '-') # replace spaces with dash\n\n uniq = headers[id] > 0 ? \"-#{headers[id]}\" : ''\n headers[id] += 1\n header_content = node.children.first\n next unless header_content\n\n entries << {\n id: id,\n uniq: uniq,\n text: text,\n node_name: node.name,\n content_node: header_content,\n h_num: node.name.delete('h').to_i\n }\n end\n\n entries\n end",
"def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end",
"def parse_metadata\n meta=Hash.new\n meta['hostname'][email protected]\n meta['name'][email protected]\n meta['spoof'][email protected]\n meta['type'][email protected]\n meta['name2'][email protected]\n meta['units'][email protected]\n [email protected]\n\n case slope\n when 0\n meta['slope']= 'zero'\n when 1\n meta['slope']= 'positive'\n when 2\n meta['slope']= 'negative'\n when 3\n meta['slope']= 'both'\n when 4\n meta['slope']= 'unspecified'\n end\n\n meta['tmax'][email protected]\n meta['dmax'][email protected]\n [email protected]\n meta['nrelements']=nrelements\n unless nrelements.nil?\n extra={}\n for i in 1..nrelements\n [email protected]\n extra[name][email protected]\n end\n meta['extra']=extra\n end\n return meta\n end",
"def parse(data)\n\n # convert to utf-8\n data_utf8 = data.encode('UTF-8', :invalid => :replace, :replace => \"\")\n\n # split into nice rows\n rows = data_utf8.split(/\\r\\n?|\\n/)\n\n # to store units info\n units = {}\n\n # read values, store each doc in array\n docs = []\n\n rows.each do |row|\n doc = {}\n row.split(/\\s+|\\\\t+/).each_with_index do |value, index|\n if index < @@header.length\n name = @@header[index]\n if !value.nil? and !value.empty?\n # try to see if this can be a float\n begin\n value = Float(value.gsub(',', '.'))\n rescue ArgumentError\n end\n\n doc[name] = value\n end\n end\n end\n\n # point to our schema\n doc[\"schema\"] = \"http://api.npolar.no/schema/radiation-zeppelin-1.0-rc1\"\n\n docs << doc\n end\n\n docs\n end",
"def unpack_header(header)\n # fixed fields\n self.version = header.slice!(0)\n self.type = header.slice!(0)\n self.seq_no = header.slice!(0)\n self.flags = header.slice!(0)\n self.session_id = header.slice!(0..3)\n self.length = header.slice!(0..3)\n return(nil)\n end",
"def grab_header\n return @header if (@header and [email protected]?)\n @file.rewind\n fields.each_with_index do |field_name, i|\n @header[i]= field_name.strip\n end\n @header\n end",
"def parse_markup\n @html = PARSER.parse(@markup, :base_heading_level => 1)\n end",
"def parse_data(page)\n if $debug\n puts 'Opening local file.'\n begin\n f = File.open(\"html/research-it.html\")\n doc = Nokogiri::HTML(f)\n f.close\n rescue\n puts \"Failed to open research-it.html file.\"\n end\n else\n puts \"Opening: #{page}\"\n doc = Nokogiri::HTML(open(page))\n end\n\n doc.xpath('//h3/a').each do |record|\n url = record['href']\n name = record.content\n $lessons[url] = {}\n $lessons[url]['name'] = name\n page = Nokogiri::HTML(open(url))\n desc = page.xpath('//p')[1].content\n if desc == ''\n $lessons[url]['short_description'] = 'No description available at this time.'\n else\n $lessons[url]['short_description'] = desc\n end\n end\n\nend",
"def parse(data)\n if !data.respond_to?(:read)\n data = StringIO.new(data || '')\n end\n\n char = data.getc\n if char.nil?\n {}\n else\n data.ungetc(char)\n LibXML::XML::Parser.io(data).parse.to_hash\n end\n end",
"def extract_torrent(unparsed_data)\n hsh = Hash.new\n\n hsh[:name] = unparsed_data.css('td')[1].text\n hsh[:magnet_url] = unparsed_data.css('td').css('a')[1].attr('href')\n hsh[:url] = unparsed_data.css('td').css('a').attr('href')\n hsh[:size] = unparsed_data.css('td')[3].text\n hsh[:seeders] = unparsed_data.css('td')[4].text.to_i\n hsh[:leeches] = unparsed_data.css('td')[5].text.to_i\n\n hsh[:tracker] = assigned_site.name\n\n Torrent.new hsh\n end",
"def load_data(data)\n data.symbolize_keys!\n\n @id = data[:id] || nil\n @name = data[:name]\n @color = data[:color]\n @indent = data[:indent]\n @item_order = data[:item_order]\n end",
"def parse835(first_line) read_header(first_line).read_parties.read_details.read_adjustments.read_trailer; end",
"def front\n header_data\n end",
"def page_header\n @page_header ||= cursor(pos_index_header).name(\"index\") do |c|\n index = PageHeader.new(\n n_dir_slots: c.name(\"n_dir_slots\") { c.read_uint16 },\n heap_top: c.name(\"heap_top\") { c.read_uint16 },\n n_heap_format: c.name(\"n_heap_format\") { c.read_uint16 },\n garbage_offset: c.name(\"garbage_offset\") { c.read_uint16 },\n garbage_size: c.name(\"garbage_size\") { c.read_uint16 },\n last_insert_offset: c.name(\"last_insert_offset\") { c.read_uint16 },\n direction: c.name(\"direction\") { PAGE_DIRECTION[c.read_uint16] },\n n_direction: c.name(\"n_direction\") { c.read_uint16 },\n n_recs: c.name(\"n_recs\") { c.read_uint16 },\n max_trx_id: c.name(\"max_trx_id\") { c.read_uint64 },\n level: c.name(\"level\") { c.read_uint16 },\n index_id: c.name(\"index_id\") { c.read_uint64 }\n )\n\n index.n_heap = index.n_heap_format & ((2**15) - 1)\n index.format = (index.n_heap_format & (1 << 15)).zero? ? :redundant : :compact\n\n index\n end\n end",
"def title() headers['title'] end",
"def header\n @result['_header']\n end",
"def scrape_meta_data\n unless @data.meta\n @data.meta!.name!\n @data.meta!.property!\n parsed_document.xpath(\"//meta\").each do |element|\n get_meta_name_or_property(element)\n end\n end\n end",
"def parse(rawdata)\n end",
"def get_data\n response = fetch\n if response \n if response.header.code == \"200\"\n doc = Nokogiri::HTML(response.body)\n self.title = doc.title.to_s\n content_description = doc.xpath(\"//meta[@name='description']/@content\")\n # Some people use the wrong capitlization\n if content_description.blank?\n content_description = doc.xpath(\"/html/head/meta[@name='Description']/@content\")\n end\n unless content_description.blank?\n self.description = content_description.to_s\n end\n content_keywords = doc.xpath(\"//meta[@name='keywords']/@content\").to_s\n if content_keywords.blank?\n content_keywords = doc.xpath(\"//meta[@name='Keywords']/@content\").to_s\n end\n \n self.tag_names = content_keywords unless content_keywords.blank?\n self.data_recived_on = Time.now\n end\n self.code = response.header.code.to_i\n else\n self.code = 502\n end\n return response\n end",
"def parse_headers raw_headers\n\t\theaders = Hash.new\n\n\t\t# Store values as hash, but don't include duplicate values\n\t\tremove_fws(raw_headers).map do |line|\n\t\t\tkey, value = line.split(\": \", 2)\n\t\t\theaders[key] ||= []\n\t\t\theaders[key] << value unless headers[key].include? value\n\t\tend\n\n\t\t# Pop value from array if there's only one value\n\t\theaders.each{ |key, value| headers[key] = value.pop if value.length == 1 }\n\tend",
"def header_data\n\t\treturn self.normalized_headers.to_s\n\tend",
"def parse_response\n parse_address()\n parse_expires()\n parse_token_type()\n parse_token()\n end",
"def [](header)\n data[header]\n end",
"def parse_profile\n load_profile_data\n # get the buddies\n @buddies = @profile_data.search(\"div[@class='buddies']//a\").map{|b| b['href'].split('/').last; }\n @buddies.reject!{|b| b.to_i == 0}\n # title and genre are in the same element\n titlegenre = @profile_data.search(\"div[@class='titlegenre']\").text.split(\"Genre:\")\n unless titlegenre.empty?\n @genre[:name] = titlegenre.last.strip\n @novel[:title] = titlegenre.first.gsub('Novel:','').strip\n else\n @genre[:name] = \"\"\n @novel[:title] = \"\"\n end\n # finally, the region is annoying to grab\n @rid = @profile_data.search(\"div[@class='infoleft']//a\").first['href'].split('/').last\n nil\n end",
"def get_content_needed(key, page)\n\t\t\tcontent_hash = Hash.new\n\n\t\t\t@data_to_render.each do |symbol|\n\t\t\t\tcontent_hash[convert_symbol_to_header(symbol)] = get_content_for_page_and_symbol(key, page, symbol)\n\t\t\tend\n\n\t\t\tcontent_hash\n\t\tend",
"def processed_data\n @processed_data ||= process_dict(Nokogiri::XML(data).xpath('//plist/dict').first)\n end",
"def process_link_header(response)\n\n linkheader = LinkHeader.parse(response.headers[:link]).to_a\n\n next_link, last_link = nil, nil\n\n #### extract the interesting header links\n linkheader.each { |link|\n next_link ||= header_link_for_rel(link, 'next')\n last_link ||= header_link_for_rel(link, 'last')\n }\n\n # If there is more data on another page log that.\n if !next_link.nil?\n page_estimate = \"\"\n # Log last_page and per_page values from the 'last' url so can get rough estimate of total number of\n # entries for query. Note: We use the page/per_page information because it turns out that Canvas puts that\n # in the URL. However that isn't a standard and we shouldn't rely on it for processing.\n if !last_link.nil?\n p = Regexp.new(/page=(\\d+)&per_page=(\\d+)/)\n p.match(last_link)\n last_page, per_page = $1, $2\n page_estimate = \"last_page: #{last_page} page_size: #{per_page} \"\n end\n logger.warn \"#{self.class.to_s}:#{__method__}:#{__LINE__}: pagination: #{page_estimate} next_link: #{next_link}\"\n end\n\n # return the raw next link (or an empty string)\n next_link.nil? ? \"\" : next_link\n end",
"def parse(data)\n if !data.respond_to?(:read)\n data = StringIO.new(data || \"\")\n end\n\n if data.eof?\n {}\n else\n LibXML::XML::Parser.io(data).parse.to_hash\n end\n end",
"def sniff\n html = Kramdown::Document.new(data[0, 512], auto_ids: false,\n smart_quotes: ['apos', 'apos', 'quot', 'quot'],\n typographic_symbols: { hellip: '...', ndash: '--', mdash: '--' }).to_html\n heading, html = html.split(\"</h1>\\n\", 2)\n return [nil, nil, nil] if html.nil?\n\n case heading\n when /([\\w_.\\[\\]~+=@:-]+)\\s*\\((\\d\\w*)\\)\\s*-+\\s*(.*)/\n # name(section) -- description\n [$1, $2, $3]\n when /([\\w_.\\[\\]~+=@:-]+)\\s+-+\\s+(.*)/\n # name -- description\n [$1, nil, $2]\n else\n # description\n [nil, nil, heading.sub('<h1>', '')]\n end\n end",
"def parse_headers!(block)\n headers.each { |header| block.call(header.key, parse_value(header.value)) }\n end",
"def parse(data, compact)\n magic = data[0..3]\n raise InvalidHeader, \"No magic bytes found at start\" unless %w( SDPX XPDS).include?(magic)\n \n is_le = (magic == \"XPDS\")\n \n version_check = FileInfo.only(:magic, :version)\n begin\n result = is_le ? version_check.apply_le!(data) : version_check.apply!(data)\n raise InvalidHeader, \"Unknown version tag #{result.version}\" unless result.version =~ /V(\\d)\\.(\\d+)/i\n rescue ArgumentError\n raise InvalidHeader, \"Cannot unpack header\"\n end\n \n struct = compact ? CompactDPX : DPX\n is_le ? struct.apply_le!(data) : struct.apply!(data)\n end",
"def parse(body)\n results = ActiveSupport::HashWithIndifferentAccess.new\n body.split(/[\\r\\n]+/).each do |pair|\n key, val = pair.split(\": \")\n results[key.downcase] = val\n end\n results\n end",
"def parse_first_header(line)\n\n # split the line into: METHOD URI PROTOCOL\n # eg: GET / HTTP/1.1\n parsed = line.split(' ')\n\n # a correct request has three parts\n return bad_parsing unless parsed.size == 3\n\n @http_request_method, uri, @http_protocol = parsed\n\n # optional query string\n @http_request_uri, @http_query_string = uri.split('?')\n end"
] | [
"0.6742138",
"0.6672907",
"0.6566992",
"0.6279731",
"0.616502",
"0.6050409",
"0.6028795",
"0.6001625",
"0.6000103",
"0.5929474",
"0.5910416",
"0.5905324",
"0.5901847",
"0.5871764",
"0.58646333",
"0.5839426",
"0.57999176",
"0.5737371",
"0.57308865",
"0.57233626",
"0.5701291",
"0.56955546",
"0.5694315",
"0.5677855",
"0.5669147",
"0.5661606",
"0.56290245",
"0.5628636",
"0.562439",
"0.5622918",
"0.55970854",
"0.55815905",
"0.55659384",
"0.5547428",
"0.55153507",
"0.551495",
"0.551339",
"0.5498385",
"0.5493311",
"0.5490757",
"0.54891175",
"0.54640156",
"0.54476595",
"0.5442843",
"0.5442843",
"0.5441245",
"0.54288125",
"0.5406613",
"0.54038745",
"0.53911895",
"0.539052",
"0.53746873",
"0.5372406",
"0.53708625",
"0.5331555",
"0.5330647",
"0.5330329",
"0.53256166",
"0.5319931",
"0.5312737",
"0.53119504",
"0.5309942",
"0.53086567",
"0.5304195",
"0.5292879",
"0.5292102",
"0.5281623",
"0.5278209",
"0.52650845",
"0.5263369",
"0.5253687",
"0.5253683",
"0.52309597",
"0.52298886",
"0.5214582",
"0.52107316",
"0.5194789",
"0.5193838",
"0.51865095",
"0.51846343",
"0.5181521",
"0.5181481",
"0.5172786",
"0.5167856",
"0.5161765",
"0.5156961",
"0.51540023",
"0.51524466",
"0.5149553",
"0.51442415",
"0.51379",
"0.5137876",
"0.51224834",
"0.51186",
"0.51151526",
"0.5113813",
"0.51092374",
"0.51016796",
"0.5099388",
"0.50902224"
] | 0.6072086 | 5 |
Must redefine this because anonymous objects can't be passed in/out/through Rubyspace. | def create(parents = nil, *args)
case parents
when Array
parents = '{' + parents.map { |p| obj_ref(p) }.join(', ') + '}'
else
parents = obj_ref(parents)
end
p = rand(36**5).to_s(36)
unless args.empty?
args = args.map { |a| value_ref(a) }.join(', ')
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}, #{args}), {player, "rw"}); return "#{@obj}._#{p}";|))
else
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}), {player, "rw"}); return "#{@obj}._#{p}";|))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anonymous?; end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def wrapped_in=(_arg0); end",
"def body=(_arg0); end",
"def body=(_arg0); end",
"def call(object); end",
"def bind_to_object=(_arg0); end",
"def writethis; end",
"def isolated=(_arg0); end",
"def isolated=(_arg0); end",
"def *(obj)\n raise 'Not Implemented'\n end",
"def outer; end",
"def wrap(object); end",
"def object_name=(_arg0); end",
"def objects; end",
"def closure! \n end",
"def jeweler=(_arg0); end",
"def jeweler=(_arg0); end",
"def jeweler=(_arg0); end",
"def owner=(_arg0); end",
"def owner=(_arg0); end",
"def __getobj__; end",
"def __getobj__\n end",
"def public=(_arg0); end",
"def __object\n __value\n end",
"def raw=(_arg0); end",
"def raw=(_arg0); end",
"def object_nl()\n #This is a stub, used for indexing\n end",
"def extra=(_arg0); end",
"def name=(o); end",
"def anonymous_safelists; end",
"def method(obj)\n a = 1\n obj\nend",
"def literal_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName\n # Ignore any other object types\n end",
"def assignCurator _obj, _args\n \"_obj assignCurator _args;\" \n end",
"def obj\n self\n end",
"def object\n raise NotImplementedError\n end",
"def __setobj__(obj); end",
"def wrapper; end",
"def custom; end",
"def custom; end",
"def object\n nil\n end",
"def initialize(*) \n end",
"def ob\n return self.class.ob\n end",
"def signature=(_); end",
"def signature=(_); end",
"def reserved=(_arg0); end",
"def node=(_arg0); end",
"def __delegate\n@o\nend",
"def isolated; end",
"def isolated; end",
"def standalone=(_arg0); end",
"def interface=(_arg0); end",
"def anonymous_blocklists; end",
"def herebody_s=(_arg0); end",
"def expose=(_arg0); end",
"def plain_old_ruby_object\n\t\treturn false\n\tend",
"def ruby_code(obj); end",
"def delegate_object; end",
"def anonymous_function(block)\n lambda do |*args|\n # args: (this, node) v8 >= 0.10, otherwise (node)\n raise ArgumentError, \"missing node\" if args.empty?\n @tree[:Anonymous].new block.call(@tree, args.last)\n end\n end",
"def private; end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def dynamic=(_arg0); end",
"def under_construction\n end",
"def methods=(_arg0); end",
"def initialize(obj); end",
"def binder; end",
"def binder; end",
"def probers=(_arg0); end",
"def base=(_arg0); end"
] | [
"0.6694541",
"0.6332925",
"0.6332925",
"0.6332925",
"0.6332925",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6280461",
"0.6115622",
"0.581167",
"0.581167",
"0.57735014",
"0.5743547",
"0.5727063",
"0.5720367",
"0.5720367",
"0.5701037",
"0.56604975",
"0.5599075",
"0.5554583",
"0.55475587",
"0.5534313",
"0.5524163",
"0.5524163",
"0.5524163",
"0.5523258",
"0.5523258",
"0.5519059",
"0.5514395",
"0.54937685",
"0.54819125",
"0.5476066",
"0.5476066",
"0.5475156",
"0.54545254",
"0.54505277",
"0.54450685",
"0.54427516",
"0.54378647",
"0.543374",
"0.5421209",
"0.5417245",
"0.5399175",
"0.53976744",
"0.53635955",
"0.53635955",
"0.5356695",
"0.5344937",
"0.5344448",
"0.53415877",
"0.53415877",
"0.53326154",
"0.53302526",
"0.53181493",
"0.5300101",
"0.5300101",
"0.52996886",
"0.52994895",
"0.529443",
"0.5287913",
"0.5286758",
"0.52728343",
"0.5262798",
"0.5260843",
"0.52534944",
"0.5251768",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5248609",
"0.5246536",
"0.5246536",
"0.5246536",
"0.5246536",
"0.5246536",
"0.5246044",
"0.5245677",
"0.52446175",
"0.52417713",
"0.5232646",
"0.5232646",
"0.5229936",
"0.5229078"
] | 0.0 | -1 |
Must redefine this because anonymous objects can't be passed in/out/through Rubyspace. | def create(parents, *args)
case parents
when Array
parents = '{' + parents.map { |p| obj_ref(p) }.join(', ') + '}'
else
parents = obj_ref(parents)
end
p = rand(36**5).to_s(36)
owner = nil
anon = nil
unless args.empty?
if args.length > 1
owner, anon = *args
elsif args[0].kind_of? Numeric
anon = args[0]
else
owner = args[0]
end
end
if !owner.nil? and !anon.nil?
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}, #{obj_ref(owner)}, #{value_ref(anon)}), {player, "rw"}); return "#{@obj}._#{p}";|))
elsif !owner.nil?
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}, #{obj_ref(owner)}), {player, "rw"}); return "#{@obj}._#{p}";|))
elsif !anon.nil?
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}, #{value_ref(anon)}), {player, "rw"}); return "#{@obj}._#{p}";|))
else
simplify(command(%Q|; add_property(#{@obj}, "_#{p}", create(#{parents}), {player, "rw"}); return "#{@obj}._#{p}";|))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anonymous?; end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object=(_arg0); end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def object; end",
"def wrapped_in=(_arg0); end",
"def body=(_arg0); end",
"def body=(_arg0); end",
"def call(object); end",
"def bind_to_object=(_arg0); end",
"def writethis; end",
"def isolated=(_arg0); end",
"def isolated=(_arg0); end",
"def *(obj)\n raise 'Not Implemented'\n end",
"def outer; end",
"def wrap(object); end",
"def object_name=(_arg0); end",
"def objects; end",
"def closure! \n end",
"def jeweler=(_arg0); end",
"def jeweler=(_arg0); end",
"def jeweler=(_arg0); end",
"def owner=(_arg0); end",
"def owner=(_arg0); end",
"def __getobj__; end",
"def __getobj__\n end",
"def public=(_arg0); end",
"def __object\n __value\n end",
"def raw=(_arg0); end",
"def raw=(_arg0); end",
"def object_nl()\n #This is a stub, used for indexing\n end",
"def extra=(_arg0); end",
"def name=(o); end",
"def anonymous_safelists; end",
"def method(obj)\n a = 1\n obj\nend",
"def literal_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName\n # Ignore any other object types\n end",
"def assignCurator _obj, _args\n \"_obj assignCurator _args;\" \n end",
"def obj\n self\n end",
"def object\n raise NotImplementedError\n end",
"def wrapper; end",
"def __setobj__(obj); end",
"def custom; end",
"def custom; end",
"def object\n nil\n end",
"def initialize(*) \n end",
"def ob\n return self.class.ob\n end",
"def signature=(_); end",
"def signature=(_); end",
"def reserved=(_arg0); end",
"def node=(_arg0); end",
"def __delegate\n@o\nend",
"def isolated; end",
"def isolated; end",
"def standalone=(_arg0); end",
"def interface=(_arg0); end",
"def anonymous_blocklists; end",
"def herebody_s=(_arg0); end",
"def expose=(_arg0); end",
"def plain_old_ruby_object\n\t\treturn false\n\tend",
"def ruby_code(obj); end",
"def delegate_object; end",
"def private; end",
"def anonymous_function(block)\n lambda do |*args|\n # args: (this, node) v8 >= 0.10, otherwise (node)\n raise ArgumentError, \"missing node\" if args.empty?\n @tree[:Anonymous].new block.call(@tree, args.last)\n end\n end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def context=(_arg0); end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def under_construction\n end",
"def dynamic=(_arg0); end",
"def methods=(_arg0); end",
"def initialize(obj); end",
"def binder; end",
"def binder; end",
"def base=(_arg0); end",
"def probers=(_arg0); end"
] | [
"0.6695099",
"0.6333414",
"0.6333414",
"0.6333414",
"0.6333414",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.62820977",
"0.6116823",
"0.58124524",
"0.58124524",
"0.5773099",
"0.5744188",
"0.57303536",
"0.5722006",
"0.5722006",
"0.57023793",
"0.5661211",
"0.5600157",
"0.5554409",
"0.55478126",
"0.5534339",
"0.5526339",
"0.5526339",
"0.5526339",
"0.5524878",
"0.5524878",
"0.552102",
"0.5516706",
"0.54963773",
"0.5484886",
"0.5477845",
"0.5477845",
"0.5476784",
"0.5456869",
"0.5450126",
"0.54445094",
"0.5442856",
"0.5438321",
"0.5432601",
"0.542416",
"0.54200816",
"0.5400733",
"0.5399741",
"0.5367385",
"0.5367385",
"0.5358177",
"0.5347749",
"0.53466344",
"0.5342024",
"0.5342024",
"0.53333884",
"0.53304535",
"0.53191257",
"0.53028655",
"0.53028655",
"0.53020394",
"0.5301734",
"0.5293976",
"0.52889806",
"0.5288336",
"0.5275813",
"0.5263513",
"0.52620655",
"0.52548736",
"0.525216",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.52507883",
"0.5249451",
"0.5249451",
"0.5249451",
"0.5249451",
"0.5249451",
"0.5248012",
"0.52479744",
"0.5246029",
"0.5242538",
"0.5234982",
"0.5234982",
"0.52323836",
"0.52312076"
] | 0.0 | -1 |
only permanent objects can have descendants | def test_that_add_property_fails_if_the_property_is_already_defined_on_a_descendant
run_test_as('programmer') do
x = simplify(command(%Q|; return create($nothing);|))
o = simplify(command(%Q|; return create(#{x});|))
add_property(o, 'foobar', 0, ['player', 'rw'])
assert_equal E_INVARG, add_property(x, 'foobar', 0, ['player', ''])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_children; end",
"def descendants_affected\n descendants\n end",
"def preserve_children?\n false\n end",
"def weaker\n descendants\n end",
"def descendants\n \t descendants = []\n \t self.children.each { |child|\n \t descendants += [child] if child.permitted?\n \t descendants += child.descendants\n \t } unless self.children.empty?\n \t descendants \n \tend",
"def children() []; end",
"def set_restrictions_to_child_pages\n self.descendants.map do |c|\n c.update_attributes(:restricted => self.restricted?)\n end\n end",
"def children\n child_check\n super\n end",
"def valid_children\n allowed_children_and_descendants.select {|child| child.allowed_parent?(self)}\n end",
"def ignore_parent_exclusion; end",
"def ignore_parent_exclusion?; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; end",
"def children; []; end",
"def is_only_child?\n return call_ancestry_method(:is_only_child?) if use_ancestry?\n\n relationships.all?(&:is_only_child?)\n end",
"def descendants\n without_self self_and_descendants\n end",
"def check_if_has_children\n self.lookups.count == 0\n end",
"def child_of?(parent); end",
"def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend",
"def descendants\n without_self self_and_descendants\n end",
"def restrict_when_referenced\n return false if nodes.count > 0\n end",
"def check_descendants!(device, mode: nil)\n raise NotImplementedError\n end",
"def restricted?\n ancestors.any?{|p| p.children_restricted?}\n end",
"def has_children?\n false\n end",
"def descendants\n @descendants ||= Set.new\n end",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def intend_children\n children.select { |child| !child.has_class :hidden }\n end",
"def children_exist?\n\tend",
"def root_relation?; !parent end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def has_children?\n self.children.size > 0 \n end",
"def get_children()\n {}\n end",
"def object\n object? ? children[2] : nil\n end",
"def weaker_or_equal\n Array(self) + descendants\n end",
"def one_instance_ancestors_cache; end",
"def matching_ancestors; end",
"def allowed_type?(parent_node); end",
"def is_childless?\n return call_ancestry_method(:is_childless?) if use_ancestry?\n\n relationships.all?(&:is_childless?)\n end",
"def all_children(special=nil)\n if special && special[:exclude]\n transaction do\n # exclude some items and all their children\n special[:exclude] = [special[:exclude]] if !special[:exclude].is_a?(Array)\n # get objects for ids\n special[:exclude].collect! {|s| s.is_a?(self.class) ? s : self.class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = special[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq.join(',')\n if exclude_list.blank?\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND id NOT IN (#{exclude_list}) AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end\n else\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} > #{self[acts_as_nested_set_options[:left_column]]}) and (#{acts_as_nested_set_options[:right_column]} < #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n end\n end",
"def child_objects(valkyrie: false)\n af_objects = Wings::ActiveFedoraConverter.new(resource: self).convert.objects\n return af_objects unless valkyrie\n af_objects.map(&:valkyrie_resource)\n end",
"def children\n self.class.children(self) \n end",
"def children\n child_objects(Dependency)\n end",
"def has_children?\n !self.children.empty?\n end",
"def use_hidden_objects?\n end",
"def can_have_associated_objects?(obj)\n true\n end",
"def children?\n self.children.any?\n end",
"def apply_children\n \n end",
"def descendants\n @descendants\n end",
"def roots\n self.ontology_classes(force_reload=true).select{|c| c.isroot?}\n end",
"def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end",
"def parents; end",
"def child?\n false\n end",
"def leaf?; false end",
"def descendants\n without_self(self_and_descendants)\n end",
"def ignore_children!\n @ignoring_children += 1\n end",
"def test_clear_without_autoloaded_singleton_parent\n mark_as_autoloaded do\n parent_instance = Parent.new\n parent_instance.singleton_class.descendants\n ActiveSupport::DescendantsTracker.clear\n assert_not ActiveSupport::DescendantsTracker.class_variable_get(:@@direct_descendants).key?(parent_instance.singleton_class)\n end\n end",
"def test_is_only_child_eh\n setup_test_tree\n\n assert( @root.is_only_child? , \"Root is an only child\")\n assert([email protected]_only_child?, \"Child1 is not the only child\")\n assert([email protected]_only_child?, \"Child2 is not the only child\")\n assert([email protected]_only_child?, \"Child3 is not the only child\")\n assert( @child4.is_only_child?, \"Child4 is an only child\")\n end",
"def child_class\n Objekt\n end",
"def orphan_children\n self.class.transaction do\n children(true).each{|child| child.orphan}\n end\n end",
"def descendants\n self.class.hierarchy_descendants(self)\n end",
"def all_children(special=nil)\n full_set(special) - [self]\n end",
"def orphan?\n false\n end",
"def replied_to?\n self.children.length > 0\n end",
"def descendants\n self.class.descendants_of(self)\n end",
"def descendants\n model_base_class.where(descendant_conditions)\n end",
"def instance_ancestors_cache; end",
"def children=(_arg0); end",
"def children=(_arg0); end",
"def is_subtree(root)\n\nend",
"def all_descendent_members\n raise TypeError.new(\"can only call on a persisted object\") unless persisted? && id.present?\n\n sql = <<~EOS\n id IN (WITH RECURSIVE tree AS (\n SELECT id, ARRAY[]::UUID[] AS ancestors\n FROM kithe_models WHERE id = '#{self.id}'\n\n UNION ALL\n\n SELECT kithe_models.id, tree.ancestors || kithe_models.parent_id\n FROM kithe_models, tree\n WHERE kithe_models.parent_id = tree.id\n ) SELECT id FROM tree WHERE id != '#{self.id}')\n EOS\n\n\n Kithe::Model.where(sql)\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def has_children?\n self.children.any?\n end",
"def children\n []\n end",
"def descendants_ids(ignore_permissions = false)\n \t descendants_ids = [] \n \t self.children.each { |child|\n \t descendants_ids += [child.id] if ignore_permissions or child.permitted?\n \t descendants_ids += child.descendants_ids\n \t } unless self.children.empty?\n \t descendants_ids\n \tend",
"def ignore_parent_exclusion=(_arg0); end",
"def base_and_descendants\n return descendants_base unless Group.supports_nested_groups?\n\n read_only(base_and_descendants_cte.apply_to(model.all))\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def has_children?\n self.children.size > 0\n end",
"def indirects_of(object)\n t = arel_table\n node = to_node(object)\n where(t[ancestry_column].matches(\"#{node.child_ancestry}/%\", nil, true))\n end",
"def child_objects\n charts + images + hyperlinks\n end"
] | [
"0.6920546",
"0.6594865",
"0.64908755",
"0.6391284",
"0.6370211",
"0.62835556",
"0.61979485",
"0.6151877",
"0.611885",
"0.61106884",
"0.6100523",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6084722",
"0.6071019",
"0.60679966",
"0.60500926",
"0.6046799",
"0.603642",
"0.6028639",
"0.6006424",
"0.59840244",
"0.5982139",
"0.5980817",
"0.59407854",
"0.59053093",
"0.58890116",
"0.58890116",
"0.58815295",
"0.58667374",
"0.58573425",
"0.58573425",
"0.58573425",
"0.58573425",
"0.5837698",
"0.5831748",
"0.5829625",
"0.5819477",
"0.5790309",
"0.57902324",
"0.57761216",
"0.5769808",
"0.5752772",
"0.57504123",
"0.5747057",
"0.5743298",
"0.5738622",
"0.5735267",
"0.5732824",
"0.57267976",
"0.5725639",
"0.5707887",
"0.5706868",
"0.56920695",
"0.5691719",
"0.5690677",
"0.56903887",
"0.5690145",
"0.56863075",
"0.5675329",
"0.5674805",
"0.5673441",
"0.56691945",
"0.5666026",
"0.56587625",
"0.56529766",
"0.56384957",
"0.5632668",
"0.5625842",
"0.56255794",
"0.56255794",
"0.56233215",
"0.5617764",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56091213",
"0.56039",
"0.55999756",
"0.55902755",
"0.55855787",
"0.55801725",
"0.55801725",
"0.55801725",
"0.55801725",
"0.55765676",
"0.5572956"
] | 0.0 | -1 |
clear_property The implementation of `clear_property()' isn't perfectly consistent with the documentation in the standard server. Specifically, nonwizard, nonowners can't clear a property, even if the property is writable contrary to what the docs say. Stunt fixes this inconsistency. | def test_that_clear_property_works_on_objects
SCENARIOS.each do |args|
run_test_as('programmer') do
o = simplify(command(%Q|; return create($nothing);|))
add_property(o, 'foobar', 123, ['player', ''])
p = create(o, args[1])
set(p, 'foobar', 'hello')
assert_equal 'hello', get(p, 'foobar')
clear_property(p, 'foobar')
assert_equal 123, get(p, 'foobar')
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @property_flush[:ensure] = :absent\n end",
"def remove_property(key)\n end",
"def delete_property field\n orientdb.delete_property self, field\n end",
"def clear_properties\n Config::Collection.clear\n end",
"def destroy\n @property_hash[:ensure] = :absent\n end",
"def del_property( propname )\n resp = conn.delete('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 204\n return\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise RestAuthPropertyNotFound.new( resp )\n else\n raise RestAuthBadResponse.new( resp, \"Received 404 without Resource-Type header\" )\n end\n else\n raise RestAuthUnknownStatus.new( resp )\n end\n end",
"def delete_property(ctx,object,propertyName,exception)\n JS::Lib.JSObjectDeleteProperty(ctx,object,propertyName,exception)\n end",
"def destroy\n begin\n if params[:id]\n Property.clear(params[:id], nil, current_user.id)\n end\n render_success(\"Property deleted\")\n rescue Exception => e\n logger.error(\"Fails to execute #{request.url} : #{e.message}\")\n render_error(e.message)\n end\n end",
"def discard_property\n if(object.is_a?(SemanticProperty))\n SemanticProperty.delete(object.id)\n end\n end",
"def delete_property (name)\n removed = !removeProperty(name).nil?\n if (removed and @_wrapper and name[0] != '_') # do not want events on internal properties\n @_wrapper.class.indexer.on_property_changed(self, name)\n end\n removed\n end",
"def reset_property_values\n write_attribute(:property_values, {})\n end",
"def delete_property(id)\n delete(\"/properties/#{id}\")\n end",
"def removeProperty(propertyId)\n return true\n end",
"def disown_property!(property)\n return false if property.class != Property\n return false if Entity.find_by_id(self.id).nil?\n return false if Property.find_by_id(property.id).nil?\n relationship = EntityPropertyRelationship.find_by(entity_id: self.id, property_id: property.id)\n return if relationship.nil?\n if relationship.position.nil?\n return relationship.destroy\n end\n index = relationship.position\n relationship.destroy\n # self.p_update_position(index)\n end",
"def flush\n @property_hash.clear\n end",
"def flush\n @property_hash.clear\n end",
"def flush\n @property_hash.clear\n end",
"def destroy_property_storage(repository, property)\n raise NotImplementedError\n end",
"def destroy_property_storage(repository, property)\n raise NotImplementedError\n end",
"def destroy\n @api_v1_property.destroy\n end",
"def destroy\n @property.destroy\n\n head :no_content\n end",
"def clear_cache\n property_cache.clear\n end",
"def remove_property(element)\n Forbidden\n end",
"def remove_property(element)\n Forbidden\n end",
"def remove_property(name)\n !@internal_node.removeProperty(name).nil?\n end",
"def set_property!(property_name, value)\n set_property(property_name, value).data!\n end",
"def delete_property(name)\n Config::Collection.delete(name)\n end",
"def delete_property property_name\n\n begin\n raise 'Property name not specified.' if property_name.empty?\n\n str_uri = $product_uri + '/words/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n response_stream = RestClient.delete(signed_str_uri, {:accept => 'application/json'})\n\n stream_hash = JSON.parse(response_stream)\n stream_hash['Code'] == 200\n\n rescue Exception => e\n print e\n end\n\n end",
"def reset_property(name)\n property = self.class.properties[name.to_sym]\n raise ArgumentError, \"Property #{name} is not defined in class #{self}\" unless property\n\n property.reset(self)\n end",
"def destroy\n authorize_action_for @property, at: current_store\n track @property\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_path,\n notice: t('.notice', property: @property) }\n format.json { head :no_content }\n end\n end",
"def delete_property(propertyName,exception = nil)\n propertyName = JS::String.create_with_utf8cstring(propertyName)\n res = super(context,self,propertyName,exception)\n return res\n end",
"def rm_properties(resource, elements)\n for element, value in elements\n resource.remove_property(element)\n end\n end",
"def clear_attribute( attribute )\n send(\"#{attribute}=\", nil)\n end",
"def clear_properties\n @filter_hash.delete(:cifilterproperties)\n end",
"def delete_property property_name\n \n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n if property_name == \"\"\n raise \"Property name not specified.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/documentProperties/\" + property_name\n signed_str_uri = Common::Utils.sign(str_uri)\n \n response_stream = RestClient.delete(signed_str_uri,{:accept=>\"application/json\"})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash[\"Code\"] == 200)\n return true\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end",
"def destroy\n if @property.user.id != @user.id\n redirect_to properties_path, notice:\"Not authorized\"\n end\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_url }\n format.json { head :ok }\n end\n end",
"def destroy\n properties_delete(@property)\n @property.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render json: {success: true} }\n end\n end",
"def unset_channel_property(channel, property, argument=nil)\n channel = normalized_channel_name(channel)\n propcode = server_type.channel_property.key(property).chr if server_type.channel_property.value? property\n propcode ||= property\n mode channel, \"-#{propcode}\", argument\n end",
"def destroy\n @auth_property.destroy\n respond_to do |format|\n format.html { redirect_to owner_token_auth_properties_path [@owner, @token], notice: 'Auth property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_properties(*args)\n args.each {|x| self.remove_property(x) }\n return self\n end",
"def delete_property property_name\n \n begin\n \n if @filename == ''\n raise 'Base file not specified.'\n end\n \n if property_name == ''\n raise 'Property name not specified.'\n end\n \n str_uri = $product_uri + '/slides/' + @filename + '/documentProperties/' + property_name\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n response_stream = RestClient.delete(signed_str_uri,{:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n if(stream_hash['Code'] == 200)\n return true\n else\n return false\n end\n \n rescue Exception=>e\n print e\n end\n \n end",
"def destroy\n property = current_user.properties.find_by(id: params[:property_id])\n\n render(\n status: 422,\n json: { error: 'You are not an owner of this property' }\n ) and return unless property\n\n property.destroy\n\n if property.destroyed?\n render status: 200, json: { property_id: params[:property_id] }\n else\n render status: 422, json: {\n error: property.errors.full_messages.join(', ')\n }\n end\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n @stolen_property.destroy\n respond_to do |format|\n format.html { redirect_to stolen_properties_url, notice: 'Stolen property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def reset_property_filters\n current_user.company.properties.each do |p|\n session[p.filter_name] = nil\n end\n end",
"def destroy\n onetemplate('delete', resource[:name])\n @property_hash.clear\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to runner_home_path, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n head :no_content\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_properties_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_property(uuid, opts = {})\n data, _status_code, _headers = delete_property_with_http_info(uuid, opts)\n data\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def flush\n return if @property_hash.empty?\n # clear this on properties, in case it's set from a previous\n # run of a different corosync type\n cmd = [command(:pcs), 'resource', 'defaults', \"#{@property_hash[:name]}=#{@property_hash[:value]}\"]\n self.class.run_command_in_cib(cmd, @resource[:cib])\n end",
"def clear_state_below(level)\n return nil if level == States::PROPERTY\n @current_property = nil\n return nil if level == States::ATTRIBUTE\n @current_attribute = nil\n return nil if level == States::RELATION\n @current_relation = nil\n return nil if level == States::SCHEMA\n @current_schema = nil\n return nil if level == States::DOMAIN\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to propertys_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to(properties_url) }\n format.xml { head :ok }\n end\n end",
"def removeFeaturedProperty(propertyId)\n return true\n end",
"def clear() \n @obj.clear() \n end",
"def destroy\n @contact = Contact.find(params[:contact_id])\n @property = Property.find(params[:id])\n authorize @property\n @property.destroy\n respond_to do |format|\n format.html { redirect_to edit_contact_path(@contact), notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :ok }\n end\n end",
"def reset\n self.ignore_unknown_properties = false\n end",
"def remove_property(property_id)\n @array.delete_if {|property| property.property_id == property_id}\n save_list(@file_path)\n end",
"def destroy\n @sys_property.destroy\n respond_to do |format|\n format.html { redirect_to sys_properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if !check_permissions?(session[:user_type], \"checkin_applicant\")\n redirect_to root_path\n end\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def clear\r\n self.value = \"\"\r\n end",
"def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end",
"def clear\n @resource = nil\n end",
"def destroy\n @client_property.destroy\n respond_to do |format|\n format.html { redirect_to client_properties_url, notice: 'Client property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to(properties_url) }\n format.xml { head :ok }\n end\n end",
"def set_cleaning!(property)\n property.services_cleaning = false\n property.services_cleaning_required = nil\n property.services_cleaning_rate = nil\n end",
"def destroy\n @quick_property = QuickProperty.find(params[:id])\n @quick_property.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_properties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @owner_property.destroy\n respond_to do |format|\n format.html { redirect_to owner_owner_properties_url(@owner), notice: 'Owner property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n @property = Property.find(params[:id])\n end",
"def destroy\n debug('Removing location')\n crm('configure', 'delete', @resource[:name])\n @property_hash.clear\n end",
"def flush\n unless @property_hash.empty?\n # Remove existing location\n cmd = ['pcs', 'constraint', 'resource', 'remove', @resource[:name]]\n PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib], false)\n cmd = ['pcs', 'constraint', 'location', 'add', @property_hash[:name], @property_hash[:primitive], @property_hash[:node_name], @property_hash[:score]]\n cmd << \"resource-discovery=#{@property_hash[:resource_discovery]}\" unless @property_hash[:resource_discovery].nil?\n PuppetX::Voxpupuli::Corosync::Provider::Pcs.run_command_in_cib(cmd, @resource[:cib])\n end\n end",
"def delete_property request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_property_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Analytics::Admin::V1alpha::Property.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end",
"def remove_property(attribute)\n `var el=this.__native__,attr=attribute.__value__,bool=c$Element.__boolean_attributes__[attr],key=c$Element.__boolean_attributes__[attr]||bool`\n `key ? el[key]=bool?false:'' : el.removeAttribute(attr)`\n return self\n end",
"def unset!(name)\n (s = setting(name)) && s.unset!\n end",
"def destroy\n @chef_property.destroy\n respond_to do |format|\n format.html { redirect_to chef_properties_url, notice: 'Chef property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @property.destroy\n respond_to do |format|\n format.html { redirect_to my_properties_properties_url , notice: \"Property was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_properties(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_properties_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_properties_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def destroy\n @property.photos.delete_all\n @property.features_properties.delete_all\n @property.destroy\n respond_to do |format|\n format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear!; end"
] | [
"0.7237162",
"0.7028978",
"0.695999",
"0.6926202",
"0.6877152",
"0.6847569",
"0.68424004",
"0.6833207",
"0.6806238",
"0.67667216",
"0.6766026",
"0.66550577",
"0.66394854",
"0.6624302",
"0.66190094",
"0.66190094",
"0.66190094",
"0.6604665",
"0.6556308",
"0.6552142",
"0.65476495",
"0.6504797",
"0.6450987",
"0.6450987",
"0.6428205",
"0.6374621",
"0.63354",
"0.63243043",
"0.63110524",
"0.62704206",
"0.6269785",
"0.62281245",
"0.62028664",
"0.61820716",
"0.61599565",
"0.6154779",
"0.6154017",
"0.6143354",
"0.6136814",
"0.6064318",
"0.60634017",
"0.6048964",
"0.60401666",
"0.6009295",
"0.5974332",
"0.5974148",
"0.5939326",
"0.59390354",
"0.5936498",
"0.59242034",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.59210896",
"0.5917402",
"0.5908203",
"0.5901001",
"0.5892354",
"0.58576",
"0.5855699",
"0.5855699",
"0.5855393",
"0.5855393",
"0.5847167",
"0.58397794",
"0.5826063",
"0.5817456",
"0.5816407",
"0.58146024",
"0.58146024",
"0.58098036",
"0.5801774",
"0.57810944",
"0.5773834",
"0.5749787",
"0.5740645",
"0.57305604",
"0.571085",
"0.57092565",
"0.5708389",
"0.5694145",
"0.56918293",
"0.5664967",
"0.5657035",
"0.56540006",
"0.56404686",
"0.5617173",
"0.5612795",
"0.561187",
"0.56052816",
"0.56042075",
"0.5604154",
"0.5598364",
"0.55907845"
] | 0.6619399 | 14 |
JWT: No need to try and load session as there is none in an API request | def skip_session
request.session_options[:skip] = true if token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_jwt_auth\n #\n @jwt_auth ||= (defined? session and session[:jwt_auth]) ? JwtToken.where(id: session[:jwt_auth]).first : nil\n end",
"def current_jwt_token\n @jwt_auth ||= session[:jwt_auth] ? JwtToken.where(id: session[:jwt_auth]).first : nil\n end",
"def authenticate_user\n jwt=cookies.signed[:jwt]\n decode_jwt(jwt) \n end",
"def current_jwt_user\n #\n @jwt_user ||= (defined? session and session[:jwt_user]) ? JwtUser.where(id: session[:jwt_user]).first : nil\n end",
"def current_jwt_context\n @jwt_context ||= session[:jwt_context]\n end",
"def login_from_jwt_header\n @current_user = if jwt_decoded_payload['sub']\n user_class.sorcery_adapter.find_by_id(jwt_decoded_payload['sub'])\n end\n end",
"def get_jwt_from_session(session)\n return nil if session.nil?\n return nil if session[:jwt].nil?\n\n session[:jwt]\n end",
"def new_jwt\n Knock::AuthToken.new(payload: { sub: current_user.id }).token\n end",
"def ensure_session_token\n self.session_token ||= User.generate_session_token\nend",
"def original_request_jwt\n env['grape_jwt_auth.original_token']\n end",
"def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end",
"def get_token\n session[:token] if authorized?\n end",
"def get_token\n # Get the user by email\n user = User.find_by_email(params[:email])\n \n # return unauthorized if the user was not found\n if !user \n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if the user is not authenticated via the authenticate method\n # then return unauthorized\n if !user.authenticate( params[:password] )\n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if our code gets here, we can generate a token and response.\n # JWT's include an expiry, we will expire the token in 24 hours\n token = jwt_encode({user_id: user.id}, 24.hours.from_now)\n render json: {token: token, exp: 24, username: user.email, userId: user.id},\n status: :ok\n \n end",
"def current_jwt_token=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\n @jwt_auth = jwt_auth\n end",
"def ensure_session_token\n self.session_token ||= generate_session_token\n end",
"def auth_token \n JWT.encode({id: self.id}, \"9885ea7895518eaf88c4a8a2e8f62c82\")\n end",
"def current_jwt_auth=(jwt_auth)\n session[:jwt_auth] = jwt_auth.nil? ? nil : jwt_auth.id\n @jwt_auth = jwt_auth\n end",
"def ensure_session_token\n self.session_token ||= User.generate_session_token\n end",
"def ensure_session_token\n self.session_token ||= User.generate_session_token\n end",
"def ensure_session_token\n self.session_token ||= User.generate_session_token\n end",
"def auto_login\n @token = params[:token]\n # byebug\n user = User.find(JWT.decode(@token, \"put your secret password here\", true, algorithm: 'HS256')[0][\"user_id\"])\n render json: user\n end",
"def authenticate_user\n return if request.headers['Authorization'].blank?\n\n jwt_payload = JwtHelper.decode(token: request.headers['Authorization'].split(' ').second)\n\n raise JWT::VerificationError if JwtBlacklist.any? { |obj| obj.jti == jwt_payload['jti'] }\n\n @current_user_id = jwt_payload['id']\n end",
"def dev_jwt_token\n JWT.encode(\n {user_id: id},\n Rails.application.secrets.json_web_token_key,\n 'HS256'\n )\n end",
"def token\n @token ||= JWT.decode(jwt_string, secret_key, true, verify_expiration: false)\n end",
"def jwt_not_authenticated\n head :unauthorized\n end",
"def call\n # after user login, will pass the user-id to the JWT to create token\n return nil unless user\n\n return JsonWebToken.create_token(user_id: user.id), user\n end",
"def jwt_auth_token( secret )\n\n # expire in 5 minutes\n exp = Time.now.to_i + 5 * 60\n\n # just a standard claim\n exp_payload = { exp: exp }\n\n return JWT.encode exp_payload, secret, 'HS256'\n\n end",
"def verify_jwt_token\n begin\n if request.format.json?\n token = request.headers['Authorization'].split(' ').last\n decoded_token = JWT.decode token, nil, false\n @current_user = User.find(decoded_token[0][\"user_id\"])\n head :unauthorized if request.headers['Authorization'].nil? || !AuthToken.valid?(token)\n else\n authenticate_user!\n end\n rescue => exception\n head :unauthorized \n end\n end",
"def issue_token(payload)\n JWT.encode(payload, Rails.application.credentials.secret_key_base)\n # JWT.encode(payload, ENV[\"SOME_SECRET\"], ENV[\"SOME_SUPER_SECRET\"])\nend",
"def decodeJWT(token)\n# puts token\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n# puts payload\n if payload[0]['exp'] >= Time.now.to_i\n payload\n else\n puts 'time expired on login'\n false\n end\n# catch the error if token is wrong\n rescue => error\n puts error\n nil\n end",
"def get_jwt_token\n payload = { data: {user: {id: self.id, email: self.email}} }\n payload[:exp] = (Time.now + Settings.jwt_token_expiry.days).to_i\n\n JWT.encode payload, ENV[\"HMAC_SECRET\"], 'HS256'\n end",
"def logged_in_user_id\n token = request.headers[\"Authorization\"]\n # something which might raise an exception\n begin \n decoded_payload = JWT.decode(token, hmac_secret, true, { algorithm: 'HS256' })\n return decoded_payload.first[\"user_id\"].to_i\n # code that deals with some exception\n rescue\n return nil\n end\n end",
"def secret_key\n jwt_config['secret_key']\n end",
"def gigya_jwt_token\n\t\t\t@gigya_jwt_token ||= begin\n\t\t\t\ttmp_token = nil\n\t\t\t\ttoken_location = nil\n\n\t\t\t\tbegin\n\t\t\t\t\tauthenticate_with_http_token do |token, options|\n\t\t\t\t\t\ttmp_token = token\n\t\t\t\t\t\ttoken_location = :header\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\t# If this is being called from a helper instead of a controller, then the authenticate_with_http_token is not available.\n\t\t\t\t\t# Additionally, we probably can't even use the HTTP Authorization header anyway\n\t\t\t\tend\n\n\t\t\t\tbegin\n\t\t\t\t\tif tmp_token.blank?\n\t\t\t\t\t\ttmp_token = params[GIGYA_QUERY_PARAM] unless params[GIGYA_QUERY_PARAM].blank?\n\t\t\t\t\t\ttoken_location = :param\n\t\t\t\t\t\tif tmp_token.blank?\n\t\t\t\t\t\t\ttmp_token = cookies[GIGYA_COOKIE_PARAM]\n\t\t\t\t\t\t\ttoken_location = :cookie\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\t# Some lightweight controllers don't do cookies\n\t\t\t\tend\n\n\t\t\t\tbegin\n\t\t\t\t\tif tmp_token.blank?\n\t\t\t\t\t\ttmp_token = session[GIGYA_SESSION_PARAM]\n\t\t\t\t\t\ttoken_location = :session\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\t# Some lightweight controllers don't do sessions\n\t\t\t\tend\n\n\t\t\t\ttoken_location = nil if tmp_token.blank?\n\n\t\t\t\t@gigya_token_location = token_location\n\n\t\t\t\ttmp_token\n\t\t\tend\n\t\tend",
"def decoded_token\n if token_from_cookie\n token= token_from_cookie\n # byebug\n begin\n JWT.decode(token, Rails.application.credentials.jwt_token, true, algorithm: \"HS256\")\n # JWT.decode => [{ \"user_id\"=>\"2\" }, { \"alg\"=>\"HS256\" }]\n rescue JWT::DecodeError\n nil\n end\n end\n end",
"def user_access_token \n session[:access_token]\n end",
"def session_token\n @session_prx_auth_token ||= if prx_jwt\n # NOTE: we already validated this jwt - so just decode it\n validator = Rack::PrxAuth::AuthValidator.new(prx_jwt)\n\n # does this jwt need to be refreshed?\n if prx_auth_needs_refresh?(validator.time_to_live)\n raise SessionTokenExpiredError.new\n end\n\n # create new data/token from access claims\n token_data = Rack::PrxAuth::TokenData.new(validator.claims)\n PrxAuth::Rails::Token.new(token_data)\n end\n end",
"def jwt_payload\n @jwt_payload ||= request.env['JWT_PAYLOAD']\n end",
"def client_key_authentication\n if request.headers['JWT'].present?\n auth_header = request.headers['JWT'].split(' ').last\n @token_payload = decodeJWT auth_header.strip\n if @token_payload\n @creators_id = @token_payload[0]['creators_id']\n else\n selected_format({ error: 'The provided token wasn´t correct' },:bad_request)\n end\n else\n selected_format({ error: 'Need to include the Authorization header JWT with correct key' },:forbidden)\n end\n end",
"def sign_in\n @user = User.find_by_email(params[:auth][:email])\n if @user && @user.authenticate(params[:auth][:password])\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token, moderator: [email protected] }, status: 200\n else \n render json: { error: 'incorrect details entered' }, status: 404\n end\nend",
"def process_token\n if request.headers['Authorization'].present?\n begin\n token = request.headers['Authorization'].split(' ')[1]\n #jwt_payload = JWT.decode(request.headers['Authorization'].split(' ')[1], Rails.application.secrets.secret_key_base).first\n jwt_payload = JWT.decode(token, nil, false)[0]\n @current_user_id = jwt_payload['id']\n rescue JWT::ExpiredSignature, JWT::VerificationError, JWT::DecodeError\n head :unauthorized\n end\n end\n end",
"def token\n @token ||= HashWithIndifferentAccess.new(\n JWT.decode(authentication_token, secret, true, decode_options).first\n )\n rescue JWT::DecodeError, JWT::ExpiredSignature, JWT::InvalidIatError\n nil\n end",
"def generate_jwt\n JWT.encode({ id: id,\n exp: 60.days.from_now.to_i },\n Rails.application.secrets.secret_key_base)\n end",
"def token\n authenticated\n end",
"def jwt_subject\n auth0_id_string\n end",
"def authentication_token\n @authentication_token ||= JWT.encode(payload, secret, algorithm)\n end",
"def ensure_session_token\n self.token ||= SecureRandom.hex\n end",
"def auth_token\n JWT.encode({ id: self.id }, '65bc368fbc69306')\n end",
"def set_session\n session['token'] = @result['data']['token']\n current_user\n end",
"def decode_jwt(jwt)\n #check the headers in post for jwt\n # byebug\n # if auth_header \n # token = cookies.signed[:jwt]\n # auth_header.split(' ')[1]\n begin\n # decode the token, return the decoded part\n JWT.decode(jwt, Rails.application.secrets.secret_key_base, true, algorithm: 'HS256')[0]\n rescue JWT::DecodeError \n # byebug \n # render json: {message: \"NOPE!!!! Really no!\"}, status: :unauthorized\n\n nil\n end\n # end\n end",
"def generate_jwt\n JWT.encode({\n id: id, \n exp: 60.days.from_now.to_i\n }, \n Rails.application.secrets.secret_key_base\n )\n end",
"def ensure_session_token\n self.session_token||=self.class.generate_session_token\n end",
"def ensure_session_token\n self.token ||= self.class.random_string\n end",
"def require_no_authentication\n require_no_authentication_or_app_jwt\n end",
"def ensure_session_token\n self.session_token ||= User.generate_session_token\n end",
"def authenticate_request\n begin\n uid = JWT.decode(request.headers['Authorization'], Rails.application.secrets.secret_key_base)[0]['uid']\n @current_user = User.find_by(uid: uid)\n rescue JWT::DecodeError\n render json: 'authentication failed', status: 401\n end\n end",
"def api_auth \n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"]; \n user = User.find_by(email: params[:email].downcase)\n if user && user.authenticate(params[:password])\n render json: { auth_token: encodeJWT(user) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def authenticate_api_token\n if request.headers[\"Authorization\"].present?\n \n auth_header = request.headers['Authorization'].split(' ').last\n \n #try to get the data from jwt token\n @payload = decode auth_header\n \n #couldnt get data for whatever reason\n if !@payload\n render json: { error: \"Problem med autentiseringssträngen. Försök att logga in igen.\" }, status: :bad_request \n #success!\n else\n @payload\n end\n #no token was sent with header \n else\n render json: { error: \"En autentiseringssträng krävs.\"}, status: :forbidden # The header isn´t present\n end\n end",
"def authenticate_request!\n\t\t# unless is if in reverse. If user_id_in_token == false then render error\n\t unless user_id_in_token?\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\t return\n\t end\n\t @current_user = User.find(auth_token[:user_id])\n\trescue JWT::VerificationError, JWT::DecodeError\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\tend",
"def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def authenticate_request!\n payload, header = JsonWebToken.verify(http_token)\n header if false # Commeent this line\n @requested_user = {\n email: payload['https://sassbox.com/email'],\n first_name: payload['https://sassbox.com/first_name'],\n last_name: payload['https://sassbox.com/last_name']\n }\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end",
"def app_jwt_token_secret\n Rails.application.secrets.app_jwt_token_secret\n end",
"def claims\n JWT.decode(jwt_token_from_request, Rails.application.secrets.secret_key_base, true)\n rescue\n nil\n end",
"def encode_token(payload) #encodes your username\n JWT.encode(payload, ENV['SECRET'])\n end",
"def current_jwt_user=(jwt_user)\n session[:jwt_user] = jwt_user.nil? ? nil : jwt_user.id\n @jwt_user = jwt_user\n end",
"def ensure_session_token \n self.session_token ||= SecureRandom::urlsafe_base64\n end",
"def authenticate!\n user_id = get_user_id_from_token\n if user_id\n @current_user = User.find(user_id)\n else\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end\n rescue JWT::ExpiredSignature\n render json: { errors: ['Authentication Timeout'] }, status: 419\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end",
"def session_api_key\n api_keys.active.session.create\n end",
"def api_auth\n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"];\n creator = Creator.find_by(creator: request.headers[:creator])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator), id: creator.id}\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end",
"def get_current_user\n return if !bearer_token\n decoded_jwt = decode_token(bearer_token)\n User.find(decoded_jwt[0][\"user\"][\"id\"])\n end",
"def signed_token(**payload)\n payload = {\n iss: 'The Identity Provider',\n iat: Time.now.to_i,\n exp: 1.hour.from_now.to_i,\n aud: ['example-api', 'user-api', 'calendar-api']\n }.merge(payload)\n private_key = OpenSSL::PKey::RSA.new(file_fixture('rsa1').read)\n JWT.encode(payload.to_h, private_key, 'RS256')\nend",
"def decodeJWT(token)\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n #Kontrollerar tiden på token\n if payload[0][\"exp\"] >= Time.now.to_i\n payload\n else\n puts \"The token has expired, please log in again to get a new one\"\n false\n end\n #Fångar felet om token var fel\n rescue => error\n puts error\n nil\n end",
"def call\n \n now = Time.new\n unless @@keys and @@expires and now < @@expires\n response = Net::HTTP.get_response(URI(\"https://www.googleapis.com/oauth2/v3/certs\"))\n @@keys = JSON.parse(response.body).deep_symbolize_keys!\n max_age = response.fetch(\"cache-control\").match(/max-age=(\\d+)/)\n @@expires = now + max_age[1].to_i - 60 # 60 second grace period\n end\n \n puts @@keys\n \n begin\n decoded_token = JWT.decode @token, nil, true, { algorithm: 'RS256', jwks: @@keys }\n payload = decoded_token[0].deep_symbolize_keys!\n \n unless ENV['GOOGLE_SIGNIN_CLIENT_ID'] === payload[:aud]\n errors.add(:client_id, \"Invalid client id\")\n end\n \n unless payload[:iss] == \"accounts.google.com\" || payload[:iss] == \"https://accounts.google.com\"\n errors.add(:issuer, \"Invalid issuer\") \n end\n \n unless payload[:exp] > Time.new.to_i\n errors.add(:expired, \"Token expired\") \n end\n \n user = User.find_or_create_by(email: payload[:email].downcase)\n user.update(username: payload[:email].downcase, first_name: payload[:given_name], last_name: payload[:family_name], picture_url: payload[:picture], locale: payload[:locale])\n return user\n rescue JWT::JWKError => e\n errors.add(:jwkError, e)\n rescue JWT::DecodeError => e\n errors.add(:decodeError, e)\n end\n \n return nil\n end",
"def set_user_session\n session[:access_token] = user_credentials.access_token\n session[:refresh_token] = user_credentials.refresh_token\n session[:expires_in] = user_credentials.expires_in\n session[:issued_at] = user_credentials.issued_at\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def authenticated?\n session[:access_token]\nend",
"def jwt\n return nil if params.format_version.zero?\n SimpleJWT.new(jwt_data, :mac => mac, :key => key, :key_id => key_id)\n end",
"def auth_bypass_token\n JWT.encode(\n {\n \"sub\" => auth_bypass_id,\n \"content_id\" => content_id,\n \"iat\" => Time.zone.now.to_i,\n \"exp\" => 1.month.from_now.to_i,\n },\n Rails.application.secrets.jwt_auth_secret,\n \"HS256\",\n )\n end",
"def auth_bypass_token\n JWT.encode(\n {\n \"sub\" => auth_bypass_id,\n \"content_id\" => content_id,\n \"iat\" => Time.zone.now.to_i,\n \"exp\" => 1.month.from_now.to_i,\n },\n Rails.application.secrets.jwt_auth_secret,\n \"HS256\",\n )\n end",
"def any_session!\n unless @session_token.present?\n _active_session = active_sessions(restricted: false, order: :updated_at.desc).first\n self.session_token = _active_session.session_token if _active_session.present?\n end\n @session_token\n end",
"def to_token_payload\n payload = {}\n # std jwt claims\n payload['sub'] = id.to_s\n payload['iat'] = Time.now.utc.to_i\n payload['iss'] = Rails.application.secrets.jwt_issuer\n # sombra claims\n payload['role'] = role\n payload['name'] = name\n payload\n end",
"def refresh_token\n warden.authenticate!(scope: resource_name)\n # the route is already hooked up for session check and jwt dispatch\n render json: {}.merge(prepared_jwt_as_access_token)\n end",
"def load_user\n case\n when session[:user_id]\n @current_user = User.find(session[:user_id]) \n when @api_key_allowed && token_provided?(params[:api_key])\n @current_user = User.where(api_key: params[:api_key]).first\n @have_valid_api_key = true\n when token_provided?(cookies[:auth_token])\n @current_user = User.where(auth_token: cookies[:auth_token]).first\n # Sign back automatically.\n sign_in_as(@current_user) unless current_user.nil?\n end\n end",
"def session_user\n decoded_hash = decoded_token\n if decoded_hash && !decoded_hash.empty?\n user_id = decoded_hash[0]['user_id']\n @user = User.find_by(id: user_id)\n else\n nil\n end\n end",
"def auth_token(payload = nil)\n if payload.nil?\n payload = {data: {authenticated: true, user: current_user_data}}\n end\n\n EchoCommon::Services::Jwt.encode payload\n end",
"def authentication_token\n if session[:authentication_token]\n if DateTime.now >= session[:expires_at]\n refresh_token\n else\n session[:authentication_token]\n end\n else\n nil\n end\n end",
"def decoded_token\n if auth_header\n # Removed token = auth_header.split(' ')[1] here\n begin\n JWT.decode(auth_header, ENV[\"SECRET\"], true, algorithm: 'HS256')\n rescue JWT::DecodeError\n nil\n end\n end\n end",
"def api_authenticate\n if request.headers[\"Authorization\"].present?\n auth_header = request.headers['Authorization'].split(' ').last\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request \n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end",
"def authenticate_with_api_key\n if @current_user.nil? && request.headers['Authorization'].nil?\n @current_user = authenticate_with_http_token(&method(:authenticator))\n end\n end",
"def create\n @user = User\n .find_by(email: get_parameters[:email].downcase)\n .try(:authenticate, get_parameters[:password]) \n\n if @user\n jwt_payload = {\n user_id: @user.id\n }\n render json: {\n status: 201,\n message: \"Successfully created new user session.\",\n user: @user,\n jwt: User.encode_jwt(jwt_payload)\n }\n\n else\n render json: {\n status: 401,\n message: \"Failed to create new user session.\"\n }\n end\n end",
"def api_authenticate\n if request.headers[\"Authorization\"].present?\n # Take the last part in The header (ignore Bearer)\n auth_header = request.headers['Authorization'].split(' ').last\n # Are we feeling alright!?\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request\n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end",
"def get_keys(jwt)\n\t\tp 'Setting the keys'\n\t\t@decodedJWT = JWT.decode(jwt.to_s,nil,settings.appSig)\n\t\t@jwtJSON = JSON.parse(@decodedJWT.to_json) \n\t\tsettings.oauthToken = @jwtJSON[\"request\"][\"user\"][\"oauthToken\"]\n\t\tsettings.internalOauthToken = @jwtJSON[\"request\"][\"user\"][\"internalOauthToken\"]\n\t\tsettings.refreshToken = @jwtJSON[\"request\"][\"user\"][\"refreshToken\"]\n\t\tsettings.jwt = jwt\n\t\tsettings.exp = @jwtJSON[\"exp\"]\nend",
"def authenticate_user_from_jwt\n _, token = request.headers['Authorization'].split\n decoded_token = AuthToken.decode(token)\n User.find(decoded_token[:user_id])\n rescue NoMethodError\n raise Exceptions::UnauthorizedError\n end",
"def current_user\n if decode_token\n #returns an array\n #user_id is the key on our payload\n user_id = decode_token[0]['user_id']\n #using user_id to find our user\n @user = User.find_by(id: user_id)\n else\n render json: { message: 'Did not find user.' }, status: :unauthorized \n end\n end",
"def authorize_request\n # request.headers[\"Authorization\"] = JsonWebToken.encode(user_id: 1)\n @current_user = (AuthorizeApiRequest.new(request.headers).call)[:user]\n end",
"def jwt_token_authen!\n data = jwt_verify(headers[\"Token\"])\n return error!('401 Unauthorized', 401) if data.nil?\n end",
"def authenticate\n authenticate_or_request_with_http_token do |token _options|\n @current_user = User.find_by token: token\n end\n end",
"def get_login(token)\n session[:login] ||= query_login(token)\nend"
] | [
"0.74579275",
"0.7307346",
"0.71927863",
"0.7164475",
"0.71471584",
"0.7094833",
"0.7042193",
"0.697402",
"0.69023854",
"0.68554103",
"0.684276",
"0.68399924",
"0.68379927",
"0.67932177",
"0.67723805",
"0.6769199",
"0.67633164",
"0.6754452",
"0.6754452",
"0.6754452",
"0.6745184",
"0.67373276",
"0.671639",
"0.67089254",
"0.668658",
"0.6675904",
"0.6633603",
"0.661652",
"0.6612317",
"0.65934634",
"0.6593243",
"0.6590826",
"0.6581085",
"0.6568426",
"0.65679234",
"0.6565342",
"0.655938",
"0.65516835",
"0.6536883",
"0.6534124",
"0.65306306",
"0.65253454",
"0.65236104",
"0.6492658",
"0.6465479",
"0.64638734",
"0.645674",
"0.64499",
"0.6448028",
"0.64445984",
"0.6444454",
"0.64392376",
"0.64390707",
"0.64371103",
"0.64301175",
"0.64218295",
"0.6419129",
"0.64154863",
"0.6398441",
"0.63972044",
"0.6389372",
"0.6388122",
"0.63820034",
"0.6377929",
"0.6376099",
"0.6362557",
"0.63607776",
"0.6355955",
"0.63497746",
"0.6346092",
"0.6344613",
"0.63377196",
"0.6326783",
"0.63049257",
"0.62973",
"0.62973",
"0.62973",
"0.62973",
"0.62973",
"0.62936205",
"0.62860763",
"0.62860763",
"0.6280847",
"0.62804717",
"0.62776953",
"0.6275211",
"0.6266366",
"0.6258269",
"0.62555236",
"0.6246491",
"0.62460923",
"0.62430304",
"0.6242477",
"0.62417006",
"0.6233505",
"0.6225574",
"0.6220772",
"0.6220623",
"0.62199646",
"0.6217141",
"0.6215836"
] | 0.0 | -1 |
JWT: overriding Knock's method to manually trigger Devise's auth. When there is no token we assume the request comes from the browser so has a session (potentially with warden key) attached. def authenticate_entity(entity_name) if token super(entity_name) else current_user end end | def set_current_user
User.current = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_entity(entity_name)\n if token\n super(entity_name)\n else\n current_user\n end\n end",
"def user_authentication!\n if params[:auth_token].present? or params[:token_authentication]== \"true\"\n #this is for api authentication and access\n authenticate_user_from_token!\n else\n #normal devise authentication\n authenticate_user!\n end\n end",
"def authenticate_user!\n token, options = ActionController::HttpAuthentication::Token.token_and_options(request)\n\n super unless token == 'rbMmEeoH8RxRDyN24PQv'\n end",
"def authenticate_user_from_token!\n auth_token = params[Devise.authentication_keys]\n if auth_token\n t = Time.now \n if (user = User.where(authentication_token: auth_token).first)\n sign_in user, store: false\n else\n # ensure requests with a failed token match are quantised to 200ms\n sleep((200 - (Time.now + t) % 200) / 1000.0)\n end\n end\n \n end",
"def authenticate_user_from_token\n email = request.headers['X-User-Email']\n\n if email && (user = User.find_by(email: email))\n token = request.headers['X-User-Authentication-Token']\n\n if Devise.secure_compare(user.authentication_token, token)\n sign_in user, store: false\n end\n end\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authenticate_user_from_token!\n auth_service = AuthenticationService.new\n user = auth_service.authenticated?(request.headers[\"name\"], request.headers[\"token\"])\n sign_in user, store: false if user\n end",
"def authenticate_user_from_token!\n\t\ttoken = request.headers[\"x-session-token\"].presence\n\t\tuser = token && User.find_by_authentication_token(token.to_s)\n\t\tif user\n\t\t\tsign_in user, store: false\n\t\tend\n\tend",
"def authenticate\n authenticate_or_request_with_http_token do |token _options|\n @current_user = User.find_by token: token\n end\n end",
"def authenticate_with_token\n # get the token from the header\n # get the token from the post body\n # get the token from json post\n \n token = request.headers[\"HTTP_AUTHORIZATION\"]\n \n if (!token)\n if (not_protected self.controller_name, self.action_name)\n return nil\n end\n\n redirect_to controller: 'application', action: 'index' \n end\n\n #@user = get_user_by_token(token)\n end",
"def authenticate_user_from_token!\n authenticate_with_http_token do |token, options|\n user_email = options[:email].presence\n user = user_email && User.find_by_email(user_email)\n\n if user && Devise.secure_compare(user.authentication_token, token)\n sign_in user, store: false\n end\n end\n end",
"def authenticate_user_from_token!\n user_email = params[:user_email].presence\n user = user_email && User.find_by_email(user_email)\n\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n if user && Devise.secure_compare(user.auth_token, params[:auth_token])\n sign_in user, store: false\n end\n\n end",
"def authenticate\n authenticate_token || render_unauthorized\nend",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def after_token_authentication\n if params[:authentication_key].present?\n @user = User.find_by_authentication_token(params[:authentication_key]) # we are finding \n sign_in @user if @user # we are siging in user if it exist. sign_in is devise method \n if @user == nil\n\trender :status=>400, :json=>{:message=>\"Invalid token.\"}\n end\n end\n end",
"def authenticate_user_from_token!\n user_email = params[:user_email].presence\n user = user_email && User.find_by_email(user_email)\n\n # Notice how we use Devise.secure_compare to compare the token\n # in the database with the token given in the params, mitigating\n # timing attacks.\n\n if user && Devise.secure_compare(user.authentication_token, params[:user_token])\n sign_in user, store: false\n end\n end",
"def authenticate_user_from_token!\n logger.info \"authenticating user\"\n authenticate_with_http_token do |token, options|\n username = options[:username].presence\n user = username && User.find_by_username(username)\n logger.info \"username: \" + username\n logger.info \"user: \" + user.inspect\n logger.info \"token: \" + token\n logger.info \"user_token: \" + user.auth_token\n if user && Devise.secure_compare(user.auth_token, token)\n sign_in user, store: false\n logger.info \"current_user: \" + current_user.inspect\n else\n logger.error \"login failed\"\n end\n end\n end",
"def authenticate_user_from_token!\n authenticate_with_http_token do |token, options|\n user_email = options[:email].presence\n user = user_email && User.find_by_email(user_email)\n\n if user && Devise.secure_compare(user.api_token, token)\n sign_in user, store: false\n end\n end\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n \n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def authenticate_or_use_token\n if params[:token].blank?\n return current_account.users.authenticate(params[:login], params[:password])\n else\n return current_account.users.first(:conditions => { :admin_login_token => params[:token] })\n end\n end",
"def authenticate\n \n authenticate_token || render_unauthorized\n end",
"def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n # else\n # authentication_error\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authentication_error\n end\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n\n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def authenticate_user_from_token!\n # user_id = params[:user_id].presence\n # user = user_id && User.find(user_id)\n # api_token = params[:api_token] || env['HTTP_API_TOKEN']\n # if user && Devise.secure_compare(user.api_token, api_token)\n # sign_in user, store: false and return\n # end\n\n # render_error({ :error => \"Please sign in first.\" })\n end",
"def token\n authenticate_username_password || render_unauthorized\n end",
"def authenticate\n authenticate_token || render_unauthorized\n end",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n \n unless user\n render json: { errors: 'user must signed in' }, status: :unprocessable_entity\n end\n end",
"def authenticate_user_from_token!\n user_token = params[:user_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n \n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n if auth_token\n authenticate_with_auth_token auth_token\n else\n authenticate_error\n end\n end",
"def authenticate\n\t\tauthenticate_token || render_unauthorized\n\tend",
"def authenticate_user_from_token!\n user_token = params[:auth_token].presence\n if user_token\n user = User.where(authentication_token: user_token.to_s).first\n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n else\n render status: 401, json: {success: false, error: \"invalid token\" }\n end\n end\n end",
"def authenticate_token \n\t\tauthenticate_with_http_token do | token, options| \n\t\t\tUser.find_by(auth_token: token)\n\t\tend\n\tend",
"def ensure_authentication_token\n self.authentication_token ||= generate_authentication_token\n end",
"def authenticate_token(token)\n Devise.secure_compare(self.authentication_token, token)\n end",
"def authenticate_user_from_token!\n key = params[:key].presence\n user = key && User.find_by_key(key)\n if user.nil?\n render :status=>401, :json=>{:status=>\"Failure\", :status_code => 401, :message=>\"Invalid Key.\"}\n return\n end\n # Notice how we use Devise.secure_compare to compare the token\n # in the database with the token given in the params, mitigating\n # timing attacks.\n if user && Devise.secure_compare(user.authentication_token, params[:authentication_token]) && user.authentication_token.present?\n sign_in user, store: true\n else\n render :status=>401, :json=>{:status=>\"Failure\", :status_code => 401, :message=>\"Invalid Authentication token.\"}\n return\n end\n end",
"def authenticate_token\n authenticate_with_http_token do |token, options|\n @current_user = User.find_by(token: token)\n @current_user\n end\n end",
"def authenticate\n authenticate_or_request_with_http_token do |token, _options|\n @current_user = User.find_by token: token\n end\n end",
"def authenticate_user_from_token!\n # Set the authentication params if not already present\n if username = params[:username].blank? && request.headers[\"X-Username\"]\n params[:username] = username\n end\n if authn_token = params[:authn_token].blank? && request.headers[\"X-User-Token\"]\n params[:authn_token] = authn_token\n end\n\n username = params[:username].presence\n user = username && self.class.token_authentication_class.find_by(username: username)\n\n # Notice how we use Devise.secure_compare to compare the token\n # in the database with the token given in the params, mitigating\n # timing attacks.\n if user &&\n ::Devise.secure_compare(user.authn_token, params[:authn_token]) &&\n DateTime.current < (user.current_sign_in_at + Devise.timeout_in)\n\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n\n # Set current user\n @current_user = user\n else\n # TODO: @giosakti investigate better behaviour for authentication during\n # testing\n raise LoginRequiredException unless ::Rails.env.test?\n end\n end",
"def authenticate_token\n render_401 if @token.blank? || [email protected]?\n end",
"def authenticate_user_from_token!\n user_token = params[:user_token].presence\n user = user_token && User.find_by_authentication_token(user_token)\n\n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def authenticate\n \n authenticate_or_request_with_http_token do |token|\n begin\n decoded = decode(token)\n @current_user = User.find_by(id: decoded[0][\"user_id\"]) \n \n rescue JWT::DecodeError\n render json: {authorized: false }, status: 401 \n end\n end \n end",
"def authenticate_with_token!\n render json: { errors: \"Not authenticated\" }, status: :unauthorized unless user_signed_in?\n end",
"def current_user\n authenticate_token\n end",
"def authenticate_with_token!\n render json: { errors: 'Acesso não autorizado!' }, status: 401 unless user_logged_in?\n end",
"def authentication_token\n object.authentication_token if !current_user || object.id == current_user.id\n end",
"def authenticate_request!\n\t\t# unless is if in reverse. If user_id_in_token == false then render error\n\t unless user_id_in_token?\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\t return\n\t end\n\t @current_user = User.find(auth_token[:user_id])\n\trescue JWT::VerificationError, JWT::DecodeError\n\t render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n\tend",
"def authenticate_user\n @token = Token.find_by(auth_token: request.headers['HTTP_AUTH_TOKEN'])\n return render json: { message: 'token invalid' }, status: 422 unless @token\n\n @current_user = @token.user\n end",
"def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def authenticate_user_devise!\n raise Errors::AuthorizationError, 'Token authentication is not correct' unless current_user_devise\n end",
"def authenticate_token\n authenticate_with_http_token do |token, options|\n User.find_by(auth_token: token)\n end\n end",
"def authenticate_or_token\n @@host = request.host_with_port\n return if params[:action].index('login') || params[:controller] == 'accesses'\n authenticate_user! if params[:controller].index('api').nil?\n @current_user = current_user if @current_user.nil?\n end",
"def authenticate_user_from_token!\n user_token = params[:user_token].presence\n user = user_token && User.find_by_authentication_token(user_token.to_s)\n\n if user\n # Notice we are passing store false, so the user is not\n # actually stored in the session and a token is needed\n # for every request. If you want the token to work as a\n # sign in token, you can simply remove store: false.\n sign_in user, store: false\n end\n end",
"def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def ensure_authentication_token\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def authenticate!\n\n # mapping comes from devise base class, \"mapping.to\" is the class of the model\n # being used for authentication, typically the class \"User\". This is set by using\n # the `devise` class method in that model\n #byebug\n klass = mapping.to\n\n if request.headers['X-HC-FB-AUTH'].present?\n # the returned user object will be saved and serialised into the session\n\n decoded = Base64.decode64(request.headers['X-HC-FB-AUTH'])\n user_and_token = decoded.split(':')\n\n users = klass.includes(:identities).where(socify_identities: { uid: user_and_token[0], token: user_and_token[1], provider: \"facebook\"})\n begin\n if users.size == 1\n u = users.first\n identity = u.identities.find_by!(uid: user_and_token[0], token: user_and_token[1], provider: \"facebook\")\n if !identity.expires_at || (identity.expires_at && identity.expires_at > Time.now)\n success! u\n else\n fail! \"token expired\"\n end\n else\n fail! \"invalid uid and/or token\"\n end\n rescue\n fail!\n end\n end\n\n # if we wanted to stop other strategies from authenticating the user\n end",
"def ensure_user_has_authentication_token\n return unless User.current.authentication_token.nil?\n\n User.current.ensure_authentication_token\n User.current.save\n end",
"def authenticate_user\n if not params.has_key?(:auth_token)\n failure\n return\n end\n @current_user = User.find_by_authentication_token(params[:auth_token])\n # Adding the conditional to throw json error\n unless @current_user\n failure\n end\n end",
"def authenticate_user_from_token2!\n puts request.format\n return true if request.format != \"application/json\"\n log_headers\n\n authenticate_or_request_with_http_token do |token, options|\n puts \"#\"*40\n # User.find_by(auth_token: token)\n user = token && User.find_by_authentication_token(token.to_s)\n # puts user.to_yaml\n if user\n sign_in user, store: false\n end\n user\n end\n\n # Notice how we use Devise.secure_compare to compare the token\n # in the database with the token given in the params, mitigating\n # timing attacks.\n end",
"def authenticate_user\n authenticate_or_request_with_http_token do |token, options|\n @user = User.find_by_auth_key(token)\n head :unauthorized unless @user\n return\n end\n end",
"def token\n authenticated\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n client_id = request.headers['Client-ID']\n\n if auth_token\n authenticate_with_auth_token(auth_token, client_id)\n else\n authentication_error\n end\n end",
"def authenticate!\n if current_identity\n true\n else\n respond_to do |format|\n format.html do\n store_location\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 authenticate_with_token!\n renders json: {errors: \"Not authenticated\"},\n status: :unauthorized unless user_signed_in?\n end",
"def ensure_authentication_token!\n if authentication_token.blank?\n self.authentication_token = generate_authentication_token\n end\n end",
"def authenticate\n \t# get token from header\n \tauthentication_token = request.headers['token']\n \t@user = User.find_by_authentication_token authentication_token if authentication_token\n \t\n \tunless @user\n \t\trender json: {success: false, message: I18n.t('unauthorized'), data: {}}, status: :unauthorized\n \t\treturn false\n \tend\n end",
"def authenticate_user\n return if request.headers['Authorization'].blank?\n\n jwt_payload = JwtHelper.decode(token: request.headers['Authorization'].split(' ').second)\n\n raise JWT::VerificationError if JwtBlacklist.any? { |obj| obj.jti == jwt_payload['jti'] }\n\n @current_user_id = jwt_payload['id']\n end",
"def authenticate!\n session_token = @_env['rack.session'][:session_token]\n session = SessionRepository.by_token(session_token).first\n\n if session and !session.expired?\n user = UserRepository.find session.user_id\n\n if user\n @current_session = session\n @current_user = user\n @authenticated = true\n end\n end\n end",
"def authenticate_user_from_token\n authenticate_with_http_token do |token, options|\n user_email = options[:email]\n user_email && User.where(email: user_email, authentication_token: token).first\n end\n end",
"def authenticate_user_from_token!\n\t\t@api_token = ApiToken.find_by_token(params[:token])\n @user = @api_token.try(:user)\n if @user.nil?\n render json: { error: 'Not authorized' }, status: 401\n end\n end",
"def authenticate_using_http_token\n return if current_user\n authenticate_with_http_token do |token_code, options|\n auth = Tokens::Api.authenticate token_code\n\n # NOTE: Setting the instance variable directly bypasses the session\n # setup. Tokens are generally used in API contexts, so the session\n # cookie would get ignored anyway.\n @current_user = auth unless auth.kind_of? Symbol\n end\n end",
"def authenticate_user!\n return true if current_user\n # get token and options\n authenticate_or_request_with_http_token do |token, options|\n access_token = AccountAccessToken.where('token_value = ? AND expires > ?', token, Date.today).first\n if access_token\n sign_in access_token.account\n else\n unauthenticated!\n end\n end\n end",
"def authenticate!\n warden.authenticate!\n end",
"def authenticate_request!\n fail NotAuthenticatedError unless user_id_included_in_auth_token?\n @current_user = User.find(decoded_auth_token[:user_id] || decoded_auth_token[:id])\n fail NotAuthenticated if @current_user.blank?\n rescue JWT::ExpiredSignature, JWT::ImmatureSignature\n raise AuthenticationTimeoutError\n rescue JWT::VerificationError, JWT::DecodeError, ActiveRecord::RecordNotFound\n raise NotAuthenticatedError\n end",
"def sign_in\n @user = User.find_by_email(params[:auth][:email])\n if @user && @user.authenticate(params[:auth][:password])\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token, moderator: [email protected] }, status: 200\n else \n render json: { error: 'incorrect details entered' }, status: 404\n end\nend",
"def auth_token\n (protect_against_forgery? ? form_authenticity_token : nil)\n end",
"def authenticate_request!\n return render_unauthorized unless request.headers['Authorization'].present?\n\n @token ||= AuthenticateRequest.get(User, request.headers['Authorization'].split(' ').last)\n @current_user = @token[:user]\n end",
"def authenticate_with_autosignin_token(attributes={})\n resource = find_by_id(attributes[self.to_s.foreign_key.to_sym].to_i)\n if resource.try(:valid_for_autosignin_token_authentication?, attributes)\n resource\n else\n nil\n end\n end",
"def authenticate_current_user\n render json: {}, status: :unauthorized if get_current_user.nil?\n end",
"def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end",
"def authenticate_token\n @is_authenticated = false\n if request.headers[\"TOKEN\"]\n if request.headers[\"TOKEN\"] == \"AppDipre\"\n @is_authenticated = true\n end\n end\n end",
"def authenticate!\n user_id = get_user_id_from_token\n if user_id\n @current_user = User.find(user_id)\n else\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end\n rescue JWT::ExpiredSignature\n render json: { errors: ['Authentication Timeout'] }, status: 419\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end",
"def authenticate_with_api_key\n if @current_user.nil? && request.headers['Authorization'].nil?\n @current_user = authenticate_with_http_token(&method(:authenticator))\n end\n end",
"def current_user\n @_current_user ||= authenticate_token\n end",
"def current_user\n @_current_user ||= authenticate_token\n end",
"def create\n respond_to do |format|\n format.html { super }\n format.json do\n self.resource = warden.authenticate!(auth_options)\n sign_in(resource_name, resource)\n current_user.update(authentication_token: nil)\n\n render json: { user: { token: current_user.authentication_token } }\n end\n end\n end",
"def authenticate_user_from_token!\n raise AuthorizationError unless http_auth_token.present?\n result = find_user\n raise BadRequestError, result.errors if result.failure?\n @current_user = result.current_user\n end",
"def authenticate_user!\n if request.headers['sid'].present? && !request.headers['sid'].nil? && request.headers['utoken'].present? && !request.headers['utoken'].nil?\n session = Session.active_sessions.find_by_id(request.headers['sid'])\n if session.nil? || session.utoken != request.headers['utoken']\n render_error_invalid_token and return\n end\n else\n render_error_user_not_signed_in and return\n end\n end",
"def authenticate_user_from_token\n unless authenticate_with_http_token { |token, options| User.find_by(auth_token: token) }\n render json: { error: 'Bad Token'}, status: 401\n end\n end",
"def authenticate_user\n authenticate_or_request_with_http_token do |token, options|\n @user = User.find_by_auth_key(token)\n head :unauthorized unless @user\n return\n end\n end",
"def active_for_authentication?; end",
"def active_for_authentication?; end",
"def authenticate_with_api_key!\n if @current_user.nil? && !request.headers['Authorization'].nil?\n @current_user = authenticate_or_request_with_http_token(&method(:authenticator))\n end\n end",
"def authenticate_user_from_token!\n auth_token = request.headers['Authorization']\n\n user = User.find_by(access_token: auth_token)\n\n fail AccessDenied unless user\n\n @current_user = user\n end",
"def authenticate_user!\n payload = decode_token\n return unless payload.is_a? Hash\n\n @current_user = User.find payload[:user_id]\n end",
"def login_by_token\n\n end",
"def create\n self.resource = warden.authenticate!(auth_options)\n sign_in(resource_name, resource)\n \n respond_to do |format|\n format.json {\n render :json => {\n :user => current_user,\n :status => :ok,\n :authentication_token => current_user.authentication_token\n }\n }\n end\n end"
] | [
"0.8261872",
"0.7478975",
"0.7437366",
"0.72052616",
"0.71870774",
"0.71349186",
"0.7121628",
"0.7084537",
"0.7070366",
"0.7066863",
"0.7056656",
"0.7041128",
"0.7021292",
"0.7016089",
"0.6996374",
"0.6987947",
"0.69855547",
"0.6961307",
"0.69611585",
"0.69534427",
"0.6942428",
"0.6932516",
"0.6913805",
"0.6905933",
"0.6905933",
"0.6892334",
"0.6891936",
"0.6890336",
"0.68879646",
"0.68821836",
"0.6871202",
"0.687089",
"0.6859253",
"0.6853254",
"0.6851719",
"0.68478394",
"0.6840576",
"0.6834787",
"0.68286324",
"0.6816427",
"0.6806137",
"0.67851603",
"0.6784729",
"0.67755353",
"0.6772256",
"0.67685825",
"0.67589545",
"0.6756972",
"0.67375904",
"0.6706657",
"0.6703961",
"0.67019844",
"0.66892123",
"0.66775644",
"0.6674046",
"0.66569334",
"0.6647797",
"0.6647797",
"0.6647797",
"0.66437787",
"0.6619252",
"0.6618036",
"0.6603877",
"0.6588971",
"0.6588139",
"0.65876985",
"0.6572283",
"0.6561602",
"0.65574145",
"0.65118223",
"0.6508604",
"0.65058017",
"0.6489769",
"0.64793736",
"0.6476146",
"0.647424",
"0.6471444",
"0.64638895",
"0.6455334",
"0.64500093",
"0.64491147",
"0.64478874",
"0.64398474",
"0.64268386",
"0.64268386",
"0.64173764",
"0.64143807",
"0.64073974",
"0.64073974",
"0.63938755",
"0.63931817",
"0.637891",
"0.6374006",
"0.63710666",
"0.636803",
"0.636803",
"0.6363488",
"0.6355682",
"0.6353513",
"0.6329792",
"0.63254696"
] | 0.0 | -1 |
GET /krishes GET /krishes.json | def index
@krishes = Krish.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @konyu_rireki = KonyuRireki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konyu_rireki }\n end\n end",
"def show\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heli_kit }\n end\n end",
"def index\n @kids = Kid.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kids }\n end\n end",
"def index\n @khs = Kh.all\n end",
"def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end",
"def show\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @koti }\n end\n end",
"def show\n @kisalli = Kisalli.find_by_key(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kisalli }\n end\n end",
"def index # public\n if params[:shelter_id]\n set_shelter\n render json: @shelter.animals\n else\n @animals = Animal.includes(:shelter).all\n render 'index.json.jbuilder'\n end\n end",
"def index\n @kifus = Kifu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kifus }\n end\n end",
"def show\n @cheer = Cheer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cheer }\n end\n end",
"def show\n render json: @shelter\n end",
"def show\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitten }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def show\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitty }\n end\n end",
"def index\n @harvestings = Harvesting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @harvestings }\n end\n end",
"def show\n @squawk = Squawk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squawk }\n end\n end",
"def show\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegij }\n end\n end",
"def show\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kit }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish }\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n @kid = Kid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kid }\n end\n end",
"def index\n @wks = Wk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wks }\n end\n end",
"def show\n @sleuths = HTTParty.get('https://webservice.wikipathways.org/findPathwaysByText?query=' + @sleuth.ext_gene + '&species=homo+sapiens&format=json',\n :headers =>{'Content-Type' => 'application/json'} )\n @pubs = HTTParty.get('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&term='+ @sleuth.ext_gene,\n :headers =>{'Content-Type' => 'application/json'} )\n end",
"def index\n @karyalay_caterers = KaryalayCaterer.all\n render json: @karyalay_caterers\n end",
"def show\n render json: @rock\n end",
"def index\n skickers = Skicker.order(power: :asc)\n render json: { status: 'SUCCESS', message: 'Loaded skickers', value: skickers }\n end",
"def show\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegiji }\n end\n end",
"def index\n # @rushes = Rush.find_by_sql \"select * from rushes as r \n # left join (select rush_id, avg(chill) as avg_chill from cpratings group by rush_id) as c \n # on c.rush_id = r.id \n # order by c.avg_chill DESC\"\n @rushes = Rush.all\n render :json => @rushes\n end",
"def index\n @hikers = Hiker.all\n end",
"def index\n @frais_hebergements = FraisHebergement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_hebergements }\n end\n end",
"def show\n @kitchen = Kitchen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitchen }\n end\n end",
"def show\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kennel_litter }\n end\n end",
"def index\n @economy_hands = EconomyHand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @economy_hands }\n end\n end",
"def show\n @event_karaoke = Event::Karaoke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_karaoke }\n end\n end",
"def show\n @shichoson = Shichoson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shichoson }\n end\n end",
"def index\n @shelters = Shelter.where(filtering_params)\n render json: @shelters\n end",
"def index\n @chairs = Chair.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chairs }\n end\n end",
"def index\n @kistings = Kisting.all\n end",
"def show\n @wk = Wk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wk }\n end\n end",
"def show\n @shunfengch = Shunfengche.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shunfengch }\n end\n end",
"def index\n @wigs = Wig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wigs }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish_style }\n end\n end",
"def show\n @rock = Rock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rock }\n end\n end",
"def show\n @saiken = Saiken.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @saiken }\n end\n end",
"def show\n @dish = Dish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish }\n end\n end",
"def king_richard_iii\n fetch('shakespeare.king_richard_iii')\n end",
"def show\n @squish = Squish.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squish }\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\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 @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def show\n @sklad = Sklad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sklad }\n end\n end",
"def index\n @rinks = Rink.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @shoes = Shoe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shoes }\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 @keys = Key.all\n render json: @keys\n end",
"def show\n @kazoku = Kazoku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kazoku }\n end\n end",
"def index\n @risikos = Risiko.all\n end",
"def index\n @chests = Chest.all\n end",
"def index\n @hks = Hk.all\n end",
"def show\n @chair = Chair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chair }\n end\n end",
"def show\n @chair = Chair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chair }\n end\n end",
"def show\n @harvesting = Harvesting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvesting }\n end\n end",
"def show\n @harvesting = Harvesting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvesting }\n end\n end",
"def show\n @frais_hebergement = FraisHebergement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_hebergement }\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def show\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink_league }\n end\n end",
"def show\n @hair_colour = HairColour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hair_colour }\n end\n end",
"def show\n @hitchhike = Hitchhike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hitchhike }\n end\n end",
"def index\n @keihis = Keihi.all\n end",
"def index\n @treks = Trek.all\n @title = \"Trekking routes and destinations\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @treks }\n end\n end",
"def show\n @skid = Skid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skid }\n end\n end",
"def klines(options)\n request :public, :get, :klines, options\n end",
"def show\n @hacker = Hacker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hacker }\n end\n end",
"def index\n @litters = Litter.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @litters }\n end\n end",
"def index\n @knols = Knol.all\n end",
"def index\n @keys = Key.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keys }\n end\n end",
"def index\n @decks = Deck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @decks }\n end\n end",
"def index\n @decks = Deck.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @decks }\n end\n end",
"def get_all_kids\n render json: Parent.find(params[:id]).kids\n end",
"def indexs\n\n\n #application/mixare-json \n\n \tslat = params[:slat]\n \tslon = params[:slon]\n \telat = params[:elat]\n \telon = params[:elon]\n\n \t# /hgt/_design/hgt/_view/tags?startkey=[-27,27]\\&endkey=[-25,28]\n #uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags?startkey=[#{slat},#{slon}]&endkey=[#{elat},#{elon}]\"\n uri = \"#{DATABASE}/hgt/_design/hgt/_view/tags\"\n\n request = RestClient.get uri\n\n request = Yajl::Parser.parse(request)\n\n puts request.inspect\n\n response = {}\n response[:results] = []\n\n request[\"rows\"].each do |row|\n\n title = row[\"value\"][\"kind\"] == \"recommendation\" ? \"Go There - \" : \"Don't Go There - \"\n title = \"#{title}#{row['value']['description']}\"\n\n response[:results] << {\n id: row[\"id\"],\n lat: row[\"value\"][\"lat\"].to_s,\n lng: row[\"value\"][\"lon\"].to_s,\n elevation: \"0.0\",\n title: title,\n distance: \"1\",\n has_detail_page: \"0\",\n webpage: \"\"\n }\n end\n response[:status] = \"OK\"\n response[:num_results] = response[:results].length\n render json: response, :content_type => 'application/mixare-json'\n end",
"def index\n @risks = Risk.all\n end",
"def show\n @shoe = Shoe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shoe }\n end\n end",
"def index\n @kickers = Kicker.all\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def show\n render json: @dice\n end",
"def show\n @rum = Rum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rum }\n end\n end",
"def show\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cheque }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kid_quote }\n end\n end",
"def index\n # Retrieve kpis templates from impac api.\n # TODO: improve request params to work for strong parameters\n attrs = params.slice('metadata', 'opts')\n auth = { username: MnoEnterprise.tenant_id, password: MnoEnterprise.tenant_key }\n\n response = begin\n MnoEnterprise::ImpacClient.send_get('/api/v2/kpis', attrs, basic_auth: auth)\n rescue => e\n return render json: { message: \"Unable to retrieve kpis from Impac API | Error #{e}\" }\n end\n\n # customise available kpis\n kpis = (response['kpis'] || []).map do |kpi|\n kpi = kpi.with_indifferent_access\n kpi[:watchables].map do |watchable|\n kpi.merge(\n name: \"#{kpi[:name]} #{watchable.capitalize unless kpi[:name].downcase.index(watchable)}\".strip,\n watchables: [watchable],\n target_placeholders: {watchable => kpi[:target_placeholders][watchable]},\n )\n end\n end\n .flatten\n\n render json: { kpis: kpis }\n end",
"def show\n render json: @sighting\n end",
"def show\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @joke }\n end\n end",
"def get_all\n hitches = ::Hitch.where(shared?: true).where(\"submit_time > now()\").near([params[:user_latitude],params[:user_longitude]], 20)\n\n serializer = HitchSerializer.new(hitches, { params: { user_latitude: params[:user_latitude], user_longitude: params[:user_longitude] } })\n render json: serializer.serializable_hash\n end",
"def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end",
"def show\n @kansei_buhin = KanseiBuhin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kansei_buhin }\n end\n end",
"def index\n @foodhampers = Foodhamper.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foodhampers }\n end\n end",
"def show\n @he = He.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @he }\n end\n end",
"def get_champion_data(patch_number)\n response_string = RestClient.get(\"http://ddragon.leagueoflegends.com/cdn/#{patch_number}/data/en_US/champion.json\")\n response_hash = JSON.parse(response_string)\n champion_data = response_hash[\"data\"]\nend",
"def index\n @rishabhs = Rishabh.all\n end",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end"
] | [
"0.64235795",
"0.6413217",
"0.63505614",
"0.63149554",
"0.6259184",
"0.61902434",
"0.6148827",
"0.61450493",
"0.613017",
"0.61261714",
"0.6111282",
"0.61100954",
"0.602197",
"0.59770715",
"0.5976871",
"0.5969935",
"0.5937085",
"0.5936833",
"0.5933155",
"0.5927539",
"0.5918369",
"0.59108937",
"0.59066445",
"0.59057254",
"0.5905105",
"0.5889064",
"0.5882202",
"0.58775616",
"0.583814",
"0.5837051",
"0.58328205",
"0.58217585",
"0.58167684",
"0.5814334",
"0.57929194",
"0.5780813",
"0.57807255",
"0.57805896",
"0.5762531",
"0.5747389",
"0.5744949",
"0.57318103",
"0.5727722",
"0.5725313",
"0.5723312",
"0.5719012",
"0.5717959",
"0.57111937",
"0.5703756",
"0.5695695",
"0.5694804",
"0.5692144",
"0.56880146",
"0.5687259",
"0.56816465",
"0.5681182",
"0.56811213",
"0.5672852",
"0.56687856",
"0.56686026",
"0.56686026",
"0.5659923",
"0.5659923",
"0.565892",
"0.564818",
"0.5644549",
"0.56406635",
"0.56362313",
"0.5632291",
"0.5629074",
"0.5625999",
"0.56257606",
"0.56215066",
"0.56156135",
"0.56129867",
"0.56119514",
"0.56118345",
"0.56109387",
"0.56109387",
"0.56107455",
"0.5602645",
"0.56020725",
"0.5598633",
"0.55973834",
"0.55971205",
"0.55967194",
"0.559328",
"0.55905116",
"0.5589668",
"0.55847603",
"0.5584295",
"0.55765355",
"0.55743605",
"0.55721384",
"0.5571478",
"0.55713946",
"0.55655456",
"0.5555637",
"0.55540395",
"0.55438143"
] | 0.72551185 | 0 |
GET /krishes/1 GET /krishes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @krishes = Krish.all\n end",
"def show\n @konyu_rireki = KonyuRireki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konyu_rireki }\n end\n end",
"def show\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @koti }\n end\n end",
"def show\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heli_kit }\n end\n end",
"def index\n @kids = Kid.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kids }\n end\n end",
"def show\n @kisalli = Kisalli.find_by_key(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kisalli }\n end\n end",
"def show\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitten }\n end\n end",
"def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end",
"def show\n @kid = Kid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kid }\n end\n end",
"def show\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegij }\n end\n end",
"def show\n @cheer = Cheer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cheer }\n end\n end",
"def show\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitty }\n end\n end",
"def show\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kit }\n end\n end",
"def index # public\n if params[:shelter_id]\n set_shelter\n render json: @shelter.animals\n else\n @animals = Animal.includes(:shelter).all\n render 'index.json.jbuilder'\n end\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def show\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegiji }\n end\n end",
"def index\n @kifus = Kifu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kifus }\n end\n end",
"def show\n @kitchen = Kitchen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitchen }\n end\n end",
"def show\n @squawk = Squawk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squawk }\n end\n end",
"def index\n @khs = Kh.all\n end",
"def show\n @wk = Wk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wk }\n end\n end",
"def show\n render json: @shelter\n end",
"def show\n @kazoku = Kazoku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @kazoku }\n end\n end",
"def show\n @shichoson = Shichoson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shichoson }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def show\n @rock = Rock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rock }\n end\n end",
"def index\n @harvestings = Harvesting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @harvestings }\n end\n end",
"def show\n @rum = Rum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rum }\n end\n end",
"def show\n render json: @rock\n end",
"def show\n @chair = Chair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chair }\n end\n end",
"def show\n @chair = Chair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chair }\n end\n end",
"def show\n @sklad = Sklad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sklad }\n end\n end",
"def index\n @wks = Wk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wks }\n end\n end",
"def show\n @event_karaoke = Event::Karaoke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_karaoke }\n end\n end",
"def show\n @rainbow = Rainbow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def show\n @skid = Skid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skid }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish }\n end\n end",
"def show\n @dish = Dish.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish }\n end\n end",
"def show\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @joke }\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end",
"def show\n @joy = Joy.find(params[:id])\n render json: @joy\n end",
"def index\n @chairs = Chair.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chairs }\n end\n end",
"def show\n @kansei_buhin = KanseiBuhin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kansei_buhin }\n end\n end",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end",
"def show\n @kennel_litter = KennelLitter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kennel_litter }\n end\n end",
"def show\n @shunfengch = Shunfengche.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shunfengch }\n end\n end",
"def show\n @harvesting = Harvesting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvesting }\n end\n end",
"def show\n @harvesting = Harvesting.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvesting }\n end\n end",
"def show\n @hair_colour = HairColour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hair_colour }\n end\n end",
"def index\n @karyalay_caterers = KaryalayCaterer.all\n render json: @karyalay_caterers\n end",
"def show\n @bruger = Bruger.find_by_id(current_user.id)\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onske }\n end\n end",
"def show\n # @kokyaku = Kokyaku.find(params[:id])\n @kokyaku = Kokyaku.find(:first, :conditions => {:kokyakuId => params[:id], :delFlg => 0})\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kokyaku }\n end\n end",
"def show\n @api_haiku = Api::Haiku.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_haiku }\n end\n end",
"def show\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recipy }\n end\n end",
"def index\n @hikers = Hiker.all\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 get\n @dish = Dish.find_by_id(params[:id]) || Dish.find_or_create_by_name(params[:name])\n respond_to do |format|\n format.json { render json: @dish.id }\n end\n end",
"def show\n @squish = Squish.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @squish }\n end\n end",
"def show\n @kpt = Kpt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kpt }\n end\n end",
"def show\n @karteikarte = Karteikarte.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @karteikarte }\n end\n end",
"def show\n @saiken = Saiken.find(params[:id])\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @saiken }\n end\n end",
"def show\n @hacker = Hacker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hacker }\n end\n end",
"def show\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @specie }\n end\n end",
"def index\n skickers = Skicker.order(power: :asc)\n render json: { status: 'SUCCESS', message: 'Loaded skickers', value: skickers }\n end",
"def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end",
"def show\n @kullanici = Kullanici.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kullanici }\n end\n end",
"def show\n @sleuths = HTTParty.get('https://webservice.wikipathways.org/findPathwaysByText?query=' + @sleuth.ext_gene + '&species=homo+sapiens&format=json',\n :headers =>{'Content-Type' => 'application/json'} )\n @pubs = HTTParty.get('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=json&term='+ @sleuth.ext_gene,\n :headers =>{'Content-Type' => 'application/json'} )\n end",
"def show\n @shoe = Shoe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shoe }\n end\n end",
"def show\n @hitchhike = Hitchhike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hitchhike }\n end\n end",
"def show\n @rink_league = RinkLeague.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink_league }\n end\n end",
"def show\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @punt }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def show\n @mostsmallresource = Mostsmallresource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallresource }\n end\n end",
"def show\n @hasil = Hasil.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hasil }\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 show\n @harvest = Harvest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvest }\n end\n end",
"def show\n @harvest = Harvest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvest }\n end\n end",
"def show\n @cheque = Cheque.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cheque }\n end\n end",
"def show\n @hetong = Hetong.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hetong }\n end\n end",
"def show\n begin\n @fucker = Fucker.find(params[:id])\n respond_to do |format|\n format.json { render json: @fucker }\n end\n rescue => err\n $log.warn(err)\n respond_to do |format|\n format.json { render json: err, status: :internal_server_error }\n end\n end\n end",
"def show\n @kf_diary = Kf::Diary.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_diary }\n end\n end",
"def index\n @wigs = Wig.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wigs }\n end\n end",
"def show\n @he = He.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @he }\n end\n end",
"def index\n @shoes = Shoe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shoes }\n end\n end",
"def show\n @golfer = Golfer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golfer }\n end\n end",
"def show\n @guitar = Guitar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guitar }\n end\n end",
"def index\n @economy_hands = EconomyHand.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @economy_hands }\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def index\n @keys = Key.all\n render json: @keys\n end",
"def index\n @rinks = Rink.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @kistings = Kisting.all\n end",
"def show\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kv }\n end\n end",
"def show\n @research = Research.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research }\n end\n end",
"def show\n @key = Key.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key }\n end\n end",
"def show\n @kf_status = Kf::Status.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_status }\n end\n end",
"def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end",
"def show\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rayon }\n end\n end",
"def show\n @rider = Rider.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rider }\n end\n end",
"def show\n @rider = Rider.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rider }\n end\n end",
"def show \n render json: @key\n end",
"def show\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @renter }\n end\n end"
] | [
"0.6977528",
"0.6757544",
"0.6619993",
"0.65624136",
"0.6532964",
"0.6509917",
"0.64181507",
"0.63769203",
"0.6376468",
"0.6366866",
"0.6349936",
"0.631369",
"0.6307003",
"0.63015926",
"0.62812805",
"0.62634414",
"0.6252709",
"0.62331706",
"0.61636144",
"0.6149472",
"0.6131012",
"0.610938",
"0.60944027",
"0.6089016",
"0.6073782",
"0.6073083",
"0.6061136",
"0.603932",
"0.6031992",
"0.6028151",
"0.6028151",
"0.60263485",
"0.6015402",
"0.6011866",
"0.60032684",
"0.5998135",
"0.59949464",
"0.5992354",
"0.5990244",
"0.5985969",
"0.5983362",
"0.59758186",
"0.5972073",
"0.5960917",
"0.5953133",
"0.5947074",
"0.59435856",
"0.59435856",
"0.59261966",
"0.59222984",
"0.591615",
"0.5909325",
"0.59080875",
"0.59006315",
"0.5897546",
"0.5896864",
"0.58960944",
"0.5887382",
"0.58831465",
"0.5879507",
"0.5876195",
"0.5868834",
"0.58674896",
"0.58626866",
"0.5862064",
"0.58618957",
"0.58595276",
"0.5858969",
"0.58589655",
"0.5853819",
"0.5849114",
"0.5848954",
"0.5847306",
"0.58427006",
"0.583903",
"0.58381635",
"0.58381635",
"0.5836436",
"0.58342755",
"0.5831339",
"0.5828367",
"0.5825368",
"0.5824315",
"0.58239686",
"0.5821461",
"0.5820317",
"0.58191985",
"0.58188474",
"0.58155745",
"0.5815421",
"0.581484",
"0.58086914",
"0.5807433",
"0.5805335",
"0.58024675",
"0.5799857",
"0.5798607",
"0.579547",
"0.579547",
"0.57852453",
"0.57812405"
] | 0.0 | -1 |
POST /krishes POST /krishes.json | def create
@krish = Krish.new(krish_params)
respond_to do |format|
if @krish.save
format.html { redirect_to @krish, notice: 'Krish was successfully created.' }
format.json { render action: 'show', status: :created, location: @krish }
else
format.html { render action: 'new' }
format.json { render json: @krish.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kraj = Kraj.new(params[:kraj])\n\n respond_to do |format|\n if @kraj.save\n format.html { redirect_to @kraj, notice: 'Kraj was successfully created.' }\n format.json { render json: @kraj, status: :created, location: @kraj }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kraj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @krishes = Krish.all\n end",
"def create\n @heli_kit = HeliKit.new(params[:heli_kit])\n\n respond_to do |format|\n if @heli_kit.save\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully created.' }\n format.json { render json: @heli_kit, status: :created, location: @heli_kit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hk = Hk.new(hk_params)\n\n respond_to do |format|\n if @hk.save\n format.html { redirect_to @hk, notice: 'Hk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hk }\n else\n format.html { render action: 'new' }\n format.json { render json: @hk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @keihi = Keihi.new(keihi_params)\n\n respond_to do |format|\n if @keihi.save\n format.html { redirect_to @keihi, notice: 'Keihi was successfully created.' }\n format.json { render :show, status: :created, location: @keihi }\n else\n format.html { render :new }\n format.json { render json: @keihi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kh = Kh.new(kh_params)\n\n respond_to do |format|\n if @kh.save\n format.html { redirect_to @kh, notice: 'Kh was successfully created.' }\n format.json { render :show, status: :created, location: @kh }\n else\n format.html { render :new }\n format.json { render json: @kh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scratcher = Scratcher.new(permitted_params)\n\n if @scratcher.save\n render json: @scratcher, status: :created, location: @scratcher\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def create\n @hiker = Hiker.new(hiker_params)\n\n respond_to do |format|\n if @hiker.save\n format.html { redirect_to @hiker, notice: 'Hiker was successfully created.' }\n format.json { render :show, status: :created, location: @hiker }\n else\n format.html { render :new }\n format.json { render json: @hiker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @keiyaku = Keiyaku.new(keiyaku_params)\n\n respond_to do |format|\n if @keiyaku.save\n format.html { redirect_to @keiyaku, notice: 'Keiyaku was successfully created.' }\n format.json { render :show, status: :created, location: @keiyaku }\n else\n format.html { render :new }\n format.json { render json: @keiyaku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shelter = Shelter.new(shelter_params)\n\n if @shelter.save\n render json: @shelter, status: :created, location: @shelter\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end",
"def create\n @koti = Koti.new(params[:koti])\n\n respond_to do |format|\n if @koti.save\n format.html { redirect_to @koti, notice: 'Koti was successfully created.' }\n format.json { render json: @koti, status: :created, location: @koti }\n else\n format.html { render action: \"new\" }\n format.json { render json: @koti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kniha = Kniha.new(kniha_params)\n\n respond_to do |format|\n if @kniha.save\n format.html { redirect_to @kniha, notice: 'Kniha was successfully created.' }\n format.json { render :show, status: :created, location: @kniha }\n else\n format.html { render :new }\n format.json { render json: @kniha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cheer = Cheer.new(params[:cheer])\n\n respond_to do |format|\n if @cheer.save\n format.html { redirect_to @cheer, notice: 'Cheer was successfully created.' }\n format.json { render json: @cheer, status: :created, location: @cheer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cheer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @inchicken_dish = InchickenDish.new(inchicken_dish_params)\n\n respond_to do |format|\n if @inchicken_dish.save\n format.html { redirect_to @inchicken_dish, notice: 'Inchicken dish was successfully created.' }\n format.json { render :show, status: :created, location: @inchicken_dish }\n else\n format.html { render :new }\n format.json { render json: @inchicken_dish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rishabh = Rishabh.new(rishabh_params)\n\n respond_to do |format|\n if @rishabh.save\n format.html { redirect_to @rishabh, notice: 'Rishabh was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rishabh }\n else\n format.html { render action: 'new' }\n format.json { render json: @rishabh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dish = @cafeteria.dishes.new(dish_params)\n\n respond_to do |format|\n if @dish.save\n format.html { redirect_to @cafeteria, notice: 'El plato se ha creado.' }\n format.json { render :show, status: :created, location: @dish }\n else\n format.html { redirect_to @cafeteria, alert: 'No se pudo crear el plato.' }\n format.json { render json: @dish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @koszyk = Koszyk.new(koszyk_params)\n\n respond_to do |format|\n if @koszyk.save\n format.html { redirect_to @koszyk, notice: 'Koszyk was successfully created.' }\n format.json { render :show, status: :created, location: @koszyk }\n else\n format.html { render :new }\n format.json { render json: @koszyk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jyanken = Jyanken.new(jyanken_params)\n\n respond_to do |format|\n if @jyanken.save\n format.html { redirect_to @jyanken, notice: 'Jyanken was successfully created.' }\n format.json { render :show, status: :created, location: @jyanken }\n else\n format.html { render :new }\n format.json { render json: @jyanken.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @knol = Knol.new(knol_params)\n\n respond_to do |format|\n if @knol.save\n format.html { redirect_to @knol, notice: 'Knol was successfully created.' }\n format.json { render action: 'show', status: :created, location: @knol }\n else\n format.html { render action: 'new' }\n format.json { render json: @knol.errors, status: :unprocessable_entity }\n end\n end\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 @kindergarten = Kindergarten.new(kindergarten_params)\n\n respond_to do |format|\n if @kindergarten.save\n format.html { redirect_to @kindergarten, notice: 'Kindergarten was successfully created.' }\n format.json { render :show, status: :created, location: @kindergarten }\n else\n format.html { render :new }\n format.json { render json: @kindergarten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @squawk = Squawk.new(params[:squawk])\n\n respond_to do |format|\n if @squawk.save\n format.html { redirect_to @squawk, notice: 'Squawk was successfully created.' }\n format.json { render json: @squawk, status: :created, location: @squawk }\n else\n format.html { render action: \"new\" }\n format.json { render json: @squawk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n title = params[:title]\n room_key = params[:rtok]\n room_id = params[:rid]\n room = Room.find_by_id(room_id.to_i) if room_id\n\n raise \"Access Denied\" unless room && room_key && room.key == room_key\n\n sgfdata = \"\"\n sgfdata = params[:sgffile].read if params[:sgffile]\n sgfdata = CGI.unescapeHTML(params[:sgfdata]) if params[:sgfdata]\n\n code_name = {\n Kconv::EUC => Encoding::EUC_JP,\n Kconv::SJIS => Encoding::Shift_JIS,\n Kconv::UTF8 => Encoding::UTF_8\n }\n sgfdata.encode!(\"UTF-8\", code_name[Kconv.guess(sgfdata)], invalid: :replace, undef: :replace, replace: \"?\")\n\n node = nil\n begin\n node = SgfReader.new.read_sgf(sgfdata)\n rescue SgfParseError => e\n session[:sgfdata] = sgfdata\n redirect_to controller: :rooms, action: :show, id: room_id, rtok: room_key, error_message: e.message\n return\n end\n\n facade = SgfNodeFacade.new(node)\n facade.set_helper(\"GM\", \"1\")\n facade.set_helper(\"FF\", \"4\")\n facade.set_helper(\"SZ\", \"19\")\n\n @kifu = Kifu.new(title: title, room_id: room_id, key: SecureRandom.urlsafe_base64(64), sgfdata: facade.to_sgf)\n @kifu.player_black = facade.player_black\n @kifu.player_white = facade.player_white\n @kifu.play_date = facade.date\n\n respond_to do |format|\n if @kifu.save\n format.html { redirect_to view_context.sec_kifu_path(@kifu), notice: 'Kifu was successfully created.' }\n format.json { render :show, status: :created, location: @kifu }\n else\n format.html { render :new }\n format.json { render json: @kifu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def krish_params\n params.require(:krish).permit(:name, :location, :is_succes, :user_count, :employe_id, :user_id)\n end",
"def create\n @onske = Onske.new(params[:onske])\n\n respond_to do |format|\n if @onske.save\n format.html { redirect_to @onske, notice: 'Onske was successfully created.' }\n format.json { render json: @onske, status: :created, location: @onske }\n else\n format.html { render action: \"new\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n render json: Dish.create(dish_params)\n end",
"def destroy\n @krish.destroy\n respond_to do |format|\n format.html { redirect_to krishes_url }\n format.json { head :no_content }\n end\n end",
"def create\n @kontum = Kontum.new(kontum_params)\n\n respond_to do |format|\n if @kontum.save\n format.html { redirect_to @kontum, notice: 'Kontum was successfully created.' }\n format.json { render :show, status: :created, location: @kontum }\n else\n format.html { render :new }\n format.json { render json: @kontum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kwasny = Kwasny.new(kwasny_params)\n\n respond_to do |format|\n if @kwasny.save\n format.html { redirect_to @kwasny, notice: 'Kwasny was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kwasny }\n else\n format.html { render action: 'new' }\n format.json { render json: @kwasny.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kisting = Kisting.new(kisting_params)\n\n respond_to do |format|\n if @kisting.save\n format.html { redirect_to @kisting, notice: 'Kisting was successfully created.' }\n format.json { render :show, status: :created, location: @kisting }\n else\n format.html { render :new }\n format.json { render json: @kisting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wk = Wk.new(params[:wk])\n\n respond_to do |format|\n if @wk.save\n format.html { redirect_to @wk, notice: 'Wk was successfully created.' }\n format.json { render json: @wk, status: :created, location: @wk }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kitten = Kitten.new(params[:kitten])\n\n respond_to do |format|\n if @kitten.save\n format.html { redirect_to @kitten, notice: 'Kitten was successfully created.' }\n format.json { render json: @kitten, status: :created, location: @kitten }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kicker = Kicker.new(kicker_params)\n\n respond_to do |format|\n if @kicker.save\n format.html { redirect_to @kicker, notice: 'Kicker was successfully created.' }\n format.json { render :show, status: :created, location: @kicker }\n else\n format.html { render :new }\n format.json { render json: @kicker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rock = Rock.new(rock_params)\n\n if @rock.save\n render json: @rock, status: :created\n else\n render json: @rock.errors, status: :unprocessable_entity\n end\n end",
"def new\n @squawk = Squawk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @squawk }\n end\n end",
"def create\n @hoge = Hoge.new(params[:hoge])\n\n respond_to do |format|\n if @hoge.save\n format.html { redirect_to @hoge, notice: 'Hoge was successfully created.' }\n format.json { render json: @hoge, status: :created, location: @hoge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kennkoukiroku = Kennkoukiroku.new(kennkoukiroku_params)\n\n respond_to do |format|\n if @kennkoukiroku.save\n format.html { redirect_to @kennkoukiroku, notice: \"健康記録を追加しました\" }\n format.json { render :show, status: :created, location: @kennkoukiroku }\n else\n format.html { render :new }\n format.json { render json: @kennkoukiroku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kifu = Kifu.new(params[:kifu])\n\n respond_to do |format|\n if @kifu.save\n format.html { redirect_to @kifu, :notice => 'Kifu was successfully created.' }\n format.json { render :json => @kifu, :status => :created, :location => @kifu }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @kifu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @karutum = Karutum.new(karutum_params)\n\n respond_to do |format|\n if @karutum.save\n format.html { redirect_to @karutum, notice: 'Karutum was successfully created.' }\n format.json { render :show, status: :created, location: @karutum }\n else\n format.html { render :new }\n format.json { render json: @karutum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hitchhike = Hitchhike.new(params[:hitchhike])\n\n respond_to do |format|\n if @hitchhike.save\n format.html { redirect_to(@hitchhike, :notice => 'Hitchhike was successfully created.') }\n format.xml { render :xml => @hitchhike, :status => :created, :location => @hitchhike }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hitchhike.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n hawkData = {\n # The first value [name:] corresponds to the backend object model\n # The second value [params[:name]] corresponds to the frontend\n name: params[:java_script_name],\n species: params[:java_script_species]\n }\n Hawk.create(hawkData)\n #render json: hawk\n end",
"def create\n @linhkien = Linhkien.new(linhkien_params)\n\n respond_to do |format|\n if @linhkien.save\n format.html { redirect_to @linhkien, notice: 'Linhkien was successfully created.' }\n format.json { render :show, status: :created, location: @linhkien }\n else\n format.html { render :new }\n format.json { render json: @linhkien.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @carrierknowledghe = Carrierknowledghe.new(carrierknowledghe_params)\n\n respond_to do |format|\n if @carrierknowledghe.save\n format.html { redirect_to @carrierknowledghe, notice: 'Carrierknowledghe was successfully created.' }\n format.json { render :show, status: :created, location: @carrierknowledghe }\n else\n format.html { render :new }\n format.json { render json: @carrierknowledghe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kolegij = Kolegij.new(params[:kolegij])\n\n respond_to do |format|\n if @kolegij.save\n format.html { redirect_to @kolegij, notice: 'Kolegij was successfully created.' }\n format.json { render json: @kolegij, status: :created, location: @kolegij }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kolegij.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kofu = Kofu.new(kofu_params)\n\n respond_to do |format|\n if @kofu.save\n format.html { redirect_to @kofu, notice: 'Kofu was successfully created.' }\n format.json { render :show, status: :created, location: @kofu }\n else\n format.html { render :new }\n format.json { render json: @kofu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @klasa = Klasa.new(klasa_params)\n\n respond_to do |format|\n if @klasa.save\n format.html { redirect_to @klasa, notice: 'Klasa was successfully created.' }\n format.json { render :show, status: :created, location: @klasa }\n else\n format.html { render :new }\n format.json { render json: @klasa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cheep = Cheep.new(cheep_params)\n\n respond_to do |format|\n if @cheep.save\n format.html { redirect_to @cheep, notice: 'Cheep was successfully created.' }\n format.json { render :show, status: :created, location: @cheep }\n else\n format.html { render :new }\n format.json { render json: @cheep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kierownik = Kierownik.new(kierownik_params)\n\n respond_to do |format|\n if @kierownik.save\n format.html { redirect_to @kierownik, notice: 'Kierownik was successfully created.' }\n format.json { render :show, status: :created, location: @kierownik }\n else\n format.html { render :new }\n format.json { render json: @kierownik.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kokyaku = Kokyaku.new\n @shobyo = Shobyo.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kokyaku }\n end\n end",
"def create\n @kit = Kit.new(kit_params)\n\n respond_to do |format|\n if @kit.save\n format.html { redirect_to @kit, notice: 'Kit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kit }\n else\n format.html { render action: 'new' }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kanri_daicho = KanriDaicho.new(kanri_daicho_params)\n\n respond_to do |format|\n if @kanri_daicho.save\n format.html { redirect_to @kanri_daicho, notice: 'Kanri daicho was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kanri_daicho }\n else\n format.html { render action: 'new' }\n format.json { render json: @kanri_daicho.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rh = Rh.new(rh_params)\n\n respond_to do |format|\n if @rh.save\n format.html { redirect_to @rh, notice: 'Rh was successfully created.' }\n format.json { render action: 'show', status: :created, location: @rh }\n else\n format.html { render action: 'new' }\n format.json { render json: @rh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @wk = Wk.new(wk_params)\n\n respond_to do |format|\n if @wk.save\n format.html { redirect_to @wk, notice: 'Wk was successfully created.' }\n format.json { render :show, status: :created, location: @wk }\n else\n format.html { render :new }\n format.json { render json: @wk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kumo = Kumo.new(kumo_params)\n\n respond_to do |format|\n if @kumo.save\n format.html { redirect_to kumos_path, notice: 'Kumo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kumo }\n else\n format.html { render action: 'new' }\n format.json { render json: @kumo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @chest = Chest.new(chest_params)\n\n respond_to do |format|\n if @chest.save\n format.html { redirect_to @chest, notice: 'Chest was successfully created.' }\n format.json { render :show, status: :created, location: @chest }\n else\n format.html { render :new }\n format.json { render json: @chest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @risk = Risk.new(risk_params)\n respond_to do |format|\n if @risk.save\n format.html { redirect_to @risk, notice: 'Risk was successfully created.' }\n format.json { render :show, status: :created, location: @risk }\n else\n format.html { render :new }\n format.json { render json: @risk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event_karaoke = Event::Karaoke.new(params[:event_karaoke])\n\n respond_to do |format|\n if @event_karaoke.save\n format.html { redirect_to @event_karaoke, notice: 'Karaoke was successfully created.' }\n format.json { render json: @event_karaoke, status: :created, location: @event_karaoke }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_karaoke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kid = Kid.new(kid_params)\n\n respond_to do |format|\n if @kid.save\n format.html { redirect_to @kid, notice: t('kid_created') }\n format.json { render :show, status: :created, location: @kid }\n else\n format.html { render :new }\n format.json { render json: @kid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @werk = Werk.new(werk_params)\n\n respond_to do |format|\n if @werk.save\n format.html { redirect_to @werk, notice: 'Werk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @werk }\n else\n format.html { render action: 'new' }\n format.json { render json: @werk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @heli_kit = HeliKit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heli_kit }\n end\n end",
"def create\n @riesgo = Riesgo.new(riesgo_params)\n\n respond_to do |format|\n if @riesgo.save\n format.html { redirect_to @riesgo, notice: 'Riesgo was successfully created.' }\n format.json { render :show, status: :created, location: @riesgo }\n else\n format.html { render :new }\n format.json { render json: @riesgo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kingsizeb = Kingsizeb.new(kingsizeb_params)\n\n respond_to do |format|\n if @kingsizeb.save\n format.html { redirect_to @kingsizeb, notice: 'Kingsizeb was successfully created.' }\n format.json { render :show, status: :created, location: @kingsizeb }\n else\n format.html { render :new }\n format.json { render json: @kingsizeb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kraj = Kraj.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kraj }\n end\n end",
"def create\n @kick = Kick.new(kick_params)\n\n respond_to do |format|\n if @kick.save\n format.html { redirect_to @kick, notice: 'Kick was successfully created.' }\n format.json { render :show, status: :created, location: @kick }\n else\n format.html { render :new }\n format.json { render json: @kick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_json_success\n c = Example::HaberdasherClient.new(conn_stub(\"/example.Haberdasher/MakeHat\") {|req|\n [200, jsonheader, '{\"inches\": 99, \"color\": \"red\"}']\n }, content_type: \"application/json\")\n\n resp = c.make_hat({})\n assert_nil resp.error\n assert_equal 99, resp.data.inches\n assert_equal \"red\", resp.data.color\n end",
"def create\n @rekamsensor = Rekamsensor.new(rekamsensor_params)\n\n respond_to do |format|\n if @rekamsensor.save\n format.html { redirect_to @rekamsensor, notice: 'Rekamsensor was successfully created.' }\n format.json { render :show, status: :created, location: @rekamsensor }\n else\n format.html { render :new }\n format.json { render json: @rekamsensor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @skater = Skater.new(skater_params)\n\n respond_to do |format|\n if @skater.save\n format.html { redirect_to @skater, notice: 'Skater was successfully created.' }\n format.json { render :show, status: :created, location: @skater }\n else\n format.html { render :new }\n format.json { render json: @skater.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @skater = Skater.new(skater_params)\n\n respond_to do |format|\n if @skater.save\n format.html { redirect_to @skater, notice: 'Skater was successfully created.' }\n format.json { render :show, status: :created, location: @skater }\n else\n format.html { render :new }\n format.json { render json: @skater.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kheer_job = ::KheerJob.new(kheer_job_params)\n\n respond_to do |format|\n if @kheer_job.save\n format.html { \n States::KheerJobState.new(@kheer_job).setNew\n redirect_to khajuri_data_kheer_job_url(@kheer_job), notice: 'Kheer job was successfully created.' \n }\n format.json { render action: 'show', status: :created, location: @kheer_job }\n else\n format.html { render action: 'new' }\n format.json { render json: @kheer_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shoe = @runner.shoes.new(shoe_params) \n\n respond_to do |format|\n if @shoe.save\n format.html { redirect_to runner_shoes_path, notice: 'Zapatilla creada satisfactoriamente.' }\n format.json { render action: 'index', status: :created, location: @shoe }\n else\n format.html { render action: 'new' }\n format.json { render json: @shoe.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def create\n @hair = Hair.new(hair_params)\n\n respond_to do |format|\n if @hair.save\n\n\n format.html { redirect_to @hair, notice: 'Hair was successfully created.' }\n format.json { render :show, status: :created, location: @hair }\n else\n format.html { render :new }\n format.json { render json: @hair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def shark_params\n\t\tparams.require(:shark).permit(:name, :age, :enjoys)\n\tend",
"def create\n @johari = Johari.new(johari_params)\n\n respond_to do |format|\n if @johari.save\n format.html { redirect_to johariscores_url, notice: 'Johari was successfully created.' }\n format.json { render :show, status: :created, location: @johari }\n else\n format.html { render :new }\n format.json { render json: @johari.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @raking = RakingExam.new(raking_params)\n update_init(@raking)\n\n respond_to do |format|\n if @raking.save\n format.html { redirect_to @raking, notice: 'Raking was successfully created.' }\n format.json { render :show, status: :created, location: @raking }\n else\n format.html { render :new }\n format.json { render json: @raking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shunfengch = Shunfengche.new(params[:shunfengch])\n\n respond_to do |format|\n if @shunfengch.save\n format.html { redirect_to @shunfengch, notice: 'Shunfengche was successfully created.' }\n format.json { render json: @shunfengch, status: :created, location: @shunfengch }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shunfengch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @squawk = Squawk.new(squawk_params)\n # current_user.squawks << @squawk\n\n respond_to do |format|\n if current_user.squawks << @squawk\n format.html { redirect_to :back, notice: 'squawk was successfully created.' }\n format.json { render :show, status: :created, location: @squawk }\n else\n format.html { render :new }\n format.json { render json: @squawk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kickoff = Kickoff.new(params[:kickoff])\n\n respond_to do |format|\n if @kickoff.save\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully created.' }\n format.json { render json: @kickoff, status: :created, location: @kickoff }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @golden_horse = GoldenHorse.new(golden_horse_params)\n\n respond_to do |format|\n if @golden_horse.save\n format.html { redirect_to @golden_horse, notice: 'Golden horse was successfully created.' }\n format.json { render :show, status: :created, location: @golden_horse }\n else\n format.html { render :new }\n format.json { render json: @golden_horse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n logger.debug(params[:konyu_rireki])\n @konyuRireki = KonyuRireki.new(params[:konyu_rireki])\n set_image_to_model\n\n # 現在日付から年度を取得する\n nend = get_nend()\n\n # 購入履歴IDの年度内最大値を取得する\n maxId = KonyuRireki.maximum(:konyuRirekiId, :conditions => [\"\\\"konyuRirekiId\\\" BETWEEN ? AND ?\", (nend.to_s + \"0000000\").to_i, (nend.to_s + \"9999999\").to_i])\n if maxId.blank? then\n maxId = 0;\n end\n maxId_s = maxId.to_s\n if maxId_s.size > 7 then\n maxId = maxId_s[(maxId_s.size - 7),7].to_i\n end\n\n # 購入履歴IDを生成する -> 年度下2桁+7桁の連番\n @konyuRireki.konyuRirekiId = \"#{nend}#{format(\"%07d\",(maxId + 1))}\".to_i\n\n respond_to do |format|\n if @konyuRireki.save\n format.html { redirect_to action: \"index\", notice: 'KonyuRireki was successfully created.', reload: 'on' }\n format.json { render json: @konyuRireki, status: :created, location: @konyuRireki }\n else\n format.html { render action: \"new\" }\n format.json { render json: @konyuRireki.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shichoson = Shichoson.new(params[:shichoson])\n\n respond_to do |format|\n if @shichoson.save\n format.html { redirect_to @shichoson, notice: 'Shichoson was successfully created.' }\n format.json { render json: @shichoson, status: :created, location: @shichoson }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shichoson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def keihi_params\n params.require(:keihi).permit(:date, :kamoku_id_id, :tekiyou, :kingaku)\n end",
"def create\n @ra_khoi_dang = RaKhoiDang.new(ra_khoi_dang_params)\n\n respond_to do |format|\n if @ra_khoi_dang.save\n format.html { redirect_to @ra_khoi_dang, notice: 'Ra khoi dang was successfully created.' }\n format.json { render :show, status: :created, location: @ra_khoi_dang }\n else\n format.html { render :new }\n format.json { render json: @ra_khoi_dang.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @epicrisis = Epicrisis.new(epicrisis_params)\n\n respond_to do |format|\n if @epicrisis.save\n format.html { redirect_to @epicrisis, notice: 'Epicrisis was successfully created.' }\n format.json { render :show, status: :created, location: @epicrisis }\n else\n format.html { render :new }\n format.json { render json: @epicrisis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def jyanken_params\n params.require(:jyanken).permit(:human, :computer, :judgment)\n end",
"def create\n @kalo = Kalo.new(kalo_params)\n\n respond_to do |format|\n if @kalo.save\n format.html { redirect_to @kalo, notice: 'Kalo was successfully created.' }\n format.json { render :show, status: :created, location: @kalo }\n else\n format.html { render :new }\n format.json { render json: @kalo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cheerup = Cheerup.new(cheerup_params)\n\n respond_to do |format|\n if @cheerup.save\n format.html { redirect_to @cheerup, notice: 'Cheerup was successfully created.' }\n format.json { render :show, status: :created, location: @cheerup }\n else\n format.html { render :new }\n format.json { render json: @cheerup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kitty = Kitty.new(params[:kitty])\n\n respond_to do |format|\n if @kitty.save\n format.html { redirect_to @kitty, notice: 'Kitty was successfully created.' }\n format.json { render json: @kitty, status: :created, location: @kitty }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kolegiji = Kolegiji.new(params[:kolegiji])\n\n respond_to do |format|\n if @kolegiji.save\n format.html { redirect_to @kolegiji, notice: 'Kolegiji was successfully created.' }\n format.json { render json: @kolegiji, status: :created, location: @kolegiji }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kolegiji.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n whiskeyParams = params[:whiskey]\n\n if !whiskeyParams.has_key?(:distillery) and whiskeyParams.has_key?(:distillery_id)\n distillery = Distillery.find(whiskeyParams[:distillery_id])\n whiskeyParams[:distillery] = distillery\n whiskeyParams.delete(:distillery_id)\n end\n\n if !whiskeyParams.has_key?(:category) and whiskeyParams.has_key?(:category_id)\n category = Category.find(whiskeyParams[:category_id])\n whiskeyParams[:category] = category\n whiskeyParams.delete(:category_id)\n end\n\n @whiskey = Whiskey.new(whiskeyParams)\n\n respond_to do |format|\n if @whiskey.save\n format.html { redirect_to @whiskey, :notice => 'Whiskey was successfully created.' }\n format.json { render :json => @whiskey, :status => :created, :location => @whiskey }\n format.xml { render :xml => @whiskey, :status => :created, :location => @whiskey }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @whiskey.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @whiskey.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @skid = Skid.new(params[:skid])\n\n respond_to do |format|\n if @skid.save\n format.html { redirect_to @skid, notice: 'Skid was successfully created.' }\n format.json { render json: @skid, status: :created, location: @skid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @chicken_run = ChickenRun.new(chicken_run_params)\n\n respond_to do |format|\n if @chicken_run.save\n format.html { redirect_to @chicken_run, notice: 'Chicken run was successfully created.' }\n format.json { render :show, status: :created, location: @chicken_run }\n else\n format.html { render :new }\n format.json { render json: @chicken_run.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kai2_ji7 = Kai2Ji7.new(kai2_ji7_params)\n\n respond_to do |format|\n if @kai2_ji7.save\n format.html { redirect_to @kai2_ji7, notice: 'Kai2 ji7 was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kai2_ji7 }\n else\n format.html { render action: 'new' }\n format.json { render json: @kai2_ji7.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @harvesting = Harvesting.new(params[:harvesting])\n\n respond_to do |format|\n if @harvesting.save\n format.html { redirect_to @harvesting, notice: 'Harvesting was successfully created.' }\n format.json { render json: @harvesting, status: :created, location: @harvesting }\n else\n format.html { render action: \"new\" }\n format.json { render json: @harvesting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hollywood = Hollywood.new(hollywood_params)\n\n respond_to do |format|\n if @hollywood.save\n format.html { redirect_to @hollywood, notice: 'Hollywood was successfully created.' }\n format.json { render :show, status: :created, location: @hollywood }\n else\n format.html { render :new }\n format.json { render json: @hollywood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hollywood = Hollywood.new(hollywood_params)\n\n respond_to do |format|\n if @hollywood.save\n format.html { redirect_to @hollywood, notice: 'Hollywood was successfully created.' }\n format.json { render :show, status: :created, location: @hollywood }\n else\n format.html { render :new }\n format.json { render json: @hollywood.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ketamine = Ketamine.new(ketamine_params)\n\n respond_to do |format|\n if @ketamine.save\n format.html { redirect_to @ketamine, notice: 'Ketamine was successfully created.' }\n format.json { render :show, status: :created, location: @ketamine }\n else\n format.html { render :new }\n format.json { render json: @ketamine.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_krish\n @krish = Krish.find(params[:id])\n end",
"def create\n @dishtype = Dishtype.new(dishtype_params)\n\n respond_to do |format|\n if @dishtype.save\n format.html { redirect_to @dishtype, notice: 'Dishtype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dishtype }\n else\n format.html { render action: 'new' }\n format.json { render json: @dishtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shouji = Shouji.new(shouji_params)\n\n respond_to do |format|\n if @shouji.save\n format.html { redirect_to @shouji, notice: 'Shouji was successfully created.' }\n format.json { render :show, status: :created, location: @shouji }\n else\n format.html { render :new }\n format.json { render json: @shouji.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @harvesting = Harvesting.new(harvesting_params)\n\n respond_to do |format|\n if @harvesting.save\n format.html { redirect_to @harvesting, notice: 'Harvesting was successfully created.' }\n format.json { render :show, status: :created, location: @harvesting }\n else\n format.html { render :new }\n format.json { render json: @harvesting.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.5828118",
"0.58169323",
"0.57454354",
"0.57131404",
"0.5639105",
"0.56224394",
"0.56178004",
"0.56003463",
"0.5546556",
"0.5528062",
"0.550135",
"0.5460965",
"0.54601884",
"0.54574925",
"0.545331",
"0.5448933",
"0.54423964",
"0.54073685",
"0.53977144",
"0.53930813",
"0.539173",
"0.5389076",
"0.5387916",
"0.5369308",
"0.53676826",
"0.53573126",
"0.533782",
"0.5326271",
"0.53235877",
"0.5312053",
"0.5291286",
"0.5286034",
"0.5274265",
"0.5274261",
"0.5267998",
"0.52674735",
"0.5261033",
"0.52547526",
"0.5249154",
"0.5245647",
"0.5238926",
"0.52376217",
"0.52374643",
"0.5228908",
"0.5227809",
"0.5225042",
"0.5224166",
"0.52213806",
"0.52213264",
"0.52204597",
"0.5217983",
"0.5213353",
"0.5208771",
"0.5207061",
"0.520244",
"0.52017367",
"0.52006084",
"0.52001494",
"0.51930076",
"0.51877093",
"0.5186363",
"0.5176976",
"0.51694876",
"0.5164124",
"0.51635647",
"0.51633704",
"0.5163169",
"0.5163169",
"0.5161628",
"0.5149098",
"0.5145554",
"0.5144712",
"0.51422185",
"0.5142074",
"0.51345384",
"0.51341563",
"0.5131028",
"0.51285374",
"0.5128431",
"0.5126864",
"0.5125842",
"0.51257473",
"0.5125332",
"0.51246095",
"0.51240206",
"0.51227164",
"0.51133376",
"0.5104891",
"0.5098867",
"0.50952685",
"0.50924677",
"0.5089535",
"0.5087718",
"0.5087333",
"0.5087333",
"0.5082571",
"0.5078858",
"0.5078758",
"0.5077797",
"0.5077523"
] | 0.61175925 | 0 |
PATCH/PUT /krishes/1 PATCH/PUT /krishes/1.json | def update
respond_to do |format|
if @krish.update(krish_params)
format.html { redirect_to @krish, notice: 'Krish was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @krish.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch!\n request! :patch\n end",
"def update\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n if @koti.update_attributes(params[:koti])\n format.html { redirect_to @koti, notice: 'Koti was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @koti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n @kickoff = Kickoff.find(params[:id])\n\n respond_to do |format|\n if @kickoff.update_attributes(params[:kickoff])\n format.html { redirect_to @kickoff, notice: 'Kickoff was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kickoff.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kraj = Kraj.find(params[:id])\n\n respond_to do |format|\n if @kraj.update_attributes(params[:kraj])\n format.html { redirect_to @kraj, notice: 'Kraj was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kraj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n if @kit.update_attributes(params[:kit])\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kit.update(kit_params)\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @knol.update(knol_params)\n format.html { redirect_to @knol, notice: 'Knol was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @knol.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n if @heli_kit.update_attributes(params[:heli_kit])\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kata.update(kata_params)\n format.html { redirect_to @kata, notice: 'Kata was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kata.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @hk.update(hk_params)\n format.html { redirect_to @hk, notice: 'Hk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kumo.update(kumo_params)\n format.html { redirect_to kumos_path, notice: 'Kumo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kumo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n if @kitten.update_attributes(params[:kitten])\n format.html { redirect_to @kitten, notice: 'Kitten was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sick.update(sick_params)\n format.html { redirect_to @sick, notice: 'Sick was successfully updated.' }\n format.json { render :show, status: :ok, location: @sick }\n else\n format.html { render :edit }\n format.json { render json: @sick.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!(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 @shelter = Shelter.find(params[:id])\n\n if @shelter.update(shelter_params)\n head :no_content\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n if @kitty.update_attributes(params[:kitty])\n format.html { redirect_to @kitty, notice: 'Kitty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kisalli = Kisalli.find_by_key(params[:id])\n\n respond_to do |format|\n if @kisalli.update_attributes(params[:kisalli])\n format.html { redirect_to @kisalli, notice: 'Kisalli was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kisalli.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n if @kolegij.update_attributes(params[:kolegij])\n format.html { redirect_to @kolegij, notice: 'Kolegij was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kolegij.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 patch(path, **args); end",
"def update\n respond_to do |format|\n if @kela.update(kela_params)\n format.html { redirect_to @kela, notice: 'Kela was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n @scratcher = Scratcher.find(params[:id])\n\n if @scratcher.update(permitted_params)\n head :no_content\n else\n render json: @scratcher.errors, status: :unprocessable_entity\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(&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, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update\n respond_to do |format|\n if @shoe.update(shoe_params)\n format.html { redirect_to runner_shoes_path, notice: 'Zapatilla actualizada satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shoe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kemboi.update(kemboi_params)\n format.html { redirect_to @kemboi, notice: 'Kemboi was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kemboi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @kit\n respond_to do |format|\n if @kit.update(kit_params)\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { render :show, status: :ok, location: @kit }\n else\n format.html { render :edit }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sheep.update(sheep_params)\n format.html { redirect_to @sheep, notice: 'Sau ble oppdatert.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sheep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cheer = Cheer.find(params[:id])\n\n respond_to do |format|\n if @cheer.update_attributes(params[:cheer])\n format.html { redirect_to @cheer, notice: 'Cheer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cheer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kontum.update(kontum_params)\n format.html { redirect_to @kontum, notice: 'Kontum was successfully updated.' }\n format.json { render :show, status: :ok, location: @kontum }\n else\n format.html { render :edit }\n format.json { render json: @kontum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:kid][:id]\n @kid = Kid.find(params[:kid][:id])\n else\n @kid = Kid.find_by_user_id_and_local_id(params[:kid][:user_id],params[:kid][:local_id])\n end\n params[:kid].delete(:user_id)\n params[:kid].delete(:id)\n if @kid.update_attributes(params[:kid])\n render json: @kid\n else\n render json: @kid.errors, status: :unprocessable_entity\n end\n end",
"def update\n @onske = Onske.find(params[:id])\n\n respond_to do |format|\n if @onske.update_attributes(params[:onske])\n format.html { redirect_to @onske, notice: 'Onske was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @onske.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @koszyk.update(koszyk_params)\n format.html { redirect_to @koszyk, notice: 'Koszyk was successfully updated.' }\n format.json { render :show, status: :ok, location: @koszyk }\n else\n format.html { render :edit }\n format.json { render json: @koszyk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rh.update(rh_params)\n format.html { redirect_to @rh, notice: 'Rh was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end",
"def update\n respond_to do |format|\n if @kisting.update(kisting_params)\n format.html { redirect_to @kisting, notice: 'Kisting was successfully updated.' }\n format.json { render :show, status: :ok, location: @kisting }\n else\n format.html { render :edit }\n format.json { render json: @kisting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @keihi.update(keihi_params)\n format.html { redirect_to @keihi, notice: 'Keihi was successfully updated.' }\n format.json { render :show, status: :ok, location: @keihi }\n else\n format.html { render :edit }\n format.json { render json: @keihi.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 respond_to do |format|\n if @kid.update(kid_params)\n format.html { redirect_to root_url, notice: 'Kid was successfully updated.' }\n format.json { render :show, status: :ok, location: @kid }\n else\n format.html { render :edit }\n format.json { render json: @kid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @klasa.update(klasa_params)\n format.html { redirect_to @klasa, notice: 'Klasa was successfully updated.' }\n format.json { render :show, status: :ok, location: @klasa }\n else\n format.html { render :edit }\n format.json { render json: @klasa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kont_klient.update(kont_klient_params)\n format.html { redirect_to @kont_klient, notice: 'Kont klient was successfully updated.' }\n format.json { render :show, status: :ok, location: @kont_klient }\n else\n format.html { render :edit }\n format.json { render json: @kont_klient.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event_karaoke = Event::Karaoke.find(params[:id])\n\n respond_to do |format|\n if @event_karaoke.update_attributes(params[:event_karaoke])\n format.html { redirect_to @event_karaoke, notice: 'Karaoke was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_karaoke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @lunch.update(lunch_params)\n format.html { redirect_to @lunch, notice: 'Lunch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lunch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @riesgo.update(riesgo_params)\n format.html { redirect_to @riesgo, notice: 'Riesgo was successfully updated.' }\n format.json { render :show, status: :ok, location: @riesgo }\n else\n format.html { render :edit }\n format.json { render json: @riesgo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chef.update(chef_params)\n format.html { redirect_to [:admin, @chef], notice: t('messages.updated', model:Chef.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @chef.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @kitchen.update_attributes(post_params)\n # format.html { redirect_to @kitchen, notice: 'Kitchen was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render action: 'edit' }\n # format.json { render json: @kitchen.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 @hoge = Hoge.find(params[:id])\n\n respond_to do |format|\n if @hoge.update_attributes(params[:hoge])\n format.html { redirect_to @hoge, notice: 'Hoge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kick.update(kick_params)\n format.html { redirect_to @kick, notice: 'Kick was successfully updated.' }\n format.json { render :show, status: :ok, location: @kick }\n else\n format.html { render :edit }\n format.json { render json: @kick.errors, status: :unprocessable_entity }\n end\n end\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\n respond_to do |format|\n if @shelter.update(shelter_params)\n format.html { redirect_to @shelter, notice: 'Shelter was successfully updated.' }\n format.json { render :show, status: :ok, location: @shelter }\n else\n format.html { render :edit }\n format.json { render json: @shelter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kid.update(kid_params)\n format.html { redirect_to @kid, notice: t('kid_updated') }\n format.json { render :show, status: :ok, location: @kid }\n else\n format.html { render :edit }\n format.json { render json: @kid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n if @joke.update_attributes(params[:joke])\n format.html { redirect_to @joke, :notice => 'Joke was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @headline.update(headline_params)\n format.html { redirect_to @headline, notice: 'Headline was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @headline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hiker.update(hiker_params)\n format.html { redirect_to @hiker, notice: 'Hiker was successfully updated.' }\n format.json { render :show, status: :ok, location: @hiker }\n else\n format.html { render :edit }\n format.json { render json: @hiker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend",
"def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end",
"def update\n @hitchhike = Hitchhike.find(params[:id])\n\n respond_to do |format|\n if @hitchhike.update_attributes(params[:hitchhike])\n format.html { redirect_to(@hitchhike, :notice => 'Hitchhike was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hitchhike.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def update\n respond_to do |format|\n if @kick.update(kick_params)\n format.html { redirect_to @kick, notice: \"Kick was successfully updated.\" }\n format.json { render :show, status: :ok, location: @kick }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @kick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kniha.update(kniha_params)\n format.html { redirect_to @kniha, notice: 'Kniha was successfully updated.' }\n format.json { render :show, status: :ok, location: @kniha }\n else\n format.html { render :edit }\n format.json { render json: @kniha.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n respond_to do |format|\n if @joke.update(joke_params)\n format.html { redirect_to @joke, notice: 'Joke was successfully updated.' }\n format.json { render :show, status: :ok, location: @joke }\n else\n format.html { render :edit }\n format.json { render json: @joke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sklad = Sklad.find(params[:id])\n\n respond_to do |format|\n if @sklad.update_attributes(params[:sklad])\n format.html { redirect_to @sklad, notice: 'Sklad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sklad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bracket_golfer.update(bracket_golfer_params)\n format.html { redirect_to @bracket_golfer, notice: 'Bracket golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bracket_golfer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @golfer = Golfer.find(params[:id])\n\n respond_to do |format|\n if @golfer.update_attributes(params[:golfer])\n format.html { redirect_to @golfer, notice: 'Golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golfer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t respond_to do |format|\n\t if @joke.update(joke_params)\n\t format.html { redirect_to @joke, notice: 'joke was successfully updated.' }\n\t format.json { render :show, status: :ok, location: @joke }\n\t else\n\t format.html { render :edit }\n\t format.json { render json: @joke.errors, status: :unprocessable_entity }\n\t end\n\t end\n\tend",
"def update\n respond_to do |format|\n if @kalo.update(kalo_params)\n format.html { redirect_to @kalo, notice: 'Kalo was successfully updated.' }\n format.json { render :show, status: :ok, location: @kalo }\n else\n format.html { render :edit }\n format.json { render json: @kalo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(path)\n output { patch(path, params) }\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", { 'passed' => success }.to_json, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @shoe.update(shoe_params)\n format.html { redirect_to @shoe, notice: t('notice.success.update',\n model: model_name) }\n format.json { render :show, status: :ok, location: @shoe }\n else\n format.html { render :edit }\n format.json { render json: @shoe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @strosek.update(strosek_params)\n format.html { redirect_to @strosek, notice: 'Strosek was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @strosek.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kifu = Kifu.find(params[:id])\n\n respond_to do |format|\n if @kifu.update_attributes(params[:kifu])\n format.html { redirect_to @kifu, :notice => 'Kifu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @kifu.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @fridge = Fridge.find(params[:id])\n\n respond_to do |format|\n if @fridge.update_attributes(params[:fridge])\n format.html { redirect_to @fridge, notice: 'Fridge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fridge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n if @kolegiji.update_attributes(params[:kolegiji])\n format.html { redirect_to @kolegiji, notice: 'Kolegiji was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kolegiji.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def update\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n if @monkey.update_attributes(params[:monkey])\n format.html { redirect_to @monkey, notice: 'Monkey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @monkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kintai.update(kintai_params)\n format.html { redirect_to @kintai, notice: 'Kintai was successfully updated.' }\n format.json { render :show, status: :ok, location: @kintai }\n else\n format.html { render :edit }\n format.json { render json: @kintai.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6548498",
"0.64746237",
"0.64552885",
"0.63674617",
"0.6347726",
"0.6305036",
"0.6280305",
"0.6232289",
"0.61980367",
"0.61739886",
"0.6171244",
"0.6136331",
"0.6131918",
"0.61314905",
"0.61225253",
"0.61162925",
"0.61161566",
"0.611597",
"0.61154187",
"0.60927117",
"0.60911006",
"0.60488176",
"0.60488176",
"0.604531",
"0.6027943",
"0.6013637",
"0.60004425",
"0.5998893",
"0.59950346",
"0.5994318",
"0.5989523",
"0.5979752",
"0.59791976",
"0.59791976",
"0.597877",
"0.59735656",
"0.5970314",
"0.5969288",
"0.5956118",
"0.59548295",
"0.59520733",
"0.5942378",
"0.5939981",
"0.59376216",
"0.5934273",
"0.59293985",
"0.5920155",
"0.5916188",
"0.59134984",
"0.59099865",
"0.59098876",
"0.5904231",
"0.5904231",
"0.5903029",
"0.58940613",
"0.58884466",
"0.5881542",
"0.58762395",
"0.58646905",
"0.5861062",
"0.58605707",
"0.58579373",
"0.58577204",
"0.58572465",
"0.58522105",
"0.58502823",
"0.5847966",
"0.5840928",
"0.5839016",
"0.5833597",
"0.58323675",
"0.58277786",
"0.58242375",
"0.5822493",
"0.5821505",
"0.5817084",
"0.5813043",
"0.5813009",
"0.58122855",
"0.58052456",
"0.5800784",
"0.5799317",
"0.57965267",
"0.57941866",
"0.57932955",
"0.5792331",
"0.5788346",
"0.57852066",
"0.5783261",
"0.5778691",
"0.5778691",
"0.5778691",
"0.57753146",
"0.57732236",
"0.5772758",
"0.57710207",
"0.5769783",
"0.57696575",
"0.57635915",
"0.5759998"
] | 0.63571364 | 4 |
DELETE /krishes/1 DELETE /krishes/1.json | def destroy
@krish.destroy
respond_to do |format|
format.html { redirect_to krishes_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @kisalli = Kisalli.find_by_key(params[:id])\n @kisalli.destroy\n\n respond_to do |format|\n format.html { redirect_to kisallis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid.destroy\n respond_to do |format|\n format.html { redirect_to kids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @koti = Koti.find(params[:id])\n @koti.destroy\n\n respond_to do |format|\n format.html { redirect_to kotis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hk.destroy\n respond_to do |format|\n format.html { redirect_to hks_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @kraj = Kraj.find(params[:id])\n @kraj.destroy\n\n respond_to do |format|\n format.html { redirect_to kraje_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @knol.destroy\n respond_to do |format|\n format.html { redirect_to knols_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @squawk = Squawk.find(params[:id])\n @squawk.destroy\n\n respond_to do |format|\n format.html { redirect_to squawks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rishabh.destroy\n respond_to do |format|\n format.html { redirect_to rishabhs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @kit.destroy\n respond_to do |format|\n format.html { redirect_to kits_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @kit = Kit.find(params[:id])\n @kit.destroy\n\n respond_to do |format|\n format.html { redirect_to kits_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @strosek.destroy\n respond_to do |format|\n format.html { redirect_to stroseks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kh.destroy\n respond_to do |format|\n format.html { redirect_to khs_url, notice: 'Kh was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kata.destroy\n respond_to do |format|\n format.html { redirect_to katas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete!\n request! :delete\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"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 @kai2_ji7.destroy\n respond_to do |format|\n format.html { redirect_to kai2_ji7s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid.destroy\n respond_to do |format|\n format.html { redirect_to kids_url, notice: t('kid_destroyed') }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete!\n Recliner.delete(uri)\n end",
"def destroy\n @kanri_daicho.destroy\n respond_to do |format|\n format.html { redirect_to kanri_daichos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid.destroy\n respond_to do |format|\n format.html { redirect_to kids_url, notice: 'Kid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heli_kit = HeliKit.find(params[:id])\n @heli_kit.destroy\n\n respond_to do |format|\n format.html { redirect_to heli_kits_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 @kishangarh_marble.destroy\n respond_to do |format|\n format.html { redirect_to kishangarh_marbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hoge = Hoge.find(params[:id])\n @hoge.destroy\n\n respond_to do |format|\n format.html { redirect_to hoges_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @kyu_entry.destroy\n respond_to do |format|\n format.html { redirect_to kyu_entries_url }\n format.json { head :ok }\n end\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def destroy\n @dish = Dish.find(params[:id])\n @dish.destroy\n\n respond_to do |format|\n format.html { redirect_to dishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish = Dish.find(params[:id])\n @dish.destroy\n\n respond_to do |format|\n format.html { redirect_to dishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kolegij = Kolegij.find(params[:id])\n @kolegij.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijs_url }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end",
"def destroy\n @dish = Dish.find(params[:id])\n @dish.destroy\n\n respond_to do |format|\n format.html { redirect_to my_page_path }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @dish.destroy\n respond_to do |format|\n format.html { redirect_to dishes_url, notice: 'El plato se ha eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inchicken_dish.destroy\n respond_to do |format|\n format.html { redirect_to inchicken_dishes_url, notice: 'Inchicken dish was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n raise \"Can't delete a resource without a REST Client\" unless @client\n @client.delete @path\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @surah.destroy\n respond_to do |format|\n format.html { redirect_to surahs_url }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @sklad = Sklad.find(params[:id])\n @sklad.destroy\n\n respond_to do |format|\n format.html { redirect_to sklads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wash = Wash.find(params[:id])\n @wash.destroy\n\n respond_to do |format|\n format.html { redirect_to washes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cow.destroy\n respond_to do |format|\n format.html { redirect_to kine_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kickoff = Kickoff.find(params[:id])\n @kickoff.destroy\n\n respond_to do |format|\n format.html { redirect_to kickoffs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ra_khoi_dang.destroy\n respond_to do |format|\n format.html { redirect_to ra_khoi_dangs_url, notice: 'Ra khoi dang was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rh.destroy\n respond_to do |format|\n format.html { redirect_to rhs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish.destroy\n respond_to do |format|\n format.html { redirect_to dishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish.destroy\n respond_to do |format|\n format.html { redirect_to dishes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @koszyk.destroy\n respond_to do |format|\n format.html { redirect_to koszyks_url, notice: 'Koszyk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kemboi.destroy\n respond_to do |format|\n format.html { redirect_to kembois_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @riesgo.destroy\n respond_to do |format|\n format.html { redirect_to riesgos_url, notice: 'Riesgo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @asthenium.destroy\n respond_to do |format|\n format.html { redirect_to asthenia_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def destroy\n @cheer = Cheer.find(params[:id])\n @cheer.destroy\n\n respond_to do |format|\n format.html { redirect_to cheers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @six.destroy\n respond_to do |format|\n format.html { redirect_to sixes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @onske = Onske.find(params[:id])\n @onske.destroy\n\n respond_to do |format|\n format.html { redirect_to onskes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @kontum.destroy\n respond_to do |format|\n format.html { redirect_to konta_url, notice: 'Kontum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def soccer_delete\n base_delete(params, \"Soccer\")\n end",
"def destroy\n @key = Key.find(params[:id])\n @key.destroy\n\n respond_to do |format|\n format.html { redirect_to keys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jedi = Jedi.find(params[:id])\n @jedi.destroy\n\n respond_to do |format|\n format.html { redirect_to jedis_url }\n format.json { head :no_content }\n end\n end",
"def 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 @shichoson = Shichoson.find(params[:id])\n @shichoson.destroy\n\n respond_to do |format|\n format.html { redirect_to shichosons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @he = He.find(params[:id])\n @he.destroy\n\n respond_to do |format|\n format.html { redirect_to hes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @squawk.destroy\n respond_to do |format|\n format.html { redirect_to squawks_url, notice: 'Squawk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @sheep.destroy\n respond_to do |format|\n format.html { redirect_to sheep_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kela.destroy\n respond_to do |format|\n format.html { redirect_to kelas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kont_klient.destroy\n respond_to do |format|\n format.html { redirect_to kont_klient_index_url, notice: 'Kont klient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n @kniha.destroy\n respond_to do |format|\n format.html { redirect_to knihy_url, notice: 'Kniha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to monkeys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kansei_buhin = KanseiBuhin.find(params[:id])\n @kansei_buhin.destroy\n\n respond_to do |format|\n format.html { redirect_to kansei_buhins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kolegiji = Kolegiji.find(params[:id])\n @kolegiji.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijis_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 @shunfengch = Shunfengche.find(params[:id])\n @shunfengch.destroy\n\n respond_to do |format|\n format.html { redirect_to shunfengches_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.71626604",
"0.6889966",
"0.6877485",
"0.68562984",
"0.68514127",
"0.68434036",
"0.6829869",
"0.68237877",
"0.6818874",
"0.67722005",
"0.673912",
"0.6737086",
"0.67237496",
"0.67152166",
"0.670024",
"0.66985",
"0.6692994",
"0.66918",
"0.66726756",
"0.6667808",
"0.6665582",
"0.66619897",
"0.66457766",
"0.6645611",
"0.6635007",
"0.66340214",
"0.6632685",
"0.6623089",
"0.66212374",
"0.66207016",
"0.66191566",
"0.66189516",
"0.6617238",
"0.66171646",
"0.66123563",
"0.6603839",
"0.6602982",
"0.6602516",
"0.6601394",
"0.6598441",
"0.65980625",
"0.65956587",
"0.6594175",
"0.65806735",
"0.65806735",
"0.65798414",
"0.65756685",
"0.6575435",
"0.65719336",
"0.65719336",
"0.65621585",
"0.65615124",
"0.6554312",
"0.655355",
"0.655355",
"0.65480316",
"0.6544675",
"0.6543911",
"0.65416837",
"0.65387255",
"0.6534447",
"0.65342236",
"0.6533066",
"0.6522443",
"0.65217245",
"0.65213686",
"0.65213686",
"0.6520412",
"0.6515571",
"0.6513987",
"0.65124613",
"0.6509501",
"0.65092564",
"0.65092564",
"0.65087247",
"0.6504728",
"0.6504547",
"0.6501803",
"0.64996064",
"0.64994407",
"0.64947474",
"0.6491146",
"0.649066",
"0.64900744",
"0.6489014",
"0.6485219",
"0.64766026",
"0.64766026",
"0.64766026",
"0.64766026",
"0.64756197",
"0.64731693",
"0.64667964",
"0.64644605",
"0.64634585",
"0.64617836",
"0.6461398",
"0.6461205",
"0.6459601",
"0.645791"
] | 0.7293339 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_krish
@krish = Krish.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 krish_params
params.require(:krish).permit(:name, :location, :is_succes, :user_count, :employe_id, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
Join the room. Pass +true+ to join even if you've already joined. | def join(force = false)
post 'join'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_room(id)\n @rooms.join id\n end",
"def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\n end\n end",
"def join_room uri\n has_room = rooms.detect { |room| room.uri == uri }\n\n return has_room if has_room\n\n @rooms = nil # clear rooms cache\n self.class.find_room(uri).join\n end",
"def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n role = @room.user_role(current_user)\n unless role == :denied\n join_internal(current_user.full_name, role, :join)\n else\n flash[:notice] = \"#{t('access_denied')}\"\n redirect_to :index and return\n end\n end",
"def join(m)\n # self.reset_timer(m)\n if Channel(@channel_name).has_user?(m.user)\n if @game.accepting_players?\n added = @game.add_player(m.user)\n unless added.nil?\n Channel(@channel_name).send \"#{m.user.nick} has joined the game (#{@game.players.count}/#{@game.max_players})\"\n Channel(@channel_name).voice(m.user)\n end\n else\n if @game.started?\n Channel(@channel_name).send \"#{m.user.nick}: Game has already started.\"\n elsif @game.at_max_players?\n Channel(@channel_name).send \"#{m.user.nick}: Game is at max players. Switch to ONUWW to add more players\"\n else\n Channel(@channel_name).send \"#{m.user.nick}: You cannot join.\"\n end\n end\n else\n User(m.user).send \"You need to be in #{@channel_name} to join the game.\"\n end\n end",
"def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end",
"def joinRoom(roomname, username)\n room = @chats.fetch roomname #get record of \"chats\"\n #puts(room)\n userID = @users.fetch username\n puts(\"joinroom userID #{userID}\")\n puts(userID)\n room.addUser(userID, username) #add user to that chat\n puts room.printMe\n end",
"def local_join(body)\n room = body.dup\n room[0,1] = '' until room[0,1] != '@'\n return nil unless room.length >= 1\n unless @var[:special_rooms].include?(room)\n room_hash = MD5::digest(room)[0,8]\n room_hash = EMPTY_ROOM if room == 'chat'\n @connection.room_names[room_hash] = room\n @connection.room_ids[room] = room_hash\n _remote_control(@var[:our_name], :invite, body, true)\n _server_control('join', room_hash)\n end\n local_switch(room.dup)\nend",
"def join\n # Check status first to see if the user can join.\n # Check if the number of users exceed the the size of the room.\n @room = Room.find(params[:id])\n\n # Room is oversize\n if @room.is_full?\n message = \"#{current_user.name} cannot joined the room because the room is full.\"\n result = false\n elsif @room.status != ROOM_STATUS[:open]\n message = \"The room #{params[:id]} is not open!\"\n elsif @room.join?(current_user)\n message = \"#{current_user.name} is already joinned the room\"\n else\n\n result = @room.join(current_user)\n if result\n message = \"#{current_user.name} has joined the room\"\n else\n message = \"#{current_user.name} cannot join the room. Server side error\"\n end\n end\n\n if result\n channel = params[:id].to_s\n respond_message = {\n message: message,\n current_user: current_user,\n room_id: @room.id,\n status: USER_STATUS[:join]\n }\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n else\n channel = \"server_channel\"\n self.broadcast_message_to_channel(channel, :user_status, respond_message)\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to @room, notice: message }\n format.json { render json: @room.to_hash_with_users(current_user).to_json, status: :created, location: @room }\n else\n format.html { render notice: \"Cannot join the room.\" }\n format.json { render json: {message: message}, status: :unprocessable_entity }\n end\n end\n end",
"def join\n\t\t@classroom = Classroom.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@membership = Membership.new\n\t\[email protected]_id = @classroom.id\n\t\[email protected]_id = params[:user_id]\n\t\tif @membership.save\n\t\t\tredirect_to params[:redirect_url] || @classroom, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to @classroom, alert: \"You are already a member of this class!\"\n\t\tend\n\tend",
"def join\n game = Game.find(params[:id])\n \n raise \"Game already started\" unless game.open?\n \n # Only add the player to the game if they aren't already in it\n game.join(current_user) unless game.has_player?(current_user)\n current_user.lives = 25\n current_user.save!\n redirect_to game_path\n rescue \n flash[:error] = \"That is not a game that can be joined\"\n redirect_to lobby_path\n end",
"def join(user)\n return false if member?(user)\n # Otherwise, we add a user\n add user\n @members.each { |m| m.notify :join, @name, :prefix => user.prefix }\n dispatch :outgoing_join, :target => @name, :nick => user.nick\n return true\n end",
"def join(id)\n precondition do\n raise unless id > 0\n end\n\n id = rpc \"join\", id \n @game.sync\n \n postcondition do\n raise unless id\n end\n end",
"def join\n @group = Group.find(params[:id])\n\n if !current_user.is_member_of?(@group)\n current_user.join!(@group)\n flash[:notice] = \"Successfully joined the group!\"\n else\n flash[:warning] = \"You are a member of this group!\"\n end\n\n redirect_to group_path(@group)\n end",
"def join\n end",
"def join\n pids = get_player_list(@match).map{|p| p.try(:id)} # list of player ids\n status = false\n if can_join(pids) #if possible, join\n status = join_now(@match, current_user.id)\n done = [\"joined\", \"success\"]\n elsif pids.include?(current_user.id) #if already joined, then leave\n status = leave_now(@match, current_user.id, @host)\n done = [\"left\", \"warning\"]\n if !get_player_list(@match).any? #if there is no more players in match, then destroy\n destroy\n return\n end\n end\n\n respond_to do |format|\n if status and @match.save\n format.html { redirect_to @match, notice: ['You have succesfully ' + done[0] + ' the match.', \"alert alert-dismissible alert-\" + done[1]] }\n else\n format.html { redirect_to @match, notice: ['Sorry, your request could not be processed.', \"alert alert-dismissible alert-danger\"] }\n end\n end\n end",
"def join\n @acceptor.join if @acceptor\n end",
"def join\n thread && thread.join\n end",
"def joined?\n meta[:joined].equal?(true)\n end",
"def join_thread\n @thread&.join\n end",
"def join\n if request_valid?\n request_user.online!\n \n msg = message(\"joined\")\n msg = javascript_chat_message(msg)\n \n # Inform all joined channels that the user has joined\n Juggernaut.send_to_channels(msg, params[:channels])\n \n render :nothing => true\n else\n # Prevent the user from joining the channel if the request is not\n # from a valid session/user combination\n render :text => \"403\", :status => 403\n end\n end",
"def join(m, channel_name = nil)\n channel = channel_name ? Channel(channel_name) : m.channel\n\n if (game2 = @user_games[m.user])\n # Be silent if the user's game is already started and user re-joins it\n # by sending !join in the same channel, or !join in a PM\n # This is so games can reuse the join command.\n different_channel = channel && channel.name != game2.channel_name\n m.reply(\"You are already in the #{game2.channel_name} game\", true) if different_channel\n return\n end\n\n if (waiting_room = @user_waiting_rooms[m.user])\n m.reply(\"You are already in the #{waiting_room.channel_name} game\", true)\n return\n end\n\n unless channel\n m.reply('To join a game via PM you must specify the channel: ' +\n '!join #channel')\n return\n end\n\n waiting_room = @waiting_rooms[channel.name]\n unless waiting_room\n m.reply(channel.name + ' is not a valid channel to join', true)\n return\n end\n\n unless channel.has_user?(m.user)\n m.reply(\"You need to be in #{channel.name} to join the game.\", true)\n return\n end\n\n if @games[channel.name]\n m.reply('Game has already started.', true)\n return\n end\n\n if waiting_room.size >= waiting_room.capacity\n m.reply(\"Game is already at #{waiting_room.capacity} players, the maximum supported for #{self.game_name}.\", true)\n return\n end\n\n waiting_room.add(m.user)\n channel.send(\"#{m.user.nick} has joined the game (#{waiting_room.size}/#{waiting_room.capacity})\")\n channel.voice(m.user)\n @user_waiting_rooms[m.user] = waiting_room\n end",
"def join\n @thread.join\n end",
"def join(channel)\n\t\t\tsend_to_server(\"JOIN #{channel}\")\n\t\tend",
"def join\n # valid user?\n if !@user\n flash[:notice => \"You must be logged in to join\" ]\n render :action => \"error\"\n return\n end\n if !@note\n flash[:notice] = \"Nothing found by that name\"\n render :action => \"error\"\n return\n end\n # already a member?\n if @note.is_a_member?(@user)\n flash[:notice] = \"You are already a member\"\n render :action => \"error\"\n return\n end\n # join\n @note.join @user\n end",
"def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end",
"def join(group)\n\t\t\treturn false unless group.is_a?(Group)\n\t\t\tgroup.add(self)\n\t\tend",
"def join\n @poller.join if @poller\n end",
"def join_path(room, name, options = {}, uid = nil)\n\n # Destroy otp current_session\n current_user.destroy_otp if current_user&.room_otp.present?\n session.delete(:otp_name)\n\n # Create the meeting, even if it's running\n start_session(room, options)\n\n # Determine the password to use when joining.\n password = options[:user_is_moderator] ? room.moderator_pw : room.attendee_pw\n\n # Generate the join URL.\n join_opts = {}\n join_opts[:userID] = uid if uid\n join_opts[:join_via_html5] = true\n\n bbb_server.join_meeting_url(room.bbb_id, name, password, join_opts)\n end",
"def join(subdomain = nil, room_name = nil, &block)\n #raise \"#{su}: #{caller[0]}\"\n\n if subdomain && room_name && !subdomain.kind_of?(Firetower::Session) && !room_name.kind_of?(Firetower::Room)\n warn \"WARNING: `join` is deprecated. use `join_room` instead: #{Kernel.caller.first.gsub(/:in .*$/, '')}\"\n join_room(subdomain, room_name)\n else\n # gross, copy pasta from hookr\n add_callback(:join, subdomain, &block)\n end\n end",
"def join\n @thread.join\n end",
"def join_lobby(player_id, lobby_id)\n find_player(player_id).join_lobby(find_lobby(lobby_id))\n self\n end",
"def join()\n raise \"Missing implementation 'join'\"\n end",
"def join(room, service, nickname = nil)\n join = Blather::Stanza::Presence::MUC.new\n join.to = if nickname\n \"#{room}@#{service}/#{nickname}\"\n else\n \"#{room}/#{service}\"\n end\n client.write join\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def join_channel(message)\n message.send_raw \"JOIN ##{message.channel.name}\"\n end",
"def do_join\n flash.keep\n begin\n # Use group invitation\n group = Group.find_by(invitation_code: params[:group][:invitation_code])\n # Fall back to normal user invitation\n if group.blank?\n invitation = GroupInvitation.get_by_invitation_code(\n params[:group][:invitation_code]\n )\n invitation.use_invitation\n group = invitation.group\n end\n group.join_group(current_user, 'member')\n flash[:notice] = 'Group joined!'\n redirect_to(action: 'show', id: group.id) && return\n rescue\n flash[:error] = 'The provided invitation code has already been used.'\n redirect_to(action: 'join') && return\n end\n end",
"def join\n @gateway.sync\n end",
"def join(channel)\n @bot.join(channel)\n end",
"def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n @membership = Membership.create\n @membership.beer_club_id = @beer_club.id\n @membership.user_id = current_user.id\n if @beer_club.memberships.count < 1\n @membership.confirmed = true\n else\n @membership.confirmed = false\n end\n respond_to do |format|\n if @membership.save\n format.html { redirect_to :back, notice: \"You joined #{@beer_club.name}\" }\n else\n format.html { redirect_to :back, notice: \"Something went awry! D:\" }\n end\n end\n end\n end",
"def join\n if !current_user\n flash[:notice] = t(:join_dream)\n elsif @camp.users.include?(current_user)\n flash[:notice] = t(:join_already_sent)\n else\n flash[:notice] = t(:join_dream)\n @camp.users << @user\n end\n redirect_to @camp\n end",
"def join\n start if [email protected]?\n @listener.join\n end",
"def join(join_clause)\n @joins.push join_clause\n self\n end",
"def join\n @server_thread.join if @server_thread\n end",
"def join_meeting(meeting_id, user_name, password, user_id = nil, web_voice_conf = nil)\n params = { :meetingID => meeting_id, :password => password, :fullName => user_name,\n :userID => user_id, :webVoiceConf => web_voice_conf }\n send_api_request(:join, params)\n end",
"def join\n @server.stop! if @server and @server.running?\n super\n end",
"def join \n\n #Check if user exists\n user = User.find_by!(id: params[:user_id])\n\n if (ChannelJoined.exists?({ channel_id: params[:id], user_id: params[:user_id]}))\n json_response({\n \"joined\": true\n })\n else\n joined = ChannelJoined.create!(user_id: params[:user_id], channel_id: params[:id])\n json_response(joined.channel)\n end\n \n \n end",
"def join(server, already); end",
"def join_request\n \n end",
"def join_meeting(meeting_id, user_name, password, options={})\n valid_options = [:userID, :webVoiceConf]\n valid_options += [:createTime] if @version >= \"0.8\"\n options.reject!{ |k,v| !valid_options.include?(k) }\n\n params = { :meetingID => meeting_id, :password => password, :fullName => user_name }.merge(options)\n\n send_api_request(:join, params)\n end",
"def join\n redirect_to event_url(@event) unless @current_role.blank? || @current_role.new_record?\n end",
"def join; end",
"def join(*) end",
"def join\n return if not running?\n @thread.join\n end",
"def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def event_join m\n uid = get_uid m\n reward_logic uid, m.channel, m.user.nick\n end",
"def join(c, k=nil)\n @socket << \"JOIN #{c} #{k}\".strip\n end",
"def channel_join(m, channel)\r\n if_admin(m) { @bot.join(channel) }\r\n end",
"def self_joined_room(&block)\n presence(:from => Blather::JID.new(agent_jid_in_room), :type => nil, &block)\n end",
"def join\n if (not @event.users.include? current_user)\n EventUser.create(user: current_user, event: @event)\n redirect_to events_path, notice: \"You are now participating.\"\n else\n ev = EventUser.find_by user: current_user, event: @event\n ev.destroy\n redirect_to events_path, notice: \"Removed you from the event.\"\n end\n end",
"def join( player )\n player.number = @players.size+1\n @players << player\n end",
"def someone_joined_room(&block)\n presence(:from => Regexp.new(\"^#{room_jid}/.*\"), :type => nil, &block)\n end",
"def join\n id = params[:id]\n if Session.exists?(id)\n session = Session.find(id)\n if session.lock\n if params[:password]\n if BCrypt::Password.new(session.password) != params[:password]\n r = {session: 'Bad password.'}\n return bad_request r\n end\n else\n r = {session: 'This session needs a password to join it.'}\n return bad_request r\n end\n end\n\n unless JoinSession.exists?(:user_id => current_user.id, :session_id => id)\n JoinSession.create(user_id: current_user.id, session_id: id)\n end\n current_user.update_columns(current_session_id: id)\n\n return ok_request ''\n else\n r = {session: 'Record Not Found'}\n return not_found r\n end\n end",
"def join\n\t\t@event = Event.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@attendance = Attendance.new\n\t\[email protected]_id = @event.id\n\t\[email protected]_id = params[:user_id]\n\t\tif @attendance.save\n\t\t\tredirect_to @event, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to root_path, alert: \"WTF did you just try to do.\"\n\t\tend\n\tend",
"def join(user_id,group=nil,role=nil)\n if !is_a_member?(user_id)\n begin\n x = Note_User.new(:user_id => user_id, :note_id => self.id )\n x.group = group.id if group\n x.role = role if role\n x.save\n rescue\n return false\n end\n end\n return true\n end",
"def join_group(id)\n\t\t\t#id: ID of the group to join\n\t\t\toptions = {\"id\" => id}\n\t\t\tdata = oauth_request(\"/group/join\", options, \"post\")\n\t\tend",
"def join\n @game = Game.find(params[:id])\n @game.assign_team(current_user)\n redirect_to \"/games/#{@game.id}\"\n end",
"def join\n @character = Character.find(params[:id])\n return_to = Rails.application.routes.recognize_path(request.referrer)[:controller] == \"characters\" ? @character : request.referrer\n if @character.join!\n redirect_to return_to, notice: \"Character is now adventuring in this campaign\"\n else\n flash[:alert] = \"Unable to proccess\"\n render 'show'\n end\n end",
"def on_join(event)\r\n \r\n end",
"def server_join(client, body)\n @rooms[body] ||= []\n return nil if @rooms[body].include?(client.name) or body.length != 8\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"presence join #{client.name}#{body}\")\n ) { |x| @rooms[body].include?(x.name) }\n if @motd[body]\n select_send(MSG_SERVER, EMPTY_ROOM, @keyring.default.iv,\n server_encrypt(\"motd #{body}#{@motd[body]}\")\n ) { |x| x == client }\n end\n @rooms[body] << client.name\nend",
"def join\n # TODO: Use Action Cable to Keep channel open to player\n # TODO: Use Action Cable to Message player_1 that it's their turn to start\n\n respond_to do |format|\n if @game.update(game_params)\n format.html { redirect_to @game, notice: @game.game_state_message }\n format.json { render :show, status: :ok, location: @game }\n else\n format.html { render :edit }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def join(m, channel)\n return unless @bot.admin?(m.user)\n Channel(channel).join\n end",
"def join\n @rufus_scheduler.join\n end",
"def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!(:user => user)\n end",
"def join\n @mutex.synchronize do\n logger.debug { \"spawned process #{@pid}\" }\n @exit_cond.wait_until { @status }\n end\n @status.success?\n end",
"def join\n unless @user && @kroog && @kroog.open? && current_actor.can_follow?\n flash[:warning] = \"Error: The specified circle does not exist or cannot be joined\".t\n respond_to do |format|\n format.html do\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id])\n end\n format.js {render :update do |page|; page << 'document.location.reload(false);'; end}\n end\n return\n end\n\n # Add the relationship directly -- no invite intermediary\n Relationship.create_kroogi_relationship(:followed => @user.id, :follower => current_actor.id, :relationshiptype_id => @kroog.relationshiptype_id, :expires_at => Time.end, :skip_activity_message => true)\n\n flash[:success] = \"You have joined the %s circle of %s\" / [@user.circle_name(params[:circle].to_i), @user.login]\n PublicQuestionHelper::set_question_artist_id(@user, self, :force_show => true)\n respond_to do |wants|\n wants.html do\n redirect_to user_url_for(@user)\n end\n wants.js {}\n end\n end",
"def join(person)\n members.push(person);\n end",
"def join\n if request.post?\n if [email protected]?(current_user)\n @group.users << current_user\n flash[:success] = \"Thanks! Your membership must now be approved by an admin of #{@group.name}.\"\n\n #SEND OUT NOTIFICATION EMAILS\n @group.admins.each do |admin|\n Notifier.pending_user(admin, @group, current_user).deliver\n end\n\n redirect_to @group\n else\n flash[:error] = \"Error requesting to join #{@group.name}. Please try again.\"\n redirect_to @group\n end\n else #it fell back to GET (no js)\n flash[:error] = \"Please enable javascript to join.\"\n redirect_to @group\n end\n end",
"def join(host, port, only_join=false)\n puts \"Join request is received from (#{host}, #{port})\"\n tmp_remote_nodes = @calendar_network.remote_nodes.dup\n \n # add given node to the list\n @calendar_network.remote_nodes |= [Node.new(host, port)]\n\n # change the calendar_network to online mode if it is not\n @calendar_network.offline_mode = false\n\n if only_join\n # this means requester does not need list of (host, port)\n # it just asks remote node to add given (host, port) pair to their list\n puts \"Joining is done. \" + @calendar_network.remote_nodes.inspect\n return true\n else\n puts \"Informing other remote nodes...\"\n # inform other online nodes\n tmp_remote_nodes.each do |remote_node|\n\tputs \"Informing #{remote_node.to_s}\"\n remote_server = xml_rpc_client(remote_node.address, @calendar_network.config[\"path\"], remote_node.port)\n remote_server.call(\"calendar_network.join\", host, port, true)\n end\n\n puts \"Joining is done. \" + @calendar_network.remote_nodes.inspect\n return tmp_remote_nodes.collect{|node| [node.address, node.port]}\n end\n rescue Exception => e\n puts e.message\n return false\n end",
"def process_join(message)\n channel = message.channel\n /:(?<user>\\w+)/ =~ message.raw\n channel.users[user] = User.new user unless channel.users.key? user\n end",
"def join(node)\n node = node.name if Node === node\n riak_admin 'join', node\n end",
"def join\n @join_errors = ActiveModel::Errors.new(self)\n begin\n load_update\n target_artist = Artist.find(params[:dest_artist_id])\n @artist.join_to_other(Setting.get_settings, target_artist)\n rescue\n @join_errors.add(:base , $!.message)\n Log.log_last_exception\n end\n\n check_errors_redirect( @join_errors , 'edit')\n end",
"def join( crew )\n\t\t\n\t\tunless crew.respond_to?( 'new' )\n\t\t\traise \"Can't instantiate that crew\"\n\t\tend\n\t\t\n\t\tif @instance.created?\n\t\t\traise \"Can't join after creation\"\n\t\telsif @instance.active?\n\t\t\traise \"Can't join while running\"\n\t\tend\n\t\t\n\t\[email protected] Player.new( crew )\n\tend",
"def join_group\n @assignment = Assignment.find(params[:id])\n @grouping = Grouping.find(params[:grouping_id])\n @user = Student.find(session[:uid])\n @user.join(@grouping.id)\n m_logger = MarkusLogger.instance\n m_logger.log(\"Student '#{@user.user_name}' joined group '#{@grouping.group.group_name}'\" +\n '(accepted invitation).')\n redirect_to action: 'student_interface', id: params[:id]\n end",
"def join\n attached? ? sleep : (running! and ::Process.waitpid2 pid rescue nil)\n end",
"def join_game\n player_one_user = User.find(message[:player_one_id])\n player_one = player_one_user.player\n player_two_user = User.find(message[:player_two_id])\n player_two = player_two_user.player\n\n player_two_available = (player_two.status == 'looking' || player_two.status.to_i == player_one.id)\n player_one_available = (player_one.status == 'looking' || player_one.status.to_i == player_two.id)\n\n if player_two_available && player_one_available\n if player_two.game_id == player_one.game_id && player_one.game_id != nil && player_one.game.round == 0 && player_one.game.status == 'starting'\n game = player_one.game\n player_one.status = 'ingame'\n player_two.status = 'ingame'\n player_one.save\n player_two.save\n game.update_attributes(status: \"started\", player_1_id: player_one_user.id, player_2_id: player_two_user.id)\n WebsocketRails[\"user#{player_one_user.id}\"].trigger('entered_game', game.to_json)\n WebsocketRails[\"user#{player_two_user.id}\"].trigger('entered_game', game.to_json)\n else\n game = Game.create(round: 0, status: 'starting')\n player_one.game_id = game.id\n player_two.game_id = game.id\n\n player_one.save\n player_two.save\n trigger_success\n end\n else # something went wrong try joining with a different player\n trigger_failure\n end\n end",
"def join\n course = Course.where(join_token: params[:course][:join_token]).first\n\n if course and not current_user.courses.include? course\n current_user.courses << course\n current_user.add_role :student, course\n course.assignments.each { |assignment| assignment.create_submissions_for_students }\n\n flash[:notice] = \"Successfully joined class\"\n redirect_to course_path(course.id)\n else\n flash[:notice] = \"Failed to join class\"\n redirect_to :back\n end\n end",
"def join\n @group = Group.find_by_id(params[:id])\n if @group\n @user.join_group(@group)\n flash[:success] = \"Join It Successed\"\n redirect_to :action => \"reports\", :id => @group\n else\n flash[:warning] = \"Not Exist Group to Join\"\n end\n end",
"def join(conn, start_tag)\r\n @users << conn.user.id\r\n @waiting[conn.user.id] = conn\r\n # find state in log for new user\r\n idx = @log.rindex{|x| x[:tag] == start_tag} || -1\r\n cnt = @log.length - idx - 1\r\n # if there is no new actions from last state just exit\r\n return unless cnt\r\n # queue actions to allow user to catch current state\r\n @log.last(cnt).each {|x| queue_act(conn.user.id, x)}\r\n end",
"def add_room room_name\n @@available_rooms.push room_name unless @@available_rooms.include? room_name\n @rooms_list.append do\n flow :margin => 5 do\n # _why assures me the :checked style will work in the next release\n joined = check :checked => @@joined_rooms.include?(room_name) do |chk|\n @@joined_rooms.push(room_name) and @@room_data[room_name].merge! Chat.join(room_name) if chk.checked?\n Chat.leave(room_name) and @@joined_rooms.delete(room_name) unless chk.checked?\n end\n \n para room_name, :underline => (@room == room_name ? :one : false)\n \n click do\n visit(\"/room/#{room_name}\")\n end unless @room == room_name\n end\n end\n end",
"def join_table\n\t\traise \"No player yet!\" unless @player_id\n\t\tjoin_specific_table(ask_to_choose_table)\n\tend",
"def join_table\n\t\traise \"No player yet!\" unless @player_id\n\t\tjoin_specific_table(ask_to_choose_table)\n\tend",
"def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend",
"def join\n if logged_in?\n @group_wanted = Group.find(params[:id]) # later change to params[:name]\n @country_wanted = Country.find(@group_wanted.country_id, :limit => 1)\n #match = current_user.countries.find(@country_wanted.id)\n #unless current_user.has_country?(@country_wanted.id) #countries.find(@country_wanted.id)\n #@matches = current_user.countries\n @match = Country.find_by_sql([\"SELECT * FROM countries_users WHERE user_id = ? AND country_id = ?\", current_user.id, @country_wanted.id])\n if @match.empty? #current_user.countries.find(@country_wanted.id).nil? #current_user.has_country?(@country_wanted.id) \n flash[:notice] = \"Joined!\"\n current_user.groups << @group_wanted # add group\n current_user.countries << @country_wanted # add country\n redirect_to '/perfil'\n else\n flash[:error] = \"You're either already subscribed to a group in the same country or in the same group.\"\n redirect_to :action => 'index'\n end \n end \n end",
"def join\n @thread.join\n unset_thread_task\n end",
"def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end",
"def joined\n meta(joined: true)\n end",
"def _in_invited(event)\n join event.channel\n end",
"def join\n\n @scheduler_thread.join\n end"
] | [
"0.726165",
"0.72291356",
"0.695971",
"0.6733938",
"0.6693268",
"0.6648598",
"0.6587703",
"0.6547608",
"0.652138",
"0.6520944",
"0.64728284",
"0.64692616",
"0.6468626",
"0.64477855",
"0.6415901",
"0.6353932",
"0.63050723",
"0.624297",
"0.62385523",
"0.62344885",
"0.621736",
"0.6216183",
"0.6213085",
"0.6188097",
"0.6141082",
"0.61281997",
"0.60913247",
"0.6056213",
"0.6048013",
"0.60329944",
"0.6020067",
"0.59938186",
"0.5975807",
"0.5968964",
"0.5959876",
"0.5938689",
"0.59184414",
"0.5903426",
"0.5864169",
"0.5853205",
"0.58482265",
"0.58440244",
"0.58287376",
"0.58179075",
"0.5797238",
"0.5796814",
"0.57904154",
"0.577914",
"0.57596517",
"0.575868",
"0.57580686",
"0.57559824",
"0.57553464",
"0.57524616",
"0.5735166",
"0.5735166",
"0.5726514",
"0.5724077",
"0.5722914",
"0.5720484",
"0.5706129",
"0.5697513",
"0.5676642",
"0.56603104",
"0.5643913",
"0.56410956",
"0.5628365",
"0.5626093",
"0.5603816",
"0.55995536",
"0.5590413",
"0.5575293",
"0.5569966",
"0.55559933",
"0.5553285",
"0.55400974",
"0.5517333",
"0.55170065",
"0.55002564",
"0.5492797",
"0.54767174",
"0.54687524",
"0.54674506",
"0.54417926",
"0.5439015",
"0.5421575",
"0.5409327",
"0.54083455",
"0.5405132",
"0.5401458",
"0.5380447",
"0.53801566",
"0.53801566",
"0.5377957",
"0.53539824",
"0.5341542",
"0.53336",
"0.5322835",
"0.5313938",
"0.53111994"
] | 0.70863837 | 2 |
Toggle guest access on or off | def toggle_guest_access
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guest_access?\n guest_access == :can_join\n end",
"def toggle_admin\n do_toggle_role :admin\n end",
"def guest?\n false\n end",
"def guest_access=(guest_access)\n client.api.set_room_guest_access(id, guest_access)\n tinycache_adapter.write(:guest_access, guest_access)\n guest_access\n end",
"def set_admin_flag\n @adminFlag = false\n end",
"def toggle_admin\n self.is_admin = !self.is_admin\n save!(:validate => false)\n end",
"def allow_guests=(allow_guests)\n self.guest_access = (allow_guests ? :can_join : :forbidden)\n allow_guests\n end",
"def toggle_auth(status, source_text)\n status_string = status == :enable ? 'true' : 'false'\n %w(dbms.security.authorization_enabled dbms.security.auth_enabled).each do |key|\n source_text = set_property(source_text, key, status_string)\n end\n source_text\n end",
"def guest\n can :read, ActiveAdmin::Page, name: \"Dashboard\"\n can [:read, :update], User, id: user.id\n end",
"def toggle_member\n do_toggle_role :member\n end",
"def guest\n allow [:show]\n end",
"def set_admin\n \t@is_admin = session[:is_admin]\n end",
"def guest_user(_user)\n if RuntimeConfig.vote_signin_active?\n can :access, :sessions\n end\n end",
"def check_guest_in\n\n end",
"def toggle\n @user.toggle\n redirect_to :back\n end",
"def is_guest?\n return @is_guest\n end",
"def guests_disabled?\n !AppConfig.check(:enable_guests)\n end",
"def guest_access\n client.api.get_room_guest_access(id)[:guest_access].to_sym\n end",
"def toggle_access\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.private = [email protected]\n @questionnaire.save\n @access = @questionnaire.private == true ? 'private' : 'public'\n undo_link(\"The questionnaire \\\"#{@questionnaire.name}\\\" has been successfully made #{@access}. \")\n redirect_to controller: 'tree_display', action: 'list'\n end",
"def guest\n\tend",
"def toggle_officer\n do_toggle_role :officer\n end",
"def toggle!\n if status\n off!\n return false\n else\n on!\n return true\n end\n end",
"def expire_guest?\r\n admin? or own? or invited?\r\n end",
"def toggle_availability\n if @chef.availability == true\n @chef.availability = false\n else\n @chef.availability = true\n end\n end",
"def make_admin\n puts \"Creating Admin\"\n user = User.create!(:name => \"Admin\",\n :email => \"[email protected]\",\n :password => \"adminpw\",\n :password_confirmation => \"adminpw\")\n user.toggle!(:admin)\n user.toggle!(:staff)\nend",
"def kvm_disable(handle:, server_id: 1)\n kvm_mo = CommKvm.new(parent_mo_or_dn: _get_comm_mo_dn(handle, server_id))\n kvm_mo.set_prop(:admin_state, \"disabled\")\n handle.set_mo(mo: kvm_mo)\nend",
"def eds_guest?\n current_or_guest_user.guest\n end",
"def create_guest?\r\n admin? or streamer?\r\n end",
"def toggle_host_status\n if !self.host.listings.empty?\n self.host.update(host: true)\n else\n self.host.update(host: false)\n end\n end",
"def toggle\n if on?\n off\n else\n on\n end\n end",
"def show\n if params[:turn_on]\n session[:admin] = true if @user&.admin && !in_admin_mode?\n elsif params[:turn_off]\n session[:admin] = nil\n end\n\n redirect_back_or_default(\"/\")\n end",
"def toggle\n cmd = \"{\\\"id\\\":7,\\\"method\\\":\\\"toggle\\\",\\\"params\\\":[]}\\r\\n\"\n request(cmd)\n end",
"def vip_member\n is_admin != true\n end",
"def show?\n @current_user.permission('Fdp', :guest)\n end",
"def revoke_admin\n self.update_attributes(:admin => false)\n end",
"def authen_method_guest!()\n @authen_method = TAC_PLUS_AUTHEN_METH_GUEST\n end",
"def disable_for_public\n self.update_attribute(:active, false)\n end",
"def org_swap?\n @user.can_super_admin?\n end",
"def disable\n\t\tif user = check_admin\n\t\t\ttarget_user = User.find_by(id: params[:id])\n\t\t\ttarget_user.toggle!(:enabled)\n\t\t\tredirect_back fallback_location: '/home'\n\t\tend\n\tend",
"def unscrape?\n @user.is_admin?\n end",
"def is_admin\n test_access :admin\n end",
"def guest_signed_in?\n !!current_guest\n end",
"def toggle\n set_switch(!self.switch) if @switch\n end",
"def login_guest()\n login(:guest)\n end",
"def set_admin!\n if admin?\n update(admin: false)\n else\n update(admin: true)\n end\n end",
"def org_swap?\n signed_in_user.can_super_admin?\n end",
"def super_check\n if self.user_name == 'profbill'\n self.admin = true\n self.suspended = false\n self.icon = \"hand-peace-o\"\n end\n end",
"def show?\n @current_user.permission('Bid', :guest)\n end",
"def eventunscrape?\n @user.is_admin?\n end",
"def is_guest?\n return @guest_of\n end",
"def toggle\n social_network = SocialNetwork.find(params[:id])\n social_network.update!(is_visible: !social_network.is_visible?)\n redirect_to :settings\n end",
"def on_guest_list?\n on_guest_list || false\n end",
"def disable_admin\n if current_user.admin?\n user = User.find(params[:id])\n user.update_attribute(\"admin\", false)\n redirect_to \"/users\"\n else\n redirect_to \"/home\"\n flash[:warning] = \"Only admins can perform that action.\"\n end\n end",
"def can_toggle? record\n return true if current_user.admin?\n case record.class.to_s\n when 'TypusUser'\n return true if current_user.admin? && record.id != current_user.id\n false\n else\n record.user_id == current_user.id\n end\n end",
"def toggle_on(outlet = 1)\n toggle(outlet, true)\n end",
"def unlock_access!; end",
"def admin_only\n false\n end",
"def switch_mode\n if params[:driver] == \"true\" then\n session[:driver] = \"false\"\n current_user.update_attributes!(driver: false)\n else\n session[:driver] = \"true\"\n current_user.update_attributes!(driver: true)\n end\n redirect_to root_path\n end",
"def switch_mode\n if params[:driver] == \"true\" then\n session[:driver] = \"false\"\n current_user.update_attributes!(driver: false)\n else\n session[:driver] = \"true\"\n current_user.update_attributes!(driver: true)\n end\n redirect_to root_path\n end",
"def toggle_state\n puts \"******* toggle_state *******\"\n end",
"def set_as_admin\n self.admin = true\n end",
"def admin?\n session[:admin] ==true\n end",
"def toggle\n @raid.toggle\n redirect_to :back\n end",
"def can_make_leaderbit_active?\n system_admin?\n end",
"def admin?\n session[:admin] ? true : false\n end",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend",
"def is_admin?\n is_admin == 1\n end",
"def toggle_enable_expiry\n @user = User.find(params[:id])\n\n respond_to do |format|\n @nav = 'show_nav'\n if (@local_manager.slave?)\n flash[:warning] = \"This action is prohibited on slave systems.\"\n format.html { redirect_to user_url(@user) }\n format.xml { render :xml => '<errors><error>This action is prohibited on slave systems.</error></errors>', :status => :not_acceptable }\n else\n @user.toggle_enable_expiry!\n @local_manager.log(:username => @session_user.username, :user_id=> @user.id, :message => \"Toggled enable expiry (current=#{@user.enable_password_expired?}) for user #{@user.username}.\")\n flash[:notice] = \"You must publish this user before changes will take effect on TACACS+ daemons.\"\n format.html { redirect_to user_url(@user) }\n format.xml { head :ok }\n end\n end\n end",
"def toggle_off\n set_state_to(:off)\n end",
"def enable_admin\n if current_user.admin?\n user = User.find(params[:id])\n user.update_attribute(\"admin\", true)\n redirect_to \"/users\"\n else\n redirect_to \"/home\"\n flash[:warning] = \"Only admins can perform that action.\"\n end\n end",
"def toggle\n\t\t@gridOn = !@gridOn\n\tend",
"def admin_access?\n admin?\n end",
"def toggle(data)\n resource = Resource.find(data[\"id\"])\n resource.toggle_availability\n end",
"def administrate!\n\tif current_user.admin == false \n\t\tredirect \"/home\"\n\tend\nend",
"def admin_in!\n access_denied! unless current_user.admin?\n end",
"def deactivate\n \n end",
"def is_admin?\n session[:is_admin]\n end",
"def toggle_edit_mode\r\n session[:edit_mode] ||= 0 \r\n# called without logged in \r\n if session[:edit_mode] < 1 \r\n dc_render_404 \r\n else\r\n session[:edit_mode] = (session[:edit_mode] == 1) ? 2 : 1\r\n redirect_to params[:return_to]\r\n end\r\nend",
"def turn_on!\n @turned_off = false\n end",
"def admin_logged_in?\n #if session[:logged_in] == true && (session[:host_id] == 670999089 || session[:host_id] == 753452019 || session[:host_id] == 100000182246137)\n if session[:logged_in] == true && User.find(session[:id]).admin == true\n true\n else\n false\n end\n\n end",
"def toggle_privacy \n\t\tif self.show_others == true\n\t\t\tupdate_attributes(show_others:false)\n \telse\n\t\t\tupdate_attributes(show_others:true)\n\t\tend\n\tend",
"def toggle_off(outlet = 1)\n toggle(outlet, false)\n end",
"def toggle_mute\n muted? ? unmute : mute\n end",
"def enable_for_public\n # TODO Create and write all the checks necessary for the listing to become active and public\n self.update_attribute(:active, true)\n end",
"def authen_method_guest?()\n return true if (@authen_method == TAC_PLUS_AUTHEN_METH_GUEST)\n return false\n end",
"def admin?\n !current_user.AdminScreen?\n end",
"def can_log_in?\n !disabled\n end",
"def admin_reactivate\n user = User.find(params[:id])\n authorize! :edit, @user #prevent other users from disabling OTP on another user.\n user.deactivated = false\n user.save!\n flash[:notice] = \"Successfully Reactivated user.\"\n redirect_back(fallback_location: '/')\n end",
"def toggle_role\n do_toggle_role params[:role]\n end",
"def show_logout\n @show_logout = true\n end",
"def make_admin\n @user = User.find(params[:user_id])\n @user.admin = [email protected]\n @user.save\n redirect_to users_path\n end",
"def admin_stat\n admin? ? 'on' : 'off'\n end",
"def setAdmin id, username\n\n user = User.get(id,username)\n if user.isAdmin?\n if id != '1' && username != user_name\n user.setAdminOff\n end\n else\n user.setAdminOn\n end\n userSave user\n end",
"def switch_light_off\n puts \"*** switch_light_off\"\n true\nend",
"def is_admin\n\t\tself.admin == true\n\tend",
"def user_onoff_flag\n @requested_user = User.find_by_account_number(params[:id])\n if @requested_user.is_active?\n @requested_user.update_columns(:is_active => false)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully de-activated.\"}\n else\n @requested_user.update_columns(:is_active => true)\n redirect_to admin_index_path, :flash => {:notice => \"Requested user(#{@requested_user.first_name} #{@requested_user.last_name}) account successfully activated.\"}\n end\n end",
"def deactivate\n admin = Administrator.find_by_user_id(params[:id])\n admin.status = false\n admin.save\n @users = User.all\n render 'index'\n end",
"def change_device_state(host, device, state)\n raise MogileFS::ReadOnlyError if readonly?\n ! @backend.set_state(:host => host, :device => device, :state => state).nil?\n end",
"def toggle_is_pinned!\n self.is_pinned = (self.is_pinned ? false : true) # will change true to false and false to true\n end",
"def toggle_locking(current_user)\n if can_toggle_locking?(current_user)\n is_locked? ? unlock : lock(current_user.id) # TODO: raise exception or report error here?\n end\n end"
] | [
"0.6607076",
"0.6488401",
"0.6369919",
"0.6237322",
"0.62227607",
"0.6190604",
"0.61766887",
"0.61213094",
"0.61032784",
"0.60904926",
"0.6074536",
"0.60504216",
"0.60217774",
"0.60018927",
"0.59932137",
"0.59780246",
"0.5976769",
"0.5957458",
"0.59057647",
"0.5886336",
"0.58831894",
"0.58386284",
"0.5809851",
"0.5805317",
"0.57603806",
"0.5746105",
"0.57413876",
"0.56693566",
"0.56630105",
"0.56571317",
"0.5652425",
"0.5635154",
"0.56177604",
"0.55843705",
"0.5578363",
"0.55690485",
"0.5566298",
"0.5565231",
"0.5557937",
"0.5556151",
"0.5552091",
"0.5534925",
"0.5514466",
"0.5507285",
"0.5501804",
"0.54941934",
"0.54928094",
"0.54799",
"0.5474497",
"0.54742515",
"0.5471846",
"0.5452798",
"0.54408294",
"0.5426097",
"0.5423369",
"0.5422578",
"0.54134864",
"0.5400379",
"0.5400379",
"0.53934157",
"0.53932637",
"0.5389063",
"0.5372843",
"0.5362367",
"0.5352472",
"0.5333758",
"0.5331287",
"0.5314778",
"0.5313946",
"0.53085643",
"0.5308168",
"0.5297194",
"0.5294684",
"0.528421",
"0.52834266",
"0.52764624",
"0.5271439",
"0.5266136",
"0.5260672",
"0.52489007",
"0.52395356",
"0.523476",
"0.5219008",
"0.52131414",
"0.5210353",
"0.5207099",
"0.5202176",
"0.52014947",
"0.5200933",
"0.5200794",
"0.51986724",
"0.51938343",
"0.5184788",
"0.51844376",
"0.51841474",
"0.5182425",
"0.5177757",
"0.51748073",
"0.51731825",
"0.51693845"
] | 0.835637 | 0 |
Get the url for guest access | def guest_url
if guest_access_enabled?
"http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}"
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guest_link\n return guest_hearing_link if guest_hearing_link.present?\n\n \"#{VirtualHearing.base_url}?join=1&media=&escalate=1&\" \\\n \"conference=#{formatted_alias_or_alias_with_host}&\" \\\n \"pin=#{guest_pin}&role=guest\"\n end",
"def guest\n allow [:show]\n end",
"def redirect_guest\n redirect_to explore_comparisons_path if @context.guest?\n end",
"def bookkeeper_invitation_url(access)\n \"#{::AppConfig.mail.host}/access/#{access}\"\n end",
"def guest\n\tend",
"def seller_url\r\n ['http:', user.user_url].join('//') rescue nil\r\n end",
"def get_path\n if self.presentation.user.role==\"guest\"\n \"#{Rails.root}/public/guestdata/\"+self.presentation.user_id.to_s+\"/\"+self.presentation.id.to_s+\"/images/:filename\"\n else\n \"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:filename\"\n #\"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:attachment/:id_:style.:extension\"\n end\n end",
"def host(inv, options = {}) \n link_to(inv.inviter.user_name, member_profile_url(:id => inv.inviter.user_name), :target => options[:target]) if inv.inviter\n end",
"def p_url\n Rails.application.routes.url_helpers.rent_url(id, host: PUBLIC_URL)\n end",
"def url\n env[:url]\n end",
"def guest_access\n client.api.get_room_guest_access(id)[:guest_access].to_sym\n end",
"def viewer_url_s\n dip_field(:viewer_path)\n end",
"def get_meeting_url(id, password)\n prepare\n @api.join_meeting_url(id, 'Guest', password)\n end",
"def url\n send(\"url_#{page.env}\")\n end",
"def identity_url(hsh)\n if APP_CONFIG[:restricted_names].include?(hsh[:username].split('.').last)\n hsh[:username]\n else\n \"#{hsh[:username]}.#{AppConfig.host(request.host)}\"\n end\n end",
"def link\n BASE_URL + (private? ? \"/private/#{@key}\" : \"/#{@id}\")\n end",
"def repel_usr_guest\n redirect_to(\"/\") if session[:usr_id].nil?\n end",
"def url\n '/users/show/' + login\n end",
"def url_for_user_show(user)\n if logged_in?\n return url_for user_path(user)\n else\n return url_for login_path\n end\n end",
"def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end",
"def current_url; end",
"def current_user_url\n view_context.user_url(current_user)\n end",
"def login_url\n DOMAINS[username_domain] || DOMAINS['hotmail.com']\n end",
"def users_url\n view_context.users_url\n end",
"def request_url(requirelogin=false, requireuserinfo=false, expirationdays=30, notifyonupload=false)\n end",
"def current_url\n return Knj::Web.url\n end",
"def gardener_url\n (ENV['SUT_SCHEME'] || 'https') + \"://\" + gardener_fqhn()\n end",
"def request_url(requirelogin=false, requireuserinfo=false, expirationdays=30, notifyonupload=false)\n end",
"def login_guest()\n login(:guest)\n end",
"def redirect_url; end",
"def auth_url\n client.authorization.authorization_uri(state: '', approval_prompt: :force, access_type: :offline, user_id: client_email).to_s\n end",
"def back_uri\n session[:prev_path] || '/admin'\n end",
"def requested_url\n raise \"URL could not be detected.\" unless @args[:request_args][:url]\n @args[:request_args][:url]\n end",
"def url(id)\n entry(id).url(@user)\n end",
"def admin_link\n admin_app_url(:host => CONSTANTS[:base_url_host], :offering => offering, :id => self)\n end",
"def host_url\n Rails.application.routes.default_url_options[:host] || Spree::Store.current.url\n end",
"def url\n url = \"#{config.url[config.env]}/#{@path}\"\n url = \"#{url}?#{@params.to_param}\" unless @params.empty?\n url\n end",
"def getAuthUrl\n\t\t\t\tURI::HTTP.build(\n\t\t\t\t\t:host => @options['auth_host'],\n\t\t\t\t\t:path => @options['auth_page'],\n\t\t\t\t\t:query => {\n\t\t\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t\t\t:scope => @options['scope'],\n\t\t\t\t\t\t:response_type => \"code\",\n\t\t\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t\t\t}.to_query\n\t\t\t\t).to_s\n\t\t\tend",
"def user_url\n @raw['user']['url']\n end",
"def url\n @client.url + self.class.path + @username\n end",
"def url\n @url || Gandi::TEST_URL\n end",
"def login_web_url\n return @login_web_url\n end",
"def url(id)\n entry(id).url(@user)\n rescue exception_block\n end",
"def server_url\n params[:server_url] || session[:server_url]\n end",
"def web_url\n @sandbox ? \"http://www.sandbox.freelancer.com\":\"http://www.freelancer.com\"\n end",
"def dev_url(path = \"/\")\n uri = URI.join(\"http://#{Radiant::Config['dev.host'] || 'dev'}.#{self.base_domain}\", path)\n uri.to_s\n end",
"def expand_guest_path(destination)\n if machine.guest.capability?(:shell_expand_guest_path)\n machine.guest.capability(:shell_expand_guest_path, destination)\n else\n destination\n end\n end",
"def account_url\n return new_user_session_url unless user_signed_in?\n return :user_dashboard_url\n end",
"def voter_attestation_url(voter)\n leo_attestation_url(@voter, :protocol => 'https')\nend",
"def browser_url\r\n \"http://#{external_app_server_host}:#{external_app_server_port}\"\r\n end",
"def get_viewer_link(urn,access_token)\n #absolute url = request.base_url\n url = \"/viewer1.html?token=#{access_token}&urn=#{urn}\"\n link = \"<a href=\\\"#{url}\\\" target=\\\"_blank\\\">View Model</a>\"\n return link\n end",
"def activation_url\n return @activation_url\n end",
"def fire_eagle_auth_url\n client = if fire_eagle_requested?\n requested_client\n else\n fire_eagle_request!\n end\n client.authorization_url \n end",
"def url_for(option)\n host = SermepaWebTpv.response_host\n path = SermepaWebTpv.send(option)\n\n return if !host.present? || !path.present?\n URI.join(host, path).to_s\n end",
"def myspace_url; \"https://myspace.com/#{myspace}\" end",
"def url\n end",
"def check_guest_in\n\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def gateway_url\n if developer?\n File.join \"/pagseguro_developer/create\"\n else\n GATEWAY_URL\n end\n end",
"def actual_url\n @browser.current_url\n end",
"def guest_name_from_params\n if request.get? && request.format.html? && (name = params[:who])\n if user_signed_in? || guest_user.name && guest_user.name != name\n reset_guest!\n end\n\n set_guest_name(name)\n\n redirect_to url_for(params.except(:who))\n end\n end",
"def url\n return nil if page.hidden?\n\n [ self.preferred_domain.url, self.path.gsub(/^\\//, '') ].join # facets\n end",
"def public_home_page_url(append_request_uri=false)\n url = \"http://www.#{account_domain}\"\n url << (append_request_uri ? request.request_uri : '/')\n url\n end",
"def get_viewing_url(session)\n \"https://crocodoc.com/view/#{session.key}\"\n end",
"def host_or_guest_user\n # First line guards against no_method errors by ensuring invite exists.\n redirect_to root_url unless (@invite = Invite.find_by(id: params[:id]))\n host_or_guest = current_user.events_as_host.find_by(id: @invite.event_id)\n host_or_guest ||= (current_user.id == @invite.user_id)\n redirect_to root_url unless host_or_guest\n end",
"def main_url(secure)\n url = \"http#{secure ? \"s\" : \"\"}://#{secure ? \"book.\" : \"\"}\"\n url += (Configuration.hostname ||= \"api.ean.com\") + \"/ean-services/rs/hotel/v3/\"\n url\n end",
"def app_url\n url\n end",
"def remember_host!; end",
"def guest_user(_user)\n if RuntimeConfig.vote_signin_active?\n can :access, :sessions\n end\n end",
"def home_page_url\n return @home_page_url\n end",
"def get_url\n @url\n end",
"def url\n return @@nfg_urls['sandbox']['url'] if @use_sandbox\n @@nfg_urls['production']['url']\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def iadmin_url\n @test_mode ? @test_url : @production_url\n end",
"def generated_url; end",
"def get_auth_url\n\t\tURI::HTTP.build(\n\t\t\t:host => @options['auth_host'],\n\t\t\t:path => @options['auth_page'],\n\t\t\t:query => {\n\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t:scope => @options['scope'],\n\t\t\t\t:response_type => \"code\",\n\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t}.to_query\n\t\t).to_s\n\tend",
"def guest_user\n User.find_by_email('[email protected]')\n end",
"def url\n raise\n end",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def getURL\r\n\t\t\t\t\treturn @url\r\n\t\t\t\tend",
"def access_token_url\n Settings.mobile_lighthouse_letters.access_token_url\n end",
"def eshelf_url\n get_institution_or_default(:eshelf_url)\n end",
"def get_access_url(app_id)\n return sprintf(REDIRECT_URL, app_id)\n end",
"def iss_url\n session[:iss_url]\n end",
"def vend_url\n URI(\"https://#{config.vend_id}.vendhq.com/\")\n end",
"def expand_guest_path(destination)\n if machine.guest.capability?(:shell_expand_guest_path)\n machine.guest.capability(:shell_expand_guest_path, destination)\n else\n destination.to_s.gsub('/', \"\\\\\")\n end\n end",
"def nice_url\n if homepage\n if Addressable::URI.parse(homepage)\n Addressable::URI.parse(homepage).host\n else\n homepage.first(15)\n end\n else\n \"\"\n end\n end",
"def nice_url\n if homepage\n if Addressable::URI.parse(homepage)\n Addressable::URI.parse(homepage).host\n else\n homepage.first(15)\n end\n else\n \"\"\n end\n end",
"def fetch_location\n session[:forwarding_url]\n end",
"def url\n @gapi[\"selfLink\"]\n end",
"def url\n @gapi[\"selfLink\"]\n end",
"def guest_and_restricted_link?\n guest? && @record.fulltext_link[:url] == 'detail'\n end",
"def getServerUrl\n puts \"******* getServerUrl \" + \"*\" * 21\n reqUrl = request.original_url\n puts \" ** reqUrl \" + reqUrl\n gon.currentServerUrl = reqUrl\n end",
"def home_page\n if current_user.guest?\n user_signup_url\n elsif current_user.administrator?\n admin_films_path\n elsif current_user.judge?\n judging_categories_path\n else\n obejct_url current_user\n end\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def url\n if self.controller and self.action and self.page_id\n return \"/#{self.controller}/#{self.action}/#{self.page_id}\"\n end\n if self.controller and self.action\n return \"/#{self.controller}/#{self.action}\"\n end\n if self.controller\n return \"/#{self.controller}\"\n end\n return \"/#{self.shortcut}\"\n end",
"def url\n end"
] | [
"0.79203606",
"0.63214844",
"0.63024205",
"0.61987704",
"0.6108481",
"0.6091542",
"0.6039268",
"0.603794",
"0.6015924",
"0.600454",
"0.5999916",
"0.5993426",
"0.5954002",
"0.5941162",
"0.59177375",
"0.5915073",
"0.59030753",
"0.58932114",
"0.5879106",
"0.58500963",
"0.5849586",
"0.58303106",
"0.58127624",
"0.57978064",
"0.5780067",
"0.57772",
"0.57746166",
"0.577366",
"0.5768387",
"0.57680774",
"0.5762027",
"0.57506037",
"0.57478964",
"0.5747885",
"0.5735859",
"0.57260025",
"0.5716858",
"0.5716429",
"0.57123643",
"0.56989986",
"0.56958675",
"0.56834364",
"0.56800395",
"0.5677814",
"0.5674136",
"0.56709826",
"0.5649031",
"0.56442606",
"0.56418496",
"0.56377244",
"0.56367075",
"0.5632487",
"0.5628608",
"0.5626666",
"0.5619722",
"0.56152153",
"0.5614915",
"0.56138015",
"0.56126213",
"0.56102854",
"0.56067896",
"0.55983",
"0.55961293",
"0.5595711",
"0.55902183",
"0.5589959",
"0.5589079",
"0.55852705",
"0.5579439",
"0.5577457",
"0.5574081",
"0.5567609",
"0.55669844",
"0.55566937",
"0.5556525",
"0.5555715",
"0.5547507",
"0.5547332",
"0.5544149",
"0.5544149",
"0.5544149",
"0.5544149",
"0.5544149",
"0.5537107",
"0.55364406",
"0.5535731",
"0.55340564",
"0.5532052",
"0.55312556",
"0.5529861",
"0.5529861",
"0.5528249",
"0.55271494",
"0.55271494",
"0.5522065",
"0.5521653",
"0.5521613",
"0.55207527",
"0.55201477",
"0.5519425"
] | 0.7852773 | 1 |
The invite code use for guest | def guest_invite_code
load
@active_token_value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_invite_code\n self.invite_code = generate_token\n end",
"def invitee_string\n\t\n\tend",
"def ensure_invite_code!\n self.invite_code ||= \"thiscord.gg/\"+SecureRandom.uuid[0..5]\n end",
"def invite\n \n end",
"def invite_code\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:invite_code] = user.invite_code\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend",
"def create_invite_code_for(identifier)\n #if email has been invited before, just update with new code.\n invite = Invite.find_by_identifier(identifier) || Invite.new(identifier:identifier)\n #code is only valid for the identifier provided and can only be used once.\n invite.is_used=false\n invite.code=SecureRandom.urlsafe_base64\n invite.save! #no need to validate\n return invite.code\n end",
"def accept_invitation\n \n end",
"def set_invitecode\n @invitecode = Invitecode.find(params[:id])\n end",
"def invite_subject\n \"Your invitation to #{org_name.possessive} Creative Difference Dashboard\"\n end",
"def join\n @invite_code = params[:invite_code]\n end",
"def accept_invite(_token)\n # stub\n end",
"def new_invitation_code\n if self.invitation_code.nil?\n write_attribute(:invitation_code, self.class.name.hashed(Time.now.to_i.to_s + rand.to_s))\n update_without_callbacks\n end\n return self.invitation_code\n end",
"def invite\n @data['invite']\n end",
"def create_invite_token\n\n # local cipher encrypt token\n invite_token_d = LocalCipher.get_sha_hashed_text(\n \"#{@client_id}::#{@email}::#{current_timestamp}::invite::#{rand}\"\n )\n\n db_row = ManagerValidationHash.create!(\n manager_id: @invitee_manager[:id],\n client_id: @client_id,\n kind: GlobalConstant::ManagerValidationHash.manager_invite_kind,\n validation_hash: invite_token_d,\n status: GlobalConstant::ManagerValidationHash.active_status,\n extra_data: {\n inviter_manager_id: @inviter_manager_id,\n is_super_admin: @admin_invite_privilege\n }\n )\n\n # create a custom key using db id and local cipher encrypt token\n invite_token_str = \"#{db_row.id}#{ManagerValidationHash.token_delimitter}#{invite_token_d}\"\n\n # encrypt it again to send it over in email\n encryptor_obj = EmailTokenEncryptor.new(GlobalConstant::SecretEncryptor.email_tokens_key)\n r = encryptor_obj.encrypt(invite_token_str, GlobalConstant::ManagerValidationHash::manager_invite_kind)\n return r unless r.success?\n\n @invite_token = r.data[:ciphertext_blob]\n\n success\n\n end",
"def guest_url\n if guest_access_enabled?\n \"http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}\"\n else\n nil\n end\n end",
"def accept_invitation(invite)\n self.invitation= invite\n self.validation_level = invite.validation_level\n self.invitation_code = invite.code\n end",
"def generate_invitation_key\n self.invitation_key ||= 'I'.freeze + SecureRandom.base64(8)\n end",
"def invite\n @obj['invite']\n end",
"def invitation_token\n \tinvitation.token if invitation\n end",
"def encrypt_code(e=nil)\n\t\tUser.encrypt((e || self.email), self.activation_code)\n\tend",
"def handle_incoming_invite(*args); false; end",
"def invite(invitee, inviter)\n @invitee = invitee\n @inviter = inviter\n\n mail to: invitee.email,\n subject: \"Invitation from #{inviter.first_name} to join a kinstagram family\"\n end",
"def invitation_token\n invitation.token if invitation\n end",
"def invite(invite)\n @invite = invite\n mail(:to => invite.email, :subject => \"#{@invite.user.name} has invited you to the \\\"#{invite.idea.name}\\\" idea\", :tag => 'invite') \n end",
"def new_workplace_invite(sender, invite, recipient_email, recipient_name, workplace, token, workplace_id)\n @sender = sender\n @invite = invite\n @recipient_email = recipient_email\n @recipient_name = recipient_name\n @workplace = workplace \n @token = token\n @workplace_id = workplace_id\n mail(to: \"#{@recipient_email}\", subject: \"#{@sender.name} invited you to join Ossemble\")\n end",
"def create_confirm_code\r\n \t\tself.confirm_code = SecureRandom.urlsafe_base64\r\n \tend",
"def invite(invitation, www_host)\n @invitation = invitation\n @www_host = www_host\n \n mail :to => invitation.email_address\n end",
"def invite\n if current_user.active_oauth_account.blank?\n session[:inviting_friend] = true\n redirect_to zh? ? \"/auth/weibo\" : \"/auth/facebook\"\n else\n redirect_to current_user.fb_invite_link\n end\n end",
"def invitation_token\n invitation.token if invitation\n end",
"def send_invite(invite, password=nil)\n @invite = invite\n @event = @invite.event\n @password = password\n @email = @invite.invited_email\n @photographer = @event.photographer\n @subject = @invite.invite_subject\n link_slug = Link.create(event_id: @event.id)\n unique_key = Shortener::ShortenedUrl.generate(event_path(link_slug, invited: 'true')).unique_key\n @link = (ENV['END_CLIENT_URL'] || Rails.application.secrets[:env]['END_CLIENT_URL']) + '/' + unique_key\n mail(to: @email, subject: @subject )\n end",
"def activate\n flash.clear\n return if params[:id].blank? and params[:activation_code].blank?\n activator = params[:activation_code] || params[:id]\n @invite = Invite.find_by_activation_code(activator)\n if @invite\n if @invite.user_id\n flash[:warning] = \"The invitation has been already registered\".t\n elsif user = User.find_by_email(@invite.user_email)\n flash[:warning] = \"The user #{user.login} is already registered with this email address\".t\n else\n # special case for :founder_circle as they can only be accepted by projects\n # so switch the user identity #@invite.circle_id == Invite::TYPES[:founder_circle][:id] &&\n # or should we always switch identity to user when accepting email invite ?? tough one ..\n Invite.transaction do\n if current_user.on_behalf_id != 0\n current_user.on_behalf_id = 0\n current_user.save!\n end\n @invite.user_id = current_actor.id\n @invite.display_name = current_actor.display_name\n @invite.save!\n\n Activity.send_message(@invite, @invite.inviter, :invite_sent)\n end\n flash[:success] = \"The invitation has been registered for %s\" / current_actor.login\n end\n redirect_to(:controller => '/activity', :action => 'list')\n else\n params[:activation_code] = activator\n flash[:warning] = \"Unable to register the invitation. Please make sure that the activation code is correct.\".t\n end\n end",
"def msg_INVITE(source, args)\n return nil\n end",
"def send_invitation(invitation_hash)\n @email = invitation_hash[:email]\n @code = invitation_hash[:code]\n mail(:to => @email, :subject => \"Invite to #{Settings.application.name}\")\n end",
"def invite\n verifier = ActiveSupport::MessageVerifier.new(\"secret\")\n begin\n message = verifier.verify(::Base64.urlsafe_decode64(params[:token]))\n rescue ActiveSupport::MessageVerifier::InvalidSignature, ArgumentError\n logger.warn \"Invalid invite link: #{params[:token]}\"\n flash[:alert] = 'Invalid link'\n redirect_to new_registration_path and return\n end\n @user = User.find_by(id: message[:user_id])\n unless @user\n flash[:alert] = 'Invalid link'\n redirect_to new_registration_path and return\n end\n unless current_user.is_signed_in?\n session[:user_id] = @user.id\n flash[:notice] = \"Please select a username and password to complete your registration\"\n end\n end",
"def invite\n invite = params[:invite]\n profile.update_attribute(:email, invite[:email])\n invite = Notifier.send_invite(profile, invite[:message])\n invite.deliver\n flash[:notice] = \"An invititation to join YentaFriend was sent to #{profile.name}. Check your dashboard for an update when they join!\"\n end",
"def generate_activation_code\n #self.security_token = Digest::SHA1.hexdigest(\"--#{Time.now.to_s}--#{email}--#{salt}--\")\n generate_security_token\n end",
"def invited?\r\n key.guest && user.id == key.created_by\r\n end",
"def invited_by\n invite = BetaInvite.where(:invitee_id => self.id).first\n invite ? invite.sender : nil\n end",
"def update\n\n #after the admin approve the invitation request\n #an invitation code will be generated and sent to the user\n invitation = Invitation.find(params[:id])\n invitation.generate_code\n redirect_to admin_invitations_path \n end",
"def create\n if verify_code_validity.nil?\n\t user = User.exists? invitation_params[:user_id] \n\t respond_to do |format|\n\t unless user.nil? \n\t\t\t\tuser_name = user.name\n\t\t\t\tuser_role = user.roles.first.id unless user.roles.first.nil? \n\t end\n\t if (user_role == ROLE_LEADER || user_role == ROLE_ADMIN)\n\t\t@invitation = Invitation.new(invitation_params)\n\t\[email protected]_sent_at = Time.now.utc\n\t\[email protected] = PENDING_INVITATION_STATUS\n\t\[email protected]\n\t\tInvitationCode.create(invitation_id: @invitation.id, code_text: params[:code])\n #UserMailer.invite_user_email(params[:code],user_name,invitation_params[:invitee_email]).deliver\n\t\tformat.html { redirect_to @invitation, notice: 'Invitation was successfully created.' }\n\t\tformat.json { render :json=> {:status => true} }\n\t else\n\t\tformat.html { render :new }\n\t\tformat.json { render :json=> {:error => 'This user id is not authorized to send invitation', :status => false} }\n\t end\n\t end\n else\n\t respond_to do |format|\n\t\tformat.html { render :new }\n\t\tformat.json { render :json => { :error => 'Invalid or taken code.', :status => false } }\n\t end\n end\n end",
"def invite(n, c)\n @socket << \"INVITE #{n} #{c}\"\n end",
"def clean_invitation_code\n self.invitation_code = generate_invite_code(10) if invitation_code.blank?\n end",
"def make_activation_code\n end",
"def invite(invitation)\n @invite = invitation\n mail :to => invitation.email,\n :subject => \"Welcome to the Panda\"\n end",
"def generate_confirm_code\n chars = (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n code = \"\"\n 20.times { |i| code << chars[rand(chars.size-1)] }\n # add the ID to ensure always unique!\n code << self.recipient_id.to_s + self.project_id.to_s\n\n self.confirm_code = code\n end",
"def send_invitation(email)\n chars = [\"A\"..\"Z\",\"a\"..\"z\",\"0\"..\"9\"].collect { |r| r.to_a }.join\n code = (1..8).collect { chars[rand(chars.size)] }.pack(\"C*\")\n invitation = Invitation.create!(:sender => self,\n :code => code,\n :receiver_email => email)\n if Notifier.deliver_invitation(invitation)\n self.update_attribute :sent_invitations, self.sent_invitations + 1\n end unless invitation.blank?\n end",
"def generate_token\n\t\t@pending_invite = Invitation.find_by_recipient_phone(self.recipient_phone)\n\t self.token = @pending_invite.try(:token) || Forgery('name').last_name + sender_id.to_s\n\tend",
"def invitation_code\n params.require(:invitation).permit(:code)\n end",
"def generate_token\n loop do\n random_token = SecureRandom.urlsafe_base64(nil, false)\n break random_token unless self.class.exists?(invite_code: random_token)\n end\n end",
"def invite_people\n end",
"def invite(email, role, label_or_expression, value)\n muf = prepare label_or_expression, value\n\n invitation = {\n \"invitations\" => [ {\n \"invitation\" => {\n \"content\" => {\n \"email\" => email,\n \"userFilters\" => [ muf[:url] ],\n \"role\" => role\n }\n }\n } ]\n }\n pp invitation\n GoodData.post \"/gdc/projects/#{@project_id}/invitations\", invitation\n end",
"def make_activation_code\n self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def accept_invite2\n # find the invitation\n @invitation = Invitation.find_by_verify_email_token(params[:token])\n duplicate_accept_invite = false\n\n # has the invitation already been accepted?\n if @invitation.status.eql?('accepted')\n duplicate_accept_invite = true\n @invitation.accept_count += 1\n @invitation.save\n else\n if @invitation.accept_count.blank?\n @invitation.accept_count = 1\n end\n @invitation.update_attributes(:status => 'accepted')\n end\n # do we know the invitee? is used in the view to customize the msg \n @person = Person.where(\"email = ? AND status = 'active_mobile'\", @invitation.invitee_email).first\n\n end",
"def existing_workplace_invite(sender, invite, recipient_email, recipient_name, workplace)\n @sender = sender\n @invite = invite\n @recipient_email = recipient_email\n @recipient_name = recipient_name\n @workplace = workplace \n mail(to: \"#{@recipient_email}\", subject: \"#{@sender.name} added you to an Ossemble Workplace\")\n end",
"def make_activation_code\n self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n end",
"def invite\n service_response = AdminManagement::AdminUser::Invite::Send.new(params).perform\n render_api_response(service_response)\n end",
"def create_invite_token\n admin_invite_token = Digest::MD5.hexdigest(\"#{@invite_admin_obj.id}::#{@invite_admin_obj.name}::#{Time.now.to_i}::invite_admin::#{rand}\")\n db_row = TemporaryToken.create!({\n client_id: @client_id,\n entity_id: @invite_admin_obj.id,\n status: GlobalConstant::TemporaryToken.active_status,\n kind: GlobalConstant::TemporaryToken.admin_invite_kind, token: admin_invite_token\n })\n\n admin_invite_token_str = \"#{db_row.id.to_s}:#{admin_invite_token}\"\n encryptor_obj = LocalCipher.new(GlobalConstant::SecretEncryptor.email_tokens_key)\n r = encryptor_obj.encrypt(admin_invite_token_str)\n return r unless r.success?\n\n @invite_token = r.data[:ciphertext_blob]\n\n success\n end",
"def invite\n invitation_service.invite(invitation_params)\n end",
"def remote_invite(sender, body)\n room_hash = MD5::digest(body)[0,8]\n @connection.room_names[room_hash] = body\n @connection.room_ids[body] = room_hash\n if _user_keyhash(sender) != @connection.comm.our_keyhash\n _notice \"You have been invited by #{sender} to join #{body}.\", :notice\n end\nend",
"def invite_valid?\n if self.given_invite_code.present?\n if self.invite.present?\n errors.add(:invite_code, \"has already been used\") if self.invite.used\n else\n errors.add(:invite_code, \"must be valid\") \n end \n end\n end",
"def invite!\n #logger.debug 'invite called'\n self.confirm!\n super\n #self.confirmed_at = Time.now\n #self.save\n end",
"def invitecode_params\n params.require(:invitecode).permit(:name, :ammount, :used)\n end",
"def require_invite\n logger.debug \"ApplicationController::require_invite\"\n if require_no_user\n unless Invitation.verify?(params[:invitation_token])\n #store_location\n flash[:notice] = \"You need a valid invite code to access this page\"\n redirect_to invitation_enter_url\n return false\n end\n end\n end",
"def invited?\n session[:dinner_path] = request.path\n dinner_id = session[:dinner_path].split('/').last\n dinner = Dinner.find(dinner_id)\n email_list = dinner.guest_emails.split(',')\n if !logged_in?\n flash[:notice] = 'You must be logged in!'\n redirect_to login_path\n else \n if dinner.host != current_user\n if !email_list.include?(current_user.email)\n flash[:notice] = \"You're not invited!\"\n redirect_to user_path(current_user)\n elsif !dinner.guests.include?(current_user)\n redirect_to \"#{session[:dinner_path]}/rsvp\"\n else\n # redirect_to \"#{session[:dinner_path]}/rsvp\"\n end\n end \n end\n end",
"def new\n @gift = Gift.new\n\t@invitations = current_host.invitations\n\t@invite_hash = {}\n @invitations.each do |i| \n\t\t@invite_hash[\"#{i.party.name} | #{i.guest.name}\"] = i.id\n\tend\n end",
"def local_invite(body)\n peer = _pop_token(body)\n room = @var[:room] if body.length < 2\n _remote_control(peer, :invite, room)\n _notice \"#{peer} has been invited to #{room}\"\nend",
"def invite(invitation)\n @invitable = invitation.invitable\n @user = invitation.user\n # TODO: UPDATE the registration URL\n @registration_url = root_url\n\n view = 'invite'\n # invite_project or invite_board if available\n view += ('_%s' % invitation.invitable_type.parameterize) if @invitable\n\n title = @invitable.nil? ? Doers::Config.app_name : @invitable.title\n subject = _('%s invites you to work on %s.') % [invitation.user.name, title]\n\n mail(:to => invitation.email, :subject => subject, :template_name => view)\n end",
"def invitation_owner\n code = params[:invitation_code]\n @invitation_owner = Owner.get_invitation_owner(code)\n end",
"def code\n @code ||= (read_attribute(:code) || (member.id * Time.now.to_i).to_s(36))\n end",
"def create\n @user = User.new(params[:user])\n invite_code = params.fetch(:invite_code)\n\n respond_to do |format|\n if invite_code != current_org.invite_code\n format.html { \n flash[:notice] = 'You need an invite code to join!'\n render action: \"new\"\n }\n elsif @user.save\n OpenExamMailer.registration_confirmation(@user).deliver\n session[:user_id] = @user.id\n format.html { redirect_to root_url, notice: 'Thanks for joining OpenExam!' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def accepted_invite(user)\n @user = user\n mail(:to => user.email, :subject => \"Welcome to the Secret Santa Society.\")\n end",
"def invite_hacker(email, team, current_user)\n # you can pass these variables into the text file for the email.\n # I'm pretty sure that you can chang the .text.haml file to .html.haml file\n # in some way to actually implement the styling.\n @team = team\n @name = current_user.first_name ? current_user.first_name : current_user.email\n mail(to: email, subject: \"#{@name} wants you to join a #{HACKATHON} team!\")\n end",
"def accepted(invite, user)\n @invite = invite\n @user = user\n mail(:to => invite.user.email, :subject => \"#{@user.name} has accepted your invitation to the \\\"#{invite.idea.name}\\\" idea\", :tag => 'invite-accepted') \n end",
"def invite\r\n if request.post?\r\n @pi = PrivateInvite.new(params[:pi]) \r\n if @pi.email == User.find(session[:user_id]).email\r\n flash[:notice] = \"you are already listed\"\r\n redirect_to :back\r\n return \r\n end \r\n PrivateInvite.find_all_by_private_event_id(@pi.private_event_id).each do |p|\r\n if p.email == @pi.email\r\n flash[:notice] = \"#{@p.email}is already on the guest list\"\r\n redirect_to :back\r\n return \r\n end\r\n end\r\n \r\n @pi.invited_at = Date.today \r\n invite = Invitation.new\r\n invite.title = PrivateEvent.find(@pi.private_event_id).title\r\n invite.host_email = User.find(session[:user_id]).email\r\n invite.guest_email = @pi.email \r\n email = InvitationMailer.create_invite(invite)\r\n email.set_content_type(\"text/html\")\r\n @guest_list = PrivateInvite.find(:all)\r\n if @pi.save\r\n begin\r\n InvitationMailer.deliver(email) \r\n rescue\r\n @pi.destroy\r\n flash[:notice] = \"address not found\"\r\n end \r\n end \r\n end\r\n redirect_to :back\r\n end",
"def accept!()\n self.status = Invite::Status::ACCEPTED\n invitable.add_member invitee\n save!\n end",
"def show_my_invite(user, invites)\n invite = invites.where(user_id: user.id).first\n return_string = \"\"\n if invite.present?\n return_string += edit_state_icons(invite, true)\n end\n return_string.html_safe\n end",
"def invite(email, user)\n @recipients = \"#{email}\"\n @from = \"[email protected]\"\n @subject = \"#{user.name} has invited you to Meetronome!\"\n @sent_on = Time.now\n @body[:user] = user\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def url_after_invite(invite)\n invite.invitable\n end",
"def showInvite\n @user = current_user\n end",
"def join_server(token, invite_code)\n request(\n __method__,\n :post,\n \"#{api_base}/invite/#{invite_code}\",\n nil,\n Authorization: token\n )\n end",
"def permit_invite_code\n devise_parameter_sanitizer.for(:sign_up) << :invite_code\n end",
"def invitee_action\n begin\n if check_magic_token\n\n event_type = params[:event]\n calendar_email = params[:payload][:event][:extended_assigned_to][0][:email] # This is the email of the account used to create the calendar\n email = params[:payload][:invitee][:email]\n first_name = params[:payload][:invitee][:first_name]\n last_name = params[:payload][:invitee][:last_name]\n event_name = params[:payload][:event_type][:name]\n start_time = params[:payload][:event][:invitee_start_time_pretty]\n\n\n contact = {}\n contact['FirstName'] = first_name\n contact['LastName'] = last_name unless last_name.blank?\n contact['Email'] = email\n\n applicant_type = 'event_volunteer'\n selected_timeslot = \"#{event_name}: #{start_time}\"\n\n bz_region = User.get_bz_region(applicant_type, calendar_email)\n if bz_region.nil?\n raise NoRegionMappingException \"No bz_region set b/c we haven't mapped the calendar #{calendar_email} to a region for #{applicant_type}\"\n end\n\n if event_type == 'invitee.created'\n calendly_url = User.get_calendar_url(bz_region)\n phone = nil\n company = nil\n title_industry = nil\n city_state = nil\n career = nil\n params[:payload][:questions_and_answers].each do |qa|\n if qa[:question].downcase.include?('phone')\n phone = qa[:answer]\n elsif qa[:question].downcase.include?('employer')\n company = qa[:answer]\n elsif qa[:question].downcase.include?('title')\n title_industry = qa[:answer]\n elsif qa[:question].downcase.include?('career')\n career = qa[:answer]\n elsif qa[:question].downcase.include?('city, state')\n city_state = qa[:answer]\n end\n end\n\n # Note: city_state is supposed to be in the format: City, State. E.g. Brooklyn, NY\n # If it's not, just set the city to the whole string\n city = city_state.split(',')[0]\n state = city_state.split(',')[1]\n\n # Create a BZ User in this platform\n current_user = User.find_by_email(email)\n if current_user.nil?\n current_user = User.new(:first_name => first_name, :last_name => last_name, :email => email, :phone => phone, :applicant_type => applicant_type, :city => city, :state => state, :external_referral_url => calendly_url, :bz_region => bz_region)\n else\n current_user.bz_region = bz_region\n current_user.applicant_type = applicant_type\n end\n current_user.skip_confirmation!\n current_user.save!\n\n # Create the user in salesforce\n contact['Phone'] = phone\n contact['Signup_Date__c'] = DateTime.now\n contact['MailingCity'] = city\n contact['MailingState'] = state unless state.nil?\n contact['Company__c'] = company\n contact['Title'] = title_industry # Both their title and industry could have commans, so can't split reliable. Just stuff it all in Title field.\n contact['Career__c'] = career\n contact['BZ_Region__c'] = bz_region\n contact['User_Type__c'] = 'Event Volunteer'\n contact['BZ_User_Id__c'] = current_user.id\n contact['Came_From_to_Visit_Site__c'] = calendly_url\n\n salesforce = BeyondZ::Salesforce.new\n existing_salesforce_id = salesforce.exists_in_salesforce(email)\n client = salesforce.get_client\n if !existing_salesforce_id.nil?\n client.update('Contact', existing_salesforce_id, contact)\n else\n # There is a bug in calendly where Last Name is not actually a required field.\n # This is meant to put something in that field so at least a Salesforce record is created.\n contact['LastName'] = '<Missing>' if last_name.blank?\n\n # Note: for new users that volunteer, we don't create BZ Users. We just populate a new Salesforce\n # contact as though it was done manually. Only Fellows and LCs get BZ Users after this calendly integration goes live.\n contact['LeadSource'] = 'Volunteer Signup'\n contact['OwnerId'] = current_user.salesforce_lead_owner_id # Note that if they are already in Salesforce, we assume they have an Owner already.\n contact = client.create('Contact', contact)\n existing_salesforce_id = contact.Id\n end\n\n current_user.salesforce_id = existing_salesforce_id\n current_user.skip_confirmation!\n current_user.save!\n \n cm = current_user.auto_add_to_salesforce_campaign('Confirmed', selected_timeslot)\n if cm.nil?\n logger.debug \"######## Failed to create Campaign Member for #{current_user.inspect}. Dunno why though.\"\n end\n\n current_user.create_mailchimp\n\n elsif event_type == 'invitee.canceled'\n current_user = User.find_by_email(email)\n if !current_user.nil?\n current_user.bz_region = bz_region\n current_user.applicant_type = applicant_type\n cancellation_reason = params[:payload][:invitee][:cancel_reason]\n current_user.cancel_volunteer_signup(selected_timeslot, cancellation_reason)\n else\n logger.warn \"No user with email = #{email} found -- NOOP\"\n end\n\n else\n logger.warn \"Unrecognized event type found: #{event_type} -- NOOP\"\n end\n end\n # Need to catch all exceptions and always report that it was OK b/c Calendly will put the webhook\n # in a failed state and stop calling our endpoint until we delete and re-register the hook.\n rescue Exception => e\n logger.warn \"###### Caught #{e.inspect} -- may have failed to add the Volunteer signup information into Salesforce.\"\n end\n\n render plain: 'OK'\n end",
"def inviter\n invite = Invitation.find_by_recipient_email(login)\n User.find(invite.sender_id) unless invite.nil?\n end",
"def exchange_code; end",
"def on_invite(&block)\n @on_invite_block = block\n end",
"def block_from_invitation?\n false\n end",
"def code_login_instructions(record, code, opts = {})\n @code = code\n opts[:subject] = \"#{@code} is your login code\"\n devise_mail(record, :login_code, opts)\n end",
"def get_invite_message(bitch_message=nil)\n name = get(\"name\").split(\" \").first # Get the first name\n id = get(\"id\")\n messages = get(\"messages\")\n bitch_message = bitch_message || messages[(rand(messages.length-1))][\"abuse\"]\n return \"#{name} says... #{bitch_message}!!\\nIs that cool with you? B*tch back!\\nInstall Yo! B*tch app from http://#{CONFIG.get(:domain)}/i/#{id}/#{name}\"\n end",
"def create_invite_hash!\n self.invite_hash = Digest::SHA2.new(256).update(\"#{self.serializable_hash}+#{Time.now}+jibffffrrrji!@#sh\").to_s[2..12]\n end",
"def invite_resource\n ## skip sending emails on invite\n u = resource_class.invite!(invite_params, current_inviter) do |u|\n u.skip_invitation = true\n u.invitation_sent_at = DateTime.now\n end\n flash[:link] = accept_user_invitation_url(:invitation_token => u.raw_invitation_token)\n u\n end",
"def add_as_client \n Event.create( \n :event_type => 'invitation',\n :detail_i1 => guest.id,\n :user_id => self.case.author.id\n ) \n self.case.author.add_client(guest) || true\n end",
"def generate_invite_code(size = 10)\n charset = %w[2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z]\n (0...size).map { charset.to_a[rand(charset.size)] }.join\n end",
"def invite_user(param)\n email_addresses.set param[:email]\n is_owner.set(true) if param[:owner] == 'true'\n unless nil_or_empty?(param[:apps])\n param[:apps].each_with_index do |item, index|\n app_drop_down.select item\n role_drop_down.select param[:roles][index] if param[:roles]\n site_drop_down.select param[:sites][index] if param[:sites]\n add_new_app.click\n end\n end\n invite_button.click\n end",
"def verify_code\n invitation = verify_code_validity\n invitation_status = invitation.status if invitation\n invitor_name = User.find(invitation.user_id).name if invitation_status == PENDING_INVITATION_STATUS\n respond_to do |format|\n #format.html { redirect_to invitations_url, notice: 'Invitation was successfully destroyed.' }\n if invitor_name\n \tformat.json { render :json => {:invitor_name => invitor_name, :status => true } }\n else\n format.json { render :json => { :error => 'Invalid or taken code.', :status => false } }\n end\n end\n end",
"def show\n\t\tif current_invite.nil?\n\t\t\tinvite = Invite.where(:id => params[:id], :secret => params[:secret]).where('expires > ?', Time.now).first\n\t\t\tif invite.present?\n\t\t\t\tsession[:invite_id] = invite.id\n\t\t\tend\n\t\tend\n\tend",
"def login_code\n user = User.first\n login_code_code = rand_validation_code\n UserMailer.login_code(user, login_code_code,\n SessionsController::LOGIN_CODE_VALIDITY)\n end",
"def invite(invitation)\n @invitation = invitation\n mail(to: invitation.email, subject: \"#{invitation.user.name} invite you to join GURUPU\")\n end",
"def invite(nickname, channel)\n send_data(\"INVITE #{nickname} #{channel}\")\n end",
"def create\n @user = User.new params[:user]\n invite_code = params[:invite_code]\n @invite = Invite.find_redeemable(invite_code)\n\n if invite_code && @invite\n if @user.save\n @invite.redeemed!\n ClearanceMailer.deliver_confirmation @user\n flash[:notice] = \"You will receive an email within the next few minutes. \" <<\n \"It contains instructions for confirming your account.\"\n redirect_to url_after_create\n else\n render :action => \"new\"\n end\n else\n flash.now[:notice] = \"Sorry, that code is not redeemable\"\n render :action => \"new\"\n end\n end"
] | [
"0.76387304",
"0.754709",
"0.72436905",
"0.72416025",
"0.6952381",
"0.6828545",
"0.6672465",
"0.6549126",
"0.6514559",
"0.64977175",
"0.64647174",
"0.64445704",
"0.6424634",
"0.6411214",
"0.63947904",
"0.6377739",
"0.63747996",
"0.63674206",
"0.6337006",
"0.6308173",
"0.62807274",
"0.62696534",
"0.62660795",
"0.62348557",
"0.6205517",
"0.6204521",
"0.61975825",
"0.6193489",
"0.6184454",
"0.6182329",
"0.61813235",
"0.61782765",
"0.61759794",
"0.61459625",
"0.61451036",
"0.61388415",
"0.61364937",
"0.60995907",
"0.6093655",
"0.6083499",
"0.6068022",
"0.60565615",
"0.60424495",
"0.6031935",
"0.6020061",
"0.60198677",
"0.5993271",
"0.5991189",
"0.5990243",
"0.5986055",
"0.5979425",
"0.59723383",
"0.59698206",
"0.5961411",
"0.59607416",
"0.5948423",
"0.5935372",
"0.5928636",
"0.59272784",
"0.5922669",
"0.5913639",
"0.59084517",
"0.59063494",
"0.59031034",
"0.5897835",
"0.5897771",
"0.58963364",
"0.5889515",
"0.5885812",
"0.5880046",
"0.58672184",
"0.5867039",
"0.5865982",
"0.58533615",
"0.58528733",
"0.58520716",
"0.584858",
"0.58432233",
"0.5836586",
"0.581892",
"0.5815684",
"0.58144236",
"0.58110297",
"0.58022845",
"0.57986987",
"0.57952523",
"0.57951325",
"0.5791237",
"0.5789498",
"0.57830834",
"0.5780035",
"0.57795453",
"0.5778913",
"0.575865",
"0.5755556",
"0.5755087",
"0.5748683",
"0.573969",
"0.57340264",
"0.5731968"
] | 0.82367903 | 0 |
Change the name of the room | def name=(name)
connection.post("/room/#{@id}.json", :body => { :room => { :name => name } })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name=(name)\n tinycache_adapter.write(:name, name)\n client.api.set_room_name(id, name)\n name\n end",
"def set_room(room_name)\n @room = find_room_by_name(room_name)\n end",
"def new_name(new_name)\n @name = new_name\n end",
"def name\n name = \"Store Room\"\n end",
"def set_room\n @room = Room.find(params[:id])\n @page_title << @room.name\n end",
"def set_name\n self.update(name: \"Medium Washer ##{self.id}\") unless self.name\n end",
"def set_name\n self.update(name: \"Large Washer ##{self.id}\") unless self.name\n end",
"def name=(value)\n if @playing_girl\n @name_girl = value\n else\n @name_boy = value\n end\n $game_actors[1].name = value\n end",
"def room_change(room_name)\n indx = @channels.index(@channels.find { |room,_| room == room_name })\n unless indx\n indx = @channels.length\n new_tab(room_name)\n end\n @tabs.current = indx\n @switcher.current = indx\n @tab_names[indx].show\n (@tabs.create ; @tabs.show) if @skin[:show_tabs] and indx != 0\n tab_notify(indx, false)\n @tabs.recalc\n @channels[indx].last.type_focus rescue nil\n end",
"def name= new_name\n @gapi.update! name: String(new_name)\n end",
"def name=(name)\n\t\t@new_name = name\n\tend",
"def set_player_name(msg, name=nil)\n player = get_player msg\n unless name\n msg.reply player.name\n return\n end\n if player.name\n msg.reply \"The majestic #{player.name} refuses to change his name!\"\n return\n end\n player.name = name\n player.save\n msg.reply \"Welcome, #{player.name}!\"\n end",
"def set_name(player_name)\n @player_name = player_name\n end",
"def name=(new_name)\n\t\t@name = new_name\n\tend",
"def name= (new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name= new_name\n @name = new_name\n end",
"def enter_name(name)\n return @player_name = 'Anonymus' if name.empty?\n\n @player_name = name[0...18]\n end",
"def change_name=(name)\n @name = name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n end",
"def name\n client.api.get_room_name(id)[:name]\n rescue MatrixNotFoundError\n # No room name has been specified\n nil\n end",
"def name_setter(new_name)\n @name = new_name\n end",
"def name=(new_name)\n @name = new_name\n $game_party.quests.add_to_sort_array(:alphabet, @id) if $game_party && \n $game_party.quests\n end",
"def local_names(body)\n body = @var[:room] if body.length < 1\n room_id = @connection.room_ids[body]\n raise \"Invalid room name: #{body}\" unless room_id\n @var[:names_requested] = true\n _server_control('names', room_id)\nend",
"def name=(new_name)\n @name=new_name\n end",
"def set_name(uuid, new_name)\n execute_prlctl('set', uuid, '--name', new_name)\n end",
"def set_name name\n\t\t\t@name = name.gsub \" (#{@addr})\", ''\n\t\tend",
"def room_has_name()\n return @room1.name\n end",
"def change_item_name(new_name:, **)\n self.name = new_name # This will generate the event!\n end",
"def update_event_name\n new_name = self.class.prompt.ask(\"New event name:\")\n self.update(name: new_name)\n end",
"def name=(new_name) \n @name = new_name\n end",
"def name=(new_name)\n if new_name != self.name\n self.old_name = self.name\n self.write_attribute(:name, new_name)\n end\n end",
"def change_name(object, symbol, old_name, new_name, activity_params)\n return if old_name == new_name || new_name.blank? || !object.update(name: new_name)\n create_activity(object, \"#{symbol}_name\", old_name, new_name, activity_params)\n end",
"def name=(name)\n @name = name.to_s\n end",
"def name=(name)\n @name = name.to_s\n end",
"def on_name_changed(new_name:, **)\n @name = new_name\n end",
"def roomName(hash={})\n\t\t$roomtitle = $_SERVERSTRING_.gsub(/<[^>]+>/o,'')\n\t\tif $roomtitle.include?(',')\n\t\t\t$roomarea = $roomtitle.split(',').first\n\t\tend\n\tend",
"def set_full_name\n self.full_name = \"#{manufacturer.name} #{name}\"\n end",
"def update_name(new_name)\n self.update(name: new_name)\n self\n puts \"Your username has been updated.\".colorize(:magenta)\n end",
"def set_other_name(other_name)\n @other_player_name = other_name\n end",
"def set_name(name)\n @name = name\n end",
"def change_name\n\t\tif not_allowed()\n\t\t\treturn\n\t\tend\n\n\t\tif missing_params(params, ['competition_id', 'round_number', 'new_name', 'old_name'])\n\t\t\treturn\n\t\tend\n\n\t\tbegin\n\t\t\thost = Host.where(host: request.host).take\n\t\t\tcompetition = host.organization.competitions.find(params[:competition_id])\n\t\trescue\n\t\t\trender json: {:result => false, :message => \"Could not find competition.\"}\n\t\t\treturn\n\t\tend\n\t\trender json: {:result => true}\n\n\t\tevent_hash = {};\n\t\tevent_hash[:event] = \"change_name\"\n\t\tevent_hash[:round_number] = params[:round_number]\n\t\tevent_hash[:new_name] = params[:new_name]\n\t\tevent_hash[:old_name] = params[:old_name]\n\n\t\tnew_event(competition, event_hash)\n\tend",
"def name=(name)\n @name ||= name.to_s\n end",
"def set_name\n name = \"\"\n\n if self.firstname.blank? && self.lastname.blank?\n unless self.login.blank?\n name = self.login\n else\n name = self.email\n end\n else\n name = \"#{self.firstname} #{self.lastname}\"\n end\n\n self.update_column(:name, name)\n #self.name = \"Ferdinand\"\n end",
"def set_name(a_name)\n @name = a_name\n end",
"def setName(n)\n @name = n\n end",
"def set_NewName(value)\n set_input(\"NewName\", value)\n end",
"def set_NewName(value)\n set_input(\"NewName\", value)\n end",
"def update_name\n # update the name so it includes the standard_template string\n name_array = [@standard_template]\n name_array << get_building_type\n @building_sections.each do |bld_tp|\n name_array << bld_tp.standards_building_type\n end\n name_array << @name if [email protected]? && !@name == ''\n @name = name_array.join('|').to_s\n end",
"def update_boat_name=(name)\n @name = name\n puts @name\n end",
"def change_partner_name(name)\n change_name_link.click\n partner_name_tb.type_text(name)\n save_changes_partnername.click\n wait_until_bus_section_load\n end",
"def change_name(name)\n self.change_all_attribute(name, 'name')\n end",
"def set_room\n @room = Room.find(params[:id])\n \n end",
"def set_room\n @room = TmuAdmin::Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def new_name; end",
"def name=(new_name)\n raise ArgumentError if new_name.nil?\n end",
"def change_name(new_name)\n Dropio::Resource.client.change_drop_name(self,new_name)\n end",
"def room\n end",
"def full_name\n Venue.find(venue_id).name + \" - \" + roomName\n end",
"def name=(new_name)\n if new_name.is_a?(String)\n unless new_name.include?(@location.delimiter)\n @location.name = new_name\n location_changed!\n end\n end\n end",
"def name\n @name || \"door\"\n end",
"def set_name=(name)\n @name = name\n end",
"def name=(aname)\n\t\t@name=aname\n\tend",
"def name=(value)\n @name = value.to_s\n end",
"def set_room\n\t\t\t@room = Room.find(params[:id])\n\t\tend",
"def name=(n)\n @name = n.capitalize\n end",
"def name=(name)\r\n @name = name.capitalize\r\n end",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def setName(name)\r\n\t\t\t\t\t@name = name\r\n\t\t\t\tend",
"def set_name\n @appname = \"Bike London\"\n end",
"def name= new_name\n patch_gapi! name: new_name\n end"
] | [
"0.74344593",
"0.7372264",
"0.6911815",
"0.6841977",
"0.68415135",
"0.6718905",
"0.66798884",
"0.6624731",
"0.659215",
"0.6544838",
"0.64946675",
"0.6442982",
"0.64412916",
"0.64101684",
"0.63888556",
"0.63838935",
"0.63838935",
"0.63493305",
"0.63428617",
"0.63157773",
"0.6304479",
"0.6304479",
"0.6303495",
"0.62922823",
"0.6286246",
"0.6282976",
"0.62817776",
"0.62713766",
"0.62417346",
"0.6226351",
"0.6224421",
"0.62177855",
"0.62147826",
"0.62116456",
"0.6201867",
"0.61457276",
"0.61414385",
"0.61414385",
"0.6137792",
"0.6132598",
"0.6090571",
"0.6066888",
"0.60605836",
"0.6050784",
"0.6049037",
"0.603895",
"0.6038393",
"0.60349065",
"0.601345",
"0.6011066",
"0.6011066",
"0.60109544",
"0.5997793",
"0.5980177",
"0.5979718",
"0.59738564",
"0.59672445",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.59584653",
"0.5958258",
"0.59553117",
"0.59465784",
"0.59431547",
"0.5941079",
"0.5928109",
"0.59257936",
"0.59252423",
"0.5923182",
"0.5918959",
"0.5908018",
"0.5907782",
"0.59076476",
"0.59068",
"0.5887342",
"0.5887342",
"0.5887342",
"0.5887342",
"0.5887342",
"0.58801144",
"0.58797777"
] | 0.7658218 | 0 |
Get the current topic | def topic
load
@topic
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topic\n return @topic\n end",
"def topic\n return @topic\n end",
"def topic\n return @topic\n end",
"def topic\n @topic ||= client.topic config.topic\n end",
"def topic\n @topic.to_s\n end",
"def get_topic\n\t\treturn Topic.find(Debate.find(self.debate_id).topic_id)\n\tend",
"def get_topic\n Topic.find(params[:id])\n end",
"def topic\n if @topic\n @topic\n else\n connected do\n fiber = Fiber.current\n callbacks = {}\n [331, 332, 403, 442].each do |numeric|\n callbacks[numeric] = @thaum.on(numeric) do |event_data|\n topic = event_data[:params].match(':(.*)').captures.first\n fiber.resume topic\n end\n end\n\n raw \"TOPIC #{@name}\"\n @topic = Fiber.yield\n callbacks.each do |type, callback|\n @thaum.callbacks[type].delete(callback)\n end\n\n @topic\n end\n end\n end",
"def topic\n if @topic\n @topic\n else\n fiber = Fiber.current\n callbacks = {}\n [331, 332, 403, 442].each do |numeric|\n callbacks[numeric] = @thaum.on(numeric) do |event_data|\n topic = event_data[:params].match(':(.*)').captures.first\n fiber.resume topic\n end\n end\n\n raw \"TOPIC #{@name}\"\n @topic = Fiber.yield\n callbacks.each do |type, callback|\n @thaum.callbacks[type].delete(callback)\n end\n\n @topic\n end\n end",
"def topic\n @topic.join('/')\n end",
"def topic\n @_topic ||= request.env['loudmouth_map'][:topic_model].singularize.downcase\n end",
"def topic()\n Sensit::Api::Topic.new @http_client\n end",
"def get_topic\n Topic.find(params[:id])\n end",
"def topic\n SignedUpTeam.find_by(team_id: id, is_waitlisted: 0).try(:topic_id)\n end",
"def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end",
"def find_topic\n @topic = current_user.topics.find(params[:topic_id])\n end",
"def show\n\n\t\t@topic = Topic.find(params[:id])\n\t\tsession[:topic_id] = @topic.id\n\n\t\treturn @topic\n\n\tend",
"def my_topic\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def get_topic topic_name, options = {}\n publisher.get_topic topic: topic_path(topic_name, options)\n end",
"def topic\n client.api.get_room_topic(id)[:topic]\n rescue MatrixNotFoundError\n # No room name has been specified\n nil\n end",
"def recent_topic\n (recent_topics count: 1)[0]\n end",
"def resource_topic\n if @topics.empty?\n raise TopicNotSubscribedError, \"Resource '#{@uid}' has not subscribed to any topics\"\n end\n @topics[0]\n end",
"def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end",
"def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end",
"def topic\n team_topic = nil\n\n participants.each do |participant|\n team_topic = participant.topic\n break if team_topic\n end\n\n team_topic\n end",
"def topic_id\n id\n end",
"def get_topic id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get TOPICS, id )\n\t\t\t\tend",
"def topic=(value)\n @topic = value\n end",
"def topic=(value)\n @topic = value\n end",
"def topic=(value)\n @topic = value\n end",
"def find_forum_topic\n @forum_topic = @node.content\n end",
"def subscription_for(topic)\n subscriptions.where(:topic_id => topic.id).first\n end",
"def sns_topic\n data.sns_topic\n end",
"def topic\n begin\n @topic = @owner.topics.find(params[:id])\n rescue render_return\n end\n end",
"def get_topic(topic_id, oauth = true)\n\t\t\toptions = {\"id\" => topic_id}\n\t\t\tif oauth\n\t\t\t\toptions.merge!(key: Goodreads.configuration[:api_key])\n\t\t\t\tdata = oauth_request(\"/topic/show.xml\", options)\n\t\t\telse\n\t\t\t\tdata = request(\"/topic/show.xml\", options)\n\t\t\tend\n\t\t\tHashie::Mash.new(data)\n\t\tend",
"def index\n @topics = current_user.topics\n end",
"def featured_topic(local_site=nil)\n ft = LayoutSetting.find_setting(local_site, nil, \"staging\", \"topic\")\n ft ? Topic.find_topic(ft.value, local_site) : Topic.find(:first) # SSS FIXME?\n end",
"def topics\n _topics\n end",
"def set_topic\n @topic = Admin::Topic.find(params[:id])\n end",
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def topic(_name)\n raise 'not implemented'\n end",
"def topic(chan, topic)\n sep = $config['plugins/topic/separator', '|']\n chan.server.cmd('TOPIC', chan.name, topic.join(\" #{sep} \"))\n end",
"def topic( name )\n Qup::Adapter::Kestrel::Topic.new( @addr, name )\n end",
"def read_topic(chan)\n sep = $config['plugins/topic/separator', '|']\n (topic = chan.topic) ? topic.split(\" #{sep} \") : []\n end",
"def id\n return self.topic['id'].to_i\n end",
"def topic(name)\n pubsub.topic(name) || create_topic(name)\n end",
"def get(topic_name, &onMessage) # string, block => Topic;\n end",
"def view\n get_topic(@current_id, :resolve => false)\n get_complete_topic(@current_id, :resolve => false)\n get_related_for_current\n end",
"def topic(channel, topic = nil)\n if topic.nil?\n raw \"TOPIC #{channel}\\r\\n\"\n else\n raw \"TOPIC #{channel} :#{topic}\\r\\n\"\n end\n end",
"def get_topic_name(id)\n @topic_map[id]\n end",
"def get(topic_name)\n topic = service.get_topic(topic_name).body\n new(topic)\n rescue Fog::Errors::NotFound\n nil\n end",
"def topic(topic_name, &proc)\n t = create_topic(topic_name)\n proc.call(t) if proc\n t\n end",
"def new\n\n\t\t@topic = Topic.new(nil)\n\n\t\treturn @topic\n\n\tend",
"def show\n @admin_topic = Admin::Topic.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @admin_topic }\n end\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def find_topic\n @topic = Topic.find(params[:topic_id]) if params[:topic_id]\n end",
"def topic(name)\n Kazoo::Topic.new(self, name)\n end",
"def GetTopic id\n\n APICall(path: \"topics/#{id}.json\")\n\n end",
"def kafka_topic\n name.pluralize.underscore.gsub(\"/\", \"-\")\n end",
"def category\n Topic.find(self.category_id)\n end",
"def topic_navigator\n Gadgets::Community::TopicNavigator.new(@config.browser)\n end",
"def sns_topic\n @sns_topic ||= if sns_topic_arn.present?\n Aws::SNS::Resource.new(region: 'eu-west-2').topic(sns_topic_arn)\n end\n end",
"def get_topic(org_unit_id, topic_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _get(query_string)\nend",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def topic(name)\n name = name.to_s\n\n @topics[name] ||= begin\n @topic_names = nil\n self.class::Topic.new(name)\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n render 'api/v1/topics/show'\n end",
"def set_topic\n @topic = Topic.friendly.find(params[:topic_id])\n end",
"def topic(message)\n puts \"-----> #{message}\"\nend",
"def subscription\n @current\n end",
"def topic=(topic)\n tinycache_adapter.write(:topic, topic)\n client.api.set_room_topic(id, topic)\n topic\n end",
"def get_topic_id_from_topicdetail\n #if topicdetail_id #!= nil\n timetable_id = 1 #topicdetail_id#Topicdetail.find(topicdetail_id).topic_code\n #end\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end",
"def set_topic\n @topic = Topic.find(params[:id])\n end"
] | [
"0.85295093",
"0.84955055",
"0.84955055",
"0.81091905",
"0.7965236",
"0.76474184",
"0.7608643",
"0.753008",
"0.7507351",
"0.7482701",
"0.74822533",
"0.73460495",
"0.72347134",
"0.71954453",
"0.7182757",
"0.7182757",
"0.7149849",
"0.7147728",
"0.7081121",
"0.70697045",
"0.69611204",
"0.694094",
"0.6937384",
"0.6937384",
"0.6937384",
"0.6918575",
"0.6853317",
"0.680214",
"0.6791219",
"0.6791219",
"0.6777723",
"0.6765587",
"0.6705638",
"0.66937906",
"0.6556595",
"0.65561616",
"0.65477395",
"0.6547055",
"0.65437543",
"0.6519768",
"0.65106064",
"0.6509683",
"0.65087396",
"0.64346683",
"0.6433978",
"0.6417452",
"0.64123446",
"0.6409094",
"0.64047855",
"0.6400289",
"0.63816905",
"0.63597786",
"0.63291407",
"0.6320828",
"0.62876576",
"0.62876576",
"0.62643224",
"0.6261085",
"0.62531346",
"0.62523043",
"0.6249646",
"0.624871",
"0.62471795",
"0.62404406",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.62083447",
"0.61956894",
"0.6189804",
"0.61817217",
"0.6169205",
"0.6167622",
"0.61672527",
"0.6126857",
"0.6125022",
"0.6125022"
] | 0.80420315 | 4 |
Lock the room to prevent new users from entering and to disable logging | def lock
post :lock
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lock_to!(user)\n update_columns(locked_at: Time.current, locked_by: user.id)\n end",
"def lock!\n @locked = true\n end",
"def lock!\n @locked = true\n end",
"def lock!\n self.for_update!\n end",
"def lock\n if unlocked_status == false\n raise ArgumentError.new(\"You cannot lock this door - it is already locked\")\n else\n door_hash[:unlocked_status] = false\n end\n end",
"def locked\n end",
"def lock\n self.is_locked = true\n self\n end",
"def locked\n # Get the current user\n user = current_user\n # If the lock has passed its expiry date, and the lock is not permanent\n if user.lock.expires_at <= Time.now && !user.lock.permanent?\n # Destroy the lock record\n user.lock.destroy!\n end\n # If the account is still locked\n if user.lock != nil\n # Notify the user that their account has been locked\n flash[:error] = \"Your account has been locked. Please contact Player Support for more information\"\n # Log the user out\n logout\n # Take the user to the homepage\n redirect_to root_path\n end\n end",
"def block_room\n\t\tself.room.set_occupied\n\tend",
"def prevent_locked_user_login\n config = sorcery_config\n should_unlock =\n !login_unlocked? &&\n config.login_lock_time_period != 0 &&\n send(config.lock_expires_at_attr_name) <= Time.current\n\n login_unlock! if should_unlock\n\n return false, :locked unless login_unlocked?\n\n true\n end",
"def admin_lock\n data = params[:user_id]\n role = params[:role_id]\n\n #start query\n query = Admin.where(id: data, role_id: role)\n\n #on change le statut de l'utilisateur\n query.lock = true\n\n if query.save\n redirect_to parametre_admins_admin_show_path, flash[:notice] = \"User locked\"\n end\n\n end",
"def lock\n @unlocked = false\n \"Diary is now locked\"\n end",
"def acquire_lock\n\t\t@@logger.info { \"Acquiring a lock in the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => false).update(:locked => true) != 0\n\tend",
"def login_lock!\n config = sorcery_config\n attributes = {\n config.lock_expires_at_attr_name => Time.current + config.login_lock_time_period,\n config.unlock_token_attr_name => self.class.generate_random_token\n }\n sorcery_orm_adapter.update_attributes(attributes)\n\n if config.unlock_token_mailer_disabled || config.unlock_token_mailer.nil?\n return\n end\n\n send_unlock_token_email!\n end",
"def lock\n if @unlocked == false\n raise Exception.new(\"a locked door needith not to be locked\")\n else\n return @unlocked = false\n end\n end",
"def locked; end",
"def lock\n # locking will automatically trigger reload\n # locker older than 1 hour is considered stale\n if !is_locked || (is_locked && locked_at < Time.now - 3600)\n self.is_locked = true\n self.locked_at = Time.now\n save!\n else\n false\n end\n end",
"def lock!(user = User.current)\n self.comment = \"Agenda closed\"\n self.author = user\n self.locked = true\n self.save\n end",
"def lock_list\n super\n end",
"def create\n login\n lock\n end",
"def lock(opts={})\n super\n end",
"def lock(opts={})\n super\n end",
"def lock(opts={})\n super\n end",
"def lock\n @locked = true\n self\n end",
"def acquire!(locker)\n self.locked_by = locker\n self.locked_at = Time.now\n save!\n end",
"def lock\n end",
"def lock\n @privkey = nil\n @locked = true\n end",
"def lock?\n record.unlocked? && (director?(record.event) || competition_admin? || super_admin?)\n end",
"def lock_topic!\n update_attribute(:locked, true)\n end",
"def lock\n shaz_nolock_lock if !@nolock\n end",
"def return_lock\n\t\t@@logger.info { \"Returning the lock to the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => true).update(:locked => false) != 0\n\tend",
"def isLocked\n room = Room.find_by_id params[:id]\n\n if room.nil?\n respond_with locked: true\n else\n if room.lock_owner_user_id.nil? || room.room_lock_start.nil? || room.lock_owner_user_id == session[:uid]\n respond_with locked: false\n else\n respond_with locked: true\n end\n end\n end",
"def unlock!\n self.locked_by = nil\n self.locked_at = nil\n save!\n end",
"def lock_expired?; end",
"def can_lock?(current_user)\n return false if current_user.anonymous?\n\n not is_locked?\n end",
"def lock_spacetime\n\t\tbroadcast_message :lock_spacetime, {\n\t\t\tid: message[:space_time_id]\n\t\t}\n\tend",
"def login_unlock!\n config = sorcery_config\n attributes = {\n config.lock_expires_at_attr_name => nil,\n config.failed_logins_count_attr_name => 0,\n config.unlock_token_attr_name => nil\n }\n sorcery_orm_adapter.update_attributes(attributes)\n end",
"def reject_locked!\n if current_user && current_user.locked?\n sign_out current_user\n user_session = nil\n current_user = nil\n flash[:alert] = \"Your account is locked.\"\n flash[:notice] = nil\n redirect_to root_url\n end\n end",
"def reject_locked!\n if current_user && current_user.locked?\n sign_out current_user\n user_session = nil\n current_user = nil\n flash[:alert] = \"Your account is locked.\"\n flash[:notice] = nil\n redirect_to root_url\n end\n end",
"def lock!\n freeze!\n @locked = true\n self\n end",
"def reject_locked!\n if current_user && current_user.locked?\n sign_out current_user\n user_session = nil\n current_user = nil\n flash[:alert] = 'Your account is locked.'\n flash[:notice] = nil\n redirect_to root_url\n end\n end",
"def account_locked\n @user = User.find(params[:id])\n end",
"def reject_locked!\n if current_user && current_user.locked?\n sign_out current_user\n flash[:alert] = \"Your account is locked.\"\n flash[:notice] = nil\n redirect_to root_url\n end\n end",
"def ensure_exclusive\n acquire_locks\n write_pid\n end",
"def reject_locked!\n if current_user && current_user.is_locked?\n sign_out current_user\n user_session = nil\n current_user = nil\n flash[:alert] = \"Your account is locked.\"\n flash[:notice] = nil\n redirect_to root_url\n end\n end",
"def toggle_locking(current_user)\n if can_toggle_locking?(current_user)\n is_locked? ? unlock : lock(current_user.id) # TODO: raise exception or report error here?\n end\n end",
"def unlock\n self.is_locked = false\n self.locked_at = nil\n save!\n end",
"def mlock!(modes)\n @session.chanserv.set(self.name, :mlock, modes)\n end",
"def unlock\n self.is_locked = false\n self\n end",
"def lock!; end",
"def is_locked=(value)\n @is_locked = value\n end",
"def lock_forum\n @lecture.forum.update(locked: true) if @lecture.forum?\n redirect_to edit_lecture_path(@lecture)\n end",
"def lock(name, mode)\n yield\n end",
"def is_locked?\n locked\n end",
"def lock\n @can_get_cards = false\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def locked?\n end",
"def locker(name)\n Locker.exclusive_locker(self, name)\n end",
"def unlock\n @locking = false\n end",
"def lock_messages\n maildrop.messages.all.each do |msg|\n locked_messages.create(message: msg)\n end\n end",
"def can_lock?(user, space)\n user.review_space_admin? && space.shared? && space.active?\n end",
"def password_require_to_unlock_from_idle=(value)\n @password_require_to_unlock_from_idle = value\n end",
"def unlock\n end",
"def current_user_owns_room\n\n \t# Then find the room that is trying to be edited\n \troom = Room.find(params[:id])\n \t# And only allow if current user made that room\n \tunless logged_in? and current_user == room.user\n \t\t# Otherwise flash error and redirect to show page\n \t\tflash[:error] = \"Only the owner can edit\"\n \t\t# (room) indicates the requirement for an id form the url\n \t\tredirect_to room_path(room) \t\t\n \tend\n end",
"def access_locked?; end",
"def enable_lock\n add option: \"-lock=true\"\n end",
"def allow_lock\n if params[:checked] == \"1\"\n if !params[:current_user_id].blank?\n locks = Communication.find(params[:note_id]).update_attributes(:lock_by_user_id => \"#{params[:current_user_id]}\")\n end\n else\n locks = Communication.find(params[:note_id]).update_attributes(:lock_by_user_id => \"\")\n end\n render :update do |page|\n if params[:checked] == \"1\"\n flash[:notice] = \"Succesfuly locked\"\n page.redirect_to wfm_notes_path\n else\n flash[:notice] = \"Succesfuly Unlocked\"\n page.redirect_to wfm_notes_path\n end\n end\n end",
"def mgmt_lock\n @dailybank.update_attribute(:status, \"Locked\")\n redirect_to @dailybank, notice: \"Thank you for reviewing End of Night. This record is now locked\"\n end",
"def access_locked?\n\n super && date_restricted?\n\n end",
"def lock\n authorize! :lock, @topic\n @topic.lock\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully locked.' }\n format.json { head :no_content }\n else\n format.html { redirect_to @topic, flash: { error: 'Unable to lock topic.' } }\n format.json { render json: 'Unable to lock topic.', status: :unprocessable_entity }\n end\n end\n end",
"def lock_movements?\n true\n end",
"def lock_status(opts)\n opts = check_params(opts,[:lock_names])\n super(opts)\n end",
"def block!\n self.update_attribute(:status, ConfigCenter::User::BLOCKED)\n end",
"def lock(key, admin = false)\n if @lockable and not @locked and (@keys.include? key or admin)\n @locked = true\n\n if self.can? :connected_to\n other = $manager.find self.connected_to\n other.lock(key, admin) if other.can? :lock\n end\n\n true\n else\n false\n end\n end",
"def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end",
"def unlocked?\n not locked?\n end",
"def lock\n if self.open?\n raise TypeError.new(\"Open doors cannot be locked. Close the door and try again.\")\n elsif self.locked?\n raise TypeError.new(\"Door is already locked. Locked doors cannot be locked again.\")\n else\n @locked = true #omg i can't believe i had this as false for so long.\n end\n return self\n end",
"def locked?\n locked_by.present? && locked_at.present? && locked_at > 10.minutes.ago\n end",
"def lock_self_and_visits!\n self.lock!\n self.visits(:lock => true)\n end",
"def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.locked_at = now\n self.locked_by = worker\n end\n\n true\n end",
"def locked?\n @locked\n end",
"def message_soft_lock_prevent\n if $game_temp.message_window_showing\n log_error('Message were still showing!')\n $game_temp.message_window_showing = false\n end\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def set_room\n @launch_params = nil\n @room = nil\n @error = nil\n begin\n @room = Room.find(params[:id])\n unless cookies[@room.handler] || session['admin']\n @room = nil\n @error = { key: t('error.room.forbiden.code'), message: t('error.room.forbiden.message'), suggestion: t('error.room.forbiden.suggestion'), :status => :forbidden }\n return\n end\n @launch_params = JSON.parse(cookies[@room.handler])\n rescue ActiveRecord::RecordNotFound => e\n @error = { key: t('error.room.notfound.code'), message: t('error.room.notfound.message'), suggestion: t('error.room.notfound.suggestion'), :status => :not_found }\n end\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def locked?\n @locked\n end",
"def unlock\n self.locked_at = nil\n self.locked_by = nil\n end",
"def check_room_user\n set_room\n if current_user.id != @room.user.id\n redirect_to bookings_path, notice: \"Cannot Accept/Decline a booking of a room belonging to another user.\"\n end\n end",
"def locks\n sql = %q(\n select\n pg_stat_activity.procpid,\n pg_class.relname,\n pg_locks.transactionid,\n pg_locks.granted,\n substr(pg_stat_activity.current_query,1,30) as query_snippet,\n age(now(),pg_stat_activity.query_start) as \"age\"\n from pg_stat_activity,pg_locks left\n outer join pg_class on (pg_locks.relation = pg_class.oid)\n where pg_stat_activity.current_query <> '<insufficient privilege>' and\n pg_locks.pid=pg_stat_activity.procpid and pg_locks.mode = 'ExclusiveLock' order by query_start)\n\n exec_sql(sql, find_uri)\n end",
"def lock\n @mutex.lock\n end",
"def require_active_user\n unless current_user && current_user.status == UserStatus::ACTIVE\n flash[:alert]= I18n.t 'auth.msg.lock_account'\n redirect_to new_user_sessions_url\n return false\n end\n end",
"def lockout?\n @lockout\n end",
"def lockable?\n @lockable\n end",
"def set_door_lock(lock_state)\r\n\t\t@lock_state = lock_state\r\n\tend",
"def lock( actor, silent = false )\n\t\tif not @closed\n\t\t\tactor.output \"You can't lock it while it's open!\" unless silent\n\t\t\treturn false\n\t\telsif @locked\n\t\t\tactor.output \"It is already locked.\" unless silent\n\t\t\treturn false\n\t\telsif actor.items.map(&:id).include?(@key_id)\n @reset.activate if @reset\n\t\t\tunless silent\n\t\t\t\tactor.output \"Click.\"\n if @direction\n\t (actor.room.occupants - [actor]).each_output \"0<N> locks the #{self.name} to the #{@direction.name}.\", [actor]\n else\n (actor.room.occupants - [actor]).each_output \"0<N> locks #{self.name}.\", [actor]\n end\n\t\t\tend\n\n\t\t\t@locked = true\n\t\t\[email protected]( actor, silent: true ) if @pair\n\t\t\treturn true\n\t\telse\n\t\t\tactor.output \"You lack the key.\" unless silent\n\t\t\treturn false\n\t\tend\n\tend",
"def isAuth\n # Redirect the browser to the homepage, unless the user is logged in\n redirect_to root_path unless signed_in?\n # Execute the 'locked' method unless the user does not have a lock associated with their account\n locked unless current_user.lock == nil\n end",
"def if_access_locked; end"
] | [
"0.6984339",
"0.6885231",
"0.6855805",
"0.67850494",
"0.6742901",
"0.67141396",
"0.6708558",
"0.6683348",
"0.66544193",
"0.6623988",
"0.6617628",
"0.66113114",
"0.65634686",
"0.6557",
"0.6520701",
"0.64591056",
"0.6440628",
"0.64358276",
"0.6420929",
"0.6420359",
"0.6416929",
"0.6416929",
"0.6416929",
"0.64124376",
"0.640684",
"0.63887507",
"0.6363048",
"0.633647",
"0.63023216",
"0.6301409",
"0.6277242",
"0.62671155",
"0.6248017",
"0.62299514",
"0.6222836",
"0.62166667",
"0.6186542",
"0.61562973",
"0.615565",
"0.61504805",
"0.61466455",
"0.6121082",
"0.6105231",
"0.6096278",
"0.6091554",
"0.6056966",
"0.60263133",
"0.6003528",
"0.5995757",
"0.5988163",
"0.59782094",
"0.5977544",
"0.59671706",
"0.5954801",
"0.5952857",
"0.5951997",
"0.5951649",
"0.59456885",
"0.59282464",
"0.5926669",
"0.58982134",
"0.5859677",
"0.5852458",
"0.5835164",
"0.5830522",
"0.5827843",
"0.5827548",
"0.5821174",
"0.58149225",
"0.58018935",
"0.57907283",
"0.57836723",
"0.5774152",
"0.5770345",
"0.5769765",
"0.576729",
"0.5761619",
"0.5749384",
"0.57453763",
"0.57442665",
"0.5736914",
"0.5736823",
"0.5735646",
"0.5733815",
"0.57338023",
"0.5725711",
"0.5725711",
"0.5725711",
"0.5725711",
"0.57254267",
"0.5721694",
"0.5721475",
"0.5715675",
"0.57127345",
"0.5702623",
"0.5701512",
"0.56960326",
"0.5692763",
"0.568762",
"0.5685466"
] | 0.6719379 | 5 |
Post a new message to the chat room | def speak(message, options = {})
send_message(message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_message(message)\n # https://api.slack.com/methods/chat.postMessage\n # scopes: chat:write\n slack_client.chat_postMessage(\n channel: channel_id,\n thread_ts: slack_ts,\n text: message\n )\n end",
"def post_message(text)\n body ={\n \"title\" => @from_name,\n \"picture\" => @from_picture,\n \"message\" => text\n }\n\n self.class.post(room_path, request_options(body))\n end",
"def post_message(params)\n self.class.post('/chat.postMessage', body: params.merge({token: @token})).tap do |response|\n raise \"error posting message: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end\n end",
"def send_message(data)\n current_user.messages.create!(body: data[\"message\"], chat_room_id: data[\"chat_room_id\"])\n # the next line broadcasts the message without a job. BUT: that is only the message.\n # We want do more :)\n # ActionCable.server.broadcast(\"chat_rooms_channel\", message: data[\"message\"])\n end",
"def post_message(params)\n self.class.post('/chat.postMessage', body: params.merge({token: @token})).tap do |response|\n raise \"error posting message: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end\n end",
"def chat_message\n @room=current_user.room\n\n @chat_message=ChatMessage.create! content: params[:message],owner_id: current_user.id\n chat_message=render_to_string partial: \"chat_message/chat_message\"\n\n publish_async(\"presence-room_#{@room.id}\", \"chat_message\", {\n message: chat_message\n })\n\n render json: {\n message: chat_message\n }\n end",
"def send_message(data)\n @chatroom = Chatroom.find(data[\"chatroom_id\"])\n message = @chatroom.messages.create(body: data[\"body\"], user: current_user)\n MessageRelayJob.perform_later(message)\n #Rails.logger.info data\n end",
"def create\n @message = RoomMessage.create(message: params[:room_message][:message],\n user_id: current_user.id,\n room_id: params[:room_id])\n redirect_to :browse\n end",
"def create\n @message = Message.create(message_params)\n ActionCable.server.broadcast(\"chatting_channel\", {\n data_type: \"message\",\n user_id: @message.user_id, \n content: @message.content,\n created_at: (@message.created_at.strftime(\"%m/%d %H:%M\")),\n }) if @message.present?\n head :ok\n\n end",
"def create\n message = Message.new({content: params[:message], chatroom_id: params[:chatroomId].to_i, user_id: params[:userId].to_i})\n\n if message.save\n user = message.user\n message_reactions = message.message_reactions\n\n message_reactions.map {|reaction| {reaction: reaction, user: reaction.user}}\n updatedChatroom = Chatroom.find(params[:chatroomId]) \n ActionCable.server.broadcast(\n \"chatroom_#{params[:chatroomId]}\",\n {\n newMessage: {message: message, user: user},\n messageReactions: message_reactions,\n user: user,\n updatedChatroom: updatedChatroom\n }\n )\n end\n end",
"def create_message\n @message = Message.new(params[:message])\n @message.sended_at = Time.now.to_f\n respond_to do |format|\n if @message.save\n format.html { redirect_to(\"/chat/update/#{@message.user.id}\") }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new(message_params)\n\n if @message.save\n ActionCable.server.broadcast 'room_channel', content: @message.content, user_name: @message.user.name\n # head :ok\n end\n end",
"def create\n @message = current_user.send_message params[:message]\n if @message.new_record?\n render :action => \"new\"\n else\n flash[:notice] = \"The message was saved successfully.\"\n redirect_to messages_path\n end\n end",
"def create\n # if params[:user_id].to_i == current_user[:id]\n # return\n # end\n @message = Message.new(message_params)\n @message.user = current_user\n @message.room_id = params[:room_id]\n @messages = Message.all\n ActionCable.server.broadcast \"room_channel_#{@message.room_id}\", message: @message\n\n if @message.save\n render json: @message\n else\n render plain: \"Failed to create a message\", status: :unprocessable_entity\n end\n end",
"def create\n chatroommessage = ChatroomMessage.new(permitted_params)\n chatroom = Chatroom.find(permitted_params[:chatroom_id])\n if chatroommessage.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n ChatroomMessageSerializer.new(chatroommessage)\n ).serializable_hash\n ChatroomMessagesChannel.broadcast_to chatroom, serialized_data\n head :ok\n end\n end",
"def create\n @message = Message.new(message_params)\n @message.room = Room.find(params[:room_id])\n @message.user = @current_user\n respond_to do |format|\n if @message.save\n format.html { redirect_to room_message_path(@message.room, @message), notice: 'Message was successfully created.' }\n format.json { render :show, status: :created }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def say(msg)\n self.signed_request '/api/v1/chat.postMessage', 'POST', {roomId: @channel_id, text: '>' + msg}\n end",
"def new_message\n end",
"def message(user, text)\n post('/direct_messages/new.json', :user => user, :text => text)\n end",
"def message(user, text)\n post('/direct_messages/new.json', :user => user, :text => text)\n end",
"def send_message(payload)\n message = Message.new(author: current_user, text: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat\", message: render(message) if message.save\n end",
"def create\n render(status: :forbidden, text: 'Invalid message') and return if params[:message].blank? or params[:message][:content].blank?\n @channel = Channel.find(params[:channel_id])\n @message = @channel.messages.create(params.require(:message).permit(:content))\n @message.user_name = session[:user_name]\n\n if @message.save\n Pusher['presence-channel-' + params[:channel_id]].trigger('message_added', {message: {user_name: h(@message.user_name), content: view_context.auto_link(@message.content)}, time: @message.created_at.localtime.strftime('%H:%M')})\n render status: :created, body: nil\n else\n render status: :forbiden, text: 'The message can\\'t save'\n end\n end",
"def create\n @message = Message.new(message_params)\n @message.user = current_user\n if @message.save\n #ActionCable.server.broadcast \"messages_#{params[:authid]}\", message: @message.content, user: current_user.name\n head :ok\n else\n render :edit\n end\n end",
"def create\n message_params = params[:message]\n message_params[:text] = params[:text]\n message = Message.new(\n author_id: current_user.id,\n chat: Chat.find(message_params[:chat_id]),\n parse_mode: message_params[:parse_mode],\n text: (message_params[:text].join \"\\r\\n\\r\\n\")\n )\n message.image = message_params[:image] if message_params[:image].present?\n puts JSON.pretty_generate message.as_json\n message.save!\n redirect_to admin_message_path(message), notice: 'A message has been created'\n # Message.create!(\n # author_id: current_user.id,\n # chat: Chat.find(message_params[:chat_id]),\n # image: message_params[:image],\n # parse_mode: message_params[:parse_mode],\n # text: (message_params[:text].join \"\\r\\n\\r\\n\")\n # )\n end",
"def send_message message\n payload = { \"text\" => message }.to_json\n data = client.post \"#{api_prefix}/rooms/#{id}/chatMessages\", payload\n\n Message.new client, id, data\n end",
"def create\n user = User.find_by(token: params[:token])\n new_message_params = {\n text: message_params[:text],\n conversation_id: message_params[:conversation_id],\n user_id: user.id,\n username: user.username\n }\n @message = Message.new(new_message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n\n if @message.save\n # render json: @message, status: :created, location: @message\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(@message)\n ).serializable_hash\n MessagesChannel.broadcast_to conversation, serialized_data\n head :ok\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end",
"def add_message\n\t\tresponse.headers['Content-Type'] = 'text/javascript' # Tells Rails/Redis that content is JavaScript\n\t\troom = current_user.room\n\t\tmessage = params[:message]\n\t\t# -- Add new message to chatroom ---\n\t\t$redis.publish(\"add_message_#{room.id}\", {message: message, author: current_user.username}.to_json)\n\t\t# --- end ---\n\t\trender nothing: true\n\tend",
"def create\r\n @message = Message.new(message_params).tap do |m|\r\n m.user = current_user\r\n m.channel = @channel\r\n end\r\n\r\n if @message.save\r\n push_notification :add\r\n @message.mark_as_read! for: current_user\r\n end\r\n\r\n render inline: \"{}\"\r\n end",
"def send_message(payload)\n message = Message.new(user: current_user, chat_id: payload[\"id\"], body: payload[\"message\"])\n\n ActionCable.server.broadcast \"chat_#{payload['id']}\", message: render(message) if message.save\n end",
"def create\n message = Message.new(message_params)\n message.user = current_user\n if message.save\n # 'messages' is name of channel we are broadcasting to\n ActionCable.server.broadcast 'messages',\n # Set message and user\n message: message.content,\n user: message.user.first_name\n head :ok\n end\n end",
"def create\n message = msg_params\n @msg = Msg.new(msg_params)\n thesender = @msg.sender\n thesentdate = @msg.sent\n theservertime = DateTime.now\n unless @msg.content.empty? || @msg.sender.empty?\n ActionCable.server.broadcast 'room_channel',\n content: @msg.content,\n sender: thesender,\n servertime: theservertime\n end\n end",
"def create\n if(params[:message]) then\n @user = User.find(session[:user][:id])\n @user.add_post(params[:message])\n redirect_to posts_path, :method => :get\n end\n end",
"def create\n @message = Message.new(message_params)\n @message.sender_id = current_user.id\n @message.recipient_id = params[:recipient_id]\n\n respond_to do |format|\n if @message.save\n flash[:notice] = \"Mesaj gönderildi.\"\n format.json { render json: {success: true} } \n # Pusher.trigger('private-'+params[:recipient_id],'new_message', {:from => current_user.name, \n # :subject => @message.subject})\n else\n flash[:error] = \"Mesaj gönderilemedi.\"\n redirect_to '/'\n end\n end\n end",
"def create\n message = Message.new(message_params)\n conversation = Conversation.find(message_params[:conversation_id])\n message.username = message.user.username\n if message.save\n serialized_data = ActiveModelSerializers::Adapter::Json.new(\n MessageSerializer.new(message)).serializable_hash\n MessagesChannel.broadcast_to(conversation, serialized_data)\n # ActionCable.server.broadcast 'conversations_channel', serialized_data\n head :ok\n # binding.pry\n end\n end",
"def receive(payload)\n ChatMessage.create(user: current_user, chat_room_id: payload[\"chat_room_id\"], body: payload[\"chat_message\"])\n end",
"def send_message(msg)\n\t\t\tdb_update({}, {'$push' => { 'messages' => msg.id.to_db } })\n\t\t\tmessages.add(msg)\n\t\tend",
"def send_new_chat(data)\n stream_from \"Chat:#{data['chat']['id']}\"\n recipient = User.find(data['chat']['recipient_id'])\n unless current_user.id == recipient.id\n ActionCable.server.broadcast \"user_#{recipient.id}_chats\", chat: data['chat'], type: 'new_chat'\n end\n end",
"def rx_message(data)\n\t\t# Get the current user from connection.rb and then create the Message\n\t\tcurrent_user.messages.create(content: data['message'], to_id: nil) # Nil means the global chatroom\n\tend",
"def on_newmessage(time, userid, username, msg)\n end",
"def create\n @chat = Chat.new(chat_params)\n @chat.user = current_user\n if @chat.save\n Pusher['global_chat_channel'].trigger('global_chat_event', {\n id: @chat.id,\n message: @chat.message,\n user: @chat.user.email,\n color: 'red',#@chat.user.color,\n created_at: @chat.user.created_at.strftime(\"%I:%M%p\")\n })\n end\n\n render nothing: true\n end",
"def new_message(message)\n if message == \"PING\"\n send(\"PONG\")\n else\n @messages << Message.new(message)\n redraw\n end\n end",
"def send_message\n message = render_to_string(:partial => 'messages/message', :object => @message)\n Juggernaut.send_to_channel(javascript_chat_message(message), @message.channel_id)\n end",
"def send_message \r\n @message = Message.new((params[:message] || {}).merge(:sender => current_user))\r\n \r\n if request.post? and @message.save\r\n flash.now[:notice] = \"Message sent\"\r\n @message = Message.new\r\n redirect_to :action => \"outbox\"\r\n end\r\n end",
"def create\n @room_message = RoomMessage.create user: current_user,\n room: @room,\n watsonmsg: false,\n message: params.dig(:room_message, :message),\n params: @room.params\n\n RoomChannel.broadcast_to @room, @room_message\n \n #check if user is currently reviewing a movie or taking quiz. If they are, send message to sentiment analysis and update rating\n if @room.lastIntent == \"already_seen\" then\n \tputs \"\\n\\n\\n The message you just sent was a review: \" + @room_message.message.to_s + \"\\n\\n\\n\" #debugging\n \t#send @room_message to sentiment analysis\n \t#set rating for movie\n \trate_movie\n\t \n\t #clear lastIntent\n\t @room.lastIntent = \"\"\n\t @room.save\n #check if user is answering quiz question\n\t elsif @room.lastIntent == \"start_quiz\" then\n\t take_quiz\n\t \n\t #clear lastIntent\n\t @room.lastIntent = \"\"\n\t @room.save\n\t #otherwise, get response from watson \n else\n\t \tget_response\n\t end\n end",
"def create\n @room = Room.find_or_create_by(room_params)\n @message = @room.messages.new(message_params)\n\n if @message.save\n render json: @message, status: :created, location: [@room, @message]\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end",
"def posted(msg, chat)\n @pgsql.exec('UPDATE telechat SET recent = $1 WHERE id = $2', [msg, chat])\n end",
"def create\n puts params['msg']\n receiver = User.find_by(username: params['receiver']).id\n\n @message = Message.new(seen: 0, sender: current_user.id, receiver: receiver, contents: params[:msg], sent_at: Time.now)\n @message.save!\n\n #Load the messages\n m = current_user.chat_with(params['receiver'])\n respond_to do |format|\n format.js { render json: m.to_json }\n format.html\n end\n\n # @message = Message.new(message_params)\n\n # respond_to do |format|\n # if @message.save\n # format.html { redirect_to @message, notice: 'Message was successfully created.' }\n # format.json { render :show, status: :created, location: @message }\n # else\n # format.html { render :new }\n # format.json { render json: @message.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n\t\tparams[:message_post][:message_thread_id] = params[\"message_thread_id\"]\n @message_post = MessagePost.new(params[:message_post])\n\t\t@message_post.author_id = current_user.id\n\t\t\n\t\t@message_thread = @message_post.message_thread\n\t\t\n\t\tRails.logger.info(\"Message Thread Length: #{@message_thread.message_posts.length}\")\n\t\tRails.logger.info(\"Messages: #{@message_thread.message_posts}\")\n\t\tRails.logger.info(\"Last Message: #{params['last_message_post']}\")\n\t\trange = Range.new(Integer(params[\"last_message_post\"])+1, -1)\n\t\t@new_message_posts = @message_thread.message_posts[range]\n\n respond_to do |format|\n if @message_post.save\n\t\t\t\t@new_message_posts.push(@message_post)\n format.html { redirect_to @message_post.message_thread, notice: 'Message post was successfully created.' }\n\t\t\t\tformat.js {}\n format.json { render json: @message_post, status: :created, location: @message_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @message = current_user.messages.build(params[:message])\n\n \n if @message.save\n \n flash[:notice] = \"Message Sent\"\n else \n flash[:notice] = \"Opps.\"\n end\n \n end",
"def record_message(room_hash, is_admin, msg, admin_name, speaker)\n create_chatroom(room_hash, admin_name, 'client_name')\n \n begin\n the_time = Time.now-Time.zone_offset('CST')\n insert_new_msg = @db.prepare \"INSERT INTO chat_messages (room_hash, chat_user_id, msg, speaker, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)\"\n #binding.pry\n insert_new_msg.execute room_hash, is_admin, msg, speaker, the_time, the_time\n \n insert_new_msg.close\n ensure\n #@db.close\n end\n end",
"def create\n @to = User.find(params[:message][:to])\n current_user.send_message(@to, params[:message][:topic], params[:message][:body])\n redirect_to outbox_url\n end",
"def new_message(message)\n @message = message\n mail\n end",
"def update\n conversation = Conversation.find(params[:conversation_id])\n conversation.messages << Message.new(user_id: current_user.id, body: params[:body])\n conversation.save\n\n redirect_to conversation_path(conversation)\n end",
"def create\n @room_message = RoomMessage.new(params[:room_message])\n\n respond_to do |format|\n if @room_message.save\n format.html { redirect_to @room_message, notice: 'Room message was successfully created.' }\n format.json { render json: @room_message, status: :created, location: @room_message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @room_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_message(message)\n self.broadcast({\n type: \"chat_message\",\n message: message\n })\n end",
"def create\n @message = Message.new\n @message.create_one!(params[:message])\n #Juggernaut.publish(1, parse_chat_message(params[:message][:message], current_user))\n respond_to do |format|\n format.html { redirect_to :index }\n format.js\n end\n end",
"def message_to_blogger\n return if self.user.id == self.blogger.id\n message = self.messages.build(\n is_read: false,\n user_id: self.blogger.id,\n from_user_id: self.user.id,\n body: \"#{self.user.uid} 回复了你: #{self.content}\"\n )\n message.save\n end",
"def handle_new_chatroom_member\n @chatroom_member = ChatroomMember.new(chatroom_member_params)\n save_chatroom_member\n end",
"def add_message room_name, message\n unless @@room_data[room_name]['messages'].include? message\n messages = @@room_data[room_name]['messages']\n messages.push message\n @@room_data[room_name]['messages'] = messages[-500,500] if messages.length > 500\n end\n \n return if room_name != @room\n scroll_down = @log.scroll_top >= @log.scroll_max - 10\n @log.append do\n flow do\n para strong(message['user']['name'] || message ['user']['id']), ': ', message['message']\n end\n end\n \n while @log.contents.length > 500\n @log.contents.first.remove\n end\n \n @log.scroll_top = @log.scroll_max\n end",
"def update\n @message = Message.new(:body => params[:message])\n if Messenger.add_reply(current_user, params[:id], @message)\n return_message(200, :ok)\n else\n return_message(200, :ok, {:err => {:messages => [106]}})\n end\n end",
"def create\n @message = @conversation.messages.new(message_params)\n if @message.save\n redirect_to conversation_messages_path(@conversation)\n end\n end",
"def create\n\n @message = current_user.messages.new(message_params)\n\n if @message\n respond_to do |format|\n if @message.save\n # debugger\n format.html do\n redirect_to @message, notice: 'Message was successfully created.'\n end\n format.json { render :_message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @message_room = MessageRoom.new(message_room_params)\n\n respond_to do |format|\n if @message_room.save\n format.html { redirect_to @message_room, notice: 'Message room was successfully created.' }\n format.json { render :show, status: :created, location: @message_room }\n else\n format.html { render :new }\n format.json { render json: @message_room.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new params[:message]\n @message.save\n respond_with @message, location: after_send_path, notice: t('hyalin.messages.sent_success')\n end",
"def create\n @conversation = Conversation.find(params[:conversation_id])\n @message = @conversation.messages.create(:body => params[:message][:body], :user_id => session[:user_id], :user_name => session[:user_name])\n\n #logger.info 'PARAMS@@@@@@@@@@@'\n #logger.info params[:message_body]\n\n respond_to do |format|\n if @message.save\n\n desc = @conversation.topic + \": \\\"\" + @message.body + \"\\\"\"\n add_event( EVENT_NEW_MESSAGE, desc[0,150], EVENTSOURCE_USER, session[:user_id], session[:user_name], nil)\n\n #MessageMailer.welcome_email(current_user).deliver\n\n format.html { redirect_to(pad_conversations_path(@pad), :notice => 'Message was successfully created.') }\n format.xml { render :xml => @message, :status => :created, :location => @message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @message.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(message)\n puts message\n end",
"def add_bot_message(message)\n messages.notification.create(sender_id: User.bot_id, body: message)\n end",
"def create\n if session.has_key?(:chat_user_id)\n @user = User.find(session[:chat_user_id])\n @chat_message = ChatMessage.new(params[:chat_message])\n @chat_message.direction = true\n @chat_message.operator = current_operator\n @chat_message.user = @user\n active_session = Session.active_session(current_operator,@user)\n @chat_message.session = active_session unless active_session.nil?\n msg = Hash.new\n msg['message'] = params[:chat_message][:message]\n msg['datetime'] = DateTime.now.to_s\n case @user.devicetype\n when \"android\"\n @user.send_android_notification(msg,'1002') unless @user.devicetoken.nil?\n when \"iphone\", \"iPhone\" \n message = \"New Message\" + current_operator.name+params[:chat_message][:message].to_s\n @user.send_ios_push(message,msg) unless @user.devicetoken.nil?\n end\n \n if @chat_message.save\n respond_to do |format|\n format.js { render action: \"create\" } and return\n end\n end\n else\n @user = nil\n end\n render :js => \"alert('failed');\" \n end",
"def create\n @message = Message.new(message_param)\n @message_thread = MessageThread.find(@message.message_thread_id)\n\n @message.receiver = current_user.equal_user?(@message_thread.started_user) ? @message_thread.to_user : @message_thread.started_user\n @message.sender = current_user\n @message.is_sender_read = true\n @message.is_receiver_read = false\n\n if @message.save\n flash[:success] = \"Message has been sent!\"\n redirect_to @message_thread\n end\n end",
"def direct_messages_new(recipient, text)\n post_params = {:user => recipient, :text => text}\n post \"direct_messages/new\", post_params\n end",
"def create\n @message = Message.new(message_params)\n\n if @message.save\n @user = User.find(@message.user_id)\n @user.messages << @message\n render json: @message, status: :created\n else\n render json: @message.errors, status: :unprocessable_entity\n end\n end",
"def new_message(message)\n @message = message\n\n mail to: @message.user.email\n end",
"def post_message(params = {}, opts = {})\n retries = 1\n begin\n log.info { \"out_slack: post_message #{params.dup.tap {|p| p[:token] = '[FILTERED]' if p[:token] }}\" }\n post(post_message_endpoint, params)\n rescue ChannelNotFoundError => e\n if opts[:auto_channels_create]\n log.warn \"out_slack: channel \\\"#{params[:channel]}\\\" is not found. try to create the channel, and then retry to post the message.\"\n channels_create({name: params[:channel], token: params[:token]})\n retry if (retries -= 1) >= 0 # one time retry\n else\n raise e\n end\n end\n end",
"def new_message(user, message)\n @user = user\n @message = message\n @service = @message.service\n mail(to: @user.email, subject: 'New message sent through SocialPresence')\n end",
"def create\n msg = Message.new(message_params)\n msg.user_id = current_user.id\n msg.status = 'closed' if params[:close_tkt]\n respond_to do |format|\n if msg.save\n parent_msg = Message.where(id: msg.message_id).first if msg.message_id\n @message = parent_msg ? parent_msg : msg\n parent_msg ? MessageMailer.new_reply(parent_msg, msg).deliver : MessageMailer.new_message(msg).deliver\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n parent_msg = Message.where(id: msg.message_id).first if msg.message_id\n @message = parent_msg ? parent_msg : msg\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n message = Message.new(message_params)\n message.user = current_user\n if message.content.blank? && !message.file.url.nil?\n message.content = \"Attachment\"\n end\n respond_to do |format|\n if message.save\n message.chatroom.users.uniq.each do |user|\n notification = Notification.where(user: user, notification_type: \"New Message\", notification_object_id: message.chatroom.id).first\n if notification.nil?\n notification = Notification.create!(user: user, notification_type: \"New Message\", notification_object_id: message.chatroom.id, read: false)\n else\n notification.read = false\n notification.save\n end\n end\n format.html {chatroom_path(message.chatroom)}\n else\n format.html {chatroom_path(message.chatroom) }\n end\n end\n\n end",
"def send_message(jid,text)\n m = Jabber::Message.new(jid, text)\n m.set_type :chat\n @client.send m\n end",
"def reply_message(params)\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n call_api(:method => :post, :uri => @api_base.merge(\"room/#{room_id}/reply\"), :body_params => params)\n end",
"def write_message\n\t\t# sender will be the current user\n\t\t@user = current_user\n\t\t@message = Message.new\n\t\[email protected] = current_user\n\t\t@unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n\t\t# if reciever has been specified, automatically use his/her name in the \"To:\" box\n\t\tif params[:receiver]\n\t\t\[email protected] = User.find_by_login(params[:receiver])\n\t\tend\n end",
"def new\n @message = Message.new\n @title = \"Новое сообщение\"\n\n if params[:reply_to]\n @reply_to = current_user.received_messages.find(params[:reply_to])\n unless @reply_to.nil?\n @message.to = @reply_to.sender.username\n @message.subject = \"Re: #{@reply_to.subject}\"\n @message.body = \"bq. #{@reply_to.body}\\n\\n\"\n end\n end\n\n if params[:to]\n @message.to = params[:to]\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end",
"def newMessage\n @message = Message.new\n end",
"def create\n room_id = params[:chat][:room_id]\n @chat = current_user.chats.build({message: params[:chat][:message],\n room_id: params[:chat][:room_id],\n receiver_id: params[:chat][:receiver_id]})\n\n if @chat.isSendToRoom?\n if current_user.rooms.find(room_id)\n response = \"ok\"\n\n else\n response = 'You have not join the room' + room_id\n end\n elsif @chat.isSendToPerson?\n response = 'Send to ' + @chat.to_user_id\n else # Broadcast to all users\n response = \"ok\"\n end\n\n chat_attrs = @chat.attributes\n chat_attrs['current_user'] = current_user\n chat_attrs['response'] = response\n if params[:chat][:room_id] == nil\n channel = \"server_channel\"\n else\n channel = room_id\n end\n\n self.broadcast_message_to_channel(channel, CHAT_EVENT_NAME, chat_attrs)\n render json: chat_attrs.to_json\n end",
"def create\n @message = @app_thread.messages.new(message_params)\n @message.user_id = @user.id\n\n respond_to do |format|\n if @message.save\n format.js {}\n format.html { redirect_to user_project_app_thread_url(@user, @project, @app_thread), notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { redirect_to user_project_app_thread_url(@user, @project, @app_thread), notice: @message.errors.full_messages.inspect }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update text\n payload = { \"text\" => message }.to_json\n data = client.post \"#{api_prefix}/rooms/#{room_id}/chatMessages/#{id}\", payload\n\n new client, room_id, data\n end",
"def send_message\n chat = Chat.find(params[:chat])\n SendMessageToChat.call(@previa_group, chat, params[:message])\n\n respond_to do |format|\n format.html { redirect_to previa_group_chat_path(@previa_group, :chat => chat) }\n format.json { head :no_content }\n end\n end",
"def create\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to new_message_url, notice: t(\"messages.created\") }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new(message_params)\n\n if @message.save\n redirect_to messages_url, notice: \"Message was successfully created.\"\n else\n redirect_to messages_url, alert: \"Message was unsuccessfully created.\"\n end\n end",
"def set_message\n @message = RoomMessage.find(param[:id])\n end",
"def answer_message(from, to, subject, message, conv_id, mess_id)\r\n conv = self.conversations.fetch(conv_id.to_s)\r\n time = Time.new\r\n message = Message.create(from, to, subject, time, message, mess_id)\r\n conv.add_message(message)\r\n end",
"def new_post(post)\n @greeting = \"Hello! There has been a new post to your discussion on \" + post.discussion.topic + \" at rubydark.herokuapp.com. Please sign in to view the post.\"\n\n mail to: post.discussion.user.email\n end",
"def send_message(other_user, room_id, content)\n from_messages.create!(to_id: other_user.id, room_id: room_id, content: content)\n end",
"def create\n \tparams[:message][:group_id] = params[:group_id]\n @message = Message.new(params[:message])\n\n respond_to do |format|\n if @message.save\n \tcurrent_user.sent_messages << @message\n format.html { redirect_to @message, notice: 'Message was successfully created.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end",
"def create\n \n @message = Message.new(body: params[:message][:body], sender_id: current_user.id, receiver_id: params[:message][:receiver_id])\n \n #@message = current_user.messages.build(message_params)\n #@message.save\n #respond_with { @message }\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to message_user_path(@message.sender_id, @message.receiver_id), notice: 'Message was successfully created.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n begin\n @message = Message.new(message_params)\n @message.update(date: DateTime.now, user: @current_user) and\n return redirect_to admin_message_path(@message)\n rescue ActiveRecord::RecordNotFound\n @message ||= Message.new\n end\n render :new\n end",
"def new_message(message)\n @message = message\n mail(\n :from => message.email,\n :to => '[email protected]',\n :subject => 'New Message From ' + message.email\n )\n end",
"def create\n @conversation = Conversation.find(params[:conversation_id])\n if @conversation.messages.create(sender: current_user,\n content: params[:message][:content])\n redirect_to @conversation\n else\n flash[:error] = \"A problem occured\"\n redirect_to @conversation\n end\n #respond_to do |format|\n # format.js { render json: @message }\n # format.html { redirect_back_or_to :back }\n #end\n end",
"def create\n params[:message][:to] = User.find_by_fullname(params[:message][:to]).id\n @message = Message.new(params[:message])\n @message.from = current_user.id\n @message.seen = false\n if @message.save\n flash[:notice] = \"Message sent\"\n else\n flash[:notice] = \"Message not sent\"\n end\n redirect_to(:action => 'index')\n end",
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def create\n @message = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: \"Message sent to #{@message.receiver.full_name}.\" }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = current_user\n @message = Message.new(params[:message])\n @message.post_id = params[:message][:post_id]\n @message.sender = @user.email\n @sender = @user.email\n @post = Post.find(@message.post_id)\n respond_to do |format|\n if @message.save\n MessageMailer.send_message(@post, @sender, params[:message][:recipient],params[:message][:subject], params[:message][:content]).deliver\n format.html { redirect_to root_path, notice: 'Message was successfully sent.' }\n format.json { render json: @message, status: :created, location: @message }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7684662",
"0.7636147",
"0.74436873",
"0.73256916",
"0.73184514",
"0.72338104",
"0.72219676",
"0.7172414",
"0.71667814",
"0.7158852",
"0.71453726",
"0.71272147",
"0.7111531",
"0.71043724",
"0.70873123",
"0.7074597",
"0.70507073",
"0.70049435",
"0.6998143",
"0.6998143",
"0.69965315",
"0.6991163",
"0.69740725",
"0.69714886",
"0.69686913",
"0.6953388",
"0.69231486",
"0.69175524",
"0.68962944",
"0.68808466",
"0.68703586",
"0.6867721",
"0.68587345",
"0.6856432",
"0.68382007",
"0.6820915",
"0.6798732",
"0.67602926",
"0.67293966",
"0.67240787",
"0.6712767",
"0.6711657",
"0.6706021",
"0.6695816",
"0.66933334",
"0.66918945",
"0.66442007",
"0.6644114",
"0.66412944",
"0.6631833",
"0.6621664",
"0.6615215",
"0.661342",
"0.6611988",
"0.66061723",
"0.660483",
"0.6593937",
"0.658898",
"0.6580747",
"0.6566087",
"0.6550668",
"0.65409887",
"0.6538703",
"0.6529964",
"0.6521537",
"0.65145653",
"0.6502626",
"0.6502053",
"0.6502036",
"0.649841",
"0.6492167",
"0.6490898",
"0.64587176",
"0.64580786",
"0.6444726",
"0.6444279",
"0.643864",
"0.6437281",
"0.6422408",
"0.64164287",
"0.64154935",
"0.64072055",
"0.63954365",
"0.63915277",
"0.6390999",
"0.6389008",
"0.6386603",
"0.6383766",
"0.63824534",
"0.63822293",
"0.63662744",
"0.6356552",
"0.6351956",
"0.6351351",
"0.63510853",
"0.63485706",
"0.6338904",
"0.633565",
"0.6334199",
"0.63325816",
"0.6331298"
] | 0.0 | -1 |
Get the list of users currently chatting for this room | def users
reload!
@users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chat_room_users\n if params[:is_group_chat]\n User.where(id: params[:user_id]).to_a << current_user\n else\n [current_user, User.find(params[:user_id])]\n end\n end",
"def index\n @chat_rooms = current_user.chat_rooms\n end",
"def users\n\t\tusers = []\n\t\trooms.each do |room|\n\t\t\troom.users.each do |user|\n\t\t\t\tusers << user\n\t\t\tend\n\t\tend\n\t\tusers\n\tend",
"def current_user_chat_rooms\n is_group_chat = params[:is_group_chat].present? ? params[:is_group_chat] : FALSE_STR\n @chat_rooms = ChatRoom.joins(:chat_room_users).includes(\n chat_room_users: :user, messages: :user\n ).where(\n chat_rooms: { is_group_chat: is_group_chat },\n chat_room_users: { user_id: current_user.id }\n )\n end",
"def users\n if text?\n server.online_members(include_idle: true).select { |u| u.can_read_messages? self }\n elsif voice?\n server.voice_states.map { |id, voice_state| server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }.compact\n end\n end",
"def chat\n\t\t#TODO: this user\n\t\t@thisuser = session[:user_id]\n\n\t\t#TODO: get other users this user chats with\n\t\t@chat = Chat.where('user1 = ? OR user2 = ?', @thisuser, @thisuser)\n\n\t\t# @chat.each do |eachChat|\n\t\t@chatData = []\n\t\tfor eachChat in @chat\n\t\t\tuser1 = User.find(eachChat.user1)\n\t\t\tuser2 = User.find(eachChat.user2)\n\n\t\t\tchat_with = user1.username\n\t\t\tchat_user_id = user1.id\n\t\t\trole = user1.role == 1 ? \"trainer\" : \"user\"\n\t\t\tif eachChat.user1 == @thisuser\n\t\t\t\tchat_with = user2.username\n\t\t\t\tchat_user_id = user2.id\n\t\t\t\trole = user1.role == 1 ? \"trainer\" : \"user\"\n\t\t\tend\n\t\t\tthisChat = { \"chat_with\": chat_with, \"chat_user_id\": chat_user_id, \"role\": role }\n\t\t\t\n\t\t\t@chatData << thisChat\n\t\t\t\n\t\tend\n\tend",
"def index\n @chatroom_users = ChatroomUser.all\n end",
"def user_list\n @room = current_user.room\n @user_list = @room.users\n render partial: \"user_list\"\n end",
"def users\n channel = Channel.find(params[:id])\n users = ChannelJoined.where(channel_id: params[:id])\n return json_response({\n users: users.map{|j| j.user}\n })\n end",
"def users\n users = Backlogjp.base._command \"getUsers\", self.id\n users.map {|hash| User.new(hash)}\n end",
"def recipient_users\n User.active.where(id: recipient_user_ids).all\n end",
"def query_chatroom_users(chatroom_id, count, order = \"1\")\n request(\"chatroom/user/query\", chatroomId: chatroom_id, count: count, order: order)\n end",
"def find_new_conversations\n #get chat rooms users where last_viewed is nil\n user_rooms = ChatRoomsUser.where(\"user_id = ?\", current_user.id)\n new_rooms = Array.new\n user_rooms.each do |room|\n if room.last_viewed.nil?\n new_rooms << ChatRoom.find_by(id: room.chat_room_id)\n end\n end\n new_rooms\n end",
"def index\n @user_chats = Chatroom.where(friendship_id: friendship_chats)\n @messages = Message.where(chatroom_id: @user_chats)\n end",
"def users\n users = Set.new\n\n @channels.each do |channel|\n users.merge(channel.users)\n end\n\n users\n end",
"def index\n @chats = Chat.where(\"reciever_id = ? OR user_id = ?\", current_user.id, current_user.id).order('created_at DESC')\n end",
"def connected_users\n @response[\"connected_users\"] rescue []\n end",
"def list\n get('users')['users']\n end",
"def list_friend\n ActionCable.server.broadcast(\n \"conversations-#{connect_user.id}\",\n message: 'list_user',\n data: User.where.not(id: connect_user).select('id, email')\n )\n end",
"def users\n users = []\n if current_user.lead?\n users = object.users.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n elsif current_user.dev?\n vms_v = object.vms.select { |vm| vm.is_jenkins }\n users = vms_v.flat_map(&:user).uniq.select { |u| u.id != current_user.id }\n users = users.unshift(current_user)\n else\n users <<= current_user\n end\n users.map { |u| u.id }\n end",
"def list_current_users *args\r\n puts \"not implemented yet\"\r\n end",
"def all_users\n\t\tshared_users.map(&:id).join(\", \")\n\tend",
"def get_all_channels\n user_id = current_user.id\n user_channels=Chatbox.uniq.where(:user_id => user_id).pluck(:channel)\n return user_channels \n end",
"def index\n list = current_user.chats.pluck :id\n\n options = filter_params\n options[:id] = filter_params[:id] == 'all' ? list : [filter_params[:id]]\n @messages = ChatMessage.filter options\n @messages = @messages.group_by(&:chat_id)\n end",
"def messages\n user_ids = users.pluck(:id)\n rooms_user_ids = RoomsUser.where(room_id: self.id, user_id: user_ids).pluck(:id)\n RoomMessage.where(rooms_user_id: rooms_user_ids).order(created_at: :asc)\n end",
"def index\n @my_rooms = current_user.message_rooms.index_by(&:id)\n @all_message_rooms = MessageRoom.all\n end",
"def users(*room_names)\n users = Hpricot(get.body).search(\"div.room\").collect do |room|\n if room_names.empty? || room_names.include?((room/\"h2/a\").inner_html)\n room.search(\"//li.user\").collect { |user| user.inner_html }\n end\n end\n users.flatten.compact.uniq.sort\n end",
"def all_users\n Skype.find_users_of_type \"ALL_USERS\"\n end",
"def index\n @users = current_user.sent_messages.distinct.map(&:receiver)\n @users += current_user.received_messages.distinct.map(&:sender)\n @users = @users.uniq\n end",
"def users(channel)\n channel = normalized_channel_name(channel)\n @chan_mutex.synchronize { @channel_members[channel] && @channel_members[channel].keys }\n end",
"def all_members(**params)\n client.api.get_room_members(id, **params)[:chunk].map { |ch| client.get_user(ch[:state_key]) }\n end",
"def users\n User.where(network_id: context[:current_network]&.id)\n end",
"def recently_contacted_users\n Skype.find_users_of_type \"RECENTLY_CONTACTED_USERS\"\n end",
"def getOnline\n @userListAndInfo = {}\n innerHashUserdata = {}\n allUsers = Pusher.get('/channels/presence-chat/users')\n allUsers[:users].each do |userHash|\n # get the user object from the id and populate the hash\n onlineUser = User.find(userHash[\"id\"])\n # skip the loop if the onlineUser is not a classmate of the current user\n next if !current_user.getAllClassmates.include?(onlineUser)\n innerHashUserdata[\"email\"] = onlineUser.email \n innerHashUserdata[\"name\"] = onlineUser.first_name + \" \" + onlineUser.last_name\n innerHashUserdata[\"commonClass\"] = current_user.firstCommonClass(onlineUser.id)\n # getting all the messages between current user and the online user\n allMessages = Message.where(\"receiver_id = '#{onlineUser.id}' OR \n receiver_id = '#{current_user.id}' AND\n sender_id = '#{current_user.id}' OR\n sender_id = '#{onlineUser.id}'\"\n ).order(\"created_at asc\")\n innerHashUserdata[\"messageHistory\"] = allMessages\n @userListAndInfo[onlineUser.id] = innerHashUserdata\n innerHashUserdata = {}\n end\n \trender \"show\"\n end",
"def get_all_participants(params = {})\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}/participant\"), :query_params => params)\n return unless res.successful?\n Users.new(res.data)\n end",
"def get_current_users\n unless @klass.repository.adapter.is_a?(::DataMapper::Adapters::MysqlAdapter)\n raise 'Unsupported DataMapper Adapter'\n end\n config = @klass.sorcery_config\n ret = @klass.all(config.last_logout_at_attribute_name => nil) |\n @klass.all(config.last_activity_at_attribute_name.gt => config.last_logout_at_attribute_name)\n ret = ret.all(config.last_activity_at_attribute_name.not => nil)\n ret = ret.all(config.last_activity_at_attribute_name.gt => config.activity_timeout.seconds.ago.utc)\n ret\n end",
"def getAllOnlineUsers\n return false if !@usrData\n @usrData[login]\n end",
"def get_chat_all_using_get(opts = {})\n data, _status_code, _headers = get_chat_all_using_get_with_http_info(opts)\n data\n end",
"def index\n @chats = current_user.chats\n end",
"def users\n user_arr = []\n subscriptions.each do |s|\n user_arr << User.find(s.user.id)\n end\n user_arr\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end",
"def chats\n @chats ||= Chat.find_all_by_match_id(params[:match_id], :include => :player)\n end",
"def getContacts\n messages = [] \n \n if !self.received_messages.nil?\n messagesRecv = (self.received_messages.order(:updated_at)).reverse \n\t messagesRecv.each do |recv|\n\t user = User.find(recv.sender_id)\n\t unless messages.include?(user)\n\t\t messages += [user]\n\t\t end\n\t end\n end\n if !self.send_messages.nil?\n messagesSend = (self.send_messages.order(:updated_at)).reverse \n\t messagesSend.each do |send|\n\t user = User.find(send.receiver_id)\n\t unless messages.include?(user)\n\t\t messages += [user]\n\t\t end\n\t end\n end\n\t return messages\n end",
"def all_users()\n User.all\n end",
"def users\n watches_unique_by_user.map(&:user)\n end",
"def index\n @chat_rooms = ChatRoom.all\n end",
"def chat\n return @chat\n end",
"def users\n @users\n end",
"def users\n return @users\n end",
"def users\n Webmail::User.in(group_ids: id)\n end",
"def index\n # @chat_messages = ChatMessage.all\n\n if params[:chat_room_id].present?\n @chat_room = ChatRoom.find(params[:chat_room_id])\n else\n if current_user.present?\n @user_chat_rooms = current_user.chat_rooms_as_sender + current_user.chat_rooms_as_reciever\n elsif current_super_admin.present?\n @user_chat_rooms = current_super_admin.chat_rooms_as_sender + current_super_admin.chat_rooms_as_reciever\n end \n @common_chat_rooms = @user_chat_rooms.select{ |cr| cr.senderable == @user || cr.recieverable == @user }\n if @common_chat_rooms.first.present?\n @chat_room = @common_chat_rooms.first\n else\n @chat_room = ChatRoom.create(senderable: current_user || current_super_admin, recieverable: @user )\n end\n end\n @chat_messages = @chat_room.chat_messages\n end",
"def index\n\t\t@chatrooms = Chatroom.all\n\tend",
"def get_users\n users = call(CMD_GET_USERS)[:users]\n users.map {|account| User.new(account) }\n end",
"def index\n #find the current user object\n @user = User.find(session[:user_id])\n #get the id of current user\n user_id = User.find(session[:user_id]).id\n #get all conversations of current user\n @started_conversations = @user.started_conversations\n @joined_conversations = @user.joined_conversations\n end",
"def list_users\n tp @users, :real_name, :slack_id, :user_name => {:display_method => :name}\n end",
"def index\n # Get the lists of various chat rooms\n @active_chat_rooms = ChatRoom.active.alpha.find(:all)\n @inactive_chat_rooms = ChatRoom.inactive.alpha.find(:all)\n\n # Get any pending notifications\n @notifications = Notification.for(whoami)\n\n # Deactivate all memberships (since we're looking at the list, not a chat room)\n Membership.deactivate_all_for(whoami)\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def index\n\t\tif !(defined? session[:chat_id]) || !session[:chat_id]\n\t\t\tif !(defined? session[:user_id]) || !session[:user_id]\n\t\t\t\t@chat = Chat.create\n\t\t\telse\n\t\t\t\tif Chat.exists?(user_id: session[:user_id])\n\t\t\t\t\t@chat = Chat.where('user_id' => session[:user_id]).first\n\t\t\t\telse\n\t\t\t\t\t@chat = Chat.create(user_id: session[:user_id])\n\t\t\t\tend\n\t\t\tend\n\t\t\tsession[:chat_id] = @chat.id\n\t\telse\n\t\t\tif defined? session[:user_id]\n\t\t\t\tif !Chat.exists?(user_id: session[:user_id])\n\t\t\t\t\tChat.where('id' => session[:chat_id]).update_all('user_id' => session[:user_id])\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t\n\t\t@messages = Message.joins(:chat).where('chat_id' => session[:chat_id])\t\n\tend",
"def index\n #@messages = Message.all\n #@messages = current_owner.messages\n @users = current_owner.conversation_users\n end",
"def index\n @room_users = RoomUser.all\n end",
"def curator_list\n users.map(&:email)\n end",
"def get_all_members(params = {})\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}/member\"), :query_params => params)\n return unless res.successful?\n Users.new(res.data)\n end",
"def all_friends\n return self.users\n end",
"def recent_users\n request('getRecentlyActiveUsers', {})['users'].map { |u| User.new(self, u) }\n end",
"def users\n GroupMembers.new(:id => id).get.items\n end",
"def returning_users\n []\n end",
"def index\n all_chat_rooms = ChatRoom.order(\"created_at DESC\")\n @private_chat_rooms, @public_chat_rooms = all_chat_rooms.partition{|chat_room| chat_room.private_room?}\n end",
"def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end\n end",
"def all_users\n return [] if @json_data['users'].nil?\n @json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }\n end",
"def get_chat_messages\n # get chat messages\n chats = Message.includes(:user).where(receiver_id: @current_user.id, user_id: params[:user_id], request_id: params[:request_id]).or(Message.includes(:user).where(user_id: @current_user.id, receiver_id: params[:user_id], request_id: params[:request_id])).order(created_at: :asc)\n if chats.any?\n render json: chats, :include => {\n :user => {\n :only => [:id, :firstname, :lastname]\n },\n },\n status: :ok\n else\n render json: {\n status: 'no-content',\n message: 'No chat on this request yet'\n },\n status: :no_content\n end\n end",
"def index\n @users = User.all\n @chats = Chat.all\n end",
"def recent_chats\n r = Skype.send_command \"SEARCH RECENTCHATS\"\n chat_ids = parse_type(r.sub(/^CHATS\\s+/, \"\"), Array)\n chat_ids.map do |id|\n Chat.new(id)\n end\n end",
"def online_users\n User.where([\"last_active_at > ?\", 5.minutes.ago])\n end",
"def recieved_requests_users\n recieved_requests.map(&:user)\n end",
"def index\n @conversations = current_user.conversations\n end",
"def users\n @users ||= begin\n users = client.team_members ENV[\"GITHUB_TEAM_ID\"], :per_page => 100\n while client.last_response.rels[:next] && client.rate_limit.remaining > 0\n users.concat client.get client.last_response.rels[:next].href\n end\n users.map { |u| User.new u[:login] }\n end\n end",
"def show_Users\n theUsers = User.select{ |user| user.group_id == self.id}\n theUsers\n end",
"def participants # :nodoc:\n @participant_ids.map { |p| @context.users[p] }\n end",
"def all_for(user)\n self.includes(:chat_participations).where(chat_participations: {user_id: user.id})\n end",
"def users_list\n\t\t\tpost= { \"token\" => @token }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('users/list', post)\n\t\t\tif docxml.nil?\n\t\t\t\treturn\n\t\t\tend\n\t\t\tusers=Array.new\n\t\t\tdocxml.root.elements['contents'].elements['users'].each_element('//user') { |user|\n\t\t\t\tentry=Hash.new\n\t\t\t\tentry['name']=user.elements['name'].text\n\t\t\t\tentry['admin']=user.elements['admin'].text\n\t\t\t\tentry['lastlogin']=user.elements['lastlogin'].text\n\t\t\t\tusers.push(entry)\n\t\t\t}\n\t\t\treturn users\n\t\tend",
"def messages\n read_only()\n @conn.uid_search(['ALL']).map do |uid|\n Message.new(@conn, uid)\n end\n end",
"def users\n gateway_check\n @users\n end",
"def participants\n users.where(parent_id: parent_id || current_user_id).flat_map(&:participants)\n end",
"def users\n []\n end",
"def current_organization_users\n endpoint = '/api/org/users'\n @logger.debug(\"Getting organization users (GET #{endpoint})\") if @debug\n get(endpoint)\n end",
"def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end",
"def all_users\r\n result = []\r\n\r\n self.descendants_and_self.each do |role|\r\n if role == self\r\n result << role.users \r\n else\r\n result << role.all_users\r\n end\r\n end\r\n self.all_groups.each { |group| result << group.all_users }\r\n result.flatten!\r\n result.uniq!\r\n return result\r\n end",
"def get_my_friends(token)\n @graph = Koala::Facebook::API.new(token)\n @friends = @graph.get_connections('me', 'friends')\n @ids = []\n @friends.each {|f| @ids << f['id']}\n @users = []\n User.all.each {|u| @users << u if @ids.include?(u.uid) }\n return @users\n end",
"def chat_with user, limit=20\n from_to_stamp = [\"#{self.id}-#{user.id}\",\"#{user.id}-#{self.id}\"]\n Message.where(:from_to_stamp.in => from_to_stamp).order_by([:created_at,:desc]).limit(limit)\n end",
"def users_messaged_by\r\n self.users_who_messaged_me\r\n end",
"def users_messaged_by\r\n self.users_who_messaged_me\r\n end",
"def index\n\n @users_with_conversation = []\n @messages = Message.where(receiver_id: params[:user_id]).reverse_order\n @new_messages = @messages.where(unread: true)\n @messages.each do |message|\n unless @users_with_conversation.include?(message.sender)\n @users_with_conversation.push(message.sender)\n end\n end\n @messages = Message.all\n end",
"def fetch_watchers\n watcher_users.to_a\n end",
"def friendable_users\n User.all.where.not('id IN (?)', [id] + friends.ids +\n friend_requests_sent.pending.pluck(:receiver_id) + friend_requests_received.pending.pluck(:sender_id))\n end",
"def chat_get_connected(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: ChatApi#chat_get_connected ...\"\n end\n \n # resource path\n path = \"/chat/connected\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\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', 'application/x-www-form-urlencoded']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConnectedUsers')\n if Configuration.debugging\n Configuration.logger.debug \"API called: ChatApi#chat_get_connected. Result: #{result.inspect}\"\n end\n return result\n end",
"def get_members()\n # TODO remove hardcap limit\n res = Array.new\n results = Note_User.all(:note_id => self.id, :order => [id.desc], :offset => 0, :limit => 10)\n results.each do |result|\n user = User.first(:id => result.user_id)\n res << user if user\n end\n return res\n end",
"def show\n @other_user = (@chat.user == current_user) ? @chat.reciever : @chat.user\n\n Chat.where(reciever_id: current_user.id, user_id: @other_user.id, status: 'unread').each do |chat|\n chat.update_attribute(:status, 'read')\n end\n\n @chats = Chat.where(\"(reciever_id = ? AND user_id = ?) OR (reciever_id = ? AND user_id = ?)\", @other_user.id, current_user.id, current_user.id, @other_user.id).order('created_at DESC').limit(50).reverse\n @new_chat = Chat.new\n end",
"def online_users\n User.online_on(self)\n end",
"def index\n @chatrooms = Chatroom.all\n end"
] | [
"0.78019845",
"0.7359228",
"0.7312027",
"0.7122309",
"0.70683384",
"0.7065807",
"0.6982438",
"0.6870897",
"0.6598247",
"0.6559906",
"0.6541818",
"0.6541668",
"0.65152454",
"0.65036994",
"0.650041",
"0.6471033",
"0.6458599",
"0.6435318",
"0.6400494",
"0.6376361",
"0.636624",
"0.63488615",
"0.6348048",
"0.63467777",
"0.63371485",
"0.6326021",
"0.6284378",
"0.6270716",
"0.62648016",
"0.6260658",
"0.62416047",
"0.6222341",
"0.62221384",
"0.61587703",
"0.6153398",
"0.614995",
"0.61479586",
"0.6134689",
"0.6120587",
"0.6114988",
"0.6114497",
"0.6114497",
"0.6110179",
"0.6096695",
"0.6096446",
"0.6090714",
"0.60864",
"0.60805035",
"0.6046089",
"0.60397774",
"0.6037902",
"0.60305244",
"0.602295",
"0.60201585",
"0.60190386",
"0.60177594",
"0.60172164",
"0.60139585",
"0.60139585",
"0.6010589",
"0.6009631",
"0.600479",
"0.59972155",
"0.59949726",
"0.598475",
"0.59699017",
"0.5958608",
"0.5957589",
"0.59569603",
"0.5937762",
"0.5932858",
"0.5931927",
"0.5923449",
"0.59218115",
"0.5904758",
"0.5896247",
"0.58895403",
"0.5886114",
"0.5881412",
"0.5880148",
"0.5877763",
"0.58757246",
"0.5865375",
"0.58604413",
"0.5858856",
"0.5854367",
"0.5848249",
"0.58392924",
"0.58343536",
"0.5833136",
"0.5833122",
"0.5830339",
"0.5830339",
"0.5829259",
"0.58272916",
"0.58243096",
"0.5817441",
"0.5811047",
"0.58105963",
"0.58029926",
"0.5798788"
] | 0.0 | -1 |
Get the dates for the available transcripts for this room | def available_transcripts
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_transcripts_from_all_rooms_between(start_date, end_date)\n puts \"Retrieving transcripts from all rooms in #{@uri.to_s} between #{start_date.strftime(\"%m/%d/%Y\")} and #{end_date.strftime(\"%m/%d/%Y\")}.\".yellow\n preset_room = @room\n @rooms.each do |room|\n @room = room\n retrieve_transcripts_between start_date, end_date\n end\n @room = preset_room\n end",
"def retrieve_all_transcripts\n puts \"Retrieving all transcripts from '#{@room[:name]}'. This could take some time.\".yellow\n retrieve_transcripts_since find_start_date(@room)\n end",
"def retrieve_transcripts_from_all_rooms_since(date)\n puts \"Retrieving transcripts from all rooms in #{@uri.to_s} since #{date.strftime(\"%m/%d/%Y\")}.\".yellow\n retrieve_transcripts_from_all_rooms_between date, Time.now\n end",
"def retrieve_transcripts_between(start_date, end_date)\n puts \"Retrieving transcripts from '#{@room[:name]}' between #{start_date.strftime(\"%m/%d/%Y\")} and #{end_date.strftime(\"%m/%d/%Y\")}.\".blue\n while start_date <= end_date\n retrieve_transcript(start_date)\n start_date = start_date + 24*60*60\n end\n end",
"def retrieve_transcripts_from_all_rooms(date = Time.now)\n preset_room = @room\n @rooms.each do |room|\n @room = room\n retrieve_transcript date\n end\n @room = preset_room\n end",
"def retrieve_transcripts_since(date)\n puts \"Retrieving transcripts from '#{@room[:name]}' since #{date.strftime(\"%m/%d/%Y\")}.\".blue\n retrieve_transcripts_between(date, Time.now)\n end",
"def enrollment_dates\n if start_date\n \"#{start_date_formatted} - #{end_date_formatted}\"\n end\n end",
"def dates_unavailable\n dates_booked = @room_reservations.map do |reservation|\n reservation.reservation_dates.all_dates\n end\n return dates_booked.flatten\n end",
"def dates\n dates_query.all\n end",
"def all_dates\n return (@start_date...@end_date).to_a\n end",
"def dates\n start_s = start_date ? start_date.to_s : '?'\n end_s = end_date ? end_date.to_s : '?'\n \"#{start_s} to #{end_s}\"\n end",
"def list_available_rooms(date)\n available_room_ids = []\n @rooms.each do |room| \n if room.dates_reserved == [] \n available_room_ids << room.id\n else \n room.dates_reserved.each do |reservation|\n if date < reservation[:start] && date <= reservation[:end]\n available_room_ids << room.id\n elsif date > reservation[:start] && date >= reservation[:end]\n available_room_ids << room.id\n end\n end\n end\n end\n \n return available_room_ids\n end",
"def available_dates\n @fx_hash[\"data\"].keys\n end",
"def dates\n @dates ||= @sequence.keys.sort\n end",
"def available_days\n unavailable = []\n unavailable = collection_of_unavailable_days.split unless collection_of_unavailable_days.blank?\n (self.meeting.calc_tentative_days - unavailable).join(' ')\n end",
"def attestation_subjects\n beg_sem = semester - 3\n end_sem = semester - 1\n return @attestation_subjects ||= plan_subjects.select do |ps|\n (beg_sem..end_sem).include? ps.finishing_on\n end\n end",
"def booked_dates\n dates = []\n bookings.each do |date|\n range = (date.checkin..date.checkout).to_a\n range.each do |interval|\n dates << interval.strftime(\"%Y-%m-%d\")\n end\n end\n return dates.uniq\n end",
"def unavailable_dates\n bookings.pluck(:start_dt, :end_dt).map do |range|\n { from: range[0], to: range[1] }\n end\n end",
"def dates\n end",
"def section_dates(section)\n schedules = recurring_schedules(section)\n schedules.size > 0 ? schedules.map {|schedule| schedule[:schedule]} : []\n end",
"def aoc_dates\n \"#{start_date.strftime('%d de %b')} al #{end_date.strftime('%d de %b')} de #{end_date.strftime('%Y')}\"\n end",
"def get_all_rent_by_date\n property = Property.find(params[:id])\n filter_date = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)\n lease_start_date = property.rent_commencement_date\n lease_end_date = property.rent_commencement_date + property.lease_duration_in_years.years\n \n if property.optional_extensions_status\n lease_end_date = lease_end_date + (property.number_of_option_period * property.length_of_option_period).years\n end\n\n if lease_start_date <= filter_date && filter_date <= lease_end_date\n rent_tables = property.rent_tables.where(\"version = ? AND start_year <= ? AND end_year >= ?\", property.rent_table_version, params[:year].to_i, params[:year].to_i)\n else\n rent_tables = []\n end\n daily_table_html = render_to_string :template => \"xhr/daily_rent\", :locals => {:rent_tables => rent_tables, :filter_date => filter_date}\n \n term_status = property.check_in_which_term filter_date\n term_wizard_html = render_to_string :template => \"xhr/lease_term_wizard\", :locals => {:property => property, :term_status => term_status}\n \n render json: { daily_rent: daily_table_html, term_wizard: term_wizard_html }\n end",
"def retrieve_all_transcripts_from_all_rooms\n puts \"Retrieving all transcripts from #{@uri.to_s}. This could take some time.\".yellow \n preset_room = @room\n @rooms.each do |room|\n @room = room\n retrieve_all_transcripts\n end\n @room = preset_room\n end",
"def date_range(pennkey = nil)\n output = Consultation::Interaction\n output = output.where(staff_pennkey: pennkey) unless pennkey.nil?\n\n [\n output.minimum(:event_date),\n output.maximum(:event_date)\n ]\n end",
"def get_reservation_list(date)\n if reservations.length != 0\n reservation_list = reservations.select { |reservation| compare_dates(reservation, date) }\n return reservation_list\n else\n return []\n end\n end",
"def calculated_dates\n [period1_from_date,period1_end_date,\n period2_from_date, period2_end_date] \n end",
"def dates(start_at, end_on)\n start_at.to_datetime.step(end_on).select { |d| d.cwday == @day }\n end",
"def getDates\n date_string = @xml.xpath('./dc:date/text()').first.to_s\n \n # Store the year as a string, along with the Ca., if it exists, so we can display it \n @doc[:date_display] = date_string[/^[Cc]a\\.+ *\\d+|^\\d+ |^\\w+ \\d+, \\d+ |^\\w+, \\d+/]\n \n if @doc[:date_display]\n \n stripped_year = @doc[:date_display][/\\d{4}/]\n # Store the year as an actual date, so we can do math on it \n @doc[:creation_date] = stripped_year.concat(\"-01-01T23:59:59Z\")\n # Store a range value\n creation_era = []\n if 100.years.ago > DateTime.parse(stripped_year)\n creation_era << \"More than 100 years old\"\n end\n if 50.years.ago > DateTime.parse(stripped_year)\n creation_era << \"More than 50 years old\"\n end\n if 20.years.ago > DateTime.parse(stripped_year)\n creation_era << \"More than 20 years old\"\n end\n if 10.years.ago > DateTime.parse(stripped_year)\n creation_era << \"More than 10 years old\"\n end\n if 10.years.ago <= DateTime.parse(stripped_year)\n creation_era << \"Less than 10 years old\"\n end\n if 5.years.ago <= DateTime.parse(stripped_year)\n creation_era << \"Less than 5 years old\"\n end\n if 1.year.ago <= DateTime.parse(stripped_year)\n creation_era << \"Less than 1 year old\"\n end\n @doc[:subject_era_facet] = creation_era\n end\n \n \n \n end",
"def list_reservations(date)\n res_on_date = @reservations.select do |reservation|\n date >= reservation.start_date && date < reservation.end_date\n end\n \n return res_on_date\n end",
"def index\n @disbursements = Disbursement.all\n @dates = (Date.parse(Setting.find_by(key: :start_date).value)..Date.parse(Setting.find_by(key: :end_date).value)).to_a\n puts @dates\n end",
"def dates\n object.send(date_property_for_english_language_indexing)\n end",
"def get_available_rooms(date_range)\n unavailable_rooms = []\n # Send the room to unavailable rooms if room has a reservation for a specific data_range. \n @reservations.each do |reservation|\n if reservation.daterange.overlap?(date_range) == true\n unavailable_rooms << reservation.room\n end\n end\n # Array substrating total_rooms minus unavailable rooms.\n return @rooms - unavailable_rooms\n end",
"def get_transcriptions()\n @client.make_request(:get, @client.concat_user_path(\"#{RECORDING_PATH}/#{id}/transcriptions\"))[0]\n end",
"def dates_requiring_data\n collected = Dir.glob(File.join(@config[:data_dir], \"*-*-*.{csv,espi}\")).map { |f| File.basename(f).split(\".\")[0] }\n all_days = []\n\n count_of_days = (Date.today - @config[:start_date]).to_i\n\n count_of_days.times do |i|\n all_days << (@config[:start_date] + i).strftime(\"%Y-%m-%d\")\n end\n\n (all_days - collected).map { |d| Date.parse(d) }\n end",
"def get_start_and_end_dates(n)\n description = Nokogiri::HTML(@description_xpath[n].text).text\n if description.include?(\"IF YOU GO\")\n description = description.split(\"IF YOU GO\")[1]\n if description.include?(\"When\" && \"Tickets\")\n description = description.split(\"When\")[1].split(\"Tickets\")[0]\n datetimes = description.gsub(\";\", \",\").split(\",\")\n @additional_datetimes = datetimes[1..-1].join(\",\") if datetimes.size > 1\n get_event_datetimes(datetimes[0])\n else\n [nil, nil]\n end\n else\n [nil, nil]\n end\n end",
"def unavailable_date_ranges_from_today\n self.reservations\n .where('end_date > ?', Date.today())\n .where(status: [1, 5])\n .map {|item| [item.start_date, item.end_date]}\n end",
"def dates\n entries = Entry.all\n $dates_array = Array.new\n entries.each do |entry|\n $dates_array << entry.created_at.strftime(\"%Y-%m-%d\")\n end\n $dates_array.uniq\n end",
"def list_of_days_worked_out\n array = []\n workouts = Workout.all.find_all do |workout| \n workout.user_id == self.id \n end\n dates = workouts.each do |workout|\n array << workout.date\n end\n array\n end",
"def dates\n @dates ||= text.select do |line|\n line =~ @date_pattern \n end.map do |line|\n line[@date_pattern]\n end.uniq.first\n end",
"def dates(start_date, end_date)\n @start = start_date.to_date\n @end = end_date.to_date\n @array_array_dates = []\n @range = (@start..@end)\n\n @dates = @range.map do |date|\n @day = date.day\n @month = date.mon - 1\n @year = date.year\n date = []\n date << @year\n date << @month\n date << @day\n @array_array_dates << date\n end\n return @array_array_dates\n end",
"def get_availabilities\n #retrieve all availability\n self.therapist_availability.collect{ |availability| availability_start_end_datetime(availability.get_occurrences, availability) }.flatten\n end",
"def key_dates\n events = Array.new\n events << birth_event if !birth_event.nil?\n events << death_event if !death_event.nil?\n events.concat(marriage_events) if (!marriage_events.nil? and marriage_events.count > 0)\n events\n end",
"def list_reservations_for_date(date)\n # Access array of rooms\n rooms.reject do |room|\n # Check if room is available for the date\n room.is_available?(date)\n end\n end",
"def getLeasesByDate(date)\n leases = getLeases()\n today_leases = []\n if leases.length !=0\n leases.each do |lease|\n if lease[\"status\"] == \"accepted\"\n #puts \"Gia na assssssssssssss\"\n #puts lease[\"valid_from\"].split('T')[0]\n #puts date\n #puts lease[\"valid_until\"].split('T')[0]\n if lease[\"valid_from\"].split(' ')[0] <= date && lease[\"valid_until\"].split(' ')[0]>=date\n #puts \"mpika\"\n today_leases << lease\n end\n end\n end\n end\n\n return today_leases\n end",
"def list_rooms_available_today\n\n return find_all_available_rooms([Date.today()])\n end",
"def list_reading_dates\n system \"clear\"\n user_choice = \"\"\n # while user_choice != \"❌ EXIT ❌\" && user_choice != \"🗑 DELETE READING 🗑\" do\n user_choice = prompt.select(\"🔮 #{self.user.name}, Select a date to view your past reading.\") do |menu|\n self.user.reading_dates.map do |date|\n menu.choice \"#{date}\", -> {self.handle_previous_reading_by_date(date)}\n end\n menu.choice \"⬅️ Back ⬅️\", -> {self.main_menu}\n end\n # end \n end",
"def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end",
"def dates\n return @dates ||=\n Mhc::PropertyValue::List.new(Mhc::PropertyValue::Range.new(Mhc::PropertyValue::Date.new))\n end",
"def transactions_in_date_range(start_date_text, end_date_text)\n\n the_display_list = []\n\n\n the_start_date, the_end_date = scrubbed_dates(start_date_text,\n end_date_text)\n\n #TODO replace all this with a join returning as_json\n\n\n\n Transaction.where(created_at: the_start_date.beginning_of_day..the_end_date.end_of_day).order(created_at: :desc).all.each do |transaction|\n\n the_display_list << {\n #FIXME we need a join here, not these lookups\n sku_num: ((transaction.sku_id.nil? || (not Sku.exists?(transaction.sku_id))) ? \"NA\" : Sku.find(transaction.sku_id).name),\n description: ((transaction.sku_id.nil? || (not Sku.exists?(transaction.sku_id))) ? \"NA\" : Sku.find(transaction.sku_id).description),\n from: ((transaction.from_id.nil? || (not Location.exists?(transaction.from_id))) ? \"TRANS.IN\" : Location.find(transaction.from_id).name),\n to: ((transaction.to_id.nil? || (not Location.exists?(transaction.to_id))) ? \"TRANS.OUT\" : Location.find(transaction.to_id).name),\n qty: transaction.qty,\n comment: transaction.comment,\n timestamp: transaction.created_at,\n who: ((transaction.user_id.nil? || (not User.exists?(transaction.user_id))) ? \"NA\" : User.find(transaction.user_id).name)}\n\n end\n\n return the_display_list\n\n end",
"def find_all_available_rooms(date_range)\n\n available_rooms = VALID_ROOM_IDS.dup\n\n if @reservations.empty?\n return @rooms\n end\n\n @reservations.each do |reservation|\n\n range_set_difference = date_range - ((reservation.checkin_date..reservation.checkout_date).to_a - [reservation.checkout_date])\n\n if range_set_difference != date_range\n available_rooms -= [reservation.room_number]\n end\n\n end\n\n if available_rooms.empty?\n raise StandardError.new(\"Hotel fully booked for this date range. Try a different date.\")\n end\n\n return available_rooms\n end",
"def lines\n @transcript_lines\n end",
"def get_availability\n unbooked_days = []\n availability_blocks = self.availabilities.includes(:bookings)\n availability_blocks.each do |availability_block|\n booked_days = []\n availability_block.bookings.each do |booking|\n booked_days += (booking.start_date..booking.end_date).to_a\n end\n (availability_block.start_date..availability_block.end_date).each do |day|\n unbooked_days.push(day) unless booked_days.include?(day)\n end\n end\n unbooked_days\n end",
"def get_years_to_date_collection\n (get_system_asset_starting_year..Date.today.year).to_a\n end",
"def booking_range\n ary = [I18n.localize(begin_date, format: DATE_AND_TIME)]\n if same_day?(begin_date, end_date)\n ary << I18n.localize(end_date, format: '%R') # example: 09:00\n else\n ary << I18n.localize(end_date, format: DATE_AND_TIME)\n end\n ary.join ' - '\n end",
"def entry_dates()\r\n return @entries_by_date.keys.sort.reverse()\r\n end",
"def room_list\n\t\t@room = Accommodation.find_all_by_host_id(@current_user.id)\n\t\t@date = RoomBooking.find_all_by_room_id(@room)\n \tend",
"def list_available_rooms(date_range)\n conflicting_reservations = reservations_by_date_range(date_range)\n\n available_rooms = @rooms.reject do |room|\n conflicting_reservations.find do |res|\n res.room_number == room[:room_number]\n end\n end\n return available_rooms\n end",
"def doctors\n # binding.pry\n self.appointments.collect {|appointment| appointment.date}\n end",
"def dates\n if @dates.nil?\n first_post = MailingList.connection.select_value(\"select min(date) from posts\")\n if first_post\n last_post = MailingList.connection.select_value(\"select max(date) from posts\")\n @dates = first_post..last_post\n end\n end\n @dates\n end",
"def unavailable_dates\n bookings.pluck(:check_in, :check_out).map do |range|\n { from: range[0], to: range[1] }\n end\n end",
"def find_start_date(room)\n list_page = @agent.get(\"#{@uri}/files+transcripts?room_id=#{room[:uri].to_s.split(\"/\").last}\")\n while list_page.links.detect { |link| link.text == \"Older\" }\n list_page.links.detect { |link| link.text == \"Older\" }.click\n list_page = @agent.page\n end\n links = list_page.links\n links.pop\n earliest = links.pop.uri.to_s.split(\"/\")\n day = earliest.pop\n month = earliest.pop\n year = earliest.pop\n Time.mktime(year.to_i, month.to_i, day.to_i)\n end",
"def available_events\n\t\treturn current_room.events || []\n\tend",
"def array_of_revisions\n \n start_date = Date.parse(@sprint_start_date)\n end_date = Date.parse(@sprint_end_date)\n\n completed_reviews_ids = []\n\n get_reviews.each do |item|\n creation_date = Date.parse(item[:creation_date]) rescue nil\n if (item[:phase] == \"Completed\") && (creation_date && (creation_date >= start_date && creation_date <= end_date)) \n completed_reviews_ids << item[:revision]\n end \n end\n completed_reviews_ids\n end",
"def due_date_task_list\n @due_date_task_list\n end",
"def readings\n\tstart_date, end_date = query_user_for_date_range\nend",
"def find_available_rooms(start_date, end_date) \n available_room_ids = []\n \n @rooms.each do |room| \n if room.dates_reserved == [] && room.blocks == []\n available_room_ids << room.id\n else \n num_available_rooms = 0 \n room.dates_reserved.each do |reservation|\n num_available_rooms += check_reservation_conflicts(start_date, end_date, reservation, num_available_rooms)\n end\n \n if room.blocks != []\n room.blocks.each do |block|\n num_available_rooms += check_reservation_conflicts(start_date, end_date, block, num_available_rooms)\n end\n end\n \n if num_available_rooms == (room.dates_reserved.length + room.blocks.length)\n available_room_ids << room.id\n end\n end\n end\n \n return available_room_ids unless available_room_ids == []\n \n raise ArgumentError, \"No rooms available at this time\"\n end",
"def list_rooms_available_for_date_range(start_date, end_date)\n # Select room if all reservations for the room return false for overlap with the given start date end date\n rooms_available = rooms.select do |room|\n room.reservations.all? { |reservation| date_range_overlap?(start_date, end_date, reservation.check_in, reservation.check_out) == FALSE }\n end\n # If there is no room available, raise an error\n if rooms_available.empty?\n raise NoRoomsAvailableError, \"No rooms are available for this date range\"\n else\n return rooms_available\n end\n end",
"def release_dates\n array = []\n table = release_info.at('#release_dates')\n table.css('tr').map do |row|\n cells = row.css('td')\n code = cells.first.at('a')['href'].clean_href.split('=').last.downcase rescue nil\n region = cells.first.at('a').text rescue nil\n date = cells.at('.release_date').text.strip.parse_date\n comment = cells.last.text.strip.clean_release_comment\n comment = nil if comment.empty?\n\n array << { :code => code, :region => region, :date => date, :comment => comment }\n end unless table.nil?\n\n array\n end",
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << element[\"massif\"]\n end\n ranges\nend",
"def getAllTexts intervalRange\n texts = [[]]\n curr_alts = []\n # Go through the interval token by token. It is indexed by token, \n # not by character\n intervalRange.each do |j|\n tok = @tokens.get(j)\n\n # If the text is parsed code or whitespace\n if (tok.channel == 0 || tok.channel == 1)\n texts.each do |text|\n text << tok.getText\n end\n\n # Get directives\n elsif (tok.channel == 2)\n d = strip_directive(tok)\n # TODO make sure combinations of alts are handled\n case d.command\n when\"ALT\"\n # Trigger creation of alternative magnet\n curr_alts << []\n texts.each do |text|\n curr_alt = Array.new(text)\n curr_alt << d.arg\n curr_alts.last << curr_alt\n end\n when \"ENDALT\"\n texts << curr_alts.pop\n end\n end\n end\n\n ret = texts.map {|t| t.join}\n # puts \"Ret\"\n # pp ret\n return ret\n end",
"def get_reservations_by_date(date)\n\t\t\tfound_reservations = []\n\n\t\t\[email protected] do |reservation|\n\t\t\t\tif reservation.range.include_single_date?(date)\n\t\t\t\t\tfound_reservations << reservation\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn found_reservations\n\t\tend",
"def entries\n settings.time_entries.present? ? settings.time_entries : []\n end",
"def reporte entrena, inicio, final\n entrenador = User.find(entrena)\n equipos = entrenador.equipos\n\n @events = []\n equipos.each do |equipo|\n\n equipo.eventos.each do |event|\n\n if (event.fecha >= inicio) && (event.fecha <= final)\n @events << event\n end\n\n end\n end\n return @events\n end",
"def list_days(start_on=start_date,end_on=end_date,show_empty=false,show_ids=false)\n (parse_date_param(start_on)..parse_date_param(end_on)).to_a.map { |_date|\n format_events_for(_date,show_empty,show_ids)\n }.compact\n end",
"def dates\n render json: @standings\n end",
"def index\n @reservations = Reservation.all\n @rooms = Room.all\n\n since_date = date_param || Date.today - 3\n until_date = since_date + 14\n @dates = ( since_date )..( until_date )\n\n @reservation_rooms = ReservationRoom.where( \"since <= ? OR until >= ?\", until_date, since_date )\n end",
"def get_calendar opt = {}\n calendar = RiCal.Calendar\n subjects = []\n events_list = []\n if opt[:space].nil?\n #Crea la lista de id's de materias que corresponden a la carrera en un año dado\n Materia.find(:all, :conditions => {:codigo_carrera => opt[:career], :anio => opt[:year]}).each do |m|\n subjects << m.codigo.to_i\n end\n #Lo de buscar no reccurrentes diferenciando de los recurrentes es algo que quedo de la vieja busqueda y deberia ser adaptado todo\n # al nuevo objetivo de esta busqueda. Deberia verse que no pertenece a ninguna materia.\n if opt[:all]\n events_list = Evento.find :all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f'\"\n events_list += Evento.find :all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1]}\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n else\n events_list = Evento.find :all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f'\" if opt[:year] == 0\n events_list += Evento.find :all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1]}\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n end\n else\n # Buscar eventos segun un espacio\n events_list = Evento.find(:all, :conditions => \"dtstart > '#{opt[:date]}' AND '#{opt[:date] + 1.day}' > dtstart AND reccurrent = 'f' AND espacio_id = #{opt[:space]}\")\n events_list += Evento.find(:all, :conditions => { :reccurrent => true, :byday => opt[:date].strftime(\"%a\").upcase[0..1], :espacio_id => opt[:space]})\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND rdate <> ''\"\n events_list += Evento.find :all, :conditions => \"reccurrent = 't' AND exdate <> ''\"\n\n end\n\n # Elimina duplicados\n events_list.uniq!\n\n # Carga al calendario\n events_list.each do |event|\n new_event = RiCal.Event\n new_event.description = event.description || ''\n new_event.dtstart = event.dtstart.strftime '%Y%m%dT%H%M00'\n new_event.dtend = event.dtend.strftime '%Y%m%dT%H%M00'\n new_event.location = event.espacio_id.to_s\n new_event.rrule = \"FREQ=\" + event.freq + \";BYDAY=\" + event.byday + \";INTERVAL=\" + event.interval.to_s + \";UNTIL=\" + event.renddate.strftime('%Y%m%dT%H%M00') if event.reccurrent\n new_event.exdates = event.exdate.to_a\n new_event.rdates = event.rdate.split(',').collect{|e| DateTime.parse e} || ''\n new_event.comment = event.id.to_s\n\n # Analisis de ocurrencia\n if event.reccurrent\n occurrence = new_event.occurrences :count => 1, :starting => opt[:date], :before => opt[:date] + 1\n if occurrence.count > 0\n if event.materia_id.nil? or opt[:all]\n # Agregar el evento sin materia\n calendar.add_subcomponent occurrence[0]\n else\n # Agregar el evento si coincide con alguna materia en subjects\n calendar.add_subcomponent occurrence[0] if subjects.include? event.materia_id #new_event\n end\n end\n else\n if event.materia_id.nil? or opt[:all]\n # Agregar el evento sin discriminarlo\n calendar.add_subcomponent new_event if Date.parse(event.dtstart.year.to_s + '/' + event.dtstart.month.to_s + '/' + event.dtstart.day.to_s) == opt[:date]\n else\n # Agregar el evento si coincide con alguna materia en subjets\n calendar.add_subcomponent new_event if Date.parse(event.dtstart.year.to_s + '/' + event.dtstart.month.to_s + '/' + event.dtstart.day.to_s) == opt[:date] and subjects.include? event.materia_id\n end\n end\n end\n return calendar\n end",
"def reservations_by_date(date_query)\n res_list = []\n @reservations.each do |res|\n if res.range.include?(date_query)\n res_list << res\n end\n end \n return res_list \n end",
"def active_expiration_dates\n active_adjustments.map do |adjustment|\n if adjustment&.expiration_year.present?\n Date.new.change(day: 1, month: adjustment.expiration_month || 1, year: adjustment.expiration_year)\n end\n end.compact.uniq.sort\n end",
"def booked_date_range\n { from: :start_date, to: :end_date }\n end",
"def find_reservations(date: Date.today)\n found_reservations = []\n\n if date.class != Date\n date = Date.parse(date)\n end\n\n reservations.each do |reservation|\n all_dates = DateRange.create_date_array(start_date: reservation.start_date, end_date: reservation.end_date)\n if all_dates.include? date\n found_reservations << reservation\n end\n end\n\n return found_reservations\n end",
"def event_start_end_dates\n esdate and eedate\n end",
"def find_day_reservations(date)\n day_reservations = all_reservations.select do |number, reservation|\n start_date = reservation.check_in\n end_date = reservation.check_out\n (start_date...end_date).include?(Date.parse(date)) && reservation.status == :CONFIRMED\n end\n \n return day_reservations\n end",
"def get_all_redemptions(start_date, end_date)\n redemption_counts = Redemption.where(created_at: start_date..end_date).count\n formatted_rc = Array.new\n formatted_rc.push end_date.to_f * 1000\n formatted_rc.push redemption_counts\n formatted_rc\n end",
"def committed_days\n @committed_days ||= begin\n days = []\n items.each do |item|\n self.class.committed?(item) && \n days << Time.zone.parse(item['created_at']).to_date\n end\n days.uniq!\n days\n end\n end",
"def appointments_on(date)\n appointments.starts_on(date).to_a\n end",
"def transactions_in_date_range(from_date, to_date, transaction_type = :all)\n validate_transaction_type transaction_type\n\n from_date = format_date from_date\n to_date = format_date to_date\n\n url = \"history/transactions/#{transaction_type.to_s.upcase}/#{from_date}/#{to_date}\"\n\n @dealing_platform.gather url, :transactions, AccountTransaction\n end",
"def getMissionIds\n now = Time.zone.now #time in UTC 00\n missionsArray = Mission.where \"start < ? AND ? < end\", now, now\n return missionsArray.map { |m| m.id.to_s}\n end",
"def available_day_ids\n available_days.map(&:id)\n end",
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << element[\"massif\"]\n end\n p ranges\n end",
"def entries_for tag: nil, date: nil, before_date: nil,\n from_date: nil\n\n entries.select do |en|\n ( tag and en['tags'].map{ |t| t.upcase }.include?( tag.upcase ) ) ||\n ( date and en['start'].to_date == date ) ||\n ( before_date and en['start'].to_date < before_date ) ||\n ( from_date and en['start'].to_date >= from_date )\n end\n end",
"def index\n @program_dates = ProgramDate.all\n end",
"def all_transfer_dates(from = nil, to)\n @user.transfers.map { |transfer| transfer.forecast(from, to) }.flatten.uniq\n end",
"def getDatesToDisplay()\n\n\t\tnumDays = 10\n\t\tretDays = []\n\n\t\tfor i in 0..10\n\t\t\ta_date = (DateTime.now + i.days)\n\t\t\tretDays.push(a_date)\n\t\tend\n\n\t\treturn retDays\n\tend",
"def reservations_by_date(date)\n date = Date.parse(date)\n res_by_date = @reservations.select do |res|\n res.date_range.included_in_date_range(date)\n end\n return res_by_date\n end",
"def create_calendar_dates(interval, ed_org_id)\n calendar_dates = []\n begin_date = interval.get_begin_date\n end_date = interval.get_end_date\n holidays = interval.get_holidays\n (begin_date..end_date).step(1) do |date|\n if DataUtility.rand_float_to_int(@prng, @scenarioYAML['HACK_PERCENTAGE_CALENDAR_DATES'] || 1) > 0\n if holidays.include?(date)\n calendar_dates << {\"date\" => date, \"event\" => :HOLIDAY, \"ed_org_id\" => ed_org_id}\n else\n calendar_dates << {\"date\" => date, \"event\" => :INSTRUCTIONAL_DAY, \"ed_org_id\" => ed_org_id} if date.wday != 0 and date.wday != 6\n end\n end\n end\n calendar_dates\n end",
"def current_lead_at\n []\n end",
"def get_rooms_by_date(date)\n\t\t\tunavail_rooms = get_reservations_by_date(date).map { |reservation| reservation.room }\n\t\t\treturn @rooms - unavail_rooms\n\t\tend",
"def date_history\n # byebug\n @date_history = MxAssessment.select(:meeting_date).distinct.joins(:patient)\n .where(patients: {facility: session[:facility]})\n .where(patients: {site: mx_assessment_params[:site]})\n .order(meeting_date: :desc)\n # byebug\n # Need to convert the ActiveRecord Relation to an array\n # Oracle doesn't present meeting_date as a formatted string\n # Need to format meeting_date (can't do that in the @meeting_date relation)\n # Can do it in an array\n @date_history.to_a.map! {|meeting| meeting.meeting_date.strftime('%F')}\n # @date_history.to_a.map! do |meeting|\n # unless meeting.meeting_date.blank?\n # meeting.meeting_date.strftime('%F')\n # # meeting.meeting_date.strftime('%m/%d/%Y')\n # end\n # end\n respond_to do |format|\n format.json {render json: @date_history}\n end\n end",
"def date_extraction(options={:text => nil})\n call_api('extract-dates', options)\n end"
] | [
"0.67828506",
"0.6743189",
"0.66180444",
"0.6598498",
"0.6519986",
"0.6219939",
"0.59861195",
"0.5943454",
"0.5906825",
"0.5753567",
"0.573729",
"0.5631875",
"0.56006277",
"0.55877954",
"0.55776006",
"0.5541773",
"0.5529693",
"0.55120283",
"0.54962283",
"0.5421641",
"0.5412622",
"0.5399431",
"0.5397206",
"0.5379967",
"0.5363419",
"0.53519773",
"0.53433126",
"0.5311876",
"0.5286972",
"0.52816266",
"0.52811325",
"0.52711767",
"0.5262361",
"0.5222805",
"0.5222689",
"0.5220364",
"0.52031356",
"0.51961863",
"0.5194396",
"0.519039",
"0.5189988",
"0.5172213",
"0.5166733",
"0.5149688",
"0.5142082",
"0.5135879",
"0.5131907",
"0.5129609",
"0.5120665",
"0.5118327",
"0.51081645",
"0.5083337",
"0.5076794",
"0.5076657",
"0.5076002",
"0.5072431",
"0.5065671",
"0.50646394",
"0.5037835",
"0.5031268",
"0.5021327",
"0.5021142",
"0.5017271",
"0.5010983",
"0.5007987",
"0.50069577",
"0.5000602",
"0.49912152",
"0.4987554",
"0.49739408",
"0.49658385",
"0.49476433",
"0.4945512",
"0.49324915",
"0.49259087",
"0.4923592",
"0.49228942",
"0.48865998",
"0.48771954",
"0.487673",
"0.48764732",
"0.4875063",
"0.48742312",
"0.48664272",
"0.48637736",
"0.48606595",
"0.48473012",
"0.4846983",
"0.4842816",
"0.4842118",
"0.4837474",
"0.48262432",
"0.48236004",
"0.48142135",
"0.48138887",
"0.48078865",
"0.48018673",
"0.48014173",
"0.47946078",
"0.47933856"
] | 0.51883656 | 41 |
Get the list of latest files for this room | def files(count = 5)
connection.get(room_url_for(:uploads))['uploads'].map { |u| u['full_url'] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recents\n files = session[:user].x_files.all(:last_update.gte => (DateTime.now - 20.days), folder: false, limit: 20)\n files_list = []\n files.each do |file|\n files_list.push(file.description(session[:user])) if file.folder || (!file.folder && file.uploaded)\n end\n @result = { files: files_list, success: true }\n end",
"def latest_file(glob)\n require 'find'\n return FileList[glob].map{|path| [path, File.mtime(path)]}.sort_by(&:last).map(&:first).last\n end",
"def all_files\n if !full && @last_full_backup\n backups = self.backups.select{|b| b.date >= @last_full_backup.date && b.date <= self.date }\n backups << self unless backups.include?(self)\n\n rfiles = backups.collect{|b| b.files}.flatten.uniq\n rfiles.reject! do |first_file|\n rfiles.detect{|second_file| second_file.path == first_file.path && second_file.backup_info.date > first_file.backup_info.date }\n end\n rfiles\n else\n self.files\n end\n end",
"def get_files_by_mtime dir='*'\n gfb dir, :mtime\nend",
"def recent_files\n # print -rl -- **/*(Dom[1,10])\n @title = 'Recent files'\n # zsh D DOT_GLOB, show dot files\n # zsh om order on modification time\n @files = `zsh -c 'print -rl -- **/*(Dom[1,15])'`.split(\"\\n\").reject { |f| f[0] == '.' }\nend",
"def last_modified_in dir\n Dir.glob( File.join( dir,'*' ) ).\n select {|f| File.file? f }.\n sort_by {|f| File.mtime f }.\n last\nend",
"def get_current_files\n get_files(OcflTools::Utils.version_string_to_int(@head))\n end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def get_updated_files(days)\n FileAsset.\n select(\"CONCAT( servers.httpurl, '/', files.filename ) AS 'link', files.filelang AS 'flang', files.filetype AS 'ftype', files.filesize AS 'fsize', files.updated AS 'updated', lessonfiles.lessonid AS 'lessonid'\").\n where(:'files.updated' => days.days.ago.to_s(:db)..0.days.ago.to_s(:db)).\n joins(:server, :lessons).\n order(:lessonid, :ftype).\n all.group_by { |x| x['lessonid'] }\n end",
"def getNewer\n files = []\n each_newer { |src,dst|\n files << [src, dst]\n }\n files\n end",
"def find_recent_files( directory, time_interval_expression )\n `find -H '#{directory}' -newermt \"#{time_interval_expression} ago\"`.split(\"\\n\")\n end",
"def files\n array = []\n @list.each do |k,v|\n array += v.filename\n end\n array\n end",
"def latest_modified_time\n tmp = Dir.glob(\"#{@dir}/**/*\").max_by do |file|\n File.mtime(file)\n end\n File.mtime(tmp)\n end",
"def get_list_of_files\n\t\t@list_of_files = Dir.entries(@wallpaper_dir) \n\tend",
"def files\n db = Database.find(params[:id])\n @files = Dir.entries(db.path)\n @files.delete_if{|f| !f.include?'.dat'}\n @results = []\n @files.each do |entry|\n @results << {:name=>entry,:version=>db.version}\n end\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def file_list\n @file_list\n end",
"def files\n return get_result('files')\n end",
"def files\n # fetch the appropriate files\n file_paths = Dir.glob(@path + \"/*.mp3\")\n file_paths.map { |file_path| @files << File.basename(file_path) }\n @files\n end",
"def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end",
"def gather_files files\n files = [\".\"] if files.empty?\n\n file_list = normalized_file_list files, true, @options.exclude\n\n file_list = remove_unparseable(file_list)\n\n if file_list.count {|name, mtime|\n file_list[name] = @last_modified[name] unless mtime\n mtime\n } > 0\n @last_modified.replace file_list\n file_list.keys.sort\n else\n []\n end\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def files\n array_full_names = Dir.glob(\"#{@path}/*.mp3\")\n array_full_names.collect do |full_name|\n full_name[21..-1]\n end\n end",
"def latest_specs\n collect_specs_via(:latest_specs)\n end",
"def get_latest_file(dir, pattern)\n # Get list of files using the pattern and max'es out\n # the file according to sort criteria.\n # Sort criteria is based on creation time\n Dir.glob(File.join(dir, pattern)).max do |f1, f2|\n File.ctime(f1) <=> File.ctime(f2)\n end\nend",
"def files\n @files ||= begin\n storage = model.storages.first\n return [] unless storage # model didn\"t store anything\n\n path = storage.send(:remote_path)\n unless path == File.expand_path(path)\n path.sub!(%r{(ssh|rsync)-daemon-module}, \"\")\n path = File.expand_path(File.join(\"tmp\", path))\n end\n Dir[File.join(path, \"#{model.trigger}.tar*\")].sort\n end\n end",
"def list\n BakFile.where('saved = ?', true).each do |file|\n Log.instance.info(\"#{file.fid},#{file.dkey},#{file.length},#{file.classname}\")\n break if SignalHandler.instance.should_quit\n end\n end",
"def files\n @files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n # This returns:\n # [\"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Thundercat - For Love I Come - dance.mp3\"]\n end",
"def find_files_newer_than_file( directory, filename )\n `find -H '#{directory}' -newer #{filename}`.split(\"\\n\")\n end",
"def files\n cached = FileAttachment.list_cache\n files = cached.select{|f|f.post_id == id}\n end",
"def latest_version_file\n sorted_files.first\n end",
"def last_log\n log_files.sort_by { |f| File.mtime(f) }.max\nend",
"def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end",
"def files\n @files ||= []\n end",
"def files\n entries.map(&:filepath)\n end",
"def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end",
"def files\n return @files\n end",
"def all\n @files\n end",
"def files\n page = get_page\n offset = PER_PAGE * page\n get_run_logs(:limit => PER_PAGE, :offset => offset)\n end",
"def find_recent_songs\n songs_with_date_modified_pair = self.lib.songs.reject do |song|\n (!song.metadata.has_key?('date_modified')) or (song.metadata['date_modified'] == nil)\n end\n\n songs_by_date_modified = songs_with_date_modified_pair.sort do |a, b| \n b.metadata['date_modified'] <=> a.metadata['date_modified']\n end\n\n songs_first = songs_by_date_modified.first(3)\n song_names = songs_first.collect {|song| song.metadata['name']} \n end",
"def latest_file_path(name)\n files = Dir[\"#{ ENV[\"HOME\"] }/workspace/*#{ name }*.txt\"]\n throw RuntimeError if files.empty?\n\n files.sort_by! do |file_name|\n file_match_data = FILE_NAME_FORMAT.match file_name\n date_match_data = file_match_data.to_s.match DATE_FORMAT\n DateTime.parse(date_match_data.to_s)\n end\n files.last\n end",
"def list\n @file_list.to_a\n end",
"def find_all_files\n self.files.order('tag')\n end",
"def list_all_files()\n\t\tfiles = Hash.new\n\t\trefresh_access_token()\n\t\trequest_url = \"https://www.googleapis.com/drive/v2/files?access_token=#{@access_token}\"\n\t\tresponse = RestClient.get request_url\n\t\tresponse_body = JSON.parse(response.body)\n\t\tresponse_body['items'].each do |item|\n\t\t\t\tfiles[item['id']] = item['title']\n\t\tend\n\t\treturn files\n\tend",
"def file_list(nginx_log_path)\n list=[]\n list.push(nginx_log_path)\n file_1hour_ago=\"#{nginx_log_path}.#{(Time.now-3600).strftime(\"%Y%m%d%H\").to_s}\"\n list.push(file_1hour_ago) if File.exist?(file_1hour_ago)\n list\n end",
"def get_remote_files\n manager = @current_source.file_manager\n manager.start do \n @current_source.folders.each do |folder|\n @files[folder] = manager.find_files folder\n @files[folder] = @files[folder].take(@take) if @take\n Logger.<<(__FILE__,\"INFO\",\"Found #{@files[folder].size} files for #{@current_source.base_dir}/#{folder} at #{@current_source.host.address}\")\n SignalHandler.check\n end\n end\n end",
"def files\n files = []\n Dir.new(self.path).each do |file|\n files << file if file.length > 4\n end\n files\n end",
"def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end",
"def each_newer()\n new = []\n @files.each { |f|\n src = @srcDir+'/'+f\n dst = @dstDir+'/'+f\n yield src, dst if newer?(src, dst)\n }\n end",
"def last_modified\n rails_root_mtime = Time.zone.at(::File.new(\"#{Rails.root}\").mtime)\n timestamps = [rails_root_mtime, self.updated_at]\n timestamps.sort.last\n end",
"def get_list(dir = nil)\n @ftp.ls(dir)[3..-1]\n end",
"def downloaded\n files_list = []\n files = session[:user].x_files.all(:downloads.gte => 1, uploaded: true)\n files.each { |file| files_list.push(file.description(session[:user])) }\n @result = { files: files_list, success: true }\n end",
"def last_mtime\n files.map do |file|\n ::File.stat(file).mtime\n end.max\n end",
"def latest(from_line_prefix = nil)\n latest_file = Tags.files(@tag).sort.delete_if(&:empty?).last\n\n cmd_string = \"tail -n 1000 '#{latest_file}'\"\n begin\n if latest_file && File.size(latest_file) == 0\n puts \"guess and go\"\n cmd_string = \"cd #{Tags.tag_folder(@tag)} && tail -n 1000 $(ls -tp | grep -v /$ | head -2) | grep ^[0-9]\"\n end\n rescue => ex\n puts \"Failed to get last tailable file #{ex.message}\"\n end\n\n results = execute_shell_command(cmd_string)\n results = trim_results(results, from_line_prefix)\n\n return { file: File.basename(latest_file), data: results }\n end",
"def fetch_files(program)\n program = init_fields(program)\n files = []\n\n SouvlakiRS.logger.info \" Trying to fetch: '#{program[:pub_title]}', use html? #{program[:use_html]}\"\n\n begin\n agent = init_agent\n files += if program[:use_html]\n from_html(agent, program)\n else\n rss, date, error = rss_shows_available(agent, program[:show_name_uri], program[:show_date])\n if rss.nil?\n program[:err_msg] = error if error\n return []\n end\n\n SouvlakiRS.logger.info \" date match (#{date})\"\n from_rss(agent, rss)\n end\n rescue StandardError => e\n SouvlakiRS.logger.error \" Fetch error: #{e}\"\n end\n\n # logout\n # logout(agent)\n # uri = \"#{@creds[:base_uri]}?op=logout&\"\n # agent.get(uri)\n\n files\n end",
"def index\n @admin_people_files = Admin::PeopleFile.desc(:created_at).page(params[:page]).per(25)\n end",
"def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\n end",
"def directory\n @recently_added_tools = Tool.ordered_by(\"recently_added\").limit(5)\n end",
"def getOutputFiles\n if (self.getCompleted)\n file_list = JSON.parse(@client[\"/StatsDownloadUrls?loadTestId=#{@test_id}\"].get)['outputFiles']\n if (file_list && file_list.length == @server_cnt)\n file_list\n end\n end\n end",
"def look_for_most_recent_log\n newest_time = nil\n newest_file = nil\n\n Dir.foreach(LOGS_DIR) do |dirEntry|\n dirEntry = LOGS_DIR + dirEntry\n if is_log_file dirEntry\n if (newest_time == nil || (File.mtime(dirEntry) <=> newest_time) > 0)\n newest_time = File.mtime(dirEntry)\n newest_file = dirEntry\n end\n end\n end\n\n newest_file\n end",
"def files\n get_back_here = Dir.pwd\n Dir.chdir(@path)\n @files = Dir.glob(\"*.mp3\")\n Dir.chdir(get_back_here)\n @files\n end",
"def files\n return @files if @files and not @files.empty?\n\n @files = []\n\n each_zip_entry do |entry|\n @files << entry.name\n end\n\n @files\n end",
"def files\n FileList.new(`#@native.files`)\n end",
"def get_file_load_list\n json_file_path = File.join(SDESK_ROOT_PATH, 'configs', 'file_list.json')\n json_data = load_json_file json_file_path\n return [] unless json_data\n\n flist_arr = []\n json_data.each_pair do |dir_name, file_h|\n file_h.each_pair do |fname, queue_id|\n flist_arr << [File.join(dir_name, fname+'.rb'), queue_id]\n end\n end\n flist_arr.sort_by!{|arr| arr.last}\n flist_arr.map(&:first)\n end",
"def all_files() = path.glob('**/*').select(&:file?).map(&:to_s)",
"def all_files\n @all_files ||= `git ls-files 2> /dev/null`.split(\"\\n\")\n end",
"def last_added(path)\n path += \"*\" unless path.index(\"*\")\n Dir[path].select {|f| test ?f, f}.sort_by {|f| File.mtime f}.pop\n end",
"def recent\n result = http_get(\"/services/data/v#{self.version}/recent\")\n collection_from(result.body)\n end",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def files\n list = []\n if @data['info'].key?('files')\n @data['info']['files'].each do |file|\n list << { 'name' => file['path'], 'length' => file['length'] }\n end\n return list\n end\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n list << { 'name' => @data['info']['name'], 'length' => @data['info']['length'] }\n end\n list\n end",
"def files\n filenames || []\n end",
"def list_file_changed\n content = \"Files changed since last deploy:\\n\"\n IO.popen('find * -newer _last_deploy.txt -type f') do |io| \n while (line = io.gets) do\n filename = line.chomp\n if user_visible(filename) then\n content << \"* \\\"#{filename}\\\":{{site.url}}/#{file_change_ext(filename, \".html\")}\\n\"\n end\n end\n end \n content\nend",
"def retrieve_files_in_main_dir\n ensure_file_open!\n @file.glob('*').map do |entry|\n next if entry.directory?\n\n entry_file_name = Pathname.new(entry.name)\n [entry_file_name, entry.get_input_stream(&:read)]\n end.compact.to_h\n end",
"def files_on_remote\n @bucket_contents = nil\n bucket_contents.map {|item| File.basename(item['Key']) }.sort\n end",
"def chunks\n Dir[\"#{model.file}-*\"].sort\n end",
"def available_files\n @available_files ||= @json_searchers.keys.sort.join(\"\\n \").brown\n end",
"def files\n Dir.open @path do |dir|\n @files = dir.entries.delete_if{|element|\n !element.include? \".mp3\"\n }\n end\n end",
"def all_files\n @files_hash.values\n end",
"def recent_specs(touched_since)\n recent_specs = FileList['app/**/*'].map do |path|\n\n if File.mtime(path) > touched_since\n spec = File.join('spec', File.dirname(path).split(\"/\")[1..-1].join('/'),\n \"#{File.basename(path, \".*\")}_spec.rb\")\n spec if File.exists?(spec)\n end\n end.compact\n\n recent_specs += FileList['spec/**/*_spec.rb'].select do |path| \n File.mtime(path) > touched_since \n end.uniq\nend",
"def get_files\n\tstart_dir = C_start_dir\n\tstart_dir += \"/\" if start_dir[-1..-1] != \"/\"\n\n\t# collect all file names recursively\n\tres = Dir.glob(\"#{start_dir}**/*\", File::FNM_DOTMATCH)\n\n\t# remove excluded dirs\n\tC_exclude_dir.each{|d| res = res.select{|x| not x[/^#{start_dir}#{d}\\//]} }\n\n\t# get db mod time for compare\n\tt = test_file(db_name) ? File.mtime(db_name).to_s[/[0-9]+\\-[0-9]+\\-[0-9]+\\ *[0-9]+\\:[0-9]+\\:[0-9]+/] : \"\"\n\n\t# remove files from os update\n\n\t# -------------------\n\t# --- dpkg plugin ---\n\t# -------------------\n\t# collect package names changed by os update from dpkg.log\n\td1 = Dir[\"/var/log/dpkg.log*.gz\"]\n\td2 = Dir[\"/var/log/dpkg.log*\"] - d1\n\tlog = \"\"\n\td1.each{|f| log += gunzip(f) }\n\td2.each{|f| log += File.read(f) }\n\t# find package name entries more recent than our db\n\tpkg = log.split(\"\\n\").sort.select{|x|x > t}.select{|x| x[/status *installed/]}.map{|x|x[/status *installed *[^\\:]+/].split[2]} - [\"man-db\"]\n\t# collect file names of all these package names\n\tlist = []\n\tpkg.sort.uniq.each {|x|\n\t\tDir.glob(\"/var/lib/dpkg/info/#{x}*.list\") {|y|\n\t\t\tlist << File.read(y).split(\"\\n\").select{|z| test_file(z)}\n\t\t}\n\t}\n\t# remove list to recursive dir list\n\tres -= list.sort.uniq\n\n\treturn [res, pkg]\nend",
"def sequential_files\n get_files_in_dir(@sequential_dir)\n end",
"def files\n Dir.glob(self.path + '**/*.mp3').collect {|file| File.basename(file)}\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end",
"def all_files\n return manifest_entry.files\n end",
"def attachment_list(model)\n s = '<div class=\"attachments\">'\n s << '<h2>Files</h2>'\n s << '<table>'\n model.attachments.each do |attachment|\n s << \"\n<tr>\n <td><a href=\\\"#{attr_h attachment.public_path}\\\">#{h attachment.name}</a></td>\n <td class=\\\"date\\\">#{File.mtime(attachment.local_path).strftime('%A, %d %B %Y, %H:%M')}</td>\n</tr>\"\n end\n s << \"</table>\\n</div>\"\n end",
"def get_latest_mtime\n return @sources.collect{ |s| File.mtime(\"#{@asset_path}/#{s}.#{@extension}\") }.max\n end",
"def files\n return unless session\n session.files.find_all_by_parent_folder_id(id)\n end",
"def files\n @files.values\n end",
"def list\n FileOperations.find_all(self)\n end",
"def retrieve_logs_for_download\n parse_files_for_download\n\n output = ''\n jsons.reverse_each do |elem|\n output.insert(0, insert_log_line_for_download(elem))\n end\n\n output\n end",
"def last_modified\n rails_root_mtime = Time.zone.at(::File.new(\"#{Rails.root}\").mtime)\n timestamps = [rails_root_mtime, self.updated_at] + self.page.elements.collect{|e| e.last_modified}\n timestamps.sort.last\n end",
"def files\n\t\t@array_of_mp3s = Dir[\"#{@path}/*.mp3\"]\n\t\t@array_of_mp3s.map do |mp3|\n\t\t\tmp3.slice!(\"#{@path}/\")\n\t\t\tmp3\n\t\tend\n\tend",
"def files\n info[\"Files\"].to_a\n end",
"def get_remote_files\n raise BucketNotFound.new(\"#{self.config.fog_provider} Bucket: #{self.config.fog_directory} not found.\") unless directory\n files = []\n directory.files.each { |f| files << f if File.extname(f.key).present? }\n return files\n end",
"def all\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n files(-1)\n end",
"def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{ |filename|filename.gsub(\"#{path}/\", \"\")}\n end",
"def files\n real_path = self.path[2...-1] + \"s/*\"#trim './' and add 's/*' \n \n Dir[real_path].map{|file| file.split(\"/\")[-1]} \n end"
] | [
"0.6851216",
"0.6728712",
"0.66088516",
"0.65985143",
"0.644003",
"0.6398718",
"0.63614875",
"0.63593876",
"0.63276464",
"0.6291387",
"0.6159493",
"0.61403316",
"0.60882336",
"0.60721946",
"0.60476243",
"0.60351056",
"0.60285884",
"0.6025172",
"0.5956404",
"0.5941372",
"0.59203845",
"0.59045964",
"0.5896449",
"0.58869565",
"0.58866704",
"0.5876092",
"0.5862909",
"0.58626896",
"0.5854611",
"0.5852867",
"0.5813353",
"0.58119714",
"0.58016926",
"0.5800775",
"0.5797193",
"0.5796545",
"0.5789099",
"0.57694095",
"0.5763768",
"0.5749135",
"0.57192665",
"0.5715331",
"0.57141584",
"0.5710858",
"0.5698312",
"0.56951666",
"0.5694142",
"0.5684277",
"0.5680122",
"0.5670252",
"0.5669167",
"0.5665257",
"0.56511956",
"0.56411034",
"0.5632183",
"0.5625949",
"0.5623575",
"0.56229854",
"0.5613724",
"0.5606307",
"0.56020844",
"0.5601418",
"0.5593784",
"0.5584018",
"0.55773646",
"0.55747676",
"0.55652934",
"0.5564913",
"0.55638516",
"0.5560304",
"0.5558746",
"0.5556377",
"0.555552",
"0.55507827",
"0.55449474",
"0.55435556",
"0.55428225",
"0.55402124",
"0.5539611",
"0.5530597",
"0.5530171",
"0.5528352",
"0.5518574",
"0.5518574",
"0.5518574",
"0.5518574",
"0.5516495",
"0.5509869",
"0.5509139",
"0.5492225",
"0.54907846",
"0.54806054",
"0.54739845",
"0.5460307",
"0.5456488",
"0.5450553",
"0.5448157",
"0.54324436",
"0.5431782",
"0.54302955"
] | 0.55531055 | 73 |
GET /tuberculoses GET /tuberculoses.json | def index
@tuberculoses = Tuberculose.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def retrieve_tubes\n show do\n title \"Retrieve tubes and spin down\"\n \n timer initial: { hours: 0, minutes: 15, seconds: 0}\n \n check \"After timer finishes, retrieve all #{operations.length} tubes from 42 C heat block.\"\n check \"Spin the tube down for 20 seconds on a small tabletop centrifuge.\"\n check \"Remove all the supernatant carefully with a 1000 µl pipettor (~400 L total)\"\n end\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end",
"def index\n @tenures = Tenure.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @tenures\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index\n @tuiters = Tuiter.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n @timers = Timer.all\n\n render json: @timers\n end",
"def index\n @toyota = Toyotum.all\n end",
"def index\n @terceros = Tercero.all\n end",
"def index *_\n @trades = owned_trades_view\n\n render json: @trades\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def index\n @uttrances = Uttrance.all\n end",
"def index\n @turkeys = Turkey.all\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n @tamires = Tamire.all\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def tattoos\n render :nothing => true and return if params[:id].nil?\n\n @tattoo = Tattoo.find(params[:id])\n render :json => @tattoo.to_json(:include => [:artist, :assets])\n #render :json => @tattoo.to_json(:include => { :assets => { :only => [:id, :data_file_name] } })\n return\n end",
"def index\n @tailors = Tailor.all\n respond_to do |format|\n format.html\n format.json { render json: @tailors}\n end\n end",
"def index\n @utentes = Utente.all\n end",
"def index\n @teathers = Teather.all\n end",
"def taken\n @travels = Travels::Travel.taken.where(performer: current_user)\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @tutor = Tutor.all\n\n render json: @tutor, status: :ok\n end",
"def index\n @turmas = Turma.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @turmas }\n end\n end",
"def index\n @takeouts = Takeout.all\n end",
"def index_user\n @tickets = Ticket.all_for_user(current_user.id)\n render json: @tickets, status: 200\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end",
"def index\n @takings = Taking.all\n end",
"def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end",
"def tbu_list\n @client.make_request :get, templates_path('tbu')\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @uzsers = Uzser.all\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def index\n @tarots = Tarot.all\n end",
"def index\n @trucks = Truck.all\n\n render json: @trucks\n end",
"def index\n @utentis = Utenti.all\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end",
"def index\n @ties = Tie.all\n end",
"def index\n @trabalhos = current_user.trabalhos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trabalhos }\n end\n end",
"def index\n @trades = Trade.all\n render json: @trades\n end",
"def index\n current_admin_user\n @tablets = Tablet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tablets }\n end\n end",
"def index\n @turista = Turistum.all\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def index\n @trayectoria = Trayectorium.all\n end",
"def index_all\n @tickets = Ticket.all_tickets\n render json: @tickets, status: 200\n end",
"def index\n @setors = Setor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @setors }\n end\n end",
"def index\n @kristine_toys = KristineToy.all\n end",
"def index\n @tyc_humen = Tyc::Human.all\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def index\n @tenancies = Tenancy.all\n end",
"def index\n @tacos = Taco.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render @tacos }\n end\n end",
"def index\n @uchronists = Uchronist.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronists }\n end\n end",
"def index\n @u_sers = USer.all\n end",
"def index\n @tomaturnos = Tomaturno.all\n end",
"def index\n @ticket_owners = TicketOwner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ticket_owners }\n end\n end",
"def index\n @tutoring_sessions = TutoringSession.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutoring_sessions }\n end\n end",
"def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def index\n @utensils = Utensil.all\n end",
"def grab_tubes\n show do\n title \"Grab #{operations.running.length} 1.5 mL tubes for diluted fragment aliquots\"\n\n check \"Grab #{operations.running.length} 1.5 mL tubes, label with following ids: #{operations.map {|op| \"#{op.output(DILUTED_STOCK).item.id}\"}.join(\", \")}\"\n check \"Add water according to table.\"\n table operations.running.start_table\n .output_item(DILUTED_STOCK)\n .custom_column(heading: \"H20 (uL)\", checkable: true) {|op| op.temporary[:dilution_water_vol]}\n .end_table\n end\n end",
"def index\n @tecidos = Tecido.all\n end",
"def index\n @trades = Trade\n .only(:created_at, :is_fair, :ash_pokemons, :brock_pokemons)\n respond_to do |format|\n format.json { render json: @trades }\n end\n end",
"def index\n @turmas = current_colegio.turmas\n end",
"def index\n @tiendas_juegos = TiendasJuego.all\n end",
"def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end",
"def index\n @otg_sesses = OtgSess.all\n end",
"def index\n @talleres = Taller.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talleres }\n end\n end",
"def index\n\n @debtors = Debtor.all\n\n render json: @debtors\n end",
"def load_tailors\n\t\t@shop_name=params[:shop_name]\n\t\t@title=params[:title]\n\t\tuser = User.where(:user_type => \"tailor\", :shop_name => @shop_name, :title => @title).select(\"id\",\"username\",\"email\")\n\t\tif user.nil?\n\t\t\trender json: {message: \"No any tailor in this group\"}\n\t\telse\t\t\t\n\t\t \tdetails = []\n\t\t\tuser.each do |chat|\n\t\t\t\tdetails << { :id => chat.id, :type => chat.username, :email => chat.email}\n\t\t\tend\n\t\t\trender :json => details.to_json\t\n\t\tend\n\tend",
"def index\n @topups = Topup.all\n end",
"def index\n @sectors = Sector.all.order(\"created_at DESC\")\n render json: @sectors\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @tombstone_timeholds = TombstoneTimehold.all\n end",
"def index\n @terrains = Terrain.all\n end",
"def index\n @observaciontutors = Observaciontutor.all\n end",
"def index\n @tubuyakis = Tubuyaki.all\n @tubuyaki = Tubuyaki.new\n end",
"def index\n @shots = Shot.all\n\n render json: @shots\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 @twets = Twet.all\n end",
"def trips\n @trip_requests = current_user.trip_requests.trips.paginate(page:params[:page], per_page:20)\n json_response(@trip_requests)\n end",
"def list\r\n #page = params[:page].nil? ? 0 : params[:page]\r\n tweets = Tweet.all\r\n render json: tweets\r\n end",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def getThreeTweets\n\t\trender json: TwitterAPI.get_top_3_tweets(params[:twitter_id])\n\tend",
"def index\n @m_titulares = MTitular.limit(10)\n end",
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def index\n @tweets = @user.tweets.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def index\n @chest_triceps1s = ChestTriceps1.all\n end",
"def trades\n Client.current.get(\"#{resource_url}/trades\")\n end",
"def index\n @ts = T.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ts }\n end\n end",
"def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end"
] | [
"0.61899436",
"0.6043484",
"0.5980227",
"0.59198403",
"0.59156847",
"0.5898723",
"0.5896654",
"0.5896654",
"0.5885377",
"0.5875285",
"0.58730227",
"0.58651614",
"0.5865042",
"0.5772566",
"0.5762172",
"0.5761809",
"0.5741422",
"0.5711907",
"0.56627285",
"0.56610477",
"0.5659338",
"0.5657349",
"0.56459016",
"0.56433064",
"0.5630062",
"0.5629968",
"0.5627898",
"0.562207",
"0.56097823",
"0.5603889",
"0.5603751",
"0.559183",
"0.55902475",
"0.55829215",
"0.55829215",
"0.55760235",
"0.5569444",
"0.55659586",
"0.555877",
"0.55574214",
"0.5557277",
"0.55487055",
"0.5544285",
"0.55424917",
"0.5538923",
"0.55315876",
"0.5525553",
"0.55247456",
"0.5519972",
"0.5519422",
"0.55098873",
"0.5506626",
"0.5504789",
"0.5502673",
"0.5498483",
"0.549145",
"0.5485189",
"0.5483761",
"0.5482756",
"0.5473013",
"0.5471116",
"0.54703337",
"0.546757",
"0.5465771",
"0.5464077",
"0.5452024",
"0.54411405",
"0.54323876",
"0.54116553",
"0.54110676",
"0.54093647",
"0.54032564",
"0.5402626",
"0.5402577",
"0.54025453",
"0.5401312",
"0.53962785",
"0.5395639",
"0.53922975",
"0.53876823",
"0.5387581",
"0.53819245",
"0.5381674",
"0.53788537",
"0.5377821",
"0.5377353",
"0.5366528",
"0.5364908",
"0.53643996",
"0.53584975",
"0.53570575",
"0.5349604",
"0.534275",
"0.5342274",
"0.5341649",
"0.5340936",
"0.533969",
"0.53373194",
"0.5336256",
"0.53350073"
] | 0.70785415 | 0 |
GET /tuberculoses/1 GET /tuberculoses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tuberculoses = Tuberculose.all\n end",
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def index\n @tunes = Tune.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tunes }\n end\n end",
"def index\n @tenures = Tenure.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @tenures\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end",
"def index\n @toyota = Toyotum.all\n end",
"def index\n @timers = Timer.all\n\n render json: @timers\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @territorios }\n end\n end",
"def index\n @tailors = Tailor.all\n respond_to do |format|\n format.html\n format.json { render json: @tailors}\n end\n end",
"def tattoos\n render :nothing => true and return if params[:id].nil?\n\n @tattoo = Tattoo.find(params[:id])\n render :json => @tattoo.to_json(:include => [:artist, :assets])\n #render :json => @tattoo.to_json(:include => { :assets => { :only => [:id, :data_file_name] } })\n return\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index *_\n @trades = owned_trades_view\n\n render json: @trades\n end",
"def index\n @terceros = Tercero.all\n end",
"def taken\n @travels = Travels::Travel.taken.where(performer: current_user)\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @tuiters = Tuiter.all\n end",
"def index\n @trucks = Truck.all\n\n render json: @trucks\n end",
"def show\n render json: @tenure\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n @trips = Trip.all\n\n render json: @trips\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def index\n @heroes = Hero.all\n\n render json: @heroes\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def index\n @turmas = Turma.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @turmas }\n end\n end",
"def index\n users = User.all\n # cheer_ups = CheerUp.all\n render json: users\n end",
"def index\n @tutor = Tutor.all\n\n render json: @tutor, status: :ok\n end",
"def index\n @teathers = Teather.all\n end",
"def index\n @trips = Trip.desc.all\n @latest_trip = @trips.first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trips }\n end\n end",
"def show\n @trumpet = Trumpet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trumpet }\n end\n end",
"def index\n @trips = Trip.all\n render :json => @trips\n end",
"def retrieve_tubes\n show do\n title \"Retrieve tubes and spin down\"\n \n timer initial: { hours: 0, minutes: 15, seconds: 0}\n \n check \"After timer finishes, retrieve all #{operations.length} tubes from 42 C heat block.\"\n check \"Spin the tube down for 20 seconds on a small tabletop centrifuge.\"\n check \"Remove all the supernatant carefully with a 1000 µl pipettor (~400 L total)\"\n end\n end",
"def index\n @timetables = Timetable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timetables }\n end\n end",
"def index\n @shots = Shot.all\n\n render json: @shots\n end",
"def index\n @setors = Setor.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @setors }\n end\n end",
"def index\n @uchronias = Uchronia.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronias }\n end\n end",
"def show\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uset }\n end\n end",
"def index\n @uchronists = Uchronist.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uchronists }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def show\n @tenure = Tenure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tenure }\n end\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def index \n render json: Tuning.all\n end",
"def index\n @tamires = Tamire.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end",
"def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end",
"def show \n @toy = Toy.find(params[:id]) \n # render json: Toy.find_by_id(params[:id]), status: :ok\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def index\n @client = Client.find params[:client_id]\n @pet = Pet.find params[:pet_id]\n @pet_histories = @pet.pet_histories\n end",
"def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end",
"def index\n @ties = Tie.all\n end",
"def index\n @equipos = Equipo.all\n render json: @equipos, status: :ok\n end",
"def index\n @trabalhos = current_user.trabalhos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @trabalhos }\n end\n end",
"def index\n @sectors = Sector.all.order(\"created_at DESC\")\n render json: @sectors\n end",
"def index\n @turkeys = Turkey.all\n end",
"def index\n @weapons = Weapon.all\n\n render json: @weapons\n end",
"def index\n @trades = Trade.all\n render json: @trades\n end",
"def index\n @tyc_humen = Tyc::Human.all\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def index\n @uttrances = Uttrance.all\n end",
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def index\n @tenancies = Tenancy.all\n end",
"def index\n @tickets = current_user.tickets.last(15).reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @specialties = Specialty.all\n\n render json: @specialties\n end",
"def index_user\n @tickets = Ticket.all_for_user(current_user.id)\n render json: @tickets, status: 200\n end",
"def index\n @ticket_owners = TicketOwner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ticket_owners }\n end\n end",
"def set_tuberculose\n @tuberculose = Tuberculose.find(params[:id])\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def show_user_tweets\n @user_tweets = TwitterClient.user_timeline(params[:name])\n render json: @user_tweets\n end",
"def index\n @talleres = Taller.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talleres }\n end\n end",
"def index\n @u_sers = USer.all\n end",
"def index\n @turista = Turistum.all\n end",
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def index\n @takings = Taking.all\n end",
"def index\n @chest_triceps1s = ChestTriceps1.all\n end",
"def index\n @tacos = Taco.all\n\n respond_to do |format|\n format.html { render :index }\n format.json { render @tacos }\n end\n end",
"def index\n @uzsers = Uzser.all\n end",
"def index_all\n @tickets = Ticket.all_tickets\n render json: @tickets, status: 200\n end",
"def index\n chain = Tweet\n chain = chain.since_id(params[:since_id]) if params[:since_id]\n @tweets = chain.all(:order => 'msg_twid ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tweets }\n end\n end",
"def index\n @tubuyakis = Tubuyaki.all\n @tubuyaki = Tubuyaki.new\n end",
"def huertopublico\n @huerto = Huerto.find_by_agrupacion(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end",
"def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end",
"def index\n current_admin_user\n @tablets = Tablet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tablets }\n end\n end",
"def index\n @trayectoria = Trayectorium.all\n end",
"def index\n @tomaturnos = Tomaturno.all\n end",
"def index\n @utentes = Utente.all\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end",
"def index\n @tweets = Tweet.all\n\n render json: @tweets\n end",
"def index\n @trades = Trade\n .only(:created_at, :is_fair, :ash_pokemons, :brock_pokemons)\n respond_to do |format|\n format.json { render json: @trades }\n end\n end",
"def load_tailors\n\t\t@shop_name=params[:shop_name]\n\t\t@title=params[:title]\n\t\tuser = User.where(:user_type => \"tailor\", :shop_name => @shop_name, :title => @title).select(\"id\",\"username\",\"email\")\n\t\tif user.nil?\n\t\t\trender json: {message: \"No any tailor in this group\"}\n\t\telse\t\t\t\n\t\t \tdetails = []\n\t\t\tuser.each do |chat|\n\t\t\t\tdetails << { :id => chat.id, :type => chat.username, :email => chat.email}\n\t\t\tend\n\t\t\trender :json => details.to_json\t\n\t\tend\n\tend",
"def tweets\n user = User.find(params[:id])\n render json: user.list_tweets, status: :ok\n end",
"def index\n @tarots = Tarot.all\n end",
"def index\n render json: Story.all\n end",
"def index\n @ts = T.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ts }\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n end",
"def get\n appid = ENV['TRIMET_APP_ID']\n response = Unirest.get( \"http://developer.trimet.org/ws/v2/vehicles?appid=#{appid}\" )\n response.body\nend",
"def index\n @teaches = Teach.all\n\t\trespond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@teaches) }\n\t\tend\n\n end",
"def index\n @tutoring_sessions = TutoringSession.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tutoring_sessions }\n end\n end"
] | [
"0.67937416",
"0.61324847",
"0.6050181",
"0.60280186",
"0.6016129",
"0.5954204",
"0.59041876",
"0.58514225",
"0.58225685",
"0.5818246",
"0.5806759",
"0.58032036",
"0.5796304",
"0.5780724",
"0.57646114",
"0.57588583",
"0.57577026",
"0.57431394",
"0.5719428",
"0.5719428",
"0.57001644",
"0.56906104",
"0.5688731",
"0.5688498",
"0.5681495",
"0.568108",
"0.56751204",
"0.56716543",
"0.5665222",
"0.5662172",
"0.5658624",
"0.5652129",
"0.56518096",
"0.5647297",
"0.5642836",
"0.5640378",
"0.5639208",
"0.5635916",
"0.56261",
"0.56078756",
"0.55986243",
"0.55907613",
"0.5579544",
"0.5579544",
"0.5576117",
"0.5572235",
"0.557111",
"0.5562155",
"0.5555452",
"0.55526716",
"0.55481833",
"0.55480015",
"0.5546703",
"0.5541993",
"0.55408674",
"0.5539889",
"0.5535026",
"0.55343187",
"0.5533434",
"0.5525715",
"0.55220354",
"0.5518747",
"0.55147266",
"0.5514285",
"0.551217",
"0.5507394",
"0.55055887",
"0.549981",
"0.54907084",
"0.54848796",
"0.54840535",
"0.54834133",
"0.548193",
"0.5479678",
"0.54650104",
"0.5462031",
"0.5457662",
"0.5450724",
"0.5449392",
"0.54437274",
"0.5432919",
"0.5426496",
"0.542644",
"0.5426236",
"0.5423183",
"0.5422255",
"0.54190886",
"0.54143167",
"0.54141426",
"0.54116213",
"0.54038584",
"0.5402641",
"0.54002476",
"0.5398389",
"0.53968436",
"0.5395323",
"0.53934085",
"0.5393065",
"0.53880715",
"0.53878963",
"0.53864837"
] | 0.0 | -1 |
POST /tuberculoses POST /tuberculoses.json | def create
@tuberculose = Tuberculose.new(tuberculose_params)
begin
@paciente = Paciente.find(params[:tuberculose][:paciente_id])
@paciente.form_laboratorio_id=8
@paciente.save
rescue Exception => e
end
respond_to do |format|
if @tuberculose.save
format.html { redirect_to @tuberculose, notice: 'Tuberculose was successfully created.' }
format.json { render :show, status: :created, location: @tuberculose }
else
format.html { render :new }
format.json { render json: @tuberculose.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tuberculoses = Tuberculose.all\n end",
"def create\n @toyotum = Toyotum.new(toyotum_params)\n\n respond_to do |format|\n if @toyotum.save\n format.html { redirect_to @toyotum, notice: 'Toyotum was successfully created.' }\n format.json { render :show, status: :created, location: @toyotum }\n else\n format.html { render :new }\n format.json { render json: @toyotum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uset = Uset.new(params[:uset])\n\n respond_to do |format|\n if @uset.save\n format.html { redirect_to @uset, notice: 'Uset was successfully created.' }\n format.json { render json: @uset, status: :created, location: @uset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @uset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end",
"def create\n # @tossup = tossup.new(tossup_params)\n #\n # if @tossup.save\n # render :show, status: :created, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end",
"def create\n @turistum = Turistum.new(turistum_params)\n\n respond_to do |format|\n if @turistum.save\n format.html { redirect_to @turistum, notice: 'Turistum was successfully created.' }\n format.json { render :show, status: :created, location: @turistum }\n else\n format.html { render :new }\n format.json { render json: @turistum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tuoshui = Tuoshui.new(params[:tuoshui])\n\n respond_to do |format|\n if @tuoshui.save\n format.html { redirect_to @tuoshui, notice: 'Tuoshui was successfully created.' }\n format.json { render json: @tuoshui, status: :created, location: @tuoshui }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tuoshui.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tubuyaki = Tubuyaki.new(tubuyaki_params)\n @tubuyaki.user = current_user\n\n respond_to do |format|\n if @tubuyaki.save\n format.html { redirect_to tubuyakis_url, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tubuyaki }\n else\n @tubuyakis = Tubuyaki.all\n format.html { render :index }\n format.json { render json: @tubuyaki.errors, status: :unprocessable_entity }\n end\n end\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 @tenure = Tenure.new(tenure_params)\n\n if @tenure.save\n audit(@tenure, current_user)\n render json: @tenure, status: :created\n else\n render json: @tenure.errors, status: :unprocessable_entity\n end\n end",
"def create\n @trucker = TruckerService.save(trucker_params)\n if response\n render json: @trucker, status: :created, location: [:api, @trucker]\n else\n render json: @trucker, status: :unprocessable_entity\n end\n end",
"def create\n @tuiter = current_user.tuiters.new(tuiter_params)\n\n respond_to do |format|\n if @tuiter.save\n format.html { redirect_to @tuiter, notice: 'Tuiter was successfully created.' }\n format.json { render :show, status: :created, location: @tuiter }\n else\n format.html { render :new }\n format.json { render json: @tuiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topup = Topup.new(topup_params)\n\n respond_to do |format|\n if @topup.save\n format.html { redirect_to @topup, notice: 'Topup was successfully created.' }\n format.json { render :show, status: :created, location: @topup }\n else\n format.html { render :new }\n format.json { render json: @topup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @toko = Toko.new(toko_params)\n @toko.user = current_user\n\n respond_to do |format|\n if @toko.save\n format.html { redirect_to '/finish', notice: 'Toko telah dibuat.' }\n format.json { render :show, status: :created, location: @toko }\n else\n format.html { render :new }\n format.json { render json: @toko.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tuberculose\n @tuberculose = Tuberculose.find(params[:id])\n end",
"def create\n @tetramod = Tetramod.new(params[:tetramod])\n\n respond_to do |format|\n if @tetramod.save\n format.html { redirect_to @tetramod, notice: 'Tetramod was successfully created.' }\n format.json { render json: @tetramod, status: :created, location: @tetramod }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tetramod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def buyTickets\n nt1 = Integer(params[:nt1])\n nt2 = Integer(params[:nt2])\n nt3 = Integer(params[:nt3])\n\n # Checks if the user deserves a free ticket\n promo = (nt1 + nt2 + nt3) >= 10? 1 : 0;\n\n ActiveRecord::Base.transaction do\n # type 1 tickets with promotion\n (nt1 + promo).times do\n Ticket.create(\n ticket_type: 1,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n\n #type 2 tickets\n nt2.times do\n Ticket.create(\n ticket_type: 2,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n\n #type 3 tickets\n nt3.times do\n Ticket.create(\n ticket_type: 3,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n end\n\n render json: {\n :status => 0,\n :msg => :ok}\n end",
"def create\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n description = params[:description]\n \n timestamp = params[:timestamp]\n total_sleep_seconds = params[:total_sleep]\n deep_sleep_seconds = params[:deep]\n light_sleep_seconds = params[:light]\n awake_seconds = params[:awake]\n \n if timestamp.nil? || total_sleep_seconds.nil?\n \n puts 'timestamp is nil or total_sleep_seconds is nil :('\n \n else\n \n total_sleep = total_sleep_seconds / 60.0\n deep = deep_sleep_seconds / 60.0\n light = light_sleep_seconds / 60.0\n awake = awake_seconds / 60.0\n \n post_to_twitter = false\n post_to_facebook = false\n \n # FellAsleepAt is formatted: August 23, 2013 at 11:01PM\n # Convert to Runkeeper's preferred format: Sat, 1 Jan 2011 00:00:00\n timestamp_datetime = DateTime.parse(timestamp)\n formatted_timestamp = timestamp_datetime.strftime(\"%a, %d %b %Y %H:%M:%S\")\n \n json_hash['timestamp'] = formatted_timestamp\n json_hash['total_sleep'] = deep\n json_hash['deep'] = deep\n json_hash['light'] = light\n json_hash['awake'] = awake\n json_hash['post_to_twitter'] = post_to_twitter\n json_hash['post_to_facebook'] = post_to_facebook\n \n url = 'https://api.runkeeper.com/sleep'\n \n uri = URI.parse(url)\n \n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri)\n request[\"Authorization\"] = \"Bearer \" + RUNKEEPER_ACCESS_TOKEN\n request[\"Content-Type\"] = \"application/vnd.com.runkeeper.NewSleep+json\"\n request.body = json_hash.to_json\n \n response = http.request(request)\n \n puts response.body\n \n end\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n \n end",
"def create\n @equipo_torneos = EquiposTorneos.new(equipos_torneos_params)\n \n if @equipo_torneos.save\n \n else\n render json: @equipo_torneos.errors, status: :unprocessable_entity\n end\n end",
"def 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 create\n @tercero = Tercero.new(tercero_params)\n\n respond_to do |format|\n if @tercero.save\n format.html { redirect_to @tercero, notice: 'Tercero was successfully created.' }\n format.json { render :show, status: :created, location: @tercero }\n else\n format.html { render :new }\n format.json { render json: @tercero.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tktest = Tktest.new(params[:tktest])\n\n respond_to do |format|\n if @tktest.save\n format.html { redirect_to @tktest, notice: 'Tktest was successfully created.' }\n format.json { render json: @tktest, status: :created, location: @tktest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tktest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @u_ser = USer.new(params[:u_ser])\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render json: @u_ser, status: :created, location: @u_ser }\n else\n format.html { render action: \"new\" }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\n\n respond_to do |format|\n if @tombstone_timehold.save\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\n format.json { render :show, status: :created, location: @tombstone_timehold }\n else\n format.html { render :new }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @u_ser = USer.new(u_ser_params)\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render :show, status: :created, location: @u_ser }\n else\n format.html { render :new }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def grab_tubes\n show do\n title \"Grab #{operations.running.length} 1.5 mL tubes for diluted fragment aliquots\"\n\n check \"Grab #{operations.running.length} 1.5 mL tubes, label with following ids: #{operations.map {|op| \"#{op.output(DILUTED_STOCK).item.id}\"}.join(\", \")}\"\n check \"Add water according to table.\"\n table operations.running.start_table\n .output_item(DILUTED_STOCK)\n .custom_column(heading: \"H20 (uL)\", checkable: true) {|op| op.temporary[:dilution_water_vol]}\n .end_table\n end\n end",
"def create\n\n \t\t\t@teetime = Teetime.new teetime_params\n\n \t\t\tif @teetime.save\n\n \t\t\t\trender json: @teetime,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def create\n if signed_in?\n @tourtable = Tourtable.new(params[:tourtable])\n\n respond_to do |format|\n if @tourtable.save\n format.html { redirect_to @tourtable, notice: 'Tourtable was successfully created.' }\n format.json { render json: @tourtable, status: :created, location: @tourtable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tourtable.errors, status: :unprocessable_entity }\n end\n end\n end\nend",
"def create\n @tack = Tack.new(tack_params)\n\n if @tack.save\n render json: @tack, status: :created, location: @tack\n else\n render json: @tack.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tickets = []\n params[:quantity].to_i.times do\n @ticket = Ticket.new(params[:ticket])\n @ticket.viber = current_viber\n @tickets << @ticket\n end\n\n respond_to do |format|\n if @tickets.map(&:save)\n format.html { redirect_to @ticket, notice: 'Your ticket(s) are booked.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @tuberculose.destroy\n respond_to do |format|\n format.html { redirect_to tuberculoses_url, notice: 'Tuberculose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n cnt = params[:tutor_availability][:repeat].to_i - 1\n params[:tutor_availability].delete :repeat\n @tutor_availability = TutorAvailability.new(params[:tutor_availability])\n\n respond_to do |format|\n if @tutor_availability.save\n if cnt > 0\n for i in 1..cnt\n new_ta = TutorAvailability.new(params[:tutor_availability])\n new_ta.start_time = @tutor_availability.start_time + 604800*i\n new_ta.save\n end\n end\n format.html { redirect_to tutor_availabilities_path, notice: 'Tutor availability was successfully created.' }\n format.json { render json: @tutor_availability, status: :created, location: @tutor_availability }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutor_availability.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uzser = Uzser.new(uzser_params)\n\n respond_to do |format|\n if @uzser.save\n format.html { redirect_to @uzser, notice: 'Uzser was successfully created.' }\n format.json { render :show, status: :created, location: @uzser }\n else\n format.html { render :new }\n format.json { render json: @uzser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @cuentum = Cuentum.new(params[:cuentum])\n\n respond_to do |format|\n if @cuentum.save\n format.html { redirect_to @cuentum, :notice => 'Cuentum was successfully created.' }\n format.json { render :json => @cuentum, :status => :created, :location => @cuentum }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cuentum.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\r\n # @user = User.find(session[:user_id])\r\n # @usertable = Usertable.new(params[:usertable])\r\n # @usertable.user = @user\r\n\r\n @user = current_user\r\n @usertable = Usertable.new(params[:usertable])\r\n @usertable.user = @user\r\n\r\n respond_to do |format|\r\n if @usertable.save\r\n format.html { redirect_to @usertable, notice: 'Your mood was successfully saved.' }\r\n format.json { render json: @usertable, status: :created, location: @usertable }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @usertable.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @turkey = Turkey.new(turkey_params)\n\n respond_to do |format|\n if @turkey.save\n format.html { redirect_to @turkey, notice: 'Turkey was successfully created.' }\n format.json { render :show, status: :created, location: @turkey }\n else\n format.html { render :new }\n format.json { render json: @turkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trumpet = Trumpet.new(params[:trumpet])\n\n respond_to do |format|\n if @trumpet.save\n format.html { redirect_to @trumpet, notice: 'Trumpet was successfully created.' }\n format.json { render json: @trumpet, status: :created, location: @trumpet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trumpet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainees = TraineeBatch.new(params[:participants][:ids], params[:training_calendar_id])\n respond_to do |format|\n if @trainees.save\n format.html { redirect_to training_calendar_path(params[:training_calendar_id]), :notice => 'The participant(s) were successfully added.' }\n format.json { render :json => @trainees, :status => :created, :location => @trainees }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainees.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @huerto = Huerto.new(params[:huerto])\n\n respond_to do |format|\n if @huerto.save\n format.html { redirect_to @huerto, notice: 'Huerto was successfully created.' }\n format.json { render json: @huerto, status: :created, location: @huerto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @huerto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tatoo = Tatoo.new(tatoo_params)\n\n respond_to do |format|\n if @tatoo.save\n format.html { redirect_to @tatoo, notice: 'Tatoo was successfully created.' }\n format.json { render :show, status: :created, location: @tatoo }\n else\n format.html { render :new }\n format.json { render json: @tatoo.errors, status: :unprocessable_entity }\n end\n end\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 create\n @tenure = Tenure.new(params[:tenure])\n\n respond_to do |format|\n if @tenure.save\n format.html { redirect_to @tenure, notice: 'Tenure was successfully created.' }\n format.json { render json: @tenure, status: :created, location: @tenure }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tenure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tumor_params\n params.require(:tumor).permit(:edad, :genero, :tipo_histologico, :grado_tumor, :hueso, :medula_osea, :pulmon, :pleura, :peritoneum, :higado, :cerebro, :piel, :cuello, :supraclavicular, :axilar, :mediastino, :abdominal, :tipo_tumor, :name, :email)\n end",
"def create\n @trumpet = Trumpet.new(trumpet_params)\n\n respond_to do |format|\n if @trumpet.save\n format.html { redirect_to new_trumpet_url, notice: 'Trumpet was successfully created.' }\n format.json { render :show, status: :created, location: @trumpet }\n else\n format.html { render :new }\n format.json { render json: @trumpet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:trabajador][:rut] = RUT::format(params[:trabajador][:rut])\n\n @trabajador = Trabajador.new(trabajador_params)\n\n\n respond_to do |format|\n if @trabajador.save\n format.html { redirect_to @trabajador, notice: 'Trabajador was successfully created.' }\n format.json { render :show, status: :created, location: @trabajador }\n else\n format.html { render :new }\n format.json { render json: @trabajador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @takeout = Takeout.new(takeout_params)\n\n respond_to do |format|\n if @takeout.save\n format.html { redirect_to @takeout, notice: 'Takeout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @takeout }\n else\n format.html { render action: 'new' }\n format.json { render json: @takeout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @table = Table.new(params[:table].permit(:name, :notes, :x, :y, :table_type, :guest_ids => []))\n\n respond_to do |format|\n if @table.save\n format.html { redirect_to @table, notice: 'Table was successfully created.' }\n format.json { render 'tables/create', status: :created, location: @table }\n else\n format.html { render action: \"new\" }\n format.json { render json: @table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tb_solicitud = TbSolicitud.new(tb_solicitud_params)\n\n respond_to do |format|\n if @tb_solicitud.save\n format.html { redirect_to @tb_solicitud, notice: 'Tb solicitud was successfully created.' }\n format.json { render :show, status: :created, location: @tb_solicitud }\n else\n format.html { render :new }\n format.json { render json: @tb_solicitud.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end",
"def create\n @trainbot = Trainbot.new(trainbot_params)\n @org = UttranceService.new\n @org.post_uttrance(trainbot_params[:message],trainbot_params[:intent],trainbot_params[:entity],trainbot_params[:start],trainbot_params[:end],trainbot_params[:body]\n )\n respond_to do |format|\n if @trainbot.save\n format.html { redirect_to @trainbot, notice: 'Trainbot was successfully created.' }\n format.json { render :show, status: :created, location: @trainbot }\n else\n format.html { render :new }\n format.json { render json: @trainbot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tecido = Tecido.new(tecido_params)\n\n respond_to do |format|\n if @tecido.save\n format.html { redirect_to @tecido, notice: 'Tecido was successfully created.' }\n format.json { render :show, status: :created, location: @tecido }\n else\n format.html { render :new }\n format.json { render json: @tecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end",
"def create\n @ty = Tie.new(ty_params)\n\n respond_to do |format|\n if @ty.save\n format.html { redirect_to @ty, notice: 'Tie was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ty }\n else\n format.html { render action: 'new' }\n format.json { render json: @ty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @templete = Templete.new(params[:templete])\n\n respond_to do |format|\n if @templete.save\n format.html { redirect_to @templete, :notice => 'Templete was successfully created.' }\n format.json { render :json => @templete, :status => :created, :location => @templete }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @templete.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n event = Event.find(params[:event_id])\n batch_id = params[:batch_id] # for when an event has multiple types of tickets\n amount = params[:amount] # amount of tickets\n user_info = { anonymous: SecureRandom::hex } # instead of a random string this could have user info\n price = event.price * amount\n address = TicketAddresses.create_ticket_address(event.id, batch_id)\n\n ticket = Ticket.create!(\n event: event,\n batch_id: batch_id,\n amount: amount,\n price: price,\n user_info: user_info,\n address: address,\n status: :unconfirmed\n )\n\n render json: {\n address: address,\n salt: ticket.salt,\n price: event.price * amount,\n }\n end",
"def retrieve_tubes\n show do\n title \"Retrieve tubes and spin down\"\n \n timer initial: { hours: 0, minutes: 15, seconds: 0}\n \n check \"After timer finishes, retrieve all #{operations.length} tubes from 42 C heat block.\"\n check \"Spin the tube down for 20 seconds on a small tabletop centrifuge.\"\n check \"Remove all the supernatant carefully with a 1000 µl pipettor (~400 L total)\"\n end\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def create\n @table = Table.new(table_params)\n respond_to do |format|\n if @table.save\n\n if params[:waiter]\n @waitertable = WaiterTable.new\n @waitertable.user_id = params[:waiter]\n @waitertable.table_id = @table.id\n @waitertable.save\n @table.assign = true\n @table.save\n \n end\n \n format.html { redirect_to @table, notice: 'Mesa creada correctamente.' }\n format.json { render :show, status: :created, location: @table }\n else\n format.html { render :new }\n format.json { render json: @table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_rounds\n\t\t@rounds = []\n\t\tcase @participant.league.type\n\t\twhen \"Fantasy\"\n\t\t\t@rounds = [\"fantasy\"]\n\t\twhen \"Elimination\"\n\t\t\t@rounds = [\"elimination\"]\n\t\tend\n\t\trender json: @rounds\n\tend",
"def create\n @time_treinador = TimeTreinador.new(time_treinador_params)\n @time_treinador.treinador = @treinador\n\n respond_to do |format|\n if @time_treinador.save\n format.html { redirect_to @time_treinador, notice: 'Time criado com sucesso' }\n format.json { render :show, status: :created, location: @time_treinador }\n else\n format.html { render :new }\n format.json { render json: @time_treinador.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 @tiendas_juego = TiendasJuego.new(tiendas_juego_params)\n\n respond_to do |format|\n if @tiendas_juego.save\n format.html { redirect_to @tiendas_juego, notice: 'Tiendas juego was successfully created.' }\n format.json { render :show, status: :created, location: @tiendas_juego }\n else\n format.html { render :new }\n format.json { render json: @tiendas_juego.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pet = Pet.find(params[:id]) \n @solicitud = Solicitud.new(solicitud_params)\n @solicitud.id = current_user.id \n @solicitud.id_pet = @pet.id\n respond_to do |format|\n if @solicitud.save\n solicitud = Solicitud.find(@solicitud.id)\n user = User.find(current_user.id)\n #user.follow(solicitud) Esto no porque crea tuplas duplicadas y mal en followers\n format.html { redirect_to @solicitud, notice: 'Tu solicitud ha sido guardada' }\n format.json { render :show, status: :created, location: @solicitud }\n else\n format.html { render :new }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torso = Torso.new(params[:torso])\n\n respond_to do |format|\n if @torso.save\n format.html { redirect_to @torso, notice: 'Torso was successfully created.' }\n format.json { render json: @torso, status: :created, location: @torso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @torso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n begin\n Twitter.user_timeline(params[:foodtruck][:handle])\n Foodtruck.create(params[:foodtruck])\n redirect_to '/foodtrucks'\n rescue\n redirect_to '/foodtrucks/new'\n end\n end",
"def create\n @waiter = Waiter.new(params[:waiter])\n\n respond_to do |format|\n if @waiter.save\n format.html { redirect_to @waiter, notice: 'Waiter was successfully created.' }\n format.json { render json: @waiter, status: :created, location: @waiter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @litter = Litter.new(params[:litter])\n @pig = Pig.find(@litter.sow_id)\n @no_of_piglets = params[:no_of_piglets].to_i\n \n @no_of_piglets.times do\n Pig.create(name: @pig.name + ' piglet', status: alive_id, dob: Time.now, litter: @litter)\n end\n\n respond_to do |format|\n if @litter.save\n format.html { redirect_to @litter, notice: 'Litter was successfully created with ' + @no_of_piglets.to_s + ' piglets' }\n format.json { render json: @litter, status: :created, location: @litter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @litter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweeeet = current_user.tweeeets.build(tweeeet_params)\n\n respond_to do |format|\n if @tweeeet.save\n format.html { redirect_to root_path, notice: 'Tweet creado con éxito!' }\n format.json { render :show, status: :created, location: @tweeeet }\n else\n format.html { render :new }\n format.json { render json: @tweeeet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def create\n @taste_tester = TasteTester.new(taste_tester_params)\n\n respond_to do |format|\n if @taste_tester.save\n format.html { redirect_to @taste_tester, notice: 'Taste tester was successfully created.' }\n format.json { render :show, status: :created, location: @taste_tester }\n else\n format.html { render :new }\n format.json { render json: @taste_tester.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tribe = Tribe.new(tribe_params)\n\n respond_to do |format|\n if @tribe.save\n format.html { redirect_to @tribe, notice: 'Tribe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tribe }\n else\n format.html { render action: 'new' }\n format.json { render json: @tribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tarot = Tarot.new(tarot_params)\n\n respond_to do |format|\n if @tarot.save\n format.html { redirect_to @tarot, notice: 'Tarot was successfully created.' }\n format.json { render :show, status: :created, location: @tarot }\n else\n format.html { render :new }\n format.json { render json: @tarot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trainee = Trainee.new(trainee_params)\n\n respond_to do |format|\n if @trainee.save\n format.html { redirect_to @trainee, notice: 'Trainee was successfully created.' }\n format.json { render :show, status: :created, location: @trainee }\n else\n format.html { render :new }\n format.json { render json: @trainee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n tp = tumor_params\n tp[:tipo_tumor], ad, p = tipo(tp)\n if p == nil\n p=0\n end\n @tumor = Tumor.new(tp)\n respond_to do |format|\n if @tumor.save\n format.html { redirect_to @tumor, notice: 'Se registro con exito con tipo de tumor => '+tp[:tipo_tumor].capitalize+\n '.<>Arbol de decision:<>'+\n ad+'<>Con un grado de acierto de: '+\n p.to_s+\n ' y un porcentaje de acierto de 83.19%' }\n format.json { render :show, status: :created, location: @tumor }\n else\n format.html { render :new }\n format.json { render json: @tumor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @utente = Utente.new(utente_params)\n\n respond_to do |format|\n if @utente.save\n format.html { redirect_to @utente, notice: \"L'utente è stato creato.\" }\n format.json { render :show, status: :created, location: @utente }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @utente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @territorio = Territorio.new(params[:territorio])\n\n respond_to do |format|\n if @territorio.save\n format.html { redirect_to @territorio, notice: 'Territorio was successfully created.' }\n format.json { render json: @territorio, status: :created, location: @territorio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @territorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tattoo = Tattoo.new(params[:tattoo])\n\n respond_to do |format|\n if @tattoo.save\n format.html { redirect_to @tattoo, notice: 'Tattoo was successfully created.' }\n format.json { render json: @tattoo, status: :created, location: @tattoo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tattoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @uttrance = Uttrance.new(uttrance_params)\n # @uttrance = Uttrance.new(data_facebook)\n respond_to do |format|\n if @uttrance.save\n format.html { redirect_to @uttrance, notice: 'Uttrance was successfully created.' }\n format.json { render :show, status: :created, location: @uttrance }\n else\n format.html { render :new }\n format.json { render json: @uttrance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uder = Uder.new(uder_params)\n\n respond_to do |format|\n if @uder.save\n format.html { redirect_to @uder, notice: 'Uder was successfully created.' }\n format.json { render action: 'show', status: :created, location: @uder }\n else\n format.html { render action: 'new' }\n format.json { render json: @uder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @usersevent = Usersevent.new(params[:usersevent])\n\n respond_to do |format|\n if @usersevent.save\n format.html { redirect_to @usersevent, :notice => 'Usersevent was successfully created.' }\n format.json { render :json => @usersevent, :status => :created, :location => @usersevent }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @usersevent.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @sluzby = Sluzby.new(params[:sluzby])\n\n respond_to do |format|\n if @sluzby.save\n format.html { redirect_to @sluzby, notice: 'Sluzby was successfully created.' }\n format.json { render json: @sluzby, status: :created, location: @sluzby }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sluzby.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tiempo = Tiempo.new(tiempo_params)\n\n respond_to do |format|\n if @tiempo.save\n format.html { redirect_to @tiempo, notice: 'Tiempo was successfully created.' }\n format.json { render :show, status: :created, location: @tiempo }\n else\n format.html { render :new }\n format.json { render json: @tiempo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipocuentum = Tipocuentum.new(tipocuentum_params)\n\n respond_to do |format|\n if @tipocuentum.save\n format.html { redirect_to @tipocuentum, notice: 'Tipocuentum was successfully created.' }\n format.json { render :show, status: :created, location: @tipocuentum }\n else\n format.html { render :new }\n format.json { render json: @tipocuentum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n current_admin_user\n @tablet = Tablet.new(params[:tablet])\n\n respond_to do |format|\n if @tablet.save\n format.html { redirect_to @tablet, notice: 'Tablet was successfully created.' }\n format.json { render json: @tablet, status: :created, location: @tablet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tablet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n name = params[:name]\n seat = params[:seat]\n desc = params[:desc]\n group_name = params[:group]\n group = Group.where(name:group_name).first\n\n new_ticket = group.tickets.new(name:name,seat:seat,description:desc)\n\n if new_ticket.save\n notice = {\"notice\"=>\"new ticket created successfully.\"}\n puts notice.to_json\n redirect_to \"http://hacked.io/almanac/get-help/submitted\"\n else\n alert = {\"alert\"=>\"ticket was not created. check your params.\"}\n puts alert.to_json\n redirect_to \"http://hacked.io/almanac/get-help/not-submitted\"\n end\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 create\n @nursery_table = NurseryTable.new(nursery_table_params)\n\n respond_to do |format|\n if @nursery_table.save\n format.html { redirect_to @nursery_table, notice: \"Nursery table was successfully created.\" }\n format.json { render :show, status: :created, location: @nursery_table }\n else\n format.html { render :new }\n format.json { render json: @nursery_table.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @russian_roulette = RussianRoulette.new(russian_roulette_params)\n @russian_roulette.bulloc = @bulloc\n @russian_roulette.round = @round\n @russian_roulette.alive = @alive\n\n respond_to do |format|\n if @russian_roulette.save\n format.html { redirect_to @russian_roulette, notice: 'Russian roulette was successfully created.' }\n format.json { render :show, status: :created, location: @russian_roulette }\n else\n format.html { render :new }\n format.json { render json: @russian_roulette.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @estatuto = Estatuto.new(params[:estatuto])\n\n respond_to do |format|\n if @estatuto.save\n format.html { redirect_to @estatuto, notice: 'Estatuto was successfully created.' }\n format.json { render json: @estatuto, status: :created, location: @estatuto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estatuto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def toyotum_params\n params.require(:toyotum).permit(:year, :model, :acceleration, :braking)\n end",
"def create\n @tyre = Tyre.new(tyre_params)\n respond_to do |format|\n if @tyre.save\n format.html { redirect_to (:back), notice: 'Treno pneumatici inserito.' }\n format.json { render json: @tyre, status: :created, location: @tyre, content_type: 'text/json' }\n else\n format.html { render action: 'new' }\n format.json { render json: @tyre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @counter = 0\n @teamstat = Teamstat.new(teamstat_params)\n\n @teamstat.toon_db = @teamstat.input.strip.split(/[\\r\\n ,]+/)\n @teamstat.toon_db.pop if @teamstat.toon_db[-1]==\"\\r\\n\"\n \n @teamstat.toon_db.each { |toonrealm| add_toon(toonrealm)}\n\n respond_to do |format|\n if @teamstat.save\n format.html { redirect_to @teamstat, notice: 'Teamstat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @teamstat }\n else\n format.html { render action: 'new' }\n format.json { render json: @teamstat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trayectorium = Trayectorium.new(trayectorium_params)\n\n respond_to do |format|\n if @trayectorium.save\n format.html { redirect_to edit_trayectorium_path(@trayectorium.id), notice: 'Trayectorium was successfully created.' }\n format.json { render :show, status: :created, location: @trayectorium }\n else\n format.html { render :new }\n format.json { render json: @trayectorium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tuberculose_params\n params.require(:tuberculose).permit(:form_laboratorio_id, :paciente_id, :tipo_de_muestra, :razon, :string, :mendico, :centro_de_salud, :observaciones)\n end",
"def create\n @turma = Turma.new(params[:turma])\n\n respond_to do |format|\n if @turma.save\n format.html { redirect_to @turma, notice: 'Turma criada com sucesso.' }\n format.json { render json: @turma, status: :created, location: @turma }\n else\n format.html { render action: \"new\" }\n format.json { render json: @turma.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.58030933",
"0.5621041",
"0.55557984",
"0.5492082",
"0.54913324",
"0.5365434",
"0.5353052",
"0.53145224",
"0.531164",
"0.52605265",
"0.52542317",
"0.5251206",
"0.52503914",
"0.5242318",
"0.52376175",
"0.52367294",
"0.52338463",
"0.52282405",
"0.5210136",
"0.5202543",
"0.51699764",
"0.5160915",
"0.5137259",
"0.51335955",
"0.51211435",
"0.5105746",
"0.5100402",
"0.50892216",
"0.5085958",
"0.5084047",
"0.50818187",
"0.5081524",
"0.50806713",
"0.5068187",
"0.5066924",
"0.5061922",
"0.50518256",
"0.5048247",
"0.5041537",
"0.5041037",
"0.503236",
"0.5027705",
"0.50255513",
"0.50175065",
"0.5015732",
"0.500334",
"0.49995807",
"0.4988944",
"0.49854717",
"0.49834535",
"0.49680904",
"0.49399963",
"0.49377757",
"0.49296054",
"0.49232024",
"0.49220982",
"0.49195597",
"0.49148175",
"0.49128038",
"0.4905819",
"0.4905819",
"0.4902275",
"0.49009398",
"0.48997417",
"0.48941723",
"0.4889604",
"0.48877022",
"0.48852852",
"0.4865453",
"0.48654294",
"0.4856484",
"0.48555604",
"0.48554224",
"0.48550072",
"0.48508233",
"0.48453534",
"0.48435974",
"0.4841913",
"0.48366258",
"0.48362216",
"0.4833688",
"0.48303404",
"0.4828561",
"0.48274687",
"0.48240483",
"0.48232004",
"0.48221594",
"0.48187292",
"0.48125777",
"0.4809599",
"0.48089224",
"0.48059523",
"0.48050782",
"0.48043346",
"0.4801815",
"0.48008046",
"0.48007402",
"0.4800446",
"0.47964197",
"0.4793603"
] | 0.48252332 | 84 |
PATCH/PUT /tuberculoses/1 PATCH/PUT /tuberculoses/1.json | def update
respond_to do |format|
if @tuberculose.update(tuberculose_params)
format.html { redirect_to @tuberculose, notice: 'Tuberculose was successfully updated.' }
format.json { render :show, status: :ok, location: @tuberculose }
else
format.html { render :edit }
format.json { render json: @tuberculose.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @toyotum.update(toyotum_params)\n format.html { redirect_to @toyotum, notice: 'Toyotum was successfully updated.' }\n format.json { render :show, status: :ok, location: @toyotum }\n else\n format.html { render :edit }\n format.json { render json: @toyotum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n if @uset.update_attributes(params[:uset])\n format.html { redirect_to @uset, notice: 'Uset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\r\n @usertable = Usertable.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @usertable.update_attributes(params[:usertable])\r\n format.html { redirect_to @usertable, notice: 'Your mood was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @usertable.errors, status: :unprocessable_entity }\r\n end\r\n end\r\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 respond_to do |format|\n if @tatoo.update(tatoo_params)\n format.html { redirect_to tatoos_path, notice: 'Tatoo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tatoo }\n else\n format.html { render :edit }\n format.json { render json: @tatoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trumpet = Trumpet.find(params[:id])\n\n respond_to do |format|\n if @trumpet.update_attributes(params[:trumpet])\n format.html { redirect_to @trumpet, notice: 'Trumpet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trumpet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n @marcas = @truck.get_marcas() \n @modelos = @truck.get_modelos()\n @tipo_unidad = @truck.get_tipos()\n @config = @truck.get_config()\n @clase = @truck.get_clase()\n @color = @truck.get_color()\n\n\n respond_to do |format|\n if @truck.update(truck_params)\n format.html { redirect_to @truck, notice: 'Truck was successfully updated.' }\n format.json { render :show, status: :ok, location: @truck }\n else\n format.html { render :edit }\n format.json { render json: @truck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tetramod = Tetramod.find(params[:id])\n\n respond_to do |format|\n if @tetramod.update_attributes(params[:tetramod])\n format.html { redirect_to @tetramod, notice: 'Tetramod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tetramod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tottle.update(tottle_params)\n format.html { redirect_to @tottle, notice: 'Tottle was successfully updated.' }\n format.json { render :show, status: :ok, location: @tottle }\n else\n format.html { render :edit }\n format.json { render json: @tottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tercero.update(tercero_params)\n format.html { redirect_to @tercero, notice: 'Tercero was successfully updated.' }\n format.json { render :show, status: :ok, location: @tercero }\n else\n format.html { render :edit }\n format.json { render json: @tercero.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chest_triceps1.update(chest_triceps1_params)\n format.html { redirect_to \"/chest_triceps1s\" } \n format.json { render :show, status: :ok, location: @chest_triceps1 }\n else\n format.html { render :edit }\n format.json { render json: @chest_triceps1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tuoshui = Tuoshui.find(params[:id])\n\n respond_to do |format|\n if @tuoshui.update_attributes(params[:tuoshui])\n format.html { redirect_to @tuoshui, notice: 'Tuoshui was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tuoshui.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trumpet.update(trumpet_params)\n format.html { redirect_to new_trumpet_url, notice: 'Trumpet was successfully updated.' }\n format.json { render :show, status: :ok, location: @trumpet }\n else\n format.html { render :edit }\n format.json { render json: @trumpet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trucker = TruckerService.save(trucker_params)\n if response\n render json: @trucker, status: :created, location: [:api, @trucker]\n else\n render json: @trucker, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @tubuyaki.update(tubuyaki_params)\n format.html { redirect_to @tubuyaki, notice: 'Tubuyaki was successfully updated.' }\n format.json { render :show, status: :ok, location: @tubuyaki }\n else\n format.html { render :edit }\n format.json { render json: @tubuyaki.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @u_ser = USer.find(params[:id])\n\n respond_to do |format|\n if @u_ser.update_attributes(params[:u_ser])\n format.html { redirect_to @u_ser, notice: 'U ser was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @toy.update(toy_params)\n format.html { redirect_to @toy, notice: \"Toy was successfully updated.\" }\n format.json { render :show, status: :ok, location: @toy }\n else\n format.html { render :edit }\n format.json { render json: @toy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tapioca.update(tapioca_params)\n format.html { redirect_to @tapioca, notice: 'Tapioca was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tapioca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tenure = Tenure.find(params[:id])\n\n if @tenure.update(tenure_params)\n audit(@tenure, current_user)\n head :no_content\n else\n render json: @tenure.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @form_tuberculose.update(form_tuberculose_params)\n format.html { redirect_to @form_tuberculose, notice: 'Form tuberculosis was successfully updated.' }\n format.json { render :show, status: :ok, location: @form_tuberculose }\n else\n format.html { render :edit }\n format.json { render json: @form_tuberculose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n request_body_Data= '{ \"widget\":\n {\n \"name\" : \"'+params[:name]+'\",\n \"description\" : \"'+params[:description]+'\"\n }}'\n response = RestClient::Request.new({\n method: :put,\n url: ENV['API_URL'] + '/widgets/' + params[:id],\n payload: request_body_Data,\n headers: { Authorization: session[:access_token], content_type: 'application/json'}\n }).execute do |response, request, result|\n case response.code\n when 400\n [ :error, JSON.parse(response) ]\n when 200\n [ :success, JSON.parse(response) ]\n json=JSON.parse(response)\n @widget= Widget.new do |widget|\n widget.id=json[\"data\"][\"widget\"][\"id\"]\n widget.name=json[\"data\"][\"widget\"][\"name\"]\n widget.description=json[\"data\"][\"widget\"][\"description\"]\n widget.kind=json[\"data\"][\"widget\"][\"kind\"]\n widget.userid=json[\"data\"][\"widget\"][\"user\"][\"id\"]\n widget.username=json[\"data\"][\"widget\"][\"user\"][\"name\"]\n widget.owner=json[\"data\"][\"widget\"][\"owner\"]\n end\n else\n fail \"Invalid response #{response.to_str} received.\"\n end\n end\n respond_to do |format|\n if @widget\n format.html { redirect_to @widget, notice: 'Widget was successfully updated.' }\n format.json { render :show, status: :ok, location: @widget }\n else\n format.html { render :edit }\n format.json { render json: @widget.errors, status: :unprocessable_entity }\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\n respond_to do |format|\n if @thuoc.update(thuoc_params)\n format.html { redirect_to @thuoc, notice: \"Thuoc was successfully updated.\" }\n format.json { render :show, status: :ok, location: @thuoc }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @thuoc.errors, status: :unprocessable_entity }\n end\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 @troll.update(troll_params)\n format.html { redirect_to dev_troll_path(@dev, @troll), notice: 'Troll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @troll.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tenure = Tenure.find(params[:id])\n\n respond_to do |format|\n if @tenure.update_attributes(params[:tenure])\n format.html { redirect_to @tenure, notice: 'Tenure was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tower = Tower.find(params[:id])\n\n respond_to do |format|\n if @tower.update_attributes(params[:tower])\n format.html { redirect_to @tower, :notice => 'Tower was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tower.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n current_admin_user\n @tablet = Tablet.find(params[:id])\n\n respond_to do |format|\n if @tablet.update_attributes(params[:tablet])\n format.html { redirect_to @tablet, notice: 'Tablet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tablet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @outlet = Outlet.find(id: params[:outlet][:id])\n\n # respond_to do |format|\n # twitter follower test\n if @outlet.twitter.present?\n credentials = Base64.encode64(\"#{TWITTER_ID}:#{TWITTER_SECRET}\").gsub(\"\\n\", '')\n url = \"https://api.twitter.com/oauth2/token\"\n body = \"grant_type=client_credentials\"\n headers = {\n \"Authorization\" => \"Basic #{credentials}\",\n \"Content-Type\" => \"application/x-www-form-urlencoded;charset=UTF-8\"\n }\n r = HTTParty.post(url, body: body, headers: headers)\n bearer_token = JSON.parse(r.body)['access_token']\n\n api_auth_header = {\"Authorization\" => \"Bearer #{bearer_token}\"}\n url = \"https://api.twitter.com/1.1/users/show.json?screen_name=#{@outlet.twitter}\"\n response = HTTParty.get(url, headers: api_auth_header).body\n parsed_response = JSON.parse(response)\n twitter_followers = parsed_response[\"followers_count\"].to_s\n\n if twitter_followers.present?\n if twitter_followers.length > 3\n twitter_followers = twitter_followers.chop.chop.chop+\"k\"\n end\n @outlet.update(twitter_followers: twitter_followers)\n end\n end\n\n # facebook follower test\n if @outlet.facebook.present?\n url = \"https://graph.facebook.com/#{@outlet.facebook}?fields=fan_count&access_token=#{FACEBOOK_ID}|#{FACEBOOK_SECRET}\"\n facebook_response = HTTParty.get(url)\n parsed_facebook_response = JSON.parse(facebook_response)\n facebook_followers = parsed_facebook_response[\"fan_count\"].to_s\n if facebook_followers.present?\n if facebook_followers.length > 3\n facebook_followers = facebook_followers.chop.chop.chop+\"k\"\n end\n @outlet.update(facebook_likes: facebook_followers)\n end\n end\n\n # insta follower test\n # if @outlet.instagram.present?\n # url = \"https://www.instagram.com/web/search/topsearch/?query=#{@outlet.name}\"\n # insta_response = HTTParty.get url\n # insta_followers = insta_response[\"users\"].first[\"user\"][\"byline\"].chomp(\" followers\")\n # if insta_followers.present?\n # @outlet.update(instagram_followers: insta_followers)\n # end\n # end\n\n\n\n if @outlet.update(outlet_params)\n\n # format.html { redirect_to edit_outlet_path(@outlet), notice: 'Outlet was successfully updated.' }\n render json: {status:\"Update successful\", outlet: @outlet}\n else\n # format.html { render :edit }\n # format.json { render json: @outlet.errors, status: :unprocessable_entity }\n render json: {status:\"Update unsuccessful\", outlet: @outlet, error: Rails.logger.info(@outlet.errors.inspect)}\n end\n # end\n end",
"def update\n @huerto = Huerto.find(params[:id])\n\n respond_to do |format|\n if @huerto.update_attributes(params[:huerto])\n format.html { redirect_to @huerto, notice: 'Huerto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @huerto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tobject = Tobject.find(params[:id])\n\n respond_to do |format|\n if @tobject.update_attributes(params[:tobject])\n format.html { redirect_to @tobject, notice: 'Tobject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tobject.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @teetime.update(teetime_params)\n\n render json: @teetime,status: :ok\n\n else\n\n render json: {error: true,errors: @teetime.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def update\n respond_to do |format|\n if @tarot.update(tarot_params)\n format.html { redirect_to @tarot, notice: 'Tarot was successfully updated.' }\n format.json { render :show, status: :ok, location: @tarot }\n else\n format.html { render :edit }\n format.json { render json: @tarot.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 @troop = Troop.find(params[:id])\n\n respond_to do |format|\n if @troop.update_attributes(params[:troop])\n format.html { redirect_to @troop, notice: 'Troop was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @troop.errors, status: :unprocessable_entity }\n end\n end\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 add_breadcrumb 'Update Trouble Ticket'\n\n respond_to do |format|\n if @troubleticket.update(troubleticket_params)\n format.html do\n redirect_to @troubleticket,\n notice: 'Trouble ticket was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @troubleticket }\n else\n format.html { render :edit , status: :unprocessable_entity }\n format.json do\n render json: @troubleticket.errors, status: :unprocessable_entity\n end\n end\n end\n end",
"def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end",
"def update\n # @user_trick = UserTrick.find(params[:id])\n @user_trick.update(user_trick_params)\n render json: UserTrickSerializer.new(@user_trick).serialized_json\n end",
"def put!\n request! :put\n end",
"def update\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n if @tags_of_novel.update_attributes(params[:tags_of_novel])\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ventum.update(ventum_params)\n format.html { redirect_to @ventum, notice: 'Venta fue modificado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tecido.update(tecido_params)\n format.html { redirect_to @tecido, notice: 'Tecido was successfully updated.' }\n format.json { render :show, status: :ok, location: @tecido }\n else\n format.html { render :edit }\n format.json { render json: @tecido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tattoo = Tattoo.find(params[:id])\n\n respond_to do |format|\n if @tattoo.update_attributes(params[:tattoo])\n format.html { redirect_to @tattoo, notice: 'Tattoo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tattoo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @trenton = Trenton.first\n\n respond_to do |format|\n if @trenton.update_attributes(params[:trenton])\n format.html { redirect_to about_path, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trenton.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket_owner = TicketOwner.find(params[:id])\n\n respond_to do |format|\n if @ticket_owner.update_attributes(params[:ticket_owner])\n format.html { redirect_to @ticket_owner, notice: 'Ticket Owner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @chronicle = Chronicle.find(params[:id])\n\n respond_to do |format|\n if @chronicle.update_attributes(params[:chronicle])\n format.html { redirect_to @chronicle, notice: 'Chronicle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chronicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ty.update(ty_params)\n format.html { redirect_to @ty, notice: 'Tie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cuentum = Cuentum.find(params[:id])\n\n respond_to do |format|\n if @cuentum.update_attributes(params[:cuentum])\n format.html { redirect_to @cuentum, :notice => 'Cuentum was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cuentum.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @t = T.find(params[:id])\n\n respond_to do |format|\n if @t.update_attributes(params[:t])\n format.html { redirect_to @t, notice: 'T was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @t.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if signed_in?\n @tourtable = Tourtable.find(params[:id])\n\n respond_to do |format|\n if @tourtable.update_attributes(params[:tourtable])\n format.html { redirect_to @tourtable, notice: 'Tourtable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tourtable.errors, status: :unprocessable_entity }\n end\n end\n end\nend",
"def update\n @kitten = Kitten.find(params[:id])\n\n respond_to do |format|\n if @kitten.update_attributes(params[:kitten])\n format.html { redirect_to @kitten, notice: 'Kitten was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitten.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tktest = Tktest.find(params[:id])\n\n respond_to do |format|\n if @tktest.update_attributes(params[:tktest])\n format.html { redirect_to @tktest, notice: 'Tktest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tktest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tprimarytumor.update(tprimarytumor_params)\n format.html { redirect_to @tprimarytumor, notice: 'tprimarytumor was successfully updated.' }\n format.json { render :show, status: :ok, location: @tprimarytumor }\n else\n format.html { render :edit }\n format.json { render json: @tprimarytumor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tiempo.update(tiempo_params)\n format.html { redirect_to @tiempo, notice: 'Tiempo was successfully updated.' }\n format.json { render :show, status: :ok, location: @tiempo }\n else\n format.html { render :edit }\n format.json { render json: @tiempo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kristine_toy.update(kristine_toy_params)\n format.html { redirect_to @kristine_toy, notice: 'Kristine toy was successfully updated.' }\n format.json { render :show, status: :ok, location: @kristine_toy }\n else\n format.html { render :edit }\n format.json { render json: @kristine_toy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n @microtask = Microtask.find(params[:id])\n\n respond_to do |format|\n if @microtask.update_attributes(params[:microtask])\n format.html { redirect_to @microtask, notice: 'Microtask was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microtask.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trainee.update(trainee_params)\n format.html { redirect_to @trainee, notice: 'Trainee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trainee.errors, status: :unprocessable_entity }\n end\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 @contract = Contract.find(params[:id])\n @units = Unit.unsold(params[:tower_id])\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to tower_contract_path(@contract.unit.tower, @contract), notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @taker = Taker.find(params[:id])\n\n respond_to do |format|\n if @taker.update_attributes(params[:taker])\n format.html { redirect_to @taker, notice: 'Taker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n if @tale.update(tale_params)#\n # prevention of identity theft\n @tale.user_id = current_user.id\n @tale.save \n format.html { redirect_to '/', notice: 'Tale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tale.errors, status: :unprocessable_entity }\n end\n\n\n\n\n\n end\n end",
"def update\n @torso = Torso.find(params[:id])\n\n respond_to do |format|\n if @torso.update_attributes(params[:torso])\n format.html { redirect_to @torso, notice: 'Torso was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @torso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tcredito.update(tcredito_params)\n format.html { redirect_to @tcredito, notice: 'Tcredito was successfully updated.' }\n format.json { render :show, status: :ok, location: @tcredito }\n else\n format.html { render :edit }\n format.json { render json: @tcredito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @trompler = Trompler.find(params[:id])\n\n respond_to do |format|\n if @trompler.update_attributes(params[:trompler])\n format.html { redirect_to @trompler, notice: 'Trompler was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trompler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @waiter = Waiter.find(params[:id])\n\n respond_to do |format|\n if @waiter.update_attributes(params[:waiter])\n format.html { redirect_to @waiter, notice: 'Waiter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @microposst.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n if @uchronia.update_attributes(params[:uchronia])\n format.html { redirect_to @uchronia, notice: 'Uchronia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uchronia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n data = tenant_update_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"customer_id\": @tenant.customer_id,\"user_type\": 0,\"name\": data[:name],\"phone\": data[:phone1],\"email\": data[:email],\"address\": data[:address],\"latitude\": data[:latitude],\"longitude\": data[:longitude]}\n response = RestClient.post \"https://api.tookanapp.com/v2/customer/edit\", tookan.to_json, :content_type => \"application/json\"\n response = JSON.parse(response)\n respond_to do |format|\n if response[\"status\"] == 200\n if @tenant.update(tenant_update_params)\n food_category = FoodCategory.find_or_create_by(name: \"Veg\")\n @tenant.tenant_details.update(food_category_id: food_category.id)\n if @tenant.active == true\n end\n end\n @tenant.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { redirect_to tenants_url, notice: 'Tenant was not updated.' }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.update_responsible(:status, 'Waiting for Staff Response')\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @toy_act = ToyAct.find(params[:id])\n\n respond_to do |format|\n if @toy_act.update_attributes(params[:toy_act])\n format.html { redirect_to @toy_act, :notice => 'Toy act was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @toy_act.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @stable = Stable.find(params[:id])\n\n respond_to do |format|\n if @stable.update_attributes(params[:stable])\n format.html { redirect_to @stable, notice: 'Stable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @taking.update(taking_params)\n format.html { redirect_to @taking, notice: 'Taking was successfully updated.' }\n format.json { render :show, status: :ok, location: @taking }\n else\n format.html { render :edit }\n format.json { render json: @taking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tailor.update(tailor_params)\n format.html { redirect_to @tailor, notice: \"Tailor was successfully updated.\" }\n format.json { render :show, status: :ok, location: @tailor }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @tailor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @testbed_owner = TestbedOwner.find(params[:id])\n\n respond_to do |format|\n if @testbed_owner.update_attributes(params[:testbed_owner])\n format.html { redirect_to @testbed_owner, notice: 'Testbed owner was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @testbed_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @tack = Tack.find(params[:id])\n\n if @tack.update(tack_params)\n head :no_content\n else\n render json: @tack.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bottle.update(bottle_params)\n format.html { redirect_to user_path(current_user.id), notice: 'Bottle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @templete = Templete.find(params[:id])\n\n respond_to do |format|\n if @templete.update_attributes(params[:templete])\n format.html { redirect_to @templete, :notice => 'Templete was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @templete.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n if @territorio.update_attributes(params[:territorio])\n format.html { redirect_to @territorio, notice: 'Territorio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @territorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tyre.update(tyre_params)\n format.html { redirect_to @tyre, notice: 'Tyre was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tyre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @utente = Utente.find(params[:id])\n\n respond_to do |format|\n if @utente.update_attributes(params[:utente])\n format.html { redirect_to @utente, notice: 'Utente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @utente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n respond_to do |format|\n if @tyc_human.update(tyc_human_params)\n format.html { redirect_to @tyc_human, notice: 'Human was successfully updated.' }\n format.json { render :show, status: :ok, location: @tyc_human }\n else\n format.html { render :edit }\n format.json { render json: @tyc_human.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # if @tossup.update(tossup_params)\n # render :show, status: :ok, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end",
"def update\n # if @tossup.update(tossup_params)\n # render :show, status: :ok, location: @tossup\n # else\n # render json: @tossup.errors, status: :unprocessable_entity\n # end\n end",
"def update\n @nut = Nut.find(params[:id])\n\n respond_to do |format|\n if @nut.update_attributes(params[:nut])\n format.html { redirect_to @nut, notice: 'Nut was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nut.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kontum.update(kontum_params)\n format.html { redirect_to @kontum, notice: 'Kontum was successfully updated.' }\n format.json { render :show, status: :ok, location: @kontum }\n else\n format.html { render :edit }\n format.json { render json: @kontum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @tuiter = current_user.tuiters.find(params[:id])\n respond_to do |format|\n if @tuiter.update(tuiter_params)\n format.html { redirect_to @tuiter, notice: 'Tuiter was successfully updated.' }\n format.json { render :show, status: :ok, location: @tuiter }\n else\n format.html { render :edit }\n format.json { render json: @tuiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n if @tecnico.update_attributes(params[:tecnico])\n format.html { redirect_to @tecnico, :notice => 'Tecnico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tecnico.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.62342656",
"0.6159337",
"0.6017543",
"0.5962537",
"0.5906415",
"0.58878356",
"0.58550674",
"0.58427715",
"0.58356863",
"0.58275104",
"0.57966566",
"0.5775827",
"0.57754874",
"0.5763261",
"0.5750018",
"0.5745397",
"0.57427526",
"0.5706849",
"0.567954",
"0.5678928",
"0.56729186",
"0.5672197",
"0.56689507",
"0.566807",
"0.565856",
"0.5655091",
"0.56536394",
"0.56474787",
"0.56470495",
"0.56351787",
"0.5627457",
"0.5609325",
"0.5604553",
"0.5598941",
"0.55959153",
"0.55955917",
"0.5591268",
"0.5590075",
"0.5588049",
"0.5581189",
"0.5574966",
"0.5573888",
"0.55706894",
"0.5569925",
"0.55600405",
"0.5549736",
"0.5549674",
"0.55489653",
"0.55445576",
"0.5544427",
"0.55413115",
"0.55375946",
"0.55375504",
"0.5537119",
"0.5536698",
"0.55353373",
"0.5531437",
"0.5528137",
"0.5522733",
"0.55205154",
"0.5516769",
"0.55154413",
"0.55105305",
"0.55056995",
"0.55055714",
"0.5499659",
"0.5498128",
"0.5497487",
"0.5496798",
"0.54962975",
"0.54955095",
"0.5492213",
"0.5491744",
"0.54906404",
"0.54905784",
"0.54896116",
"0.5489546",
"0.5489341",
"0.5484602",
"0.54821855",
"0.5481839",
"0.54804486",
"0.54799044",
"0.54780847",
"0.5470418",
"0.54700875",
"0.5469876",
"0.54664",
"0.54662",
"0.54661816",
"0.54653716",
"0.5465192",
"0.54535943",
"0.54535943",
"0.54535407",
"0.5453249",
"0.5452787",
"0.54503524",
"0.5450172",
"0.5450143"
] | 0.60361046 | 2 |
DELETE /tuberculoses/1 DELETE /tuberculoses/1.json | def destroy
@tuberculose.destroy
respond_to do |format|
format.html { redirect_to tuberculoses_url, notice: 'Tuberculose was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @uset = Uset.find(params[:id])\n @uset.destroy\n\n respond_to do |format|\n format.html { redirect_to usets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @toyotum.destroy\n respond_to do |format|\n format.html { redirect_to toyota_url, notice: 'Toyotum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tetramod = Tetramod.find(params[:id])\n @tetramod.destroy\n\n respond_to do |format|\n format.html { redirect_to tetramods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tatoo.destroy\n respond_to do |format|\n format.html { head :no_content }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chest_triceps1.destroy\n respond_to do |format|\n format.html { redirect_to chest_triceps1s_url, notice: 'Chest/Triceps 1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uginuce.sheep.update status:'na farmi'\n @uginuce.destroy\n respond_to do |format|\n format.html { redirect_to uginuces_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tenure = Tenure.find(params[:id])\n @tenure.destroy\n\n respond_to do |format|\n format.html { redirect_to tenures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @click_thru = ClickThru.find(params[:id])\n @click_thru.destroy\n\n respond_to do |format|\n format.html { redirect_to click_thrus_url }\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\r\n @usertable = Usertable.find(params[:id])\r\n @usertable.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to usertables_url }\r\n format.json { head :ok }\r\n end\r\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @tumor.destroy\n respond_to do |format|\n format.html { redirect_to tumors_url, notice: 'El registro se elimino con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tribe.destroy\n respond_to do |format|\n format.html { redirect_to tribes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tattoo = Tattoo.find(params[:id])\n @tattoo.destroy\n\n respond_to do |format|\n format.html { redirect_to tattoos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troll.destroy\n respond_to do |format|\n format.html { redirect_to dev_trolls_path(@dev) }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"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 @trumpet = Trumpet.find(params[:id])\n @trumpet.destroy\n\n respond_to do |format|\n format.html { redirect_to trumpets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uchronist = Uchronist.find(params[:id])\n @uchronist.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @male_shot_put_head.destroy\n respond_to do |format|\n format.html { redirect_to male_shot_put_heads_url, notice: 'Male shot put head was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trainee.destroy\n respond_to do |format|\n format.html { redirect_to trainees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def destroy\n @tuoshui = Tuoshui.find(params[:id])\n @tuoshui.destroy\n\n respond_to do |format|\n format.html { redirect_to tuoshuis_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thuoc.destroy\n respond_to do |format|\n format.html { redirect_to thuocs_url, notice: \"Thuoc was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thermostat.destroy\n respond_to do |format|\n format.html { redirect_to thermostats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hustle.destroy\n respond_to do |format|\n format.html { redirect_to hustles_url, notice: 'Hustle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trump.destroy\n respond_to do |format|\n format.html { redirect_to trumps_url, notice: 'Trump was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tattoo.destroy\n respond_to do |format|\n format.html { redirect_to tattoos_url, notice: 'Tattoo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stable = Stable.find(params[:id])\n @stable.destroy\n\n respond_to do |format|\n format.html { redirect_to stables_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tantosha.destroy\n # @tantosha.delete\n respond_to do |format|\n format.html { redirect_to tantoshas_url }\n format.json { head :no_content }\n end\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 destroy\n @tubuyaki.destroy\n respond_to do |format|\n format.html { redirect_to tubuyakis_url, notice: 'Tubuyaki was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alumno.destroy\n respond_to do |format|\n format.html { redirect_to grupos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tottle.destroy\n respond_to do |format|\n format.html { redirect_to tottles_url, notice: 'Tottle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @huerto = Huerto.find(params[:id])\n @huerto.destroy\n\n respond_to do |format|\n format.html { redirect_to huertos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tea = Tea.find(params[:id])\n @tea.destroy\n\n respond_to do |format|\n format.html { redirect_to teas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tea = Tea.find(params[:id])\n @tea.destroy\n\n respond_to do |format|\n format.html { redirect_to teas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rum = Rum.find(params[:id])\n @rum.destroy\n\n respond_to do |format|\n format.html { redirect_to rums_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @humanidades3 = Humanidades3.find(params[:id])\n @humanidades3.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades3s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cow.destroy\n respond_to do |format|\n format.html { redirect_to kine_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n current_admin_user\n @tablet = Tablet.find(params[:id])\n @tablet.destroy\n\n respond_to do |format|\n format.html { redirect_to tablets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'[email protected]_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @setum.destroy\n respond_to do |format|\n format.html { redirect_to seta_url, notice: 'Setum 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 destroy\n @turistum.destroy\n respond_to do |format|\n format.html { redirect_to turista_url, notice: 'Turistum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tombstone_timehold.destroy\n respond_to do |format|\n format.html { redirect_to tombstone_timeholds_url, notice: 'Tombstone timehold was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end",
"def destroy\n @harvest_trello = HarvestTrello.find(params[:id])\n @harvest_trello.destroy\n\n respond_to do |format|\n format.html { redirect_to harvest_trellos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @utente = Utente.find(params[:id])\n @utente.destroy\n\n respond_to do |format|\n format.html { redirect_to utenti_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tarot.destroy\n respond_to do |format|\n format.html { redirect_to tarots_url, notice: 'Tarot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stall.destroy\n respond_to do |format|\n format.html { redirect_to stalls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tyre.destroy\n respond_to do |format|\n format.html { redirect_to tyres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tapioca.destroy\n respond_to do |format|\n format.html { redirect_to tapiocas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rutum.destroy\n respond_to do |format|\n format.html { redirect_to ruta_url, notice: \"Rutum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @human = Human.find(params[:id])\n @human.destroy\n\n respond_to do |format|\n format.html { redirect_to humen_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cuentum = Cuentum.find(params[:id])\n @cuentum.destroy\n\n respond_to do |format|\n format.html { redirect_to cuenta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tea_club.destroy\n respond_to do |format|\n format.html { redirect_to tea_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trayectorium.destroy\n respond_to do |format|\n format.html { redirect_to trayectoria_url, notice: 'Trayectorium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @therapist = Therapist.find(params[:id])\n @therapist.destroy\n\n respond_to do |format|\n format.html { redirect_to therapists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sumit.destroy\n respond_to do |format|\n format.html { redirect_to sumits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if signed_in?\n @tourtable = Tourtable.find(params[:id])\n @tourtable.destroy\n\n respond_to do |format|\n format.html { redirect_to tourtables_url }\n format.json { head :no_content }\n end\n end\nend",
"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 @waitertable = WaiterTable.where(\"table_id = #{@table.id}\")\n @waitertable.delete_all\n @table.destroy\n respond_to do |format|\n format.html { redirect_to tables_url, notice: 'Mesa eliminada correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ty.destroy\n respond_to do |format|\n format.html { redirect_to ties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trumpet.destroy\n respond_to do |format|\n format.html { redirect_to trumpets_url, notice: 'Trumpet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beast.destroy\n respond_to do |format|\n format.html { redirect_to beasts_url, notice: 'Bestia została usunięta' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tangent.destroy\n respond_to do |format|\n format.html { redirect_to tangents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @strosek.destroy\n respond_to do |format|\n format.html { redirect_to stroseks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sche_t.destroy\n respond_to do |format|\n format.html { redirect_to sche_ts_url, notice: 'Sche t was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mueble.destroy\n respond_to do |format|\n format.html { redirect_to muebles_url, notice: 'Mueble was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tablet = Tablet.find(params[:id])\n @tablet.destroy\n\n respond_to do |format|\n format.html { redirect_to tablets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beattape = Beattape.find(params[:id])\n @beattape.destroy\n\n respond_to do |format|\n format.html { redirect_to beattapes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troop.destroy\n respond_to do |format|\n format.html { redirect_to troops_url, notice: 'Tropa exitosamente borrada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kontum.destroy\n respond_to do |format|\n format.html { redirect_to konta_url, notice: 'Kontum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tower = Tower.find(params[:id])\n @tower.destroy\n\n respond_to do |format|\n format.html { redirect_to towers_url }\n format.json { head :ok }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tecido.destroy\n respond_to do |format|\n format.html { redirect_to tecidos_url, notice: 'Tecido was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ujumbe.destroy\n respond_to do |format|\n format.html { redirect_to ujumbes_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7034478",
"0.6960446",
"0.69082654",
"0.6850429",
"0.6813731",
"0.6807011",
"0.6773395",
"0.6765198",
"0.6764767",
"0.6760868",
"0.67534345",
"0.67516494",
"0.6729735",
"0.6699983",
"0.66778886",
"0.6662065",
"0.66490984",
"0.6642172",
"0.6641188",
"0.66382045",
"0.66227305",
"0.6618089",
"0.66105366",
"0.66084385",
"0.6606685",
"0.6604442",
"0.6603138",
"0.65957755",
"0.65849894",
"0.65803194",
"0.65785944",
"0.65783644",
"0.6572835",
"0.6571302",
"0.6570497",
"0.6567881",
"0.6554311",
"0.65520126",
"0.65514207",
"0.6550953",
"0.65457356",
"0.6540709",
"0.65403545",
"0.65396565",
"0.65323305",
"0.65319514",
"0.65297097",
"0.65293217",
"0.6525537",
"0.6525537",
"0.65253586",
"0.6522931",
"0.6519594",
"0.6518662",
"0.6517597",
"0.6514839",
"0.65139",
"0.65123856",
"0.6510382",
"0.65084416",
"0.65030915",
"0.6501949",
"0.6501932",
"0.64992756",
"0.6497026",
"0.64967364",
"0.6496314",
"0.64961624",
"0.64929926",
"0.64924103",
"0.64909434",
"0.64870983",
"0.6486649",
"0.6480197",
"0.6477619",
"0.64754426",
"0.6472471",
"0.64714277",
"0.647092",
"0.6470725",
"0.6468002",
"0.6459338",
"0.64582473",
"0.6457314",
"0.6456751",
"0.6454594",
"0.64544666",
"0.6454439",
"0.64543515",
"0.6451338",
"0.6450598",
"0.6449877",
"0.64490175",
"0.6447177",
"0.644617",
"0.6444007",
"0.64428",
"0.64428",
"0.64419526",
"0.64395624"
] | 0.6925316 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_tuberculose
@tuberculose = Tuberculose.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 setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\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 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\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\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 init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def 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 setup\n #implement in subclass;\n end",
"def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; 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 setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def 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 call\n setup_context\n super\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.5330087",
"0.5311993",
"0.5297402",
"0.5296789",
"0.52957207",
"0.52596015",
"0.5245442",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5235431",
"0.5231888",
"0.5226663",
"0.52220625",
"0.5217086",
"0.52137345",
"0.5208314",
"0.5205469",
"0.5175606",
"0.5174914",
"0.5173361",
"0.51662856",
"0.5161792",
"0.51572216",
"0.5153063",
"0.5152982",
"0.5152632",
"0.51435786",
"0.5139829",
"0.51346594",
"0.511372",
"0.511372",
"0.51136476",
"0.51083213",
"0.5108011",
"0.5091935",
"0.5089297",
"0.5081576",
"0.50807106",
"0.50656676",
"0.50548106",
"0.50537366",
"0.505074",
"0.505074",
"0.5033361",
"0.5025158",
"0.5020441",
"0.5015611",
"0.50142473",
"0.5000281",
"0.50001067",
"0.49989453",
"0.4989465",
"0.4989465",
"0.4985425",
"0.49805096",
"0.49795893",
"0.49783278",
"0.49676263",
"0.49656346",
"0.49579078",
"0.4955427",
"0.49554235",
"0.49536413",
"0.49523768",
"0.49457142",
"0.49433607",
"0.4933641",
"0.49320185",
"0.49265638",
"0.49262375",
"0.49259067",
"0.4922456",
"0.49201223",
"0.49165115",
"0.49158815",
"0.49151883",
"0.49149552",
"0.4914386"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tuberculose_params
params.require(:tuberculose).permit(:form_laboratorio_id, :paciente_id, :tipo_de_muestra, :razon, :string, :mendico, :centro_de_salud, :observaciones)
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 /pharmas GET /pharmas.json | def index
@pharmas = Pharma.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @phlog = Phlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phlog }\n end\n end",
"def show\n @pharm = Pharm.find(params[:id])\n end",
"def show\n\t\t@pharmacy = Pharmacy.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @pharmacy }\n\t\tend\n\tend",
"def show\n @presenza = Presenza.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @presenza }\n end\n end",
"def index\n @parishes = Parish.all\n\n render json: @parishes\n end",
"def show\n @amplicon = Amplicon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @amplicon }\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n @pichanga = Pichanga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pichanga }\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 render json: @parish\n end",
"def show\n @psa = Psa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @psa }\n end\n end",
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def show\n @aroma = Aroma.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aroma }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def index\n @phones = Phone.all\n json_response(@phones)\n end",
"def show\n @patrocinio = Patrocinio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patrocinio }\n end\n end",
"def index\n @heroes = Hero.all\n\n render json: @heroes\n end",
"def show\n @papel = Papel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @papel }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end",
"def show\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ramal }\n end\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def show\n @publicaciones = Publicacione.find(params[:id])\n render json: @publicaciones, status: :ok\n end",
"def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end",
"def index\n @papels = Papel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @papels }\n end\n end",
"def index\n @prueba_jsons = PruebaJson.all\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 @shichoson = Shichoson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shichoson }\n end\n end",
"def show\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pony }\n end\n end",
"def show\n @jam = Jam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jam }\n end\n end",
"def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @phosphosite_type = PhosphositeType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phosphosite_type }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @micrrapost = Micrrapost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micrrapost }\n end\n end",
"def index\n @ramais = Ramal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ramais }\n end\n end",
"def show\n @reltramovano = Reltramovano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reltramovano }\n end\n end",
"def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end",
"def index\n champions = Champion.all\n render json: champions\n end",
"def index\n @symptoms = Symptom.all\n\n render json: @symptoms\n end",
"def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def show\n @photographer = Photographer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photographer }\n end\n end",
"def show\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @farm }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def index\n @himalayas = Himalaya.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @himalayas }\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 show\n @torso = Torso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torso }\n end\n end",
"def index\n @normas = Norma.all\n render json: @normas\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 @campanhas = Campanha.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @campanhas }\n end\n end",
"def show\n @photoid = Photoid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photoid }\n end\n end",
"def show\n @lugar = Lugar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lugar }\n end\n end",
"def index\n render json: Apartment.all\n end",
"def show\n @horace = Horace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horace }\n end\n end",
"def index\n @powiadomienia = Powiadomienie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @powiadomienia }\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 show\n @spaethi = Spaethi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spaethi }\n end\n end",
"def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end",
"def index\n authorize! :view_pharmacy, @pharmacys\n @pharmacys = Pharmacy.all\n end",
"def show\n render json: @lugar\n end",
"def show\n @campanha = Campanha.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @campanha }\n end\n end",
"def index\n @lugars = Lugar.all\n\n render json: @lugars\n end",
"def index\n @processos = Processo.all\n\n render json: @processos\n end",
"def show\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planner }\n end\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end",
"def show\n @hetong = Hetong.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hetong }\n end\n end",
"def show\n @moresmallmobsquad = Moresmallmobsquad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallmobsquad }\n end\n end",
"def show\n @palabras_buscar = PalabrasBuscar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @palabras_buscar }\n end\n end",
"def show\n @hackplatformrelation = Hackplatformrelation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hackplatformrelation }\n end\n end",
"def show\n @sala = Sala.find(params[:id])\n\n render json: @sala, root: \"data\", include: '**', adapter: :json, status: :ok\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 show\n @pinit = Pinit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinit }\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 show\n @himalaya = Himalaya.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @himalaya }\n end\n end",
"def show\n @sabor = Sabor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sabor }\n end\n end",
"def show\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @precious_metal }\n end\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end",
"def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end",
"def show\n @harvest_trello = HarvestTrello.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @harvest_trello }\n end\n end",
"def index\n @protectoras = Protectora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @protectoras }\n end\n end",
"def show\n @publicidad = Publicidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publicidad }\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 show\n @trabalho = Trabalho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trabalho }\n end\n end",
"def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end",
"def show\n @whattelpp = Whattelpp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @whattelpp }\n end\n end",
"def show\n @huerto = Huerto.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @horario = Horario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horario }\n end\n end",
"def index\n @slams = Slam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @slams }\n end\n end",
"def index\n respond_to do |format|\n format.json { render :json => Phrase.all }\n end\n end",
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @periodismo = Periodismo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @periodismo }\n end\n end",
"def show\n @prestador = Prestador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prestador }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end"
] | [
"0.6479799",
"0.6422723",
"0.6421849",
"0.6397673",
"0.63839346",
"0.63242126",
"0.62848365",
"0.6218878",
"0.6213666",
"0.6208553",
"0.62017393",
"0.6198759",
"0.61778975",
"0.6164403",
"0.616128",
"0.6150613",
"0.61449045",
"0.6138376",
"0.61362934",
"0.6135968",
"0.61357605",
"0.6121112",
"0.6115152",
"0.61061907",
"0.6101381",
"0.608646",
"0.60592014",
"0.60572",
"0.60520005",
"0.60498273",
"0.6043618",
"0.6037991",
"0.60375637",
"0.60367733",
"0.6017475",
"0.60160977",
"0.5990025",
"0.5974748",
"0.5969791",
"0.5967272",
"0.5963679",
"0.5958005",
"0.5955344",
"0.59548235",
"0.5950122",
"0.5950122",
"0.59455913",
"0.59398615",
"0.5935957",
"0.592304",
"0.59186715",
"0.59181434",
"0.5910727",
"0.5904502",
"0.59026796",
"0.58994514",
"0.58922344",
"0.5889811",
"0.58824897",
"0.5880767",
"0.5880532",
"0.5879813",
"0.58794516",
"0.58779347",
"0.586765",
"0.58652586",
"0.58645445",
"0.58619547",
"0.58619547",
"0.585988",
"0.5858441",
"0.58583146",
"0.5855573",
"0.5840581",
"0.5834287",
"0.5828536",
"0.5827567",
"0.5826133",
"0.5821495",
"0.5820532",
"0.58120555",
"0.580812",
"0.5807978",
"0.58071643",
"0.58053875",
"0.580338",
"0.580338",
"0.580338",
"0.5803314",
"0.5799613",
"0.57991165",
"0.579888",
"0.57957196",
"0.57905436",
"0.57894677",
"0.5788682",
"0.57876",
"0.5787397",
"0.5784759",
"0.578363"
] | 0.68925804 | 0 |
GET /pharmas/1 GET /pharmas/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @phlog = Phlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phlog }\n end\n end",
"def index\n @pharmas = Pharma.all\n end",
"def show\n @pharm = Pharm.find(params[:id])\n end",
"def show\n @presenza = Presenza.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @presenza }\n end\n end",
"def show\n @amplicon = Amplicon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @amplicon }\n end\n end",
"def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end",
"def show\n\t\t@pharmacy = Pharmacy.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @pharmacy }\n\t\tend\n\tend",
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end",
"def show\n @pichanga = Pichanga.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pichanga }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @jam = Jam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jam }\n end\n end",
"def show\n @phosphosite_type = PhosphositeType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phosphosite_type }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end",
"def show\n @patrocinio = Patrocinio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patrocinio }\n end\n end",
"def show\n @aroma = Aroma.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aroma }\n end\n end",
"def show\n @shichoson = Shichoson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shichoson }\n end\n end",
"def show\n @psa = Psa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @psa }\n end\n end",
"def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pony }\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 @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 @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ramal }\n end\n end",
"def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end",
"def show\n @papel = Papel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @papel }\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 show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @osoba = Osoba.find(params[:id])\n\n render json: @osoba\n end",
"def show\n @photoid = Photoid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photoid }\n end\n end",
"def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end",
"def show\n @hackplatformrelation = Hackplatformrelation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @hackplatformrelation }\n end\n end",
"def show\n @reltramovano = Reltramovano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reltramovano }\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\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 show\n @publicaciones = Publicacione.find(params[:id])\n render json: @publicaciones, status: :ok\n end",
"def index\n @parishes = Parish.all\n\n render json: @parishes\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @spaethi = Spaethi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spaethi }\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 show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @photographer = Photographer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photographer }\n end\n end",
"def index\n @phones = Phone.all\n json_response(@phones)\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @farm }\n end\n end",
"def show\n @periodismo = Periodismo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @periodismo }\n end\n end",
"def show\n @torso = Torso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torso }\n end\n end",
"def show\n @micrrapost = Micrrapost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @micrrapost }\n end\n end",
"def show\n render json: @parish\n end",
"def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end",
"def show\n @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 show\n @phone = Phone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phone }\n end\n end",
"def show\n @phone = Phone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phone }\n end\n end",
"def show\n @trabalho = Trabalho.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trabalho }\n end\n end",
"def show\n @horace = Horace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horace }\n end\n end",
"def show\n @lugar = Lugar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lugar }\n end\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end",
"def show\n @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 show\n @horario = Horario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horario }\n end\n end",
"def show\n @pinit = Pinit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinit }\n end\n end",
"def show\n @campanha = Campanha.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @campanha }\n end\n end",
"def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end",
"def show\n @huerto = Huerto.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end",
"def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @persona }\n end\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @peso }\n end\n end",
"def show\n @minicurso = Minicurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @minicurso }\n end\n end",
"def show\n @moresmallmobsquad = Moresmallmobsquad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallmobsquad }\n end\n end",
"def index\n @heroes = Hero.all\n\n render json: @heroes\n end",
"def show\n @precious_metal = PreciousMetal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @precious_metal }\n end\n end",
"def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end",
"def show\n @publicidad = Publicidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @publicidad }\n end\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def show\n @jamaat = Jamaat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jamaat }\n end\n end",
"def show\n @platform = Platform.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @platform }\n end\n end",
"def show\n @himalaya = Himalaya.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @himalaya }\n end\n end",
"def show\n @promo = Promo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promo }\n end\n end",
"def show\n @plannegocio = Plannegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plannegocio }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @planner = Planner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @planner }\n end\n end",
"def show\n @sabio = Sabio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sabio }\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 @ram = Ram.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ram }\n end\n end",
"def show\n @hetong = Hetong.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hetong }\n end\n end",
"def index\n @pizzas = Pizza.all\n render json: @pizzas\n end",
"def show\n @quiniela = Quiniela.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quiniela }\n end\n end",
"def show\n @palabras_buscar = PalabrasBuscar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @palabras_buscar }\n end\n end",
"def show\n @hasil = Hasil.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hasil }\n end\n end",
"def show\n @hospital = Hospital.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hospital }\n end\n end",
"def show\n @hydraulic_system = HydraulicSystem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hydraulic_system }\n end\n end",
"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 @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def show\n @spiel = Spiel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spiel }\n end\n end",
"def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end",
"def show\n @protein_complex = ProteinComplex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @protein_complex }\n end\n end",
"def show\n @webling = Webling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @webling }\n end\n end",
"def show\n @mostsmallmission = Mostsmallmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mostsmallmission }\n end\n end",
"def show\n @apuesta_detail = ApuestaDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apuesta_detail }\n end\n end"
] | [
"0.6703745",
"0.6700327",
"0.6653632",
"0.65828764",
"0.65435284",
"0.65236574",
"0.6495796",
"0.6471314",
"0.64363825",
"0.643502",
"0.64038706",
"0.64022493",
"0.6388125",
"0.6366552",
"0.63664764",
"0.6361207",
"0.6347709",
"0.6343804",
"0.6333667",
"0.632796",
"0.6320854",
"0.63170916",
"0.62991387",
"0.6295527",
"0.62935954",
"0.62781274",
"0.6258943",
"0.62581724",
"0.6256216",
"0.6232965",
"0.62295246",
"0.6229363",
"0.6226268",
"0.6218998",
"0.6210253",
"0.61971474",
"0.6195731",
"0.6192363",
"0.61838573",
"0.6179348",
"0.6172797",
"0.6168597",
"0.61608",
"0.614979",
"0.614979",
"0.6148449",
"0.6144075",
"0.6143404",
"0.61419004",
"0.6136509",
"0.6133596",
"0.6130871",
"0.6128864",
"0.6128864",
"0.6115114",
"0.6113929",
"0.6107104",
"0.6105374",
"0.6105374",
"0.6105078",
"0.6105078",
"0.6105078",
"0.61021096",
"0.61020476",
"0.61014324",
"0.60981673",
"0.60964423",
"0.60953236",
"0.6090355",
"0.6086132",
"0.6084672",
"0.60844827",
"0.6079826",
"0.60783",
"0.6077855",
"0.6073455",
"0.6070844",
"0.60705125",
"0.60685533",
"0.6068512",
"0.60668266",
"0.6065378",
"0.60559744",
"0.6050431",
"0.60498977",
"0.6044123",
"0.6040059",
"0.6033914",
"0.6031519",
"0.6031363",
"0.6026491",
"0.60236377",
"0.60226357",
"0.6022587",
"0.60211176",
"0.6019346",
"0.60149217",
"0.6014348",
"0.6013693",
"0.6012719",
"0.60126454"
] | 0.0 | -1 |
POST /pharmas POST /pharmas.json | def create
@pharma = Pharma.new(pharma_params)
respond_to do |format|
if @pharma.save
format.html { redirect_to @pharma, notice: 'Pharma was successfully created.' }
format.json { render :show, status: :created, location: @pharma }
else
format.html { render :new }
format.json { render json: @pharma.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pharm = Pharm.new(pharm_params)\n @pharm.user_id = current_user.id\n\n respond_to do |format|\n if @pharm.save\n format.html { redirect_to @pharm, notice: 'Pharm was successfully created.' }\n format.json { render :show, status: :created, location: @pharm }\n else\n format.html { render :new }\n format.json { render json: @pharm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmacy = Pharmacy.new(pharmacy_params)\n respond_to do |format|\n if @pharmacy.save\n format.json { render :show, status: :created, location: @pharmacy }\n else\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @parish = Parish.new(parish_params)\n\n if @parish.save\n render json: @parish, status: :created, location: @parish\n else\n render json: @parish.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\t@pharmacy = Pharmacy.new(params[:pharmacy])\n\n\t\trespond_to do |format|\n\t\t\tif @pharmacy.save\n\t\t\t\tformat.html { redirect_to @pharmacy, notice: 'Pharmacy was successfully created.' }\n\t\t\t\tformat.json { render json: @pharmacy, status: :created, location: @pharmacy }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @phonenumber = Phonenumber.new(params[:phonenumber])\n\n if @phonenumber.save\n render json: @phonenumber, status: :created, location: @phonenumber\n else\n render json: @phonenumber.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @presenza = Presenza.new(params[:presenza])\n\n respond_to do |format|\n if @presenza.save\n format.html { redirect_to @presenza, notice: 'Presenza was successfully created.' }\n format.json { render json: @presenza, status: :created, location: @presenza }\n else\n format.html { render action: \"new\" }\n format.json { render json: @presenza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manga = Manga.new(manga_params)\n\n respond_to do |format|\n if @manga.save\n format.html { redirect_to @manga, notice: 'Manga was successfully created.' }\n format.json { render :show, status: :created, location: @manga }\n else\n format.html { render :new }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pharma_params\n params.require(:pharma).permit(:name, :hsopitalname)\n end",
"def create\n @pharmaceuticalform = Pharmaceuticalform.new(pharmaceuticalform_params)\n\n respond_to do |format|\n if @pharmaceuticalform.save\n format.html { redirect_to @pharmaceuticalform, notice: 'Pharmaceuticalform was successfully created.' }\n format.json { render :show, status: :created, location: @pharmaceuticalform }\n else\n format.html { render :new }\n format.json { render json: @pharmaceuticalform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prueba_json = PruebaJson.new(prueba_json_params)\n\n respond_to do |format|\n if @prueba_json.save\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prueba_json }\n else\n format.html { render action: 'new' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def 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 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 @pichanga = Pichanga.new(params[:pichanga])\n\n respond_to do |format|\n if @pichanga.save\n format.html { redirect_to @pichanga, :notice => 'Pichanga was successfully created.' }\n format.json { render :json => @pichanga, :status => :created, :location => @pichanga }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @pichanga.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @plate = Plate.new(params[:plate])\n\n if @plate.save\n render json: @plate, status: :created, location: @plate\n else\n render json: @plate.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 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 @prestamo = Prestamo.new(prestamo_params)\n\n respond_to do |format|\n if @prestamo.save\n format.html { redirect_to @prestamo, notice: \"Prestamo was successfully created.\" }\n format.json { render :show, status: :created, location: @prestamo }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @prestamo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @psa = Psa.new(params[:psa])\n\n respond_to do |format|\n if @psa.save\n format.html { redirect_to @psa, notice: 'Psa was successfully created.' }\n format.json { render json: @psa, status: :created, location: @psa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @psa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pockemon = Pockemon.new(pockemon_params)\n\n respond_to do |format|\n if @pockemon.save\n format.html { redirect_to @pockemon, notice: 'Pockemon was successfully created.' }\n format.json { render :show, status: :created, location: @pockemon }\n else\n format.html { render :new }\n format.json { render json: @pockemon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmaceutical_master = PharmaceuticalMaster.new(pharmaceutical_master_params)\n\n respond_to do |format|\n if @pharmaceutical_master.save\n format.html { redirect_to @pharmaceutical_master, notice: CREATE_NOTICE }\n format.json { render :show, status: :created, location: @pharmaceutical_master }\n else\n format.html { render :new }\n format.json { render json: @pharmaceutical_master.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmacy = Pharmacy.new(params[:pharmacy])\n\n respond_to do |format|\n if @pharmacy.save\n flash[:notice] = 'Pharmacy was successfully created.'\n format.html { redirect_to(@pharmacy) }\n format.xml { render :xml => @pharmacy, :status => :created, :location => @pharmacy }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pharmacy.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 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",
"def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, :notice => 'Premio was successfully created.' }\n format.json { render :json => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @pinjam = Pinjam.new(pinjam_params)\n\n respond_to do |format|\n if @pinjam.save\n format.html { redirect_to @pinjam, notice: 'Pinjam was successfully created.' }\n format.json { render :show, status: :created, location: @pinjam }\n else\n format.html { render :new }\n format.json { render json: @pinjam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def process_post\n service.sign_up_fisherman(\n JSON.parse(request.body.to_s).symbolize_keys\n ).on(\n fishing_application_succeeded: ->(result) {\n response.headers['Content-Type'] = \"application/json\"\n response.body = result.to_json\n true\n },\n fishing_application_conflicts: ->(result) {\n render_json_error_response(\n error: \"command_failed_validation\", message: result.fetch(:message)\n )\n 409\n },\n fishing_application_invalid: ->(result) {\n render_json_error_response(\n error: \"command_failed_validation\", message: result.fetch(:message)\n )\n 422\n }\n )\n end",
"def create\n @amplicon = Amplicon.new(params[:amplicon])\n\n respond_to do |format|\n if @amplicon.save\n format.html { redirect_to @amplicon, notice: 'Amplicon was successfully created.' }\n format.json { render json: @amplicon, status: :created, location: @amplicon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @amplicon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @marca = Marca.new(marca_params)\n if @marca.save\n render json: @marca\n else\n render json: @marca.errors, status: :unprocessable_entity \n end\n end",
"def create\n @phonetic = Phonetic.new(phonetic_params)\n\n respond_to do |format|\n if @phonetic.save\n format.html { redirect_to @phonetic, notice: 'Phonetic was successfully created.' }\n format.json { render :show, status: :created, location: @phonetic }\n else\n format.html { render :new }\n format.json { render json: @phonetic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n apartment = Apartment.create(apartment_params)\n render json: apartment\n end",
"def create\n @arma = Arma.new(params[:arma])\n\n respond_to do |format|\n if @arma.save\n format.html { redirect_to @arma, notice: 'Arma was successfully created.' }\n format.json { render json: @arma, status: :created, location: @arma }\n else\n format.html { render action: \"new\" }\n format.json { render json: @arma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phonetic_test = PhoneticTest.new(phonetic_test_params)\n\n respond_to do |format|\n if @phonetic_test.save\n format.html { redirect_to @phonetic_test, notice: 'Phonetic test was successfully created.' }\n format.json { render :show, status: :created, location: @phonetic_test }\n else\n format.html { render :new }\n format.json { render json: @phonetic_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @micrrapost = Micrrapost.new(params[:micrrapost])\n\n respond_to do |format|\n if @micrrapost.save\n format.html { redirect_to @micrrapost, notice: 'Micrrapost was successfully created.' }\n format.json { render json: @micrrapost, status: :created, location: @micrrapost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @micrrapost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @policeman = Policeman.new(policeman_params)\n\n respond_to do |format|\n if @policeman.save\n format.html { redirect_to @policeman, notice: \"Policía creado con éxito.\" }\n format.json { render :show, status: :created, location: @policeman }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @policeman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pharm_params\n params.require(:pharm).permit(:commune, :pharma_name, :owner_name, :description, :tel, :lat, :long, :h_openning, :h_closing, :garde, :star_date, :end_date)\n end",
"def create\n megam_rest.post_appdefn(to_hash)\n end",
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n @pautum = Pautum.new(pautum_params)\n\n respond_to do |format|\n if @pautum.save\n format.html { redirect_to @pautum, notice: 'Pautum was successfully created.' }\n format.json { render :show, status: :created, location: @pautum }\n else\n format.html { render :new }\n format.json { render json: @pautum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promocion = Promocion.new(params[:promocion])\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully created.' }\n format.json { render json: @promocion, status: :created, location: @promocion }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def create\n @farm = Farm.new(params[:farm])\n @farm.save\n respond_with(@farm)\n end",
"def create\n @ram_post = RamPost.new(ram_post_params)\n\n respond_to do |format|\n if @ram_post.save\n format.html { redirect_to @ram_post, notice: 'Ram post was successfully created.' }\n format.json { render :show, status: :created, location: @ram_post }\n else\n format.html { render :new }\n format.json { render json: @ram_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phile = Phile.new(params[:phile])\n\n respond_to do |format|\n if @phile.save\n format.html { redirect_to @phile, notice: 'Phile was successfully created.' }\n format.json { render json: @phile, status: :created, location: @phile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @phile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @osoba = Osoba.new(params[:osoba])\n\n if @osoba.save\n render json: @osoba, status: :created, location: @osoba\n else\n render json: @osoba.errors, status: :unprocessable_entity\n end\n end",
"def create\n @prospecto_meta_mediano_plazo = ProspectoMetaMedianoPlazo.new(prospecto_meta_mediano_plazo_params)\n\n respond_to do |format|\n if @prospecto_meta_mediano_plazo.save\n format.html { redirect_to @prospecto_meta_mediano_plazo, notice: 'Prospecto meta mediano plazo was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto_meta_mediano_plazo }\n else\n format.html { render :new }\n format.json { render json: @prospecto_meta_mediano_plazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pimo = Pimo.new(pimo_params)\n\n respond_to do |format|\n if @pimo.save\n format.html { redirect_to @pimo, notice: 'Pimo was successfully created.' }\n format.json { render :show, status: :created, location: @pimo }\n else\n format.html { render :new }\n format.json { render json: @pimo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thuctap = Thuctap.new(thuctap_params)\n respond_to do |format|\n if @thuctap.save\n format.html { redirect_to @thuctap, notice: 'Thuctap was successfully created.' }\n format.json { render :show, status: :created, location: @thuctap }\n else\n format.html { render :new }\n format.json { render json: @thuctap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promocion = Promocion.new(promocion_params)\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, notice: 'Promocion ha sido creado.' }\n format.json { render :show, status: :created, location: @promocion }\n else\n format.html { render :new }\n format.json { render json: @promocion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, notice: 'Premio was successfully created.' }\n format.json { render json: @premio, status: :created, location: @premio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ramal = Ramal.new(params[:ramal])\n\n respond_to do |format|\n if @ramal.save\n format.html { redirect_to @ramal, notice: 'Ramal criado com sucesso!' }\n format.json { render json: @ramal, status: :created, location: @ramal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ramal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plan_quirurgico = PlanQuirurgico.new(plan_quirurgico_params)\n @plan_quirurgico.servicios = params[:servicios]\n @plan_quirurgico.estatus = \"En Proceso\"\n puts params\n puts @plan_quirurgico.examen \n respond_to do |format|\n if @plan_quirurgico.save\n format.html { redirect_to @plan_quirurgico, notice: 'El plan quirurgico fue registrado exitosamente.' }\n format.json { render :show, status: :created, location: @plan_quirurgico }\n else\n format.html { render :new }\n format.json { render json: @plan_quirurgico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @parjo = Parjo.new(parjo_params)\n\n respond_to do |format|\n if @parjo.save\n format.html { redirect_to @parjo, notice: 'Parjo was successfully created.' }\n format.json { render :show, status: :created, location: @parjo }\n else\n format.html { render :new }\n format.json { render json: @parjo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.create(post_params)\n puts \"LLLLLOOOOOOOLLLLLL\"\n puts current_usuario.to_json\n @post = current_usuario.posts.create(post_params)\n \n @post.sangre = current_usuario.tipoDeSangre\n\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alumno = Alumno.new(params[:alumno])\n\n respond_to do |format|\n if @alumno.save\n render json: @alumno.as_json(include: :persona), status: :created, location: @alumno\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n @armazena = Armazena.new(armazena_params)\n\n respond_to do |format|\n if @armazena.save\n format.html { redirect_to @armazena, notice: 'Armazena was successfully created.' }\n format.json { render :show, status: :created, location: @armazena }\n else\n format.html { render :new }\n format.json { render json: @armazena.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @palabra_bolsa = PalabraBolsa.new(palabra_bolsa_params)\n\n respond_to do |format|\n if @palabra_bolsa.save\n format.html { redirect_to @palabra_bolsa, notice: 'Palabra bolsa was successfully created.' }\n format.json { render :show, status: :created, location: @palabra_bolsa }\n else\n format.html { render :new }\n format.json { render json: @palabra_bolsa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @horario_alarma = HorarioAlarma.new(horario_alarma_params)\n\n respond_to do |format|\n if @horario_alarma.save\n format.html { redirect_to @horario_alarma, notice: 'Horario alarma was successfully created.' }\n format.json { render :show, status: :created, location: @horario_alarma }\n else\n format.html { render :new }\n format.json { render json: @horario_alarma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @placa = Placa.new(placa_params)\n\n respond_to do |format|\n if @placa.save\n format.html { redirect_to @placa, notice: 'Placa was successfully created.' }\n format.json { render action: 'show', status: :created, location: @placa }\n else\n format.html { render action: 'new' }\n format.json { render json: @placa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tipoapreensao = Tipoapreensao.new(tipoapreensao_params)\n\n respond_to do |format|\n if @tipoapreensao.save\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipoapreensao }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lugar = Lugar.new(lugar_params)\n\n if @lugar.save\n render json: @lugar, status: :created, location: @lugar\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end",
"def create\n @galactic_arm = Galacticarm.new(galactic_arm_params)\n\n respond_to do |format|\n if @galactic_arm.save\n format.html { redirect_to @galactic_arm, notice: 'Galactic arm was successfully created.' }\n format.json { render :show, status: :created, location: @galactic_arm }\n else\n format.html { render :new }\n format.json { render json: @galactic_arm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phone = Phone.create!(valid_params)\n json_response(@phone, :created)\n end",
"def create\n @plasmid_probe = PlasmidProbe.new(plasmid_probe_params)\n\n respond_to do |format|\n if @plasmid_probe.save\n format.html { redirect_to @plasmid_probe, notice: 'Plasmid probe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @plasmid_probe }\n else\n format.html { render action: 'new' }\n format.json { render json: @plasmid_probe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phosphosite_type = PhosphositeType.new(params[:phosphosite_type])\n\n respond_to do |format|\n if @phosphosite_type.save\n format.html { redirect_to @phosphosite_type, notice: 'Phosphosite type was successfully created.' }\n format.json { render json: @phosphosite_type, status: :created, location: @phosphosite_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @phosphosite_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n @asama_tanim = AsamaTanim.new(asama_tanim_params)\n\n respond_to do |format|\n if @asama_tanim.save\n format.html { redirect_to @asama_tanim, notice: 'Asama tanim was successfully created.' }\n format.json { render :show, status: :created, location: @asama_tanim }\n else\n format.html { render :new }\n format.json { render json: @asama_tanim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @paradigm_praat = ParadigmPraat.new(paradigm_praat_params[:paradigm_praat])\n\n respond_to do |format|\n if @paradigm_praat.save\n format.html { redirect_to @paradigm_praat, notice: 'Paradigm praat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @paradigm_praat }\n else\n format.html { render action: 'new' }\n format.json { render json: @paradigm_praat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @minnpaku = Minnpaku.new(minnpaku_params)\n\n respond_to do |format|\n if @minnpaku.save\n format.html { redirect_to @minnpaku, notice: 'Minnpaku was successfully created.' }\n format.json { render :show, status: :created, location: @minnpaku }\n else\n format.html { render :new }\n format.json { render json: @minnpaku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @panneau = Panneau.new(panneau_params)\n\n respond_to do |format|\n if @panneau.save\n format.html { redirect_to @panneau, notice: 'Panneau was successfully created.' }\n format.json { render :show, status: :created, location: @panneau }\n else\n format.html { render :new }\n format.json { render json: @panneau.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @platoon = Platoon.new(platoon_params)\n\n respond_to do |format|\n if @platoon.save\n format.html { redirect_to @platoon, notice: 'Platoon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @platoon }\n else\n format.html { render action: 'new' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hanghoa = Hanghoa.new(hanghoa_params)\n\n respond_to do |format|\n if @hanghoa.save\n format.html { redirect_to @hanghoa, notice: \"Hanghoa was successfully created.\" }\n format.json { render :show, status: :created, location: @hanghoa }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @hanghoa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @masut_assay = MasutAssay.new(params[:masut_assay])\n\n respond_to do |format|\n if @masut_assay.save\n format.html { redirect_to masut_assays_url, notice: 'Данные нового анализа мазута успешно записаны.' }\n format.json { render json: @masut_assay, status: :created, location: @masut_assay }\n else\n format.html { render action: \"new\" }\n format.json { render json: @masut_assay.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pingguodingshirenwu = Pingguodingshirenwu.new(pingguodingshirenwu_params)\n\n respond_to do |format|\n if @pingguodingshirenwu.save\n format.html { redirect_to @pingguodingshirenwu, notice: 'Pingguodingshirenwu was successfully created.' }\n format.json { render :show, status: :created, location: @pingguodingshirenwu }\n else\n format.html { render :new }\n format.json { render json: @pingguodingshirenwu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pendaftaran_kela = PendaftaranKela.new(pendaftaran_kela_params)\n\n respond_to do |format|\n if @pendaftaran_kela.save\n format.html { redirect_to @pendaftaran_kela, notice: 'Pendaftaran kela was successfully created.' }\n format.json { render :show, status: :created, location: @pendaftaran_kela }\n else\n format.html { render :new }\n format.json { render json: @pendaftaran_kela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prospecto_meta_largo_plazo = ProspectoMetaLargoPlazo.new(prospecto_meta_largo_plazo_params)\n\n respond_to do |format|\n if @prospecto_meta_largo_plazo.save\n format.html { redirect_to @prospecto_meta_largo_plazo, notice: 'Prospecto meta largo plazo was successfully created.' }\n format.json { render :show, status: :created, location: @prospecto_meta_largo_plazo }\n else\n format.html { render :new }\n format.json { render json: @prospecto_meta_largo_plazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @asana = Asana.new(asana_params)\n\n respond_to do |format|\n if @asana.save\n format.html { redirect_to @asana, notice: 'Asana criado com sucesso.' }\n format.json { render :show, status: :created, location: @asana }\n else\n format.html { render :new }\n format.json { render json: @asana.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pocetna = Pocetna.new(pocetna_params)\n\n respond_to do |format|\n if @pocetna.save\n format.html { redirect_to @pocetna, notice: \"Pocetna was successfully created.\" }\n format.json { render :show, status: :created, location: @pocetna }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @pocetna.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, status: :created, location: @agronomiaquimica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @the_rasp = TheRasp.new(the_rasp_params)\n\n respond_to do |format|\n if @the_rasp.save\n format.html { redirect_to @the_rasp, notice: 'The rasp was successfully created.' }\n format.json { render :show, status: :created, location: @the_rasp }\n else\n format.html { render :new }\n format.json { render json: @the_rasp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @spaethi = Spaethi.new(params[:spaethi])\n\n respond_to do |format|\n if @spaethi.save\n format.html { redirect_to @spaethi, notice: 'Spaethi was successfully created.' }\n format.json { render json: @spaethi, status: :created, location: @spaethi }\n else\n format.html { render action: \"new\" }\n format.json { render json: @spaethi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @thema = Thema.new(thema_params)\n\n respond_to do |format|\n if @thema.save\n format.html { redirect_to @thema, notice: 'Thema was successfully created.' }\n format.json { render action: 'show', status: :created, location: @thema }\n else\n format.html { render action: 'new' }\n format.json { render json: @thema.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torso = Torso.new(params[:torso])\n\n respond_to do |format|\n if @torso.save\n format.html { redirect_to @torso, notice: 'Torso was successfully created.' }\n format.json { render json: @torso, status: :created, location: @torso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @torso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @postavka = Postavka.new(postavka_params)\n\n respond_to do |format|\n if @postavka.save\n format.html { redirect_to @postavka, notice: 'Postavka was successfully created.' }\n format.json { render action: 'show', status: :created, location: @postavka }\n else\n format.html { render action: 'new' }\n format.json { render json: @postavka.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @Empresa = Empresa.find(params[:empresa_id])\n p simulacion_params[:id]\n if simulacion_params[:id]!=nil\n respond_to do |format| \n format.html { render json: 1 and return}\n end\n end\n [email protected](simulacion_params)\n respond_to do |format|\n if simulacion.save\n format.html { render json: {simulacion:simulacion}}\n else\n format.html { render action: simulacion.errors }\n end\n end\n end",
"def create\n @processo = Processo.new(processo_params)\n\n if @processo.save\n render json: @processo, status: :created, location: @processo\n else\n render json: @processo.errors, status: :unprocessable_entity\n end\n end",
"def create\n @farm = Farm.new(farm_params)\n\n if @farm.save\n render :show, status: :created, location: api_farm_url(@farm)\n else\n render json: @farm.errors, status: :unprocessable_entity\n end\n end",
"def create\n @apertura_moneda = AperturaMoneda.new(apertura_moneda_params)\n\n respond_to do |format|\n if @apertura_moneda.save\n format.html { redirect_to @apertura_moneda, notice: 'Apertura moneda was successfully created.' }\n format.json { render :show, status: :created, location: @apertura_moneda }\n else\n format.html { render :new }\n format.json { render json: @apertura_moneda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ponderacion = Ponderacion.new(ponderacion_params)\n\n respond_to do |format|\n if @ponderacion.save\n format.html { redirect_to @ponderacion, notice: 'Ponderacion was successfully created.' }\n format.json { render :show, status: :created, location: @ponderacion }\n else\n format.html { render :new }\n format.json { render json: @ponderacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ahoogah = Ahoogah.new(ahoogah_params)\n\n respond_to do |format|\n if @ahoogah.save\n format.html { redirect_to @ahoogah, notice: 'Ahoogah was successfully created.' }\n format.json { render :show, status: :created, location: @ahoogah }\n else\n format.html { render :new }\n format.json { render json: @ahoogah.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @plataform = Plataform.new(plataform_params)\n\n respond_to do |format|\n if @plataform.save\n format.html { redirect_to @plataform, notice: 'Plataform was successfully created.' }\n format.json { render :show, status: :created, location: @plataform }\n else\n format.html { render :new }\n format.json { render json: @plataform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pharmaceuticalform_params\n params.require(:pharmaceuticalform).permit(:name)\n end",
"def create\n @shichoson = Shichoson.new(params[:shichoson])\n\n respond_to do |format|\n if @shichoson.save\n format.html { redirect_to @shichoson, notice: 'Shichoson was successfully created.' }\n format.json { render json: @shichoson, status: :created, location: @shichoson }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shichoson.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torneo_apartura = TorneoApartura.new(torneo_apartura_params)\n\n respond_to do |format|\n if @torneo_apartura.save\n format.html { redirect_to @torneo_apartura, notice: 'Torneo apartura was successfully created.' }\n format.json { render :show, status: :created, location: @torneo_apartura }\n else\n format.html { render :new }\n format.json { render json: @torneo_apartura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @exam = Exam.new(exam_params)\n @exam.patient = @patient\n\n if @exam.save\n render json: @exam, include: [:point_po, :point_or, :point_n, :point_a], methods: :maxillary_depth_angle, status: :created\n else\n render json: @exam.errors, status: :unprocessable_entity\n end\n end",
"def create\n @pro_asphalt = ProAsphalt.new(pro_asphalt_params)\n\n respond_to do |format|\n if @pro_asphalt.save\n format.html { redirect_to pro_asphalts_path(@pro_asphalt), notice: 'Pro asphalt was successfully created.' }\n format.json { render :show, status: :created, location: @pro_asphalt }\n else\n format.html { render :new }\n format.json { render json: @pro_asphalt.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.66720706",
"0.66034615",
"0.6332219",
"0.61596787",
"0.61153233",
"0.5994991",
"0.59933317",
"0.5993134",
"0.595828",
"0.5924629",
"0.5921499",
"0.5913209",
"0.5893331",
"0.5881247",
"0.58505136",
"0.5849291",
"0.5835567",
"0.5826907",
"0.5820701",
"0.5779027",
"0.577251",
"0.5770727",
"0.57693434",
"0.57672906",
"0.57646275",
"0.575245",
"0.5722463",
"0.57177657",
"0.57137793",
"0.5710011",
"0.5709386",
"0.5701911",
"0.57014173",
"0.56866866",
"0.5685287",
"0.5677498",
"0.5676962",
"0.56752545",
"0.5674191",
"0.56713283",
"0.56701934",
"0.5659997",
"0.5641688",
"0.5637206",
"0.562985",
"0.5625103",
"0.5622153",
"0.56179774",
"0.56150347",
"0.56026185",
"0.55908513",
"0.5577924",
"0.55722225",
"0.5571277",
"0.5569593",
"0.55689126",
"0.5566237",
"0.55652344",
"0.55618125",
"0.5560435",
"0.5558932",
"0.5558138",
"0.5556869",
"0.55544823",
"0.55510855",
"0.5544729",
"0.55417335",
"0.5535447",
"0.5529704",
"0.5521967",
"0.55212003",
"0.5514932",
"0.55130064",
"0.5511898",
"0.55113655",
"0.55112976",
"0.55051214",
"0.55016094",
"0.5501581",
"0.5498557",
"0.5492269",
"0.5488956",
"0.54875034",
"0.54847497",
"0.54842347",
"0.54812264",
"0.5480268",
"0.5477862",
"0.5477602",
"0.5476245",
"0.54744244",
"0.54715425",
"0.54697055",
"0.5464317",
"0.54637694",
"0.5462599",
"0.545832",
"0.54572815",
"0.54558235",
"0.5455708"
] | 0.6895389 | 0 |
PATCH/PUT /pharmas/1 PATCH/PUT /pharmas/1.json | def update
respond_to do |format|
if @pharma.update(pharma_params)
format.html { redirect_to @pharma, notice: 'Pharma was successfully updated.' }
format.json { render :show, status: :ok, location: @pharma }
else
format.html { render :edit }
format.json { render json: @pharma.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pharm = Pharm.find(params[:id])\n respond_to do |format|\n if @pharm.update(pharm_params)\n format.html { redirect_to @pharm, notice: 'Pharm was successfully updated.' }\n format.json { render :show, status: :ok, location: @pharm }\n else\n format.html { render :edit }\n format.json { render json: @pharm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @pharmacy.update(pharmacy_params)\n format.json { render :show, status: :ok, location: @pharmacy }\n else\n format.json { render json: @pharmacy.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 api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @pharmaceutical_master.update(pharmaceutical_master_params)\n format.html { redirect_to @pharmaceutical_master, notice: UPDATE_NOTICE }\n format.json { render :show, status: :ok, location: @pharmaceutical_master }\n else\n format.html { render :edit }\n format.json { render json: @pharmaceutical_master.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 put!\n request! :put\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 @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.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 patch!\n request! :patch\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end",
"def 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_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\n respond_to do |format|\n if @pharmaceuticalform.update(pharmaceuticalform_params)\n format.html { redirect_to @pharmaceuticalform, notice: 'Pharmaceuticalform was successfully updated.' }\n format.json { render :show, status: :ok, location: @pharmaceuticalform }\n else\n format.html { render :edit }\n format.json { render json: @pharmaceuticalform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @placa.update(placa_params)\n format.html { redirect_to @placa, notice: 'Placa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @placa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @homeroom.update(homeroom_params)\n format.html { redirect_to @homeroom, notice: 'Homeroom was successfully updated.' }\n format.json { render :show, status: :ok, location: @homeroom }\n else\n format.html { render :edit }\n format.json { render json: @homeroom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @phonenumber = Phonenumber.find(params[:id])\n\n if @phonenumber.update(params[:phonenumber])\n head :no_content\n else\n render json: @phonenumber.errors, status: :unprocessable_entity\n end\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @manifesto_promise.update(manifesto_promise_params)\n format.html { redirect_to @manifesto_promise, notice: 'Manifesto promise was successfully updated.' }\n format.json { render :show, status: :ok, location: @manifesto_promise }\n else\n format.html { render :edit }\n format.json { render json: @manifesto_promise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospecto_meta_largo_plazo.update(prospecto_meta_largo_plazo_params)\n format.html { redirect_to @prospecto_meta_largo_plazo, notice: 'Prospecto meta largo plazo was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto_meta_largo_plazo }\n else\n format.html { render :edit }\n format.json { render json: @prospecto_meta_largo_plazo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @phonetic.update(phonetic_params)\n format.html { redirect_to @phonetic, notice: 'Phonetic was successfully updated.' }\n format.json { render :show, status: :ok, location: @phonetic }\n else\n format.html { render :edit }\n format.json { render json: @phonetic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manga = Manga.find(params[:id])\n\n respond_to do |format|\n if @manga.update_attributes(params[:manga])\n format.html { redirect_to @manga, notice: 'Manga was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @parish = Parish.find(params[:id])\n\n if @parish.update(parish_params)\n head :no_content\n else\n render json: @parish.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @thuctap.update(thuctap_params)\n format.html { redirect_to @thuctap, notice: 'Thuctap was successfully updated.' }\n format.json { render :show, status: :ok, location: @thuctap }\n else\n format.html { render :edit }\n format.json { render json: @thuctap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @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 @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @farm = Farm.find(params[:id])\n\n respond_to do |format|\n if @farm.update_attributes(params[:farm])\n format.html { redirect_to @farm, notice: 'Farm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @farm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n # respond_to do |format|\n # if @thing.update(thing_params)\n # format.html { redirect_to @thing, notice: 'Thing was successfully updated.' }\n # format.json { render :show, status: :ok, location: @thing }\n # else\n # format.html { render :edit }\n # format.json { render json: @thing.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pony = Pony.find(params[:id])\n\n respond_to do |format|\n if @pony.update_attributes(params[:pony])\n format.html { redirect_to @pony, notice: 'Pony was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pony.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 @presenza = Presenza.find(params[:id])\n\n respond_to do |format|\n if @presenza.update_attributes(params[:presenza])\n format.html { redirect_to @presenza, notice: 'Presenza was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @presenza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @houmon.update(houmon_params)\n format.html { redirect_to @houmon, notice: 'Houmon was successfully updated.' }\n format.json { render :show, status: :ok, location: @houmon }\n else\n format.html { render :edit }\n format.json { render json: @houmon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @pichanga = Pichanga.find(params[:id])\n\n respond_to do |format|\n if @pichanga.update_attributes(params[:pichanga])\n format.html { redirect_to @pichanga, :notice => 'Pichanga was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @pichanga.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n if @tipo_pregunta.update(params[:tipo_pregunta])\n head :no_content\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @slam = Slam.find(params[:id])\n \n respond_to do |format|\n if @slam.update_attributes(params[:slam])\n format.html { redirect_to @slam, notice: 'Fixed up!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @slam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plasmid_probe.update(plasmid_probe_params)\n format.html { redirect_to @plasmid_probe, notice: 'Plasmid probe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plasmid_probe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @hospice.update(hospice_params)\n format.html { redirect_to @hospice, notice: 'Hospice was successfully updated.' }\n format.json { render :show, status: :ok, location: @hospice }\n else\n format.html { render :edit }\n format.json { render json: @hospice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @cephalopod.update(cephalopod_params)\n format.html { redirect_to @cephalopod, notice: 'Cephalopod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cephalopod.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n @amplicon = Amplicon.find(params[:id])\n\n respond_to do |format|\n if @amplicon.update_attributes(params[:amplicon])\n format.html { redirect_to @amplicon, notice: 'Amplicon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @amplicon.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 @bla = Bla.find(params[:id])\n\n respond_to do |format|\n if @bla.update_attributes(params[:bla])\n format.html { redirect_to @bla, :notice => 'Bla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bla.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @phone.update(phone_params)\n format.html { redirect_to phones_path, notice: 'Phone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @phone.errors, status: :unprocessable_entity }\n end\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 @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 respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @protein_complex = ProteinComplex.find(params[:id])\n\n respond_to do |format|\n if @protein_complex.update_attributes(params[:protein_complex])\n format.html { redirect_to @protein_complex, notice: 'Protein complex was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @protein_complex.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @thing = Thing.find(params[:id])\n\n respond_to do |format|\n if @thing.update_attributes(params[:thing])\n format.html { redirect_to things_path, notice: 'Your thing was successfully updated!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @parola.update(parola_params)\n format.html { redirect_to parolas_url, notice: 'Parola was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @parola.errors, status: :unprocessable_entity }\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 patch\n end",
"def update\n @photoid = Photoid.find(params[:id])\n\n respond_to do |format|\n if @photoid.update_attributes(params[:photoid])\n format.html { redirect_to @photoid, notice: 'Photoid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photoid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to personas_path, notice: 'Persona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, **args); end",
"def update\n @phone = Phone.find(params[:id])\n if Rails::VERSION::MAJOR > 5\n mtd = :update\n else\n mtd = :update_attributes\n end\n\n respond_to do |format|\n if @phone.send(mtd, phone_params)\n format.html { redirect_to @phone, notice: 'Phone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @phone.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 update\n @foam = Foam.find(params[:id])\n\n respond_to do |format|\n if @foam.update_attributes(params[:foam])\n format.html { redirect_to @foam, notice: 'Foam was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @foam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n apartment = Apartment.find(params[:id])\n apartment.update_attributes(apartment_params)\n render json: apartment\n end",
"def update\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n if @repa.update_attributes(params[:repa])\n format.html { redirect_to @repa, notice: 'Repa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end",
"def update\n respond_to do |format|\n if @hoho.update(hoho_params)\n format.html { redirect_to @hoho, notice: 'Hoho was successfully updated.' }\n format.json { render :show, status: :ok, location: @hoho }\n else\n format.html { render :edit }\n format.json { render json: @hoho.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @male_shot_put_head.update(male_shot_put_head_params)\n format.html { redirect_to @male_shot_put_head, notice: 'Male shot put head was successfully updated.' }\n format.json { render :show, status: :ok, location: @male_shot_put_head }\n else\n format.html { render :edit }\n format.json { render json: @male_shot_put_head.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loph.update(loph_params)\n format.html { redirect_to @loph, notice: 'Loph was successfully updated.' }\n format.json { render :show, status: :ok, location: @loph }\n else\n format.html { render :edit }\n format.json { render json: @loph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n if @sphere.update_attributes(params[:sphere])\n format.html { redirect_to @sphere, notice: 'Sphere a été édité avec succès.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n @symptom = Symptom.find(params[:id])\n\n if @symptom.update(symptom_params)\n render json: @symptom, status: :updated\n else\n render json: @symptom.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @plate.update(plate_params)\n format.html { redirect_to [@client, @budget, @mobile], notice: 'Chapa atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @plate }\n else\n format.html { render :edit }\n format.json { render json: @plate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trophy.update(trophy_params)\n format.html { redirect_to @trophy, notice: 'Trophy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trophy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @single_housing.update(single_housing_params)\n format.html { redirect_to @single_housing, notice: 'Single housing was successfully updated.' }\n format.json { render :show, status: :ok, location: @single_housing }\n else\n format.html { render :edit }\n format.json { render json: @single_housing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @lunch.update(lunch_params)\n format.html { redirect_to @lunch, notice: 'Lunch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lunch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pizzatopping.update(pizzatopping_params)\n format.html { redirect_to @pizzatopping, notice: 'Pizzatopping was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pizzatopping.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_method\n :put_json\n end",
"def update\n @spaethi = Spaethi.find(params[:id])\n\n respond_to do |format|\n if @spaethi.update_attributes(params[:spaethi])\n format.html { redirect_to @spaethi, notice: 'Spaethi was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spaethi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mohr.update(mohr_params)\n format.html { redirect_to @mohr, notice: 'Mohr was successfully updated.' }\n format.json { render :show, status: :ok, location: @mohr }\n else\n format.html { render :edit }\n format.json { render json: @mohr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hackplatformrelation = Hackplatformrelation.find(params[:id])\n\n respond_to do |format|\n if @hackplatformrelation.update_attributes(params[:hackplatformrelation])\n format.html { redirect_to @hackplatformrelation, :notice => 'Hackplatformrelation was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @hackplatformrelation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tap.update(tap_params)\n format.html { redirect_to taps_path, notice: 'Tap was successfully updated.' }\n format.json { head :no_content }\n else\n format.json { render json: @tap.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n if @ramal.update_attributes(params[:ramal])\n format.html { redirect_to @ramal, notice: 'Ramal alterado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ramal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@pharmacy = Pharmacy.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @pharmacy.update_attributes(params[:pharmacy])\n\t\t\t\tformat.html { redirect_to @pharmacy, notice: 'Pharmacy was successfully updated.' }\n\t\t\t\tformat.json { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update_attr\n #sanity checks \n @persona = current_persona\n @mediaset = @persona.mediasets.find(params[:id])\n \n respond_to do |format|\n @mediaset.update_attributes( params[:mediaset] )\n format.json{ respond_with_bip(@mediaset) }\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n respond_to do |format|\n if @manga.update(manga_params)\n format.html { redirect_to @manga, notice: 'Manga was successfully updated.' }\n format.json { render :show, status: :ok, location: @manga }\n else\n format.html { render :edit }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @phone.update(phone_params)\n format.html { redirect_to @phone, notice: 'Phone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @phone.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6336532",
"0.6231755",
"0.6189727",
"0.61738074",
"0.61282563",
"0.60966814",
"0.6094203",
"0.6090823",
"0.6073731",
"0.6050702",
"0.60389566",
"0.60285115",
"0.6013566",
"0.5987759",
"0.594626",
"0.5922043",
"0.5915093",
"0.5915093",
"0.59119517",
"0.59048057",
"0.58823335",
"0.58804405",
"0.5866278",
"0.5848483",
"0.58473164",
"0.5840135",
"0.58295393",
"0.58137685",
"0.5807163",
"0.58060384",
"0.57979155",
"0.5781314",
"0.5775494",
"0.576546",
"0.576546",
"0.576546",
"0.5764449",
"0.57543105",
"0.5752785",
"0.5752785",
"0.574847",
"0.57438886",
"0.57438886",
"0.57432014",
"0.57429886",
"0.5742089",
"0.57410896",
"0.57391936",
"0.57286674",
"0.57276386",
"0.5710614",
"0.57089716",
"0.5706538",
"0.5702471",
"0.57018924",
"0.56985885",
"0.5698062",
"0.5697778",
"0.5696697",
"0.5687912",
"0.56871784",
"0.56808776",
"0.56804574",
"0.5680098",
"0.56777567",
"0.56743497",
"0.5669762",
"0.56644845",
"0.5662331",
"0.56600004",
"0.5659883",
"0.56562686",
"0.565623",
"0.56560653",
"0.56543374",
"0.5645599",
"0.56450343",
"0.56441885",
"0.5641006",
"0.5640769",
"0.5639381",
"0.5639208",
"0.5638651",
"0.5637394",
"0.56353617",
"0.56340736",
"0.56333345",
"0.56326234",
"0.56318086",
"0.56295997",
"0.56286544",
"0.5627125",
"0.56270486",
"0.56240666",
"0.5622238",
"0.5620258",
"0.561957",
"0.56190753",
"0.56189716",
"0.5617686"
] | 0.62516516 | 1 |
DELETE /pharmas/1 DELETE /pharmas/1.json | def destroy
@pharma.destroy
respond_to do |format|
format.html { redirect_to pharmas_url, notice: 'Pharma was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pharm = Pharm.find(params[:id])\n @pharm.destroy\n respond_to do |format|\n format.html { redirect_to pharms_url, notice: 'Pharm was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @manga = Manga.find(params[:id])\n @manga.destroy\n\n respond_to do |format|\n format.html { redirect_to mangas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmaceutical_master.destroy\n respond_to do |format|\n format.html { redirect_to pharmaceutical_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"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 @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 @farmacium.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\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 delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 @rishabh.destroy\n respond_to do |format|\n format.html { redirect_to rishabhs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @himalaya.destroy\n\n respond_to do |format|\n format.html { redirect_to himalayas_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 @himalaya = Himalaya.find(params[:id])\n @himalaya.destroy\n\n respond_to do |format|\n format.html { redirect_to himalayas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aquarium = Aquarium.find(params[:id])\n @aquarium.destroy\n\n respond_to do |format|\n format.html { redirect_to aquaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@phone.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @ramal = Ramal.find(params[:id])\n @ramal.destroy\n\n respond_to do |format|\n format.html { redirect_to ramais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @midia.destroy\n\n respond_to do |format|\n format.html { redirect_to midias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @walikela.destroy\n respond_to do |format|\n format.html { redirect_to walikelas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shouldersbicepshome3.destroy\n respond_to do |format|\n format.html { redirect_to shouldersbicepshome3s_url, notice: 'Shouldersbicepshome3 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end",
"def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end",
"def destroy\n @shichoson = Shichoson.find(params[:id])\n @shichoson.destroy\n\n respond_to do |format|\n format.html { redirect_to shichosons_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @amplicon = Amplicon.find(params[:id])\n @amplicon.destroy\n\n respond_to do |format|\n format.html { redirect_to amplicons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thuctap.destroy\n respond_to do |format|\n format.html { redirect_to thuctaps_url, notice: 'Thuctap was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @galactic_arm.destroy\n respond_to do |format|\n format.html { redirect_to galactic_arms_url, notice: 'Galactic arm was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @surah.destroy\n respond_to do |format|\n format.html { redirect_to surahs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tantosha.destroy\n # @tantosha.delete\n respond_to do |format|\n format.html { redirect_to tantoshas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pichanga = Pichanga.find(params[:id])\n @pichanga.destroy\n\n respond_to do |format|\n format.html { redirect_to pichangas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jam = Jam.find(params[:id])\n @jam.destroy\n\n respond_to do |format|\n format.html { redirect_to jams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"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 @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @placa.destroy\n respond_to do |format|\n format.html { redirect_to placas_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 @asthenium.destroy\n respond_to do |format|\n format.html { redirect_to asthenia_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manga.destroy\n respond_to do |format|\n format.html { redirect_to mangas_url, notice: 'Manga was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manga.destroy\n respond_to do |format|\n format.html { redirect_to mangas_url, notice: 'Manga was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @homeroom.destroy\n respond_to do |format|\n format.html { redirect_to homerooms_url, notice: 'Homeroom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @astronomium.destroy\n respond_to do |format|\n format.html { redirect_to astronomia_url, notice: 'Astronomium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @phlog = Phlog.find(params[:id])\n @phlog.destroy\n\n respond_to do |format|\n format.html { redirect_to phlogs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @antropo.destroy\n respond_to do |format|\n format.html { redirect_to antropos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @samochod.destroy\n respond_to do |format|\n format.html { redirect_to samochods_url, notice: 'Samochod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @presenza = Presenza.find(params[:id])\n @presenza.destroy\n\n respond_to do |format|\n format.html { redirect_to presenze_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pharmacy = Pharmacy.find(params[:id])\n @pharmacy.destroy\n\n respond_to do |format|\n format.html { redirect_to(pharmacies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @phile = Phile.find(params[:id])\n @phile.destroy\n\n respond_to do |format|\n format.html { redirect_to philes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shouldersbiceps1.destroy\n respond_to do |format|\n format.html { redirect_to shouldersbiceps1s_url, notice: 'Shouldersbiceps1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @galinha.destroy\n respond_to do |format|\n format.html { redirect_to galinhas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kishangarh_marble.destroy\n respond_to do |format|\n format.html { redirect_to kishangarh_marbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @protein_complex = ProteinComplex.find(params[:id])\n @protein_complex.destroy\n\n respond_to do |format|\n format.html { redirect_to protein_complexes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jamaat = Jamaat.find(params[:id])\n @jamaat.destroy\n\n respond_to do |format|\n format.html { redirect_to jamaats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @obsah.destroy\n respond_to do |format|\n format.html { redirect_to obsahs_url, notice: 'Obsah was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sabio = Sabio.find(params[:id])\n @sabio.destroy\n\n respond_to do |format|\n format.html { redirect_to sabios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @aroma = Aroma.find(params[:id])\n @aroma.destroy\n\n respond_to do |format|\n format.html { redirect_to aromas_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gatha.destroy\n respond_to do |format|\n format.html { redirect_to gathas_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @prestamo.destroy\n respond_to do |format|\n format.html { redirect_to prestamos_url, notice: \"Prestamo was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @pinglun = Pinglun.find(params[:id])\n @pinglun.destroy\n\n respond_to do |format|\n format.html { redirect_to pingluns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_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 @ahoogah.destroy\n respond_to do |format|\n format.html { redirect_to ahoogahs_url, notice: 'Ahoogah was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @musica.audios.purge\n @musica.destroy\n respond_to do |format|\n format.html { redirect_to musicas_url, notice: 'Álbum apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arma = Arma.find(params[:id])\n @arma.destroy\n\n respond_to do |format|\n format.html { redirect_to armas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @houmon.destroy\n respond_to do |format|\n format.html { redirect_to houmons_url, notice: 'Houmon was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @makrana_marble.destroy\n respond_to do |format|\n format.html { redirect_to makrana_marbles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rayon = Rayon.find(params[:id])\n @rayon.destroy\n\n respond_to do |format|\n format.html { redirect_to rayons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n head :no_content\n end",
"def destroy\n @unique_whiteline.destroy\n respond_to do |format|\n format.html { redirect_to unique_whitelines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verb.destroy\n\n head :no_content\n end",
"def destroy\n @malarium.destroy\n respond_to do |format|\n format.html { redirect_to malaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @waldo.destroy\n respond_to do |format|\n format.html { redirect_to waldos_url, notice: 'Waldo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thre.destroy\n respond_to do |format|\n format.html { redirect_to thres_url, notice: 'Thre was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medalha.destroy\n respond_to do |format|\n format.html { redirect_to medalhas_url, notice: 'Medalha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thirtyone.destroy\n respond_to do |format|\n format.html { redirect_to thirtyones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ambush = Ambush.find(params[:id])\n @ambush.destroy\n\n respond_to do |format|\n format.html { redirect_to ambushes_url }\n format.json { head :ok }\n end\n end"
] | [
"0.70930415",
"0.7069602",
"0.7018399",
"0.6955611",
"0.6899932",
"0.6857838",
"0.6847263",
"0.68359846",
"0.6833831",
"0.6815114",
"0.6804892",
"0.67765373",
"0.676942",
"0.6760427",
"0.67448163",
"0.6741097",
"0.67396224",
"0.67310315",
"0.6724449",
"0.67188543",
"0.67162967",
"0.671477",
"0.6712814",
"0.67028165",
"0.66991365",
"0.6694927",
"0.6694927",
"0.6686407",
"0.66855145",
"0.66852003",
"0.6684447",
"0.66837186",
"0.6680807",
"0.66749674",
"0.667397",
"0.6671429",
"0.66692495",
"0.6668131",
"0.6666551",
"0.6666551",
"0.6662346",
"0.6657173",
"0.6657173",
"0.66563064",
"0.66558087",
"0.6650574",
"0.66446054",
"0.66401666",
"0.66401666",
"0.6639129",
"0.663541",
"0.66310996",
"0.66281646",
"0.6627504",
"0.6626612",
"0.66257775",
"0.6621748",
"0.66216195",
"0.66216195",
"0.6621321",
"0.6620811",
"0.6616658",
"0.66161853",
"0.6611919",
"0.66107744",
"0.66065943",
"0.6600237",
"0.6598241",
"0.6594565",
"0.65939236",
"0.6593587",
"0.65928197",
"0.6590492",
"0.65868676",
"0.65830827",
"0.658209",
"0.65790844",
"0.65788925",
"0.6576655",
"0.657636",
"0.6576221",
"0.6574712",
"0.65722495",
"0.65706444",
"0.65706444",
"0.65676945",
"0.6565639",
"0.65652883",
"0.65635395",
"0.6563425",
"0.65622157",
"0.6561879",
"0.6561129",
"0.65605175",
"0.655492",
"0.6553367",
"0.6553103",
"0.65507185",
"0.6545072",
"0.65442926"
] | 0.70656323 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_pharma
@pharma = Pharma.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 pharma_params
params.require(:pharma).permit(:name, :hsopitalname)
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 strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"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 url_whitelist; 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 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 sensitive_params=(params)\n @sensitive_params = params\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\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 maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\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 backend_user_params\n params.permit!\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 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.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.62905645",
"0.6289235",
"0.6283876",
"0.62425834",
"0.62410337",
"0.6218672",
"0.62151134",
"0.62096137",
"0.6192354",
"0.6178057",
"0.6177618",
"0.61727077",
"0.6162073",
"0.6152049",
"0.61515594",
"0.61458135",
"0.6122875",
"0.61165285",
"0.6107696",
"0.6104097",
"0.6091097",
"0.6080201",
"0.60699946",
"0.6063739",
"0.60206395",
"0.60169303",
"0.60134894",
"0.601003",
"0.6007347",
"0.6007347",
"0.6001054",
"0.59997267",
"0.5997844",
"0.5991826",
"0.5991213",
"0.59911627",
"0.5980111",
"0.5967009",
"0.59597385",
"0.5958542",
"0.595787",
"0.5957425",
"0.59522784",
"0.5951228",
"0.59423685",
"0.5939385",
"0.5939122",
"0.5939122",
"0.59325653",
"0.5930178",
"0.59248054",
"0.59243476",
"0.59164625",
"0.59106",
"0.59101933",
"0.59084356",
"0.5905666",
"0.58975077",
"0.58974737",
"0.5895128",
"0.58946574",
"0.589308",
"0.58916",
"0.5885987",
"0.58838505",
"0.58792",
"0.58723736",
"0.58684355",
"0.58677715",
"0.5865701",
"0.5865538",
"0.5865288",
"0.586385",
"0.5862139",
"0.58614355",
"0.58593005",
"0.5857459",
"0.58541363",
"0.58536613",
"0.58520085",
"0.585011"
] | 0.0 | -1 |
GET /message_outs GET /message_outs.json | def index
@message_outs = MessageOut.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @outmessages = Outmessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outmessages }\n end\n end",
"def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end",
"def smssend\n http = get_http_connection() \n post_args = { 'number' => params[:number], 'text' => params[:text],'replyto' => params[:replyto], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n \n request = Net::HTTP::Post.new('/messages/out.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def new\n @outmessage = Outmessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @outmessage }\n end\n end",
"def messages\n get_json('messages.json')\n end",
"def outgoings\n @patient=User.find_by_wedgetail(params[:wedgetail],:order =>\"created_at DESC\")\n authorize_only (:patient) {@patient.wedgetail == @user.wedgetail}\n authorize :user\n @narrative = Narrative.find(params[:id])\n @outgoings = @narrative.outgoing_messages\n end",
"def show\n @outmessage = Outmessage.find(params[:id])\n respond_to do |format|\n format.html {\n render :layout => false\n }# show.html.erb\n format.json { \n render :json => @outmessage\n\n message = Message.new\n message.origin = \"DEVICE\"\n message.message = @outmessage.message\n message.timestamp = (Time.now.to_i)*1000\n message.user = @outmessage.user\n message.destination = @outmessage.destination\n message.save\n\n @outmessage.destroy }\n end\n end",
"def index\n @messages = current_user.received_messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = current_user.received_messages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def set_message_out\n @message_out = MessageOut.find(params[:id])\n end",
"def destroy\n @message_out.destroy\n respond_to do |format|\n format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def create\n @message_out = MessageOut.new(message_out_params)\n\n respond_to do |format|\n if @message_out.save\n format.html { redirect_to @message_out, notice: 'Message out was successfully created.' }\n format.json { render :show, status: :created, location: @message_out }\n else\n format.html { render :new }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @outmessage = Outmessage.find(params[:id])\n @outmessage.destroy\n\n respond_to do |format|\n format.html { redirect_to outmessages_url }\n format.json { head :ok }\n end\n end",
"def index\n @outs = Out.all\n end",
"def index\n @messages = Message.all\n\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def outbox\n cur_emp = get_logged_employee\n @messages = Message.where(\"sent_by = ?\", cur_emp).where(:is_deleted => nil) \n render \"resumes/message_show\"\n end",
"def index\n @messages = Message.find_all_by_user_id(session[:user_id], :order => \"timestamp DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @messages }\n end\n end",
"def outbox\n\n #handle new signatures\n @general_signature = params[:general_signature]\n @gw_signature = params[:gw_signature]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unsent_messages }\n end\n end",
"def index\n @messages = Room.find(params['room_id']).messages\n end",
"def sent_messages\n get('/direct_messages/sent.json')\n end",
"def visit_inbox\n get '/messages'\n end",
"def outbox\r\n @messages = current_user.outbox_messages\r\n session[:mail_box] = \"outbox\"\r\n render :action => \"messages\"\r\n end",
"def index\n @messages = message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def read_all_messages\n post(\"/api/read_all_messages\")\n end",
"def shouts(event)\n get(:standard, {:method => \"event.getShouts\", :event => event})\n end",
"def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end",
"def inbox\n @messages = current_user.received_messages\n respond_with @messages\n end",
"def index\n\t\t@messages = Message.all.order('created_at DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend",
"def index\n @messages = Message.order(\"time desc\").page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def message_from_mentee_outreach\n MenteeOutreachResponse.process_text(params)\n render :text => ''\n end",
"def index\n render json: Message.all\n end",
"def msg_arnoldbot\n uri = URI(\"https://arnoldbot-api.herokuapp.com/talk?msg=\"+params[:msg])\n resp = Net::HTTP.get(uri)\n render json: resp\n end",
"def show\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outgoing_message_log }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n raise ApiAccessEvanta::PermissionDenied unless AppSettings::Value.new(:messages, user: current_user).on?\n @messages = Message.get_message_list(current_user)\n render json: @messages\n end",
"def index\n\t\t@messages = Message.where(:to_user => current_user.id)\n\t\trespond_with(@messages) \n\tend",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @messages}\n end\n end",
"def messages\n Client.get(EVENTS_PATH, {\n recipient: @email_address\n })\n end",
"def index\n workouts = @ws.workouts\n render json: workouts\n end",
"def smsmark\n http = get_http_connection() \n post_args = { 'ids' => params[:ids], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n request = Net::HTTP::Post.new('/messages/in.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def index\n @messages = current_user.messages_in.order('created_at ASC').group('sender_id')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def update\n respond_to do |format|\n if @message_out.update(message_out_params)\n format.html { redirect_to @message_out, notice: 'Message out was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_out }\n else\n format.html { render :edit }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def direct_messages(params = {})\n get \"direct_messages\", params\n end",
"def index\n # @messages = Message.message_in_area(params[:latitude], params[:longitude], current_user.message_zone).main_information\n\t @messages = Message.all\n render json: @messages\n end",
"def show\n respond_to do |format|\n format.html {\n @messages = Message.find_all_by_user_id(session[:user_id], :conditions => [\"origin=? OR destination=?\",params[:id],params[:id]], :order => \"timestamp ASC\")\n @outmessages = Outmessage.find_all_by_user_id(session[:user_id], :conditions => [\"destination=?\",params[:id]])\n @number = params[:id]\n @ajax_refresh = params[:ajaxrefresh]\n render :layout => false\n }# show.html.erb\n format.json { \n @message = Message.find(params[:id])\n render :json => @message }\n end\n end",
"def unseen\n messages = current_user.received_messages.where(seen: false)\n render json: messages\n end",
"def show\n out = Out.find(params[:id])\n respond_to do |format|\n format.json {\n render :json => out, :layout => false\n }\n end\n end",
"def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end",
"def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end",
"def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentor_messages }\n end\n end",
"def index\n @messages = apply_scopes(scope.messages)\n @messages.read!\n respond_to do |format|\n format.html {\n redirect_to action: :inbox\n }\n format.json\n format.js\n end\n end",
"def new\n @messaging_outbox = Messaging::Outbox.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messaging_outbox }\n end\n end",
"def index\n @messages = Message.where(\" messages.room_id = ? and messages.to is NULL\", params[:room_id])\n totalMessages = (@messages.size>10) ? 9 : @messages.size\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages.reverse[0..totalMessages].reverse }\n end\n end",
"def show\n\t\t@messages = Message.where(recipient: params[:id]).order('created_at DESC')\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend",
"def direct_messages_sent(params = {})\n get \"direct_messages/sent\", params\n end",
"def index\n @messages = current_user.received_messages.paginate(:page => params[:page])\n @title = \"Входящие сообщения\"\n @path = \"index\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def new\n @outgoing_message_log = OutgoingMessageLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @outgoing_message_log }\n end\n end",
"def index\n #@messages = Message.all\n \n @messages = Message.page(params[:page]).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n if params[:last_message_id]\n @messages = Message.includes(:user).where(\"id > ?\", params[:last_message_id])\n else\n @messages = Message.includes(:user).limit(5).order(:created_at).reverse_order\n end\n\n @message_data = []\n @messages.each do |message|\n @message_data.push({\n :id => message.id,\n :user => message.user.name,\n :content => message.content\n })\n end\n \n respond_to do |format|\n format.json { render :json => @message_data}\n end\n end",
"def get_messages where = \"inbox\", opts = {}\n query = {\n mark: false\n }\n query.merge! opts\n get(\"/message/#{where}.json\", query: query)\n end",
"def messages\n end",
"def messages\n end",
"def index\n @channel = Channel.find(params[:channel_id])\n time = params[:ts] || 2.hours.ago\n @messages = @channel.messages.created_after(time)\n\n render json: @messages\n end",
"def destroy\n @messaging_outbox = Messaging::Outbox.find(params[:id])\n @messaging_outbox.destroy\n\n respond_to do |format|\n format.html { redirect_to messaging_outboxes_url }\n format.json { head :ok }\n end\n end",
"def receivedMessagesToUser\n render json: Message.where(receiver_id: params[:id], created_at: (Time.now - 30.day)..Time.now).limit(100)\n end",
"def process_outbox\n messages = @redis.lrange(OUTBOX, 0, @redis.llen(OUTBOX))\n while message = messages.delete_at(0)\n begin\n log_message(\"Message is #{message.inspect}\")\n message_hash = JSON.parse(message)\n socket_id = message_hash[\"socket_id\"]\n original_message = message_hash[\"message\"].to_json\n socket = @sockets[socket_id]\n send_to_socket(socket, original_message)\n rescue\n log_message(\"Message Failure: #{message}\")\n end\n end\n true\n end",
"def message_out_params\n params.require(:message_out).permit(:content)\n end",
"def index\n @messages = Rails.cache.fetch('all_messages', :expires_in => 30.seconds) do\n Message.all\n end\n\n respond_to do |format|\n format.json { render json: @messages }\n end\n end",
"def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end",
"def index\n @messages = current_user.received_messages\n @messages = @messages.order(created_at: :desc)\n @messages = @messages.paginate(page: params[:page], per_page:5)\n @messages = @messages.to_a\n end",
"def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end",
"def show\n\n render json: @message\n\n end",
"def show\n render_json :entry => @message\n end",
"def message(message)\n render json: {\n message: message,\n status: :success\n }, status: 200\n end",
"def index\n\n @outgoings = Outgoing.order(updated_at: :desc).limit(50)\n @outgoings_count = Outgoing.where(:status => 'INSERTED').count\n respond_to do |format|\n \tformat.html\n#\tformat.csv { send_data Outgoing.where(\"EXISTS (select * from answers where INSTR(telephone, contact) = 0)\").to_csv, filename: \"autodialer-#{Date.today}.csv\" } \n format.csv { send_data Outgoing.all.to_csv, filename: \"autodialer-#{Date.today}.csv\" } \n format.json { render :json => Outgoing.where.not(:trank => nil).as_json(only: [:id, :trank_id])}\n end\n end",
"def show\n render json: @inbox\n end",
"def receivedMessagesFromSender\n render json: Message.where(receiver_id: params[:id_1].to_i, sender_id: params[:id_2].to_i, created_at: (Time.now - 30.day)..Time.now).limit(100)\n end",
"def index\n @messaging_messages = Messaging::Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messaging_messages }\n end\n end",
"def index\n @messages = current_user.messages\n respond_with(@messages)\n end",
"def messages\n responses.map(&:messages).flatten\n end",
"def index\n @peer_to_peer_messages_incoming = PeerToPeerMessage.where(reciever: @current_user.id).order('updated_at desc')\n @peer_to_peer_messages_outgoing = PeerToPeerMessage.where(sender: @current_user.id).order('updated_at desc')\n end",
"def index\n @mod_messages = ModMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mod_messages }\n end\n end",
"def index\n @messies = Messy.all\n\n render json: @messies\n end",
"def show\n render json: @message\n end",
"def show\n render json: @message\n end",
"def get_messages(page = 0)\r\n if page > 0\r\n message_url = \"/message_threads?page=#{page}\"\r\n else\r\n message_url = \"/message_threads\"\r\n end\r\n response = self.class.get(message_url, headers: { \"authorization\" => @user_auth_token })\r\n JSON.parse(response.body)\r\n end",
"def messages(older_than = nil, newer_than = nil)\n oauth_response = access_token.get \"/api/v1/messages.json\"\n JSON.parse(oauth_response.body)\n end\n\n # Return a list of the 20 most recent direct messages sent by the\n # authenticated user\n def sent_messages\n oauth_response = access_token.get \"/api/v1/messages/sent.json\"\n JSON.parse(oauth_response)\n end\n\n # Return messages received by the logged-in user. Corresponds to the\n # \"Received\" tab on the website.\n def received_messages\n oauth_response = access_token.get \"/api/v1/messages/received.json\"\n JSON.parse(oauth_response)\n end\n\n # Return messages in the group with the given ID. Corresponds to the\n # messages you'd see on a group's profile page.\n def group_messages(group_id)\n oauth_response = access_token.get \"/api/v1/messages/in_group/#{group_id}.json\"\n JSON.parse(oauth_response)\n end\n\n # Update the current user's status\n def update(message, group_id = nil)\n if group_id.nil?\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message)\n else\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :group_id => group_id)\n end\n JSON.parse(oauth_response)\n end\n\n # Delete a message owned by the current user\n def delete(message_id)\n oauth_response = access_token.delete(\"/api/v1/messages/#{message_id}\")\n JSON.parse(oauth_response)\n end\n\n # Reply to a message\n def reply_to(message, message_id)\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :replied_to_id => message_id)\n JSON.parse(oauth_response)\n end\n\n # Sends a private message direct to the user indicated\n def direct_to(message, user_id)\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :direct_to_id => user_id)\n JSON.parse(oauth_response)\n end\n end\nend",
"def index\n @client_name = nil\n if session[:cos_session_id]\n if @application_session = Session.find_by_id(session[:cos_session_id])\n @client_name = Client.find_by_id(@application_session.client_id).name\n end\n end\n unless @client_name == nil\n http = get_http_connection()\n path = '/messages/in.json?name='+@pysmsd_config.app_name+'&password='+@pysmsd_config.app_password+'&keyword='+@client_name\n resp = http.get(path)\n json = JSON.parse(resp.body)\n json['messages'].each do | message |\n @person = Person.find_by_phone_number(message['number'])\n if @person\n message['user_id'] = @person.guid\n end\n end\n\n render_json :entry => json and return\n end\n render_json :status => :bad_request, :messages => \"No matching application ID was found, cannot proceed to fetch SMS from server.\" and return\n end",
"def index\n last_modified = nil\n \n role = :default # assume lowest possible role\n \n if params.has_key?(:character_id)\n @character = Fundamental::Character.find(params[:character_id])\n raise NotFoundError.new('Character not found.') if @character.nil?\n outbox = @character.outbox \n last_modified = outbox.updated_at if !outbox.nil?\n @messaging_outboxes = outbox.nil? ? [] : [ outbox ]\n role = determine_access_role(@character.id, @character.alliance_id)\n else\n @asked_for_index = true\n raise ForbiddenError.new('AccessForbidden') unless admin? || staff?\n end\n\n render_not_modified_or(last_modified) do\n respond_to do |format|\n format.html do\n if @messaging_outboxes.nil?\n @messaging_outboxes = Messaging::Outbox.paginate(:page => params[:page], :per_page => 50) \n @paginate = true \n end \n end\n format.json do\n raise ForbiddenError.new('Access Forbidden') if @asked_for_index \n render json: @messaging_outboxes, :only => Messaging::Outbox.readable_attributes(role)\n end\n end\n end \n end",
"def show\n @message = Message.find(params[:id])\n render json: @message\n\n end",
"def show\n @chat_room = ChatRoom.find(params[:chat_room_id])\n #@chat_messages = @chat_room.chat_messages\n @chat_messages = @chat_room.chat_messages.order(created_at: :desc).page(params[:page]).per(5)\n\n render json: @chat_messages, each_serializer: ChatMessageSerializer\n end",
"def chat\n if params[:user] && params[:opp]\n @user = User.find_by_id(params[:user])\n if @user\n @opp = User.find_by_id(params[:opp])\n if @opp\n @messages = Message.all_messages(@user.id, @opp.id)\n @json = {:status => {:status => \"success\"}, :messages => @messages.as_json(:only => [:origin, :opponent, :created_at])}\n render json: @json\n else\n send_error_obj(\"opp not found\")\n end\n else\n send_error_obj(\"user not found\")\n end\n else\n send_error_obj(\"bad parameters\")\n end\n end",
"def echo\n render json: {\n :message => params[:message],\n :timestamp => Time.current,\n }\n end",
"def index\n @messages = Message.where(:to_user => current_user.id).order('id desc').paginate(:page => params[:page])\n @sent_messages = Message.where(:user_id => current_user.id).order('id desc').paginate(:page => params[:sent_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @messages }\n end\n end",
"def index\n # only list current user's hangouts\n @hangouts = current_user.hangouts.order(\"start_date_time DESC\").page(params[:page]).per(10)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hangouts }\n end\n end"
] | [
"0.70113707",
"0.63836396",
"0.62472916",
"0.6224572",
"0.6138406",
"0.6136233",
"0.61274123",
"0.6113622",
"0.6110786",
"0.60970414",
"0.60852665",
"0.60795325",
"0.60603845",
"0.60270935",
"0.6025916",
"0.60208464",
"0.6019969",
"0.6019969",
"0.60160685",
"0.6008911",
"0.60076755",
"0.59977806",
"0.5943561",
"0.59358704",
"0.591892",
"0.58896744",
"0.5882455",
"0.5879614",
"0.5879469",
"0.58405477",
"0.5837196",
"0.5826727",
"0.58115023",
"0.5807103",
"0.57771224",
"0.5764947",
"0.57619894",
"0.57612115",
"0.5747688",
"0.57323265",
"0.57301295",
"0.56965727",
"0.56960493",
"0.5688302",
"0.56853485",
"0.5670974",
"0.5664758",
"0.5660999",
"0.5660973",
"0.565794",
"0.5650203",
"0.5631646",
"0.56144255",
"0.56052446",
"0.56032133",
"0.5597516",
"0.5559358",
"0.5552951",
"0.5525127",
"0.5517451",
"0.5506529",
"0.5505494",
"0.54956377",
"0.54773766",
"0.5474624",
"0.5469077",
"0.5469077",
"0.54637784",
"0.5459956",
"0.5458687",
"0.5457259",
"0.54526836",
"0.54525054",
"0.5451823",
"0.5451491",
"0.54417664",
"0.54412645",
"0.543822",
"0.5426915",
"0.54149514",
"0.54141366",
"0.5407412",
"0.5405638",
"0.5403017",
"0.5393196",
"0.5389075",
"0.53854495",
"0.5383763",
"0.5368711",
"0.5368711",
"0.5365063",
"0.5358586",
"0.5347255",
"0.53462875",
"0.53448087",
"0.5344604",
"0.53430825",
"0.53398764",
"0.5335626",
"0.53345454"
] | 0.7497711 | 0 |
GET /message_outs/1 GET /message_outs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @message_outs = MessageOut.all\n end",
"def index\n @outmessages = Outmessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outmessages }\n end\n end",
"def new\n @outmessage = Outmessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @outmessage }\n end\n end",
"def show\n @outmessage = Outmessage.find(params[:id])\n respond_to do |format|\n format.html {\n render :layout => false\n }# show.html.erb\n format.json { \n render :json => @outmessage\n\n message = Message.new\n message.origin = \"DEVICE\"\n message.message = @outmessage.message\n message.timestamp = (Time.now.to_i)*1000\n message.user = @outmessage.user\n message.destination = @outmessage.destination\n message.save\n\n @outmessage.destroy }\n end\n end",
"def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def show\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outgoing_message_log }\n end\n end",
"def messages\n get_json('messages.json')\n end",
"def index\n @messages = Message.all\n\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = current_user.received_messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def set_message_out\n @message_out = MessageOut.find(params[:id])\n end",
"def smssend\n http = get_http_connection() \n post_args = { 'number' => params[:number], 'text' => params[:text],'replyto' => params[:replyto], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n \n request = Net::HTTP::Post.new('/messages/out.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def index\n @messages = current_user.received_messages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.find_all_by_user_id(session[:user_id], :order => \"timestamp DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @messages }\n end\n end",
"def index\n @messages = message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end",
"def show\n @v1_message = V1::Message.find(params[:id])\n\n render json: @v1_message\n end",
"def index\n @messages = Message.order(\"time desc\").page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Room.find(params['room_id']).messages\n end",
"def destroy\n @outmessage = Outmessage.find(params[:id])\n @outmessage.destroy\n\n respond_to do |format|\n format.html { redirect_to outmessages_url }\n format.json { head :ok }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n render json: Message.all\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def show\n respond_to do |format|\n format.html {\n @messages = Message.find_all_by_user_id(session[:user_id], :conditions => [\"origin=? OR destination=?\",params[:id],params[:id]], :order => \"timestamp ASC\")\n @outmessages = Outmessage.find_all_by_user_id(session[:user_id], :conditions => [\"destination=?\",params[:id]])\n @number = params[:id]\n @ajax_refresh = params[:ajaxrefresh]\n render :layout => false\n }# show.html.erb\n format.json { \n @message = Message.find(params[:id])\n render :json => @message }\n end\n end",
"def create\n @message_out = MessageOut.new(message_out_params)\n\n respond_to do |format|\n if @message_out.save\n format.html { redirect_to @message_out, notice: 'Message out was successfully created.' }\n format.json { render :show, status: :created, location: @message_out }\n else\n format.html { render :new }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def msg_arnoldbot\n uri = URI(\"https://arnoldbot-api.herokuapp.com/talk?msg=\"+params[:msg])\n resp = Net::HTTP.get(uri)\n render json: resp\n end",
"def index\n\t\t@messages = Message.all.order('created_at DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend",
"def read_all_messages\n post(\"/api/read_all_messages\")\n end",
"def new\n @outgoing_message_log = OutgoingMessageLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @outgoing_message_log }\n end\n end",
"def show\n out = Out.find(params[:id])\n respond_to do |format|\n format.json {\n render :json => out, :layout => false\n }\n end\n end",
"def show\n @message = Message.find(params[:id])\n render json: @message\n\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @messages}\n end\n end",
"def sent_messages\n get('/direct_messages/sent.json')\n end",
"def destroy\n @message_out.destroy\n respond_to do |format|\n format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def outbox\n\n #handle new signatures\n @general_signature = params[:general_signature]\n @gw_signature = params[:gw_signature]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unsent_messages }\n end\n end",
"def show\n\t\t@messages = Message.where(recipient: params[:id]).order('created_at DESC')\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend",
"def new\n @messaging_outbox = Messaging::Outbox.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messaging_outbox }\n end\n end",
"def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end",
"def index\n @outs = Out.all\n end",
"def show\n render_json :entry => @message\n end",
"def index\n @client_name = nil\n if session[:cos_session_id]\n if @application_session = Session.find_by_id(session[:cos_session_id])\n @client_name = Client.find_by_id(@application_session.client_id).name\n end\n end\n unless @client_name == nil\n http = get_http_connection()\n path = '/messages/in.json?name='+@pysmsd_config.app_name+'&password='+@pysmsd_config.app_password+'&keyword='+@client_name\n resp = http.get(path)\n json = JSON.parse(resp.body)\n json['messages'].each do | message |\n @person = Person.find_by_phone_number(message['number'])\n if @person\n message['user_id'] = @person.guid\n end\n end\n\n render_json :entry => json and return\n end\n render_json :status => :bad_request, :messages => \"No matching application ID was found, cannot proceed to fetch SMS from server.\" and return\n end",
"def index\n @messages = current_user.received_messages.paginate(:page => params[:page])\n @title = \"Входящие сообщения\"\n @path = \"index\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def visit_inbox\n get '/messages'\n end",
"def show\n\n render json: @message\n\n end",
"def message\n response_json.fetch(\"message\", \"\")\n end",
"def get_message\n @msg = Message.find_by_id(get_message_params[:message_id])\n\n if request.xhr?\n render :json => {\n :text => @msg.m_message,\n :offset => @msg.m_offset\n }\n end\n\n end",
"def index\n @messaging_messages = Messaging::Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messaging_messages }\n end\n end",
"def index\n if params[:last_message_id]\n @messages = Message.includes(:user).where(\"id > ?\", params[:last_message_id])\n else\n @messages = Message.includes(:user).limit(5).order(:created_at).reverse_order\n end\n\n @message_data = []\n @messages.each do |message|\n @message_data.push({\n :id => message.id,\n :user => message.user.name,\n :content => message.content\n })\n end\n \n respond_to do |format|\n format.json { render :json => @message_data}\n end\n end",
"def index\n @messages = current_user.messages_in.order('created_at ASC').group('sender_id')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def outbox\n cur_emp = get_logged_employee\n @messages = Message.where(\"sent_by = ?\", cur_emp).where(:is_deleted => nil) \n render \"resumes/message_show\"\n end",
"def index\n #@messages = Message.all\n \n @messages = Message.page(params[:page]).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.where(\" messages.room_id = ? and messages.to is NULL\", params[:room_id])\n totalMessages = (@messages.size>10) ? 9 : @messages.size\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages.reverse[0..totalMessages].reverse }\n end\n end",
"def message\n response.body.match(/\"message\":\"(.*)\"/)[1]\n end",
"def message(message)\n render json: {\n message: message,\n status: :success\n }, status: 200\n end",
"def message\n response.to_json\n end",
"def index\n @mod_messages = ModMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mod_messages }\n end\n end",
"def index\n\t\t@messages = Message.where(:to_user => current_user.id)\n\t\trespond_with(@messages) \n\tend",
"def show\n render json: @message\n end",
"def show\n render json: @message\n end",
"def show\n @chat = Chat.find(params[:id])\n @receiver = interlocutor(@chat)\n @messages = @chat.messages\n @message = Message.new\n render json: $message\n end",
"def update\n respond_to do |format|\n if @message_out.update(message_out_params)\n format.html { redirect_to @message_out, notice: 'Message out was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_out }\n else\n format.html { render :edit }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def message\n @message ||= (request.GET[:msg] || Hash.new)\n end",
"def read\n @message = Message.find(params[:id])\n @message.read(current_user)\n respond_to do |format|\n format.html # read.html.erb\n format.json { render json: @message }\n end\n end",
"def index\n @channel = Channel.find(params[:channel_id])\n time = params[:ts] || 2.hours.ago\n @messages = @channel.messages.created_after(time)\n\n render json: @messages\n end",
"def show\n @chat_room = ChatRoom.find(params[:chat_room_id])\n #@chat_messages = @chat_room.chat_messages\n @chat_messages = @chat_room.chat_messages.order(created_at: :desc).page(params[:page]).per(5)\n\n render json: @chat_messages, each_serializer: ChatMessageSerializer\n end",
"def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentor_messages }\n end\n end",
"def show\n @room_message = RoomMessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @room_message }\n end\n end",
"def index\n @messies = Messy.all\n\n render json: @messies\n end",
"def index\n workouts = @ws.workouts\n render json: workouts\n end",
"def index\n @messages = Rails.cache.fetch('all_messages', :expires_in => 30.seconds) do\n Message.all\n end\n\n respond_to do |format|\n format.json { render json: @messages }\n end\n end",
"def get_messages(page = 0)\r\n if page > 0\r\n message_url = \"/message_threads?page=#{page}\"\r\n else\r\n message_url = \"/message_threads\"\r\n end\r\n response = self.class.get(message_url, headers: { \"authorization\" => @user_auth_token })\r\n JSON.parse(response.body)\r\n end",
"def message(*ids)\n result = records(\"post\", \"/msg/get/#{ids.join(\",\")}\")\n result.length == 1 ? result.first : result\n end",
"def smsmark\n http = get_http_connection() \n post_args = { 'ids' => params[:ids], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n request = Net::HTTP::Post.new('/messages/in.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def show\n render json: get_message()\n end",
"def direct_messages(params = {})\n get \"direct_messages\", params\n end",
"def index\n raise ApiAccessEvanta::PermissionDenied unless AppSettings::Value.new(:messages, user: current_user).on?\n @messages = Message.get_message_list(current_user)\n render json: @messages\n end",
"def message(message)\n get(\"inbox/messages/#{message}\").pop\n end",
"def inbox\n @messages = current_user.received_messages\n respond_with @messages\n end",
"def echo\n render json: {\n :message => params[:message],\n :timestamp => Time.current,\n }\n end",
"def show\n @rooms = { \n items: Room.all, \n }\n if room = Room.find_by(id: params[:id])\n response_data = {\n room: room,\n messages: module_get_messages(room)\n }\n status= :ok\n else \n status= :unprocessable_entity\n end\n\n #puts \"#######################\"\n #puts @room.as_json(:include => @messages)\n #puts Room.includes(:messages.limit(2)).find(params[:id] || 1).as_json(:include => :messages)\n\n respond_to do |format|\n format.html\n format.json { render json: response_data, status: status }\n end\n end",
"def index\n # @messages = Message.message_in_area(params[:latitude], params[:longitude], current_user.message_zone).main_information\n\t @messages = Message.all\n render json: @messages\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :_message }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end",
"def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end",
"def show\n @chatroom = Chatroom.find(params[:id])\n @messages = @chatroom.messages.order(\"created_at DESC\")\n @user = User.find(session[:user_id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chatroom }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end",
"def show\n @message = Message.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message }\n end\n end"
] | [
"0.71900153",
"0.6946622",
"0.65348715",
"0.6396523",
"0.62391096",
"0.62051475",
"0.61953485",
"0.61840504",
"0.61580974",
"0.6157837",
"0.6157837",
"0.613405",
"0.61328566",
"0.6126474",
"0.6123998",
"0.61012584",
"0.6079397",
"0.6049314",
"0.5996184",
"0.5989917",
"0.59854305",
"0.5967823",
"0.59653676",
"0.5964972",
"0.59639335",
"0.5945482",
"0.59430665",
"0.59426475",
"0.59297615",
"0.59152234",
"0.59142435",
"0.588218",
"0.5881713",
"0.5874286",
"0.58520705",
"0.58357275",
"0.5835336",
"0.58054274",
"0.5782411",
"0.57559985",
"0.57455456",
"0.57366437",
"0.5725648",
"0.5722246",
"0.57066023",
"0.56962895",
"0.5692905",
"0.5686896",
"0.56842357",
"0.5683683",
"0.5683451",
"0.56645316",
"0.56596",
"0.565733",
"0.5653844",
"0.5648227",
"0.5646143",
"0.5641061",
"0.56347376",
"0.5632579",
"0.56308335",
"0.56308335",
"0.56302303",
"0.56281805",
"0.5628058",
"0.56244403",
"0.56141555",
"0.56128335",
"0.5611324",
"0.56085986",
"0.5605856",
"0.56002074",
"0.55937815",
"0.55820405",
"0.5576884",
"0.5569845",
"0.55552727",
"0.5554439",
"0.5543813",
"0.5540618",
"0.5529116",
"0.5525833",
"0.5523987",
"0.5519845",
"0.55150425",
"0.5513976",
"0.5509579",
"0.5501898",
"0.54972935",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365",
"0.54952365"
] | 0.0 | -1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.