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
Update properties for a Device Group
def properties=(value) start = Time.now debug "Updating properties for device group: \"#{resource[:full_path]}\"" connection = self.class.get_connection(resource[:account]) update_device_group(connection, resource[:full_path], resource[:description], value, resource[:disable_alerting]) debug "Finished in #{(Time.now-start)*1000.0} ms" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if params[:device_group][:property_ids]\n params[:device_group][:property_ids].each do |property_id|\n @property = Property.find(property_id)\n @device_group.properties << @property\n end\n end\n respond_to do |format|\n if @device_group.update(device_group_params)\n format.html { redirect_to @device_group, notice: 'Device group was successfully updated.' }\n format.json { render :show, status: :ok, location: @device_group }\n format.js {\n @device_groups = DeviceGroup.all\n render :update\n }\n else\n format.html { render :edit }\n format.json { render json: @device_group.errors, status: :unprocessable_entity }\n format.js {\n @device_groups = DeviceGroup.all\n render :update\n }\n end\n end\n end", "def update_device_group(connection, fullpath, description, properties, disable_alerting)\n device_group = get_device_group(connection, fullpath, 'id,parentId')\n device_group_hash = build_group_json(fullpath,\n description,\n properties,\n disable_alerting,\n device_group['parentId'])\n update_device_group = rest(connection,\n Puppet::Provider::Logicmonitor::DEVICE_GROUP_ENDPOINT % device_group['id'],\n Puppet::Provider::Logicmonitor::HTTP_PATCH,\n build_query_params(nil, nil, -1, device_group_hash.keys),\n device_group_hash.to_json)\n valid_api_response?(update_device_group) ? debug(update_device_group) : alert(update_device_group)\n end", "def update_group(group, attributes)\n group.update(attributes)\n end", "def device_group_params\n params.require(:device_group).permit(:name, :icon, properties_attributes: [:id, :name, :style, :unit, :values, :fa_style])\n end", "def set_device_group\n @device_group = DeviceGroup.find(params[:id])\n end", "def set_property_group\n @property_group = PropertyGroup.find(params[:id])\n end", "def update_group(group_or_id, attributes)\n instantize_group(group_or_id).update(attributes)\n end", "def properties\n start = Time.now\n debug \"Checking properties for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n properties = Hash.new\n device_group = get_device_group(connection, resource[:full_path], 'id')\n if device_group\n device_group_properties = rest(connection,\n Puppet::Provider::Logicmonitor::DEVICE_GROUP_PROPERTIES_ENDPOINT % device_group['id'],\n Puppet::Provider::Logicmonitor::HTTP_GET,\n build_query_params('type:custom,name!:system.categories,name!:puppet.update.on',\n 'name,value'))\n if valid_api_response?(device_group_properties, true)\n device_group_properties['data']['items'].each do |property|\n name = property['name']\n value = property['value']\n if value.include?('********') && resource[:properties].has_key?(name)\n debug 'Found password property. Verifying'\n verify_device_group_property = rest(connection,\n Puppet::Provider::Logicmonitor::DEVICE_GROUP_PROPERTIES_ENDPOINT % device_group['id'],\n Puppet::Provider::Logicmonitor::HTTP_GET,\n build_query_params(\"type:custom,name:#{name},value:#{value}\", nil, 1))\n if valid_api_response?(verify_device_group_property)\n debug 'Property unchanged'\n value = resource[:properties][name]\n else\n debug 'Property changed'\n end\n end\n properties[name] = value\n end\n else\n alert device_group_properties\n end\n else\n alert device_group\n end\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n properties\n end", "def update\n unless @group.update(group_params)\n render :edit and return\n end\n msg = [\"Updated group.\", rebuild_configs].join(\" \")\n redirect_to groups_url, notice: msg\n end", "def update\n if @group.update_attributes(params[:group])\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20103, \"Failed to update group info\")\n end\n end", "def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { redirect_to(@group) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_group(group_id, attributes)\n put(\"/v1/groups/#{group_id}\", attributes)\n end", "def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name, :error => @group.errors.full_messages)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_device_properties()\n return MicrosoftGraph::DeviceManagement::WindowsAutopilotDeviceIdentities::Item::UpdateDeviceProperties::UpdateDevicePropertiesRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @group = Group.find_by_guid(params[:id])\n respond_to do |format|\n if @group.update_attributes(update_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render json: @group }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group.update(group_params)\n respond_with(@group)\n end", "def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end", "def update\n @group = Group.find(params[:id])\n @users = @group.users\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to edit_user_registration_path, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meta_data_group = MetaDataGroup.find(params[:id])\n\n respond_to do |format|\n if @meta_data_group.update_attributes(params[:meta_data_group])\n format.html { redirect_to @meta_data_group, notice: 'MetaData group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meta_data_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record_group = RecordGroup.find(params[:id])\n @record_group.accessible = :all if admin?\n respond_to do |format|\n if @record_group.update_attributes(params[:record_group])\n flash[:notice] = 'RecordGroup was successfully updated.'\n format.html { redirect_to(@record_group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @record_group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @group.update(group_params)\n render_json_message({success: t('.success')}, 200)\n else\n render_json_message({errors: @group.errors.messages}, 422)\n end\n end", "def update\n @group = Group.find(params[:id])\n\n unless params[:metro_area_id].blank?\n @group.metro_area = MetroArea.find(params[:metro_area_id])\n @group.state = (@group.metro_area && @group.metro_area.state) ? @group.metro_area.state : nil\n @group.country = @group.metro_area.country if (@group.metro_area && @group.metro_area.country)\n else\n @group.metro_area = @group.state = @group.country = nil\n end\n\n @avatar = Groupphoto.new(params[:avatar])\n @avatar.group = @group\n\n @group.avatar = @avatar if @avatar.save\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @product_group = ProductGroup.find(params[:id])\n\n respond_to do |format|\n if @product_group.update_attributes(params[:product_group])\n format.html { redirect_to @product_group, notice: 'Product group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @contact_group_id = args[:contact_group_id] if args.key?(:contact_group_id)\n @delegated_group_info = args[:delegated_group_info] if args.key?(:delegated_group_info)\n @metadata = args[:metadata] if args.key?(:metadata)\n @system_contact_group_id = args[:system_contact_group_id] if args.key?(:system_contact_group_id)\n end", "def update\n respond_to do |format|\n if @resource_group.update(resource_group_params)\n format.html { redirect_to @resource_group, notice: 'Resource group was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource_group }\n else\n format.html { render :edit }\n format.json { render json: @resource_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @delegated_group_id = args[:delegated_group_id] if args.key?(:delegated_group_id)\n end", "def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end", "def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end", "def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end", "def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end", "def update\n @attribute_group = AttributeGroup.find(params[:id])\n\n respond_to do |format|\n if @attribute_group.update_attributes(params[:attribute_group])\n format.html { redirect_to(@attribute_group, :notice => 'Attribute group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attribute_group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.json { head :no_content }\n else\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @group_id = args[:group_id] if args.key?(:group_id)\n end", "def update!(**args)\n @group_id = args[:group_id] if args.key?(:group_id)\n end", "def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update\n @field_group = FieldGroup.find(params[:id])\n @field_group.update_attributes(field_group_params)\n\n respond_with(@field_group)\n end", "def update options = {}\n\n group_opts = group_options(options) \n\n # tags must be updated using a separate request from the\n # other attributes, *sigh*\n if tags = group_opts.delete(:tags)\n tags.map(&:to_hash).each do |tag|\n tag[:resource_type] = 'auto-scaling-group'\n tag[:resource_id] = name\n end\n client.create_or_update_tags(:tags => tags)\n end\n\n unless group_opts.empty?\n client_opts = group_opts.merge(:auto_scaling_group_name => name)\n client.update_auto_scaling_group(client_opts)\n end\n\n nil\n\n end", "def update #:nodoc:\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = I18n.t(\"{{value}} was successfully updated.\", :default => \"{{value}} was successfully updated.\", :value => I18n.t(\"Group\", :default => \"Group\"))\n format.html { redirect_to groups_url }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @polco_group = PolcoGroup.find(params[:id])\n @polco_group.title = \"#{params[:polco_group][:name]}_custom\" \n\n respond_to do |format|\n if @polco_group.update_attributes(params[:group])\n format.html { redirect_to(@polco_group, :notice => 'PolcoGroup was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @polco_group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n if @group.update(group_params)\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end", "def update\n case current_user.email.split('@')[0]\n when 'gallery'\n if params.has_key?(:in_gallery_start)\n @group.in_gallery_start = Time.now() \n elsif params.has_key?(:in_gallery_end)\n @group.in_gallery_end = Time.now()\n end\n when 'robot'\n if params.has_key?(:drive_robot_start)\n @group.drive_robot_start = Time.now() \n elsif params.has_key?(:drive_robot_end)\n @group.drive_robot_end = Time.now()\n end\n end\n \n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit', error: @group.errors.full_messages }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = load_group\n @group_form = group_form\n\n if @group_form.valid? && @group_form.save\n redirect_to(admin_group_path(@group_form.id))\n else\n render :edit\n end\n end", "def update\n @objectgrouptoobjectgroup = Objectgrouptoobjectgroup.find(params[:id])\n\n respond_to do |format|\n if @objectgrouptoobjectgroup.update_attributes(params[:objectgrouptoobjectgroup])\n flash[:notice] = 'Objectgrouptoobjectgroup was successfully updated.'\n format.html { redirect_to(@objectgrouptoobjectgroup) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @objectgrouptoobjectgroup.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:group].delete(:domain) unless current_group.shapado_version.has_custom_domain?\n if params[:group][:languages]\n params[:group][:languages].reject! { |lang| lang.blank? }\n end\n @group.safe_update(%w[track_users name legend description default_tags subdomain logo logo_info forum enable_latex enable_mathjax\n custom_favicon language languages current_theme_id reputation_rewards daily_cap reputation_constrains\n has_adult_content registered_only enable_anonymous signup_type custom_css wysiwyg_editor layout\n fb_button notification_opts auth_providers allow_any_openid], params[:group])\n @group.share.safe_update(%w[fb_app_id fb_secret_key fb_active starts_with ends_with enable_twitter twitter_user twitter_pattern], params[:group][:share]) if params[:group][:share]\n @group.safe_update(%w[isolate domain private has_custom_analytics has_custom_html has_custom_js], params[:group]) #if current_user.admin?\n @group.safe_update(%w[analytics_id analytics_vendor], params[:group]) if @group.has_custom_analytics\n @group.custom_html.update_attributes(params[:group][:custom_html] || {}) if @group.has_custom_html\n @group.notification_opts.safe_update(%w[questions_to_twitter badges_to_twitter favorites_to_twitter answers_to_twitter comments_to_twitter], params[:group][:notification_opts]) if params[:group][:notification_opts]\n if params[:group][:language] && !params[:group]['languages']\n @group.languages = []\n end\n\n if @group.domain == AppConfig.domain ||\n @group.domain.index(AppConfig.domain).nil? ||\n @group.user.role == 'admin'\n @group.has_custom_js = true\n else\n @group.has_custom_js = false\n end\n\n if params[:group][:logo]\n @group.logo_version += 1\n end\n if params[:group][:custom_favicon]\n @group.custom_favicon_version += 1\n end\n\n respond_to do |format|\n if @group.save\n flash[:notice] = I18n.t('groups.update.notice')\n format.html {\n if params[:group][:custom_domain] && @group.has_custom_domain?\n redirect_to \"#{request.protocol}#{AppConfig.domain}:#{request.port}#{check_custom_domain_path(@group.id)}\"\n elsif params[:group][:custom_domain]\n redirect_to \"#{request.protocol}#{@group.domain}:#{request.port}/manage/properties/domain\"\n else\n redirect_to(params[:source] ? params[:source] : group_path(@group))\n end\n }\n format.json { head :ok }\n else\n format.html {\n flash[:error] = @group.errors.messages.first[1]\n redirect_to :back\n }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\tparams[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n\t\t#special method update_attribute only updates explicitly stated attribute\n\t\tif @group.update_attributes(params[:group])\n\t\t\tredirect_to @group\n\t\t\tflash[:success] = \"group updated\"\n\t\tend\n\tend", "def update\n begin\n @deptgroup = Deptgroup.find(params[:id])\n\n updated_group = @@data_util.hash_data_to_upper_case(@@data_util.strip_hash_data(params[:dept_group]), ['description'])\n updated_group[:lastupdateby] = session[:username]\n\n if @deptgroup.update_attributes(updated_group)\n @@request_result[:success] = true\n @@request_result[:notice] = 'Department Sub Group was successfully updated.'\n else\n @@request_result[:errormsg] = @deptgroup.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n audit(@group, \"update\", @group.name)\n format.html { redirect_to group_path(@group), notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to( view_group_path(@group.label), :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @product_group.update(product_group_params)\n format.html { redirect_to @product_group, notice: \"Product group was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product_group }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @garden_group.update(garden_group_params)\n format.html { redirect_to @garden_group, notice: 'Garden group was successfully updated.' }\n format.json { render :show, status: :ok, location: @garden_group }\n else\n format.html { render :edit }\n format.json { render json: @garden_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @group_id = args[:group_id] if args.key?(:group_id)\n @owner_gaia_id = args[:owner_gaia_id] if args.key?(:owner_gaia_id)\n @required_consistency_timestamp_usec = args[:required_consistency_timestamp_usec] if args.key?(:required_consistency_timestamp_usec)\n end", "def update!(**args)\n @group_id = args[:group_id] if args.key?(:group_id)\n @owner_gaia_id = args[:owner_gaia_id] if args.key?(:owner_gaia_id)\n @required_consistency_timestamp_usec = args[:required_consistency_timestamp_usec] if args.key?(:required_consistency_timestamp_usec)\n end", "def update\n respond_to do |format|\n if @unit_group.update(unit_group_params)\n format.html { redirect_to @unit_group, notice: 'Unit group was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_group }\n else\n format.html { render :edit }\n format.json { render json: @unit_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_config(groupinfo, user=User.lister)\n if configatron.populate_group_settings\n begin\n settings = user.requestor.get_group_settings(self.group_email)\n rescue Google::APIClient::ServerError => e\n # This API seems to be flaky sometimes, so swallow error and\n # continue on.\n log.error(\"Error requesting group settings: #{e.message} (#{e.class})\", group_email: self.group_email)\n rescue Google::APIClient::ClientError => e\n # Be helpful to people\n if e.message =~ /Domain cannot use Api, Groups service is not installed/\n e.message << ' (HINT: you need to be on Google Groups for Business to use the Groups service. You can turn off groups settings population by disabling the `populate_group_settings` key.)'\n end\n raise\n else\n self.group_settings = settings\n end\n end\n\n groupinfo ||= user.requestor.get_group(self.group_email)\n\n self.description = groupinfo.fetch('description')\n self.direct_members_count = groupinfo.fetch('directMembersCount')\n\n _, config = parse_description\n # Keep the existing category if one set\n config['category'] ||= self.category || self.group_email.split(/[@-]/)[0]\n\n self.config = config\n self.deleted = false\n end", "def update\n group = Group.find(params[:id])\n if group.update(group_params)\n render json: group\n else\n render json: group.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = '{object} was successfully {action}.'[:object_action_notice, \"Group\"[], \"updated\"[]]\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n if [email protected]?\n @user=User.find(@group.admin)\n puts \"///////group controller update//////////\"+ @user.to_json\n @user.update_attributes(role: '1')\n @user.update_attributes(group_id: @group._id)\n end\n @group.update_attributes(params[:group])\n #format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n #format.json { render json: @group, status: :accepted, location: @group }\n render 'show'\n #format.html { render action: \"edit\" }\n #format.json { render json: @group.errors, status: :unprocessable_entity } \n end", "def update\n \n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to groups_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(by_id)\n if @group.update_attributes(group_params)\n flash[:success] = \"Group updated\"\n redirect_to @group\n else\n render 'edit'\n end\n end", "def update\n\n if @size_group.update_attributes(params[:size_group])\n flash[:notice] = 'SizeGroup was successfully updated.'\n render :partial => 'show', :object => @size_group\n else\n render :partial => 'edit', :object => @size_group, :status => 409\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to [@group], notice: 'group was successfully updated.' }\n format.json { render :show, status: :ok, location: [@group] }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @group.update_attributes(group_params)\n format.html { redirect_to @group.becomes(Group), notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def device_properties(id, params={})\n put(\"/devices/#{id}/properties\", params)\n end", "def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if ((params.has_key?(:group_size)) && (not params[:group_size].empty?))\n update_max_group_size(params[:group_size])\n end\n if ((params.has_key?(:group_reader)) && (not params[:group_reader].empty?))\n update_group_readers(params[:group_reader])\n end\n redirect_to admin_path\n end", "def update_rsgroup_config(groupName)\n @admin.updateConfiguration(groupName)\n end", "def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n flash[:notice] = t('flash_msg47')\n @groups = Group.all\n # format.html { redirect_to(@group) }\n # format.xml { head :ok }\n else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end", "def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @musical_group = MusicalGroup.find(params[:id])\n\n respond_to do |format|\n if @musical_group.update_attributes(params[:musical_group])\n format.html { redirect_to @musical_group, notice: 'Musical group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @musical_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_location_group(project_id, location_group_id, opts = {})\n put \"projects/#{project_id}/group/location/#{location_group_id}\", opts\n end" ]
[ "0.73503065", "0.73163116", "0.7088025", "0.6695261", "0.6664472", "0.65236855", "0.6408554", "0.6379127", "0.6376438", "0.6365804", "0.63204944", "0.63078314", "0.6294496", "0.6292342", "0.6290587", "0.6253899", "0.6189208", "0.6179692", "0.6177306", "0.6166517", "0.6164902", "0.61576027", "0.6149976", "0.61429703", "0.6141543", "0.612913", "0.61096567", "0.6096349", "0.6096349", "0.6096349", "0.6096349", "0.6095198", "0.60929", "0.60913134", "0.6087207", "0.6087207", "0.6082782", "0.6080127", "0.6072121", "0.6070744", "0.606678", "0.6047384", "0.6042168", "0.6042", "0.601736", "0.6011914", "0.60048133", "0.6002308", "0.6001447", "0.5991726", "0.5985396", "0.5980448", "0.5975414", "0.597302", "0.597302", "0.5970683", "0.5970645", "0.5969082", "0.59676385", "0.59676385", "0.5965114", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59629637", "0.59621257", "0.5959263", "0.5959263", "0.5959263", "0.59528923", "0.5950796", "0.59341717", "0.5928516", "0.5927279", "0.5918154", "0.5907808", "0.5891378", "0.5891378", "0.5891378", "0.5891378", "0.5888855", "0.5888772", "0.5886777", "0.58820033", "0.5880113", "0.5869789", "0.5867876", "0.58667105", "0.58667105", "0.58658415", "0.5861978", "0.5861458" ]
0.79387367
0
Helper method for updating a Device Group via HTTP PATCH
def update_device_group(connection, fullpath, description, properties, disable_alerting) device_group = get_device_group(connection, fullpath, 'id,parentId') device_group_hash = build_group_json(fullpath, description, properties, disable_alerting, device_group['parentId']) update_device_group = rest(connection, Puppet::Provider::Logicmonitor::DEVICE_GROUP_ENDPOINT % device_group['id'], Puppet::Provider::Logicmonitor::HTTP_PATCH, build_query_params(nil, nil, -1, device_group_hash.keys), device_group_hash.to_json) valid_api_response?(update_device_group) ? debug(update_device_group) : alert(update_device_group) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @group.update_attributes(params[:group])\n respond_with(@group, only: [:id, :name, :creator_id, :admin_id])\n else\n render_error(404, request.path, 20103, \"Failed to update group info\")\n end\n end", "def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end", "def update\n @group.update(group_params)\n respond_with(@group)\n end", "def update\n if @group.update(group_params)\n render_json_message({success: t('.success')}, 200)\n else\n render_json_message({errors: @group.errors.messages}, 422)\n end\n end", "def update\n @field_group = FieldGroup.find(params[:id])\n @field_group.update_attributes(field_group_params)\n\n respond_with(@field_group)\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.json { head :no_content }\n else\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if @group.update(group_params)\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @request_group.update(request_group_params)\n format.html { redirect_to @request_group, \n\t\t\t\t\t\t\t\t\t\t\tnotice: 'Request group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_group.errors, \n\t\t\t\t\t\t\t\t\t\t\tstatus: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_group_update.update(api_v1_group_update_params)\n format.html { redirect_to @api_v1_group_update, notice: 'Group update was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_group_update }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_group_update.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n group = Group.find(params[:id])\n if group.update(group_params)\n render json: group\n else\n render json: group.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n @group = Group.find_by_guid(params[:id])\n respond_to do |format|\n if @group.update_attributes(update_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render json: @group }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(params[:group])\n format.html { redirect_to [@hub, @group], :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to( view_group_path(@group.label), :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_group(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'UpdateGroup'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :group_name\n\t\t\targs[:query]['GroupName'] = optional[:group_name]\n\t\tend\n\t\tif optional.key? :new_comments\n\t\t\targs[:query]['NewComments'] = optional[:new_comments]\n\t\tend\n\t\tif optional.key? :new_group_name\n\t\t\targs[:query]['NewGroupName'] = optional[:new_group_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_group_with_http_info(group, group_oid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserApi.update_group ...'\n end\n # verify the required parameter 'group' is set\n if @api_client.config.client_side_validation && group.nil?\n fail ArgumentError, \"Missing the required parameter 'group' when calling UserApi.update_group\"\n end\n # verify the required parameter 'group_oid' is set\n if @api_client.config.client_side_validation && group_oid.nil?\n fail ArgumentError, \"Missing the required parameter 'group_oid' when calling UserApi.update_group\"\n end\n # resource path\n local_var_path = '/user/groups/{group_oid}'.sub('{' + 'group_oid' + '}', group_oid.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=UTF-8'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(group)\n auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GroupResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserApi#update_group\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n \n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @group\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(@group), notice: \"Group was successfully updated.\" }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resource_group.update(resource_group_params)\n format.html { redirect_to @resource_group, notice: 'Resource group was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource_group }\n else\n format.html { render :edit }\n format.json { render json: @resource_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update #:nodoc:\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = I18n.t(\"{{value}} was successfully updated.\", :default => \"{{value}} was successfully updated.\", :value => I18n.t(\"Group\", :default => \"Group\"))\n format.html { redirect_to groups_url }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_group_field.update(api_v1_group_field_params)\n format.html { redirect_to @api_v1_group_field, notice: 'Group field was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_group_field }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_group_field.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to groups_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = '{object} was successfully {action}.'[:object_action_notice, \"Group\"[], \"updated\"[]]\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(admin_groups_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_group_with_http_info(group_id, group_body_update, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: GroupsApi.update_group ...\"\n end\n # verify the required parameter 'group_id' is set\n fail ArgumentError, \"Missing the required parameter 'group_id' when calling GroupsApi.update_group\" if group_id.nil?\n # verify the required parameter 'group_body_update' is set\n fail ArgumentError, \"Missing the required parameter 'group_body_update' when calling GroupsApi.update_group\" if group_body_update.nil?\n # resource path\n local_var_path = \"/groups/{groupId}\".sub('{format}','json').sub('{' + 'groupId' + '}', group_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?\n query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :csv) if !opts[:'fields'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(group_body_update)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GroupEntry')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: GroupsApi#update_group\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to [@group], notice: 'group was successfully updated.' }\n format.json { render :show, status: :ok, location: [@group] }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: I18n.t(:group_update) }\n format.json { render :show, status: :ok, location: @group }\n else\n flash[:alert] = @group.errors.full_messages.to_sentence\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @group\n @group.creator = current_user\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n audit(@group, \"update\", @group.name)\n format.html { redirect_to group_path(@group), notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tqrdc_group.update(tqrdc_group_params)\n format.html { redirect_to @tqrdc_group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @tqrdc_group }\n else\n format.html { render :edit }\n format.json { render json: @tqrdc_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n authorize @group, :update?\n respond_to do |format|\n if @group.update_attributes(permitted_params)\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Le groupe a été modifié.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { redirect_to(@group) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Группа обновлена!' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n \n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n newparam= checker()\n respond_to do |format|\n if @group.update(newparam)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @contact_group.update(contact_group_params)\n render json: @contact_group, status: :ok\n else\n render json: @contact_group.errors, status: :unprocessable_entity\n end\n end", "def update\n begin\n @deptgroup = Deptgroup.find(params[:id])\n\n updated_group = @@data_util.hash_data_to_upper_case(@@data_util.strip_hash_data(params[:dept_group]), ['description'])\n updated_group[:lastupdateby] = session[:username]\n\n if @deptgroup.update_attributes(updated_group)\n @@request_result[:success] = true\n @@request_result[:notice] = 'Department Sub Group was successfully updated.'\n else\n @@request_result[:errormsg] = @deptgroup.errors.full_messages[0]\n end\n rescue Exception => e\n @@request_result[:errormsg] = e.message\n end\n render json: @@request_result\n end", "def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find_by_param(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to(@group, :notice => 'Group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n @users = @group.users\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to edit_user_registration_path, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@group = Group.find(params[:id])\n\t\[email protected]_accessor(current_user)\n\t\trespond_to do |format|\n\t\t\tif @group.update_attributes(params[:group])\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_group), :ident => @group.name)\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated, :typeobj => t(:ctrl_group), :ident => @group.name, :error => @group.errors.full_messages)\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_group(group_id, attributes)\n put(\"/v1/groups/#{group_id}\", attributes)\n end", "def update\n @group = WorkGroup.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n# format.json { head :no_content }\nformat.json { render :json=>{'statusCode'=>'200','message'=>'Edit Group Success!','navTableId'=>'','rel'=>'','callbackType'=>'','forwardUrl'=>'','confirmMsg'=>''} }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group_request.update(group_request_params)\n format.html { redirect_to @group_request, notice: 'Group request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_group = UserGroup.find(params[:id])\n\n respond_to do |format|\n if @user_group.update_attributes(params[:user_group])\n format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n token = params[:token]\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to group_path(:id => @group.id), notice: 'Group was successfully updated.' }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n format.html { redirect_to params[:back_to], notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @group.update(group_params)\n render :edit and return\n end\n msg = [\"Updated group.\", rebuild_configs].join(\" \")\n redirect_to groups_url, notice: msg\n end", "def update\n #logger.info \"Put parameters: #{params.to_json}\"\n\n if @membership.admin \n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n else \n render json: {error: \"YOU MUST BE AN ADMINISTRATOR TO COMPLETE THIS ACTION\"}, status: :unprocessable_entity\n end \n end", "def update\n respond_to do |format|\n if @dis_group.update(dis_group_params)\n format.html { redirect_to @dis_group, notice: 'Dis group was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_group }\n else\n format.html { render :edit }\n format.json { render json: @dis_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @group.update_attributes(group_params)\n format.html { redirect_to @group.becomes(Group), notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entry = Entry.find(params[:id])\n\n if (a = params.delete(:group))\n params[:entry][:group_id] = set_group(a)\n end\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { 'Entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { 'Foo' }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n redirect_to :action => :index and return unless is_owner?\n respond_to do |format|\n if @group.update(group_params)\n format.html { redirect_to @group, notice: 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = 'Group was successfully updated.'\n format.html { redirect_to((current_user and current_user.is_site_admin? and current_user != @group.users.owners.first) ? by_user_groups_path(:user_id => @group.users.owners.first.id) : groups_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_group(id, params)\n put(\"groups/#{id}\", group: params)\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:success] = \"Группа успешно отредактирована.\"\n format.html { redirect_to @group }\n format.json { head :no_content }\n else\n flash.now[:error] = \"Введены некорректные данные!\"\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @group.update(group_params)\n invite_members\n format.html { redirect_to @group, notice: t('flash.notice.groups.successfully_updated') }\n format.json { render :show, status: :ok, location: @group }\n else\n format.html { render :edit }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @group = Group.find(params[:id])\n\n respond_to do |format|\n if @group.update_attributes(params[:group])\n flash[:notice] = t('flash.notice.group_update') # 'Group was successfully updated.'\n format.any(:html,:iphone) { redirect_to(@group) }\n format.xml { head :ok }\n else\n format.any(:html,:iphone) { render :action => \"edit\" }\n format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @attribute_group = AttributeGroup.find(params[:id])\n\n respond_to do |format|\n if @attribute_group.update_attributes(params[:attribute_group])\n format.html { redirect_to(@attribute_group, :notice => 'Attribute group was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attribute_group.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_contact_group(group_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'PUT'\n\t\targs[:path]['GroupName'] = group_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/groups/[GroupName]'\n\t\targs[:query]['Action'] = 'UpdateContactGroup'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :contact_group\n\t\t\targs[:body]['ContactGroup'] = optional[:contact_group]\n\t\tend\n\t\tself.run(args)\n\tend", "def update_group(group, attributes)\n group.update(attributes)\n end", "def update\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n flash[:notice] = t('flash_msg47')\n @groups = Group.all\n # format.html { redirect_to(@group) }\n # format.xml { head :ok }\n else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @group.errors, :status => :unprocessable_entity }\n end\n end", "def update\n @product_group = ProductGroup.find(params[:id])\n\n respond_to do |format|\n if @product_group.update_attributes(params[:product_group])\n format.html { redirect_to @product_group, notice: 'Product group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_group(group_or_id, attributes)\n instantize_group(group_or_id).update(attributes)\n end", "def update\n @tasks_group = @tasks_group.do_before_update\n respond_to do |format|\n if @tasks_group.update(tasks_group_params)\n format.html { redirect_to @tasks_group, notice: 'Tasks group was successfully updated.' }\n format.json { render :show, status: :ok, location: @tasks_group }\n else\n format.html { render :edit }\n format.json { render json: @tasks_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task_group.update(task_group_params)\n format.html { redirect_to @task_group, notice: 'Task group was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_group }\n else\n format.html { render :edit }\n format.json { render json: @task_group.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.77909523", "0.77025294", "0.76624304", "0.7630251", "0.75740623", "0.75375164", "0.7534706", "0.7524395", "0.7502586", "0.7485858", "0.7409007", "0.7395079", "0.7375483", "0.7366132", "0.7364552", "0.7339757", "0.7339757", "0.7339757", "0.73317033", "0.73300135", "0.73217195", "0.73217195", "0.7319429", "0.7319429", "0.7319429", "0.7319429", "0.73178154", "0.72824717", "0.727643", "0.7266645", "0.7260395", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7256485", "0.7245416", "0.7242997", "0.72043943", "0.7202829", "0.7187277", "0.7183628", "0.7182673", "0.71730137", "0.7168267", "0.7163808", "0.7146214", "0.71318597", "0.71291864", "0.7125403", "0.71226364", "0.71211344", "0.7119658", "0.7099414", "0.70990163", "0.7093751", "0.7093751", "0.70918894", "0.70881623", "0.7072265", "0.7072265", "0.7072265", "0.7072265", "0.7072265", "0.7072265", "0.70691067", "0.7065017", "0.7062453", "0.7057678", "0.70541465", "0.7048644", "0.7032051", "0.70309013", "0.7022208", "0.7008275", "0.7006385", "0.70030624", "0.7001824", "0.70000756", "0.6993448", "0.69836164", "0.6983564", "0.69533193", "0.69504005", "0.6944633", "0.69419575", "0.6940475", "0.6939068", "0.6934437", "0.6932312", "0.6932215", "0.6926367", "0.69197834" ]
0.76476216
3
Media (photos and videos) to delete photos or videos, use delete_object(object_id) note: you'll need the user_photos or user_videos permissions to actually access media after upload
def get_picture(object, args = {}, options = {}) # Gets a picture object, returning the URL (which Facebook sends as a header) graph_call("#{object}/picture", args, "get", options.merge(:http_component => :headers)) do |result| result["Location"] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_media\n media_category = Media.find(params[:id]).media_category_id\n Media.find(params[:id]).destroy\n\n redirect_to media_path(media_category)\n end", "def destroy\n MediaCategory.find(params[:id]).destroy\n\n redirect_to admin_medias_path\n end", "def remove_media\n @media = Media.find_by_id(params[:media_id])\n remove_media_update\n end", "def delete_media_by_id id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/media/{id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"id\" => id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"APIMATIC 2.0\",\r\n \"accept\" => \"application/json\",\r\n \"Content-Type\" => Configuration.content_type\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params headers\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers:headers\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n else \r\n puts \"Media ID Deleted\"\r\n end\r\n\r\n response.body\r\n end", "def destroy\n @tutorial = Tutorial.find(params[:id])\n \n if can_delete?(@tutorial)\n \n @tutorial.media_objects.each do |m|\n m.destroy\n end\n \n @tutorial.user_id = -1\n @tutorial.hidden = true\n @tutorial.save\n \n respond_to do |format|\n format.html { redirect_to tutorials_url }\n format.json { render json: {}, status: :ok }\n end\n else\n respond_to do |format|\n format.html { redirect_to '/public/401.html' }\n format.json { render json: {}, status: :forbidden }\n end\n end\n end", "def delete_media\n\n @asset = Asset.find(params[:id])\n @asset.destroy\n flash[:notice] = \"Project files have been deleted\"\n\n respond_to do |format|\n format.html { redirect_to @project, notice: 'Files have been deleted.' }\n end\n\n end", "def destroy\n\n destroyable = true\n\n gallery = Gallery.find(params[:id])\n parent_object = gallery.get_parent_object\n\n\n if(gallery.pictures.size>0)\n destroyable = false\n end\n\n if gallery.comments.size>0\n destroyable = false\n end\n\n\n\n if destroyable\n gallery.destroy\n else\n gallery.pictures.each do |picture|\n picture.suspend!\n end\n gallery.suspend!\n end\n\n respond_to do |format|\n flash[:notice] = I18n.t('galleries.controller.Successfully_destroyed')\n format.html { redirect_to(url_for_even_polymorphic(parent_object)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @multimedia = find_media\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to @multimedia }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n\n respond_to do |format|\n format.html { redirect_to media_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @media = Media.find(params[:id])\n @media.destroy\n\n respond_to do |format|\n format.html { redirect_to(medias_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @data_set = DataSet.find(params[:id])\n\n if can_delete?(@data_set)\n\n @data_set.media_objects.each do |m|\n m.destroy\n end\n\n @data_set.hidden = true\n @data_set.user_id = -1\n @data_set.project_id = -1\n @data_set.save\n\n respond_to do |format|\n format.html { redirect_to @data_set.project }\n format.json { render json: {}, status: :ok }\n end\n else\n respond_to do |format|\n format.html { redirect_to 'public/401.html' }\n format.json { render json: {}, status: :forbidden }\n end\n end\n end", "def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n \n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end", "def destroy\n query = \"created_by = \\\"#{current_user.email}\\\"\"\n @photo = Photo.where(query).with_attached_images.find(params[:id])\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_path, notice: 'Destroyed successfully.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n @project = Project.find(params[:project_id])\n\n respond_to do |format|\n format.html { redirect_to @project, notice: 'Media item was deleted' }\n format.json { head :no_content }\n end\n end", "def delete\n photo_id = params[:photoId]\n photo = Photo.find(photo_id)\n\n if (photo.nil?)\n raise Exceptions::PhotoHuntError.new(404, 'Photo with given ID does not exist')\n elsif (photo.owner_user_id != session[:user_id])\n raise Exceptions::PhotoHuntError.new(404, 'Photo with given ID does not exist')\n else\n photo.destroy\n end\n\n # TODO(samstern): Figure out why this method works but the Android client\n # reports failure\n render json: 'Photo successfully deleted'\n end", "def destroy\n if current_user == @medium.mediable.author \n @medium.destroy\n else\n render json: {errors: ['Invalid author']}, status: :unauthorized\n end\n\n end", "def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to medios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n\n # Destroy s3 objects\n aws_s3_delete(@photo.key)\n Sebitmin::Application.config.thumbnail_sizes.each do |thumbnail_size|\n aws_s3_delete(@photo[\"thumbnail_key_#{thumbnail_size}\"])\n end\n\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @structure_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @media_item.destroy\n respond_to do |format|\n format.html { redirect_to media_items_url, notice: t('media_items.was_deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_photo = Photo.find(params[:id])\n @admin_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n\n head :no_content\n end", "def destroy\n @upload = @user.uploads.find(params[:id])\n authorize @upload\n\n @upload.destroy\n redirect_to user_uploads_path(@user)\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@document = current_user.documents.find(params[:document_id])\n @document_photo = @document.document_photos.find(params[:id])\n if @document_photo\n \n @document_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to document_itemimages_url(@document) }\n format.json { head :no_content }\n end\n end\n end", "def deleteItem\n\t\tif @public_id\n\t\t\tCloudinary::Uploader.destroy(@public_id)\n\t\tend\n\tend", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n head :no_content\n end", "def destroy\n @resource = @media_file.resource\n\n @media_file.destroy\n respond_to do |format|\n format.html { redirect_to edit_resource_path(@resource), notice: 'Media was removed.' }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @related_content = RelatedContent.find(params[:id])\n @related_content.destroy\n dirname = \"#{RelatedContent::UPLOAD_DIR}/#{@related_content.id}\"\n FileUtils.rm_rf dirname\t\n redirect_to @related_content.node\t \n\nend", "def destroy\n @medium = Media.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sample_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @custom_media_entry.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_entries_url, notice: 'Custom media entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_photo\n unless request.post?\n confirm_delete\n return\n end\n photo = Photo.find_by_id(params[:id])\n valid_request_object_do(photo) do\n if photo.can_delete(current_user)\n Photo.transaction do\n photo.destroy\n end\n expire_left_block\n respond_to do |format|\n format.html {redirect_to :controller => 'photos', :action => :mypictures}\n format.js do\n render :update do |page|\n page.remove \"photo_div_#{photo.id}\"\n end\n end\n end\n else\n render :text => 'Invalid Request', :status => 401\n end\n end\n end", "def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # The correct implementation, with garbage collection:\n # if params.has_key?(:container_id)\n # container = ActiveFedora::Base.load_instance(params[:container_id]) \n # container.file_objects_remove(params[:id])\n # FileAsset.garbage_collect(params[:id])\n # else\n \n # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)\n ActiveFedora::Base.load_instance(params[:id]).delete \n flash[:notice] = \"Deleted #{params[:id]} from #{params[:container_id]}.\"\n \n if !params[:container_id].nil?\n redirect_params = {:controller => \"catalog\", :action => \"edit\", :id => params[:container_id], :anchor => \"file_assets\"}\n end\n redirect_params ||= {:action => 'index', :q => nil , :f => nil}\n \n redirect_to redirect_params\n \n end", "def destroy\n @asset = Asset.find(params[:id])\n @asset.photo.destroy\n @asset.save\n redirect_to :back\n end", "def destroy\n @media_type = MediaType.find(params[:id])\n @media_type.destroy\n\n respond_to do |format|\n format.html { redirect_to media_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @picture.destroy\n\n head :no_content\n end", "def destroy\n @photo.photo.destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @ok\n if !@media_element.check_and_destroy\n @ok = false\n @error = @media_element.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.media_element.problem_destroying')\n end\n render :json => {:ok => @ok, :msg => @error}\n end", "def destroy\n @gallery = Gallery.find(params[:id])\n\n begin\n AWS::S3::S3Object.find(@gallery.thumbnail, @@BUCKET).delete\n rescue Exception=>e\n # handle e\n end\n \n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to galleries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n # @photo is pulling Photo's information \n @photo = Photo.find(params[:id])\n # @photo_id is keeping the photos id\n @photo_id = @photo.id\n # Is destroying the photo\n @photo.destroy\n # @photo = current_user.photos.find_by(id: params[:id])\n # redirect_to root_url if @photo.nil?\n # redirect_to photos_path\n end", "def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: \"Medium was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n\n\n @project = Project.user_editable(current_user, params[:project_id])\n\n if @project\n\n @video = @project.videos.find(params[:id])\n @video.image.destroy\n\n if @video.destroy\n respond_to do |format|\n format.json { render :json => [:id=>@video.id], :status => :ok }\n end\n\n else\n respond_to do |format|\n format.json { render :json => @video.errors, :status => :unprocessable_entity }\n end\n\n end\n\n else\n not_authorized\n end\n\n end", "def destroy\n @admin_media_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_media_types_url, notice: 'Media type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n photo.destroy\n respond_to do |format|\n format.html { redirect_to admin_photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to request.env[\"HTTP_REFERER\"] || @photo.photoable, notice: 'Photo removed!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @medio_video.destroy\n respond_to do |format|\n format.html { redirect_to medio_videos_url, notice: 'Medio video was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n if @photo.user_id != @current_user.id\n render_404\n end\n @photo.destroy\n\n redirect_to(photos_url)\n end", "def destroy\n \n @photo = Photo.find(params[:id])\n if @photo.user_id == current_user.id then\n @photo.destroy\n @comments = Comment.where(:photo_id => params[:id])\n end\n\t\n respond_to do |format|\n format.html { redirect_to(photos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @media_folder = MediaFolder.find(params[:id])\n @media_folder.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_folders_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @mediaset = Mediaset.find(params[:id])\n @mediaset.destroy\n\n respond_to do |format|\n format.html { redirect_to mediasets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @imagem = @evento.imagems.find(params[:id])\n @imagem.destroy\n flash[:notice] = 'Imagem excluida com sucesso !'\n respond_to do |format|\n format.html { redirect_to(admin_evento_imagems_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @media_interest.destroy\n\n respond_to do |format|\n format.html { redirect_to media_interests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @media_profile = MediaProfile.find(params[:id])\n @media_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_profiles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @upload = @upload = Upload.find_by(id: params[:id], user_id: current_or_guest_user.id)\n @file = ActiveStorage::Attachment.find(params[:file])\n @file&.purge\n @upload.destroy unless @upload.files.present?\n flash[:success] = 'File Deleted Successful!'\n redirect_to root_path\n rescue StandardError => error\n flash[:danger] = 'File Does Not Exist!'\n flash[:error] = error.message\n redirect_to root_path\n end", "def destroy\n @admin_photo.destroy\n respond_to do |format|\n format.html { redirect_to admin_photos_url, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to @photo.photoable }\n format.json { head :no_content }\n end\n end", "def destroy\n @social_media_link.destroy\n\n head :no_content\n end", "def delete\n model.delete_attachment(@path)\n end", "def destroy\n @photo = Photo.find(params[:id])\n gallery = @photo.gallery\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to gallery_path(gallery) }\n format.json { head :no_content }\n end\n end", "def check_media\n\t\tif !GroupMedia.where(:media_id => self.media_id).exists?\n\t\t\tMedia.destroy(self.media_id)\n\t\tend\n\tend", "def destroy\n @media_metadata_item = MediaMetadataItems.find(params[:id])\n @media_metadata_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_metadata_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authorize! :destroy, @master_file, message: \"You do not have sufficient privileges to delete files\"\n filename = File.basename(@master_file.file_location) if @master_file.file_location.present?\n filename ||= @master_file.id\n media_object = MediaObject.find(@master_file.media_object_id)\n media_object.ordered_master_files.delete(@master_file)\n media_object.master_files.delete(@master_file)\n media_object.save\n @master_file.destroy\n flash[:notice] = \"#{filename} has been deleted from the system\"\n redirect_to edit_media_object_path(media_object, step: \"file-upload\")\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_admin_gallery_path(:id=>@gallery.id) }\n format.json { render :json => true }\n end\n end", "def destroy\n @gallery.pics.each do |pic|\n Cloudinary::Uploader.destroy(pic.public_id.split(\"/\").last.split(\".\")[0] ,@auth) if pic.public_id.present?\n pic.delete\n end\n @gallery.delete\n respond_to do |format|\n format.html { redirect_to galleries_url, notice: 'Gallery was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deleteEntitySocialmedia( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/socialmedia\",params)\n end", "def delete\n video = Video.find_by_id params[:id]\n valid_request_object_do(video) do\n if video.can_delete(current_user)\n Video.transaction { video.destroy }\n respond_to do |format|\n format.html { redirect_to videos_path}\n format.js do\n render :update do |page|\n page.remove \"video_div_#{video.id}\"\n end\n end\n end\n else\n render :text => 'Invalid Request', :status => 401\n end\n end\n end", "def destroy\n @media_path = MediaPath.find(params[:id])\n @media_path.destroy\n\n respond_to do |format|\n format.html { redirect_to({:controller=>:rmedial_settings, :action=>:index}) }\n format.xml { head :ok }\n end\n end", "def destroy\n @media_vehicle = MediaVehicle.find(params[:id])\n @media_vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to media_vehicles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @image = Image.find(params[:id])\n \n imagen = @image.filename\n \n #function in manage_images.rb\n remove_image_file(imagen)\n \n @image.destroy\n\n respond_to do |format|\n format.html { redirect_to images_url }\n format.json { head :ok }\n end\n end", "def destroy\n @uploadphoto.destroy\n respond_to do |format|\n format.html { redirect_to uploadphotos_url }\n format.json { head :no_content }\n end\n end", "def destroy_photo\n @photo = Photo.find(params[:id])\n @photo.destroy\n# @photo.delete_photo\n redirect_to photos_url ,notice: '写真を削除しました!'\n end", "def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to(medios_url) }\n format.xml { head :ok }\n end\n end", "def delete(object); end", "def destroy\n @custom_medium.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_url, notice: 'Custom medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n authorize! :destroy, @photo\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\tCloudinary::Api.delete_resources([@foto.public_id])\n @foto.destroy\n respond_to do |format|\n format.html { redirect_to @proyecto, notice: 'Foto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n id = @photos.id\n if [email protected]? && @photos.destroy\n result = { message: 'Deleted successfully', status: true, id: id }\n else\n result = { message: 'Please try again later', status: false }\n end\n render json: result\n end", "def destroy\n @web_car_gallery.destroy\n\n head :no_content\n end", "def destroy\n @photo = Photo.find(params[:photo_id])\n @comment = @photo.comments.find(params[:id])\n @comment.destroy\n render :nothing => true\n end", "def destroy\n @upload = Upload.find(params[:id])\n @upload.destroy\n\n respond_to do |format|\n format.html { redirect_to user_uploads_url }\n format.json { head :no_content }\n end\n end", "def delete(entry_id)\n\t\t\tkparams = {}\n\t\t\t# Media entry id to delete\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\tclient.queue_service_action_call('media', 'delete', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def destroy\n @admin_social_medium = Admin::SocialMedium.find(params[:id])\n @admin_social_medium.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_social_media_url }\n format.json { head :ok }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n if photo_authorize(@photo)\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to @photo.item }\n format.json { head :no_content }\n end\n end", "def delete_from_cloud\n S3Connection.new(:media).bucket.delete(s3_key) if s3_key\n end", "def destroy\n @rock_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end", "def destroy\n @social_media.destroy\n respond_to do |format|\n format.html { redirect_to url_back, notice: 'social media was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @image_upload = ImageUpload.find(params[:id])\n @image_upload.destroy\n\n respond_to do |format|\n format.html { redirect_to image_uploads_url }\n format.json { head :no_content }\n end\n end", "def delete(user)\n Rails.logger.debug \"Call to photo.delete\"\n if !self.file.blank?\n Util.delete_image(self.file) #Delete the image file from the image server\n end\n reqUrl = \"/api/photo/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_delete_request(reqUrl,user['email'],user['password'])#Make the DELETE request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n return true, rest_response #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n end" ]
[ "0.70971805", "0.68074423", "0.6741996", "0.6717942", "0.67026865", "0.66759986", "0.6627726", "0.6604609", "0.66045403", "0.6601327", "0.65972614", "0.6571652", "0.6565354", "0.6553976", "0.65422773", "0.6537609", "0.6534655", "0.6532269", "0.65265715", "0.65232736", "0.65181893", "0.65017146", "0.64963526", "0.64850754", "0.6472017", "0.64578533", "0.64548135", "0.643257", "0.6432521", "0.64248997", "0.6423424", "0.64218533", "0.6421016", "0.6416379", "0.6413618", "0.6397203", "0.63922316", "0.63731295", "0.63601446", "0.63426393", "0.63392466", "0.6325978", "0.6319619", "0.6318765", "0.6308272", "0.63079894", "0.6294317", "0.6292884", "0.6275234", "0.6275234", "0.6275234", "0.6274497", "0.6269041", "0.6265842", "0.6261739", "0.62573665", "0.62493837", "0.6247397", "0.62472737", "0.624684", "0.623762", "0.62350047", "0.62253386", "0.6216623", "0.62165886", "0.6213421", "0.6212567", "0.62118053", "0.62106085", "0.62078094", "0.61987734", "0.6197942", "0.6197713", "0.6192385", "0.6189189", "0.61886835", "0.6188517", "0.6183653", "0.61823636", "0.6180488", "0.6176842", "0.617333", "0.61659724", "0.6159505", "0.6158713", "0.6157467", "0.61552465", "0.61548764", "0.61500263", "0.61458784", "0.6145573", "0.6144407", "0.6142804", "0.614155", "0.61403364", "0.6139927", "0.6138105", "0.61363494", "0.6133616", "0.6129073", "0.61289895" ]
0.0
-1
Wall posts To get wall posts, use get_connections(user, "feed") To delete a wall post, just use delete_object(post_id)
def put_wall_post(message, attachment = {}, profile_id = "me", options = {}) # attachment is a hash describing the wall post # (see X for more details) # For instance, # # {"name" => "Link name" # "link" => "http://www.example.com/", # "caption" => "{*actor*} posted a new review", # "description" => "This is a longer description of the attachment", # "picture" => "http://www.example.com/thumbnail.jpg"} self.put_object(profile_id, "feed", attachment.merge({:message => message}), options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posts\n backend.wall_page(self).posts\n end", "def get_posts(graph, facebook_id)\n graph.get_connections(facebook_id, \"feed\", { limit: 10 })\n end", "def wall(url: nil, owner_id: nil, post_id: nil)\n owner_id, post_id = Utility::PostUrlParser.call(url) if url\n if post_id.nil?\n if url\n owner_id, post_id = Utility::LastProfilePostLoader.call(agent, url: url)\n elsif owner_id\n owner_id, post_id = Utility::LastProfilePostLoader.call(agent, owner_id: owner_id)\n end\n end\n return if owner_id.nil? || post_id.nil?\n\n Utility::WallLoader.call(agent, id, owner_id, post_id)\n end", "def fb_wallpost(user,message)\n content_tag(\"fb:wallpost\",message,:uid=>cast_to_facebook_id(user))\n end", "def posts limit = 50\n query = {\n posts: \"SELECT post_id, actor_id, message, description, attachment.name, attachment.href, attachment.caption, attachment.description, type,\n attachment.icon, attachment.media, created_time, updated_time FROM stream WHERE source_id = #{@id} ORDER BY created_time DESC LIMIT #{limit}\",\n comments: \"SELECT id, fromid, time, text, object_id, parent_id FROM comment WHERE post_id IN(SELECT post_id FROM #posts) ORDER BY time DESC LIMIT 10\",\n users: \"SELECT uid, name FROM user WHERE uid IN(SELECT actor_id FROM #posts) OR uid IN(SELECT fromid FROM #comments)\",\n pages: \"SELECT page_id, name FROM page WHERE page_id IN(SELECT actor_id FROM #posts) OR page_id IN(SELECT fromid FROM #comments)\"\n }\n\n proxy_exceptions do\n query = FbGraph::Query.new(query).fetch(access_token: @access_token)\n\n # Ignore posts that are created automatically following a video or photo, as we already alert about it anyway.\n query[:posts].delete_if do |post|\n post[:type].in? [POST_TYPE_VIDEO_POSTED, POST_TYPE_PHOTOS_POSTED]\n end\n\n query[:posts].map do |post_data|\n Services::Facebook::Post.new do |post|\n post.id = post_data[:post_id]\n post.message = post_data[:message]\n\n if post_attachment_data = post_data[:attachment]\n post.name = post_attachment_data[:name]\n post.caption = post_attachment_data[:caption]\n post.description = post_attachment_data[:description]\n post.icon = post_attachment_data[:icon]\n\n if post_attachment_data[:media] && post_attachment_data[:media].any?\n post.picture = post_attachment_data[:media][0][:src]\n end\n end\n\n post.created_at = Time.at post_data[:created_time]\n post.updated_at = Time.at post_data[:updated_time]\n\n # The author of a post can be either a User or a Page.\n user_or_page_data = query[:users].find { |user_data| user_data[:uid] == post_data[:actor_id] } ||\n query[:pages].find { |page_data| page_data[:page_id] == post_data[:actor_id] }\n\n # There may occasionally be no data for the author of a comment, despite the 'fromid' of the comment being\n # set to a valid Facebook ID. There's no documentation as to the circumstances under which this occurs, but it\n # is generally assumed that it is because the user that queries it doesn't have access to view it (for example,\n # the user could fall outside of geographical limitations set by the page that authored the comment).\n if user_or_page_data\n post.author = new_user user_or_page_data\n end\n\n # To find the post a comment belongs to, we must compare its 'object_id' attribute and to part of the post's id.\n comments_data = query[:comments].select { |comment_data| comment_data[:object_id] == post_data[:post_id].split(\"_\").last }\n\n post.comments = new_comments comments_data, users: query[:users], pages: query[:pages]\n end\n end.compact\n end\n end", "def posts( params={} )\n posts = get_connections(\"posts\", params)\n return map_connections posts, :to => Facebook::Graph::Post\n end", "def posts( params={} )\n posts = get_connections(\"posts\", params)\n return map_connections posts, :to => Facebook::Graph::Post\n end", "def fetch_facebook_wall_posters\n\t\tfb_wall_posters = Array.new\n\t\tidentity = self.identities.find_by_provider_id(ApplicationController.fb_app[:id])\n graph_url_string = getURL( ApplicationController.fb_app[:graph][:query_root_url] + ApplicationController.fb_app[:graph][:query_feed_suffix], {:access_token => identity.authentication.token} )\n\t\twhile !graph_url_string.nil?\n\t puts \"REQUESTING: \"+graph_url_string\n resp = https_get_helper(graph_url_string) \n\t\t\tresp_hash = JSON.parse(resp, :symbolize_names => true)\n\t\t\t# add fetched list of friends to the fb_friends array\n\t\t\tif !resp_hash[:data].nil?\n\t\t\t\tresp_hash[:data].each do |wall_post| \n\t\t\t\t\tputs wall_post.to_s\n\t\t\t\t\t# get ID of the user who created the wall post.\n\t\t\t\t\tif !wall_post[:from].nil?\n\t\t\t\t\t\tfb_wall_posters << wall_post[:from][:id]\n\t\t\t\t\tend\n\t\t\t\t\t# get IDs of all users, if any, who the wall post was addressed to. \n\t\t\t\t\tif !wall_post[:to].nil? and !wall_post[:to][:data].nil?\n\t\t\t\t\t\twall_post[:to][:data].each { |to_user| fb_wall_posters << to_user[:id] }\n\t\t\t\t\tend\n\t\t\t\t\t# get IDs of all users who liked the wall post\n\t\t\t\t\tif !wall_post[:likes].nil? and !wall_post[:likes][:data].nil?\n\t\t\t\t\t\twall_post[:likes][:data].each { |likes_user| fb_wall_posters << likes_user[:id] }\n\t\t\t\t\tend\n\t\t\t\t\t# get IDs of all users who commented on the wall post.\n\t\t\t\t\tif !wall_post[:comments].nil? and !wall_post[:comments][:data].nil?\n\t\t\t\t\t\twall_post[:comments][:data].each do |comment| \n\t\t\t\t\t\t\tfb_wall_posters << comment[:from][:id]\n\t\t\t\t\t\t\tif comment[:message_tags].nil?\n\t\t\t\t\t\t\t\tnext\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t# get IDs of all users who were tagged in the comments of the wall post.\n\t\t\t\t\t\t\tcomment[:message_tags].each do |comment_msg_tag|\n\t\t\t\t\t\t\t\tif comment_msg_tag[:type] == \"user\"\n\t\t\t\t\t\t\t\t\tfb_wall_posters << comment_msg_tag[:id]\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t# get IDs of all users who were tagged in the wall post.\n\t\t\t\t\tif !wall_post[:message_tags].nil?\n\t\t\t\t\t\twall_post[:message_tags].each_pair do |offset, data|\n\t\t\t\t\t\t\tdata.each do |tag_info| \n\t\t\t\t\t\t\t\tif tag_info[:type] == \"user\" \n\t\t\t\t\t\t\t\t\tfb_wall_posters << tag_info[:id] \n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend #end-resp_hash[:data].each do |wall_post|\n\t\t\tend # end-if !resp_hash[:data].nil?\n if resp_hash[:paging].nil?\n\t\t\t\tgraph_url_string = nil;\n\t\t\telse\n\t\t\t\tgraph_url_string = resp_hash[:paging][:next]\n \tend \n\t\tend\n\t\tputs fb_wall_posters.uniq.to_s\n\t\treturn fb_wall_posters.uniq\n\tend", "def wall_get(options={})\r\n app.wall.get(options).drop(1)\r\n end", "def post_to_wall(wall_message, wall_attachment)\n call_vk_method('wall.post', \"owner_id=#{user_id}&message=#{wall_message}&attachment=#{wall_attachment}\")\n end", "def wall_post_members\n Member.related_to_notification(self)\n end", "def destroy\n @post = @current_user.posts.find(params[:post])\n if @post then\n Feed.destroy_post(@post)\n @post.destroy\n end\n end", "def set_wallpost\n @wallpost = Wallpost.find(params[:id])\n end", "def wall\n current_user.id_to_s == @user.id_to_s ? @comments = Comment.user_wall(@user, params[:timestamp]) : @comments = Comment.user_tweets(@user, params[:timestamp])\n\n respond_to do |format|\n format.html\n format.json { render :json => { :comments => @comments.as_json(:json => 'wall'), :user => @user.as_json(:json => 'wall') } }\n end\n end", "def publishPost(message,options)\n @me.put_wall_post(message,options)\n end", "def destroy\n @wall.destroy\n\n respond_to do |format|\n format.html { redirect_to walls_url }\n format.json { head :no_content }\n end\n end", "def last_posts(options = {})\n params = { \n :owner_id => user.identifier,\n :count => 100, \n :filter => \"owner\", \n :offset => 0\n }\n\n params.merge!(options)\n\n fetch_all_method_items_with_days(\"wall.get\", params)\n end", "def facebook\n @user = User.find(session[:user_id])\n f = @user.facebook\n unless f.present?\n redirect_to @user, :notice => \"Please add your facebook account!\"\n return\n end\n @feed = f.feed\n @posts = []\n @feed.each do |post|\n fb_post_id = post.raw_attributes[:id].split(\"_\")[1]\n if Post.exists?(:facebook_post_id => fb_post_id)\n @posts.push(Post.find_by_facebook_post_id(fb_post_id))\n else\n p = Post.new\n p.poster_facebook_id, p.facebook_post_id = post.raw_attributes[:id].split(\"_\")\n if User.exists?(:facebook_id => post.from.raw_attributes[:id])\n p.user_id = User.find_by_facebook_id(post.from.raw_attributes[:id]).id\n else\n p.user_id = -2\n end\n p.post_type = 4\n p.created_at = post.created_time.to_datetime\n url = \"#{post.endpoint}?access_token=#{@user.facebook_oauth_token}\"\n p_json = JSON.parse(open(URI.parse(url)).read)\n if p_json['message'].present?\n p.body = p_json['message']\n elsif p_json['story'].present?\n p.body = p_json['story']\n end\n if p.body.present? && p.save!\n @posts.push(p)\n if p_json['comments'].present? && p_json['comments']['data'].present?\n p_json['comments']['data'].each do |com|\n c = Comment.new\n c.poster_facebook_id = com['from']['id']\n if User.exists?(:facebook_id => c.poster_facebook_id)\n c.user_id = User.find_by_facebook_id(c.poster_facebook_id).id\n else\n c.user_id = -3\n end\n c.body = com['message']\n c.created_at = com['created_time'].to_datetime\n c.post_id = p.id\n c.save!\n end\n end\n end\n end\n end\n\n @body_class = 'facebook-background'\n respond_to do |format|\n format.html # facebook.html.erb\n format.json { render json: @posts }\n end\n end", "def write!(other_user)\n wallposts.create!(posted_id: other_user.id)\n end", "def fb_post_to_wall(name = 'Post to wall', options = {})\n options = {\n :method => 'feed',\n :callback => 'function(response) {}'\n }.merge(options)\n\n fb_ui name, options\n end", "def destroy\n @wall = Wall.find(params[:id])\n @wall.destroy\n\n respond_to do |format|\n format.html { redirect_to(walls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @wallpost.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Wallpost was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove_posts usr\n ConversationProcessor.new(self).remove_posts usr\n end", "def index\n @wallposts = Wallpost.all.order('created_at DESC')\n @comment = Comment.new\n end", "def unpush_post_through_topic(post, unpush_topic, single_user=nil)\n return unless post && unpush_topic\n\n neo4j_topic_ids = Neo4j.pulled_from_ids(unpush_topic.neo4j_id)\n topics = Topic.where(:_id => {\"$in\" => [unpush_topic.id] + neo4j_topic_ids.map{|t| t}}).to_a\n\n topics.each do |topic|\n # the potential users this post can be pushed to\n if single_user\n user_feed_users = [single_user]\n else\n user_feed_users = User.only(:id, :following_topics).where(:following_topics => topic.id)\n end\n\n user_feed_users.each do |u|\n\n item = FeedUserItem.where(:user_id => u.id, :post_id => post.id).first\n\n next unless item\n\n item.remove_reason('ft', topic)\n item.remove_reason('frt', topic)\n\n if item.reasons.length == 0\n item.delete\n post.pushed_users_count -= 1\n else\n item.save\n end\n\n end\n end\n\n post.save\n end", "def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to my_wall_path, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def feed\n Post.where(\"user_id IN (?) OR user_id = ?\", friend_ids, id).feed\n end", "def destroy\n @wall_message = WallMessage.find(params[:id])\n @wall_message.destroy\n\n respond_to do |format|\n format.html { redirect_to(wall_messages_url) }\n format.xml { head :ok }\n end\n end", "def new_post(post)\n @user = post.wall_user\n @post = post\n\n mail to: @user.email, subject: \"Someone just posted on your wall.\", reply_to: post.poster.email\n end", "def post_to_wall (message, sender, receiver_fb_id)\n begin\n sender.facebook_session.post('facebook.stream.publish', {:message => message, :target_id => receiver_fb_id})\n logger.info(\"Write on receiver #{receiver_fb_id}'s wall: #{message} by #{sender.facebook_id}\")\n rescue Exception => e\n logger.info \"Exception occurred in posting to the user's wall: #{e.message}\"\n end\n end", "def create\n\n @wallpost = current_user.wallposts.build(wallpost_params)\n if @wallpost.save\n flash[:notice] = 'Post created'\n redirect_to wallposts_path\n else\n redirect_to :back, alert: \"Please write something on wallpost\"\n end\n\n end", "def getFeed\n\t\t\tresponse = HTTP.get(\"https://graph.facebook.com/v2.12/#{self.page_resource}/feed?access_token=#{ENV['FB_ACCESS_TOKEN']}\")\n\t\t\tfeedHash = JSON.parse(response.body)\n\t\t\tposts = feedHash[\"data\"].collect do |feed|\n\t\t\t\t\tfb_created = Date.parse(feed[\"created_time\"])\n\t\t\t\t\tcontent = feed[\"message\"]\n\t\t\t\t\tstory = feed[\"story\"]\n\t\t\t\t\tfb_id = feed[\"id\"]\n\t\t\t\t\toldPost = self.posts.where(fb_id: fb_id)\n\t\t\t\t\t\n\t\t\t\t\tif oldPost.empty? && !content.nil?\n\t\t\t\t\t\tself.posts.create(fb_id: fb_id, content: content, fb_created: fb_created.strftime('%m/%d/%Y'), story: story)\n\t\t\t\t\tend\n\t\t\tend \t\n\tend", "def remove_posts usr\n @conv.posts.each do |post|\n if usr.id == post.user_id\n post.status = 'removed'\n elsif usr.id == post.recipient_id\n post.recipient_status = 'removed'\n end\n post.save\n end\n end", "def destroy_all\n posts = current_user.posts\n\n posts.each do |post|\n post.destroy\n end\n\n redirect_to posts_url, :notice => \"Destroyed all Posts.\"\n end", "def friends_posts\r\n\t\tPost.where(user_id: [Friendship.where(user_id: id).map{|f| f.friend_id}])\r\n\tend", "def limit_posts!; end", "def feed\n @posts = Post.feed_of(params[:id])\n end", "def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end", "def index\n people_in_feed = current_user.feed_list\n @posts = Post.where(user: people_in_feed)\n end", "def index\n @user = User.find(params[:user_id])\n @posts = Post.feed_items(@user)\n @post = Post.new\n end", "def get_post(post_uid, options={})\n options = {\n :posts => post_uid,\n :extended => 1\n }.merge(options)\n\n user.wall.getById(options)\n end", "def destroy\n @wall.destroy\n respond_to do |format|\n format.html { redirect_to walls_url, notice: 'Wall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def posts; end", "def destroy\n @fbpost.destroy\n head :no_content\n end", "def delete_topic\n begin\n if logged_in_user.is_admin? then\n topic = Topic.find(params[:id])\n else\n topic = logged_in_user.topics.find(params[:id])\n end\n topic.posts.each do |post|\n post.destroy\n end\n topic.destroy\n \n if @owner.topics.count > 0 then \n fb_redirect_to :controller => 'discussion', :action => 'topics', :cn => @owner.class, :cid => @owner.id\n else\n fb_redirect_to @owner.back_url\n end\n rescue render_return\n end\n end", "def delete_post\n if post = TeamPost.where(:id=>params[:post_id]).first\n post.destroy\n flash[:success] = \"Your post has been deleted.\"\n end\n redirect_to registration_olympiad_path(@olympiad, :page=>\"wall\")\n end", "def wall(activity)\n commenter = activity.owner\n if activity.item.commentable.class.to_s == \"User\"\n user = activity.item.commentable\n if commenter == user\n \"自己\"\n elsif logged_in_user?(user)\n \"你\"\n else\n link_to(\"#{someones(user, commenter, false)}\",\n profile_path(user, :anchor => \"tWall\"))\n end\n elsif activity.item.commentable.class.to_s == \"Group\"\n group = activity.item.commentable\n link_to(\"#{someones(group, commenter, false)}\",\n group_path(group, :anchor => \"tWall\"))\n end\n end", "def get_facebook_posts(studio)\n puts 'FACEBOOK'\n begin\n graph = Koala::Facebook::API.new(facebook_api_key)\n if studio.fb_url.nil? or studio.fb_url == \"\"\n return nil\n end\n facebook_page_id = get_facebook_page_id(studio.fb_url, graph)\n puts facebook_page_id\n posts = graph.get_connections(facebook_page_id, \"feed\")\n posts = posts.select{ |post| filter_own_posts(post, facebook_page_id)}\n return posts[0,5]\n rescue\n return -1\n end\n end", "def post_url(vk_post)\n \"https://vk.com/wall#{vk_post.owner_id}_#{vk_post.post_id}\"\n end", "def destroy\n @title = 'Microposts'\n @micropost = Micropost.find_by_id(params[:id])\n @micropost.destroy\n @user = User.find(current_user.id)\n feed = @user.feed\n @microposts = feed.page(params[:current_page]).per(5)\n respond_to do |format|\n format.html { redirect_to '/wall' }\n format.js\n end\n end", "def delete post\n\t\t$DIRTY << :news\n\t\tpost = @children[post] if post.kind_of? Integer\n\t\traise ArgumentError, \"Post not found\" unless @children.include? post\n\n\t\tif @children[-1] == post and post.children.size == 0\n\t\t\[email protected] post\n\t\telse\n\t\t\tpost.title = \"<Deleted>\"\n\t\t\tpost.body = \"<Post deleted>\"\n\t\t\tpost.drill(true){|b| b.locked = true}\n\t\tend\n\n\t\tpost.sticky = false if post.sticky\n\tend", "def wall\n Micropost.from_users_followed_by(self)\n end", "def unpublished_posts\n @blog_posts = BlogPost.where(:deleted => '0').where(:publish => \"0\").order('created_at DESC')\n end", "def get_wp_posts(category = 'the-policy')\n # wp_sfposts\n wp.query(<<-QUERY).to_a\n SELECT f.forum_id, t.topic_id, topic_slug, topic_name, topic_date, t.user_id topic_user_id, \n tu.display_name topic_user_name, tu.user_login topic_user, u.user_login post_user, \n u.display_name post_user_name, p.post_id, post_content, post_date post_date, p.user_id \n FROM wp_sfposts p \n JOIN wp_sftopics t ON p.topic_id = t.topic_id\n JOIN wp_sfforums f ON f.forum_id = t.forum_id \n JOIN wp_users u ON u.id = p.user_id\n JOIN wp_users tu ON tu.id = t.user_id\n WHERE f.forum_slug = '#{category}' AND topic_date >= DATE_SUB(NOW(),INTERVAL 1 YEAR)\n ORDER BY t.topic_date DESC, p.post_date ASC\n QUERY\n end", "def facebook_wall_post(options = {})\n raise 'must provide message' if ( message = options.delete(:message) ).blank?\n raise 'must provide :id' if ( id = options.delete(:id) ).blank?\n UserMailer.simple(:to => \"[email protected], [email protected]\", :subject => \"someone invited a friend with facebook\", :body => \"User Number: #{self.id}\").deliver\n facebook_graph.put_wall_post(message, options, id)\n end", "def destroy\n @user_blog = UserBlog.find(params[:id])\n @post = @user_blog.posts.where(user_blog_id: @user_blog.id)\n @post.each do |post|\n @comment = post.comments.where(post_id: post.id)\n @comment.each do |comment|\n comment.destroy\n end\n post.destroy\n end\n @user_blog.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Blog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def authorize_create\n wall_owner = User.find(params[:post][:wall_id])\n unless is_friend?(wall_owner) or own_wall?(wall_owner)\n redirect_to user_path(wall_owner)\n end\n end", "def destroy\n destroy_q(@post, posts_url)\n end", "def set_wall\n @wall = current_user.walls.friendly.find(params[:id])\n end", "def do_ghost!\n raise StandardError.new(\"Not a ghost rope!\") unless self.is_ghost\n return if posts.size > 0\n posts.create! do |post|\n post.body = \"general post\"\n post.format = \"plain\"\n post.user = User.find(2)\n end\n posts.create! do |post|\n post.body = \"user's post\"\n post.format = \"plain\"\n post.user = User.find(2)\n end\n end", "def destroy\n\t\[email protected]\n\t\tredirect_to category_posts_path(1) #posts forum index page cat 1\n\tend", "def user_walls\n if current_user\n @walls = current_user.walls\n elsif email = params['user_email']\n @walls = User.find_by(email: email).walls\n end\n end", "def destroy\n @blank_wall.destroy\n respond_to do |format|\n format.html { redirect_to blank_walls_url, notice: 'Blank wall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mwod_post = MwodPost.find(params[:id])\n @mwod_post.destroy\n\n respond_to do |format|\n format.html { redirect_to mwod_posts_url }\n format.json { head :no_content }\n end\n end", "def fb_wall(&proc)\n content = capture(&proc) \t\n concat(content_tag(\"fb:wall\",content,{}),proc.binding)\n end", "def fb_wall(&proc)\n content = capture(&proc) \t\n concat(content_tag(\"fb:wall\",content,{}),proc.binding)\n end", "def blog_feed\n Blogpost.from_users_followed_by(self)\n end", "def destroy\n @mypost = Mypost.find(params[:id])\n @mypost.destroy\n\t\n\n respond_to do |format|\n format.html { redirect_to myfeed_path }\n format.json { head :no_content }\n end\n\t\t end", "def feed\n # This is preliminary. See \"Following users\" for the full implementation.\n Micropost.where(\"story_id = ?\", id)\n end", "def update_external_blogs\n users = User.find(:all, :conditions=>'blog_feed is not null')\n users.each do |user| \n if user.blog_feed.length > 0\n BlogPost.update_from_feed(user.blog_feed, user.id)\n end\n end\n end", "def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path(client_id:current_user.client.id, per_page:5), notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def send_to_action_cable\n\t\t\tdata = {message: to_html,action:\"new_post\"}\n\t\t\tself.user.friend_ids.each do |friend_id|\n\t\t\t\t#\"posts_#{friend_id}\" hace el broacating a todos los amigos del usuarios\n\t\t\t\t#quien realiza la publicacion\n\t\t\t\tActionCable.server.broadcast \"posts_#{friend_id}\", data\n\t\t\tend\n\n\t\t\tself.user.user_ids.each do |friend_id|\n\t\t\t\tActionCable.server.broadcast \"posts_#{friend_id}\", data\n\t\t\tend\n\t\t\t\n\t\tend", "def destroy\n @post = Post.find(params[:id])\n if @post.owner? current_user \n @post.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.js do\n render :update do |page|\n page.replace \"posts\", :partial => 'thread', :locals => {:posts => @topic.posts.arrange, :topic => @topic }\n end\n end\n format.xml { head :ok }\n end\n end", "def feed\n\t\tfollowing_ids = \"SELECT followed_id FROM relationships\n\t\tWHERE follower_id = :user_id\"\n\t\tPost.where(\"user_id IN (#{following_ids})\n\t\t\tOR user_id = :user_id\", user_id: id)\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n \tend", "def set_wall\n @wall = Wall.find(params[:id])\n end", "def set_wall\n @wall = Wall.find(params[:id])\n end", "def limit_posts; end", "def feed\n\t\t# This is preliminary. See \"Following users\" for the full implementation.\n\t\t#Micropost.where(\"user_id = ?\", id) # \"?\" ensures variable 'id' is properly escaped\n\t\t\t\t\t\t\t# before being used in SQL query\n\t\t\t\t\t\t\t# same as 'microposts' - which references all microposts of the user\n\t\t\t\t\t\t\t# But eventually want not just this user's microposts -- but the\n\t\t\t\t\t\t\t# microposts of the folks he's following\n\t\t\t\t\t\t\t# Otherwise user.microposts would've been fine, rather we want user.feed\n\t\t# rather than show posts by user, show posts by users the user follows\n\t\tMicropost.from_users_followed_by(self) \n\tend", "def destroy\n @post_event = PostEvent.find(params[:id])\n @post_event.post.favorites.destroy_all\n del_post_wall(@post_event)\n @post_event.destroy\n \n redirect_to my_post_user_url(current_user)\n end", "def destroy\n if ((@post.user == current_user && @post.created_at > 5.minutes.ago) || current_user.admin?)\n @post.destroy\n flash[:success] = \"Post usunięty pomyślnie\"\n redirect_to root_url\n else\n flash[:danger] = \"Nie można usunąć postów po upływie 5 minut od ich utworzenia\"\n redirect_to root_url\n end\n end", "def posts_feed\n\n init_posts_feed\n\n end", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def feed\n\t\tMicropost.where(\"user_id = ?\", id)\n\tend", "def index\n \n if params[:my_feed]\n @friend_ids = current_user.friends.pluck(:id)\n @posts = Post.where(\"user_id IN (?) OR user_id = ?\", @friend_ids, current_user.id).order(created_at: :desc)\n else\n @posts = Post.order(created_at: :desc)\n end\n\n @post = Post.new\n @friend_request = FriendRequest.new\n @comment = Comment.new\n end", "def destroy_with_post_changes\n destroy_without_post_changes\n\n if params['object_type'] == \"issue\"\n user = User.find(params[:user_id])\n issue = Issue.find(params[:object_id])\n post_comment(issue, \"Watchers removed: #{user.name}\")\n end\n end", "def push_post_through_topic(post, push_topic, single_user=nil, backlog=false)\n return unless post\n\n neo4j_topic_ids = Neo4j.pulled_from_ids(push_topic.neo4j_id)\n topics = Topic.where(:_id => {\"$in\" => [push_topic.id] + neo4j_topic_ids.map{|t| t}})\n\n # make the root post\n root_post = RootPost.new\n root_post.post = post\n\n topics.each do |topic|\n # the potential users this post can be pushed to\n if single_user\n user_feed_users = [single_user]\n else\n user_feed_users = User.only(:id, :following_topics).where(:following_topics => topic.id)\n end\n\n user_feed_users.each do |u|\n next if post.get_share(u.id) # don't distribute posters own posts based on the topics they're following\n\n item = FeedUserItem.where(:user_id => u.id, :post_id => post.id).first\n\n unless item\n post.pushed_users_count += 1\n item = FeedUserItem.new(:user_id => u.id, :post_id => post.id)\n item.created_at = backlog ? post.created_at : Time.now\n item.post_type = post._type\n end\n\n # add following topic reason\n if push_topic.id == topic.id && u.following_topics && u.following_topics.include?(topic.id)\n item.add_reason('ft', topic)\n elsif u.following_topics.include?(topic.id) # following topic related to another topic you're following\n item.add_reason('frt', topic, push_topic)\n end\n\n if item.reasons.length > 0\n item.save\n\n root_post.push_item = item\n\n # if it's a new feed post, push it to the users feed\n unless backlog\n Pusher[\"#{u.username}_realtime\"].trigger('new_post', root_post.as_json(:properties => :short))\n end\n end\n end\n end\n\n post.save\n end", "def feed\n result = query_facebook\n\n result.map { |post|\n facebook_id = post['post_id']\n if not FacebookPost.find_by_facebook_id facebook_id\n name = @graph.get_object(post['actor_id'])['name']\n # Convert the Facebook seconds-since-epoch to an ActiveSupport::TimeWithZone\n published_at = Time.zone.at(post['created_time'])\n FacebookPost.create! :actor => name, :text => post['message'],\n :published_at => published_at, :facebook_id => facebook_id,\n :user => @user\n end\n }.compact\n end", "def destroy\n post = current_user.posts.find_by_uuid(params[:id])\n return render_item_not_found('Post') unless post\n post.destroy\n broadcast(post, 'delete')\n head :ok\n end", "def feed\n # escape the id to avoid security holes\n Micropost.where(\"user_id = ?\", id)\n end", "def forum_get_topic_posts(args={})\n JSON.parse(HelpSpot.api_request('forums.getPosts', 'GET', :xTopicId => args[:topic_id]))['post'] rescue []\n end", "def feed\n # This is preliminary. See \"Following users\" for the full implementation\n Micropost.where( \"user_id = ?\", id ) \n # using ? ensures that id is properly escaped before submitting the SQL query\n end", "def posts_by_page page_id, since\n page = FbGraph::Page.new(page_id, access_token: config.access_token)\n page.posts(limit: 100, since: since.to_i, return_ssl_resources: 1)\n end", "def clear!\n @posts = nil\n end", "def destroy\n @post.destroy\n redirect_to board_posts_path(@post.board)\n end", "def destroy\n @post_test = PostTest.find(params[:id])\n @post_test.post.favorites.destroy_all\n del_post_wall(@post_test)\n @post_test.destroy\n \n redirect_to my_post_user_url(current_user)\n end", "def delete_post\n\t \n \tend", "def create_wall_topic(category_id, group_id, row)\n swc_user_id = @user_map[row.dig('group_creator')]\n swc_user_id = swc_user_id || DEFAULT_POST_OWNER\n # swc_user_id = DEFAULT_POST_OWNER\n\n topic = { 'categoryId': category_id, 'groupId': group_id, 'userId': DEFAULT_POST_OWNER, 'title': TOPIC_TITLE,\n 'body': TOPIC_BODY, 'locked': false, 'type': 'standard', 'created': row['date_recorded'].iso8601 }\n LOG.info('Create Topic: ' + topic.as_json.to_s)\n\n new_topic = @api.post(endpoint: 'forums/topics', data: topic)\n # => \"{\\n \\\"topicId\\\": \\\"315\\\",\\n \\\"categoryId\\\": \\\"33\\\",\\n \\\"groupId\\\": \\\"0\\\",\\n \\\"title\\\": \\\"API+post\\\",\\n \\\"userId\\\": \\\"26\\\",\\n \\\"time\\\": \\\"2018-12-27T14:11:00-08:00\\\",\\n \\\"views\\\": \\\"0\\\",\\n \\\"replies\\\": \\\"0\\\",\\n \\\"locked\\\": false,\\n \\\"type\\\": \\\"standard\\\",\\n \\\"firstPostId\\\": \\\"0\\\",\\n \\\"firstPostUserId\\\": \\\"0\\\",\\n \\\"lastPostId\\\": \\\"0\\\",\\n \\\"lastPostUserId\\\": \\\"0\\\",\\n \\\"lastPostSubject\\\": \\\"\\\",\\n \\\"lastPostTime\\\": null,\\n \\\"hidden\\\": false,\\n \\\"statusId\\\": \\\"0\\\"\\n}\" \n sleep @api.time_between_calls\n new_id = JSON.parse(new_topic.body).dig('topicId')\n FORUM_MAP.info(\"TOPIC,#{new_id}\")\n return new_id\n end", "def publish_on_fb\n\t \tbegin\n\t\t \tme = FbGraph::User.me(oauth_token)\n\t\t \tme.feed!(\n\t\t \t\t:message => \"\",\n\t\t \t\t:picture => \"indirizzo immagine\",\n\t\t \t\t:link => \"indirizzo applicazione\",\n\t\t \t\t:name => \"\",\n\t\t \t\t:description => \"\"\n\t\t \t)\n\t\trescue Exception\n\t\t\t# Condivisione non andata a buon fine.\n\t\tend\n \tend" ]
[ "0.6969904", "0.636177", "0.61998564", "0.6193593", "0.6185437", "0.61118764", "0.61118764", "0.60961396", "0.6036085", "0.5957265", "0.5956041", "0.59383345", "0.59217465", "0.59200907", "0.5912457", "0.5890358", "0.5878921", "0.58526814", "0.58435625", "0.58228964", "0.5760064", "0.57598907", "0.5751934", "0.57380706", "0.57372177", "0.57360226", "0.56513584", "0.56373", "0.56232107", "0.55883974", "0.558779", "0.5587523", "0.5571177", "0.5561976", "0.5543618", "0.5527637", "0.5519911", "0.55017054", "0.5472753", "0.5457399", "0.54379106", "0.54339176", "0.54306084", "0.5427824", "0.5426852", "0.54231215", "0.54172045", "0.54150033", "0.5413984", "0.5398216", "0.5391716", "0.5387542", "0.5357722", "0.5310167", "0.5295502", "0.5286835", "0.52862555", "0.52847415", "0.52844757", "0.5284001", "0.52749556", "0.52686745", "0.52622163", "0.5252002", "0.52451855", "0.52451855", "0.5241617", "0.5236914", "0.52330303", "0.5232522", "0.52252686", "0.5221729", "0.5215821", "0.521565", "0.5213313", "0.52087337", "0.52087337", "0.52084905", "0.5204573", "0.5202113", "0.52017593", "0.52000684", "0.51963085", "0.51963085", "0.51963085", "0.5196028", "0.51955926", "0.5186283", "0.51828873", "0.51733005", "0.51713103", "0.5170727", "0.5162606", "0.51567864", "0.5147726", "0.514628", "0.51420605", "0.5140454", "0.51277953", "0.5124265" ]
0.57916296
20
Comments to delete comments, use delete_object(comment_id) to get comments, use get_connections(object, "likes")
def put_comment(object_id, message, options = {}) # Writes the given comment on the given post. self.put_object(object_id, "comments", {:message => message}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_comments\n end", "def destroy\n id = @comment.micropost_id\n likes = Like.find_by_sql(['SELECT \"likes\".* FROM \"likes\" WHERE \"likes\".\"comment_id\" = ?', @comment.id])\n likes.each do |like|\n like_id = ActiveRecord::Base.sanitize(like.id)\n execute_statement(\"DELETE FROM likes WHERE id = #{like_id}\")\n end\n comment_id = ActiveRecord::Base.sanitize(@comment.id)\n execute_statement(\"DELETE FROM comments WHERE id = #{comment_id}\")\n redirect_to micropost_path(id)\n end", "def destroy\n @comment.destroy\n end", "def delete_comment user\n edit_comment user, nil\n end", "def delete_comment(id)\n record \"/msg/delete_comment/#{id}\"\n end", "def delete_comment\n @comment=Comment.find(params[:comment_id])\n @comment.destroy\n end", "def destroy\n @comment = Comment.find(params[:id])\n \[email protected]_recycling = true\n \n if (can? :delete, @comment)\n \tif @comment.save\n \t\trespond_to do |format|\n \t\t format.html { redirect_to it_category_content_url(@comment.content.category.it, \n \t\t @comment.content.category, @comment.content) }\n \t\t format.json { head :ok }\n \t\tend\n \tend\n \tend\n end", "def destroy\n if @commentable.comments.find(params[:id]).destroy\n render json: { success: true }\n end\n end", "def destroy\n Comment.transaction do\n post = @object.post\n id = @object.id\n @object.destroy\n create_change_log_entry(id)\n respond_to do |format|\n format.html { redirect_to post }\n format.xml { head :ok }\n end\n end\n end", "def destroy\n @comment = Comment.destroy(params[:id])\n end", "def destroy\n @comment = Comment.destroy(params[:id])\n end", "def delete_comment\n comment = Comment.find_by_id(params[:id])\n if !comment.nil?\n comment.destroy\n end\n end", "def destroy\n @comment.destroy\n head :no_content\n end", "def destroy\n @comment.destroy\n head :no_content\n end", "def destroy\n @comment.destroy!\n head :no_content\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n end", "def destroy\n comment = Comment.find(params[:id])\n if current_user.id == comment.user_id\n post = comment.post\n post.data['comments'] = post.data['comments'] - 1\n if comment.destroy && post.save\n render json: {status: \"success\", data: {id: Integer(params[:id]), comments: post.data['comments']}}, status: :ok\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n\n else\n render json: {status: \"failure\", data: nil}, status: 404\n end\n end", "def delete_comment(permlink)\n @operations << {\n type: :delete_comment,\n author: account_name,\n permlink: permlink\n }\n \n self\n end", "def destroy\n #TODO translate\n @current_object = Comment.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @current_object.destroy\n\t\t\t\t@current_objects = Comment.find(:all)\n\t\t\t\tflash[:notice] = 'Comment was successfully deleted.'\n\t\t\t\tformat.html { redirect_to(admin_comments_url) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\t@current_objects = Comment.find(:all)\n\t\t\t\tflash[:error] = 'Comment deletion error.'\n\t\t\t\tformat.html { redirect_to(admin_comments_url) }\n\t\t\t\tformat.xml { head :ok }\n\t\t\tend\n\t\tend\n end", "def destroy\n @fbcomment.destroy\n\n head :no_content\n end", "def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n if @comment.destroy\n flash[:notice] = t('views.message.destroy.success')\n else\n flash[:alert] = CommentDecorator.flash(@comment, flash)\n end\n redirect_to \"/posts/#{@comment.id}?comments=deleted\"\n end", "def destroy\n @comment = @commentable.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end", "def delete_comment\n comment = Admin::QueueItemComment.find_by_id(params['comment_id'])\n raise ArgumentError.new( 'Could not find this comment.') if comment.nil?\n if can?(:destroy, comment)\n comment.delete\n notice = 'Comment deleted.'\n else\n notice = 'You may not delete this comment.'\n end\n redirect_to @admin_digitization_queue_item,\n notice: notice\n end", "def delete_comment(article_id, id)\n delete \"articles/#{article_id}/comments/#{id}\"\n end", "def destroy\n\t@post = Post.find(@comment.post_id)\n\n @comment.destroy\n\[email protected]_attribute(:nComments, @post.comments.count)\n respond_to do |format|\n format.html { redirect_to @comment.post, notice: 'Comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy_comments\n Comment.where(user_id: id).destroy_all\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n redirect_to comments_url, :message => 'Comment deleted.'\n end", "def destroy\n\t\t@comment = Comment.find( params[:id] )\n\t\t\n\t\tif @comment.commentable.class.comments_extension.can_remove?( @comment.commentable, @comment, current_user_get )\t\t\n\t\t\t@removed_ids = [ @comment.id ]\n\t\t\t\n\t\t\tfor comment in @comment.descendants do\n\t\t\t\t@removed_ids << comment.id\n\t\t\tend\n\t\t\t\n\t\t\[email protected]\n\t\t\t\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to comments_url }\n\t\t\t\tformat.xml { head :ok }\n\t\t\t\tformat.js\n\t\t\tend\n\t\telse\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to comments_url }\n\t\t\t\tformat.xml { head :err }\n\t\t\t\tformat.js\t{ render :update do |page| page.alert \"You can't remove this comment\" end }\n\t\t\tend\n\t\tend\n\tend", "def destroy\n @comment = @posting.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n #@comment.create_activity :destroy, owner: current_user\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = @article.comments.find(params[:id])\n @comment.destroy\n redirect_to article_path @article\n end", "def comment_delete\n @memorial = Memorial.find(params[:id])\n Comment.find(params[:comment]).destroy\n redirect_to :action => \"show\", :id => @memorial\n end", "def comment_delete\n @memorial = Memorial.find(params[:id])\n Comment.find(params[:comment]).destroy\n redirect_to :action => \"show\", :id => @memorial\n end", "def destroy\n @c_like = CLike.find_by(user_id: current_user.id, comment_id: params[:comment_id])\n @c_like.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Like was successfully destroyed.' }\n format.json { render json: {status: 'success', like: @c_like, counts: CLike.where(comment_id: params[:comment_id]).count}, liked: false }\n end\n end", "def destroy\n @comment.destroy\n redirect_to @comment.post, notice: t(:comment_delete) #используем удаленный из базы коммент, но еще существующий\n #в пространству памяти для перенаправления на родительский пост\n end", "def destroy\n\t\t@post = Post.find(params[:post_id])\n \t@reply = @post.replies.find(params[:id])\n \[email protected]\n \tredirect_to @post, notice: \"Comment deleted!\"\n end", "def destroy\n \t@post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n @comment.destroy\n redirect_to post_path(@post)\n end", "def destroy\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n @comment.destroy\n redirect_to post_path(@post)\n end", "def destroy\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n @comment.destroy\n redirect_to post_path(@post)\n end", "def comment_delete(ids=[], options={})\n post(\"wrike.comment.delete\", options.merge(:ids => ids.join(',')))\n end", "def destroy\n @post = Post.find(params[:post_id])\n @comment = @post.comments.find(params[:id])\n @comment.destroy\n redirect_to post_path(@post)\n\tend", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n respond_with(@post, @comment)\n end", "def destroy\n @comment = Comment.find(params[:id])\n unless @comment.present?\n @comment.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to admin_comments_url }\n format.json { head :no_content }\n end\n end", "def destroy_like\n @like = Like.where(likeable_id: params[:comment_id], likeable_type: \"Comment\", user_id: current_user.id).first\n @like.destroy\n render 'api/likes/destroy_like.json.jbuilder'\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_blog_post_comments_url(@comment.post.blog, @comment.post)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n redirect_to @comment.list\n end", "def destroy\n @comment = @repository.comments.find(params[:id])\n authorize @comment\n @comment.destroy\n respond_with @comment\n end", "def destroy\n # comment ya lo carga la funcion check\n @comment.destroy\n render :nothing => true\n end", "def destroy\n @comment = Comment.find(params[:id])\n \n \n if @comment.has_children?\n @comment.children.each do |child|\n child.destroy\n end\n end\n @comment.destroy\n\n respond_with do |format|\n flash.now[:notice] = 'Comment was successfully deleted.'\n end\n end", "def destroy\n if @comment.sub_comments\n message = 'This comment cannot be deleted; there are sub comments associated.'\n else\n @comment.destroy\n message = 'Comment was successfully destroyed.'\n end\n respond_to do |format|\n format.html { redirect_to magazine_article_path(@magazine, @article), notice: message }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n authorize @comment\n if @comment.destroy\n ArticleRankingWorker.perform_async(params[:article_id])\n end\n\n head :no_content\n end", "def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_comments_url) }\n format.xml { head :ok }\n end\n end", "def test_delete_comment\n\n comments = Comment.getAll()\n\n for comment in comments\n\n result = Comment.deleteComment(comment.commentId)\n\n assert_equal true, result\n \n end\n\n end", "def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n if @comment.nil?\n render json: {error: \"Not found\"}, status: :not_found\n else\n @comment.destroy\n render json: @comment, status: :ok\n\n end\n end", "def destroy\n @article = Article.find(params[:article_id])\n @comment = @article.comments.find(params[:id])\n @comment.destroy\n redirect_to article_path(@article)\n end", "def destroy\n \t@post = Post.find(params[:post_id])\n\t @comment = @post.comments.find(params[:id])\n\t @comment.destroy\n\t redirect_to post_path(@post)\n \tend", "def destroy\n @article = Article.find(params[:article_id])\n @comment = @article.comments.find(params[:id])\n @comment.destroy\n redirect_to article_path(@article)\n end", "def destroy\n @comment.destroy\n \n redirect_to post_path(params[:post_id])\n end", "def delete_likes\n end", "def delete_likes\n end", "def delete_likes\n end", "def destroy_comment(resource_id, comment_id)\n http.delete(\"#{comment_endpoint(resource_id)}/#{comment_id}\") do |response|\n true\n end\n end", "def destroy\n\t\t@article = Article.find(params[:article_id])\n\t\t@comment = @article.comments.find(params[:id])\n\t\[email protected]\n\t\tredirect_to article_path(@article)\n\tend", "def destroy\n\t\t@article = Article.find(params[:article_id])\n\t\t@comment = @article.comments.find(params[:id])\n\t\[email protected]\n\t\tredirect_to article_path(@article)\n\tend", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n redirect_to request_path(@comment.request)\n end", "def destroy\n\t\n\t\t#find the post in question\n\t\t@post = Post.find(params[:post_id])\n\t\t\n\t\t#locate the comment in question within the @post.comments collection\n\t\t@comment = @post.comments.find(params[:id])\n\t\t\n\t\t#remove comment from the database\n\t\[email protected]\n\t\t\n\t\t#send user back to original post\n\t\tredirect_to post_path(@post)\n\tend", "def destroy\n\n if @comment.destroy\n\n render json: {comment: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @comment.errors},status: :unprocessable_entity\n\n end\n\n \t\tend", "def destroy\n comment = Comment.find(params[:id])\n if comment.destroy\n render json: {destroyed: true}\n end\n end", "def destroy\n if @comment.user_id != current_user.id && !current_user.admin?\n redirect_back(fallback_location: root_path,\n notice: t('comment.del_not_admin_msg'))\n end\n if @comment.destroy\n notice_msg = t('comment.del_success_msg')\n else\n notice_msg = t('comment.del_unsuccessful_msg')\n end\n respond_to do |format|\n format.html {\n redirect_back(fallback_location: root_path,\n notice: notice_msg)\n }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = @question.comments.find(params[:id])\n @comment.destroy\n redirect_to question_path(@question)\n end", "def destroy\n @comment = @network.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n flash[:notice] = 'Comment destroyed.'\n format.html { redirect_to([:admin, @network,:comments]) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dish_comment = @dish.dish_comments.find(params[:id])\n @dish_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to dish_comments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n if @comment.c_type == 'song'\n @comments = Comment.where(:song_id => params[:id])\n @song = Song.find(@comment.song_id) \n redirect_to comments_index_path(song_id: @song.id, c_type: 'song'),\n header_type: 'song', \n notice: 'Comment was successfully deleted.'\n elsif @comment.c_type == 'post'\n @comments = Comment.where(:post_id => params[:id])\n @post = Post.find(@comment.post_id) \n redirect_to comments_index_path(post_id: @post.id, c_type: 'post'),\n header_type: 'post', \n notice: 'Comment was successfully deleted.' \n end\n #redirect_to comments_url \n end", "def delete_comment(cmt)\n @comments.delete(cmt)\n return self\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok } \n end\n end", "def destroy\n if super_user?\n @comment = Comment.find(params[:id])\n @comment.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to(comments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n\n @comment.destroy\n render json: @comment, status: :ok\n\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { render :nothing => true }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'коммент успешно удалён' }\n end\n end", "def destroy\n comment = @commentable.comments.find(params[:id])\n\n # Prevent those who don't have access from deleting the Comment.\n head :forbidden and return false if !comment.profile_has_access?(current_profile)\n\n comment.destroy\n respond_to do |format|\n format.html { redirect_to @commentable }\n format.json { head :no_content }\n end\n end", "def destroy\n @blog = Blog.find(params[:blog_id])\n @comment = @blog.comments.find(params[:id])\n @comment.destroy\n redirect_to blogs_path\n end", "def destroy\n @comment = Comment.find(params[:comment_id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end", "def delete_if\n deleted = []\n @queue.delete_if do |fullname|\n comment = Models::Comment.new(@client, name: fullname).reload\n action = yield comment\n if action == :delete\n comment.delete\n deleted << fullname\n end\n action == :keep || action == :delete\n end\n deleted\n end", "def destroy\n\t\t@post = Post.find(params[:post_id])\n\t\t@comment = Comment.find(params[:id])\n\t\[email protected]\n\t\tredirect_to post_path(@post)\n\tend", "def destroy\n\t\t@comment = current_user.\n\t\t\tprojects.find(params[:project_id]).\n\t\t\ttasks.find(params[:task_id]).\n\t\t\tcomments.find(params[:id]).destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def del_comment\n @comment = ''\n end", "def destroy\n @article = Article.find(params[:article_id])\n @comment = @article.comments.find(params[:id])\n @comment.destroy\n redirect_to \"/articles/#{@article.id}\"\n end", "def destroy\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to_commentable(@comment, false) }\n format.xml { head :ok }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n render json:@comment\n end", "def destroy\n hack = @comment.hack\n @comment.destroy\n redirect_to hack_path(hack.id)\n end", "def destroy\n\n @comment = Comment.find(params[:comment_id])\n @comment.destroy\n flash[:success] = \"Comentário deletado com sucesso\"\n\n return redirect_to(Topic.find(session[:topic_id]))\n\n end", "def destroy\n\n @comment = @post.comments.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html {redirect_to comments_and_forum_path }\n format.xml { head :ok }\n end\n end", "def destroy\n @votecomment = Votecomment.find(params[:id])\n @votecomment.destroy\n redirect_to(posts_path)\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n\t\trespond_with @comment, :location => @comment.post\n end", "def prune\n if Comment.count > 15\n comment = Comment.order('id asc').first\n comment.destroy\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to post_url(@comment.post_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n\n respond_to do |format|\n format.html { redirect_to comments_url }\n format.json { head :no_content }\n end\n end", "def remove_comment repo, comment_id\n response = @@connection.delete do | request |\n request.url \"repos/#{repo}/issues/comments/#{comment_id}\"\n request.headers['Authorization'] = \"token #{@@token}\"\n end\n \n # look for Status: 204 No Content\n return if response.env[:status] != 204\n \n # Comment successfully deleted from GitHub so remove from comment.db\n @@db.execute \"delete from comment where id == #{comment_id}\"\n end", "def destroy\n @comment = Comment.find(params[:id])\n if @comment.destroy\n redirect_to posts_url\n else\n render :text => \" hey something gonna wrong\"\n end\n end" ]
[ "0.7735174", "0.7133519", "0.7115246", "0.6976745", "0.68903834", "0.68854874", "0.6883965", "0.6844737", "0.68358815", "0.68180704", "0.68180704", "0.68142796", "0.67961085", "0.67961085", "0.6794491", "0.67932653", "0.6763884", "0.6755012", "0.67180836", "0.66879106", "0.6652046", "0.6646541", "0.6628573", "0.6624627", "0.6622229", "0.66155875", "0.66105795", "0.65976113", "0.657787", "0.6551035", "0.65507823", "0.6529825", "0.6529825", "0.6519548", "0.65161216", "0.6491181", "0.6490553", "0.6486266", "0.6486266", "0.64740497", "0.64685065", "0.6467801", "0.645084", "0.6445499", "0.644366", "0.64373696", "0.64270115", "0.64236623", "0.6420607", "0.64185995", "0.6415215", "0.6414703", "0.6409252", "0.64083743", "0.6398182", "0.6395128", "0.6391924", "0.63887125", "0.63846403", "0.6383956", "0.6366761", "0.6366761", "0.6366761", "0.63582754", "0.63479143", "0.63479143", "0.63405454", "0.6337179", "0.63284117", "0.6322436", "0.6321233", "0.63128936", "0.6310628", "0.63031775", "0.6301725", "0.63015586", "0.62989956", "0.6298866", "0.6287394", "0.628437", "0.6274532", "0.62745", "0.6273123", "0.62728626", "0.62706554", "0.62680256", "0.6267101", "0.6264153", "0.6257908", "0.62552375", "0.6251172", "0.624991", "0.62454444", "0.62423", "0.6240591", "0.623025", "0.6226386", "0.62229675", "0.62190366", "0.6218904", "0.6217921" ]
0.0
-1
Likes to get likes, use get_connections(user, "likes")
def put_like(object_id, options = {}) # Likes the given post. self.put_object(object_id, "likes", {}, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Like\n end", "def likes( params={} )\n likes = get_connections(\"likes\", params)\n return map_connections likes, :to => Facebook::Graph::Generic\n end", "def likes\n likers(User).count\n end", "def likes\n\t\t@likes ||= fetch_likes\n\tend", "def likes_given(user_id)\n likes = Like.where(user_id: user_id)\n end", "def likes\n @likes = @person.likes\n end", "def likes\n likes_response = client.get(\"/venues/#{id}/likes\")[\"response\"]\n @likes = {}\n if likes_response[\"likes\"]\n @likes.merge!(likes_response[\"likes\"])\n if @likes[\"groups\"]\n @likes[\"groups\"].each do |group|\n group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}\n end\n end\n end\n @likes\n end", "def fetch_facebook_likes(facebook_user)\n facebook_user.likes.each do |friend_like|\n movie = Movie.find_by_fbpage_id(friend_like.id.to_s)\n if movie && movie.facebook_feeds.friend_likes.by_fb_item_id(friend_like.id.to_s).by_fbid(facebook_user.id.to_s).blank?\n post = FacebookFeed.create!(:feed_type => 'friend_likes', :movie_id => movie.id, :value => friend_like.name, :fbid => facebook_user.id, :fb_item_id => friend_like.id, :posted_on => friend_like.created_time.to_date, :facebook_name => facebook_user.name)\n Activity.create_log_for_each_friend(post, movie, 'liked', facebook_user.id.to_s, facebook_user.name)\n end\n end\n end", "def get_likes(id, type)\r\n\t\treturn Like.where(user_id: self.id, likeable_type: type, likeable_id: id)\r\n\tend", "def likes(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n all_likes = from_instagram[\"data\"].map do |datum|\n datum[\"likes\"][\"count\"]\n end\n\n all_likes = all_likes.reduce(:+)\n\n return all_likes\n end", "def user_likes\n q = \"INNER JOIN liked_info ON users.id = liked_info.user_id WHERE liked_info.thing_id = #{id} AND liked_info.thing_type = 'Serial'\"\n User.joins(q)\n end", "def all_likes\n get_likes_of(self)\n end", "def likes(username, opts={})\n opts = opts.merge({:https => @https})\n Likes.likes(username, @api_key, opts)\n end", "def likes(fields: nil, cursor: nil, limit: nil)\n get_pins_collection(\"/me/likes/\", nil, fields, cursor, limit)\n end", "def user_likes\n user = User.find(params[:user_id])\n likes = user.likes\n render json: likes\n\nend", "def object_likes(uid, options = {})\n fetch_all = options.delete(:fetch_all)\n\n params = { \n :owner_id => user.identifier,\n :count => 1000, \n :type => \"post\", \n :item_id => uid,\n :offset => 0\n }\n params.merge!(options)\n \n if fetch_all\n return fetch_all_method_items(\"likes.getList\", params)\n end\n\n\n user.likes.getList(params)\n end", "def likes\n verbs_of_interest = %w[like unlike]\n\n query = Activity.joins(:verb)\n .with_actor_id(id: guid)\n .with_target_id(id: nil)\n .merge(Verb.with_display_name(name: verbs_of_interest))\n\n @likes ||= query.group(:activity_object_id).having(\"COUNT(1) % 2 == 1\")\n end", "def tip_likes tip_id\n response = get(\"/tips/#{tip_id}/likes\")[\"response\"]\n @likes = response[\"likes\"]\n @likes[\"groups\"].each{ |group| group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes[\"groups\"]\n end", "def likes\n @page.like_count\n end", "def is_liked user\n \tLike.find_by(user_id: user_id, post_id: id)\n end", "def get_likes media_id\n url = API + \"media/#{media_id}/likes?access_token=\" + @access_token\n get(url)['data'].map {|data| data}\n end", "def like(user)\n likes << Like.new(user: user)\n end", "def like_by user\n likers << user && change_like_count(1)\n end", "def set_likes\n @likes = likes.find(params[:id])\n end", "def get_like(comment)\n like = comment.likes.select { |l| l.user_id == current_user.id }\n return like\n end", "def fb_likes_url(access_token)\n \"https://graph.facebook.com/#{self.fb_object_id}?\" \\\n \"access_token=#{access_token}&fields=id,likes&\" \\\n \"likes.limit=50\"\n end", "def likes()\r\n db = connect()\r\n result2 = db.execute(\"SELECT * FROM likes\")\r\n return result2\r\n end", "def getClientLikes()\n\t\tmy_likes = Array.new\n\t\tcleaned_up = Array.new\n\t\tlikes = $client.likes :limit => 20\n\t\tlikes[\"liked_posts\"].each do |like|\n\t\t\tif(like[\"type\"] === \"quote\" || like[\"type\" === \"text\"])\n\t\t\t\tmy_likes.push(like[\"text\"])\n\t\t\tend\n\t\tend\n\t\tmy_likes\n\tend", "def likes(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n number_of_photos = from_instagram[\"data\"].size\n all_likes = Array.new\n i = 0\n while i < number_of_photos\n likes = from_instagram[\"data\"][i][\"likes\"][\"count\"]\n all_likes.push(likes)\n i = i + 1\n end\n\n all_likes = all_likes.reduce(:+)\n\n return all_likes\n end", "def like\n @comment.liked_by current_user\n end", "def likes\n Activity.joins(:activity_verb).where('activity_verbs.name' => \"like\").\n joins(:activity_objects).where('activity_objects.id' => activity_object_id)\n end", "def likes(options = {})\n urn = options.delete(:urn)\n path = \"/socialActions/#{urn}/likes\"\n get(path, options)\n end", "def likes\n return (@likes.present?) ? @likes : ActiveRecord::Base.connection.execute(\"SELECT COUNT(news_id) AS count FROM newslikes WHERE news_id = #{self.id.to_s}\")[0][\"count\"]\n end", "def retrieve_user_likes(uid, order=nil, per_page=nil, page=nil)\n response = get(\"/api/v1/users/#{uid}/likes\", query: {order: order, per_page: per_page, page: page})\n ITout::Touts.new.from_response(response)\n end", "def likes\n UserReaction.where(note_id: self.id, like: 1).count\n end", "def likes\n Like.where(:song_path => path).group(:user_id)\n end", "def like!(options = {})\n post(options.merge(:connection => :likes))\n end", "def likes(user_id)\n\t\tfrom_instagram = retrieve_last_10_photos(user_id)\n\t\tnumber_of_photos = from_instagram[\"data\"].size\n\t\tall_likes = Array.new\n\t\ti = 0\n\t\twhile i < number_of_photos\n\t\t\tlikes = from_instagram[\"data\"][i][\"likes\"][\"count\"]\n\t\t\tall_likes.push(likes)\n\t\t\ti = i + 1\n\t\tend\n\n\t\tall_likes = all_likes.reduce(:+)\n\n\t\treturn all_likes\n\tend", "def likes\n query = \"SELECT COUNT(*) AS num_likes FROM likes WHERE post_id = #{id}\"\n result = DATABASE.execute(query)[0]\n return result[\"num_likes\"]\n end", "def setLike(value)\n @likes = value\n end", "def like(user)\n likes.create(user: user)\n end", "def all_likes_by_model(model)\n get_likes_of(self, model)\n end", "def likers \n self.likes.map {|like| like.user_id}\n end", "def index\n @user_post_likes = UserPostLike.all\n end", "def get_facebook_likes_count\n graph = Koala::Facebook::API.new(FACEBOOK_OAUTH_TOKEN)\n fb_page_id = @pages[:facebook].href.split('/').last\n number_of_likes = begin\n id = graph.get_object(fb_page_id)[\"id\"]\n graph.get_object(id + \"?fields=likes\")[\"likes\"]\n rescue\n 0\n end\n number_of_likes\n end", "def liked\n get '/users/self/media/liked', auth_params\n end", "def like\n if @vote\n authorize! :like, @vote\n @vote.like\n else \n authorize! :create_vote, @votable.votes.new\n @votable.votes.create(user: current_user, nominal: 'like')\n end\n\n rating_respond_with_json\n end", "def like\n login_to_facebook\n bob.like\nend", "def venue_likes(id)\n get(\"venues/#{id}/likes\").likes\n end", "def like_tip tip_id, options={}\n response = post(\"/tips/#{tip_id}/like\", options)[\"response\"]\n @likes = response[\"likes\"]\n @likes[\"groups\"].each{ |group| group[\"items\"].map!{|item| Foursquared::Response::User.new(client, item)}} if @likes and @likes[\"groups\"]\n @likes\n end", "def liked_comments_count\n # Creating comments\n comment_ids = \"SELECT id FROM comments WHERE user_id = :user_id\"\n # Except for self like\n CommentLike.where(\"comment_id IN (#{comment_ids}) AND user_id <> :user_id\", user_id: id).count\n end", "def likes_count\n self.likes_count_field\n end", "def show\n @likes = Like.where(tweet_id: @tweet)\n end", "def likes_count\n self.likes.size\n end", "def likes(options={})\n likes = post(\"/v2/user/likes\", options)\n\n likes.body[\"response\"][\"liked_posts\"].map do |post|\n TumblrV2Api::Post.new(post)\n end\n end", "def who_likes(url)\n track = resolve_url(url)\n if track && track.kind == \"track\"\n @users.map {|username|\n if get_liked(username, track.id)\n username\n end\n }.compact\n else # TODO: handle if track isn't found\n []\n end\nend", "def show\n @tweet_likes = @tweet.likes\n end", "def likes\n Like.where(target_id:self.id, target_type:'comment')\n end", "def venue_likes venue_id\n response = get(\"/venues/#{venue_id}/likes\")[\"response\"][\"likes\"]\n response[\"groups\"].each do |group|\n response[\"items\"].map!{|item| Foursquared::Response::User.new(self, item)}\n end\n response\n end", "def moment_likes(moment_id)\n get(\"/v1/moments/#{moment_id}/likes\")\n end", "def like!\n connection.post(\"/photos/#{id}/like\")\n true\n end", "def likes\n @likes ||= raw[\"tumblr\"][\"posts\"][\"post\"].collect do |raw_like|\n if raw_like[\"type\"] == \"regular\"\n title = raw_like[\"regular_title\"]\n body = raw_like[\"regular_body\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"quote\"\n title = raw_like[\"quote_text\"]\n body = raw_like[\"quote_source\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"photo\"\n title = raw_like[\"photo_caption\"]\n body = raw_like[\"photo_caption\"]\n type = \"photo\"\n photo_url = raw_like[\"photo_url\"].last\n elsif raw_like[\"type\"] == \"link\"\n title = raw_like[\"link_text\"]\n body = raw_like[\"link_description\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"conversation\"\n title = raw_like[\"conversation_title\"]\n body = raw_like[\"conversation_text\"]\n type = \"text\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"video\"\n title = raw_like[\"video_caption\"]\n body = raw_like[\"video_player\"]\n type = \"video\"\n photo_url = nil\n elsif raw_like[\"type\"] == \"audio\"\n title = raw_like[\"audio_caption\"]\n body = raw_like[\"audio_player\"]\n type = \"audio\"\n photo_url = nil\n end\n\n Butterfly::Like.new({\n :service => \"tumblr\",\n :id => raw_like[\"id\"],\n :title => title,\n :description => body,\n :created_at => Time.at(raw_like[\"unix_timestamp\"].to_i),\n :liked_at => nil,\n :tags => raw_like[\"tag\"],\n :photo_url => photo_url,\n :url => raw_like[\"url_with_slug\"],\n :type => type,\n :user => Butterfly::User.new({\n :id => raw_like[\"tumblelog\"],\n :username => raw_like[\"tumblelog\"],\n :name => raw_like[\"tumblelog\"],\n :service_url => \"#{raw_like[\"tumblelog\"]}.tumblr.com\",\n :photo_url => nil,\n :website_url => nil,\n :location => nil,\n })\n })\n end\n end", "def likers\n likes.map do |like|\n like.user\n end\n end", "def find_like\n @like = @post.likes.find(params[:id])\n end", "def user_likes_list?\n Like.exists?(:user_id => current_user, :list_id => @list)\n end", "def liked\n likes.map {|like| like.likeable}\n end", "def likes?(user)\n if likes.where(user_id: user.id).any?\n return true\n else\n return false\n end\n end", "def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end", "def get_likes\n Like.all.select {|like| like.dog_id == self.id}\n end", "def set_postlike\n @likes = Like.where(post_id: params[:post_id])\n end", "def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset], options)\n url = \"v2/blog/#{blog_name}/likes\"\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end", "def change_like\n user = User.find(params[:id])\n if current_user.likes?(user)\n msg = \"I <span>like</span> this profile\"\n Like.delay.delete_all([\"user_id = ? and likeable_id = ? and likeable_type = ?\", current_user.id, user.id, \"User\"])\n NetworkUpdate.removeLikedUpdate(current_user.id, user.id)\n else\n current_user.like!(user)\n msg = \"Remove <span>like</span>\"\n NetworkUpdate.delay.createLikedUpdate(current_user.id, user.id)\n SneakPeekMailer.delay.like_email(current_user, user)\n end\n render :text => msg\n end", "def liked_tweets\n Like.all.select { |l| l.user == self }.map { |l| l.tweet }\n end", "def likes(force = false)\n if force || @likes.nil?\n @likes = flags.all(:conditions => { :reason => 'like' })\n end\n @likes\n end", "def blog_likes(blog_name, options = {})\n validate_options([:limit, :offset, :before, :after], options)\n url = blog_path(blog_name, 'likes')\n\n params = { :api_key => @consumer_key }\n params.merge! options\n get(url, params)\n end", "def like(params,userid)\r\n db = connect_non_hash()\r\n likedposts=db.execute(\"SELECT likes.postid FROM likes WHERE userid=(?)\", userid)\r\n likedposts = likedposts.flatten\r\n if likedposts.include? params[\"postid\"].to_i\r\n redirect('/cantliketwice')\r\n else\r\n db.execute(\"INSERT INTO likes(userid, postid) VALUES (?, ?)\", userid, params[\"postid\"])\r\n redirect('/posts')\r\n end\r\n end", "def request_like_fan_page?\n Rails.logger.info(\"TOKEN : #{self.f_token}\")\n oauth = Koala::Facebook::OAuth.new(ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'])\n graph = Koala::Facebook::API.new(self.f_token)\n data = graph.get_connections(self.f_id, \"likes/#{ENV['FACEBOOK_PAGE_ID']}\")\n\n found = false\n data.each do |like|\n found = true if like['id'] == \"#{ENV['FACEBOOK_PAGE_ID']}\"\n end\n return found\n end", "def liked_by\n\t\tcomment = Comment.includes(:liked_by).find_by(id: params[:id])\n\t\t@users = comment.has_been_liked_by\t\t\t\t\t\t\t\t\t\n\tend", "def get_likers(object_id)\n results = @request.do_request { session.fql_query(@query.likes_fql(object_id)) }\n if results \n results.map! do |res| \n if res['user_id'] == id.to_s\n user.name\n else\n friend(res['user_id']).name rescue nil\n end\n end\n results.compact\n end\n end", "def update_like_count\n Recommendable.redis.set \"#{redis_key}:like_count\", liked_by.count\n end", "def show\n @comments = Comment.where(post_id: params[:id])\n if logged_in?\n #@like = Like.where(post_id: params[:id], user_id: current_user.id)\n \n if params[:havelike] == '1'\n if params[:like] == '1'\n @like = Like.new(:post_id => params[:id], :user_id => current_user.id)\n @like.save\n else\n Like.find_by_sql(\"delete from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n end\n @likes = Like.find_by_sql(\"select * from Likes where post_id = \" + params[:id] + \" and user_id = \" + current_user.id.to_s )\n end\n \n end", "def like\n post_id = params[:id]\n @post = Post.where(:id => post_id).first\n if current_user && @post\n if @post.is_like?(current_user.id)\n @post.unlike(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> Like\" \n else\n @post.like(current_user.id)\n render :text => \"<span class='badge badge-success'> #{@post.get_likes_count}</span> UnLike\" \n end\n return\n end\n render :text => 'fail' and return\n end", "def likes(like_type = :all)\n case like_type\n when :tracks\n scrape_for(:liked_tracks, :get_liked_tracks)\n when :artists\n scrape_for(:liked_artists, :get_liked_artists)\n when :stations\n scrape_for(:liked_stations, :get_liked_stations)\n when :albums\n scrape_for(:liked_albums, :get_liked_albums)\n when :all\n { artists: likes(:artists),\n albums: likes(:albums),\n stations: likes(:stations),\n tracks: likes(:tracks) }\n end\n end", "def like(user_id)\n UserLike.find_or_create_by(user_id: user_id, feed_id: self.id)\n end", "def likes\n people = []\n query = Activity.joins { verb }.where { activity_object_id.eq(my { id }) }\n\n activities_likes = query.where { verb.name.eq('like') }\n activities_likes.each do |activity|\n people.push activity.actor\n end\n\n activities_unlikes = query.where { verb.name.eq('unlike') }\n activities_unlikes.each do |activity|\n people.delete_at people.index(activity.actor)\n end\n\n people\n end", "def share_likes(update_key, options={})\n path = \"#{person_path(options)}/network/updates/key=#{update_key}/likes\"\n simple_query(path, options)\n end", "def likes\n Like.all.select do |like|\n # like.tweet.message == self.message # this works, but its extra\n like.tweet == self # self in an instance method refers to that instance\n end\n end", "def show\n @user = User.where(id: @post.user_id)[0]\n @likes = UserLike.where(post_id: @post.id)\n end", "def liked_by_count\n Recommendable.redis.scard(Recommendable::Helpers::RedisKeyMapper.liked_by_set_for(self.class, id))\n end", "def index\n @c_likes = CLike.all\n if params[:comment_id].present?\n like = CLike.find_by(user_id: current_user.id, comment_id: params[:comment_id])\n render json: {status: 'success', like: like, counts: CLike.where(comment_id: params[:comment_id]).count, liked: like.present?}\n end\n end", "def likes?(tweet)\n \ttweet.likes.where(user_id: id).any?\n end", "def index\n @likes = Like.all\n end", "def index\n @likes = Like.all\n end", "def get_random_like(client)\n likes = client.favorites(self.get_uid_int, options = {count: 5})\n like = likes.sample\n end", "def get_all_likes(objects)\n returning Hash.new do |res|\n if results = @request.do_request { session.fql_query(@query.all_likes_fql(objects)) }\n results.each do |result|\n friend_name = (result['user_id'] == id.to_s) ? user.name : (friend(result['user_id']).name rescue nil)\n (res[result['object_id']] ||= []) << friend_name\n end\n end\n end\n end", "def count_likes\n self.likers(Profile).length\n end", "def liked_by?(user)\n likes.find_by_user_id(user.id).present?\n end", "def show\n @tweet = Tweet.find(params[:id]) #Encontramos el tweet segun el ID\n @tweet_likes = @tweet.likes #Creamos la variable para mostrar los usuarios que le dieron el like\n end", "def like\n if params[:post_id]\n likeable = Comment.find(params[:id])\n what = \"Comment\"\n else\n likeable = Post.find(params[:id])\n what = \"Post\"\n end\n like = likeable.likes.where(:user_id => current_user.id).first || Like.new\n unless like.id\n like.likeable = likeable\n like.user = current_user\n like.save\n redirect_to back_page_post, flash: { :success => what + ' was liked.' }\n else\n like.destroy\n redirect_to back_page_post, flash: { :success => what + ' was unliked.' }\n end\n end", "def liked?\n liked_ids = h.current_user.liked_replies.pluck(:id)\n liked_ids.include?(self.id)\n end", "def index\n @likes = Like.in_conference(current_conference).all\n end" ]
[ "0.80367583", "0.79998726", "0.73243344", "0.7257137", "0.72164446", "0.71479404", "0.7044396", "0.70388806", "0.698619", "0.6977709", "0.6969903", "0.69543606", "0.69101554", "0.68826574", "0.6868834", "0.68577665", "0.6851651", "0.68404746", "0.68315595", "0.6821983", "0.6796474", "0.6784012", "0.6749933", "0.67459255", "0.6741661", "0.6722251", "0.6712926", "0.66900057", "0.66861576", "0.66741365", "0.666795", "0.66575956", "0.66575694", "0.6634105", "0.66212314", "0.6612439", "0.65990305", "0.6596234", "0.6589227", "0.65653294", "0.6556221", "0.65546644", "0.6547497", "0.65424633", "0.6496092", "0.6494626", "0.6481844", "0.64789313", "0.6452173", "0.64507586", "0.6442412", "0.6432218", "0.64280343", "0.6424807", "0.6414767", "0.64004976", "0.63962513", "0.6386133", "0.638085", "0.63594365", "0.63534254", "0.6352126", "0.6346042", "0.63335633", "0.6326773", "0.6321498", "0.63155204", "0.6315218", "0.6315218", "0.6299462", "0.62949806", "0.6286087", "0.628579", "0.62774754", "0.6264697", "0.6256341", "0.62445647", "0.6241786", "0.62378883", "0.6232361", "0.6224736", "0.6203151", "0.62028694", "0.61928463", "0.61905", "0.618188", "0.6170467", "0.61653584", "0.6159881", "0.6158314", "0.6158071", "0.61527383", "0.61527383", "0.61421186", "0.6123246", "0.6119013", "0.611876", "0.61155635", "0.6114785", "0.610373", "0.61001736" ]
0.0
-1
Direct access to the Facebook API see any of the above methods for example invocations
def graph_call(path, args = {}, verb = "get", options = {}, &post_processing) result = api(path, args, verb, options) do |response| error = check_response(response) raise error if error end # now process as appropriate (get picture header, make GraphCollection, etc.) post_processing ? post_processing.call(result) : result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def facebook\n\n end", "def facebook\n end", "def facebook\n handle_oauth\n end", "def facebook\n callback\n end", "def fbCall(path,params = {})\n params['access_token'] = self.token ? self.token['access_token'] : self.originalFriend.token['access_token']\n getJSON(\"https://graph.facebook.com#{path}\", params)\n end", "def fb_load_api\n\n\n end", "def facebook\n handle_auth \"facebook\"\n end", "def facebook\n FbConnection\n end", "def index\n @graph = Koala::Facebook::API.new(session[:fb_access_token])\n profile = @graph.get_object(\"me\")\n puts profile\n end", "def rest_api\n Koala::Facebook::RestAPI.new(access_token)\n end", "def facebook\n @fb_user ||= FbGraph::User.me(self.authentications.find_by_provider('facebook').token)\n @fb_user.fetch\n end", "def like\n login_to_facebook\n bob.like\nend", "def facebook_request\n redirect_to facebook_authenticate_url\n end", "def facebook\n @facebook ||= Koala::Facebook::API.new(oauth_token)\n end", "def facebook\n social_login(request.env['omniauth.auth'], current_user,\"Facebook\")\n end", "def facebook\n # By default, client-side authentication gives you a short-lived\n # token:\n short_lived_token = params[:access_token]\n\n fb_hash = GenericApiRails.config.facebook_hash\n if fb_hash.nil?\n logger.error('Facebook login/signup not configured. For configuration instructions see controllers/generic_api_rails/authentication_controller.rb in the generic_api_rails project')\n render :json => { success: false , error: \"Facebook login/signup not configured\" }\n return\n end\n\n app_id = fb_hash[:app_id]\n app_secret = fb_hash[:app_secret]\n\n # to upgrade it, hit this URI, and use the token it hands back:\n token_upgrade_uri = \"https://graph.facebook.com/oauth/access_token?client_id=#{app_id}&client_secret=#{app_secret}&grant_type=fb_exchange_token&fb_exchange_token=#{short_lived_token}\"\n\n begin\n res = URI.parse(token_upgrade_uri).read\n\n res_hash = Rack::Utils.parse_query(res)\n\n long_lived_token = res_hash['access_token']\n rescue Exception => x\n logger.error(self.class.name + \" - facebook: #{x}\")\n long_lived_token = short_lived_token\n # render :json => { :error => \"token-upgrade error (#{x})\" }\n # return\n end\n\n # at this point, we have verified that the credential is authorized by\n # Facebook- facebook has even given us a long-lived token to\n # manipulate this credential via FB. Now, all we need is some details\n # about our credential, namely the credential ID, and email. We use Koala\n # here because it is a more flexible endpoint for Facebook, and we\n # don't want to be using OAuth here - we already have the token we\n # need.\n\n @graph = ::Koala::Facebook::API.new(long_lived_token, app_secret)\n fb_user = @graph.get_object(\"me\", fields: \"email,first_name,last_name,middle_name,birthday,about,location\")\n # logger.info(\"FB_USER: #{fb_user}\")\n uid = fb_user[\"id\"]\n profile_pic = @graph.get_picture(uid, { height: 500, width: 500 })\n\n # create a hash that matches what oauth spits out, but we've done\n # it with Koala:\n @provider = \"facebook\"\n @uid = uid\n @email = fb_user[\"email\"]\n\n person_hash = {\n fname: fb_user[\"first_name\"],\n lname: fb_user[\"last_name\"],\n minitial: fb_user[\"middle_name\"],\n profile_picture_uri: profile_pic,\n birthdate: fb_user[\"birthday\"]\n }\n\n @results = GenericApiRails.config.oauth_with.call(provider: \"facebook\", uid: uid, email: @email , person: person_hash)\n\n if @results[0].nil?\n # error = @results[1]\n @credential = nil\n else\n @credential = @results[0]\n end\n\n done\n end", "def fb_friends\n graph = facebook()\n facebook().get_connection('me','friends') if graph\n end", "def facebook\n @facebook ||= Koala::Facebook::API.new(oauth_token)\n block_given? ? yield(@facebook) : @facebook\n rescue Koala::Facebook::APIError => e\n logger.info.e.to_s\n nil\n end", "def create_fb_url_with_creds(indv_u_id, ac_token, decoded_state: nil)\n url = FACEBOOK_URL + \"?individual_user_id=#{indv_u_id}&secret=#{ac_token}\"\n if decoded_state\n url += \"pathway=#{decoded_state['pathway']}\" +\n \"&gift_template_id=#{decoded_state['gift_template_id']}\" \n end\n \n #Creates facebook oauth dialog url\n #--PE 10/30/14\n def create_oauth_url(cb_url, encoded_auth_state)\n oauth_url = \"https://www.facebook.com/dialog/oauth/?client_id=\" +\n \"#{APP_ID}&redirect_uri=#{cb_url}&state=#{encoded_auth_state}\"\n end\n\n #########\n protected\n ######### \n\n #Renew the access_token after API failure --PE July 17, 2012\n def rescue_api_error\n session.delete(:access_token)\n\t session.delete(:individual_user_id)\n\t oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, AUTH_CALLBACK)\n\t redirect_to(:action => \"exit_portal\", :url => oauth.url_for_oauth_code)\n end\n\n #Redirect to app index page after connection is reset --PE July 23, 2012\n def rescue_connection_reset\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (connection reset). \" +\n \"Please try again.\"\n end\n\n #Redirect to app index page after undefined method errors --PE July 23, 2012\n def rescue_undefined_method\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (undefined method). \" +\n \"Please try again.\"\n end\nend", "def facebook\n @facebook ||= Koala::Facebook::API.new(oauth_token)\n block_given? ? yield(@facebook) : @facebook\nrescue Koala::Facebook::APIError => e\n logger.info e.to_s\n nil\nend", "def post(message)\n login_to_facebook\n bob.post(message)\nend", "def authenticate(fb_user)\n \n \n end", "def facebook\n @facebook ||= Koala::Facebook::API.new(oauth_token)\n # error recovery (block-ish so can be shared across the rest of the Facebook methods)\n block_given? ? yield(@facebook) : @facebook\n rescue Koala::Facebook::APIError => e\n if Rails.env.production?\n logger.info e.to_s\n nil\n else\n raise e\n ### e.fb_error_xx parses the error, as in e.fb_error_type, e.fb_error_code, ...\n end\n end", "def logged_in_to_facebook_and_app_authorized\n if ensure_application_is_installed_by_facebook_user \n # filter_parameter_logging :fb_sig_friends # commenting out for now because it fails sometimes\n end\n end", "def get_facebook_page(page_id)\n # Facebooker::Page.new(page_id)\n @graph = Koala::Facebook::API.new(fb_access_token)\n page_token = @graph.get_page_access_token(page_id)\n @page_graph = Koala::Facebook::API.new(page_token)\n @page_graph.get_object('me')\n end", "def facebook\n oauth_info = OauthToken.get_oauth_info('facebook')\n session[:redirect_after_oauth] = params[:redirect_to] ? params[:redirect_to] : nil\n redirect_to \"https://graph.facebook.com/oauth/authorize?client_id=#{oauth_info['consumer_key']}\"+\n \"&redirect_uri=#{oauth_info['callback']}\"+\n \"&scope=read_stream,publish_stream,publish_actions,offline_access,user_likes,user_status,\"+\n \"user_birthday,user_relationships,user_relationship_details,\"+\n \"email,user_checkins,sms,user_online_presence\"+\n \"&display=touch\"\n end", "def initialize options={}\n @oauth = Koala::Facebook::OAuth.new \\\n Facebook.config[:app_id], Facebook.config[:secret_key]\n @graph = Koala::Facebook::API.new access_token\n @page = @graph.get_object(Facebook.config[:page_id])\n end", "def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token!\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n# redirect_to dashboard_url\n redirect_to root_url\n end", "def graph\n Koala::Facebook::GraphAPI.new(access_token)\n end", "def try\r\n\r\n\tif session[\"fb_access_token\"].present?\r\n\t@fql = Koala::Facebook::API.new(session[\"fb_access_token\"])\r\n\tfql = @fql.fql_query(\"SELECT eid FROM event_member WHERE uid = me()\")\r\n\tend\r\nend", "def fb_permissions\n fb_user = FbGraph::User.new('me', :access_token => self.access_token)\n fb_user.permissions\n end", "def new\n \n fb_auth = FbGraph::Auth.new('155275974530339', '309d340d359061c890906926e8139e4a')\n fb_auth.client # => Rack::OAuth2::Client\n \n client = fb_auth.client\n client.redirect_uri = \"http://localhost:3000/config_keys\"\n\n # redirect user to facebook\n redirect_to client.authorization_uri(\n :scope => [:email, :read_stream, :offline_access]\n )\n\n # in callback\n client.authorization_code = params[:code]\n access_token = client.access_token! # => Rack::OAuth2::AccessToken\n FbGraph::User.me(access_token).fetch # => FbGraph::User\n \n end", "def userinfo(access_token) \n querystr = \"https://graph.facebook.com/me?access_token=\"+access_token\n\n uri = URI.parse(URI.encode(querystr))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n response = http.request(request)\n result = JSON.parse(response.body)\n myinfo = {}\n if result['name']\n myinfo['name']=result['name']\n myinfo['fbid']=result['id']\n end\n return myinfo\n end", "def facebook_callback\n if params[:error_reason]\n redirect_to :controller => :home, :action => :index\n return\n end\n oauth_info = OauthToken.get_oauth_info('facebook')\n uri = URI.parse(\"https://graph.facebook.com/oauth/access_token\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n new_params = {:client_id => oauth_info['consumer_key'],\n :client_secret => oauth_info['consumer_secret'],\n :redirect_uri => oauth_info['callback'],\n :code => params[:code]}\n \n request = Net::HTTP::Post.new(uri.request_uri)\n request.set_form_data(new_params)\n response = http.request(request)\n \n fields = response.body.split('=')\n access_token = fields[1]\n\n oauth_token = OauthToken.find_by_token_and_site_token(access_token,'facebook')\n \n if current_user and oauth_token.present? and oauth_token.user and current_user != oauth_token.user\n redirect_to :controller => :oauth, :action => :duplicate_users, :id => oauth_token.id\n return\n end\n\n # Create the Oauth token\n if oauth_token\n oauth_token.update_attributes({:site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n else\n oauth_token = OauthToken.create({:user_id => (current_user ? current_user.id : nil),\n :site_token => 'facebook',\n :site_name => \"Facebook\",\n :token => access_token}) \n oauth_token.get_user_info\n \n TrackedAction.add(:connected_to_third_party_site, oauth_token.user)\n TrackedAction.add(:connected_to_facebook, oauth_token.user)\n oauth_token.user.give_level_up_credits(10)\n end\n\n OauthToken.delay.autofollow_friends(oauth_token.id)\n\n flash[:authenticated_facebook] = 1\n if !session[:redirect_after_oauth].blank?\n redirect_to session[:redirect_after_oauth]\n session[:redirect_after_oauth] = nil\n else\n redirect_to :controller => :home, :action => :index\n end\n end", "def facebook\n @fb_user ||= FbGraph::User.me( self.authentications.find_by_provider('facebook').token)\n end", "def getFirebaseExample\n $fb_root.get(\"/\").body\nend", "def list\n oauth_check_authorization\n \n @friends = facebook_client.friends_with_pictures\n end", "def index \n session[:oauth] = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + '/home/callback')\n @auth_url = session[:oauth].url_for_oauth_code(:permissions=>\"read_stream,publish_stream\") \t\n\t\tputs session.to_s + \"<<< session\"\n end", "def facebook(*args)\n W \"TRY facebook\", *args unless Rails.env.test?\n\n oauth = args.extract_options!\n expect! oauth => {\n :oauth_token => String,\n :oauth_expires_at => [Integer, nil],\n }\n \n client = Koala::Facebook::API.new(oauth[:oauth_token])\n client.put_connections(*args) unless Rails.env.development?\n W \"OK facebook\", *args unless Rails.env.test?\n end", "def show\n if $graph.nil?\n $graph = Koala::Facebook::API.new\n end\n end", "def fb_authenticate \n # If we have a new access token, validate it by attempting to get 'me',\n # the logged in facebook user\n if params[:access_token]\n begin\n rg = RestGraph.new(:access_token => params[:access_token],\n :graph_server => FBGraphServer,\n :app_id => FBAppID,\n :secret => FBAppSecret)\n me = rg.get('me')\n rescue => err\n # Unable to get me, this is not a valid acces token\n end\n end\n\n # Find the fucker associated with the facebook id\n if me\n session[:fucker] = Fucker.first(:conditions => {:facebook_id => me['id']})\n if !session[:fucker]\n session[:fucker] = Fucker.new({:name => me['name'], :facebook_id => me['id']})\n begin \n session[:fucker].save!\n rescue => e\n $log.warn(\"Unable to save new session fucker: #{e.message}\")\n session[:fucker] = nil\n end\n end\n elsif !params.has_key? :access_token && !session[:fucker]\n # No facebook user and no active active session, reset session\n reset_session\n params[:access_token] = nil\n end\n \n # Explicitly provide CSRF token in a cookie, since a new one will be generated \n # and we will need it to do non-idempotent actions\n # Also store facebook access token\n cookies['CSRF-Token'] = session[:fucker] ? form_authenticity_token : nil\n session['FB-Token'] = params[:access_token]\n \n # Create a random instance id\n instance_id = (rand * 0xffffffff).to_i;\n\n # Return the fucker\n respond_to do |format|\n format.json { render json: {:instance_id => instance_id, :fucker => session[:fucker], \n :csrf_token => cookies['CSRF-Token']}}\n end\n end", "def get_permissions_facebook(api_client)\n api_request = 'me?fields=permissions'\n logger.debug2 \"api_request = #{api_request}\"\n begin\n api_response = api_client.get_object(api_request)\n rescue Koala::Facebook::ClientError => e\n e.logger = logger\n e.puts_exception(\"#{__method__}: \")\n raise\n end # rescue\n logger.debug2 \"api_response = #{api_response}\"\n self.permissions = api_response['permissions']['data']\n save!\n self\n end", "def facebook\n authorize! :connect_facebook, current_user\n facebook = Koala::Facebook::API.new(params[:fb_token])\n me = facebook.get_object(\"me\")\n \n @user = current_user\n @user.update_attributes(fb_uid: me['id'], fb_token: facebook.access_token, fb_token_expires_at: params[:fb_token_expires_at], fb_token_refreshed_at: params[:fb_token_refreshed_at])\n @include_auth_token = true\n respond_with @user, :location => nil\n \n rescue Koala::Facebook::APIError => error\n render :json => { :error => error.fb_error_message }, :status => :unauthorized\n end", "def grab_info(name)\n\n\n\n\n result = HTTParty.get(\"https://graph.facebook.com/#{name}\")\n\n user_fb = JSON.parse(result)\n\n# id = result[\"id\"]\n# name = result[\"name\"]\n# gender = result[\"gender\"]\n# locale = result[\"locale\"]\n# un = result[\"username\"]\n\nend", "def det_facebook_login_method\n @status, @msg, @data = UserValidator.det_facebook_login_method(params)\n end", "def create\n client = Facebook.auth(callback_facebook_url).client\n client.authorization_code = params[:code]\n access_token = client.access_token! :client_auth_body\n user = FbGraph::User.me(access_token).fetch\n authenticate Facebook.identify(user)\n redirect_to dashboard_url\n end", "def client\n Mogli::Client.new(Network::Facebook.access_token)\n end", "def facebook(name: T.unsafe(nil), email: T.unsafe(nil), username: T.unsafe(nil), uid: T.unsafe(nil)); end", "def invite_facebook_friends\n end", "def facebook_oauth\n # Insert your own Facebook client ID and secret here\n # auth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n @facebook_oauth = Koala::Facebook::OAuth.new(ENV[\"FACEBOOK_KEY\"], ENV[\"FACEBOOK_SECRET\"])\n\n\n\n end", "def facebook_authorization_callback\n begin\n #Fetch the 'code' query parameter from the callback\n code = params[:code]\n\n #Get token object, passing in the authorization code from the previous step\n logger.fatal \"Redirect to facebook for getting token: #{code} , #{Settings.facebook.REDIRECT_URI}\"\n token = facebook_client.auth_code.get_token(code, {:redirect_uri => Settings.facebook.REDIRECT_URI, :parse => :facebook})\n\n api_endpoint = \"#{Settings.api_endpoints.Login}\"\n response = Typhoeus.post(api_endpoint, body: {\n userId: current_user_id,\n loginType: 'FACEBOOK',\n accessToken: token.token\n })\n\n if response.success? && !api_contains_error(\"Login\", response)\n add_access_token_api_response = JSON.parse(response.response_body)\n add_access_token_api_response = add_access_token_api_response[\"LoginResult\"]\n if add_access_token_api_response[\"isUserLogedIn\"] == true\n session[:facebook_token] = token.token\n end\n end\n\n redirect_to user_path(current_user_id)\n rescue OAuth2::Error => e\n logger.fatal e.message\n logger.fatal e.backtrace.inspect\n redirect_to Settings.facebook_auth_url\n end\n end", "def index\n\n # Authentication\n @oauth_redirect_url = request.url\n if params[:code]\n session[:access_token] = Koala::Facebook::OAuth.new(@oauth_redirect_url).get_access_token(params[:code])\n redirect_to \"#{request.protocol}#{request.host_with_port}#{request.path}\" and return\n end\n\n @fb_users = FbUser.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @fb_user }\n end\n end", "def return_from_general_auth\t\n # back from oauth wormhole..obtain facebook user and credentials\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GEN_AUTH_CALLBACK)\n session[:access_token] = oauth.get_access_token(params[:code])\n graph = Koala::Facebook::API.new(session[:access_token])\n facebook_user_id = graph.get_object(\"me\")[\"id\"]\n session[:individual_user_id] = \n IndividualUser.login_or_create(facebook_user_id,session[:access_token])\n\n # determine where to redirect\n state, link = false, false\n\t if params[:state]\n state = true\n decoded_state = ActiveSupport::JSON.decode(params[:state])\n \n # [Page Tab] return to the page tab\n if decoded_state['page_tab_id']\n\t\t\t graph = Koala::Facebook::API.new\n\t\t\t page_tab = graph.get_object(\"#{decoded_state['page_tab_id']}\")\n\t\t\t if page_tab[\"link\"]\n link = true\n\t\t\t\t encoded_page_state = URI.encode(ActiveSupport::JSON.encode(\n {:individual_user_id => session[:individual_user_id], \n :secret => session[:access_token]\n }))\n end\n end\n end\n \n # handle the redirect\n if state && link\n redirect_to(page_tab[\"link\"] + \n \"?sk=app_#{APP_ID}&app_data=#{encoded_page_state}\")\n else\n redirect_to(create_fb_url_with_creds(session[:individual_user_id],\n session[:access_token]))\n end\n return\n end", "def fb_friends\n fb_user = FbGraph::User.new('me', :access_token => self.access_token)\n fb_user.friends\n end", "def fetch_facebook_friends\n\t\treturn fetch_facebook_friends_or_subscribers_or_subscribedto(\"friends\")\n\tend", "def get_fb_permissions\n if fb_access_token\n @graph = Koala::Facebook::API.new(fb_access_token)\n @graph.get_connections('me', 'permissions') rescue []\n else\n []\n end\n end", "def publish_on_fb\n\t \tbegin\n\t\t \tme = FbGraph::User.me(oauth_token)\n\t\t \tme.feed!(\n\t\t \t\t:message => \"\",\n\t\t \t\t:picture => \"indirizzo immagine\",\n\t\t \t\t:link => \"indirizzo applicazione\",\n\t\t \t\t:name => \"\",\n\t\t \t\t:description => \"\"\n\t\t \t)\n\t\trescue Exception\n\t\t\t# Condivisione non andata a buon fine.\n\t\tend\n \tend", "def load_facebook_api\n return if !@facebook_api.nil?\n \n # Find the user token\n auth = authorizations.where(:provider => 'facebook').first\n if !auth.nil?\n @facebook_api = Koala::Facebook::API.new(auth.token)\n else\n raise 'User does not have a Facebook authorization.'\n end\n end", "def fb_me token=nil\n \t\tif ENV['PAGE_ID']\n \t\t\t@token = token || Rails.cache.read('page_token') || ENV['PAGE_TOKEN']\n \t\t\t@fb_user = FbGraph::Page.new( ENV['PAGE_ID'], :access_token => @token ).fetch\n \t\telse\n\t\t\t@token = token || Rails.cache.read('TOKEN') || ENV['TOKEN']\n \t\t\t@fb_user = FbGraph::User.me( @token )\n \t\tend\n \tend", "def facebook\n handle_redirect('devise.facebook_data', 'Facebook')\n end", "def get_facebook_user(facebook_id)\n @graph = Koala::Facebook::API.new(fb_access_token) if !fb_access_token.blank?\n @graph ? @graph.get_object(\"me\") : nil\n end", "def fb_user\n FbGraph::User.me(fb_token)\n end", "def show\n auth = Facebook.auth.from_cookie(cookies)\n authenticate Facebook.identify(auth.user)\n redirect_to dashboard_url\n end", "def access_token\n Rails.configuration.fb.messenger.access_token\n end", "def facebook_id \n self.facebook_auth_cache.uid\n end", "def rc_facebook\n @rc_facebook ||= RestCore::Facebook.new(rc_facebook_options_new)\n end", "def login_from_facebook\n fb_cookie = get_facebook_cookie\n return unless fb_cookie and fb_cookie[\"uid\"]\n\n #uid : 507527287\n #sig : ddf9dffcd85fcc41dbe4257b5eee922b\n #base_domain : gear.com\n #secret : fSoxbS_tGGF0oP2c9_SUbw__\n #access_token : 225955489319|2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287|d5zULU1zLZFguUUcsqVU0-C-tOM.\n #session_key : 2.KBSGTAnBP5tSEIxJBXcWfA__.3600.1278799200-507527287\n #expires : 1278799200\n\n user = User.find_by_fb_user_id(fb_cookie[\"uid\"])\n\n # cant find the user in the db but they have a fb session..\n return unless user\n \n # Add fb user to the user object and set the current user\n self.current_user = user \n end", "def facebook_callback\n hash = request.env[\"omniauth.auth\"]\n if hash\n email = hash[\"info\"][\"email\"]\n username = hash[\"info\"][\"nickname\"]\n gender = hash[\"extra\"][\"raw_info\"][\"gender\"]\n provider = hash[\"provider\"]\n gid = hash[\"uid\"]\n token = hash[\"credentials\"][\"token\"]\n auth = Authentication.find_by_provider_and_gid(provider, gid)\n if !gamer_signed_in?\n if auth\n if auth.gamer\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, auth.gamer)\n else\n flash[:error] = t(:no_account)\n redirect_to \"/gamers/sign_up\"\n end\n else\n gamer = Gamer.find_by_email(email)\n if gamer\n Authentication.create_with_omniauth(provider, gid,\n token, nil, email, gamer.id)\n flash[:success] = t(:signed_in_fb)\n sign_in_and_redirect(:gamer, gamer)\n else\n session[\"devise.token\"] = token\n session[\"devise.gid\"] = gid\n session[\"devise.token_secret\"] = nil\n flash[:info] = t(:continue_reg_fb)\n redirect_to controller: \"social_registrations\",\n action: \"new_social\", email: email, username: username,\n gender: gender, provider: provider\n end\n end\n else\n if !auth\n Authentication.create_with_omniauth(provider,gid,\n token, nil, email, current_gamer.id)\n flash[:success] = t(:logged_in_to_fb)\n redirect_to \"/gamers/edit\"\n else\n Authentication.update_token(current_gamer.id, provider, token)\n redirect_to \"/games/post_facebook\"\n end\n end\n else\n flash[:error] = t(:oops_error_fb)\n redirect_to root_url\n end\n end", "def get_other_friends(fbid)\n graph_url = \"https://graph.facebook.com/#{fbid}/friends?access_token=TOKEN\"\n parsed_resp = query_graph(graph_url)\n friends = parsed_resp[\"data\"]\n return friends\nend", "def facebook_authentication\n begin\n data = 0\n user = WebUser.find_by_email(params[:email])\n \n if user.nil?\n data = register(params[:provider], params[:uid], params[:name], params[:email], params[:oauth_token], params[:gender], params[:birthday], params[:nickname])\n else\n data = user\n check_pending_friends(user['id'], user['bv_player_id'], user['email'])\n end\n rescue\n data = 1\n end\n \n render :json => data\n end", "def fbauthorize\n redirect_to fb_auth_login_url.to_s\n end", "def oauth_authorize\n redirect_to facebook_client.authorize(oauth_callback_url)\n end", "def facebook?\n self.kind == 'facebook'\n end", "def facebook_data_about(item, keys = {})\n begin\n res = JSON.parse(token_get(item) || \"{}\") \n keys[:as] ? res[keys[:as]] : res\n rescue SocketError, Errno::ECONNRESET, OAuth2::HTTPError, EOFError => e\n # TODO :: hoptoad\n nil\n end\n end", "def ensure_authenticated\n if current_facebook_user.nil? && params[:Caller].blank?\n redirect_to url_for(:controller => \"login\")\n else\n if params[:Caller]\n phone = params[:Caller].match(/(\\d){10}$/)[0]\n @user = Phone.find_by_number(phone).try(:user)\n unless @user\n redirect_to url_for(:controller => \"login\", :action => \"not_found\", :format => :xml)\n return\n end\n offline_client = Mogli::Client.new(@user.facebook_access_token, nil)\n fb_user = Mogli::User.find(@user.facebook_id, offline_client) # reusing current_facebook_user breaks use in else, somehow\n else\n @user = User.find_or_create_by_facebook_id(current_facebook_user.id)\n #not the best place, but ...\n set_access_token\n current_facebook_user.fetch\n end\n @feed = FbFeed.new(@user)\n logger.debug(\"twilio, #{ @feed }\")\n logger.debug(\"url = https://graph.facebook.com/#{ @user.facebook_id }/home?access_token=#{ @user.facebook_access_token }\")\n end\n end", "def fb_token\n x = self.authentications.find_by(provider: 'facebook')\n return x.token unless x.nil?\n end", "def fb_token\n x = self.authentications.find_by(provider: 'facebook')\n return x.token unless x.nil?\n end", "def fb_token\n x = self.authentications.find_by(provider: 'facebook')\n return x.token unless x.nil?\n end", "def facebook_activity(share_url=CONFIG[:host], connection_name='dropresume:update')\n if self.auth_provider == 'facebook'\n share_to_facebook(self, connection_name, \"http://#{share_url}\")\n end\n end", "def show\n auth = Authentication.auth.from_cookie(cookies)\n authenticate Authentication.identify(auth.user)\n redirect_to Facebook.config[:app_url]\n end", "def client\n if current_account && current_account.fb_token\n FBGraph::Client.new(:client_id => $api_key,:secret_id =>$secret_key,:token=>current_account.fb_token) \n else\n FBGraph::Client.new(:client_id => $api_key,:secret_id =>$secret_key) \n end\n\n # OAuth2::Client.new($api_key, $secret_key, :site => 'https://graph.facebook.com')\n end", "def show\n session[:oauth] = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + '/callback?event_id='+params[:id])\n @auth_url = session[:oauth].url_for_oauth_code(:permissions=>\"email, user_events, friends_events, rsvp_event\") \n puts session.to_s + \"<<< session\"\n \n\n @event = Event.find(params[:id])\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end", "def koala\n return Koala::Facebook::API.new(facebook_access_token)\n end", "def facebook_client\n @_facebook_client ||= begin\n _id, _secret = resource.facebook_app_id, resource.facebook_app_secret\n \n ::OAuth2::Client.new(_id, _secret, {\n :site => 'https://graph.facebook.com',\n\n # by default this would be /oauth/token\n :token_url => '/oauth/access_token',\n\n # Docs are vague on this, but I believe it may work with :post also\n :token_method => :get\n })\n end\n end", "def show\n auth = Facebook.auth.from_cookie(cookies)\n authenticate Facebook.identify(auth.user)\n redirect_to dashboard_url\n end", "def facebook_client\n @facebook_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"facebook\").first\n Koala::Facebook::API.new(provider.access_token)\n end\n end\n end", "def facebook_variables\n @facebooker_config = Facebooker::AdapterBase.facebooker_config\n @canvas_page_name = @facebooker_config['canvas_page_name']\n @application_base_url = 'http://apps.facebook.com/' + @canvas_page_name\n @api_key = @facebooker_config['api_key']\n @ajax_server = \"#{Facebooker::AdapterBase.facebooker_config['callback_url']}\"\n @facebook_session = facebook_session\n @scrollbar = session[:scrollbar]\n end", "def fb_auth\n @auth ||= self.authentications.facebook.first\n end", "def get_facebook_queries project_id, query_id\n get \"projects/#{project_id}/facebookqueries/#{query_id}\"\n end", "def fetch_details_from_facebook\n\t\t# graph = Koala::Facebook::API.new(self.token)\n\t\t# facebook_data = graph.get_object(\"me\")\n\t\t# self.username = facebook_data['username']\n\t\t# self.save\n\t\t# self.user.username = facebook_data['username'] if self.user.username.blank?\n\t\t# self.user.image = \"http://graph.facebook.com/\" + self.username + \"/picture?type=large\" if self.user.image.blank?\n\t\t# self.user.location = facebook_data['location'] if self.user.location.blank?\n\t\t# self.user.save\n\t\tself.user.has_facebook = true\n\t\tself.user.save\n\tend", "def current_user\n User.find_by(facebook_id: params[:facebook_id])\n end", "def user_from_code(temp_code)\n MiniFB.get(access_token(temp_code), \"me\")\n end", "def find_facebook_friends_with_accounts\n load_facebook_api\n friends = @facebook_api.get_connections('me', 'friends')\n \n friend_ids = []\n friends.each { |friend| friend_ids << friend['id'] }\n\n auths = Authorization.where(:provider => 'facebook', :uid => friend_ids)\n\n output = []\n auths.each { |auth| output << auth.user }\n\n output\n end", "def facebook_callback\n user_data = parse_facebook_user_data\n token = sign_user_token(user_data[\"email\"],\"facebook\")\n\n user = User.find_by_token(token)\n if user\n set_current_user(user)\n else\n user = User.new(:email => user_data[\"email\"],\n :nick => user_data[\"first_name\"],\n :token => token)\n user.save!\n\n set_current_user(user)\n end\n redirect_to :controller => \"sales_management\",\n :action => \"index\",\n :user_id => user.id\n end", "def facebook_client\n FacebookClient.new FB_CONFIG[:client_id], FB_CONFIG[:secret_id],\n session[:access_token]\n end", "def fb_authorized?\n self.access_token.present? \n end", "def request_like_fan_page?\n Rails.logger.info(\"TOKEN : #{self.f_token}\")\n oauth = Koala::Facebook::OAuth.new(ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'])\n graph = Koala::Facebook::API.new(self.f_token)\n data = graph.get_connections(self.f_id, \"likes/#{ENV['FACEBOOK_PAGE_ID']}\")\n\n found = false\n data.each do |like|\n found = true if like['id'] == \"#{ENV['FACEBOOK_PAGE_ID']}\"\n end\n return found\n end", "def facebook\n @user = User.find_for_facebook_oauth(request.env[\"omniauth.auth\"], current_user)\n\n if @user.persisted?\n @user\n sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated\n set_flash_message(:notice, :success, :kind => \"Facebook\") if is_navigational_format?\n else\n request.env[\"omniauth.auth\"]\n session[\"devise.facebook_data\"] = request.env[\"omniauth.auth\"]\n redirect_to new_user_registration_url\n end\n end", "def fb_object_id\n self.fb_action_id\n end", "def connected_to_facebook?\n fb_uid && fb_access_token\n end", "def get_fb_params\n\t\"user_photos,email\"\nend" ]
[ "0.7738893", "0.77128214", "0.72962236", "0.7192094", "0.7100549", "0.6969892", "0.6934083", "0.67646575", "0.65992135", "0.6581492", "0.6576277", "0.6563032", "0.6537288", "0.648308", "0.6481627", "0.64763224", "0.6459488", "0.64523834", "0.6420313", "0.6404448", "0.63965833", "0.6383513", "0.63702196", "0.63616216", "0.63193744", "0.63139856", "0.63107795", "0.6288096", "0.6271107", "0.6249337", "0.6231048", "0.6229602", "0.6221857", "0.62216276", "0.6218555", "0.62077296", "0.62009376", "0.6191118", "0.61874956", "0.61468333", "0.6111112", "0.6108001", "0.6106183", "0.61038834", "0.6098127", "0.6086875", "0.6086225", "0.60785073", "0.60735697", "0.6070215", "0.6034833", "0.60174733", "0.6008479", "0.60083884", "0.5996197", "0.5985113", "0.59571296", "0.5954565", "0.5943611", "0.5938786", "0.59272057", "0.59269243", "0.591739", "0.58879656", "0.58848697", "0.5878259", "0.5871882", "0.586952", "0.5868145", "0.5857465", "0.5848039", "0.58414537", "0.58376074", "0.5826203", "0.5796128", "0.5784177", "0.5784177", "0.5784177", "0.57800007", "0.57732135", "0.5770208", "0.5761131", "0.5758561", "0.57561135", "0.5755046", "0.57343936", "0.5721785", "0.5720443", "0.5712259", "0.5704968", "0.57013166", "0.56997037", "0.5686788", "0.5681392", "0.56620073", "0.56565726", "0.5652042", "0.5649579", "0.5647998", "0.56418365", "0.564096" ]
0.0
-1
Action responders must be public to receive Wisper notifications; see for relevant detail. (Needless to say that, even though these are public methods, they should never be called directly.)
def on_create_success(entity) Responder::CreateSuccess.new(self).respond_to entity end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_methods; end", "def action_methods; end", "def action_methods; end", "def actions; end", "def action_hook; end", "def send_action(*_arg0); end", "def run_actions; end", "def process_action(...)\n send_action(...)\n end", "def action_responder(name_of_action)\n action_responders[name_of_action.to_sym]\n end", "def active_responder\n action_responder(action_name)\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def mco_action\n raise RuntimeError, \"Not implemented\"\n end", "def playable_action\n raise NotImplementedError\n end", "def define_action_hook; end", "def actions\n client.actions\n end", "def notifications\n end", "def action_missing(*)\n end", "def add_actions; end", "def notifier; end", "def notifier; end", "def action\n end", "def only_render_implemented_actions\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n raise AbstractController::ActionNotFound unless action_methods.include?(params[:action])\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n end", "def action\n end", "def method_for_action(action_name); end", "def actions\n []\n end", "def receive_action(action)\n self.define_singleton_method(:perform_action, &action)\n end", "def _handle_action_missing(*args); end", "def actions() ; info[:actions] ; end", "def actions() ; info[:actions] ; end", "def _my_action_action\n {:text => \"Not used\"}\n end", "def handlers; end", "def handlers; end", "def handlers; end", "def to_wires_event; self; end", "def action_target()\n \n end", "def allow_own_actions_while_proxied?\n true\n end", "def invoke_action(name)\n end", "def invoke_action(name)\n end", "def invoke_action(name)\n end", "def available_actions\n fail NotImplementedError\n end", "def watched_actions\n @watched_actions\n end", "def blocklisted_responder; end", "def action_run\n end", "def process\n send_request @action\n end", "def method_missing(action, *args)\n action.to_s =~ /^(.+)!$/\n if $1 && respond_to?($1)\n send($1, *args)\n status\n else\n super.method_missing(action, *args)\n end\n end", "def respond(); end", "def action_enable\n end", "def actions\n %w{void}\n end", "def actions\n self.class.actions\n end", "def release_actions; end", "def publish_action(f)\n send_as :notification\n from f\n story_size SHORT # or ONE_LINE or FULL\n data :friend=>\"Mike\"\n end", "def handle_action(username, actiontype)\n \n end", "def act notification, options={}\n # ...or nothing\n end", "def action_want_to_perform(arg)\r\n self.class.actions_allowed[arg]\r\n end", "def act\n end", "def action\n driver.action\n end", "def send_events; end", "def action_name; end", "def actions\n @actions\n end", "def lookup_action; end", "def click_action\n raise NotImplementedError \"Subclasses must implement this method\"\n end", "def actions\r\n return @actions\r\n end", "def only_render_implemented_actions\n raise AbstractController::ActionNotFound unless action_methods.include?(params[:action])\n end", "def _call_action(action)\n send(action)\n end", "def public_methods # :nodoc:\n @client.wsdl.soap_actions\n end", "def process_action(method_name, *args); end", "def skip_actions; end", "def set_actions\n actions :all\n end", "def deliver\n raise Pomodori::Notifier::Error, \"This method needs to be overwritten\"\n end", "def action_methods\n self.class.action_methods\n end", "def send_notifications\n end", "def perform_action(*args)\n end", "def subscribed; end", "def user_action_on_resource_authorized\n end", "def blocklisted_responder=(_arg0); end", "def is_public_action?\n klass = self.class\n return false unless klass.const_defined? 'PUBLIC_ACTIONS'\n klass::PUBLIC_ACTIONS.collect(&:to_s).include? action_name\n end", "def factions\n \n end", "def handler_method; end", "def method_for_action(action_name)\n self.class.visible_action?(action_name) && super\n end", "def handleAction evt, action, caller\n # DO NOTHING - this method shall be implemented by the children\n return false\n end", "def default_action(msg)\n #\n # do nothing.\n #\n end", "def method_missing(action, *args, &block)\n return nil\n end", "def broadcast\n end", "def defined_actions\n\n controller.instance_methods.map(&:to_sym) & ResourceController::ACTIVE_ADMIN_ACTIONS\n\n end", "def messaging\n end", "def initialize\n @actions = []\n end", "def action_list\n case\n when no_servers_or_positive_balance? then clear_notifications\n when before_shutdown_warnings? then before_shutdown_actions\n when perform_shutdown? then shutdown_servers_actions\n when before_destroy_warnings? then before_destroy_actions\n when perform_destroy? then destroy_servers_actions\n else no_actions\n end\n end", "def waiver\n end", "def action(unit)\n\tend", "def callable_actions\n @callable_actions ||= Merb::SimpleSet.new(begin\n callables = []\n klass = self\n begin\n callables << (klass.public_instance_methods(false) + klass._shown_actions) - klass._hidden_actions\n klass = klass.superclass\n end until klass == Merb::Controller || klass == Object\n callables\n end.flatten)\n end", "def public_methods # :nodoc:\n [:ws_activation, :xml_subscribe, :xml_chk_subscriber, :xml_unsubscribe, :upd_subscriber]\n end", "def default_action; end", "def send_action action_name, service_name\n self.class.actions[action_name][service_name].run(self)\n end", "def app_wired_actions\n @hash[I_AM_APP_NOT_A_MIDDLEWARE]\n end", "def handler; end", "def handler; end", "def copy_actions\r\n end" ]
[ "0.663267", "0.663267", "0.663267", "0.6596799", "0.65697277", "0.6409653", "0.6386967", "0.6314557", "0.63032794", "0.6278916", "0.6277532", "0.6277532", "0.6277532", "0.6277532", "0.6277532", "0.6275237", "0.62480766", "0.6240649", "0.6225163", "0.6221447", "0.6182863", "0.6153445", "0.61447823", "0.61447823", "0.6022608", "0.6007472", "0.5992935", "0.5955097", "0.5954935", "0.59526086", "0.591621", "0.59057367", "0.59057367", "0.58896756", "0.5874879", "0.5874879", "0.5874879", "0.58644533", "0.586036", "0.585987", "0.5859057", "0.5859057", "0.5856737", "0.5856699", "0.58268654", "0.5822214", "0.58044124", "0.5803877", "0.5797872", "0.57868284", "0.5786466", "0.57734764", "0.5773036", "0.57721716", "0.576698", "0.57637143", "0.5748274", "0.57477546", "0.57263327", "0.57249266", "0.57185996", "0.5717092", "0.57158244", "0.570646", "0.56837904", "0.56834054", "0.5677283", "0.5673467", "0.5672196", "0.5672086", "0.5669818", "0.56697696", "0.5669752", "0.5664414", "0.56518227", "0.5650198", "0.5648244", "0.56415224", "0.56308085", "0.56301373", "0.5625267", "0.56158173", "0.5614817", "0.56142515", "0.56071013", "0.5603244", "0.55875427", "0.55769217", "0.55753434", "0.55743873", "0.55681956", "0.5567851", "0.5553618", "0.5543303", "0.55428725", "0.5538902", "0.55353", "0.5531195", "0.55269533", "0.55269533", "0.5526846" ]
0.0
-1
Actual Edit and Update failure logic is identical.
def on_edit_failure(payload) Responder::EditFailure.new(self).respond_to payload end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit?\n update? # same as update - no access \n end", "def test_editability(model_instance)\n return unless fee_classes.include?(model_instance.class)\n model_instance.errors.add(:base, 'uneditable_state') unless model_instance.claim.editable?\n rescue StandardError\n true\n end", "def handle_silent_modification_failure?\n self[:raise_on_save_failure] == false\n end", "def edit; raise ActionController::RoutingError.new('Not Found'); end", "def render_update_error\n render_error @resource\n end", "def edit\n raise NotImplementedError\n end", "def update\n if @task.update(task_params)\n if @task.saved_change_to_attribute?(\"item\") || @task.saved_change_to_attribute?(\"description\")\n redirect_to session.delete(:return_to), notice: \"Entry was successfully updated.\"\n elsif @task.saved_change_to_attribute?(\"status\")\n redirect_to session.delete(:return_to), notice: \"Status was successfully updated.\"\n elsif @task.saved_change_to_attribute?(\"deadline\")\n redirect_to session.delete(:return_to), notice: \"Deadline was successfully changed.\"\n else\n redirect_back(fallback_location: root_path)\n end\n # redirect_to session.delete(:return_to)\n else\n render action: 'edit'\n end\n end", "def protect_update\n unless self.changes.keys == [\"text\"] && self.changes[\"text\"].first.blank?\n raise ActiveRecord::ReadOnlyRecord\n end\n end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def on_modifying_entry(state, event, *event_args)\n super\n\n # Verify validity of the submission. # TODO: simulation - remove\n if simulating\n # From UploadController#update:\n # @item, failed = upload_edit(**data)\n __debug_sim('CODE') do\n args = \"data=#{submission.data.inspect}\"\n opt = 'index: false'\n \"@item, failed = upload_edit(#{args}, #{opt})\"\n end\n bad = nil\n if (db_fail = submission.db_failure)\n self.failures << 'DB create failed'\n elsif (bad = !(submission.metadata_valid = !submission.invalid_entry))\n self.failures << 'bad metadata'\n else\n self.succeeded << submission.id\n end\n if db_fail\n __debug_sim('[edit_db_failure: true]')\n __debug_sim('The database entry could not be updated.')\n elsif bad\n __debug_sim('[edit_invalid_entry: true]')\n __debug_sim('The entry is invalid/incomplete.')\n __debug_sim('(NOTE: PROBABLE FAILURE OF CLIENT-SIDE FORM VALIDATION)')\n else\n __debug_sim('[edit_invalid_entry: false]')\n __debug_sim('[edit_db_failure: false]')\n end\n end\n\n # Verify validity of the submission.\n unless simulating\n wf_validate_submission(*event_args)\n end\n\n valid = ready?\n\n # TODO: simulation - remove\n if valid\n __debug_sim('The database entry was updated.')\n else\n __debug_sim('System generates a form error message to be displayed.')\n end\n\n # Automatically transition to the next state based on submission status.\n if valid\n advance! # NOTE: => :modified\n else\n reject! # NOTE: => :editing\n end\n self\n end", "def save\n !update_case.has_key?(\"error\")\n end", "def render_invalid_record\n render (action_name == 'create' ? 'new' : 'edit')\n end", "def correctly_update_status\n\t\terrors.add(:base, 'La transaccion no fue exitosa') if self.invalid_status\n\tend", "def update\n access(:update)\n checked_params = check_params(FAILURE_PROPERTIES)\n checked_params[\"device\"] = Device.find(failure_params[\"device_id\"])\n checked_params[\"announcer\"] = Employee.find(failure_params[\"announcer_id\"])\n if failure_params[\"technician_id\"]\n checked_params[\"technician\"] = Employee.find(failure_params[\"technician_id\"])\n end\n\n respond_to do |format|\n if @failure.update(checked_params)\n format.html { redirect_to @failure}\n format.json { render :show, status: :ok, location: @failure }\n else\n format.html { render :edit }\n format.json { render json: @failure.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_action\n if has_errors?\n render :edit, options\n else\n redirect_to resource_location\n end\n end", "def should_fail_to_create(key, value, error, message)\n # Create and update are identical; both use PUT\n should_fail_to_change(key, value, error, message, false, true)\n end", "def edit_resource(type, id, data)\n bad_attrs = data_includes_invalid_attrs(data)\n\n if bad_attrs.present?\n msg = \"Attribute(s) '#{bad_attrs}' should not be specified for updating a server resource\"\n raise BadRequestError, msg\n end\n\n super\n end", "def update_failed?\n @update_failed\n end", "def update\n respond_to do |format|\n if @entry.valid_params?(entry_params) && @entry.update(entry_params)\n format.html { redirect_to redirect_path, notice: 'Entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @entry }\n else\n format.html { render :edit }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n rescue ActiveRecord::StaleObjectError\n respond_to do |format|\n format.html {\n flash[:alert] = \"This project has been updated while you were editing. Please refresh to see the latest version.\"\n render :edit\n }\n format.json { render json: { error: \"Stale object.\" } }\n end\n \n end", "def do_edit\n @record = find_if_allowed(params[:id], :update)\n end", "def update_existing?\n !self.errors.any? && !item_return? && exists?\n end", "def update\n validate_save_and_respond(update_change_set, :edit)\n end", "def edit\n \n end", "def update?\n # the edit here refers to the edit in material_shared_policy\n # that edit lets any admin, project_admin, or material_admin to edit the material\n # admins and material_admins makes sense in this case. project_admins require access\n # so they can update project and project cohorts of materials they aren't the owner of\n # and are not part of their project yet\n # This is needed when there are multiple authors on a project. An non project admin\n # author creates the material. Then the project admins needs to find it and mark\n # configure the advanced configuration options. Otherwise a portal admin needs to\n # get involved.\n edit? || owner?\n end", "def updateEdit\n id_t = params[:project][:editItem][:id]\n new_state = params[:project][:editItem][:new_state]\n puts \"id_t: \" + id_t\n @project_edit = ProjectEdit.find_by(id: id_t)\n @project_edit.update(:aasm_state => new_state)\n puts @project_edit.description\n if new_state == \"accepted\"\n @project.description = @project_edit.description\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render json: @project, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end\n\n\n\n if new_state == \"rejected\"\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render json: @project, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end\n\n\n end", "def update\n if @resource.update_attributes(safe_parameters)\n redirect_to(action: :index, notice: l(\"#{snake_case_model_name}_edit_success_message\"))\n else\n render action: 'edit'\n end\n rescue ActiveRecord::RecordNotFound\n render_404\n end", "def edit\n \n end", "def edit\n \n end", "def edit\n \n end", "def edit\n \n end", "def edit\n \n end", "def edit\n \n end", "def edit\n \n end", "def can_modify\n\t\tself.changed_attributes.each do |attr|\n\n\t\t\tif attr.to_s == \"reports\"\n\t\t\t\tself.reports.each do |r|\n\t\t\t\t\tunless r.changed_attributes.blank?\n\t\t\t\t\t\tif r.owner_ids.include? self.created_by_user_id\n\t\t\t\t\t\telsif r.owner_ids.include? self.created_by_user.organization.id.to_s\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself.errors.add(:reports,\"You cannot edit #{attr.name.to_s}\")\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\n\t\t\telsif attr.to_s == \"recipients\"\n\t\t\t\trecipients_changed\n\t\t\telsif attr.to_s == \"payments\"\n\t\t\t\told_payment_not_deleted\n\t\t\telse\n\t\t\t\t## only in case of \n\t\t\t\tif self.owner_ids.include? self.created_by_user.id.to_s\n\t\t\t\telsif self.owner_ids.include? self.created_by_user.organization.id.to_s\n\t\t\t\telse\n\t\t\t\t\tself.errors.add(:owner_ids,\"You cannot edit the field: #{attr.to_s}\")\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend", "def edit?\n update?\n end", "def edit?\n update?\n end", "def edit\n #Nothing necessary\n end", "def assert_valid_update_page(model, **opt)\n action = opt[:id] ? :edit : :edit_select\n assert_valid_action_page(model, action, **opt)\n end", "def assert_validations_fail attrs\n put :update, :user => attrs\n assert_response :success\n assert @controller.current_user.errors.any?, \"Validation expected to fail\"\n end", "def update\n validate_save_and_respond(load_change_set, :edit)\n end", "def check_for_admin_update(updated_task)\n (self.request_number != updated_task.request_number ||\n self.description != updated_task.description ||\n self.mfg != updated_task.mfg ||\n self.mfg_num != updated_task.mfg_num ||\n self.cae_model != updated_task.cae_model ||\n self.cad_model != updated_task.cad_model ||\n self.completed != updated_task.completed ||\n self.closed != updated_task.closed ||\n self.model_types != updated_task.model_types.reverse)\n end", "def handle_silent_modification_failure?\n false\n end", "def update\n #prevent2_access('test',self)\n @user = User.find(params[:id])\n @user.save!\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => user.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def handle_edit\n render nothing: true\n end", "def action_if_note_not_created_or_updated(errors,from)\n if from.eql?('iframe')\n responds_to_parent do\n render :update do |page|\n page << \"enableAllSubmitButtons('buttons_to_disable');jQuery('#TB_ajaxContent').animate({scrollTop: 0}, 1000);show_error_msg('modal_new_task_errors','#{escape_javascript(errors.to_s)}','message_error_div');\"\n end\n end\n elsif from.eql?('assign')\n render :update do |page|\n page << \"enableAllSubmitButtons('buttons_to_disable');jQuery('#TB_ajaxContent').animate({scrollTop: 0}, 1000);show_error_msg('modal_new_task_errors','#{escape_javascript(errors.to_s)}','message_error_div');\"\n end\n end\n end", "def update_entry\n current_entry.update(permitted_entry_params)\n current_entry.errors.empty?\n end", "def do_update\n do_edit\n update_save\n end", "def new_or_edit\nend", "def test_update_with_invalid_name\r\n @user = User.find(@testUser)\r\n # It will raise an error while execute render method in controller\r\n # Because the goldberg variables didn't been initialized in the test framework\r\n assert_raise (ActionView::TemplateError){\r\n post :update, :id => @testUser, :user => { :clear_password => \"\",\r\n :name => \"\" }\r\n }\r\n assert !assigns(:user).valid? \r\n assert_template 'users/edit'\r\n end", "def update_with_conflict_validation(*args)\n update(*args)\n rescue ActiveRecord::StaleObjectError\n self.lock_version = lock_version_was\n errors.add :base, \"この記事は、あなたが編集中に他の人に更新されました。\"\n changes.except(:content, :updated_at).each do |title, values|\n errors.add title, \"was #{values.first}\"\n end\n false\n end", "def valid_edit_check(_traversal_env)\n Result::DENY\n end", "def edit?\n false\n end", "def test_edit(pid)\n result = super\n if result\n return result\n else\n return test_edit_from_policy(pid)\n end\n end", "def test_illegal_edit_assignment\r\n\r\n id = Assignment.first.id\r\n @assignment = Assignment.first\r\n original_assignment_name = @assignment.name\r\n number_of_assignment = Assignment.count\r\n # It will raise an error while execute render method in controller\r\n # Because the goldberg variables didn't been initialized in the test framework\r\n assert_raise (ActionView::TemplateError){\r\n post :update, :id => id, :assignment=> { :name => '',\r\n :directory_path => \"admin/test1\",\r\n :review_questionnaire_id => 1,\r\n :review_of_review_questionnaire_id => 1,\r\n },\r\n :due_date => { \"1\" , { :resubmission_allowed_id =>1 ,\r\n :submission_allowed_id =>3,\r\n :review_of_review_allowed_id =>1,\r\n :review_allowed_id =>1,\r\n :due_at =>\"2007-07-10 15:00:00\",\r\n :rereview_allowed_id =>1\r\n }\r\n }\r\n }\r\n assert_template 'assignment/edit'\r\n assert_equal original_assignment_name, Assignment.first.name\r\n end", "def view_edit\n\t\trequest_user(params[:id])\n\t\ttarget_user = @user\n\t\tif current_user.id != target_user.id && @admin == false\n\t\t\tredirect_to '/public/422.html', status: 422\n\t\t\treturn false\n\t\tend\n\tend", "def edit \n end", "def edit \n end", "def edit\n if !(current_user.id == @user.id || is_admin?)\n indicate_illegal_request I18n.t('users.not-your-account')\n end\n end", "def ignore_test_update_with_wrong_http_method_redirects\n get :update, :id => test_entry.id, model_identifier => test_entry_attrs\n assert_redirected_to_index\n \n delete :update, :id => test_entry.id, model_identifier => test_entry_attrs\n assert_redirected_to_index\n end", "def handle_update\n obj = model.with_pk(normalized_type, request, request.id)\n model.set_fields(obj, :edit, request, model_params)\n model.hook(:before_update, request, obj)\n if model.save(obj)\n model.hook(:after_update, request, obj)\n request.set_flash_notice(\"Updated #{model.class_name}\")\n redirect(:edit, obj)\n else\n request.set_flash_now_error(\"Error Updating #{model.class_name}\")\n edit_page(obj)\n end\n end", "def update\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n if @thing_with_error.update_attributes(params[:thing_with_error])\n format.html { redirect_to @thing_with_error, notice: 'Thing with error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing_with_error.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n redirect_to action: 'index', status: 303\n end", "def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @title = t 'oportunity.edit_title'\n\n respond_to do |format|\n Oportunity.transaction do\n if @oportunity.update(oportunity_params)\n flash.notice = t 'oportunity.correctly_updated'\n format.html { redirect_to(edit_oportunity_url(@oportunity)) }\n else\n format.html { render :action => :edit }\n raise ActiveRecord::Rollback\n end\n end\n end\n\n rescue ActiveRecord::StaleObjectError\n flash.alert = t 'oportunity.stale_object_error'\n redirect_to :action => :edit\n end", "def edit\r\n end", "def update\n @doco = Doco.find(params[:id].to_s)\n edit_check = edit_input('edit')\n \n if edit_check == 'passed edits'\n \n respond_to do |format|\n if @doco.update_attributes(params[:doco])\n flash[:notice] = 'Doco was successfully updated.'\n #format.html { redirect_to(@doco) }\n format.html { redirect_to(docos_url(:docotype => @doco.docotype)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doco.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def finish_editing(item = nil, meth: nil, **attr)\n meth ||= __method__\n item = edit_record(item)\n Log.warn { \"#{meth}: not editing: #{item.inspect}\" } unless item.editing\n editing_update(item, **attr)\n end", "def test_illegal_edit_assignment\n\n id = Assignment.first.id\n @assignment = Assignment.first\n original_assignment_name = @assignment.name\n number_of_assignment = Assignment.count\n # It will raise an error while execute render method in controller\n # Because the goldberg variables didn't been initialized in the test framework\n assert_raise (ActionView::TemplateError){\n post :update, :id => id, :assignment=> { :name => '',\n :directory_path => \"admin/test1\",\n :review_questionnaire_id => 1,\n :review_of_review_questionnaire_id => 1,\n },\n :due_date => { \"1\" , { :resubmission_allowed_id =>1 ,\n :submission_allowed_id =>3,\n :review_of_review_allowed_id =>1,\n :review_allowed_id =>1,\n :due_at =>\"2007-07-10 15:00:00\",\n :rereview_allowed_id =>1\n }\n }\n }\n assert_template 'assignment/edit'\n assert_equal original_assignment_name, Assignment.first.name\n end", "def handle_edit_response(response)\n edit_response = response\n status = edit_response[\"status\"]\n data = edit_response[\"data\"]\n\n if status == \"success\"\n response = {\"error\": false, \"data\": data}\n return JSON.parse(response.to_json)\n else\n response = {\"error\": true, \"data\": data}\n raise EditPaymentPlanError, JSON.parse(response.to_json)\n end\n end", "def edit\r\n \r\n end", "def test_edit\n\n # Try editing without logging in.\n get(:edit, {:id => subsections( :subsection_01_1_1).id }, {})\n assert_redirected_to(:controller => 'user', :action => 'login')\n\n # Try editing from a non-Admin account.\n get(:edit, { :id => subsections(:subsection_01_1_1).id }, rich_designer_session)\n assert_redirected_to(:controller => 'tracker',\t:action => 'index')\n #assert_equal(Pcbtr::MESSAGES[:admin_only], flash['notice'])\n\n # Try editing from an Admin account\n get(:edit, { :id => subsections(:subsection_01_1_1).id }, cathy_admin_session)\n assert_response 200\n assert_equal(subsections(:subsection_01_1_1).id, assigns(:subsection).id)\n assert_raise(ActiveRecord::RecordNotFound) { post(:edit, :id => 32423423) }\n\n end", "def update?\n edit? || owner?\n end", "def edit\n resource.before_actions[:edit].call(@record) if resource.before_actions[:edit]\n end", "def api_behavior(error)\n if resourceful? && put?\n display resource, :status => :ok\n else\n super\n end\n end", "def update\n @aiaioo_failure = AiaiooFailure.find(params[:id])\n\n respond_to do |format|\n if @aiaioo_failure.update_attributes(params[:aiaioo_failure])\n format.html { redirect_to @aiaioo_failure, notice: 'Aiaioo failure was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aiaioo_failure.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update_valid\n #TODO: reenable this once we can figure out how to remove any_instance\n # Recipe.any_instance.stubs(:valid?).returns(true)\n put :update, :id => Factory.create(:recipe)\n assert_redirected_to recipe_url(assigns(:recipe))\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end" ]
[ "0.6398828", "0.634274", "0.63220274", "0.6293285", "0.62882596", "0.624533", "0.6231929", "0.62030977", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.61782444", "0.6128053", "0.6126381", "0.6108158", "0.6069577", "0.6059538", "0.60548204", "0.6052061", "0.603915", "0.60386103", "0.6037889", "0.60227984", "0.6019513", "0.5959443", "0.5959106", "0.5958975", "0.5939945", "0.5939173", "0.5934021", "0.5934021", "0.5934021", "0.5934021", "0.5934021", "0.5934021", "0.5934021", "0.5930214", "0.59287584", "0.59287584", "0.5923715", "0.5922181", "0.59198165", "0.591102", "0.58997023", "0.5898121", "0.5893682", "0.58903533", "0.5885335", "0.58794165", "0.58767706", "0.5869763", "0.5857734", "0.585002", "0.58398443", "0.5834298", "0.58309305", "0.5830323", "0.58293223", "0.58157414", "0.58157414", "0.5812829", "0.5802254", "0.57888776", "0.57715625", "0.5769175", "0.5765262", "0.5758261", "0.57573885", "0.5756303", "0.5743784", "0.57403284", "0.5740048", "0.5729657", "0.5728545", "0.5728346", "0.5727279", "0.572446", "0.5723245", "0.57193077", "0.57192594", "0.57192594", "0.57192594", "0.57192594" ]
0.682925
0
============= Explict block =============
def hello(&block) block.call if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block?; end", "def block_node; end", "def block_node; end", "def require_block; end", "def blocks; end", "def blocks; end", "def blocks; end", "def captured_by_block?; end", "def yield; end", "def block=(_arg0); end", "def block=(_arg0); end", "def pre_block\n end", "def pre_block\n end", "def before_block_boundary?; end", "def blocks() end", "def block\n true\n end", "def block_given?() end", "def captured_by_block; end", "def after_block_boundary?; end", "def block_node=(_); end", "def run(&block); end", "def run(&block)\n end", "def post_block\n end", "def post_block\n end", "def context(&block); end", "def context(&block); end", "def begin; end", "def i_take_an_explicit_block &block\n puts block.inspect\nend", "def method &block\r\n\t1\r\nend", "def method &block\r\n\t1\r\nend", "def return(&block); end", "def method &block \r\n\t1\r\nend", "def with_block(&block)\n end", "def execute(&block)\n\tblock\nend", "def execute(&block)\n\tblock\nend", "def anonymous_blocklists; end", "def list_block()\n\nend", "def block_class() Block; end", "def call_block\n puts \"start\"\n yield \"foobar\" if block_given?\n puts \"end\"\nend", "def gimme_your_blocks\n yield if block_given?\nend", "def what_i_am(&block)\n\t\tblock.class\n\tend", "def block_checker\n block_given?\nend", "def perform(&block); end", "def parse_codeblock; end", "def block(_hash)\n raise Sibit::NotSupportedError, 'block() doesn\\'t work here'\n end", "def execute(block) # the syntax requires an & in the paramater name.\n \t block.call\n\tend", "def warden(&block); end", "def execute(&block)\r\n block\r\nend", "def callBlock\n yield\n yield\nend", "def i_take_a_block\n yield\nend", "def parse_block(*_arg0); end", "def if_block_given\n p \"hoge\"\n yield if block_given?\n p \"end\"\nend", "def begin() end", "def run_block\n yield\nend", "def private; end", "def sup_bro\n puts \"This is before a block!\"\n name = \"Katy\"\n yield(name)\n puts \"This is after a block!\"\nend", "def accept_nonblock\r\n end", "def explicit_block(&sloth)\n sloth.call # same as yield\nend", "def record_block\n @block = true\n end", "def block_method\nputs \"called outside block in block_method\"\n#add method, to check if there is a block on this method\nyield if block_given? #predicate method, it have question mark on end\nputs \"now we are returning again to block\"\nend", "def accept_nonblock(*) end", "def accept_nonblock(*) end", "def accept_nonblock(*) end", "def m12a(p1,p2,p3, &blk)\n\tyield(p1,p2) # два параметра передаем в блок\n\tputs \"The third parameter is #{p3}\" # один параметр испоьзуем прямо тут\nend", "def call_block\n @_block.call(self) if @_block\n end", "def post_init_block(&block)\n raise ArgumentError, \"does not accept a block\"\n end", "def block_checker(param) \n [ param , block_given? ]\nend", "def run_this_for_me\n\tyield\nend", "def return!(&block); end", "def optional\n puts 'A code block isn\\'t required, but it\\'s nice.'\n yield if block_given? #Kernel#block_given?\n puts 'I\\'m happy either way, really.'\nend", "def block_valid?(block)\n # ...\n end", "def run_block # this is a method that accepts a block and yields action to block once method is called (just like map or each)\n yield if block_given? # prevents error if no block is run with method invocation; only use this if you have a specific reason for it, otherwise, it's best to fail and fail early\nend", "def anonymous?; end", "def block\n options.fetch(:block)\n end", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def execute(&block)\n\tblock.call\nend", "def actual_flow_control\n super\n end", "def block_method_3\n yield\nend", "def block_method_3\n yield\nend" ]
[ "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.80390704", "0.768099", "0.7338067", "0.7338067", "0.72850883", "0.7229391", "0.7229391", "0.7229391", "0.7085792", "0.7056543", "0.7029989", "0.7029989", "0.6986464", "0.6986464", "0.69166327", "0.69164515", "0.6915606", "0.68934435", "0.6835991", "0.6803628", "0.6776746", "0.6715412", "0.6713424", "0.6698541", "0.6698541", "0.66651326", "0.66651326", "0.66174346", "0.6612839", "0.66098446", "0.66098446", "0.6609183", "0.6607888", "0.650325", "0.64694273", "0.64694273", "0.646692", "0.64124537", "0.6407544", "0.6386574", "0.6369296", "0.63440293", "0.63431853", "0.6299161", "0.6290362", "0.62839085", "0.6282481", "0.6278347", "0.62744385", "0.6265337", "0.6264225", "0.6263392", "0.6252061", "0.6246919", "0.62349856", "0.621864", "0.6216598", "0.6202197", "0.61806834", "0.61744237", "0.6166935", "0.61567056", "0.61567056", "0.61567056", "0.61471933", "0.6145409", "0.613371", "0.611941", "0.61132497", "0.6108002", "0.61067533", "0.60907376", "0.60905254", "0.6075646", "0.60745454", "0.60729474", "0.60729474", "0.60729474", "0.6072605", "0.60722625", "0.6070509", "0.6070509" ]
0.0
-1
Looks for a logged in user in the session and loads it. If no officer found, returns nil
def current_officer if (officer_id = session[:officer_id]) @current_officer ||= Officer.find(officer_id) elsif (officer_id = cookies.signed[:officer_id]) officer = Officer.find(officer_id) if officer && officer.authenticated?(cookies[:remember_token]) log_in officer @current_officer = officer end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user\n return nil if !session[:user]\n @user ||= fetch_user(session[:user])\n end", "def user_from_session\n if session[:user] && session[:user][:id]\n User.find_by_id(session[:user][:id])\n else\n nil\n end\n end", "def fetch_user\n @current_user = User.find_by(:id => session[:user_id]) if session[:user_id]\n\n session[:user_id] = nil unless @current_user.present?\n end", "def load_current_user\n the_id = session[:user_id]\n @current_user = User.where({ :id => the_id }).first\n end", "def load_current_user\n if session[:user_id]\n @current_user = User.find(session[:user_id])\n end\n end", "def find_user\n return nil if session[:user_id].nil?\n User.find(session[:user_id])\n end", "def find_user\n return nil if session[:user_id].nil?\n User.find(session[:user_id])\n end", "def load_current_user\n @current_user ||= session[:user_id] && User.find(session[:user_id])\n end", "def lookup_user\n reset_session #use this when they ask you to find a user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end", "def user_from_session\n if session[:current_user_id].present?\n @current_user ||= User.find(session[:current_user_id])\n elsif session[:current_auditor_id].present?\n @current_user ||= Auditor.find(session[:current_auditor_id])\n elsif session[:current_super_user_id].present?\n @current_user ||= SuperUser.find(session[:current_super_user_id])\n end\n end", "def find_user\n @user = User.find(session[:user_id])\n end", "def loaded_user\n user_type == 'MeetupUser' ? meetup_user : bridgetroll_user\n end", "def get_user\n\t\tif !session[:user_id]\n\t\t\t@user = nil\n\t\telse\n\t\t\t@user = User.find(session[:user_id])\n\t end\n\tend", "def find_current_user #for madlib/user connection - am i using this?\n @user_found = User.find_by(id: session[:user_id])\n end", "def load_user\n if session[:user_id]\n @current_user = User.where(id: session[:user_id]).first\n end\n\n if !@current_user\n @current_user = User.create\n session[:user_id] = @current_user.id\n end\n end", "def find_current_user\n if session[:current_user_id]\n @user = User.find_by(id: session[:current_user_id])\n else\n @user = nil\n end\n end", "def get_user_from_session\r\n return User.find(session[:user_id]) if session[:user_id]\r\nend", "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 lookup_user\n self.class.send(:session_model_for_this_controller).find_by_id(\n session[:session_id]\n ).try(:user)\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 find_current_user\n user_id = session[:user_id]\n if user_id\n user = Marty::User.active.find(user_id) rescue nil\n else\n user = try_to_autologin\n end\n\n user\n end", "def load\n @user ||= User.find(@id)\n end", "def getLoggedInUser\n if session[:user_id]\n return User.find(session[:user_id])\n else\n return nil\n end\n end", "def load_user\n @user ||= ((params[:id] && params[:id] != 'current' && User.find(params[:id])) || current_user)\n end", "def get_logged_user()\n begin\n #logger.warn \"session[:logged_user_id]=#{session[:logged_user_id].inspect}\"\n if session[:logged_user_id]\n @current_user ||= User.find(session[:logged_user_id])\n end\n rescue\n logger.warn \"Oups I'can't find user with id=#{session[:logged_user_id].inspect}\"\n nil\n end\n end", "def user_from_session\n Admin::User.find(session[:user_id]) if session[:user_id]\n end", "def get_user\n \n # Retrieve user id if stored in a cookies\n # @TODO Secure ID when stored in cookies\n if cookies[:user]\n return User.find(cookies[:user])\n\n # Retrieve user id if stored in session\n elsif session[:user]\n return User.find(session[:user])\n\n # No user logged in\n else\n return nil\n end\n\n end", "def actual_user\n User.find_by_id(session[:user_id])\n end", "def user\n return unless user_id && user_type\n return @user if instance_variable_defined?('@user')\n\n @user = user_type.constantize.find_by(id: user_id)\n end", "def current_user\n @current_user ||= ::User.send(\"find_by_#{self.identifier_attribute}!\", session[identifier_name])\n rescue ActiveRecord::RecordNotFound\n nil\n end", "def fetch_user\n\n # Check if user_id in the session is the id of a real user in our db. If it is, we will get the user object in @current_user; if not, we will get nil\n if session[:user_id].present?\n @current_user = User.find_by id: session[:user_id]\n end\n\n # If we did get nil from the above query, delete the session because the user_id is stale (invalid)\n if @current_user.nil?\n session[:user_id] = nil # unless @current_user.present?\n end\n\n end", "def authenticated_user\n if session[:user_id].nil?\n return nil\n else\n return User.find(session[:user_id])\n end\n end", "def get_user_from_session\n authorize()\n @user = @current_user\n end", "def get_user\n unless session[:drupal_user_id].nil?\n uid = session[:drupal_user_id]\n @user = User.find_by_uid(uid)\n end\n\n @user || nil\n end", "def find_user\n @user = current_user\n end", "def find_user\n @user = current_user\n end", "def find_user\n if session[:merchant_id]\n @login_user = User.find_by(id: session[:user_id])\n end\n end", "def current_user\n puts \"Finding user: \" + session[:user_id].to_s\n if session[:user_role] == 'Customer'\n @current_user ||= Customer.find_by(CustomerID: session[:user_id])\n else\n @current_user ||= Employee.find_by(EmployeeID: session[:user_id])\n end\n end", "def user_from_session\n case RAILS_ENV\n when 'production'\n @user = User.find( :first, :conditions => {\n :screen_name => session[:screen_name],\n :token => session[:access_token]\n })\n when 'development'\n logger.debug 'session = '+session.inspect\n @user = User.find( :first, :conditions => {\n :screen_name => DEBUG_SCREEN_NAME\n })\n #nil\n end\n end", "def identify_the_user\n \t@current_user = User.find_by_id(session[\"user_id\"])\n end", "def find_current_user\n if is_logged_in?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id] \n #return this user if session[:user_id] that is stored in our session hash if so then find the user in our database and display it, \n # the @current_user is handy if the user already exist and we do not want the user id keep heiting the database every time \n end", "def load_user_if_logged_in\n if user?\n @user = current_user\n else\n @user = nil\n end\n return true\nend", "def load_user\n if(user_signed_in?)\n @user = User.find(current_user.id)\n @config = @user.config\n @timer = @user.timer\n active_quest = @user.active_quest\n if(active_quest.nil?)\n @active_quest_model = nil\n @active_quest_name = ''\n @active_quest_url = '#'\n @active_quest_campaign_name = ''\n @active_quest__campaign_url = '#'\n else\n @active_quest_model = active_quest\n @active_quest_name = active_quest.name\n @active_quest_url = quest_path(active_quest)\n @active_quest_campaign_name = active_quest.campaign.name\n @active_quest_campaign_url = campaign_path(active_quest.campaign)\n end\n end\n end", "def _user\n @_user ||= Squeeze::User.kept.find_by(email: token[:email])\n end", "def user\n\t\t\treturn nil if ! logged_in?\n\n\t\t\tPicombo::Session.instance.get('user')\n\t\tend", "def _fetch_user(session, scope = :default) # :nodoc:\n key = session[\"warden.user.#{scope}.key\"]\n return nil unless key\n serialize_from_session.call(key)\n end", "def user\n @user ||= Innsights::Fetchers::User.new(@user_object) if @user_object\n end", "def get_user(uid)\n @inv = User.find_by_id(uid)\n end", "def set_user\n @user = User.find(session[:user_id])\n if current_user.is_seeker\n @jobseeker = Jobseeker.find_by(user_id: current_user.id)\n end\n if current_user.is_biz\n @bizowner = Bizowner.find_by(user_id: current_user.id)\n end\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 _user_urn\n user = OMF::Web::SessionStore[:urn, :user]\n unless user\n warn \"Can't find 'urn' for user '#{OMF::Web::SessionStore[:urn, :id]}'\"\n return nil\n end\n user\n end", "def session_user\n return @session_user if defined? @session_user\n if session.has_key? :user_id\n @session_user ||= User.find_by_id(session[:user_id])\n end\n end", "def find_user\n @current_user = User.find_by github_access_token: session[:github_access_token]\n end", "def find_responder\n @responder = User.find_by_id(params[:user_id])\n @responder ||= current_user\n @responder\n end", "def current_user\n if session[:user_id]\n return @user ||= User.find(session[:user_id]['$oid'])\n else\n return nil\n end\n end", "def current_user\n # find_by only executes when current user hasn't been assigned yet\n @current_user ||= 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 actual_user\n if @current_user.nil? || session[:cas_user] != @current_user.cas_directory_id\n update_current_user(User.eager_load(*eager_loads).find_by(cas_directory_id: session[:cas_user]))\n end\n @current_user\n end", "def current_user \n #if session's chef_id is set/defined, find chef based on its id and stores it in the @current_user instance var which is a memory var\n #the ||= when used,subsequent call to methof current_user wont hit the database for find again, it will just use the @current_user memory var\n #tis is good for efficiency \n @current_user ||= Chef.find(session[:chef_id]) if session[:chef_id]\n end", "def current_user\n if session[:user_id]\n user = User.find(session[:user_id])\n else\n nil\n end\n end", "def current_user\n load_session\n @current_user\n end", "def cookied_user\n cookies[:auth] and User.find_by_auth_token(cookies[:auth])\n end", "def get_logged_in_user\n if @logged_in\n if Student.exists?(session[:id])\n @logged_in_user = Student.find(session[:id])\n elsif Marker.exists?(session[:id])\n @logged_in_user = Marker.find(session[:id])\n end\n end\n end", "def user\n @user ||= User.find(user_id)\n end", "def current_user\n begin \n User.find(session[:user_id])\n rescue ActiveRecord::RecordNotFound\n nil\n end\n end", "def current_user\n if session[:user_id]\n return User.find(session[:user_id])\n end\nend", "def current_user\n\tif session[:user_id].present?\n\t\tUser.find(session[:user_id])\t\n\tend\nend", "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\t\tif session[:user_id].present?\n\t\t\tUser.find(session[:user_id])\n\t\tend\n\tend", "def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n @user = User.find(session[:user_id])\n end\n end", "def current_user\n\t\t# checks to see if session exists, if so, loads user\n\t\t# and saves into @user instance variable\n\t\t@current_user ||= User.find(session[:user_id]) if session[:user_id]\n\tend", "def current_user\n # if current_user is et use it otherwise ask the data store\n @current_user ||= User.find_by(id: session[:user_id])\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 find_current_user\n @currentUser = User.find_by_id(session[:user_id])\n end", "def find_current_user\n # adding if to prevent rails from checking user when logged out\n if is_logged_in?\n #save to a variable\n @current_user = User.find(session[:user_id]);\n else\n @current_user = nil\n end\n end", "def get_current_user\n unless session[:user_id].blank?\n @current_user = User.find(session[:user_id])\n else\n @current_user = nil\n end\n end", "def current_user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n #this way so if no session we don't .find nil\n end", "def load_user\n if (params[:id].blank?)\n @user = nil\n return @user\n end\n\n @user = User.where(:_id => params[:id]).first\n\n if (@user.blank?)\n # If not found, show an error and redirect\n flash[:error] = t(\"users.error.not_found\")\n redirect_to users_path()\n end\n\n return @user\n end", "def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end", "def current_user\n User.find_by(uid: session[:user]) if logged_in?\n end", "def current_user\n return unless session[:user_id]\n @current_user ||= Socio.find_by_id(session[:user_id])\n end", "def user\n return User.current unless user_id\n user = User.get_from_cache(user_id)\n user || User.first({:id => user_id})\n end", "def guest_user\n # Cache the value the first time it's gotten.\n @cached_guest_user ||= User.find(session[:guest_user_id] ||= create_guest_user.id)\n\n rescue Mongoid::Errors::DocumentNotFound # if session[:guest_user_id] invalid\n session[:guest_user_id] = nil\n guest_user\n end", "def load_user\n @user = User.find(params[:user_id])\n end", "def current_user\n @user ||= User.find_by_id(session[:user_id])if logged_in?\n end", "def user_session\n @user_session ||= UserSession.find\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 current_user\n if valid_session?\n User.find(session[:user_id])\n end\n end", "def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end", "def current_user # Check the current user\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n end", "def current_user\n if session[:user_id]\n puts \"session user_id #{session[:user_id]}\"\n User.find(session[:user_id])\n end\nend", "def request_user\n # request_valid? is called first which creates a @session instance\n # variable which acts like the global session object of a normal request.\n @request_user ||= User.find(@session[:user_id]) if request_valid?\n end", "def logged_in_user\n if session[:user]\n if session[:user].to_i < 1\n @logged_in_user = Person.new\n elsif !@logged_in_user || @logged_in_user.id != session[:user].to_i\n @logged_in_user = Person.find session[:user].to_i\n end\n end\n \n @logged_in_user\n end", "def get_current_user\n unless session[:user_id]\n @current_user = nil\n return\n end\n @current_user = User.first(:conditions => {:id => session[:user_id] })\n end", "def set_user\n @user = User.find(session[:id]) if @user.nil && session[:id]\n end" ]
[ "0.6956786", "0.6956786", "0.6956786", "0.686571", "0.67203736", "0.67181337", "0.6704728", "0.6673909", "0.6673909", "0.66702896", "0.664347", "0.663861", "0.66304016", "0.66133827", "0.661182", "0.65681595", "0.6561061", "0.6559997", "0.6506697", "0.6502818", "0.6502818", "0.64957315", "0.6470902", "0.64655995", "0.64597625", "0.64509857", "0.6447573", "0.6445394", "0.640977", "0.63657594", "0.6351659", "0.6288545", "0.6283947", "0.62652355", "0.62565", "0.62465805", "0.6238909", "0.62361956", "0.62361956", "0.6221973", "0.6218169", "0.620706", "0.620351", "0.6202255", "0.61992437", "0.6195973", "0.6187934", "0.61783326", "0.61712843", "0.6171203", "0.6166614", "0.61621577", "0.6139495", "0.61317253", "0.6129053", "0.6106072", "0.608627", "0.60843384", "0.6071698", "0.60653144", "0.6042521", "0.6037223", "0.6031908", "0.60251343", "0.6024894", "0.6021947", "0.6017615", "0.60144764", "0.600822", "0.60073054", "0.6001305", "0.60006183", "0.59978616", "0.5996017", "0.5996017", "0.5994745", "0.59877604", "0.5984769", "0.59845835", "0.59843606", "0.59823257", "0.59805256", "0.597522", "0.5970834", "0.59681565", "0.596723", "0.596421", "0.5961534", "0.5958097", "0.595778", "0.59572744", "0.595593", "0.5955276", "0.59533024", "0.5945604", "0.59436023", "0.59435356", "0.5943021", "0.59413177", "0.59368485" ]
0.7068578
0
Redirects to login if officer is not logged in. This serves as an access security
def login_required redirect_to new_session_path if current_officer.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_required\n redirect_to login_path unless logged_in?\n end", "def login_required\n if !logged_in?\n redirect \"/login?#{env[\"REQUEST_PATH\"]}\"\n end\n end", "def login_required\n redirect_to(login_url) unless logged_in? && authorized?\n end", "def login_required\n redirect_to login_path unless logged_in?\n end", "def login_required! \n if ! is_logged_in? \n redirect '/login' \n end \n end", "def authentication_required\n if !logged_in?\n redirect_to login_path\n end\n end", "def require_login\n redirect_to root_path unless logged_in?\n end", "def require_login\n redirect_to root_path unless logged_in?\n end", "def require_login\n if !current_user\n redirect_to \"/\"\n end\n end", "def redirect_if_not_logged_in\n redirect_to login_path unless logged_in?\n end", "def login_required\n \t\t redirect_to(root_url, notice: 'You have to be signed in to do that! Top right ~') unless current_user\n \tend", "def require_login\n unless logged_in?\n redirect url(:admin_login)\n throw :halt\n end\n end", "def enforce_login\n redirect_to welcome_path if @user.nil?\n end", "def logged_in_user\n unless logged_in?\n redirect_to login_url\n end\n end", "def auth\n #redirect to login page unless already logged in\n redirect_to new_user_session_path, alert: \"You must login to access that page\" unless logged_in?\n end", "def login\n redirect_to lato_core.root_path if core_controlSession\n end", "def require_login\n redirect R(:login) unless logged_in?\n end", "def login_required\n return true if session[:affiliate]\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n redirect_to :action =>\"login\" and return false \n end", "def redirect_if_not_logged_in\n #redirect the user if the user is not logged in\n end", "def check_login!\n u = check_and_get_user\n redirect to('/signin.html') unless u\n u\n end", "def login_checkpoint\n redirect to '/' if !logged_in?\n end", "def verify_logged_in\n redirect_to root_path unless logged_in?\n end", "def authenticate_user\n redirect_to \"/login\" unless logged_in?\n end", "def login_required\n unless session[:user_id].present?\n redirect_to login_user_index_path\n end\n end", "def require_login\n redirect_to login_path unless logged_in?\n end", "def req_login\n unless curr_user\n flash[:danger] = \"Login to view this content\"\n redirect_to login_url\n end\n end", "def require_login\n if current_user.nil? then\n redirect_to root_path\n end\n end", "def require_login\n redirect_to login_path if !user_logged?\n end", "def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end", "def check_for_login\n #if not, back home with you!\n redirect_to root_path unless @current_user.present?\n end", "def check_login\n redirect_to root_url, alert: \"You must login to view this page.\" if current_user.nil?\n end", "def require_login\n if !current_user\n flash[:error] = \"You must be logged in to access this section\"\n redirect_to main_app.root_path # halts request cycle\n end\n \n end", "def require_login\n unless @current_account\n redirect_to root_path\n end\n end", "def authenticate_user\n redirect_to login_path unless logged_in_user?\n end", "def login_required\n if logged_in?\n return true\n else\n redirect_to(:controller => '/user', :action => 'index')\n return false\n end\n end", "def require_login\n unless @current_user\n \tredirect_to root_url, :notice => \"You must be logged in to access this section\"\n end\n end", "def require_login\n unless logged_in?\n redirect_to login_path\n end\n end", "def authenticate_user\n \tif !logged_in?\n \tredirect_to login_url\n \tend\n end", "def logged_in\n unless customer_logged_in? || employee_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to customer_login_url\n end\n end", "def logged_in_user\n unless logged_in?\n redirect_to '/login'\n end\n end", "def protect\n unless logged_in?\n session[:return_to] = request.request_uri\n \n respond_to do |format|\n flash[:notice] = \"Please log in first\"\n format.html { redirect_to login_url }\n format.xml { render :xml => { :error => \"User must be logged in.\", :status => :unprocessable_entity } }\n end\n end\n end", "def user_login\n unless logged_in?\n navigated_location #stores the location that was navigated before login\n flash[:alert]= \"You Must Be Log In Order To Access that Portion of the Site\" \n redirect_to login_path\n end\n end", "def ensure_logged_in\n if (!logged_in?)\n redirect_to login_url\n end\n end", "def login_required\n access_denied unless session_login || cookie_login\n end", "def require_login\n redirect_to '/login' unless session[:name]\n end", "def require_authentication\n \tif current_user.nil? then\n \t\tredirect_to login_page_path\n \tend\n end", "def authorized\n redirect_to \"/login\" unless logged_in? \n end", "def login_required\n return true unless protect?(action_name)\n\n user = session_user\n return true if user && authorize?(user)\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end", "def redirect_if_no_login\n if !current_user\n flash[:notice] = \"You need to sign in before viewing this page.\"\n redirect_to root_path\n end\n end", "def login_required\n \n if not protect?(action_name)\n return true \n end\n\n if @session['user'] and authorize?(@session['user'])\n return true\n end\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n \n # call overwriteable reaction to unauthorized access\n access_denied\n return false \n end", "def auth_user\n if !current_user\n redirect_to root_url\n end\n end", "def auth_user\n if !current_user\n redirect_to root_url\n end\n end", "def auth_user\n if !current_user\n redirect_to root_url\n end\n end", "def requires_login\n unless user_logged_in?\n return redirect_to login_index_path, notice: \"You must login to view that page.\"\n end\n end", "def check_login\n unless logged_in?\n access_denied\n end\n end", "def require_login\n return head(:forbidden) unless current_user || current_employee\n end", "def require_login\n if !current_user\n flash[:error] = \"You must be logged in to access this section\"\n redirect_to main_app.root_path # halts request cycle\n end\n end", "def require_login\n if !current_user\n flash[:error] = \"You must be logged in to access this section\"\n redirect_to main_app.root_path # halts request cycle\n end\n end", "def logged_in_user\n unless current_user \n redirect_to root_path\n end\n end", "def require_logged_in\n redirect_to root_path unless logged_in?\n end", "def index\n redirect_to(:action => 'login') unless logged_in? \n end", "def require_login\n\t\tunless current_user\n\t\t\tredirect_to login_url\n\t\tend\n\tend", "def check_login\n head :forbidden unless self.current_user\n end", "def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end", "def autenticathe_login!\n unless someone_is_logged_in?\n store_location\n flash[:danger] = \"Por favor, Inicie sesion.\"\n redirect_to welcome_path\n end\n end", "def make_user_login\n #If you aren't logged in redirect to login page\n if !logged_in?\n redirect_to(:controller => 'sessions', :action => 'login')\n end\n end", "def require_login\n unless current_user\n redirect_to signin_path\n end\n end", "def authenticate\n redirect_to login_path if !logged_in\n end", "def login_required\n logged_in? ? true : access_denied\n end", "def login_required\n return true unless protect?(action_name)\n\n return true if user? && authorize?(session[:user])\n\n # store current location so that we can\n # come back after the user logged in\n store_location\n\n # call overwriteable reaction to unauthorized access\n access_denied\n false\n end", "def ensure_logged_in\n redirect_to api_session_url unless logged_in?\n end", "def require_login\n if logged_in? or authorized?\n # Let them pass\n else\n flash[:warning] = \"You must be logged in to view that page\"\n redirect_to login_path(:redirect => request.url)\n end\n end", "def login_required\n logged_in? || access_denied\n end", "def must_be_logged_in\n redirect_to root_path unless logged_in?\n end", "def must_login\n redirect_to login_path unless logged_in?\n end", "def require_login\n redirect_to root_path unless session.include?(:user_id)\n end", "def require_login\n redirect_to '/sessions/new' unless current_user\n end", "def require_login\n if session[:user_id].blank?\n redirect_to root_url, notice: \"Login is required to perform this action!\"\n end\n end", "def require_login\n if session[:user_id].blank?\n redirect_to root_url, notice: \"Login is required to perform this action!\"\n end\n end", "def login_required\n return true if logged_in?\n store_location\n access_denied and return false\n end", "def require_login\n redirect_to '/' if session[:user_id] == nil\n end", "def ensure_logged_in\n redirect_to new_session_url unless logged_in?\n end", "def authorise\n unless User.find_by_id(session[:user_id]) || (self.controller_name == 'users' && (self.action_name == 'new' || self.action_name == 'create'))\n session[:original_uri] = request.request_uri\n flash[:notice] = \"Please login!\"\n redirect_to login_url\n end\n end", "def require_authentication\r\n\r\n return true if session_user\r\n\r\n # per security audit, don't even show the login form if admin was requested...take 'em home\r\n if params[:controller] =~ /^admin/i\r\n logger.debug \"Admin request from unauthenticated session, sending to homepage.\" if logger.debug?\r\n redirect_to home_url\r\n else\r\n logger.debug \"Session not authenticated, sending to login screen.\" if logger.debug?\r\n # respond based on the type of request: normal, XHR, etc.\r\n if request.xhr?\r\n render :update do |page|\r\n page.redirect_to login_url(:protocol => 'https://')\r\n end\r\n else\r\n redirect_to login_url(:protocol => 'https://', :redirect_to => request.request_uri)\r\n end\r\n end\r\n\r\n # return false to prevent any other filters from executing\r\n false\r\n end", "def authorized\n redirect_to '/signin' unless current_driver\n end", "def user_authenticated\n redirect_to root_url, alert: 'You must be logged in to go here' unless current_user\n end", "def restrict_access\n unless logged_in?\n flash[:error] = \"You have to login to access this page.\"\n redirect_to login_url\n end\n end", "def login_advofinder_client_required\n login_required\n if logged_in? && current_user.person && !current_user.person.is_a?(client_class)\n redirect_to \"/\"\n end\n end", "def login_required\n logged_in? ? true : access_denied\n end", "def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end", "def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact [email protected].\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end", "def user_authorized\n redirect_to \"/\" unless session[:user_id]\n end", "def authenticate_user!\n redirect_to '/auth/sweetsuite' unless access_token && current_user\n end", "def login_required\n if session[:customer]\n return true\n end\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n \n redirect_to :action =>\"login\" and return false \n end", "def login_required\n call(Rs(:login)) unless logged_in?\n end", "def authenticate_user\n redirect_to root_path unless signed_in?\n end", "def login_required\n not_authorized unless current_user\n end", "def logged_in?\n redirect_to(root_path, notice: 'Unauthorized access!') unless current_user\n end", "def redirect_unless_logged_in\n unless current_member\n session[:redirect] = request.original_url\n flash.alert = \"You must be logged in to view page\"\n redirect_to root_path and return false\n end\n end", "def login_required\n # Skip this filter if the requested action is not protected\n return true unless protect?(action_name)\n\n # Check if user is logged in and authorized\n return true if logged_in? and authorized?(current_user)\n\n # Store current location so that we can redirect back after login\n store_location\n\n # Call access_denied for an appropriate redirect and stop the filter\n # chain here\n access_denied and return false\n end" ]
[ "0.7664395", "0.7662895", "0.7567415", "0.75009376", "0.7475761", "0.74498796", "0.7428888", "0.7428888", "0.74228156", "0.74139184", "0.7412023", "0.73886734", "0.73806614", "0.7353687", "0.7340208", "0.7339743", "0.73382807", "0.7325659", "0.7319789", "0.731788", "0.7305822", "0.72981787", "0.72901374", "0.7287386", "0.7283419", "0.72827107", "0.72735995", "0.7272233", "0.7265421", "0.7264224", "0.7260889", "0.7255796", "0.7252606", "0.72518486", "0.72478735", "0.72468376", "0.7239666", "0.723059", "0.7230017", "0.7226916", "0.72232574", "0.722055", "0.7205025", "0.71948326", "0.7191464", "0.7179698", "0.7174863", "0.71649253", "0.71613723", "0.7150397", "0.7148711", "0.7148711", "0.7148711", "0.7147008", "0.7142076", "0.71385", "0.7138427", "0.7138427", "0.7138364", "0.7137306", "0.7134311", "0.71327865", "0.71271724", "0.7126374", "0.71244943", "0.71239686", "0.7123093", "0.7110403", "0.71100074", "0.71087056", "0.7106442", "0.7104808", "0.7102188", "0.7091081", "0.7088523", "0.7087022", "0.7077204", "0.70761263", "0.70761263", "0.7073142", "0.7072971", "0.7070985", "0.70624", "0.7057324", "0.7055274", "0.7049731", "0.7049076", "0.7047451", "0.70443165", "0.70419455", "0.70404124", "0.70394456", "0.7036645", "0.70359147", "0.70274913", "0.7026294", "0.70253944", "0.7022913", "0.70220375", "0.7018913" ]
0.8211434
0
Sets default language if no language is transmitted in params
def set_locale I18n.locale = params[:locale] || I18n.default_locale end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_language\n params[:lang] ||= 'en'\n Localization.use params[:lang]\n end", "def set_language\n I18n.locale = params[:locale] || I18n.default_locale\n @lang = Wzs::Multilang::get_language(I18n.locale)\n end", "def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end", "def set_default_language\n I18n.locale = :ja\n end", "def set_defaults\n \tdefault_language = lexeme.try(:language) || Language.new\n \n \tself.language ||= default_language\n\tend", "def set_language\n self.language = I18n.locale.to_s unless self.language.present?\n end", "def set_language\n\n if current_user.nil? || params[:controller] =~ /rails_admin/i\n I18n.locale = params[:language] || I18n.default_locale\n else\n I18n.locale = params[:language] || current_user.language.try(:iso_code) || I18n.default_locale\n end\n end", "def set_language!(lang = 'en')\n @options[:lang] = lang\n end", "def set_locale\n available = %w{en de}\n I18n.locale = params[:locale] || request.compatible_language_from(available)\n end", "def default_language=(language)\n raise ArgumentError unless [:en, :pt].include?(language.to_sym)\n @default_language = language.to_sym\n end", "def change_lang\n eng = :en\n jap = :ja\n if I18n.locale == eng\n params[:locale] = :ja\n I18n.locale = :ja\n elsif I18n.locale == jap\n params[:locale] = :en\n I18n.locale = :en\n end\n end", "def set_locale\n \n #raise \"params[:locale] = #{params[:locale].present?}\"\n #raise \"params[:locale] = #{params[:locale].blank?}\"\n # Se non ho assegnato il parametro :locale allora gli passo la lingua impostata sul browser \n # (per testare usa Google chrome Extension: Locale Switcher)\n params[:locale] = request.env.fetch('HTTP_ACCEPT_LANGUAGE', '').scan(/[a-z]{2}/).first if params[:locale].blank?\n #raise \"params[:locale] = #{params[:locale]}\"\n\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end", "def set_language\n @lecture.update(locale: I18n.default_locale.to_s)\n end", "def set_language\r\n session[:language] = 'english'\r\n end", "def set_language_from\n session[:lang_from] = params[:lang].to_sym\n I18n.locale = session[:lang_from]\n render nothing: true\n end", "def default_language\n @default_language || :en\n end", "def set_locale\n I18n.locale = extract_locale_from_accept_language_header || I18n.default_locale\n # I18n.locale = params[:locale] if params[:locale].present?\n end", "def set_locale\n # Either through a param, that has highest priority\n locale = if params[:locale]\n params[:locale].to_s\n # Then let's check the browser if there was no param\n elsif accept_language = request.env['HTTP_ACCEPT_LANGUAGE']\n # TODO: Facebook would like to have the country when using authentication there. We should save the browser country somewhere.\n accept_language.scan(/^[a-z]{2}/).first.to_s\n end\n I18n.locale = locale if locale.present? and I18n.available_locales.include?(locale.to_sym)\n end", "def set_language\n language = params[:language].to_s\n unless language.blank?\n session[:language] = nil # Don't want to \"remember\" this anymore, since they've manually changed it.\n alter_current_user do |user|\n I18n.locale = language\n user.language = Language.from_iso(language)\n end\n end\n return_to = (params[:return_to].blank? ? root_url : params[:return_to])\n redirect_to return_to\n end", "def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end", "def set_locale\n \tI18n.locale = params[:locale] if params[:locale].present? \n end", "def set_language\r\n @language = Language.find(params[:id]) rescue Language.find(params[:language_id])\r\n end", "def set_locale\n I18n.locale = params[:locale] unless params[:locale].blank?\n end", "def set_lang(lang)\n\t\t\tlang = 'en' unless languages.include? lang\n\t\t\t@lang = lang.to_sym\n\t\tend", "def set_locale\n I18n.locale = params[:locale] if params[:locale].present?\n # \"en\"\n # params[:locale] if params[:locale].present?\n # current_user.locale\n # request.subdomain\n # request.env[\"HTTP_ACCEPT_LANGUAGE\"]\n # request.remote_ip\n end", "def default_locale=(locale); end", "def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end", "def initialize(params)\n if lang = params[:language]\n @lang = lang\n end\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.default_locale = :pt_BR\n I18n.locale = params[:locale] unless params[:locale].blank?\n I18n.locale = I18n.default_locale if params[:locale].blank?\n end", "def set_translation\n if params[:locale].blank? && session[:current_locale].present?\n ::I18n.locale = session[:current_locale]\n elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym)\n session[:current_locale] = ::I18n.locale = params[:locale]\n elsif current_alchemy_user && current_alchemy_user.respond_to?(:language) && current_alchemy_user.language.present?\n ::I18n.locale = current_alchemy_user.language\n else\n ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) || ::I18n.default_locale\n end\n end", "def set_language\n params[:language] = 'ruby' if params[:language].blank?\n params[:scope] = 'categories' if params[:scope].blank?\n params[:scope] = '' if params[:scope] == 'categories'\n params[:scope] = 'repos' if request.path.start_with?('/repos')\n end", "def default_language?\n return true unless params[:locale]\n\n params[:locale].to_s == I18n.default_locale.to_s\n end", "def set_website_locale\n app_locales = %w(es ca)\n I18n.locale = params[:lang] if app_locales.include?(params[:lang])\n end", "def set_locale\n \tI18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end", "def set_locale\n I18n.locale = get_locale_from_params || I18n.default_locale\n end", "def set_locale\n accept_language = request.headers['Accept-Language']\n return if accept_language.blank?\n\n available = %w{en ja}\n accept_language.split(',').each do |locale_set|\n locale = locale_set.split(';').first\n if available.include?(locale)\n I18n.locale = locale\n break\n end\n end\n end", "def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end", "def set_locale \n locale = params[:locale]\n locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']\n I18n.locale = (locale && I18n.available_locales.include?(locale.to_sym)) ? locale : I18n.default_locale\n end", "def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = 'en'\n\n # if params[:locale].present? || session[:locale].present?\n # session[:locale] = params[:locale] if params[:locale].present?\n # I18n.locale = session[:locale]\n # else\n # logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n # I18n.locale = extract_locale_from_accept_language_header\n # logger.debug \"* Locale set to '#{I18n.locale}'\"\n # end\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_language\n return if request.fullpath.match(/^\\/(\\S+)preview/)\n unless current_user.nil?\n I18n.locale = current_user.language\n end\n I18n.locale = session[:lang] if session[:lang]\n end", "def set_locale\n I18n.locale = cookies[:locale] || params[:locale] || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale\n end", "def locale\n lang = params.fetch(:language, I18n.default_locale).to_sym\n I18n.available_locales.include?(lang) ? lang : I18n.default_locale\n end", "def set_locale\n available = TRANSLATIONS.map(&:code)\n if cookies[:locale] && available.include?(cookies[:locale])\n selected = cookies[:locale]\n end\n I18n.locale = selected ||\n http_accept_language.preferred_language_from(available) ||\n I18n.default_locale\n end", "def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n # TODO: Let user decide which language - to high prio in keytech environment\n I18n.locale = 'de' # current_user.language_id\n end\n end", "def set_locale\n #logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n #logger.debug request.env['HTTP_ACCEPT_LANGUAGE']\n\n if session[:default_locale] != nil\n I18n.locale = (session[:default_locale]).to_sym\n mapping_locale_to_area\n return\n end\n\n logger.debug \"'#{I18n.locale}'\"\n\n I18n.locale = extract_locale_from_accept_language_header\n\n logger.debug \"'#{I18n.locale}'\"\n\n if I18n.locale == :\"zh\"\n \n logger.debug env['HTTP_ACCEPT_LANGUAGE'][3]\n # Ealin: 84 == 'T' (特別處理: zh_TW)\n if env['HTTP_ACCEPT_LANGUAGE'][3] == 84 || env['HTTP_ACCEPT_LANGUAGE'][3] == 116 || \\\n env['HTTP_ACCEPT_LANGUAGE'][3] == 'T' || env['HTTP_ACCEPT_LANGUAGE'][3] == 't'\n\n #\n # Ealin: 避免繁體與簡體可能混淆, 將繁體的locale name設為zh_tw\n #\n I18n.locale = :zh_tw\n end\n end\n\n # save mapped area to session[:default_area]\n mapping_locale_to_area\n \n #logger.debug I18n.locale.length\n #logger.debug \"* Locale set to '#{I18n.locale}'\"\n end", "def set_language_to\n session[:lang_to] = params[:lang].to_sym\n \n respond_to do |format|\n format.html { redirect_to root_url } \n format.js { render nothing: true }\n end\n end", "def set_locale\n # force by params\n if params[:locale] && WEB_LOCALES_SUPPORT.include?(params[:locale])\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n cookies[:locale] = params[:locale]\n elsif session[:locale] && WEB_LOCALES_SUPPORT.include?(session[:locale])\n # get from session\n I18n.locale = session[:locale]\n elsif cookies[:locale] && WEB_LOCALES_SUPPORT.include?(cookies[:locale])\n # get from session\n I18n.locale = cookies[:locale]\n else\n I18n.locale = DEFAULT_WEB_LOCALE\n end\n\n @current_locale = I18n.locale\n @current_locale_string = t('locale.' + I18n.locale.to_s, default: 'Not define language')\n end", "def set_locale\n logger.debug \"* Accept-Language: #{request.env['HTTP_ACCEPT_LANGUAGE']}\"\n I18n.locale = params[:locale] || locale_from_header || I18n.default_locale\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n end", "def set_Language(value)\n set_input(\"Language\", value)\n end", "def set_Language(value)\n set_input(\"Language\", value)\n end", "def set_Language(value)\n set_input(\"Language\", value)\n end", "def set_language\n @language = Language.find(params[:id])\n end", "def set_language\n @language = Language.find(params[:id])\n end", "def set_Language(value)\n set_input(\"Language\", value)\n end", "def set_Language(value)\n set_input(\"Language\", value)\n end", "def set_locale\n I18n.locale = params[:locale] \n end", "def set_locale\n if params[:locale].nil?\n I18n.locale = session[:locale].nil? ? :ar : session[:locale]\n else\n I18n.locale = params[:locale]\n session[:locale] = params[:locale]\n end\n end", "def select_language\n I18n.backend.send(:init_translations) unless I18n.backend.initialized?\n lang = PatientHelper.languages(primary_language)&.dig(:code)&.to_sym || :en\n lang = :en unless %i[en es es-PR so fr].include?(lang)\n lang\n end", "def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end", "def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end", "def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def language=(v)\n @language = v.is_a?(String) ? [v] : v \n end", "def set_locale(host, params, default_locale = I18n.default_locale)\r\n case I18n.config.language_detection_method\r\n when I18n::Config::DETECT_LANGUAGE_FROM_URL_PARAM\r\n lang = params[I18n.config.language_url_param.to_sym]\r\n when I18n::Config::DETECT_LANGUAGE_FROM_SUBDOMAIN\r\n @@hosts ||= Hash.new\r\n if @@hosts.has_key?(host)\r\n return @@hosts[host]\r\n end\r\n lang = get_locale(host)\r\n end\r\n if lang.present? && locale_enabled?(lang)\r\n I18n.locale = lang\r\n return true\r\n end\r\n I18n.locale = I18n.default_locale\r\n return (lang.present? && I18n.locale_available?(lang)) ? false : nil\r\n end", "def set_user_language\n cookies[:language] ||= '0'\n I18n.locale = LOCALES_AVAILABLE[cookies[:language].to_i]\n end", "def set_current_language(lang)\n GetText.locale, prev_value = sanitize_lang(lang), GetText.locale\n prev_value\n end", "def language=(value)\n @language = value\n end", "def set_lang\n return true unless lang = params[:lang]\n cookies[:lang] = {:value => lang, :expires => Time.now+1.day, :path => '/'}\n end", "def set_user_language\n I18n.locale = 'es-VE'\n end", "def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end", "def set_locale\n if current_user.blank?\n I18n.locale = valid_language\n logger.debug \"* Locale set to '#{I18n.locale}'\"\n else\n I18n.locale = current_user.language_id\n end\n end", "def language_params\n params.permit(:language)\n end", "def set_locale\n @current_user = User.find_user(session)\n puts \"set_locale:params[:locale]=#{params[:locale]}\"\n if params[:locale]\n I18n.locale = params[:locale]\n session[:lng] = I18n.locale\n else\n unless @current_user.nil?\n puts \"set_locale:@current_user=#{@current_user} lng=#{@current_user.language}\"\n I18n.locale = @current_user.language\n else\n if session[:lng]\n I18n.locale = session[:lng]\n else\n I18n.locale = PlmServices.get_property(:LOCAL_DEFAULT)\n session[:lng] = I18n.locale\n end\n end\n end\n puts \"fin de set_locale\"\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n #Rails.application.routes.default_url_options[:locale]= I18n.locale \n end", "def set_language\n @language = current_user.languages.find(params[:language_id])\n end", "def language=(value)\n if value == @defaults['ai.device.language']\n @values.delete 'ai.device.language' if @values.key? 'ai.device.language'\n else\n @values['ai.device.language'] = value\n end\n end", "def set_locale\n I18n.select_locale( params[:locale], session[:locale], I18n.from_http_header(request) )\n logger.info \"Using language: #{I18n.locale}\"\n session[:locale] = I18n.locale\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def specifyLanguage\n l = Language.all\n l_list = []\n l.each do |language|\n l_list << language.abbreviation\n end\n if (user_signed_in?)\n @languageSelected = current_user.language\n elsif (cookies.has_key?(:language) && l_list.include?(cookies[:language]))\n @languageSelected = cookies[:language]\n else\n @languageSelected = \"EN\"\n cookies[:language] = \"EN\"\n end\n end" ]
[ "0.87640315", "0.8170733", "0.78735316", "0.76710534", "0.7607171", "0.75601506", "0.7544727", "0.7510447", "0.7499547", "0.7463825", "0.74463946", "0.74122393", "0.73782843", "0.7375852", "0.73630977", "0.7358266", "0.7337584", "0.72784275", "0.7273415", "0.72496027", "0.7220066", "0.7205322", "0.71856266", "0.7182568", "0.7175178", "0.71702754", "0.71430427", "0.7113242", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.7092498", "0.70852", "0.70726943", "0.7069836", "0.70687526", "0.7067849", "0.7060602", "0.7056825", "0.7056825", "0.70479834", "0.70459074", "0.70357233", "0.7034303", "0.70284224", "0.70284224", "0.70284224", "0.70284224", "0.70093316", "0.70081204", "0.6992694", "0.6988429", "0.6976085", "0.6974219", "0.6958417", "0.69570374", "0.6920699", "0.6917857", "0.69171447", "0.69171447", "0.6916079", "0.6916079", "0.69152695", "0.69152695", "0.69146067", "0.691314", "0.69120204", "0.69040805", "0.69010955", "0.68866813", "0.68703794", "0.68703794", "0.6867032", "0.68642676", "0.685608", "0.68527395", "0.6849717", "0.6847157", "0.6844556", "0.68292767", "0.68223655", "0.68213636", "0.68175936", "0.68160826", "0.68156254", "0.6814095", "0.68108535", "0.68056655", "0.6800278" ]
0.70497996
51
Adds the locale for I18n to every link inside the app
def default_url_options { locale: I18n.locale } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link_with_locale(url)\n params.to_unsafe_h.include?('locale') ? \"#{url}?locale=#{I18n.locale}\" : url\n end", "def lang_switcher\n I18n.available_locales.each do |loc|\n locale_param = request.path == root_path ? root_path(locale: loc) : params.merge(locale: loc)\n if I18n.locale != loc\n concat content_tag(:li, (link_to I18n.t(\"l#{loc}\"), locale_param), class: nil)\n end\n end\n end", "def switch_locale_link(locale)\n link_to locale, url_for(locale: I18n.default_locale != locale.to_sym ? locale.to_sym : nil)\n end", "def locale_switch_link(language)\n path = request.original_fullpath\n if params.to_unsafe_h.include? 'locale'\n path.gsub(%r{locale=#{I18n.locale}}, \"locale=#{language}\")\n elsif request.query_parameters.empty?\n path + \"?locale=#{language}\"\n else\n path + \"&locale=#{language}\"\n end\n end", "def english_locale_link(locale)\n if locale === :en\n \"English\"\n else\n link_to(\"English\", \"/en\")\n end\n end", "def translatable_items_links\n AvailableLocale.translatables.map do |t|\n translatable_links(t)\n end.join.html_safe\n end", "def use_i18n; end", "def generate_language_switcher_link(locale)\n\t\tvis = nil\n\t\torg = nil\n\n\t\tif @organization\n\t\t\torg = OrganizationTranslation.where(:locale => locale, :organization_id => @organization.id)\n\t\tend\n\n\t\tif @visualization\n\t\t\tvis = VisualizationTranslation.where(:locale => locale, :visualization_id => @visualization.id)\n\t\tend\n\n category = nil\n if params[:category]\n category = params[:category]\n index = @categories.index{|x| x.permalink == params[:category]}\n if index\n category = CategoryTranslation.where(:locale => locale, :category_id => @categories[index].id)\n if !category.blank?\n category = category.first.permalink\n end\n end\n end\n\n\t\tclas = 'language-switcher-item-link'\n clas += locale == I18n.locale ? ' is-active' : ''\n\n\t\tif !vis.blank? && !org.blank?\n\t\t\tlink_to t(\"app.language_abbreviation.#{locale}\"), params.merge(:locale => locale,\n\t\t\t\t:organization_id => org.first.permalink,\n\t\t\t\t:id => vis.first.permalink,\n :category => category\n\t\t\t), title: t(\"app.language.#{locale}\"), class: clas\n\t\telsif !vis.blank?\n\t\t\tlink_to t(\"app.language_abbreviation.#{locale}\"), params.merge(:locale => locale,\n\t\t\t\t:id => vis.first.permalink,\n :category => category), title: t(\"app.language.#{locale}\"), class: clas\n\t\telsif !org.blank?\n\t\t\tlink_to t(\"app.language_abbreviation.#{locale}\"), params.merge(:locale => locale,\n\t\t\t\t:id => org.first.permalink,\n :category => category), title: t(\"app.language.#{locale}\"), class: clas\n\t\telse\n\t\t\tlink_to t(\"app.language_abbreviation.#{locale}\"), params.merge(:locale => locale,\n :category => category), title: t(\"app.language.#{locale}\"), class: clas\n\t\tend\n\tend", "def set_website_locale\n app_locales = %w(es ca)\n I18n.locale = params[:lang] if app_locales.include?(params[:lang])\n end", "def generate_language_switcher_link(locale)\n cat_permalink = nil\n tag_permalink = nil\n \n if params[:category].present?\n cat_permalink = Category.get_differnt_locale_permalink(Category::TYPES[:category], locale, params[:category])\n end\n \n if params[:tag].present?\n tag_permalink = Category.get_differnt_locale_permalink(Category::TYPES[:tag], locale, params[:tag])\n end\n \n if cat_permalink && tag_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => cat_permalink, :tag => tag_permalink)\n elsif cat_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => cat_permalink, :tag => nil)\n elsif tag_permalink\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => nil, :tag => tag_permalink)\n else\n\t\t\tlink_to t(\"app.language.#{locale}\"), params.merge(:locale => locale,\n :category => nil, :tag => nil)\n end\n \n end", "def current_locale_links\n if @available_locale\n link = link_to(@available_locale.name, [:cms, @available_locale])\n if current_page?(cms_available_locale_path(@available_locale))\n content_tag(:li, link, class: 'current hide-for-small')\n else\n content_tag(:li, link) + translatable_items_links + other_items_links\n end\n end\n end", "def set_locale\n I18n.locale = set_locale_from_params || I18n.default_locale\n Rails.application.routes.default_url_options[:locale]= I18n.locale\n end", "def i18n\n %w(en es).each do |locale|\n copy_file \"i18n.#{ locale }.yml\", \"config/locales/seo_landing_pages.#{ locale }.yml\"\n end\n end", "def apply_locale; end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n Rails.application.routes.default_url_options[:locale]= I18n.locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n #Rails.application.routes.default_url_options[:locale]= I18n.locale \n end", "def change_locale_url(locale)\n current_path = \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n if current_path.include?('lang_to=')\n current_path.gsub(\"lang_to=#{session[:lang_to]}\", \"lang_to=#{locale.to_s}\")\n elsif current_path.include?('?')\n \"#{current_path}&lang_to=#{locale.to_s}\"\n else\n \"#{current_path}?lang_to=#{locale.to_s}\"\n end\n \n end", "def set_locale\n DmCore::Language.locale = (params[:locale].presence || current_account.preferred_default_locale)\n rescue I18n::InvalidLocale\n # if it's an invalid locale, append the default locale and try again\n # this also fixes the case of using simple link names on a home page.\n # So if home page is \"http://example.com\" and the link is <a href=\"calendar\">\n # then the link is \"http://example.com/calendar\", instead of \"http://example.com/en/calendar\"\n # This will allow that to work.\n redirect_to \"/#{current_account.preferred_default_locale}#{request.path}\"\n end", "def set_locale\n end", "def generate_language_switcher_link(locale)\n distrct = nil\n place = nil\n year = nil\n event = nil\n\n if params[:district].present? && @districts.present?\n index = @districts.map{|x| x.permalink}.index(params[:district])\n if index\n x = CategoryTranslation.where(:locale => locale, :category_id => @districts[index].id)\n if x.present?\n district = x.first.permalink\n end\n end\n end\n\n if params[:place].present? && @places.present?\n index = @places.map{|x| x.permalink}.index(params[:place])\n if index\n x = CategoryTranslation.where(:locale => locale, :category_id => @places[index].id)\n if x.present?\n place = x.first.permalink\n end\n end\n end\n\n if params[:year].present? && params[:year] != I18n.t('filters.time.unknown', :locale => :en) && @years.present?\n index = @years.map{|x| x.permalink}.index(params[:year])\n if index\n x = YearRangeTranslation.where(:locale => locale, :year_range_id => @years[index].id)\n if x.present?\n year = x.first.permalink\n end\n end\n end\n\n if params[:event].present? && @events.present?\n index = @events.map{|x| x.permalink}.index(params[:event])\n if index\n x = CategoryTranslation.where(:locale => locale, :category_id => @events[index].id)\n if x.present?\n event = x.first.permalink\n end\n end\n end\n\n\n\t link_to t(\"app.language.#{locale}\"), params.merge(:locale => locale, :event => event, :year => year, :district => district, :place => place)\n\n\tend", "def set_locale\n I18n.locale = extract_locale_from_tld\n end", "def add_current_locale\n locale = ::Mongoid::Fields::I18n.locale.to_s\n self.locales << locale unless self.locales.include?(locale)\n end", "def set_locale_metatags! tags, record\n tags['og:locale:alternate'] = []\n tags['hreflang'] = []\n\n fields = %i[locale]\n fields << :state if record.respond_to? :state\n fields << :published if record.respond_to? :published\n fields << :published_at if record.respond_to? :published_at\n translations = record.translations.unscope(where: :locale).select(*fields)\n\n translations.each do |translation|\n next if translation.respond_to?(:state) && translation.state != record.class.states[:published]\n next if translation.respond_to?(:published) && !translation.published\n next if translation.respond_to?(:published_at) && !translation.published_at.nil? && translation.published_at > DateTime.now\n\n tags['og:locale:alternate'] << translation.locale\n tags['hreflang'] << [translation.locale, wm_url_for(record, locale: translation.locale)]\n end\n end", "def set_locale\n # This requires a user model to work. I'm assuming there will be a \"current_user\" helper.\n # If we decide to use Devise, that will be default.\n # I18n.locale = current_user.language || I18n.default_locale\n end", "def locales_menu\n returning html = \"\" do\n html << content_tag(:ul) do\n locales.map do |locale|\n title = locale == I18n.locale ? \"* #{h(locale)}\" : h(locale)\n content_tag(:li) do\n link_to title, change_locale_path(locale), :title => title, :method => :put\n end\n end * \" | \"\n end\n end\n end", "def lang\n # get current page url hash\n back_hash = Rails.application.routes.recognize_path request.referer\n Rails.logger.debug(\"original back_hash: #{back_hash.inspect}\")\n # change the locale code in the current page url hash\n back_hash[:locale] = @locale_code\n Rails.logger.debug(\"redirect to: #{back_hash.inspect}\")\n # see current page in new locale!\n redirect_to back_hash\n end", "def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n end", "def set_locale\n if params[:controller] == \"rails_admin/main\"\n I18n.locale = :en\n else\n I18n.locale = :ru\n end\n end", "def set_locale\n I18n.locale = Rails.configuration.oyambre.languages.first\n end", "def language_switch\n content_tag(:ul, id: 'switch') do\n I18n.available_locales.each do |loc|\n locale_param = request.path == root_path ? root_path(locale: loc) : params.merge(locale: loc).permit!\n concat content_tag(:li, (link_to I18n.t(:language, locale: loc), locale_param), class: (I18n.locale == loc ? \"active\" : \"\"))\n end\n end\n end", "def use_i18n=(value); end", "def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def init_i18n\n I18n.backend.class.send(:include, I18n::Backend::Pluralization)\n I18n.load_path.unshift(*locale_files)\n\n I18n.reload!\n end", "def set_locale\n return unless Language.current\n\n ::I18n.locale = Language.current&.locale\n end", "def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end", "def set_locale\n I18n.locale = params[:locale] \n end", "def set_locale\n new_locale = find_matching_locale(extract_locale_from_subdomain || extract_locale_from_url)\n unless new_locale.nil?\n I18n.locale = new_locale\n else\n I18n.locale = I18n.default_locale\n end\n end", "def translatable_links(t)\n link = link_to(t.titleize.pluralize, [:cms, @available_locale, t.constantize])\n\n var_name = t.underscore.parameterize # (ie, \"brand\" or \"product\")\n if item = instance_variable_get(\"@#{var_name.singularize}\")\n content_tag(:li, link) + item_link(item)\n elsif instance_variable_get(\"@#{var_name.pluralize}\")\n content_tag(:li, link, class: 'current hide-for-small')\n end\n end", "def set_locale\n #I18n.locale = params[:lang] ? params[:lang] : I18n.default_locale\n end", "def set_locale\r\n I18n.locale = extract_locale_from_request\r\n end", "def default_url_options\n { locale: I18n.locale }\n\nend", "def default_url_options\n { locale: I18n.locale }\n end", "def set_locale\n locale = request.subdomains.first\n locale = (logged_in? ?\n current_user.profile.language :\n browser_language) if locale.blank? || !I18n.available_locales.include?(locale.to_sym)\n I18n.locale = locale\n end", "def link_to_unless_current_locale *opts, &block\n locale = opts.shift.to_s\n if locale == ::I18n.locale.to_s\n opts.first\n else\n link_to *opts, &block\n end\n end", "def i18n_set_locale(locale, &blk)\n locale = ::R18n::I18n.default.to_s if locale.nil?\n \n i18n = ::R18n::I18n.new(\n locale, \n ::R18n.default_places, \n off_filters: :untranslated, \n on_filters: :untranslated_html\n )\n ::R18n.set(i18n)\n yield if block_given?\n # return # NB!! needed to enable routes below to work\n end", "def set_locale\n I18n.locale = params[:locale]\n end", "def locale\n @locales = Ramaze::Tool::Localize.languages.map{ |lang|\n [\n Ramaze::Tool::Localize.localize('locale_menu_descrition', lang),\n Ramaze::Tool::Localize.localize('locale_name', lang),\n lang\n ]\n }\n end", "def set_locale\n I18n.locale = \"fr\"\n end", "def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end", "def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end", "def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end", "def set_locale\n I18n.locale = access_control.user.locale\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def set_locale\n case params[:locale]\n when \"it\", \"en\"\n I18n.locale = params[:locale]\n else\n I18n.locale = I18n.default_locale\n end\n end", "def canonical\n Globalize.with_locale(::Refinery::I18n.default_frontend_locale) { url }\n end", "def default_url_options\n {locale: I18n.locale}\n end", "def default_url_options\n {locale: I18n.locale}\n end", "def set_locale_meta_tags\n set_meta_tags(og: {locale: t('locale.short-code', default: 'en_US')} )\n # @todo When we support multiple locales, pull them in below\n #alternate: { \"fr\" => \"http://yoursite.fr/alternate/url\",\n # \"de\" => \"http://yoursite.de/alternate/url\" }\n end", "def track_locales\n I18n.track_locales = true if can_read?('Locale Admin')\n end", "def set_permalink\n translations.each(&:set_permalink)\n end", "def set_locale\n I18n.locale = I18n.default_locale\n end", "def set_locale\n # if params[:locale] is nil then I18n.default_locale will be used\n I18n.locale = params[:locale]\n end", "def set_locale\n I18n.locale = :fi\n end", "def default_url_options\n {:locale => I18n.locale}\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options\n { locale: I18n.locale }\n end", "def default_url_options # donne les parametres par defaut a passer dans l'url\n { locale: I18n.locale } # permet de maintenir la locale courante (laisser le site en francais s'il a utilise le bouton de langue)\n end", "def set_application(app)\n self.application = app\n translations.values.each do |locale_translations|\n locale_translations.each do |translation|\n translation.translation_key = self\n translation.language = self.application.language(translation.locale)\n end\n end\n self\n end", "def link_to_switch_locale( locale, trigger=false )\n uparams = params.dup\n uparams[:locale] = locale\n options = {:title => locale}\n options = options.merge({:class => \"dropdown-toggle locale-switcher\", :\"data-toggle\" => \"dropdown\", :\"data-target\" => \"#\" }) if trigger\n link_to \"#{image_tag(\"flags/#{locale}.png\")}#{trigger ? '<b class=\\'caret\\'></b>' : ''}\".html_safe, refinery.url_for(uparams.merge(:only_path => true )), options\n end", "def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end", "def set_locale\n default_locale = 'en-US'\n Locale.set default_locale\n\n # fix the hostname to represent the reality \n # todo - move it so its only done once somehow\n APP_CONFIG[:hostname] = user_domain\n end", "def japanese_locale_link(locale)\n if locale === :ja\n \"日本語\"\n else\n link_to(\"日本語\", \"/ja\")\n end\n end", "def translate_route(app, conditions, requirements, defaults, as, anchor, route_set)\n locales = defaults.delete(:localize) || defaults.delete(:localize_subdomain)\n if locales.present?\n\n # Makes sure the routes aren't created before i18n can read translations\n # This happens when gems like activeadmin call `Rails.application.reload_routes!`\n return unless I18n.load_path.grep(/routes.yml$/).any?\n\n locales.each do |locale|\n route = Route.new(app, conditions, requirements, defaults,\n as, anchor, route_set, locale)\n yield *route.to_add_route_arguments\n end\n\n define_locale_helpers(as, route_set.named_routes.module)\n else\n yield app, conditions, requirements, defaults, as, anchor\n end\n end", "def set_locale\n if params[:locale]\n cookies[:locale] = params[:locale]\n redirect_to request.referer || root_url\n end\n I18n.locale = cookies[:locale] || I18n.default_locale\n end", "def enabled_locales(app_path = nil)\r\n ::LinguaFranca.enabled_locales(app_path)\r\n end", "def locale_from_link(link)\n locale = link[/^https?:\\/\\/([^.]+)\\./i, 1]\n locale unless locale.nil? || locale == 'static'\n end", "def locale_from_link(link)\n locale = link[/^https?:\\/\\/([^.]+)\\./i, 1]\n locale unless locale.nil? || locale == 'static'\n end", "def set_locale#Esta accion o metodo indica el idioma que esta en config/locales/es.yml\n I18n.locale = 'es'\n end", "def set_locale\n I18n.locale = if user_signed_in?\n current_user.language.to_sym\n else\n I18n.default_locale\n end\n end", "def load_locale!(locale)\n @projects.each do |project|\n @adapter.allowed_extensions.each do |extension|\n result = project.export locale, extension, @fallback\n\n if result.nil?\n raise \"Could not load project #{project} with extension #{extension} and locale #{locale}\"\n end\n\n strings, plurals = @adapter.parse result, extension\n\n strings = project.filter strings\n plurals = project.filter plurals\n\n warn \"Did not find any strings or plurals in #{project}\" if strings.empty? && plurals.empty?\n\n @strings[locale] = (@strings[locale] || {}).merge(strings)\n @plurals[locale] = (@plurals[locale] || {}).merge(plurals)\n end\n end\n end", "def default_url_options(options = {})\n { locale: I18n.locale }.merge options\n end", "def set_locale\n\t # if params[:locale] is nil then I18n.default_locale will be used\n \t\tlocale = params[:locale] || 'pt'\n\t \tI18n.locale = locale\n \t\tI18n.load_path += Dir[ File.join(Rails.root.to_s, 'lib', 'locale', '*.{rb,yml}') ]\n\tend", "def locale=(locale); end", "def set_locale\n session[:locale] = params[:locale] if params[:locale]\n I18n.locale = session[:locale] || I18n.default_locale\n locale_path = \"#{LOCALES_DIRECTORY}#{I18n.locale}.yml\"\n unless I18n.load_path.include? locale_path\n I18n.load_path << locale_path\n I18n.backend.send(:init_translations)\n end\n rescue Exception => err\n logger.error err\n flash.now[:notice] = \"#{I18n.locale} translation not available\"\n I18n.load_path -= [locale_path]\n I18n.locale = session[:locale] = I18n.default_locale\n end", "def language_option_links\n return \"\"\n end", "def track_locale\n I18n.locale = session[:current_locale] || I18n.default_locale\n end", "def set_locale\n if user_signed_in?\n I18n.locale = current_user.language.to_sym\n else\n I18n.locale = I18n.default_locale\n end\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end", "def set_locale\n I18n.locale = params[:locale] || I18n.default_locale\n end" ]
[ "0.69857645", "0.6824832", "0.6811", "0.6720647", "0.6645329", "0.662629", "0.6561275", "0.64823794", "0.6480525", "0.6465635", "0.63504946", "0.62871486", "0.6280675", "0.6256917", "0.6227062", "0.6204205", "0.61334425", "0.6131501", "0.6130126", "0.61041915", "0.6100411", "0.6098026", "0.6064679", "0.6063881", "0.60427916", "0.60011727", "0.5995432", "0.5978676", "0.59767085", "0.59658414", "0.594671", "0.5938916", "0.5930637", "0.5930637", "0.5927235", "0.592248", "0.5921512", "0.5907513", "0.5907317", "0.5906933", "0.58980983", "0.5856557", "0.5856517", "0.5844392", "0.5837674", "0.583264", "0.5829466", "0.5829213", "0.57958335", "0.578973", "0.5789281", "0.5789281", "0.5775845", "0.57752305", "0.57530373", "0.57530373", "0.57530373", "0.57530373", "0.57530373", "0.57530373", "0.5741935", "0.57247496", "0.57206917", "0.57206917", "0.5712686", "0.57121503", "0.57106453", "0.56882256", "0.5674016", "0.567375", "0.56725055", "0.56666386", "0.56666386", "0.5662582", "0.5662389", "0.5659102", "0.56485796", "0.56485796", "0.5646543", "0.56441545", "0.5622019", "0.5616146", "0.56152034", "0.56152034", "0.5611224", "0.5596858", "0.55968535", "0.5596425", "0.55945265", "0.55798894", "0.5579492", "0.55758965", "0.5563432", "0.5545689", "0.5521674", "0.5521674", "0.5521674", "0.5521674", "0.5521674", "0.5521674" ]
0.5832629
46
scrap les urls des sites des mairies du 92
def get_townhall_email array1 = [] get_townhall_urls.each do |i| url = Nokogiri::HTML(open("http://annuaire-des-mairies.com/#{i}")) n = url.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]') array1 << n.text.to_s end return array1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_the_urls_of_val_doise_townhalls(page_url)\n doc = Nokogiri::HTML(open(page_url))\n urls = []\n#on recupere le css a[class=lientxt]\n get_urls = doc.css(\"a[class=lientxt]\")\n get_urls.each{|link| urls.push(\"http://annuaire-des-mairies.com\"+link['href'][1...link['href'].length])}\n urls\nend", "def gets_urls\n page = Nokogiri::HTML(URI.open('http://www2.assemblee-nationale.fr/deputes/liste/alphabetique'))\n urls = []\n\n page.css('div.col-container > ul > li > a').each do |fetch|\n urls.push('http://www2.assemblee-nationale.fr' + fetch['href'])\n end\n\n urls\nend", "def get_all_the_urls_of_val_doise_townhalls (web_list)\npage = Nokogiri::HTML(RestClient.get(web_list))#recupere le code html du site\npage.css(\"a.lientxt\").each do |note|\nnote['href'] = note['href'][1..-1]#donne les urls de chaque commune en retirant le premier caractaire c-a-d \".\"\nweb_page = \"http://annuaire-des-mairies.com\" + note['href']\nputs web_page\nget_the_email_of_a_townhal_from_its_webpage(web_page)#rappel la fonction get_the_email_of_a_townhal_from_its_webpage pour recuperer les adresses emails grace aux liens (fonctions recurssive)\nend\nend", "def get_all_the_urls_of_val_doise_townhalls\n\n\n page1 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\")) #ouvre la page ciblée\n $get_llinks = page1.css('a[href*=\"95\"]').map{|link| link[\"href\"]} #definie un array \"get_llinks\" cible la balise avec href 95 et prend toutes les fin d'url\n\n\nend", "def get_all_the_urls_of_val_doise_townhalls\n\n\n page1 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\")) #ouvre la page ciblée\n $get_llinks = page1.css('a[href*=\"95\"]').map{|link| link[\"href\"]} #definie un array \"get_llinks\" cible la balise avec href 95 et prend toutes les fin d'url\n\n\nend", "def get_all_the_urls_of_val_doise_townhalls(url)\n page = Nokogiri::HTML(open(url))\n urls = []\n source = \"http://annuaire-des-mairies.com/\"\n news_links = page.css(\"a\").select{|link| link['class'] == \"lientxt\"}\n news_links.each do |link|\n lien = link['href']\n nv_link = lien.byteslice(2,lien.length)\n nv_link = source + nv_link\n urls << nv_link\n end\n return urls\nend", "def get_all_the_urls_of_val_doise_townhalls()\n urls_town = []\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n doc.css('a.lientxt').each do |x|\n lien_page_mairie = x['href']\n lien_page_mairie.slice!(0)\n lien_page_mairie = \"http://annuaire-des-mairies.com\" + lien_page_mairie\n urls_town.push(lien_page_mairie)\n end\n return urls_town\nend", "def get_all_the_urls_townhalls_cot_d_or\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/cote-d-or.html\"))\n doc2 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/cote-d-or-2.html\"))\n doc3 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/cote-d-or-3.html\"))\n doc4 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/cote-d-or-4.html\"))\n urlend = []\n tabname = []\n doc.css('.lientxt').each do |i| tabname << i.content end\n doc.css('a.lientxt @href').each do |i| urlend << i.content end\n doc2.css('.lientxt').each do |i| tabname << i.content end\n doc2.css('a.lientxt @href').each do |i| urlend << i.content end\n doc3.css('.lientxt').each do |i| tabname << i.content end\n doc3.css('a.lientxt @href').each do |i| urlend << i.content end\n doc4.css('.lientxt').each do |i| tabname << i.content end\n doc4.css('a.lientxt @href').each do |i| urlend << i.content end\n i = 0\n while i < urlend.size\n begin\n urlend[i] = get_the_email_of_a_townhal_from_its_webpage(\"http://annuaire-des-mairies.com#{urlend[i]}\")\n i += 1\n rescue => exception\n p urlend[i] = (\"L'url de la mairie de #{tabname[i]} est indisponible\")\n i += 1\n ensure\n end\n end \n return myhash = Hash[tabname.zip(urlend)]\n end", "def get_all_urls\r\n val_d_oise = \"http://annuaire-des-mairies.com/val-d-oise.html\"\r\n page = Nokogiri::HTML(URI.open(val_d_oise))\r\n links = page.xpath('//*[@class=\"lientxt\"]').map{|anchor| anchor[\"href\"]}\r\n return links\r\nend", "def get_townhall_urls(url)\n urls_department = []\n \n doc = Nokogiri::HTML(open(url))\n \n # Extraire le texte et mettre ça dans un hash \n \n doc.xpath(\"//a[@class=\\\"lientxt\\\"]\").each do |node|\n urls_department << { name: node.text, url: \"http://annuaire-des-mairies.com\" + node[:href][1, node[:href].size - 1]}\n end\n urls_department\n end", "def get_all_the_urls_of_val_doise_townhalls\n mairie_val_d_oise = Array.new\n page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n links = page.css('a.lientxt')\n links.each do |mairie|\n mairie_val_d_oise << mairie['href']\n end\n return mairie_val_d_oise\nend", "def get_all_the_urls_of_val_doise_townhalls\n\n\tdoc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\tdoc.xpath('//a[@class = \"lientxt\"]').each do |link|\n\t puts @mairie_url = link['href']\n\n\t get_the_email_of_a_townhal_from_its_webpage \n\tend\nend", "def get_urls(page)\n doc = Nokogiri::XML(open_url(page))\n urls = []\n\n doc.search('nodes > node').each do |node|\n url = nil\n node.search('URL').each do |t|\n url = t.inner_text\n end\n if url\n urls << url\n end\n end\n\n urls\n end", "def get_townhall_urls\r\n\r\n # Scrapping de toutes les URLs\r\n page = Nokogiri::HTML(URI.open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\r\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') # toutes les URLs appartiennent à la classe lientxt\r\n\r\n #stockage des URLs scrappées dans une array\r\n\turl_array = []\r\n urls.each do |url| # pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\r\n\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] # A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\r\n\t\turl_array << url\r\n end\r\n\r\n puts \" ⏳ URLs scrapping in process...3️, 2️, 1️\" \r\n sleep 3\r\n puts \"⭐⭐⭐ BINGOOOOOO ⭐⭐⭐\" #https://emojipedia.org/\r\n sleep 1\r\n return url_array \r\nend", "def get_all_the_urls_of_val_doise_townhalls\n urls = []\n\n directory = Nokogiri::HTML(open('http://annuaire-des-mairies.com/val-d-oise.html'))\n directory.css('a[class = lientxt]').each do |element|\n # element => <a class=\"lientxt\" href=\"./95/nom-de-la-ville.html\">NOM DE LA VILLE</a>\n link = element['href']\n link[0] = ''\n urls << \"http://annuaire-des-mairies.com#{link}\"\n end\n\n urls\nend", "def get_all_the_urls_of_val_doise_townhalls(page_url)\n tab = []\n doc = Nokogiri::HTML(open(page_url))\n tab_lien = doc.css(\"a\").select{|link| link['class']==\"lientxt\"}\n lien =\"http://annuaire-des-mairies.com/\"\n tab_lien.each{|link| tab.push(lien+link['href'])}\n tab\nend", "def get_all_the_urls_of_val_doise_townhalls(x)\n doc = Nokogiri::HTML(open(x))\n doc.css('.lientxt').each do |url|\n Tab_url.push(\"http://annuaire-des-mairies.com\" + (url[\"href\"][1..-1]))\n end\n Tab_url\nend", "def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('.zone_B_with_ads')\n allUrl = links.css('div.tile__content a.tile__read_more').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n #puts i\n end\nend", "def get_townhall_urls\n page = Nokogiri::HTML(open(\"https://www.annuaire-des-mairies.com/val-d-oise.html\"))\n town_url_list = []\n url_root = \"https://annuaire-des-mairies.com\"\n page.xpath('//*[@class=\"lientxt\"]/@href').each do |node|\n townhall_url = url_root + node.value.to_s.delete_prefix(\".\")\n town_url_list << townhall_url\n end \n town_url_list\nend", "def get_url_cities_array(page)\r\n url_cities_array = []\r\n urls = page.xpath('//*[@class=\"lientxt\"]/@href') \r\n urls.each do |url|\r\n url_cities_array << (\"https://www.annuaire-des-mairies.com\" + url.text[1..-1]) # rajout à partir du deuxième caractère pour éviter d'ajouter le point \r\n print \".\" # affichage pour simuler le chargement\r\n end\r\n return url_cities_array\r\nend", "def get_townhall_urls\n\tpage = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\turl_array = []\n\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') \n\n urls.each do |url| \n# ->Pour chaque URL récupérée : indiquer l'url parent \"http://annuaire-des-mairies.com\"\n url = \"http://annuaire-des-mairies.com\" + url.text[1..-1] \n#->A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\turl_array << url\t\t\n\tend\n\treturn url_array \nend", "def get_depute_urls\n list_url_depute = 'http://www.assemblee-nationale.fr/qui/xml/regions.asp?legislature=14'\n result_array = []\n\n doc = Nokogiri::HTML(open(list_url_depute))\n\n #allows to test the program without planting it\n doc.xpath('//*[@class=\"dep2\"]/@href').to_a.sample(10).each do |url|\n full_url_depute = \"http://www.assemblee-nationale.fr#{url}\"\n\n #Exception and rescuing\n begin\n depute_infos = get_depute_infos(full_url_depute)\n result_array << depute_infos\n rescue => e\n puts \"Not Found : #{full_url_depute}\"\n end\n\n end\n return result_array\nend", "def get_townhall_urls(url)\n\n page = Nokogiri::HTML(URI.open(url)) \n #townhall_url = page.xpath(\"//a/@href\").map {|x| x.value}\n townhall_urls_array_incomplete = page.css('a[href].lientxt').map {|x| x[\"href\"]}\n #remove the dot at the beginning of the url\n townhall_urls_array_incomplete = townhall_urls_array_incomplete.map {|x| x[2..]}\n townhall_urls_array = townhall_urls_array_incomplete.map {|x| \"http://annuaire-des-mairies.com/\" + x}\n return townhall_urls_array\n\nend", "def get_townhall_urls(url)\n urls_department = []\n\n doc = Nokogiri::HTML(open(url))\n\n# Extraire le texte et mettre ça dans un hash \n\n doc.xpath(\"//a[@class=\\\"lientxt\\\"]\").each do |node|\n urls_department << { name: node.text, url: \"http://annuaire-des-mairies.com\" + node[:href][1, node[:href].size - 1]}\n end\n\n urls_department\nend", "def get_townhall_urls\n city = []\n town.xpath('//p/a').each do |node|\n city << node.text.downcase #l'array city, est l'ensemble des villes du 95\n end\n array_url = city\n final = []\n array_url.each do |town|\n return array_url2 = Nokogiri::HTML(URI.open(\"http://annuaire-des-mairies.com/95/#{town.gsub(\" \", \"-\" )}.html\"))\n end\nend", "def get_townhall_urls\n\tpage = la_page\n\turls = page.xpath('//*[@class=\"lientxt\"]/@href') #/ toutes les URLs appartiennent à la classe lientxt\n\turl_array = []\n\turls.each do |url| #/ pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\n\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] #/ A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\turl_array << url\n\tend\n puts url_array\n\n\treturn url_array\nend", "def urls_of_val_doise_townhalls\n\turl_parent = \"http://annuaire-des-mairies.com/\" # The parent page url which list the town hall pages url\n\tpage = Nokogiri::HTML(open(url_parent+\"/val-d-oise.html\")) # url from the page and the specific town link\n\turls_array = page.xpath('//a[@class = \"lientxt\"]').map { |node| url_parent + node.attributes[\"href\"].value[1..-1] }\n\treturn urls_array # urls sheet\nend", "def get_townhall_urls(html)\n url = []\n get_townhall_city(html).each do |x|\n url << \"http://annuaire-des-mairies.com/95/#{x}.html\"\n end \n return url\n end", "def get_all_the_urls_of_val_doise_townhalls\n\tdoc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\tputs doc.xpath('//a[@class = \"lientxt\"]/@href')\nend", "def crawler(url)\n result = []\n doc = Nokogiri::HTML.parse(open(url))\n row = doc.xpath(\"//tr[4]\").first\n while(row)do\n row_doc = Nokogiri::HTML(row.to_s)\n link = row_doc.xpath(\"//a\").first\n if(link)then\n href = url + link.attribute(\"href\").value\n if(href =~ /\\/$/)then\n result = result + crawler(href)\n else\n result << href\n end\n end\n row = row.next\n end\n return result\n end", "def crawler(url)\n result = []\n doc = Nokogiri::HTML.parse(open(url))\n row = doc.xpath(\"//tr[4]\").first\n while(row)do\n row_doc = Nokogiri::HTML(row.to_s)\n link = row_doc.xpath(\"//a\").first\n if(link)then\n href = url + link.attribute(\"href\").value\n if(href =~ /\\/$/)then\n result = result + crawler(href)\n else\n result << href\n end\n end\n row = row.next\n end\n return result\n end", "def scrap_data\n\turl_array = get_townhall_urls \n url_array.each do |townhall_url| \n# -> Pour chaque URL d'une ville du Val d'Oise, on associe l'adresse mail de la mairie\n\t\tget_townhall_email(townhall_url)\n\tend\nend", "def get_all_the_urls_townhalls_rhone\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/rhone.html\"))\n doc2 = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/rhone-2.html\"))\n urlend = []\n tabname = []\n doc.css('.lientxt').each do |i| tabname << i.content end\n doc.css('a.lientxt @href').each do |i| urlend << i.content end\n doc2.css('.lientxt').each do |i| tabname << i.content end\n doc2.css('a.lientxt @href').each do |i| urlend << i.content end\n i = 0\n while i < urlend.size\n begin\n urlend[i] = get_the_email_of_a_townhal_from_its_webpage(\"http://annuaire-des-mairies.com#{urlend[i]}\")\n i += 1\n rescue => exception\n p urlend[i] = (\"L'url de la mairie de #{tabname[i]} est indisponible\")\n i += 1\n ensure\n end\n end \n return myhash = Hash[tabname.zip(urlend)]\n end", "def get_all_the_urls_of_manche\n#On créer deux tableau, 1 pour stocker les noms des maries, l'autre pour stocker les e-mails\n @town_names = []\n @town_emails = []\n urls = %w[http://www.annuaire-des-mairies.com/manche.html]\n\n urls.each do |url|\n doc = Nokogiri::HTML(open(url))\n \tdoc.css(\".lientxt\").each do |link|\n \t\turl = \"http://annuaire-des-mairies.com\" + link[\"href\"][1..-1].to_s\n \t\ttown_name = link.text\n \t\ttown_email = get_the_email_of_a_townhal_from_its_webpage(url)\n @town_names << town_name\n @town_emails << town_email\n end\n end\n\n urls = %w[http://www.annuaire-des-mairies.com/manche-2.html]\n\n urls.each do |url|\n doc = Nokogiri::HTML(open(url))\n \tdoc.css(\".lientxt\").each do |link|\n \t\turl = \"http://annuaire-des-mairies.com\" + link[\"href\"][1..-1].to_s\n \t\ttown_name = link.text\n \t\ttown_email = get_the_email_of_a_townhal_from_its_webpage(url)\n @town_names << town_name\n @town_emails << town_email\n end\n end\n\n urls = %w[http://www.annuaire-des-mairies.com/manche-3.html]\n\n urls.each do |url|\n doc = Nokogiri::HTML(open(url))\n \tdoc.css(\".lientxt\").each do |link|\n \t\turl = \"http://annuaire-des-mairies.com\" + link[\"href\"][1..-1].to_s\n \t\ttown_name = link.text\n \t\ttown_email = get_the_email_of_a_townhal_from_its_webpage(url)\n @town_names << town_name\n @town_emails << town_email\n end\n end\n envoie_mail #Cette méthode ce trouve dans townhalls_mailer.rb\n pro_twitter #Cette méthode ce trouve dans townhalls_follower.rb\n end", "def process_links(host_url)\n file = open(url)\n links = Nokogiri::HTML(file).search('a')\n protocol = url.split('://').first\n links = links.map { |link| [link.text.strip, link['href']] }.to_h\n create_report(links, protocol, host_url)\n rescue StandardError => error\n puts \"Error Encountered : #{error}\"\n end", "def urls(env)\n begin\n page = env[:page]\n agent = env[:agent]\n follower_url = page.search(FLAG)[1].attributes['href'].value\n follower_page = agent.get(follower_url)\n tables = follower_page.search(FOLLOWER_FLAG)\n tables.map{|table| get_url_from_table(table)}\n rescue => err\n CrawlingService.log(err.message)\n CrawlingService.log(err.backtrace)\n []\n end\n\n end", "def urls\n @urls ||= all_urls(sitemap)\n end", "def fetch_movies_url\n # Visiter le site imdb: https://www.imdb.com/chart/top\n raw_html = URI.open(IMDB_TOP_CHART_URL).read\n # Utiliser nokogiri pour parser le fichier html recu\n html_doc = Nokogiri::HTML(raw_html)\n urls = []\n\n # Rechercher avec nokogiri les urls des 5 premiers films\n html_doc.search('.titleColumn a').first(5).each do |link|\n # Stocker dans un tableau\n urls << \"https://www.imdb.com#{link.attribute('href').value}\"\n end\n\n urls\nend", "def download_sites_urls(response)\n return [] if !response.is_a?(Hash) ||\n (sites_urls = response.dig('receipt', 'sites_urls')).nil?\n sites_urls.map do |url|\n Infosimples::Data::HTTP.request(url: url, http_timeout: 30)\n end\n end", "def parse_from_website\n log 'Parsing from Website:'\n offer_links = HomepageParser.new(get_body_from('/leistungen/alle-leistungen-2016/index.html')).offer_links\n offer_links.each do |offer_link|\n create_and_parse_offer(offer_link)\n end\n log\n end", "def get_townhall_urls(url)\n page = Nokogiri::HTML(open(url))\n cities_url = page.xpath('//a[@class=\"lientxt\"]').to_a\n links = (cities_url.map {|url| url[\"href\"][1..-1]}).to_a\n #puts links\n return links\nend", "def get_url\n nokogiri_object = Nokogiri::HTML(open(\"https://www.nosdeputes.fr/deputes\"))\n web_object = nokogiri_object.xpath('//tr/td/a') #.xpath = cherche plus precisement\n array = []\n web_object.each {|link| array << link[\"href\"]}\n # ajoute le reste de l'url contenant les noms à l'url de base\n array.map! {|url| url = \"https://www.nosdeputes.fr\" + url}\n return array\nend", "def get_child_links(url)\n\n $log.info \"START #{__FILE__}.#{__method__}\"\n\t\n doc = Nokogiri::HTML(open(url))\n\t\n # append hostname to url\n if url == $url_root_shopping\n doc.xpath($deal_config[$site_name][\"child_links\"][\"a\"]).each do |link|\n $child_links << \"#{URI.parse(url).host}#{link['href']}\"\n #puts $child_links[-1]\n end\n\n else\n doc.xpath($deal_config[$site_name][\"child_links\"][\"b\"]).each do |link|\n $child_links << \"#{URI.parse(url).host}#{link['href']}\"\n #puts $child_links[-1]\n end\n end\n \n #puts doc.xpath($deal_config[$site_name][\"child_links\"][\"1\"])\n\t\n $log.info \"END #{__FILE__}.#{__method__}\"\n\t\n end", "def grabUrlsFromDomain(domain)\n @htmlDocument = Nokogiri::HTML(open(domain,{ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}))\n if @htmlDocument.nil?\n abort red('Something went wrong ...')\n else\n puts green('Fetched.')\n end\n\n #Varibles\n tempArray = Array.new\n count = 1\n progress = ProgressBar.create(:starting_at => 0, :total => 200)\n\n @htmlDocument.xpath('//a[@href]').each do |link|\n #se for do mesmo dominio colocar no array\n if !link['href'].to_s.include? \"http://\"\n if !link['href'].to_s.include? \"https://\"\n tempUrl = domain+\"/\"+link['href']\n tempArray << tempUrl+\"\\n\"\n end\n end\n\n if count <= 200\n progress.increment\n end\n\n count+=1\n end\n\n #make they uniq then return\n return tempArray.uniq!\n\n end", "def get_townhall_urls\n\t\tpage = Nokogiri::HTML(open(@url_dept))\n\t\t\n\t\turls = page.xpath('//*[@class=\"lientxt\"]/@href') #/ toutes les URLs appartiennent à la classe lientxt\n\n\t\turls.each do |url| #/ pour chaque URLs récupérées, il faut leur indiquer l'url parent \"http://annuaire-des-mairies.com\"\n\t\t\turl = \"http://annuaire-des-mairies.com\" + url.text[1..-1] #/ A l'url parent, on ajoute les urls récupérées du deuxième caractère au dernier caractère, car on veut se débarasser du point devant.\n\t\t\t@urls_town << url\t\t\n\t\tend\n\t\treturn @urls_town\n\tend", "def get_links(url)\n # catch 404 error from host\n\n doc = Nokogiri::HTML(open(url))\n # find internal links on page\n doc.css('#tagCloud a').each do |link|\n link = link.attr('href')\n # If link correspond to a recipe we add it to recipe to scraw\n if link.include?(ALLOWED_URLS[@host]) && !@crawled_urls.include?(url)\n @to_crawl_urls << link\n end\n end\n @to_crawl_urls.delete url\n @crawled_urls << url\n @to_crawl_urls.uniq!\n rescue OpenURI::HTTPError\n @to_crawl_urls.delete url\n warn \"#{url} cannot be reached\"\n end", "def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('.new-restaurants')\n allUrl = links.css('p a').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n #puts i\n end\nend", "def get_all_the_urls_townhalls\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/bouches-du-rhone.html\"))\n urlend = []\n tabname = []\n doc.css('.lientxt').each do |i| tabname << i.content end\n doc.css('a.lientxt @href').each do |i| urlend << i.content end\n i = 0\n while i < urlend.size\n urlend[i][0] = ''\n urlend[i] = get_the_email_of_a_townhal_from_its_webpage(\"http://annuaire-des-mairies.com#{urlend[i]}\")\n i += 1\n end\n return myhash = Hash[tabname.zip(urlend)]\n end", "def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('div.case')\n allUrl = links.css('h3 a').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n puts i\n end\nend", "def pet_urls_from_doc(doc)\n doc.xpath(\"//h3[@class='catItemTitle']/a/@href\").map do |href|\n \"https://www.strayrescue.org#{href}\"\n end\n end", "def get_urls(url, d)\n useragent = \"NotubeMiniCrawler/0.1\"\n u = URI.parse url \n req = Net::HTTP::Get.new(u.request_uri,{'User-Agent' => useragent})\n begin \n res2 = Net::HTTP.new(u.host, u.port).start {|http|http.request(req) }\n end\n j = nil\n begin\n j = JSON.parse(res2.body)\n rescue JSON::ParserError=>e\n puts \"Error \"+e.to_s\n return Array.new\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 return Array.new\n end\n txt = \"\"\n service=j[\"schedule\"][\"service\"][\"key\"]\n serviceTitle=j[\"schedule\"][\"service\"][\"key\"]\n arr = j[\"schedule\"][\"day\"][\"broadcasts\"]\n arr2 = Array.new\n pids = Array.new\n arr.each do |x|\n pid = x[\"programme\"][\"pid\"]\n tt1 = x[\"programme\"][\"display_titles\"][\"title\"]\n tt2 = x[\"programme\"][\"display_titles\"][\"subtitle\"]\n pidTitle = \"#{tt1}: #{tt2}\"\n # fix up &amps;\n pidTitle.gsub!(\"&\",\"&amp;\")\n startd = x[\"start\"]\n endd = x[\"end\"]\n #puts \"start #{startd} date to match #{d} ''\"\n if (startd.match(d))\n pids.push(pid)\n arr2.push({\"pid\"=>pid,\"displayTitle\"=>pidTitle,\"startd\"=>startd,\"endd\"=>endd,\"service\"=>service,\"serviceTitle\"=>serviceTitle})\n end\n end\n return arr2,pids\n end", "def get_all_the_urls_of_val_doise_townhalls(url)\n doc = Nokogiri::HTML(URI.open(url))\n hash = {}\n doc.css('//p/a').each do |node|\n html = node[\"href\"]\n html = \"http://annuaire-des-mairies.com\" + html[1..-1] # => permet d'enlever le . devant le lien <a class=\"lientxt\" href=\"./95/ableiges.html\">ABLEIGES</a>\n hash[node.text]=get_the_email_of_a_townhal_from_its_webpage(html)\n end\n puts hash\nend", "def urls\n @urls ||= extract_urls('url')\n end", "def get_townhall_urls(townhall_list)\n page = Nokogiri::HTML(URI.open(townhall_list))\n annuaire = []\n page.xpath('//a[@class=\"lientxt\"]/@href').each do |link|\n annuaire << link.text\n end\n annuaire.map!{ |x| [\"https://www.annuaire-des-mairies.com\", x.reverse.chop.reverse].join}\n return annuaire\nend", "def get_urls(target)\n trail_urls = []\n i = 24\n while i < 162\n search_page_hike_url = target[i].to_s\n search_page_hike_url = search_page_hike_url.gsub(\"&amp;\", \"&\")\n search_page_hike_url = search_page_hike_url.gsub(/\\<a href=\"/, \"\")\n search_page_hike_url = search_page_hike_url.gsub(/\" .*/, \"\")\n trail_urls << search_page_hike_url\n i+=1\n end\n trail_urls\nend", "def scrape_page(url) \r\n puts \"Scraping \" + url + \".\"\r\n elements = []\r\n \r\n begin\r\n doc = Nokogiri::HTML(open(url))\r\n elements = doc.xpath(\"//a[@href]\")\r\n rescue RuntimeError\r\n #puts \"Runtime error caught\"\r\n rescue OpenURI::HTTPError\r\n #puts \"OpenURI error caught\"\r\n rescue OpenURI::HTTPRedirect \r\n #puts \"OpenURI redir error caught\"\r\n rescue SocketError\r\n #puts \"SocketError caught\"\r\n end\r\n \r\n puts \"Number of href elements found: \" + elements.length.to_s\r\n results = []\r\n elements.each do |link|\r\n #link = (link.first.to_s.scan(/.+?href=\".*\"/)) # Replaced by URI::extract!!\r\n urls = URI::extract(link.to_s) # extract URL\r\n if !urls.empty?\r\n urls.each do |u| \r\n if u.include?(\"http\") # don't store links which aren't prefixed with \"http\"\r\n results << (u.to_s) # store link\r\n end\r\n end\r\n end\r\n end\r\n \r\n if results.empty? then puts \"No links found in \" + url + \".\" end\r\n \r\n results.compact.uniq # avoid nils and duplicates\r\n \r\nend", "def urls\n each_url.to_set\n end", "def get_links(page_url)\n ndoc = Nokogiri::HTML(open(page_url))\n links = ndoc.css('a')\n tmp = []\n found = nil\n links.each do |ln|\n if ln.text == \"next 5,000\"\n tmp = get_links(\"http://en.wikipedia.org\" + ln[\"href\"])\n tmp << \"http://en.wikipedia.org\" + ln[\"href\"]\n found = true\n break\n end\n end\n if found == nil\n tmp << page_url\n end\n tmp\nend", "def scrap_trip_pages\n \n mp_trip_pages.each do |mp, trip_page|\n printf \"mp - #{mp}\\n\"\n doc = utf_page(trip_page)\n t = Time.now\n komandiruotes = (doc/\"//a[text()='Komandiruotės']\").first\n mp_business_trip(mp, denormalize( komandiruotes.attributes['href'] ) ) if komandiruotes\n printf \"Laikas: #{Time.now - t}\\n\"\n #sleep 3\n end\n \n end", "def route_de_la_mairie\n page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\")) \n puts \"nata\"\n #page.xpath('/html/body/table/tbody/tr[3]/td/table/tbody/tr/td[2]/p[2]/object/table/tbody/tr[2]/td/table/tbody/tr/td[2]/p/a').each do |link|\n page.css('html body table tbody tr td table tbody tr td p object#voyance-par-telephone table tbody tr td table.Style20 tbody tr td p a.lientxt').each do |link|\n #page.css('html body table tbody').css('tr')[2].css('td table tbody tr').css('td')[1].css('p')[1].css('object table tbody').css('tr')[1].css('td table tbody tr').css('td')[2].css('p a').each do |link| \n puts link['href']\n puts link.text\n end\nend", "def urls\n info.map(&:value).select { |u| u.match %r{\\Ahttps?://} }\n end", "def get_article_urls(url, article_urls)\n uri = URI.parse(URI.encode(url.to_s.strip))\n # doc = Nokogiri::HTML(open(uri, \"User-Agent\" => \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0\", :allow_redirections => :all))\n\n response_page = \"\"\n begin\n Timeout.timeout(25) do\n response_page = open(uri, \"User-Agent\" => \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0\", :allow_redirections => :all)\n end\n rescue Exception => e\n response_page = \"\"\n end\n doc = Nokogiri::HTML(response_page)\n\n articles = doc.xpath(\".//article\")\n\n articles.each do |article|\n begin\n article_urls << article.at(\".entry-post-thumbnail\")[\"href\"]\n rescue Exception => e\n p e.backtrace\n end\n end\nend", "def links\n return unless success? and body\n\n doc = Nokogiri::HTML(@body)\n \n links = []\n\n doc.css('div.list-lbc a').each do |a|\n link = {\n :url => a['href'],\n :title => a.css('div.title').first.content.strip\n }\n\n link[:ad_id] = link[:url][/^http:\\/\\/www.leboncoin.fr\\/locations\\/(\\d+).*/,1]\n links << link\n yield link if block_given?\n end\n\n links\n end", "def crawl\n recursive_explore([@origin_url],1)\n end", "def scrap\n\t\tdef get_townhall_email(townhall_url)\n\t\t\tpage = Nokogiri::HTML(open(townhall_url))\n\t\t\temail = page.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]').text\n\n\t\t\tif email.size < 1\n\t\t\t\temail = \"nill\"\n\t\t\tend\n\t\t\treturn email\n\t\tend\n\n\t\tdef get_townhall_urls\n\t\t\ti = 0\n\t\t\tpage = Nokogiri::HTML(open('http://annuaire-des-mairies.com/val-d-oise.html'))\n\t\t\tarray_ville = []\n\t\t\tarray_mail = []\n\t\t\thachier = {}\n\t\t\tarray = []\n\t\t\tville = page.xpath('//a[@class=\"lientxt\"]')\n\n\t\t\tville.each do |a|\n\t\t \tarray_ville[i] = a['href'][1..-1]\n\t\t \tarray_mail = get_townhall_email(\"http://annuaire-des-mairies.com#{array_ville[i].downcase}\")\n\t\t \thachier = {}\n\t\t \thachier[a.text] = array_mail\n\t\t \tarray[i] = hachier\n\t\t \ti = i + 1\n\t\t \tputs hachier\n\t\t end\n\t\t return array\n\t\tend\n\t\treturn get_townhall_urls\n\tend", "def get_townhall_urls\n h = {}\n page = 'http://annuaire-des-mairies.com'\n doc = Nokogiri::HTML(open(page + '/val-d-oise.html'))\n doc.xpath('//a[@class=\"lientxt\"]').each do |node|\n h[node.text.capitalize.to_sym] = get_townhall_email(page +\n node.xpath('@href').text.gsub!(/^\\./, '').to_s)\n end\n return h\n end", "def nonadword_urls(page)\n\t\tnonadwords_xpath(page).inject([]) do |result, adword|\n\t\t\tresult << fetch_nonadword_url(adword)\n\t\tend\t\t\n\tend", "def get_urls\n\n url_array = []\n top_five = 0\n\n while top_five < 5\n url_array << @news_instance[\"response\"][\"docs\"][top_five][\"web_url\"]\n top_five += 1\n end\n\n # returns the array\n return url_array\n\n end", "def get_link\n page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n faux_liens_villes =[]\n page.xpath('//*[@class=\"lientxt\"]').each do |lien|\n faux_liens_villes << lien.values[1]\n end\n liens_villes = faux_liens_villes.map{ |el| \"http://annuaire-des-mairies.com\" + el[1..-1]}\n return liens_villes\n end", "def all_list_page_urls\n LIST_PAGE_URLS.each_with_index do |list_page_url, i|\n begin\n puts \"-- Crawling #{list_page_url} (#{i + 1} of #{LIST_PAGE_URLS.count}) --\"\n yield(list_page_url)\n rescue => e\n puts \"Failed to crawl list_page_url:#{e.message}\"; next\n end\n end\n end", "def all_list_page_urls\n LIST_PAGE_URLS.each_with_index do |list_page_url, i|\n begin\n puts \"-- Crawling #{list_page_url} (#{i + 1} of #{LIST_PAGE_URLS.count}) --\"\n yield(list_page_url)\n rescue => e\n puts \"Failed to crawl list_page_url:#{e.message}\"; next\n end\n end\n end", "def find_urls_on_page(current_url,domain_url,urls_hash)\n dom = get_dom_for_page(current_url)\n if not dom \n $log.info \"Unable to create dom\" \n return \n end\n urls_list = {}\n\t dom.xpath('//a/@href').each do |node|\n\t url = node.content\n next if not url \n create_bag_of_words_for_parent_class(node)\n create_bag_of_words_for_parent_name(node)\n if node.parent.parent.attributes['class']\n parent_parent_class = node.parent.parent.attributes['class'].to_s\n else\n parent_parent_class = \"UNKNOWN\"\n end\n parent_parent_name = node.parent.parent.name\n node_path = node.path\n url = url.chomp.strip\n url = url.gsub(\"..\",\"\") \n url = url.gsub(\"./\",\"/\")\n if relative?(url)\n url = make_absolute(domain_url,url)\n end\n if not url.match(/\\%/)\n\t url = URI.encode(url)\n\t end\n next if not url.match(/http(s)?:\\/\\/[^\\/]+/).to_s == domain_url\n urls_list[url] = true if not urls_list[url]\n url_length = get_url_length(url)\n if not urls_hash[url]\n urls_hash[url] = [1,parent_parent_class,parent_parent_name,url_length,node_path]\n else\n urls_hash[url][0] += 1\n end\n\t end\n\t return urls_list.keys\n end", "def craw_result_page_urls\n start_time = Time.now\n agent = touch_and_customize_cookies\n \n detail_urls = []\n page_indexes = (0..245)\n\n Parallel.each(page_indexes, :in_threads => 2, :in_processes => 2) do |page_index|\n # (0..245).each do |page_index|\n url = \"http://www.smc.gov.sg/PRSCPDS/scripts/profSearch/searchList.jsp?page=#{page_index}&spectext=\" \n search_results = agent.post(url)\n search_results.search(\".displayTabledata a\").each do |link|\n COLL.insert(:url => link.attribute(\"href\").value)\n end\n end\n p Time.now - start_time\nend", "def craw_result_page_urls\n start_time = Time.now\n agent = touch_and_customize_cookies\n \n detail_urls = []\n page_indexes = (0..245)\n\n Parallel.each(page_indexes, :in_threads => 2, :in_processes => 2) do |page_index|\n # (0..245).each do |page_index|\n url = \"http://www.smc.gov.sg/PRSCPDS/scripts/profSearch/searchList.jsp?page=#{page_index}&spectext=\" \n search_results = agent.post(url)\n search_results.search(\".displayTabledata a\").each do |link|\n COLL.insert(:url => link.attribute(\"href\").value)\n end\n end\n p Time.now - start_time\nend", "def get_city_list\r\n url = \r\n page = Nokogiri::HTML(URI.open('http://annuaire-des-mairies.com/val-d-oise.html'))\r\n citys = page.css('a.lientxt[href]').each {|city| @citys_list << city.text.downcase.gsub(' ', '-')}\r\nend", "def getwebsite()\n\tpage = Nokogiri::HTML(open(\"https://annuaire-des-mairies.com/val-d-oise.html\"))\n\tsession = GoogleDrive::Session.from_config(\"config.json\")\n\tws = session.spreadsheet_by_key(\"1v7XEnpGDtgjgRom3bp7OwzaK99zlUQIfKuW3QdawXBc\").worksheets[0]\n\tcities = \"\"\n\ti = 1\n\t#define a loop for list of emails\n\tpage.css('a.lientxt').each do |town|\n\t\tsite = \"https://annuaire-des-mairies.com\" + town['href'][1..-1]\n\t\tcities = town.text\n\t\tws[(i), 1] = cities\n\t\tws[(i), 2] = getemail(site)\n\t\ti += 1\n\tend\n\tws.save\nend", "def parse_for_urls(doc, domains)\n\tlinks = doc.search('//*[@id=\"wg0\"]/li/div/div/div[1]/h3/a')\n\tlinks.each do |link|\n\t\tdomain = get_host_name(link.attributes['href'])\n\t\tdomains[domain] = link.inner_text\n\tend\n\treturn domains\nend", "def get_hrefs\n # this will grab all the html from the url that\n # the user created the scraper with\n url_to_scrape = HTTParty.get(self.url)\n # nokogiri turns everything from HTTParty into nodes.\n nodes = Nokogiri::HTML(url_to_scrape)\n nodes.css('a').each do |a|\n self.hrefs << a['href']\n end\n self.hrefs\n end", "def scrape\n google_url = create_google_url\n google_data = Scrubyt::Extractor.define do\n fetch google_url\n\n link_title \"//a[@class='l']\", :write_text => true do\n link_url\n end\n end\n google_data.to_hash.map {|r| r[:link_url]}\n end", "def crawl_site(url = @urls.first, &block)\n assert_type(url, Wgit::Url)\n\n doc = crawl_url(url, &block)\n return nil if doc.nil?\n\n host = url.to_base\n alt_url = url.end_with?('/') ? url.chop : url + '/'\n crawled = [url, alt_url]\n externals = doc.external_links\n internals = get_internal_links(doc)\n\n return doc.external_links.uniq if internals.empty?\n\n loop do\n crawled.uniq!\n internals.uniq!\n\n links = internals - crawled\n break if links.empty?\n\n links.each do |link|\n orig_link = link.dup\n doc = crawl_url(\n link, follow_external_redirects: false, host: host, &block\n )\n\n crawled.push(orig_link, link) # Push both in case of redirects.\n next if doc.nil?\n\n internals.concat(get_internal_links(doc))\n externals.concat(doc.external_links)\n end\n end\n\n externals.uniq\n end", "def pages(url)\n urls = Array.new\n data = Array.new \n data << Nokogiri::HTML(ScraperWiki.scrape(url))\n data[0].css('p.pages a').each do |link|\n urls << editUrl(link.attribute(\"href\").to_s())\n end\n\n urls.uniq.each do |link|\n data << Nokogiri::HTML(ScraperWiki.scrape(link))\n end\n\n return data\nend", "def pages(url)\n urls = Array.new\n data = Array.new \n data << Nokogiri::HTML(ScraperWiki.scrape(url))\n data[0].css('p.pages a').each do |link|\n urls << editUrl(link.attribute(\"href\").to_s())\n end\n\n urls.uniq.each do |link|\n data << Nokogiri::HTML(ScraperWiki.scrape(link))\n end\n\n return data\nend", "def get_urls_to_retrieve(d1)\n urls = []\n\n if (d1==nil || d1 ==\"\")\n t = DateTime.now\n d = t.strftime(\"%Y/%m/%d\")\n else\n d = d1\n end\n pt1 = \"http://www.bbc.co.uk/\"\n pt2 = \"/programmes/schedules/\"\n\n channel = \"bbcone\"\n url = \"#{pt1}#{channel}#{pt2}london/#{d}.json\"\n urls.push(url)\n\n channel = \"bbctwo\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n urls.push(url)\n\n channel = \"bbcthree\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcfour\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbchd\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbeebies\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"cbbc\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"parliament\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"bbcnews\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio4\"\n url = \"#{pt1}#{channel}#{pt2}fm/#{d}.json\"\n\n channel = \"radio1\"\n url = \"#{pt1}#{channel}#{pt2}england/#{d}.json\"\n\n channel = \"1extra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio2\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"radio3\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5live\" \n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"5livesportsextra\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"6music\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"asiannetwork\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n channel = \"worldservice\"\n url = \"#{pt1}#{channel}#{pt2}#{d}.json\"\n urls.push(url)\n\n return urls\n end", "def news_links\n visit \"http://hk.apple.nextmedia.com/\"\n\n links = doc.css(\"#article_ddl option\").collect do |option|\n link = Link.new\n link.title = option.text\n link.url = option[\"value\"]\n link\n end.reject { |l| l.url.nil? }\n links\n end", "def get_url\n page = Nokogiri::HTML(open(\"http://www2.assemblee-nationale.fr/deputes/liste/alphabetique\"))\n url_deputy = page.css(\"ul.col3 a\")\nend", "def crawl\n while NG_URL.where(:a_hrefs_unprocessed => { :$not => { :$size => 0}}).count > 0 do\n next_unprocessed_url\n end\n end", "def sites\n unless @sites\n @sites = {}\n (html / 'div#list > a').each do |el_a|\n site_name = he_decode strip_html(el_a.inner_html)\n @sites[site_name] = $1 if URL_HOST_PART.match el_a[:href]\n end\n end\n \n @sites\n end", "def open_link\n\n scrapped = []\n\n mail = []\n\n landing_page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\n links = []\n landing_page.css('a[class = lientxt]').each do |link|\n\tlink_end = link[\"href\"].sub!(\".\",\"http://annuaire-des-mairies.com\")\n\tlinks << link_end\n end\n\n\nlinks.each do |ville|\n page = Nokogiri::HTML(open(\"#{ville}\"))\n\n error = [] # on doit vider le tableau à chaque boucle\n text_array = page.css('td[class = style27]').text.split\n\n text_array.each do |element|\n adress = element if element.include?(\"@\")\n mail << adress\n scrapped << adress\n error << adress # dqsdsqd\n end\n\n if error.size == 0 # rezrezrez\n scrapped << \"Unavailable\" # fdscsdd\n end\n puts scrapped\n\nend\nend", "def getScrapingURLs(shared)\n\tFile.open(\"urls.txt\").each do |line|\n\t\tshared.pushurl(line.chomp)\n\tend\nend", "def contract_urls\n Scrapers::ContractUrlExtractor.new(report.url).urls\n end", "def get_urls(proxy=nil)\n query = SETTINGS.extract_query!\n payloads = SETTINGS.create_payloads(PAYLOAD_TEMPLATE_PATH)\n File.read(\"#{QUERY_BLACKLIST_PATH}\").each_line do |black| # check if the search query is black listed\n if query == black\n FORMAT.warning(\"Query: #{query} is blacklisted, defaulting to random query\")\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample # Retry if it is\n end\n end\n\n FORMAT.info(\"I'm searching for possible SQL vulnerable sites, using search query #{query.chomp}\")\n agent = Mechanize.new\n if proxy\n agent.set_proxy(proxy.split(\":\").first, proxy.split(\":\").last) # Set your proxy if used\n end\n correct_agent = SETTINGS.random_agent?\n agent.user_agent = correct_agent\n\n correct_agent == DEFAULT_USER_AGENT ? FORMAT.info(\"Using default user agent\") :\n FORMAT.info(\"Grabbed random agent from #{RAND_AGENT_PATH}\")\n\n google_page = agent.get(\"http://google.com\")\n google_form = google_page.form('f')\n\n FORMAT.info(\"Verifying search query...\")\n unless SETTINGS.test_query(query, correct_agent, proxy)\n query = File.readlines(\"#{PATH}/lib/lists/search_query.txt\").sample\n LOGGER.info(\"Query changed to: #{query}\")\n end\n\n google_form.q = \"#{query}\" # Search Google for the query\n url = agent.submit(google_form, google_form.buttons.first)\n\n url.links.each do |link|\n if link.href.to_s =~ /url.q/ # Pull the links from the search\n str = link.href.to_s\n str_list = str.split(%r{=|&})\n urls = str_list[1]\n if urls.split(\"/\")[2].start_with?(*SKIP) # Skip all the bad URLs\n next\n end\n urls_to_log = URI.decode(urls)\n FORMAT.success(\"Site found: #{urls_to_log}\")\n sleep(0.3)\n payloads.each { |payload|\n File.open(\"#{SITES_TO_CHECK_PATH}\", \"a+\") { |to_check| to_check.puts(\"#{urls_to_log}#{payload}\")}\n }\n end\n end\n FORMAT.info(\"I've dumped possible vulnerable sites into #{SITES_TO_CHECK_PATH}\")\n end", "def fetch_movie_urls\n url = \"https://www.imdb.com/chart/top\"\n doc = Nokogiri::HTML(open(url).read)\n movies = doc.search(\".titleColumn a\")[0...5]\n movies.map do |movie_link|\n end_url = movie_link.attribute(\"href\").value\n \"http://www.imdb.com#{end_url}\"\n\n end\n\nend", "def sitemap_urls\n each_sitemap_url.to_a\n end", "def extract_video_page_urls(webpage,options)\r\n puts \"Extracting data from html5 data\"\r\n webpage.css('li.regularitem').each do |post|\r\n link = post.css('h4.itemtitle').css('a').first\r\n description = post.css('div.itemcontent').first.text\r\n download_episode(link.child.text,link['href'],description, options)\r\n end\r\nend", "def get_paginated_urls(doc)\n doc.xpath(\"//div[@class='k2Pagination initialPagination']\").first.content =~ /\\d+ of (\\d+)/\n last_page_number = $1.to_i\n (1..last_page_number).map do |n|\n \"https://www.strayrescue.org/animals-for-adoption/page-#{n}\"\n end\n end", "def get_urls()\n generate_thread(@@source_url)\n end", "def python_hard_way_urls\n urls = ['http://learnpythonthehardway.org/book/intro.html']\n (0..52).each do |val|\n urls << 'http://learnpythonthehardway.org/book/ex' + val.to_s + '.html'\n end\n urls << 'http://learnpythonthehardway.org/book/next.html'\n urls << 'http://learnpythonthehardway.org/book/advice.html'\n urls\nend", "def city_list(url)\n\troot = Nokogiri::HTML(open(url))\n list = root.css(\"a\").map do |link|\n\n\t\t# This makes sure that we only store actual links, then stores the text & link for each valid link in an array.\n\n if link[:href] =~ /http/ \n [link.text, link[:href]] \n end \n end\n\n\t# This cleans up the array and gets rid of nil elements\n\n\tlist = list.reject {|x| x.nil?} \n\t\t\n\t## Here we have various sections of CL that we can search in for various gigs. \n\t## If you wanted to see more software development stuff, you may search in /sof and /eng\n\t\n\t\t\n\t# list.map! {|f,l| [f, l + \"/cpg/\"]}\n\t# list.map! {|f,l| [f, l + \"/web/\"]}\n\tlist.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\"]}\t\n\t# list.map! {|f,l| [f, l + \"/web/\", l + \"/cpg/\", l + \"/eng/\", l + \"/sof/\", l + \"/sad/\"]}\n\t\nend", "def scrape_pages(url)\n\n pages = []\n\n agent = Mechanize.new do |agent|\n agent.user_agent_alias = \"Windows Chrome\"\n\n pages << agent.get(url)\n sleep(0.5)\n pages << pages.last.link_with(id: 'nextWeek').click\n sleep(0.5)\n pages << pages.last.link_with(id: 'nextWeek').click\n sleep(0.5)\n pages << pages.last.link_with(id: 'nextWeek').click\n sleep(0.5)\n pages << pages.last.link_with(id: 'nextWeek').click\n end\n\n pages\n end", "def google_sitemap\n\t\t@urls = []\n\t\t# 1. 305 - Redirected back to the reverse proxy to show old site page.\n\t\tREDIRECTIONS.select {|k,v| v[:action] == 305}.each {|r| @urls.push(r[0])}\n\t\t# 2. All Homepage's (including mainpage)\n\t\tSection.environments().each do |section|\n\t\t\thome = section_homepage_url(section)\n\t\t\t@urls << home if home\n\t\tend\n\t\t# 3. All Pages\n\t\tAsset.find_all_by_resource_type('Page').select {|p| p.published_page?}.each {|p| @urls << site_page_url(p)}\n\n respond_to do |format|\n format.xml\n end\n\tend", "def urls\n (url.split(\",\") rescue []) + [cran_url]\n end" ]
[ "0.75841486", "0.75577265", "0.75274456", "0.74938786", "0.74938786", "0.73440087", "0.731884", "0.7153854", "0.7124843", "0.711707", "0.7111645", "0.7109259", "0.7074819", "0.7040674", "0.6990799", "0.6988434", "0.69736946", "0.69699204", "0.69004107", "0.6876272", "0.6850029", "0.6848129", "0.684432", "0.6836566", "0.6798951", "0.6793837", "0.67877835", "0.67389625", "0.6711877", "0.6672705", "0.6672705", "0.66677415", "0.6657644", "0.6653104", "0.66486555", "0.6643472", "0.6631555", "0.66314936", "0.66218126", "0.658409", "0.6575213", "0.6552531", "0.6550038", "0.6543777", "0.65346414", "0.65116674", "0.65062964", "0.6505162", "0.64925146", "0.6475741", "0.6469341", "0.6452369", "0.64513737", "0.64430165", "0.64426225", "0.6438199", "0.6426435", "0.6413407", "0.6409304", "0.63924533", "0.6390899", "0.6387426", "0.6369253", "0.6369171", "0.6364427", "0.6351103", "0.6347944", "0.6347824", "0.63347393", "0.6333065", "0.6333065", "0.63272077", "0.6320561", "0.6320561", "0.6318105", "0.6315689", "0.63110274", "0.63048077", "0.62898904", "0.6282912", "0.6281984", "0.6281984", "0.627575", "0.6272902", "0.62667537", "0.6264426", "0.62463415", "0.62397355", "0.62166035", "0.6216424", "0.62075377", "0.62001216", "0.61952597", "0.61813647", "0.61748946", "0.61465627", "0.6141611", "0.61394584", "0.61338884", "0.6126621", "0.6125569" ]
0.0
-1
scrappe tous les noms de villes du val d'oise
def get_townhall_names url_générale = Nokogiri::HTML(open("http://annuaire-des-mairies.com/val-d-oise.html")) names_mairies_array = [] names_mairies = url_générale.xpath('//p/a') names_mairies.each do |urls| names = urls.text names_mairies_array << names end return names_mairies_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def veichles\n ['Bil', 'Moped', 'Motorsykkel', 'Tungt kjøretøy', 'ATV', 'Buss', 'Sykkel']\n end", "def names\n [\n \"Charge de travail\" , #00\n \"Travail en groupe\" , #01\n \"Maths\" , #02\n \"Codage\" , #03\n \"Théorique\" , #04\n \"Technique\" , #05\n \"Satisfaction\" , #06\n \"Dur à valider\" , #07\n \"Fun\" , #08\n \"Pipo\" , #09\n \"Économie\" , #10\n \"fondamental\" , #11\n \"Difficile à suivre\" , #12\n \"Calcul\" , #13\n \"Professionalisant\" , #14\n \"Étendue du cours\" , #15\n \"Interactivité\" , #16\n \"Culture générale\" , #17\n ]\n end", "def nom_ville\n\tnom = []\n\tjson_to_ruby.each do |i| \n\t nom.push(i['name'])\n \tend\n \tnom\nend", "def devolver_nombre \n return @nombre\n end", "def ausgabe\n\t\t@name\n\tend", "def ausgabe\n\t\t@name\n\t\n\tend", "def sigla; @nome; end", "def hide_name\n str = \" utente Fiscosport n° \" + self.id.to_s\n if self.comune_id && self.comune\n str += \" - prov. di \" + self.comune.province.name + \" (\" + self.comune.province.sigla + \")\" unless self.comune.province.nil?\n end\n return (str.nil? || str.blank?) ? \"-\" : str\n end", "def to_s\n name_value.titleize\n end", "def name ; self[:name].downcase end", "def country_str(specimens)\r\n v = {} \r\n v[\"country not specified\"] = []\r\n specimens.each do |s|\r\n if !s.ce.blank? && !s.ce.geog.blank? && !s.ce.geog.country.blank? && !s.ce.geog.country.name.blank?\r\n if v[s.ce.geog.country.name].nil?\r\n v[s.ce.geog.country.name] = [s]\r\n else\r\n v[s.ce.geog.country.name] << s\r\n end\r\n else\r\n v[\"country not specified\"] << s\r\n end\r\n end\r\n v.delete(\"country not specified\") if v[\"country not specified\"].size == 0 \r\n is = []\r\n v.keys.sort.each do |c|\r\n txt = \"#{c.upcase}: \"\r\n txt << sex_str(v[c])\r\n txt += \". \"\r\n txt += inst_str(v[c]) + \".\"\r\n is << txt\r\n end\r\n is.join(\" \") \r\n end", "def to_s\n \"#{value}#{land[0,1].upcase}\"\n end", "def labels\n super.map{ |i| i.to_s.upcase } unless super.nil?\n end", "def slogan\n # 'A maneira mais fácil de pré-qualificar ao Atlas.'\n ''\n end", "def vet_name\n self.veterinarian.name\n end", "def french_name\n self[4]\n end", "def french_name\n self[4]\n end", "def get_nombre; @nombre; end", "def namekomplett\n\t\t\t\t vorname.capitalize + \" \" + nachname.capitalize # methode vor und nachname mit leerzeichen\n\t\t\t\tend", "def name\n value\n end", "def nombre=(val)\n self[:nombre] = val.squish if val\n end", "def species\r\n villagers.map{ |villager| villager.species}\r\n end", "def vialidad_condicion_w\n if self.vialidad_condicion == 'E'\n return 'Excelente'\n elsif self.vialidad_condicion == 'B'\n return 'Bueno'\n elsif self.vialidad_condicion == 'R'\n return 'Regular'\n elsif self.vialidad_condicion == 'M'\n return 'Malo'\n end\n end", "def varietal_name\n if varietal.nil? || varietal.name.nil?\n return nil\n else\n varietal.name\n end\n end", "def name\n self.estado.upcase\n end", "def nome_proprio\n palavras = []\n self.titleize().each do |palavra|\n palavra =~ /^(.)(.*)$/\n palavras << \"#{$1.upcase_br}#{$2}\"\n end\n palavras.join(' ').gsub(/ D(a|e|o|as|os) /, ' d\\1 ').gsub(/ E /, ' e ')\n end", "def full_name\n \"#{type_etablissement.nom} #{nom}\"\n end", "def vypis_reseni\n\n vystup = \"(\"\n @reseni.each do |prvek|\n if(prvek)then\n vystup += \"1\"\n else\n vystup += \"0\"\n end \n end\n vystup += \")\"\n \n return vystup\n end", "def label\n namestr = @name == '' ? '' : \", #{@name}\"\n \"#{@province.name}#{namestr}\"\n end", "def name; nutrdesc; end", "def name\n \"#{self[:asn]} #{self[:vrf]} #{self[:neighbor]} #{self[:afi]} \" \\\n \"#{self[:safi]}\"\n end", "def all_names(values)\n values.each do |name|\n puts name[1]\n end\nend", "def generos\n (self.genero == 1) ? \"Masculino\" : \"Femenino\"\n end", "def get_vct\n \"#{@calorias} kcal\" \n end", "def display_name\n phylum_name\n end", "def to_s\n\t\t\t \"( Nombre:#{@nombre}, Conjunto Alimentos: #{@la} ,Conjunto Gramos: #{@lg} ,Proteinas :#{@proteinas},Carbo :#{@carbohidratos},Lipidos :#{@lipidos},VCT :#{@vct} )\"\n\n\t\tend", "def Nombre\n\t\treturn @name\n\tend", "def label\n nome\n end", "def gerund\n b = gerundive.sub( /.*\\s+(.*)um.*$/, \"\\\\1\" )\n b += \"ī, ō, etc.\"\n return b\n end", "def process_return_facets(values)\n map_values(values) do |value|\n Inflector.camelize(value, false)\n end\n end", "def other_name\n @other_name ||= select { |type,value| type == :other_name }.map do |(type,value)|\n value\n end\n end", "def two_word_name; end", "def each\n\t\t@nombre\n\tend", "def nome\n @nome \n end", "def nombres_comunes\n datos = eval(naturalista_info.decodifica64)\n datos = datos.first if datos.is_a?(Array)\n return [] unless datos['taxon_names'].present?\n nombres_comunes_faltan = []\n\n # Nombres comunes de la base de catalogos\n nom_comunes = especie.nombres_comunes\n nom_comunes = nom_comunes.map(&:nombre_comun).map{ |nom| I18n.transliterate(nom).downcase }.sort if nom_comunes\n\n datos['taxon_names'].each do |datos_nombres|\n next unless datos_nombres['is_valid']\n next if datos_nombres['lexicon'] == 'Scientific Names'\n\n # Nombre comun de NaturaLista\n nombre = I18n.transliterate(datos_nombres['name']).downcase\n lengua = datos_nombres['lexicon']\n\n if nom_comunes.present?\n next if nom_comunes.include?(nombre)\n end\n nombres_comunes_faltan << \"#{especie.catalogo_id},\\\"#{datos_nombres['name']}\\\",#{lengua},#{especie.nombre_cientifico},#{especie.categoria_taxonomica.nombre_categoria_taxonomica},http://naturalista.conabio.gob.mx/taxa/#{naturalista_id}\"\n end\n\n nombres_comunes_faltan\n end", "def unicode_names; end", "def to_s\r\n @nome\r\n end", "def name; termid;end", "def tipo_name\n if tipo == 1 \n 'Venta'\n elsif tipo == 2\n 'Compra'\n elsif tipo == 3\n 'Renta'\n elsif tipo == 4\n 'Servicios'\n elsif tipo == 5\n 'Ofresco Trabajo'\n elsif tipo == 6\n 'Busco Trabajo'\n end\n end", "def to_s() # :nodoc:\n mano_seleccionada = super.to_s # Hago un llamado al metodo to_s de mi padre que maneja\n # la impresion de la mano seleccionada\n if not @estrategias.nil?\n return \"Las estrategias suministradas son \" + @estrategias.to_s + \" \" + mano_seleccionada\n end\n return \"La lista de estrategias provista no es valida\"\n end", "def one_word_names(values)\n one_word_names = values.map {|names| names}\n one_word_names.delete_if{|names| names[1].include?\" \"}\n one_word_names.each {|info| puts info.to_s}\nend", "def human_to_name; end", "def to_label()\n \"[#{person.initials rescue '??' }] #{name.capitalize}\"\n end", "def populate_patient_name_details(patientinfo,value)\n if patientinfo\n if ((patientinfo.insured_last_name == \"SAME\") || (patientinfo.insured_first_name == \"SAME\"))\n val = \"patient_#{value}\"\n patientinfo.send(val)\n else\n val = \"insured_#{value}\"\n patientinfo.send(val)\n end\n end\n end", "def get_type_in_french\n type = ''\n if !self.achievement_type.nil?\n if self.achievement_type.downcase == 'weight'\n type = 'Poids'\n elsif self.achievement_type.downcase == 'time'\n type = 'Temps'\n elsif self.achievement_type.downcase == 'kilometer'\n type = 'Kilomètre'\n end\n else\n type = 'kilometer'\n end\n\n type\n end", "def species\n \"#{@species}\"\n end", "def name\n @n.to_s + characterization\n end", "def display_name\n titre\n end", "def secunia\n\t\t\t\t\twhere(:reference_name => \"secunia\").select('DISTINCT value')\n\t\t\t\tend", "def my_cults_slogans\n self.cults.map do |cult|\n cult.slogan\n end\n end", "def name_seo_display\n (self.name_seo[I18n.locale].present?) ? self.name_seo[I18n.locale].parameterize : \"-\"\n end", "def nombre\n m = []\n m << self.padre.nombre unless self.padre.blank?\n m << self.madre.nombre unless self.madre.blank?\n m = m.join('&')\n n = []\n n << self.padre.apepat unless self.padre.blank? \n n << self.madre.apepat unless self.madre.blank?\n n << \"(#{m})\"\n n.join(' ')\n end", "def name(val); @name = val.to_sym; end", "def name\n case @value\n when 0\n 'Joker'\n when 11\n \"Jack of #{@suit}\"\n when 12\n \"Queen of #{@suit}\"\n when 13\n \"King of #{@suit}\"\n when 14\n \"Ace of #{@suit}\"\n else\n \"#{@value.to_s} of #{@suit}\"\n\n end\n end", "def name; \"#{accidental.name}f\"; end", "def get_nombre()\n @nombre\n end", "def full_name\n \"#{(self.company.salutation_types.find_by_id(self.salutation_id).try(:alvalue)) unless self.salutation_id.blank?} #{(self.last_name + ', ') unless self.last_name.blank?} #{self.first_name} #{(self.middle_name) unless self.middle_name.blank?}\"\n end", "def all_deputies_full_names\n names = []\n\n @doc.css('span[class = list_nom]').each do |element|\n names << element.text.strip\n end\n\n names.map { |name| name.split(', ') }.flatten\nend", "def to_s\n #$\"#{nombre} #{pais}\"\n #%(#{nombre} #{pais})\n nombre\n end", "def spanish_name\n self[5]\n end", "def names; end", "def names; end", "def names; end", "def names; end", "def names; end", "def names; end", "def names; end", "def name_significance #adding an instance method\n parts = self.split( '-' )\n syllables = @@syllables.dup\n signif = parts.collect do |p|\n syllables.shift[p]\n end\n signif.join( ' ' )\n end", "def nome_perfil\n \tself.descricao\n end", "def to_s\n \treturn self.nome\n\tend", "def get_names\n\tval_d_oise = \"http://annuaire-des-mairies.com/val-d-oise.html\"\n\tpage = Nokogiri::HTML(URI.open(val_d_oise))\n\tnames = page.xpath('//*[@class=\"lientxt\"]').map{|element| element = element.text}\n\treturn names\nend", "def nome\n @nome\n end", "def display_name\n \"#{self.year} #{self.make} #{self.model}\" + (self.color.blank? ? \"\" : \", #{self.color}\") + \" (#{self.vin})\"\n end", "def to_s\n \"Nombre del plato: #{@nombre}\"\n end", "def ou_to_short(name)\n name = name.upcase\n\n case name\n when \"DSS IT SERVICE CENTER\", \"DSS IT SHARED SERVICE CENTER\"\n return \"IT\"\n when \"DSS HR/PAYROLL SERVICE CENTER\"\n return \"HR\"\n when \"CALIFORNIA HISTORY SS PROJECT\"\n return \"CHP\"\n when \"UC CENTER SACRAMENTO\"\n return \"UCCS\"\n when \"HEMISPHERIC INSTITUTE-AMERICAS\"\n return \"PHE\"\n when \"HISTORY PROJECT\", \"HISTORY PROJECT UCD\"\n return \"HP\"\n when \"SOCIAL SCIENCES PROGRAM\"\n return \"SSP\"\n when \"PHYSICAL EDUCATION PROGRAM\"\n return \"PHE\"\n when \"DSS RESEARCH SERVICE CENTER\"\n return \"RSC\"\n when \"GEOGRAPHY\"\n return \"GEO\"\n when \"ANTHROPOLOGY\"\n return \"ANT\"\n when \"COMMUNICATION\"\n return \"CMN\"\n when \"ECONOMICS\"\n return \"ECN\"\n when \"HISTORY\"\n return \"HIS\"\n when \"LINGUISTICS\"\n return \"LIN\"\n when \"MILITARY SCIENCE\"\n return \"MSC\"\n when \"PHILOSOPHY\"\n return \"PHI\"\n when \"POLITICAL SCIENCE\"\n return \"POL\"\n when \"PSYCHOLOGY\"\n return \"PSC\"\n when \"EASTERN ASIAN STUDIES\"\n return \"EAS\"\n when \"INTERNATIONAL RELATIONS\"\n return \"IRE\"\n when \"MIDDLE EAST/SOUTH ASIA STUDIES\", \"MIDDLE EAST/SOUTH ASIA PROGRAM\"\n return \"MSA\"\n when \"SCIENCE & TECHNOLOGY STUDIES\"\n return \"STS\"\n when \"CENTER FOR MIND AND BRAIN\", \"CENTER FOR MIND & BRAIN\"\n return \"CMB\"\n when \"SOCIOLOGY\"\n return \"SOC\"\n when \"COM, PHIL & LIN RED CLUSTER\"\n return \"RED\"\n when \"POLI SCI, IR ORANGE CLUSTER\", \"SOCIAL SCIENCE ORANGE CLUSTER\"\n return \"ORANGE\"\n when \"ECON, HIS, MS BLUE CLUSTER\", \"SOCIAL SCIENCES BLUE CLUSTER\"\n return \"BLUE\"\n when \"ANT, SOC GREEN CLUSTER\", \"SOCIAL SCIENCES GREEN CLUSTER\"\n return \"GREEN\"\n when \"L&S DEANS - SOCIAL SCIENCES\"\n return \"DEANS\"\n when \"PSYCH, CMB YELLOW CLUSTER\", \"SOCIAL SCIENCE YELLOW CLUSTER\"\n return \"YELLOW\"\n when \"EDUCATION - PH.D.\"\n return \"EDU\"\n when \"COMMUNITY DEVELOPMENT\"\n return \"ComDev\"\n when \"NEUROSCIENCE\", \"CENTER FOR NEUROSCIENCE\"\n return \"NueroSci\"\n when \"CENTER FOR INNOVATION STUDIES\"\n return \"CSIS\"\n when \"ASUCD\", \"UC DAVIS\", \"ASIAN AMERICAN\", \"UNIVERSITY EXTENSION\", \"CHEDDAR\", \"STUDENT EMPLOYMENT CENTER\",\n \"TEMPORARY EMPLOYMENT SERVICE\", \"CAMPUS RECREATION AND UNIONS\", \"CRESS DEPARTMENT\", \"LIBRARY\", \"POLICE\",\n \"COMPARATIVE LITERATURE\", \"PRIMATE CENTER\", \"L&S DEANS - U/G ED & ADVISING\", \"STATISTICS\",\n \"AGR & ENV SCI DEANS OFFICE\", \"OFFICE OF THE CHANCELLOR\", \"UNDERGRADUATE ADMISSIONS\",\n \"UNIVERSITY WRITING PROGRAM\", \"TEXTILES & CLOTHING\", \"STUDENT HOUSING\", \"ENGLISH\", \"ANIMAL SCIENCE\",\n \"IRB ADMINISTRATION\", \"SCHOOL OF LAW-DEANS OFFICE\", \"STUDENT ACADEMIC SUCCESS CTR\", \"GERMAN & RUSSIAN\",\n \"INTERCOLLEGIATE ATHLETICS\", \"HUMAN ECOLOGY\", \"GRADUATE DIVISION\", \"MED: NEUROLOGY\",\n \"ENVIRONMENTAL TOXICOLOGY\", \"SCHOOL OF MED - STAFF\", \"L&S DEANS - DEVELOPMENT\",\n \"TEMPORARY EMPLOYMENT POOL ADMN\", \"SCHOOL OF MED - APS\", \"MED: GENERAL PEDIATRICS\",\n \"MED:PSYCHIATRY & BEHAV SCI\", \"NATIVE AMERICAN STUDIES\", \"ART\", \"VP UNDERGRADUATE EDUCATION\", \"GEOLOGY\",\n \"VM: CTR COMPARATIVE MEDICINE\", \"ENGR COMPUTER SCIENCE\", \"MED: DIV OF INTERNAL MED\",\n \"FM: CUSTODIAL SERVICES\", \"VOORHIES ADMINISTRATIVE UNIT\", \"MED: OPHTHALMOLOGY\", \"MED: PUBLIC HEALTH SCIENCES\",\n \"NEURO PHYSIO & BEHAVIOR\", \"INST OF TRANSPORTATION STUDIES\", \"ENVIRONMENTAL HEALTH & SAFETY\",\n \"MEDIEVAL STUDIES\", \"EDUCATION\", \"ACADEMIC AFFAIRS\", \"ANR SUSTAINABLE AG PROG\"\n return nil\n else\n Rails.logger.warn \"AD Sync: Missing OU for translation to container name: #{name}\"\n ActivityLog.err!(\"Could not translate unknown organization to AD group equivalent: #{name}\", ['active_directory'])\n end\n\n return false\nend", "def notifier_salutation_and_title_and_last_name\n result = []\n result << (self.female? ? \"Sehr geehrte\" : \"Sehr geehrter\")\n result << self.salutation_and_title_and_last_name\n result.compact.map {|m| m.to_s.strip}.reject {|i| i.blank?}.join(' ')\n end", "def species\n return \"human\"\n end", "def rolf_desc\n name_descriptions(:peltigera_alt_desc)\n end", "def show_name_state\n @estados = Estado.order(:sigla)\n end", "def getName\n @value + \":\" + @suit + \" \"\n end", "def name\n case\n when current_language == :fr && french_name?\n read_attribute(:name_fr)\n\n when current_language == :fr && english_name?\n read_attribute(:name)\n\n when current_language != :fr && english_name?\n read_attribute(:name)\n\n when current_language != :fr && french_name?\n read_attribute(:name_fr)\n\n else\n ''\n end\n end", "def to_s\n \t\t\t\"(Nombre:#{@nombre},Proteinas:#{@proteinas},Carbohidratos:#{@carbohidratos},Lipidos:#{@Lipidos},Gei:#{@gei},Terreno:#{@terreno})\"\n \t\t\n\t\tend", "def all_names; end", "def all_names; end", "def genres\n search_by_text('жанры').split(', ')\n end", "def value\n nsdname.to_s\n end", "def titulares_serial\n Representante.find(self.titular_ids_serial).map(&:nombre)\n end", "def name\n \"#{self[:asn]} #{self[:vrf]} #{self[:afi]} #{self[:safi]} #{self[:aa]}\"\n end", "def retorna_nome_primeiro_produto\n nome_primeiro_produto.greenify\n nome_primeiro_produto.text\n end", "def names\n collect { |n, v|\n n\n }\n end", "def view_label(value)\n value.tr(\"-\", \" \").capitalize\n end" ]
[ "0.6302191", "0.61695415", "0.61365914", "0.5993862", "0.5949413", "0.59219325", "0.5921589", "0.58743227", "0.58566976", "0.57994145", "0.5736827", "0.5700763", "0.5653994", "0.5649113", "0.56256217", "0.561919", "0.561919", "0.5558732", "0.5555831", "0.55493015", "0.55459976", "0.553681", "0.55332184", "0.55316544", "0.5519916", "0.5510122", "0.5507323", "0.54845655", "0.54839396", "0.5466616", "0.5459117", "0.5445035", "0.5437149", "0.5437106", "0.5434778", "0.5429722", "0.54245746", "0.541892", "0.5418853", "0.54140127", "0.5411385", "0.5409533", "0.54008687", "0.53962034", "0.5390611", "0.5387797", "0.5376282", "0.53757906", "0.5373074", "0.5367749", "0.53644043", "0.53589714", "0.535645", "0.53546035", "0.53540516", "0.5352731", "0.5350147", "0.5342295", "0.5330407", "0.53297764", "0.53270376", "0.532148", "0.53151923", "0.5308727", "0.53032523", "0.5299659", "0.52990645", "0.52985966", "0.529699", "0.52913344", "0.52867347", "0.52867347", "0.52867347", "0.52867347", "0.52867347", "0.52867347", "0.52867347", "0.5286548", "0.52816594", "0.5279914", "0.5278278", "0.5278145", "0.52752984", "0.5267855", "0.52675605", "0.52664804", "0.52624047", "0.5261707", "0.52561414", "0.52560985", "0.52516204", "0.5250701", "0.5246454", "0.5246454", "0.5244144", "0.5243989", "0.52434045", "0.52423394", "0.5241224", "0.5237147", "0.523504" ]
0.0
-1
fusionne les deux arrays en un array de hashs au format (ville => email mairie)
def perform final_array = [] names = get_townhall_names email = get_townhall_email final_hash = Hash[names.zip(email)] save_as_json(final_hash) save_as_spreadsheet(final_hash) save_as_csv(final_hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_fusion\r\n results = Hash[*@citys_list.zip(@citys_mail).flatten]\r\n print results.each_slice(1).map(&:to_h)\r\n \r\nend", "def final_array_def (emails,names)\n\tfinal_array = []\n\temails.length.times do |i|\n\thash = {}\n\thash[names[i]] = emails[i]\n\tfinal_array << hash\n\tend\n\treturn final_array\nend", "def build_hash(emails, first_names, last_names)\n deputies_array = []\n\n emails.each_with_index do |email, index|\n deputy_hash = {}\n deputy_hash['first_name'] = first_names[index]\n deputy_hash['last_name'] = last_names[index]\n deputy_hash['email'] = email\n deputies_array << deputy_hash\n end\n\n deputies_array\nend", "def get_townhall_email(townhalls_urls_and_cities)\n\n return nil if townhalls_urls_and_cities.nil? || townhalls_urls_and_cities.empty?\n # return nil if list_townhall_urls.nil? || list_townhall_urls.empty? || list_cities.empty? || list_cities.nil?\n\n # Pour une meilleur compréhension\n list_townhall_urls = townhalls_urls_and_cities[0]\n list_cities = townhalls_urls_and_cities[1]\n\n\n #2/Liste des emails--------------------je fais une recherche sur tout... qui contient du text et @ (email ;o)! ) \n list_townhall_email=Array.new\n\n list_townhall_email = list_townhall_urls.each{ |url_hall|\n\n # Lecture d'une page html url_hall (de la ville) pour chaque mairie\n Nokogiri::HTML(URI.open(url_hall)).xpath('//*[contains(text(), \"@\")]').text\n }\n \n # -=-=-=- Init d'un Array (tableau de hash, conformément au format demandé) -=-=-=-\n # -=-=-=- MISE EN FORME -=-=-=-\n townhall_and_email_tab = Array.new\n\n # for i in 0..cities.length-1 do \n (0..list_cities.length-1).each do | i |\n townhall_and_email_tab[i] = Hash.new\n townhall_and_email_tab[i][list_cities[i]] = list_townhall_email[i]\n end\n \n return townhall_and_email_tab\nend", "def names_mails\n mail_array = depute_mail\n names_array = names\n a = []\n\n names_array.each_with_index do |x, y|\n a << {x => (mail_array) [y]}\n end\n \n puts a\n return a\nend", "def get_email_list\n return get_townhall_list_and_url.map{|town, url| {town => get_townhall_email(url)}}\n end", "def create_hash\n \n \thash = Hash[get_thoses_fucking_name.zip(get_bitches_mail)]\n \t\n \thash.each do |key, mail|\n\n\tputs \":nom => #{key} ; :e-mail => #{mail}\"\n\t\n\tend\nend", "def create_hash_city_email\n emails_mairies = []\n villes = get_city\n url_villes = get_link\n townhall_emails = get_townhall_email(url_villes)\n @global_list = Hash.new\n @global_list = Hash[villes.zip(townhall_emails)]\n return @global_list\n end", "def get_townhalls_emails()\n\n annuaire_emails_val_doise = []\n get_townhall_urls('https://www.annuaire-des-mairies.com/val-d-oise.html').each do |link|\n annuaire_emails_val_doise << get_townhall_email(link)\n end\n \n annuaire_villes_val_doise = get_townhall_names('https://www.annuaire-des-mairies.com/val-d-oise.html')\n \n hash_annuaire = annuaire_villes_val_doise.zip(annuaire_emails_val_doise).to_h\n array_of_hashes = hash_annuaire.each_slice(1).map &:to_h \n return array_of_hashes\nend", "def name_and_email_val_doise\n\tresult = []\n\tlist_url = urls_of_val_doise_townhalls # city pages urls\n\tlist_url.each { |town_url| name, mail = emails_from_webpage(town_url); result.push({:name => name.to_s, :email => mail}) } # name & email from each city\n\tputs result; # un tableau avec le nom et le mail des mairies\nend", "def get_townhall_email(townhall_url)\r\n page = get_page(townhall_url)\r\n email = page.xpath('//*[contains(text(), \"@\")]').text\r\n town_name = page.xpath('//*[contains(text(), \"Adresse mairie de\")]').text.split #nom de ville\r\n email_array_one_hash = [{town_name[3] => email}] #nom\r\n return email_array_one_hash\r\nend", "def contacts_gmail_email(contacts)\n @hash_contactos = Hash.new\n \t\t@contact_email = []\n contacts.each {|lista|\n lista.each {|key,value|\n if (key == :email)\n @contact_email << value\n end\n }\n }\n return @contact_email\n\tend", "def afficeur\n @city_link.map do |element|\n villes = get_city_names(element)\n email = get_townhall_email(element)\n @result = []\n @result << {villes => email}\n end\n end", "def array_to_hash\n @final_array = []\n gender_and_date_formater.map do |element|\n final_array << {last_name: element[0], first_name: element[1], gender: element[2], birth_date: element[3], fav_color: element[4]}\n end\n @final_array\nend", "def get_townhall_email(townhall_url)\n\tpage = Nokogiri::HTML(open(townhall_url)) \n\temail_array = []\n\n\temail = page.xpath('//*[contains(text(), \"@\")]').text\n town = page.xpath('//*[contains(text(), \"Adresse mairie de\")]').text.split \n# On divise la string pour pouvoir récupérer uniquement le nom de la ville\n\n email_array << {town[3] => email} \n# On indique la position du nom de la ville dans la string pour la récupérer\n\tputs email_array\n\treturn email_array\nend", "def emails_to_hash(emails)\n {\n :primary => emails.find { |email| email.primary }.email,\n :additional => emails.select { |email| !email.primary && email.verified}.map { |email| email.email }\n }\nend", "def townhall_and_email(html)\n \n contact = get_townhall_city(html).zip(get_townhall_email(html)).map{ |x| [x].to_h}\n puts contact\n\n end", "def get_email (ville_names)\n\n # Loop on each cities in the array to get the email\n for n in 0...ville_names.length\n\n # get each link to the depute\n page_url_ville = \"https://www.annuaire-des-mairies.com/95/#{ville_names[n]}.html\"\n\n ville_page = Nokogiri::HTML(open(page_url_ville))\n\n # If any bug when trying to get any email\n begin\n\n # Put each email in an array \"ville_email_array\"\n @ville_email_array << ville_page.xpath(\"//html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]/text()\").to_s\n rescue => e\n\n @ville_email_array << \" \"\n end\n end\n\n # This value as to be returned.\n # If not this not show email in the json file for the function save_as_json\n return @ville_email_array\n end", "def perform\n mails = []\n #ne montre que les 20 premiers elements\n get_url[0..20].each {|url| mails << get_mail(url)}\n #supprime les doublons\n the_mails = mails.uniq\n names = get_name(\"https://www.nosdeputes.fr/deputes\")\n #creation du hash\n my_hash = Hash[names.zip(the_mails)]\n\n #pour voir le résultat sous forme de hash\n # puts my_hash\n\n #presentation plus claire\n my_hash.each {|key, value| puts \"L'email du député #{key} est '#{value}'\", \"\\n\"}\nend", "def initialize\n @ville = [] # Je vais me servir de ces array car ce sera bien plus simple pour la sauvegarde\n @email = [] \n end", "def captureurlmail #capture url des villes du 95\r\nurl2 = \"http://www.annuaire-des-mairies.com/val-d-oise.html\"\r\ndoc2 = Nokogiri::HTML(open(url2))\r\nadresse2 = doc2.css('.lientxt')\r\nnoms = []\r\nvilles = []\r\nemails = []\r\nadresse2.each do |link|\r\n\t#noms.push(url2 + (link['href'][1..-1]))\r\n\tp=\"http://www.annuaire-des-mairies.com\"\t\r\n\t#puts link['href'][1..-1]\r\n\tp+=link['href'][1..-1]\r\n\tnoms << p\r\n\tq=link['href'][1..-1]\r\n\tr=q.split('/')\r\n\ts=r[2]\r\n\tt=s.split('.')\t\t\r\n\tville=t[0]\r\n\tvilles << ville\t\r\nend\r\nnoms.each do |adresse|\r\n\tdoc3 = Nokogiri::HTML(open(adresse))\r\n\tadresse3 = doc3.css(\".txt-primary\")[3].text.split(\" \")[2]\r\n\tif ['@'].include?(adresse3) == true\r\n\t\temails << adresse3.to_s\r\n\telse\r\n\t\temails << nil\r\n\tend\r\n\t\r\nend\r\n\r\nHash[villes.zip(emails)].each do |ville,email|\r\n\tputs ville+\" => \"+email\r\n#my_hash=Hash[villes.zip(emails)]\r\n#return my_hash(ville_entree)\r\nend\r\nend", "def transform_array_with_map(array)\n # Avec la fonction map, on transforme le tableau appelé grâce au paramètre array.\n # Au début, le tableau renvoie ça : [#<Twitter::Tweet id=954654232795283457>, ...]\n # On applique le regex puis on s'assure que les emails soient renvoyés en tant que string.\n\n # La fonction map renvoie ça : [[email protected],nil,nil,[email protected],...]\n # Ensuite, on applique la fonction compact, qui élimine les valeurs nil du tableau.\n # Enfin, on élimine les potentiels doublons avec la fonction uniq.\n array.map do |tweet|\n result = \"#{tweet.text}\".match(/\\w+\\.?\\+?\\w+?@\\w+\\-?\\w+\\.\\w+/)\n result.to_s unless result == nil\n end.compact.uniq\nend", "def get_and_put_in_hash(page_url)\n names = get_the_name(page_url)\n emails = get_all_the_urls_of_val_doise_townhalls(page_url)\n taille = names.length\n indice = 0\n result = []\n while indice < taille\n mairie = Hash.new\n mairie[:name] = names[indice]\n mairie[:email] = emails[indice]\n indice += 1\n result << mairie\n end\n return result\nend", "def perform\n urls = get_townhall_urls(\"https://annuaire-des-mairies.com/val-d-oise.html\")\n puts array = get_townhall_email_city_name(urls)\n #puts getHash(name_array, mail_array)\n end", "def joinData(arr)\n return data = {\"rusr\" => arr[0][1..-1].split(\"!\")[0], \"raddress\" => arr[0].split(\"!\")[1], \"type\" => arr[1], \"where\" => arr[2][1..-1]}\n end", "def get_emails(emails,incidente)\n return ['[email protected]'] if RAILS_ENV.include?'development'\n area_id=incidente.funcionario.cargo.area_id\n cargo_ids=Cargo.find(:all,:select=>'id',:conditions=>{:area_id=>area_id,:recibe_mails_hechos=>true}).map(&:id)\n mails1=Usuario.activos.find(:all,:select=>'email',:conditions=>{:cargo_id=>cargo_ids}).map(&:email)\n mails2=case true\n when (!emails[:parametro].blank? and !emails[:direcciones].blank?)\n Parametro.destinatarios(emails[:parametro]).concat(emails[:direcciones]).uniq\n when !emails[:parametro].blank?\n Parametro.destinatarios(emails[:parametro])\n when !emails[:direcciones].blank?\n emails[:direcciones].uniq \n else\n [\"[email protected]\"]\n end\n mails1.concat(mails2).uniq\n end", "def hash_addresses(address_field)\n return nil unless address_field\n\n address_field.formatted.map do |address|\n address_obj = Mail::Address.new(address)\n {\n email: address_obj.address,\n name: address_obj.display_name,\n type: address_field.name.downcase\n }\n end\n end", "def email_map(emails)\n emails.each do |e|\n result = self.map[e]\n unless result.nil? || result.empty?\n return result\n end\n end\n nil\n end", "def get_all_email\r\n\turl_array = get_townhall_urls #définir une array équivalente au résultat de la méthode qui a permis de créer l'array\r\n\turl_array.each do |townhall_url| \r\n\t\tget_townhall_email(townhall_url) # pour chaque URL d'une ville du Val d'Oise, on associe l'adresse mail de la mairie via la méthode get_townhall_email\r\n\tend\r\nend", "def get_townhall_urls\n \tnames_arr = []\n \temails_arr = []\n \turls_arr = []\n \t\n\tpage = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n\tnames = page.xpath('//tr/td/p/a').each do |name|#Voici la liste du nom des villes\n\tnames_arr.push(name.text)\n\tputs names_arr \n end\n\t\t\n\turls = page.xpath('//a[contains(@href, \"95\")]/@href').each do |url|\n\turls_arr.push(url.value)\n\t\t\t \n\tend\n\n\turls_arr.each do |url|\n\tcom = \"http://annuaire-des-mairies.com/\"+url\n\temails_arr.push(get_townhall_email(com))#Voici la liste des emails pour chaque ville\n\t\t\t\n\tend\n\n\tmy_hash = names_arr.zip(emails_arr).to_h\n\treturn my_hash\n\n def file_json(my_hash)\n\tFile.open('./db/emails.json', \"w\") do |json|\n\tjson << my_hash.to_json\n \tend\n end\n\n\tdata = get_townhall_urls\n\tfile_json(data)\n\t\n#-----------------------------------------------------------------------------------------------------------------------\n\t\t\n def spreadsheet\n\tindex = 1\n\tsession GoogleDrive::Session.from_config(\"config.json\")\n\tws = session.spreadsheet_by_key(\"157NepG10EpvxtEhokrNWlma16BjTeD8bQDovwKxQlwY\").worksheets[0]\n\t@@my_hash.each_key do |key|\n\tws[index, 1]\t= key\n\tws[index, 2] = @@my_hash[key]\n\tindex += 1\n\t end\n\tws.save\n\tws.reload\n end\n def csv\n\t File.open(\"./db/email.csv\", \"w\") do |f|\n f << @@my_hash.map { |c| c.join(\",\")}.join(\"\\n\")\n end \n end\nend", "def nyc_pigeon_organizer_two(data)\n# MAP will return a changed value, EACH will return original\n\n # coerce each name as the key in the hash\n #access all names\n #names - ['']\n # unique list of names\n names = data.values[0].values.flatten.uniq\n\n # use name as key in hash - fill in with scaffold hash\n initial_structure = names.each_with_object ({}) do |name, hash|\n hash[name] = {color: [], gender: [], lives:[]}\n end\n\n names.each_with_object(initial_structure) do |pigeon, my_initial_structure|\n attributes = data.keys\n attributes.each do |attribute|\n data[attribute].each do |value, names|\n if names.include?(pigeon)\n my_initial_structure[pigeon][attribute] << value.to_s\n end\n end\n end\n end\n\n\nend", "def get_townhall_emails\n n = get_townhall_urls.count\n i = 0\n @emails = []\n while i <= 4\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com#{get_townhall_urls[i].to_s}\"))\n result = doc.xpath('//section[2]/div/table/tbody/tr[4]/td[2]').map do |node|\n @emails.push(node.text)\n end\n p @emails[i]\n i += 1\n end\n @result_scrap = Hash[@names_of_town.zip(@emails)]\n return @result_scrap\n end", "def combine_address_fields\n %w[to cc bcc].map do |field|\n hash_addresses(@mail[field])\n end\n end", "def get_array_final(name,value)\n\thash_final = Hash[name.zip(value.map)]\n\treturn hash_final\nend", "def create_arr_hashes(arr_arrays)\n\thash_keys = arr_arrays.shift.map { |key| key.to_sym }\n\tarr_index = 0\n\tarr_hashes = []\n\tarr_arrays.each do |student|\n\t\t\tstudent_hash = {}\n\t\t\tstudent.each do |value|\n\t\t\t\tstudent_hash[hash_keys[arr_index]] = value\n\t\t\t\tarr_index += 1\n\t\t\t\tend\n\t\t\tstudent_hash[:cohort] = :March\n\t\t\tarr_hashes << student_hash\n\t\t\tarr_index = 0\n\t\t\tend\n\tarr_hashes\nend", "def get_townhall_mail(full_url, name, array_final)\n general_townhall = Nokogiri::HTML(open(full_url))\n townhall_mail = general_townhall.at('td:contains(\"@\")').text.strip\n array_final << {name => townhall_mail}\nend", "def arrays_to_hashes\n end", "def student_data_hash\n\n # turn data into 2 Dim array containing arrays of eles where delimiter is colon :\n clean_user_account_data = ruby_class_user_accounts.map { |x| x.split(/:/) }\n\n # turn data into a hash using 2 arrays for keys and values\n keys = %w[user_name password uid gid gcos_field home_directory login_shell]\n final_array_of_hashes = []\n\n clean_user_account_data.each do |account_data|\n hash = Hash.new\n keys.each_with_index { |item, index| hash[item] = account_data[index] }\n final_array_of_hashes << hash\n end\n final_array_of_hashes\n end", "def colour_association(array)\n array.map{|pair| Hash[pair.first, pair.last]}\nend", "def extract_user_emails(user_fields, client)\n user_emails = []\n user_fields.each_index do |row|\n user_emails.push(user_fields[row][0])\n end\n user_emails\nend", "def hash_maker(array)\n hash = {}\n array.each do |element|\n hash[element] = {:color => [], :gender => [], :lives => []}\n end\n hash\nend", "def lien_pret\n\n\tlien_pret=get_townhall_urls(oise_town_urls,ville)\n\tmail_pret=[]\n\tmyash=Hash.new\n\tt=0\n\tfor i in lien_pret\n\t\t\n\t\tu = \"\"\n\t\tbegin\n\t\t\tu = get_townhall_email(i)\n\n\t\trescue => e\n\n\t\t\tputs \"il y a erreur\"\n\n\t\tend\n\n\t\tif u !=\"\"\n\t\t\tprint \"#{get_townhall_email(i)} \"\n\n\t\t\tmyash.store(nom_pret[t],u)\n\t\t\toptions = { :address => \"smtp.gmail.com\",\n\t\t\t\t:port => 587,\n\t\t\t\t:user_name => '',\n\t\t\t\t:password => '',\n\t\t\t\t:authentication => 'plain',\n\t\t\t\t:enable_starttls_auto => true }\n\n\t\t\t\tMail.defaults do\n\t\t\t\t\tdelivery_method :smtp, options\n\t\t\t\tend\n\n\t\t\t\tMail.deliver do\n\t\t\t\t\tto '#{get_townhall_email(i)} '\n\t\t\t\t\tfrom 'jose'\n\t\t\t\t\tsubject 'Test programmation ruby'\n\t\t\t\t\tbody \"Bonjour,\nJe m'appelle [PRÉNOM] et je permets de contacter la mairie de [CITY_NAME] à propos du remarquable travail que font Les Restos du Coeur. Cette association répand le bien dans la France et aide les plus démunis à s'en tirer.\n\nAvez-vous pensé à travailler avec eux ? Soutenir Les Restos du Coeur, c'est important pour notre cohésion sociale : rejoignez le mouvement !\n\nMerci à vous\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tt=t+1\n\t #puts t\n\n\t\t#if t==10\n\t\t# \tbreak\n\t\t# end=end\n\t\t\n\tend\nend", "def email_addresses\n emails.map(&:address)\n end", "def marr2hash(mps)\n mps.map{|e|[e[0], e[1].to_h, e[2]]}\n end", "def merge_data(array1, array2)\n keys.collect do |name|\n name.merge(data[0][name[:first_name]])\n end\nend", "def collect_hashes(data, basis)\n language_list = data[basis]\n language_list\nend", "def townhall_email_array\n urls = townhalls_urls\n size = urls.size\n emails_array = []\n for i in (0..size-1) do\n emails_array << townhall_email(urls[i])\n end \n return emails_array\nend", "def transform_array_with_each_with_object(array)\n # Merci à Zaratan pour ce code. Vous noterez qu'il a modifié la façon\n # dont on exclue nil : (if email) = (unless email == nil ).\n\n # Avec la fonction each_with_object,\n # on crée un tableau en même temps qu'on itère sur l'objet.\n # le [] dans la parenthèse signifie qu'on crée un tableau vide.\n # Le second paramètre après le do : \"results\" est le nom donné au tableau.\n # On applique comme d'habitude le regex.\n # Et on l'enregistre dans le tableau \"results\" qu'on vient de nommer.\n # On applique .uniq pour supprimer les doublons dans le tableau.\n array.each_with_object([]) do |tweet, results|\n email = \"#{tweet.text}\".match(/\\w+\\.?\\+?\\w+?@\\w+\\-?\\w+\\.\\w+/)\n puts email\n results << email.to_s if email\n end.uniq\nend", "def hash\n [first_name, last_name, address_one, address_two, city, state, zip, phone, email, country_code].hash\n end", "def transform_array_with_each(array)\n # On crée un tableau avant de faire l'itération.\n # On itère sur le tableau. Notez qu'il s'appelle \"array\" étant donné que c'est le paramètre\n # de la fonction.\n # On détecte les emails grâce au regex.\n # On élimine les cases vides grâce à la condition (ici unless).\n # On intègre les résultats au tableau.\n # On retourne le tableau results désormais rempli.\n # Notez qu'il faut le retourner sinon la fonction\n # renvoie la variable tweets.\n\n results = []\n array.each do |tweet|\n email = \"#{tweet.text}\".match(/\\w+\\.?\\+?\\w+?@\\w+\\-?\\w+\\.\\w+/)\n results << email.to_s unless email == nil\n end\n results\nend", "def grapher(array)\n hash = Hash.new { |hash, key| hash[key] = [] }\n array.each do |pair|\n hash[pair[0]] ||= []\n hash[pair[0]] << pair[1]\n end\n hash\nend", "def parse \n \n list = @email_list.split.map {|email| email.split(\",\")}\n list.flatten.uniq\n ##list.uniq\n \n end", "def hash\n [id, type, state, country, street, postal_code, city, phone_country, phone_number, email, ip, address_description, identification_number, identification_type, lang, name, first_name, middle_name, last_name, birth_date, occupation, nationality, legal_entity_type, registration_date, registration_number, nature_of_business, source_of_funds, custom_source_of_funds, core_business_activity, purpose_of_opening_account, office_phone, vat_registration_number, financial_regulator, regulatory_licence_number, contact_person_email, trading_country, trading_address, trading_name, number_monthly_transactions, amount_monthly_transactions, documents, metadata, errors, onboarding_status, politically_exposed_people, external_id, city_of_birth, country_of_birth, gender, sales_lead_id, created_at, company_office_number, company_office_number_country, aml_officer_email, aml_officer_phone, aml_officer_phone_country, company_website_url, number_of_employees_in_company, list_of_countries_of_operation, estimated_annual_revenue_turnover, declaration].hash\n end", "def get_pigeons(data)\r\npigeon_list = {}\r\npigeons = []\r\n#here it gets all the pigeons as values, then flattens array and removes duplicates. Saves into array.\r\n data.each do |key, values|\r\n values.collect do |desc, pigeon|\r\n pigeons << pigeon\r\n pigeons = pigeons.flatten.uniq \r\n end \r\n end\r\n#iterates in new no duplicates pigeons array to add to new pigeon hash\r\n pigeons.each do |pigeon|\r\n pigeon_list[pigeon] = {} \r\n end\r\n pigeon_list\r\nend", "def nyc_pigeon_organizer(data)\n # write your code here!\n i = 0\n new_hash = {}\n #overall main hash\n description_key = {}\n #hash with symbols color, gender, and lives\n details_array = []\n # Array will include actual colors, which gender, and where they live\n data.each do |description, details|\n details.each do |details, names|\n names.each do |names, i|\n if !new_hash[names]\n new_hash[names] = {}\n end\n if !new_hash[names][description]\n new_hash[names][description] = []\n end\n new_hash[names][description] << details.to_s\n #binding.pry\n end\n end\n end\n new_hash\nend", "def get_email(dpt, url)\n mairies = []\n tab_link = get_all_the_urls_of_mairie(url)# appel de la methode pour les urls\n i = 0\n tab_link.each do \n |link|\n mairie = Nokogiri::HTML(open(link)).css('main h1')[0].text.split(\" \")[0] # On scrap le nom\n # On push le tout dans mairies\n mairies.push({\n :name => mairie,\n :email => get_the_email_of_a_townhal_from_its_webpage(link),\n :departement => dpt\n })\n \n puts mairies\n end\n puts \"#################################################################################################\"\n puts \" RESULTAT\"\n puts \"#################################################################################################\"\n mairies\nend", "def arr_to_hash\n questions_hash = {}\n @data.each do |q_or_a|\n questions_hash[q_or_a.first] = q_or_a.last\n end\n @data = questions_hash\n end", "def peer_array_to_hash(data)\n\t\t\tphash = {}\n\t\t\tpeer_keys.each_with_index{|k,i|\n\t\t\t\tphash[k] = data[i] || ''\n\t\t\t}\n\t\t\tphash[:peers] = phash[:peers].split(',')\n\t\t\tpeer_hash_defaults(phash)\n\t\tend", "def mapArrayToHash(rowarr, field_names)\n\ta = [] # an array of hashes\n\trowarr.each do |row|\n\t\thash = Hash.new\n\t\t0.upto(field_names.length-1) do |index|\n\t\t\t#puts \"#{index} #{field_names[index]} VALUE= #{row[index]} }\"\n\t\t\thash[field_names[index].downcase.to_sym] = row[index]\n\t\tend\n\t\ta << hash\n\tend\n\ta\nend", "def merge_data(keys, data)\n result = Array.new\n data.each do |original|\n # Below each is for each person\n original.each do |person_name, person_data|\n person_hash = Hash.new\n\n # Adding elements from the 'key' variable\n keys.each do |keys_arr|\n if keys_arr[:first_name] == person_name\n keys_arr.each do |attribute, value|\n person_hash[attribute] = value\n end\n end\n end\n\n # Adding elements from the 'data' variable\n person_data.each do |attribute, value|\n person_hash[attribute] = value\n end\n\n result.push(person_hash)\n end\n\n end\n result\nend", "def getEmailList\n\t\tdata = index()\n\t\temailList = []\n\t\tdata.each do |person|\n\t\t\temailList.push(\"#{person[\"email_address\"]}\")\n\t\tend\n\t\treturn emailList\n\tend", "def email_list\n @entries.collect do |line|\n name, email = line.split(\",\")\n format_email_address name, email.chomp\n end.join(\", \")\n end", "def get_all_the_urls_of_val_doise_townhalls\n \n #declare un hash vide \n @my_hash = Hash.new {}\n\n #on recupere tout le code de annuaire...\n val_doise = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n #tout les a des communes\n a_des_communes = val_doise.css(\"a\")\n a_des_communes.each do |a_d_une_commune|\n #tout les href des communes\n url_commune = a_d_une_commune['href']\n #on recup tout les url qui contiennent 95\n if rege = url_commune =~ (/95/)\n mairie_name = a_d_une_commune.text #on recup le texte \"nom de commune\"\n # ensuite on change le . par https://...com\n url_commune[0] = \"http://annuaire-des-mairies.com\"\n # et on envoie l'adresse dans la fonction pour recup l'adresse mail \n mairie_mail = get_the_email_of_a_townhal_from_its_webpage(url_commune) \n # et ensuite on rempli notre hash avec nom et mail\n @my_hash[mairie_name] = mairie_mail\n end\n end\n \n tempHash = {}\n #et on print proprement\n session = GoogleDrive::Session.from_config(\"./config.json\")\n\n ws = session.spreadsheet_by_key(\"1gpKzo_6gH78KdlhfEqrxS6xpgKLbnoBqoEVeV0W4tZQ\").worksheets[0]\n compteur = 1\n @my_hash.each do |key, val|\n\n ws[compteur, 1] = key\n ws[compteur, 2] = val\n compteur +=1\n puts \"Adresse mail de : #{key} - #{val}\"\n end\n ws.save\n # binding.pry\n end", "def hash\n [additional_contact_billing_id, additional_contact_billing_is_primary, additional_contact_billing_name, additional_contact_executive_sponsor_id, additional_contact_executive_sponsor_is_primary, additional_contact_executive_sponsor_name, additional_contact_hiring_manager_id, additional_contact_hiring_manager_is_primary, additional_contact_hiring_manager_name, additional_contact_internal_recruiter_id, additional_contact_internal_recruiter_is_primary, additional_contact_internal_recruiter_name, additional_contact_other_id, additional_contact_other_is_primary, additional_contact_other_name, attachments, created_by_id, created_by_name, created_on, expected_value, external_email_address, id, job_code, last_activity_date, last_engagement_date, modified_by_id, modified_by_name, modified_on, owners, status_id, status_name, time_to_close, actual_value, additional_contact_client_first_name, additional_contact_client_id, additional_contact_client_is_primary, additional_contact_client_last_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, bill_rate, bonus, commission, company_id, company_name, compensation, compensation_details, custom_field1, custom_field10, custom_field11, custom_field12, custom_field13, custom_field14, custom_field15, custom_field16, custom_field17, custom_field18, custom_field19, custom_field2, custom_field20, custom_field21, custom_field22, custom_field23, custom_field24, custom_field25, custom_field26, custom_field27, custom_field28, custom_field29, custom_field3, custom_field30, custom_field4, custom_field5, custom_field6, custom_field7, custom_field8, custom_field9, description, discount, estimated_close_date, external_primary_key, fee, fee_percent, hourly_rate, is_lead, is_on_hold, job_title_id, job_title_name, job_types, lead_source_id, lead_source_name, margin, name, number_of_openings, opportunity_type_id, opportunity_type_name, parent_job_id, parent_job_name, pay_rate, potential_value, priority_id, priority_name, probability, salary, start_date, tags, total_hours, website_description, website_description_is_primary, website_other, website_other_is_primary].hash\n end", "def list_students\n #code here \n # First redo hash to list last name first\n # and format into array to get only name and email values\n s = []\n @students.each do |stu|\n \tn = ''\n stu.each do |k,v| \n # *** instead of this process stu[:name] & stu[:email] ***\n #puts \"**key = #{k}, value = #{v}\"\n if (k == :name) #want every other value (only names not emails)\n \tn = v.split(' ')\n tmp = n[0]\n n[0] = n[1]\n n[1] = tmp\n n = n.join(\" \")\n else\n #puts \"pushing #{n}, #{v}\"\n \t#s.push({name: n, email: v})\n \ts.push(n + \", \" + v)\n\t end\n end\n end\n\n #@students.reverse.sort_by {|n| n[:name] } #this sorts by 1st name given the original hash array\n return s.sort\nend", "def hash\n [attachments, created_by_id, created_by_name, created_on, id, modified_by_id, modified_by_name, modified_on, name, owners, status_id, status_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_home_city, address_home_country, address_home_is_primary, address_home_line1, address_home_state, address_home_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, current_position_company_id, current_position_company_name, current_position_title, current_position_when_end, current_position_when_start, description, education_accreditation_id, education_accreditation_name, education_honors, education_institution_id, education_institution_name, education_when_end, education_when_start, email_address_other, email_address_other_is_primary, email_address_personal, email_address_personal_is_primary, email_address_work, email_address_work_is_primary, ethnicity_id, ethnicity_name, external_primary_key, first_name, gender_id, gender_name, key_date_anniversary, key_date_birthday, key_date_other, last_name, middle_name, nick_name, phone_number_fax, phone_number_fax_extension, phone_number_fax_is_primary, phone_number_home, phone_number_home_extension, phone_number_home_is_primary, phone_number_mobile, phone_number_mobile_extension, phone_number_mobile_is_primary, phone_number_other, phone_number_other_extension, phone_number_other_is_primary, phone_number_skype, phone_number_skype_extension, phone_number_skype_is_primary, phone_number_work_direct, phone_number_work_direct_extension, phone_number_work_direct_is_primary, phone_number_work_main, phone_number_work_main_extension, phone_number_work_main_is_primary, preferred_contact_method_type_id, preferred_contact_method_type_name, record_type, related_contact_assistant_first_name, related_contact_assistant_id, related_contact_assistant_is_primary, related_contact_assistant_last_name, related_contact_client_first_name, related_contact_client_id, related_contact_client_is_primary, related_contact_client_last_name, related_contact_other_first_name, related_contact_other_id, related_contact_other_is_primary, related_contact_other_last_name, related_contact_referred_by_first_name, related_contact_referred_by_id, related_contact_referred_by_is_primary, related_contact_referred_by_last_name, related_contact_spouse_first_name, related_contact_spouse_id, related_contact_spouse_is_primary, related_contact_spouse_last_name, salary, salary_details, salutation_id, salutation_name, social_aim, social_aim_is_primary, social_facebook_chat, social_facebook_chat_is_primary, social_face_time, social_face_time_is_primary, social_google_talk, social_google_talk_is_primary, social_icq, social_icq_is_primary, social_other, social_other_is_primary, social_skype, social_skype_is_primary, social_twitter, social_twitter_is_primary, social_yahoo_msg, social_yahoo_msg_is_primary, source_id, source_name, suffix_id, suffix_name, tags, website_blog, website_blog_is_primary, website_business, website_business_is_primary, website_facebook, website_facebook_is_primary, website_linked_in, website_linked_in_is_primary, website_other, website_other_is_primary, website_personal, website_personal_is_primary].hash\n end", "def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end", "def hash\n [actual_value, additional_contact_client_first_name, additional_contact_client_id, additional_contact_client_is_primary, additional_contact_client_last_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, bill_rate, bonus, commission, company_id, company_name, compensation, compensation_details, custom_field1, custom_field10, custom_field11, custom_field12, custom_field13, custom_field14, custom_field15, custom_field16, custom_field17, custom_field18, custom_field19, custom_field2, custom_field20, custom_field21, custom_field22, custom_field23, custom_field24, custom_field25, custom_field26, custom_field27, custom_field28, custom_field29, custom_field3, custom_field30, custom_field4, custom_field5, custom_field6, custom_field7, custom_field8, custom_field9, description, discount, estimated_close_date, external_primary_key, fee, fee_percent, hourly_rate, is_lead, is_on_hold, job_title_id, job_title_name, job_types, lead_source_id, lead_source_name, margin, name, number_of_openings, opportunity_type_id, opportunity_type_name, parent_job_id, parent_job_name, pay_rate, potential_value, priority_id, priority_name, probability, salary, start_date, tags, total_hours, website_description, website_description_is_primary, website_other, website_other_is_primary].hash\n end", "def hash\n [id, numero_estabelecimento, flag_matriz, id_grupo_economico, numero_receita_federal, nome, descricao, nome_fantasia, cep, nome_logradouro, numero_endereco, bairro, cidade, complemento, uf, cep2, nome_logradouro2, numero_endereco2, bairro2, cidade2, complemento2, uf2, obs, contato, email, flag_arquivo_secr_fazenda, flag_cartao_digitado, inativo, id_moeda, id_pais, associado_spc_brasil, mcc, id_tipo_estabelecimento, correspondencia, cargo_contato, tipo_pagamento, consulta, consulta2, consulta3, terminal, data_cadastramento, usuario].hash\n end", "def fs_contact_addresses_array\n pre_format = fscontact.blank? ? evaluator : fscontact\n return [] if pre_format.nil?\n\n pre_format.split(',').map do |a|\n (a =~ /@/ ) ? a : a + '@' + SCs[:standard_mail_domain]\n end\n end", "def staff\n [\n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\"\n ]\nend", "def staff\n [\n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\", \n \"[email protected]\"\n ]\nend", "def set_entourage_user_hashes\n User.find_each do |user|\n email_hashes[hash(user.email)] = user.id\n phone_hashes[hash(user.phone)] = user.id\n end\n end", "def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend", "def get_townhall_urls\n h = {}\n page = 'http://annuaire-des-mairies.com'\n doc = Nokogiri::HTML(open(page + '/val-d-oise.html'))\n doc.xpath('//a[@class=\"lientxt\"]').each do |node|\n h[node.text.capitalize.to_sym] = get_townhall_email(page +\n node.xpath('@href').text.gsub!(/^\\./, '').to_s)\n end\n return h\n end", "def nyc_pigeon_organizer(data)\n final_results = data.each_with_object({}) do |(key, value), final_array| \n # binding.pry\n value.each do |inner_key, names|\n names.each do |name|\n if !final_array[name]\n final_array[name] = {}\n end \n if !final_array[name][key]\n !final_array[name][key] = [] \n end \n final_array[name][key].push(inner_key.to_s)\n end\n end \nend \n # binding.pry \nend", "def hash\n [company_id, company_type, compnay_name, company_name_en, company_address, company_address_en, company_zip_code, company_tax_id, company_branch, company_branch_en, company_branch_code, company_phone, company_mobile, company_fax, company_website].hash\n end", "def team_names \n # team_array = []\n # game_hash.each do |location, team_data|\n # team_array << team_data[:team_name]\n # end\n # team_array\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def nyc_pigeon_organizer(data)\n #get all the variables you need \n #use pry to check \n #set up what will be taking in your values \n #then use conditionals \"if this is the case give it if not ignore it\"\n new_hash = {}\n data.each do |attribute,attribute_hash| \n attribute_hash.each do |key, array_names| \n #info = purple..,male...,subway...\n array_names.each do |name|\n #array_names = [\"Alex\", \"Theo\"]\n new_hash[name] ||= {} #returns true if you already have a value assigned\n #does this name exist for a particular attribute if so set up its array?\n### We've made the list of bird names with empty hashes\n###those hashes will contain keyvalue pairs of color gender and lives \n### now we need to update new hash at each name with their value pairs \n new_hash[name][attribute] ||= [] \n if array_names.include?(name)\n new_hash[name][attribute] << key.to_s\n \n end\n end\n end\n end\n return new_hash\nend", "def collect_countries(country_table)\n result = []\n chunked = []\n\n country_table.each_with_index do |v, i|\n if i.even?\n country_abbreviation = v.attributes['name'].value\n result << country_abbreviation\n else\n country_name = v.children.text\n country_link = v.attributes['href'].value\n result << country_name\n result << \"https://www.geonames.org#{country_link}\"\n end\n end\n#taking each set of three data points and associating them together\n while result.length > 3\n chunked << result.slice!(0,3)\n end\n chunked\nend", "def convert_email\n %w[[email protected] [email protected] [email protected] [email protected] [email protected]]\n end", "def combine_two_arrays_into_hashes(array_one, array_two)\n\tcombined_hash = {}\n\tcounter = 0\n\tarray_one.each do |array_item|\n\t\tcombined_hash[array_item] = array_two[counter]\n\t\tcounter = counter +\t1\n\tend\n\tcombined_hash\nend", "def scrap\n\t\tdef get_townhall_email(townhall_url)\n\t\t\tpage = Nokogiri::HTML(open(townhall_url))\n\t\t\temail = page.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]').text\n\n\t\t\tif email.size < 1\n\t\t\t\temail = \"nill\"\n\t\t\tend\n\t\t\treturn email\n\t\tend\n\n\t\tdef get_townhall_urls\n\t\t\ti = 0\n\t\t\tpage = Nokogiri::HTML(open('http://annuaire-des-mairies.com/val-d-oise.html'))\n\t\t\tarray_ville = []\n\t\t\tarray_mail = []\n\t\t\thachier = {}\n\t\t\tarray = []\n\t\t\tville = page.xpath('//a[@class=\"lientxt\"]')\n\n\t\t\tville.each do |a|\n\t\t \tarray_ville[i] = a['href'][1..-1]\n\t\t \tarray_mail = get_townhall_email(\"http://annuaire-des-mairies.com#{array_ville[i].downcase}\")\n\t\t \thachier = {}\n\t\t \thachier[a.text] = array_mail\n\t\t \tarray[i] = hachier\n\t\t \ti = i + 1\n\t\t \tputs hachier\n\t\t end\n\t\t return array\n\t\tend\n\t\treturn get_townhall_urls\n\tend", "def pic_team (array)\n teams = []\n array.each do |row|\n teams << row[:team]\n end\nteams.uniq\nend", "def array_to_hashes(table_array)\n # Skip rows of empty strings\n while true\n if table_array.size < 2\n return []\n end\n fieldnames = table_array.shift.map {|f| cleanup_field_name(f)}\n if fieldnames.any? {|x| x != \"\"}\n break\n end\n end\n fieldnames.size.times do |i|\n (i + 1 .. fieldnames.size).each do |j|\n # Replace any empty strings with prev non-empty field name followed by 2, 3, ...\n if fieldnames[j] != \"\"\n break\n end\n fieldnames[j] = \"#{fieldnames[i]} #{j - i + 1}\"\n end\n end\n table_array.map {|row| Hash[*fieldnames.zip(row).flatten]}\nend", "def get_townhall_email\n array1 = []\n get_townhall_urls.each do |i|\n url = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/#{i}\"))\n n = url.xpath('/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]')\n array1 << n.text.to_s\n end\n return array1\nend", "def nyc_pigeon_organizer(data)\n # write your code here!\n data.each_with_object({}) do |(key, value), final_array|\n value.each do |inner_key, names|\n names.each do |name|\n if !final_array[name]\n final_array[name] = {}\n end\n if !final_array[name][key]\n final_array[name][key] = []\n end\n final_array[name][key].push(inner_key.to_s)\n end\n end\nend \nend", "def compareAndExtractEmail\n a = amazonSnackList()\n b = nibbleSnackList()\n c = amazonSnackListEmail()\n\n e = a.zip(c)\n\n g = a & b\n\n arr = []\n i = 0\n while (i < e.length)\n if g[0] == e[i][0] then\n d = e[i]\n arr << d\n elsif g[1] == e[i][0] then\n d = e[i]\n arr << d\n end\n i = i + 1\n end\n r = 0\n while (r < arr.length)\n puts 'Product sold: ' + arr[r][0].to_s\n puts 'Contact of person selling it: ' + arr[r][1].to_s\n r = r + 1\n end \nend", "def hash\n [id_conta, id_pessoa, id_cartao, id_bandeira, id_tipo_cartao, numero_cartao, nome_plastico, cvv2, data_geracao, data_validade, cpf, tipo_portador, trilha1, trilha2, trilha_cvv1, trilha_cvv2, flag_virtual, nome_bandeira, flag_titular, sequencial_cartao, id_status, descricao_status_cartao, data_status, id_estagio, descricao_estagio, data_estagio, numero_bin, id_produto, descricao_produto, id_status_conta, descricao_status_conta, data_embossing, codigo_desbloqueio, nome_pessoa, tipo_pessoa, data_nascimento, id_endereco, id_tipo_endereco, descricao_tipo_endereco, cep, logradouro, numero_endereco, complemento_endereco, bairro, cidade, uf, pais, senha_criptografada, icvv, id_status_impressao].hash\n end", "def array_of_hashes_2_hash(arr)\n Hash[*arr.collect{|h| h.to_a}.flatten]\nend", "def merge_hasharray(array1, array2, commonfield)\n xref = {}\n array2.each { |hash| xref[hash[commonfield]] = hash }\n array1.each do |hash|\n next if xref[hash[commonfield]].empty?\n xref[hash[commonfield]].each_pair do |kk, vv|\n next if commonfield == kk\n hash[kk] = vv\n end\n end\nend", "def fill_hash(url)\n @url = url\n countries = Array.new\n populations = Array.new\n country_hash = {}\n\n doc = Nokogiri::HTML(open(@url))\n doc.css('table.wikitable tr:nth-child(2)~tr').each do |item|\n countries << item.at_css('td:nth-child(2) a:nth-child(2)')['title']\n populations << item.at_css('td:nth-child(3)').text\n end\n\n @countries = countries\n @populations = populations\n\n ([email protected] - 1).each do |index|\n country_hash[@countries[index]] = @populations[index]\n end\n return country_hash\nend", "def hashes email\n text_with_hashes = \"\"\n entries = Entry.select(:text).uniq.where(:email => email).where(\"text LIKE ?\", \"%#%\")\n entries.each do |e|\n text_with_hashes += \" \" + e.text\n end\n\n return text_with_hashes.split(' ').delete_if {|a| !a.match('^#\\w+$') }.sort.uniq\n end", "def scrap_data\n\turl_array = get_townhall_urls \n url_array.each do |townhall_url| \n# -> Pour chaque URL d'une ville du Val d'Oise, on associe l'adresse mail de la mairie\n\t\tget_townhall_email(townhall_url)\n\tend\nend", "def get_emails\n emails = [self.email1, self.email2, self.email3]\n emails.compact!\n emails.delete('')\n return emails\n end", "def organize_schools(schools)\n\n nyc = []\n sf = []\n chicago = []\n\n schools.each do |key, value|\n\n if value.values == [\"NYC\"]\n nyc << key\n elsif value.values == [\"SF\"]\n sf << key\n elsif value.values == [\"Chicago\"]\n chicago << key\n end\n\n end\n\n{\"NYC\" => nyc, \"SF\" => sf, \"Chicago\" => chicago}\nend", "def to_addresses\n emails = interest_addresses.concat(focus_addresses)\n if emails.empty?\n emails << '[email protected]'\n end\n emails.uniq\n end", "def to_array(data, legislators, filter = nil)\n array = []\n filters = filter ? filter.split(/\\s+/) : []\n \n sources = sort_by_ref(data.keys, source_keys)\n header = []\n header << 'Bioguide ID'\n sources.each do |source|\n sort_fields(data[source].keys, source).each do |column|\n header << (data[source][column][:header] ? data[source][column][:header] : column.to_s.titleize)\n end\n end\n \n array << header\n \n legislators.each do |legislator|\n row = []\n row_filters = filters.dup\n \n row << legislator.bioguide_id\n \n sources.each do |source|\n sort_fields(@data[source].keys, source).each do |column|\n cell = data[source][column][legislator.bioguide_id]\n if cell.is_a?(Hash)\n raw_data = cell[:data]\n searchable = cell[:searchable]\n else\n raw_data = cell\n searchable = nil\n end\n \n if row_filters and row_filters.any?\n row_filters.reject! {|f| (raw_data =~ /#{f}/i) || (searchable and searchable =~ /#{f}/i)}\n end\n \n row << raw_data\n end\n end\n \n array << row unless filter and row_filters.any?\n end\n \n array\n end", "def get_all_the_urls_townhalls\n doc = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/bouches-du-rhone.html\"))\n urlend = []\n tabname = []\n doc.css('.lientxt').each do |i| tabname << i.content end\n doc.css('a.lientxt @href').each do |i| urlend << i.content end\n i = 0\n while i < urlend.size\n urlend[i][0] = ''\n urlend[i] = get_the_email_of_a_townhal_from_its_webpage(\"http://annuaire-des-mairies.com#{urlend[i]}\")\n i += 1\n end\n return myhash = Hash[tabname.zip(urlend)]\n end", "def company_array(arr)\n companies_array = []\n arr.each {|comp| companies_array << comp }\n companies_array \nend", "def hash_for_search\n return addresses.each.inject([]) do |memo, a|\n memo.push({\n search_customer: \"#{last_name} #{first_name} #{primary_phone} #{a.format_for_search}\",\n label: \"#{last_name}, #{first_name} #{number_to_phone(primary_phone)} #{a.label}\",\n customer_id: id,\n address_id: a.id\n })\n end\n end" ]
[ "0.70264107", "0.70173794", "0.7000443", "0.69379234", "0.68922484", "0.6876014", "0.68097246", "0.6761626", "0.67136663", "0.66391397", "0.64845324", "0.6476739", "0.64660305", "0.6347685", "0.628613", "0.6281741", "0.6236079", "0.61879957", "0.6152429", "0.61379975", "0.6025951", "0.6000618", "0.5990624", "0.5979712", "0.59721744", "0.59703237", "0.5913255", "0.5909556", "0.5877522", "0.5849852", "0.58183295", "0.5816949", "0.58041203", "0.5763518", "0.57580143", "0.5742989", "0.5733388", "0.5698775", "0.56470513", "0.56386966", "0.5638056", "0.5635197", "0.56281364", "0.56154513", "0.5611793", "0.56093013", "0.55986106", "0.5565483", "0.55640554", "0.55452263", "0.5531692", "0.5525858", "0.55236965", "0.55137295", "0.55093753", "0.5485854", "0.545859", "0.54549354", "0.5454167", "0.5440455", "0.5439157", "0.54384303", "0.54336625", "0.5424868", "0.5408245", "0.5391749", "0.53873414", "0.5367566", "0.53591216", "0.53316003", "0.5324254", "0.5324254", "0.5320485", "0.5312928", "0.53112966", "0.5295395", "0.52891487", "0.52823174", "0.5281182", "0.52787656", "0.5274476", "0.52729857", "0.5267236", "0.5260933", "0.5253147", "0.52529985", "0.5250458", "0.52472216", "0.5237169", "0.5233849", "0.52188843", "0.52149034", "0.5207245", "0.5205237", "0.51958376", "0.5192377", "0.51801175", "0.51794523", "0.51790065", "0.51763165", "0.5176116" ]
0.0
-1
Recursively walk terms and parameters (leaf nodes)
def walkTerm(statement, sublevel, entity = nil, parentFunction = nil, argidx = nil) # Map subject and object when walkTerm is called non-recursively if entity == :subject element = "cause" unless statement.nestedStatement statement.currentobj = statement.obj.subject else statement.currentobj = statement.nestedStatement.subject end elsif entity == :object element = "theme" unless statement.nestedStatement statement.currentobj = statement.obj.object else statement.currentobj = statement.nestedStatement.object end end # Shorthand assignments obj = statement.currentobj document = statement.document passage = statement.passage debug = statement.debug includeBEL = statement.includeBEL unless statement.nestedStatement relation = statement.relation relationTriple = statement.relationTriple else relation = statement.nestedRelation relationTriple = statement.nestedrelationTriple end if !obj.nil? and !statement.obj.relationship.nil? if sublevel == 0 # Statements are relations unless they are unary unless !obj.instance_of?(BEL::Language::Statement) and statement.keeptogether and obj.arguments.length == 1 and obj.arguments[0].instance_of?(BEL::Language::Parameter) relationTriple[element].refid = "r" + String($relationId) else relationTriple[element].refid = "a" + String($annotationId) end if includeBEL # Substitute elements for relative original BEL string substitutionString = relation.infons["BEL (relative)"].sub String(obj), relationTriple[element].refid if entity == :object #strip remaining brackets substitutionString = substitutionString.tr('()','') end relation.infons["BEL (relative)"] = substitutionString end end # # Map terms # if obj.instance_of?(BEL::Language::Term) mapTerms(statement, sublevel, parentFunction, argidx) # # Map parameters # elsif obj.instance_of?(BEL::Language::Parameter) mapParameters(statement, parentFunction, argidx) # # Map statements # elsif obj.instance_of?(BEL::Language::Statement) statement.nestedStatement = obj statement.insideNestedStatement = true walkStatement(statement) end elsif statement.obj.relationship.nil? puts "Note: Skipping #{statement.obj}, single-term statements not (yet) supported." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursiveTreeTraversal(element)\n if StereotypesHelper.hasStereotype(element, $veStereotype)\n findRefinedParameters(element)\n end\n for child in element.getOwnedElement()\n recursiveTreeTraversal(child)\n end\nend", "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 traverse(root, ar)\n if root\n traverse(root.left, ar)\n traverse(root.right, ar)\n ar << root.val\n end \nend", "def traverse; end", "def traverse(tree, on_enter, on_exit = nil, on_leaf = nil)\n on_enter.call(tree) unless on_enter == nil\n tree.children.each do |child|\n if child.empty?\n on_leaf.call(child) unless on_leaf == nil\n else\n traverse(child, on_enter, on_exit, on_leaf)\n end\n end\n on_exit.call(tree) unless on_exit == nil\n end", "def recursive_search(path,current_depth)\n # If we haven't hit our max depth\n if current_depth < @depth \n sub_hash = @wiki\n # Follow our path down the hash\n path.each do |node|\n sub_hash = sub_hash[node]\n end\n\n # Expand this node of the sub-tree\n sub_hash.keys.each do |link|\n sub_hash[link] = get_links(\"http://en.wikipedia.org#{link}\")\n # Here's our magic recursion, add this node to the\n # path, increment our depth, and traverse that\n recursive_search(path+[link],current_depth+1)\n end\n\n end\nend", "def produce_tree(ary); 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 process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value == \"*\"\n node_kleene(node, this, nxt)\n elsif node.value == \"lambda\"\n leaf_lambda(node, this, nxt)\n else\n leaf_child(node, this, nxt)\n end\n end", "def iterate(itr)\n itr.call(@leaf)\n end", "def process_child_nodes(node); end", "def walk_tree(tree, depth = -1, &blk)\n return enum_for(:walk_tree) unless blk # ignore me for now, I'm a convention for being versatile\n \n # Perform the block action specified at top level!!!\n yield tree, depth unless depth == -1\n \n # next if we're a text node\n return if tree.type == :text\n \n # Enter into recursion (including block action) for each child node in this node\n tree.children.each do |node|\n walk_tree(node, depth + 1, &blk)\n end\n end", "def to_tree\n if term?\n [type, *args]\n else\n [type, *args.map(&:to_tree)]\n end\n end", "def recursive => nil", "def each_recursive(&block)\n tree.each_recursive(&block)\n end", "def each(&proc)\n @subtrees.each(&proc)\n end", "def each_leaf!\n raise \"Method not yet written.\"\n\n self.each do |leaf|\n yield(leaf)\n end\n end", "def 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 each_leaf#:yields: leaf\n leafs.compact!\n \n leafs.each do |leaf|\n yield leaf\n end\n end", "def recurse_otml_dirs(&block)\n return unless self.has_otmls\n yield(self)\n self.children.each do |child|\n child.recurse_otml_dirs(&block)\n end\nend", "def print_operators(node)\n return if node == nil\n print_operators(node.left) #starts recursion -- go left\n if node.value.match(/\\+|\\-|\\/|\\%|\\*/) #if operators included\n print node.value + \" \" #print value of this node\n end\n print_operators(node.right) #recursion -- go right\nend", "def visit_root(node)\n visit_rule_level(node.children)\n end", "def each_term(start_instr = nil) \n cur_expr = @parse_tree\n \n if start_instr\n cur_expr = start_instr\n end\n \n while true\n if cur_expr[:term]\n yield cur_expr[:term]\n end\n if cur_expr[:rhs]\n cur_expr = cur_expr[:rhs]\n else\n break\n end\n end\n end", "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 build_current_children_and_evaluate! opts={}\n these_asserts\n @current.clear\n if (@start_offset > final_offset) # see :note3\n @done = true\n evaluate_ok!\n return nil\n end\n @ok = nil\n @done = false\n @children_productions = production.children\n @ctxt = parse_context\n ([email protected]).each do |idx|\n @current.push idx\n break unless build_this_child_and_keep_going?(idx, opts)\n end\n @children_productions = nil\n @ctxt = nil\n evaluate_ok!\n nil\n end", "def parameters\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 31 )\n return_value = ParametersReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n __PARAMS259__ = nil\n parameter260 = nil\n\n tree_for_PARAMS259 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 215:5: ^( PARAMS ( parameter )* )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __PARAMS259__ = match( PARAMS, TOKENS_FOLLOWING_PARAMS_IN_parameters_1582 )\n\n tree_for_PARAMS259 = @adaptor.copy_node( __PARAMS259__ )\n\n root_1 = @adaptor.become_root( tree_for_PARAMS259, root_1 )\n\n\n\n if @input.peek == DOWN\n match( DOWN, nil )\n # at line 215:15: ( parameter )*\n while true # decision 35\n alt_35 = 2\n look_35_0 = @input.peek( 1 )\n\n if ( look_35_0 == ASGN || look_35_0 == SPLAT || look_35_0 == ID )\n alt_35 = 1\n\n end\n case alt_35\n when 1\n # at line 215:15: parameter\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_parameter_IN_parameters_1584 )\n parameter260 = parameter\n @state.following.pop\n\n @adaptor.add_child( root_1, parameter260.tree )\n\n\n else\n break # out of loop for decision 35\n end\n end # loop for decision 35\n\n match( UP, nil )\n end\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\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__, 31 )\n\n end\n \n return return_value\n end", "def traverse(person)\n loop = false\n queue = []\n queue << tree\n\n until loop || queue.size <= 0\n current = queue.pop()\n found = current.generation.compact.map(&:name).include?(person)\n\n if found\n loop = true\n return current unless block_given?\n\n yield(current)\n else\n children = current.children\n (children || []).each do |child|\n queue << child\n end\n end\n end\n end", "def get_children_recursion(node)\n\tif node.class == SOCIAL_NETWORK[0].class\n\t\tnode.children.each do |child|\n\t\t\tget_children_recursion(delegate_word(child))\n\t\tend\n\tend\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 walk(options = {}, &blk)\n retrieve_members unless @members\n @root_member.traverse(0, options, &blk)\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 evaluate(parsed_tree)\n left_child = parsed_tree.left_child\n right_child = parsed_tree.right_child\n\n if left_child && right_child\n return evaluate(left_child).send(parsed_tree.get_root_value, evaluate(right_child))\n else\n return parsed_tree.get_root_value\n end\nend", "def deep_each\n \n end", "def apply_deep_nesting(*args, &block)\n outputs = collect_outputs\n nested_stacks(:with_resource).each do |stack, resource|\n unless stack.nested_stacks.empty?\n stack.apply_deep_nesting(*args)\n end\n unless stack.root?\n stack.compile.parameters.keys!.each do |parameter_name|\n next if stack.compile.parameters.set!(parameter_name).stack_unique == true\n if !stack.parent.compile.parameters.data![parameter_name].nil?\n resource.properties.parameters.set!(parameter_name, resource.ref!(parameter_name))\n elsif output_name = output_matched?(parameter_name, outputs.keys)\n next if outputs[output_name] == stack\n stack_output = stack.make_output_available(output_name, outputs)\n resource.properties.parameters.set!(parameter_name, stack_output)\n end\n end\n end\n end\n if block_given?\n extract_templates(&block)\n end\n compile\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 each\n [@lval,@rval,@operator].each { |child| yield child }\n end", "def traverse(&block)\n\t\ttraverse(@current_node, &block)\n\tend", "def call(*args)\n left = root.call(*args)\n\n right = nodes.map { |node|\n response =\n if node.lazy?\n node.call(args.first, left)\n else\n node.call(left)\n end\n\n if node.one? && !node.graph?\n [response]\n else\n response\n end\n }\n\n if one?\n [[left], right]\n else\n [left, right]\n end\n end", "def traverse_tree(idea=self, depth=1, &blk)\n if idea.has_citations?\n blk.call(idea, depth)\n depth += 1\n idea.citations.each { |citation| traverse_tree(citation, depth, &blk) }\n else\n blk.call(idea, depth)\n end\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 traverse obj=self, &block\n case\n when obj.respond_to?(:parent?) && obj.respond_to?(:child?)\n block.call obj\n obj.children.each { |c| traverse(c, &block) }\n when obj.respond_to?(:parent?)\n obj.children.each { |c| traverse(c, &block) }\n when obj.respond_to?(:child?)\n block.call obj\n end\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 dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end", "def walk &blk\n self.children.each do |child|\n yield child\n end\n self.children.each do |child|\n child.walk &blk\n end\n end", "def xpath(*args); end", "def xpath(*args); 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 visit(params = {})\n @parameters.visit params\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 see_tree(tree)\n tree.each do |i|\n puts \"---------------\"\n puts \"Node: #{i.value}\"\n puts \"Parent: \" + i.find_parent[0].value.to_s if i.find_parent.count > 0\n puts \"Left Child: \" + i.find_left_child[0].value.to_s if i.find_left_child.count > 0\n puts \"Right Child: \" + i.find_right_child[0].value.to_s if i.find_right_child.count > 0\n end\nend", "def parsed_tree; end", "def walk(arg=true, &block)\n children do |child|\n if ch_arg = block.call(arg, child)\n child.walk(ch_arg, &block)\n end\n end\n end", "def recursive_terms(n)\n all_ns << n\n # if we get 1111\n # we have 1111 and should then get 211 and then 31 and then 4\n # then continue from 1111 to 121 then 13\n # then continue from 1111 to 112\n # to find these terms, find the \n next_ns = convert_n_to_next_terms(n)\n next_ns.each do |next_n|\n all_ns << recursive_terms(next_n)\n end\n return all_ns.flatten.uniq\nend", "def each\n return enum_for :each unless block_given?\n\n yield as_word if terminal?\n\n children_tree.each_value do |child|\n child.each do |word|\n yield word\n end\n end\n\n self\n end", "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 walk(node)\n return unless componentizable?(node)\n @component_xpaths.push(node.path)\n node.children.each { |c| walk(c) }\n end", "def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end", "def apply_deep_nesting(*args, &block)\n outputs = collect_outputs\n nested_stacks(:with_resource).each do |stack, resource|\n unless(stack.nested_stacks.empty?)\n stack.apply_deep_nesting(*args)\n end\n stack.compile.parameters.keys!.each do |parameter_name|\n if(output_name = output_matched?(parameter_name, outputs.keys))\n next if outputs[output_name] == stack\n stack_output = stack.make_output_available(output_name, outputs)\n resource.properties.parameters.set!(parameter_name, stack_output)\n end\n end\n end\n if(block_given?)\n extract_templates(&block)\n end\n compile.dump!\n end", "def operators(node)\n return if node == nil\n operators(node.left)\n if node.left != nil || node.right != nil\n print node.value + \" \"\n end\n operators(node.right)\nend", "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 preoder_tree_walk(x)\n unless x.nil?\n p x.key\n preoder_tree_walk(x.left)\n preoder_tree_walk(x.right)\n end\n end", "def each_tree(expand=false)\n each_pair(expand) do |key, value|\n next unless value.kind_of?(Tree)\n yield(key, value)\n end\n end", "def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end", "def recursive(*args)\n @scope.with_values += args\n @scope.recursive_value = true\n @scope\n end", "def apply_children\n \n end", "def findme(subtree)\n if subtree.class == Hash\n if subtree.keys.first.to_s == @name\n @subtree = subtree\n else\n subtree.values.first.each do |subelement|\n findme(subelement)\n end\n end\n end\n end", "def visit_nodes\n # Run a depth-first traversal of the graph with a worklist and a\n # visited set.\n\n worklist = [@start]\n visited = Set.new\n until worklist.empty?\n node = worklist.pop\n if visited.add?(node)\n yield node\n worklist.push *node.inputs.nodes\n worklist.push *node.outputs.nodes\n end\n end\n end", "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 transform_params(param_node, scope_stack)\n param_node = param_node[1] if param_node[0] == :paren\n if param_node\n positional_1, optional, rest, positional_2, block = param_node[1..5]\n add_variable_list(positional_1, scope_stack, false) if positional_1\n if optional\n optional.each do |var, value|\n # MUST walk value first. (def foo(y=y); end) == (def foo(y=y()); end)\n transform_tree(value, scope_stack)\n add_variables_from_node(var, scope_stack, false)\n end\n end\n if rest && rest[1]\n add_variables_from_node(rest, scope_stack, false)\n end\n add_variable_list(positional_2, scope_stack, false) if positional_2\n add_variables_from_node(block, scope_stack, false) if block\n end\n end", "def walk(fexp, tree)\n\n ftree = Ruote.compact_tree(@ps.current_tree(fexp))\n\n if ftree[0] != tree[0] || ftree[1] != tree[1]\n #\n # if there is anything different between the current tree and the\n # desired tree, let's force a re-apply\n\n register(MutationPoint.new(fexp.fei, tree, :re_apply))\n\n elsif ftree[2] == tree[2]\n #\n # else, if the tree children are the same, exit, there is nothing to do\n\n return\n\n else\n\n register(MutationPoint.new(fexp.fei, tree, :update))\n #\n # NOTE: maybe a switch for this mutation not to be added would\n # be necessary...\n\n if fexp.is_concurrent?\n #\n # concurrent expressions follow a different heuristic\n\n walk_concurrence(fexp, ftree, tree)\n\n else\n #\n # all other expressions are considered sequence-like\n\n walk_sequence(fexp, ftree, tree)\n end\n end\n end", "def visit_nodes(node)\n return if node.blank?\n if node.respond_to?(:each) # e.g. a list of nodes from a has_many association\n node.each { |n| visit_nodes(n) }\n else\n class_name = node.class.name\n @hash[class_name] ||= Set.new\n @hash[class_name] << visit(node)\n get_associations(node).each do |assoc|\n @logger.debug(\"Visiting #{assoc.name}\")\n new_nodes = node.send(assoc.name)\n next if new_nodes.blank?\n\n if new_nodes.respond_to?(:find_each)\n new_nodes.find_each { |n| visit_nodes(n) }\n else\n visit_nodes(new_nodes)\n end\n end\n\n end\n end", "def dfs_rec(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil \r\n return nil if tree.visited == true\r\n tree.visited = true\r\n return tree if tree.value == value\r\n puts \"current = #{tree}\" if verbose\r\n left = dfs_rec(tree.children[0], value, args)\r\n return left if left != nil\r\n right = dfs_rec(tree.children[1], value, args)\r\n return right # if right != nil\r\n end", "def traverse(&block); end", "def traverse(&block); end", "def dfs(root, result)\n return if root.nil?\n result << root.val if root.left.nil? && root.right.nil?\n dfs(root.left, result)\n dfs(root.right, result)\nend", "def visit_nodes(nodes, my_left, parent, depth, tree, url, restricted)\n nodes.each do |item|\n my_right = my_left + 1\n my_restricted = item['restricted'] || restricted\n urls = process_url(url, item)\n\n if item['children']\n my_right, tree = visit_nodes(item['children'], my_left + 1, item['id'], depth + 1, tree, urls[:children_path], my_restricted)\n end\n\n tree[item['id']] = TreeNode.new(my_left, my_right, parent, depth, urls[:my_urlname], my_restricted)\n my_left = my_right + 1\n end\n\n [my_left, tree]\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 walk; end", "def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend", "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 depth=(_arg0); 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 print_tree(d)\n \n print_tree(d['l']) if d.key?('l')\n print \"#{d['v']},\" if d.key?('v')\n print_tree(d['r']) if d.key?('r')\n \nend", "def autocomplete(curr_node, curr_path, word_list)\n if curr_node.is_word\n word_list << curr_path\n end\n\n # recursively visit each child in the node's children => all prefixed words\n curr_node.children.each_value { |child| \n autocomplete(child, curr_path + child.val, word_list)\n }\n end", "def display_tree() \n list = []\n yield @tree.value\n left_child = @tree.left_child\n right_child = @tree.right_child\n\n list << left_child if left_child != nil\n list << right_child if right_child != nil\n\n loop do\n break if list.empty?\n node = list.shift\n yield node.value\n list << node.left_child if node.left_child != nil\n list << node.right_child if node.right_child != nil\n end\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 nested_set_recurse(&block)\n self.each do |x| \n x.nested_set_recurse(self, &block)\n end\n end", "def tree\n while token = @tokens.next\n case token.type\n when :operator\n token.build(@nodes.pop, tree).tap do |node|\n @nodes.push(node)\n end\n when :value\n token.build.tap do |leaf|\n @nodes.push(leaf)\n end\n end\n end\n rescue StopIteration\n @nodes.last || Lexeme::Null.new\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 traverse_starter (node)\n return if node == nil\n traverse(node, 0)\n traverse_starter(node.left) if node.left\n traverse_starter(node.right) if node.right\nend", "def walk(node=nil, match = Match.create({}) { true })\n self[node].walk match # calls Changeset#walk\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 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 get_kids(obj)\n # if it's a hash, then there are more layers\n if(obj.class.to_s == \"Hash\")\n # drill down and keep getting kids\n obj.keys.map{|name| {:name=>name, :children=> get_kids(obj[name])}}\n else\n # Otherwise, we're at the edge. Just build an array of \"name\" hashes.\n obj.map{|name| {:name=>name}}\n end\nend", "def walk_node(code, &block)\n yield(self, code)\n @esquerda.walk_node(code + '0', &block) unless @esquerda.nil? # Zero para caminhos para a esquerda\n @direita.walk_node(code + '1', &block) unless @direita.nil? # Uns para caminhos para direita\n end", "def traverse(operator,match)\n ParseNodeSet.new(self).traverse(operator,match)\n end", "def walk(&blk)\n yield self\n self.each_child do |child|\n child.walk(&blk)\n end\n end", "def context(nodes, &block); end", "def each_element_tree regex, namelast, subtree\n begin\n @reader.read # move pointer forward\n e = get_element(nil,namelast)\n # p e\n break if e == nil\n if e.name =~ /#{regex}/\n get_element(subtree) if subtree\n yield e.name, @reader.expand\n end\n end while e != nil\n end", "def each()\n @root.each(\"\") do |k, v|\n yield(k, v)\n end\n end", "def deep_apply(parser, context)\n parser = apply(parser, context)\n apply(parser.map_children { |child|\n deep_apply(child, child_context(parser, context))\n }, context)\n end" ]
[ "0.6116803", "0.60215497", "0.5911224", "0.5800048", "0.57956296", "0.5748433", "0.56565636", "0.5616083", "0.55600804", "0.5555625", "0.55397785", "0.5534623", "0.55264634", "0.5502355", "0.5477033", "0.54680836", "0.5467178", "0.54525036", "0.54069024", "0.54062235", "0.5405444", "0.5388739", "0.53784835", "0.53643996", "0.5356878", "0.5346802", "0.53435755", "0.5317456", "0.53134865", "0.5306368", "0.5303682", "0.5298463", "0.5273554", "0.5272965", "0.52700925", "0.5267639", "0.5266471", "0.5263181", "0.5250958", "0.5247957", "0.52471316", "0.5243445", "0.524107", "0.52276915", "0.5216621", "0.5216621", "0.5208342", "0.52069455", "0.5199393", "0.519936", "0.5194334", "0.51932967", "0.5181207", "0.51725817", "0.51708764", "0.51641315", "0.51563764", "0.5156159", "0.51558083", "0.515105", "0.5150053", "0.51490456", "0.51396585", "0.51396585", "0.5138181", "0.5127509", "0.5122011", "0.5119535", "0.5118379", "0.5117019", "0.51054037", "0.5097217", "0.5090546", "0.5090546", "0.5085871", "0.5081003", "0.5076135", "0.50636077", "0.50601304", "0.5055782", "0.50538176", "0.5053542", "0.5052972", "0.50476724", "0.5037704", "0.503127", "0.5030568", "0.5026424", "0.5026112", "0.5017099", "0.50127214", "0.5008223", "0.50046", "0.49993348", "0.49963635", "0.49910837", "0.49892494", "0.49866402", "0.4985681", "0.49850017", "0.49824193" ]
0.0
-1
davids token is 6461766964626c697540676d61696c2e636f6d
def cors_set_access_control_headers headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, Authorization, Token' headers['Access-Control-Max-Age'] = "1728000" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rfc_2045_token; end", "def token_uri; end", "def cdr(token)\n token.split(DELIMITER).second.then(&Base64.method(:decode64))\n end", "def segmentation_anonymous_id_cookie\n \"sanmid\"\n end", "def car(token)\n token.split(DELIMITER).first.then(&Base64.method(:decode64))\n end", "def token\n len = 8\n token = self.id.to_s\n token = token + self.sha\n token = token[0..5]\n end", "def id\n token\n end", "def token_secret; end", "def token_secret; end", "def token_secret; end", "def dom_id; end", "def dom_id; end", "def dom_id; end", "def dom_id; end", "def token\n return nil if !id\n encode(id)\n end", "def example2\n 'ca679660018162' \\\n 'eyJhbGciOiJIUzI1NiIsImtpZCI6IjE6ODE5MjpjYTY3OTY6QUFBQUFBQUFBQUFBIiw' \\\n 'idHlwIjoiSldUIn0.' \\\n 'eyJjb2RlIjoiZXhhbXBsZS5jb20iLCJmbGciOjk2LCJsZW4iOjEyLCJtc2siOiJfX19' \\\n 'fX19fX19fX19fX19fIiwidmVyIjoyfQ.' \\\n '7YhYmorl6qcKy2LeKfJDKrSi-d5r6c8VL8adJxNPfbY' \\\n 'example.com'\n end", "def key_for(token)\n \"afid-access-token:#{token}\".to_sym\n end", "def root_keys; <<~EOS\n . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5\n . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d\n EOS\n end", "def elastics_id\n Digest::MD5.hexdigest url\n end", "def generate_xd_token\n @connector_token = \"authoring\"\n end", "def token_user_id\n decoded_token.first['id']\n end", "def ACCESS_TOKEN\n return '74d84308fb5a4bc795ab17b87c46e0e5'\n end", "def token_id\n SecureRandom.random_bytes(16).bytes.to_a\n end", "def rdfs_domain\n end", "def id_token\n @id_token ||= nil\n end", "def nonce; end", "def xsrf_token\n SecureRandom.urlsafe_base64 + SecureRandom.urlsafe_base64 + SecureRandom.urlsafe_base64\n end", "def decode_token(token)\n encryptedBytes = Base64.decode64(token)\n key = \"STINGMIMI\"\n blowfish = Crypt::Blowfish.new(key)\n\n position = 0\n decrypted_token = ''\n\n while position < encryptedBytes.length\n decrypted_token += blowfish.decrypt_block(encryptedBytes[position..position + 7]);\n position += 8\n end\n\n npad = decrypted_token.slice(-1)\n if (npad > 0 && npad < 9)\n decrypted_token = decrypted_token.slice(0, decrypted_token.length-npad)\n end\n\n return decrypted_token\n end", "def external_id; end", "def token(request)\n end", "def token\n (self.created.to_i.modulo(100000) + self.id).to_s\n end", "def token\n end", "def cloudmail_token(message)\n Digest::SHA1.hexdigest(\"#{message.id}-#{id}-#{CLOUDMAIL_SEED}-#{email}\")[0..8]\n end", "def get_token\n token_data = vault_read('littlered.stanford.edu', 'netdb-token')\n credentials = JSON.parse(token_data)\n encoded = Base64.urlsafe_encode64(\"#{credentials['client_id']}:#{credentials['client_secret']}\")\n headers = { Authorization: \"Basic #{encoded}\" }\n query = { grant_type: credentials['grant_type'] }\n response = HTTParty.post(credentials['token_endpoint'],\n :headers => headers,\n :query => query\n )\n raise \"Bad response to getting token: #{response.body}\" if response.code != 200\n\n response_json = JSON.parse(response.body)\n response_json['access_token']\nend", "def write_token\n 'ddbc8384eaf4b6f0e70d66b606ccbf7ad4bb22bfe113'\n end", "def druid\n id.split(/:/).last\n end", "def get_token\n ((Time.now.to_f - Time.mktime(2009,\"jan\",1,0,0,0,0).to_f) * 10**6).to_i\n end", "def new_token\n \t SecureRandom.urlsafe_base64\n \tend", "def authCookie\n \"auth_pubtkt=uid%3D...\"\n end", "def token_secret; config[:token_secret]; end", "def token\n Digest::MD5.hexdigest(\"#{id}#{created_at}\")\n end", "def owner_token\n end", "def sid_algorithm; SecureRandom.hex(@options[:sid_len]); end", "def user_id\n decoded_token.first['user_id']\n end", "def digest\n Digest::MD5.hexdigest(id.to_s+Interactiff::Application.config.secret_token).to_i(16).to_s[3,8]\n end", "def get_auth_tkt_token_list\n cookie_decoded = Base64.decode64(cookies[:auth_tkt])\n return cookie_decoded.split('!')[1]\n end", "def get_raw_token_identity(token,options={})\n response = els_http_request(\"/attributes\",\"subjectid=#{token}\",options)\n if response.code.eql? \"200\"\n response.body\n else\n response.error!\n end\n end", "def openid_client_id; end", "def auth0_id_token\n session.fetch(:id_token, nil)\n end", "def handle_rdn_od(tokens, options); end", "def handle_rdn_od(tokens, options); end", "def graphql_id\n Base64.encode64(\"04:#{self.class.name}#{id}\").rstrip\n end", "def decrypt_token token\n @me.decrypt_and_verify(token).split ThreeScale::SSO::SEPARATOR\n end", "def token_id\n if defined?(ActiveSupport::Deprecation)\n ActiveSupport::Deprecation.warn(\"`token_id` on SnapResult is deprecated. Please use `token` instead.\")\n else\n warn \"DEPRECATION WARNING: `token_id` on SnapResult is deprecated. Please use `token` instead.\"\n end\n @data[:token]\n end", "def data\n token\n end", "def get_token_from_auth_data(auth_data)\n auth_data.split(\" \")[1]\nend", "def _next_dsid(fedora_obj)\n dsids = fedora_obj.datastreams.keys.select { |dsidv| dsidv =~ /^ds[\\d]+/ }\n dsids.map! { |dsidv| dsidv[2..-1] }\n dsids.map!(&:to_i).sort!\n \"ds#{(dsids[-1] || 0).to_i + 1}\"\n end", "def content_security_policy_nonce; end", "def get_xtid(xtid, id)\n self.class.headers 'X-tid' => xtid\n self.class.get(\"/aldebaran-recdocs/recdocs/#{id}\", :basic_auth => @auth)\n end", "def auth_token\n response_hash[:ebay_auth_token]\n end", "def content_security_policy_nonce_directives; end", "def content_security_policy_nonce_directives; end", "def parse_token\n binary_token = get_element('//t:RequestSecurityTokenResponse/t:RequestedSecurityToken/wsse:BinarySecurityToken')\n @validation_errors << \"No binary token exists.\" and return if binary_token.nil?\n \n decoded_token = Base64.decode64(binary_token)\n name_values={}\n decoded_token.split('&').each do |entry|\n puts entry\n pair=entry.split('=') \n name_values[CGI.unescape(pair[0]).chomp] = CGI.unescape(pair[1]).chomp\n end\n puts \"expires on\"\n puts name_values[\"ExpiresOn\"]\n @validation_errors << \"Response token is expired.\" if Time.now.to_i > name_values[\"ExpiresOn\"].to_i\n @validation_errors << \"Invalid token issuer.\" unless name_values[\"Issuer\"]==\"#{self.class.issuer}\"\n @validation_errors << \"Invalid audience.\" unless name_values[\"Audience\"] ==\"#{self.class.realm}\"\n \n # is HMAC valid?\n token_hmac = decoded_token.split(\"&HMACSHA256=\")\n swt=token_hmac[0]\n puts \"====\"\n puts \"incoming hmac is\"\n puts name_values['HMACSHA256']\n puts \"calculated hmac is\"\n puts Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'),Base64.decode64(self.class.token_key),swt)).chomp\n puts \"====\"\n \n @validation_errors << \"HMAC does not match computed value.\" unless name_values['HMACSHA256'] == Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'),Base64.decode64(self.class.token_key),swt)).chomp\n \n # remove non-claims from collection and make claims available\n\n @claims = name_values.reject {|key, value| !key.include? '/claims/'}\n end", "def openid_client_secret; end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def token_secret=(_arg0); end", "def principal_token=(token)\n end", "def device_id\n apn_device_token\n end", "def client_token\n data[:client_token]\n end", "def initialize(id_token)\n @id_token = id_token\n end", "def parse_taxon_ids_list full_document\n full_document.gsub(/%tl\\[(.*?)\\]/) do\n ids_string = $1\n ids = ids_string.gsub(\" \", \"\").split(\",\")\n\n ids.map do |id|\n try_linking_taxon_id id\n end.join(\", \")\n end\n end", "def directors_ids\n directors_ids = []\n directors_name.each_with_index do |director, index|\n directors_ids << document[\"castMember\"][index][\"person\"][\"code\"] if director == document[\"castMember\"][index][\"person\"][\"name\"]\n end\n directors_ids\n end", "def parse_ddm(ddm);end", "def signature_bytes; NaCl::ED25519_SIGNATUREBYTES; end", "def getNativeID(data)\n\n id= data[\"id\"]\n\n if @publisher == \"twitter\" then\n native_id = id.split(\":\")[-1]\n end\n\n if @publisher == \"tumblr\" then\n native_id = id.split(\"/\")[-2]\n p native_id\n end\n\n #These comment/like/vote streams have a blog ID, post ID and a comment ID, so I decided to capture all three.\n if @publisher.include?(\"wordpress\") then\n if @stream_type == \"post\" then\n native_id = id.split(\"/\")[-3] + \"-\" + id.split(\"/\")[-1]\n else\n native_id = id.split(\"/\")[-5] + \"-\" + id.split(\"/\")[-3] + \"-\" + id.split(\"/\")[-1]\n end\n end\n\n #These comment/vote streams have a thread ID and a comment/vote ID, so I decided to capture both.\n if @publisher == \"automattic\" or @publisher == \"intensedebate\" then\n\n if @stream_type == \"vote\" then\n native_id = id.split(\"/\")[-5] + \"-\" + id.split(\"/\")[-3]\n else\n native_id = id.split(\"/\")[-3] + \"-\" + id.split(\"/\")[-1]\n end\n end\n\n if @publisher == \"foursquare\" or @publisher == \"newsgator\" or @publisher == \"stocktwits\" then\n native_id = id.split(\"/\")[-1]\n end\n\n if @publisher == \"getglue\" then\n if data[\"verb\"] != \"user_protect\" then\n native_id = id.split(\"/\")[-2] + \"-\" + id.split(\"/\")[-1]\n else\n native_id = id.split(\"/\")[-1]\n end\n end\n\n if @publisher == \"estimize\" then\n native_id = id.split(\":\")[-1]\n end\n\n\n return native_id\n end", "def vivo_ids\n vivo_uris.map {|uri| uri.to_s.split('/').last.to_i }\nend", "def get_nics(token, nics_url)\n nic_ids = Array.new \n endpoint = nics_url.scan(/\\/organizations.*nics/)\n resp_hash = get_url(token, endpoint[0], {})\n resp_hash[:embedded][:nics].each do |nic|\n nic_ids.push extract_id(nic[:_links][:self][:href], 'nics')\n end\n return nic_ids, resp_hash\nend", "def auth_token\n Auth.decode(header_token)\n end", "def random_token\n SecureRandom.urlsafe_base64\n end", "def new_token\n SecureRandom.urlsafe_base64\nend", "def token(auth_code = T.unsafe(nil), headers = T.unsafe(nil)); end", "def new_token\n \t\tSecureRandom.urlsafe_base64\n \tend", "def token; end", "def token; end", "def token; end", "def token; end", "def token; end", "def token; end", "def get_metadata_by_token(did_token)\n issuer = token.get_issuer(did_token)\n get_metadata_by_issuer(issuer)\n end", "def token_key\n @token_key\n end", "def getTrustedToken(user)\n if user.nil? or user.empty?\n debug('Error: getTrustedToken: Null user specified.')\n return\n end\n token = \"appid=#{appid}&uid=#{CGI.escape(user)}&ts=#{timestamp}\"\n token += \"&sig=#{e64(signToken(token))}\"\n CGI.escape token\n end", "def getTokenDecode( token)\n params = Hash.new\n params['token'] = token\n return doCurl(\"get\",\"/token/decode\",params)\n end", "def get_token_identity(token,options={})\n ElsIdentity.new(get_raw_token_identity(token,options))\n end", "def str2id(s)\n s.id.delete('/hostedzone/')\nend", "def request_authenticity_tokens; end", "def remote_id; end", "def api_nonce\n\t\t\t8.times.map { [*'0'..'9'].sample }.join\n\t\tend", "def from_global_id(global_id)\n Base64.decode64(global_id).split(\"-\")\n end", "def gettoken(url,username,password,tenant)\n url1 = \"#{url}/identity/api/tokens\"\n uri = URI.parse(url1)\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n request.body = JSON.dump({\n \"username\" => username,\n \"password\" => password,\n \"tenant\" => tenant\n })\n\n req_options = {\n use_ssl: uri.scheme == \"https\",\n verify_mode: OpenSSL::SSL::VERIFY_NONE,\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n\n token_output = response.body\n token_json = JSON.parse(token_output)\n vra_token = token_json[\"id\"]\n return vra_token\n end", "def new_token\n SecureRandom.urlsafe_base64\n end" ]
[ "0.5868119", "0.58402586", "0.5652484", "0.5499712", "0.5450319", "0.5412386", "0.54016435", "0.5383668", "0.5383668", "0.5383668", "0.5329039", "0.5329039", "0.5329039", "0.5329039", "0.53263116", "0.52567434", "0.5247727", "0.52104074", "0.52011883", "0.5192306", "0.51591533", "0.5158565", "0.5148345", "0.51115024", "0.5103159", "0.5098478", "0.5068809", "0.5061794", "0.5049389", "0.5047624", "0.50409156", "0.50381774", "0.50253576", "0.5022887", "0.501562", "0.5014213", "0.5009039", "0.49910387", "0.49880612", "0.49762854", "0.49649358", "0.49632612", "0.49610966", "0.4959266", "0.4958863", "0.49575117", "0.4952135", "0.49484146", "0.49358958", "0.4928241", "0.4928241", "0.49269632", "0.48960447", "0.489037", "0.4888323", "0.48822856", "0.48730654", "0.48657423", "0.4861996", "0.48592854", "0.48565656", "0.48565656", "0.48557773", "0.48255163", "0.48222536", "0.48222536", "0.48222536", "0.4817912", "0.48128366", "0.4809387", "0.4807769", "0.48065314", "0.4806136", "0.47988242", "0.47976562", "0.47953314", "0.47933975", "0.47908035", "0.47822255", "0.4778774", "0.47781092", "0.47667482", "0.47667274", "0.47664797", "0.47664797", "0.47664797", "0.47664797", "0.47664797", "0.47664797", "0.47573364", "0.47556695", "0.47497514", "0.4748259", "0.47460005", "0.47453147", "0.47441772", "0.47416374", "0.47381482", "0.47379816", "0.4731496", "0.47270718" ]
0.0
-1
main users based on last 10000 clicks
def main_users @main_users = ParseGoLink.main_users render json: @main_users end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.where(\"verified = 1\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n end\n end\n end", "def quantify_edits\n\t\[email protected]_with_index do |changeset, index|\n\t\t\tthis_user = changeset['properties']['user']\n\t\t\t\n\t\t\t@users[this_user] ||= 0\n\t\t\t@users[this_user] += 1\n\n\t\t\tif (index%10000).zero?\n\t\t\t\tprint \"#{index}..\"\n\t\t\tend\n\t\tend\n\tend", "def crawl users_to_crawl = @seed, infinity: false\n user = users_to_crawl.to_a.sample\n twitter_catcher_main_block do\n crawl_user( user )\n users_to_crawl = @sn.users_to_crawl if infinity\n crawl( users_to_crawl.delete( user ) ) if users_to_crawl.size > 0\n end\n end", "def randomStatUser(num)\n\t\tif(@user != nil)\n\t\t\tstats = [\n\t\t\t\[email protected],\n\t\t\t\tUser.all.count,\n\t\t\t\t10,\n\t\t\t\t\"Fiction\",\n\t\t\t]\n\t\t\tstats.at(num)\n\t\tend\n\tend", "def visit_counter\n\t\t\t@all = Session.all\n\t\t\t@online_users = []\n\t\t\t@online_guess_count = 0\n\t\t\t@day_count = 0\n\t\t\t@week_count = 0\n\t\t\t@month_count = 0\n\t\t\t@year_count = 0\n\t\t\t@in_day_users = []\n\n\t\t\[email protected] do |s|\n\t\t\t\tif s.updated_at > 15.minutes.ago\n\t\t\t\t\tif s.data['user_id'].present?\n\t\t\t\t\t\t@online_users << s.data['user_id']\n\t\t\t\t\telse\n\t\t\t\t\t\t@online_guess_count += 1\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\tif s.updated_at.year == Date.current.year\n\t\t\t\t\t@year_count += 1\n\t\t\t\t\tif s.updated_at.month == Date.current.month\n\t\t\t\t\t\t@month_count += 1\n\t\t\t\t\t\tif s.updated_at.day >= Date.current.at_beginning_of_week.day\n\t\t\t\t\t\t\t@week_count += 1\n\t\t\t\t\t\t\tif s.updated_at.day == Date.current.day\n\t\t\t\t\t\t\t\t@day_count += 1\n\t\t\t\t\t\t\t\tif s.data['user_id'].present?\n\t\t\t\t\t\t\t\t\t@in_day_users << s.data['user_id']\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t@online_users = User.where id: @online_users.uniq, is_online: true\n\t\t\t@in_day_users = User.find @in_day_users.uniq\n\n\t\t\trender layout: 'layout_back'\n\t\tend", "def events_about_users opts = {:limit => 4 }\n # FIXME: TO nooisy for your own items.. neeeds better filtering, for\n # example, removingn events about items conceerning actions I took\n #events = %w(user.follow.user user.update.item.* user.comment.* user.add.item)\n events = %w(user.follow.user user.comment.* )\n current_user.events_where(events).last(opts[:limit])\n end", "def users_by_amount_visited\n user_visits = self.visited_museums.count\n other_user_visits = User.where.not(id: self.id).map { |user| user.visited_museums.count }\n other_user_visits.unshift(user_visits)\n end", "def random_users\n @users = User.where.not(id: current_user.id) - current_user.all_following\n render json: @users.sample(5) #this method fetches 5 random users from @users\n end", "def near_buddies(limit = 8)\n # all users with a watchlist ( not self ) -- sample selection of LIMIT\n WatchList.all.collect { |w| w.user }.reject { |user| user == self }.uniq.sample(limit)\n end", "def set_user_id\n User.stats.limit(2).each do |user|\n self.user_id = user['id']\n\n # prevents us from setting back to the same user\n if self.changes['user_id'][0] != self.changes['user_id'][0]\n break\n end\n end\n end", "def fetch_users(limit)\n system_users = %w[AFL APL LSC MSEL SAIS WELCH reserve Nanjing ILS1 welchharrison]\n ds = @db[@illiad_table].where(\n nvtgc: @nvtgc,\n cleared: 'No'\n ).exclude(\n username: system_users\n ).exclude(\n cleared: %w[DIS]\n ).exclude(\n Sequel.ilike(:UserName, '%@%')\n ).order_by(:nvtgc).order_by(:userinfo3).limit(limit)\n # ap ds.sql exit\n rescue Sequel::Error => e\n p 'ERROR: ' + e.message + ds\n end", "def fetch_player_activity\n unique_ids_two_weeks_ago = Card.for_quizzes.between_days('quizzes', 14, 8).select(:user_id).distinct.pluck(:user_id)\n unique_ids_one_week_ago = Card.for_quizzes.between_days('quizzes', 7, 1).select(:user_id).distinct.pluck(:user_id)\n returned_user_ids = unique_ids_two_weeks_ago.select { |id| unique_ids_one_week_ago.include?(id) }\n left_user_ids = unique_ids_two_weeks_ago.reject { |id| unique_ids_one_week_ago.include?(id) }\n returned_users = User.where(id: returned_user_ids).sample(25)\n left_users = User.where(id: left_user_ids).sample(25)\n message_count = Notification.where('notifications.created_at BETWEEN ? AND ?', DateTime.current.beginning_of_day - 7, DateTime.current.end_of_day - 1).size\n new_users = User.where('users.created_at BETWEEN ? AND ?', DateTime.current.beginning_of_day - 7, DateTime.current.end_of_day - 1).sample(25)\n confirmed_can_users = Hash.new(0)\n can_users = Hash.new(0)\n User.confirmed.where(source: \"mlb_scan_lp\").each do |user|\n role = user.roles.first\n role ? confirmed_can_users[user.roles.first.name] += 1 : confirmed_can_users['global'] += 1\n end\n User.where(confirmed: false).where(source: \"mlb_scan_lp\").each do |user|\n role = user.roles.first\n role ? can_users[user.roles.first.name] += 1 : can_users['global'] += 1\n end\n registered_count = confirmed_can_users.size\n unregistered_count = can_users.size\n phone_number_count = PhoneNumber.all.size\n WeeklyUserActivityMailer.stats_email(\n new_users: new_users, \n returned_users: returned_users, \n left_users: left_users,\n message_count: message_count,\n can_users: can_users,\n confirmed_can_users: confirmed_can_users,\n registered_count: registered_count,\n unregistered_count: unregistered_count,\n phone_number_count: phone_number_count\n ).deliver_now\n end", "def get_app_visits(start, finish)\n\t\t5000 + rand(500)\n\tend", "def index\n @rand_user = User.all.sample\n unless @rand_user.id != current_user.id\n @rand_user = User.all.sample\n end\n @breaches = Breach.where(user_id: current_user.id)\n enemy_failed_breaches = Breach.where(target_id: current_user.id)\n @enemy_list = Array.new\n enemy_failed_breaches.each do |breach|\n @enemy_list.push(User.find(breach.user_id))\n end\n end", "def num_uniq_recent_clicks\n visitors.select(\"visits.user_id\").where(\"visits.created_at > ?\", 10.minutes.ago ).distinct.count\n # This works, too, but only because in all the joins we make, \"user_id\" is unique:\n # visitors.select(\"user_id\").where(\"visits.created_at > ?\", 10.minutes.ago ).distinct.count\n end", "def user_test(users, level)\n\tres = Array.new\n\tlength = users.length\n\tputs 'starting user_test, length is ' + length.to_s\n\ttest_i = 0\n\tusers.each do |person|\n\t\tleft = length - test_i\n\t\tputs left.to_s + ' left'\n\t\ttmp = person['id'].to_s\n\t\tresponse = TOKEN.get('/v2/users/' + tmp).parsed\n\t\tif ((response['cursus_users'].length > 0) && (response['cursus_users'][0]['level'] >= level))\n\t\t\tres.push(person)\n\t\tend\n\t\ttest_i += 1\n\tend\n\treturn res\nend", "def topusers\n\t\t@topusers = User.find(:all, :order => \"points DESC\", :limit => \"10\")\n\tend", "def fetch_users(limit)\n system_users = %w[AFL APL LSC MSEL SAIS WELCH reserve Nanjing ILS1]\n ds = @db[@illiad_table].where(\n userinfo1: nil,\n userinfo3: nil,\n emailaddress: nil,\n nvtgc: @nvtgc\n ).exclude(\n username: system_users,\n cleared: %w[DIS]\n ).order_by(\n :userinfo3\n ).limit(limit)\n rescue Sequel::Error => e\n p 'ERROR: ' + e.message + ds\n end", "def num_recent_uniques\n # should only collect unique clicks in a recent time period \n # (say, 10.minutes.ago)\n visits\n .select('user_id')\n .where('created_at > ?', 10.minutes.ago)\n .distinct\n .count\n end", "def getUsers( num_users = nil )\n\n #get all users\n users = (@min_user..@max_user).to_a\n \n #limit if necessary\n if num_users\n users = users.sample( num_users )\n end\n \n #return\n users\n \n end", "def get_latest_users_logged_in(top = 5)\n doc = DocumentStore.get_document(DOCS[:latest_users_loggedin])\n return nil if doc[:users].empty?\n\n Rails.logger.debug(\"Latest Users Logged In\")\n Rails.logger.debug(doc[:users].inspect)\n Rails.logger.debug(\"Slice List!\")\n users = doc[:users]\n\n Rails.logger.debug(users.first(top).inspect)\n Rails.logger.debug(\" \")\n\n get_multiple_users_by_uid(users.first(top))\n end", "def follow(num_users=N)\n num_users.times do |n|\n user = User.find_by_username(\"testuser#{n}\")\n NUM_FOLLOWEES.times do\n f = User.find_by_username(\"testuser#{rand(num_users)}\")\n user.follow(f)\n end\n end\nend", "def default_back_up( current_results, cur_user )\n\t\t#the the current_results number of items is less than 20 is the reason why we're in here\n\t\tusername = cur_user.email\n\t\ttarget_country = cur_user.lives_in \n\t\tuser_traveled_list = cur_user.has_been_to\n\t\tarray_string = get_name_list( user_traveled_list )\n\t\tmatch_exp = \"(user)-[:lives_in]->(country:Country)<-[lives_in]-(user2),(user2)-[:has_been_to]->(traveled_list:Country) \"\n\t\twhere_exp = \"country.name = '#{target_country.name}' AND traveled_list.name IN #{array_string} AND user2.email <> '#{username}'\"\n\t\tback_up_matches = User.query_as(:users).match(user2: User).match(\"#{match_exp}\").where(\"#{where_exp}\").return('user2.uuid').to_a\n\n\t\tcurrent_results = current_results.to_a\n\t\tid_list = Array.new\n\n\t\tcurrent_results.each do |current_item|\n\t\t id_list << current_item.uuid\n\t\tend\n\n\t\tcurrent_results.concat(back_up_matches)\n\n\t\twhere_exp = \"users.email <> '#{username}'\"\n\t\tif current_results.length < 10\n\n\t\t default = User.query_as(:users).where(\"#{where_exp}\").proxy_as(User, :users).paginate(:page => params[:page], per_page: 10, return: :'distinct users')\n\t\t return default\n\t\telse\n\t\t where_exp << \"AND users.uuid IN #{id_list}\"\n\t\t join_match = User.query_as(:users).where(\"#{where_exp}\").proxy_as(User, :users).paginate(:page => params[:page], per_page: 10, return: :'distinct users')\n\t\t return join_match\n\t\tend\n\tend", "def select_user\n # @users = ['ichthala', 'wescarr17', 'seraphicmanta', 'tcclevela', 'antonwheel', 'horse_ebooks', 'catlandbooks']\n # @users.each_with_index do |user, index|\n # @users[index] = Twitter.user(user)\n # end\n\n @users = []\n\n while @users.count < 9\n offset = rand(Twitteruser.count)\n rand_sn = Twitteruser.first(:offset => offset).screen_name\n unless @users.find_index(rand_sn)\n @users << rand_sn\n end\n end\n\n @users << 'horse_ebooks'\n\n @users.each_with_index do |user, index|\n @users[index] = Twitter.user(user)\n end\n\n respond_to do |format|\n format.html\n format.json {render json: @users}\n end\n\n end", "def random_user\n\t\tUser.find([*1..40].sample)\n\tend", "def list(garbage, start)\n @all_user = session_user.agency.users\n @start = start.to_i || 0\n @limit = request.params[\"limit\"] || UserListingLength\n @user = @all_user[@start .. (@start+@limit)-1] # FIXME: Do it with sequel!\n @uparted = @user.partition{|u| @user.index(u) % 2 == 0 }\n end", "def how_many_users\n records = @logs.records.sort_by { |record| record.ip.uniq.length }.reverse\n @view.display_how_many_users(records)\n end", "def num_clicks\n count = 0\n self.visits.each { |user| count += user.visits }\n count\n end", "def get_most_active_users(num_users = 5)\n get_most_generic_for_users(DOCS[:most_active_users], num_users)\n end", "def get_all_users(spec)\n user = spec.or_contributors_to_spec\n if @users.include? user\n @numbers[user] = @numbers[user] + 1\n else\n @users.add user\n @numbers[user] = 1\n end\nend", "def top_users(limit = 10)\n @users.sort_by{|user_id,user| -user.score}.first(limit).map do |t|\n {\n :id => t.first,\n :score => t.last.score,\n :common_tracks_count => t.last.common_tracks_count,\n :total_tracks_count => t.last.total_tracks_count\n }\n end\n end", "def numUser\n\t \trandom = rand(@arr.size)\n\t \t@statSentence = randomStatSentenceUser(@arr.at(random));\n\t \t@stat = randomStatUser(@arr.at(random));\n\t \[email protected]_at(random)\n\tend", "def typical_users(n=1,randomize=true)\n ids = items.flat_map {|item|\n item.subscriber_ids\n }.reduce(Hash.new(0)) { |h,id|\n h[id] += 1\n h\n }\n .sort_by{|k,v| v}.reverse\n .take(2*n)\n .sample(n)\n .map(&:first)\n\n User.any_in(id: ids)\n end", "def index\n @users = User.all\n ref = Bigbertha::Ref.new( 'https://trackme-22c21.firebaseio.com/' )\n counted=ref.child(:count).read\n if counted!=0\n a_val=ref.child(:pids).read\n b_val=ref.child(:users).read\n \n\n \nflag=-1\n\n\n \nuser_newest = User.order(\"created_at\").last\n\n\ncounted=counted-1\n if user_newest.blank?||counted>user_newest.count\n \tif user_newest.blank?\nfor i in 0..counted\n @str=a_val[i]\n long=b_val[@str][\"latLng\"][\"longitude\"]\n emai=b_val[@str][\"email\"]\n mobil=b_val[@str][\"mobile\"]\n na=b_val[@str][\"name\"]\n dep=b_val[@str][\"department\"]\n des=b_val[@str][\"designation\"]\n lat=b_val[@str][\"latLng\"][\"latitude\"]\n object = User.new(:latitude => lat, :longitude => long,:name => na,:department => dep,:title => des,:count => counted,:email => emai,:mobile => mobil,:push_id => @str)\n object.save\n\n end\n else\n u=user_newest.count+1\nfor i in u..counted\n @str=a_val[i]\n long=b_val[@str][\"latLng\"][\"longitude\"]\n emai=b_val[@str][\"email\"]\n mobil=b_val[@str][\"mobile\"]\n na=b_val[@str][\"name\"]\n dep=b_val[@str][\"department\"]\n des=b_val[@str][\"designation\"]\n lat=b_val[@str][\"latLng\"][\"latitude\"]\n object = User.new(:latitude => lat, :longitude => long,:name => na,:department => dep,:title => des,:count => counted,:email => emai,:mobile => mobil,:push_id => @str)\n object.save\n\n end\nend\nend\n\nif user_newest.blank?\nelse\n for i in 0..counted\n @str=a_val[i]\n long=b_val[@str][\"latLng\"][\"longitude\"]\n lat=b_val[@str][\"latLng\"][\"latitude\"]\n @user=User.find_by_push_id(@str)\n @[email protected]\n @user.update_attributes(:latitude => lat, :longitude => long)\n @user.save\n end\n\nend \n\n\n \n\n\n\n\n\n\n\n \n\n @hash = Gmaps4rails.build_markers(@users) do |user, marker|\n marker.lat user.latitude\n marker.lng user.longitude\n marker.infowindow user.name+\",\"+user.department\n end\n end\nend", "def call_tracing\n @page_title = _('Call_Tracing')\n @page_icon = 'lightning.png'\n @users = User.find_all_for_select(correct_owner_id)\n end", "def all_people_tracked\n Timing.users_for_client(self.id)\n end", "def non_first_time_user_feed products\n #generate raking based on the search, bookmarks and feedback \n searches = @user.searches.limit(3)\n feedbacks = @user.feedbacks\n bookmarks = @user.bookmarks\n results = Hash.new\n products.each do |product|\n score = product.internal_score\n bookmarks.each do |bookmark|\n if bookmark.product_id == product.id\n score += 2 #bookmarked products should be on top.\n end\n end\n feedbacks.each do |feedback|\n if feedback.product_id == product.id\n score += (feedback.rating - 3) #considering 3 rating as average\n elsif feedback.product.sub_category_id == product.sub_category_id\n score += (3 - feedback.rating) #For postive feedback user might not want to see other products in that sub_category at top, for negative feedback reverse\n end \n end\n searches.each do |search|\n if search.searchable_type == 'Product'\n if search.searchable_id == product.id\n score += 2 #latest search products at top\n end\n else\n if search.searchable_id == product.sub_category_id\n score += 1 #latest serach subcategory products at top\n end\n end\n end\n results[score] = results.key?(score) ? results[score] + [product] : [product]\n end\n results = results.sort.reverse.to_h\n result_array = Array.new\n results.each do |key, value| \n result_array += value\n end\n result_array\n end", "def smart_bfs(len, to_get_users = [], to_get_neighbors = [], visited = Set.new)\n sample = []\n i = 0\n while i < len do\n while i < len do\n if to_get_users.empty? then\n break\n end\n # ask Twitter for a chunk of user objects from ids list\n uids = to_get_users.slice!(0..$max_users-1)\n users = get_users(uids)\n p \"got #{users.length} users\"\n sample.concat(users)\n\n # add ids to neighbors todo\n to_get_neighbors.concat( users.map { |u| u.attrs[:id] } )\n i+=users.length\n end\n\n while to_get_users.empty? do\n if to_get_neighbors.empty? then \n return sample\n end\n uid = to_get_neighbors.slice!(0)\n\n next_cursor = -1\n last_index = 0\n next_user_id = 0\n while next_cursor != 0 do\n # get the next page of follower ids\n cur = get_followers_cursor(uid, next_cursor)\n\n # add never-before-seen users to worklist\n newusers = cur[:ids].sselect { |fid| not visited.member?(fid) }\n newusers.each { |u| visited.add(u) }\n to_get_users.concat( newusers ) \n\n # next page index \n next_cursor = cur[:next_cursor]\n end\n end\n end\n \n return sample\nend", "def last_checkins(response)\n user = response.matches.first.first || response.user.name\n\n if redis.sismember('users', user)\n log.debug(\"#{user} looks like an Untappd user\")\n untappd_user = user\n else\n # look up the Untappd user for this chat user\n log.debug(\"#{user} looks like it may be a chat user\")\n chat_user = User.fuzzy_find(user)\n\n unless chat_user\n response.reply_with_mention(\"I don't know anyone by that name\")\n return\n end\n\n untappd_user = redis.get(\"username_#{chat_user.id}\")\n end\n\n # Get the last three or today's checkins, whichever is more\n log.info(\"Getting last few beers for Untappd user #{untappd_user}\")\n checkins = ::Untappd::User.feed(untappd_user).checkins.items\n last_24_hour_checkins = checkins.find_all do |checkin|\n Time.parse(checkin.created_at) > (Time.now - (60 * 60 * 24))\n end\n\n if last_24_hour_checkins.length >= 3\n checkins = last_24_hour_checkins\n else\n checkins = checkins.take 3\n end\n\n log.debug(\"Got #{checkins.length} checkins for #{untappd_user}\")\n\n # accounce last beers\n beers = []\n checkins.each do |checkin|\n beers << \"#{checkin.beer.beer_name} by #{checkin.brewery.brewery_name}\"\n end\n\n if beers.empty?\n response.reply(\"#{user} hasn't checked in any beers!\")\n else\n response.reply(\"#{user}'s last few beers: #{beers.join(', ')}\")\n end\n end", "def sorted_top_users\n add_github_user('redline6561')\n followers = github.get_followers('redline6561',1,100)\n followers.map { |x| x['login'] }.sample(20).each do |username|\n add_github_user(username)\n end\n\n Cheepcreep::GithubUser.order(:followers => :desc).each do |u|\n puts \"User: #{u.login}, Name: #{u.name}, Followers: #{u.followers}\"\n end\nend", "def frontpage\n @users = User.order(karma: :desc).limit(5)\n end", "def user_views\n session[:views] = if current_user\n session[:views].to_i == 10 ? 1 : session[:views].to_i + 1\n else\n 0\n end\n end", "def users_who_completed_all_studies\n @downloaded_studies = Study.find(self.study_ids)\n\n user_arr = []\n @downloaded_studies.each do |study|\n user_arr.push(study.study_completions.pluck(:user_id).uniq)\n end\n\n ## SELECT THE COMMON VALUES OF ALL INTERIOR ARRAYS\n user_ids_and_nil = user_arr.reduce { |a, b| a & b }\n\n\n ## THIS COMMAND GETS RID OF ALL LOGGED OUT USER SURVEY DATA -- could be interesting to see if its use can dry up code\n user_ids_who_completed_all_studies = user_ids_and_nil.grep(Integer)\n\n user_ids_who_completed_all_studies\n end", "def home\n # Get the history logs of all users that you follow or have public privacy\n @historyLog = HistoryLog.all\n @historyLog = @historyLog.order(created_at: :desc)\n @currUserFollowers = Follower.where(users_id: current_user.id)\n @historyLogs = @historyLog.select{|log| log.users_id == current_user.id || Preference.find_by(users_id: log.users_id) == nil || !Preference.find_by(users_id: log.users_id).privacy || @currUserFollowers.any?{|x| x.fTarget == log.users_id}}.take(10).to_a\n end", "def most_active_user\n \n end", "def rec_users_to_follow(num_scrolls)\n num_results = 3\n Rails.cache.delete(\"fof_sorted_scores_#{self.id}\") if num_scrolls == 0\n \n cached_sorted_rec_users = Rails.cache.fetch(\"fof_sorted_scores_#{self.id}\", expires_in: 5.hours) do\n followed_users = self.users_followed.includes(:users_followed)\n fof_scores = Hash.new(){0}\n followed_users.each do |followed_user|\n followed_user.users_followed.each do |fof_user|\n fof_scores[fof_user] += 3 if (!followed_users.include?(fof_user)) \n end\n end \n sorted_rec_users = fof_scores.sort_by{|key, value| value}.map(&:first).reverse\n end\n\n return cached_sorted_rec_users[num_scrolls*num_results, num_results]\n end", "def working\n @users=User.where.not(timer_activity: 0)\n end", "def find_and_return_cur_day_user_count(browser)\n fm_user_ids = []\n facepiles = browser.all 'div.facepile a'\n facepiles.each do |face|\n fm_user_ids << /\\d+/.match(face['onclick'])[0]\n end\n return fm_user_ids.count\nend", "def get_web_visits(start, finish)\n\t\t5000 + rand(1000)\n\tend", "def index\n @aspect = params[:aspect].to_sym\n @users = []\n @key = \"\"\n @cache_options = {}\n\n case @aspect\n when :likers\n purchase = Purchase.with_likes.find params[:purchase_id]\n @users = purchase.likes.map(&:user)\n @key = [\"v1\",purchase,@users.map(&:updated_at).max.to_i, \"likers\"]\n\n when :followers\n user = params[:handle] ? \n User.find_by_handle(params[:handle]) :\n User.find(params[:user_id])\n @users = user.followers\n @key = [\"v1\",user,@users.map(&:updated_at).max.to_i, \"followers\"]\n\n when :ifollowers\n user = params[:handle] ? \n User.find_by_handle(params[:handle]) :\n User.find(params[:user_id])\n @users = user.ifollowers\n @key = [\"v1\",user,@users.map(&:updated_at).max.to_i, \"ifollowers\"]\n\n when :search\n query = params[:q]\n @key = [\"v1\",self.current_user,Base64.encode64(query).gsub(\"\\n\",\"\")[0..99]]\n @cache_options = {:expires_in => 1.minute}\n @users = User.search do \n fulltext query do \n unless params[:skip_followers]\n boost(10) do \n with(:followers,self.current_user.id)\n end \n boost(5) do \n with(:followers,self.current_user.ifollower_ids)\n end unless self.current_user.inverse_followings_count.zero?\n end\n end \n without(:followers,self.current_user.id) if params[:skip_followers]\n paginate :per_page => 5\n end.results unless fragment_exist?(@key)\n\n Search.add(\n {:query => query,:source => SearchSource::User},\n self.current_user.id)\n\n when :connections\n @user = User.find_by_handle params[:handle]\n @origin = \"connections\"\n @view = \"connections\"\n populate_theme @user if @user\n\n when :suggestions\n @view = \"suggestions\"\n @user = self.current_user\n ifollower_ids = self.current_user.ifollower_ids \n per_page = params[:per_page] ? params[:per_page].to_i : 3\n\n followings = Following.find_all_by_follower_id(\n ifollower_ids,\n :conditions => [\"user_id not in (?) AND U.has_purchases_mined = 1 AND U.purchases_count > 2 AND is_active = true\", ifollower_ids + [self.current_user.id]],\n :joins => 'INNER JOIN users ON users.id = followings.follower_id INNER JOIN users as U ON U.id = followings.user_id',\n :group => :user_id,\n :include => :user,\n :select => 'followings.*,\n GROUP_CONCAT(CONCAT_WS(\\' \\', users.first_name, users.last_name)) AS FOLLOWED_BY',\n :order => 'RAND()',\n :limit => per_page * 0.667)\n \n @users = followings.each do |f|\n f.user['message'] = follow_message(f['FOLLOWED_BY'],params[:mobile])\n end.map(&:user)\n \n @users += User.find_all_by_is_special(\n true,\n :conditions => [\"id not in (?)\", followings.map(&:user_id) + ifollower_ids + [self.current_user.id]],\n :order => 'RAND()',\n :limit => per_page - @users.size).each{|u| u['message'] = u.byline}\n end\n\n rescue => ex\n handle_exception(ex)\n ensure\n raise_not_found if @aspect == :connections && !@user\n\n respond_to do |format|\n format.html do\n track_visit\n render @view\n end\n format.json\n end\n end", "def new_requests_since_last_login(user)\n now = Time.now\n\n if !user.last_sign_in_at.blank?\n user_last_login = user.last_sign_in_at.to_datetime\n else\n user_last_login = Time.now.to_datetime\n end\n\n Request.pending.where(updated_at: (user_last_login)..now).count\n end", "def explore\n @users = User.all\n @TopChart = Song.all\n @TopArtist = User.last(5)\n @topDJ = Broadcaster.find_by_sql(\"select * from broadcasters where is_playing = true order by num_listeners DESC limit 5\")\n end", "def permitted_users_id\n\treturn_user_ids = Array.new\n\tif !self.venue_id.nil?\n\t return_user_ids = ActiveInVenue.where(venue_id: self.venue_id).where.not(user_id: self.user_id).map(&:user_id)\n end\n\tif self.allow_nearby\n\t\treturn_user_ids = return_user_ids | User.where.not(id: self.user_id).near([self.latitude, self.longitude], 25, units: :km).map(&:id)\n\tend\n\tblack_list = BlockUser.blocked_user_ids(self.user_id)\n \tcontent_black_list = ShoutReportHistory.where(reportable_id: self.id).where(reportable_type: 'Shout').map(&:reporter_id)\n \treturn_user_ids = return_user_ids - black_list - content_black_list\n\n \t# only user pusher for online users\n \tonline_users_ids = User.where(id: return_user_ids).where(pusher_private_online: true).map(&:id)\n \treturn online_users_ids\n end", "def get_more_users(l=1,n = nil)\n\t #u is a User in the database\n\t\t#n is the number we want to had \n\t\t#l is the level of recursivity\n\t\tif l != 0\n #call the API\n\t\t\t#fws = self.get_followers\n\t\t\tfi = self.get_following\n\t\t\t#from the API objects create databases objects \n\t users = User.set_users_from_twitter_users(fi,n)\n\t\t\tself.save!\n self.add_followings(users)\n\t users.each{|f|\n\t\t\t f.get_more_users(l-1, n)\n\t\t\t}\n\t\tend\n\t\treturn users\n end", "def all_people_scheduled\n Entry.users_for_client(self.id)\n end", "def initialize(user_offset)\n @retire_num = 3\n # @active_user_set = User.limit(10).offset(user_offset).map(&:id)\n @active_user_set = (1..10).to_a.map { |n| user_offset + n }\n @query_times = []\n end", "def index\n @users = User.all.order(\"updated_at DESC\").paginate(page:params[:page],per_page:10)\nif session[:auth].include?'all'\n @users = User.all.order(\"updated_at DESC\").paginate(page:params[:page],per_page:10)\nelse\n @users=User.where(\"admin_id=?\",session[:id]).order(\"updated_at DESC\").paginate(page:params[:page],per_page:10)\nend\n @admins=Admin.all\n #require 'md5'\n @mycpu=::Digest::MD5.hexdigest('BFEBBFFF000306C4:20161201:1:CLOUDTIMESOFT')#bfebfbff000306c3\n\n\n #c12c-7881-d171-03e5\n #BF3E-A5AC-9455-EDE4\n #5c824ae9d86c37e1db5812b5583769df\n #b5197056ce8c70bc81f489283f149e81\n #464b 71841d6842377b94c467ea267558\n #7542670a3cf536689ec3907bb112e57a\n #5C82-B519-464B-7542\n #f345c094be13e1650214c2bfd12712cd\n#d600-384f-9969-987f\n#8180-0320-5227-611e\n#bcb1-abba-c612-776a\n#be11-e165-0214-c2bf\n if params[:user]!='' && params[:user]!= nil\n @users=User.where(\"login like '%\"+params[:user]+\"%'\").paginate(page:params[:page],per_page:10)\n\n end\n @[email protected]\n\n end", "def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end", "def throttles; end", "def get_random_user_list \n @users = user_list.sample(5).insert(rand(5), {name: \"ME\", bot: false})\n end", "def most_active_users\n ids = replies.not_anonymous.count(:user_id,\n :group => :user_id,\n :order => \"count_user_id DESC\",\n :limit => (4 - experts.length)).keys\n User.find(ids.compact)\n end", "def fetch_users!(track)\n log(\"Fetching users for track #{track.id}\")\n\n user_ids = track.user_ids.members\n\n user_ids.each do |user_id|\n next if user_id == @user.id.to_s\n\n user = Smoothie::User.new(user_id)\n\n next unless user.synced? && user.favorites_synced?\n\n add_user!(user, track)\n end\n end", "def index\n\t\t@interval = 10\n\t\t@page = 0\n\t\t@users = User.all.order('points DESC')\n\tend", "def unique_users(days=30)\n latest_executions(days).select(:user_id).distinct.count\n end", "def userActions\n timer = WebCrawler::startTime\n @session.all(\"[#{@vars[:user]}='popup'], [#{@vars[:user]}='click']\", :visible=>true).each do |el|\n begin\n event = el.native[@vars[:user]].to_s\n if event!='checked'\n WebCrawler::logInfo 'user.'+event, 'id => '+el.native[@vars[:id]]+', tag => '+el.native.tag_name\n el.click # Click (and Open Modal)\n if event=='popup'\n [email protected](\"[#{@vars[:user]}='popup.close']\",\n :visible =>true)\n if close!=nil\n WebCrawler::logInfo 'user.popup.close'+event, 'id => '+close.native[@vars[:id]]+', tag => '+close.native.tag_name\n close.click # Close Modal\n end\n end\n end\n rescue Selenium::WebDriver::Error::UnhandledAlertError\n begin\n @session.driver.browser.switch_to.alert.dismiss\n WebCrawler::logError 'user.click', 'Javascript Alert Closed'\n rescue\n #skip\n end\n rescue Capybara::Poltergeist::JavascriptError\n begin\n @session.find('body').native.send_keys :escape\n rescue\n #skip\n end\n rescue => e\n WebCrawler::logError 'user.error', e.message\n end\n end\n WebCrawler::logTime timer, 'userActions'\n end", "def select_tweeters(followers)\n result = []\n start_time = Time.now\n result_quality = 0\n\n # do grouping\n # should end up with an array of arrays (or nil), where each n-th position in\n # main array represents the array of userids that have n followers.\n grouped_users = [];\n followers.each_with_index do |follower_list, userid|\n list = grouped_users[follower_list.length];\n\n if list.nil?\n list = []\n grouped_users[follower_list.length] = list\n end\n\n list << userid\n end\n top_users = grouped_users.flatten.compact.reverse\n\n # determine top-n users to inspect\n top_n = sqrt(top_users.length)\n top_n = top_users.length / 5 if top_n < 7 # 20%\n top_n = top_users.length / 2 if top_n < 7 # 50%\n top_n = top_users.length if top_n < 7 # 100%\n # top_n = 34\n\n top_users[0..top_n].combination(5) do |combi|\n # array style\n # obtain a list of ALL followers of the chosen users\n follower_list = []\n\n # use concat to avoid creating new arrays\n # or having to flatten the array later\n combi.each { |num| follower_list.concat(followers[num]) }\n\n # remove dupes\n follower_list.uniq!\n\n # remove the candidate users\n combi.each { |num| follower_list.delete(num) }\n\n # update tracker variables if necessary\n if follower_list.size > result_quality\n result = combi\n result_quality = follower_list.size\n end\n\n # if (Time.now - start_time) > 5.985 # 0.25 is the floor\n # break\n # end\n end\n\n return result\nend", "def fremont_users\n\ttmp = Array.new\n\tres = Array.new\n\ti = 0\n\twhile (tmp = TOKEN.get('/v2/campus/7/users', params: { page: i, per_page: 100 }).parsed).length > 0\n\t\tputs 'user request page is ' + i.to_s\n\t\ttmp.each do |page|\n\t\t\tres.push(page)\n\t\tend\n\t\ti += 1\n\tend\n\treturn res\nend", "def find_next_userid\n number = ldap.search(:base => user_dn, :filter => \"cn=*\")\n uids = []\n number.each do |result|\n uids.push(result[:uidnumber])\n end\n next_uid = uids.flatten.last.to_i + 1\n if uids.flatten.include?(next_uid)\n next_uid + 1\n elsif uids.empty?\n next_uid = 20000\n end\n next_uid\n end", "def index\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['index']) do\n if params[:ids]\n ids = params[:ids].split(\",\")\n if ids.length <= 10\n @users = User.find(ids)\n @status = 200\n else\n render_error(400, \"too many ids included (max 10)\")\n end\n elsif user_signed_in?\n @status = 200\n @user = current_user\n @user_personal_roll_subdomain = (@user.public_roll and @user.public_roll.subdomain)\n render 'v1/user/show'\n else\n render_error(401, \"current user not authenticated\")\n end\n end\n end", "def entries user_id, num = 1, offset = 0, day = 30000000\n ActivityEntry.recent_most user_id, self.id, num, offset, day\n end", "def user_activity_live_data\n [\n {\n key: 'active_in_last_hour',\n name: t('statistics.entries.users.currently_active'),\n data: ExternalUser.joins(:submissions)\n .where(['submissions.created_at >= ?', DateTime.now - 5.minutes])\n .distinct('external_users.id').count,\n },\n {\n key: 'submissions_per_minute',\n name: t('statistics.entries.exercises.submissions_per_minute'),\n data: (Submission.where('created_at >= ?', DateTime.now - 1.hour).count.to_f / 60).round(2),\n unit: '/min',\n axis: 'right',\n },\n ]\n end", "def index\n @gatherings = current_user.gatherings\n @own_gatherings = (current_user.own_gatherings).sort_by{|g| g.created_at}\n @invited_gatherings = (@gatherings - @own_gatherings).sort_by{|g| g.created_at}\n session[:return_to] ||= request.referer\n end", "def top_ten_users\n # Get top 3 dank ranks total scores\n top_danks = DankRank.order('total_score DESC').limit(6)\n # For each top dank_rank, retrieve [lvl, points, id]\n top_users = top_danks.map { |dank| [User.find(dank.user_id).dank_rank.total_score, User.find(dank.user_id).dank_rank.rank_up_xp_progress, User.find(dank.user_id).id] }\n # Sort that array by level and then points\n top_users.sort!{|a, b| b <=> a}\n # Return the users\n return top_users.map { |array| User.find(array[2]) }\n end", "def user_ids\n page = 1\n per_page = 100\n user_ids = []\n puts 'collecting all user ids'\n loop do\n response = @conn.get api_url('/users'),\n { page: page, per_page: per_page }.merge(token)\n raise 'Error Retrieving user_ids' if response.status != 200\n ids = JSON.parse(response.body).collect { |u| u['id'] }\n user_ids.concat(ids)\n break if ids.size < per_page\n page += 1\n end\n puts 'returning now the user ids'\n user_ids.sort\n end", "def get_another_user\n\t\tputs \"Are there any more guests coming?\"\n\t\tmore_guests = gets.chomp\n\t\tuntil more_guests == \"no\"\n\t\t\tmerge_usr_icecream_choice(get_info)\n\t\t\tputs \"Are there any more guests coming?\"\n\t\t\tmore_guests = gets.chomp\n\t\tend\t\n\t\t@ice_cream_hash\t\n\tend", "def vertica_userids\n dd = dy2k() - 3 #let's be very conservatibe\n cmd = \"select distinct(sifi_uid) from cost_events where clicks > 0 and dd_id >= #{dd}\"\n puts cmd\n s = go_direct(cmd)\n xs = s.split(\"\\n\")\n vus = {} \n xs.each do |x|\n vus[x] = true\n end \n vus\nend", "def set_users\n @users = []\n \n if user_signed_in\n @users << current_user.tweets(:sort){:time_stamp}\n else\n User.all.each do |user|\n @users << user.tweets(:sort){:time_stamp}\n end\n end\n end", "def get_latest_users_signed_up(top = 5)\n doc = DocumentStore.get_document(DOCS[:latest_users_signedup])\n return nil if doc[:users].empty?\n users = doc[:users]\n\n get_multiple_users_by_uid(users.first(top))\n end", "def cumulative_company_users(stop, company)\n users = UserCompany.\n where(company: company).\n where.not(user_id: @test).\n where('started_at < ?', stop).\n pluck(:user_id).\n uniq\nend", "def index\n redirect_to new_user_session_path and return unless current_user\n @shortened_urls = ShortenedUrl.where(user_id: current_user.id)\n end", "def last_updates_viewed\n self.user.extend(Montage::User).last_login\n end", "def people_tracked_for_a_week_from(start_date)\n end_date = start_date + 6.days\n Timing.users_for_client_in_period(self.id, start_date, end_date)\n end", "def get_most_generic_for_users(doc_key, top = 5)\n doc = DocumentStore.get_document(doc_key)\n\n list = doc[:list]\n\n # now take all the uid's from activities and create an array of uid's\n keys = []\n list.each do |item|\n keys.push(item[0])\n end\n\n # if size > top (item count), trim back the array to the number of items desired\n keys = keys.first(top) if keys.size > top\n\n Rails.logger.debug(\"Most: #{doc_key}\")\n Rails.logger.debug(keys.inspect)\n Rails.logger.debug(\" \")\n\n # retrieve Users\n x = get_multiple_users_by_uid(keys)\n #Rails.logger.debug(x.inspect)\n x\n end", "def index\n $new_unread_messages_cnt = Message.current_user_unread(current_user).unread_messages.length\n @users = User.all.sort_by {|user| user.userInterests(current_user) + user.ccLocation(current_user.latitude, current_user.longitude) }.reverse\n @user = current_user\n @latTest = params[:lat]\n\n\n if current_user.is_admin == false or current_user.is_admin == nil\n redirect_to root_path\n end\n\n end", "def fetch_users\n user_relational_query = get_model_query\n @total_filtered_users = user_relational_query.count\n\n return if @total_filtered_users < 1\n offset = 0\n offset = @page_size * (@page_number - 1) if @page_number > 1\n @users = user_relational_query.limit(@page_size).offset(offset).all\n # No need to query kyc detail if filter applied is kyc_submitted_no\n if @allowed_filters[GlobalConstant::User.is_kyc_submitted_filter].to_s != GlobalConstant::User.kyc_submitted_false\n @user_kyc_details = UserKycDetail.using_client_shard(client: @client).\n where(user_id: @users.collect(&:id)).all.index_by(&:user_id)\n end\n end", "def facebook_actions\n self.publish_on_facebook\n self.notify_friends\n\n if Rails.env.production? and LevelUserLink.count % 1000 == 0\n FacebookFeedService.delay.publish_level_count(LevelUserLink.count)\n end\n end", "def raw_userids\n users = {}\n cmd = \"find /data/log/ctr -name 'ctr*.gz' -mtime -2 | xargs zcat\" \n IO.popen(cmd) do |io|\n while line = io.gets\n r = get_uid(line)\n #users[r[0]] = true # from cookie\n users[r[1]] = true # from sifi param\n end \n end\n users\nend", "def assign_user_id(users)\r\n highest_id = users.ids.max || 100 # reserve first 100 ids for testing\r\n return highest_id + 1\r\nend", "def twitter_user_data\n\t\t# IT WOULD BE NICE TO RE-FACTOR THIS SO IT IS THE SAME current_user as for other stats display...\n\t\t@twitter_graph = Authorization.where(\"user_id = ?\", current_user).where(\"provider = ?\", \"twitter\")\n\t\t@twitter_graph_user = TwitterUser.where(\"uid = ?\", @twitter_graph.first['uid'])\n\t\tdata_by_day = @twitter_graph_user.total_grouped_by_date(2.weeks.ago)\n\t\t#twitter_index_by_day = IvolveIndex.twitter_grouped_by_day(2.weeks.ago)\n\t\t(2.weeks.ago.to_date..Time.zone.today).map do |date|\n\t\t\tif !data_by_day[date].nil?\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = data_by_day[date].first.try(:friends_int_count)\n\t\t\t\tfollowers_count = data_by_day[date].first.try(:followers_int_count)\n\t\t\t\ttweets_count = data_by_day[date].first.try(:tweet_int_count)\n\t\t\t\tfavd_count = data_by_day[date].first.try(:favorite_int_count)\n\t\t\t\tlist_count = data_by_day[date].first.try(:listed_int_count)\n\t\t\telse\n\t\t\t\tcreated_at = date\n\t\t\t\tfriends_count = 0\n\t\t\t\tfollowers_count = 0\n\t\t\t\ttweets_count = 0\n\t\t\t\tfavd_count = 0\n\t\t\t\tlist_count = 0\n\t\t\tend\n\n\t\t\t{\n\t\t\t\tcreated_at: date,\n\t\t\t\tnum_friends: friends_count,\n\t\t\t\t#index_friends: twitter_index_friends,\n\t\t\t\tnum_followers: followers_count,\n\t\t\t\t#index_followers: twitter_index_followers,\n\t\t\t\ttweets_sent: tweets_count,\n\t\t\t\t#index_sent: twitter_index_sent,\n\t\t\t\ttweets_favd: favd_count,\n\t\t\t\t#index_favd: twitter_index_favd,\n\t\t\t\tnum_lists: list_count,\n\t\t\t\t#index_lists: twitter_index_lists,\n\t\t\t}\n\t\tend\n\tend", "def user_keep_stats\n for_every_user { |name, agent|\n begin\n page = agent.post('https://web4.castleagegame.com/castle_ws/keep.php', {'ajax' => '1'})\n\n # The only selector that is available is this awful style block\n stats = page.parser.xpath(\"//div[@style='width:112px;height:25px;font-size:15px;text-align:center;overflow:hidden;cursor:default;']\")\n\n if (stats.length != 0)\n energy = stats[0].text[/[0-9]+/]\n stamina = stats[1].text[/[0-9]+/]\n attack = stats[2].text[/[0-9]+/]\n defense = stats[3].text[/[0-9]+/]\n health = stats[4].text[/[0-9]+/]\n army = stats[5].text[/[0-9]+/]\n\n puts \"#{name}\\nE:#{energy}, S:#{stamina}, A:#{attack}, D:#{defense}, H:#{health}, Army:#{army}\\n\"\n end\n rescue Exception => ex\n puts \"Error in user_keep_stats. #{ex.class}, Message: #{ex.message}\"\n end\n }\n end", "def unseen_for(user_id, limit: 5)\n subjects.subtract user(user_id).seen, limit\n end", "def bootstrap_users\n @@bootstrap_users ||= []\n return @@bootstrap_users unless @@bootstrap_users.length == 0\n 12.times do\n u = User.gen\n @@bootstrap_users << u\n u.build_watch_collection\n end\n return @@bootstrap_users\nend", "def frauded\n Event.click.one_day.where('id != ? AND (ip = ? or uniqueuser = ?)', self.id, self.ip, self.uniqueuser)\n end", "def recent_login(users)\n\tputs 'starting recent_login, length is ' + users.length.to_s\n\tres = Array.new\n\tlast_month_unform = (Time.current - 30.days).to_s.split(\" \")\n\ttoday_unform = Time.current.to_s.split(\" \")\n\tlast_month = last_month_unform[0] + 'T' + last_month_unform[1]\n\ttoday = today_unform[0] + 'T' + today_unform[1]\n\tusers.each do |person|\n\t\ttmp = person['id'].to_s\n\t\tresponse = TOKEN.get(\"/v2/users/\" + tmp + \"/locations?range[begin_at]=#{last_month},#{today}\").parsed\n\t\tif response.length > 0\n\t\t\tres.push(person)\n\t\tend\n\tend\n\treturn res\nend", "def top_10_followers\n users_array = UserLeague.all.collect{|user| user.user_id}\n most_common_value = users_array.uniq.sort_by{ |i| users_array.count( i ) }.reverse\n biggest_followers = most_common_value.map {|user| User.find(user).name}[0..9]\n users_league_count = most_common_value.map {|user| User.find(user).leagues.count}[0..9]\n counter = 0\n return_hash = {}\n until counter == biggest_followers.length do\n return_hash[biggest_followers[counter].to_s] = users_league_count[counter].to_s\n counter += 1\n end\n return_hash\nend", "def perform\n users = User.all\n\n users.each do |user|\n\n # Pull User status using Steam API\n url = \"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=#{ENV[\"STEAM_WEB_API_KEY\"]}&steamids=#{user.steam_uid}\"\n parsed_data = JSON.parse(open(url).read)\n online_status = parsed_data[\"response\"][\"players\"][0][\"personastate\"]\n\n\n # Steam has many different status types, but anything above zero is indicative of the User having Steam open and being sign-in on at least one device\n if online_status > 0\n online_status = 1\n\n in_game_status = parsed_data[\"response\"][\"players\"][0][\"gameid\"]\n\n # If user is not in-game, in_game_status will be nil\n if in_game_status.nil?\n in_game_status = 0\n looking_to_play_status = 0\n else\n # Set Looking to play status based on game (Steamm returns app_id number when player is playing a game)\n current_game = user.owned_games.find_by(:app_id => in_game_status)\n looking_to_play_status = user.libraries.find_by(:game_id => current_game.id).default_looking_to_play_status\n end\n #If offline, player cannot be in a game and is not looking to play\n else\n in_game_status = 0\n looking_to_play_status = 0\n end\n\n # Store the user's last played game if they have played a game and this has been previously recorded in our database\n if user.in_game_status != 0 && in_game_status == 0\n user.last_played_game = user.in_game_status\n end\n\n #Update user entry\n user.online_status = online_status\n user.in_game_status = in_game_status\n user.looking_to_play_status = looking_to_play_status\n user.save\n end\n end", "def update_user_data!(owner_user_ids)\n owner_user_ids.each do|user_id|\n ::User.recalculate_item_count_of!(user_id)\n end\n end", "def recent_five(company, user)\n if !user.auditor?\n if user.owner?\n includes(:user).where(:company_id => company.id).limit(5).order(\" action_time DESC\")\n elsif user.on_branch?\n includes(:user).where(:company_id => company.id, :user_id => user.id, :branch_id => user.branch_id).limit(5).order(\" action_time DESC\")\n else\n includes(:user).where(:company_id => company.id, :user_id => user.id).limit(5).order(\" action_time DESC\")\n end\n end\n end", "def get_results\n \titems = self.possessions.find(:all, :limit => 20, :order => 'wants_count DESC')\n #reset data just for testing\n Possession.all.each do |item|\n item.new_owner = nil\n item.save\n end\n \t# items = prune(items)\n \tif items.count > 1\n \t\tfind_some_trades(items)\n \tend\n end", "def top_comm\n\t\t\t@commenters = User.all.order('comments.id DESC').joins('LEFT JOIN comments ON \n\t\t\t\tcomments.user_id == users.id').group('users.id').where('comments.created_at >= ?',\n\t\t\t\t1.week.ago.utc).limit(10)\n\t\tend", "def add_extra_openings\n users = User.all\n n = 0\n users.each do |u|\n n += 1\n next if n < 20 || rand < 0.2 || u.openings.count.positive?\n\n u.openings.create(title: \"Opening #{n}: #{Faker::Job.title}\",\n description: \"Description #{n}: #{Faker::Lorem.paragraph(10)}\",\n created_at: 11.minutes.ago,\n updated_at: 10.minutes.ago)\n end\nend" ]
[ "0.6103421", "0.5991539", "0.5965249", "0.5948182", "0.5870699", "0.58474016", "0.58361214", "0.57954884", "0.5776195", "0.5744218", "0.5740562", "0.572575", "0.57246447", "0.57131743", "0.56965244", "0.5663211", "0.5655865", "0.56164676", "0.56138456", "0.560787", "0.5579076", "0.5574053", "0.5571326", "0.5556961", "0.55287176", "0.55272514", "0.5522721", "0.5521195", "0.55204326", "0.5506196", "0.55031985", "0.5496341", "0.5493238", "0.5483814", "0.54747295", "0.54676956", "0.5458723", "0.5444451", "0.5437552", "0.54336447", "0.5411328", "0.5401441", "0.5397945", "0.53901094", "0.5389196", "0.53812385", "0.5377088", "0.53663623", "0.536281", "0.53426534", "0.533448", "0.5333778", "0.5325047", "0.5315426", "0.5314002", "0.5313893", "0.5308513", "0.5305774", "0.5301555", "0.52935594", "0.52900213", "0.5288681", "0.5276834", "0.5261081", "0.5250937", "0.5249221", "0.5248121", "0.52470446", "0.52437264", "0.52402884", "0.52402365", "0.52350175", "0.52337354", "0.5230441", "0.52256745", "0.52206624", "0.5212454", "0.5203923", "0.5200468", "0.51977015", "0.51938844", "0.51903325", "0.5184626", "0.51834494", "0.51809675", "0.51796794", "0.51744515", "0.5167717", "0.51654977", "0.51644593", "0.51619", "0.5151098", "0.51426625", "0.51400566", "0.513687", "0.51356643", "0.51344544", "0.5132761", "0.5131827", "0.5126623", "0.5125558" ]
0.0
-1
GQL updates assign values using the array syntax See gql_expression.rb
def []=(attr_name, value) writer_method = "#{attr_name}=" send(writer_method, value) if respond_to?(writer_method) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update()\ndb = PG connect( {dbname: 'bounty_hunter',\n host: 'localhost'\n })\nsql = \"UPDATE bounty_hunters\nSET (name,\n species,\n homeworld,\n favourite_weapon\n )=(\n $1, $2, $3, $4\n )\n WHERE id = $5\n \"\n\nvalues = [@name, @species, @homeworld, @favourite_weapon]\ndb.prepare('update',sql)\n db.exec_prepared('update', values)\n db.close\nend", "def _construct_multiple_update_sql(table, where_update_fields, where_update_values)\n id_collector = Array.new\n update_sql = \"UPDATE #{table} SET\"\n \n (where_update_fields.length - 1).times do |field_i|\n update_sql += \", \" if field_i > 0\n update_sql += \" #{where_update_fields[field_i + 1]} = CASE #{where_update_fields[0]}\"\n \n where_update_values.each_index do |i|\n update_sql += \" WHEN \" + _construct_sql_value(where_update_values[i][0]) + \" THEN \" + _construct_sql_value(where_update_values[i][field_i + 1])\n id_collector << _construct_sql_value(where_update_values[i][0]) if field_i == 0\n end\n \n update_sql += \" END\"\n end\n \n update_sql += \" WHERE #{where_update_fields[0]} in (\" + id_collector.join(\",\") + \")\"\n \n update_sql\n end", "def assign_arrays_to_profile(args = {}) \n body_put(\"/profiles.json/#{args[:profileId]}/arrays\", args[:array_of_ids])\nend", "def update_value(tsvector_sql)\n sql = <<~SQL\n UPDATE polysearches\n SET value = (#{tsvector_sql})\n WHERE searchable_type = :searchable_type\n AND searchable_id = :searchable_id;\n SQL\n self.class.connection.execute self.class.sanitize_sql_array([\n sql,\n searchable_type: searchable_type,\n searchable_id: searchable_id\n ])\n end", "def build_update(data)\n sql = \"\"\n data.each do |k,v|\n sql += \"`#{escape_str_field(k)}` = \"+escape_value(v)+\", \"\n end\n sql.chomp(\", \")\n end", "def update()\n #connect to db\n db = PG.connect({ dbname: \"bounty_hunters\", host: \"localhost\" })\n #write big SQL statement string\n sql = \"UPDATE bounties\n SET\n (\n name,\n species,\n bounty_value,\n favourite_weapon\n ) =\n (\n $1, $2, $3, $4\n )\n WHERE id = $5\"\n\n #make array of values for prepared statement\n values = [@name, @species, @bounty_value, @favourite_weapon, @id]\n #prepare statement\n db.prepare(\"update\", sql)\n #run statement with db\n db.exec_prepared(\"update\", values)\n #close link to db\n db.close()\n end", "def assign_arrays_to_tenant(args = {}) \n body_put(\"/tenants.json/#{args[:tenantId]}/arrays\", args[:array_of_ids])\nend", "def batch_update(updates,commit=true)\n params=\"[{\\\"id\\\":\\\"#{id}\\\",\"\n updates.each do |update|\n params+=\"\\\"#{update[:field]}\\\":\"\n if update[:operation] == 'add'\n params+=\"{\\\"add\\\":\\\"#{update[:new_values].gsub('\"','\\\"')}\\\"}\"\n elsif update[:operation] == 'remove'\n params+=\"{\\\"set\\\":null}\"\n else\n update[:new_values]=self.class.to_array(update[:new_values])\n new_values = update[:new_values].map {|s| s.to_s.gsub(\"\\\\\",\"\\\\\\\\\\\\\").gsub('\"','\\\"').strip} # strip leading/trailing spaces and escape quotes for each value\n params+=\"{\\\"set\\\":[\\\"#{new_values.join('\",\"')}\\\"]}\"\n end\n params+=\",\"\n end\n params.chomp!(\",\")\n params+=\"}]\"\n post_to_solr(params,commit)\n end", "def make_update_expression_values(event,attr_values)\n\t\tupdate_string = 'SET '\n\t\tevent.each do |k,v|\n\t\t\tupdate_string += \"#{make_expression_key(k,\"names\")} = #{attr_values[k].key(v)}, \"\n\t\tend\n\t\treturn update_string[0...-2]\n\tend", "def dbupdate(table, variables, condition, names)\n if variables.kind_of?(Array) == false\n v = variables.to_s + \"=?\"\n else\n v = \"\"\n i = 0\n while i < variables.length\n v += variables[i].to_s + \"=?\"\n i += 1\n if i < variables.length\n v += \", \"\n end\n end\n end\n\n if condition.kind_of?(Array) == false\n c = condition.to_s + \"=?\"\n else\n c = \"\"\n i = 0\n while i < condition.length\n c += condition[i].to_s + \"=?\"\n i += 1\n if i < condition.length\n c += \" AND \"\n end\n end\n end\n\n return db.execute(\"UPDATE #{table} SET #{v} WHERE #{c}\", names)\nend", "def push_all(*args)\n if args.length == 1 && args.first.is_a?(Hash)\n query.update_all(\"$push\" => collect_each_operations(args.first))\n else\n query.update_all(\"$push\" => { database_field_name(args[0]) => { \"$each\" => Array.wrap(args[1]) } })\n end\n end", "def update!(**args)\n @sql_expression = args[:sql_expression] if args.key?(:sql_expression)\n end", "def update!(**args)\n @sql_expression = args[:sql_expression] if args.key?(:sql_expression)\n end", "def sql_array(array)\n Arel.sql(ActiveRecord::Base.sanitize_sql([\"ARRAY[?]\", array]))\n end", "def update_all_by(key, values={})\n CQLModel::Query::UpdateStatement.new(self.class).update(values.merge({ key => @cql_properties[key.to_s] }))\n end", "def update_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend", "def update!(**args)\n @all_values = args[:all_values] if args.key?(:all_values)\n @range = args[:range] if args.key?(:range)\n @value = args[:value] if args.key?(:value)\n end", "def convert_to_sql(array_of_values)\n array_of_values.inspect[1...-1].gsub('[', '(').gsub(']', ')')\n end", "def update!(**args)\n @dimension = args[:dimension] if args.key?(:dimension)\n @expression = args[:expression] if args.key?(:expression)\n @operator = args[:operator] if args.key?(:operator)\n end", "def update()\n sql = \"UPDATE customers (name, funds) = ($1, $2) WHERE id = $3\"\n values = [@name, @funds, @id]\n SqlRunner.run(sql,values)\n# => Updating only, no need to return any array\n end", "def compose_sql_array(ary)\n statement, *values = ary\n if values.first.is_a?(Hash) and statement =~ /:\\w+/\n replace_named_bind_variables(statement, values.first)\n elsif statement.include?('?')\n replace_bind_variables(statement, values)\n else\n statement % values.collect { |value| client.escape(value.to_s) }\n end\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @values = args[:values] if args.key?(:values)\n end", "def update!(**args)\n @gx_ids = args[:gx_ids] if args.key?(:gx_ids)\n @primary_keys = args[:primary_keys] if args.key?(:primary_keys)\n end", "def set(assignments)\n assignments.map do |attr, value|\n next unless attr.present?\n\n name = attr.is_a?(Arel::Attributes::Attribute) ? attr.name : attr.to_s\n\n quoted = record.class.connection.quote_column_name(name)\n \"#{quoted} = (#{value.to_sql})\"\n end.join(', ')\n end", "def update\n sql = 'UPDATE albums SET (title, genre) = ($1, $2) WHERE id = $3;'\n values = [@title, @genre, @id]\n SqlRunner.run(sql, values)\n end", "def update()\n\n sql = \"UPDATE customers SET (\n name,\n funds\n ) =\n (\n $1, $2\n )\n WHERE id = $3\"\n values = [@title, @price, @id]\n tickets_update = SqlRunner.run(sql, values)\n\nend", "def update!(**args)\n @annotation_list = args[:annotation_list] if args.key?(:annotation_list)\n @eval_data = args[:eval_data] if args.key?(:eval_data)\n @qref = args[:qref] if args.key?(:qref)\n @raw_text = args[:raw_text] if args.key?(:raw_text)\n end", "def update where: , set: {}, **arg\n\t\t# In OrientDB V.3 the database only returns the affected rid's \n\t\t# We have to update the contents manually, this is done in the execute-block\n\t\tquery( kind: :update, set: set.merge(arg), where: where).execute{|y| y[:$current].reload!}\n\tend", "def update_sql(values = {}, opts = nil, &block)\n opts = opts ? @opts.merge(opts) : @opts\n\n if opts[:group]\n raise Error::InvalidOperation, \"A grouped dataset cannot be updated\"\n elsif (opts[:from].size > 1) or opts[:join]\n raise Error::InvalidOperation, \"A joined dataset cannot be updated\"\n end\n \n sql = \"UPDATE #{source_list(@opts[:from])} SET \"\n if block\n sql << block.to_sql(self, :comma_separated => true)\n else\n set = if values.is_a?(Hash)\n # get values from hash\n values = transform_save(values) if @transform\n values.map do |k, v|\n # convert string key into symbol\n k = k.to_sym if String === k\n \"#{literal(k)} = #{literal(v)}\"\n end.join(COMMA_SEPARATOR)\n else\n # copy values verbatim\n values\n end\n sql << set\n end\n if where = opts[:where]\n sql << \" WHERE #{literal(where)}\"\n end\n\n sql\n end", "def set(values); end", "def []=(*args) #:nodoc:\n self[].send(:[]=, *args)\n end", "def values_to_query(new_query_values, options = {})\n options[:notation] ||= :subscript\n return if new_query_values.nil?\n\n unless new_query_values.is_a?(Array)\n unless new_query_values.respond_to?(:to_hash)\n raise TypeError,\n \"Can't convert #{new_query_values.class} into Hash.\"\n end\n new_query_values = new_query_values.to_hash\n new_query_values = new_query_values.inject([]) do |object, (key, value)|\n key = key.to_s if key.is_a?(::Symbol) || key.nil?\n if value.is_a?(Array) && value.empty?\n object << [key.to_s + '[]']\n elsif value.is_a?(Array)\n value.each { |v| object << [key.to_s + '[]', v] }\n elsif value.is_a?(Hash)\n value.each { |k, v| object << [\"#{key.to_s}[#{k}]\", v]}\n else\n object << [key.to_s, value]\n end\n object\n end\n # Useful default for OAuth and caching.\n # Only to be used for non-Array inputs. Arrays should preserve order.\n begin\n new_query_values.sort! # may raise for non-comparable values\n rescue NoMethodError, ArgumentError\n # ignore\n end\n end\n\n buffer = ''.dup\n new_query_values.each do |parent, value|\n encoded_parent = ::Addressable::URI.encode_component(\n parent.dup, ::Addressable::URI::CharacterClasses::UNRESERVED\n )\n buffer << \"#{to_query(encoded_parent, value, options)}&\"\n end\n buffer.chop\n end", "def update!(**args)\n @conjunctions = args[:conjunctions] if args.key?(:conjunctions)\n @disjunctions = args[:disjunctions] if args.key?(:disjunctions)\n @subs_key = args[:subs_key] if args.key?(:subs_key)\n end", "def update_statement(properties, query)\n conditions_statement, bind_values = conditions_statement(query.conditions)\n\n statement = \"UPDATE #{quote_name(query.model.storage_name(name))}\"\n statement << \" SET #{properties.map { |property| \"#{quote_name(property.field)} = ?\" }.join(', ')}\"\n statement << \" WHERE #{conditions_statement}\" unless conditions_statement.blank?\n\n return statement, bind_values\n end", "def sql_update_set\n attributes.keys.map { |attr_name| \"#{attr_name} = ?\" }\n .join(\", \")\n end", "def update # EXTENSION\n sql = \"UPDATE tickets SET customer_id = $1, film_id = $2, screening_id = $3 WHERE id = $4\"\n values = [@customer_id, @film_id, @screening_id, @id]\n SqlRunner.run(sql, values)\nend", "def test_update_with_GT1;\n a=[[1,0,1],[0,1,0]]\n show(a)\n a[1][2]=1.1\n end", "def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end", "def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end", "def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end", "def update!(**args)\n @ids = args[:ids] if args.key?(:ids)\n end", "def table_update_query(table, values, org_key = nil)\n org_key ||= values\n query = \"update #{quote_table_name(table)} set \"\n query << values.map do |column_name, value|\n \"#{quote_column_name(column_name)} = #{quote_value(table, column_name, value)}\"\n end.join(', ')\n query << \" where (\" << quote_key_list(table) << \") = (\"\n query << primary_key_names(table).map do |key|\n quote_value(table, key, org_key[key])\n end.join(', ') << \")\"\n end", "def update(groceries_list, update_item, update_quantity)\n groceries_list[update_item.to_sym] = update_quantity\nend", "def update_solr(field_name,operation,new_values,commit=true)\n params=\"[{\\\"id\\\":\\\"#{id}\\\",\\\"#{field_name}\\\":\"\n if operation == 'add'\n params+=\"{\\\"add\\\":\\\"#{new_values.gsub('\"','\\\"')}\\\"}}]\"\n elsif operation == 'remove'\n params+=\"{\\\"set\\\":null}}]\"\n else\n new_values=[new_values] unless new_values.class==Array\n new_values = new_values.map {|s| s.to_s.gsub(\"\\\\\",\"\\\\\\\\\\\\\").gsub('\"','\\\"').strip} # strip leading/trailing spaces and escape quotes for each value\n params+=\"{\\\"set\\\":[\\\"#{new_values.join('\",\"')}\\\"]}}]\"\n end\n post_to_solr(params,commit)\n end", "def update_quantity(list, string, integer)\n\tlist[string]=integer\n\treturn list\nend", "def update_quantity(list, string, integer)\n\tlist[string]=integer\n\treturn list\nend", "def update!(**args)\n @group_ids = args[:group_ids] if args.key?(:group_ids)\n @id = args[:id] if args.key?(:id)\n end", "def update\n sql =\"UPDATE tags SET (tag_name) = ($1) WHERE id = $2\"\n values = [@tag_name, @id]\n SqlRunner.run(sql, values)\n end", "def update_array_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/arrays/{arrayId}\"\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 mutliplied(array)\nend", "def rewrite_param_values(array_params); end", "def update_query( hash )\n \n # Convert symbols to strings to avoid duplicate entries\n hash = Hash[hash.map {|k, v| [ k.to_s, v] }] if hash.keys.any? { |k| k.is_a?(Symbol) }\n \n # Merge the changes with the existing query\n query.query_values = query.query_values.merge!( hash )\n \n self\n end", "def update_many(filter, update, options = nil)\n result = native.update_many(filter, update, options || {})\n update_result(result)\n end", "def set_values(array)\n @row = array\n end", "def update data, table, condition = {}\n sql = \"update #{table} set\"\n data.each do |k,v|\n v = v.to_json if v.is_a?(Hash)\n if !!v == v\n sql = \"#{sql} #{k}=#{v},\"\n else\n sql = \"#{sql} #{k}='#{v}',\"\n end\n end\n sql = sql[0..-2] + \" where\"\n condition.each do |k,v|\n sql = \"#{sql} #{k} = '#{v}' and\"\n end\n query(sql[0..-4])\n end", "def update()\n sql = \"UPDATE artists SET (title, genre, artist_id)\n VALUES ($1, $2, $3) WHERE id = $4\"\n values = [@title, @genre, @artist_id, @id]\n SqlRunner.run(sql, values)\n end", "def update!(**args)\n @annotation_list = args[:annotation_list] if args.key?(:annotation_list)\n @eval_data = args[:eval_data] if args.key?(:eval_data)\n @play_more = args[:play_more] if args.key?(:play_more)\n @qref = args[:qref] if args.key?(:qref)\n @raw_text = args[:raw_text] if args.key?(:raw_text)\n end", "def update!(**args)\n @max_comparison_value = args[:max_comparison_value] if args.key?(:max_comparison_value)\n @dimension_name = args[:dimension_name] if args.key?(:dimension_name)\n @operator = args[:operator] if args.key?(:operator)\n @expressions = args[:expressions] if args.key?(:expressions)\n @case_sensitive = args[:case_sensitive] if args.key?(:case_sensitive)\n @min_comparison_value = args[:min_comparison_value] if args.key?(:min_comparison_value)\n end", "def update!(**args)\n @group_edges = args[:group_edges] if args.key?(:group_edges)\n @identities = args[:identities] if args.key?(:identities)\n end", "def update_relation(field_name, *obj)\n # Should be an Array of RDF::Term objects\n return unless obj\n\n obj.map! { |item| item.is_a?(RDF::URI) ? Ladder::Resource.from_uri(item) : item }\n relation = send(field_name)\n\n if Mongoid::Relations::Targets::Enumerable == relation.class\n obj.map { |item| relation.send(:push, item) unless relation.include? item }\n else\n send(\"#{field_name}=\", obj.size > 1 ? obj : obj.first)\n end\n end" ]
[ "0.61298466", "0.593655", "0.5844621", "0.5781451", "0.57772154", "0.5749875", "0.5727808", "0.568228", "0.5679099", "0.56617135", "0.56531876", "0.5637537", "0.5637537", "0.5619162", "0.55932915", "0.5591016", "0.5575658", "0.55086315", "0.55009204", "0.54883045", "0.54776835", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.54615635", "0.5460738", "0.5433715", "0.5416812", "0.5375689", "0.5361208", "0.5356713", "0.53412086", "0.5325315", "0.53245676", "0.53081775", "0.5307174", "0.52914053", "0.52805704", "0.52767694", "0.5273872", "0.52725023", "0.5268797", "0.5268797", "0.5268797", "0.5268797", "0.526876", "0.526521", "0.5254116", "0.5251785", "0.5251785", "0.5242434", "0.5240901", "0.5232523", "0.5207515", "0.5201276", "0.51928467", "0.5185528", "0.51824963", "0.51718426", "0.51564026", "0.51511973", "0.51275396", "0.51230866", "0.5121119" ]
0.0
-1
need to add model test
def pet_count pets.count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup(model_class); end", "def setup(model_class); end", "def make_and_model; end", "def set_test_model\n @test_model = TestModel.find(params[:id])\n end", "def set_test_model\n @test_model = TestModel.find(params[:id])\n end", "def test_model\n assert_raise(ArgumentError){@test_car.model('Civic')}\n end", "def testing\n # ...\n end", "def tests; end", "def tests; end", "def test_WITH_a_model_defined_in_both_app_and_plugin_IT_should_load_the_one_in_app\r\n \t assert_equal 'AppAndPluginModel (from app)',\tAppAndPluginModel.report_location \r\n \t assert_raises(NoMethodError) { AppAndPluginLibModel.defined_only_in_alpha_engine_version }\r\n end", "def test_setup\r\n \r\n end", "def test_model_model_get\n models = %w(Model1 Model2 Model3 Model4)\n values = [%w(one1 many1 belong1 att1 ser1), %w(one2 many2 belong2 att2 ser2), %w(one3 many3 belong3 att3 ser3)]\n models.each do |model_name|\n assert model = Microformats::Models.model_get(model_name), \"Failed to get new model #{model}\"\n assert_equal model.name, \"Microformats::Models::#{model_name}\", \"Name for model #{model} not set correctly\"\n # setup the initial values and test they are what we expect\n assert model.have_one << values[0][0], \"Failed to append #{values[0][0]} to #{model.name}.have_one\"\n assert model.have_many << values[0][1], \"Failed to append #{values[0][1]} to #{model.name}.have_many\"\n assert model.belong_to << values[0][2], \"Failed to append #{values[0][2]} to #{model.name}.belong_to\"\n assert model.validations << values[0][3], \"Failed to append #{values[0][3]} to #{model.name}.validations\"\n assert model.serialize << values[0][4], \"Failed to append #{values[0][4]} to #{model.name}.serialize\"\n # check they are there\n assert_equal model.have_one[0], values[0][0], \"Expected #{values[0][0]} but was #{model.have_one[0]}\"\n assert_equal model.have_many[0], values[0][1], \"Expected #{values[0][1]} but was #{model.have_many[0]}\"\n assert_equal model.belong_to[0], values[0][2], \"Expected #{values[0][2]} but was #{model.belong_to[0]}\"\n assert_equal model.validations[0], values[0][3], \"Expected #{values[0][3]} but was #{model.validations[0]}\"\n assert_equal model.serialize[0], values[0][4], \"Expected #{values[0][4]} but was #{model.serialize[0]}\"\n # append a 2nd value\n assert model.have_one << values[1][0], \"Failed to append #{values[1][0]} to #{model.name}.have_one\"\n assert model.have_many << values[1][1], \"Failed to append #{values[1][1]} to #{model.name}.have_many\"\n assert model.belong_to << values[1][2], \"Failed to append #{values[1][2]} to #{model.name}.belong_to\"\n assert model.validations << values[1][3], \"Failed to append #{values[1][3]} to #{model.name}.validations\"\n assert model.serialize << values[1][4], \"Failed to append #{values[1][4]} to #{model.name}.serialize\"\n # check it is there\n assert_equal model.have_one[1], values[1][0], \"Expected #{values[1][0]} but was #{model.have_one}\"\n assert_equal model.have_many[1], values[1][1], \"Expected #{values[1][1]} but was #{model.have_many}\"\n assert_equal model.belong_to[1], values[1][2], \"Expected #{values[1][2]} but was #{model.belong_to}\"\n assert_equal model.validations[1], values[1][3], \"Expected #{values[1][3]} but was #{model.validations}\"\n assert_equal model.serialize[1], values[1][4], \"Expected #{values[1][4]} but was #{model.serialize}\"\n # try to add a duplicate\n assert_nil model.have_one << values[1][0], \"Should not be able to append #{values[1][0]} to #{model.name}.have_one\"\n assert_nil model.have_many << values[1][1], \"Should not be able to append #{values[1][1]} to #{model.name}.have_many\"\n assert_nil model.belong_to << values[1][2], \"Should not be able to append #{values[1][2]} to #{model.name}.belong_to\"\n assert_nil model.validations << values[1][3], \"Should not be able to append #{values[1][3]} to #{model.name}.validations\"\n assert_nil model.serialize << values[1][4], \"Should not be able to append #{values[1][4]} to #{model.name}.serialize\"\n # check the orginals are still valid\n assert_equal model.have_one[0], values[0][0], \"Expected #{values[0][0]} but was #{model.have_one[0]}\"\n assert_equal model.have_many[0], values[0][1], \"Expected #{values[0][1]} but was #{model.have_many[0]}\"\n assert_equal model.belong_to[0], values[0][2], \"Expected #{values[0][2]} but was #{model.belong_to[0]}\"\n assert_equal model.validations[0], values[0][3], \"Expected #{values[0][3]} but was #{model.validations[0]}\"\n assert_equal model.serialize[0], values[0][4], \"Expected #{values[0][4]} but was #{model.serialize[0]}\"\n # re-define the whole shooting match\n# model.have_one, model.have_many, model.belong_to, model.validations = *values[2]\n# assert_equal model.have_one[0], values[2][0], \"Expected #{values[2][0]} but was #{model.have_one[0]}\"\n# assert_equal model.have_many[0], values[2][1], \"Expected #{values[2][1]} but was #{model.have_many[0]}\"\n# assert_equal model.belong_to[0], values[2][2], \"Expected #{values[2][2]} but was #{model.belong_to[0]}\"\n# assert_equal model.validations[0], values[2][3], \"Expected #{values[2][3]} but was #{model.validations[0]}\"\n # and is this the only attribute\n# assert_equal model.have_one.length, 1, \"Expected 1 value but got #{model.have_one}\"\n# assert_equal model.have_many.length, 1, \"Expected 1 value but got #{model.have_many}\"\n# assert_equal model.belong_to.length, 1, \"Expected 1 value but got #{model.belong_to}\"\n# assert_equal model.validations.length, 1, \"Expected 1 value but got #{model.validations}\"\n end\n # test the enumerator\n end", "def build_unit_test \n \n return if skip_method(__method__)\n \n filename = \"#{singular_table_name}_test.rb\"\n puts \"build Rails unit test for #{model_name} in test/models\"\n # build model test\n \n template = File.read(template(\"rails/test/unit_test.rb\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = File.join(\"test\",\"models\",filename)\n write_artifact(path,text)\n end", "def test_created(test)\n\n end", "def generate_alltest\n\n end", "def test\n\n end", "def test \n end", "def mock_model_simple(model,expected=:all)\n mock_model model, :name, expected\n end", "def test\n puts \"(model): RUNNING before_save CALLBACK!!!##\"\n end", "def test_model_stored\r\n model=Model[1]\r\n assert_equal(@mymodel, model)\r\n \r\n newmodel = Model.new(2, 'short term') \r\n assert_equal(Model[2], newmodel)\r\n Model.delete(newmodel)\r\n\r\n begin\r\n Model[newmodel.ident]\r\n assert(false)\r\n rescue EvidenceError\r\n assert(true)\r\n end\r\n end", "def test_is_applicable_to_test_models\n\t[\"LargeHotel-90.1-2010-ASHRAE 169-2006-3B.osm\", \"LargeOffice-90.1-2010-ASHRAE 169-2006-5A.osm\", \"MediumOffice-90.1-2010-ASHRAE 169-2006-5A.osm\", \"PrimarySchool-90.1-2007-ASHRAE 169-2006-2A.osm\", \"SecondarySchool-90.1-2010-ASHRAE 169-2006-4A.osm\", \"SmallHotel-90.1-2010-ASHRAE 169-2006-3B.osm\", \"SmallOffice-90.1-2010-ASHRAE 169-2006-2A.osm\"].each do |m|\n\t\tresult,_ = applytotestmodel(m)\n\t\tassert_equal(\"Success\", result.value.valueName)\n end\n end", "def default_test\r\n end", "def model_class\n self.name.gsub(/Test$/, '').constantize\n end", "def test\n end", "def test\n end", "def test\n end", "def test_listchunk_attributes\n\t\t\n\tend", "def test_0_dummy\n\t\tend", "def test_method\n end", "def before_test(test); end", "def before_test(test); end", "def test_model\n tacoma = Vehicle.new(color: \"Silver\", model_year: 2007, manufacturer: \"Toyota\", model: \"Tacoma\")\n actual = tacoma.model\n assert_equal('Tacoma', actual, \"'Tacoma' as a string should be returned\")\n\n tacoma.model = 'Tundra'\n actual = tacoma.model\n assert_equal('Tundra', actual, \"'Tundra' as a string should be returned\")\n end", "def test_case; end", "def default_test\n end", "def setup_test(test_name, idf_output_requests, model_in_path, epw_path = epw_path_default)\n\n if !File.exist?(run_dir(test_name))\n FileUtils.mkdir_p(run_dir(test_name))\n end\n assert(File.exist?(run_dir(test_name)))\n\n if File.exist?(report_path(test_name))\n FileUtils.rm(report_path(test_name))\n end\n\n assert(File.exist?(model_in_path))\n\n if File.exist?(model_out_path(test_name))\n FileUtils.rm(model_out_path(test_name))\n end\n\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new(\"Draft\".to_StrictnessLevel, \"EnergyPlus\".to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(test_name), true)\n\n if is_openstudio_2?\n setup_test_2(test_name, epw_path)\n else\n setup_test_1(test_name, epw_path)\n end\n end", "def run(model, runner, user_arguments)\n super(model, runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments(model), user_arguments)\n return false\n end\n\n # assign the user inputs to variables\n case_num = runner.getStringArgumentValue(\"case_num\", user_arguments)\n runner.registerInfo(\"Full case number: #{case_num}\")\n\n # report initial condition of model\n runner.registerInitialCondition(\"The initial model named #{model.getBuilding.name} has #{model.numObjects} objects.\")\n\n # map case number to arguments and report back arguments\n variable_hash = BestestCaseVarLib.bestest_5_4_case_lookup(case_num,runner)\n if variable_hash == false\n runner.registerError(\"Didn't find #{case_num} in model variable hash.\")\n return false\n else\n # should return one item, get the hash\n variable_hash = variable_hash.first\n end\n\n # Adjust simulation settings if necessary\n # todo - do I want simple or should this be skipped\n BestestModelMethods.config_sim_settings(runner,model,'Simple','Simple')\n\n # Add weather file(won't work in apply measures now)\n top_dir = File.dirname(__FILE__)\n weather_dir = \"#{top_dir}/resources/\"\n weather_file_name = \"#{variable_hash[:epw]}WY2.epw\"\n weather_file = File.join(weather_dir, weather_file_name)\n epw_file = OpenStudio::EpwFile.new(weather_file)\n weather_object = OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file).get\n weather_name = \"#{epw_file.city}_#{epw_file.stateProvinceRegion}_#{epw_file.country}\"\n weather_lat = epw_file.latitude\n weather_lon = epw_file.longitude\n weather_time = epw_file.timeZone\n weather_elev = epw_file.elevation\n site = model.getSite\n site.setName(weather_name)\n site.setLatitude(weather_lat)\n site.setLongitude(weather_lon)\n site.setTimeZone(weather_time)\n site.setElevation(weather_elev)\n runner.registerInfo(\"Weather > setting weather to #{weather_object.url.get}\")\n\n # need design days for OpenStudio to run, but values should not matter\n summer_design_day = OpenStudio::Model::DesignDay.new(model)\n winter_design_day = OpenStudio::Model::DesignDay.new(model)\n winter_design_day.setDayType('WinterDesignDay')\n\n # set runperiod\n run_period = model.getRunPeriod\n run_period.setEndMonth(3)\n run_period.setEndDayOfMonth (31)\n runner.registerInfo(\"Run Period > Setting Simulation Run Period from 1/1 through 3/31.\")\n\n # Lookup envelope\n file_to_clone = nil\n if case_num.include? 'HE'\n file_to_clone = 'Bestest_Geo_HE100.osm'\n else\n runner.registerError(\"Unexpected Geometry Variables.\")\n return false\n end\n\n # Add envelope from external file\n runner.registerInfo(\"Envelope > Adding spaces and zones from #{file_to_clone}\")\n translator = OpenStudio::OSVersion::VersionTranslator.new\n geo_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/resources/\" + \"#{file_to_clone}\")\n geo_model = translator.loadModel(geo_path).get\n geo_model.getBuilding.clone(model)\n\n # change heat balance defaults\n model.getHeatBalanceAlgorithm.setMinimumSurfaceConvectionHeatTransferCoefficientValue(0.0000001)\n\n # Specific to HE cases, set SurfacePropertyConvectionCoefficients\n conv_coef = OpenStudio::Model::SurfacePropertyConvectionCoefficientsMultipleSurface.new(model)\n conv_coef.setSurfaceType('AllExteriorWalls')\n conv_coef.setConvectionCoefficient1Location('Inside')\n conv_coef.setConvectionCoefficient1Type('Value')\n conv_coef.setConvectionCoefficient1(0.1)\n conv_coef.setConvectionCoefficient2Location('Outside')\n conv_coef.setConvectionCoefficient2Type('Value')\n conv_coef.setConvectionCoefficient2(0.0000001)\n\n conv_coef = OpenStudio::Model::SurfacePropertyConvectionCoefficientsMultipleSurface.new(model)\n conv_coef.setSurfaceType('AllExteriorRoofs')\n conv_coef.setConvectionCoefficient1Location('Inside')\n conv_coef.setConvectionCoefficient1Type('Value')\n conv_coef.setConvectionCoefficient1(20.0)\n conv_coef.setConvectionCoefficient2Location('Outside')\n conv_coef.setConvectionCoefficient2Type('Value')\n conv_coef.setConvectionCoefficient2(20.0)\n\n # Load resource file\n file_resource = \"bestest_resources.osm\"\n runner.registerInfo(\"Shared Resources > Loading #{file_resource}\")\n translator = OpenStudio::OSVersion::VersionTranslator.new\n resource_path = OpenStudio::Path.new(File.dirname(__FILE__) + \"/resources/\" + \"#{file_resource}\")\n resource_model = translator.loadModel(resource_path).get\n\n # no internal loads in HE cases\n\n # no infiltration in HE cases\n\n # setup clg thermostat schedule\n bestest_no_clg = resource_model.getModelObjectByName(\"No Cooling\").get.to_ScheduleRuleset.get\n clg_setp = bestest_no_clg.clone(model).to_ScheduleRuleset.get\n\n # setup htg thermostat schedule\n if variable_hash[:htg_set].is_a? Float\n htg_setp = OpenStudio::Model::ScheduleConstant.new(model)\n htg_setp.setValue(variable_hash[:htg_set])\n htg_setp.setName(\"#{variable_hash[:htg_set]} C\")\n elsif variable_hash[:htg_set] == [15.0,20.0] # HE220 and HE230 use same htg setpoint schedule\n resource_sch = resource_model.getModelObjectByName(\"HE220_htg\").get.to_ScheduleRuleset.get\n htg_setp = resource_sch.clone(model).to_ScheduleRuleset.get\n else\n runner.registerError(\"Unexpected heating setpoint variable\")\n return false\n end\n\n # create thermostats\n thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(model)\n thermostat.setCoolingSetpointTemperatureSchedule(clg_setp)\n thermostat.setHeatingSetpointTemperatureSchedule(htg_setp)\n zone = model.getThermalZones.first\n zone.setThermostatSetpointDualSetpoint(thermostat)\n runner.registerInfo(\"Thermostat > #{zone.name} has clg setpoint sch named #{clg_setp.name} and htg setpoint sch named #{htg_setp.name}.\")\n\n # add in HVAC\n BestestModelMethods.create_he_system(runner,model,variable_hash)\n\n # rename the building\n model.getBuilding.setName(\"BESTEST Case #{case_num}\")\n runner.registerInfo(\"Renaming Building > #{model.getBuilding.name}\")\n\n # set timesteps per hour\n timestep = model.getTimestep\n timestep.setNumberOfTimestepsPerHour(4)\n\n # note: set interior solar distribution fractions isn't needed if E+ auto calculates it\n\n # note: moved variable requests to reporting measure in energyPlusOutputReqests method\n\n # report final condition of model\n runner.registerFinalCondition(\"The final model named #{model.getBuilding.name} has #{model.numObjects} objects.\")\n\n return true\n\n end", "def test_entry_attrs\n raise 'Implement the method \"test_entry_attrs\" in your test class'\n end", "def get_model\n self.class.name.gsub(/Test/, \"\").constantize\n end", "def test_method\n return \"this is a test from the order model!\"\n end", "def test_create_my_cars\n assert_equal(@test_car.speed, 0, 'Speed of new car should be 0')\n assert_equal(MyCar.new.model, '')\n assert_equal(MyCar.new.year, 1999)\n assert_equal(MyCar.new.color, 'primer')\n assert_equal(MyCar.new(model:TEST_CAR_MODEL).model, TEST_CAR_MODEL)\n assert_equal(MyCar.new(year:TEST_CAR_YEAR).year, TEST_CAR_YEAR)\n assert_equal(MyCar.new(color:TEST_CAR_COLOR).color, TEST_CAR_COLOR)\n end", "def __dummy_test__\n end", "def create_model class_name, file_name\n # ViewModels\n #\n create_file \"app/view_models/#{file_name}.rb\", <<-FILE\nclass ViewModels::#{class_name} < ViewModels::Project\n\n# model_reader :icon, :filter_through => [:h]\n\nend\n FILE\n\n # Specs\n #\n \n create_file \"spec/view_models/#{file_name}_spec.rb\", <<-FILE\nrequire 'spec_helper'\n\ndescribe ViewModels::#{class_name} do\n\nend\n FILE\n\n end", "def run_test \n \n test_table = make_test_table(\"ml-100k/u1.test\")\n @testdata = MovieTest.new(test_table)\n end", "def initialize_model\n end", "def setup\n @test_car = MyCar.new(model:TEST_CAR_MODEL,\n year:TEST_CAR_YEAR,\n color:TEST_CAR_COLOR)\n end", "def test_cases; end", "def test_create_product_formula\n \n end", "def default_test\n end", "def default_test\n end", "def mocked_model\n model = mock(SimpleModel)\n \n model.class_eval do\n include CodeZone::Acts::Linkable\n acts_as_linkable\n end\n \n model\nend", "def test_default_value_in_just_create_model\n assert_equal 'new default value', ModelSecond.new.custom_field_renamed\n end", "def default_test\n end", "def test_order; end", "def love_test\nend", "def test_create_user_temperament\n @user.temperament = Temperament.new('Artisan','estp')\n @user.temperament = Temperament.new('Guardian','estj')\n @user.temperament = Temperament.new('Idealist','enfj')\n @user.temperament = Temperament.new('Rational','entj')\n end", "def test_steps; end", "def test_steps; end", "def default_test; end", "def test_create_product \n check_product\n end", "def test_lists\r\n nodelist = @mymodel.node_list\r\n linklist = @mymodel.link_list\r\n \r\n assert(nodelist.size == 0)\r\n assert(linklist.size == 0)\r\n end", "def test_step; end", "def my_tests\n end", "def test_basic_functionality\n u = DefaultSettings.create!\n end", "def test_additional_model_properties()\n # Parameters for the API call\n model = AdditionalModelParameters.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\",\"field\":\"QA\",\"address\":\"Ghori Town\",\"Job\":{\"company\":\"'\\\n 'APIMATIC\",\"location\":\"NUST\"}}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.additional_model_parameters(model)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def test_defaults\n end", "def test_entry_attrs\n raise \"Implement this method in your test class\"\n end", "def run_app_tests\n end", "def test_car\n new_car = Car.new :make => cars(:new_car).make,\n :model => cars(:new_car).model,\n :Vin => cars(:new_car).Vin,\n :created_at => cars(:new_car).created_at\n assert new_car.save\n\n end", "def set_test\n @test = Test.find(params[:id])\n end", "def add_to_model\n BETA_TESTERS.each do |email, username|\n password = username.delete(' ').downcase + rand(10..99).to_s\n BetaTester.create(email: email, username: username, password: password)\n end\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def setup_test(osm_file_or_model, test_name, idf_output_requests, epw_path, sch_path, model_in_path)\n # convert output requests to OSM for testing, OS App and PAT will add these to the E+ Idf\n workspace = OpenStudio::Workspace.new('Draft'.to_StrictnessLevel, 'EnergyPlus'.to_IddFileType)\n workspace.addObjects(idf_output_requests)\n rt = OpenStudio::EnergyPlus::ReverseTranslator.new\n request_model = rt.translateWorkspace(workspace)\n\n translator = OpenStudio::OSVersion::VersionTranslator.new\n model = translator.loadModel(model_in_path)\n assert((not model.empty?))\n model = model.get\n model.addObjects(request_model.objects)\n model.save(model_out_path(osm_file_or_model, test_name), true)\n\n osw_path = File.join(test_dir(test_name), 'in.osw')\n osw_path = File.absolute_path(osw_path)\n\n workflow = OpenStudio::WorkflowJSON.new\n workflow.setSeedFile(File.absolute_path(model_out_path(osm_file_or_model, test_name)))\n workflow.setWeatherFile(epw_path)\n workflow.saveAs(osw_path)\n\n if !File.exist?(\"#{test_dir(test_name)}\")\n FileUtils.mkdir_p(\"#{test_dir(test_name)}\")\n end\n\n FileUtils.cp(sch_path, \"#{test_dir(test_name)}\")\n\n cli_path = OpenStudio.getOpenStudioCLI\n cmd = \"\\\"#{cli_path}\\\" run -w \\\"#{osw_path}\\\"\"\n puts cmd\n system(cmd)\n\n return model\n end", "def test_model_params\n params.require(:test_model).permit(:title, :body, :user_id)\n end", "def run \n create_model_file\n create_migration if @valid==true\n enable_apis if @valid==true\n end", "def new\n @smoke_test = SmokeTest.new\n # package builders\n @smoke_test.build_nova_package_builder\n @smoke_test.nova_package_builder.merge_trunk = false\n @smoke_test.build_glance_package_builder\n @smoke_test.glance_package_builder.merge_trunk = false\n @smoke_test.build_keystone_package_builder\n @smoke_test.keystone_package_builder.merge_trunk = false\n @smoke_test.build_swift_package_builder\n @smoke_test.swift_package_builder.merge_trunk = false\n @smoke_test.build_cinder_package_builder\n @smoke_test.cinder_package_builder.merge_trunk = false\n @smoke_test.build_neutron_package_builder\n @smoke_test.neutron_package_builder.merge_trunk = false\n @smoke_test.build_ceilometer_package_builder\n @smoke_test.ceilometer_package_builder.merge_trunk = false\n @smoke_test.build_heat_package_builder\n @smoke_test.heat_package_builder.merge_trunk = false\n\n # config modules\n @smoke_test.build_nova_config_module\n @smoke_test.nova_config_module.merge_trunk = false\n @smoke_test.build_glance_config_module\n @smoke_test.glance_config_module.merge_trunk = false\n @smoke_test.build_keystone_config_module\n @smoke_test.keystone_config_module.merge_trunk = false\n @smoke_test.build_swift_config_module\n @smoke_test.swift_config_module.merge_trunk = false\n @smoke_test.build_cinder_config_module\n @smoke_test.cinder_config_module.merge_trunk = false\n @smoke_test.build_neutron_config_module\n @smoke_test.neutron_config_module.merge_trunk = false\n @smoke_test.build_ceilometer_config_module\n @smoke_test.ceilometer_config_module.merge_trunk = false\n @smoke_test.build_heat_config_module\n @smoke_test.heat_config_module.merge_trunk = false\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @smoke_test }\n format.xml { render :xml => @smoke_test }\n end\n end", "def setup\r\n puts 'starting a new test: ' + self.name\r\n cfT1 = CustomField.new(\"testField\", \"kuku\")\r\n cfT2 = CustomField.new(\"tester\", \"new_tester\")\r\n @reportiumClient.testStart(self.name, TestContext.new(TestContext::TestContextBuilder\r\n\t .withCustomFields(cfT1, cfT2)\r\n .withTestExecutionTags('TagYW1', 'TagYW2', 'unittest')\r\n .build()))\r\n end", "def setup\n\t\tend", "def setup\n\t\tend", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n\n\n # Make an argument for evap effectiveness\n input_csv_path = OpenStudio::Measure::OSArgument::makeStringArgument(\"input_csv_folder_path\",true)\n input_csv_path.setDisplayName(\"raw_data_input_folder_path\")\n input_csv_path.setDefaultValue(\"data_file\")\n args << input_csv_path\n\n test_numbers = OpenStudio::StringVector.new\n test_numbers << 'Test_3'\n test_numbers << 'Test_6'\n test_numbers << 'Test_8'\n \n test_names = OpenStudio::StringVector.new\n test_names << 'UA_test'\n test_names << 'Cooling_test'\n test_names << 'Plenum_test'\n\n test_selections = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('test_data',test_numbers,test_names,true)\n\n \n test_selections.setDisplayName(\"Experiment\")\n test_selections.setDefaultValue(\"Test_3\")\n args << test_selections\n\n \n return args\n end", "def model_class\n Sms::Test\n end", "def assert_content_model\n add_relationship(:has_model, \"info:fedora/hull-cModel:bookChapter\") \n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\") \n end", "def test_sti\n assert_equal @special_model_name, SpecialAddress.localized_model_name\n assert_equal @special_attribute_names[:purpose], SpecialAddress.human_attribute_name('purpose')\n end", "def before_setup; end", "def run_fe_tests\n end", "def setup_test_1(test_name, epw_path)\n\n co = OpenStudio::Runmanager::ConfigOptions.new(true)\n co.findTools(false, true, false, true)\n\n if !File.exist?(sql_path(test_name))\n puts \"Running EnergyPlus\"\n\n wf = OpenStudio::Runmanager::Workflow.new(\"modeltoidf->energypluspreprocess->energyplus\")\n wf.add(co.getTools())\n job = wf.create(OpenStudio::Path.new(run_dir(test_name)), OpenStudio::Path.new(model_out_path(test_name)), OpenStudio::Path.new(epw_path))\n\n rm = OpenStudio::Runmanager::RunManager.new\n rm.enqueue(job, true)\n rm.waitForFinished\n end\n end", "def set_test\n @test = Test.friendly.find(params[:id])\n end", "def test_should_create_a_model_file\n run_generator %w(foo)\n assert_file \"#{javascripts_path}/models/foo.js.coffee\"\n end", "def setup\n login_as Factory(:user,:person => Factory(:person,:roles_mask=> 0))\n @object = Factory(:sample,:contributor => User.current_user,\n :title=> \"test1\",\n :policy => policies(:policy_for_viewable_data_file))\n end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end" ]
[ "0.68206626", "0.68206626", "0.6769266", "0.6736159", "0.67325836", "0.67102265", "0.667959", "0.6659984", "0.6659984", "0.6613454", "0.6529699", "0.65260917", "0.64172745", "0.63526446", "0.6314491", "0.6305458", "0.62906384", "0.6284235", "0.62495846", "0.6245142", "0.6226386", "0.62214684", "0.6194202", "0.61932594", "0.61932594", "0.61932594", "0.61803395", "0.6162586", "0.6155449", "0.6151172", "0.6151172", "0.6123603", "0.6108683", "0.60976136", "0.60464704", "0.6041031", "0.60291153", "0.60129577", "0.5990839", "0.5971257", "0.5971241", "0.59687155", "0.5956057", "0.5951105", "0.5942271", "0.5933246", "0.5926427", "0.592158", "0.592158", "0.592066", "0.5916228", "0.59064597", "0.5897165", "0.58935505", "0.5892516", "0.58902335", "0.58902335", "0.58900595", "0.5876862", "0.5876634", "0.5857972", "0.58559513", "0.58447105", "0.58372504", "0.58337814", "0.58219594", "0.5808408", "0.58049244", "0.57908", "0.5785411", "0.57786065", "0.57786065", "0.5778038", "0.57758474", "0.57682884", "0.5760531", "0.5755428", "0.5755428", "0.5752171", "0.5718314", "0.5715442", "0.57147", "0.5710274", "0.57077086", "0.56973284", "0.56821173", "0.5680547", "0.56791663", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476", "0.5678476" ]
0.0
-1
Yes, it's called package because module is a reserved word
def package @package ||= path.split('/lib/')[0].split('/').last.split('.js').last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def packages; end", "def k_package!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n\n type = K_PACKAGE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 341:4: 'package'\n match( \"package\" )\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__, 22 )\n\n\n end", "def package(name)\n Packaged.instance self , name\n end", "def package_name\n raise NotImplementedError\n end", "def current_package\n @current_package\n end", "def package(pkg)\n @pkg = pkg\n end", "def definition\n \"module #{full_name}\"\n end", "def only_name(mod); end", "def package_name\n raise AbstractMethod.new(\"#{self.class.name}#package_name\")\n end", "def package_by_name(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package_by_name\"\n end", "def modules; end", "def modules; end", "def modules; end", "def module\n RDoc::TopLevel.find_module_named(@name) || @name\n end", "def isolate_namespace(mod); end", "def isolate_namespace(mod); end", "def getsfLma__PackageObjName\r\n\t\t\treturn \"sfLma__Package__c\"\r\n\t\tend", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def needpackage *args\n\t\tpackage *args\n\tend", "def package(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite package\"\n end", "def module?\n true\n end", "def module?\n true\n end", "def module?\n false\n end", "def packages()\n\t\t\tend", "def table_name; \"gdo_module\"; end", "def module_name\n File.basename(File.dirname(__FILE__)).sub(/^[A-Za-z]*?-/, '')\nend", "def modulename\n \"vds\"\n end", "def full_name\n \"#{@package}.#{parameterized_name}\"\n end", "def package\n @options['package']\n end", "def module_name\n (i = name.index(\"::\")) ? name[0..i-1] : name\n end", "def module_name\n root? ? nil : @name.camelize\n end", "def fully_qualified_name\n return \".#{self.package}\"\n end", "def prefixed_label(package)\n label = ( package =~ /^#{$prefix}(.*)$/ ) && $1 || package\n label = '.' if label.empty?\n label\nend", "def before_package_create(package)\n end", "def before_package_create(package)\n end", "def package_name\n raise Puppet::Error, 'luet requires packages have a category set' unless @resource[:category]\n\n \"#{@resource[:category]}/#{@resource[:name]}\"\n end", "def package_name\n # TODO: verify renamed packages\n resource['title']\n end", "def real_table_name\n packageid.gsub('.', '_')\n end", "def name\n @module.name\n end", "def module_name\n 'KfGame'\nend", "def is_module_package?(name)\n filename = File.expand_path(name)\n filename =~ /.tar.gz$/\n end", "def using(mod)\n ::Kernel.raise 'main.using is permitted only at toplevel'\n end", "def name\n\t\tmodule_info['Name']\n\tend", "def check_module_name\n case\n when @arguments.empty?; puts 'Module name required.'; exit 3\n when !@arguments[0].match(/^[a-z][\\w]+/); puts 'Invalid module name.'; exit 4\n else @module = @arguments[0]\n end\n end", "def [](packagename)\n\t\t\t\treturn(packages()[packagename])\n\t\t\tend", "def vendored_package_name(package)\n\tFile.join($package_name, 'vendor/src', package)\nend", "def access_package\n return @access_package\n end", "def access_package\n return @access_package\n end", "def package_name\n @version ? \"#{@name}-#{@version}\" : @name\n end", "def key_for_package(pkg)\n if !pkg.id.nil?\n \"#{pkg.id}-#{@name}\"\n else\n return \"#{pkg.categories.split.first}/#{pkg.name}-#{@name}\"\n end\n end", "def print_module(*) end", "def module\n klass[0..(klass.index(\"::\")-1)] if has_module?(klass)\n end", "def uses?(mod); end", "def extended(a_module)\n end", "def inspect\n ((@name.nil?) ? \"Unnamed package\" : \"\\\"#{@name}\\\"\" )+\" (#{@links.length} links, #{@passwords.length} passwords)\"+((@comment == \"\") ? \"\" : \"\\n# #{@comment}\")\n end", "def access_package=(value)\n @access_package = value\n end", "def access_package=(value)\n @access_package = value\n end", "def extended_modules; end", "def package?(package_name)\n id = @package_ids[package_name]\n return id if id\n\n package_id = nil\n\n page = \"/frs/\"\n\n form = {\n \"group_id\" => group_id\n }\n scrape = http_post(page, form)\n\n restr = ''\n restr << Regexp.escape( package_name )\n restr << '\\s*'\n restr << Regexp.escape( '<a href=\"/frs/monitor.php?filemodule_id=' )\n restr << '(\\d+)'\n restr << Regexp.escape( %{&group_id=#{group_id}} )\n re = Regexp.new( restr )\n\n md = re.match( scrape )\n if md\n package_id = md[1]\n end\n\n @package_ids[package_name] = package_id\n end", "def metapackage(name, *packages)\n Autoproj.workspace.manifest.metapackage(name, *packages)\nend", "def modular_class_name\n @modular_class_name\n end", "def module_app_name(name)\n name.split(\"_\").map!{|x| x.capitalize}.join\n end", "def module_function(sym, *rest) end", "def key\n \"gem-package-#{name}\"\n end", "def package?(package)\n # implement inside child\n end", "def test_module\n assert_parses(\n s(:module,\n s(:const, nil, :Foo),\n nil),\n %q{module Foo; end},\n %q{~~~~~~ keyword\n | ~~~ name\n | ~~~ end})\n end", "def package_name(val = NULL)\n if null?(val)\n @package_name || name\n else\n @package_name = val\n end\n end", "def package_name\n @package_name ||=\n Pathname(\"#{cartage.final_name}.tar#{cartage.tar_compression_extension}\")\n end", "def split_name_package(fullname)\n fixing = fullname.gsub(/:/, \".\")\n split = fixing.match(/^(?:((?:\\w+\\.?)*)\\.)?(\\w+)$/) || []\n name = split[2] || \"\"\n package = split[1] || \"\"\n # downcase the first letter of each package name\n package = package.split(\".\").map {|s| s[0].downcase+s[1..-1]}.join(\".\")\n [name, package]\n end", "def installed_packages()\n\t\t\tend", "def module_title\n static_module.title\n end", "def package\n return @children['package'][:value]\n end", "def import(package_name)\n raise \"#{self.class} needs to overwrite import\"\n end", "def outer_module_name(name)\n outer_module = name.rpartition('::').first\n outer_module.sub!(/^::/,'')\n return outer_module == \"\" ? '::Object' : ('::'+outer_module)\n end", "def ignore_package(package)\n invalidate_ignored_package_names\n @ignored_packages << validate_package_name_argument(package, require_existing: false)\n end", "def clean_module_name(module_name)\n module_name.gsub /[\\-@]/, ''\n end", "def package_name(val = NULL_ARG)\n @package_name = val unless val.equal?(NULL_ARG)\n @package_name.nil? ? @name : @package_name\n end", "def namespace\n case language\n when 'py', 'go', 'java'\n File.basename(file_name, '.' + language)\n end\n # TODO: Add support for Java packages.\n #open(file_name) { |f| /^\\s*package\\s+(.*)\\s*;$/.match(f.read)[1] }\n end", "def module?\n @type == :module\n end", "def module?\n @type == :module\n end", "def assertNamespace(name)\n ns, base = DataMetaDom.splitNameSpace(name)\n scalaPackage = DataMetaDom.validNs?(ns, base) ? ns : ''\n packagePath = scalaPackage.empty? ? '' : scalaPackage.gsub('.', File::SEPARATOR)\n\n [scalaPackage, base, packagePath]\n end", "def hadoop_package(name)\n return name unless hdp22?\n return name if node['platform_family'] == 'debian'\n fw = name.split('-').first\n pv = hdp_version.tr('.', '_').tr('-', '_')\n nn = \"#{fw}_#{pv}\"\n name.gsub(fw, nn)\n end", "def add_package(package)\n [package_handler(File.extname(package).tr(\".\", \"\")).add(content, package)].flatten.compact\n end", "def safe_base_package_name\n if project.package_name =~ /\\A[a-z0-9\\.\\+\\-]+\\z/\n project.package_name.dup\n else\n converted = project.package_name.downcase.gsub(/[^a-z0-9\\.\\+\\-]+/, \"-\")\n\n log.warn(log_key) do\n \"The `name' component of IPS package names can only include \" \\\n \"lowercase alphabetical characters (a-z), numbers (0-9), dots (.), \" \\\n \"plus signs (+), and dashes (-). Converting `#{project.package_name}' to \" \\\n \"`#{converted}'.\"\n end\n converted\n end\n end", "def after_package_create(package)\n end", "def after_package_create(package)\n end", "def module_path\n nil\n end", "def package_from_name\n case name.downcase\n when 'splunk' then package :splunk\n when 'universal_forwarder' then package :universal_forwarder\n else raise 'Package must be specified (:splunk or :universal_forwarder)'\n end\n end", "def template_module_name(path); end", "def pkginfo_from_pkg(package)\n raise RuntimeError, \"#{self.class} needs to overwrite pkginfo_from_pkg\"\n end", "def add_subpackage pack\n if not pack.is_a? Package\n raise TypeError\n end\n if pack.name =~ JTools::PACKAGE_NAME\n @subpackages[pack.name] = pack # map name to package object\n else puts \"Invalid pacakge name '#{pack.name}'. Skipping.\"\n end\n end", "def test_get_module_name\n name = AdWords::Service.get_module_name(200909, 'Campaign')\n # Does it match what we expect?\n assert_equal('AdWords::V200909::CampaignService', name,\n 'Module name does not match expected output')\n end", "def is_metapackage?(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite is_metapackage?\"\n end" ]
[ "0.67353594", "0.6665122", "0.6556278", "0.6536218", "0.6508328", "0.6426168", "0.6362813", "0.6327646", "0.62823504", "0.6250995", "0.62251645", "0.62251645", "0.62251645", "0.62143946", "0.61981213", "0.61981213", "0.61562824", "0.6152726", "0.6152726", "0.6152726", "0.6152726", "0.6152726", "0.6152726", "0.6152726", "0.6152726", "0.6136696", "0.6119769", "0.61039364", "0.61039364", "0.60790044", "0.6055114", "0.60532165", "0.6035556", "0.60303104", "0.60239017", "0.6020719", "0.59876156", "0.5976553", "0.59550816", "0.5936597", "0.5935671", "0.5935671", "0.5920001", "0.5896468", "0.5884214", "0.5870002", "0.58576286", "0.58505136", "0.58501923", "0.5848483", "0.5845533", "0.5837103", "0.5834759", "0.58281857", "0.58281857", "0.5806591", "0.58007824", "0.5797516", "0.5771887", "0.5762282", "0.5746672", "0.5745305", "0.5735548", "0.5735548", "0.57091033", "0.5708125", "0.56953675", "0.5676804", "0.56677866", "0.5664244", "0.56635916", "0.5656512", "0.56504864", "0.56425977", "0.5621244", "0.5602554", "0.5579283", "0.55692565", "0.5566387", "0.5561647", "0.5559625", "0.55513585", "0.55513066", "0.5539748", "0.552884", "0.5528784", "0.5528784", "0.5526924", "0.5525361", "0.551774", "0.5517435", "0.5517288", "0.5517288", "0.5510001", "0.55083007", "0.54987186", "0.54851985", "0.54832023", "0.5481903", "0.5470199" ]
0.60383797
32
I want to return an array that doubles each element of the input array
def double_array(arr) doubled_arr = arr.map do | element| element *2 end doubled_arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def map_to_double(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] * 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend", "def map_to_double(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index] * 2)\n index += 1 \n end\n return array\nend", "def double_array(input_array)\n \n double_array = []\n \n input_array.each do |number|\n double_array << number *= 2\n end\n return double_array\n\nend", "def map_to_double(array)\n new_array = array.map{|n| n*2}\n return new_array\nend", "def calculate_doubles(arr)\n doubled_array = []\n arr.each {|int| doubled_array.push(int * 2)}\n doubled_array\nend", "def double_array(array)\n output_array = []\n\n array.each do |thing|\n output_array << thing * 2\n end\n\n return output_array\nend", "def double_array(array)\n array*2\nend", "def calculate_doubles!(array)\n\t\n\tarray.map! { |num| num * 2}\nend", "def double_numbers(input_array)\n doubled_array =[]\n input_array.each {|num| doubled_array << num*2} \n doubled_array\nend", "def calculate_doubles(arr)\n array = []\n arr.each {|x| array << x + x}\n array\n\nend", "def calculate_doubles(array)\n\tmapped_array = array.map { |num| num * 2 }\nend", "def calculate_doubles(arr)\n arr.map {|a|a*2}\n\nend", "def double_all(arr)\n doubles = []\n\n arr.each do |num|\n doubles.push(num * 2)\n end\n\n doubles\nend", "def map(arr)\n i = 0\n # Double each item in the array and replace values.\n arr.each do |item|\n arr[i] = double(item)\n i += 1\n end\n # Return the new doubled array.\n # This is the result of the map function.\n return arr\nend", "def double_all array\n array.map { |i| i*2 }\nend", "def double_numbers(array)\n new_array = []\n\n array.each do |number|\n new_array << number *= 2\n end\n return new_array\nend", "def double_array(array)\n\tn = [1, 2, 3]\n\tn * 2\nend", "def double_numbers(array)\n doubled_numbers = []\n array.each do |number|\n doubled_numbers << number * 2\n end\n return doubled_numbers\nend", "def calculate_doubles!(arr)\n arr.map! {|int| int * 2}\nend", "def calculate_doubles!(arr)\n\n arr.map! {|x| x + x}\n arr\n\nend", "def double_numbers(array)\n\tarray.map { |integer| integer * 2 }\t\nend", "def map_to_square(source_array)\n \n i = 0\n new_array = []\n \n while i < source_array.length do\n new_array_value = source_array[i] ** 2\n new_array << new_array_value\n \n i += 1\n end\n \n new_array\nend", "def map_to_square(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index] ** 2)\n index += 1 \n end\n return array\nend", "def doubler(arr)\n new = []\n arr.each do |i|\n new << i*2\n end\n return new\nend", "def multiply_by(array)\n return array.map { |el| el * 3}\nend", "def doubler(array)\r\n res = []\r\n array.each do |ele|\r\n res << ele * 2\r\n end\r\n res\r\nend", "def square_array(array)\n new_array = []\n array.each { |e| new_array << e ** 2 }\n new_array\nend", "def square_array(array)\n array.map! { |ele| ele ** 2 }\nend", "def double_array(array)\n # your code here\nend", "def double_eles(arr)\n arr.map do |ele|\n ele * 2\n end\nend", "def square_array(array)\n new_array = []\n array.each{|a| new_array.push(a*a)}\n return new_array\nend", "def double_arr(nums)\n numb_arr = [] # create empty arr\n i = 0 # the indice counter start @ 0\n\n while i < nums.length # for the length of indices in array \n new_num = nums[i] * 2 # variable new_num = looped var i * 2\n numb_arr << new_num # shovel the value of new_num into empty arr\n i += 1 # iterate into next indice of passed array\n end\n return numb_arr # the new array\n puts numb_arr # display the result of the new array\nend", "def array_times_two(array)\n new_array = array.map{ |el| el * 2}\n end", "def square_array_2(array)\n array.collect { |i| i**2 }\n array\nend", "def arr_product(arr)\n product = arr.reduce(:*)\n arr.map { |el| product / el }\nend", "def square_array(array)\nnew_array = []\ncounter = 0\nwhile counter < array.length do\n new_array << array[counter] ** 2 #**squaring incrments\ncounter += 1 #increments plus 1 after squaring elements\nend\nreturn new_array #can also just write new_array without the retun before it \nend", "def square_array(array)\n array.map do |element|\n element ** 2 \n end\nend", "def square_array2(array)\n return array.collect { |num| num ** 2 }\nend", "def compute_squares(array)\n arrayFinal = []\n array.each do |element|\n arrayFinal << element * element\n end\n return arrayFinal\nend", "def square_array(array)\n squared = []\n array.each { |element| squared << element ** 2 }\n squared\nend", "def square_array(array)\narray.map { |to_square| to_square**2}\nend", "def calculate_doubles!(arr)\n arr.map!{|a|a=a*2}\nend", "def map_to_square(array)\n new_array = array.map{|n| n**2}\n return new_array\nend", "def multiply_by_two(array)\n # double_numbers = []\n # array.each do |number|\n # double_numbers << number * 2\n # end\n # double_numbers\n array.map { |number| number * 2 }\nend", "def productify_easy(arr)\n product = arr.inject(:*)\n new_arr = []\n arr.each do |num|\n new_arr << product / num\n end\n new_arr\nend", "def square_array(array)\n array.collect {|num| num * num}\n \nend", "def basic_9 (array_iterate)\n square_array = array_iterate.collect { |n| n * n}\n return square_array\nend", "def cubed_values (array)\n\n cubed_array = array.map { | number | number ** 3 }\n return cubed_array\n\nend", "def array_product_bruteforce(a)\r\n\tprod = Array.new(a.size)\r\n\ti = 0\r\n\r\n\twhile i < a.size\r\n\t\tc = a[0..a.size]\r\n\t\tc.delete_at(i)\r\n\t\tprod[i] = c.inject(:*)\r\n\t\ti += 1\r\n\tend\r\n\treturn prod\r\nend", "def square_array (array)\n\nnewarray = []\n\narray.each do |element|\n newarray.push(element**2) \nend\n\nnewarray\n\nend", "def double_array(array)\n array + array\nend", "def square_each_w_obj(array)\n array.each_with_object([]) { |elem, new_arr| new_arr << elem ** 2 }\nend", "def square_array(array)\n numbers = []\n array.each do |number| numbers << number ** 2\n end\n numbers\nend", "def doubler(numbers)\n\ti = 0\n \tarry = []\n while i < numbers.length\n arry[i] = (numbers[i] * 2)\n i += 1\n end\n return arry\nend", "def square_array_with_collect(array)\n array.collect{|element| element**2}\nend", "def square_array(some_array)\n array_squared = []\n some_array.each do |item|\n array_squared << item*item\nend\n return array_squared\nend", "def doubled\n @doubled = []\n @digits.each_with_index do |item, index|\n if index.odd?\n @doubled << item * 2\n else\n @doubled << item\n end\n end\n end", "def square_array(some_array)\n array_squared = []\n some_array.each do |number|\n array_squared << number * number\n end \n return array_squared\nend", "def index_multiplier_method\n #@multiplied_integer_array = []\n @reversed_array.each_with_index do |value, index|\n if index.odd? == true\n value = value * 2\n @multiplied_integer_array << value\n else\n value = value\n @multiplied_integer_array << value\n end\n end\n return @multiplied_integer_array\n end", "def triplify(array)\n \t \n \t new_array = array.map { |i| i * 3 }\n \t p new_array\n end", "def square_array(numbers)\n numbers.map { |e| e ** 2 }\nend", "def square_array_collect(array)\n array.collect{|num| num ** 2}\nend", "def doubler(numbers)\n\tdouble = []\n\n\ti = 0\n\twhile i < numbers.length\n\t\tnum = numbers[i]*2\n\t\tdouble << num\n\t\ti += 1\n end\n\t\n\treturn double\nend", "def transform_array(array)\n i = 0\n array2 = []\n while i < array.length\n num1 = array[i]\n array2.push(square(num1))\n i += 1\n end\n return array2\n end", "def my_function2(arr)\n final_arr = []\n first_half = []\n first_product = 1\n last_half = []\n arr.each_with_index do |n, i|\n first_half = arr[0...i]\n last_half = arr[i+1..-1]\n first_product = first_half.reduce(:*) || 1\n last_product = last_half.reduce(:*) || 1\n products = first_product * last_product\n final_arr.push(products)\n end\n return \"Products: #{final_arr}\"\nend", "def custom_multiply(array,number)\n new_array = []\n number.times {new_array+=array}\n return new_array\nend", "def double_to_single_method\n #single_digit_array = []\n @multiplied_integer_array.each do |value|\n if value > 9\n value = value - 9\n @single_digit_array << value\n else\n value = value\n @single_digit_array << value\n end\n end\n return @single_digit_array\n end", "def doubler(numbers)\n\tdoubled_nums = [] # Creates empty array to store double nums\n\n\ti = 0\n\twhile i < numbers.length\n\t\told_elem = numbers[i] # Creates temporary variable to hold number for each iteration\n\t\tnew_elem = old_elem * 2 # Multiplies old element by two and saves to new variable\n\t\tdoubled_nums << new_elem\n\n\t\ti += 1 # Iterates upwards\n\tend\n\n\treturn doubled_nums\nend", "def multiply(array,mult)\n array.map{|num| num*mult}\nend", "def square_array(array) #build square_array method\r\n\r\n new_array = [] #new array of squared numbers\r\n\r\n array.each do |integer|#implement own logic\r\n new_array << integer ** 2 #shovel /push logic into array \r\n end\r\n return new_array #returns array of these squared numbers\r\nend", "def multiply_me(array, int)\r\n\r\n arr = [] # empty array created\r\n\r\n i = 0 # iteration starts to multiply each item\r\n while i < array.length\r\n arr << array[i] * int # products collected\r\n i += 1\r\n end\r\n\r\n arr # result\r\nend", "def array_of_array_multi(array)\n # YOUR CODE HERE\n multiArr = array.map{ |arr| arr.map{ |num| num * num } }\n p multiArr\n p array\n # array\nend", "def doubler(array)\n array.map { |num| num * 2 }\nend", "def doubler(array)\n array.map { |num| num * 2 }\nend", "def square_array(array)\n new_array = []\n array.each { |n| new_array << n*n }\n new_array\nend", "def square_array(array)\n # Use an Enumerable to square every element in the passed in array\n # Return a new array of the results\n array.map do |n|\n n*n\nend\nend", "def double_it(numbers)\n numbers.map{|number| number * 2}\nend", "def my_function4(arr)\n products_arr = []\n products_so_far = 1\n i = 0\n while i < arr.length\n products_arr[i] = products_so_far\n products_so_far *= arr[i]\n i += 1\n end\n\n products_so_far = 1\n i = arr.length - 1\n while i >= 0\n products_arr[i] *= products_so_far\n products_so_far *= arr[i]\n i -= 1\n end\n\n return \"Products: #{products_arr}\"\nend", "def square_array(some_array)\n some_array.collect {|num| num*num} \nend", "def square_array(array)\nnew_array = []\n array.length.times do |squared|\n new_array.push(array[squared]**2)\nend\n new_array\nend", "def square_collect(array)\n\n return array.collect do |x|\n x ** 2\n end\n\nend", "def multiply(array)\n array.inject(:*)\nend", "def square_array(numbers)\n new_arr = []\n numbers.each do |number|\n new_arr << (number**2)\n end\n return new_arr\nend", "def square_array(array)\n # your code here\n newArray = []\n array.each do |num|\n number = num**2\n newArray.push(number)\n end\n return newArray\nend", "def square_array(array)\n counter = 0\n new_array = []\n while counter < array.length do\n new_array << array[counter] ** 2\n counter += 1\n end\n p new_array\nend", "def products_of_all_other_nums(array)\n\n\tresult = Array.new() { [] }", "def square_array(array)\n\n squared = []\n array.each do |num|\n squared.push(num * num)\n end\n\n squared\n \nend", "def square_array(numbers)\n new_numbers = []\n numbers.each do |num|\n new_numbers << (num ** 2)\n end\n return new_numbers\nend", "def array_times_two!(array)\n array.map!{ |el| el *2}\n end", "def product_array(input_array)\n return_array = []\n input_array.each_with_index do |x, i|\n # puts \"x is #{x} and i is #{i}\"\n product = 1\n input_array.each_with_index do |y,j|\n if i!=j\n product *= y\n end\n end\n return_array << product\n end\n return return_array\nend", "def square_array(array)\n squared_array = []\n \n array.each do |number| \n squared_array << number**2 \n end\n \n squared_array\nend", "def my_function3(arr)\n final_arr = []\n first_product = 1\n last_half = []\n arr.each_with_index do |n, i|\n last_half = arr[i+1..-1]\n first_product *= arr[i-1] unless i == 0\n last_product = last_half.reduce(:*) || 1\n products = first_product * last_product\n final_arr.push(products)\n end\n return \"Products: #{final_arr}\"\nend", "def productify(array)\n\nend", "def doubler(numbers)\n new_arr = []\n i = 0\n while i < numbers.length\n old_numbers = numbers[i]\n new_numbers = old_numbers * 2\n new_arr << new_numbers\n i += 1\n end\n return new_arr\nend", "def double_array(array)\n array.concat(array)\nend", "def doubler(array)\n array.map do |num|\n num *= 2\n end\n\nend", "def array_element_mult(array_a, array_b)\n array_a.zip(array_b).map {|x,y| x*y}\n end", "def square_array(array)\n square = []\n \n array.each do |num|\n square << num * num\n end\n square\nend", "def double_to_single_method(multiplied_integer_array)\n single_digit_array = []\n multiplied_integer_array.each do |value|\n if value > 9\n value = value - 9\n single_digit_array << value\n else\n value = value\n single_digit_array << value\n end\n end\n return single_digit_array\nend", "def square_array(square_array)\ncounter = 0\nnew_numbers = [] \n while counter < square_array.count do\n new_numbers << (square_array[counter] ** 2)\n counter += 1\n end\n new_numbers\nend" ]
[ "0.8113166", "0.8093475", "0.78498197", "0.7824536", "0.76009935", "0.75924516", "0.757723", "0.75660414", "0.73971635", "0.7390382", "0.73832947", "0.73761904", "0.73294103", "0.72993433", "0.7280207", "0.7257046", "0.72050697", "0.7188062", "0.7178201", "0.70868623", "0.70067495", "0.6878737", "0.68555295", "0.6785973", "0.6739739", "0.673722", "0.67336714", "0.6716145", "0.6707527", "0.66586405", "0.6637806", "0.6631021", "0.66220665", "0.6617086", "0.66060156", "0.65831596", "0.6565778", "0.65474284", "0.6531206", "0.6520322", "0.6518258", "0.65059984", "0.6502208", "0.650022", "0.6487935", "0.64855397", "0.64814234", "0.6475221", "0.6459908", "0.64550674", "0.6438936", "0.64190435", "0.63734853", "0.6373212", "0.6363821", "0.6362882", "0.6350157", "0.63454854", "0.63422996", "0.63344127", "0.63273", "0.6319234", "0.6317683", "0.6314181", "0.6291388", "0.6288787", "0.6281807", "0.628178", "0.6280306", "0.62798375", "0.627889", "0.6275699", "0.62635", "0.62635", "0.626344", "0.62535393", "0.62455046", "0.6244748", "0.6234895", "0.6233869", "0.6232896", "0.6223699", "0.622348", "0.6222148", "0.622073", "0.6219187", "0.62142146", "0.6208553", "0.6206103", "0.62023485", "0.61977684", "0.61976117", "0.61929697", "0.619088", "0.61842877", "0.61809367", "0.6177982", "0.6174958", "0.6172607", "0.61693466" ]
0.7410474
8
GET /customized_concepts GET /customized_concepts.json
def index @customized_concepts = CustomizedConcept.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.find(params[:id])\n end", "def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end", "def create\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.new(customized_concept_params)\n\n respond_to do |format|\n if @customized_concept.save\n format.html { redirect_to @course, notice: 'Customized concept was successfully created.' }\n format.json { render :show, status: :created, location: @customized_concept }\n else\n format.html { render :new }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @concepts = Concept.all\n end", "def update\n respond_to do |format|\n if @customized_concept.update(customized_concept_params)\n format.html { redirect_to @customized_concept, notice: 'Customized concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @customized_concept }\n else\n format.html { render :edit }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def customized_concept_params\n params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)\n end", "def find_concepts(options = {})\n @language_permalink = options[:language_permalink]\n category_id = options[:category_id]\n if @language_permalink\n options.delete(:language_permalink)\n if category_id\n options.delete(:category_id)\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/categories/#{category_id}/concepts\")\n else\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/concepts\")\n end\n end\n end", "def show\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concept }\n end\n end", "def resourceType\n 'ConceptMap'\n end", "def resourceType\n 'ConceptMap'\n end", "def get_concept_required_edges\n concept = @course.topicconcepts.concepts.where(id: params[:id]).first\n if !concept.nil?\n required_concept_edges = concept.concept_edge_required_concepts\n respond_to do |format|\n format.json { render :json => { :current_concept => concept, :dependencies => required_concept_edges.map { |e| { concept_edge_id: e.id, required_concept_name: e.required_concept.name} }}} \n end\n else\n raise \"Concept id is invalid\"\n end\n end", "def show\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orderable_concept }\n end\n end", "def concept_view_data(concept)\n res = {}\n\n render_concept_association(res, concept, Collection::Member::Base)\n\n Iqvoc::Concept.labeling_classes.each do |labeling_class, languages|\n render_concept_association(res, concept, labeling_class, available_languages: languages || Iqvoc.available_languages)\n end\n\n Iqvoc::Concept.relation_classes.each do |relation_class|\n render_concept_association(res, concept, relation_class)\n end\n\n render_match_association(res, concept, Iqvoc::Concept.match_classes)\n\n Iqvoc::Concept.note_classes.each do |note_class|\n render_concept_association(res, concept, note_class)\n end\n\n Iqvoc::Concept.notation_classes.each do |notation_class|\n render_concept_association(res, concept, notation_class)\n end\n\n Iqvoc::Concept.additional_association_classes.keys.each do |assoc_class|\n render_concept_association(res, concept, assoc_class)\n end\n\n res\n end", "def get_concept\n concept ? concept : 'N/A'\n end", "def index\n #@concepts = Concept.all#order('updated_at DESC')\n\n #Displaying institute specific concepts\n @concepts = case current_user.role.name when 'Edutor Admin'\n Concept.all\n when 'Institute Admin'\n Concept.where(:institution_id=>current_user.institution_id)\n when 'Teacher'\n Concept.where(:user_id => current_user.id)\n else\n Concept.where(:user_id => current_user.id)\n end\n\n #TO Differentiate new and old concept maps\n @new_concepts = ConceptElement.where(\"x IS NOT NULL\").where(:parent_id => nil)\n @new_ids = Array.new\n @new_concepts.each do |e|\n @new_ids << e.concept_id\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concepts }\n end\n end", "def destroy\n @customized_concept.destroy\n respond_to do |format|\n format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def concept(name, *args, &block)\n controller.concept(name, *args, &block)\n end", "def index\n @cover_concepts = CoverConcept.all\n end", "def show\n @conceptual_entity = ConceptualEntity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conceptual_entity }\n end\n end", "def new\n @concept = Concept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concept }\n end\n end", "def new\n @orderable_concept = OrderableConcept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orderable_concept }\n end\n end", "def extract_concepts( content , page , location = LOC_CONTENT)\n #$lgr.info(\"Content : #{content} \")\n content.scan( PTN_CONCEPT ).each do |concept_title|\n if /(\\w+):=(.*)/ =~ concept_title[0]\n Property.create!( :page => page , :name => $1 , :value => $2 )\n next\n end\n refs = PTN_CONCEPT_RELATION.match(concept_title[0])\n #$lgr.info refs.to_a.inspect\n data = [] #Concept instance for odd index, ConceptRelation instance for even index\n if refs.size % 2 != 0 then flash[:notice] = \"Illegal concept definition! #{refs[0]}\" end\n \n refs.to_a.each_with_index do |match_str , i|\n #$lgr.info(\" [#{i}]=>[#{match_str}] / \")\n if match_str == nil || match_str.length == 0 then break end\n if i == 0 then next end\n if i % 2 == 1 #Concept\n data[i] = Concept.find_by_title( match_str )\n if data[i] == nil\n data[i] = Concept.create!( :title=>match_str )\n end\n #ConceptOccurrence will be handled by Organizer\n ConceptOccurrence.create!( :page => page , :concept => data[i] , :location => location)\n #Finalize ConceptRelation\n if i > 1\n data[i-1].other_concept = data[i]\n data[i-1].page = page\n data[i-1].save\n #$lgr.info data[i-1].inspect\n end\n elsif i % 2 == 0 #ConceptRelation\n data[i] = ConceptRelation.new\n data[i].concept = data[i-1]\n data[i].kind = match_str\n end\n end # end of block\n end #end of block\n end", "def show\n @concept_map = ConceptMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@concept_map }\n end\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def index\n @special_requirements = SpecialRequirement.all\n end", "def create\n @orderable_concept = OrderableConcept.new(params[:orderable_concept])\n\n respond_to do |format|\n if @orderable_concept.save\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully created.' }\n format.json { render json: @orderable_concept, status: :created, location: @orderable_concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def create\n @concept = Concept.new(concept_params)\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render :show, status: :created, location: @concept }\n else\n format.html { render :new }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concept = Concept.new(params[:concept])\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render json: @concept, status: :created, location: @concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @concept_maps = ConceptMap.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@concept_maps }\n end\n end", "def concept_options\n\t\tconcept_name = params[:search_string]\n\t\toptions = concept_set(concept_name).flatten.uniq\n\n\t\trender plain: (\"<li></li><li>\" + options.join(\"</li><li>\") + \"</li>\").html_safe\n\tend", "def show\n @go_term_enrichment = GoTermEnrichment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go_term_enrichment }\n end\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def generate_concept(concept_uri)\n\n @log.info(\"Generate concept #{concept_uri}\")\n\n concept_info = RDF::Query.execute(@graph) do\n pattern [concept_uri, :predicate, :object]\n end\n\n preflabels = []\n altlabels = []\n definition = \"\"\n has_broader = nil\n has_narrower = nil\n editorialNote = nil\n\n concept_info.each do |solution|\n\n case solution.predicate\n when \"http://www.w3.org/2004/02/skos/core#prefLabel\"\n if solution.object.language?\n preflabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n preflabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#altLabel\"\n if solution.object.language?\n altlabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n altlabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#definition\"\n definition = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#editorialNote\"\n editorialNote = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#broader\"\n has_broader = solution.object.value\n when \"http://www.w3.org/2004/02/skos/core#narrower\"\n has_narrower = solution.object.value\n end\n\n end\n\n\n @builder.div(:id => concept_uri.fragment, :class => \"concept\") { |html|\n # preflabel in defaultlang\n html.h2(preflabels.detect {|label| label[\"lang\"] == @default_lang}[\"val\"])\n html.dl {\n html.dt(\"Definition\", :class => \"definition\")\n html.dd(definition, :class => \"definition\")\n\n if altlabels.size > 0\n html.dt(\"Alternative labels\", {:class => \"altlabels\"})\n\n altlabels.each do |label|\n\n if label[\"lang\"]\n\n if label[\"lang\"] != @default_lang\n html.dd(label[\"val\"] + \"(#{label['lang']})\", :lang => label[\"lang\"], :class => \"altlabel\")\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n end\n end\n\n\n if has_broader\n\n has_broader_uri = has_broader\n\n unless has_broader.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_broader[1..-1]\n has_broader_uri = r.to_s\n end\n\n html.dt(\"Has broader\", :class => \"broader\")\n html.dd(:class => \"broader\") {\n html.a(concept_preflabel(has_broader_uri), :href => has_broader)\n }\n end\n\n\n if has_narrower\n\n has_narrower_uri = has_narrower\n\n unless has_narrower.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_narrower[1..-1]\n has_narrower_uri = r.to_s\n end\n html.dt(\"Has narrower\", :class => \"narrower\")\n html.dd(:class => \"narrower\") {\n html.a(concept_preflabel(has_narrower_uri), :href => has_narrower)\n }\n end\n\n if editorialNote\n html.dt(label_for(RDF::SKOS.editorialNote, @default_lang))\n html.dd(editorialNote, :class => \"editorial_note\")\n end\n\n html.dt(\"Identifier\", :class => \"identifier\")\n html.dd(concept_uri, :class => \"identifier\")\n }\n }\n\n end", "def index\n @resources_customs = ResourcesCustom.all\n end", "def show\n @taxonomy_term = TaxonomyTerm.find(params[:id])\n \n @locations = apply_scopes(@taxonomy_term.locations).uniq().page(params[:page]).per(params[:per_page])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_term }\n end\n end", "def index\n @projects_and_concepts = ProjectsAndConcept.all\n end", "def to_s\n return \"#{name}: #{self.set_concept.concepts.collect{|c|c.name}}\"\n end", "def index\n @customizations = Customization.all\n end", "def index\n @conceptos = Concepto.all\n end", "def show\n @terms_of_use = TermsOfUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @terms_of_use }\n end\n end", "def resourceType\n 'Observation'\n end", "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def show\n render json: @given_circumstance\n end", "def concept_params\n params.require(:concept).permit(:idea, :relevance, :speech_id)\n end", "def concept_influences\n find_related_frbr_objects( :is_influenced_by, :which_concepts?) \n end", "def concept_influences\n find_related_frbr_objects( :is_influenced_by, :which_concepts?) \n end", "def terms\n @api_v1_pages = Api::V1::Page.where('title = \"terms\"').first\n\n render json: @api_v1_pages\n end", "def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end", "def show\n @concepts = Concept.where(course_id: @course.id).order(fiat: :asc)\n end", "def test_get_skills_route\n render :json => get_profile_skills_for_profile(\"https://www.linkedin.com/in/marissamayer\").to_json\n end", "def show\n @taxonomy_term = TaxonomyTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_term }\n end\n end", "def show\n @resource = Resource.find(params[:id])\n @terms = Term.all_iit_subjects\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end", "def my_scn\n\t if @questions.present?\n\t\t\t# response to the JSON\n\t\t\trender json: { success: true, \"questions\" => @questions.as_json('my_scn') }\n\t else\n\t render :json=> { success: false, message: \"Questions are not present\" },:status=> 203\n\t end\n\tend", "def index\n @special_needs_types = SpecialNeedsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @special_needs_types }\n end\n end", "def new\n @owner = current_user\n @concept = Concept.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @concept }\n end\n end", "def show\n @taxonomy = Taxonomy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy }\n end\n end", "def show\n render json: @trait_type\n end", "def concept_params\n params.require(:concept).permit(:name, :definition, :subject_id)\n end", "def show\n # Hack to make ontologyid and conceptid work in addition to id and ontology params\n params[:id] = params[:id].nil? ? params[:ontologyid] : params[:id]\n params[:ontology] = params[:ontology].nil? ? params[:id] : params[:ontology]\n\n # PURL-specific redirect to handle /ontologies/{ACR}/{CLASS_ID} paths\n if params[:purl_conceptid]\n params[:purl_conceptid] = \"root\" if params[:purl_conceptid].eql?(\"classes\")\n if params[:conceptid]\n params.delete(:purl_conceptid)\n else\n params[:conceptid] = params.delete(:purl_conceptid)\n end\n redirect_to \"/ontologies/#{params[:acronym]}?p=classes#{params_string_for_redirect(params, prefix: \"&\")}\", :status => :moved_permanently\n return\n end\n\n if params[:ontology].to_i > 0\n acronym = BPIDResolver.id_to_acronym(params[:ontology])\n if acronym\n redirect_new_api\n return\n end\n end\n\n # Note: find_by_acronym includes ontology views\n @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology]).first\n not_found if @ontology.nil?\n \n # Handle the case where an ontology is converted to summary only. \n # See: https://github.com/ncbo/bioportal_web_ui/issues/133.\n if @ontology.summaryOnly && params[:p].present?\n pages = KNOWN_PAGES - [\"summary\", \"notes\"]\n if pages.include?(params[:p])\n redirect_to(ontology_path(params[:ontology]), status: :temporary_redirect) and return\n end\n end\n\n @ob_instructions = helpers.ontolobridge_instructions_template(@ontology)\n\n # Retrieve submissions in descending submissionId order (should be reverse chronological order)\n @submissions = @ontology.explore.submissions.sort {|a,b| b.submissionId.to_i <=> a.submissionId.to_i } || []\n LOG.add :error, \"No submissions for ontology: #{@ontology.id}\" if @submissions.empty?\n\n # Get the latest submission (not necessarily the latest 'ready' submission)\n @submission_latest = @ontology.explore.latest_submission rescue @ontology.explore.latest_submission(include: \"\")\n\n # Is the ontology downloadable?\n restrict_downloads = $NOT_DOWNLOADABLE\n @ont_restricted = restrict_downloads.include? @ontology.acronym\n\n # Fix parameters to only use known pages\n params[:p] = nil unless KNOWN_PAGES.include?(params[:p])\n\n # This action is now a router using the 'p' parameter as the page to show\n case params[:p]\n when \"terms\"\n params[:p] = 'classes'\n redirect_to \"/ontologies/#{params[:ontology]}#{params_string_for_redirect(params)}\", :status => :moved_permanently\n return\n when \"classes\"\n self.classes #rescue self.summary\n return\n when \"mappings\"\n self.mappings #rescue self.summary\n return\n when \"notes\"\n self.notes #rescue self.summary\n return\n when \"widgets\"\n self.widgets #rescue self.summary\n return\n when \"properties\"\n self.properties #rescue self.summary\n return\n when \"summary\"\n self.summary\n return\n else\n self.summary\n return\n end\n end", "def show\n @what_custom = WhatCustom.find(params[:id], :include => :what_custom_factors)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @what_custom }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json\n format.json_api { render({ json: @workflows }.merge(api_collection_properties)) }\n end\n end", "def new\n @conceptual_entity = ConceptualEntity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conceptual_entity }\n end\n end", "def index\n # Get all registered ControlledVocabularies\n @controlled_vocabularies = ControlledVocabulary.all.order(:string_key)\n\n # Also get additional controlled vocabularies from UriService that haven't been registered\n controlled_vocabulary_string_keys = @controlled_vocabularies.map(&:string_key)\n @additional_uri_service_controlled_vocabularies = UriService.client.list_vocabularies(1000) # Ridiculously high limit to show all\n @additional_uri_service_controlled_vocabularies.delete_if { |uri_service_vocabulary| controlled_vocabulary_string_keys.include?(uri_service_vocabulary['string_key']) }\n end", "def common_variable_relationships_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: CommonVariableRelationshipApi#common_variable_relationships_get ...\"\n end\n \n # resource path\n path = \"/commonVariableRelationships\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'id'] = opts[:'id'] if opts[:'id']\n query_params[:'confidence_level'] = opts[:'confidence_level'] if opts[:'confidence_level']\n query_params[:'confidence_score'] = opts[:'confidence_score'] if opts[:'confidence_score']\n query_params[:'direction'] = opts[:'direction'] if opts[:'direction']\n query_params[:'duration_of_action'] = opts[:'duration_of_action'] if opts[:'duration_of_action']\n query_params[:'error_message'] = opts[:'error_message'] if opts[:'error_message']\n query_params[:'onset_delay'] = opts[:'onset_delay'] if opts[:'onset_delay']\n query_params[:'outcome_variable_id'] = opts[:'outcome_variable_id'] if opts[:'outcome_variable_id']\n query_params[:'predictor_variable_id'] = opts[:'predictor_variable_id'] if opts[:'predictor_variable_id']\n query_params[:'predictor_unit_id'] = opts[:'predictor_unit_id'] if opts[:'predictor_unit_id']\n query_params[:'sinn_rank'] = opts[:'sinn_rank'] if opts[:'sinn_rank']\n query_params[:'strength_score'] = opts[:'strength_score'] if opts[:'strength_score']\n query_params[:'strength_level'] = opts[:'strength_level'] if opts[:'strength_level']\n query_params[:'up_votes'] = opts[:'up_votes'] if opts[:'up_votes']\n query_params[:'down_votes'] = opts[:'down_votes'] if opts[:'down_votes']\n query_params[:'value_predicting_high_outcome'] = opts[:'value_predicting_high_outcome'] if opts[:'value_predicting_high_outcome']\n query_params[:'value_predicting_low_outcome'] = opts[:'value_predicting_low_outcome'] if opts[:'value_predicting_low_outcome']\n query_params[:'number_of_users'] = opts[:'number_of_users'] if opts[:'number_of_users']\n query_params[:'data_source'] = opts[:'data_source'] if opts[:'data_source']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(: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 => 'inline_response_200_3')\n if Configuration.debugging\n Configuration.logger.debug \"API called: CommonVariableRelationshipApi#common_variable_relationships_get. Result: #{result.inspect}\"\n end\n return result\n end", "def retrieve_concept_list_from_params params, key, alternate_size\n concept_ids = []\n if params.has_key?(key)\n concept_ids = JSON.parse(params[key]).map { |fc| fc[\"id\"] }\n get_all_concepts = false\n concept_ids.each do |concept_id|\n if concept_id == \"nil\"\n get_all_concepts = true\n break\n end\n end\n end\n\n if get_all_concepts\n concepts = @course.topicconcepts.concepts\n elsif concept_ids.size > 0\n concepts = @course.topicconcepts.concepts.where(id: concept_ids)\n elsif alternate_size > 0\n concepts = @course.topicconcepts.concepts.limit(alternate_size)\n else\n concepts = []\n end\n\n concepts\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 @concept = Concept.find(params[:id])\n @owner = @concept.owner\n @user = current_user\n @comment = Comment.new\n @comments = @concept.comments\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @concept }\n end\n end", "def setup\n #build our isaac_root object from our yaml fixture\n json = YAML.load_file(FILES[Fixtures::CONCEPT_CHRONOLOGY])\n @rest_concept_chronology = Concept.new(uuid: TEST_UUID, params: nil, body_params: nil, action: ACTION_CHRONOLOGY, action_constants: ACTION_CONSTANTS).get_rest_class(json).send(:from_json, json)\n end", "def show\n @lifestyle_subgenre_inference_clarification_connector = LifestyleSubgenreInferenceClarificationConnector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lifestyle_subgenre_inference_clarification_connector }\n end\n end", "def index\n @taxonomies = Taxonomy.find_all_by_taxonomy_type(params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxonomies }\n end\n end", "def custom_regimen_ingredients\n arv_extras_concepts = Concept.joins(:concept_names).where(\n concept_name: { name: ['INH', 'CPT', 'Pyridoxine', 'Rifapentine', 'INH / RFP'] }\n )\n Drug.where(concept: arv_extras_concepts) + Drug.arv_drugs.order(name: :desc)\n end", "def show\n @go_term = GoTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go_term }\n end\n end", "def index\n @custom_collections = CustomCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @custom_collections }\n end\n end", "def show\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @special_needs_type }\n end\n end", "def index\n @co_independent_traits = CoIndependentTrait.all\n end", "def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end", "def index\n @api_v1_custom_texts = Api::V1::CustomText.all\n end", "def index\n @marketplace_tender_qualification_criterias = @tender.qualification_criterias.all\n # authorize @marketplace_tender_qualification_criterias\n render json: @marketplace_tender_qualification_criterias\n end", "def index\n @special_occasions = current_user.special_occasions\n end", "def get_taxonomies(options = {})\n get \"/api/taxonomies\", options\n end", "def concept_set(concept_name)\n concept_id = ConceptName.find_by_name(concept_name).concept_id\n \n set = ConceptSet.find_all_by_concept_set(concept_id, :order => 'sort_weight')\n options = set.map{|item|next if item.concept.blank? ; item.concept.fullname }\n return options\n end", "def update\n respond_to do |format|\n if @concept.update(concept_params)\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @concept }\n else\n format.html { render :edit }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @custom_collection = get_collection\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @custom_collection }\n end\n end", "def show\n @taxonomy_category = TaxonomyCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_category }\n end\n end", "def show\n @lifestyle_cue_inference_clarification_connector = LifestyleCueInferenceClarificationConnector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lifestyle_cue_inference_clarification_connector }\n end\n end", "def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end", "def generic_resource( unit )\n resources unit, concerns: [:search_suggestion, :uniqueness_validation, :retrieve_resource]\n end", "def show\n @concept_group = ConceptGroup.find(params[:id])\n @concepts = @concept_group.concepts\n @concept_groups = @concept_group.concept_groups\n @parent = @concept_group.parent\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concept_group }\n end\n end", "def terms_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TermsApi.terms_get ...'\n end\n # resource path\n local_var_path = '/terms'\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 => 'InlineResponse20021')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TermsApi#terms_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident_kind }\n end\n end", "def set_concepto\n @concepto = Concepto.find(params[:id])\n end", "def set_concept\n @concept = Concept.find_or_create_by(id: params[:id] || params[:concept_id])\n end", "def show\n render json: @event_requirement\n end", "def get_mapped_concept_name(concept_name)\n mapped_concepts = {\n 'eye infection, acute' => 'Red eye',\n 'acute eye infection' => 'Red eye',\n 'acute red eye' => 'Red eye',\n 'skin dryness' => 'Dry skin',\n 'skin dry' => 'Dry skin',\n 'skindryness' => 'Dry skin',\n 'gained or lost weight' => 'Weight change'\n }\n return mapped_concepts[concept_name.to_s.downcase]\n end", "def get_mapped_concept_name(concept_name)\n mapped_concepts = {\n 'eye infection, acute' => 'Red eye',\n 'acute eye infection' => 'Red eye',\n 'acute red eye' => 'Red eye',\n 'skin dryness' => 'Dry skin',\n 'skin dry' => 'Dry skin',\n 'skindryness' => 'Dry skin',\n 'gained or lost weight' => \"Weigth change\"\n }\n return mapped_concepts[concept_name.to_s.downcase]\n end", "def index\n @trait_types = TraitType.all\n\n render json: @trait_types\n end" ]
[ "0.68541723", "0.68018615", "0.6728507", "0.62837774", "0.6267942", "0.60885704", "0.60455537", "0.6031294", "0.5994282", "0.5994282", "0.59654725", "0.58847564", "0.58569443", "0.58115816", "0.5737045", "0.5665238", "0.5556035", "0.5491585", "0.54797035", "0.54778033", "0.53885776", "0.53872705", "0.53864104", "0.53501385", "0.53016335", "0.5223924", "0.52133447", "0.52133447", "0.52129775", "0.51851857", "0.5183657", "0.5182646", "0.516493", "0.5141081", "0.5141081", "0.513657", "0.5103968", "0.5095117", "0.507474", "0.50558376", "0.50143653", "0.50125194", "0.5011033", "0.5007429", "0.5006636", "0.5006636", "0.5002161", "0.5002044", "0.49829242", "0.49829242", "0.4978678", "0.49583066", "0.49405602", "0.49207523", "0.49112323", "0.49025884", "0.48959836", "0.4883363", "0.4859506", "0.48505986", "0.4827662", "0.4820862", "0.48092043", "0.4807868", "0.48048466", "0.4781209", "0.4766388", "0.47548273", "0.47516853", "0.4748975", "0.47294548", "0.47277227", "0.47186846", "0.470952", "0.47074282", "0.46997112", "0.46953836", "0.46934873", "0.4685644", "0.4680449", "0.46665198", "0.46555448", "0.46552014", "0.4651251", "0.46469876", "0.4645586", "0.46422952", "0.46407956", "0.46400934", "0.4639703", "0.4639018", "0.46356046", "0.46354833", "0.46266577", "0.4626232", "0.46241385", "0.4622561", "0.4619818", "0.4619447", "0.46143222" ]
0.78086793
0
GET /customized_concepts/1 GET /customized_concepts/1.json
def show @course = Course.find(params[:course_id]) @customized_concept = @course.customized_concepts.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @customized_concepts = CustomizedConcept.all\n end", "def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end", "def create\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.new(customized_concept_params)\n\n respond_to do |format|\n if @customized_concept.save\n format.html { redirect_to @course, notice: 'Customized concept was successfully created.' }\n format.json { render :show, status: :created, location: @customized_concept }\n else\n format.html { render :new }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @concepts = Concept.all\n end", "def show\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concept }\n end\n end", "def show\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @orderable_concept }\n end\n end", "def update\n respond_to do |format|\n if @customized_concept.update(customized_concept_params)\n format.html { redirect_to @customized_concept, notice: 'Customized concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @customized_concept }\n else\n format.html { render :edit }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def find_concepts(options = {})\n @language_permalink = options[:language_permalink]\n category_id = options[:category_id]\n if @language_permalink\n options.delete(:language_permalink)\n if category_id\n options.delete(:category_id)\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/categories/#{category_id}/concepts\")\n else\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/concepts\")\n end\n end\n end", "def get_concept_required_edges\n concept = @course.topicconcepts.concepts.where(id: params[:id]).first\n if !concept.nil?\n required_concept_edges = concept.concept_edge_required_concepts\n respond_to do |format|\n format.json { render :json => { :current_concept => concept, :dependencies => required_concept_edges.map { |e| { concept_edge_id: e.id, required_concept_name: e.required_concept.name} }}} \n end\n else\n raise \"Concept id is invalid\"\n end\n end", "def resourceType\n 'ConceptMap'\n end", "def resourceType\n 'ConceptMap'\n end", "def get_concept\n concept ? concept : 'N/A'\n end", "def index\n #@concepts = Concept.all#order('updated_at DESC')\n\n #Displaying institute specific concepts\n @concepts = case current_user.role.name when 'Edutor Admin'\n Concept.all\n when 'Institute Admin'\n Concept.where(:institution_id=>current_user.institution_id)\n when 'Teacher'\n Concept.where(:user_id => current_user.id)\n else\n Concept.where(:user_id => current_user.id)\n end\n\n #TO Differentiate new and old concept maps\n @new_concepts = ConceptElement.where(\"x IS NOT NULL\").where(:parent_id => nil)\n @new_ids = Array.new\n @new_concepts.each do |e|\n @new_ids << e.concept_id\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concepts }\n end\n end", "def customized_concept_params\n params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)\n end", "def new\n @concept = Concept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concept }\n end\n end", "def concept(name, *args, &block)\n controller.concept(name, *args, &block)\n end", "def show\n @conceptual_entity = ConceptualEntity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conceptual_entity }\n end\n end", "def concept_view_data(concept)\n res = {}\n\n render_concept_association(res, concept, Collection::Member::Base)\n\n Iqvoc::Concept.labeling_classes.each do |labeling_class, languages|\n render_concept_association(res, concept, labeling_class, available_languages: languages || Iqvoc.available_languages)\n end\n\n Iqvoc::Concept.relation_classes.each do |relation_class|\n render_concept_association(res, concept, relation_class)\n end\n\n render_match_association(res, concept, Iqvoc::Concept.match_classes)\n\n Iqvoc::Concept.note_classes.each do |note_class|\n render_concept_association(res, concept, note_class)\n end\n\n Iqvoc::Concept.notation_classes.each do |notation_class|\n render_concept_association(res, concept, notation_class)\n end\n\n Iqvoc::Concept.additional_association_classes.keys.each do |assoc_class|\n render_concept_association(res, concept, assoc_class)\n end\n\n res\n end", "def destroy\n @customized_concept.destroy\n respond_to do |format|\n format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def new\n @orderable_concept = OrderableConcept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orderable_concept }\n end\n end", "def index\n @cover_concepts = CoverConcept.all\n end", "def show\n @concept_map = ConceptMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@concept_map }\n end\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def extract_concepts( content , page , location = LOC_CONTENT)\n #$lgr.info(\"Content : #{content} \")\n content.scan( PTN_CONCEPT ).each do |concept_title|\n if /(\\w+):=(.*)/ =~ concept_title[0]\n Property.create!( :page => page , :name => $1 , :value => $2 )\n next\n end\n refs = PTN_CONCEPT_RELATION.match(concept_title[0])\n #$lgr.info refs.to_a.inspect\n data = [] #Concept instance for odd index, ConceptRelation instance for even index\n if refs.size % 2 != 0 then flash[:notice] = \"Illegal concept definition! #{refs[0]}\" end\n \n refs.to_a.each_with_index do |match_str , i|\n #$lgr.info(\" [#{i}]=>[#{match_str}] / \")\n if match_str == nil || match_str.length == 0 then break end\n if i == 0 then next end\n if i % 2 == 1 #Concept\n data[i] = Concept.find_by_title( match_str )\n if data[i] == nil\n data[i] = Concept.create!( :title=>match_str )\n end\n #ConceptOccurrence will be handled by Organizer\n ConceptOccurrence.create!( :page => page , :concept => data[i] , :location => location)\n #Finalize ConceptRelation\n if i > 1\n data[i-1].other_concept = data[i]\n data[i-1].page = page\n data[i-1].save\n #$lgr.info data[i-1].inspect\n end\n elsif i % 2 == 0 #ConceptRelation\n data[i] = ConceptRelation.new\n data[i].concept = data[i-1]\n data[i].kind = match_str\n end\n end # end of block\n end #end of block\n end", "def create\n @concept = Concept.new(concept_params)\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render :show, status: :created, location: @concept }\n else\n format.html { render :new }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concept = Concept.new(params[:concept])\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render json: @concept, status: :created, location: @concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @special_requirements = SpecialRequirement.all\n end", "def terms\n @api_v1_pages = Api::V1::Page.where('title = \"terms\"').first\n\n render json: @api_v1_pages\n end", "def create\n @orderable_concept = OrderableConcept.new(params[:orderable_concept])\n\n respond_to do |format|\n if @orderable_concept.save\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully created.' }\n format.json { render json: @orderable_concept, status: :created, location: @orderable_concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @go_term_enrichment = GoTermEnrichment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go_term_enrichment }\n end\n end", "def index\n @custom_definitions = CustomDefinition.all\n end", "def show\n @terms_of_use = TermsOfUse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @terms_of_use }\n end\n end", "def index\n @conceptos = Concepto.all\n end", "def index\n @concept_maps = ConceptMap.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:@concept_maps }\n end\n end", "def index\n @projects_and_concepts = ProjectsAndConcept.all\n end", "def show\n @concepts = Concept.where(course_id: @course.id).order(fiat: :asc)\n end", "def show\n @resource = Resource.find(params[:id])\n @terms = Term.all_iit_subjects\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end", "def show\n @taxonomy_term = TaxonomyTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_term }\n end\n end", "def show\n # Hack to make ontologyid and conceptid work in addition to id and ontology params\n params[:id] = params[:id].nil? ? params[:ontologyid] : params[:id]\n params[:ontology] = params[:ontology].nil? ? params[:id] : params[:ontology]\n\n # PURL-specific redirect to handle /ontologies/{ACR}/{CLASS_ID} paths\n if params[:purl_conceptid]\n params[:purl_conceptid] = \"root\" if params[:purl_conceptid].eql?(\"classes\")\n if params[:conceptid]\n params.delete(:purl_conceptid)\n else\n params[:conceptid] = params.delete(:purl_conceptid)\n end\n redirect_to \"/ontologies/#{params[:acronym]}?p=classes#{params_string_for_redirect(params, prefix: \"&\")}\", :status => :moved_permanently\n return\n end\n\n if params[:ontology].to_i > 0\n acronym = BPIDResolver.id_to_acronym(params[:ontology])\n if acronym\n redirect_new_api\n return\n end\n end\n\n # Note: find_by_acronym includes ontology views\n @ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology]).first\n not_found if @ontology.nil?\n \n # Handle the case where an ontology is converted to summary only. \n # See: https://github.com/ncbo/bioportal_web_ui/issues/133.\n if @ontology.summaryOnly && params[:p].present?\n pages = KNOWN_PAGES - [\"summary\", \"notes\"]\n if pages.include?(params[:p])\n redirect_to(ontology_path(params[:ontology]), status: :temporary_redirect) and return\n end\n end\n\n @ob_instructions = helpers.ontolobridge_instructions_template(@ontology)\n\n # Retrieve submissions in descending submissionId order (should be reverse chronological order)\n @submissions = @ontology.explore.submissions.sort {|a,b| b.submissionId.to_i <=> a.submissionId.to_i } || []\n LOG.add :error, \"No submissions for ontology: #{@ontology.id}\" if @submissions.empty?\n\n # Get the latest submission (not necessarily the latest 'ready' submission)\n @submission_latest = @ontology.explore.latest_submission rescue @ontology.explore.latest_submission(include: \"\")\n\n # Is the ontology downloadable?\n restrict_downloads = $NOT_DOWNLOADABLE\n @ont_restricted = restrict_downloads.include? @ontology.acronym\n\n # Fix parameters to only use known pages\n params[:p] = nil unless KNOWN_PAGES.include?(params[:p])\n\n # This action is now a router using the 'p' parameter as the page to show\n case params[:p]\n when \"terms\"\n params[:p] = 'classes'\n redirect_to \"/ontologies/#{params[:ontology]}#{params_string_for_redirect(params)}\", :status => :moved_permanently\n return\n when \"classes\"\n self.classes #rescue self.summary\n return\n when \"mappings\"\n self.mappings #rescue self.summary\n return\n when \"notes\"\n self.notes #rescue self.summary\n return\n when \"widgets\"\n self.widgets #rescue self.summary\n return\n when \"properties\"\n self.properties #rescue self.summary\n return\n when \"summary\"\n self.summary\n return\n else\n self.summary\n return\n end\n end", "def to_s\n return \"#{name}: #{self.set_concept.concepts.collect{|c|c.name}}\"\n end", "def show\n @taxonomy_term = TaxonomyTerm.find(params[:id])\n \n @locations = apply_scopes(@taxonomy_term.locations).uniq().page(params[:page]).per(params[:per_page])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_term }\n end\n end", "def show\n @taxonomy = Taxonomy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy }\n end\n end", "def generate_concept(concept_uri)\n\n @log.info(\"Generate concept #{concept_uri}\")\n\n concept_info = RDF::Query.execute(@graph) do\n pattern [concept_uri, :predicate, :object]\n end\n\n preflabels = []\n altlabels = []\n definition = \"\"\n has_broader = nil\n has_narrower = nil\n editorialNote = nil\n\n concept_info.each do |solution|\n\n case solution.predicate\n when \"http://www.w3.org/2004/02/skos/core#prefLabel\"\n if solution.object.language?\n preflabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n preflabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#altLabel\"\n if solution.object.language?\n altlabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n altlabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#definition\"\n definition = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#editorialNote\"\n editorialNote = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#broader\"\n has_broader = solution.object.value\n when \"http://www.w3.org/2004/02/skos/core#narrower\"\n has_narrower = solution.object.value\n end\n\n end\n\n\n @builder.div(:id => concept_uri.fragment, :class => \"concept\") { |html|\n # preflabel in defaultlang\n html.h2(preflabels.detect {|label| label[\"lang\"] == @default_lang}[\"val\"])\n html.dl {\n html.dt(\"Definition\", :class => \"definition\")\n html.dd(definition, :class => \"definition\")\n\n if altlabels.size > 0\n html.dt(\"Alternative labels\", {:class => \"altlabels\"})\n\n altlabels.each do |label|\n\n if label[\"lang\"]\n\n if label[\"lang\"] != @default_lang\n html.dd(label[\"val\"] + \"(#{label['lang']})\", :lang => label[\"lang\"], :class => \"altlabel\")\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n end\n end\n\n\n if has_broader\n\n has_broader_uri = has_broader\n\n unless has_broader.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_broader[1..-1]\n has_broader_uri = r.to_s\n end\n\n html.dt(\"Has broader\", :class => \"broader\")\n html.dd(:class => \"broader\") {\n html.a(concept_preflabel(has_broader_uri), :href => has_broader)\n }\n end\n\n\n if has_narrower\n\n has_narrower_uri = has_narrower\n\n unless has_narrower.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_narrower[1..-1]\n has_narrower_uri = r.to_s\n end\n html.dt(\"Has narrower\", :class => \"narrower\")\n html.dd(:class => \"narrower\") {\n html.a(concept_preflabel(has_narrower_uri), :href => has_narrower)\n }\n end\n\n if editorialNote\n html.dt(label_for(RDF::SKOS.editorialNote, @default_lang))\n html.dd(editorialNote, :class => \"editorial_note\")\n end\n\n html.dt(\"Identifier\", :class => \"identifier\")\n html.dd(concept_uri, :class => \"identifier\")\n }\n }\n\n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def concept_genres\n find_related_frbr_objects( :has_as_its_genre, :which_concepts?) \n end", "def resourceType\n 'Observation'\n end", "def new\n @owner = current_user\n @concept = Concept.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @concept }\n end\n end", "def show\n render json: @given_circumstance\n end", "def show\n @lifestyle_subgenre_inference_clarification_connector = LifestyleSubgenreInferenceClarificationConnector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lifestyle_subgenre_inference_clarification_connector }\n end\n end", "def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\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 concept_params\n params.require(:concept).permit(:idea, :relevance, :speech_id)\n end", "def concept_options\n\t\tconcept_name = params[:search_string]\n\t\toptions = concept_set(concept_name).flatten.uniq\n\n\t\trender plain: (\"<li></li><li>\" + options.join(\"</li><li>\") + \"</li>\").html_safe\n\tend", "def show\n @go_term = GoTerm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @go_term }\n end\n end", "def new\n @conceptual_entity = ConceptualEntity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conceptual_entity }\n end\n end", "def index\n @resources_customs = ResourcesCustom.all\n end", "def index\n @special_needs_types = SpecialNeedsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @special_needs_types }\n end\n end", "def set_concepto\n @concepto = Concepto.find(params[:id])\n end", "def show\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @special_needs_type }\n end\n end", "def show\n @research_c = ResearchC.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @research_c }\n end\n end", "def show\n @concept = Concept.find(params[:id])\n @owner = @concept.owner\n @user = current_user\n @comment = Comment.new\n @comments = @concept.comments\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @concept }\n end\n end", "def concept_params\n params.require(:concept).permit(:name, :definition, :subject_id)\n end", "def show\n @taxonomy_category = TaxonomyCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxonomy_category }\n end\n end", "def show\n render json: @trait_type\n end", "def show\n @lifestyle_cue_inference_clarification_connector = LifestyleCueInferenceClarificationConnector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lifestyle_cue_inference_clarification_connector }\n end\n end", "def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end", "def show\n @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident_kind }\n end\n end", "def show\n @concept_group = ConceptGroup.find(params[:id])\n @concepts = @concept_group.concepts\n @concept_groups = @concept_group.concept_groups\n @parent = @concept_group.parent\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concept_group }\n end\n end", "def set_concept\n @concept = Concept.find_or_create_by(id: params[:id] || params[:concept_id])\n end", "def show\n @what_custom = WhatCustom.find(params[:id], :include => :what_custom_factors)\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @what_custom }\n end\n end", "def index\n @customizations = Customization.all\n end", "def index\n respond_to do |format|\n format.html\n format.json\n format.json_api { render({ json: @workflows }.merge(api_collection_properties)) }\n end\n end", "def new\n @resource = Resource.new\n @terms = Term.all_iit_subjects\n @iit_terms = Term.all_iit_subjects\n @non_iit_terms = Term.all_iit_non_subjects\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def concept_influences\n find_related_frbr_objects( :is_influenced_by, :which_concepts?) \n end", "def concept_influences\n find_related_frbr_objects( :is_influenced_by, :which_concepts?) \n end", "def update\n respond_to do |format|\n if @concept.update(concept_params)\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @concept }\n else\n format.html { render :edit }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @special_word = SpecialWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @special_word }\n end\n end", "def retrieve_concept_list_from_params params, key, alternate_size\n concept_ids = []\n if params.has_key?(key)\n concept_ids = JSON.parse(params[key]).map { |fc| fc[\"id\"] }\n get_all_concepts = false\n concept_ids.each do |concept_id|\n if concept_id == \"nil\"\n get_all_concepts = true\n break\n end\n end\n end\n\n if get_all_concepts\n concepts = @course.topicconcepts.concepts\n elsif concept_ids.size > 0\n concepts = @course.topicconcepts.concepts.where(id: concept_ids)\n elsif alternate_size > 0\n concepts = @course.topicconcepts.concepts.limit(alternate_size)\n else\n concepts = []\n end\n\n concepts\n end", "def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end", "def index\n # Get all registered ControlledVocabularies\n @controlled_vocabularies = ControlledVocabulary.all.order(:string_key)\n\n # Also get additional controlled vocabularies from UriService that haven't been registered\n controlled_vocabulary_string_keys = @controlled_vocabularies.map(&:string_key)\n @additional_uri_service_controlled_vocabularies = UriService.client.list_vocabularies(1000) # Ridiculously high limit to show all\n @additional_uri_service_controlled_vocabularies.delete_if { |uri_service_vocabulary| controlled_vocabulary_string_keys.include?(uri_service_vocabulary['string_key']) }\n end", "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def concept_themes\n find_related_frbr_objects( :has_as_its_theme, :which_concepts?) \n end", "def show\n @taxon_rule = TaxonRule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taxon_rule }\n end\n end", "def index\n @taxonomies = Taxonomy.find_all_by_taxonomy_type(params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxonomies }\n end\n end", "def destroy\n @concept = Concept.find(params[:id])\n @concept.destroy\n\n respond_to do |format|\n format.html { redirect_to concepts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept = Concept.find(params[:id])\n @concept.destroy\n\n respond_to do |format|\n format.html { redirect_to concepts_url }\n format.json { head :no_content }\n end\n end", "def show\n @frequent_set = FrequentSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @frequent_set }\n end\n end", "def new\n @title = 'New Clinical Specialty'\n @description = 'Add a new clinical specialty'\n @clinicalsection = Clinicalsection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clinicalsection }\n end\n end", "def common_variable_relationships_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: CommonVariableRelationshipApi#common_variable_relationships_get ...\"\n end\n \n # resource path\n path = \"/commonVariableRelationships\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'id'] = opts[:'id'] if opts[:'id']\n query_params[:'confidence_level'] = opts[:'confidence_level'] if opts[:'confidence_level']\n query_params[:'confidence_score'] = opts[:'confidence_score'] if opts[:'confidence_score']\n query_params[:'direction'] = opts[:'direction'] if opts[:'direction']\n query_params[:'duration_of_action'] = opts[:'duration_of_action'] if opts[:'duration_of_action']\n query_params[:'error_message'] = opts[:'error_message'] if opts[:'error_message']\n query_params[:'onset_delay'] = opts[:'onset_delay'] if opts[:'onset_delay']\n query_params[:'outcome_variable_id'] = opts[:'outcome_variable_id'] if opts[:'outcome_variable_id']\n query_params[:'predictor_variable_id'] = opts[:'predictor_variable_id'] if opts[:'predictor_variable_id']\n query_params[:'predictor_unit_id'] = opts[:'predictor_unit_id'] if opts[:'predictor_unit_id']\n query_params[:'sinn_rank'] = opts[:'sinn_rank'] if opts[:'sinn_rank']\n query_params[:'strength_score'] = opts[:'strength_score'] if opts[:'strength_score']\n query_params[:'strength_level'] = opts[:'strength_level'] if opts[:'strength_level']\n query_params[:'up_votes'] = opts[:'up_votes'] if opts[:'up_votes']\n query_params[:'down_votes'] = opts[:'down_votes'] if opts[:'down_votes']\n query_params[:'value_predicting_high_outcome'] = opts[:'value_predicting_high_outcome'] if opts[:'value_predicting_high_outcome']\n query_params[:'value_predicting_low_outcome'] = opts[:'value_predicting_low_outcome'] if opts[:'value_predicting_low_outcome']\n query_params[:'number_of_users'] = opts[:'number_of_users'] if opts[:'number_of_users']\n query_params[:'data_source'] = opts[:'data_source'] if opts[:'data_source']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(: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 => 'inline_response_200_3')\n if Configuration.debugging\n Configuration.logger.debug \"API called: CommonVariableRelationshipApi#common_variable_relationships_get. Result: #{result.inspect}\"\n end\n return result\n end", "def show\n @chiropractic_compliance = ChiropracticCompliance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chiropractic_compliance }\n end\n end", "def get\n @research_output = @service.get({type: params[:graph], detail: params[:detail], id: params[:id]},\n host: request.env[\"HTTP_HOST\"], limit: params[:num_results], offset: params[:start_offset], :per_project => params[:per_project], format: params[:format])\n\n respond_with @research_output\n end", "def show\n @knowledge = Knowledge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @knowledge }\n end\n end", "def setup\n #build our isaac_root object from our yaml fixture\n json = YAML.load_file(FILES[Fixtures::CONCEPT_CHRONOLOGY])\n @rest_concept_chronology = Concept.new(uuid: TEST_UUID, params: nil, body_params: nil, action: ACTION_CHRONOLOGY, action_constants: ACTION_CONSTANTS).get_rest_class(json).send(:from_json, json)\n end", "def show\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation_type }\n end\n end", "def show\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinicalsection }\n end\n end", "def show\n @restriction = Restriction.find(params[:id])\n\n render json: @restriction\n end", "def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end", "def show\n @conclusion = Conclusion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conclusion }\n end\n end", "def concept_set(concept_name)\n concept_id = ConceptName.find_by_name(concept_name).concept_id\n \n set = ConceptSet.find_all_by_concept_set(concept_id, :order => 'sort_weight')\n options = set.map{|item|next if item.concept.blank? ; item.concept.fullname }\n return options\n end" ]
[ "0.7831783", "0.6775864", "0.66508", "0.66340804", "0.6481487", "0.62545395", "0.62069273", "0.61926204", "0.6136589", "0.6037333", "0.6037333", "0.6014648", "0.5907674", "0.5893592", "0.58694124", "0.5839345", "0.58303535", "0.5772579", "0.5735444", "0.5725731", "0.5708238", "0.5683142", "0.5640991", "0.5640991", "0.556963", "0.5525927", "0.5515082", "0.54918635", "0.5459808", "0.54434866", "0.54344547", "0.54005706", "0.5376336", "0.5373093", "0.536701", "0.5353388", "0.5348751", "0.5339724", "0.5303523", "0.5295406", "0.5270152", "0.526599", "0.5246018", "0.5242401", "0.52077043", "0.52077043", "0.5202978", "0.51709175", "0.51609755", "0.515902", "0.5150414", "0.514684", "0.51390415", "0.51319134", "0.51003903", "0.5087594", "0.50825655", "0.5074466", "0.50740653", "0.50705254", "0.5058207", "0.50547034", "0.5047977", "0.5042585", "0.50417346", "0.5041111", "0.5033434", "0.50317913", "0.50294155", "0.5013099", "0.497153", "0.497132", "0.49696386", "0.49647307", "0.4964024", "0.4964024", "0.49609384", "0.49553105", "0.49457034", "0.49406376", "0.49384093", "0.49371532", "0.49371532", "0.49340647", "0.4925801", "0.49222454", "0.49222454", "0.49198225", "0.49164942", "0.49077922", "0.49044916", "0.48934045", "0.48920387", "0.4890461", "0.48846558", "0.4882497", "0.48804125", "0.48796946", "0.48785675", "0.48708826" ]
0.7014512
1
POST /customized_concepts POST /customized_concepts.json
def create @course = Course.find(params[:course_id]) @customized_concept = @course.customized_concepts.new(customized_concept_params) respond_to do |format| if @customized_concept.save format.html { redirect_to @course, notice: 'Customized concept was successfully created.' } format.json { render :show, status: :created, location: @customized_concept } else format.html { render :new } format.json { render json: @customized_concept.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @customized_concepts = CustomizedConcept.all\n end", "def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end", "def customized_concept_params\n params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)\n end", "def update\n respond_to do |format|\n if @customized_concept.update(customized_concept_params)\n format.html { redirect_to @customized_concept, notice: 'Customized concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @customized_concept }\n else\n format.html { render :edit }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @orderable_concept = OrderableConcept.new(params[:orderable_concept])\n\n respond_to do |format|\n if @orderable_concept.save\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully created.' }\n format.json { render json: @orderable_concept, status: :created, location: @orderable_concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concept = Concept.new(concept_params)\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render :show, status: :created, location: @concept }\n else\n format.html { render :new }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concept = Concept.new(params[:concept])\n\n respond_to do |format|\n if @concept.save\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render json: @concept, status: :created, location: @concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @customized_concept.destroy\n respond_to do |format|\n format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def concept_params\n params.require(:concept).permit(:name, :definition, :subject_id)\n end", "def concept_params\n params.require(:concept).permit(:idea, :relevance, :speech_id)\n end", "def create\n authorize! :create, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n @concepto = Concepto.new(concepto_params)\n\n respond_to do |format|\n if @concepto.save\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> El concepto fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto }\n else\n format.html { render :new }\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_regimen_type(regimen_concept)\n return nil if regimen_concept.blank?\n drug_concept = self.concept\n return nil if drug_concept.blank? or User.current_user.nil?\n concept_set = ConceptSet.new(:concept_id => drug_concept.id, :concept_set => regimen_concept.id,\n :creator => User.current_user.id, :date_created => Time.now)\n concept_set.save\n end", "def create\n @conceptual_entity = ConceptualEntity.new(params[:conceptual_entity])\n\n respond_to do |format|\n if @conceptual_entity.save\n format.html { redirect_to @conceptual_entity, notice: 'Conceptual entity was successfully created.' }\n format.json { render json: @conceptual_entity, status: :created, location: @conceptual_entity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @conceptual_entity.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_params\n params.require(:question).permit(:content, :response_type_id, :parent_id, :category_id, :groups,\n :version_independent_id, :description, :other_allowed, :subcategory_id,\n concepts_attributes: [:id, :value, :display_name, :code_system],\n data_collection_methods: [])\n end", "def create\n @concept = Concept.new(params[:concept])\n # make sure that the status is correct\n @concept.owner = current_user\n \n waiting_on = []\n waiting_on << 'Marketing' unless params[:concept][:consulted_marketing]\n waiting_on << 'Legal' unless params[:concept][:consulted_legal]\n status = waiting_on.empty? ? 'Pending Approval' : \"Awaiting #{waiting_on.join(' & ')} Approval\"\n @concept.attributes = {:status => status}\n \n respond_to do |format|\n if @concept.save\n email = ReportMailer.deliver_concept_created(@concept)\n flash[:notice] = 'Concept was successfully created.'\n format.html { redirect_to concept_path(@concept) }\n format.xml { render :xml => @concept, :status => :created, :location => @concept }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @concept.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @special_requirement = SpecialRequirement.new(special_requirement_params)\n\n respond_to do |format|\n if @special_requirement.save\n format.html { redirect_to @special_requirement, notice: 'Special requirement was successfully created.' }\n format.json { render :show, status: :created, location: @special_requirement }\n else\n format.html { render :new }\n format.json { render json: @special_requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @concept = Concept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concept }\n end\n end", "def concept(name, *args, &block)\n controller.concept(name, *args, &block)\n end", "def common_variable_relationships_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: CommonVariableRelationshipApi#common_variable_relationships_post ...\"\n end\n \n # resource path\n path = \"/commonVariableRelationships\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_4')\n if Configuration.debugging\n Configuration.logger.debug \"API called: CommonVariableRelationshipApi#common_variable_relationships_post. Result: #{result.inspect}\"\n end\n return result\n end", "def create\n render_json_auto @survey.add_logic_control_rule(params[:logic]) and return\n end", "def show\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.find(params[:id])\n end", "def create\n string = request.body.read\n @parseConceptJson = ActiveSupport::JSON.decode(string)\n logger.info\"ConceptJson=========#{@parseConceptJson}\"\n if @parseConceptJson['conceptmap_id'] == 'null'\n @concept = Concept.new\n #@conceptJson[\"id\"][\"name\"][\"details\"][\"parentId\"][email protected]\n #@parseConceptJson=JSON.load(@concept.concept)\n #print @parseConceptJson[\"id\"]\n @concept.name=@parseConceptJson[\"conceptmap_name\"]\n @concept.board_id=@parseConceptJson[\"board_id\"]\n @concept.content_year_id=@parseConceptJson[\"class_id\"]\n @concept.subject_id=@parseConceptJson[\"subject_id\"]\n @concept.chapter_id=@parseConceptJson[\"chpater_id\"]\n @elements = @parseConceptJson[\"cmap\"]\n respond_to do |format|\n if @concept.save\n @concept_element=ConceptElement.create(\"name\" => @elements[\"name\"], \"description\" => @elements[\"detail\"], \"concept_id\" => @concept.id)\n insertConceptElement(@elements, @concept, @concept_element)\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render json: 200, status: :created, location: @concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: 404, status: :unprocessable_entity }\n end\n end\n\n else\n @concept = Concept.find(@parseConceptJson['conceptmap_id'])\n @elements = @parseConceptJson[\"cmap\"]\n respond_to do |format|\n if @concept\n @concept.concept_elements.destroy_all\n @concept_element=ConceptElement.create(\"name\" => @elements[\"name\"], \"description\" => @elements[\"detail\"], \"concept_id\" => @concept.id)\n insertConceptElement(@elements, @concept, @concept_element)\n format.html { redirect_to @concept, notice: 'Concept was successfully created.' }\n format.json { render json: 200, status: :created, location: @concept }\n else\n format.html { render action: \"new\" }\n format.json { render json: 404, status: :unprocessable_entity }\n end\n end\n end\n\n\n end", "def new\n @orderable_concept = OrderableConcept.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orderable_concept }\n end\n end", "def create\n @taxonomy = Taxonomy.new(params[:taxonomy])\n\n respond_to do |format|\n if @taxonomy.save\n format.html { redirect_to edit_admin_taxonomy_path(@taxonomy), notice: 'Taxonomy was successfully updated.' }\n format.json { render json: @taxonomy, status: :created, location: @taxonomy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taxonomy.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_concept\n concept ? concept : 'N/A'\n end", "def set_concept\n @concept = Concept.find_or_create_by(id: params[:id] || params[:concept_id])\n end", "def create\n @requisition = Requisition.new(requisition_params)\n respond_to do |format|\n if @requisition.save\n # Send to the Business Insight Model\n RestClient::Resource.new(APP_CONFIG[:insight_url], :verify_ssl => false, :user => APP_CONFIG[:insight_username], :password => APP_CONFIG[:insight_password]).post({\n \"modelId\" => \"Resupply_Ky06ggwO\",\n \"measures\" => [{\n \"name\" => \"TotalCost\",\n \"value\" => @requisition.amount\n }],\n \"identifierValue\" => @requisition.id,\n \"correlationValue\" => @requisition.id,\n \"eventTime\" => Time.now.strftime('%Y-%m-%dT%H:%M:%S'),\n \"milestoneId\" => \"RequsitionRaised\",\n \"dimensions\" => [ {\n \"name\" => \"Location\",\n \"value\" => @requisition.loc\n } ]\n }.to_json, :content_type=>'application/json')\n format.html { redirect_to requisitions_url, notice: 'Requisition was successfully created.' }\n format.json { render :show, status: :created, loc: @requisition }\n else\n format.html { render :new }\n format.json { render json: @requisition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Conceptopersonal\n @conceptopersonal = Conceptopersonal.new(conceptopersonal_params)\n\n respond_to do |format|\n if @conceptopersonal.save\n\n\n format.html { redirect_to conceptospersonales_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> El concepto fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @conceptopersonal }\n else\n format.html { render :new }\n format.json { render json: @conceptopersonal.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @concepts = Concept.all\n end", "def concepto_params\n params.require(:concepto).permit(:clave, :description, :capitulo_id)\n end", "def create\n @recipe = Recipe.new(recipe_params)\n @recipe.uuid = SecureRandom.uuid\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe.objective}\n format.json { render :show, status: :created, location: @recipe.objective }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @canonical_gconcepts = args[:canonical_gconcepts] if args.key?(:canonical_gconcepts)\n end", "def create\n @resources_custom = ResourcesCustom.new(resources_custom_params)\n\n respond_to do |format|\n if @resources_custom.save\n format.html { redirect_to @resources_custom, notice: 'Resources custom was successfully created.' }\n format.json { render :show, status: :created, location: @resources_custom }\n else\n format.html { render :new }\n format.json { render json: @resources_custom.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @indicate_taxonomy = Indicate::Taxonomy.new(indicate_taxonomy_params)\n\n respond_to do |format|\n if @indicate_taxonomy.save\n format.html { redirect_to @indicate_taxonomy, notice: 'Taxonomy was successfully created.' }\n format.json { render :show, status: :created, location: @indicate_taxonomy }\n else\n format.html { render :new }\n format.json { render json: @indicate_taxonomy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @go_term_enrichment = GoTermEnrichment.new(params[:go_term_enrichment])\n\n respond_to do |format|\n if @go_term_enrichment.save\n format.html { redirect_to @go_term_enrichment, notice: 'Go term enrichment was successfully created.' }\n format.json { render json: @go_term_enrichment, status: :created, location: @go_term_enrichment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @go_term_enrichment.errors, status: :unprocessable_entity }\n end\n end\n end", "def find_concepts(options = {})\n @language_permalink = options[:language_permalink]\n category_id = options[:category_id]\n if @language_permalink\n options.delete(:language_permalink)\n if category_id\n options.delete(:category_id)\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/categories/#{category_id}/concepts\")\n else\n Syntaxdb::Request.send_request(options, \"/languages/#{@language_permalink}/concepts\")\n end\n end\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def extract_concepts( content , page , location = LOC_CONTENT)\n #$lgr.info(\"Content : #{content} \")\n content.scan( PTN_CONCEPT ).each do |concept_title|\n if /(\\w+):=(.*)/ =~ concept_title[0]\n Property.create!( :page => page , :name => $1 , :value => $2 )\n next\n end\n refs = PTN_CONCEPT_RELATION.match(concept_title[0])\n #$lgr.info refs.to_a.inspect\n data = [] #Concept instance for odd index, ConceptRelation instance for even index\n if refs.size % 2 != 0 then flash[:notice] = \"Illegal concept definition! #{refs[0]}\" end\n \n refs.to_a.each_with_index do |match_str , i|\n #$lgr.info(\" [#{i}]=>[#{match_str}] / \")\n if match_str == nil || match_str.length == 0 then break end\n if i == 0 then next end\n if i % 2 == 1 #Concept\n data[i] = Concept.find_by_title( match_str )\n if data[i] == nil\n data[i] = Concept.create!( :title=>match_str )\n end\n #ConceptOccurrence will be handled by Organizer\n ConceptOccurrence.create!( :page => page , :concept => data[i] , :location => location)\n #Finalize ConceptRelation\n if i > 1\n data[i-1].other_concept = data[i]\n data[i-1].page = page\n data[i-1].save\n #$lgr.info data[i-1].inspect\n end\n elsif i % 2 == 0 #ConceptRelation\n data[i] = ConceptRelation.new\n data[i].concept = data[i-1]\n data[i].kind = match_str\n end\n end # end of block\n end #end of block\n end", "def resourceType\n 'ConceptMap'\n end", "def resourceType\n 'ConceptMap'\n end", "def create(client, workspace: required(\"workspace\"), resource_subtype: nil, type: nil, name: required(\"name\"), description: nil, precision: nil, enum_options: nil, options: {}, **data)\n with_params = data.merge(workspace: workspace, resource_subtype: resource_subtype || type, name: name, description: description, precision: precision, enum_options: enum_options).reject { |_,v| v.nil? || Array(v).empty? }\n Resource.new(parse(client.post(\"/custom_fields\", body: with_params, options: options)).first, client: client)\n end", "def create\n @customizing = Customizing.new(customizing_params)\n # params[:goal][:user_id]\n # params :c, :freigabe_status_id\n respond_to do |format|\n if @customizing.save\n format.html { redirect_to @customizing, notice: 'Customizing was successfully created.' }\n format.json { render :show, status: :created, location: @customizing }\n else\n format.html { render :new }\n format.json { render json: @customizing.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_occasion = SpecialOccasion.new(special_occasion_params)\n\n @special_occasion.user = current_user\n\n respond_to do |format|\n if @special_occasion.save\n format.html { redirect_to @special_occasion, notice: 'Special occasion was successfully created.' }\n format.json { render :show, status: :created, location: @special_occasion }\n else\n format.html { render :new }\n format.json { render json: @special_occasion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @taxonomy_term = TaxonomyTerm.new(params[:taxonomy_term])\n\n respond_to do |format|\n if @taxonomy_term.save\n format.html { redirect_to admin_taxonomy_term_path(@taxonomy_term), notice: 'Taxonomy term was successfully created.' }\n format.json { render json: @taxonomy_term, status: :created, location: @taxonomy_term }\n else\n \tset_site_entities @taxonomy_term\n \t\n format.html { render action: \"new\" }\n format.json { render json: @taxonomy_term.errors, status: :unprocessable_entity }\n end\n end\n end", "def special_requirement_params\n params.require(:special_requirement).permit(:requirementDesc, :requirementValue)\n end", "def concepto_params\n params.require(:concepto).permit(:nombre, :modalidad_de_pago, :tipo_de_concepto, :condicion, tipo_ids: [], formulas_attributes: [:id, :empleado, :patrono, :_destroy])\n end", "def create\n @concept_group = ConceptGroup.new(params[:concept_group])\n\n respond_to do |format|\n if @concept_group.save\n format.html { redirect_to @concept_group, notice: 'Concept group was successfully created.' }\n format.json { render json: @concept_group, status: :created, location: @concept_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @concept_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_concept_required_edges\n concept = @course.topicconcepts.concepts.where(id: params[:id]).first\n if !concept.nil?\n required_concept_edges = concept.concept_edge_required_concepts\n respond_to do |format|\n format.json { render :json => { :current_concept => concept, :dependencies => required_concept_edges.map { |e| { concept_edge_id: e.id, required_concept_name: e.required_concept.name} }}} \n end\n else\n raise \"Concept id is invalid\"\n end\n end", "def create\n @term_relationship = TermRelationship.new(term_relationship_params)\n\n respond_to do |format|\n if @term_relationship.save\n format.html { redirect_to @term_relationship, notice: 'Term relationship was successfully created.' }\n format.json { render :show, status: :created, location: @term_relationship }\n else\n format.html { render :new }\n format.json { render json: @term_relationship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @custom_definition = @site.custom_definitions.new(custom_definition_params)\n\n if @custom_definition.save\n redirect_to @site\n else\n render 'new'\n end\n end", "def create\n @customization = Customization.new(customization_params)\n\n respond_to do |format|\n if @customization.save\n format.html { redirect_to @customization, notice: 'Customization was successfully created.' }\n format.json { render :show, status: :created, location: @customization }\n else\n format.html { render :new }\n format.json { render json: @customization.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_concept(concept_uri)\n\n @log.info(\"Generate concept #{concept_uri}\")\n\n concept_info = RDF::Query.execute(@graph) do\n pattern [concept_uri, :predicate, :object]\n end\n\n preflabels = []\n altlabels = []\n definition = \"\"\n has_broader = nil\n has_narrower = nil\n editorialNote = nil\n\n concept_info.each do |solution|\n\n case solution.predicate\n when \"http://www.w3.org/2004/02/skos/core#prefLabel\"\n if solution.object.language?\n preflabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n preflabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#altLabel\"\n if solution.object.language?\n altlabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n altlabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#definition\"\n definition = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#editorialNote\"\n editorialNote = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#broader\"\n has_broader = solution.object.value\n when \"http://www.w3.org/2004/02/skos/core#narrower\"\n has_narrower = solution.object.value\n end\n\n end\n\n\n @builder.div(:id => concept_uri.fragment, :class => \"concept\") { |html|\n # preflabel in defaultlang\n html.h2(preflabels.detect {|label| label[\"lang\"] == @default_lang}[\"val\"])\n html.dl {\n html.dt(\"Definition\", :class => \"definition\")\n html.dd(definition, :class => \"definition\")\n\n if altlabels.size > 0\n html.dt(\"Alternative labels\", {:class => \"altlabels\"})\n\n altlabels.each do |label|\n\n if label[\"lang\"]\n\n if label[\"lang\"] != @default_lang\n html.dd(label[\"val\"] + \"(#{label['lang']})\", :lang => label[\"lang\"], :class => \"altlabel\")\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n end\n end\n\n\n if has_broader\n\n has_broader_uri = has_broader\n\n unless has_broader.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_broader[1..-1]\n has_broader_uri = r.to_s\n end\n\n html.dt(\"Has broader\", :class => \"broader\")\n html.dd(:class => \"broader\") {\n html.a(concept_preflabel(has_broader_uri), :href => has_broader)\n }\n end\n\n\n if has_narrower\n\n has_narrower_uri = has_narrower\n\n unless has_narrower.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_narrower[1..-1]\n has_narrower_uri = r.to_s\n end\n html.dt(\"Has narrower\", :class => \"narrower\")\n html.dd(:class => \"narrower\") {\n html.a(concept_preflabel(has_narrower_uri), :href => has_narrower)\n }\n end\n\n if editorialNote\n html.dt(label_for(RDF::SKOS.editorialNote, @default_lang))\n html.dd(editorialNote, :class => \"editorial_note\")\n end\n\n html.dt(\"Identifier\", :class => \"identifier\")\n html.dd(concept_uri, :class => \"identifier\")\n }\n }\n\n end", "def create\n @text = (params[:text] || \"\").strip\n @offset = (params[:offset] || \"-1\").to_i\n @concept = params[:concept] || \"\"\n @type = params[:type] || \"\"\n\n @ret = @document.add_annotation(@text, @offset, @type, @concept)\n @entity_types = EntityType.where(collection_id: @document.collection_id)\n\n respond_to do |format|\n format.html { redirect_to @annotation, notice: 'The annotation was successfully created.' }\n format.json { render :show, status: :ok, location: @annotation }\n end\n end", "def create\n @terms_and_condition = TermsAndCondition.new(terms_and_conditions_params)\n\n respond_to do |format|\n if @terms_and_condition.save\n format.html { redirect_to admin_terms_and_conditions_path, notice: 'terms_and_condition was succesfully created.' }\n format.json { render :show, status: :created, location: @terms_and_condition }\n else\n format.html { render :new }\n format.json { render json: @terms_and_condition.errors, status: :unprocesable_entity }\n end\n end\n end", "def create\n @ontology = Ontology.new(ontology_params)\n\n respond_to do |format|\n if @ontology.save\n format.html { redirect_to @ontology, notice: 'Ontology was successfully created.' }\n format.json { render :show, status: :created, location: @ontology }\n else\n format.html { render :new }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_needs_type = SpecialNeedsType.new(params[:special_needs_type])\n\n respond_to do |format|\n if @special_needs_type.save\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial criada com sucesso.' }\n format.json { render :json => @special_needs_type, :status => :created, :location => @special_needs_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @specialty = Specialty.new(specialty_params)\n\n if @specialty.save\n render json: @specialty, status: :created, location: @specialty\n else\n render json: @specialty.errors, status: :unprocessable_entity\n end\n end", "def post\n \"\n desc 'create #{resource.singularize}' do\n tags %w[#{resource.singularize}]\n end\n params do\n # TODO: specify the parameters\n end\n post do\n # your code goes here\n end\"\n end", "def index\n #@concepts = Concept.all#order('updated_at DESC')\n\n #Displaying institute specific concepts\n @concepts = case current_user.role.name when 'Edutor Admin'\n Concept.all\n when 'Institute Admin'\n Concept.where(:institution_id=>current_user.institution_id)\n when 'Teacher'\n Concept.where(:user_id => current_user.id)\n else\n Concept.where(:user_id => current_user.id)\n end\n\n #TO Differentiate new and old concept maps\n @new_concepts = ConceptElement.where(\"x IS NOT NULL\").where(:parent_id => nil)\n @new_ids = Array.new\n @new_concepts.each do |e|\n @new_ids << e.concept_id\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concepts }\n end\n end", "def create_ontology(ont_info)\n uri = URI.parse(TARGET_API)\n http = Net::HTTP.new(uri.host, uri.port)\n\n req = Net::HTTP::Put.new(\"/ontologies/#{ont_info['acronym']}\")\n req['Content-Type'] = 'application/json'\n req['Authorization'] = \"apikey token=#{TARGET_APIKEY}\"\n\n if ont_info['viewingRestriction'] == 'private'\n # In case of private ontology (acl: list of user that have the right to see the ontology)\n req.body = { 'acronym': ont_info['acronym'], 'name': ont_info['name'],\n 'group': ont_info['group'], 'hasDomain': ont_info['hasDomain'],\n 'administeredBy': [TARGETED_PORTAL_USER],\n 'viewingRestriction': 'private',\n 'acl': [TARGETED_PORTAL_USER] }.to_json\n else\n req.body = { 'acronym': ont_info['acronym'], 'name': ont_info['name'],\n 'group': ont_info['group'], 'hasDomain': ont_info['hasDomain'],\n 'administeredBy': [TARGETED_PORTAL_USER] }.to_json\n end\n\n response = http.start do |http|\n http.request(req)\n end\n\n return response\nend", "def add_generic\n\t\temp = getMyEnterpriseAPP\n\t\tdim = params[:dimension]\n\t\t# ES: La dimension puede venir en español o en ingles, verifica y ajusta (En la BD SIEMPRE EN ESPAÑOL!)\n\t\t# EN: The dimension could be in spanish or english, verify and adjust it (In the DB ALWAYS IN SPANISH!)\n\t\tif !I18n.default_locale.to_s.eql?(\"es\")\n\t\t\t# ES: Viene en ingles, debe pasarla a español:\n\t\t\t# EN: English, must translate it:\n\t\t\tdim = view_context.translateDimensionToES(dim)\n\t\tend\n\t\t\n\t\tdesc = params[:description]\n\t\t# ES: Crea una decision generica:\n\t\t# EN: Creates a generic decision:\n\t\tdecGen = GovernanceDecision.new\n\t\tdecGen.description = desc\n\t\tdecGen.dimension = dim\n\t\tdecGen.decision_type = GENERIC_TYPE\n\t\tdecGen.enterprise_id = emp.id\n\n\t\trespond_to do |format|\n\t\t\tif decGen.save\n\t\t\t\t# OK\n\t\t\t\tformat.json {render json: decGen}\n\t\t\telse\n\t\t\t\t# ES: No se pudo guardar\n\t\t\t\t# EN: Couldn't save\n\t\t\t\tformat.json {render json: 'ERROR'}\n\t\t\tend\n\t\t\t\n end\t\n\tend", "def create\n @what_custom = WhatCustom.new(params[:what_custom])\n\n respond_to do |format|\n if @what_custom.save\n format.html { redirect_to(@what_custom, :notice => 'WhatCustom was successfully created.') }\n format.xml { render :xml => @what_custom, :status => :created, :location => @what_custom }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @what_custom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def concept_view_data(concept)\n res = {}\n\n render_concept_association(res, concept, Collection::Member::Base)\n\n Iqvoc::Concept.labeling_classes.each do |labeling_class, languages|\n render_concept_association(res, concept, labeling_class, available_languages: languages || Iqvoc.available_languages)\n end\n\n Iqvoc::Concept.relation_classes.each do |relation_class|\n render_concept_association(res, concept, relation_class)\n end\n\n render_match_association(res, concept, Iqvoc::Concept.match_classes)\n\n Iqvoc::Concept.note_classes.each do |note_class|\n render_concept_association(res, concept, note_class)\n end\n\n Iqvoc::Concept.notation_classes.each do |notation_class|\n render_concept_association(res, concept, notation_class)\n end\n\n Iqvoc::Concept.additional_association_classes.keys.each do |assoc_class|\n render_concept_association(res, concept, assoc_class)\n end\n\n res\n end", "def create\n @scenario = current_user.scenarios.build(scenario_params)\n respond_to do |format|\n if @scenario.save\n format.json { render :json => 1, :status => 200 }\n else\n format.json { render :json => 2, :status => 200 }\n end\n end\n end", "def create\n @co_independent_trait = CoIndependentTrait.new(co_independent_trait_params)\n\n respond_to do |format|\n if @co_independent_trait.save\n format.html { redirect_to @co_independent_trait, notice: 'Co independent trait was successfully created.' }\n format.json { render :show, status: :created, location: @co_independent_trait }\n else\n format.html { render :new }\n format.json { render json: @co_independent_trait.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_ontologies_and_submissions(options = {})\n LinkedData::SampleData::Ontology.create_ontologies_and_submissions(options)\n end", "def create\n @common_term = CommonTerm.new(common_term_params)\n\n respond_to do |format|\n if @common_term.save\n format.html { redirect_to @common_term, notice: 'Common term was successfully created.' }\n format.json { render :show, status: :created, location: @common_term }\n else\n format.html { render :new }\n format.json { render json: @common_term.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @custom_search_engine = CustomSearchEngine.new(params[:custom_search_engine])\n @custom_search_engine.author = current_user\n @custom_search_engine.status = 'draft'\n @custom_search_engine.annotations.each do |a|\n prefix = a.about.slice(/http(s)?:\\/\\//)\n a.about = prefix.nil? ? \"http://#{a.about}\" : \"#{a.about}\"\n end\n respond_to do |format|\n if @custom_search_engine.save\n add_cse_to_dashboard(@custom_search_engine)\n link_cse(@custom_search_engine)\n flash[:success] = I18n.t('human.success.create', \n item: I18n.t('human.text.cse'))\n format.html { redirect_to node_cse_path(@node, @custom_search_engine)}\n format.json { render json: @custom_search_engine, status: :created, \n location: @custom_search_engine }\n else\n format.html { render action: \"new\" }\n format.json { render json: @custom_search_engine.errors, \n status: :unprocessable_entity }\n end\n end\n end", "def create\n @terms_of_use = TermsOfUse.new(params[:terms_of_use])\n\n respond_to do |format|\n if @terms_of_use.save\n format.html { redirect_to @terms_of_use, notice: 'Terms of use was successfully created.' }\n format.json { render json: @terms_of_use, status: :created, location: @terms_of_use }\n else\n format.html { render action: \"new\" }\n format.json { render json: @terms_of_use.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup\n #build our isaac_root object from our yaml fixture\n json = YAML.load_file(FILES[Fixtures::CONCEPT_CHRONOLOGY])\n @rest_concept_chronology = Concept.new(uuid: TEST_UUID, params: nil, body_params: nil, action: ACTION_CHRONOLOGY, action_constants: ACTION_CONSTANTS).get_rest_class(json).send(:from_json, json)\n end", "def conceptopersonal_params\n params.require(:conceptopersonal).permit(:nombre, :tipo_de_concepto)\n end", "def setup_concept_stages_from submission, concepts\n concepts.each do |concept|\n if !concept.concept_option.nil? and concept.concept_option.can_enter?\n concept_stage = submission.concept_stages.new\n concept_stage.topicconcept_id = concept.id\n concept_stage.save\n setup_concept_edge_stage_from submission, concept_stage, concept.concept_edge_dependent_concepts\n end\n end\n end", "def create_taxonomy(rid, add_params = nil)\n params = {\n uid: uid,\n rid: rid,\n }\n api_call('/stores/:uid/taxonomies/:rid(.:format)',:post,params,add_params)\n end", "def create\n authorize :question_resquest_criminal, :create?\n @question_resquest_criminal = QuestionResquestCriminal.new(question_resquest_criminal_params)\n\n respond_to do |format|\n if @question_resquest_criminal.save\n format.html { redirect_to @question_resquest_criminal, notice: 'Question resquest criminal was successfully created.' }\n format.json { render :show, status: :created, location: @question_resquest_criminal }\n else\n format.html { render :new }\n format.json { render json: @question_resquest_criminal.errors, status: :unprocessable_entity }\n end\n end\n end", "def scenarios_params\n params.require(:scenario).permit(:title, :content)\n end", "def create\n @observation_type = ObservationType.new(params[:observation_type])\n\n respond_to do |format|\n if @observation_type.save\n format.html { redirect_to @observation_type, notice: 'Observation type was successfully created.' }\n format.json { render json: @observation_type, status: :created, location: @observation_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @observation_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trait_type = TraitType.new(trait_type_params)\n\n if @trait_type.save\n render json: @trait_type, status: :created, location: @trait_type\n else\n render json: @trait_type.errors, status: :unprocessable_entity\n end\n end", "def create\n @incident_kind = IncidentKind.new(params[:incident_kind])\n\n respond_to do |format|\n if @incident_kind.save\n format.html { redirect_to @incident_kind, notice: 'Incident kind was successfully created.' }\n format.json { render json: @incident_kind, status: :created, location: @incident_kind }\n else\n format.html { render action: \"new\" }\n format.json { render json: @incident_kind.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_rest_api(endpoint, data, http)\n rest_api_endpoint = \"/classifier-api/v1/#{endpoint}\"\n\n # Create an HTTP POST request against the specified REST API endpoint\n request = Net::HTTP::Post.new(rest_api_endpoint)\n # Set the Content-Type and data of the HTTP POST request\n request.content_type = \"application/json\"\n request.body = data\n # Submit the request\n response = http.request(request)\n # Return the response bosy (JSON containing the result of the POST operation)\n response.body\nend", "def create\n @custom_document = @trip.custom_documents.build(custom_document_params)\n\n if @custom_document.save\n redirect_to admin_trip_custom_documents_path(@trip), notice: 'Custom document was successfully created.'\n else\n render :new\n end\n end", "def create\n @concept_map = ConceptMap.new(params[:concept_map])\n respond_to do |format|\n if@concept_map.save\n #if@concept_map.rb.status == 1\n Content.send_message_to_est(false,current_user,@concept_map)\n #end\n format.html { redirect_to@concept_map, notice: 'ConceptMap was successfully created.' }\n format.json { render json:@concept_map, status: :created, location:@concept_map }\n else\n format.html { render action: \"new\" }\n format.json { render json:@concept_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @term = Term.new(term_params)\n\n if @term.save\n render :show, status: :created, location: api_v1_term_url(@term)\n else\n render json: @term.errors, status: :unprocessable_entity\n end\n end", "def custom_definition_params\n params.require(:custom_definition).permit(:name, :report_type_id)\n end", "def create\n @given_circumstance = GivenCircumstance.new(given_circumstance_params)\n\n if @given_circumstance.save\n render json: @given_circumstance, status: :created, location: @given_circumstance\n else\n render json: @given_circumstance.errors, status: :unprocessable_entity\n end\n end", "def term_relationship_params\n params.require(:term_relationship).permit(:term_taxonomy_id, :term_order)\n end", "def create\n @restriction = Restriction.new(params[:restriction])\n\n if @restriction.save\n render json: @restriction, status: :created, location: @restriction\n else\n render json: @restriction.errors, status: :unprocessable_entity\n end\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create_sample_controlled_vocab_terms_attributes(array)\n attributes = []\n array.each do |type|\n attributes << { label: type }\n end\n attributes\nend", "def create\n# authorize! :create, Observation\n @observation = Observation.new(observation_params)\n @classroom = @observation.classroom\n @principals = User.with_role(:principal)\n @specialists = User.with_role(:specialist)\n if current_user.has_role? :admin\n if !params[:observation][:specialist].nil?\n @observation.specialist = params[:observation][:specialist]\n elsif !params[:observation][:principal].nil?\n @observation.principal = params[:observation][:principal]\n end\n \n elsif current_user.has_role? :principal\n @observation.principal_id = current_user.id\n else\n @observation.specialist_id = current_user.id\n end\n \n respond_to do |format|\n if @observation.save\n format.html { redirect_to observation_observation_form_index_url(@observation), notice: 'Observation was started.' }\n format.json { render :show, status: :created, location: @observation }\n else\n format.html { render :new }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @owner = current_user\n @concept = Concept.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @concept }\n end\n end", "def add_relation\n #add relation\n @word.word_roots.create(@word_root)\n respond_to do |format|\n format.js\n end\n end", "def create_custom_gradebook_category(course_id, custom_category)\r\n post(Path::COURSES_GRADEBOOK_CUSTOMCATEGORIES % [course_id], custom_category)\r\n end", "def create\n\t\tunless @custom_word = @user.custom_words.find_by_word(params[:id])\n\t\t\t@custom_word = @user.custom_words.create(word: params[:id], correct: false)\n\t\tend\n\t\t@custom_word.corrections.create( {replacement: params[:replacement]} )\n\t\t\n\t\trespond_with @custom_user\n\tend", "def update\n respond_to do |format|\n if @concept.update(concept_params)\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @concept }\n else\n format.html { render :edit }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @projects_and_concept = ProjectsAndConcept.new(projects_and_concept_params)\n\n respond_to do |format|\n if @projects_and_concept.save\n format.html { redirect_to @projects_and_concept, notice: 'Projects and concept was successfully created.' }\n format.json { render :show, status: :created, location: @projects_and_concept }\n else\n format.html { render :new }\n format.json { render json: @projects_and_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_label(name, description, types, color) \n data = {\n 'name' => name,\n 'description' => description,\n 'types' => types,\n 'color' => color\n }\n\n result = @access_token.post(\n \"#{SITE}/api/v2/labels\", \n data.to_json, \n {'Accept'=>'application/json', 'Content-Type' => 'application/json'}\n )\n\n JSON.parse(result.body)\n end", "def create\n @go_term = GoTerm.new(params[:go_term])\n\n respond_to do |format|\n if @go_term.save\n format.html { redirect_to @go_term, notice: 'Go term was successfully created.' }\n format.json { render json: @go_term, status: :created, location: @go_term }\n else\n format.html { render action: \"new\" }\n format.json { render json: @go_term.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n check_tutorial_params(property_and_casualty_params[:name]) and return\n \n @insurance_card = PropertyAndCasualty.new(property_and_casualty_params.merge(user_id: resource_owner.id, category: Category.fetch(Rails.application.config.x.InsuranceCategory.downcase)))\n authorize @insurance_card\n PolicyService.fill_property_and_casualty_policies(policy_params, @insurance_card)\n respond_to do |format|\n if validate_params && @insurance_card.save\n PolicyService.update_shares(@insurance_card.id, @insurance_card.share_with_ids, nil, resource_owner)\n PolicyService.update_properties(@insurance_card, property_params)\n @path = success_path(property_path(@insurance_card), property_and_casualty_shared_view_path(shared_user_id: resource_owner.id, id: @insurance_card.id))\n \n # If comes from Tutorials workflow, redirect to next step\n if params[:tutorial_name]\n tutorial_redirection(format, @insurance_card.as_json)\n else\n format.html { redirect_to @path, flash: { success: 'Insurance successfully created.' } }\n format.json { render :show, status: :created, location: @insurance_card }\n end\n else\n # If comes from Tutorials workflow, redirect to same Tutorial step\n tutorial_error_handle(\"Fill in Insurance Provider Name field to continue\") && return\n error_path(:new)\n format.html { render controller: @path[:controller], action: @path[:action], layout: @path[:layout] }\n format.json { render json: @insurance_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @taxon_name_relationship = TaxonNameRelationship.new(taxon_name_relationship_params)\n\n respond_to do |format|\n if @taxon_name_relationship.save\n format.html { redirect_to @taxon_name_relationship.metamorphosize, notice: 'Taxon name relationship was successfully created.' }\n format.json { render action: 'show', status: :created, location: @taxon_name_relationship.metamorphosize }\n else\n format.html { render action: 'new' }\n format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6761858", "0.66796887", "0.64662015", "0.6328216", "0.61436796", "0.59552485", "0.5952309", "0.59016407", "0.5662458", "0.56600857", "0.5626573", "0.5467005", "0.54021335", "0.5401365", "0.5382899", "0.5310986", "0.52510834", "0.52383316", "0.5234013", "0.52316713", "0.5226467", "0.51937425", "0.51770735", "0.51389635", "0.5128806", "0.5118377", "0.50980645", "0.5093381", "0.50896925", "0.5078768", "0.5072402", "0.5055542", "0.5042289", "0.5041342", "0.50407577", "0.50384957", "0.5023097", "0.5023097", "0.5022868", "0.50135595", "0.50135595", "0.50017786", "0.49826747", "0.4972699", "0.49696636", "0.49560642", "0.49450552", "0.49436587", "0.49431676", "0.49385127", "0.49354798", "0.49307498", "0.49306414", "0.4926313", "0.488535", "0.48719275", "0.48576054", "0.4852399", "0.48397478", "0.48356006", "0.48307616", "0.48200104", "0.47980726", "0.47975716", "0.47935733", "0.47934222", "0.47933027", "0.47916478", "0.47852123", "0.47772807", "0.47621995", "0.47581863", "0.47515517", "0.4749587", "0.4736527", "0.4735342", "0.47330734", "0.472484", "0.47239885", "0.47132564", "0.47025877", "0.47022006", "0.4700013", "0.4697355", "0.46857122", "0.46827286", "0.46797973", "0.4679792", "0.46730378", "0.46683583", "0.46623746", "0.46594653", "0.46553862", "0.46533912", "0.4644625", "0.4644181", "0.46434146", "0.46422023", "0.46301684", "0.46298704" ]
0.733524
0
PATCH/PUT /customized_concepts/1 PATCH/PUT /customized_concepts/1.json
def update respond_to do |format| if @customized_concept.update(customized_concept_params) format.html { redirect_to @customized_concept, notice: 'Customized concept was successfully updated.' } format.json { render :show, status: :ok, location: @customized_concept } else format.html { render :edit } format.json { render json: @customized_concept.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_customized_concept\n @customized_concept = CustomizedConcept.find(params[:id])\n end", "def update\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n if @orderable_concept.update_attributes(params[:orderable_concept])\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @concept.update(concept_params)\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @concept }\n else\n format.html { render :edit }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @concept = Concept.find(params[:id])\n\n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n format.html { redirect_to @concept, notice: 'Concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @canonical_gconcepts = args[:canonical_gconcepts] if args.key?(:canonical_gconcepts)\n end", "def update\n respond_to do |format|\n if @special_requirement.update(special_requirement_params)\n format.html { redirect_to @special_requirement, notice: 'Special requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_requirement }\n else\n format.html { render :edit }\n format.json { render json: @special_requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course = Course.find(params[:course_id])\n @customized_concept = @course.customized_concepts.new(customized_concept_params)\n\n respond_to do |format|\n if @customized_concept.save\n format.html { redirect_to @course, notice: 'Customized concept was successfully created.' }\n format.json { render :show, status: :created, location: @customized_concept }\n else\n format.html { render :new }\n format.json { render json: @customized_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @concept = Concept.find(params[:id])\n \n respond_to do |format|\n if @concept.update_attributes(params[:concept])\n flash[:notice] = 'Concept was successfully updated.'\n format.html { redirect_to(@concept) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @concept.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Concepto\n if params[:concepto][:tipo_ids]\n params[:concepto][:tipo_ids] = params[:concepto][:tipo_ids].map { |k, _v| k }\n else\n params[:concepto][:tipo_ids] = []\n end\n\n respond_to do |format|\n if @concepto.update(concepto_params)\n\n\n format.html { redirect_to @concepto, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @concepto }\n else\n format.html { render :edit } if params[:concepto][:tipo_ids]\n format.json { render json: @concepto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @conceptual_entity = ConceptualEntity.find(params[:id])\n\n respond_to do |format|\n if @conceptual_entity.update_attributes(params[:conceptual_entity])\n format.html { redirect_to @conceptual_entity, notice: 'Conceptual entity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conceptual_entity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @concept = params[:concept] || \"\"\n @type = params[:type] || \"\"\n @concept.strip!\n @type.strip!\n if params[:mode] == \"true\" || params[:mode] == \"1\"\n logger.debug(\"update_concept\")\n @document.update_concept(params[:id], @type, @concept)\n else\n logger.debug(\"update_mention\")\n @document.update_mention(params[:id], @type, @concept)\n end\n @entity_types = EntityType.where(collection_id: @document.collection_id)\n respond_to do |format|\n if true\n format.html { redirect_to @annotation, notice: 'The annotation was successfully updated.' }\n format.json { render :show, status: :ok, location: @annotation }\n else\n format.html { render :edit }\n format.json { render json: @annotation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @gconcept = args[:gconcept] if args.key?(:gconcept)\n @is_required = args[:is_required] if args.key?(:is_required)\n end", "def customized_concept_params\n params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture)\n end", "def index\n @customized_concepts = CustomizedConcept.all\n end", "def update\n respond_to do |format|\n if @custom_definition.update(custom_definition_params)\n format.html { redirect_to @custom_definition, notice: 'Custom definition was successfully updated.' }\n format.json { render :show, status: :ok, location: @custom_definition }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @custom_definition.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @feature_type = args[:feature_type] if args.key?(:feature_type)\n @gconcepts = args[:gconcepts] if args.key?(:gconcepts)\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def set_concept\n @concept = Concept.find(params[:id])\n end", "def update\n respond_to do |format|\n if @assessment_info.update(assessment_info_params)\n format.html { redirect_to edit_concept_url(@assessment_info.concept_id), notice: 'assessment_info was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment_info }\n else\n format.html { render :edit }\n format.json { render json: @assessment_info.errors, status: :unprocessable_entity }\n end\n end\nend", "def destroy\n @customized_concept.destroy\n respond_to do |format|\n format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @co_independent_trait.update(co_independent_trait_params)\n format.html { redirect_to @co_independent_trait, notice: 'Co independent trait was successfully updated.' }\n format.json { render :show, status: :ok, location: @co_independent_trait }\n else\n format.html { render :edit }\n format.json { render json: @co_independent_trait.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @what_custom = WhatCustom.find(params[:id], :include => :what_custom_factors)\n\n respond_to do |format|\n if @what_custom.update_attributes(params[:what_custom])\n format.html { redirect_to(@what_custom, :notice => 'WhatCustom was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @what_custom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @concept_id = args[:concept_id] if args.key?(:concept_id)\n @freebase_mid = args[:freebase_mid] if args.key?(:freebase_mid)\n end", "def update\n respond_to do |format|\n if @ontology.update(ontology_params)\n format.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n format.json { render :show, status: :ok, location: @ontology }\n else\n format.html { render :edit }\n format.json { render json: @ontology.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n render_json_auto @survey.update_logic_control_rule(params[:id].to_i, params[:logic]) and return\n end", "def update\n @concept_group = ConceptGroup.find(params[:id])\n\n respond_to do |format|\n if @concept_group.update_attributes(params[:concept_group])\n format.html { redirect_to @concept_group, notice: 'Concept group was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @concept_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def put(path_part, payload, additional_headers = {}, &block)\n api_request { @rest.put('/REST/' + path_part, payload.to_json, additional_headers, &block) }\n end", "def patch_kubernetes_version_with_http_info(moid, kubernetes_version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_version ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_version\"\n end\n # verify the required parameter 'kubernetes_version' is set\n if @api_client.config.client_side_validation && kubernetes_version.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_version' when calling KubernetesApi.patch_kubernetes_version\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/Versions/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_version)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesVersion'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_version\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_version\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n if @question.status == 'published' || @question.version_independent_id != question_params[:version_independent_id]\n render json: @question.errors, status: :unprocessable_entity\n else\n update_response_sets(params)\n @question.update_concepts('Question')\n @question.updated_by = current_user\n if @question.update(question_params)\n @question.groups.each do |group|\n @question.add_to_group(group.id)\n end\n render :show, status: :ok, location: @question\n else\n @categories = Category.all\n render json: @question.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 @resources_custom.update(resources_custom_params)\n format.html { redirect_to @resources_custom, notice: 'Resources custom was successfully updated.' }\n format.json { render :show, status: :ok, location: @resources_custom }\n else\n format.html { render :edit }\n format.json { render json: @resources_custom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end", "def update\n @event_requirement = EventRequirement.find(params[:id])\n\n if @event_requirement.update(event_requirement_params)\n head :no_content\n else\n render json: @event_requirement.errors, status: :unprocessable_entity\n end\n end", "def update\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n if @special_needs_type.update_attributes(params[:special_needs_type])\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @ontology.update(ontology_params)\n\t\t\t\tformat.html { redirect_to @ontology, notice: 'Ontology was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.json { render json: @ontology.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n authorize! :update, Conceptopersonal\n respond_to do |format|\n if @conceptopersonal.update(conceptopersonal_params)\n\n\n format.html { redirect_to conceptospersonales_path, notice: '<i class=\"fa fa-check-square fa-lg\"></i> Los datos del concepto fueron actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @conceptopersonal }\n else\n format.html { render :edit }\n format.json { render json: @conceptopersonal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update\n @concept_map = ConceptMap.find(params[:id])\n if current_user.role.id == 7\n params[:concept_map][:status] = 6\n end\n respond_to do |format|\n if @concept_map.update_attributes(params[:concept_map])\n format.html { redirect_to@concept_map, notice: 'ConceptMap was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@concept_map.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_concept\n @concept = Concept.find_or_create_by(id: params[:id] || params[:concept_id])\n end", "def update( concept_s,\n concept_o, \n property_name, \n property_type = DEFAULT_PROPERTY_TYPE)\n concept_s = Converter.rsc_2_str(concept_s)\n concept_o = Converter.rsc_2_str(concept_o)\n property_name = Converter.rsc_2_str(property_name)\n @concepts_list.push(concept_o)\n update_properties_list( concept_s,\n property_name,\n concept_o,\n property_type)\n if ! @visited_concepts.include?(concept_o)\n @visited_concepts.push(concept_o)\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 api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def concept_params\n params.require(:concept).permit(:name, :definition, :subject_id)\n end", "def update\n @specialty = Specialty.find(params[:id])\n\n if @specialty.update(specialty_params)\n head :no_content\n else\n render json: @specialty.errors, status: :unprocessable_entity\n end\n end", "def partial_update_object(object, objectID = nil, create_if_not_exits = true, request_options = {})\n client.post(Protocol.partial_object_uri(name, get_objectID(object, objectID), create_if_not_exits), object.to_json, :write, request_options)\n end", "def update!(**args)\n @gconcept_id = args[:gconcept_id] if args.key?(:gconcept_id)\n @metadata = args[:metadata] if args.key?(:metadata)\n @prominence = args[:prominence] if args.key?(:prominence)\n end", "def update\n @trait_type = TraitType.find(params[:id])\n\n if @trait_type.update(trait_type_params)\n head :no_content\n else\n render json: @trait_type.errors, status: :unprocessable_entity\n end\n end", "def patch_kubernetes_addon_definition_with_http_info(moid, kubernetes_addon_definition, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.patch_kubernetes_addon_definition ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling KubernetesApi.patch_kubernetes_addon_definition\"\n end\n # verify the required parameter 'kubernetes_addon_definition' is set\n if @api_client.config.client_side_validation && kubernetes_addon_definition.nil?\n fail ArgumentError, \"Missing the required parameter 'kubernetes_addon_definition' when calling KubernetesApi.patch_kubernetes_addon_definition\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/AddonDefinitions/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/json-patch+json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(kubernetes_addon_definition)\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesAddonDefinition'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.patch_kubernetes_addon_definition\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#patch_kubernetes_addon_definition\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @requirement.update(requirement_params)\n format.html { redirect_to @requirement, notice: 'Requirement was successfully updated.' }\n format.json { render :show, status: :ok, location: @requirement }\n else\n format.html { render :edit }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @special_occasion.update(special_occasion_params)\n format.html { redirect_to @special_occasion, notice: 'Special occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_occasion }\n else\n format.html { render :edit }\n format.json { render json: @special_occasion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # workflow_attributes = workflow_params\n # step_definitions_attributes = workflow_attributes.delete(\"step_definitions\")\n\n # StepDefinition.updateStepDefinitions(step_definitions_attributes)\n\n respond_to do |format|\n if @workflow.update(workflow_params)\n format.html { redirect_to @workflow, notice: 'Workflow was successfully updated.' }\n format.json { render :show, status: :ok, location: @workflow }\n else\n format.html { render :edit }\n format.json { render json: @workflow.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n feature.update_attributes(feature_params)\n\n respond_with(feature)\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def put!\n request! :put\n end", "def update\n @employee_remunerative_concept = @employee.employee_emunerative_concept.find(params[:id])\n\n respond_to do |format|\n if @employee_remunerative_concept.update_attributes(params[:employee_remunerative_concept])\n format.html { redirect_to([@employee,@employee_remunerative_concept], :notice => 'Employee remunerative concept was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @employee_remunerative_concept.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @projects_and_concept.update(projects_and_concept_params)\n format.html { redirect_to @projects_and_concept, notice: 'Projects and concept was successfully updated.' }\n format.json { render :show, status: :ok, location: @projects_and_concept }\n else\n format.html { render :edit }\n format.json { render json: @projects_and_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit(id, options = {})\n optional = [:label,\n :description,\n :compatible_with,\n :script_type\n ]\n params.accepts(optional).validate! options\n request(:put, \"/recipes/#{id}.json\", default_params(options))\n end", "def update\n respond_to do |format|\n if @requirement.update_attributes(requirement_params)\n format.html { redirect_to action: :index, notice: 'Update Success.' }\n format.json { render action: :index, status: :accepted }\n else\n format.html { render action: :edit }\n format.json { render json: @requirement.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 @hypothetical.update(hypothetical_params)\n format.html { redirect_to @hypothetical, notice: 'Hypothetical was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hypothetical.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @requirement.update(requirement_params)\n format.html { redirect_to requirements_path, notice: \"Requisito (#{@requirement.name}) atualizado com sucesso!\" }\n format.json { render :show, status: :ok, location: @requirement }\n else\n format.html { render :edit }\n format.json { render json: @requirement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n update_annotations(params[:tag_list], @model)\n update_sharing_policies @model\n update_relationships(@model, params)\n respond_to do |format|\n if @model.update(model_params)\n flash[:notice] = \"#{t('model')} metadata was successfully updated.\"\n format.html { redirect_to model_path(@model) }\n format.json {render json: @model, include: [params[:include]]}\n else\n format.html { render action: 'edit' }\n format.json { render json: json_api_errors(@model), status: :unprocessable_entity }\n end\n end\n end", "def update\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n if @familiar.update_attributes(params[:familiar])\n format.html { redirect_to @familiar, notice: 'Familiar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familiar.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @customizing.update(customizing_params)\n format.html { redirect_to @customizing, notice: 'Customizing was successfully updated.' }\n format.json { render :show, status: :ok, location: @customizing }\n else\n format.html { render :edit }\n format.json { render json: @customizing.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_concern.update(api_v1_concern_params)\n format.html { redirect_to @api_v1_concern, notice: 'Concern was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_concern }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_concern.errors, status: :unprocessable_entity }\n end\n end\n end", "def 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 @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n if @incident_kind.update_attributes(params[:incident_kind])\n format.html { redirect_to @incident_kind, notice: 'Incident kind was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident_kind.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 authorize @specialization\n\n respond_to do |format|\n if @specialization.update(specialization_update_params)\n format.html { redirect_to @specialization, notice: I18n.t(\"activerecord.notice.specialization.success_update\") }\n format.json { render :show, status: :ok, location: @specialization }\n else\n format.html { render :edit }\n format.json { render json: @specialization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_subscription.update(event_subscription_params)\n @event_subscription.save\n\n file_params.each do |requirement|\n if(requirement[\"doc\"])\n requirement.symbolize_keys\n requirement[:doc].symbolize_keys\n path = \"data:#{requirement[:doc][:filetype]};base64, #{requirement[:doc][:base64]}\"\n Document.update(id: requirement[:doc][:id],\n user_id: @event_subscription.user_id,\n requirement_id: requirement[:id],\n state: \"pending_review\",\n path: path\n )\n end\n end\n render json: @event_subscription, status: :updated\n end", "def edit\n @therapist_consent = TherapistConsent.find(params[:id])\n respond_to do |format|\n format.html { render action: 'edit' }\n format.json { render :status => 200, :json => { action: 'edit', therapist_consent: @therapist_consent}}\n end\n end", "def update\n @terms_of_use = TermsOfUse.find(params[:id])\n\n respond_to do |format|\n if @terms_of_use.update_attributes(params[:terms_of_use])\n format.html { redirect_to @terms_of_use, notice: 'Terms of use was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @terms_of_use.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end", "def update\n respond_to do |format|\n if @special_collection_request.update(special_collection_request_params)\n format.html { redirect_to @special_collection_request, notice: 'Special collection request was successfully updated.' }\n format.json { render :show, status: :ok, location: @special_collection_request }\n else\n format.html { render :edit }\n format.json { render json: @special_collection_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @genericcallout.update(genericcallout_params)\n format.html { redirect_to @genericcallout, notice: 'Generic Call-Out was successfully updated.' }\n format.json { render :show, status: :ok, location: @genericcallout }\n else\n format.html { render :edit }\n format.json { render json: @genericcallout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @question_localized = QuestionLocalized.find(params[:id])\n\n respond_to do |format|\n if @question_localized.update_attributes(params[:question_localized])\n flash[:notice] = 'QuestionLocalized was successfully updated.'\n format.html { redirect_to(@question_localized) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_localized.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def update\n respond_to do |format|\n if @taxon_name_relationship.update(taxon_name_relationship_params)\n format.html { redirect_to @taxon_name_relationship.metamorphosize, notice: 'Taxon name relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ontology = SYMPH::Ontology.find(params[:id])\n\n respond_to do |format|\n if @ontology.update_attributes(params[:ontology])\n flash[:notice] = 'Ontology was successfully updated.'\n format.html { redirect_to(ontologies_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ontology.errors, :status => :unprocessable_entity }\n end\n end\n\t\n end", "def update\n @use_case = UseCase.find(params[:id])\n @use_case.data = params[:data].to_json\n\n respond_to do |format|\n if @use_case.update_attributes(params[:use_case])\n\n if params[:subaction]==\"step\"\n format.html { redirect_to requirements_project_use_case_path(@use_case.project, @use_case, :type=>\"step\"), notice: 'Use case was successfully updated.' }\n else\n format.html { redirect_to project_use_case_path(@project, @use_case), notice: 'Use case was successfully updated.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize :question_resquest_criminal, :update?\n respond_to do |format|\n if @question_resquest_criminal.update(question_resquest_criminal_params)\n format.html { redirect_to @question_resquest_criminal, notice: 'Question resquest criminal was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_resquest_criminal }\n else\n format.html { render :edit }\n format.json { render json: @question_resquest_criminal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @go_term_enrichment = GoTermEnrichment.find(params[:id])\n\n respond_to do |format|\n if @go_term_enrichment.update_attributes(params[:go_term_enrichment])\n format.html { redirect_to @go_term_enrichment, notice: 'Go term enrichment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @go_term_enrichment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @objective.strategy, :update_objective?\n respond_to do |format|\n if @objective.update(objective_params)\n format.html { redirect_to @objective}\n format.json { render :show, status: :ok, location: @objective }\n else\n format.html { render :edit }\n format.json { render json: @objective.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @concept_id = args[:concept_id] if args.key?(:concept_id)\n @contact_source = args[:contact_source] if args.key?(:contact_source)\n @is_relationship_from_annotation = args[:is_relationship_from_annotation] if args.key?(:is_relationship_from_annotation)\n @is_relationship_from_source = args[:is_relationship_from_source] if args.key?(:is_relationship_from_source)\n @is_single_candidate = args[:is_single_candidate] if args.key?(:is_single_candidate)\n @is_starred = args[:is_starred] if args.key?(:is_starred)\n @matched_name_type = args[:matched_name_type] if args.key?(:matched_name_type)\n @num_alternate_name_from_fuzzy_contact_match = args[:num_alternate_name_from_fuzzy_contact_match] if args.key?(:num_alternate_name_from_fuzzy_contact_match)\n @num_alternate_names_from_s3 = args[:num_alternate_names_from_s3] if args.key?(:num_alternate_names_from_s3)\n @num_alternative_names_from_interpretation = args[:num_alternative_names_from_interpretation] if args.key?(:num_alternative_names_from_interpretation)\n @num_candidates = args[:num_candidates] if args.key?(:num_candidates)\n @recognition_alternate_source = args[:recognition_alternate_source] if args.key?(:recognition_alternate_source)\n end", "def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end", "def update\n respond_to do |format|\n if @interesting_thing.update(interesting_thing_params)\n format.html { redirect_to student_interesting_things_path(@student), notice: 'Interesting thing was successfully updated.' }\n format.json { render :show, status: :ok, location: @interesting_thing }\n else\n format.html { render :edit }\n format.json { render json: @interesting_thing.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.patch do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update\r\n @theoretical_part = TheoreticalPart.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @theoretical_part.update_attributes(params[:theoretical_part])\r\n format.html { redirect_to @theoretical_part, notice: 'Theoretical part was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @theoretical_part.errors, status: :unprocessable_entity }\r\n end\r\n end\r\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 if @requirement.update(requirement_params)\n render :show, status: :ok, location: @requirement\n else\n render json: @requirement.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.65403557", "0.65271056", "0.6336022", "0.63072926", "0.63072926", "0.60435414", "0.5915217", "0.5841427", "0.5825572", "0.5803414", "0.57943493", "0.5770371", "0.5721804", "0.5683588", "0.55955327", "0.5583532", "0.55675054", "0.5534411", "0.5534411", "0.55102235", "0.5485856", "0.54483354", "0.54430413", "0.5439008", "0.543096", "0.54254866", "0.54058343", "0.5403035", "0.540222", "0.537452", "0.5374279", "0.5373992", "0.5372796", "0.5359119", "0.5352179", "0.5347746", "0.53373736", "0.53285456", "0.5303211", "0.52896607", "0.52858365", "0.5283667", "0.526974", "0.5262678", "0.52565527", "0.5253765", "0.5251367", "0.52450746", "0.5238778", "0.52357256", "0.52312595", "0.5230232", "0.5214702", "0.5207798", "0.52038103", "0.51963556", "0.51905143", "0.5188051", "0.51868784", "0.5181136", "0.51771957", "0.5163906", "0.5163034", "0.51625425", "0.5162038", "0.51601255", "0.5154049", "0.51529855", "0.5152509", "0.5152107", "0.5145143", "0.5145143", "0.5141105", "0.51385105", "0.5133689", "0.51290756", "0.5124745", "0.51218766", "0.5120837", "0.51205224", "0.51177454", "0.5116916", "0.5115831", "0.51119506", "0.5105453", "0.5105453", "0.5104364", "0.5103375", "0.50981706", "0.509261", "0.50905204", "0.5089627", "0.50868535", "0.5078707", "0.5072832", "0.50703347", "0.5070284", "0.5069624", "0.50689095", "0.50651586" ]
0.73499787
0
DELETE /customized_concepts/1 DELETE /customized_concepts/1.json
def destroy @customized_concept.destroy respond_to do |format| format.html { redirect_to customized_concepts_url, notice: 'Customized concept was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @orderable_concept = OrderableConcept.find(params[:id])\n @orderable_concept.destroy\n\n respond_to do |format|\n format.html { redirect_to orderable_concepts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept = Concept.find(params[:id])\n @concept.destroy\n\n respond_to do |format|\n format.html { redirect_to concepts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept = Concept.find(params[:id])\n @concept.destroy\n\n respond_to do |format|\n format.html { redirect_to concepts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept.destroy\n respond_to do |format|\n format.html { redirect_to concepts_url, notice: 'Concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @conceptual_entity = ConceptualEntity.find(params[:id])\n @conceptual_entity.destroy\n\n respond_to do |format|\n format.html { redirect_to conceptual_entities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_requirement.destroy\n respond_to do |format|\n format.html { redirect_to special_requirements_url, notice: 'Special requirement was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, Concepto\n @concepto.destroy\n\n\n respond_to do |format|\n format.html { redirect_to conceptos_url, notice: '<i class=\"fa fa-check-square fa-lg\"></i> El concepto fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ontology.destroy\n respond_to do |format|\n format.html { redirect_to ontologies_url, notice: 'Ontology was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept = Concept.find(params[:id])\n @concept.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @scenario = Scenario.find(params[:id])\n @scenario.destroy\n\n respond_to do |format|\n format.html { redirect_to scenarios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assessment_info.destroy\n respond_to do |format|\n format.html { redirect_to edit_concept_url(@assessment_info.concept_id), notice: 'assessment_info was successfully destroyed.' }\n format.json { head :no_content }\n end\nend", "def destroy\n @controlled_vocabulary.destroy\n respond_to do |format|\n format.html { redirect_to controlled_vocabularies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @concept_group = ConceptGroup.find(params[:id])\n @concept_group.destroy\n\n respond_to do |format|\n format.html { redirect_to concept_groups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_name_relationship.destroy\n respond_to do |format|\n format.html { redirect_to taxon_name_relationships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_determination.destroy\n respond_to do |format|\n format.html { redirect_to taxon_determinations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @co_independent_trait.destroy\n respond_to do |format|\n format.html { redirect_to co_independent_traits_url, notice: 'Co independent trait was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @assumption.destroy\n respond_to do |format|\n format.html { redirect_to assumptions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_logic_control_rule(params[:id].to_i) and return\n end", "def destroy\n @custom.destroy\n respond_to do |format|\n format.html { redirect_to customs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\tFile.delete(@ontology.url)\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to ontologies_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend", "def destroy\n \n @ontology = SYMPH::Ontology.find(params[:id])\n @ontology.disable\n @ontology.destroy\n \n respond_to do |format|\n format.html { redirect_to :action => :index }\n format.xml { 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 @education_service_provided_typology.destroy\n respond_to do |format|\n format.html { redirect_to education_service_provided_typologies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxirequest = Taxirequest.find(params[:id])\n @taxirequest.destroy\n\n respond_to do |format|\n format.html { redirect_to taxirequests_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 @go_term_enrichment = GoTermEnrichment.find(params[:id])\n @go_term_enrichment.destroy\n\n respond_to do |format|\n format.html { redirect_to go_term_enrichments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_rule = TaxonRule.find(params[:id])\n @taxon_rule.destroy\n\n respond_to do |format|\n format.html { redirect_to taxon_rules_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @objective.strategy\n @objective.destroy\n respond_to do |format|\n format.html { redirect_to objectives_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqstatus.destroy\n respond_to do |format|\n format.html { redirect_to reqstatuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recreation_service_typology.destroy\n respond_to do |format|\n format.html { redirect_to recreation_service_typologies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @liquidacion = Liquidacion.find(params[:id])\n\n #Elimino todos los conceptos incluidos en la liquidacion\n @conceptos_liquidacion = ConceptoLiquidacion.where(:liquidacion_id => @liquidacion.id)\n @conceptos_liquidacion.each do |concepto|\n concepto.destroy\n end\n\n @liquidacion.destroy\n respond_to do |format|\n format.html { redirect_to liquidacions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_occasion.destroy\n respond_to do |format|\n format.html { redirect_to special_occasions_url, notice: 'Special occasion was successfully destroyed.' }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @custom_definition.destroy\n redirect_to @site\n end", "def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxonomy_term = TaxonomyTerm.find(params[:id])\n @taxonomy_term.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_taxonomy_terms_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @constraint.destroy\n respond_to do |format|\n format.html { redirect_to constraints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incident_kind = IncidentKind.find(params[:id])\n @incident_kind.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_kinds_url }\n format.json { head :no_content }\n end\n end", "def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end", "def destroy\n @claim.destroy\n respond_to do |format|\n format.html { redirect_to claims_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_outcome.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_outcomes_url, notice: 'Outcome was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @am_run_observation_type = AmRunObservationType.find(params[:id])\n @am_run_observation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to am_run_observation_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @observations.destroy\n respond_to do |format|\n format.html { redirect_to observations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @go_term = GoTerm.find(params[:id])\n @go_term.destroy\n\n respond_to do |format|\n format.html { redirect_to go_terms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @terms_and_condition.destroy\n respond_to do |format|\n format.html { redirect_to admin_terms_and_conditions_url, notice: 'terms_and_conditions was succesfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @routed_generic.destroy\n respond_to do |format|\n format.html { redirect_to routed_generics_url, notice: 'Combination dose was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxinomy = Taxinomy.find(params[:id])\n @taxinomy.destroy\n\n respond_to do |format|\n format.html { redirect_to taxinomies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dis_routed_generic.destroy\n respond_to do |format|\n format.html { redirect_to dis_routed_generics_url, notice: 'Dis routed generic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n UriService.client.delete_term(@term['uri'])\n respond_to do |format|\n format.html { redirect_to terms_controlled_vocabulary_path(@controlled_vocabulary), notice: 'Term has been deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @occasion = Occasion.find(params[:id])\n @occasion.destroy\n\n respond_to do |format|\n format.html { redirect_to occasions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @employee_remunerative_concept = @employee.employee_remunerative_concept.find(params[:id])\n @employee_remunerative_concept.destroy\n\n respond_to do |format|\n format.html { redirect_to(employee_remunerative_concepts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @customfieldcondition.destroy\n respond_to do |format|\n format.html { redirect_to customfieldconditions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @terms_of_use = TermsOfUse.find(params[:id])\n @terms_of_use.destroy\n\n respond_to do |format|\n format.html { redirect_to terms_of_uses_url }\n format.json { head :no_content }\n end\n end", "def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; 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 @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 delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n @customf.destroy\n respond_to do |format|\n format.html { redirect_to customfs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @indicate_taxonomy.destroy\n respond_to do |format|\n format.html { redirect_to indicate_taxonomies_url, notice: 'Taxonomy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxonomy = Taxonomy.find(params[:id])\n taxonomy_type = @taxonomy.taxonomy_type \n @taxonomy.delete_node_keep_sub_nodes\n @taxonomy.reload\n @taxonomy.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_taxonomies_url(:taxonomy_type => taxonomy_type) }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @chiropractic_assessment = ChiropracticAssessment.find(params[:id])\n @chiropractic_assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to chiropractic_assessments_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize! :destroy, Conceptopersonal\n @conceptopersonal.destroy\n\n\n respond_to do |format|\n format.html { redirect_to conceptospersonales_url, notice: '<i class=\"fa fa-check-square fa-lg\"></i> El concepto fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_meta_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_meta_data_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @tx_land_grants_special_collection.destroy\n respond_to do |format|\n format.html { redirect_to tx_land_grants_special_collections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dco_resource.destroy\n respond_to do |format|\n format.html { redirect_to dco_resources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @genotype = Genotype.find(params[:id])\n @genotype.destroy\n\n respond_to do |format|\n format.html { redirect_to genotypes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @crit_requirement = CritRequirement.find(params[:id])\n @crit_requirement.destroy\n\n respond_to do |format|\n format.html { redirect_to(crit_requirements_url) }\n format.xml { head :ok }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @socioeconomic_study = SocioeconomicStudy.find(params[:id])\n @socioeconomic_study.destroy\n\n respond_to do |format|\n format.html { redirect_to socioeconomic_studies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resources_custom.destroy\n respond_to do |format|\n format.html { redirect_to resources_customs_url, notice: 'Resources custom was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rule.destroy\n respond_to do |format|\n format.json { head :no_content }\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 @go_slim_sequence = GoSlimSequence.find(params[:id])\n @go_slim_sequence.destroy\n\n respond_to do |format|\n format.html { redirect_to go_slim_sequences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observation_type = ObservationType.find(params[:id])\n @observation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\n end", "def delete\n client.delete(\"/customFields/#{id}\")\n end", "def destroy\n @farm_practice_typology.destroy\n respond_to do |format|\n format.html { redirect_to farm_practice_typologies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @projects_and_concept.destroy\n respond_to do |format|\n format.html { redirect_to projects_and_concepts_url, notice: 'Projects and concept was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_custom_field(custom_field_id)\n url = \"#{@goseg_base_url}/custom_fields/#{custom_field_id}\"\n puts url\n return RestClient.delete(url){|response, request, result| response }\n end", "def destroy\n @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 @clinical_course = ClinicalCourse.find(params[:id])\n @clinical_course.destroy\n\n respond_to do |format|\n format.html { redirect_to clinical_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ruby = Ruby.find(params[:id])\n @ruby.destroy\n\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @observation = Observation.find(params[:id])\n @observation.destroy\n\n respond_to do |format|\n format.html { redirect_to observations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @clinicalsection = Clinicalsection.find(params[:id])\n @clinicalsection.destroy\n\n respond_to do |format|\n format.html { redirect_to clinicalsections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon = Taxon.find(params[:id])\n @taxon.destroy\n\n respond_to do |format|\n format.html { redirect_to taxons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_attribute = TaxonAttribute.find(params[:id])\n @taxon_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to taxon_attributes_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.72778064", "0.7265202", "0.7265202", "0.710455", "0.66949916", "0.65777224", "0.6565862", "0.65384096", "0.65101707", "0.64560324", "0.64560324", "0.6449879", "0.64449114", "0.64107627", "0.6386794", "0.6385608", "0.63815707", "0.63799417", "0.6369514", "0.6353753", "0.63314784", "0.63188523", "0.631606", "0.62997055", "0.6297002", "0.62836397", "0.628346", "0.6275926", "0.6275053", "0.62738717", "0.62722266", "0.62713945", "0.62700367", "0.62700367", "0.6259518", "0.6258186", "0.62558883", "0.6252868", "0.62388474", "0.623334", "0.6231863", "0.62294847", "0.6227917", "0.62264913", "0.6224342", "0.6223137", "0.62227666", "0.6221069", "0.6214158", "0.6208846", "0.62080497", "0.6202687", "0.6202235", "0.6200143", "0.61995643", "0.61979437", "0.6194354", "0.619048", "0.6188955", "0.61869216", "0.61864287", "0.61839855", "0.61745083", "0.6170945", "0.61697245", "0.6165897", "0.6162811", "0.6160329", "0.61569315", "0.61568993", "0.6153597", "0.6151689", "0.6151539", "0.6149485", "0.6149485", "0.6149485", "0.6149485", "0.6146933", "0.6146933", "0.6146538", "0.6146512", "0.6145989", "0.6140981", "0.614026", "0.61400133", "0.61371934", "0.6136557", "0.61363447", "0.6136041", "0.6132486", "0.613236", "0.61315453", "0.61294144", "0.61280686", "0.6126763", "0.61235183", "0.61228836", "0.6122485", "0.61210555", "0.611947" ]
0.78199947
0
Use callbacks to share common setup or constraints between actions.
def set_customized_concept @customized_concept = CustomizedConcept.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 customized_concept_params params.require(:customized_concept).permit(:course_id, :title, :description, :video, :lecture) 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 /pets GET /pets.json
def index if user_signed_in? @user = current_user @pets = current_user.pets.reverse else redirect_to root_path return end respond_to do |format| format.html # index.html.erb format.json { render json: @pets } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end", "def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end", "def show\n render json: @pet\n end", "def index\n pets = pets_from_query\n\n respond_to do |format|\n format.html do\n @pets = pets.paginate(page: params[:page], per_page: 10)\n end\n format.json do\n @pets = pets\n end\n end\n end", "def show\n @species = Specie.find(params[:id])\n\n @pets = Pet.where(:specie_id => @species).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:secie => @species, :pets => @pets } }\n end\n end", "def show\n @petdetail = Petdetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @petdetail }\n end\n end", "def index\n @pets = Pet.all\n # @users= Pet.user.all\n render json: @pets, each_serializer: PetSerializer\n \n end", "def show\n @lost_pet = LostPet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def show\n pet = BattlePet.find(params[:id])\n render json: pet, status: :ok\n end", "def show\n\n if !params[:id].nil?\n pet = Pet.find_by_id(params[:id])\n if pet\n render json: pet, include: :user, status: :ok\n else\n render json: {message: 'Pet doesn\\'t exist'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error getting pet detail, please try it again'}, status: :bad_request\n end\n end", "def index\n @client = Client.find params[:client_id]\n @pets = @client.pets\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 @pets = Pet.all\n end", "def index\n @pets = Pet.all\n end", "def show\n @pet = Pet.find(params[:id])\n end", "def index\n if !params[:email].nil?\n user = User.find_by_email(params[:email])\n if user\n render json: user.pets, status: :ok\n else\n render json: {message: '**There was an error getting pets, please try it again'}, status: :bad_request\n end\n else\n render json: {message: '!!There was an error getting pets, please try it again'}, status: :bad_request\n end\n end", "def show\n # load all that users pets\n @pets = @user.pets.page(params[:page]).per(3)\n end", "def show\n respond_to do | format |\n format.html #show.html.erb\n format.json { render json: @pet_breed }\n end\n end", "def show\n @team = Team.find(params[:id])\n @team_pets = @team.pets\n if @team_pets.length > 0\n @pets = current_user.pets.where('id not in (?)', @team_pets)\n else\n @pets = current_user.pets\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end", "def show\n @pet = Pet.find_by id: params[:id]\n end", "def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end", "def index\n @pets = current_user.pets.all\n end", "def pets\n @pets\n end", "def index\n @pugs = Pug.all\n\n render json: @pugs\n end", "def show\n #@pet = Pet.find(params[:id])\n @pet = Pet.includes(:petphotos).find(params[:id])\n\n if (@pet.petphotos.length > 0)\n logger.debug(\"image = \" + @pet.petphotos[0].image)\n end \n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @pet }\n format.json { render json: {:pet => @pet, :petphoto => @pet.petphotos[0] } }\n end\n end", "def find_pets_by_tags_with_http_info(tags, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...'\n end\n # verify the required parameter 'tags' is set\n if @api_client.config.client_side_validation && tags.nil?\n fail ArgumentError, \"Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags\"\n end\n # resource path\n local_var_path = '/pet/findByTags'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'tags'] = @api_client.build_collection_param(tags, :csv)\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Array<Pet>'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.find_pets_by_tags\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#find_pets_by_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def pets\n\t\t@pets_list\n\tend", "def show\n @love = Love.find(params[:id])\n render json: @love\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pet }\n end\n end", "def shelter_pets(options = {})\n defaults = {'id' => 1}\n options = defaults.merge(options)\n \n @petfinder.shelter_pets(options['id'], options)\n end", "def index\n @loves = Love.all\n render json: @loves\n end", "def new\n @user = current_user\n @pet = @user.pets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def index\n @title = 'Mascotas'\n @pets = Pet.where(adpted: 'f').page(params[:page]).per(3)\n end", "def index\n @pets = []\n if current_user.role.name != 'cliente'\n @pets = Pet.all\n else\n if !current_user.nil?\n id = current_user.data_id\n if !id.nil?\n @client = Client.find(id)\n @pets = @client.pets\n end\n end\n end\n end", "def show\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tags_of_novel }\n end\n end", "def show\n render json: @dog\n end", "def index\n @diets = @profile.diets\n respond_with @diets\n end", "def show\n @competent = Competent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competent }\n end\n end", "def get_dogs\n user_dog = User.find(params[:id]).dog\n if user_dog\n render json: user_dog.to_json(include: :dog_photos)\n else\n render json: []\n end\n end", "def show\n @client = Client.find params[:client_id]\n @pet = Pet.find params[:pet_id]\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 # byebug\n @user_resources = current_user.user_detail.pets\n @resources = @user_resources.page(params[:page]).per(10)\n super\n end", "def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end", "def new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def index\n @pet_items = PetItem.all\n end", "def index\n @postulation_pets = PostulationPet.all\n end", "def show\n dog = Dog.find(params[:id])\n render json: dog\n end", "def show\n render json: @diet, status: 200, root: true\n end", "def show\n @pocket = Pocket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pocket }\n end\n end", "def index\n @varieties = Variety.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @varieties }\n end\n end", "def show\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vet }\n end\n end", "def index\n @parishes = Parish.all\n\n render json: @parishes\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 busca_por_pet_id(pet_id) \n uri = \"#{ENV['BASE_URI']}/pet/#{pet_id}\"\n \n without_authentication('get', uri)\n end", "def index\n @peticions = Peticion.all\n end", "def show\n @petition = Petition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @petition }\n end\n end", "def show\n render json: @pizza\n end", "def index\n @pots = Pot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pots }\n end\n end", "def index\n @question_pets = QuestionPet.all\n end", "def index\n @petprofiles = Petprofile.all\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 @Love = Love.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @Love }\n end\n end", "def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end", "def index\n @adopted_pets = AdoptedPet.all\n end", "def index\n @adopted_pets = AdoptedPet.all\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 @typeofpets = Typeofpet.all\n end", "def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def index\n @pets = Pet.all\n # render 'index' => where render is a method call and 'index' is an argument\n # rails will implicitly try to render a view template with the same name as the action\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @plants = Plant.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @plants }\n end\n end", "def create\n @pet = @person.pets.build(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @person }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @parks = Park.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @parks }\n end\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 @pets = Pet.all\n #@pets = Pet.order(\"created_at DESC\").page(params[:page]).per(10)\n @pet = Pet.new\n end", "def index\n @line_pets = LinePet.all\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def show\n @pictures_of_cat = PicturesOfCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end", "def get_pet_by_id_with_http_info(pet_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.get_pet_by_id ...'\n end\n # verify the required parameter 'pet_id' is set\n if @api_client.config.client_side_validation && pet_id.nil?\n fail ArgumentError, \"Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id\"\n end\n # resource path\n local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Pet'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['api_key']\n\n new_options = opts.merge(\n :operation => :\"PetApi.get_pet_by_id\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#get_pet_by_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end", "def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end", "def index\n\t\tall_people = Person.all.sort_by(&:id)\n\t\tif all_people\n\t\t\trender json: {people: all_people}\n\t\telse\n\t\t\trender body: 'People Not Found', status: 404\n\t\tend\n\tend", "def index\n @dogs = Dog.all\n # render erb: 'dogs/index'\n render json: @dogs\n end", "def show\n @species = Species.find(params[:id]) \n @pets = Pet.paginate(:conditions => ['species_id = ?', @species.id], :order => \"regid ASC\", :per_page => 50, :page => params[:page])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ets }\n end\n end", "def show\n @pet_status = PetStatus.find(params[:id])\n\n end", "def create\n pet_response = pet_create_service.call(pet_params)\n lost_pet_match_service.call(pet_response)\n\n @pet = pet_response\n\n respond_to do |format|\n if pet_response.success?\n format.html { redirect_to pet_response, notice: I18n.t(\"pets.show.created\") }\n format.json { render :show, status: :created, location: pet_response }\n else\n format.html { render :new }\n format.json { render json: pet_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def demo\n render json: Cat.all\n end", "def show\n render json: @pug\n end", "def show\n @petition = Petition.friendly.find(params[:id])\n\n render json: @petition\n end", "def index\n @peds = Ped.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peds }\n end\n end", "def find_pet_by_name(pets, pet_name)\n for pet in pets[:pets]\n if pet[:name] == pet_name\n return pet\n end\n end\n return nil\nend", "def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end", "def show\n @variety = Variety.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @variety }\n end\n end", "def index\n @pizzas = Pizza.all\n render json: @pizzas\n end", "def index\n @pets = Pet.all\n @missing = Pet.find :all, :conditions => {:missing => true}\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pets }\n end\n end", "def index\n @shelter = Shelter.first\n @pets = Pet.get_available_pets.order(:pet_type)\n if (!@cart)\n set_cart\n end\n @selectedPets = @cart.selected_pets\n end" ]
[ "0.7532408", "0.7481141", "0.7442882", "0.7442882", "0.7365796", "0.7232409", "0.7110083", "0.6978937", "0.6939604", "0.6848388", "0.683465", "0.6797097", "0.6695568", "0.6684484", "0.6653209", "0.6653209", "0.6602785", "0.65907687", "0.6585763", "0.6477046", "0.64590454", "0.64536464", "0.64381623", "0.6242217", "0.6228629", "0.62263596", "0.6204602", "0.6188801", "0.6177844", "0.61666745", "0.6154845", "0.6129276", "0.6119822", "0.61052334", "0.6093586", "0.60856813", "0.60562783", "0.60510373", "0.6037627", "0.6035347", "0.6015391", "0.6005324", "0.59784454", "0.5968737", "0.59599566", "0.5959677", "0.59433174", "0.5931258", "0.5926484", "0.5922781", "0.5921832", "0.59153414", "0.59081084", "0.5892078", "0.58861554", "0.5874938", "0.5873199", "0.5866529", "0.585755", "0.585658", "0.5847572", "0.5845833", "0.58390164", "0.5838406", "0.5833994", "0.5824008", "0.5824008", "0.58218634", "0.58202416", "0.5810929", "0.5809702", "0.5804872", "0.58025676", "0.5800584", "0.5799708", "0.57974875", "0.57885695", "0.5788137", "0.5767305", "0.5767305", "0.5767305", "0.57592", "0.57547224", "0.5738024", "0.57332546", "0.5732865", "0.572897", "0.5727053", "0.57241726", "0.5718939", "0.57183915", "0.5712356", "0.5710386", "0.56796753", "0.56733686", "0.5668777", "0.56609863", "0.5638358", "0.5636394", "0.5635831" ]
0.6523989
19
GET /pets/1 GET /pets/1.json
def show @pet = Pet.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @pet } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end", "def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end", "def show\n render json: @pet\n end", "def show\n @petdetail = Petdetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @petdetail }\n end\n end", "def index\n pets = pets_from_query\n\n respond_to do |format|\n format.html do\n @pets = pets.paginate(page: params[:page], per_page: 10)\n end\n format.json do\n @pets = pets\n end\n end\n end", "def show\n @species = Specie.find(params[:id])\n\n @pets = Pet.where(:specie_id => @species).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:secie => @species, :pets => @pets } }\n end\n end", "def show\n pet = BattlePet.find(params[:id])\n render json: pet, status: :ok\n end", "def show\n @lost_pet = LostPet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def index\n @client = Client.find params[:client_id]\n @pets = @client.pets\n end", "def show\n\n if !params[:id].nil?\n pet = Pet.find_by_id(params[:id])\n if pet\n render json: pet, include: :user, status: :ok\n else\n render json: {message: 'Pet doesn\\'t exist'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error getting pet detail, please try it again'}, status: :bad_request\n end\n end", "def show\n @pet = Pet.find(params[:id])\n end", "def index\n @pets = Pet.all\n # @users= Pet.user.all\n render json: @pets, each_serializer: PetSerializer\n \n end", "def show\n @pet = Pet.find_by id: params[:id]\n end", "def show\n # load all that users pets\n @pets = @user.pets.page(params[:page]).per(3)\n end", "def index\n @pets = Pet.all\n end", "def index\n @pets = Pet.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 show\n respond_to do | format |\n format.html #show.html.erb\n format.json { render json: @pet_breed }\n end\n end", "def show\n #@pet = Pet.find(params[:id])\n @pet = Pet.includes(:petphotos).find(params[:id])\n\n if (@pet.petphotos.length > 0)\n logger.debug(\"image = \" + @pet.petphotos[0].image)\n end \n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @pet }\n format.json { render json: {:pet => @pet, :petphoto => @pet.petphotos[0] } }\n end\n end", "def show\n @love = Love.find(params[:id])\n render json: @love\n end", "def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pet }\n end\n end", "def index\n if user_signed_in?\n @user = current_user\n @pets = current_user.pets.reverse\n else\n redirect_to root_path \n return\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end", "def index\n if !params[:email].nil?\n user = User.find_by_email(params[:email])\n if user\n render json: user.pets, status: :ok\n else\n render json: {message: '**There was an error getting pets, please try it again'}, status: :bad_request\n end\n else\n render json: {message: '!!There was an error getting pets, please try it again'}, status: :bad_request\n end\n end", "def show\n @client = Client.find params[:client_id]\n @pet = Pet.find params[:pet_id]\n end", "def show\n dog = Dog.find(params[:id])\n render json: dog\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 show\n @team = Team.find(params[:id])\n @team_pets = @team.pets\n if @team_pets.length > 0\n @pets = current_user.pets.where('id not in (?)', @team_pets)\n else\n @pets = current_user.pets\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end", "def show\n @competent = Competent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competent }\n end\n end", "def show\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vet }\n end\n end", "def show\n @petition = Petition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @petition }\n end\n end", "def show\n @Love = Love.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @Love }\n end\n end", "def index\n @pugs = Pug.all\n\n render json: @pugs\n end", "def show\n @pocket = Pocket.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pocket }\n end\n end", "def show\n render json: @dog\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 show\n @tags_of_novel = TagsOfNovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tags_of_novel }\n end\n end", "def show\n @pet_status = PetStatus.find(params[:id])\n\n end", "def index\n @loves = Love.all\n render json: @loves\n end", "def new\n @user = current_user\n @pet = @user.pets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def show\n render json: @diet, status: 200, root: true\n end", "def index\n @diets = @profile.diets\n respond_with @diets\n end", "def show\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moose }\n end\n end", "def show\n @variety = Variety.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @variety }\n end\n end", "def 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 animal_id = params[:id]\n # Find that animal (by id) in the database\n @animal = Animal.find(animal_id)\n \n #Give back JSON details of that animal\n render json: @animal\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 @petition = Petition.friendly.find(params[:id])\n\n render json: @petition\n end", "def show\n recipe = Recipe.find(params[:id])\n # recipes = Recipe.find_by(params[:id])\n # render json: recipe\n render json: recipe\n end", "def index\n @varieties = Variety.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @varieties }\n end\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\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 get_random_pokemon(number)\n uri = URI(\"https://pokeapi.co/api/v2/pokemon/#{number}\")\n res = Net::HTTP.get_response(uri)\n JSON.parse(res.body)\nend", "def index\n @pets = current_user.pets.all\n end", "def show\n render json: @pizza\n end", "def show\n @pictures_of_cat = PicturesOfCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end", "def client_choose(offset = 10, limit = 20)\n response = Net::HTTP.get(\n URI(\"https://pokeapi.co/api/v2/pokemon/?offset=#{offset}&limit=#{limit}\")\n )\n \n JSON.parse(response)\nend", "def index\n @pets = []\n if current_user.role.name != 'cliente'\n @pets = Pet.all\n else\n if !current_user.nil?\n id = current_user.data_id\n if !id.nil?\n @client = Client.find(id)\n @pets = @client.pets\n end\n end\n end\n end", "def show\n @competency = Competency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competency }\n end\n end", "def get_pet_by_id_with_http_info(pet_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.get_pet_by_id ...'\n end\n # verify the required parameter 'pet_id' is set\n if @api_client.config.client_side_validation && pet_id.nil?\n fail ArgumentError, \"Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id\"\n end\n # resource path\n local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Pet'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['api_key']\n\n new_options = opts.merge(\n :operation => :\"PetApi.get_pet_by_id\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#get_pet_by_id\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end", "def show\n\n @food = Food.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @food }\n end\n end", "def index\n @title = 'Mascotas'\n @pets = Pet.where(adpted: 'f').page(params[:page]).per(3)\n end", "def shelter_pets(options = {})\n defaults = {'id' => 1}\n options = defaults.merge(options)\n \n @petfinder.shelter_pets(options['id'], options)\n end", "def show\n @person = Person.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @person }\n end\n end", "def show\n params.require(%i[id])\n render json: Beverage.find_by!(id: params[:id])\n end", "def index\n @plants = Plant.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @plants }\n end\n end", "def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end", "def busca_por_pet_id(pet_id) \n uri = \"#{ENV['BASE_URI']}/pet/#{pet_id}\"\n \n without_authentication('get', uri)\n end", "def show\n @pot = Pot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pot }\n end\n end", "def show\n @vegetable = Vegetable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vegetable }\n end\n end", "def show\n @dog = Dog::Dog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dog }\n end\n end", "def index\n @pets = Pet.all\n #@pets = Pet.order(\"created_at DESC\").page(params[:page]).per(10)\n @pet = Pet.new\n end", "def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def index\n @dogs = Dog.all\n render json: @dogs, each_serializer: DogSerializer, root: 'dogs'\n end", "def show \n bird = Bird.find(params[:id])\n if bird \n render json: bird.slice(:id, :name, :species)\n else \n render json: {message: \"Bird not found\"}\n end\n # {id: bird.id, name: bird.name, species: bird.species}\n end", "def pets\n\t\t@pets_list\n\tend", "def index\n @pet_items = PetItem.all\n end", "def show\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cat }\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def show\n @species = Species.find(params[:id]) \n @pets = Pet.paginate(:conditions => ['species_id = ?', @species.id], :order => \"regid ASC\", :per_page => 50, :page => params[:page])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ets }\n end\n end", "def pets\n @pets\n end", "def index\n @pots = Pot.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pots }\n end\n end", "def index_single_gift\n render json: @gift, include: :ages, status: :ok\n end", "def show\n @cvi = Cvi.find(params[:id])\n @animals = @cvi.animals\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cvi }\n end\n end", "def show\n @pic = Pic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pic }\n end\n end", "def person(id)\n get(\"/catalog/people/#{id.to_s}\")\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 destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to pets_url }\n format.json { head :no_content }\n end\n end", "def find_pets_by_tags_with_http_info(tags, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...'\n end\n # verify the required parameter 'tags' is set\n if @api_client.config.client_side_validation && tags.nil?\n fail ArgumentError, \"Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags\"\n end\n # resource path\n local_var_path = '/pet/findByTags'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'tags'] = @api_client.build_collection_param(tags, :csv)\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Array<Pet>'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.find_pets_by_tags\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#find_pets_by_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @prime = Prime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prime }\n end\n end", "def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end", "def show\n params.require(%i[id])\n render json: Ingredient.find_by!(id: params[:id])\n end", "def index\n @dogs = Dog.all\n # render erb: 'dogs/index'\n render json: @dogs\n end", "def index\n @parishes = Parish.all\n\n render json: @parishes\n end", "def show\n @species = Species.find_by_name(params[:species_name])\n @pet = Pet.first(:conditions => ['species_id = ? AND regid = ?', @species.id, params[:regid]])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pet }\n end\n end" ]
[ "0.75733095", "0.73931026", "0.7245301", "0.70816267", "0.7062426", "0.7058671", "0.6981802", "0.6895421", "0.6866418", "0.6858466", "0.6762347", "0.66688824", "0.6666302", "0.64767885", "0.6471701", "0.6471701", "0.64502436", "0.6442229", "0.6401544", "0.6370456", "0.63654625", "0.63480365", "0.6303754", "0.6287651", "0.6284281", "0.62656856", "0.62610674", "0.62497246", "0.6227918", "0.6185398", "0.60955787", "0.6092138", "0.60841733", "0.607263", "0.6067855", "0.60659796", "0.6049707", "0.6039924", "0.6036608", "0.6018903", "0.6013699", "0.60131764", "0.60027033", "0.5983427", "0.59621215", "0.59528494", "0.595024", "0.594084", "0.59365034", "0.593586", "0.593444", "0.59237075", "0.59109867", "0.5900624", "0.58980197", "0.5886887", "0.5879392", "0.587192", "0.5870984", "0.5869736", "0.58680964", "0.5866481", "0.5863882", "0.5857605", "0.58570594", "0.5855788", "0.5844345", "0.58395195", "0.58391136", "0.5837061", "0.58346254", "0.5833209", "0.5833197", "0.5832931", "0.58320343", "0.58251816", "0.58228916", "0.58217764", "0.5821748", "0.5818781", "0.58148575", "0.5814281", "0.58114433", "0.5810552", "0.58053005", "0.5803238", "0.5799393", "0.57966936", "0.57964927", "0.57964104", "0.57964104", "0.57964104", "0.57947236", "0.57945", "0.57921374", "0.57766294", "0.5776064", "0.5773305", "0.5772474" ]
0.7517837
2
GET /pets/new GET /pets/new.json
def new @user = current_user @pet = @user.pets.build respond_to do |format| format.html # new.html.erb format.json { render json: @pet } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def new\n @pet = Pet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pet }\n end\n end", "def new\n @pet = Pet.new\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end", "def new\n @moose = Moose.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moose }\n end\n end", "def new\n @petition = Petition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @petition }\n end\n end", "def new\n @pocket = Pocket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pocket }\n end\n end", "def new\n @Love = Love.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @Love }\n end\n end", "def new\n @variety = Variety.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @variety }\n end\n end", "def new\n @pto = Pto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pto }\n end\n end", "def new\n @pony = Pony.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pony }\n end\n end", "def new\n #@pet = Pet.new\n #@person = Person.find(params[:person_id])\n #@current_user = current_user\n #@person = current_user.person\n #logger.debug(\"@person.email = \" + @person.email)\n\n @pet = Pet.new\n #@petphoto = @pet.petphotos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def new\n @vet = Vet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vet }\n end\n end", "def new\n @competent = Competent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competent }\n end\n end", "def new\n @trumpet = Trumpet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trumpet }\n end\n end", "def new\n @tags_of_novel = TagsOfNovel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tags_of_novel }\n end\n end", "def new\n @pot = Pot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pot }\n end\n end", "def new\n @patch = Patch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patch }\n end\n end", "def create\n @pet = Pet.new(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = @person.pets.build(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @person }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @ped = Ped.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ped }\n end\n end", "def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end", "def new\n @food = Food.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @food }\n end\n end", "def create\n pet_response = pet_create_service.call(pet_params)\n lost_pet_match_service.call(pet_response)\n\n @pet = pet_response\n\n respond_to do |format|\n if pet_response.success?\n format.html { redirect_to pet_response, notice: I18n.t(\"pets.show.created\") }\n format.json { render :show, status: :created, location: pet_response }\n else\n format.html { render :new }\n format.json { render json: pet_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end", "def new\n @peso = Peso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peso }\n end\n end", "def new\n @stuff = Stuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stuff }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @spot = Spot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spot }\n end\n end", "def new\n @potluck = Potluck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @potluck }\n end\n end", "def new\n @dog = Dog::Dog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dog }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @newspage = Newspage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newspage }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end", "def new\n @person = people_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end", "def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end", "def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end", "def new\n @carpool = Carpool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carpool }\n end\n end", "def new\n @t = T.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @t }\n end\n end", "def new\n @foil = Foil.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foil }\n end\n end", "def create\n @pet = current_user.pets.new(pet_params)\n\n # TODO wipe this out later \n # This assigns pet to user\n # @current_user = current_user\n # @current_user.pets << @pet\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @recipe = Recipe.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recipe }\n end\n end", "def new\n @pageType = \"new\"\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end", "def new\n @price = Price.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @price }\n end\n end", "def new\n @pet = Pet.new\n @breeds = [::Bertslist::Breeds::Cat, ::Bertslist::Breeds::Dog];\n @craigslist = ThirdParty.new\n\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def new\n @vegetable = Vegetable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vegetable }\n end\n end", "def new\n @precinct = Precinct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precinct }\n end\n end", "def new\n @tango = Tango.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tango }\n end\n end", "def new\n @pictures_of_cat = PicturesOfCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pictures_of_cat }\n end\n end", "def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end", "def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @po }\n end\n end", "def create\n @pet = Pet.new(pet_params)\n @pet.save\n redirect_to \"/pets\"\n end", "def new\n @park = Park.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @park }\n end\n end", "def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end", "def new\n @prop = Prop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prop }\n end\n end", "def new\n @papel = Papel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @papel }\n end\n end", "def new\n @volunteer = Volunteer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volunteer }\n end\n end", "def new\n @prime = Prime.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prime }\n end\n end", "def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end", "def new\n @pokeparty = Pokeparty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pokeparty }\n end\n end", "def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def new\n post = Post.new\n render json: post\n end", "def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end", "def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end", "def new\n @galaxy = Galaxy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @galaxy }\n end\n end", "def new\n @templete = Templete.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @templete }\n end\n end", "def new\n @name = Name.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end", "def new\n @troop = Troop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @troop }\n end\n end", "def new\n @meteor = Meteor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meteor }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end", "def new\n @name = Name.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @name }\n end\n end", "def new\n @bob = Bob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bob }\n end\n end", "def new\n @title = \"New Book\"\n @book = Book.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end", "def new\n add_breadcrumb :new\n @visit = Visit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visit }\n end\n end", "def new\n @tagging = Tagging.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagging }\n end\n end", "def new\n @tag = Tag.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end", "def new\n @collection = Collection.new\n respond_to do |format|\n format.html { create }\n format.json { render :json => @collection }\n end\n end", "def new\n @competency = Competency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency }\n end\n end", "def new\n @new_review = NewReview.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_review }\n end\n end", "def new\n @dotsmember = Dotsmember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dotsmember }\n end\n end", "def new\n @foam = Foam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foam }\n end\n end", "def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @collection }\n end\n end", "def new\n @pet_status = PetStatus.new\n\n end", "def new\n @pst = Pst.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @pst }\n end\n end", "def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end", "def new\n\t\t@person = Person.new\n\t\t# render json: @person #skips the view, and just renders out the json\n\tend" ]
[ "0.75966233", "0.723062", "0.7222331", "0.7056523", "0.7056523", "0.7009805", "0.70057005", "0.70012003", "0.69963574", "0.69676054", "0.69582736", "0.695148", "0.69497854", "0.69350594", "0.6931725", "0.69169813", "0.69073385", "0.6881428", "0.68494684", "0.68481183", "0.6842758", "0.68234646", "0.6820051", "0.67994577", "0.6796505", "0.67809695", "0.6763158", "0.67603743", "0.67483616", "0.67379785", "0.67379785", "0.6730214", "0.67242223", "0.67229056", "0.671656", "0.6705532", "0.6705532", "0.6705532", "0.6705532", "0.6705532", "0.6705532", "0.6705532", "0.6696811", "0.6692302", "0.669152", "0.6689597", "0.6687611", "0.6682383", "0.66696376", "0.6667544", "0.666372", "0.66577595", "0.66577595", "0.66577595", "0.66577595", "0.66577595", "0.6657212", "0.6652936", "0.66429627", "0.66396445", "0.6637075", "0.66297436", "0.66240305", "0.6621503", "0.6618869", "0.6615731", "0.6615283", "0.6614144", "0.6610677", "0.66084695", "0.6607109", "0.66045976", "0.66036284", "0.66030717", "0.6600204", "0.65985465", "0.6586462", "0.65841794", "0.6582998", "0.65829074", "0.65824443", "0.65806276", "0.6580362", "0.65776014", "0.6576193", "0.6574952", "0.65726477", "0.6566127", "0.6565682", "0.6564898", "0.6562052", "0.6559703", "0.6553825", "0.6552323", "0.65482545", "0.6548236", "0.654482", "0.6544626", "0.6543422", "0.6535817" ]
0.74882567
1
POST /pets POST /pets.json
def create @user = current_user @pet = @user.pets.new(params[:pet]) binding.pry if humane_society_ips.include?(request.remote_ip) @pet.at_humane_society = true end respond_to do |format| if @pet.save format.html { redirect_to root_path, notice: 'Pet was successfully created.' } format.json { render json: @pet, status: :created, location: @pet } else format.html { render action: "new" } format.json { render json: @pet.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @pet = @person.pets.build(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @person }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = Pet.new(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = Pet.new(pet_params)\n @pet.save\n redirect_to \"/pets\"\n end", "def create\n\n if !params[:name].nil? && !params[:email].nil?\n user = User.find_by_email(params[:email])\n if user\n pet = user.pets.create(name:params[:name], observations: params[:observations])\n if pet\n render json: pet, status: :created\n else\n render json: {message: 'There was an error saving pet, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error saving pet, please try it again'}, status: :bad_request\n end\n else\n render json: {message: 'Pet name not provided'}, status: :bad_request\n end\n end", "def create\n pet_response = pet_create_service.call(pet_params)\n lost_pet_match_service.call(pet_response)\n\n @pet = pet_response\n\n respond_to do |format|\n if pet_response.success?\n format.html { redirect_to pet_response, notice: I18n.t(\"pets.show.created\") }\n format.json { render :show, status: :created, location: pet_response }\n else\n format.html { render :new }\n format.json { render json: pet_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @pet = Pet.new(pet_params)\n @pet.user = @user\n \n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = current_user.pets.new(pet_params)\n\n # TODO wipe this out later \n # This assigns pet to user\n # @current_user = current_user\n # @current_user.pets << @pet\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = Pet.new(pet_params)\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: I18n.t('Pet card was successfully created') }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @adopted_pet = Pet.find(params[:pet_id])\n # @adopted_pet = adopted_pet.build(:pet => pet)\n\n respond_to do |format|\n if @adopted_pet.save\n format.html { redirect_to @adopted_pet, notice: 'You are about to adopt a pet!' }\n format.json { render action: 'show', status: :created, location: @adopted_pet }\n else\n format.html { render action: 'new' }\n format.json { render json: @adopted_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = current_user.pets.new(pet_params)\n\n params[:pet][:photos][:photo].each {|photo| @pet.photos.build(photo: photo)} if params[:pet][:photos].present?\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n# @pet = Pet.new(pet_params)\n@pet = current_user.pets.create(pet_params)\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Has registrado a tu mascota' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question_pet = QuestionPet.new(question_pet_params)\n\n respond_to do |format|\n if @question_pet.save\n format.html { redirect_to @question_pet, notice: 'Question pet was successfully created.' }\n format.json { render :show, status: :created, location: @question_pet }\n else\n format.html { render :new }\n format.json { render json: @question_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = current_user.pets.new(pet_params)\n if @pet.save\n redirect_to pets_path, success: 'Votre animal a bien été créé'\n else\n render :new\n end\n end", "def pet_params\n params.require(:pet).permit(:animal_type, :age, :sex, :name, :description, :lost_on, :lost_in, :user_id, :race_id, :solved)\n end", "def pet_params\n params.require(:pet).permit(:name, :dob, :died, :species_id)\n end", "def pet_params\n params.require(:pet).permit(:name, :adoptions_id, :races_id, :weight, :description, :special_needs, :dewormed, :neutered, :aprox_age, :species)\n end", "def create\n @pet = Pet.new(pet_params)\n if @pet.save\n redirect_to pets_path\n flash[:alert] = \"Pet Saved\"\n else\n render :new\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :gender, :birthday, :species_id, :image)\n end", "def new\n @user = current_user\n @pet = @user.pets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def create2\n @person= Person.find_by_upid(params[:person_upid])\n @pet = Pet.new(params[:pet])\n\n respond_to do |format|\n if @pet.save\n @pp = @person.as_json(:include => :addresses)\n @pp[:pets] = Pet.joins(:caretakers).includes(:petphotos).where(\"caretakers.primary_role = 'Owner' and caretakers.person_id = ?\", @person.id).all.as_json(:include => :petphotos)\n\n if @person.status.eql? \"active mobile\"\n # add pet to related peeps (f&f, pet_pros)\n @person.person_connections.each do |fandf|\n famfrnd = Person.find(fandf.person_b_id)\n if fandf.category.eql? 'Spouse-Partner'\n prim_role = 'Owner'\n else # category in Family, Friend, Dog Walker\n prim_role = fandf.category\n end\n famfrnd.caretakers.build(:pet_id => @pet.id, :primary_role => prim_role, :status => 'active', :started_at => Time.now)\n famfrnd.save\n end\n end\n\n format.json { render json: @pp }\n else \n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :description, :animal_type, :breed, :user_id, :parent_id)\n end", "def pet_params\n params.require(:pet).permit(:name, :age, :breed, :species, :photo_url)\n end", "def create\n \n @client = Client.find params[:client_id].to_i\n @pet = Pet.new(pet_params)\n\n @pet.client = @client\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to client_pet_path(@client, @pet), notice: 'Mascota registrada exitosamente.' }\n else\n format.html { render :new }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:id, :name, :img_url, :about, :user_id)\n end", "def pet_params\n params.require(:pet).permit(:name, :species, :year_of_birth, :good_with_kids)\n end", "def pet_params\n params.require(:pet).permit(:name, :species, :desc, :image, :remote_image_url)\n end", "def pet_params\n params.require(:pet).permit(:name, :age, :specie, :sex, :race, :height, :sterilization, :adpted, :description, :imagen)\n end", "def pet_params\n params.require(:pet).permit(:name, :species, :year_of_birth, :good_with_kids)\n end", "def pet_params\n params.require(:pet).permit(:name, :specie, :age, :gender, :race, :size, :sterilized, :avatar, :user_id, \n :adoption, :moquillo, :rabia, :parainfluenza)\n end", "def create\n pet = Pet.find(params[:pet_id])\n @line_pet = @consider.add_pet(pet.id)\n\n respond_to do |format|\n if @line_pet.save\n format.html { redirect_to foster_url }\n\tformat.js\n format.json { render action: 'show', status: :created, location: @line_pet }\n else\n format.html { render action: 'new' }\n format.json { render json: @line_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :care_instructions, :household_id, :owner_id)\n end", "def pet_params\n params.require(:pet).permit(:name, :description, :city, :state, :price, :avatar, :user_id, :reservation_id, :reservation_date)\n end", "def pet_params\n params.require(:pet).permit(:name, :race, :birthdate)\n end", "def pet_params\n params.require(:pet).permit(:name, :color, :age, :weight, :markings, :gender, :collar, :collar_description, :chipped, :injured,\n :listing_type, :missing_since_found_at, :location, :latitude, :longitude, :description,\n :returned_to_owner, :scraping_script, :scraped_feed, :source_url, :breed_id, :user_id, :photo_url)\n end", "def prepare_pet\n # remove the pet\n SwaggerClient::PetApi.delete_pet(10002)\n # recreate the pet\n pet = SwaggerClient::Pet.new('id' => 10002, 'name' => \"RUBY UNIT TESTING\")\n SwaggerClient::PetApi.add_pet(:body => pet)\nend", "def pet_params\n params.require(:pet).permit(:type, :name, :breed, :size, :gender, :color, :age, :behavior)\n end", "def create\n @pet = Pet.new(params[:pet])\n @pet.organization_id = current_user.organization_id\n\n respond_to do |format|\n if @pet.save\n session[:message] = \"Pet was successfully listed\"\n format.html { redirect_to @pet, notice: 'Pet was successfully listed' }\n format.json { render json: {\"message\" => \"Pet was successfully listed\", \"success\" => true, \"data\" => @pet}, status: :created, location: @pet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :age)\n end", "def create\n @typeofpet = Typeofpet.new(typeofpet_params)\n\n respond_to do |format|\n if @typeofpet.save\n format.html { redirect_to @typeofpet, notice: 'Typeofpet was successfully created.' }\n format.json { render :show, status: :created, location: @typeofpet }\n else\n format.html { render :new }\n format.json { render json: @typeofpet.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:pet_kind, :breed, :size, :user_id)\n end", "def pet_params\n params.require(:pet).permit(:age, :name, :sex, :description, :avatar, :breed_id)\n end", "def pet_params\n params.require(:pet).permit(:name, :sex, :health, :clean, :mood, :status, :asleep, :strength, :defense, :age, :user_id, :highscore_id)\n end", "def create\n @pet = Pet.new(params[:pet])\n\n respond_to do |format|\n if @pet.save\n flash[:notice] = 'Pet was successfully added to system.'\n format.html { redirect_to(@pet) }\n format.xml { render :xml => @pet, :lost => :created, :location => @pet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @pet.errors, :lost => :unprocessable_entity }\n end\n end\n end", "def create\n @pet_true = PetTrue.new(pet_true_params)\n\n respond_to do |format|\n if @pet_true.save\n format.html { redirect_to @pet_true, notice: 'Pet true was successfully created.' }\n format.json { render action: 'show', status: :created, location: @pet_true }\n else\n format.html { render action: 'new' }\n format.json { render json: @pet_true.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :description, post_attributes: [:post_type])\n end", "def create\n @postulation_pet = PostulationPet.new(postulation_pet_params)\n respond_to do |format|\n if @postulation_pet.save\n\n @postulation_pet.addAnswer(params[:postulation_pet][:answer_pets], @postulation_pet.id )\n\n format.html { redirect_to @postulation_pet, notice: 'Postulation pet was successfully created.' }\n format.js\n # format.json { render :show, status: :created, location: @postulation_pet }\n else\n format.html { render :new }\n format.js\n # format.json { render json: @postulation_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:type, :name, :age)\n end", "def pet_params\n params.require(:pet).permit(:category_id, :name, :price, :age, :weight, :date_of_birth, :adopted_at, :wakeup_time, :desexed, :description)\n end", "def create\n @photo = Photo.new(photo_params)\n @photo.pet = @pet\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { render :new }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).\n permit(:type, :name, :description, :gender, :colors, :needs_transit_home, :published, :vaccinated, :location,\n :metadata, :age, :children_friendly, :pet_friendly, :publication_type, videos: [])\n end", "def create\n @pet = Pet.new(pet_params)\n @pet.user_id = current_user.id\n @pet.latitude = current_user.latitude\n @pet.longitude = current_user.longitude\n respond_to do |format|\n if @pet.save\n pet = Pet.find(@pet.id)\n user = User.find(current_user.id)\n format.html { redirect_to @pet, notice: 'Mascota fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def postulation_pet_params\n params.require(:postulation_pet).permit(:pet_id, :user_id, { question_ids: []}, {answer_pet_id: []}, :state )\n end", "def pet_params\n params.require(:pet).permit(:age, :breed, :gender, :name, :user_id)\n end", "def create\n animal = Animal.new(animal_params)\n if !animal.name.nil?\n animal.save\n render json: animal, status: 201, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end", "def pet_params\n # params.fetch(:pet, {})\n params.require(:pet).permit(:user_id, :owner_phone, :owner_address, :species, :name, :weight, :breed, :age_years, :age_months, :sex, :spayed, :housetrained, :housetrained_info, :chipped, :otherdogs, :otherdogs_info, :othercats, :othercats_info, :children, :children_info, :shed, :shed_info, :hypoallergenic, :hypoallergenic_info, :noise, :noise_info, :aggression, :aggression_info, :specialcare, :vet, :about, :instructions)\n end", "def pet_params\n params.require(:pet).permit(:ci, :name, :gender, :race, :bornDate, :client_id, :imagen)\n end", "def create\n @pet = Pet.new(pet_params)\n @pet.administrators << current_user\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @peticion = Peticion.new(peticion_params)\n\n respond_to do |format|\n if @peticion.save\n format.html { redirect_to @peticion, notice: 'Peticion was successfully created.' }\n format.json { render :show, status: :created, location: @peticion }\n else\n format.html { render :new }\n format.json { render json: @peticion.errors, status: :unprocessable_entity }\n end\n end\n end", "def typeofpet_params\n params.require(:typeofpet).permit(:name, :pet_id)\n end", "def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end", "def pet_params\n params.require(:pet).permit(:user_id, :image)\n end", "def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end", "def create\n pet = Pet.find(params[:pet_id])\n @pet_item = @pet_list.add_pet(pet.id) #pet_items.build(pet: pet) #PetItem.new(pet_item_params)\n\n respond_to do |format|\n if @pet_item.save\n format.html { redirect_to @pet_item.pet_list }\n format.js { @current_item = @pet_item }\n format.json { render action: 'show', status: :created, location: @pet_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @pet_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @pet\n end", "def prepare_pet(pet_api)\n pet_id = random_id\n category = Petstore::Category.new('id' => 20002, 'name' => 'category test')\n tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test')\n pet = Petstore::Pet.new('id' => pet_id, 'name' => \"RUBY UNIT TESTING\", 'photo_urls' => 'photo url',\n 'category' => category, 'tags' => [tag], 'status' => 'pending')\n pet_api.add_pet(pet)\n pet_id\nend", "def create\n @dog = Dog.new(dog_params)\n\n if @dog.save\n render json: @dog, status: 201\n else\n render json: {\n errors: @dog.errors\n }\n end\n end", "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def create\n @diet = Diet.new(diet_params)\n @diet.user = @current_user\n\n if @diet.save\n render json: @diet, status: 201, location: @diet, root: true\n else\n render json: @diet.errors, status: 422\n end\n end", "def add_pet_with_http_info(pet, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.add_pet ...'\n end\n # verify the required parameter 'pet' is set\n if @api_client.config.client_side_validation && pet.nil?\n fail ArgumentError, \"Missing the required parameter 'pet' when calling PetApi.add_pet\"\n end\n # resource path\n local_var_path = '/pet'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/xml'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(pet)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.add_pet\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#add_pet\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def addpets\n\t\t@petowner = Petowner.find( params[:id] )\n\t\t@all_pets_in_system = Pettype.all\n\t\t\n\tend", "def create\n @tags_of_novel = TagsOfNovel.new(params[:tags_of_novel])\n\n respond_to do |format|\n if @tags_of_novel.save\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully created.' }\n format.json { render json: @tags_of_novel, status: :created, location: @tags_of_novel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:pname, :gender_cd, :status_cd, :age_cd, :size_cd, :bio, :for_adoption, :photos, :breed_id)\n end", "def create\n @pet_breed = PetBreed.new(pet_breed_params)\n\n respond_to do |format|\n if @pet_breed.save\n format.html { redirect_to @pet_breed, notice: 'Pet breed was successfully created.' }\n format.json { render :show, status: :created, location: @pet_breed }\n else\n format.html { render :new }\n format.json { render json: @pet_breed.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n #@pet = Pet.new\n #@person = Person.find(params[:person_id])\n #@current_user = current_user\n #@person = current_user.person\n #logger.debug(\"@person.email = \" + @person.email)\n\n @pet = Pet.new\n #@petphoto = @pet.petphotos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pet }\n end\n end", "def question_pet_params\n params.require(:question_pet).permit(:pet_id, :text)\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 new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end", "def pet_params\n params.fetch(:pet, {})\n end", "def pet_item_params\n params.require(:pet_item).permit(:pet_id)\n end", "def create\n dive = Dive.new(dive_params)\n if dive.save\n render json: dive\n else\n render json: {message: dive.errors}, status: 400\n end\n end", "def prepare_pet(pet_api)\n pet_id = random_id\n category = Petstore::Category.new('id' => 20002, 'name' => 'category test')\n tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test')\n pet = Petstore::Pet.new('id' => pet_id, 'name' => \"RUBY UNIT TESTING\", 'photo_urls' => 'photo url',\n 'category' => category, 'tags' => [tag], 'status' => 'pending')\n pet_api.add_pet(pet)\n return pet_id\nend", "def create\n @puppy = Puppy.new(puppy_params)\n\n respond_to do |format|\n if @puppy.save\n format.html { redirect_to @puppy, notice: 'Puppy was successfully created.' }\n format.json { render :show, status: :created, location: @puppy }\n else\n format.html { render :new }\n format.json { render json: @puppy.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_all_the_dogs_are_in_one_pack\n @params = {\n packs: [\n {\n dogs: ['Spot', 'Fido', 'Rover'],\n location: 'San Francisco',\n },\n {\n dogs: ['Doggie', 'Lassie'],\n location: 'Canada',\n },\n ],\n }\n\n\n post \"/dogs\", params = @params\n assert_equal 'Spot, Fido, Rover, Doggie, and Lassie are all in one pack. Oh no!', last_response.body\n end", "def create\n @poke = Poke.new(poke_params)\n\n respond_to do |format|\n if @poke.save\n format.html { redirect_to @poke, notice: 'Poke was successfully created.' }\n format.json { render :show, status: :created, location: @poke }\n else\n format.html { render :new }\n format.json { render json: @poke.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @animal = @shelter.animals.build(animal_params)\n respond_with(@shelter)\n end", "def adopted_pet_params\n params.require(:adopted_pet).permit(:pet_id)\n end", "def create_params\n params.permit(user: [:pet_id])\n end", "def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end", "def create\n @pokemon = Pokemon.new(pokemon_info)\n \n #check if the pokemon was saved\n #everything went fine\n if @pokemon.save\n render json:{\n status: \"success\",\n message: \"Pokemon was saved, and sent to the PC Storage\",\n data: @pokemon \n }\n else\n render json:{\n status: \"error\",\n message: \"Pokemon ran away...\",\n data: @pokemon.errors\n } \n\n \n end \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 @petition = Petition.new(params[:petition])\n\n respond_to do |format|\n if @petition.save\n format.html { redirect_to @petition, notice: 'Petition was successfully created.' }\n format.json { render json: @petition, status: :created, location: @petition }\n else\n format.html { render action: \"new\" }\n format.json { render json: @petition.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_add(client_id)\n name = @prompt.ask(\"Pet Name?\") do |q|\n # error handling requiring input\n q.required true\n q.validate /[a-z]+/\n # error handling message\n q.messages[:valid?] = \"Name need to start with a letter.\"\n q.messages[:required?] = \"Required pet name\"\n q.modify :capitalize\n end\n\n age = @prompt.ask(\"Pet Age?\", convert: :integer) do |q|\n # error handling requiring input\n q.required true\n # error handling message\n q.messages[:required?] = \"Required pet age\"\n q.messages[:convert?] = \"Age has to be a number\"\n end\n\n # option to choose between cat and dog (animal type)\n type = @prompt.select(\"Pet type? \", [\n {name: \"#{@emoji[:smiling_cat_face_with_open_mouth]} Cat\", value: \"Cat\"},\n {name: \"#{@emoji[:dog_face]} Dog\", value: \"Dog\"},\n ])\n\n observations = @prompt.ask(\"Observations: \") do |q|\n q.modify :capitalize\n end\n \n new_id = @db.get_new_id(\"pets\")\n pet = Pet.new(new_id, name, age, type, observations, client_id)\n \n @db.add(\"pets\", pet)\n end", "def create\n @pet = Pet.new(pet_params)\n @pet.user = current_user\n @pet.health = 100\n @pet.clean = 100\n @pet.mood = 100\n @pet.status = true # Not Sick\n @pet.strength = rand(0...100)\n @pet.defense = rand(0...100)\n @pet.age = Time.now\n\n if Time.now > (Time.parse \"8:00 am\")\n if Time.now < (Time.parse \"8:00 pm\")\n @pet.asleep = false\n else\n @pet.asleep = true\n end\n else\n @pet.asleep = true\n end\n\n respond_to do |format|\n if @pet.save\n format.html { redirect_to @pet, notice: 'Your pet ' + @pet.name + ' was born!' }\n format.json { render :show, status: :created, location: @pet }\n else\n format.html { render :new }\n format.json { render json: @pet.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 sit_pet_params\n params.require(:sit_pet).permit(:pet_kind, :breed, :size, :user_id)\n end", "def set_pet\n @pet = params[:id] ? Pet.find(params[:id]) : Pet.new\n end", "def create\n @petition = Petition.new(petition_params)\n\n respond_to do |format|\n if @petition.save\n format.html { redirect_to @petition, notice: 'Petition was successfully created.' }\n format.json { render :show, status: :created, location: @petition }\n else\n format.html { render :new }\n format.json { render json: @petition.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pokemon = Pokemon.new(pokemon_params)\n\n respond_to do |format|\n if @pokemon.save\n format.html { redirect_to @pokemon, notice: 'Pokemon was successfully created.' }\n format.json { render :show, status: :created, location: @pokemon }\n else\n format.html { render :new }\n format.json { render json: @pokemon.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_params\n params.require(:pet).permit(:name, :picture, :max_weight)\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" ]
[ "0.7303997", "0.7081908", "0.7000595", "0.6952367", "0.68931097", "0.6804849", "0.6789769", "0.6748069", "0.6664846", "0.66344166", "0.6613724", "0.65952945", "0.6573272", "0.6449908", "0.64429986", "0.64418715", "0.6437518", "0.64174235", "0.6417186", "0.6385124", "0.63812435", "0.63778245", "0.634393", "0.6329564", "0.63255626", "0.6324972", "0.6301884", "0.6282331", "0.6251503", "0.6250378", "0.6241996", "0.62408876", "0.622892", "0.6228394", "0.62160105", "0.62133455", "0.6206123", "0.6204976", "0.6201753", "0.61939704", "0.619102", "0.61893976", "0.6164527", "0.6157699", "0.61529243", "0.6152788", "0.61317176", "0.61099803", "0.6104427", "0.61002994", "0.6078643", "0.6074737", "0.60648894", "0.6063761", "0.60386", "0.6029947", "0.60085183", "0.60040367", "0.59966147", "0.59761465", "0.59734803", "0.596305", "0.5948492", "0.59405506", "0.5930962", "0.59148425", "0.5906766", "0.5892311", "0.5882417", "0.5880871", "0.5873497", "0.5833719", "0.5818248", "0.58078206", "0.5785746", "0.5775635", "0.57755613", "0.57719797", "0.5763049", "0.5754444", "0.5744153", "0.5744028", "0.5738897", "0.57379085", "0.5734995", "0.5723776", "0.5696599", "0.56943095", "0.5692312", "0.56920123", "0.5688308", "0.5684619", "0.56813824", "0.56636876", "0.565539", "0.5647957", "0.5639789", "0.56372213", "0.562707", "0.5619821" ]
0.6113706
47
PUT /pets/1 PUT /pets/1.json
def update @pet = Pet.find(params[:id]) respond_to do |format| if @pet.update_attributes(params[:pet]) format.html { redirect_to root_path, notice: 'Pet was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @pet.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n if @pet.update_attributes(params[:pet])\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n if @pet.update_attributes(params[:pet])\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render json: {\"message\" => \"Pet was successfully updated\", \"success\" => true, \"data\" => @pet}, status: :created, location: @pet }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pet.update(pet_params)\n redirect_to \"/pets/#{pet_id}\"\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: I18n.t(\"pets.show.updated\") }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # find_pet\n @pet.update(pet_params)\n redirect_to pet_path(@pet)\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Mascota fue actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: I18n.t('Pet card was successfully updated') }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def prepare_pet\n # remove the pet\n SwaggerClient::PetApi.delete_pet(10002)\n # recreate the pet\n pet = SwaggerClient::Pet.new('id' => 10002, 'name' => \"RUBY UNIT TESTING\")\n SwaggerClient::PetApi.add_pet(:body => pet)\nend", "def update_pet_with_http_info(pet, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.update_pet ...'\n end\n # verify the required parameter 'pet' is set\n if @api_client.config.client_side_validation && pet.nil?\n fail ArgumentError, \"Missing the required parameter 'pet' when calling PetApi.update_pet\"\n end\n # resource path\n local_var_path = '/pet'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/xml'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(pet)\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.update_pet\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PetApi#update_pet\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to @pet, notice: 'Has registrado a tu mascota' }\n format.json { render :show, status: :ok, location: @pet }\n else\n format.html { render :edit }\n format.json { render json: @pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end", "def update\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n if @pet.update_attributes(params[:pet])\n flash[:notice] = 'Pet was successfully updated.'\n format.html { redirect_to(@pet) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @pet.errors, :lost => :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request(:put, *args)\n end", "def update\n @petdetail = Petdetail.find(params[:id])\n\n respond_to do |format|\n if @petdetail.update_attributes(params[:petdetail])\n format.html { redirect_to @petdetail, notice: 'Petdetail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @petdetail.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question_pet.update(question_pet_params)\n format.html { redirect_to @question_pet, notice: 'Question pet was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_pet }\n else\n format.html { render :edit }\n format.json { render json: @question_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n animal = Animal.find(params[:id])\n\n if validate_params(animal_params)\n animal.update(animal_params)\n render json: animal, status: 200, location: [:api, animal]\n else\n render json: { errors: animal.errors }, status: 422\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n if @pet.update(pet_params)\n redirect_to owner_pets_url(@pet.owner), notice: 'Pet was successfully updated.'\n else\n render :edit\n end\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def set_pet\n @pet = Pet.find(params[:id])\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @pet_item.update(pet_item_params)\n format.html { redirect_to @pet_item, notice: 'Pet item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pet_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def atualiza_um_pet_existente(objeto)\n uri = \"#{ENV['BASE_URI']}/pet\"\n \n without_authentication('put', uri, objeto.to_json)\n end", "def update\n respond_to do |format|\n if @pet_true.update(pet_true_params)\n format.html { redirect_to @pet_true, notice: 'Pet true was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pet_true.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(url, body = {})\n call(url: url, action: :put, body: body)\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 set_pet\n @pet = params[:id] ? Pet.find(params[:id]) : Pet.new\n end", "def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n @lost_pet = LostPet.find(params[:id])\n\n respond_to do |format|\n if @lost_pet.update_attributes(params[:lost_pet])\n format.html { redirect_to @lost_pet, notice: 'Lost pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lost_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @pet.update(pet_params)\n redirect_to pets_path, success: 'Votre animal a bien été modifié'\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @adopted_pet.update(adopted_pet_params)\n format.html { redirect_to @adopted_pet, notice: 'Adopted pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @adopted_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @adopted_pet.update(adopted_pet_params)\n format.html { redirect_to @adopted_pet, notice: 'Adopted pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @adopted_pet.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 put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end", "def set_pet\n @pet = Pet.find_by!(id: params[:pet_id])\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 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 put endpoint, data\n do_request :put, endpoint, data\n end", "def create_method\n :put_json\n end", "def update\n @client = Client.find params[:client_id]\n respond_to do |format|\n if @pet.update(pet_params)\n format.html { redirect_to client_pet_path(@client,@pet), notice: 'Datos de mascota actualizados.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n put :update\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end", "def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\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 @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, options={})\n request :put, path, options\n end", "def put(path, opts = {})\n request(:put, path, opts).body\n end", "def update\n if @diet.update(diet_params)\n head :no_content, status: 204\n else\n render json: @diet.errors, status: 422\n end\n end", "def update\n animal = Animal.find(params[:id])\n animal.update(animal_params)\n if animal.valid?\n render json: animal\n else\n render json: animal.errors\n end\n end", "def update\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n if @vet.update_attributes(params[:vet])\n format.html { redirect_to @vet, notice: 'Vet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_pet\n @pet = current_user.pets.find(params[:id])\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def put(path, params = {})\n request(:put, path, params)\n end", "def update\n respond_to do |format|\n if @typeofpet.update(typeofpet_params)\n format.html { redirect_to @typeofpet, notice: 'Typeofpet was successfully updated.' }\n format.json { render :show, status: :ok, location: @typeofpet }\n else\n format.html { render :edit }\n format.json { render json: @typeofpet.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 @line_pet.update(line_pet_params)\n format.html { redirect_to @line_pet, notice: 'Line pet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @line_pet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_pet(pet, opts = {})\n update_pet_with_http_info(pet, opts)\n nil\n end", "def pet_params\n params.require(:pet).permit(:id, :name, :img_url, :about, :user_id)\n end", "def update\n tag = Tag.find_by_id(params[:id])\n if tag.update(params.permit(:name))\n render json: tag, status: :ok\n else\n respond_with tag.errors, status: :unprocessable_entity\n end\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def put(path, params={})\n request(:put, path, params)\n end", "def put(path, params={})\n request(:put, path, params)\n end" ]
[ "0.66811895", "0.66649413", "0.6663732", "0.66373914", "0.66149145", "0.6559485", "0.6559485", "0.6559485", "0.6559485", "0.6559485", "0.6559485", "0.65266526", "0.65131277", "0.63891435", "0.63477635", "0.6334447", "0.6322319", "0.6314258", "0.6288815", "0.62430245", "0.6216046", "0.621439", "0.61898464", "0.61877394", "0.617232", "0.614936", "0.6123581", "0.6091936", "0.6088591", "0.60730064", "0.60730064", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.60582376", "0.6003918", "0.60038996", "0.6001843", "0.5979833", "0.5978806", "0.5956442", "0.5953565", "0.5948892", "0.594564", "0.59442484", "0.5936809", "0.59367394", "0.59367394", "0.5926387", "0.5924298", "0.5909859", "0.58929783", "0.5890109", "0.5890107", "0.5886296", "0.5882471", "0.587409", "0.58515203", "0.58478546", "0.5826357", "0.58231807", "0.5807418", "0.5807418", "0.5807418", "0.57915", "0.57792854", "0.57770735", "0.5762569", "0.5759866", "0.5752977", "0.57514906", "0.5746021", "0.57441247", "0.57441247", "0.5740968", "0.5725429", "0.5721903", "0.5721369", "0.57162225", "0.5713376", "0.5708554", "0.5708554", "0.57000726", "0.57000726" ]
0.6643125
3
DELETE /pets/1 DELETE /pets/1.json
def destroy @pet = Pet.find(params[:id]) @pet.destroy respond_to do |format| format.html { redirect_to pets_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n pet = @user.pets.find(params[:id])\n pet.destroy\n render json: pet\n end", "def pet_delete(pet)\n @db.delete(\"pets\", pet[\"id\"])\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: I18n.t(\"pets.index.destroyed\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet = Pet.find(params[:id])\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to(pets_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @line_pet.destroy\n respond_to do |format|\n format.html { redirect_to line_pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n head 204\n end", "def destroy\n @petdetail = Petdetail.find(params[:id])\n @petdetail.destroy\n\n respond_to do |format|\n format.html { redirect_to petdetails_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to users_path, notice: 'Pet was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Has dado de baja a tu mascota' }\n format.json { head :no_content }\n end\n end", "def destroy\n @adopted_pet.destroy\n respond_to do |format|\n format.html { redirect_to adopted_pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adopted_pet.destroy\n respond_to do |format|\n format.html { redirect_to adopted_pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n\n respond_to do |format|\n format.html { redirect_to person_path(@person), notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet_item.destroy\n respond_to do |format|\n format.html { redirect_to pet_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet_true.destroy\n respond_to do |format|\n format.html { redirect_to pet_trues_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n redirect_to \"/pets\"\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.html { redirect(person_animals_url, :delete, 'animal') }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal.destroy\n\n respond_to do |format|\n format.html { redirect_to animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find params[:client_id]\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to client_pets_path(@client), notice: 'Mascota eliminada... Todos los perritos van al cielo' }\n end\n end", "def destroy\n @lost_pet = LostPet.find(params[:id])\n @lost_pet.destroy\n\n respond_to do |format|\n format.html { redirect_to lost_pets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @typeofpet.destroy\n respond_to do |format|\n format.html { redirect_to typeofpets_url, notice: 'Typeofpet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @diet.destroy\n head :no_content, status: 200\n else\n render json: @diet.errors, status: 405\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\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 @pet.destroy\n respond_to do |format|\n format.html { redirect_to pets_url, notice: 'Publicación eliminada correctamente.' }\n format.json { head :no_content }\n format.js\n end\n end", "def deleta_pet(pet_id)\n uri = \"#{ENV['BASE_URI']}/pet/#{pet_id}\"\n\n without_authentication('delete', uri)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @question_pet.destroy\n respond_to do |format|\n format.html { redirect_to question_pets_url, notice: 'Question pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @postulation_pet.destroy\n respond_to do |format|\n format.html { redirect_to my_postulations_path, notice: 'Postulation pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete\n request(:delete)\n end", "def destroy\n @vet = Vet.find(params[:id])\n @vet.destroy\n\n respond_to do |format|\n format.html { redirect_to vets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @pet.destroy\n redirect_to pets_path\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @animal = Animal.find(params[:id])\n @animal.destroy\n\n respond_to do |format|\n format.html { redirect_to zoo_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to @user, notice: I18n.t('Pet card was successfully destroyed') }\n format.json { head :no_content }\n end\n end", "def destroy\n session[:pet_id] = nil\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to @user, notice: 'Pet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pet_breed.destroy\n respond_to do |format|\n format.html { redirect_to pet_type_path(@pet_breed.pet_type), notice: 'Pet breed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dog = Dog::Dog.find(params[:id])\n @dog.destroy\n\n respond_to do |format|\n format.html { redirect_to dog_dogs_url }\n format.json { head :ok }\n end\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @animal = Animal.find(params[:id])\n @animal.destroy\n render json: { message: \"Congrats youve won\"}\n end", "def destroy\n @pet_breed.destroy\n respond_to do |format|\n format.html { redirect_to pet_breeds_url, notice: 'Pet breed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @diet.destroy\n respond_to do |format|\n format.html { redirect_to diets_url, notice: 'Diet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tags_of_novel = TagsOfNovel.find(params[:id])\n @tags_of_novel.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_of_novels_url }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def destroy\n animal = Animal.find(params[:id])\n if animal.destroy\n render json: animal\n else\n render json: animal.errors\n end\n end", "def destroy\n @petprofile.destroy\n respond_to do |format|\n format.html { redirect_to petprofiles_url, notice: 'Petprofile was successfully destroyed.' }\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 @peticion.destroy\n respond_to do |format|\n format.html { redirect_to peticions_url, notice: 'Peticion was successfully destroyed.' }\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 @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @puppy_dog_two.destroy\n respond_to do |format|\n format.html { redirect_to puppy_dog_twos_url, notice: 'Puppy dog two was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @adopcion = Adoption.find(@pet.adoptions_id)\n\n @pet.destroy\n respond_to do |format|\n format.html { redirect_to admin_pets_path, notice: 'La mascota fue eliminada exitosamente.' }\n format.json { head :no_content }\n end\n\n @adopcion.destroy\n\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 @competent = Competent.find(params[:id])\n @competent.destroy\n\n respond_to do |format|\n format.html { redirect_to competents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal = Animal.find(params[:id])\n @animal.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Animal was successfully deleted from database.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dog.destroy\n respond_to do |format|\n format.html { redirect_to dogs_url, notice: 'Dog was successfully removed' }\n format.json { head :no_content }\n end\n end", "def destroy\n @custom_pet_template.destroy\n respond_to do |format|\n format.html { redirect_to custom_pet_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n respond_to do |format|\n format.json { render json: {}, status: :ok }\n end\n end", "def destroy\n @diet_type.destroy\n respond_to do |format|\n format.html { redirect_to diet_types_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\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n\n if @diet.nil?\n send_error_json(nil, \"Failed to delete\", 400)\n return\n end\n\n if @diet.destroy\n send_success_json(@diet.id, { diet_name: @diet.diet_name})\n else\n send_error_json(@diet.id, \"Delete error\", 400)\n end\n\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @animal = Animal.find(params[:id])\n @animal.destroy\n # respond_to do |format|\n # formal.html { redirect_to animals_url, notice: \"Animal was successfully removed.\"}\n # format.json { head :no_content}\n # end\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.html { redirect_to animals_url, notice: \"Animal was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.html { redirect_to animals_url, notice: \"Animal was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.html { redirect_to animals_url, notice: 'Animal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @animal.destroy\n respond_to do |format|\n format.html { redirect_to animals_url, notice: 'Animal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n animal = Animal.find(params[:id])\n animal.destroy\n if animal.valid?\n render json: animal\n else\n render json: animal.errors\n end\n end", "def destroy\n @dart = Dart.find(params[:id])\n @dart.destroy\n\n respond_to do |format|\n format.html { redirect_to darts_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def destroy\n @client = Client.find params[:client_id]\n @pet = Pet.find params[:pet_id]\n @pet_history.destroy\n \n respond_to do |format|\n format.html { redirect_to client_pet_pet_histories_path(@client,@pet), notice: 'Control eliminado... no ha quedado evidencia alguna' }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n @api_v1_post_vote = PostVote.find(params[:id])\n @api_v1_post_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_post_votes_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 @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 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 @vet.destroy\n respond_to do |format|\n format.html { redirect_to vets_url, notice: 'Vet 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 delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end", "def soccer_delete\n base_delete(params, \"Soccer\")\n end", "def destroy\n @Love = Love.find(params[:id])\n @Love.destroy\n\n respond_to do |format|\n format.html { redirect_to loves_url }\n format.json { head :ok }\n end\n end", "def destroy\n @petition = Petition.find(params[:id])\n @petition.destroy\n\n respond_to do |format|\n format.html { redirect_to petitions_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.76552933", "0.76330024", "0.7302086", "0.7267687", "0.7248253", "0.72239506", "0.721972", "0.72023845", "0.72023845", "0.72023845", "0.72023845", "0.72023845", "0.71824735", "0.7175317", "0.7128093", "0.7128093", "0.7124565", "0.7117816", "0.7114961", "0.70514756", "0.70454204", "0.7042455", "0.6987198", "0.69527864", "0.69471693", "0.69452167", "0.6944163", "0.69342446", "0.69131285", "0.6899794", "0.6883305", "0.6848241", "0.68448704", "0.6828139", "0.6823597", "0.68180025", "0.6800069", "0.6797093", "0.67765903", "0.67565936", "0.6755552", "0.6755552", "0.6741928", "0.67291975", "0.6728329", "0.67258894", "0.6715318", "0.6710058", "0.6709622", "0.6702887", "0.66994333", "0.6683136", "0.66774726", "0.66749823", "0.6649015", "0.6643763", "0.6643636", "0.6640267", "0.6638449", "0.66301143", "0.6620687", "0.6620101", "0.661939", "0.66187567", "0.66187567", "0.66186875", "0.66159755", "0.66065615", "0.66050804", "0.66044813", "0.66014266", "0.660108", "0.660108", "0.6600033", "0.65961325", "0.65958893", "0.65929407", "0.6591946", "0.6591946", "0.65884244", "0.65884244", "0.6587372", "0.6583986", "0.6572442", "0.65702564", "0.6568631", "0.6568264", "0.6560999", "0.65588045", "0.6557603", "0.6557603", "0.655744", "0.65564257", "0.6555721", "0.6554221", "0.6550207", "0.65493256", "0.6547224" ]
0.750838
3
validates :name, presence: true
def index @patrons = Patron.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_is_valid\n errors.add(:name,'Invalid empty string for name.') unless name_is_valid?\n end", "def name_present\n if name.blank?\n errors.add(:name, \"Can't be empty\")\n end\n end", "def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end", "def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n end\n end", "def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end", "def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end", "def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n else\n return false\n end\n end", "def validateName(name)\n if (name == nil)\n return false\n end\n \n return true # TODO This is wrong. Finish this function.\nend", "def name_not_blank\n if self.name.blank?\n self.errors.add(:name, I18n.t('stage.errors.blank_name'))\n end\n end", "def validate_name?\n # if you create user from admin interface(or as a team member), then \"name\" param is provided, it is present or blank - not nil\n !name.nil?\n end", "def validate_name\n if third_party && name.blank?\n errors.add(\n :name,\n :blank,\n )\n end\n end", "def valid?\n !name.nil?\n end", "def valid?\n !name.nil?\n end", "def valid?\n !name.nil?\n end", "def validate\n validates_presence([:name, :phone])\n end", "def check_create_user_name_is_valid\n return self.name != \"\" ? true : false\n end", "def validate_name\n unless name.length > 0\n add_error :name, 'name of the price item shall be provided'\n end\n\n unless price.to_i > 0\n add_error :price, 'price should be a number'\n end\n end", "def valid_name!\n return unless @name.blank?\n\n @success = false\n @error = 'Error: site name must be present'\n end", "def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end", "def validate_name\n\t\t\tunless Nacreon::NameRX.match(name)\n\t\t\t\terrors.add(:name,\n\t\t\t\t\t'must contain only letters, numbers, and \"-\".')\n\t\t\tend\n\t\tend", "def test_should_require_name\n intitution = create(:name => nil)\n assert intitution.errors.invalid?(:name), \":name should be required\"\n assert_invalid intitution, \"intitution shouldn't be created\"\n end", "def valid?\n valid = true\n\n if self.name.nil? || self.name == \"\"\n valid = false\n end\n\n return valid\n end", "def name?\n if name.nil?\n errors.add(:name, \"can't be blank\")\n return false\n end\n return true\n end", "def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end", "def test_presence_of_name\n client = Client.new(:tat => 13, :partener_bank_group_code => 'HJ',\n :internal_tat => 89, :group_code => 'JO',:max_jobs_per_user_payer_wise => 5,\n :max_jobs_per_user_client_wise => 5, :max_eobs_per_job => 5)\n assert_equal(false, client.save, \"Name can't be blank!\")\n end", "def validated?(name)\n true\n end", "def name_invalid\n errors.add(:name, :unknown)\n end", "def test_career_has_name_validator\n\t\t# Arrange\n\t\tcareer = Career.new\n\n\n\t\t# Act\n\t\tcareer.name = ''\n\n\t\t# Assert\n\t\tassert_equal career.valid?, false\n\tend", "def valid_name (name)\r\n /^\\w+$/.match (name)\r\n end", "def validate_name(value)\n return false if(value.to_s.length >= MAX_NAME_LENGTH)\n return true\n end", "def your_name_is_not_dumb\n if name.include?(\"dumb\")\n errors.add(:name, \"is dumb\")\n end\n end", "def valid?\n return false if @name.nil?\n return true\n end", "def name_valid?(name)\n name.nil? || /^[A-Za-z]{2,}$/.match?(name)\n end", "def name_present?\n name.present?\n end", "def validate_name\n errors.add(:abstract, \"person_name or company_name must be present\") unless (person_name || company_name)\n end", "def validate_presence(attribute_name, message = nil)\n value = send(attribute_name)\n if !value || value.to_s.empty?\n append_error(attribute_name, message || :cant_be_empty)\n end\n end", "def validate_name(name)\n !name.scan(/\\D/).empty?\n end", "def _validate_name(name)\n if name =~ %r{/}\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'a slash.')\n end\n\n if name =~ /\\s/\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'whitespace.')\n end\n\n if name[0, 1] == '.'\n results.add_error('name', 'The name of a spec should not begin' \\\n ' with a period.')\n end\n end", "def empty_name_error(type, what)\n validation_error(type, what, 'name is empty')\n end", "def names_valid?\n return nil unless AccountType.individual?(account_type)\n\n errors.add(:forename, :cant_be_blank) if forename.to_s.empty?\n errors.add(:surname, :cant_be_blank) if surname.to_s.empty?\n names_length_valid?\n end", "def required?(name); end", "def valid_name!(name)\n not_empty!(name)\n unless [String, Symbol].include?(name.class)\n coercion_error!\n end\n name\n end", "def valid_name?(name)\n !!(name =~ NAME_REGEX)\n end", "def valid?\n return false if [email protected]? && @name.to_s.length > 250\n true\n end", "def validate()\n errors.add(:nombre, \"debe ser positivo\") if nombre.nil?\n end", "def validate_display_name\nif ! validate_a_display_name( self.display_name )\nerrors.add( :display_name , \"Invalid display name (see RFC 3261).\" )\nend\nend", "def name_params\n params.require(:name).permit(:name)\n end", "def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end", "def name_can_not_be_greg\n if self && self.name.downcase == \"greg\"\n self.errors.add(:name, \"Can not be Greg\")\n end \n end", "def validate_name(arg = nil)\n set_or_return(:name, arg, :kind_of => String, :callbacks => {\n \"user must be string of word characters and Engine ID should be either empty string or 5 to 32 octets separated by colons\" => lambda {\n |name| !@@title_pattern.match(name).nil?\n }\n })\n end", "def check_presence!(obj, name)\n if obj.nil? || (obj.is_a?(String) && obj.empty?)\n fail ArgumentError, \"#{name} must be given\"\n end\n end", "def first_name_is_valid\n errors.add(:first_name,'Invalid empty string for first name.') unless first_name_is_valid?\n end", "def validate_name_and_entity_id\n @patient.valid?\n #@patient.errors.add(:entity_id, I18n.t('patients.create.no_entity')) if @patient.new_record? && [email protected]_id.present?\n @patient.errors.add(:name, I18n.t('patients.create.no_name')) unless @patient.name.present?\n @patient.errors.empty?\n end", "def is_valid_name(name)\n return false if name.split.length < 2\n name == format_name(name)\nend", "def check_presence!(obj, name)\n if obj.nil? || (obj.is_a?(String) && obj.empty?)\n raise ArgumentError, \"#{name} must be given\"\n end\n end", "def check_presence!(obj, name)\n if obj.nil? || (obj.is_a?(String) && obj.empty?)\n raise ArgumentError, \"#{name} must be given\"\n end\n end", "def validate_name(arg=nil)\n set_or_return(:name, arg, kind_of: String, callbacks: {\n 'user must be string of word characters and ' \\\n 'Engine ID should be either empty string or ' \\\n '5 to 32 octets separated by colons' => lambda do |name|\n !@@title_pattern.match(name).nil?\n end,\n })\n end", "def validate_name_and_url\n # check name and url_safe_name first and set validation error\n if self.name.blank? || self.name.nil?\n errors.add(:name, \" cannot be blank - please provide a name for your study.\")\n end\n if Study.where(name: self.name).any?\n errors.add(:name, \": #{self.name} has already been taken. Please choose another name.\")\n end\n if Study.where(url_safe_name: self.url_safe_name).any?\n errors.add(:url_safe_name, \": The name you provided (#{self.name}) tried to create a public URL (#{self.url_safe_name}) that is already assigned. Please rename your study to a different value.\")\n end\n end", "def name_legal?\n if @params\n if self.name.include?(\"\\\\\") or self.name.include?(\"/\")\n errors.add(\"Invalid name:\", \"Slashes not allowed in names.\")\n elsif self.name == \"\"\n errors.add(\"Invalid name:\", \"No name provided.\")\n end\n end\n end", "def test_should_require_name\n archive = create(:name => nil)\n assert archive.errors.invalid?(:name), \":name should be required\"\n assert_invalid archive, \"archive shouldn't be created\"\n end", "def validate_attributes!(attributes)\n return missing_required unless attributes.key?(:name)\n return missing_required unless defined_value?(attributes[:name])\n\n true\n end", "def name=(name)\n if name == \"\"\n raise \"Name cannot be blank!\"\n else\n @name = name\n end\n end", "def check_name_length\n unless self.name.length >= 4\n errors[:name] << \"Name is too short, must be 4+ characters\"\n end\n end", "def validates_presence_of_final_calculation_prerequisite(name)\n return unless validators_on(name).empty?\n validates_presence_of name\n end", "def first_name_is_valid?\n return false unless not_nil_and_string(self.first_name)\n return self.first_name.length > 0\n end", "def empty_name?\n if @name.empty?\n print 'You need to pass a name: '\n @name = gets.chomp\n empty_name?\n end\n\n false\n end", "def full_name_format\n valid_full_name = true\n\n if !self.name.nil?\n # Must contains white space\n valid_full_name = false if (/^(.*\\s+.*)+$/i =~ self.name).nil?\n # Must be alpha\n valid_full_name = false if(/^[A-Z]+$/i =~ self.name.remove(' ')).nil?\n else\n valid_full_name = false\n end\n\n if !valid_full_name\n self.errors.add(:name, 'deve ser Completo')\n raise ActiveRecord::Rollback\n end\n end", "def valid?\n self.name.match(/^[a-zA-Z0-9_]+$/) ? true : false\n end", "def test_validate\n naming = Naming.new\n assert_not(naming.save)\n assert_equal(3, naming.errors.count)\n assert_equal(:validate_naming_name_missing.t, naming.errors[:name].first)\n assert_equal(:validate_naming_observation_missing.t,\n naming.errors[:observation].first)\n assert_equal(:validate_naming_user_missing.t, naming.errors[:user].first)\n end", "def valid_name?(nm)\n\t\treturn false unless (nm =~ VALID_NAME)\n\t\ttrue\n\tend", "def is_valid_name?(name)\n return name.class == String && name.match(/[a-zA-Z]+?/)\n end", "def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end", "def name_check(name)\n if name.nil? or name.empty? or name =~ /\\W+/ or name == \"0\"\n\n #raise an error in case of invalid input\n raise ArgumentError.new(\"Error - invalid name\")\n end\n #capitalize the first letter of the name\n name = name.capitalize\n end", "def valid_attributes\n { name: 'do this' }\n end", "def validate\n errors.add(:username, \"already exists.\") if Player.get_player(username) != nil\n end", "def validation_name\n @company = Company.accessible_by(current_ability).where(:name => params[:name]).first\n\n if @company\n render json: false\n else\n render json: true\n end\n end", "def is_valid_name(str)\n return str.include?(\" \") && format_name(str) == str\nend", "def last_name_is_valid\n errors.add(:last_name,'Invalid empty string for last name.') unless last_name_is_valid?\n end", "def name_valid?\n\t\tif self.name == nil\n\t\t\treturn false\n\t\telsif VALID_NAME_REGEX !~ self.name || self.name.empty? || self.name.length > MAX_CREDENTIAL_LENGTH\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend", "def name?\n @name.is_a?(String) && [email protected]?\n end", "def assert_name(name=nil)\n if name && (self.pre_registered? || self.creation_pending?) && name != email\n self.name = name\n save!\n end\n self\n end", "def valid_attributes\n {name: \"Businesses\"}\n end", "def name?\n [email protected]?\n end", "def validate_name(name)\n return if name =~ /\\A[a-z0-9]+[-\\/][a-z][a-z0-9_]*\\Z/i\n\n namespace, modname = name.split(/[-\\/]/, 2)\n modname = :namespace_missing if namespace == ''\n\n err = case modname\n when nil, '', :namespace_missing\n \"the field must be a namespaced module name\"\n when /[^a-z0-9_]/i\n \"the module name contains non-alphanumeric (or underscore) characters\"\n when /^[^a-z]/i\n \"the module name must begin with a letter\"\n else\n \"the namespace contains non-alphanumeric characters\"\n end\n\n raise ArgumentError, \"Invalid 'name' field in metadata.json: #{err}\"\n end", "def name=(name)\n if name == \"\"\n raise \"name cannot be blank\"\n end\n @name = name\n end", "def file_name_exist?(name)\n return true if !name.blank?\n errors.add(:name, \"Nazwa nie moze byc pusta!\")\n false\n end", "def test_should_require_name\n ng = NodeGroup.create(:name => nil)\n assert ng.errors.on(:name)\n end", "def validate\n if @name.empty?\n @message = \"Please input a username.\"\n elsif @password.empty?\n @message = \"Please input a password.\"\n elsif @names.include?(@name) == false\n @message = \"That username does not exist. Please make sure to check your spelling.\"\n elsif @names.include?(@password) == false\n @message = \"Wrong password. Please check your spelling and try again.\"\n elsif @names.include?(@name) && @names.include?(@password)\n @message = \"Welcome {@name}\"\n end\n end", "def validate_name\n if name.match(/\\|/)\n errors.add(:name, \"cannot have a '|' character\")\n end\n end", "def name_is_unique\n return if self.name.nil?\n errors.add(:name, 'has already been taken') if Institution.where(name: self.name).reject{|r| r == self}.any?\n end", "def names_length_valid?\n errors.add(:forename, :too_long, count: 50) if forename.length > 50\n errors.add(:surname, :too_long, count: 100) if surname.length > 100\n end", "def empty?\n name.blank?\n end", "def after_save\n validate_uniqueness_as_run(:name)\n end", "def name=(value)\n if value == \"\"\n raise \"Name cannot be blank!\"\n elsif value.is_a? Integer\n raise \"Name cannot contain numbers!\"\n else\n if value.is_a? String\n @name = value\n end\n end\n end", "def is_validated\n\tif $user_name.size <= 1 #string have \\n \n\t\tre_enter_name\n\telse\n\t\treturn true;\t\n\tend\t\nend", "def name_unique_in_clinic\n errors.add(:name, \"Name: #{name} already in use\") unless\n name_unique_in_clinic?\n end", "def test_schools_must_have_names\n s = School.new()\n refute s.save\n end", "def create\n @name = Name.new(name_params)\n if @name.save\n flash[:notice] = \"Saved successfully.\"\n else\n flash[:error] = \"Not saved.\"\n redirect_to :back\n end\n end", "def test_should_require_name_group\n group = create(:name => nil)\n assert group.errors.invalid?(:name), \":name should be required\"\n assert_invalid group, \"group shouldn't be created\"\n end", "def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_participating\" and [\"event\",\"class\",\"game\", \"offering_session\", \"personal_trainer\", \"group_training\"].include? name.underscore\n\t\tend", "def name_params\n params.require(:name).permit(:title, :subtitle)\n end" ]
[ "0.85423356", "0.85312206", "0.8309702", "0.80220187", "0.79651934", "0.79651934", "0.79517025", "0.78527737", "0.7687741", "0.76870894", "0.7671357", "0.7638802", "0.7638802", "0.7638802", "0.76169115", "0.75806874", "0.75749415", "0.749427", "0.7447472", "0.74231964", "0.73716664", "0.73695487", "0.7315406", "0.730295", "0.7287202", "0.7258515", "0.72581017", "0.7250372", "0.72391707", "0.7181529", "0.7168913", "0.71456933", "0.714257", "0.7136518", "0.71297604", "0.7084499", "0.7079994", "0.70544684", "0.70436007", "0.70196867", "0.701257", "0.69596237", "0.6946661", "0.69386846", "0.6936578", "0.6908342", "0.68660074", "0.68582445", "0.6850349", "0.68412715", "0.68331647", "0.6827399", "0.6818295", "0.6810905", "0.6804922", "0.67957777", "0.67949474", "0.67887175", "0.6772059", "0.6770116", "0.6761893", "0.6730616", "0.6696296", "0.6671314", "0.6636682", "0.66284084", "0.66222477", "0.66171485", "0.6610324", "0.6601378", "0.6587737", "0.6584978", "0.6584978", "0.6577393", "0.6565692", "0.65593755", "0.65473217", "0.6542753", "0.652937", "0.6517315", "0.65080416", "0.65046895", "0.64922523", "0.64835185", "0.6459996", "0.6458161", "0.6457343", "0.6450457", "0.6450085", "0.6449921", "0.6435275", "0.64297247", "0.6404922", "0.6404858", "0.6404504", "0.6403901", "0.6394726", "0.638933", "0.63819", "0.6378264", "0.634735" ]
0.0
-1
Generate a friendly string randomly to be used as token. By default, length is 20 characters.
def friendly_token(length = 20) # To calculate real characters, we must perform this operation. # See SecureRandom.urlsafe_base64 rlength = (length * 3) / 4 SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random_token\n 32.times.map{ rand(36).to_s(36) }.join # 32 alphanumeric characters\n end", "def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end", "def rand_token length=36\r\n\ttoken = ''\r\n\tlength.times do\r\n\t\ttoken += (random(0, 2)==1) ? (random(0,10).to_s) : (rand_let())\r\n\tend\r\n\ttoken\r\nend", "def random_token length = 5\n token = \"\"\n alphabets = \"abcdefghijklmnopqrstuvwxyz\"\n 1.upto(length) do |i|\n idx = rand(alphabets.length)\n token += alphabets[idx..idx]\n end\n return token\nend", "def rand_string(length = 10)\r\n rand(36**length).to_s(36)\r\n end", "def rand_string(length = 10)\n rand(36**length).to_s(36)\n end", "def rand_string(length = 10)\n\t\trand(36**length).to_s(36)\n\tend", "def rand_token\n\t\ttok = rand(36**8).to_s(36)\n\t\tif tok.length < 8\n\t\t\trand_token\n\t\telse\n\t\t\ttok\n\t\tend\n\tend", "def random_string(length)\n rand(36**length).to_s(36)\n end", "def friendly_token\n SecureRandom.base64(32).tr('+/=lIO0', 'pqrsxyz')\n end", "def ran_str_maker\r\n length = 10\r\n ran_str = rand(36**length).to_s(36)\r\n return ran_str\r\nend", "def random_word(length = 5)\r\n rand(36**length).to_s(36)\r\nend", "def random_word(length = 5)\n rand(36**length).to_s(36)\nend", "def random_word(length = 5)\n rand(36**length).to_s(36)\nend", "def random_word(length = 5)\n rand(36**length).to_s(36)\nend", "def random_word(length = 5)\n rand(36**length).to_s(36)\nend", "def generatePlayerToken\n\t\to = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n\t\tstring = (0...50).map { o[rand(o.length)] }.join\n\t\treturn string\n\tend", "def get_random_string\r\n length=30\r\n source=(\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (0..9).to_a + [\"_\",\"-\"]\r\n key=\"\"\r\n length.times{ key += source[rand(source.size)].to_s }\r\n return key\r\nend", "def randstr\n\trand(36 ** 8).to_s(36)\nend", "def random_string(length = 30)\n o = [('0'..'9'), ('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n (1..length).map { o[rand(o.length)] }.join\n end", "def random_string\n letters = [['!','\"','$','&',';','@'],\n ('a'..'z').to_a,\n ('A'..'Z').to_a,\n ('0'..'9').to_a].flatten\n (1..16).map { |i| letters[ rand(letters.length) ] }.join\n end", "def generate_token\n UUIDTools::UUID.random_create.to_s\n end", "def random_string(length=nil)\n length = Random.rand(32) if length.nil?\n (0...length).map { random_character }.join('')\nend", "def generate(len = 5)\n @str = ''\n \n len.times do\n i = rand(@@CHARS.size)\n @str += @@CHARS[i]\n end\n \n @str\n end", "def generate_random(length = 32)\n (1..length).inject(\"\") { |token, _| token << CHOICES.sample }\n end", "def generate_secure_token_string\n SecureRandom.urlsafe_base64(25).tr('lIO0', 'sxyz')\n end", "def generate_random_string(length=8)\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'\n string = ''\n length.times { string << chars[rand(chars.size)] }\n return string\nend", "def generate_random_token\n SecureRandom.hex(15)\n end", "def generate_token(length = 48)\n SecureRandom.base64(length)\n end", "def random_chars(length = 64)\n return rand(36**length).to_s(36)\nend", "def random_token\n SecureRandom.hex(20)\n end", "def random_string(len)\n rand_max = RAND_CHARS.size\n ret = \"\" \n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret \n end", "def random_string(length)\n random_chars(length).join\n end", "def random_name\n SecureRandom.hex(20)\n end", "def random_string(len)\n rand_max = RAND_CHARS.size\n ret = \"\"\n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret\n end", "def make_token\n secure_digest(Time.now, (1..10).map{ rand.to_s })\n end", "def get_random_string(length=8)\n string = \"\"\n chars = (\"a\"..\"z\").to_a\n length.times do\n string << chars[rand(chars.length-1)]\n end\n return string\n end", "def RandomString(len)\n rand_max = RAND_CHARS.size\n ret = \"\" \n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret \n end", "def random_string(len=8)\n (0...len).map{65.+(rand(25)).chr}.join\n end", "def generate_token\n SecureRandom.hex(10)\n end", "def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the bucket and return a 255 char string\n\treturn (0...255).map{ bucket[rand(bucket.length)] }.join\nend", "def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end", "def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end", "def random_string(length)\n o = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten\n (0...length).map{ o[rand(o.length)] }.join\n end", "def generate_password\r\n return rand(36 ** 20).to_s(36)\r\n end", "def generate_access_token\n allowed_chars = [*'0'..'9', *'a'..'z', *'A'..'Z'].join\n self.access_token = 128.times.map { allowed_chars[rand(allowed_chars.size)] }.join\n end", "def generate_random_token\n #generates a random hex string of length 5\n unless self.random_token\n self.random_token = SecureRandom.hex(5)\n end\n end", "def random_string size \n (0..size).map { ('a'..'z').to_a[rand(26)] }.join\n end", "def random_string(len)\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n str = \"\"\n 1.upto(len) { |i| str << chars[rand(chars.size-1)] }\n str\n end", "def random_string_upto_length(max_length)\r\n length = random_integer(max_length)\r\n random_string_of_length(length)\r\n end", "def randomString\n o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten \n string = (1..ROOM_NAME_LENGTH).map{ o[rand(o.length)] }.join\n end", "def generate_slug\n rand(36**@@string_length).to_s(36)\n end", "def generate_random_id\n len = 8\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newpass = \"\"\n 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }\n return newpass\n end", "def generate_string\n (0...6).map{(65+rand(26)).chr}.join\n end", "def random_string(size=25)\n (1..size).collect { (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }.join\n end", "def generateRandomString ()\n return SecureRandom.hex(4)\nend", "def utter_randomly\n length = Utterance::MinLength +\n rand(Utterance::MaxLength - Utterance::MinLength)\n (0...length).map{ Alphabet.sample }.join\n end", "def generate_token(size)\n validity = Proc.new {|token| Token.where(:token => token).first.nil?}\n\n begin\n token = SecureRandom.hex(size)[0, size]\n token = token.encode(\"UTF-8\")\n end while validity[token] == false\n\n token\n end", "def random_string(length); random_bytes(length / 2).unpack(\"H*\")[0] end", "def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end", "def random_string_of_length(length)\r\n str = ''\r\n 1.upto(length) do\r\n str << CHARS[rand(CHARS.size)]\r\n end\r\n str\r\n end", "def random_big_string offset = rand(1..500)\n generate_string(25000 + offset)\n end", "def generate_string(size)\n charset = [('a'..'z'),('A'..'Z'),(0..9)].map { |i| i.to_a }.flatten\n return (0...size).map{ charset[rand(charset.length)] }.join\n end", "def generate_random_string(size = 64)\r\n charset = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten; \r\n (0...size).map{ charset.to_a[rand(charset.size)] }.join\r\nend", "def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end", "def generate_random_key(length=32)\n\t\to = [('a'..'z'), (0..9)].map { |i| i.to_a }.flatten\n\t\t(0...length).map { o[rand(o.length)] }.join\n\tend", "def generate_token\n SecureRandom.hex(64)\nend", "def generate\n ('a'..'z').to_a.shuffle[0, length].join.capitalize\n end", "def random_word\n letters = ('a'..'z').to_a\n word = []\n length = (rand 15) + 1\n \n length.times do\n word << letters[rand(25)] \n end\n\n word.join ''\nend", "def generate_token\n loop do\n token = SecureRandom.base64(44).tr(\"+/=\", \"xyz\").first(16).upcase\n break token unless self.class.where(:token => token).first\n end\n end", "def random_suffix\n length = 10\n SecureRandom.random_number(36 ** length).to_s(36).rjust(length, '0')\n end", "def friendly_token(length=40)\n Pillowfort::Helpers::DeprecationHelper.warn(self.name, :friendly_token, :friendly_secret)\n friendly_secret(length)\n end", "def rand_string(len)\n o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten\n string = (0..len).map{ o[rand(o.length)] }.join\n\n return string\n end", "def random_id(length=1)\n\t\tchars = ('A'..'Z').to_a + ('a'..'z').to_a + ('1'..'9').to_a - %w[I i l L O o 0 U u V v B 8]\n\t\tresult = ''\n\t\tlength.times { result << chars.sample }\n\t\tresult \n\tend", "def generate_token(n: 36)\n token = nil\n loop do\n token = SecureRandom.urlsafe_base64(n)\n return token if valid_new_token?(token)\n end\n end", "def random_string(len)\n (0...len).map{ ('a'..'z').to_a[rand(26)] }.join\nend", "def generate_password\n password = [('a'..'z'), ('A'..'Z'),(0..9)].map { |i| i.to_a }.flatten\n (8...32).map { password[rand(password.length)] }.join\n end", "def create_password(length)\n chars = ('a' .. 'z').to_a + ('1' .. '9').to_a + '%$?@!'.split(//)\n Array.new(length, '').collect { chars[rand(chars.size)] }.join\nend", "def rand_pass(length=8)\n return rand(36**length).to_s(36)\nend", "def generate_secret\n rand(36**secret_length).to_s(36)\n end", "def random_key\n (0...10).map { ('a'..'z').to_a[rand(26)] }.join\n end", "def randStr()\n str = \"\"\n 5.times { str << (65 + rand(26)).chr }\n return str\nend", "def rand_text_alphanumeric(length, bad=payload_badchars)\n if debugging?\n rand_text_debug(length)\n else\n Rex::Text.rand_text_alphanumeric(length, bad)\n end\n end", "def randomString\r\n\t(0...8).map{(65+rand(26)).chr}.join\r\nend", "def random_password(size=10)\n random_string(size, :chars, 'ABCDEFGHJKLMNPQRSTUVWXYabcdefghkmnpqrstuvwxyz23456789#%^&$*i-_+=')\n end", "def random_string(len)\n # first, we make a bunch of random characters in an array\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newpass = \"\"\n # then we grab a random element of that array, and add it onto our newpass\n 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }\n return newpass\n end", "def random_hex_string_upto_length(max_length)\r\n length = random_integer(max_length)\r\n random_hex_string_of_length(length)\r\n end", "def rand_text_debug(length, char = 'A')\n char * (length.kind_of?(Range) ? length.first : length)\n end", "def generate_token\n self.token ||= SecureRandom.hex(16)\n end", "def generate_password( len = 6 )\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 a c d e g h j k m n p q r v w x y z }\n (0...len).map{ charset.to_a[rand(charset.size)] }.join\nend", "def random_key\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n (0...8).map { o[rand(o.length)] }.join\n end", "def rand_text(length, bad=payload_badchars)\n if debugging?\n rand_text_debug(length)\n else\n Rex::Text.rand_text(length, bad)\n end\n end", "def make_token\r\n # From the restful-authentication plug-in\r\n args = [ Time.now, (1..10).map{ rand.to_s } ]\r\n Digest::SHA1.hexdigest(args.flatten.join('--'))\r\n end", "def createRandomUserName20\n len = 20\n # Random capital letter for first and last name\n nameFirst = (65 + rand(26)).chr\n nameLast = (65 + rand(26)).chr\n # Length of first and last remaining lower case letters\n remainingFirst = rand(len - 2) # First name can be between 1 and full length minus 2 (space and at least 1 char for last name)\n remainingLast = rand(len - 2 - remainingFirst) # Last name between 1 and full length minus 2 (space and at least 1 char for first name\n # Remaining letters\n (remainingFirst).times{nameFirst << (97 + rand(26)).chr}\n (remainingLast).times{nameLast << (97 + rand(26)).chr}\n return nameFirst, nameLast\nend", "def generate_password(length = 8)\n chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('1'..'9').to_a - ['o', 'O', 'i', 'I']\n Array.new(length) { chars[rand(chars.size)] }.join\n end", "def randstr\n (0...50).map{ ('a'..'z').to_a[rand(26)] }.join\nend", "def generate_token\n SecureRandom.urlsafe_base64.tap do |token|\n logger.debug \"Generated token #{token}\"\n end\n end", "def generate_password\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K M N P Q R T V W X Y Z @ # $ & ! }\n (0...6).map{ charset.to_a[rand(charset.size)] }.join\n end", "def random_id\n \"#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}\"\n end", "def generate_token(options = {})\n values = [rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000)]\n \"%04x%04x-%04x-%04x-%04x-%06x%06x\" % values\n end" ]
[ "0.8341831", "0.8303068", "0.82232136", "0.8050449", "0.8020398", "0.80009365", "0.797985", "0.79169524", "0.78613895", "0.78367186", "0.775581", "0.77160907", "0.76943225", "0.76943225", "0.76943225", "0.76943225", "0.7681546", "0.76418835", "0.7629756", "0.75901985", "0.75875133", "0.7541928", "0.75304866", "0.75136197", "0.7498374", "0.7497955", "0.7494543", "0.74944025", "0.7444822", "0.74372125", "0.7436046", "0.7411946", "0.74012554", "0.73915064", "0.7388615", "0.73781514", "0.7374321", "0.7321631", "0.72948223", "0.72936887", "0.72522473", "0.7245894", "0.7245894", "0.7225945", "0.7220848", "0.72157717", "0.7210718", "0.72027385", "0.7202344", "0.71941763", "0.719236", "0.717139", "0.7167952", "0.71579975", "0.7155609", "0.7142306", "0.7125349", "0.7120735", "0.711737", "0.71027285", "0.7090549", "0.7086546", "0.7078603", "0.70727825", "0.7067003", "0.7063758", "0.7054581", "0.7033468", "0.70012236", "0.699802", "0.6996769", "0.69936514", "0.69892436", "0.69858134", "0.6985625", "0.69840604", "0.694821", "0.6925711", "0.6921732", "0.6907658", "0.6904663", "0.689555", "0.68899435", "0.6865757", "0.6848409", "0.6845295", "0.6845145", "0.68390894", "0.68376416", "0.6828759", "0.68160284", "0.6815497", "0.6805257", "0.680423", "0.6801699", "0.6797139", "0.67967767", "0.6794979", "0.67937875", "0.6793338" ]
0.83982605
0
find all of the employees for the location instance
def employees Employee.all.select do |emp| emp.location == self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def employees\n employee_array = []\n locations.each do |location|\n location.employees.each do |employee|\n employee_array << employee\n end\n end\n employee_array\n end", "def all_employees\n self.workplace.employees\n end", "def all_employees\n ServiceProvider.all(:conditions => [\"user_id IN (?)\", self.users.map(&:id)])\n end", "def employeeLocationsByCity()\n locations = Hash.new\n \n employeesList = (RawData.new(\"employee_details\").getMnoData())['content']['employees']\n \n employeesList.each do | employee |\n # extract the city/country information from the 'address' field\n address = employee['address']\n location = employee['address'].gsub(/\\ \\d+/, \"\")\n location = location.split(/\\s*[,;]\\s*/x).from(-2).join(', ')\n \n # Add to locations records\n occurrence = locations.fetch(location, nil)\n \n if !occurrence\n locations[location] = Array.new\n end \n \n locations[location].push(address)\n \n #puts locations\n end\n\n return locations\n end", "def employees\n self.employee_examination_sessions.map(&:employee)\n end", "def get_employees\n @employees = User.find_user_not_admin_not_client(get_company_id)\n end", "def employees\n emps = []\n url = prefix + \"liste\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n emps << User.new(u[\"id\"], @authid, @subdomain)\n end\n return emps\n else #failed\n return users\n end\n end", "def list \n @employees = Employee.find( :all ) # return an array of all Employees\n end", "def employees\n Employee.all.select {|employees| employees.manager_name == self.name} \n end", "def show\n @program_employee = ProgramEmployee.find(params[:id])\n @employees = @program_employee.program_location.program_employees\n end", "def employees\n Employee.all.select do |employee|\n employee.manager == self\n \n end\n end", "def list_employees(opts = {})\n data, _status_code, _headers = list_employees_with_http_info(opts)\n return data\n end", "def list_employees(opts = {})\n data, _status_code, _headers = list_employees_with_http_info(opts)\n return data\n end", "def getFullNameEmployees\n\n @employees = Array.new\n @EmployeesAndPeople= Employee.joins(person: :user).where(users: {role: [2,3,4,5]})\n\n @EmployeesAndPeople.all.each do |emp|\n @employees << [ emp.person.first_name + ' ' + emp.person.last_name, emp.id]\n end\n\n end", "def getAllLocations()\n coll = self.coll_locations\n puts coll.find()\n coll.find.each { |row| puts row.inspect }\n end", "def list_employees(order: nil,\n begin_updated_at: nil,\n end_updated_at: nil,\n begin_created_at: nil,\n end_created_at: nil,\n status: nil,\n external_id: nil,\n limit: nil,\n batch_token: nil)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/employees'\n _query_builder = APIHelper.append_url_with_query_parameters(\n _query_builder,\n 'order' => order,\n 'begin_updated_at' => begin_updated_at,\n 'end_updated_at' => end_updated_at,\n 'begin_created_at' => begin_created_at,\n 'end_created_at' => end_created_at,\n 'status' => status,\n 'external_id' => external_id,\n 'limit' => limit,\n 'batch_token' => batch_token\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end", "def show\n @employees = MusterLocation.find(params[:id]).employees.order(:last_name)\n end", "def employees\n Employee.all.select{|employee| employee.role == self}\n \n end", "def current_employees\n\tassignments = Assignment.current.for_store(self.id)\n\temployees = assignments.map{|a| Employee.find(a.employee_id)}\n\temployees = employees.sort_by { |e| [e.last_name, e.first_name] }\n\treturn employees\n end", "def index\n @emergency_locations = EmergencyLocation.all\n end", "def index\n @emp_locacions = EmpLocacion.all\n end", "def get_all_locations\n @locations = []\n results = Location.all\n results.each do |loc|\n @locations << loc.to_hash\n end\n end", "def employees\n emps = []\n url = prefix + \"liste\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n emps << ShareUser.new(u[\"id\"], @authid, @subdomain)\n end\n return emps\n else #failed\n return users\n end\n end", "def employees\n Employee.select{|employees| employees.manager == self.name}\nend", "def display_employees\n\t\t@@name_and_salary.each do |x|\n\t\t\tputs \"Name: #{x[:name]}, Salary: $#{x[:salary]}\"\n\t\tend\n\tend", "def get_all_locations\n @locations = []\n\n Location.all.each do|loc|\n @locations << loc.to_hash\n end\n end", "def get_all_locations\n @locations = []\n Location.all.each do |loc|\n @locations << loc.to_hash\n end\n end", "def my_department_members\n departments = employee&.departments&.ids || []\n Employee.where(id: Position.where.not(department_id: nil).where(department_id: departments).map(&:efective_id))\n end", "def list\n @locations = Location.find(:all, :order => \"name\")\n end", "def index\n @admin_employees = Employee.all\n end", "def v1_employees_get(opts = {})\n data, _status_code, _headers = v1_employees_get_with_http_info(opts)\n return data\n end", "def index\n @program_employees = ProgramEmployee.all\n end", "def index\r\n\t\t@employees = Employee.all\r\n\tend", "def index\n @wing_employees = WingEmployee.all\n end", "def index\n @employees = User.all\n end", "def index\n @employees = User.all\n end", "def index\n @employees = User.all\n end", "def index\n @registry_employees = filtering_params(params).paginate(:page => params[:page])\n end", "def employees_of_companies\n CRM[:companies].each do |company|\n company_id = company.delete(:id)\n puts company[:name]\n\n CRM[:people].each do |person|\n person[:employments].each do |employment|\n if employment[:company_id] == company_id\n employment.delete(:company_id)\n puts \" (#{person[:id]}) #{person[:first_name]} #{person[:last_name]} - #{employment[:title]}\"\n end\n end\n end\n\n end\n end", "def list_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true)\n end", "def employee\n @last_ext += 1\n p = Person.new\n p.office_phonenumber = Phonenumber.new(@phonenumber.prefix, phonenumber.number, @last_ext.to_s)\n p.office_email = Email.new(p)\n p.office_email.user_from_names(p, \".\")\n p.office_email.host = @domain\n p\n end", "def index\n @employees = []\n if current_user.user_type <= 1\n @employees = Employee.all\n elsif current_user.user_type == 3 # manager\n @employees = Employee.where(department_id: current_user.role.department_id)\n end\n end", "def company_employee_list(company_id)\n roles = Role.where(company_id: company_id)\n workers = []\n User.where(id: roles.pluck(:user_id).uniq).each do |w|\n workers.push(\n id: w.id,\n email: w.email,\n roles: roles.where(user_id: w.id).select(:id, :name)\n )\n end\n workers\n end", "def index\n @employees = @employees = Employee.all\n end", "def index\n @employee_rooms = EmployeeRoom.all\n end", "def index\n @job_locations = JobLocation.all\n end", "def index\n @employees = @client.employees\n @events = fetch_events\n end", "def report_data\n @data[:employees].map do |id, employee_data|\n employee = Employee.new(employee_data)\n [employee.name, week_date_ranges.map { |range| \n employee.net_hours_for_date_range(range)} ]\n end\n end", "def list_employees_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmployeesApi.list_employees ...\"\n end\n # resource path\n local_var_path = \"/v2/employees\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'location_id'] = opts[:'location_id'] if !opts[:'location_id'].nil?\n query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n \n header_params['Square-Version'] = \"2019-06-12\"\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ListEmployeesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmployeesApi#list_employees\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def employees\n times.map(&:employee).uniq\n end", "def employees\n if EMPLOYEES_VIEW_MUST_HAVE.include?(Employee.where(id: session[\"found_user_id\"]).first.admin_rights)\n @employees = Employee.where(florist_id: session[\"found_florist_id\"]).order(\"primary_poc\", \"status\", \"name\")\n render(:employees) and return\n else\n redirect_to \"/employee/#{session[\"found_user_id\"]}\" and return\n end\n end", "def get_locations\n location_references =\n lighthouse_appointments.each_with_object({}) do |appt, acc|\n reference = appt.resource.participant.first.actor.reference\n location_id = reference.match(ID_MATCHER)[1]\n\n acc[location_id] ||= []\n acc[location_id] << appt\n end\n\n clinic_identifiers = location_references&.keys&.join(',')\n location_response = location_service.search(_id: clinic_identifiers, _count: '100')\n\n location_response&.resource&.entry\n end", "def form_setup\n\t\t@employees = Person.active.map { |person| [person.full_name, person.id] }\n\tend", "def list_employees(api_object)\n puts \"Current Employees:\"\n doc = Nokogiri::XML.parse api_object.read\n names = doc.xpath('employees/employee/name').collect {|e| e.text }\n puts names.join(\", \")\n puts \"\"\nend", "def index\n if params[:term].present?\n if params[:department].present?\n @employees = Employee.where('firstname LIKE ? or lastname LIKE ? or email LIKE ?', \"%#{params[:term]}%\" ,\"%#{params[:term]}%\", \"%#{params[:term]}%\").where(department: params[:department])\n else\n @employees = Employee.where('firstname LIKE ? or lastname LIKE ? or email LIKE ?', \"%#{params[:term]}%\" ,\"%#{params[:term]}%\", \"%#{params[:term]}%\")\n end\n elsif params[:department].present?\n @employees = Employee.where(department: params[:department])\n puts \"employees\"\n puts @employees.inspect\n # render partial: \"employeeList\", :collection => @employees\n \n else \n @employees = Employee.all\n end\n end", "def index\n @employees = Employee.where(department_id: current_employee.department_id)\n end", "def index\n @service_employees = ServiceEmployee.all\n end", "def locations()\n sql = \"SELECT dives.*\n FROM dives\n INNER JOIN schedules\n ON schedules.dive_id = dives.id\n WHERE schedules.id = $1\"\n values = [@schedule_id]\n result = SqlRunner.run(sql,values)\n dive = Dive.map_items(result)\n return dive\n end", "def index\n @employee_physicals = EmployeePhysical.all\n end", "def get_unallocated_employees(employees)\n employees_list = []\n employees.each do |employee|\n employees_list.push employee.name\n end\n return employees_list\n end", "def \n # Adds the passed employee to the company employee list\n def hire_employee(employee)\n self.employees\n @employees\n end", "def index\n @item_locations = ItemLocation.all\n end", "def addresses\n query(:address)\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def work_day_employees\n all_week_employees = self.current_columns.each_slice(2).to_a\n\n return all_week_employees[Date.today.wday]\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @employees = Employee.all\n end", "def index\n @totem_locations = TotemLocation.all\n end", "def generate_new_employees(employee_ids)\n new_employees = []\n employee_ids.each do |ei|\n employee = Employee.find_by(employee_id: ei)\n unless employee.present?\n new_employee = Employee.new(employee_id: ei)\n new_employee.save!\n new_employees << new_employee\n end\n end\n return new_employees if new_employees.present?\n end", "def index\n @aga_employees = AgaEmployee.all\n end", "def hire_employee(employee)\n @employees << employee\n end", "def list_locations\n query = create_query(:Location, :all, by: default_sort_order)\n show_selected_locations(query, link_all_sorts: true)\n end", "def get_report_locations()\n locations = Location.where(company_id: self.id)\n\n return locations\n end", "def get_report_locations()\n locations = Location.where(company_id: self.id)\n\n return locations\n end", "def get_report_locations()\n locations = Location.where(company_id: self.id)\n\n return locations\n end", "def index\n @employees = Employee.where(\"users_id = ?\",current_user.id)\n end", "def index\n @specific_locations = SpecificLocation.all\n end", "def get_locations( fsl = true )\n loc = run( 'http://' + domain + '/redetrack/bin/mylocations.php?pid=249&rnd=3865&uid=2366&org=33&rdt_site_id=222&si=243')\n loc.column(1).delete\n loc.range('D:G').delete\n loc.insert_rows( 1, 1 )\n loc['A1:C1'] = [ 'Name', 'City', 'Parent Location' ]\n hash = {}\n loc.rows(2) do |row|\n hash[ row['A'].upcase.strip ] = if row['B'].nil? || row['B'] !~ /Milton Keynes/i \n fsl ? 'FSL' : ( row['B'].nil? ? 'Blank' : row['B'] )\n else \n 'MILTON KEYNES'\n end\n end\n hash\n end", "def show\n @employees = @department.employees\n end", "def retrive_employees_by_manager\n @employees = \n if params[:manager_id].present? \n Employee.includes(:department)\n .where(manager_id: params[:manager_id])\n else\n Employee.includes(:department).all\n end\n\n render :partial => \"employees\", :object => @employees\n end", "def index\n @q = params[:search_query]\n @departments = Department.all\n if @q.present? ? @q : nil\n #Employee.where(\"name ilike ?\",\"%#{search}%\")\n puts \"Your search is #{@q}\"\n @employees = Employee.search @q, fields: [\"department_name\",\"name\"], match: :word_start\n else\n @employees = Employee.all\n end\n end", "def list\n # list possible locations \n\n @location_suggest = get_location_suggest\n\n if params[:location]\n locations = WoeidHelper.search_by_name params[:location]\n if not locations.nil? and locations.count == 1\n set_location locations[0]\n else\n @location_asked = locations\n end\n end\n end", "def locations\n\t\t[]\n\tend", "def add_employees\n add_leave_type_data(params)\n @departments = EmployeeDepartment.active_and_ordered\n @search_params = params[:search]||params[:advanced_search]||{}\n @search_filters = LeaveGroup.fetch_search_filters(params[:advanced_search], params[:selectAlladvanced_search]) if params[:advanced_search].present?\n @employees = Employee.leave_group_not_assigned.search(@search_params).all(:include => [:employee_department, :employee_position, :employee_grade]) if @search_params.present?\n @hash = @leave_group.build_employees(@search_params.present?, @employees||[])\n @total = @employees.length if @employees.present?\n if request.xhr?\n render :update do |page|\n page.replace_html 'employee_list', :partial => \"list_employees\"\n end\n end\n end", "def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @locations\n end", "def findAllPepLocations\n hits = @doc.xpath(\"//#{@xmlns}search_hit\")\n all = []\n @locations = []\n i = 0\n \n # Parses out each peptide and protein\n hits.each do |hit|\n all << [hit.xpath(\"./@peptide\").to_s, proteinID(hit.xpath(\"./@protein\").to_s)]\n i += 1\n end\n \n all.uniq!\n dataHash = Hash.new\n \n Ms::Fasta.foreach(@database) do |entry|\n @sequences += 1\n pID = proteinID(entry.header)\n dataHash[pID] = entry.sequence\n @proteinIndices << pID\n end\n \n all.each do |set|\n if dataHash[set[1]] != nil\n startVal = dataHash[set[1]].scan_i(set[0])[0]\n \n if startVal != nil\n @locations << [set[0], set[1], startVal + 1, startVal + set[0].length]\n end\n end\n end\n end", "def index\n @admin_locations = Admin::Location.all\n end", "def employee(employee_id)\n get(\"employees/#{employee_id}\")\n end", "def index\n @locations = Location.search(params[:search])\n end", "def census_employees\n @census_employees = CensusMembers::PlanDesignCensusEmployee.by_benefit_sponsorship(self)\n end" ]
[ "0.7776603", "0.7423415", "0.67937756", "0.67202336", "0.6630696", "0.6623034", "0.64878774", "0.6389549", "0.6299226", "0.6144151", "0.6106964", "0.6096123", "0.6096123", "0.60584205", "0.6013435", "0.6008707", "0.5984021", "0.5969415", "0.5963448", "0.5938073", "0.58840406", "0.58672744", "0.5840639", "0.577013", "0.57622737", "0.5685966", "0.5676653", "0.56717867", "0.5664899", "0.56532145", "0.56317073", "0.562565", "0.5620454", "0.5620077", "0.5618816", "0.5618816", "0.5618816", "0.5617332", "0.5603825", "0.55835706", "0.5570418", "0.55479246", "0.55377597", "0.5526971", "0.5523798", "0.55199796", "0.55168885", "0.55140686", "0.5513432", "0.5512918", "0.5512289", "0.55055517", "0.55053246", "0.54989225", "0.54943126", "0.5479927", "0.5467441", "0.54592764", "0.5448992", "0.54480696", "0.54430884", "0.5439785", "0.54131454", "0.5412456", "0.539249", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5384275", "0.5383884", "0.5369523", "0.5367063", "0.53518057", "0.5346125", "0.5344062", "0.5328651", "0.5328651", "0.5328651", "0.53247786", "0.5322863", "0.5315162", "0.53096175", "0.53035206", "0.53006953", "0.52999413", "0.5295674", "0.52936065", "0.52865136", "0.5276392", "0.5268474", "0.52628154", "0.525877", "0.52587426" ]
0.74121946
2
Returns the single root for the class (or just the first root, if there are several). Deprecation note: the original acts_as_nested_set allowed roots to have parent_id = 0, so we currently do the same. This silliness will not be tolerated in future versions, however.
def root acts_as_nested_set_options[:class].find(:first, :conditions => "(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root\n if self.dotted_ids\n self.class.find(self.dotted_ids.split('.').first)\n else\n node = self\n node = node.parent while node.parent\n node\n end\n end", "def root\n nested_set_class.find_with_nested_set_scope(:first, :conditions => \"(#{nested_set_parent} IS NULL)\")\n end", "def root\n ancestors.first || self\n end", "def root\n return self if root?\n (root_relation_enabled? && root_ancestor) || ancestors.first\n end", "def root\n object = self\n while (object.parent) do object = object.parent; end\n object || self\n end", "def root\n return self if is_root?\n ancestors.select { |category| category.is_root? }.first\n end", "def root\r\n\t\t\t\tself.find(:first, :conditions => 'parent_id IS NULL')\r\n\t\t\tend", "def root\n self[tree_parent_id_field].nil? ? self : tree_search_class.find(self[tree_path_field].first)\n end", "def root_entity\n root = self\n loop do\n break if root.parent_id.nil?\n root = root.parent\n end\n root\n end", "def root\n self_and_ancestors.first\n end", "def root\n root = self\n until (parent = root.parent).nil?\n root = parent\n end\n root\n end", "def effective_root\n if empty? and children.size == 1\n children.first.effective_root\n else\n self\n end\n end", "def root\n @key.nil? ? self : parents.first\n end", "def root\n first :parent_id => nil\n end", "def root_level\n self.find\n end", "def root\n parent ? parent.root : self\n end", "def root\n parent ? parent.root : self\n end", "def root\n if self.root?\n self\n else\n self.parent.root\n end\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def get_root\n return self if tag == :root || parent.nil?\n parent.get_root\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def root\n return nodes.first if nodes.size == 1\n nodes.find { |node| root?(node) }\n end", "def root\n self.find(:first, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\")\n end", "def root\n return @root if @root\n return self if parent.nil?\n @root = parent.root\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def root\n node = self\n node = node.parent while !node.parent.nil?\n node\n end", "def root \n parent.nil? ? self : parent.root\n end", "def root\n root? ? self : parent.root\n end", "def root_document\n ri = root_item\n return self if ri == nil # i.e, if it is a root document\n ri_id = ri.id\n return if ri_id == nil\n DocumentRepository.find(ri_id)\n end", "def root(reload=false)\n ancestors(reload).first\n end", "def root\n n = self\n while n.parent \n n = n.parent\n end\n n\n end", "def root_node\n root_nodes.first\n end", "def root\n return @root\n end", "def root\n return @root\n end", "def root\n if is_root?\n self\n else\n return Especie.none unless ancestry_ascendente_directo.present?\n ancestros = ancestry_ascendente_directo.split(',').map{|a| a.to_i if a.present?}.compact\n return Especie.none unless ancestros.any?\n\n Especie.find(ancestros.first)\n end\n end", "def root_parent\n if parent\n parent.root_parent\n else\n self\n end\n end", "def root_node(node)\n return node.respond_to?(:root_node) ? node.root_node : node\n end", "def roots\n acts_as_nested_set_options[:class].find(:all, :conditions => \"(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def root\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, 1)\", ltree_path).first\n end", "def root\n self.where(parent: nil).order('index asc').first\n end", "def root(scope = {})\n find_in_nested_set(:first, { :conditions => \"(#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\" }, scope)\n end", "def root\n self\n end", "def root\n self\n end", "def root_object\n self\n end", "def root\n @parent.root\n end", "def root\n return @root\n end", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def tree_root\n if (root_id = visibility_path_ids.first)\n return content_model::Page.get(root_id)\n end\n nil\n end", "def root_model\n node = @model\n\n loop do\n parent = node.parent\n if parent\n node = parent\n else\n break\n end\n end\n\n node\n end", "def root_model\n node = @model\n\n loop do\n parent = node.parent\n if parent\n node = parent\n else\n break\n end\n end\n\n node\n end", "def root\n if(rails_3?)\n configuration[:class].where(\"#{configuration[:foreign_key]} IS NULL\").order(configuration[:order]).first\n else\n configuration[:class].find(\n :first, \n :conditions => \"#{configuration[:foreign_key]} IS NULL\", \n :order => configuration[:order]\n )\n end\n end", "def root\n return @root if defined?(@root)\n\n @root = nil\n\n @root = issue.root if issue\n end", "def root_id\n if is_root?\n id\n else\n root.id\n end\n end", "def root\n return @notes.find { |note| note.part == :root } || self.low_note\n end", "def root\n cursor = self\n cursor = cursor.up until cursor.root?\n cursor\n end", "def root\n @__cache__[:root] ||= @superstate ? @superstate.root : self\n end", "def root\n @root\n end", "def root\n unless @root\n @root = Entry.new\n self.class.parse @root, @raw\n @raw = nil\n end\n\n @root\n end", "def root\n instance.options[:root]\n end", "def root\n instance.options[:root]\n end", "def get_path_root\n return self if @path.nil?\n @path.get_path_root\n end", "def get_root(doc)\n doc.children.first\n end", "def root_rel\n rel = relationship.try!(:root)\n # micro-optimization: if the relationship is us, \"load\" the resource\n rel.resource = self if rel && rel.resource_id == id && rel.resource_type == self.class.base_class.name.to_s\n rel || relationship_for_isolated_root\n end", "def root_folder\n if new_record?\n material_folders.find(&:root?) || (raise ActiveRecord::RecordNotFound)\n else\n material_folders.find_by!(parent: nil)\n end\n end", "def root\n return nil unless self.document\n self.document.root\n end", "def get_root()\n \n end", "def root_collection\n return @root_collection ||= file_by_id(\"root\")\n end", "def root\n\t\t\t\tfind_root[0].to_s\n\t\t\tend", "def find_root_element\n if parent\n parent.find_root_element\n else\n self\n end\n end", "def roots\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def root\n @root ||= start\n end", "def root\n @elements[@root]\n end", "def root?\n self[tree_parent_id_field].nil?\n end", "def roots\n nested.filter(self.model_classes[nil].qualified_parent_column => nil)\n end", "def root?\n self.class.roots.exists?(self.id)\n end", "def roots\n self.find(:all, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def root\n case parent\n when Pathname then parent\n when FileStore then parent.root\n else nil\n end\n end", "def root_ancestor\n has_parent? ? parent.root_ancestor : self\n end", "def root_node\n if @root_node.nil?\n # TODO: Fix this so that added content at the end of the file doesn't\n # break this stuff.\n # E.g.: http://smogzer.tripod.com/smog.rdf\n # ===================================================================\n begin\n if self.xml_document.nil?\n return nil\n else\n @root_node = self.xml_document.root\n end\n rescue Exception\n return nil\n end\n end\n return @root_node\n end", "def make_root\n if self.rep_parent.nil?\n return super\n else\n return self.rep_parent.make_root\n end\n end", "def root\n klass = MAPPING.fetch(input.class)\n klass.new(left, right)\n end", "def root\n @elements[@root_name]\n end", "def root\n @root ||= NodeProxy.new(@doc.root) if @doc && @doc.root\n end", "def root(*args)\n return call_ancestry_method(:root) if use_ancestry?\n\n Relationship.resource(root_rel(*args))\n end", "def root\n folders.first\n end", "def root\n subject.root(node)\n end", "def getRoot\n @path[0]\n end", "def root\n @attributes[:root]\n end", "def root\n blk = self.class.has_widgets_blocks or raise \"Please setup a widget tree using has_widgets()\"\n @root ||= Apotomo::Widget.new(parent_controller, \"root\").tap do |root|\n self.instance_exec(root, &blk)\n end\n end", "def root_id(*args)\n return call_ancestry_method(:root_id) if use_ancestry?\n\n Relationship.resource_pair(root_rel(*args))\n end", "def root\n\t\treturn @doc == nil ? nil : @doc.root;\n\tend", "def class_root\n @class_root ||= Root.new(Dir.tmpdir)\n end", "def rootObject\n @otrunk.getRoot\n end", "def rootObject\n @otrunk.getRoot\n end", "def root?\n parent_id.nil?\n end", "def get_parent\n return nil\n end", "def root(e)\n while e != id[e]\n id[e] = id[id[e]] # halve the tree\n e = id[e]\n end\n e\n end", "def root?\n _parent_id.nil?\n end" ]
[ "0.7639601", "0.7573074", "0.73372406", "0.7283091", "0.7256298", "0.72382885", "0.7212995", "0.72067875", "0.71194696", "0.71082735", "0.70686173", "0.70459086", "0.7044596", "0.7016398", "0.6982343", "0.6969877", "0.6969877", "0.69552547", "0.69273543", "0.69190854", "0.690871", "0.69044816", "0.68591607", "0.6853956", "0.6852032", "0.68495804", "0.68495804", "0.6823264", "0.6765558", "0.673637", "0.669332", "0.6674829", "0.6661071", "0.66098815", "0.65012443", "0.65012443", "0.640314", "0.6392138", "0.6387844", "0.6383501", "0.6362278", "0.63442236", "0.62792194", "0.6275218", "0.6275218", "0.62646174", "0.62585527", "0.625488", "0.62533814", "0.62446177", "0.6217002", "0.6217002", "0.620092", "0.6200289", "0.6188673", "0.6141753", "0.6138855", "0.60831094", "0.6072115", "0.60626405", "0.60607743", "0.60607743", "0.6031576", "0.60123587", "0.5937486", "0.59222776", "0.5906219", "0.59039026", "0.5895103", "0.58918697", "0.58847326", "0.5884653", "0.587086", "0.5868706", "0.58490425", "0.5844888", "0.5833329", "0.58300227", "0.58089983", "0.57992655", "0.5792479", "0.5787611", "0.5783829", "0.5781128", "0.5770046", "0.5753185", "0.57510227", "0.5736809", "0.5728409", "0.57186764", "0.57127297", "0.5685071", "0.56850207", "0.5673137", "0.56582266", "0.56582266", "0.56552774", "0.56473494", "0.5640842", "0.5639613" ]
0.72842383
3
Returns the roots and/or virtual roots of all trees. See the explanation of virtual roots in the README.
def roots acts_as_nested_set_options[:class].find(:all, :conditions => "(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)", :order => "#{acts_as_nested_set_options[:left_column]}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roots\n nodes.select{ |n| n.root? }\n end", "def roots\n self.ontology_classes(force_reload=true).select{|c| c.isroot?}\n end", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def roots\n select\n end", "def x_get_tree_roots\n objects = []\n objects.push(configured_systems)\n count_only_or_objects(false, objects + FILTERS.values)\n end", "def x_get_tree_roots\n objects = []\n objects << {:id => \"compliance\", :text => _(\"Compliance Policies\"), :icon => \"pficon pficon-history\", :tip => _(\"Compliance Policies\")}\n objects << {:id => \"control\", :text => _(\"Control Policies\"), :icon => \"fa fa-shield\", :tip => _(\"Control Policies\")}\n\n # Push folder node ids onto open_nodes array\n objects.each { |o| open_node(\"xx-#{o[:id]}\") }\n\n count_only_or_objects(false, objects)\n end", "def roots\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def roots\n self.find(:all, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def x_get_tree_roots(count_only, _options)\n objects = Rbac.filtered(VmdbDatabase.my_database.evm_tables).to_a\n # storing table names and their id in hash so they can be used to build links on summary screen in top 5 boxes\n @sb[:vmdb_tables] = {}\n objects.each do |o|\n @sb[:vmdb_tables][o.name] = o.id\n end\n count_only_or_objects(count_only, objects, \"name\")\n end", "def x_get_tree_roots\n count_only_or_objects(false, PxeServer.all, \"name\")\n end", "def all\n root.to_a\n end", "def collect_roots\n\n\t\t# Array to return\n\t\troots = Array.new\n\t\t# For each template\n\t\ttemplates.each do |key, val|\n\t\t\t# Push to array if root\n\t\t\troots << val if template_root? key\n\t\tend\n\t\t\n\t\t# Return results\n\t\troots\n\n\tend", "def roots(scope = {})\n find_in_nested_set(:all, { :conditions => \"(#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def root_branches\n @root_branches = branches.select(&:root?)\n end", "def roots(*args)\n #return find_by_sql(\"select a.* from #{table_name} as a left join #{table_name} b on a.parent_node_id = b.child_node_id where b.child_node_id IS NULL\")\n conditions=['b.child_node_id IS NULL']\n joins=\"LEFT JOIN #{table_name} b ON #{table_name}.parent_node_id = b.child_node_id\"\n with_scope(:find=>{:conditions=>conditions, :joins=>joins, :select=>'#{table_name}.*', :from=>\"#{table_name} #{table_name}\"}) do\n find(:all, *args)\n end\n end", "def get_roots\n find_all{|entry| entry.type==Morpheme::ROOT}\n end", "def roots\n nested.filter(self.model_classes[nil].qualified_parent_column => nil)\n end", "def subgraph_roots\n @subgraph_roots || []\n end", "def x_get_tree_roots\n objects = [\n {:id => \"sis\", :text => _(\"Analysis Profiles\"), :icon => \"fa fa-search\", :tip => _(\"Analysis Profiles\")},\n {:id => \"z\", :text => _(\"Zones\"), :icon => \"pficon pficon-zone\", :tip => _(\"Zones\")}\n ]\n objects.push(:id => \"msc\", :text => _(\"Schedules\"), :icon => \"fa fa-clock-o\", :tip => _(\"Schedules\"))\n objects\n end", "def nodes()\n self.root.nodes()\n end", "def all\n root.branch\n end", "def x_get_tree_roots\n u = User.current_user\n user_groups = u.report_admin_user? ? nil : u.miq_groups\n having_report_results(user_groups).sort\n end", "def x_get_tree_roots\n count_only_or_objects(false, StorageCluster.all)\n end", "def x_get_tree_roots\n objects = []\n objects.push(:id => \"xx-system\",\n :text => _(\"Examples (read only)\"),\n :icon => \"pficon pficon-folder-close\",\n :tip => _(\"Examples (read only)\"))\n PxeImageType.all.sort.each do |item, _idx|\n objects.push(item)\n end\n objects\n end", "def roots(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND (#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def x_get_tree_roots(count_only, _options)\n objects = []\n objects.push(:id => \"asrv\",\n :text => _(\"Active Services\"),\n :icon => \"pficon pficon-folder-close\",\n :load_children => true,\n :tip => _(\"Active Services\"))\n objects.push(:id => \"rsrv\",\n :text => _(\"Retired Services\"),\n :icon => \"pficon pficon-folder-close\",\n :load_children => true,\n :tip => _(\"Retired Services\"))\n count_only_or_objects(count_only, objects)\n end", "def roots\n self.where(parent: nil).order('index asc')\n end", "def tree_root\n repo.tree\n end", "def roots\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0)\", :order => \"#{left_col_name}\")\n end", "def allNodes!(&block)\n NodeSet.freeze\n ns = RootGroupNodeSet.instance\n return RootNodeSetPath.new(ns, nil, nil, block)\n end", "def find_all(conditions)\n @root.find_all(conditions)\n end", "def root_mappings\n [*options.roots].flatten\n end", "def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end", "def x_get_tree_roots(_count_only, _options)\n resolve = {}\n CustomButton.button_classes.each { |db| resolve[db] = ui_lookup(:model => db) }\n @sb[:target_classes] = resolve.invert\n resolve = Array(resolve.invert).sort\n resolve.collect do |typ|\n {:id => \"ab_#{typ[1]}\", :text => typ[0], :image => buttons_node_image(typ[1]), :tip => typ[0]}\n end\n end", "def x_get_tree_roots(_count_only, _options)\n resolve = {}\n CustomButton.button_classes.each { |db| resolve[db] = ui_lookup(:model => db) }\n @sb[:target_classes] = resolve.invert\n resolve = Array(resolve.invert).sort\n resolve.collect do |typ|\n {:id => \"ab_#{typ[1]}\", :text => typ[0], :tip => typ[0]}.merge(buttons_node_image(typ[1]))\n end\n end", "def find_all_paths\n found_paths = []\n \n explore(found_paths, nil, @start_node)\n \n found_paths\n end", "def all_root_groups\n results = root_groups\n subgroups.each do |subgroup|\n unless results.include? subgroup.parent\n results << subgroup.parent\n end\n end\n results.sort_by { |group| group.name }\n end", "def roots(user = nil)\n domain = config.site_domain\n roots = pages_dataset.where(depth: 0).all\n pub, hidden = roots.partition { |p| p.root? }\n map = {}\n map[domain] = pub.first.id unless pub.empty?\n hidden.each { |p| map[p.path] = p.id }\n { \"public\" => domain, \"roots\" => map }\n end", "def root_scrapers\n roots = []\n scrapers.each_pair do |group, scrapers_in_group|\n scrapers_in_group.each_pair do |key, val|\n roots << val if val.is_root?\n end\n end\n roots\n end", "def trees\n nests.map do |tree_instance|\n tree_isntance.tree\n end\n end", "def subtrees!\n trees = Array.new\n subtrees {|tree| trees.push(tree)}\n return trees\n end", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def root_expressions\n\n roots = @expressions.select { |e| e.h.parent_id == nil }\n\n roots = roots.each_with_object({}) { |e, h|\n h[\"#{e.h.fei['expid']}__#{e.h.fei['subid']}\"] = e\n }\n\n roots.keys.sort.collect { |k| roots[k] }\n end", "def all_in_tree\n accounts = Array.new\n accounts += ancestors\n accounts += sibling_accounts\n accounts += children\n accounts << self\n return accounts\n end", "def get_feature_reviews_roots\n @trees ||= self.product.category.self_and_ancestors.collect { |cat| [cat, Feature.node_roots(:include => :feature_reviews, :conditions => [\"features.category_id=? AND feature_reviews.review_id=?\", cat.id, id])] }\n end", "def get_root()\n \n end", "def binary_tree_paths(root)\n paths = []\n binary_tree_paths_recursive(root, [], paths)\n\n paths.map do |path|\n path.join(\"->\")\n end\nend", "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", "def roots(extension_name = nil)\n return @roots ||= self.extensions.map(&:root) if extension_name.nil?\n\n extension_name.to_s.camelize.constantize.root\n end", "def global; return root end", "def all_nodes\n nodes = []\n visit_nodes do |node|\n nodes.push node\n end\n nodes\n end", "def roots\n @objects = Node.roots\n respond_to do |format|\n format.html\n format.json {render json: @objects}\n end\n end", "def roots(extension_name = nil)\n return @roots ||= self.extensions.map { |extension| extension.root } if extension_name.nil?\n\n extension_name.to_s.camelize.constantize.root\n end", "def ancestors\n TreeNode.find(:all,\n :from => \"cms_treenode_ancestors(#{self.id}, #{AuthenticationModel.current_user}) tree_nodes\") rescue []\n end", "def find_all_nodes(*args)\n raise NotImplementedError\n nodes = @database.all_nodes\n # TODO: design node finder syntax\n nodes\n end", "def build_tree\n roots = Set.new\n hash = {}\n nodes = selected_nodes\n\n nodes.each do |node|\n loop do\n id = node.id\n parent_id = node.parent_id\n\n hash[id] ||= {}\n if hash.key?(parent_id)\n # Another loop has already added our parent. Add ourself to its hash\n # and break early.\n hash[parent_id][id] = hash[id]\n break\n else\n if selected_node_ids.include?(parent_id)\n # Our parent is a selected node. Add a hash for it and add ourself\n # to that. Keep looping to add our parent's parent.\n hash[parent_id] = {}\n hash[parent_id][id] = hash[id]\n node = nodes_by_id[parent_id]\n else\n # Our parent isn't selected, so we must be a root.\n roots.add(id)\n break\n end\n end\n end\n end\n\n hash.keep_if { |k, _| roots.include?(k) }\n end", "def regions\n @root\n end", "def roots_of(dump, root_dump: nil)\n if root_dump && root_dump.empty?\n raise ArgumentError, \"no roots provided\"\n end\n\n root_addresses =\n if root_dump then root_dump.addresses\n else\n ['ALL_ROOTS']\n end\n\n ensure_graphs_computed\n\n result_nodes = Set.new\n dump_addresses = dump.addresses\n root_addresses.each do |root_address|\n visitor = RGL::DijkstraVisitor.new(@forward_graph)\n dijkstra = RGL::DijkstraAlgorithm.new(@forward_graph, Hash.new(1), visitor)\n dijkstra.find_shortest_paths(root_address)\n path_builder = RGL::PathBuilder.new(root_address, visitor.parents_map)\n\n dump_addresses.each_with_index do |record_address, record_i|\n if path = path_builder.path(record_address)\n result_nodes.merge(path)\n end\n end\n end\n\n find_and_map do |record|\n address = record['address']\n next if !result_nodes.include?(address)\n\n # Prefer records in 'dump' to allow for annotations in the\n # source\n record = dump.find_by_address(address) || record\n record = record.dup\n record['references'] = result_nodes & record['references']\n record\n end\n end", "def root(v, w)\n v_ids = []\n w_ids = []\n roots = []\n\n @synsets.each do |key, value|\n if value.include?(v)\n v_ids.push(key)\n end\n if value.include?(w)\n w_ids.push(key)\n end\n end\n\n lcas = ancestor(v_ids, w_ids)\n if lcas == -1\n return -1\n else\n lcas.each do |a|\n roots += @synsets[a]\n end\n end\n return roots\n end", "def bfs\n return [] if @root.nil?\n end", "def find_all_parents\n end", "def get_feature_values_roots()\n @trees ||= self.category.self_and_ancestors.collect { |cat| [cat, Feature.node_roots(:include => :feature_values, :conditions => [\"features.category_id=? AND feature_values.product_id =?\", cat.id, id])] }\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def x_get_tree_roots(count_only, _options)\n count_only_or_objects(count_only,\n Rbac.filtered(ManageIQ::Providers::AnsibleTower::ConfigurationManager.order(\"lower(name)\"),\n :match_via_descendants => ConfigurationScript), \"name\")\n end", "def root\n return @root\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def page_tree\n @tree ||= [self.root_page.tree_hash_value]\n @tree\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def root_volumes\n volumes.select {|vol| vol.parent_id == nil}\n end", "def trees\n contents.select { |v| v.kind_of? Tree }\n end", "def root\n @root\n end", "def ancestors\n self.root? ? [] : self.parent.ancestors_and_self\n end", "def x_get_tree_roots\n count_only_or_objects(false, MiqPolicySet.all, :description)\n end", "def all_objects\n Registry.all(:root, :module, :class)\n end", "def find_incoming_roots(remote, opts={:base => nil, :heads => nil,\n :force => false, :base => nil})\n common_nodes(remote, opts)[1]\n end", "def all\n @store.transaction do\n @store.roots.map {|id| @store[id] }\n end\n end", "def get_root\n return self if tag == :root || parent.nil?\n parent.get_root\n end", "def nests\n Nest.all.select do |nest|\n nest.tree == self\n end\n end", "def recurse_otml_dirs(&block)\n return unless self.has_otmls\n yield(self)\n self.children.each do |child|\n child.recurse_otml_dirs(&block)\n end\nend", "def root_edges\n adjacent(root, :type => :edges)\n end", "def root_entity\n root = self\n loop do\n break if root.parent_id.nil?\n root = root.parent\n end\n root\n end", "def for_tree_nodes(tree_nodes, check_root_record = true)\n return {} if tree_nodes.empty?\n assert_same_type!(tree_nodes)\n\n # E.g. ArchivalObject\n node_model = tree_nodes[0].class.node_model\n\n # E.g. Resource\n root_model = tree_nodes[0].class.root_model\n\n # Initialize our result map to true -- assuming \"published\" by default.\n result = Hash[tree_nodes.map {|node| [node, true]}]\n\n if check_root_record\n # If we're the top-level call, we'll check the repository and root\n # record's publication status. There's no point doing this at every\n # level of the tree, but do it up front to save some potential work.\n root_record_id_to_child = {}\n tree_nodes.each do |node|\n if repository_published?(node[:repository_id])\n root_record_id_to_child[node.root_record_id] ||= []\n root_record_id_to_child[node.root_record_id] << node\n else\n result[node] = false\n end\n end\n\n return result if root_record_id_to_child.empty?\n\n root_model\n .filter(:id => root_record_id_to_child.keys)\n .filter(Sequel.|({:publish => 0},\n {:suppressed => 1}))\n .select(:id)\n .each do |root_record|\n root_record_id_to_child.fetch(root_record.id).each do |node|\n result[node] = false\n end\n end\n end\n\n parent_id_to_child = {}\n tree_nodes.each do |node|\n if result[node] && node.publish == 1 && node.suppressed == 0\n # OK so far, but check the ancestors.\n if node.parent_id\n parent_id_to_child[node.parent_id] ||= []\n parent_id_to_child[node.parent_id] << node\n end\n else\n # Unpublished/suppressed. Nothing more to check.\n result[node] = false\n end\n end\n\n unless parent_id_to_child.empty?\n parent_ids = parent_id_to_child.keys\n parent_publication_status = for_tree_nodes(node_model.filter(:id => parent_ids)\n .select(:id, :parent_id, :root_record_id, :publish, :suppressed)\n .all,\n false)\n\n parent_publication_status.each do |parent, published|\n # If the parent was unpublished, that overrides our previous result.\n parent_id_to_child.fetch(parent.id).each do |node|\n result[node] &&= published\n end\n end\n end\n\n result\n end", "def leaves\n #FIXME this is probably a bit newbish\n the_leaves = []\n each do |child|\n if child.kind_of? Tree\n the_leaves.push(child)\n else\n the_leaves = the leaves + (child.leaves)\n end\n end\n\n the_leaves\n end", "def find_root(circles=nil, roles=nil)\n circles ||= self.get :circles\n roles ||= self.get :roles\n Glassfrog::Graph.root(circles, roles)\n end", "def all_parents\n parents(all: true)\n end", "def find_outgoing_roots(remote, opts={:base => nil, :heads => nil, :force => false})\n base, heads, force = opts[:base], opts[:heads], opts[:force]\n if base.nil?\n base = {}\n find_incoming_roots remote, :base => base, :heads => heads, :force => force\n end\n \n UI::debug(\"common changesets up to \"+base.keys.map {|k| k.short_hex}.join(\" \"))\n \n remain = Hash.with_keys changelog.node_map.keys, nil\n \n # prune everything remote has from the tree\n remain.delete NULL_ID\n remove = base.keys\n while remove.any?\n node = remove.shift\n if remain.include? node\n remain.delete node\n changelog.parents_for_node(node).each {|p| remove << p }\n end\n end\n \n # find every node whose parents have been pruned\n subset = []\n # find every remote head that will get new children\n updated_heads = {}\n remain.keys.each do |n|\n p1, p2 = changelog.parents_for_node n\n subset << n unless remain.include?(p1) || remain.include?(p2)\n if heads && heads.any?\n updated_heads[p1] = true if heads.include? p1\n updated_heads[p2] = true if heads.include? p2\n end\n end\n \n # this is the set of all roots we have to push\n if heads && heads.any?\n return subset, updated_heads.keys\n else\n return subset\n end\n end", "def all\n Directory.all.map do |node_id|\n find node_id\n end\n end", "def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end", "def roots\n @fieldsets = DynamicFieldsets::Fieldset.roots\n\n respond_to do |format|\n format.html { render action: 'index' }\n end\n end", "def dump_root()\n self.dump_info(@evm.root, \"$evm.root\")\n end", "def paths\n root.paths\n end", "def roots\n if(rails_3?)\n configuration[:class].where(\n \"#{configuration[:foreign_key]} IS NULL\"\n ).order(configuration[:order])\n else\n configuration[:class].scoped(\n :conditions => \"#{configuration[:foreign_key]} IS NULL\",\n :order => configuration[:order]\n )\n end\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def x_get_tree_roots(count_only, _options)\n objects = Rbac.filtered(Dialog.all).sort_by { |a| a.label.downcase }\n count_only_or_objects(count_only, objects)\n end", "def all_children\n children(all: true)\n end", "def inorder\n if @root.nil?\n return []\n end\n return inorder_helper(@root, [])\n end", "def leaves\n result = children.where(is_dir: false).to_a\n dirs = children.where(is_dir: true).to_a\n while dirs.size > 0\n child = dirs.pop\n dirs += child.children.where(is_dir: true)\n result += child.children.where(is_dir: false)\n end\n result\n end", "def bfs\n return bfs_helper(@root, [])\n end", "def root_nodes\n @nodes ||= discovered_files.collect do |file|\n raising_with_file file[0] do\n Dock::Node.new context.call('Dock.generate', *file, language)\n end\n end\n end" ]
[ "0.7494112", "0.7006442", "0.6990156", "0.6775148", "0.6615451", "0.6530727", "0.6464751", "0.63990253", "0.63784933", "0.6316445", "0.63004977", "0.62469256", "0.62237465", "0.6211025", "0.61942333", "0.61899465", "0.6174147", "0.61655897", "0.61340314", "0.6131425", "0.6114312", "0.6086924", "0.6069337", "0.60640466", "0.60528815", "0.6019361", "0.5967279", "0.5931865", "0.5929475", "0.58739835", "0.5858424", "0.5808567", "0.58019185", "0.5801393", "0.5794313", "0.5793272", "0.57921326", "0.57702756", "0.5764552", "0.5749822", "0.572328", "0.5694976", "0.5660019", "0.5643785", "0.563926", "0.56316394", "0.5631555", "0.56103605", "0.5609753", "0.5585662", "0.5572827", "0.55684686", "0.5565515", "0.55593145", "0.5558267", "0.5537403", "0.5532095", "0.55024225", "0.5497042", "0.5486232", "0.5475434", "0.5473719", "0.5469145", "0.54644066", "0.5454163", "0.5437836", "0.5437836", "0.54374", "0.54320264", "0.5431845", "0.54237026", "0.54202044", "0.5420126", "0.5416176", "0.5407938", "0.54073966", "0.5406192", "0.54034144", "0.53976536", "0.53926146", "0.5363875", "0.53261435", "0.53078115", "0.53040344", "0.53037965", "0.5298063", "0.5297286", "0.529321", "0.52895176", "0.52771485", "0.5272802", "0.52722186", "0.5270116", "0.52700835", "0.5267818", "0.5261382", "0.52597517", "0.52573645", "0.5254535", "0.52433765" ]
0.6628554
4
Recalculate the left/right values of all nodes. Can be used to convert ordinary trees into nested sets.
def renumber_all scopes = [] # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems) roots.each do |r| r.renumber_full_tree unless scopes.include?(r.scope_condition) scopes << r.scope_condition end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end", "def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end", "def set_default_left_and_right\n maxright = dataset.nested.max(self.class.qualified_right_column).to_i || 0\n # adds the new node to the right of all existing nodes\n self.left = maxright + 1\n self.right = maxright + 2\n end", "def rebuild!\n # Don't rebuild a valid tree.\n return true if valid?\n \n scope = lambda{ |node| {} }\n if acts_as_nested_set_options[:scope]\n scope = lambda { |node|\n scope_column_names.inject({}) { |hash, column_name|\n hash[column_name] = node.send(column_name.to_sym)\n hash\n }\n }\n end\n indices = {}\n \n set_left_and_rights = lambda do |node|\n # set left\n node.send(:\"#{left_column_name}=\", (indices[scope.call(node)] += 1))\n # find\n all(scope.call(node).merge(parent_column_name => node.id)).each { |n| set_left_and_rights.call(n) }\n # set right\n node.send(:\"#{right_column_name}=\", (indices[scope.call(node)] += 1))\n node.save! \n end\n \n # Find root node(s)\n root_nodes = all(parent_column_name => nil, :order => \"#{left_column_name}, #{right_column_name}, id\").each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n set_left_and_rights.call(root_node)\n end\n end", "def set_default_left_and_right\n unless @skip_nested_set_callbacks\n maxright = base_class.first(scoped(:order => \"#{right_column_name} DESC\")).try(right_column_name) || 0\n # adds the new node to the right of all existing nodes\n self[left_column_name] = maxright + 1\n self[right_column_name] = maxright + 2\n end\n end", "def set_default_left_and_right\n maxright = nested_set_scope.remove_order_by.max(right_field_name) || 0\n self[left_field_name] = maxright + 1\n self[right_field_name] = maxright + 2\n self[:depth] = 0\n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n left.parent = self unless left.parent\n @right = ruby_block.call(@right)\n right.parent = self unless right.parent\n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n @left.parent = self unless @left.parent\n @right = ruby_block.call(@right)\n @right.parent = self unless @right.parent\n end", "def left_rotate( node=@tree )\n node.left = node.right\n node.right = node.right.right\n node.left.right = nil\n node.value, node.left.value = node.left.value, node.value\n end", "def prune_from_tree\n return if self.right.nil? || self.left.nil?\n diff = self.right - self.left + 1\n\n #TODO: implemente :dependent option\n # delete_method = acts_as_nested_set_options[:dependent] == :destroy ?\n # :destroy_all : :delete_all\n\n #TODO: implement prune method\n # self.class.base_class.transaction do\n # nested_set_scope.send(delete_method,\n # [\"#{quoted_left_column_name} > ? AND #{quoted_right_column_name} < ?\",\n # left, right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_left_column_name} = (#{quoted_left_column_name} - ?)\", diff],\n # [\"#{quoted_left_column_name} >= ?\", right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)\", diff],\n # [\"#{quoted_right_column_name} >= ?\", right]\n # )\n # end\n end", "def double_left_rotate( node=@tree )\n node.left = node.right.left\n node.right.left = nil\n node.value, node.left.value = node.left.value, node.value\n end", "def rebuild!\n\n scope = lambda{}\n # TODO: add scope stuff\n \n # Don't rebuild a valid tree.\n return true if valid?\n indices = {}\n \n move_to_child_of_lambda = lambda do |parent_node|\n # Set left\n parent_node[nested_set_options[:left_column]] = indices[scope.call(parent_node)] += 1\n # Gather child noodes of parend_node and iterate by children\n parent_node.children.order(:id).all.each do |child_node|\n move_to_child_of_lambda.call(child_node)\n end\n # Set right\n parent_node[nested_set_options[:right_column]] = indices[scope.call(parent_node)] += 1\n parent_node.save\n end\n\n # Gatcher root nodes and iterate by them\n self.roots.all.each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n move_to_child_of_lambda.call(root_node)\n end\n end", "def reduceTree( rootNode=@root )\n return if rootNode.nil?\n return if (rootNode.leftChild.nil? && rootNode.rightChild.nil? )\n reduceTree( rootNode.leftChild ) \n reduceTree( rootNode.rightChild )\n\n # If both children are numeric values, we can just perform the proper\n # operation on the children values and then replace the current node's\n # data with the result\n if( rootNode.leftChild.isNumeric? && rootNode.rightChild.isNumeric? )\n # This is a little verbose\n case rootNode.data\n when '+'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f + rootNode.rightChild.data.to_f).to_s )\n when '-'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f - rootNode.rightChild.data.to_f).to_s )\n when '*'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f * rootNode.rightChild.data.to_f).to_s )\n when '/'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f / rootNode.rightChild.data.to_f).to_s )\n end\n rootNode.leftChild = nil\n rootNode.rightChild = nil\n end\n\n end", "def shift_values(root)\n root.value = get_next_value(root.right)\n root.right = right_subtree_without_next_value(root.right)\n root\n end", "def each_node(&block)\n block.call(@value)\n @left.each_node(&block) if @left\n @right.each_node(&block) if @right\n end", "def convert_binary_tree_to_mirror(root)\n return if !root\n temp_node = Node.new()\n # recursively call the method on both left and right subtrees\n convert_binary_tree_to_mirror(root.left_child)\n convert_binary_tree_to_mirror(root.right_child)\n\n # swap the left and right subtrees\n temp_node = root.left_child\n root.left_child = root.right_child\n root.right_child = temp_node\n\n return root\nend", "def sum_of_left_leaves(root)\nend", "def nodes\n left_nodes + [self] + right_nodes\n end", "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def reload_nested_set\n doc = self.class.find(_id)\n self.class.associations.each { |name, assoc| send(name).reset if respond_to?(name) }\n [ left_column_name, right_column_name, parent_column_name ].each do |column|\n send :\"#{column}=\", doc.send(column.to_sym)\n end\n self\n end", "def recompute_recursive_subsets\n @recursive_subsets = subsets.inject(ValueSet.new) do |set, child|\n set.merge(child.recursive_subsets)\n end\n if parent\n parent.recompute_recursive_subsets\n end\n end", "def recalculate!(tree,order,memo=nil,&block)\n if tree\n\n case order\n when :postorder\n \n arr = tree.children.map{ |t| recalculate!(t,order,memo,&block) }\n result = block.call(arr.push tree.data)\n tree.data = result\n\n\n when :preorder\n \n tree.data = yield tree, memo\n memo = tree.data\n\n tree.children.each do |t|\n recalculate!(t,order,memo,&block)\n end\n\n when :inorder\n raise ArgumentError unless self.tree.is_a? BinaryTree\n recalculate!(tree.left,order,memo,&block)\n\n tree.data = yield tree, memo\n memo = tree.data\n\n recalculate!(tree.right,order,memo,&block)\n\n end\n end\n end", "def clear_nodes\n\t\t\t@tree = []\n\t\t\t@node_stack = [ @tree ]\n\t\tend", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.left.replace_expressions!(node2rep)\n res.merge!(self.right.replace_expressions!(node2rep))\n # Is there a replacement to do on the left?\n rep = node2rep[self.left]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.left\n # node.set_parent!(nil)\n self.set_left!(rep)\n # And register the replacement.\n res[node] = rep\n end\n # Is there a replacement to do on the right?\n rep = node2rep[self.right]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.right\n # node.set_parent!(nil)\n self.set_right!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.left.replace_expressions!(node2rep)\n res.merge!(self.right.replace_expressions!(node2rep))\n # Is there a replacement to do on the left?\n rep = node2rep[self.left]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.left\n # node.set_parent!(nil)\n self.set_left!(rep)\n # And register the replacement.\n res[node] = rep\n end\n # Is there a replacement to do on the right?\n rep = node2rep[self.right]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.right\n # node.set_parent!(nil)\n self.set_right!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def clear_node\n self.value = nil\n self.left_child = nil\n self.right_child = nil\n end", "def invert_tree root\n temp_pointer = root.left\n root.left = root.right\n root.right = temp_pointer\n\n invert_tree(root.left) if root.left\n invert_tree(root.right) if root.right\n root\nend", "def rotate_left\n root = @right\n @right = root.left\n root.left = self\n root.left.update_height\n root\n end", "def normalise!(tree)\n tree.each.with_index do |node, i|\n if node.is_a?(Array)\n if node.first == :loop && tree[i+1]\n key = tree[i+1][0]\n if key == :block\n tree[i+1][0] = :lblock\n elsif key == :query # wrap queries like `c.each(&:destroy)` \n tree[i+1] = [:lblock, tree[i+1]]\n end\n end\n tree[i] = normalise!(node)\n end\n end\n tree\n end", "def right_rotate( node=@tree )\n node.right = node.left\n node.left = node.left.left\n node.right.left = nil\n node.value, node.right.value = node.right.value, node.value\n end", "def recalculate_hash_at(node)\n return node._hash = node.value if node.value\n recalculate_hash_at(node.left) if node.left\n recalculate_hash_at(node.right) if node.right\n node._hash = self.class.hash_children(*node_subhashes(node))\n end", "def each\n unless left.nil?\n unless left_number.left.nil? then yield left_number.left.data end\n yield left_number.data\n unless left_number.right.nil? then yield left_number.right.data end\n end\n yield number\n unless right.nil?\n unless right_number.left.nil? then yield right_number.left.data end\n yield right_number.data\n unless right_number.right.nil? then yield right_number.right.data end\n end\n end", "def mirror_tree_support(node)\n return if node.nil?\n tmp = node.left\n node.left = node.right\n node.right = tmp\n mirror_tree_support(node.left)\n mirror_tree_support(node.right)\n end", "def convert_to_mirror(node)\n return if node.nil?\n\n # We will do a post-order traversal of the binary tree.\n convert_to_mirror(node.left) unless node.left.nil?\n convert_to_mirror(node.right) unless node.right.nil?\n\n # Let's swap the left and right nodes at current level.\n temp = node.left\n node.left = node.right\n node.right = temp\nend", "def invert_tree(root)\n # recursive base case\n return nil if root.nil?\n\n # perform operation (switching left and right children) on root\n root.left, root.right = root.right, root.left\n\n # recursively perform operation on children\n invert_tree(root.left)\n invert_tree(root.right)\n\n root\nend", "def reset\n @left_generator.reset\n @right_generator.reset\n\n nil\n end", "def map_nodes!(&ruby_block)\n @range = ruby_block.call(@range.first)..ruby_block.call(@range.last)\n @range.first.parent = self unless @range.first.parent\n @range.last.parent = self unless @range.last.parent\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end", "def rebalance\n order = self.level_order\n return build_tree(order)\n end", "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\t\tbalanced_rotate_left\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# flip this sub-tree into another type of 3-children node\n\t\t\t\t\tret = rotate_left\n\t\t\t\t\t# try to rebalance in sub-tree\n\t\t\t\t\tleft, rebalance = ret.left.rebalance_for_left_delete\n\t\t\t\t\traise 'should not happen' if rebalance\n\t\t\t\t\tret.with_left(left)\n\t\t\t\tend\n\t\t\telse # red\n\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t# make right sub-tree 1 level lower\n\t\t\t\t\twith_right(@right.with_color(color)).with_color(@right.color)\n\t\t\t\telse\n\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\tbalanced_rotate_left\n\t\t\t\tend\n\t\t\tend, rebalance]\n\t\tend", "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 evaluate(parsed_tree)\n left_child = parsed_tree.left_child\n right_child = parsed_tree.right_child\n\n if left_child && right_child\n return evaluate(left_child).send(parsed_tree.get_root_value, evaluate(right_child))\n else\n return parsed_tree.get_root_value\n end\nend", "def merge_trees(t1, t2)\n return t2 if t1 == nil\n return t1 if t2 == nil\n value = t1.val += t2.val\n new = TreeNode.new(value)\n new.left = merge_trees(t1.left, t2.left)\n new.right = merge_trees(t1.right, t2.right)\n return new\nend", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def double_right_rotate( node=@tree )\n node.right = node.left.right\n node.left.right = nil\n node.value, node.right.value = node.right.value, node.value\n end", "def invert_tree(root)\n return nil unless root\n\n left_inverted = invert_tree(root.left)\n right_inverted = invert_tree(root.right)\n\n root.left = right_inverted\n root.right = left_inverted\n\n root\nend", "def convert_to_mirror_iterative(node)\n return if node.nil?\n\n queue = [node]\n while queue.any?\n current = queue.shift\n queue << current.left unless current.left.nil?\n queue << current.right unless current.right.nil?\n current.left = current.left\n current.right = current.right\n end\nend", "def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n \n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n base_class.delete_all scoped(left_column_name => { '$gt' => left }, right_column_name => { '$lt' => right })\n end\n \n # update lefts and rights for remaining nodes\n diff = right - left + 1\n base_class.all(scoped(left_column_name => { '$gt' => right })).each do |node|\n node.update_attributes left_column_name => node.left - diff\n end\n base_class.all(scoped(right_column_name => { '$gt' => right })).each do |node|\n node.update_attributes right_column_name => node.right - diff\n end\n \n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end", "def left=(other)\n raise TypeError, 'Left must be a node or nil.' unless other.is_a?(Node) || other.nil?\n\n @left = other\n end", "def nodes_except_self_leftward\n LinkEnumerator.new :left, self\n end", "def invert_tree(root)\n return if root.nil?\n root.left, root.right = root.right, root.left\n invert_tree(root.left)\n invert_tree(root.right)\n\n root\nend", "def update_children(node, new_node)\n\t\tleft \t= node.left\n\t\tright = node.right\n\t\tleft.parent = new_node unless left.nil? \n\t\tright.parent = new_node unless right.nil?\n\tend", "def all_right\n @right.empty? ? [self] : @right.flat_map { |r| r.all_right }.uniq\n end", "def calculate(node = self.tree)\n\n # base case when a leaf is reached (number) \n return ExpressionTree.process_number(node.value) if node.left.nil? && node.right.nil?\n\n left = Number.new(0)\n if node.left\n left = calculate(node.left)\n end\n\n right = Number.new(0)\n if node.left\n right = calculate(node.right)\n end\n\n # using send to pass the actual operator and evaluate ir using overloading of operators\n return left.send(node.value,right) \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 left=(value)\n @left = value\n end", "def left=(value)\n @left = value\n end", "def before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts_as_nested_set_options[:right_column]] = maxright+2\n end", "def set_left_right # already protected by a transaction within #create\n maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0\n self[left_col_name] = maxright+1\n self[right_col_name] = maxright+2\n end", "def reset_all_nodes\n nodes.where(net_id: id).each do |node|\n node.output = 0\n node.total_input = 0\n node.save\n end\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 reload_nested_set\n reload(:select => \"#{quoted_left_column_name}, \" +\n \"#{quoted_right_column_name}, #{quoted_parent_column_name}\")\n end", "def invert_tree(root)\n return root unless root\n\n temp = root.left\n root.left = invert_tree(root.right)\n root.right = invert_tree(temp)\n\n root\nend", "def revalue\n @value = nil\n @ops.each do |v|\n v[1].revalue\n end\n end", "def initialize(*)\n super\n @left = optimize_left\n @right = optimize_right\n end", "def each &block\n return enum_for(:each) unless block_given?\n @left.each(&block) if @left\n yield @value\n @right.each(&block) if @right\n nil\n end", "def invert_tree(root)\n return nil if root.nil?\n\n invert_tree(root.left)\n invert_tree(root.right)\n\n temp = root.left\n root.left = root.right\n root.right = temp\n\n root\nend", "def setLeft(nodeCurrent, nodeLeft)\n return nodeCurrent.setLeft(nodeLeft)\n end", "def assign_tree(tree)\n nodes = tree.sort_by { |e| e['weight'].to_i }\n new_collection_ids = nodes.map { |e| e['id'] }\n if ordered_subset?(new_collection_ids)\n removed_collection_ids = collection_member_ids - new_collection_ids\n self.member_ids = (member_ids.map(&:to_s) - removed_collection_ids) unless removed_collection_ids.empty?\n else\n self.member_ids = new_collection_ids + noncollection_member_ids\n end\n nodes.each do |node|\n b = ActiveFedora::Base.find(node['id'])\n b.assign_tree node['children']\n b.save! #TODO We could move this save into an after_save hook.\n end\n end", "def calc_numbers(n, indexes) #:nodoc:\n my_lft = n\n # performance improvements (3X or more for tables with lots of columns) by using :select to load just id, lft and rgt\n ## i don't use the scope condition here, because it shouldn't be needed\n my_children = base_set_class.find(:all, :conditions => \"#{parent_col_name} = #{self.id}\",\n :order => left_col_name, :select => \"#{self.class.primary_key}, #{left_col_name}, #{right_col_name}\")\n if my_children.empty?\n my_rgt = (n += 1)\n else\n for c in (my_children)\n n = c.calc_numbers(n + 1, indexes)\n end\n my_rgt = (n += 1)\n end\n indexes << {:id => self.id, :lft => my_lft, :rgt => my_rgt} unless self[left_col_name] == my_lft && self[right_col_name] == my_rgt\n return n\n end", "def convert_to_ints\n @tree.each_index do |vert_pos|\n @tree[vert_pos].each_index do |horiz_pos|\n @tree[vert_pos][horiz_pos] = @tree[vert_pos][horiz_pos].to_i\n end\n end\n end", "def convert_tree(tree)\n return nil,nil if tree.nil?\n left_list_head,left_list_tail = convert_tree(tree.left) \n right_list_head,right_list_tail = convert_tree(tree.right)\n current_head, current_tail = tree,tree\n if left_list_tail\n current_head = left_list_head\n tree.left = left_list_tail\n left_list_tail.right = tree\n end\n if right_list_head\n current_tail = right_list_tail\n tree.right = right_list_head\n right_list_head.left = tree\n end\n [current_head,current_tail]\nend", "def delete_zero_sum_sub_trees(root)\n return 0 if root.nil?\n\n left = right = 0\n\n left = delete_zero_sum_sub_trees(root.left)\n right = delete_zero_sum_sub_trees(root.right)\n\n if left == 0\n root.left = nil\n end\n\n if right == 0\n root.right = nil\n end\n\n sum = root.value + left + right\n\n return sum\nend", "def invert_tree_dfs_iter(root)\n stack = [root]\n while !stack.empty?\n node = stack.pop()\n next if !node\n node.left, node.right = node.right, node.left\n stack += [node.left, node.right]\n end\n\n root\nend", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def pos; [lft,rgt] end", "def reload_nested_set\n reload(\n :select => \"#{quoted_left_column_full_name}, #{quoted_right_column_full_name}, #{quoted_parent_column_full_name}\",\n :lock => true\n )\n end", "def clone\n new_set = TreeSet.new\n # Create new nodes in the same order as self's\n if root\n root.root_traverse do |node|\n new_set << node.value\n end\n end\n new_set\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 initial_setup\n # set initial values of vert_pos and sum\n vert_pos = 0\n @sum = @tree[0][0]\n\n # set initial children nodes\n @initial_child_1 = @tree[1][0]\n @initial_child_2 = @tree[1][1]\n end", "def reset_nodes\n # get all nodes for the active game\n self.nodes.update_all(:game_id => nil) \n # reset ownership for all nodes\n end", "def recalculate(inode)\n full_count = 0\n inode.list_of_children.each do |node|\n#p node\n komvos = self.get(node)\n#p komvos\n if komvos.normalize==0\n puts \"node #{node} is not leaf\"\n # if not leaf\n #recalc(holon.searchFor(node).listOfChildren)\n self.recalculate(komvos)\n else \n # exw kanei: node.normalize kai einai leaf\n puts \"node #{node} is leaf\"\n \n end\n # uplogizw to sum of coun and re-normalize\n full_count = full_count + komvos.weight\n end\n inode.weight = full_count\n end", "def nested_set_recurse(&block)\n self.each do |x| \n x.nested_set_recurse(self, &block)\n end\n end", "def set_nodes(nodeids)\n # Have to be careful here to handle existing virtual assignments\n # properly. If the user has specified a new node and there's an\n # existing virtual assignment we need to convert that into a real\n # assignment. And when removing nodes that the user didn't\n # specify we don't want to remove virtual assignments.\n \n # First ensure that all of the specified assignments exist\n new_assignments = []\n nodeids.each do |nodeid|\n node = Node.find(nodeid)\n if !node.nil?\n assignment = NodeGroupNodeAssignment.find_by_node_group_id_and_node_id(id, nodeid)\n if assignment.nil?\n assignment = NodeGroupNodeAssignment.new(:node_group_id => id,\n :node_id => nodeid)\n new_assignments << assignment\n elsif assignment.virtual_assignment?\n assignment.update_attributes(:virtual_assignment => false)\n end\n end\n end\n \n # Save any new assignments\n node_assignment_save_successful = true\n new_assignments.each do |assignment|\n if !assignment.save\n node_assignment_save_successful = false\n # Propagate the error from the assignment to ourself\n # so that the user gets some feedback as to the problem\n assignment.errors.each_full { |msg| errors.add(:node_ids, msg) }\n end\n end\n \n # Now remove any existing assignments that weren't specified\n node_group_node_assignments.each do |assignment|\n if !nodeids.include?(assignment.node_id) && !assignment.virtual_assignment?\n assignment.destroy\n end\n end\n \n node_assignment_save_successful\n end", "def map_nodes!(&ruby_block)\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end", "def rotate_left(node)\n puts \"left rotation on node #{node}\"\n v = node.right\n v.parent = node.parent\n node.right = v.left\n\n node.right.parent=node unless node.right.nil?\n\n v.left = node\n node.parent = v\n\n unless v.parent.nil?\n v.parent.right = v if v.parent.right==node\n v.parent.left = v if v.parent.left==node\n end\n\n update_balance(node)\n update_balance(v)\n v\n end", "def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.value.replace_expressions!\n # Is there a replacement to do on the value?\n rep = node2rep[self.value]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.value\n # node.set_parent!(nil)\n self.set_value!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def consolidate\n roots = []\n root = @next\n min = root\n # find the nodes in the list\n loop do\n roots << root\n root = root.right\n break if root == @next\n end\n degrees = []\n roots.each do |root|\n min = root if @compare_fn[root.key, min.key]\n # check if we need to merge\n if degrees[root.degree].nil? # no other node with the same degree\n degrees[root.degree] = root\n next\n else # there is another node with the same degree, consolidate them\n degree = root.degree\n until degrees[degree].nil? do\n other_root_with_degree = degrees[degree]\n if @compare_fn[root.key, other_root_with_degree.key] # determine which node is the parent, which one is the child\n smaller, larger = root, other_root_with_degree\n else\n smaller, larger = other_root_with_degree, root\n end\n link_nodes(larger, smaller)\n degrees[degree] = nil\n root = smaller\n degree += 1\n end\n degrees[degree] = root\n min = root if min.key == root.key # this fixes a bug with duplicate keys not being in the right order\n end\n end\n @next = min\n end", "def rotate_left\n\t\t\troot = @right\n\t\t\troot = root.with_left(with_right(root.left))\n\t\t\troot.with_left(root.left.with_color(root.color)).with_color(root.left.color)\n\t\tend", "def full_set(options = {})\n return [self] if new_record? or self[nested_set_right]-self[nested_set_left] == 1\n [self] + all_children(options)\n end", "def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end", "def destroy_descendants # already protected by a transaction within #destroy\n return if self[right_col_name].nil? || self[left_col_name].nil? || self.skip_before_destroy\n reloaded = self.reload rescue nil # in case a concurrent move has altered the indexes - rescue if non-existent\n return unless reloaded\n dif = self[right_col_name] - self[left_col_name] + 1\n if acts_as_nested_set_options[:dependent] == :delete_all\n base_set_class.delete_all( \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\" ) \n else \n set = base_set_class.find(:all, :conditions => \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\", :order => \"#{prefixed_right_col_name} DESC\") \n set.each { |child| child.skip_before_destroy = true; remove_descendant(child) } \n end\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \\\n ELSE #{right_col_name} END\",\n scope_condition)\n end", "def each(&p)\n @left.each(&p)\n\tyield(@value)\n\[email protected](&p)\n end", "def original_tree\n\n @root_expression && @root_expression.original_tree\n end" ]
[ "0.7184487", "0.7098187", "0.65608287", "0.64842767", "0.6427803", "0.63191175", "0.62815183", "0.62173057", "0.6019624", "0.59977704", "0.5987223", "0.59181285", "0.5853808", "0.5853663", "0.58239204", "0.5711054", "0.57010436", "0.5676017", "0.56590146", "0.5627154", "0.5611065", "0.55980766", "0.55540663", "0.55389124", "0.55389124", "0.5535398", "0.55141354", "0.5511323", "0.54866445", "0.5473109", "0.5471071", "0.54667276", "0.5455282", "0.5432253", "0.54312295", "0.542758", "0.540079", "0.5396647", "0.53420675", "0.53370744", "0.5324207", "0.5322565", "0.5321089", "0.53035086", "0.5299359", "0.5269036", "0.5260902", "0.5254576", "0.5238402", "0.52362275", "0.5235124", "0.52233726", "0.52166104", "0.5211308", "0.520652", "0.520652", "0.52027863", "0.52008075", "0.51988155", "0.51982415", "0.519805", "0.51945287", "0.51905787", "0.5174612", "0.51629984", "0.51587605", "0.5157556", "0.5151647", "0.51474524", "0.51422995", "0.5137604", "0.5135556", "0.51326054", "0.51227725", "0.5120399", "0.5120399", "0.5120399", "0.5120399", "0.5120399", "0.5120399", "0.5120399", "0.5120399", "0.51186794", "0.5113397", "0.51121503", "0.51090515", "0.51056576", "0.51028454", "0.50964266", "0.50962746", "0.508155", "0.5068721", "0.50583255", "0.5056139", "0.5054912", "0.50497794", "0.50481665", "0.5046987", "0.5046627", "0.5037518", "0.5032215" ]
0.0
-1
On creation, automatically add the new node to the right of all existing nodes in this tree.
def before_create # already protected by a transaction maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0 self[left_col_name] = maxright+1 self[right_col_name] = maxright+2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts_as_nested_set_options[:right_column]] = maxright+2\n end", "def set_default_left_and_right\n maxright = dataset.nested.max(self.class.qualified_right_column).to_i || 0\n # adds the new node to the right of all existing nodes\n self.left = maxright + 1\n self.right = maxright + 2\n end", "def insert_right(value)\n right.insert(value) or self.right = Node.new(value, self)\n end", "def add_node(current_node, v)\n left = current_node.left if current_node.left\n right = current_node.right if current_node.right\n current_node.left = TreeNode.new(v)\n current_node.right = TreeNode.new(v)\n current_node.left.left = left\n current_node.right.right = right\nend", "def insert_right( item )\n # note this works both if subtree is nil or if one is already present\n new_right = BinaryTree.new( item )\n new_right.right_subtree = self.right_subtree\n @right_subtree = new_right\n end", "def push(node)\n node.parent = self if node.respond_to? :parent\n super(node)\n end", "def set_default_left_and_right\n unless @skip_nested_set_callbacks\n maxright = base_class.first(scoped(:order => \"#{right_column_name} DESC\")).try(right_column_name) || 0\n # adds the new node to the right of all existing nodes\n self[left_column_name] = maxright + 1\n self[right_column_name] = maxright + 2\n end\n end", "def add_node( node )\n super( node )\n __add_node__( node )\n end", "def <<(node)\n root << node\n end", "def <<(node)\n existing = node_for(node.name)\n\n if existing\n children.delete(existing)\n\n self.children << (existing + node)\n else\n node.parent = self\n self.children << node\n node\n end\n end", "def <<(node); add(node); end", "def add_node(node); end", "def insert_left(obj)\n self.left, self.right = obj.left, obj\n reinsert_horizontal\n end", "def add_child(node)\n node.build\n nodes << node\n end", "def append_tree( newtree )\n\t\t\tnewtree.each do |node|\n\t\t\t\tself.node_stack.last << node\n\t\t\tend\n\t\tend", "def insert_node\n insert_node_helper(@root)\n end", "def add_node(key, value)\n node = Node.new(key, value)\n\n # if there is current no root node set for the tree we need to set it\n if root.nil?\n @root = node\n else\n # lets find where we need to place the node \n current = @root\n placed = false\n\n while not placed\n # get the property to travese, either left_child or right_child\n property = direction(node.key, current.key)\n\n # set a pointer to remember the previous loops node value and\n # change the current value current based on the property flag \n parent = current\n current = current.send(property)\n\n # if the node under examination is nil then this means we have found\n # a spot to place the current node and we set the placed flag to \n # true in order to exit out of the loop\n if current.nil?\n parent.send(property+'=', node)\n placed = true\n end\n end\n\n end\n end", "def put_in_place\n if place==:append\n item = self\n self.class.with_tree_scope(self) do\n root.append(item)\n end\n end\n end", "def update_children(node, new_node)\n\t\tleft \t= node.left\n\t\tright = node.right\n\t\tleft.parent = new_node unless left.nil? \n\t\tright.parent = new_node unless right.nil?\n\tend", "def test_insert_node_to_right\n @tree.insert(\"c\")\n @tree.insert(\"a\")\n @tree.insert(\"d\")\n refute_equal nil, @tree.root.right\n end", "def add_to_tree(curr_node, new_node, queue = [])\n if curr_node.nil?\n curr_node = new_node\n elsif curr_node.left_node.nil?\n curr_node.left_node = new_node\n elsif curr_node.right_node.nil?\n curr_node.right_node = new_node\n else\n queue.push(curr_node.left_node)\n queue.push(curr_node.right_node)\n next_node = queue.shift\n next_node = add_to_tree(next_node, new_node, queue)\n end\n curr_node\n end", "def <<(node)\n n = find_by_term(node.term)\n if n.nil? then\n @children.push(node)\n node.parent = self\n return node\n else\n n.merge(node)\n return n\n end\n end", "def move_to_right_of(node)\n self.move_to node, :right\n end", "def <<(node)\n @child_array.push(node)\n node.parent = self\n end", "def move_to_right_of(node)\n self.move_to node, :right\n end", "def move_to_right_of(node)\n self.move_to(node, :right)\n end", "def insert_brother_node(path, node)\n @rootNode.get_node(path).add_rightbrother_node(node)\n end", "def right_rotate(node)\n l_child = node.l\n if node.p\n node == node.p.l ? node.p.l = l_child : node.p.r = l_child\n else\n @root = l_child\n end\n node.l = l_child.r\n l_child.r.p = node\n l_child.r = node\n l_child.p = node.p\n node.p = l_child\n end", "def rebalance_for_right_insert\n\t\t\tif @right.left.red?\n\t\t\t\twith_right(@right.rotate_right)\n\t\t\telse\n\t\t\t\tself\n\t\t\tend.rotate_left\n\t\tend", "def add_to_tree(item, node)\n return rebalance(super(item, node))\n end", "def nodes\n left_nodes + [self] + right_nodes\n end", "def insert_left(val)\n\t\t\tleft.insert(val) or self.left = Node.new(val)\n\t\tend", "def move_to_right_of(node)\n move_to node, :right\n end", "def move_to_right_of(node)\n move_to node, :right\n end", "def move_to_right_of(node)\n move_to node, :right\n end", "def move_right\n move_to_right_of right_sibling\n end", "def move_right\n move_to_right_of right_sibling\n end", "def move_right\n self.move_to_right_of(self.right_sibling)\n end", "def rotate_right\n root = @left\n @left = root.right\n root.right = self\n root.right.update_height\n root\n end", "def add_node(new_node)\n @nodes[new_node] ||= Array.new #only adds if not in graph\n @node_dir_ancestors[new_node] ||= Array.new\n end", "def calculate_right_child\n # Guard condition for movement not possible\n return nil if blank_x - 1 < 0\n\n # Make the movement\n new_state = swap_right\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x - 1, blank_y)\n end", "def store(node)\n if !node.nil?\n @children.push(node) if [email protected]?(Node)\n node.parent = self if node.parent != self\n end\n node\n end", "def update_nodes\n incr = 0\n self.original_nodes.build(:displayed => true) if not new_record? and self.original_nodes.count == 0 # Insure at least 1 node\n self.original_nodes.each do |node|\n node.title = self.name\n node.menu_name = self.name\n incr = (node.new_record? ? node.set_safe_shortcut(self.name.parameterize.html_safe, 0, incr) : node.set_safe_shortcut(self.name.parameterize.html_safe, node.id, incr))\n node.displayed = self.display\n incr += 1\n end\n end", "def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n left.parent = self unless left.parent\n @right = ruby_block.call(@right)\n right.parent = self unless right.parent\n end", "def <<(node); end", "def push_tree\n new_node = NaryTree.new nil\n @tree_stack.last.children << new_node\n @tree_stack.push new_node\n end", "def create_node!\n node.save\n end", "def add_node(node)\n\t\t\tunless has_node?(node)\n\t\t\t\t@nodes[node] = new_node(node)\n\t\t\t\t@order += 1\n\t\t\tend\n\t\t\tself\n\t\tend", "def add(key, value)\n new_nodelet = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_nodelet \n else \n @root = add_helper(@root, new_nodelet)\n end \n end", "def addNodeChild node, name\n\t\tif @root != nil\n\t\t if !node.leftChild\n\t\t \tnode.leftChild = Node.new name\n\t\t \treturn node.leftChild\n\t\t end\n\n\t\t if !node.rightChild\n\t\t \tnode.rightChild = Node.new name\n\t\t \treturn node.rightChild\n\t\t end\n\t\tend\n\tend", "def assign_position\n # Position for new nodes is (number of siblings + 1), but only for new categories\n if self.read_attribute(parent_id_column).nil?\n self.write_attribute(position_column, self.class.roots(true).size + 1)\n else\n self.write_attribute(position_column, self.class.find(:all, :conditions => [\"#{parent_id_column} = ?\", self.read_attribute(parent_id_column)]).size + 1)\n end\n end", "def insert_right(value, tree)\n right = tree[:right]\n if right == nil\n right = Hash.new()\n right[:parent] = tree\n tree[:right] = right\n end\n insert(value, right)\nend", "def insert_left( item )\n # note this works both if subtree is nil or if one is already present\n new_left = BinaryTree.new( item )\n new_left.left_subtree = self.left_subtree\n @left_subtree = new_left\n end", "def branch\n descendents.unshift(self)\n end", "def <<(node)\n node.dispatcher = @dispatcher\n @nodes << node\n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n @left.parent = self unless @left.parent\n @right = ruby_block.call(@right)\n @right.parent = self unless @right.parent\n end", "def concat(other)\n @left, @right = Node.new(@left, @right), Rope.Node(other)\n update_size\n update_depth\n end", "def <<(relation)\n new_node(relation.name, relation)\n end", "def update_nodes\n incr = 0\n self.nodes.build(:displayed => true) if not new_record? and self.nodes.count == 0 # Insure at least 1 node\n self.nodes.each do |node|\n node.title = name\n node.menu_name = name\n node.set_safe_shortcut(\"#{incr.to_s}-#{name}\")\n node.displayed = display\n incr += 1\n end\n end", "def add_child(child_node) \n child_node.parent = self \n end", "def append(node)\n children.append(node)\n end", "def rotate_left\n root = @right\n @right = root.left\n root.left = self\n root.left.update_height\n root\n end", "def generate_initial_node\n\t\tnode_text = \".,\" + self.name\n\t\t\n\t\tinitial_node = Node.new()\n\t\t#this line will also build the \"\" category, since it is the first instance of it\n\t\tinitial_node = build_node(initial_node, node_text)\n\t\tinitial_node.save\n\n\t\t#update the ordering\n\t\tordering = []\n\t\tordering.insert(0, ObjectPlace.new(\"Node\", initial_node.id))\n\t\tset_order(ordering)\n\t\t#insert_element(0, node_text)\n\tend", "def add(key, value)\n new_node = TreeNode.new(key,value)\n \n if @root.nil?\n @root = new_node\n else \n add_helper(@root, key, value)\n end\n end", "def add_node(node)\n @nodes.add node\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 right_rotate( node=@tree )\n node.right = node.left\n node.left = node.left.left\n node.right.left = nil\n node.value, node.right.value = node.right.value, node.value\n end", "def add\n working_repo.add tree\n end", "def new_node\n id = @nodes.size\n node = Node.new(id: id)\n @nodes.push(node)\n id\n end", "def <<( node )\n\t\t# self.log.debug \"Appending a %p to %p\" % [ node.class, self ]\n\t\toriginal_node = node\n\t\toriginal_node.before_rendering( self )\n\n\t\tif self.rendering_enabled?\n\t\t\tself.destination << self.make_node_comment( node ) if self.options[:debugging_comments]\n\t\t\tprevious_node = nil\n\t\t\tenc = self.options[:encoding] || Encoding.default_internal\n\n\t\t\tbegin\n\t\t\t\t# Allow render to be delegated to subobjects\n\t\t\t\twhile node.respond_to?( :render ) && node != previous_node\n\t\t\t\t\t# self.log.debug \" delegated rendering to: %p\" % [ node ]\n\t\t\t\t\tprevious_node = node\n\t\t\t\t\tnode = node.render( self )\n\t\t\t\tend\n\n\t\t\t\t# self.log.debug \" adding a %p (%p; encoding: %s) to the destination (%p)\" %\n\t\t\t\t#\t[ node.class, node, node.respond_to?(:encoding) ? node.encoding : 'n/a', self.destination.class ]\n\t\t\t\tself.destination << node\n\t\t\t\t# self.log.debug \" just appended %p to %p\" % [ node, self.destination ]\n\t\t\trescue ::StandardError => err\n\t\t\t\t# self.log.debug \" handling a %p while rendering: %s\" % [ err.class, err.message ]\n\t\t\t\tself.destination << self.handle_render_error( original_node, err )\n\t\t\tend\n\t\tend\n\n\t\toriginal_node.after_rendering( self )\n\t\treturn self\n\tend", "def append(node)\n nxt = @nxt\n top = self\n while nxt\n top = nxt\n nxt = nxt.nxt\n end\n node = node.first\n top.nxt = node\n node.prv = top\n node\n end", "def add_child(node_or_tags); end", "def add_child(node_or_tags); end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_node\n else\n add_helper(@root, new_node)\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_node \n else \n @root = add_helper(@root, new_node)\n end\n\n end", "def <<(tree)\n @trees << tree\n end", "def right_sibling=(node)\n to = validate_sibling!(node)\n\n self.position = higher_than?(node) ? to.position - 1 : to.position\n self.parent_id = to.parent_id\n\n node\n end", "def rotate_right(node)\n new_node = node.left\n node.left = new_node.right\n new_node.right = node\n return new_node\n end", "def new_node(*args)\n add_node(build_node(*args))\n end", "def add_child_node_and_reparent_attrs(node); end", "def add_child_node_and_reparent_attrs(node); end", "def append_node(node, parent = nil)\n # Add the node to the parents node list\n add_entry(node, parent)\n\n # Recursively get all filesystem entries contained in the current folder\n if node.is_a? FileSystem::Folder then\n pattern = '/*'\n entries = Dir.glob(node.path + pattern).sort_by { |a| a.downcase }\n files = []\n folders = []\n\n # Store files and folders in different collections\n # because files will be added before folders\n entries.each do |e|\n if File.directory? e\n folders << e\n else\n files << e\n end\n end\n\n # First add contained files\n files.each do |f|\n file = build_entry(:file, @index, f, @left_entry)\n append_node(file, node)\n end\n\n # After add contained folders and its entries\n folders.each do |f|\n folder = build_entry(:folder, @index, f, @left_entry)\n append_node(folder, node)\n end\n end\n end", "def <<(node_or_tags)\n add_child node_or_tags\n self\n end", "def add(key, value)\n new_tree_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_tree_node\n else\n current = @root\n while current\n if new_tree_node.key <= current.key\n if !current.left\n current.left = new_tree_node\n return\n else\n current = current.left\n end\n else\n if !current.right\n current.right = new_tree_node\n return\n else\n current = current.right\n end\n end\n end\n end\n end", "def insert_node(node)\n raise \"Node must be a leaf\" unless node.is_leaf?\n if (self.view) \n node.position = self.view.get_node_position(node)\n node.visible = self.view.get_node_visibility(node)\n node.search_value = self.view.get_node_search_value(node)\n end\n leafs << node\n end", "def on_mlhs_add_star(left, right)\n if right\n left << right.updated(nil, [*right.children, true])\n # Add a placeholder for the expander token.\n else\n left << nil\n end\n\n return left\n end", "def append_node\r\n # Load parent package.\r\n parent_package = ProductPackage.find params[:id], :include => \"product_package_nodes\"\r\n # position = parent_package.product_package_nodes.collect{|node| node.position}.sort.last.nexts\r\n \r\n # Build a child node.\r\n case params[:node_type]\r\n when \"package\"\r\n parent_package.product_package_nodes << ProductPackage.new(:name => params[:new_package_name])\r\n when \"product\"\r\n parent_package.product_package_nodes << ProductPackageProduct.new(:product_id => params[:product_id], :display_style => \"checkbox\")\r\n end\r\n \r\n # Save node and redirect back.\r\n redirect_to :back\r\n end", "def add_node(p_node_text, p_node_type, p_parent_node = nil, p_node_color = nil)\n new_node = create_node(p_node_text, p_node_type, p_node_color)\n # add new node on top level per default\n if p_parent_node.nil?\n p_parent_node = @nodes[0]\n end\n p_parent_node[\"nodes\"].insert(0, new_node)\n return new_node\n end", "def insert_right(other)\n right.insert(other.project(right.header))\n end", "def add_node(node)\n @nodes[node.uri] ||= node\n end", "def move_to_left_of(node)\n self.move_to node, :left\n end", "def after(node)\n @parent.insert_after(node, self)\n end", "def add(text)\n\n\t\t# create a new node and set navigation pointers\n\t\t@old = @tree\n\t\t@tree = Node.new(text)\n\t\[email protected] = @old.next\n\t\tif @old.next != nil\n\t\t\[email protected] = @tree\n\t\tend\n\t\[email protected] = @old\n\t\[email protected] = @tree\n\n\t\t# Prune the tree, so it doesn't get too big.\n\t\t# Start by going back.\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.prev\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.next\n\t\t\tx.prev.delete\n\t\tend\n\t\t# now forward\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.next\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.prev\n\t\t\tx.next.delete\n\t\tend\n\tend", "def insert(root, new_node)\n new_node.id = @count + 1\n current = find_parent(root, new_node)\n\n current.left.nil? ? current.left = new_node : current.right = new_node\n new_node.parent = current\n\n heapify(new_node)\n @count += 1\n end", "def create\n @node = Node.new(params[:node])\n @node.modifier = current_user\n respond_to do |format|\n if @node.save\n @node.move_to_right_of(params[:insert_after_id]) if Node.exists?(params[:insert_after_id])\n flash[:notice] = 'Project was successfully created.'\n format.html { redirect_to(nodes_url) }\n format.xml { render :xml => @node, :status => :created, :location => @node }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def move_right\n tenacious_transaction do\n move_to_right_of right_sibling.try(:lock!)\n end\n end", "def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end", "def add_node(node)\n @nodes[node.id.to_i] = node\n node.db = self\n end", "def add_child( child ) \n self.reload\n child.reload\n\n if child.root?\n raise ActiveRecord::ActiveRecordError, \"Adding sub-tree isn\\'t currently supported\"\n else\n if ( (self[acts_as_nested_set_options[:left_column]] == nil) || (self[acts_as_nested_set_options[:right_column]] == nil) )\n # Looks like we're now the root node! Woo\n self[acts_as_nested_set_options[:left_column]] = 1\n self[acts_as_nested_set_options[:right_column]] = 4\n \n # What do to do about validation?\n return nil unless self.save\n \n child[acts_as_nested_set_options[:parent_column]] = self.id\n child[acts_as_nested_set_options[:left_column]] = 2\n child[acts_as_nested_set_options[:right_column]]= 3\n return child.save\n else\n # OK, we need to add and shift everything else to the right\n child[acts_as_nested_set_options[:parent_column]] = self.id\n right_bound = self[acts_as_nested_set_options[:right_column]]\n child[acts_as_nested_set_options[:left_column]] = right_bound\n child[acts_as_nested_set_options[:right_column]] = right_bound + 1\n self[acts_as_nested_set_options[:right_column]] += 2\n self.class.transaction {\n self.class.update_all( \"#{acts_as_nested_set_options[:left_column]} = (#{acts_as_nested_set_options[:left_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:left_column]} >= #{right_bound}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:right_column]} = (#{acts_as_nested_set_options[:right_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:right_column]} >= #{right_bound}\" )\n self.save\n child.save\n }\n end\n end \n end", "def move_to_left_of(node)\n self.move_to node, :left\n end" ]
[ "0.73110974", "0.66116565", "0.6545355", "0.65242076", "0.6497894", "0.6453593", "0.635631", "0.6343747", "0.627902", "0.6275489", "0.62203336", "0.6182126", "0.61652964", "0.6160576", "0.6140413", "0.6065717", "0.6057033", "0.60449076", "0.60440564", "0.6031852", "0.6010775", "0.60084134", "0.5982031", "0.5952065", "0.5947077", "0.59300935", "0.59243315", "0.58926386", "0.5879358", "0.5875927", "0.5844461", "0.5843581", "0.58197504", "0.58197504", "0.58197504", "0.5817788", "0.5817788", "0.58155483", "0.57983935", "0.5796142", "0.5793237", "0.5793203", "0.57878435", "0.57724965", "0.57673025", "0.57647264", "0.57629323", "0.5762189", "0.57557315", "0.5737964", "0.5695749", "0.56934154", "0.5692764", "0.5687056", "0.5686477", "0.5686386", "0.56680775", "0.5664503", "0.5661781", "0.5650479", "0.56498486", "0.56454235", "0.56409097", "0.56388015", "0.5631473", "0.56294304", "0.5623146", "0.56216705", "0.5616603", "0.5612277", "0.5604498", "0.55955464", "0.55887175", "0.55887175", "0.5579211", "0.5575876", "0.55733556", "0.5561945", "0.55613583", "0.5557432", "0.55533785", "0.55533785", "0.55522466", "0.5545122", "0.55428433", "0.5540159", "0.5534679", "0.55342364", "0.5525412", "0.5522907", "0.5520652", "0.55189276", "0.55160713", "0.55101013", "0.55099857", "0.5505275", "0.55038714", "0.54936236", "0.54931605", "0.5492016", "0.5491501" ]
0.0
-1
On destruction, delete all children and shift the lft/rgt values back to the left so the counts still work.
def before_destroy # already protected by a transaction return if self[right_col_name].nil? || self[left_col_name].nil? self.reload # in case a concurrent move has altered the indexes dif = self[right_col_name] - self[left_col_name] + 1 base_set_class.delete_all( "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})" ) base_set_class.update_all("#{left_col_name} = CASE \ WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \ ELSE #{left_col_name} END, \ #{right_col_name} = CASE \ WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \ ELSE #{right_col_name} END", scope_condition) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def teardown\n @root.remove!(@left_child1)\n @root.remove!(@right_child1)\n @root = nil\n end", "def destroy_tree_from_leaves\n self.subdirectories.each do |subdirectory|\n subdirectory.destroy_tree_from_leaves\n end\n self.subdirectories.reload\n self.cfs_files.each do |cfs_file|\n cfs_file.destroy!\n end\n self.cfs_files.reload\n self.destroy!\n end", "def clear_children!\n @children.clear\n end", "def destroy\n super\n\n @children.each do |_child_name, child_group|\n child_group.each(&:destroy)\n end\n\n @children = {}\n end", "def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n \n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n base_class.delete_all scoped(left_column_name => { '$gt' => left }, right_column_name => { '$lt' => right })\n end\n \n # update lefts and rights for remaining nodes\n diff = right - left + 1\n base_class.all(scoped(left_column_name => { '$gt' => right })).each do |node|\n node.update_attributes left_column_name => node.left - diff\n end\n base_class.all(scoped(right_column_name => { '$gt' => right })).each do |node|\n node.update_attributes right_column_name => node.right - diff\n end\n \n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end", "def delete_tree\n @root = nil # In ruby it will be taken care by garbage collector\n end", "def destroy_descendants # already protected by a transaction within #destroy\n return if self[right_col_name].nil? || self[left_col_name].nil? || self.skip_before_destroy\n reloaded = self.reload rescue nil # in case a concurrent move has altered the indexes - rescue if non-existent\n return unless reloaded\n dif = self[right_col_name] - self[left_col_name] + 1\n if acts_as_nested_set_options[:dependent] == :delete_all\n base_set_class.delete_all( \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\" ) \n else \n set = base_set_class.find(:all, :conditions => \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\", :order => \"#{prefixed_right_col_name} DESC\") \n set.each { |child| child.skip_before_destroy = true; remove_descendant(child) } \n end\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \\\n ELSE #{right_col_name} END\",\n scope_condition)\n end", "def clear_node\n self.value = nil\n self.left_child = nil\n self.right_child = nil\n end", "def before_destroy\n return if self[nested_set_right].nil? || self[nested_set_left].nil?\n diff = self[nested_set_right] - self[nested_set_left] + 1\n\n nested_set_class.transaction {\n nested_set_class.delete_all \"#{nested_set_scope} AND #{nested_set_left} > #{self[nested_set_left]} and #{nested_set_right} < #{self[nested_set_right]}\"\n nested_set_class.update_all \"#{nested_set_left} = (#{nested_set_left} - #{diff})\", \"#{nested_set_scope} AND #{nested_set_left} >= #{self[nested_set_right]}\"\n nested_set_class.update_all \"#{nested_set_right} = (#{nested_set_right} - #{diff} )\", \"#{nested_set_scope} AND #{nested_set_right} >= #{self[nested_set_right]}\"\n }\n end", "def destroy\n #primitives in structs are without parent\n parent and parent.children.delete self\n end", "def clear\n @tree.clear\n return 0\n end", "def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n\n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n c = nested_set_scope.where(left_field_name.to_sym.gt => left, right_field_name.to_sym.lt => right)\n scope_class.where(c.selector).delete_all\n end\n\n # update lefts and rights for remaining nodes\n diff = right - left + 1\n\n # scope_class.with(:safe => true).where(\n scope_class.where(\n nested_set_scope.where(left_field_name.to_sym.gt => right).selector\n ).inc(left_field_name => -diff)\n\n # scope_class.with(:safe => true).where(\n scope_class.where(\n nested_set_scope.where(right_field_name.to_sym.gt => right).selector\n ).inc(right_field_name => -diff)\n\n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end", "def remove\n each { |x| x.parent.children.delete(x) }\n end", "def prune_from_tree\n return if self.right.nil? || self.left.nil?\n diff = self.right - self.left + 1\n\n #TODO: implemente :dependent option\n # delete_method = acts_as_nested_set_options[:dependent] == :destroy ?\n # :destroy_all : :delete_all\n\n #TODO: implement prune method\n # self.class.base_class.transaction do\n # nested_set_scope.send(delete_method,\n # [\"#{quoted_left_column_name} > ? AND #{quoted_right_column_name} < ?\",\n # left, right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_left_column_name} = (#{quoted_left_column_name} - ?)\", diff],\n # [\"#{quoted_left_column_name} >= ?\", right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)\", diff],\n # [\"#{quoted_right_column_name} >= ?\", right]\n # )\n # end\n end", "def clear!\n\t\t\tself.tree = []\n\t\t\tself.current = tree\n\t\tend", "def destroy\n @parent = nil\n @root = nil\n end", "def retrieve_all_children\n self.to_be_removed = false\n self.save\n\n self.tags.each do |i|\n i.to_be_removed = false\n i.save\n end\n end", "def clean_children\n\n return unless @children\n\n @children.each do |child_fei|\n #next unless child.is_a?(FlowExpressionId)\n get_expression_pool.remove(child_fei)\n end\n end", "def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end", "def finish\n @children.each { |kid| \n kid[:link].finish()\n kid[:link] = nil\n kid[:residue].finish()\n kid[:residue] = nil\n }\n\n @ring_positions.each { |pos,node| \n node.finish()\n }\n\n remove_relations\n \n end", "def clear_nodes\n\t\t\t@tree = []\n\t\t\t@node_stack = [ @tree ]\n\t\tend", "def reset_state\n @children = nil\n @logdev = nil\n @loglvl = nil\n end", "def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end", "def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n child.outdent\n child.remove_act\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.permissions.destroy_all\n self.destroy\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end", "def ll_clear()\n @head = nil\n @tail = nil\n @num_nodes = 0\n end", "def process_tree_with_renew\n @process_tree = nil\n process_tree\n end", "def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end", "def update_children_when_delete\n if self.to_be_removed == true\n self.tag_types.each do |m|\n if m.to_be_removed == false\n m.to_be_removed = true\n m.save\n end\n end\n end\n end", "def prune\n # First: prune all children.\n self.each { |_, n| n.prune }\n # Then delete all nil leaf children.\n @succ.clone.each do |key, n|\n delete key if n.val == nil && n.leaf?\n end\n end", "def before_destroy\n return if self[acts_as_nested_set_options[:right_column]].nil? || self[acts_as_nested_set_options[:left_column]].nil?\n dif = self[acts_as_nested_set_options[:right_column]] - self[acts_as_nested_set_options[:left_column]] + 1\n\n self.class.transaction {\n self.class.delete_all( \"#{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]]}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:left_column]} = (#{acts_as_nested_set_options[:left_column]} - #{dif})\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:left_column]} >= #{self[acts_as_nested_set_options[:right_column]]}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:right_column]} = (#{acts_as_nested_set_options[:right_column]} - #{dif} )\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:right_column]} >= #{self[acts_as_nested_set_options[:right_column]]}\" )\n }\n end", "def clear\n @parent = nil\n end", "def remove_finished_children\n # We call #to_a to get a copy of children, since we will remove\n # children in the block. Note that we can't use #delete_if here\n # since #children is a relation enumerator (not the relation list\n # itself)\n children = each_child.to_a\n for child in children\n child, info = child\n if info[:success].evaluate(child)\n remove_child(child)\n end\n end\n end", "def recursively_destroy!\n children.each { |c| c.recursively_destroy! }\n destroy\n end", "def remove_or_decrement_ref(*nodes); end", "def prune_liberally\n update_masses\n\n hashes_to_prune = Hash.new { |h,k| h[k] = [] }\n\n # record each subtree by subhash, but skip if subtree mass > parent mass\n self.hashes.values.each do |nodes|\n nodes.each do |node|\n tophash = node.structural_hash\n topscore = self.masses[tophash]\n\n node.deep_each do |subnode|\n subhash = subnode.structural_hash\n subscore = self.masses[subhash]\n\n next if subscore and subscore > topscore\n\n hashes_to_prune[subhash] << subnode\n end\n end\n end\n\n # nuke only individual items by object identity\n self.hashes.each do |h,v|\n v.delete_eql hashes_to_prune[h]\n end\n\n # nuke buckets we happened to fully empty\n self.hashes.delete_if { |k,v| v.size <= 1 }\n end", "def remove_children\n\t\tinterests.destroy_all\n\tend", "def destroy\n self.littles.each do | little|\n little.big_id = nil;\n end\n self.positions.each do | pos |\n pos.dke_info_id = nil;\n end\n return super\n end", "def destroy_and_child\n materials.each do |material|\n material.destroy\n end\n measures.each do |measure|\n measure.destroy\n end\n destroy\n end", "def purge\r\n @head = nil\r\n @tail = nil\r\n end", "def remove_from_parents\n ordered_by.each do |parent|\n parent.ordered_members.delete(self) # Delete the list node\n parent.members.delete(self) # Delete the indirect container Proxy\n parent.save! # record the changes to the ordered members\n end\n end", "def mark_children_for_removal\n work_graphics.each do |work_graphic|\n work_graphic.destroy\n end\n end", "def delete_ltree_column_value\n update!(ltree_path_column => nil)\n end", "def prune!\n return if root? #you cannot prune the root\n if normal?\n parent.normal_children.delete(self)\n else\n parent.fallback_child = nil\n end\n old_parent = parent\n @parent = nil\n old_parent.prune! if old_parent.useless?\n end", "def children() []; end", "def clear\n remove_instance_variable(:@left)\n remove_instance_variable(:@middle)\n remove_instance_variable(:@right)\n end", "def remove_unused_leaves\n each_node do |n|\n n.pin([]) if n.weight == 0 && n.children.empty?\n end\n end", "def teardown\n @root = nil\n end", "def children_to_zero\n self.youngsters ||= 0\n end", "def cleanup(paths)\n item = path_tree.descend(paths)\n item.cleanup \n save_path_tree\n # print what happened here\n print_depth item\n end", "def cleanup_dfs\n # clean up vertices attributes set during dfs\n @vertices.values.each do |vertex|\n vertex.color = nil\n vertex.predecessor = nil\n vertex.discovery = nil\n vertex.finish = nil\n end\n @time = 0\n end", "def clear\n @root = nil\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 all_children_count\n return (self[right_col_name] - self[left_col_name] - 1)/2\n end", "def remove_all\n @peer.remove_all\n# @children.each { |child| scene.unindex_prop(child) } if scene\n# @children = []\n end", "def ref_cleanup(xmldoc)\n xmldoc.xpath(\"//p/ref\").each do |r|\n parent = r.parent\n parent.previous = r.remove\n end\n end", "def purge \n\t\t@head = nil\n\t\t@tail = nil\n\tend", "def clean\n while(@actual != nil) do\n aux= @actual\n @actual = @actual[:next]\n aux = nil\n end\n \n @actual = nil\n @fin = nil\n @Max = 0\n end", "def reset_daughters\n\t\t@daughters = Array.new @children\n\t\[email protected] do |child|\n\t\t\tchild.reset_daughters\n\t\tend\n\tend", "def clear\n each_child { |child| child.clear if child.kind_of?(BranchNode) }\n @children.clear\n end", "def freshen_parent_and_child_indexes\n freshen_parent_and_child_indexes(0)\n end", "def remove_dead_ends\n size = @open.size\n for child in @n.children\n if child.dead_end\n @open.delete(child).name\n end\n end\n clean_up_closed(@n) if size != @open.size\n end", "def children_count\n return (self[nested_set_right] - self[nested_set_left] - 1) / 2\n end", "def finalize\r\n drop_chopsticks\r\n end", "def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n if child.type != 'GoalTracker'\n child.outdent\n child.remove_act\n end\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.state = Activity::ABANDONED\n self.save!\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end", "def remove_child(le)\n\t\t\[email protected] le\n\t\t\tle.parent = nil\n\t\tend", "def clear\n @sizes = FloatRect.new 0, 0, 1, 1\n @paddings = Paddings.new\n @margins = Margins.new\n @children = []\n @handle = nil\n self\n end", "def cascade_destroy\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} <@ ?\", ltree_path_in_database).destroy_all\n end", "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_max\n @root = delete_max_node(@root)\n end", "def children_count\n return (self[acts_as_nested_set_options[:right_column]] - self[acts_as_nested_set_options[:left_column]] - 1)/2\n end", "def del_final\n @tail = @tail.node_ant\n if @tail != nil\n @tail.edi_sig(nil)\n else\n @head = @tail\n end\n end", "def detach()\n @left.detach\n @right.detach\n @results.clear\n end", "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\t\tbalanced_rotate_left\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# flip this sub-tree into another type of 3-children node\n\t\t\t\t\tret = rotate_left\n\t\t\t\t\t# try to rebalance in sub-tree\n\t\t\t\t\tleft, rebalance = ret.left.rebalance_for_left_delete\n\t\t\t\t\traise 'should not happen' if rebalance\n\t\t\t\t\tret.with_left(left)\n\t\t\t\tend\n\t\t\telse # red\n\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t# make right sub-tree 1 level lower\n\t\t\t\t\twith_right(@right.with_color(color)).with_color(@right.color)\n\t\t\t\telse\n\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\tbalanced_rotate_left\n\t\t\t\tend\n\t\t\tend, rebalance]\n\t\tend", "def delete_unwanted_children\n @children.keys.each do |key|\n if(@children[key][:value].class.name === \"Array\")\n if(@children[key][:value].empty?)\n @children.tap { |hs| hs.delete(key) }\n end\n else\n if(@children[key][:value].nil?)\n @children.tap { |hs| hs.delete(key) }\n end\n end\n end\n end", "def orphan_child_categories\n self.children.each do |child|\n child.parent_id = nil\n child.save\n end\n end", "def clean_up\n if self.deleted?\n # clean room type mapping\n RoomTypeChannelMapping.find_all_by_room_type_id(self.id).each do |rtcm|\n rtcm.update_attribute(:deleted, true)\n end\n # clean master rate mapping\n RoomTypeMasterRateMapping.find_all_by_room_type_id(self.id).each do |rtmr|\n RoomTypeMasterRateChannelMapping.find_all_by_room_type_master_rate_mapping_id(rtmr.id).each do |rtc|\n rtc.update_attribute(:deleted, true)\n end\n rtmr.update_attribute(:deleted, true)\n end\n # clean availability link from\n RoomTypeInventoryLink.find_all_by_room_type_from_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n # clean availability link to\n RoomTypeInventoryLink.find_all_by_room_type_to_id(self.id).each do |rml|\n rml.update_attribute(:deleted, true)\n end\n end\n end", "def remove_illegitimate_children\n puts \"Destroying illegitimate children of response #{id}: #{text}\" if illegitimate_children.length > 1\n illegitimate_children.select {|q| q != child_question }.each do |q|\n puts \" Destroying illegitimate child question #{q.id}: #{q.text}\"\n q.destroy\n end\n end", "def delete_old_nodes (days_to_keep = DAYS_TO_KEEP_NODE)\n children.where('updated_at < ?', Time.now - days_to_keep.day).each do |node|\n node.destroy_self_and_children!\n end\n end", "def finalize\n @list.each do |bp|\n bp.related_bp.each { |bp| bp.remove! }\n bp.remove!\n end\n clear\n end", "def _clear_cache\n @cache_parent.clear\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 rm_cddts_outof_blk\n axes = [@ref_rows, @ref_cols]\n axes.each{|axis|\n axis.each{|ref|\n intrsct_cddts = []\n (self.to_a.flatten & ref).each{|elm|\n intrsct_cddts.push(elm.cddts).flatten!.uniq!\n }\n six_cells_cddts = []\n (self.to_a.flatten - ref).each{|elm|\n six_cells_cddts.push(elm.cddts).flatten!.uniq!\n }\n intrsct_cddts.each{|cddt|\n unless six_cells_cddts.include?(cddt)\n (ref - self.to_a.flatten).each{|elm|\n elm.cddts.delete(cddt)\n# if ProgramConfig[:debug]\n# if elm.fixed == false and elm.cddts.length == 1\n# print \"DEBUG: [#{elm.i}, #{elm.j}] = #{elm.cddts.first}\\n\"\n# end\n# end\n elm.fixed = true if(elm.cddts.length == 1)\n }\n end\n }\n }\n }\n end", "def clear\n @ary.clear\n @heapsize = 0\n @mode = nil\n end", "def delete_children(id, gel)\n element_dataset.filter(container_id_sym => id).delete\n end", "def demolish\n @children.each_value(&:demolish)\n end", "def clean_up!\n puts Item.where(thread_id: self.uid).count\n Item.where(thread_id: self.uid).destroy_all\n @forum_items = []\n self.items = []\n self.items_md5 = nil\n save\n end", "def remove_act\n # select rep_parent if it exists\n node = self\n if !self.rep_parent.nil?\n node = self.rep_parent\n end\n\n # outdent children in case remove_act doesn't delete\n node.children.each do |child|\n child.outdent\n child.remove_act\n end\n\n # hold parent in case it need be updated\n old_parent = node.parent\n \n node.repititions.destroy_all\n node.destroy\n\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end", "def children; []; end", "def replace_children(start_child_index, stop_child_index, t)\n # System.out.println(\"replaceChildren \"+startChildIndex+\", \"+stopChildIndex+\n # \" with \"+((BaseTree)t).toStringTree());\n # System.out.println(\"in=\"+toStringTree());\n if ((@children).nil?)\n raise IllegalArgumentException.new(\"indexes invalid; no children in list\")\n end\n replacing_how_many = stop_child_index - start_child_index + 1\n replacing_with_how_many = 0\n new_tree = t\n new_children = nil\n # normalize to a list of children to add: newChildren\n if (new_tree.is_nil)\n new_children = new_tree.attr_children\n else\n new_children = ArrayList.new(1)\n new_children.add(new_tree)\n end\n replacing_with_how_many = new_children.size\n num_new_children = new_children.size\n delta = replacing_how_many - replacing_with_how_many\n # if same number of nodes, do direct replace\n if ((delta).equal?(0))\n j = 0 # index into new children\n i = start_child_index\n while i <= stop_child_index\n child = new_children.get(j)\n @children.set(i, child)\n child.set_parent(self)\n child.set_child_index(i)\n j += 1\n i += 1\n end\n else\n if (delta > 0)\n # fewer new nodes than there were\n # set children and then delete extra\n j = 0\n while j < num_new_children\n @children.set(start_child_index + j, new_children.get(j))\n j += 1\n end\n index_to_delete = start_child_index + num_new_children\n c = index_to_delete\n while c <= stop_child_index\n # delete same index, shifting everybody down each time\n killed = @children.remove(index_to_delete)\n c += 1\n end\n freshen_parent_and_child_indexes(start_child_index)\n else\n # more new nodes than were there before\n # fill in as many children as we can (replacingHowMany) w/o moving data\n j = 0\n while j < replacing_how_many\n @children.set(start_child_index + j, new_children.get(j))\n j += 1\n end\n num_to_insert = replacing_with_how_many - replacing_how_many\n j_ = replacing_how_many\n while j_ < replacing_with_how_many\n @children.add(start_child_index + j_, new_children.get(j_))\n j_ += 1\n end\n freshen_parent_and_child_indexes(start_child_index)\n end\n end\n # System.out.println(\"out=\"+toStringTree());\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 before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts_as_nested_set_options[:right_column]] = maxright+2\n end", "def total_child_count\n count = 0\n self.apply_to_children { |e| count += 1 }\n count\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_branch\n #we'll get all descendants by level descending order. That way we'll make sure deletion will come from children to parents\n children_to_be_deleted = self.class.find(:all, :conditions => \"id_path like '#{self.id_path},%'\", :order => \"level desc\")\n children_to_be_deleted.each {|d| d.destroy}\n #now delete my self :)\n self.destroy\n end", "def remove()\n return nil if self.empty?\n\n # swap root node and last leaf node (swap head and rear of internal array) and pop it\n last_index = @store.length - 1\n swap(0, last_index)\n removed = @store.pop\n\n # ensure heap property via calling heap_down\n heap_down(0)\n return removed.value\n end", "def remove!(child)\n @last_items_count -= +1 if child && child.last\n super\n end", "def eject!\n #removes the first node\n node = @store.first\n @store.remove(node.key)\n\n #get rid of the map's reference to the deleted node\n @map.delete(node.key)\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 delete_tail\r\n delete_node @tail\r\n end", "def clear\n @level = 0\n @out = []\n @labels = []\n self\n end", "def children=(children)\n (self.children - children).each do |child_to_remove|\n remove_child(child_to_remove)\n end\n super\n end" ]
[ "0.66812104", "0.64786756", "0.6347992", "0.6293292", "0.6208786", "0.618475", "0.61661756", "0.61547375", "0.6106653", "0.6055133", "0.6049484", "0.6042418", "0.59881234", "0.59858346", "0.58628696", "0.5859962", "0.58414835", "0.58174384", "0.581299", "0.5811586", "0.5773907", "0.5767387", "0.57409537", "0.5731064", "0.5729142", "0.5724764", "0.5719761", "0.570823", "0.5693816", "0.56868213", "0.55992424", "0.5589535", "0.55859506", "0.55815387", "0.5568983", "0.5568643", "0.5556465", "0.55473584", "0.5541896", "0.5541417", "0.5538016", "0.5531543", "0.5527603", "0.552165", "0.55103576", "0.5500913", "0.54795206", "0.5479123", "0.5472793", "0.54691064", "0.54677725", "0.54618716", "0.5457128", "0.5455787", "0.5452372", "0.5449147", "0.54489815", "0.5442144", "0.5432531", "0.54323536", "0.5418901", "0.540938", "0.5404362", "0.53932595", "0.5385561", "0.53828394", "0.5378648", "0.5377259", "0.53564453", "0.5343524", "0.53205776", "0.53057736", "0.5303444", "0.52947503", "0.52930117", "0.52798074", "0.5267619", "0.5266482", "0.525648", "0.5255022", "0.5247172", "0.5246966", "0.52444243", "0.524269", "0.5236747", "0.52290636", "0.52264124", "0.5226109", "0.52190244", "0.5207299", "0.52044046", "0.5202777", "0.5198935", "0.5197277", "0.51923084", "0.51893973", "0.51864636", "0.5183825", "0.5179134", "0.5177249", "0.51672924" ]
0.0
-1
By default, records are compared and sorted using the left column.
def <=>(x) self[left_col_name] <=> x[left_col_name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmp (left_element, right_element)\n #puts left_element\n #puts right_element\n if @order == \"ASC\"\n if left_element[@order_column] < right_element[@order_column]\n return true\n else\n return false\n end\n else\n if left_element[@order_column] > right_element[@order_column]\n return true\n else\n return false \n end \n end\n end", "def <=>(x)\n self[acts_as_nested_set_options[:left_column]] <=> x[acts_as_nested_set_options[:left_column]]\n end", "def sort_records(raw_records)\n records = raw_records.clone\n return records if records.size < 2\n (records.size - 2).downto(0) do |i|\n (0 .. i).each do |j|\n records[j], records[j + 1] = records[j + 1], records[j] if records[j].id.to_i < records[j + 1].id.to_i\n end\n end\n records\n end", "def <=>(schema)\n sort_key <=> schema.sort_key\n end", "def <=> other\n Bytes.compareTo(rowkey(:raw), other.rowkey(:raw))\n end", "def sort_data\n store.sort_data!\n end", "def sort_entries; end", "def sort_fields(fields)\n fields.sort {|a,b| (COLUMN_SORTING_MAP[a] || a).to_s <=> (COLUMN_SORTING_MAP[b] || b).to_s }\n end", "def sort_column\n nil\n end", "def sort_data\n sort_cols = @columns.select{ |col| col.sort_order }.sort_by{ |col| col.sort_order }\n if sort_cols.length > 0\n log.fine \"Sorting by #{sort_cols.map(&:header).to_sentence}\"\n @data.sort! do |a, b|\n ord = nil\n sort_cols.each do |col|\n if col.sort_ascending\n a_val = a[col.column_index]\n b_val = b[col.column_index]\n else\n a_val = b[col.column_index]\n b_val = a[col.column_index]\n end\n ord = a_val <=> b_val || (a_val && 1) || (b_val && -1) || 0\n break unless ord == 0\n end\n ord\n end\n end\n end", "def sorted\n all.order(Arel.sql(%[ #{quoted_table_name}.\"recorded_at\" ASC, #{quoted_table_name}.\"hid\" ASC ]))\n end", "def sort_order\n 0\n end", "def sortPlayers\r\n\[email protected]_players = @table.sort\r\n\[email protected] = @table.current_players.dup\r\nend", "def ascending?(objects)\n column_values_array = []\n objects.each do |row|\n column_values_array << row.text.downcase\n end\n column_values_array == column_values_array.sort\n end", "def is_sorted\r\n false\r\n end", "def sort_norm_data\n store.sort_norm_data!\n end", "def sort_records(records)\n sort_order = order.map { |direction| [ direction.target, direction.operator == :asc ] }\n\n records.sort_by do |record|\n sort_order.map do |(property, ascending)|\n Sort.new(record_value(record, property), ascending)\n end\n end\n end", "def sort_docs_by_key!; end", "def use_composite_row_comparison(values)\n columns = Arel::Nodes::Grouping.new(column_definitions.map(&:column_expression))\n values = Arel::Nodes::Grouping.new(column_definitions.map do |column_definition|\n value = values[column_definition.attribute_name]\n build_quoted(value, column_definition.column_expression)\n end)\n\n if column_definitions.first.ascending_order?\n [columns.gt(values)]\n else\n [columns.lt(values)]\n end\n end", "def sorted\n all.order(%[ #{quoted_table_name}.\"recorded_at\", #{quoted_table_name}.\"hid\" ])\n end", "def fields_with_consistent_order\n fields.sort { |f1, f2| f1.schema_id <=> f2.schema_id }\n end", "def my_quick_sort(&prc)\n prc ||= Proc.new{|a,b| a <=> b}\n return self if self.length <= 1\n mdix = self.length()/2\n left = []\n right = []\n # debugger\n self.each_with_index do |item, idx|\n case prc.call(item,self[mdix])\n when -1 #a smaller\n left << item\n when 0\n left << item if idx != mdix\n when 1\n right << item\n end\n end\n # debugger\n left.my_quick_sort(&prc) + [self[mdix]] + right.my_quick_sort(&prc)\n end", "def sort_data!(is_ascending, sort_keys)\n sort_key_indices = sort_keys.collect { |key| @columns.index(@columns.find { |column| column.id == key }) }.reject { |e| !e }\n\n @data.sort! do |row1, row2|\n comparison_result = 0\n\n sort_key_indices.each do |index|\n comparison_result = @columns[index].data_comparator.call(row1[index], row2[index])\n comparison_result *= -1 if !is_ascending\n break unless comparison_result == 0\n end\n\n comparison_result\n end\n end", "def <=>(x)\n self[nested_set_left] <=> x[nested_set_left]\n end", "def check_sort_options #:nodoc:\r\n table_name = @tables.first[1]\r\n return if session[table_name][:sort].nil? || @records.class != Mongoid::Criteria\r\n\r\n sort, direction = session[table_name][:sort].split(' ')\r\n @records = @records.order_by( sort => direction.to_i )\r\nend", "def <=>(other)\n # only be comparable if we're in the same table\n if @table.equal?(other.instance_variable_get(@table))\n other_id = other.instance_variable_get('@id')\n @id <=> other_id\n else\n nil\n end\n end", "def __sort_pair__\n { first => Mongoid::Criteria::Translator.to_direction(last) }\n end", "def asc\n from(default_table).asc\n end", "def sort a\r\n sort_rec a, []\r\nend", "def sort a\r\n sort_rec a, []\r\nend", "def sort_by_default\n 1\n end", "def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data = @data.compact.sort { |us1, us2|\n comp =\n if us1[@sortfield] && us2[@sortfield]\n us1[@sortfield] <=> us2[@sortfield]\n elsif us1[@sortfield]\n 1\n elsif us2[@sortfield]\n -1\n else\n 0\n end\n comp * reverse\n }\n end", "def sorted_for_field(field)\n for_field(field).sort\n end", "def add_sort_field(*) super end", "def sort(column=@sort_by, asc = @sort_order)\n column_format = format[index(column)]\n x_sort_string = \"x.data[index('#{column}')]\"\n y_sort_string = \"y.data[index('#{column}')]\"\n \n if !(NUMBER_FORMATS + DATE_FORMATS).include? format[index(column)]\n x_sort_string = x_sort_string + \".to_s\"\n y_sort_string = y_sort_string + \".to_s\"\n end\n \n if NUMBER_FORMATS.include? format[index(column)]\n x_sort_string = x_sort_string + \".to_f\"\n y_sort_string = y_sort_string + \".to_f\" \n end\n\n # Sort the rows:\n # By returning -1 in case the comparison fails, we ensure that the sort never raises an error; however,\n # we may not get a proper sort, but it's better to have the app not fail\n @rows.sort! {|x, y| (instance_eval(x_sort_string) <=> instance_eval(y_sort_string)) || -1}\n \n @rows.reverse! unless asc\n end", "def sort_column\n super \"Room\", \"sort_order\"\n end", "def sort_column\n super \"Room\", \"sort_order\"\n end", "def bubble_sort_rec(&prc)\n end", "def advancedSort\n @sortField = params[:sortField]#field to search on \n @searchField =params[:searchField]# value to search for\n @sortField2 = params[:sortField2]\n @searchField2 =params[:searchField2]\n @graphField = params[:graphField] #datapoint to build graph around\n \n if @sortField2 == \" \"#check if default second value was changed\n @records = Record.where(@sortField => @searchField) #if not only use the first search field\n else#otherwise use both seach fields\n @records = Record.where(@sortField => @searchField, @sortField2 => @searchField2 )\n end\n @sortedSet = @records.order(@graphField)\n end", "def <=>(other)\n first <=> other.first\n end", "def sort_with!(field, direction)\n return self if 'usefulness' == field && 'desc' == direction\n return self.reverse! if 'usefulness' == field && 'asc' == direction\n if 'asc' == direction\n self.sort! { |review1, review2| review1[field] <=> review2[field]}\n elsif 'desc' == direction\n self.sort! { |review1, review2| review2[field] <=> review1[field]}\n end\n end", "def sort_column\n super \"Umbra::Record\", \"title_sort\"\n end", "def <=>(other)\n self[position_column] <=> other[position_column]\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def sort_column\n super \"User\", \"lastname\"\n end", "def show\n @records= @recs.where(name: @record.name).sort_by {|x| x.val}.reverse\n if @record.typ.upcase=='MIN' then @[email protected] end\n end", "def sort_entries=(_arg0); end", "def sort_id\n self.id\n end", "def sort\n super { |x, y| x.file_name <=> y.file_name }\n end", "def sort_by!\n return to_enum unless block_given?\n @rownames = Hash[*@rownames.sort_by.with_index do |(rowname, i), rowid| [yield(Row.new(self, rowid, @rows[i])), rowid] end.flatten(1)]\n self\n end", "def sort!\n @que.sort! do |a,b|\n case @cmp.call(a,b)\n when 0, nil then 0\n when 1, true then 1\n when -1, false then -1\n else\n warn \"bad comparison procedure in #{self.inspect}\"\n 0\n end\n end\n self\n end", "def render_order(entity, other)\n entity.id <=> other.id\n end", "def sort_order\n super\n end", "def <=> other\n #This is a stub, used for indexing\n end", "def sort_by( & block )\n\n load_parent_state\n \n return super\n\n end", "def sort!\n sort_if_needed\n self\n end", "def user_records\n @user_records = (view_context.filter_params[:sort].present?) ? user.records.reorder(\"#{view_context.parsed_current_sort.first} #{view_context.parsed_current_sort.last}\", view_context.secondary_sort) : user.records.reorder(created_at: :desc) \n end", "def check_sort_options() #:nodoc:\r\n table_name = @tables.first[1]\r\n old_sort = session[table_name][:sort].to_s\r\n sort, direction = old_sort.split(' ')\r\n# sort is requested\r\n if params['sort']\r\n # reverse sort if same selected\r\n if params['sort'] == sort\r\n direction = (direction == '1') ? '-1' : '1'\r\n end\r\n direction ||= 1\r\n sort = params[:sort]\r\n session[table_name][:sort] = \"#{params['sort']} #{direction}\"\r\n session[table_name][:page] = 1\r\n end\r\n @records.sort( sort => direction.to_i ) if session[table_name][:sort]\r\n params['sort'] = nil # otherwise there is problem with other links\r\nend", "def bigSorting(unsorted)\n\nend", "def <=>(other)\n return -(hits <=> other.hits) if hits != other.hits\n\n # We want years to sort inverse, while we want others normal.\n return -(value <=> other.value) if field == :year\n (value <=> other.value)\n end", "def ordered_mark_rows\n\t\tif @row < @mark_row\n\t\t\trow = @mark_row\n\t\t\tmark_row = @row\n\t\telse\n\t\t\trow = @row\n\t\t\tmark_row = @mark_row\n\t\tend\n\t\treturn mark_row,row\n\tend", "def tie_breaking_sort\n { \"content_id\" => { order: \"asc\" } }\n end", "def default_sort\n 'name asc'\n end", "def sort_order\n 10 - object.id\n end", "def sort\[email protected] do |key,value|\n value.sort!\nend \nend", "def _literal_table_sort(tables)\n tables.sort_by{|s| literal(s)}\n end", "def left\n send left_column_name\n end", "def <=>(other)\n # Bump one to the surface if it is conflicted and the other isn't\n #return -1 if (conflicted? and !other.conflicted?)\n #return 1 if (!conflicted? and other.conflicted?)\n comparison = (sort_level <=> other.sort_level)\n return comparison unless comparison == 0\n # Next sort by initialism, then meaning\n comparison = (initialism.downcase <=> other.initialism.downcase)\n return comparison unless comparison == 0\n meaning.downcase <=> other.meaning.downcase\n end", "def <=>(other)\n m = self.class.default_sort_method\n my_val = send(m)\n\n # other can be a string or a model of the same type as this model.\n other_val =\n if other.is_a?(::String)\n other\n elsif other.class == self.class\n other.send(m)\n else\n nil\n end\n\n my_val <=> other_val\n end", "def sort_by_ln!\n @entries.sort! { |a,b| a.ln <=> b.ln }\n @entries.reverse!\n end", "def ordered(field, o1, o2) \n o1[field.name].each do |left|\n different_insert(o2, field, left)\n end\n end", "def <=>(x,y)\n x.date <=> y.date\n end", "def sort_params; end", "def sort_params; end", "def sort\r\n @roster.each do |key, value|\r\n value.sort!\r\n end\r\n end", "def sort\n return @sort\n end", "def sort_fields\n Blacklight.config[:sort_fields]\n end", "def sort_display_data\n if @total_data.has_key?(\"\") or @total_data.has_key?(nil) and @total_data.length > 1\n @total_data = @total_data.sort do|a,b|\n a[0].to_s <=> b[0].to_s\n end\n deleted = @total_data.delete_at(0)\n @total_data.push(deleted)\n else\n @total_data = @total_data.sort\n end\n @total_data\n end", "def sorted_keys; end", "def sort_data_ascending!(*sort_keys)\n self.sort_data!(true, sort_keys)\n end", "def sort()\n\t\t@events = @events.sort do |a,b| a[0] <=> b[0] end\n\tend", "def sort\n self[:sort]\n end", "def <=>(other)\n sd1,vt1 = self.showdate, self.vouchertype\n sd2,vt2 = other.showdate, other.vouchertype\n if vt1 == vt2\n # same vouchertype: order by OPENING DATE of the show for which reserved, or display order\n # if not reserved\n return (if (sd1 && sd2) then (sd1 <=> sd2) else (vt1.display_order <=> vt2.display_order) end)\n end\n # else different vouchertypes, so the rules are:\n # if same show, order by showdate\n if (sd1 && sd2 && (sd1.show == sd2.show))\n return sd1 <=> sd2\n end\n # vouchertypes WITH assigned showdates always go first\n shows1,shows2 = vt1.showdates, vt2.showdates # which showdates is vouchertype valid for?\n if ! shows1.empty? && ! shows2.empty? then (shows1.min <=> shows2.min)\n elsif shows1.empty? && shows2.empty? then (vt1.display_order <=> vt2.display_order) # voucher having show validity goes first\n elsif shows1.empty? && ! shows2.empty? then 1 # voucher having show validity goes first\n else # !shows1.empty? && shows2.empty?\n -1\n end\n end", "def sort\n _in_order(@root, @@id_fun) # use Id function\n end", "def ja_sort\n [{ :created_at => :desc }]\n end", "def compare(x, y); end", "def cmp1(a,b)\n\t\t@order*@sort.call(*(@sort_by ? [@sort_by.call(a), @sort_by.call(b)] : [a, b]))\n\tend", "def sort_docs_by_key!\n meta_key = metadata[\"sort_by\"]\n # Modify `docs` array to cache document's property along with the Document instance\n docs.map! { |doc| [doc.data[meta_key], doc] }.sort! do |apples, olives|\n order = determine_sort_order(meta_key, apples, olives)\n\n # Fall back to `Document#<=>` if the properties were equal or were non-sortable\n # Otherwise continue with current sort-order\n if order.nil? || order.zero?\n apples[-1] <=> olives[-1]\n else\n order\n end\n\n # Finally restore the `docs` array with just the Document objects themselves\n end.map!(&:last)\n end", "def sort_rows!(order, *columns)\n correlation = (order == :ascending ? 1 : -1)\n @rows.sort! { |a,b|\n pivot = 0\n columns.each { |column|\n pivot = column\n break if a.cell(column).value != b.cell(column).value\n }\n (a.cell(pivot).value <=> b.cell(pivot).value) * correlation \n }\n end", "def <=>(object)\n return -1 if object.language.nil?\n # Put Chinese when sorting\n return -1 if object.language.code == 'chi'\n return 1 if object.language.code == 'eng'\n return self.name <=> object.name\n end", "def <=>(other)\n return 0 if self[:id] && self[:id] == other[:id]\n diff = (position <=> other.position)\n if diff == 0\n name <=> other.name\n else\n diff\n end\n end", "def compare(attr, statable)\r\n a = self.send(attr)\r\n\tb = statable.send(attr)\r\n#\treturn 0 if a.nil? || b.nil?\r\n\t\r\n\torder = StatSummary::STATS[attr][:order]\r\n\tif order == 1\r\n\t return (a || 10000) <=> (b || 10000)\r\n# return a <=> b\r\n\telse\r\n\t return (b || -1) <=> (a || -1)\r\n# return b <=> a\r\n\tend\r\n end", "def sortable_sort\n @sortable_sort\n end", "def sort arr\r\n\trec_sort arr, []\r\nend", "def columns_in_order\n @columns.values.sort_by { |c| c.order }\n end", "def stable_sort_by(list); end", "def apply_sorting(relation)\n relation.order(@q.sorting.to_sql)\n end", "def sorted?(field=nil)\n return true if self.empty?\n\n if field.nil?\n last = self[0]\n else\n last = self[0].send(field)\n end\n\n self[1..-1].each do |elt|\n curr = (field.nil?) ? elt : elt.send(field)\n return false if curr < last\n last = curr\n end\n\n return true\n end" ]
[ "0.6703479", "0.66438", "0.6443174", "0.6358814", "0.6303578", "0.6174257", "0.616655", "0.61394936", "0.61229604", "0.60936207", "0.60879433", "0.60340875", "0.60009676", "0.59609056", "0.59419787", "0.5916788", "0.59127635", "0.58945715", "0.5874114", "0.5871756", "0.5843819", "0.58335525", "0.58199805", "0.5814787", "0.5807262", "0.5796387", "0.579157", "0.578766", "0.57876354", "0.57876354", "0.57571256", "0.575255", "0.570827", "0.56901175", "0.5685574", "0.56570774", "0.56570774", "0.56563884", "0.56550545", "0.5639339", "0.5614697", "0.56124705", "0.5610887", "0.5603017", "0.5603017", "0.5603017", "0.56008613", "0.5596719", "0.556579", "0.5559136", "0.5558626", "0.5546082", "0.5545979", "0.5541998", "0.554004", "0.55315834", "0.5527534", "0.55243576", "0.55148613", "0.5506387", "0.55030686", "0.55016315", "0.54980606", "0.54968977", "0.5496582", "0.548607", "0.548578", "0.54753184", "0.5473728", "0.54681623", "0.5464019", "0.5460471", "0.5459739", "0.54587966", "0.54587966", "0.54558146", "0.5450759", "0.54482836", "0.5447286", "0.54331625", "0.5430819", "0.5426172", "0.5422487", "0.5421296", "0.5418749", "0.54179126", "0.54169786", "0.54161406", "0.5409145", "0.5408256", "0.54021484", "0.53980774", "0.53975886", "0.5394116", "0.5392132", "0.53906345", "0.53882", "0.53865474", "0.53739804" ]
0.6554659
3
Deprecated. Returns true if this is a root node.
def root? parent_id = self[parent_col_name] (parent_id == 0 || parent_id.nil?) && self[right_col_name] && self[left_col_name] && (self[right_col_name] > self[left_col_name]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_root_node?\n @nodes.size == 1\n end", "def root?\n root\n end", "def root?\n !has_parent?\n end", "def root?\n @type == ROOT\n end", "def root?\n true\n end", "def root?\n root == self\n end", "def root?\n false\n end", "def root?\n false\n end", "def root?\n true\n end", "def root?\n true\n end", "def has_root?\n @root != nil\n end", "def root?\n parent.on_node { |p| p }.nil?\n end", "def root?\n ROOT == self\n end", "def root?\n !parent\n end", "def is_root?\n return call_ancestry_method(:is_root?) if use_ancestry?\n\n rel = relationship # TODO: Handle a node that is a root and a node at the same time\n rel.nil? ? true : rel.is_root?\n end", "def root?\n self.parent ? false : true\n end", "def root?\n parent.nil?\n end", "def root?\n parent.nil?\n end", "def root?\n parent.nil?\n end", "def root?\n parent.nil?\n end", "def root?\n parent.nil?\n end", "def root?\n root_id.nil?\n end", "def is_root?\n false\n end", "def root?\r\n\t\treturn parent == nil\r\n\tend", "def root?\n @parent.nil?\n end", "def is_root?\n self.parent_id.nil?\n end", "def root?\n depth == 1\n end", "def is_root?()\n return (name.nil? and parent.nil?) \n end", "def root?\n id == Id::ROOT\n end", "def root?\n _parent_id.nil?\n end", "def is_root?\n @parent.nil?\n end", "def root?\n parent_id.nil?\n end", "def is_root?\n \troot == id\n end", "def root?\n @parent.nil?\n end", "def empty?\n root.nil?\n end", "def root?\n parent_id.nil?\n end", "def root?\n parent_id.nil?\n end", "def root?\n parent_id.nil?\n end", "def root?(node)\n in_degree(node) == 0 && out_degree(node) > 0\n end", "def is_root?\n parent_id.nil?\n end", "def is_root?\n parent_id.nil?\n end", "def empty?\n @root.nil?\n end", "def empty?\n @root.nil?\n end", "def root?\n !self.hier? || self.path == '/' || self.path.to_s.empty?\n end", "def root?\n context.root_component == self\n end", "def root?\n self.path == '/'\n end", "def root?\n self.class.roots.exists?(self.id)\n end", "def root?\n prev.nil? && self.next.nil?\n end", "def empty?\n @root.empty? && @root.leaf?\n end", "def root?\n self.depth.zero?\n end", "def root?\n self.depth.zero?\n end", "def root?\n self.parent.nil?\n end", "def root? # :nodoc:\n not (id =~ ROOT_ID_REGEXP).nil?\n end", "def root?\n parent.terminal?\n end", "def is_empty\n @root == nil\n end", "def is_root?() @name === '__root__'; end", "def root?\n is_root?(@path)\n end", "def root?\n full_name.empty?\n end", "def child?\n !root?\n end", "def child?\n !root?\n end", "def root?\n self[tree_parent_id_field].nil?\n end", "def is_root?()\n @rootpath == @path\n end", "def child?\n !root?\n end", "def root?\n return @active_context.empty?\n end", "def root?\n #%r{\\A/+\\z} =~ @path ? true : false\n @absolute and @path.empty?\n end", "def root_object?\n root_object == self\n end", "def child?\n !root?\n end", "def node?\n node.present?\n end", "def has_parent?\n !root?\n end", "def root?\n class_name == nil && method_name == nil\n end", "def test_is_root_eh\n setup_test_tree\n assert(@root.is_root?, \"The ROOT node must respond as the root node\")\n end", "def empty?()\n return @root.children.empty? ? true : false\n end", "def include_root?\n min_depth == 0\n end", "def is_root?\n @path == '/' || @path == ''\n end", "def is_root_term?\n return false\n end", "def root?\n !!@root || app_file?\n end", "def root?\n (@nv === 0) and (@dv === 1) and (@snv === 1) and (@sdv === 0)\n end", "def root?\n self[parent_column].nil?\n end", "def is_leaf?\n self.children_count.zero?\n end", "def leaf?\n !node?\n end", "def parent?\n !root?\n end", "def root?\n parent_id = self[nested_set_parent]\n (parent_id == 0 || parent_id.nil?) && (self[nested_set_left] == 1) && (self[nested_set_right] > self[nested_set_left])\n end", "def _is_root?\n [email protected]_a?(BaseEndpoint)\n end", "def leaf?\n children.empty?\n end", "def leaf?\n @children.empty?\n end", "def root?\n \tfolder_id.nil?\n end", "def is_leaf\n return @left == nil\n end", "def xml?\n type == DOCUMENT_NODE\n end", "def valid?\n inner_root.children.detect{|node| node.valid? == false} == nil # should be explicitely nil !!\n end", "def is_root_site?\n @depth == 0\n end", "def leaf?\n self.children.size == 0\n end", "def leaf_version?\n\t\treturn self.child_versions.empty?\n\tend", "def root_node; end", "def starts_with_root_ui_entry?\n @data[16,4] == \"root\" or @data[32,4] == \"root\"\n end", "def root_version?\n\t\treturn self.parent_image.nil?\n\tend", "def root?\n @uid || @uid = fetch_uid\n end", "def lowest_level?\n !children.any? {|child| child.kind_of?(NonLeafNode)}\n end", "def node?\n any?(&:node?)\n end", "def leaf?\n @children.length.zero?\n end", "def root_private?\n self.root.private?\n end", "def unknown?\n !root? && !child?\n end" ]
[ "0.81766397", "0.80926067", "0.80271626", "0.80203354", "0.79955834", "0.7992824", "0.7992352", "0.7940613", "0.7914862", "0.7914862", "0.7881153", "0.78369236", "0.7809944", "0.7802172", "0.7782715", "0.7733866", "0.7585806", "0.7537625", "0.7537625", "0.7537625", "0.7537625", "0.75354755", "0.75306064", "0.7509453", "0.74924624", "0.7421414", "0.7395882", "0.73414654", "0.7335174", "0.73336", "0.73229617", "0.7319948", "0.7303596", "0.7294033", "0.7275705", "0.7245771", "0.7245771", "0.7228233", "0.71813333", "0.71508723", "0.71508723", "0.71449876", "0.7144702", "0.71328074", "0.7127335", "0.7119345", "0.71068555", "0.71044457", "0.7076951", "0.70768464", "0.70768464", "0.7071796", "0.7051637", "0.7050989", "0.7026531", "0.7016815", "0.69994706", "0.69943845", "0.6922092", "0.6922092", "0.6921775", "0.6915842", "0.6907303", "0.68978256", "0.68901736", "0.68704325", "0.6862473", "0.6849161", "0.6847144", "0.6840319", "0.68323314", "0.68307996", "0.68294996", "0.6772496", "0.66850126", "0.6684434", "0.66806996", "0.66626173", "0.66541326", "0.66527903", "0.66259205", "0.6613446", "0.66051143", "0.6571879", "0.6571392", "0.6561091", "0.65579426", "0.6521575", "0.6505711", "0.64841336", "0.6460525", "0.64601815", "0.6411572", "0.6402732", "0.6402007", "0.6400329", "0.639832", "0.6392081", "0.6361363", "0.6353373", "0.63530546" ]
0.0
-1
Deprecated. Returns true if this is a child node
def child? parent_id = self[parent_col_name] !(parent_id == 0 || parent_id.nil?) && (self[left_col_name] > 1) && (self[right_col_name] > self[left_col_name]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_child_nodes()\n if @child_nodes.first_child.nil? then\n return false\n else\n return true\n end\n end", "def child?\n !root?\n end", "def child?\n !root?\n end", "def child?\n !root?\n end", "def child?\n !root?\n end", "def is_only_child?\n return false if parent.nil? # root\n 1 == parent.children.size\n end", "def has_children?\n @nodes && [email protected]?\n end", "def has_children?\n false\n end", "def has_child?\n [email protected]?\n end", "def child?\n !_parent_id.nil?\n end", "def has_children?\n ( self[:has_children] == 1 )\n end", "def is_child?\n !is_parent?\n end", "def child_of?(parent); end", "def child?\n false\n end", "def children?\n\t\t\[email protected] > 0 ? true : false\n\t\tend", "def has_children?\n @nokogiri.children.any? {|child| child.kind_of? Nokogiri::XML::Element }\n end", "def children?\n return false if ((self.children == nil) || (self.children == []))\n return true\n end", "def child?\n true\n end", "def children?\n return false if @children.length == 0\n end", "def children?\n !children.empty?\n end", "def children?\n !children.empty?\n end", "def has_child(name)\n @hasChild = name\n end", "def children?\n [email protected]?\n end", "def is_node?(obj)\n obj.respond_to?(:children) && obj.location.expression\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 has_children?\n !children.empty?\n end", "def has_children?\n !self.children.empty?\n end", "def valid_child(le)\n\t\t\treturn false\n\t\tend", "def has_children?\n `#@native.hasChildren()`\n end", "def has_children?\n children.size > 0\n end", "def has_children?\n children.size > 0\n end", "def has_children?\n !leaf?\n end", "def children?\n\t\t\treturn children.size > 0\n\t\tend", "def nested_child?\n @elements.last.class.method_defined?('add_element') && @elements.last.container\n end", "def has_children?\n @children.length > 0\n end", "def children?\n !children.empty?\n end", "def has_children?\n children.size > 0\n end", "def has_children?\n 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 has_children?\n self.children.size > 0 \n end", "def children?\n\t\t\t@children && [email protected]?\n\t\tend", "def has_child?(childPath)\n `#@native.hasChild(childPath)`\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 invalid_child?(child)\n false\n end", "def invalid_child?(child)\n false\n end", "def invalid_child?(child)\n false\n end", "def children?\n @contents.children?\n end", "def allowed_child?(tag); end", "def node?\n node.present?\n end", "def children?\n self.children.any?\n end", "def has_children?(tree_node)\n tree_node.left || tree_node.right\n end", "def is_child_of?(_parent)\n return false if (self == _parent) or self.root?\n _parent == self.parent\n end", "def nested_child?\n @options.last.last.class.method_defined?('add_element') && @options.last.last.container\n end", "def child_of?(parent)\n self.class.child?(type, parent)\n end", "def child_node; end", "def has_children?\n children.any?\n end", "def hasChildren?\n children = getChildren\n return false if children.empty? or children.nil?\n return true\n end", "def allowed_type?(parent_node); end", "def has_children()\n return 1 if(@children.length > 0)\n 0\n end", "def have_children?\n children.count != 0\n end", "def nested?\n @nodes.any?\n end", "def child? \n parent_id = self[acts_as_nested_set_options[:parent_column]]\n !(parent_id == 0 || parent_id.nil?) && (self[acts_as_nested_set_options[:left_column]] > 1) && (self[acts_as_nested_set_options[:right_column]] > self[acts_as_nested_set_options[:left_column]])\n end", "def child?\n parent_id = self[nested_set_parent]\n !(parent_id == 0 || parent_id.nil?) && (self[nested_set_left] > 1) && (self[nested_set_right] > self[nested_set_left])\n end", "def is_a_node?\n element_type == 'node'\n end", "def is_a_child?(object)\n object.respond_to?(:parent) && object.parent\n end", "def each_child\n return nil unless self.child\n node = self.child\n while node\n yield node\n node = node.next_sibling\n end\n return true\n end", "def has_children?\n\t return true unless self.child_a.nil? || self.child_b.nil? \n\tend", "def hasChild?\n @path.size > 1\n end", "def preserve_children?\n false\n end", "def no_child?\n body.kind_of?(NullNode)\n end", "def is_node?(); @type == GRT_NODE; end", "def node?\n any?(&:node?)\n end", "def xml?\n type == DOCUMENT_NODE\n end", "def allowed_child?(tag)\n if @allowed_children.include?(tag.name)\n true\n elsif @allowed_children.include?(:_inline) && tag.type == :inline\n true\n elsif @allowed_children.include?(:_block) && tag.type == :block\n true\n else\n false\n end\n end", "def element?\n type == ELEMENT_NODE\n end", "def parent?\n !children.empty?\n end", "def children_exist?\n\tend", "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 leaf?\n children.empty?\n end", "def is_decendant_of?(node_map)\n\t\t\t# Hit ourselves\n\t\t\tif node_map == self\n\t\t\t\treturn true\n\t\t\tend\n\n\t\t\t# Recurse\n\t\t\tif self.parent\n\t\t\t\treturn self.parent.is_decendant_of?(node_map)\n\t\t\tend\n\n\t\t\tfalse\n\t\tend", "def isRightChild?\r\n return nil if isRoot?\r\n self == parent.rightChild\r\n end", "def leaf?\n @children.length.zero?\n end", "def leaf?\n @children.empty?\n end", "def has_parent?\n !root?\n end", "def has_graph_child?\n return @has_graph_child unless @has_graph_child.nil? # set by `#set_has_graph_child`\n children.select(:type).any? {|child| child.graph? }\n end", "def isLeftChild?\r\n return nil if isRoot?\r\n self == parent.leftChild\r\n end" ]
[ "0.79603773", "0.7814983", "0.7814983", "0.7786256", "0.7737336", "0.76288193", "0.7578937", "0.7540097", "0.7527541", "0.73899573", "0.73824453", "0.7351262", "0.7334665", "0.7334231", "0.73064137", "0.7286926", "0.7278749", "0.7270024", "0.726623", "0.72097003", "0.72097003", "0.7208084", "0.7184835", "0.71695495", "0.7163963", "0.7163963", "0.7163963", "0.7163963", "0.7162094", "0.7157555", "0.7145153", "0.71336806", "0.7130593", "0.7130593", "0.71296674", "0.71295863", "0.7119349", "0.71108454", "0.71050537", "0.7103841", "0.7103841", "0.70999014", "0.70999014", "0.70999014", "0.70999014", "0.708951", "0.70373905", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.7020977", "0.69979495", "0.69979495", "0.69979495", "0.6996162", "0.6991285", "0.6987423", "0.69854915", "0.69545746", "0.69524175", "0.69163156", "0.6902643", "0.68786836", "0.6873112", "0.68729836", "0.68664753", "0.6856611", "0.6841546", "0.6835229", "0.6826047", "0.6808881", "0.68053967", "0.67761546", "0.6773145", "0.6772242", "0.6693003", "0.6692384", "0.66861963", "0.66678035", "0.6659274", "0.66557574", "0.66470826", "0.6643684", "0.6642868", "0.6631689", "0.6619766", "0.6605117", "0.65944725", "0.65454656", "0.65350765", "0.65343076", "0.6533668", "0.65281314", "0.6508574" ]
0.6638566
90
Deprecated. Returns true if we have no idea what this is
def unknown? !root? && !child? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def legacy?\n false\n end", "def deprecated?\n false\n end", "def completely_deprecated?\n @deprecated == :completely\n end", "def deprecated?\n superseded_by.present?\n end", "def ordinary?\n raise \"Not implemented yet\"\n end", "def deprecated?\n comment.include?(\"(Deprecated)\")\n end", "def usable?; end", "def delicious?\n\t\treturn true\n\tend", "def delicious?()\n\t\treturn TRUE\n\tend", "def deprecated?\n parsed {\n @status == 'Deprecated'\n }\n end", "def tainted?() end", "def internal?; end", "def supported?\n false\n end", "def warning?\n false\n end", "def unknown?; false; end", "def unknown?; false; end", "def missing?; false; end", "def delicious?\n #its automattically true\n true\n end", "def obsolete?\n [email protected]?\n end", "def deprecated?\n self[:slug].nil?\n end", "def obsolete?\n @obsolete ? true : false\n end", "def obsolete?\n self.obsolete\n end", "def disabled?\n deprecated? || deleted?\n end", "def usable?\n false\n end", "def dumb?\n false\n end", "def soy_edificable\n return false\n end", "def soy_edificable\n return false\n end", "def unknown?\n false\n end", "def magical?\n fail NotImplementedError\n end", "def warning?\n check_warnings\n end", "def compilable?\n false\n end", "def info?\n false\n end", "def available?\n return false\n end", "def sos_piedra?() raise NotImplementedError end", "def created_identity?\n ActiveSupport::Deprecation.warn nil, caller\n true \n end", "def warning?; end", "def warning?; end", "def warning?; end", "def check?\n raise NotImplementedError\n end", "def enotsup?() super; end", "def internal?\n self.internal\n end", "def used?; end", "def compilable?\n false\n end", "def available?()\n #This is a stub, used for indexing\n end", "def info?\n raise NotImplementedError.new\n end", "def missing?; end", "def warn?\n raise NotImplementedError.new\n end", "def warning?\n @result.retval == 1\n end", "def allowed_on_commandline?\n @deprecated == :allowed_on_commandline\n end", "def used?\n true\n end", "def broken?\n @broken == :broken \n\tend", "def basic?\n false\n end", "def allowed?() raise NotImplementedError end", "def change_deprecation_iff_user_requested\n return nil unless @name.deprecated != (params[:name][:deprecated] == \"true\")\n\n [email protected]\n end", "def has_warnings?\n @has_warnings ||= false\n end", "def for_dead_friend?\n fail NotImplementedError\n end", "def suitable?\n false\n end", "def suitable?\n false\n end", "def sos_tijera?() raise NotImplementedError end", "def broken?\n ! not_broken?\n end", "def soy_edificable\n return true\n end", "def defanged?\n\t\tdriver.defanged?\n\tend", "def private_call?()\n #This is a stub, used for indexing\n end", "def recommendable?() false end", "def eprotonosupport?() EPROTONOSUPPORT == @error_code; end", "def disable_warnings?(method_key = T.unsafe(nil)); end", "def internal?\n internal\n end", "def sos_papel?() raise NotImplementedError end", "def sos_mono?() raise NotImplementedError end", "def alive?()\n not_implemented()\n end", "def version?\n false\n end", "def consigned?\n false\n end", "def dead?()\n #This is a stub, used for indexing\n end", "def despined?(*)\n end", "def broken?\n\t\t@broken\n\tend", "def controlable?\n respond_to?(:call)\n end", "def supports?\n [email protected]?\n end", "def pointer?; false; end", "def check ; true ; end", "def available?\n raise ::NotImplementedError\n end", "def plain_old_ruby_object\n\t\treturn false\n\tend", "def has_key?(name)\n warn \"#{self.class}#has_key? is deprecated. Use #{self.class}#named? instead: #{caller.first}\"\n named?(name)\n end", "def informational?; end", "def name_safe?; end", "def available?\n false\n end", "def needed_if_relevant?\n false\n end", "def supported?(name); end", "def isSatisfiable?()\n\tend", "def valid_for_platform?; true; end", "def info?\n !success?\n end", "def legacy?\n concierge_version.to_s.empty?\n end", "def autorun?\n fail NotImplementedError\n end", "def available?\n true\n end", "def complain_about_bad_flags?\n @complain_about_bad_flags\n end", "def method_missing(m, *args)\n return false\n end", "def method_missing(*_args)\n true\n end", "def semact?; false; end", "def needed_if_relevant?\n false\n end", "def experimental?\n (@name.first == \"X\")\n end", "def pure?\n raise \"Not implemented yet\"\n end", "def enocompatproto?() ENOCOMPATPROTO == @error_code; end" ]
[ "0.766861", "0.7548163", "0.74961597", "0.74371773", "0.7401675", "0.7229891", "0.71265566", "0.7114632", "0.71074533", "0.71001107", "0.70476544", "0.70336086", "0.6980551", "0.69424057", "0.6933448", "0.6933448", "0.6929677", "0.6925631", "0.68161255", "0.67866397", "0.6772155", "0.67708915", "0.67701334", "0.67472625", "0.6728651", "0.67087895", "0.67087895", "0.6706511", "0.66678", "0.66453177", "0.66358054", "0.6618413", "0.6596792", "0.6589964", "0.6566829", "0.65656734", "0.65656734", "0.65656734", "0.6564713", "0.6560087", "0.65582687", "0.65511626", "0.65381306", "0.6518622", "0.6512527", "0.65091896", "0.6502346", "0.6502252", "0.6496068", "0.6492141", "0.6486993", "0.64832443", "0.64781827", "0.6454642", "0.64483505", "0.6446636", "0.644582", "0.644582", "0.64308095", "0.64299995", "0.64243454", "0.64235383", "0.6422225", "0.6421299", "0.6414341", "0.63996625", "0.63934785", "0.6382169", "0.6376144", "0.6375485", "0.6366719", "0.63612765", "0.6353082", "0.6352491", "0.63390005", "0.6332822", "0.6319279", "0.6304913", "0.6297885", "0.62961835", "0.6296118", "0.629388", "0.629084", "0.6290158", "0.6288865", "0.6277836", "0.62725466", "0.62720144", "0.62710536", "0.62702227", "0.62670857", "0.62620705", "0.62554014", "0.62522775", "0.6250057", "0.6247356", "0.62432957", "0.6242427", "0.623717", "0.6234783", "0.6219363" ]
0.0
-1
Returns this record's root ancestor.
def root # the BETWEEN clause is needed to ensure we get the right virtual root, if using those base_set_class.find(:first, :conditions => "#{scope_condition} \ AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0) AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root_ancestor\n has_parent? ? parent.root_ancestor : self\n end", "def root\n ancestors.first || self\n end", "def root\n return self if root?\n (root_relation_enabled? && root_ancestor) || ancestors.first\n end", "def root\n self_and_ancestors.first\n end", "def root\n return self if is_root?\n ancestors.select { |category| category.is_root? }.first\n end", "def root\n if self.root?\n self\n else\n self.parent.root\n end\n end", "def root\n object = self\n while (object.parent) do object = object.parent; end\n object || self\n end", "def root\n root = self\n until (parent = root.parent).nil?\n root = parent\n end\n root\n end", "def left_ancestor\n ancestors.left_ancestor\n end", "def get_root\n return self if tag == :root || parent.nil?\n parent.get_root\n end", "def root\n root? ? self : parent.root\n end", "def root\n @key.nil? ? self : parents.first\n end", "def root\n parent ? parent.root : self\n end", "def root\n parent ? parent.root : self\n end", "def root_parent\n if parent\n parent.root_parent\n else\n self\n end\n end", "def root\n n = self\n while n.parent \n n = n.parent\n end\n n\n end", "def root \n parent.nil? ? self : parent.root\n end", "def root_entity\n root = self\n loop do\n break if root.parent_id.nil?\n root = root.parent\n end\n root\n end", "def root\n @parent.root\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def root\n return @root if @root\n return self if parent.nil?\n @root = parent.root\n end", "def right_ancestor\n ancestors.right_ancestor\n end", "def parent\n ancestors.last\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def ancestors\n self.root? ? [] : self.parent.ancestors_and_self\n end", "def root\n return @notes.find { |note| note.part == :root } || self.low_note\n end", "def root_level\n self.find\n end", "def root\n self[tree_parent_id_field].nil? ? self : tree_search_class.find(self[tree_path_field].first)\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end", "def root\n if self.dotted_ids\n self.class.find(self.dotted_ids.split('.').first)\n else\n node = self\n node = node.parent while node.parent\n node\n end\n end", "def root\r\n\t\t\t\tself.find(:first, :conditions => 'parent_id IS NULL')\r\n\t\t\tend", "def root\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, 1)\", ltree_path).first\n end", "def root\n node = self\n node = node.parent while !node.parent.nil?\n node\n end", "def effective_root\n if empty? and children.size == 1\n children.first.effective_root\n else\n self\n end\n end", "def first_ancestors(method)\n return nil if root?\n if value = parent.send(method)\n return value\n end\n parent.first_ancestors(method) \n end", "def root\n nested_set_class.find_with_nested_set_scope(:first, :conditions => \"(#{nested_set_parent} IS NULL)\")\n end", "def root\n case parent\n when Pathname then parent\n when FileStore then parent.root\n else nil\n end\n end", "def record_with_ancestor_chain(record)\n TraverseAncestors[record]\n end", "def root\n return @root\n end", "def root\n return @root\n end", "def ancestors\n return @ancestors unless @ancestors.nil?\n # Stop if this is already the root node\n return @ancestors = [self] if File.basename(tree).empty?\n # Path for parent is blank if parent is root node\n parent_path = if File.dirname(tree) == '.'\n \"\"\n # Otherwise it is the directory in which this node is located\n else\n File.dirname tree\n end\n parent = git_flow_repo.working_file parent_path\n @ancestors = parent.ancestors + [ self ]\n end", "def get_language_root\n self_and_ancestors.find_by(language_root: true)\n end", "def ancestors\n without_self self_and_ancestors\n end", "def root\n self.find(:first, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\")\n end", "def ancestor_class\n list = ancestor_classes\n self if list.length == 0\n ancestor_classes[1]\n end", "def self_and_ancestors\n # 1. recursively load ancestors\n nodes = []\n node = self\n\n while node\n nodes << node\n node = node.parent\n end\n\n # 2. first ancestor is a root\n nodes.reverse!\n\n # 3. create fake scope\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => nodes.map(&:id).compact).\n extending(Arrangeable).\n records(nodes)\n end", "def root(reload=false)\n ancestors(reload).first\n end", "def ancestors\n TreeNode.find(:all,\n :from => \"cms_treenode_ancestors(#{self.id}, #{AuthenticationModel.current_user}) tree_nodes\") rescue []\n end", "def parent\n self.parents.where('forestify_level = ?', self.forestify_level - 1).first\n end", "def get_path_root\n return self if @path.nil?\n @path.get_path_root\n end", "def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end", "def pbt_top_parent\n record = self\n return nil unless record.pbt_parent\n no_repeat = PolyBelongsTo::SingletonSet.new\n while !no_repeat.include?(record.pbt_parent) && !record.pbt_parent.nil?\n no_repeat.add?(record)\n record = record.pbt_parent\n end\n record\n end", "def get_parent\n return nil\n end", "def ancestors(node, root = nil)\n root ||= @root\n (self.path(root, node) - [ node ]).reverse\n end", "def parent\n case\n when root? then nil\n else\n require 'pathname' unless defined?(Pathname)\n if path = Pathname.new(self.path).parent\n uri = self.dup\n uri.path = path.to_s\n uri.path << '/' unless uri.root?\n uri\n end\n end\n end", "def root(scope = {})\n find_in_nested_set(:first, { :conditions => \"(#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\" }, scope)\n end", "def parent\n if parent_id.blank? then nil else unscoped_find(parent_id) end\n end", "def root\n return @root\n end", "def ancestors\n model_base_class.where(ancestor_conditions).order(:materialized_path)\n end", "def find_root_element\n if parent\n parent.find_root_element\n else\n self\n end\n end", "def get_parent\n note = self\n return Note.first(:id=>note.parent)\n end", "def root\n cursor = self\n cursor = cursor.up until cursor.root?\n cursor\n end", "def ultimate_parent # note: ultimate parent is self, not nil, if self has no parent...\n if parent_id.blank?\n self\n else\n parent.ultimate_parent\n end\n end", "def root_id\n if ancestor_ids.empty? then\n id\n else\n branches.first.split('/').first\n end\n end", "def root_id\n if ancestor_ids.empty? then\n id\n else\n branches.first.split('/').first.to_i\n end\n end", "def ancestors\n model_base_class.scoped(:conditions => ancestor_conditions, :order => :ancestry_string)\n end", "def parent\n parent_path = @location.parent_path\n \n if parent_path.nil?\n nil\n else\n begin\n self.class.find(@conn_id, parent_path)\n rescue Errors::FolderNotFound, parent_path\n nil\n end\n end\n end", "def root\n\t\t\t\tfind_root[0].to_s\n\t\t\tend", "def root\n first :parent_id => nil\n end", "def parent\n dataset.nested.filter(self.primary_key => self.parent_id).first if self.parent_id\n end", "def parent()\n bag.get(bag.parent(path))\n end", "def ancestors\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_left} < #{self[nested_set_left]} and #{nested_set_right} > #{self[nested_set_right]})\", :order => nested_set_left )\n end", "def parent\n tree.parent_for(parent_id).first\n end", "def root\n @root\n end", "def root_rel\n rel = relationship.try!(:root)\n # micro-optimization: if the relationship is us, \"load\" the resource\n rel.resource = self if rel && rel.resource_id == id && rel.resource_type == self.class.base_class.name.to_s\n rel || relationship_for_isolated_root\n end", "def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end", "def root\n self\n end", "def root\n self\n end", "def parent\n unless @parent\n @parent = search(:base => dn.parent, :scope => :base, :limit => true)\n @parent.instance_variable_get(:@children)[rdn] = self\n end\n @parent\n end", "def root\n if is_root?\n self\n else\n return Especie.none unless ancestry_ascendente_directo.present?\n ancestros = ancestry_ascendente_directo.split(',').map{|a| a.to_i if a.present?}.compact\n return Especie.none unless ancestros.any?\n\n Especie.find(ancestros.first)\n end\n end", "def root(scope = {})\n # the BETWEEN clause is needed to ensure we get the right virtual root, if using those\n self.class.find_in_nested_set(:first, { :conditions => \"#{scope_condition} \\\n AND (#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0) AND (#{self[left_col_name]} BETWEEN #{prefixed_left_col_name} AND #{prefixed_right_col_name})\" }, scope)\n end", "def ancestors\n records = self_and_ancestors - [self]\n\n scope = self_and_ancestors.where(arel[:id].not_eq(id))\n scope.records(records)\n end", "def ancestors\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", "def ancestors\n self_and_ancestors - [self]\n end", "def parent\n\t\tpardn = self.parent_dn or return nil\n\t\treturn self.class.new( self.directory, pardn )\n\tend", "def ancestors\n without_self(self_and_ancestors)\n end", "def root_node\n root_nodes.first\n end", "def parent\n @parent ||= Wayfinder.for(file_set).parent\n end", "def parent\n parents.empty? ? nil : parents[0]\n end", "def parent\n\t\treturn parent_of @current_node\n\tend", "def root\n @attributes[:root]\n end", "def get_root(doc)\n doc.children.first\n end", "def getRoot\n @path[0]\n end", "def ancestors() end", "def self_and_ancestors\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} @> ?\", ltree_path)\n end", "def ancestors; end", "def ancestors; end" ]
[ "0.83231187", "0.80980664", "0.79259104", "0.7638012", "0.74833167", "0.73352784", "0.72664464", "0.72638637", "0.7249485", "0.7242637", "0.7212541", "0.7176655", "0.7155322", "0.7155322", "0.7134192", "0.71137166", "0.7070988", "0.7007501", "0.6996722", "0.6957024", "0.6930425", "0.6928335", "0.69190377", "0.6907104", "0.68647206", "0.6816081", "0.6808035", "0.6802164", "0.6764966", "0.67579633", "0.67579633", "0.67157745", "0.666738", "0.661612", "0.6615108", "0.66001433", "0.6573578", "0.6562193", "0.65566874", "0.6540017", "0.652649", "0.6504365", "0.6504365", "0.64948994", "0.64751613", "0.64595973", "0.6458965", "0.64333373", "0.64176387", "0.6409914", "0.64067066", "0.6395821", "0.6393175", "0.63821757", "0.63538074", "0.6353347", "0.6339294", "0.63166356", "0.630358", "0.63018316", "0.6257192", "0.6252785", "0.6229425", "0.6215905", "0.62126195", "0.6197458", "0.61917764", "0.6188546", "0.6188007", "0.61838263", "0.618139", "0.61798364", "0.6175908", "0.6168021", "0.6145471", "0.61358273", "0.6134452", "0.61274296", "0.6123028", "0.61152", "0.61152", "0.61031705", "0.60882413", "0.6078963", "0.6073159", "0.6073071", "0.60598904", "0.6053617", "0.60515136", "0.60514164", "0.6044268", "0.6042628", "0.60402626", "0.6022904", "0.6003101", "0.5995565", "0.5993431", "0.5981101", "0.5980956", "0.5980956" ]
0.615257
74
Returns the root or virtual roots of this record's tree (a tree cannot have more than one real root). See the explanation of virtual roots in the README.
def roots base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0)", :order => "#{left_col_name}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roots\n nodes.select{ |n| n.root? }\n end", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def roots\n acts_as_nested_set_options[:class].find(:all, :conditions => \"(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def roots\n select\n end", "def roots\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def roots\n self.find(:all, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def roots\n nested.filter(self.model_classes[nil].qualified_parent_column => nil)\n end", "def x_get_tree_roots(count_only, _options)\n objects = Rbac.filtered(VmdbDatabase.my_database.evm_tables).to_a\n # storing table names and their id in hash so they can be used to build links on summary screen in top 5 boxes\n @sb[:vmdb_tables] = {}\n objects.each do |o|\n @sb[:vmdb_tables][o.name] = o.id\n end\n count_only_or_objects(count_only, objects, \"name\")\n end", "def roots(scope = {})\n find_in_nested_set(:all, { :conditions => \"(#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def subgraph_roots\n @subgraph_roots || []\n end", "def roots\n self.ontology_classes(force_reload=true).select{|c| c.isroot?}\n end", "def root\n self[tree_parent_id_field].nil? ? self : tree_search_class.find(self[tree_path_field].first)\n end", "def root\n return self if root?\n (root_relation_enabled? && root_ancestor) || ancestors.first\n end", "def roots\n self.where(parent: nil).order('index asc')\n end", "def x_get_tree_roots\n count_only_or_objects(false, PxeServer.all, \"name\")\n end", "def root_level\n self.find\n end", "def root\n return @root\n end", "def root\n return @root\n end", "def root_volumes\n volumes.select {|vol| vol.parent_id == nil}\n end", "def roots(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND (#{prefixed_parent_col_name} IS NULL OR #{prefixed_parent_col_name} = 0)\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def tree_root\n repo.tree\n end", "def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end", "def x_get_tree_roots\n objects = []\n objects.push(configured_systems)\n count_only_or_objects(false, objects + FILTERS.values)\n end", "def x_get_tree_roots(count_only, _options)\n objects = []\n objects.push(:id => \"asrv\",\n :text => _(\"Active Services\"),\n :icon => \"pficon pficon-folder-close\",\n :load_children => true,\n :tip => _(\"Active Services\"))\n objects.push(:id => \"rsrv\",\n :text => _(\"Retired Services\"),\n :icon => \"pficon pficon-folder-close\",\n :load_children => true,\n :tip => _(\"Retired Services\"))\n count_only_or_objects(count_only, objects)\n end", "def root\n return @notes.find { |note| note.part == :root } || self.low_note\n end", "def root\n return @root\n end", "def x_get_tree_roots\n objects = [\n {:id => \"sis\", :text => _(\"Analysis Profiles\"), :icon => \"fa fa-search\", :tip => _(\"Analysis Profiles\")},\n {:id => \"z\", :text => _(\"Zones\"), :icon => \"pficon pficon-zone\", :tip => _(\"Zones\")}\n ]\n objects.push(:id => \"msc\", :text => _(\"Schedules\"), :icon => \"fa fa-clock-o\", :tip => _(\"Schedules\"))\n objects\n end", "def x_get_tree_roots\n u = User.current_user\n user_groups = u.report_admin_user? ? nil : u.miq_groups\n having_report_results(user_groups).sort\n end", "def root\n object = self\n while (object.parent) do object = object.parent; end\n object || self\n end", "def x_get_tree_roots\n objects = []\n objects << {:id => \"compliance\", :text => _(\"Compliance Policies\"), :icon => \"pficon pficon-history\", :tip => _(\"Compliance Policies\")}\n objects << {:id => \"control\", :text => _(\"Control Policies\"), :icon => \"fa fa-shield\", :tip => _(\"Control Policies\")}\n\n # Push folder node ids onto open_nodes array\n objects.each { |o| open_node(\"xx-#{o[:id]}\") }\n\n count_only_or_objects(false, objects)\n end", "def root\n if self.dotted_ids\n self.class.find(self.dotted_ids.split('.').first)\n else\n node = self\n node = node.parent while node.parent\n node\n end\n end", "def root\n @root\n end", "def x_get_tree_roots\n count_only_or_objects(false, StorageCluster.all)\n end", "def root_entity\n root = self\n loop do\n break if root.parent_id.nil?\n root = root.parent\n end\n root\n end", "def x_get_tree_roots\n objects = []\n objects.push(:id => \"xx-system\",\n :text => _(\"Examples (read only)\"),\n :icon => \"pficon pficon-folder-close\",\n :tip => _(\"Examples (read only)\"))\n PxeImageType.all.sort.each do |item, _idx|\n objects.push(item)\n end\n objects\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def get_root\n return self if tag == :root || parent.nil?\n parent.get_root\n end", "def get_root()\n \n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def roots(*args)\n #return find_by_sql(\"select a.* from #{table_name} as a left join #{table_name} b on a.parent_node_id = b.child_node_id where b.child_node_id IS NULL\")\n conditions=['b.child_node_id IS NULL']\n joins=\"LEFT JOIN #{table_name} b ON #{table_name}.parent_node_id = b.child_node_id\"\n with_scope(:find=>{:conditions=>conditions, :joins=>joins, :select=>'#{table_name}.*', :from=>\"#{table_name} #{table_name}\"}) do\n find(:all, *args)\n end\n end", "def root\n @root ||= (parent ? parent.root : self)\n end", "def root\n root = self\n until (parent = root.parent).nil?\n root = parent\n end\n root\n end", "def root\n ancestors.first || self\n end", "def root\n cursor = self\n cursor = cursor.up until cursor.root?\n cursor\n end", "def root_expressions\n\n roots = @expressions.select { |e| e.h.parent_id == nil }\n\n roots = roots.each_with_object({}) { |e, h|\n h[\"#{e.h.fei['expid']}__#{e.h.fei['subid']}\"] = e\n }\n\n roots.keys.sort.collect { |k| roots[k] }\n end", "def get_roots\n find_all{|entry| entry.type==Morpheme::ROOT}\n end", "def root(stubborn=false)\n\n previous = nil\n current = @h\n\n exps = @context.storage.find_expressions(\n h.fei['wfid']\n ).each_with_object({}) { |exp, h|\n h[exp['fei']] = exp\n }\n\n while current && current['parent_id']\n previous = current\n current = exps[current['parent_id']]\n end\n\n current ||= previous unless stubborn\n\n current ? Ruote::Exp::FlowExpression.from_h(@context, current) : nil\n end", "def root\n return nodes.first if nodes.size == 1\n nodes.find { |node| root?(node) }\n end", "def collect_roots\n\n\t\t# Array to return\n\t\troots = Array.new\n\t\t# For each template\n\t\ttemplates.each do |key, val|\n\t\t\t# Push to array if root\n\t\t\troots << val if template_root? key\n\t\tend\n\t\t\n\t\t# Return results\n\t\troots\n\n\tend", "def root\n if self.root?\n self\n else\n self.parent.root\n end\n end", "def root\n\t\t\t\tfind_root[0].to_s\n\t\t\tend", "def roots(user = nil)\n domain = config.site_domain\n roots = pages_dataset.where(depth: 0).all\n pub, hidden = roots.partition { |p| p.root? }\n map = {}\n map[domain] = pub.first.id unless pub.empty?\n hidden.each { |p| map[p.path] = p.id }\n { \"public\" => domain, \"roots\" => map }\n end", "def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end", "def all\n root.to_a\n end", "def root\n nested_set_class.find_with_nested_set_scope(:first, :conditions => \"(#{nested_set_parent} IS NULL)\")\n end", "def root\n n = self\n while n.parent \n n = n.parent\n end\n n\n end", "def root\n words.find(&:root?)\n end", "def root \n parent.nil? ? self : parent.root\n end", "def root\n @key.nil? ? self : parents.first\n end", "def root_scrapers\n roots = []\n scrapers.each_pair do |group, scrapers_in_group|\n scrapers_in_group.each_pair do |key, val|\n roots << val if val.is_root?\n end\n end\n roots\n end", "def root\r\n\t\t\t\tself.find(:first, :conditions => 'parent_id IS NULL')\r\n\t\t\tend", "def root\n root? ? self : parent.root\n end", "def root\n ltree_scope.where(\"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, 1)\", ltree_path).first\n end", "def root\n @parent.root\n end", "def root\n parent ? parent.root : self\n end", "def root\n parent ? parent.root : self\n end", "def root\n self_and_ancestors.first\n end", "def root_branches\n @root_branches = branches.select(&:root?)\n end", "def roots\n if(rails_3?)\n configuration[:class].where(\n \"#{configuration[:foreign_key]} IS NULL\"\n ).order(configuration[:order])\n else\n configuration[:class].scoped(\n :conditions => \"#{configuration[:foreign_key]} IS NULL\",\n :order => configuration[:order]\n )\n end\n end", "def x_get_tree_roots(_count_only, _options)\n resolve = {}\n CustomButton.button_classes.each { |db| resolve[db] = ui_lookup(:model => db) }\n @sb[:target_classes] = resolve.invert\n resolve = Array(resolve.invert).sort\n resolve.collect do |typ|\n {:id => \"ab_#{typ[1]}\", :text => typ[0], :image => buttons_node_image(typ[1]), :tip => typ[0]}\n end\n end", "def root\n @root ||= NodeProxy.new(@doc.root) if @doc && @doc.root\n end", "def nodes()\n self.root.nodes()\n end", "def x_get_tree_roots(_count_only, _options)\n resolve = {}\n CustomButton.button_classes.each { |db| resolve[db] = ui_lookup(:model => db) }\n @sb[:target_classes] = resolve.invert\n resolve = Array(resolve.invert).sort\n resolve.collect do |typ|\n {:id => \"ab_#{typ[1]}\", :text => typ[0], :tip => typ[0]}.merge(buttons_node_image(typ[1]))\n end\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def ancestors\n TreeNode.find(:all,\n :from => \"cms_treenode_ancestors(#{self.id}, #{AuthenticationModel.current_user}) tree_nodes\") rescue []\n end", "def root_collection\n return @root_collection ||= file_by_id(\"root\")\n end", "def tree_root\n if (root_id = visibility_path_ids.first)\n return content_model::Page.get(root_id)\n end\n nil\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def root(v, w)\n v_ids = []\n w_ids = []\n roots = []\n\n @synsets.each do |key, value|\n if value.include?(v)\n v_ids.push(key)\n end\n if value.include?(w)\n w_ids.push(key)\n end\n end\n\n lcas = ancestor(v_ids, w_ids)\n if lcas == -1\n return -1\n else\n lcas.each do |a|\n roots += @synsets[a]\n end\n end\n return roots\n end", "def root\n case parent\n when Pathname then parent\n when FileStore then parent.root\n else nil\n end\n end", "def root\n unless @root\n @root = Entry.new\n self.class.parse @root, @raw\n @raw = nil\n end\n\n @root\n end", "def root?\n parent_id = self[nested_set_parent]\n (parent_id == 0 || parent_id.nil?) && (self[nested_set_left] == 1) && (self[nested_set_right] > self[nested_set_left])\n end", "def root_model\n node = @model\n\n loop do\n parent = node.parent\n if parent\n node = parent\n else\n break\n end\n end\n\n node\n end", "def root_model\n node = @model\n\n loop do\n parent = node.parent\n if parent\n node = parent\n else\n break\n end\n end\n\n node\n end", "def get_feature_reviews_roots\n @trees ||= self.product.category.self_and_ancestors.collect { |cat| [cat, Feature.node_roots(:include => :feature_reviews, :conditions => [\"features.category_id=? AND feature_reviews.review_id=?\", cat.id, id])] }\n end", "def get_feature_values_roots()\n @trees ||= self.category.self_and_ancestors.collect { |cat| [cat, Feature.node_roots(:include => :feature_values, :conditions => [\"features.category_id=? AND feature_values.product_id =?\", cat.id, id])] }\n end", "def effective_root\n if empty? and children.size == 1\n children.first.effective_root\n else\n self\n end\n end", "def root\n # the BETWEEN clause is needed to ensure we get the right virtual root, if using those\n base_set_class.find(:first, :conditions => \"#{scope_condition} \\\n AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0) AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})\")\n end", "def x_get_tree_roots\n count_only_or_objects(false, MiqPolicySet.all, :description)\n end", "def root\n node = self\n node = node.parent while !node.parent.nil?\n node\n end", "def rootObject\n @otrunk.getRoot\n end", "def rootObject\n @otrunk.getRoot\n end", "def root\n acts_as_nested_set_options[:class].find(:first, :conditions => \"(#{acts_as_nested_set_options[:parent_column]} IS NULL OR #{acts_as_nested_set_options[:parent_column]} = 0)\")\n end", "def root\n self.find(:first, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\")\n end", "def root\n return self if is_root?\n ancestors.select { |category| category.is_root? }.first\n end", "def page_tree\n @tree ||= [self.root_page.tree_hash_value]\n @tree\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end", "def root\n node = self\n node = node.parent while node.parent\n node\n end" ]
[ "0.7079386", "0.7046463", "0.6888999", "0.6759608", "0.6606695", "0.65630203", "0.65467656", "0.6501717", "0.632362", "0.6297851", "0.6291363", "0.61610913", "0.61275357", "0.6116486", "0.6111284", "0.609791", "0.6067172", "0.6067172", "0.60617656", "0.604975", "0.6027195", "0.5999041", "0.5996342", "0.59850746", "0.5971054", "0.5935369", "0.59219146", "0.5916268", "0.59051794", "0.5894288", "0.58933043", "0.5890902", "0.5889508", "0.5886693", "0.58701575", "0.5862946", "0.584323", "0.58396333", "0.5831059", "0.58306515", "0.58306515", "0.5829976", "0.58286405", "0.5823955", "0.5811326", "0.580079", "0.57937235", "0.57899743", "0.57588226", "0.575212", "0.5747471", "0.5747298", "0.5739979", "0.57392895", "0.57328105", "0.571572", "0.5709449", "0.5706882", "0.5702045", "0.56821024", "0.56787205", "0.56635165", "0.5658974", "0.56539416", "0.5637208", "0.55904996", "0.55899936", "0.55899936", "0.5589984", "0.5575857", "0.5574943", "0.556152", "0.5551718", "0.55515665", "0.55459344", "0.5541844", "0.5537372", "0.5535825", "0.55310404", "0.5528808", "0.5528251", "0.5510411", "0.5510099", "0.550767", "0.550695", "0.550695", "0.55029684", "0.55027556", "0.5496273", "0.5492482", "0.54841435", "0.5481592", "0.54732776", "0.54732776", "0.5470429", "0.5458875", "0.54558754", "0.5452996", "0.5449333", "0.54489356" ]
0.6163727
11
Returns this record's parent.
def parent base_set_class.find(self[parent_col_name]) if self[parent_col_name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parent\n if parent_id.blank? then nil else unscoped_find(parent_id) end\n end", "def parent\n return @parent\n end", "def parent\n\n h.parent_id ?\n Ruote::Exp::FlowExpression.fetch(@context, h.parent_id) :\n nil\n end", "def parent\n tree.parent_for(parent_id).first\n end", "def parent\n o = Object.const_get(parent_model) rescue nil\n o && o.get(parent_id)\n end", "def parent\n dataset.nested.filter(self.primary_key => self.parent_id).first if self.parent_id\n end", "def parent\n if self.rep_parent.nil?\n if self.parent_id.nil?\n return nil\n else\n return Activity.find(self.parent_id)\n end\n\n else\n return self.rep_parent.parent\n end\n end", "def get_parent\n note = self\n return Note.first(:id=>note.parent)\n end", "def parent\n self.class.find_by_id(self.parent_id) unless self.parent_id.nil?\n end", "def parent\n @parent\n end", "def parent\n @parent\n end", "def parent\n @parent\n end", "def parent\n @parent\n end", "def parent\n _parent\n end", "def get_parent\n return nil\n end", "def parent_id\n self.parent._id.to_s\n end", "def parent\n self.class.find_in_nested_set(self[parent_col_name]) if self[parent_col_name]\n end", "def parent\n @parent ||= new_or_create? ? find_parent_by_id : lookup_parent_from_child\n end", "def parent_id\n object[\"parent_id\"]\n end", "def parent_id\n self[self.nested_set_options[:parent_column]]\n end", "def parent\n @parent ||= @parent_id ? @book.find_account_by_id(@parent_id) : nil\n end", "def parent\n nil\n end", "def parent\n return nil unless catalog\n\n unless defined?(@parent)\n if parents = catalog.adjacent(self, :direction => :in)\n # We should never have more than one parent, so let's just ignore\n # it if we happen to.\n @parent = parents.shift\n else\n @parent = nil\n end\n end\n @parent\n end", "def parent\n @parent\n end", "def parent\n @parent\n end", "def parent\n return @links[:parent]\n end", "def parent\n self\n end", "def parent\n owner\n end", "def parent\n return @parent unless @parent.nil?\n return Message.find(parent_id) unless parent_id.nil?\n end", "def parent\n\t\tself.residue_at_position(@parent_position)\n\tend", "def parent\n has_parent? and history.first\n end", "def parent\n\t\tpardn = self.parent_dn or return nil\n\t\treturn self.class.new( self.directory, pardn )\n\tend", "def parent\n parents.empty? ? nil : parents[0]\n end", "def parent\n\t\treturn parent_of @current_node\n\tend", "def parent\n return persistence_strategy.parent if\n persistence_strategy.respond_to?(:parent)\n\n nil\n end", "def parent\n @parent ||= resource.decorate.parent\n end", "def parent\n \tif self.parent_id == -1\n \t\treturn nil\n \telse\n \t\treturn Category.find(self.parent_id)\n \tend\n end", "def parent\n self.parents.where('forestify_level = ?', self.forestify_level - 1).first\n end", "def parent_object\n # hack by sean to allow permalink parents\n parent? && !parent_singleton? ? parent_model_find(parent_param) : nil\n end", "def parent\n self\n end", "def parent_id\n\n h.parent_id ?\n Ruote::FlowExpressionId.new(h.parent_id) :\n nil\n end", "def parent_id\n data[:parent_id]\n end", "def parent\n ltree_scope.find_by \"#{self.class.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)\", ltree_path,\n ltree_path\n end", "def parent_object\n @parent_object ||= parent? && !parent_singleton? ? parent_model.find(parent_param) : nil\n end", "def parent\n return @parent if defined?(@parent)\n\n @parent = nil\n\n @parent = issue.parent if issue\n end", "def find_creator_parent_item\n ModelReference.find_where_referenced_from(self).first&.from_record\n end", "def parent\n @parent || NullResource.new\n end", "def parent\n ancestors.last\n end", "def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end", "def parent\n object.try(:loaded)&.[](:parents)&.first || wayfinder.decorated_parent\n end", "def parent_name\n parent_info && parent_info.name\n end", "def parent_id\n parent_ids.last\n end", "def parent\n SideJob.find(SideJob.redis.get(\"#{redis_key}:parent\"))\n end", "def parent\n parent_path = @location.parent_path\n \n if parent_path.nil?\n nil\n else\n begin\n self.class.find(@conn_id, parent_path)\n rescue Errors::FolderNotFound, parent_path\n nil\n end\n end\n end", "def parent_document\n pi = parent_item\n return if pi == nil\n pi_id = pi.id\n return if pi_id == nil\n DocumentRepository.find(pi_id)\n end", "def parent()\n bag.get(bag.parent(path))\n end", "def parent\n nil\n end", "def parent_notebook\n return @parent_notebook\n end", "def parent_notebook\n return @parent_notebook\n end", "def parent_notebook\n return @parent_notebook\n end", "def parent\n DataStore::Base.find(identifier: identifier)\n end", "def _parent_id\n send parent_column_name\n end", "def parent_id\r\n return nil unless ar_object\r\n ar_object[ar_p]\r\n end", "def get_parent\n\n get_expression_pool.fetch_expression(@parent_id)\n end", "def parent\n unless @parent\n @parent = search(:base => dn.parent, :scope => :base, :limit => true)\n @parent.instance_variable_get(:@children)[rdn] = self\n end\n @parent\n end", "def parent_id(target = self)\n target[parent_column_name]\n end", "def parent_object\n if has_parent?\n actual_class = parent_class_name.camelize.constantize\n actual_class.find(parent_id)\n else\n nil\n end\n end", "def parent_of(post)\n posts.find { |t| t.id == post.parent_post }\n end", "def parent\n @parent ||= begin\n parent_id = data[\"parentId\"]\n client.categories.find(parent_id) if parent_id\n end\n end", "def current_parent\n\t Parent.where(id: session[\"parent_id\"]).first\n\tend", "def parent_name\n self.class.parent_name\n end", "def parent_name\n @parent ? @parent.full_name : '(unknown)'\n end", "def ultimate_parent # note: ultimate parent is self, not nil, if self has no parent...\n if parent_id.blank?\n self\n else\n parent.ultimate_parent\n end\n end", "def polymorph_parent(parent=nil)\n\t\t@parent ||= parent\n\t\treturn @parent\n\tend", "def parent\n hyper_schema_link.parent\n end", "def parent\n p = (@context.parent.nil? || (@context == @context.parent)) ? nil : R2Doc.all_references[parent_name]\n # guard against pollution of all_references with methods having conflicting names\n (p.respond_to?(:is_method_context?) && p.is_method_context?) ? nil : p\n end", "def parent_handle\n self.parent ? self.parent.handle : @parent_handle\n end", "def parent\n if @resource[:parent] =~ /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/\n gindex = $ngs.index { |i| i['id'] == @resource[:parent] }\n $ngs[gindex]['id']\n else\n @property_hash[:parent]\n end\n end", "def parent\n @parent ||= Wayfinder.for(file_set).parent\n end", "def parent_foreign_key\n @parent_hierarchy_relationship.foreign_key\n end", "def find_parent_by\n self.class.find_parent_by || :id\n end", "def parent\n @parent ||= self.class.current_parent_block_helper\n end", "def parent\n bibliography && bibliography[fields[:crossref]]\n end", "def parent\n if @obj.parent\n LazyEvaluator.new(@obj.parent)\n else\n nil\n end\n end", "def get_parent_object\n nil\n end", "def parent_model\n return @parent_model if @parent_model\n\n if parent_model_name && parent_model_class\n parent_id_param = \"#{parent_model_name}_id\"\n if params[parent_id_param]\n @parent_model = parent_model_class.find_by(find_parent_by => params[parent_id_param])\n end\n end\n\n @parent_model\n end", "def parent\n @controller.instance_variable_get(:\"@#{parent_name}\")\n end", "def parent\n User.find(self.user_id)\n end", "def parent\n send(parent_type)\n end", "def get_parent_of(record, path)\n parent_object = path[0..-2].reduce(record) { |a, e| a.is_a?(Hash) ? a[e] : nil }\n [parent_object, path[-1]]\n end", "def parent_node(node)\n return node.respond_to?(:parent) ? node.parent : node\n end", "def parent_list\n self.parent_lists[0]\n end", "def parent(reload:false)\n if reload || !defined?(@parent)\n @parent = self.class.where({\n document_id: document_id,\n child_ids: id\n }).first\n end\n @parent\n end", "def parent_of node\n\t\treturn is_valid(node) ? node.parent : nil\n\tend", "def parent\n return @parent if @parent\n return nil unless @parent_name\n\n if @parent_class == RDoc::TopLevel then\n @parent = @store.add_file @parent_name\n else\n @parent = @store.find_class_or_module @parent_name\n\n return @parent if @parent\n\n begin\n @parent = @store.load_class @parent_name\n rescue RDoc::Store::MissingFileError\n nil\n end\n end\n end", "def parent parent\n @menu.parent parent\n end", "def find_parent_comment_id\n comment = Comment.find_by_id(self.likeable_id)\n comment.parent_comment_id\n end", "def pbt_top_parent\n record = self\n return nil unless record.pbt_parent\n no_repeat = PolyBelongsTo::SingletonSet.new\n while !no_repeat.include?(record.pbt_parent) && !record.pbt_parent.nil?\n no_repeat.add?(record)\n record = record.pbt_parent\n end\n record\n end", "def parent_section\n return @parent_section\n end", "def parent_reply\n Reply.find_by_id(self.parent_id)\n end" ]
[ "0.84784544", "0.83824444", "0.8354035", "0.830168", "0.82071406", "0.82053274", "0.8205208", "0.819517", "0.81944245", "0.8117471", "0.8117471", "0.8117471", "0.8117471", "0.80889726", "0.8035122", "0.79576796", "0.7908726", "0.7894084", "0.78788114", "0.7874622", "0.7869753", "0.78525805", "0.7849903", "0.78396535", "0.78396535", "0.78319794", "0.778764", "0.7782898", "0.7769842", "0.7767768", "0.77668005", "0.77349776", "0.7717105", "0.7716044", "0.7714786", "0.7701549", "0.7681508", "0.76271117", "0.7626219", "0.7624688", "0.76174027", "0.76135486", "0.7574703", "0.75741297", "0.75727844", "0.75698316", "0.7568332", "0.7537927", "0.75188893", "0.7489151", "0.7476298", "0.74602395", "0.74472964", "0.74292535", "0.7426245", "0.7417285", "0.7406656", "0.73787814", "0.73787814", "0.73787814", "0.73467755", "0.73369104", "0.7318385", "0.7316556", "0.7307841", "0.73053646", "0.7281778", "0.7249263", "0.7230399", "0.7230111", "0.72004795", "0.7199402", "0.71923596", "0.7189037", "0.718008", "0.71777815", "0.71638346", "0.7159625", "0.7156457", "0.71553266", "0.7147086", "0.71418554", "0.7115151", "0.7109904", "0.7106669", "0.7105867", "0.71042156", "0.7095587", "0.70858014", "0.70681244", "0.70469683", "0.70301074", "0.70234203", "0.7000302", "0.6979588", "0.6977342", "0.6965999", "0.6952784", "0.6944666", "0.6938901" ]
0.7128962
82
Returns an array of all parents, starting with the root.
def ancestors self_and_ancestors - [self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end", "def parents\n unless @parents\n @parents = []\n object = self\n while object.respond_to?(:parent) && object.parent\n @parents << object.parent\n object = object.parent\n end\n end\n @parents\n end", "def parents\n @parents ||= parent ? parent.parents + Array(parent) : []\n end", "def all_parents\n parents(all: true)\n end", "def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end", "def parents\n page, parents = self, Array.new\n while page.parent\n page = page.parent\n parents << page\n end\n parents\n end", "def getAllParents\n parents = []\n parent = self.getParentRec\n self_code = self.code.split('.')\n self_code.pop(1)\n while self_code.length > 0 do\n puts \"self_code: #{self_code}\"\n if parent.present?\n parents << parent\n parent = parent.getParentRec\n self_code.pop(1)\n else\n parents << nil\n self_code.pop(1)\n parent = Tree.where(\n tree_type_id: self.tree_type_id,\n version_id: self.version_id,\n subject_id: self.subject_id,\n grade_band_id: self.grade_band_id,\n code: self_code.join(\".\")\n ).first\n end\n end\n Rails.logger.debug(\"*** tree parents: #{parents.inspect}\")\n return parents\n end", "def ancestors \n \t\tres=parents\n \t\tparents.each {|c| res += c.ancestors}\n \t\treturn res.uniq\n \tend", "def find_all_parents\n end", "def ancestors_r(*args)\n # fetch all parents\n pending = [self]\n ans = []\n while !pending.empty?\n e = pending.pop\n e.parents(*args).each do |p|\n if !ans.include?(p)\n ans << p\n pending.push(p)\n end\n end\n end\n ans\n end", "def ancestors\n ancestors = []\n current_ancestor = self\n \n while !current_ancestor.nil?\n \n if current_ancestor.respond_to?(:parent)\n ancestors << current_ancestor\n current_ancestor = current_ancestor.parent\n else\n current_ancestor = nil\n end\n \n end\n \n ancestors\n end", "def get_parents\n return @parents\n end", "def ancestors\n []\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def ancestors\n parents + parents.map(&:ancestors).flatten\n end", "def ancestors\n if parent.nil?\n []\n else\n parent.ancestors + [parent]\n end\n end", "def hierarchy\n parents = []\n parent = self.parent\n\n while parent && !parent.parent_id.nil?\n parents << parent\n parent = parent.parent\n end\n\n return parents.reverse\n end", "def parents_and_self\n ret = []\n ret.concat(parent.parents_and_self) if parent\n ret << self\n ret\n end", "def parent_rel_ids\n rel = relationships\n if rel.kind_of?(Array) || rel.try(:loaded?)\n rel.reject { |x| x.ancestry.blank? }.collect(&:parent_id)\n else\n rel.where.not(:ancestry => [nil, \"\"]).select(:ancestry).collect(&:parent_id)\n end\n end", "def ancestors\n parent ? [parent, parent.ancestors].flatten : []\n end", "def parents\n if parent.nil?\n [self]\n else\n parent.parents + [self]\n end\n end", "def parents\n\n TapirLogger.instance.log \"Finding parents for #{self}\"\n parents = []\n self.entity_mappings.each do |mapping|\n\n # Go through each associated entity mapping, and find mappings where the child_id is us \n # which means that the parent_id is some other entity, and it's a parent\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectId\n parents << mapping.get_parent if mapping.child_id == self.id.to_s \n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n\n end\n parents\n end", "def ancestors_ids\n node, nodes = self, []\n while node.parent\n node = node.parent\n nodes << node.id\n end\n nodes\n end", "def ancestors\n parent ? [parent, *parent.ancestors].reverse : []\n end", "def ancestors\n []\n end", "def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end", "def parents\n anc = if @this.respond_to?(:ancestors)\n if @this.ancestors.include?(@this)\n @this.ancestors[1..-1]\n else\n # singletons have no doodle_parents (they're orphans)\n []\n end\n else\n @this.class.ancestors\n end\n anc.select{|x| x.kind_of?(Class)}\n end", "def parents(*args)\n find_parents(:all, *args)\n end", "def parents\n self.class.where(id: parent_ids)\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def all_ancestors(ancestors=[])\n # Assumes only one parent\n result = []\n c = self\n while c && c.parent_groups\n result += c.parent_groups\n c = c.parent_groups[0]\n end\n result\n end", "def parents # rubocop:disable MethodLength\n return @_parents if defined?(@_parents)\n return @_parents = [::Object] if singleton_class?\n\n @_parents = []\n\n to_s.split('::').tap do |arr|\n arr.pop\n\n until arr.empty?\n @_parents << ::Object.const_get(arr.join('::'), false)\n arr.pop\n end\n\n @_parents << ::Object\n end\n\n @_parents.freeze\n end", "def ancestors\n self.root? ? [] : self.parent.ancestors_and_self\n end", "def parents\n @key.nil? ? [] : [@group.parents, @group].compact.flatten\n end", "def crumb_parents\n []\n end", "def parents\n return @parents if [email protected]?\n @parents = []\n path_components = self.path.split('/')\n path_components.each_with_index do |path,i|\n parent_path = path_components[0,i].join('/')\n @parents.push(PhotoCollection.find_by_path(parent_path)) if parent_path != ''\n end\n @parents.reverse!\n end", "def parents(*classes)\n result = []\n ancestor = self.parent\n until ancestor.nil?\n # Filter ancestors by class\n if classes.nil? || classes.empty? || classes.include?(ancestor.class)\n # If a block is given, it must return true for the ancestor to be included\n result.push(ancestor) unless block_given? && !yield(ancestor)\n end\n ancestor = ancestor.parent\n end\n result\n end", "def ancestors\n node_ancestors.map(&:ancestor)\n end", "def parents\n EarLogger.instance.log \"Finding parents for #{self}\"\n ObjectManager.instance.find_parents(self.id, self.class.to_s)\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def get_parents\n parents = Array.new\n seen = Hash.new\n\n current = self.id\n \n while current\n role = Role.find(current)\n if role \n if not seen.has_key?(role.id)\n parents << role\n seen[role.id] = true\n current = role.parent_id\n else\n current = nil\n end\n else\n current = nil\n end\n end\n\n return parents\n end", "def parents\n @parents ||= begin\n p = @repo.dirstate.parents\n p = [p[0]] if p[1] == NULL_ID\n p.map {|x| Changeset.new(@repo, x) }\n end\n end", "def parent_ids\n if ancestor_ids.empty? then\n []\n else\n branches.map { |branch| cast_primary_key(branch.split('/').last) }.uniq\n end\n end", "def ancestors\n @ancestors ||= parent ? parent.ancestors + [parent] : []\n end", "def parents\n parse!\n @parents\n end", "def ancestors_through_parents(result = [self], start = self)\n if start.parent.nil?\n return result.reverse\n else\n result << start.parent\n ancestors_through_parents(result, start.parent)\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 parents(target)\n\t\tancestors = [target]\n\t\tcurrent_ancestor = target\n\t\tmoves = []\n\t\tuntil current_ancestor==nil\n\t\t\tcurrent_ancestor = current_ancestor.parent\n\t\t\tancestors << current_ancestor unless current_ancestor.nil?\n\t\tend\n\t\tancestors.each {|node| moves << node.value}\n\t\treturn moves.reverse\n\tend", "def parent_ids(*args)\n return Array.wrap(parent_id(*args)) if use_ancestry?\n\n Relationship.resource_pairs(parent_rels(*args))\n end", "def parents\n respond_to?(:collectionHasParent) ? collectionHasParent : []\n end", "def self_and_parents\n p = [self]\n parent = self.parent \n \n while parent do\n p << parent\n parent = parent.parent \n end\n p\n end", "def parent_objects\n return [] if parents.empty?\n return @parent_objects if @parent_objects\n\n first = parent_models[0].find(parent_params[0])\n @parent_objects = [first]\n parent_params.zip(parents)[1..-1].inject(first) do |memo, arr|\n id, name = arr\n @parent_objects << memo.send(name.pluralize).find(id)\n end\n @parent_objects\n end", "def all_branches_to_top\n\n res=[]\n if parents.count == 0\n res = [[self]]\n else\n parents.each do |parent|\n parent_b = parent.all_branches_to_top\n parent_b.each do |pb|\n res << pb.unshift(self)\n end\n end\n end\n\n return res\n\n end", "def ancestors\n @ancestors ||= [self] + (self.parent.try(:ancestors) || [])\n end", "def ancestors_for(namespace)\n ancestors = []\n current = namespace\n\n while current&.parent_id\n # We're using find_by(id: ...) here to deal with cases where the\n # parent_id may point to a missing row.\n current = Namespace.unscoped.select([:id, :parent_id])\n .find_by(id: current.parent_id)\n\n ancestors << current.id if current\n end\n\n ancestors\n end", "def all_ancestor_ids\n ancestors.pluck(:id)\n end", "def path\n result = []\n obj = self\n while obj\n result.unshift(obj.__parent_name)\n obj = obj.__parent_struct\n end\n result.shift # we alwas add a nil for one-after-the-root\n result\n end", "def parent_categories\n c = self\n categories = []\n until c.parent.blank? do\n c = c.parent\n categories.unshift c\n end\n categories\n end", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def parents\n check_commit\n @parents \n end", "def parents\n references\n end", "def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end", "def parent_ids\n if ancestor_ids.empty? then\n nil\n else\n branches.map { |branch| cast_primary_key(branch.split('/').last) }\n end\n end", "def preorder\n if @root.nil?\n return []\n else\n return preorder_helper(@root, [])\n end\n end", "def hierarchy\n p = self\n h = []\n while(p.parent != nil)\n h = [p] + h\n p = p.parent\n end\n h = [p] + h\n \n h\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 roots\n nodes.select{ |n| n.root? }\n end", "def parent_ids\n []\n end", "def get_parents( node=self )\n sql = <<-SQL\n select\n subject_term.identifier as child_identifier,\n subject_term.term_name as child_term,\n predicate_term.term_name as relation,\n object_term.identifier as parent_identifier,\n object_term.term_name as parent_term\n from\n term_relationship tr\n join term as subject_term \ton tr.subject_term_pk = subject_term.term_pk\n join term as predicate_term on tr.predicate_term_pk = predicate_term.term_pk\n join term as object_term on tr.object_term_pk = object_term.term_pk\n where\n predicate_term.term_name in ('part_of','is_a','develops_from')\n and subject_term.identifier = ?\n SQL\n \n OLS_DB[ sql, node.term ].each do |row|\n parent = OntologyTerm.new( row[:parent_identifier], row[:parent_term] )\n parent << node\n get_parents( parent )\n end\n end", "def pbt_parents\n if poly?\n Array[pbt_parent].compact\n else\n self.class.pbts.map do |i|\n try{ \"#{i}\".camelize.constantize.where(id: send(\"#{i}_id\")).first }\n end.compact\n end\n end", "def parents\n parent_objects(Dependency)\n end", "def self_and_parents(node=self)\n [ ].tap do |parents|\n while node.parent != node.document\n parents.unshift(node)\n node = node.parent\n end\n parents.unshift node\n end\n end", "def useful_parents\n ret_parents = self.parents\n if ret_parents[1].nil?\n if ret_parents[0].revision >= self.revision - 1\n ret_parents = []\n else\n ret_parents = [ret_parents[0]]\n end\n end\n ret_parents\n end", "def parents\n in_edges.each{|e| e.src}\n end", "def parents\n @parents || (parse! && @parents)\n end", "def roots\n self.where(parent: nil).order('index asc')\n end", "def get_children_ids_recursive\n ids = []\n children.each do |c|\n\t\t\t\tif !c.children.empty?\n\t\t\t\t\tids += c.get_children_ids_recursive\n\t\t\t\tend\n\t\t\t\tids << c.id\n\t\t\tend\n return ids\n\t\tend", "def ancestors\n TreeNode.find(:all,\n :from => \"cms_treenode_ancestors(#{self.id}, #{AuthenticationModel.current_user}) tree_nodes\") rescue []\n end", "def find_parent_ids(array=nil)\n parent_id = []\n\n puts array.class\n parent = Parent.find_by(array)\n puts parent\n\n parent_id << parent.children.pluck(:child_id)\n\n parent.children.each do |child| \n unless child.children.blank?\n parent_id << child.child_id\n end\n end\n\n # parent.each do |p|\n # unless p.child.blank?\n # parent_id << child.child_id\n # child_id = p.child.pluck(:child_id)\n\n # unless child_id.blank?\n # find_parent_ids(child_id)\n # end\n # end\n # end\n\n parent_id\n end", "def name_path_to_parent\n path = []\n p = parent\n while p do\n path.unshift p\n p = p.parent\n end\n path\n end", "def parents\n options['parents'] || []\n end", "def ancestors(child_flow = self)\n parents = []\n parents << child_flow\n parents << child_flow.parent_steps.map { |s| ancestors(s.flow) } if child_flow.parent_steps.present?\n parents.flatten.uniq\n end", "def ancestor_ids\n read_attribute(self.base_class.ancestry_column).to_s.split(%r|[,/]|).uniq.map { |id| cast_primary_key(id) }\n end", "def parents; end", "def category_tree\n cats = []\n categories.each do |cat|\n cats << cat\n cats = cats + cat.ancestors\n end\n return cats\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def parents\n p = @path\n rp = repo_path\n pcl = @changeset.parents\n fl = file_log\n pl = [[rp, pcl[0].manifest_entry[rp] || NULL_ID, fl]]\n if pcl.size > 1\n if rp != p\n fl = nil\n end\n pl << [p, pcl[1].manifest_entry[p] || NULL_ID, fl]\n end\n pl.select {|_, n, __| n != NULL_ID}.map do |parent, n, l|\n VersionedFile.new(@repo, parent, :file_id => n, :file_log => l)\n end\n end", "def references\n @parents.keys\n end", "def ancestors\n \tif parent_name.blank?\n\t \tancestors = [] \n \telse\n \t\tp = Category.where(name: parent_name).first\n \t\tancestors = p.ancestors\n \t\tancestors << parent_name\n \tend\n \tancestors\n end", "def ancestors\n return @ancestors unless @ancestors.nil?\n # Stop if this is already the root node\n return @ancestors = [self] if File.basename(tree).empty?\n # Path for parent is blank if parent is root node\n parent_path = if File.dirname(tree) == '.'\n \"\"\n # Otherwise it is the directory in which this node is located\n else\n File.dirname tree\n end\n parent = git_flow_repo.working_file parent_path\n @ancestors = parent.ancestors + [ self ]\n end", "def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_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 descendants\n children + children.map(&:descendants).flatten\n end", "def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end", "def parents(all: false)\n parents = []\n\n # Start with infrageneric and genus names.\n # Get rid of quoted words and ssp., var., f., etc.\n words = text_name.split - %w[group clade complex]\n words.pop\n until words.empty?\n name = words.join(\" \")\n words.pop\n next if name == text_name || name[-1] == \".\"\n\n parent = Name.best_match(name)\n parents << parent if parent\n return [parent] if !all && parent && !parent.deprecated\n end\n\n # Next grab the names out of the classification string.\n lines = try(&:parse_classification) || []\n lines.reverse_each do |(_line_rank, line_name)|\n parent = Name.best_match(line_name)\n parents << parent if parent\n return [parent] if !all && !parent.deprecated\n end\n\n # Get rid of deprecated names unless all the results are deprecated.\n parents.reject!(&:deprecated) unless parents.all?(&:deprecated)\n\n # Return single parent as an array for backwards compatibility.\n return parents if all\n return [] unless parents.any?\n\n [parents.first]\n end", "def preorder\n return [] if @root.nil?\n result = []\n return preorder_helper(@root, result)\n end" ]
[ "0.8063405", "0.7997283", "0.77717274", "0.7750851", "0.7635208", "0.7568248", "0.751398", "0.74752855", "0.7475203", "0.745758", "0.74157244", "0.74121433", "0.74039507", "0.73833936", "0.7382528", "0.73592144", "0.7347399", "0.7326278", "0.7285764", "0.7271115", "0.7200792", "0.7179063", "0.7153389", "0.7086119", "0.7054172", "0.70118463", "0.7004127", "0.69794273", "0.6973758", "0.6957037", "0.69524956", "0.69524956", "0.6912935", "0.69105124", "0.68901813", "0.6888181", "0.6881387", "0.6870881", "0.68551534", "0.68415505", "0.6832425", "0.6819602", "0.681958", "0.681958", "0.67986643", "0.6791011", "0.67752415", "0.6728103", "0.67032236", "0.66476953", "0.6621074", "0.6616342", "0.66086155", "0.65982735", "0.65933794", "0.6555348", "0.6533291", "0.65322465", "0.6532241", "0.6531516", "0.65297705", "0.6522935", "0.6496508", "0.64711267", "0.6441601", "0.6425677", "0.6401167", "0.6378884", "0.6374794", "0.63726324", "0.6367262", "0.6359372", "0.6341189", "0.63229316", "0.6309593", "0.63074857", "0.62823445", "0.6281251", "0.62811565", "0.62733394", "0.62339365", "0.6217669", "0.62138665", "0.62037843", "0.6198518", "0.6179309", "0.6165164", "0.61516255", "0.61464924", "0.61449236", "0.61449236", "0.6143711", "0.6140437", "0.6139857", "0.6136276", "0.61227524", "0.6118125", "0.6108829", "0.6100553", "0.60958767", "0.609174" ]
0.0
-1
Returns an array of all parents plus self, starting with the root.
def self_and_ancestors base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})", :order => left_col_name ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def parents\n unless @parents\n @parents = []\n object = self\n while object.respond_to?(:parent) && object.parent\n @parents << object.parent\n object = object.parent\n end\n end\n @parents\n end", "def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end", "def parents_and_self\n ret = []\n ret.concat(parent.parents_and_self) if parent\n ret << self\n ret\n end", "def parents\n @parents ||= parent ? parent.parents + Array(parent) : []\n end", "def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end", "def parents\n page, parents = self, Array.new\n while page.parent\n page = page.parent\n parents << page\n end\n parents\n end", "def getAllParents\n parents = []\n parent = self.getParentRec\n self_code = self.code.split('.')\n self_code.pop(1)\n while self_code.length > 0 do\n puts \"self_code: #{self_code}\"\n if parent.present?\n parents << parent\n parent = parent.getParentRec\n self_code.pop(1)\n else\n parents << nil\n self_code.pop(1)\n parent = Tree.where(\n tree_type_id: self.tree_type_id,\n version_id: self.version_id,\n subject_id: self.subject_id,\n grade_band_id: self.grade_band_id,\n code: self_code.join(\".\")\n ).first\n end\n end\n Rails.logger.debug(\"*** tree parents: #{parents.inspect}\")\n return parents\n end", "def ancestors_r(*args)\n # fetch all parents\n pending = [self]\n ans = []\n while !pending.empty?\n e = pending.pop\n e.parents(*args).each do |p|\n if !ans.include?(p)\n ans << p\n pending.push(p)\n end\n end\n end\n ans\n end", "def all_parents\n parents(all: true)\n end", "def parents\n if parent.nil?\n [self]\n else\n parent.parents + [self]\n end\n end", "def find_all_parents\n end", "def ancestors\n ancestors = []\n current_ancestor = self\n \n while !current_ancestor.nil?\n \n if current_ancestor.respond_to?(:parent)\n ancestors << current_ancestor\n current_ancestor = current_ancestor.parent\n else\n current_ancestor = nil\n end\n \n end\n \n ancestors\n end", "def get_parents\n return @parents\n end", "def ancestors\n []\n end", "def ancestors\n parents + parents.map(&:ancestors).flatten\n end", "def ancestors \n \t\tres=parents\n \t\tparents.each {|c| res += c.ancestors}\n \t\treturn res.uniq\n \tend", "def self_and_parents\n p = [self]\n parent = self.parent \n \n while parent do\n p << parent\n parent = parent.parent \n end\n p\n end", "def ancestors\n if parent.nil?\n []\n else\n parent.ancestors + [parent]\n end\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def parents\n\n TapirLogger.instance.log \"Finding parents for #{self}\"\n parents = []\n self.entity_mappings.each do |mapping|\n\n # Go through each associated entity mapping, and find mappings where the child_id is us \n # which means that the parent_id is some other entity, and it's a parent\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectId\n parents << mapping.get_parent if mapping.child_id == self.id.to_s \n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n\n end\n parents\n end", "def hierarchy\n parents = []\n parent = self.parent\n\n while parent && !parent.parent_id.nil?\n parents << parent\n parent = parent.parent\n end\n\n return parents.reverse\n end", "def ancestors\n self.root? ? [] : self.parent.ancestors_and_self\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def parents\n self.class.where(id: parent_ids)\n end", "def ancestors\n return [] if root?\n tree_search_class.find(self[tree_path_field])\n end", "def ancestors\n parent ? [parent, parent.ancestors].flatten : []\n end", "def parents\n EarLogger.instance.log \"Finding parents for #{self}\"\n ObjectManager.instance.find_parents(self.id, self.class.to_s)\n end", "def parents\n @key.nil? ? [] : [@group.parents, @group].compact.flatten\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 ancestors\n []\n end", "def ancestors_ids\n node, nodes = self, []\n while node.parent\n node = node.parent\n nodes << node.id\n end\n nodes\n end", "def parents\n anc = if @this.respond_to?(:ancestors)\n if @this.ancestors.include?(@this)\n @this.ancestors[1..-1]\n else\n # singletons have no doodle_parents (they're orphans)\n []\n end\n else\n @this.class.ancestors\n end\n anc.select{|x| x.kind_of?(Class)}\n end", "def parents # rubocop:disable MethodLength\n return @_parents if defined?(@_parents)\n return @_parents = [::Object] if singleton_class?\n\n @_parents = []\n\n to_s.split('::').tap do |arr|\n arr.pop\n\n until arr.empty?\n @_parents << ::Object.const_get(arr.join('::'), false)\n arr.pop\n end\n\n @_parents << ::Object\n end\n\n @_parents.freeze\n end", "def ancestors_through_parents(result = [self], start = self)\n if start.parent.nil?\n return result.reverse\n else\n result << start.parent\n ancestors_through_parents(result, start.parent)\n end\n end", "def ancestors\n parent ? [parent, *parent.ancestors].reverse : []\n end", "def self_and_parents(node=self)\n [ ].tap do |parents|\n while node.parent != node.document\n parents.unshift(node)\n node = node.parent\n end\n parents.unshift node\n end\n end", "def parent_rel_ids\n rel = relationships\n if rel.kind_of?(Array) || rel.try(:loaded?)\n rel.reject { |x| x.ancestry.blank? }.collect(&:parent_id)\n else\n rel.where.not(:ancestry => [nil, \"\"]).select(:ancestry).collect(&:parent_id)\n end\n end", "def path\n result = []\n obj = self\n while obj\n result.unshift(obj.__parent_name)\n obj = obj.__parent_struct\n end\n result.shift # we alwas add a nil for one-after-the-root\n result\n end", "def parents\n return @parents if [email protected]?\n @parents = []\n path_components = self.path.split('/')\n path_components.each_with_index do |path,i|\n parent_path = path_components[0,i].join('/')\n @parents.push(PhotoCollection.find_by_path(parent_path)) if parent_path != ''\n end\n @parents.reverse!\n end", "def parents(*args)\n find_parents(:all, *args)\n end", "def ancestors\n @ancestors ||= [self] + (self.parent.try(:ancestors) || [])\n end", "def parents\n parse!\n @parents\n end", "def get_parents\n parents = Array.new\n seen = Hash.new\n\n current = self.id\n \n while current\n role = Role.find(current)\n if role \n if not seen.has_key?(role.id)\n parents << role\n seen[role.id] = true\n current = role.parent_id\n else\n current = nil\n end\n else\n current = nil\n end\n end\n\n return parents\n end", "def all_ancestors(ancestors=[])\n # Assumes only one parent\n result = []\n c = self\n while c && c.parent_groups\n result += c.parent_groups\n c = c.parent_groups[0]\n end\n result\n end", "def ancestors\n node_ancestors.map(&:ancestor)\n end", "def ancestors\n @ancestors ||= parent ? parent.ancestors + [parent] : []\n end", "def crumb_parents\n []\n end", "def parent_categories\n c = self\n categories = []\n until c.parent.blank? do\n c = c.parent\n categories.unshift c\n end\n categories\n end", "def parents\n @parents ||= begin\n p = @repo.dirstate.parents\n p = [p[0]] if p[1] == NULL_ID\n p.map {|x| Changeset.new(@repo, x) }\n end\n end", "def to_array\n children.each_with_object( [ self ] ) { |child, memo|\n memo.concat( child.to_array )\n }.flatten\n end", "def hierarchy\n p = self\n h = []\n while(p.parent != nil)\n h = [p] + h\n p = p.parent\n end\n h = [p] + h\n \n h\n end", "def parents\n respond_to?(:collectionHasParent) ? collectionHasParent : []\n end", "def parent_objects\n return [] if parents.empty?\n return @parent_objects if @parent_objects\n\n first = parent_models[0].find(parent_params[0])\n @parent_objects = [first]\n parent_params.zip(parents)[1..-1].inject(first) do |memo, arr|\n id, name = arr\n @parent_objects << memo.send(name.pluralize).find(id)\n end\n @parent_objects\n end", "def parents(*classes)\n result = []\n ancestor = self.parent\n until ancestor.nil?\n # Filter ancestors by class\n if classes.nil? || classes.empty? || classes.include?(ancestor.class)\n # If a block is given, it must return true for the ancestor to be included\n result.push(ancestor) unless block_given? && !yield(ancestor)\n end\n ancestor = ancestor.parent\n end\n result\n end", "def all_branches_to_top\n\n res=[]\n if parents.count == 0\n res = [[self]]\n else\n parents.each do |parent|\n parent_b = parent.all_branches_to_top\n parent_b.each do |pb|\n res << pb.unshift(self)\n end\n end\n end\n\n return res\n\n end", "def parents\n references\n end", "def parent_ids(*args)\n return Array.wrap(parent_id(*args)) if use_ancestry?\n\n Relationship.resource_pairs(parent_rels(*args))\n end", "def parents\n check_commit\n @parents \n end", "def descendants_and_self\r\n result = [self]\r\n children.each { |child| result << child.descendants_and_self }\r\n result.flatten!\r\n return result\r\n end", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def self_and_ancestors\n \t\tres = [self] + self.ancestors\n \t\treturn res.uniq\n \tend", "def pbt_parents\n if poly?\n Array[pbt_parent].compact\n else\n self.class.pbts.map do |i|\n try{ \"#{i}\".camelize.constantize.where(id: send(\"#{i}_id\")).first }\n end.compact\n end\n end", "def self_and_parent_menus(options={})\n\t\t\tarr = [self]\n\t\t\tfather = self.parent\n\t\t\twhile father.present?\n\t\t\t\tarr << father\n\t\t\t\tfather = father.parent\n\t\t\tend\n\n\t\t\treturn arr.reverse\n\t\tend", "def parents(target)\n\t\tancestors = [target]\n\t\tcurrent_ancestor = target\n\t\tmoves = []\n\t\tuntil current_ancestor==nil\n\t\t\tcurrent_ancestor = current_ancestor.parent\n\t\t\tancestors << current_ancestor unless current_ancestor.nil?\n\t\tend\n\t\tancestors.each {|node| moves << node.value}\n\t\treturn moves.reverse\n\tend", "def parent_ids\n if ancestor_ids.empty? then\n []\n else\n branches.map { |branch| cast_primary_key(branch.split('/').last) }.uniq\n end\n end", "def parent\n map do |q|\n q.get_parent_element\n end\n end", "def parents\n options['parents'] || []\n end", "def all_in_tree\n accounts = Array.new\n accounts += ancestors\n accounts += sibling_accounts\n accounts += children\n accounts << self\n return accounts\n end", "def parents\n parent_objects(Dependency)\n end", "def parents; end", "def ancestors\n (parent ? parent.ancestors : []) << self\n end", "def parents\n @parents || (parse! && @parents)\n end", "def path\n return @path_array if @path_array\n parent_category = self\n @path_array = [parent_category]\n while (parent_category = parent_category.parent) != nil do\n @path_array.insert(0, parent_category) \n end\n @path_array\n end", "def all_ancestor_ids\n ancestors.pluck(:id)\n end", "def useful_parents\n ret_parents = self.parents\n if ret_parents[1].nil?\n if ret_parents[0].revision >= self.revision - 1\n ret_parents = []\n else\n ret_parents = [ret_parents[0]]\n end\n end\n ret_parents\n end", "def parent_ids\n []\n end", "def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end", "def roots\n self.where(parent: nil).order('index asc')\n end", "def parents\n in_edges.each{|e| e.src}\n end", "def preorder\n return [] if @root == nil\n return preorder_helper(@root, [])\n end", "def ancestors\n return @ancestors unless @ancestors.nil?\n # Stop if this is already the root node\n return @ancestors = [self] if File.basename(tree).empty?\n # Path for parent is blank if parent is root node\n parent_path = if File.dirname(tree) == '.'\n \"\"\n # Otherwise it is the directory in which this node is located\n else\n File.dirname tree\n end\n parent = git_flow_repo.working_file parent_path\n @ancestors = parent.ancestors + [ self ]\n end", "def get_parents( node=self )\n sql = <<-SQL\n select\n subject_term.identifier as child_identifier,\n subject_term.term_name as child_term,\n predicate_term.term_name as relation,\n object_term.identifier as parent_identifier,\n object_term.term_name as parent_term\n from\n term_relationship tr\n join term as subject_term \ton tr.subject_term_pk = subject_term.term_pk\n join term as predicate_term on tr.predicate_term_pk = predicate_term.term_pk\n join term as object_term on tr.object_term_pk = object_term.term_pk\n where\n predicate_term.term_name in ('part_of','is_a','develops_from')\n and subject_term.identifier = ?\n SQL\n \n OLS_DB[ sql, node.term ].each do |row|\n parent = OntologyTerm.new( row[:parent_identifier], row[:parent_term] )\n parent << node\n get_parents( parent )\n end\n end", "def parents(result=nil)\n if result\n if @parents\n result |= @parents\n else\n\n upstreams.each do |upstream|\n if upstream.job == job\n upstream.parents(result)\n else\n result.add(upstream)\n end\n end\n\n result.to_a\n end\n else\n @parents ||= parents(Set.new)\n end\n end", "def get_self_and_children_ids\n ids = [self.id]\n ids += get_children_ids_recursive\n return ids\n\t\tend", "def allparent\n\t\t@parent = parent_user\n\t\t@all_parent = Parent.all\n\t\t@parent_children = @parent.children\n\tend", "def preorder\n preordred_array = []\n if @root != nil\n preorder_helper(@root, preordred_array)\n end\n return preordred_array\n end", "def to_a\n ret = [self]\n if self.kids\n self.kids.each do |kid|\n kid.to_a.each {|node|\n ret.push node\n }\n end\n end\n ret\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def depth_first\n result = [self]\n if child_ids.empty?\n return result\n else\n children.sort.each do |child|\n result += child.depth_first\n end \n end\n return result \n end", "def parent_dependencies\n @parents\n end", "def preorder\n if @root.nil?\n return []\n else\n return preorder_helper(@root, [])\n end\n end", "def ancestors\n self_and_ancestors - [self]\n end", "def references\n @parents.keys\n end", "def ancestors_for(namespace)\n ancestors = []\n current = namespace\n\n while current&.parent_id\n # We're using find_by(id: ...) here to deal with cases where the\n # parent_id may point to a missing row.\n current = Namespace.unscoped.select([:id, :parent_id])\n .find_by(id: current.parent_id)\n\n ancestors << current.id if current\n end\n\n ancestors\n end", "def grand_children\n []\n end", "def ancestors_until_node_not_ancestor_of(klass)\n\t\t\tif !self.parent || !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.parent.ancestors_until_node_not_ancestor_of(klass)\n\t\tend" ]
[ "0.8120564", "0.81204414", "0.80846035", "0.80822563", "0.799836", "0.7768516", "0.7661956", "0.76125795", "0.76058424", "0.7586401", "0.7563383", "0.7562111", "0.7486465", "0.74743366", "0.7452375", "0.7411038", "0.73923314", "0.72901964", "0.7288449", "0.7263943", "0.72535056", "0.72535056", "0.7237954", "0.7150146", "0.7096618", "0.70928144", "0.7086957", "0.7086957", "0.708442", "0.70726836", "0.70649487", "0.7062495", "0.70551777", "0.70187384", "0.70076144", "0.7006542", "0.7003565", "0.6971747", "0.69230646", "0.691683", "0.6887055", "0.687742", "0.6863686", "0.68609565", "0.68550444", "0.6850048", "0.68317956", "0.68037856", "0.6754496", "0.6709803", "0.67091197", "0.6708745", "0.67006415", "0.6694071", "0.66832846", "0.6676094", "0.6669037", "0.6636177", "0.663409", "0.66253656", "0.65873003", "0.65682024", "0.65573865", "0.6525952", "0.65199316", "0.65113384", "0.6499819", "0.6479205", "0.64388067", "0.6438801", "0.64153963", "0.64105546", "0.64045763", "0.63948745", "0.63940525", "0.63781285", "0.63736963", "0.6365189", "0.6364641", "0.6343134", "0.6328094", "0.6318791", "0.6316386", "0.63158786", "0.6312392", "0.63053364", "0.62956417", "0.62940097", "0.62886375", "0.6281843", "0.6276097", "0.6259119", "0.6253338", "0.62500215", "0.6237314", "0.62365204", "0.6234864", "0.6229307", "0.6211804", "0.6206318", "0.6197534" ]
0.0
-1
Returns all the children of this node's parent, except self.
def siblings self_and_siblings - [self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def children\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end", "def children\n\t\treturn children_of @current_node\n\tend", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def children\n []\n end", "def children\n []\n end", "def parent\n map do |q|\n q.get_parent_element\n end\n end", "def children_until_node_not_ancestor_of(klass)\n\t\t\tif !self.node.class.ancestors.include?(klass)\n\t\t\t\treturn []\n\t\t\tend\n\n\t\t\t[self] + self.children.collect { |i|\n\t\t\t\ti.children_until_node_not_ancestor_of(klass)\n\t\t\t}\n\t\tend", "def parents\n unless @parents\n @parents = []\n object = self\n while object.respond_to?(:parent) && object.parent\n @parents << object.parent\n object = object.parent\n end\n end\n @parents\n end", "def siblings\n parent && (parent.children - [self])\n end", "def parent_adopts_children\n if parent(true)\n self.class.transaction do\n children(true).each{|child| parent.children << child}\n end\n else\n orphan_children\n end\n end", "def parents_and_self\n ret = []\n ret.concat(parent.parents_and_self) if parent\n ret << self\n ret\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def children\n []\n end", "def get_children\n return children\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n node.children\n end", "def siblings\n if self.parent.nil?\n self.class.where('forestify_level = 0').where('id != ?', self.id)\n else\n self.parent.children.where('forestify_level = ?', self.forestify_level).where('id != ?', self.id)\n end\n end", "def parents\n page, parents = self, Array.new\n while page.parent\n page = page.parent\n parents << page\n end\n parents\n end", "def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end", "def parents\n self.class.where(id: parent_ids)\n end", "def negating_children\n return [] if !has_children?\n\n children.find_all(&:negation?)\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end", "def children\n _children\n end", "def siblings\n parent&.children || []\n end", "def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end", "def get_parents\n return @parents\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def get_children\n return @children\n end", "def parents\n @parents ||= parent ? parent.parents + Array(parent) : []\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def children\n self.class.children(self) \n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND #{parent_col_name} = #{self.id}\", :order => left_col_name)\n end", "def parent_posts\n posts.find_all { |p| p.parent_post.nil? }\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def parents\n if parent.nil?\n [self]\n else\n parent.parents + [self]\n end\n end", "def children(node, root = nil)\n root ||= @root\n c = self.adjacent_nodes(node)\n c.delete(self.parent(node, root))\n c\n end", "def children\n NotImplemented\n end", "def children\n NotImplemented\n end", "def children\n self.node.children.collect(&:content)\n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def allparent\n\t\t@parent = parent_user\n\t\t@all_parent = Parent.all\n\t\t@parent_children = @parent.children\n\tend", "def siblings\n tree_search_class.where({\n :_id => { \"$ne\" => self._id },\n tree_parent_id_field => self[tree_parent_id_field]\n }).sort(self.class.tree_sort_order()).all\n end", "def children\n rows\n end", "def children(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def orphans\n retval = []\n all.each{|r| retval << r if r.node_id.nil?}\n retval\n end", "def children\n []\n end", "def ancestors\n if parent.nil?\n []\n else\n parent.ancestors + [parent]\n end\n end", "def children_of(post)\n posts.find_all { |t| t.parent_post == post.id }\n end", "def children\n ary = normal_children.dup\n ary << fallback_child if fallback_child\n ary\n end", "def children\n Product.unscoped.deleted.where(:parent_id=>self.id)\n end", "def children(entity)\n self.all(:parent_id => entity.id)\n end", "def living_parents\n dirstate.parents.select {|p| p != NULL_ID }\n end", "def children\n entries\n end", "def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def _children\n @children\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def children\n Array.new\n end", "def descendants\n without_self self_and_descendants\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def parent_categories\n c = self\n categories = []\n until c.parent.blank? do\n c = c.parent\n categories.unshift c\n end\n categories\n end", "def all_parents\n parents(all: true)\n end", "def ancestors\n []\n end", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end", "def all_children(special=nil)\n full_set(special) - [self]\n end", "def get_siblings\n self.root? ? [] : self.siblings.select { |d| d.id != self.id }\n end", "def self_and_parents\n p = [self]\n parent = self.parent \n \n while parent do\n p << parent\n parent = parent.parent \n end\n p\n end", "def siblings\n pages = (p = parent and p.children)\n return Set.new unless pages\n return Set.new unless pages.include?(self)\n Set.new(pages)\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\n @children\n end", "def parents\n EarLogger.instance.log \"Finding parents for #{self}\"\n ObjectManager.instance.find_parents(self.id, self.class.to_s)\n end", "def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end", "def children\n @children ||= []\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end", "def all_children\n\n yielded_self = if block_given?\n yield self\n end\n\n return ( yielded_self || self ) if self.children.empty?\n _child = self.children.map do |child|\n _name = (yield child if block_given?) || self\n if child.children.empty?\n _name\n else\n [_name, child.all_children{ |this_child| yield this_child if block_given? }]\n end\n end\n return _child\n end", "def self_and_siblings\n nested_set_scope.children_of parent_id\n end", "def descendants\n without_self self_and_descendants\n end", "def hierarchy\n parents = []\n parent = self.parent\n\n while parent && !parent.parent_id.nil?\n parents << parent\n parent = parent.parent\n end\n\n return parents.reverse\n end", "def children() []; end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end" ]
[ "0.72534496", "0.6916118", "0.6714133", "0.6709741", "0.66709584", "0.6619373", "0.6498624", "0.64912295", "0.64912295", "0.64787", "0.6464504", "0.6463161", "0.6460375", "0.64581126", "0.6452195", "0.64503527", "0.6448903", "0.6419546", "0.6403517", "0.6384796", "0.6384796", "0.6384796", "0.6379432", "0.6349141", "0.63056254", "0.6291504", "0.6274516", "0.6267904", "0.62645894", "0.6256566", "0.6193542", "0.61840755", "0.6160798", "0.61539847", "0.61539847", "0.6146085", "0.6142138", "0.61356103", "0.61179525", "0.61178845", "0.6106601", "0.61054903", "0.6102248", "0.609989", "0.60959417", "0.60959417", "0.6091532", "0.6087988", "0.6087901", "0.6087901", "0.60867256", "0.6079256", "0.6076803", "0.60618705", "0.60351264", "0.60048705", "0.59949744", "0.59900856", "0.5983548", "0.5977478", "0.59633833", "0.59474", "0.5928518", "0.5928262", "0.5914892", "0.5906278", "0.5905511", "0.5897215", "0.5896827", "0.5894123", "0.58898026", "0.5884334", "0.5882461", "0.5879578", "0.5879578", "0.58726203", "0.5871827", "0.5871188", "0.5860885", "0.5855888", "0.5855652", "0.58534116", "0.5853006", "0.5851087", "0.5844949", "0.58373827", "0.58333945", "0.58333945", "0.5832816", "0.5826418", "0.5824248", "0.582221", "0.5817324", "0.5817324", "0.581365", "0.581197", "0.5806213", "0.5802027", "0.5801726", "0.58010125", "0.5791778" ]
0.0
-1
Returns all the children of this node's parent, including self.
def self_and_siblings if self[parent_col_name].nil? || self[parent_col_name].zero? [self] else base_set_class.find(:all, :conditions => "#{scope_condition} AND #{parent_col_name} = #{self[parent_col_name]}", :order => left_col_name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end", "def children\n\t\treturn children_of @current_node\n\tend", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def siblings\n return [] unless parent\n parent.children.reject { |p| p == self }\n end", "def parents\n unless @parents\n @parents = []\n object = self\n while object.respond_to?(:parent) && object.parent\n @parents << object.parent\n object = object.parent\n end\n end\n @parents\n end", "def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end", "def get_children\n return children\n end", "def children\n node.children\n end", "def children\n _children\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def parents_and_self\n ret = []\n if self.parent\n ret.concat(self.parent.parents_and_self)\n end\n ret << self\n ret\n end", "def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def parents_and_self\n ret = []\n ret.concat(parent.parents_and_self) if parent\n ret << self\n ret\n end", "def parent\n map do |q|\n q.get_parent_element\n end\n end", "def parent_adopts_children\n if parent(true)\n self.class.transaction do\n children(true).each{|child| parent.children << child}\n end\n else\n orphan_children\n end\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def get_children\n return @children\n end", "def allparent\n\t\t@parent = parent_user\n\t\t@all_parent = Parent.all\n\t\t@parent_children = @parent.children\n\tend", "def children\n []\n end", "def children\n []\n end", "def parents\n page, parents = self, Array.new\n while page.parent\n page = page.parent\n parents << page\n end\n parents\n end", "def get_parents\n return @parents\n end", "def parents\n self.class.where(id: parent_ids)\n end", "def parents\n @parents ||= parent ? parent.parents + Array(parent) : []\n end", "def children\n []\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def children\n self.class.children(self) \n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def ancestors\n parents = []\n\n this_parent = self.parent\n\n while this_parent != nil\n parents << this_parent\n this_parent = this_parent.parent\n end\n parents\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end", "def parents\n if parent.nil?\n [self]\n else\n parent.parents + [self]\n end\n end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end", "def children(entity)\n self.all(:parent_id => entity.id)\n end", "def children\n self.node.children.collect(&:content)\n end", "def children\n rows\n end", "def hierarchy\n parents = []\n parent = self.parent\n\n while parent && !parent.parent_id.nil?\n parents << parent\n parent = parent.parent\n end\n\n return parents.reverse\n end", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end", "def _children\n @children\n end", "def parents\n EarLogger.instance.log \"Finding parents for #{self}\"\n ObjectManager.instance.find_parents(self.id, self.class.to_s)\n end", "def siblings\n if self.parent.nil?\n self.class.where('forestify_level = 0').where('id != ?', self.id)\n else\n self.parent.children.where('forestify_level = ?', self.forestify_level).where('id != ?', self.id)\n end\n end", "def children\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND #{parent_col_name} = #{self.id}\", :order => left_col_name)\n end", "def _children\n @children\n end", "def children\n entries\n end", "def siblings\n parent && (parent.children - [self])\n end", "def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end", "def get_node_children(parent,parent_id)\n @kids = []\n children = parent.get_elements(\"children\")\n children.each do |child|\n ps = construct_node(child,parent_id)\n if ps != nil\n @kids << ps\n end\n end\n if [email protected]?\n @kids = @kids.sort_by { |k| k.name.downcase }\n end\n @kids\n end", "def siblings\n parent&.children || []\n end", "def children\n @children ||= []\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def all_parents\n parents(all: true)\n end", "def children\n Array.new\n end", "def all_children\n\n yielded_self = if block_given?\n yield self\n end\n\n return ( yielded_self || self ) if self.children.empty?\n _child = self.children.map do |child|\n _name = (yield child if block_given?) || self\n if child.children.empty?\n _name\n else\n [_name, child.all_children{ |this_child| yield this_child if block_given? }]\n end\n end\n return _child\n end", "def children_of(post)\n posts.find_all { |t| t.parent_post == post.id }\n end", "def self_and_parents\n p = [self]\n parent = self.parent \n \n while parent do\n p << parent\n parent = parent.parent \n end\n p\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def children\n @children\n end", "def children\n @children\n end", "def parents\n return Resource.joins(:resource_hierarchies).where(\"child_resource_id = ?\", self.id)\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def ancestors\n node, nodes = self, []\n nodes << node = node.parent while node.parent\n nodes\n end", "def getAllParents\n parents = []\n parent = self.getParentRec\n self_code = self.code.split('.')\n self_code.pop(1)\n while self_code.length > 0 do\n puts \"self_code: #{self_code}\"\n if parent.present?\n parents << parent\n parent = parent.getParentRec\n self_code.pop(1)\n else\n parents << nil\n self_code.pop(1)\n parent = Tree.where(\n tree_type_id: self.tree_type_id,\n version_id: self.version_id,\n subject_id: self.subject_id,\n grade_band_id: self.grade_band_id,\n code: self_code.join(\".\")\n ).first\n end\n end\n Rails.logger.debug(\"*** tree parents: #{parents.inspect}\")\n return parents\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def parents\n parse!\n @parents\n end", "def ancestors\n if parent.nil?\n []\n else\n parent.ancestors + [parent]\n end\n end", "def parent_posts\n posts.find_all { |p| p.parent_post.nil? }\n end", "def self_and_siblings\n nested_set_scope.children_of parent_id\n end", "def get_children()\n return @space.get_children()\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def children\n []\n end", "def self_and_siblings\n parent ? parent.children : self.class.roots\n end", "def parent_categories\n c = self\n categories = []\n until c.parent.blank? do\n c = c.parent\n categories.unshift c\n end\n categories\n end", "def tree\n return [self] if @children.empty?\n\n @children.each_with_object([self]) do |child, tree|\n tree.concat(child.tree)\n end\n end", "def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end", "def parents\n respond_to?(:collectionHasParent) ? collectionHasParent : []\n end", "def children_get()\n @children\n end", "def children\n @root.children & @initial_contents\n end", "def children\n @resource.children\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def get_children\n @children\n end", "def ancestors\n itr = self\n res = []\n until itr.top_level?\n itr = itr.parents.first\n res << itr\n end\n res\n end", "def all_children\n @all_children ||= children + children.inject([]) {|records, child| records + child.all_children}\n end", "def children\n NotImplemented\n end", "def children\n NotImplemented\n end", "def children(node, root = nil)\n root ||= @root\n c = self.adjacent_nodes(node)\n c.delete(self.parent(node, root))\n c\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def parents(*args)\n find_parents(:all, *args)\n end", "def find_all_parents\n end" ]
[ "0.7634356", "0.7259016", "0.7202455", "0.719435", "0.7178175", "0.7161041", "0.7087561", "0.69796944", "0.69543666", "0.6890178", "0.68715376", "0.68399674", "0.6838534", "0.6824851", "0.6803588", "0.6788061", "0.6763411", "0.6750177", "0.6750177", "0.67488354", "0.67442113", "0.6737502", "0.6737502", "0.67055523", "0.6691445", "0.6681726", "0.66711336", "0.6664803", "0.66580164", "0.66572666", "0.66532296", "0.66187", "0.66187", "0.66187", "0.65823877", "0.65803766", "0.6557694", "0.65386915", "0.65340406", "0.652243", "0.6511583", "0.6504861", "0.6492104", "0.6482198", "0.6475728", "0.6468907", "0.64687943", "0.64656806", "0.64639384", "0.64620733", "0.6429124", "0.64119375", "0.64116156", "0.6378714", "0.63665897", "0.6348746", "0.63277334", "0.6316482", "0.6290314", "0.6272338", "0.627194", "0.62469727", "0.6244237", "0.62426794", "0.62308526", "0.62292504", "0.62151915", "0.62151915", "0.6211734", "0.61959964", "0.61959964", "0.619218", "0.6187068", "0.6187068", "0.6187068", "0.6187068", "0.61842847", "0.61815894", "0.61806977", "0.61776143", "0.6169487", "0.6168443", "0.6144304", "0.61310863", "0.6127449", "0.6124648", "0.6109524", "0.6101208", "0.6083633", "0.60737556", "0.60662246", "0.60637337", "0.6053543", "0.605168", "0.60506237", "0.6036705", "0.6036705", "0.6029617", "0.6029189", "0.6020001", "0.60067093" ]
0.0
-1
Returns the level of this object in the tree, root level being 0.
def level return 0 if self[parent_col_name].nil? base_set_class.count(:conditions => "#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{left_col_name} AND #{right_col_name})") - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def level\n return 0 if root?\n\n @parent.level + 1\n end", "def level\n parent_id.nil? ? 0 : compute_level\n end", "def level\n if parent.nil?\n 0\n else\n parent.level + 1;\n end\n end", "def level\n root? ? 0 : ancestors.count\n end", "def level\n return @level\n end", "def level\n return @level\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 level\n return 0 if self[nested_set_parent].nil?\n sql = %Q( SELECT COUNT(t2.id) - 1 AS level\n FROM #{nested_set_class.table_name} AS t1, #{nested_set_class.table_name} AS t2\n WHERE t1.lft BETWEEN t2.lft AND t2.rgt AND t1.id = #{id} AND #{nested_set_scope} )\n nested_set_class.count_by_sql sql\n end", "def level\n @level\n end", "def level\n @level\n end", "def level_index\n @level_index || 0\n end", "def level_index\n @level_index || 0\n end", "def level\n @level\n end", "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 level\n return 0 if self[acts_as_nested_set_options[:parent_column]].nil?\n self.class.count(\"#{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]]})\")\n end", "def level\n\t\tlevel = 0\n\t\[email protected] do |_class|\n\t\t\tlevel += _class.level\n\t\tend\n\t\tlevel\n\tend", "def level\n is_root? ? nil : option_set.try(:level, depth)\n end", "def level\n @level || Helpers.char_level(@entity)\n end", "def level \n if (self.parent_category_id == nil)\n @level = 1\n elsif (@level == nil) \n @level = computeLevelBySQL\n end \n @level\nend", "def level\n init unless @initialized\n level = level_to_sym(@level)\n end", "def current_level\n @cur_level\n end", "def depth\n @cur_level - @base_level + 1\n end", "def level(circle = self)\n return 0 unless circle.super_circle\n\n 1 + level(circle.super_circle)\n end", "def root_level\n self.find\n end", "def getLevels\n @level\n end", "def level\n @location.level\n end", "def level(value = nil)\n if value.nil?\n @level\n else\n @level = value\n end\n end", "def level\n return @state[:fiber][:level]\n end", "def current_depth\n 0\n end", "def depth\n self[:depth]\n end", "def get_depth\n raise \"Not implemented\"\n end", "def level\n length = 0\n cursor = self\n while cursor.parent_document\n length += 1\n cursor = cursor.parent_document\n end\n length\n end", "def default_level\n self.levels[nil]\n end", "def level\n level = 0\n while get_points >= rounded_maximum_points_for_level(level)\n level += 1\n end\n level\n end", "def min_number_of_a_level(level)\n max_number_of_a_level(level - 1) + 1\n end", "def levelname\n\t\t\tlevel.level_name\n\t\tend", "def level_text\n @level.to_s\n end", "def length\n @tree.length\n end", "def depth()\n #This is a stub, used for indexing\n end", "def level; end", "def level; end", "def level; end", "def level; end", "def level; end", "def level; end", "def max_level_depth\n MAXIMUM_LEVEL_DEPTH\n end", "def level(scope = {})\n return 0 if self[parent_col_name].nil?\n self.class.count_in_nested_set({ :conditions => \"#{scope_condition} AND (#{self[left_col_name]} BETWEEN #{prefixed_left_col_name} AND #{prefixed_right_col_name})\" }, scope) - 1\n end", "def depth\n depth_support(self.root)\n end", "def attribute_level\n @attribute_level\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 levels_from_parent\n bridge_class.levels_from_parent\n end", "def level_group\n @level_group\n end", "def depth\n Sequel::SQL::NumericExpression.new(:NOOP, function(:depth, self))\n end", "def level\n @log.level\n end", "def depth\n @depth ||= to && to.depth + 1 || 0\n end", "def get_node_level(node, key)\n get_level_of_node(node, key, 1)\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 levels\n @levels ||= {}\n end", "def heading_level\n self.get_heading_level\n end", "def depth\n self.parents.size\n end", "def level=(value)\n @level = value\n end", "def level=(value)\n @level = value\n end", "def max_level\r\n # パーティ人数が 0 人の場合\r\n if @actors.size == 0\r\n return 0\r\n end\r\n # ローカル変数 level を初期化\r\n level = 0\r\n # パーティメンバーの最大レベルを求める\r\n for actor in @actors\r\n if level < actor.level\r\n level = actor.level\r\n end\r\n end\r\n return level\r\n end", "def level_id\r\n @level_id ||= SEVERITY_LIST.index(level.to_s.upcase) || 5\r\n end", "def depth\n @attributes[:depth]\n end", "def level\n return :row if @row\n return :importer\n end", "def last_level_exp\n return 0 if @level <= 0\n return exp_for_level(@level - 1)\n end", "def compute_level_number(experience_points)\n level = compute_level(experience_points)\n level ? level.level_number : 0\n end", "def find_level\n level = 0\n max_value = max_number_of_a_level(level)\n while max_value < input\n level += 1\n max_value = max_number_of_a_level(level)\n end\n level\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 my_depth\n 1\n end", "def top_level\n @top_level\n end", "def lowest\n @level_order.first\n end", "def leaf?\n level.zero?\n end", "def left_side_of_tree(root, current_level)\n return if root.nil?\n if (current_level > @max_level)\n puts root.val\n @max_level = current_level\n end\n left_side_of_tree(root.left, current_level + 1)\n left_side_of_tree(root.right, current_level + 1)\nend", "def depth\n node = @kids.max {|k, j| k.depth <=> j.depth }\n node.depth + 1\n end", "def level=(level)\n @level_index = self.class.map_level_to_index(level)\n @level = level\n end", "def level\n (@line[/^#+/] || '').size\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 level\n logger.level\n end", "def get_level(key)\n case key\n when \"L\", \"l\" then 0 # Level L\n when \"M\", \"m\" then 1 # Level M\n when \"Q\", \"q\" then 2 # Level Q\n when \"H\", \"h\" then 3 # Level H\n end\n end", "def level\n bid[0] if contract?\n end", "def nesting_levels\n return unless @options.fetch :folder_limit\n\n tree&.path_length || @options.fetch(:nesting_levels)\n end", "def get_level msg\n add_origin msg unless has_key? msg.nick_canon\n\n return self[msg.nick_canon].level\n end", "def badge_level(name)\n these_badges = self.badges.find_all { |b| b.name == name }\n if these_badges.any?\n these_badges.sort_by { |b| b.level }.last.level\n else\n 0\n end\n end", "def level\n @loggers.each do |logger|\n return logger.level if logger.respond_to?(:level)\n end\n end", "def test_level\n assert_equal(0, @root.level, \"A root node's level is 0\")\n\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n\n setup_test_tree\n for child in [@child1, @child2, @child3]\n assert_equal(1, child.level, \"Node #{child.name} should have level 1\")\n assert_equal(@root.node_depth, @root.level, \"Level and depth should be the same\")\n end\n\n assert_equal(2, @child4.level, \"Child 4 should have level 2\")\n end", "def nil_check\n self.level = self.level || 0\n end", "def depth\n children_depth + my_depth\n end", "def hierarchy_levels\n required_hierarchy_levels + optional_hierarchy_levels\n end", "def depth\n @traversal_position.depth\n end", "def max_level=(level)\n @max_level = level.is_a?(Integer) ? level : nil\n end", "def depth\n ancestors.count\n end", "def depth\n ancestors.count\n end", "def leaf_count\n @leaf_count\n end", "def level\n logger_instance.level\n end", "def level=(lvl)\n @level = if lvl.is_a?(Integer)\n lvl\n else\n Level::NAME_TO_LEVEL.fetch(lvl.to_s.upcase)\n end\n end", "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 self.ancestors.size\n end", "def current_depth\n current = Fiber.current\n managed_fiber?(current) ? current.depth : 0\n end" ]
[ "0.8281878", "0.81978035", "0.7918772", "0.778641", "0.7766266", "0.7766266", "0.76997364", "0.75247705", "0.7508308", "0.7508308", "0.7395063", "0.7395063", "0.7258708", "0.72070634", "0.7155497", "0.7098564", "0.7096889", "0.6991486", "0.69806343", "0.6958423", "0.68818164", "0.6772512", "0.6742017", "0.670979", "0.6698013", "0.66516", "0.6650519", "0.66054326", "0.65561444", "0.6537062", "0.6515529", "0.6513172", "0.64537895", "0.6354188", "0.62866306", "0.6246538", "0.6203296", "0.6181157", "0.61706334", "0.6169244", "0.6169244", "0.6169244", "0.6169244", "0.6169244", "0.6169244", "0.6149968", "0.6142217", "0.6140515", "0.61149085", "0.61115503", "0.60895246", "0.6084189", "0.6077016", "0.6064306", "0.6038082", "0.60208774", "0.600303", "0.59910065", "0.5980317", "0.5979919", "0.59723675", "0.59723675", "0.59720373", "0.5971665", "0.5967698", "0.5963614", "0.59480935", "0.59453744", "0.5940873", "0.59396267", "0.5938478", "0.59290016", "0.5916346", "0.5908472", "0.5907934", "0.59074026", "0.5896012", "0.58959633", "0.5893832", "0.5866808", "0.58578515", "0.58476084", "0.58406264", "0.5835304", "0.5828974", "0.578513", "0.5774181", "0.5770487", "0.5766813", "0.5763543", "0.5759983", "0.5759399", "0.5742669", "0.5742669", "0.5733203", "0.57278824", "0.57268995", "0.572236", "0.57221866", "0.57192636" ]
0.6271305
35
Returns the number of nested children of this object.
def all_children_count return (self[right_col_name] - self[left_col_name] - 1)/2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_children\n @children.size\n end", "def num_children\n @children.size\n end", "def num_children\n count = 0\n self.children.each do |child|\n count = count + child.num_children\n end\n\n return self.children.size + count\n end", "def count_children\n count = children.count\n if count\n children.each { |child| count += child.count_children }\n end\n count\n end", "def length\n @children.length\n end", "def total_child_count\n count = 0\n self.apply_to_children { |e| count += 1 }\n count\n end", "def num_children\n `#@native.numChildren()`\n end", "def size\n @children.size\n end", "def child_count(*args)\n child_rels(*args).size\n end", "def children_size\n leaf? ? 0 : children.map(&:size).reduce(:+)\n end", "def children_count\n return (self[nested_set_right] - self[nested_set_left] - 1) / 2\n end", "def children_count\n return (self[acts_as_nested_set_options[:right_column]] - self[acts_as_nested_set_options[:left_column]] - 1)/2\n end", "def num_documents_include_tree_children\n num_documents_include_tree_children_rec( self )\n end", "def count_child_nodes(hash = self)\n count = 0\n walk_tree(hash) do\n count += 1\n end\n count\n end", "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 num_children\n super\n end", "def child_element_count\n num = 0\n self.each_child_node do |n|\n if n.node_type == ELEMENT_NODE then\n num += 1\n end\n end\n return num\n end", "def actual_amount\n children.length\n end", "def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end", "def count_children(node)\n\t\treturn 0 if node.children.nil?\n\t\tnode.children.count + (node.children.map {|child| count_children(child)}).inject(&:+)\n\tend", "def children_size\n size = locations.size\n locations.each{|location|\n locations = location.locations\n if locations.present?\n size += location.children_size\n end\n }\n return size\n end", "def depth\n self.parents.size\n end", "def depth\n children_depth + my_depth\n end", "def size\n children_size + my_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 number_of_parents\n if self.is_parent\n return 0\n else\n return 1 + self.parent.number_of_parents\n end\n end", "def all_children_count(scope = nil)\n return all_children(scope).length if scope.is_a?(Hash)\n return (self[right_col_name] - self[left_col_name] - 1)/2\n end", "def child_count(type=nil)\n if ((type != Resource::RESOURCE) && (type != Resource::LEARNING_COLLECTION) && (type != Resource::COLLECTION_OBJECT) && (type != Resource::EXHIBITION))\n type = nil\n end\n if (type == nil)\n responses = Resource.where(\"in_response_to_resource_id = ? AND response_banned_on IS ?\", self.id, nil)\n return self.children.length - responses.length\n end\n\n # TODO: cache this\n r = ResourceHierarchy.joins(:child_resource).where(\"resources.resource_type = ? AND resource_hierarchies.resource_id = ?\", type, self.id)\n return r.length\n end", "def parent_count(*args)\n parent_rels(*args).size\n end", "def length\n @tree.length\n end", "def width\n return 1 unless has_children?\n children.inject(0) {|sum,c| sum + c.width}\n end", "def num_nests\n my_nests.length\n end", "def size\n @errors.size + @children.each_value.reduce(0) do |total, child|\n total + child.size\n end\n end", "def descendant_count(*args)\n descendant_rels(*args).size\n end", "def children_count\n 0 if @left.nil? && @right.nil?\n 1 if @left.nil? || @right.nil?\n 2\n end", "def rowCount(parent)\n if info = info_from_index(parent)\n info.children.size\n else 0\n end\n end", "def _num_of_children(root)\n return [ 0, nil, nil ] if root.nil?\n #\n n = root.lnode.nil? ? 0 : 1\n n += root.rnode.nil? ? 0 : 1\n [n, root.lnode, root.rnode]\n end", "def size\n return @tree.size\n end", "def total_count\n object.nodes.size\n end", "def depth\n crumbs.size\n end", "def render_child_count(node = @tree.root)\n @stack.push(node)\n child_count = 0\n until @stack.empty?\n current_node = @stack.pop\n current_node.children.each do |child|\n @stack.push(child)\n child_count += 1\n end\n end\n child_count\n end", "def segment_count\n children.map(&:segment_count).inject(:+).to_i + 2\n end", "def has_children()\n return 1 if(@children.length > 0)\n 0\n end", "def nested_notes_count\n count = notes.any? ? notes.count : 0\n subcategories.each do |category|\n next unless category.notes.any?\n\n count += category.notes.count\n end\n count\n end", "def wordCount\n count = 0\n\n if (@word.to_s != '')\n count += 1\n end\n\n if @children.size\n @children.each do |key, val|\n count += val.wordCount\n end\n end\n\n count\n end", "def num_clusters_include_tree_children\n num_clusters_include_tree_children_rec( self )\n end", "def children_count(id)\n wait_for_ajax do\n page.driver.browser.execute_script(<<-JS)\n return Ext.ComponentQuery.query('treepanel')[0].getStore().getNodeById('#{id}').childNodes.length;\n JS\n end\n end", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def depth\n ancestors.count\n end", "def depth\n ancestors.count\n end", "def get_number_of_root_elements(elements)\n num = 0\n parent_field = @db_fields[:parent]\n elements.each do |e|\n num += 1 if e.send(parent_field) == 0\n end\n num\n end", "def size(children: true)\n c_size = 0\n request = $postgres.exec_prepared('wsfile_size', [self.id])\n c_size += request[0].map{|k,v| v.to_i }.inject(:+)\n c_size += self.children.map{|child| child.size}.inject(:+) || 0 if children\n c_size\n end", "def count()\n return @child_path_parts.count\n end", "def depth\n self.ancestors.size\n end", "def subtree_count(*args)\n subtree_rels(*args).size\n end", "def total_bags_inside\n children.size + children.map(&:total_bags_inside).sum\n end", "def num_documents_include_tree_children_rec(parent_cluster) \n num_total = parent_cluster.num_documents\n\n parent_cluster.tree_children.each do |child|\n num_total += child.num_documents_include_tree_children\n end\n\n return num_total\n end", "def child_count(node, count = 0)\n return count if node.nil?\n if !node.is_a? Node\n child_count(find(node))\n else\n count += 1 if !node.left.nil?\n count += 1 if !node.right.nil?\n end\n count\n end", "def height\n count = 0\n if @root != nil\n count = height_helper(@root)\n end\n return count\n end", "def children_get()\n @children\n end", "def depth\n breadcrumbs.size\n end", "def depth\n self.dotted_ids.scan(/\\./).size\n end", "def ancestors_count(*args)\n ancestor_rels(*args).size\n end", "def num_below\n\t\t\tcount = 0\n\t\t\tself.node_maps.each { |node_map|\n\t\t\t\tnode_map.children.each { |child|\n\t\t\t\t\t# Child is one of us as well - include it and check its children\n\t\t\t\t\tif child.node.class.ancestors.include?(self.class)\n\t\t\t\t\t\tcount = count + 1 + child.node.num_below\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t}\n\t\t\tcount\n\t\tend", "def length\n\n count_objects()\n end", "def get_children\n @children\n end", "def tag_counts\n self.parent.tag_counts\n end", "def children\n attributes.fetch(:children)\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def fulltree_count(*args)\n fulltree_rels(*args).size\n end", "def _children\n @children\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 level\n root? ? 0 : ancestors.count\n end", "def children\n _children\n end", "def descendants_count_bfs(options={})\n count = 0\n each_level_ids(options) do |level_ids|\n count += level_ids.count\n end\n return count\n end", "def _children\n @children\n end", "def size\n # We don't include the Hash that stores the root objects into the object\n # count.\n @lock.synchronize do\n @db.item_counter - 1\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 children\n @children\n end", "def children\n @children\n end", "def get_children\n return @children\n end", "def num_child_jobs\n @gapi.statistics.num_child_jobs || 0\n end", "def size\n count = 0\n visit_nodes do\n count += 1\n end\n count\n end", "def size\n @root and @root.size or 0\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\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 get_children\n return children\n end", "def level\n length = 0\n cursor = self\n while cursor.parent_document\n length += 1\n cursor = cursor.parent_document\n end\n length\n end", "def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end", "def size\n @references.count do |_, ref|\n ref.object\n end\n end", "def num_below\n count = 0\n node_maps.each do |node_map|\n node_map.children.each do |child|\n # Child is one of us as well - include it and check its children\n if child.node.class.ancestors.include?(self.class)\n count = count + 1 + child.node.num_below\n end\n end\n end\n count\n end", "def number_of_living_descendants\n count_descendants_matching { |d| d.alive? }\nend", "def total\n object.nodes.size\n end", "def top_level_section_count\n @top_level.items.size\n end", "def compute_child_mod_count\n target_child_count = case self.grid_type\n when FULL\n 1\n when HALVES, LEFT, RIGHT\n 2\n when THIRDS\n 3\n else\n 0\n end\n (target_child_count - self.columns.size)\n end", "def depth\n self[:depth]\n end" ]
[ "0.8398504", "0.8378222", "0.83523947", "0.8122807", "0.8009751", "0.79829365", "0.7730541", "0.7683608", "0.7582975", "0.7526048", "0.7504786", "0.7484354", "0.73339397", "0.7274246", "0.721356", "0.7212441", "0.71243304", "0.7067528", "0.70630413", "0.7061069", "0.7051977", "0.70482326", "0.7030816", "0.6968522", "0.692589", "0.6882336", "0.6848661", "0.67188185", "0.670649", "0.6699573", "0.66989076", "0.6642092", "0.6630836", "0.6627816", "0.6613137", "0.66095346", "0.6604078", "0.6602961", "0.65302736", "0.65273696", "0.64994377", "0.6487857", "0.64865255", "0.64780426", "0.64701515", "0.64604217", "0.6459386", "0.6452707", "0.64424014", "0.64424014", "0.64420384", "0.6429007", "0.6418579", "0.64088553", "0.6378302", "0.63669133", "0.6352883", "0.63505375", "0.6245566", "0.6243579", "0.62134165", "0.62050694", "0.61502117", "0.6147946", "0.6147202", "0.61366475", "0.61315405", "0.61306715", "0.6128558", "0.6128558", "0.6128558", "0.6128558", "0.6127501", "0.6115903", "0.61082363", "0.6108223", "0.6104822", "0.61015344", "0.60991424", "0.6097518", "0.609591", "0.6079023", "0.6079023", "0.60788286", "0.6078228", "0.60658544", "0.605629", "0.6054272", "0.6054272", "0.6050857", "0.5996917", "0.5978623", "0.5964502", "0.59634", "0.5961134", "0.5960036", "0.59577096", "0.59519464", "0.5951095", "0.59475213" ]
0.6513029
40
Returns itself and all nested children. Pass :exclude => item, or id, or [items or id] to exclude one or more items and all of their descendants.
def full_set(special=nil) if special && special[:exclude] exclude_str = " AND NOT (#{base_set_class.sql_for(special[:exclude])}) " elsif new_record? || self[right_col_name] - self[left_col_name] == 1 return [self] end base_set_class.find(:all, :conditions => "#{scope_condition} #{exclude_str} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})", :order => left_col_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end", "def 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 children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def direct_children_by_id(*args)\n scope = args.last.is_a?(Hash) ? args.pop : {}\n ids = args.flatten.compact.uniq\n self.class.find_in_nested_set(:all, { \n :conditions => [\"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id} AND #{self.class.table_name}.#{self.class.primary_key} IN (?)\", ids]\n }, scope) \n end", "def children\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end", "def get_childs(recursive, ret_obj)\n\n return self.class.get_childs(self.id, recursive, ret_obj)\n end", "def get_children\n return children\n end", "def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end", "def descendants\n without_self self_and_descendants\n end", "def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end", "def descendants\n tree.children_of(id)\n end", "def descendants\n without_self self_and_descendants\n end", "def all_children\n find_all_children_with_dotted_ids\n end", "def negating_children\n return [] if !has_children?\n\n children.find_all(&:negation?)\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n (items + collections)\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def children\n Product.unscoped.deleted.where(:parent_id=>self.id)\n end", "def get_children\n return @children\n end", "def descendants\n without_self(self_and_descendants)\n end", "def descendants\n base_and_descendants.where.not(id: descendants_base.select(:id))\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\n return @children if [email protected]?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end", "def get_children\n @children\n end", "def onlychildren_list\n if matches.length == 1\n [self] + matches[0].onlychildren_list\n else\n [self]\n end\n end", "def children(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\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 children(entity)\n self.all(:parent_id => entity.id)\n end", "def children\n Feature.find(:all, :conditions => [ 'parent_id=?', self.id] )\n end", "def self_and_siblings\n nested_set_scope.children_of parent_id\n end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n self.class.children(self) \n end", "def descendants\n records = fetch_self_and_descendants - [self]\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id).compact).\n extending(Arrangeable).\n records(records)\n end", "def descendants_r(*args)\n pending = [self]\n des = []\n while !pending.empty?\n e = pending.pop\n e.children(*args).each do |c|\n if !des.include?(c)\n des << c\n pending.push(c)\n end\n end\n end\n des\n end", "def find_nested\n [self] + @properties.values.select {|v| v.is_a?(Mida::Item) ? v.find_nested : nil }.compact.flatten\n end", "def all_children\n children(all: true)\n end", "def children\n entries\n end", "def all_children(special=nil)\n full_set(special) - [self]\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def descendants_and_self\r\n result = [self]\r\n children.each { |child| result << child.descendants_and_self }\r\n result.flatten!\r\n return result\r\n end", "def children\n _children\n end", "def children\n @children\n end", "def children\n @children\n end", "def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end", "def children_get()\n @children\n end", "def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end", "def sub_items\n return self.elems if self.elems.all? { |e| e.is_a?(Item) }\n [self]\n end", "def self_and_siblings\n #parent ? parent.children : self.class.roots\n self.class.find(:all, :conditions => {:parent_id => self.parent_id})\n end", "def get_children\n \t@children\n end", "def get_all_posts()\n return Post.where(:parent_id => nil )\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end", "def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end", "def descendants\n tree.tap(&:shift)\n end", "def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def children\n if self.rep_parent.nil?\n return super\n else\n the_children = Array.new\n self.rep_parent.children.each do |child|\n if child.is_a?(Repeatable)\n \n child.repititions.\n where(:show_date => self.show_date).each do |r|\n the_children << r\n end\n elsif child.show_date == self.show_date\n the_children << child\n end\n end\n return the_children\n end\n end", "def find_selected_childentries(userid)\n @entries = Entry.find(:all, :conditions => [\"user_id=? and parent_id = ? \", userid, self.id])\n \n \n return @entries\n end", "def children\n []\n end", "def children\n []\n end", "def all_children\n return @all_children if !@all_children.nil?\n @all_children = PhotoCollection.all_urls.find_all{|url| url[self.url] && url != self.url}.collect{|url| PhotoCollection.find_by_url(url)}\n end", "def children\n []\n end", "def get_child!(children)\n children[1] || children\n end", "def children(options={})\n @global_page.children.all options\n end", "def get_childs\n childs = Category.any_in(parent_ids: [parent.id])\n\n results = Array.new\n childs.each do |child|\n results << child\n end\n\n results\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children_with_results\n children.select(&:any_results_including_children?)\n end", "def children\n []\n end", "def children\n attributes.fetch(:children)\n end", "def get_children()\n {}\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def self_and_siblings\n parent ? parent.children : Category.roots\n end", "def self_and_siblings\n parent ? parent.children : Category.roots\n end", "def resolve_inclusions(items)\n items.combination(2){|parent, child|\n if parent.include? child\n items.delete(child)\n end\n }\n items\n end", "def sub_tasks\n MatterTask.all(:conditions => [\"parent_id = ?\", self.id])\n end", "def ignore_parent_exclusion; end", "def self_and_siblings\n dataset.nested.filter(self.class.qualified_parent_column => self.parent_id)\n end", "def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRoot = true;\n @work = DcmWork.new(@id)\n @children = [@work.pi]\n else\n @isRoot = false;\n @children = get_children(\"nla.\"+params[:root])\n end\n render :action => \"children.json\"\n end", "def children\n @resource.children\n end", "def _children\n @children\n end", "def children\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND #{parent_col_name} = #{self.id}\", :order => left_col_name)\n end", "def parent_adopts_children\n if parent(true)\n self.class.transaction do\n children(true).each{|child| parent.children << child}\n end\n else\n orphan_children\n end\n end", "def descendants\n children + children.map(&:descendants).flatten\n end", "def siblings(options = {})\n self.siblings_and_self(options).excludes(id: self.id)\n end", "def children\n NotImplemented\n end", "def children\n NotImplemented\n end", "def children\n @children ||= {}.with_indifferent_access\n end", "def roots\n nested.filter(self.model_classes[nil].qualified_parent_column => nil)\n end", "def _children\n @children\n end", "def siblings(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=? OR child_node_id=?', self.parent_node_id, self.child_node_id]}) do\n self.class.find(:all, *args) - [self]\n end\n end", "def all_children(accummulator=[])\n return accummulator if children.size == 0\n children.each do |child_id|\n child = Folder.get(child_id)\n accummulator << child\n child.all_children(accummulator)\n end\n accummulator\n end" ]
[ "0.6893128", "0.6810607", "0.64480454", "0.62908393", "0.6191619", "0.6076562", "0.59581566", "0.5936782", "0.5933396", "0.5921334", "0.59110093", "0.5899419", "0.5893955", "0.5873582", "0.58590585", "0.5819769", "0.579713", "0.5791045", "0.5767786", "0.57394755", "0.5689808", "0.5685415", "0.56838876", "0.5676916", "0.5676916", "0.5663467", "0.563442", "0.5587001", "0.5556042", "0.5541277", "0.554069", "0.5518459", "0.5516636", "0.5511094", "0.55023754", "0.5499184", "0.5493638", "0.54792", "0.54724807", "0.5463095", "0.54354835", "0.5434497", "0.54254186", "0.542478", "0.54239047", "0.54218197", "0.5417541", "0.5417541", "0.5417323", "0.54102385", "0.5404741", "0.5387967", "0.53866655", "0.5384583", "0.53805983", "0.5380406", "0.5380162", "0.53780687", "0.537491", "0.5364727", "0.53615403", "0.5357057", "0.53528154", "0.53426147", "0.53426147", "0.5339732", "0.53380835", "0.5329535", "0.5329367", "0.53278583", "0.5325181", "0.5325181", "0.5325181", "0.5314684", "0.53083", "0.5304055", "0.52954304", "0.52795887", "0.52795887", "0.52795887", "0.52795887", "0.527915", "0.527915", "0.5276553", "0.52747405", "0.52708197", "0.5265426", "0.525827", "0.52542937", "0.52521074", "0.5248798", "0.52350587", "0.52348", "0.5230931", "0.52225167", "0.52225167", "0.52165455", "0.5213921", "0.52086073", "0.52081853", "0.52077454" ]
0.0
-1
Returns all children and nested children. Pass :exclude => item, or id, or [items or id] to exclude one or more items and all of their descendants.
def all_children(special=nil) full_set(special) - [self] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_children(options = {})\n conditions = \"(#{nested_set_left} > #{self[nested_set_left]}) and (#{nested_set_right} < #{self[nested_set_right]})\"\n if options[:exclude]\n transaction do\n # exclude some items and all their children\n options[:exclude] = [options[:exclude]] if !options[:exclude].is_a?(Array)\n # get objects for ids\n options[:exclude].collect! {|s| s.is_a?(nested_set_class) ? s : nested_set_class.find(s)}\n # get all subtrees and flatten the list\n exclude_list = options[:exclude].map{|e| e.full_set.map{|ee| ee.id}}.flatten.uniq\n conditions += \" AND id NOT IN (#{exclude_list.join(',')})\" unless exclude_list.empty?\n end\n end\n nested_set_class.find_with_nested_set_scope(:all, :conditions => conditions, :order => nested_set_left)\n end", "def 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 children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def all_children\n find_all_children_with_dotted_ids\n end", "def get_children\n return children\n end", "def descendants\n tree.children_of(id)\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def children\n params[:scope] ||= \"private\"\n\n children = if params[:scope] == Scopes::SCOPE_PRIVATE\n @folder&.children ||\n current_user.nodes.where(parent_folder_id: nil)\n elsif params[:scope] == Scopes::SCOPE_PUBLIC\n @folder&.children ||\n Node.where(scope: params[:scope], parent_folder_id: nil)\n end\n\n if [Scopes::SCOPE_PRIVATE, Scopes::SCOPE_PUBLIC].include?(params[:scope])\n children = children.where.not(sti_type: \"Asset\")\n end\n\n children = children.where(scope: params[:scope]).order(:sti_type, :name)\n\n render json: children, root: \"nodes\", adapter: :json\n end", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def get_childs(recursive, ret_obj)\n\n return self.class.get_childs(self.id, recursive, ret_obj)\n end", "def children(*args)\n self.class.send(:with_scope, :find=>{:conditions=>['parent_node_id=?', self.child_node_id]}) do\n self.class.find(:all, *args)\n end\n end", "def get_children(args = '', output = :OBJECT)\n kids = {}\n if args.blank?\n if $GLOBALS['post']\n args = { post_parent: $GLOBALS['post'].post_parent }\n else\n return kids\n end\n elsif args.is_a? Integer\n args = { post_parent: args}\n elsif args.is_a? String\n args = { post_parent: args.to_i}\n elsif args.is_a? Railspress::WpPost\n args = { post_parent: args.post_parent }\n end\n\n defaults = {\n numberposts: -1,\n post_type: 'any',\n post_status: 'any',\n post_parent: 0,\n }\n\n r = defaults.merge args\n\n children = get_posts(r)\n\n return kids if children.nil?\n\n return children unless r[:fields].blank?\n\n # update_post_cache(children)\n\n children.each do |child|\n kids[child.id] = child\n end\n\n if output == :OBJECT\n kids\n elsif output == :ARRAY_A\n weeuns = {}\n kids.values.each do |kid|\n weeuns[kid.id] = kid.attributes\n end\n return weeuns\n elsif output == :ARRAY_N\n babes = {}\n kids.values.each do |kid|\n babes[kid.id] = kid.attributes.values\n end\n return babes\n else\n kids\n end\n end", "def get_children\n return @children\n end", "def negating_children\n return [] if !has_children?\n\n children.find_all(&:negation?)\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children(options={})\n @global_page.children.all options\n end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\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\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end", "def all_children\n children(all: true)\n end", "def get_children(params)\n scope_data_class(params) do\n params[:limit] = config[:rows_per_page] if config[:enable_pagination] && (params[:id].nil? || params[:id] == 'root')\n params[:scope] = config[:scope]\n data_adapter.get_records(params, final_columns)\n end\n end", "def descendants\n base_and_descendants.where.not(id: descendants_base.select(:id))\n end", "def direct_children_by_id(*args)\n scope = args.last.is_a?(Hash) ? args.pop : {}\n ids = args.flatten.compact.uniq\n self.class.find_in_nested_set(:all, { \n :conditions => [\"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id} AND #{self.class.table_name}.#{self.class.primary_key} IN (?)\", ids]\n }, scope) \n end", "def children(*args)\n return call_ancestry_method(:children) if use_ancestry?\n\n Relationship.resources(child_rels(*args))\n end", "def get_childs\n childs = Category.any_in(parent_ids: [parent.id])\n\n results = Array.new\n childs.each do |child|\n results << child\n end\n\n results\n end", "def descendants\n children.inject([]) { |m,child|\n m << child\n m += child.descendants\n }\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def children\n Product.unscoped.deleted.where(:parent_id=>self.id)\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def descendants\n _descendants = children(true)\n children.each do |child|\n _descendants = _descendants + child.descendants\n end\n _descendants\n end", "def descendants\n records = fetch_self_and_descendants - [self]\n\n ActsAsOrderedTree::Relation::Preloaded.new(self.class).\n where(:id => records.map(&:id).compact).\n extending(Arrangeable).\n records(records)\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def getAllChildren\n children = Tree.where(\"tree_type_id = ? AND version_id = ? AND subject_id = ? AND grade_band_id = ? AND code like ?\", tree_type_id, version_id, subject_id, grade_band_id, code+'.%')\n Rails.logger.debug(\"*** tree children: #{children.inspect}\")\n return children\n end", "def get_children\n @children\n end", "def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\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 children\n _children\n end", "def children(entity)\n self.all(:parent_id => entity.id)\n end", "def children\n return [] if child_count <= 0\n with_cache(:children) do\n @od.request(\"#{api_path}/children?$top=1000\")['value'].map do |child|\n OneDriveItem.smart_new(@od, child)\n end\n end\n end", "def all_children\n @all_children ||= children + children.inject([]) {|records, child| records + child.all_children}\n end", "def get_children_ids_recursive\n ids = []\n children.each do |c|\n\t\t\t\tif !c.children.empty?\n\t\t\t\t\tids += c.get_children_ids_recursive\n\t\t\t\tend\n\t\t\t\tids << c.id\n\t\t\tend\n return ids\n\t\tend", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end", "def children\n return @children if [email protected]?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end", "def descendants\n children + children.map(&:descendants).flatten\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(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def children\n @children ||= {}.with_indifferent_access\n end", "def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end", "def children\n (items + collections)\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def descendants_r(*args)\n pending = [self]\n des = []\n while !pending.empty?\n e = pending.pop\n e.children(*args).each do |c|\n if !des.include?(c)\n des << c\n pending.push(c)\n end\n end\n end\n des\n end", "def children_of(page)\n children = (page_repository.children_of(page) || [])\n children\n .map { |child| decorate_page(child) }\n .select { |child| self.include_page?(child) }\n end", "def children(options = {})\n children = get_children(\"directory\").collect { |child| Dirk.new(child) }\n children.reject! { |child| child.published == false || child.draft == true }\n children.sort! { |a, b| a.send(options[:sort]).to_s <=> b.send(options[:sort]).to_s } if options[:sort]\n children.reverse if options[:order].to_s.upcase == \"DESC\"\n children\n end", "def children\n @resource.children\n end", "def get_childs\n access = Access.where(:parent_id=>id)\n childs=\"\"\n access.each do |item|\n if childs.empty?\n if item.get_childs.empty?\n childs=item.id.to_s\n else\n childs=item.id.to_s+\",\"+item.get_childs\n end\n else\n if item.get_childs.empty?\n childs= childs+\",\"+item.id.to_s\n else\n childs= childs+\",\"+item.id.to_s+\",\"+item.get_childs.to_s\n end\n end\n end\n return childs\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependencies\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def fetch_children\n @children = []\n for item in self.listex\n if item[\"type\"] == \"folder\" and item[\"id\"]!=@id #sharefile API includes self in list\n @children << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n @children << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n end", "def all_activities_children\n @activity_children = ActivityChild.includes(:child)\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def children\n []\n end", "def children\n []\n end", "def get_descendants(id, opts = {})\n input_json = {\n id: id,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/get_descendants\", input_json)\n Dropbox::API::DescendantList.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end", "def onlychildren_list\n if matches.length == 1\n [self] + matches[0].onlychildren_list\n else\n [self]\n end\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def descendants\n list = []\n children.each do |child|\n list << child\n list.concat(child.descendants)\n end\n list\n end", "def children\n entries\n end", "def children_with_results\n children.select(&:any_results_including_children?)\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def block_children(options = {})\n throw ArgumentError.new('Required arguments :block_id missing') if options[:block_id].nil?\n if block_given?\n Pagination::Cursor.new(self, :block_children, options).each do |page|\n yield page\n end\n else\n get(\"blocks/#{options[:block_id]}/children\", options.except(:block_id))\n end\n end", "def get_children\n \t@children\n end", "def get_children()\n {}\n end", "def descendants\n node, nodes = self, []\n node.children.each { |child|\n # Check for circular dependenciess\n if !nodes.include?(child)\n nodes += [child]\n nodes += child.descendants\n end\n } unless node.children.empty?\n nodes\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def children_get()\n @children\n end", "def descendants(*args)\n return call_ancestry_method(:descendants) if use_ancestry?\n\n Relationship.resources(descendant_rels(*args))\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def descendants\n without_self self_and_descendants\n end", "def children\n if no_child?\n []\n else\n [ body ]\n end\n end", "def _children\n @children\n end", "def all_children(accummulator=[])\n return accummulator if children.size == 0\n children.each do |child_id|\n child = Folder.get(child_id)\n accummulator << child\n child.all_children(accummulator)\n end\n accummulator\n end", "def children\n node.children\n end", "def children\n attributes.fetch(:children)\n end", "def children\n []\n end", "def children\n self.class.children(self) \n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def children(options={:type => nil, :get_dataset => false, :recursive => false, :keep_cache => true, :reload => false, :preconditions => {:hidden => false}})\n return @children_cache if @children_cache and !options[:get_dataset] and !options[:reload]\n klass = Ecore::db[:documents]\n if options[:type]\n raise(TypeError, \":type must be an Ecore::DocumentResource\") unless options[:type].respond_to?(:table_name)\n klass = Ecore::db[:\"#{options[:type].table_name}\"]\n end\n query = klass.store_preconditions((@user_obj || @group_ids || @user_id),nil,self,nil,(options[:preconditions] || {:hidden => false}))\n query = ( options[:recursive] ? query.where(:path.like(\"#{absolute_path}%\")) : query.where(:path => absolute_path) )\n return query if options[:get_dataset]\n children_cache = query.order(:position,:name).receive(:all)\n return children_cache if options[:keep_cache]\n @children_cache = children_cache\n end", "def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end", "def get_children(h, n)\n rr = h[n[:id]]\n if !rr.nil?\n rr[:children]\n else\n []\n end\n end", "def children\n @children\n end", "def children\n @children\n end", "def items_children(item, items)\n \tuser = item.user\n # if item.new_owner\n # return []\n # end\n \tuser_wants = user.wants.find_all {|want| items.include?(want.possession) and want.value > item.value and want.possession.new_owner == nil}\n \tuser_wants.sort! {|x,y| x.value <=> y.value}.reverse\n \tchildren = user_wants.map {|want| want.possession }\n end", "def with_descendants(id)\n next_ids = [id]\n descendants = [id]\n\n while next_ids.any?\n parents = next_ids\n next_ids = []\n\n parents.each do |pid|\n if children = node_ids_by_parent_id[pid]\n descendants.concat(children)\n next_ids.concat(children)\n end\n end\n end\n\n descendants\n end", "def _children\n @children\n end", "def descendants\n without_self self_and_descendants\n end", "def children\n\t\treturn children_of @current_node\n\tend" ]
[ "0.74371666", "0.70197344", "0.6592408", "0.63761985", "0.6288133", "0.62532914", "0.62080973", "0.6190531", "0.61816496", "0.61080414", "0.6103033", "0.6084506", "0.6062308", "0.60235035", "0.6003771", "0.596848", "0.59574425", "0.592502", "0.59181404", "0.59181404", "0.5910012", "0.590742", "0.5892576", "0.5879159", "0.58718127", "0.5861764", "0.582273", "0.57876396", "0.5766469", "0.57648706", "0.5759692", "0.57575876", "0.57467866", "0.5738714", "0.5731992", "0.5707084", "0.5681248", "0.56709003", "0.56656677", "0.5663239", "0.5652054", "0.5649312", "0.5629911", "0.56035995", "0.5601806", "0.5580816", "0.5564712", "0.55585194", "0.55552757", "0.5551433", "0.55503964", "0.55469936", "0.55452305", "0.553543", "0.5532982", "0.5524354", "0.55240643", "0.5516487", "0.5509811", "0.55096924", "0.5495706", "0.54938906", "0.54938906", "0.54885066", "0.54775393", "0.54744554", "0.54744554", "0.5471582", "0.54697573", "0.5468073", "0.5468073", "0.5468073", "0.54631567", "0.54614294", "0.54606235", "0.54454005", "0.54369676", "0.5433958", "0.54271996", "0.5427088", "0.5427088", "0.54264003", "0.5417659", "0.54126245", "0.5401265", "0.5398964", "0.5389653", "0.537533", "0.53746", "0.5371393", "0.5370159", "0.53680944", "0.53680944", "0.5365235", "0.5365235", "0.5364888", "0.53631204", "0.5359323", "0.5354767", "0.5350549" ]
0.53822553
87
Returns this record's immediate children.
def children base_set_class.find(:all, :conditions => "#{scope_condition} AND #{parent_col_name} = #{self.id}", :order => left_col_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_children\n return children\n end", "def children\n _children\n end", "def children\n entries\n end", "def get_children\n return @children\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def _children\n @children\n end", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def _children\n @children\n end", "def get_children()\n return @space.get_children()\n end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end", "def all_children\n @all_children ||= children + children.inject([]) {|records, child| records + child.all_children}\n end", "def children\n self.class.children(self) \n end", "def children_get()\n @children\n end", "def children\n @children\n end", "def children\n @children\n end", "def children\n rows\n end", "def children\n @children ||= []\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def children\n attributes.fetch(:children)\n end", "def children\n Array.new\n end", "def children\n\t\treturn children_of @current_node\n\tend", "def get_children\n @children\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def children\n @children ||= {}.with_indifferent_access\n end", "def children\n @resource.children\n end", "def children\n self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} = #{self.id}\", :order => acts_as_nested_set_options[:left_column])\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def children\n []\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def grand_children\n []\n end", "def get_children\n \t@children\n end", "def all_children\n children(all: true)\n end", "def children\n @root.children & @initial_contents\n end", "def children\n properties \n end", "def children\n self.class.find(:all, \n :select => \"a.*\",\n :joins => \"a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}\", \n :conditions => [\"b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1\", self.id])\n end", "def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def children\n @ref.children.to_ruby\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n 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 all_children\n find_all_children_with_dotted_ids\n end", "def children\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"#{nested_set_parent} = #{self.id}\", :order => nested_set_left)\n end", "def children\n node.children\n end", "def children()\r\n raise \"get_children is not implemented for class #{self.class}\"\r\n end", "def children\n NotImplemented\n end", "def children\n NotImplemented\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def children() []; end", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end", "def children\n rows + tags\n end", "def children\n if self.rep_parent.nil?\n return super\n else\n the_children = Array.new\n self.rep_parent.children.each do |child|\n if child.is_a?(Repeatable)\n \n child.repititions.\n where(:show_date => self.show_date).each do |r|\n the_children << r\n end\n elsif child.show_date == self.show_date\n the_children << child\n end\n end\n return the_children\n end\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n raise NotImplementedError\n end", "def children; []; end", "def children\n if no_child?\n []\n else\n [ body ]\n end\n end", "def values\n @children\n end", "def children(options={})\n @global_page.children.all options\n end", "def all_children(scope = {})\n full_set(scope) - [self]\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n self.node.children.collect(&:content)\n end", "def children(entity)\n self.all(:parent_id => entity.id)\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children(scope = {})\n self.class.find_in_nested_set(:all, { :conditions => \"#{scope_condition} AND #{prefixed_parent_col_name} = #{self.id}\", :order => \"#{prefixed_left_col_name}\" }, scope)\n end", "def children()\n #Ressource.filter(:parent_id => self.id, :parent_service_id => self.service_id).all\n end", "def children\n [@before, @mid, @after].compact\n end", "def children\n [@before, @mid, @after].compact\n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def children\n child_objects(Dependency)\n end", "def children\n elements = []\n\n %x{\n var children = #@native.children;\n for(var i = 0; i < children.length; i++) {\n elements[i] = #{Element.new(`children[i]`)};\n }\n }\n\n elements\n end", "def children\n Children.new({\n cc_conditions: self.association( :cc_conditions),\n cc_loops: self.association( :cc_loops),\n cc_questions: self.association( :cc_questions),\n cc_sequences: self.association( :cc_sequences),\n cc_statements: self.association( :cc_statements)\n })\n end", "def getChildren\n begin\n elementObject = waitForObject(@symbolicName, OBJECT_WAIT_TIMEOUT)\n children = Squish::Object.children(elementObject)\n return children\n rescue Exception => e\n\t Log.TestFail(\"#{self.class.name}::#{__method__}(): Failed to get children for #{@name}: #{e.message}\")\n return nil\n end\n end", "def children \n\t\t_c = Children.joins(:families).where(:families => {:parent_id => id} )\n\t\tif _c.present?\n\t\t\t_c\n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def children\n @@devices.find {|i, v| i == @id }\n end", "def children()\n bag.ls(path).map { |pat| bag.get(pat) }.compact\n end", "def children\n ary = normal_children.dup\n ary << fallback_child if fallback_child\n ary\n end", "def children\n return @children if [email protected]?\n @children = all_children.find_all{|collection| collection.url.count('/') == self.url.count('/') + 1}\n end", "def all_children\n\n yielded_self = if block_given?\n yield self\n end\n\n return ( yielded_self || self ) if self.children.empty?\n _child = self.children.map do |child|\n _name = (yield child if block_given?) || self\n if child.children.empty?\n _name\n else\n [_name, child.all_children{ |this_child| yield this_child if block_given? }]\n end\n end\n return _child\n end", "def all_children(special=nil)\n full_set(special) - [self]\n end", "def get_children()\n {}\n end" ]
[ "0.79561377", "0.7917964", "0.78821695", "0.78709346", "0.77638066", "0.77638066", "0.77529913", "0.76823556", "0.76823556", "0.76823556", "0.7682236", "0.76585543", "0.76379603", "0.7629049", "0.7611802", "0.76102257", "0.7590137", "0.7582787", "0.753093", "0.752095", "0.752095", "0.75161743", "0.75037855", "0.7486849", "0.7486849", "0.7486849", "0.7486849", "0.7476957", "0.7475678", "0.7469629", "0.7435383", "0.7426856", "0.7426856", "0.73792154", "0.7377197", "0.7366177", "0.7338161", "0.7322788", "0.7313972", "0.7255388", "0.72510654", "0.7226797", "0.7220748", "0.7219744", "0.7195605", "0.71863717", "0.7176887", "0.7143257", "0.71127546", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7086354", "0.7075097", "0.70677096", "0.70630217", "0.7021516", "0.7018738", "0.7018738", "0.7016121", "0.70084023", "0.7004932", "0.70013434", "0.6986742", "0.69621557", "0.69468826", "0.69158393", "0.69108766", "0.68906003", "0.68381196", "0.68198115", "0.68183243", "0.68176067", "0.68048406", "0.68023556", "0.6791009", "0.6774548", "0.67611754", "0.67611754", "0.67506903", "0.6693813", "0.66829157", "0.6679343", "0.66647774", "0.66398114", "0.6634733", "0.6608613", "0.66022253", "0.65975755", "0.65933293", "0.65807414", "0.6569422" ]
0.72143537
44
Returns this record's terminal children (nodes without children).
def leaves base_set_class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]}) AND #{left_col_name} + 1 = #{right_col_name}", :order => left_col_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n\t\treturn children_of @current_node\n\tend", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def children\n []\n end", "def get_children\n return @children\n end", "def children\n node.children\n end", "def children\n []\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def get_children\n return children\n end", "def children\n _children\n end", "def children\n @children ||= []\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def get_children()\n return @space.get_children()\n end", "def _children\n @children\n end", "def children\n attributes.fetch(:children)\n end", "def children\n []\n end", "def _children\n @children\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def children\n @children\n end", "def children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def children\n Array.new\n end", "def children\n entries\n end", "def children_get()\n @children\n end", "def children\n @children ||= {}.with_indifferent_access\n end", "def get_children\n @children\n end", "def children() []; end", "def children\n self.node.children.collect(&:content)\n end", "def all_children\n @all_children ||= children + children.inject([]) {|records, child| records + child.all_children}\n end", "def children\n list = NodeSet.new(document)\n document.decorate(list)\n\n first = self.child\n return list unless first # Empty list\n\n list << first unless first.blank?\n while first = first.next\n list << first unless first.blank?\n end\n list\n end", "def children\n @ref.children.to_ruby\n end", "def children\n if no_child?\n []\n else\n [ body ]\n end\n end", "def children; []; end", "def children\n EarLogger.instance.log \"Finding children for #{self}\"\n ObjectManager.instance.find_children(self.id, self.class.to_s)\n end", "def children\n children = []\n\n unless leaf?\n zipper = down\n children << zipper\n\n until zipper.last?\n zipper = zipper.next\n children << zipper\n end\n end\n\n children\n end", "def children\n children = []\n @board.rows.each_with_index do |row, r_idx|\n row.each_index do |c_idx|\n kid_board = @board.dup\n pos = [r_idx, c_idx]\n if kid_board.empty?(pos)\n kid_board[pos] = @next_mover_mark\n children << TicTacToeNode.new(kid_board, next_mark, pos)\n end\n end\n end\n children\n end", "def children\n self.class.children(self) \n end", "def children\n rows\n end", "def children\n children = []\n @board.rows.each_with_index do |row, row_idx|\n row.each_with_index do |col, col_idx|\n if @board.empty?([row_idx, col_idx])\n dup_board = @board.dup\n dup_board[[row_idx, col_idx]] = @next_mover_mark\n child_node = TicTacToeNode.new(dup_board, other_mark(@next_mover_mark), [row_idx, col_idx])\n children << child_node\n end\n end\n end\n children\n end", "def all_children\n children(all: true)\n end", "def grand_children\n []\n end", "def children\n [] if leaf?\n self.class.where('forestify_left_position > ?', self.forestify_left_position).where('forestify_right_position < ?', self.forestify_right_position)\n end", "def all_children\n find_all_children_with_dotted_ids\n end", "def get_children\n \t@children\n end", "def children\n children = []\n following_mark = @next_mover_mark == :x ? :o : :x\n @board.empty_positions.each do |pos|\n next_board = @board.dup\n next_board[pos] = @next_mover_mark\n children << TicTacToeNode.new(next_board, following_mark, pos)\n end\n children\n end", "def children\n children_nodes = Array.new\n i = 0\n while i < self.board.rows.length\n j = 0\n while j < self.board.rows.length\n if self.board.empty?([i,j])\n duped_board = self.board.dup\n duped_board.[]=([i,j],self.next_mover_mark) \n duped_node = self.class.new(duped_board,self.alternate_mark,[i,j])\n children_nodes << duped_node\n end\n j += 1\n end\n i += 1\n end\n return children_nodes\n end", "def children\n @root.children & @initial_contents\n end", "def tree_children\n\n tree[2]\n end", "def children\n result = []\n @children.each do |_, child_group|\n result.concat(child_group)\n end\n\n result\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n NodeSetProxy.new(@node.children, self)\n end", "def children\n children = []\n children << up_child unless up_child.nil?\n children << down_child unless down_child.nil?\n children << left_child unless left_child.nil?\n children << right_child unless right_child.nil?\n children\n 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\n children = []\n next_next_mover_mark = [:x, :o].reject { |mark| mark == next_mover_mark }.first\n\n @board.rows.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n pos = [row_idx, col_idx]\n if @board.empty?(pos)\n child_board = @board.dup\n child_board[pos] = @next_mover_mark\n children << TicTacToeNode.new(child_board, next_next_mover_mark, pos)\n end\n end\n end\n children\n end", "def children\n elements = []\n\n %x{\n var children = #@native.children;\n for(var i = 0; i < children.length; i++) {\n elements[i] = #{Element.new(`children[i]`)};\n }\n }\n\n elements\n end", "def children\n empty_squares.map { |pos| make_new_node(pos) }\n end", "def get_children( node=self )\n sql = <<-SQL\n select\n subject_term.identifier as child_identifier,\n subject_term.term_name as child_term,\n predicate_term.term_name as relation,\n object_term.identifier as parent_identifier,\n object_term.term_name as parent_term\n from\n term_relationship tr\n join term as subject_term on tr.subject_term_pk = subject_term.term_pk\n join term as predicate_term on tr.predicate_term_pk = predicate_term.term_pk\n join term as object_term on tr.object_term_pk = object_term.term_pk\n where\n predicate_term.term_name in ('part_of','is_a','develops_from')\n and object_term.identifier = ?\n SQL\n \n OLS_DB[sql,node.term].each do |row|\n child = OntologyTerm.new( row[:child_identifier], row[:child_term] )\n node << child\n end\n end", "def children\n children = [] \n @board.rows.each_with_index do |row, idx_1|\n row.each_with_index do |space, idx_2|\n pair = [idx_1, idx_2]\n if @board.empty?(pair)\n @board[pair] = :x\n node = TicTacToeNode.new(@board.dup, :o, pair)\n children << node\n end\n end\n end\n children\n end", "def children\n dataset.nested.filter(self.class.qualified_parent_column => self.id)\n end", "def children\n tree_search_class.where(tree_parent_id_field => self._id).sort(self.class.tree_sort_order()).all\n end", "def children\n \n TapirLogger.instance.log \"Finding children for #{self}\"\n children = []\n EntityMapping.all.each do |mapping| \n\n # Go through each associated entity mapping, and find mappings where the parent_id is us\n # which means that the child_id is some other entity, and it's a child\n \n # the to_s is important, otherwise self.id returns a :Moped::BSON::ObjectID\n children << mapping.get_child if mapping.parent_id == self.id.to_s\n\n # TODO - what happens if parent_id and child_id are the same. We'll\n # end up grabbing it. Could that break any assumptions?\n end\n \n children\n end", "def descendants\n children + children.map(&:children).flatten\n end", "def children\n @resource.children\n end", "def children\n @children ||= begin\n nodes =\n if comment?\n []\n elsif defined?(@value.class::ParseTreeVisitor)\n @value.class::ParseTreeVisitor.new(@value, {}).children\n elsif @value.respond_to?(:nodelist)\n Array(@value.nodelist)\n else\n []\n end\n # Work around a bug in Liquid::Variable::ParseTreeVisitor that doesn't return\n # the args in a hash as children nodes.\n nodes = nodes.flat_map do |node|\n case node\n when Hash\n node.values\n else\n node\n end\n end\n nodes.map { |node| Node.new(node, self, @template) }\n end\n end", "def children\n children = []\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |_, j|\n if @board.empty?([i, j])\n board_dup = @board.dup\n board_dup.rows[i][j] = @next_mover_mark\n next_mark = (@next_mover_mark == :x ? :o : :x)\n prev_move = [i, j]\n child = TicTacToeNode.new(board_dup, next_mark, prev_move)\n children << child\n end\n end\n end\n children\n end", "def children\n nodes = []\n\n self.get_empty_posns.each do |posn| \n updated_board = @board.dup\n updated_board[posn] = @next_mover_mark\n next_mark = @next_mover_mark == :x ? :o : :x\n new_node = TicTacToeNode.new(updated_board, next_mark, posn) \n nodes << new_node\n end\n\n nodes\n end", "def values\n @children\n end", "def children\n children = []\n board.rows.each_index do |row|\n board.rows[row].each_index do |col|\n pos = [row, col]\n if board[pos].nil?\n new_board = board.dup\n new_board[pos] = next_mover_mark\n children << self.class.new(new_board, switch_mark(next_mover_mark), pos)\n end\n end\n end\n children\n end", "def children()\n bag.ls(path).map { |pat| bag.get(pat) }.compact\n end", "def children\n childs = []\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if @board.empty?(pos)\n duped_board = @board.dup\n duped_board.[]=(pos, @next_mover_mark)\n childs << TicTacToeNode.new(duped_board, self.class.toggle(@next_mover_mark), pos)\n end\n end\n end\n childs\n\n end", "def children\n nodes = []\n @board.rows.each_with_index do |row, row_idx|\n row.each_index do |col_idx|\n pos = [row_idx, col_idx]\n next unless @board[pos].nil?\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n nodes << TicTacToeNode.new(new_board, this_mark, pos)\n end\n end\n nodes\n end", "def children\n children_arr = []\n @board.rows.each_index do |i|\n @board.rows.each_index do |j|\n if @board.empty?([i, j])\n children_arr << TicTacToeNode.new(@board.dup, @next_mover_mark, @board[i, j])\n end\n end\n end\n children_arr\n end", "def children\n children = []\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |square, j|\n pos = [i,j]\n if @board.empty?(pos)\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n mark = (@next_mover_mark == :x ? :o : :x)\n children << add_child(TicTacToeNode.new(new_board, mark, pos))\n end\n end\n end\n children\n end", "def children\n children = []\n new_next_mover_mark = @next_mover_mark == :x ? :o : :x\n\n BOARD_POS.each do |pos|\n next if @board[pos]\n new_board = @board.dup\n new_prev_move_pos = pos\n children << TicTacToeNode.new(new_board, new_next_mover_mark, new_prev_move_pos)\n end\n children\n end", "def children\n spaces = [0, 1, 2].product([0, 1, 2])\n children = []\n spaces.each do |space|\n b = @board.dup\n\n if b[space].nil?\n b[space] = @next_mover_mark\n children << TicTacToeNode.new(b, @prev_mover_mark, space)\n end\n end\n\n children\n end", "def getChildren\n begin\n elementObject = waitForObject(@symbolicName, OBJECT_WAIT_TIMEOUT)\n children = Squish::Object.children(elementObject)\n return children\n rescue Exception => e\n\t Log.TestFail(\"#{self.class.name}::#{__method__}(): Failed to get children for #{@name}: #{e.message}\")\n return nil\n end\n end", "def children_of(node)\n\t\treturn is_valid(node) ? node.children : nil\n\tend", "def children\n children = []\n empty_tiles = find_empty_tiles\n empty_tiles.each do |pos|\n new_board = @board.dup\n new_board[pos] = @next_mover_mark\n new_mark = @next_mover_mark == :x ? :o : :x\n children << TicTacToeNode.new(new_board,new_mark,pos)\n end\n children\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def children\n properties \n end", "def children\n nodes = []\n board.rows.each_with_index do |row, r_index|\n row.each_with_index do |cell, c_index|\n if cell.nil?\n new_board = board.dup\n new_board[[r_index, c_index]] = next_mover_mark\n nodes << TicTacToeNode.new(new_board, get_next_mover, [r_index, c_index])\n end\n end\n end\n\n nodes\n end", "def children\n self.class.where('? = ANY(parent_ids)', id.to_s)\n end", "def children\n out_edges.each{|e| e.dest}\n end", "def descendants\n return [] if new_record?\n tree_search_class.where(tree_path_field => self._id).sort(self.class.tree_sort_order()).all\n end" ]
[ "0.7485976", "0.7482659", "0.7482659", "0.74710757", "0.74710757", "0.74710757", "0.74622446", "0.745783", "0.74518925", "0.7441958", "0.7397935", "0.7368642", "0.734426", "0.7332586", "0.7332586", "0.73195386", "0.7237186", "0.7208795", "0.7179286", "0.71649426", "0.7156215", "0.71479076", "0.71479076", "0.7112406", "0.7112406", "0.7112406", "0.7112406", "0.71093434", "0.70486826", "0.7047421", "0.70452124", "0.70066047", "0.69507647", "0.69420177", "0.6934389", "0.69326407", "0.69287306", "0.6911018", "0.6904478", "0.6900853", "0.68901515", "0.68117154", "0.6798391", "0.6786006", "0.6775922", "0.6775258", "0.67587787", "0.67582035", "0.67447567", "0.671685", "0.67036235", "0.67035645", "0.6701654", "0.670151", "0.6699134", "0.66921055", "0.66740096", "0.6651806", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.66333133", "0.65940094", "0.6588325", "0.6585553", "0.658147", "0.65532625", "0.65504456", "0.653025", "0.6529967", "0.65236", "0.6517927", "0.6517509", "0.6517272", "0.6516187", "0.65158474", "0.6510234", "0.65016884", "0.6489538", "0.64856243", "0.6472461", "0.64707863", "0.6469513", "0.6466475", "0.64652693", "0.6463292", "0.6455218", "0.6451544", "0.64458084", "0.6422189", "0.641939", "0.6416232", "0.641385" ]
0.0
-1
Returns the count of this record's terminal children (nodes without children).
def leaves_count base_set_class.count(:conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]}) AND #{left_col_name} + 1 = #{right_col_name}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_children\n @children.size\n end", "def count_children\n count = children.count\n if count\n children.each { |child| count += child.count_children }\n end\n count\n end", "def num_children\n @children.size\n end", "def num_children\n count = 0\n self.children.each do |child|\n count = count + child.num_children\n end\n\n return self.children.size + count\n end", "def length\n @children.length\n end", "def total_child_count\n count = 0\n self.apply_to_children { |e| count += 1 }\n count\n end", "def num_children\n `#@native.numChildren()`\n end", "def children_size\n leaf? ? 0 : children.map(&:size).reduce(:+)\n end", "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 count_children(node)\n\t\treturn 0 if node.children.nil?\n\t\tnode.children.count + (node.children.map {|child| count_children(child)}).inject(&:+)\n\tend", "def count_child_nodes(hash = self)\n count = 0\n walk_tree(hash) do\n count += 1\n end\n count\n end", "def child_count(*args)\n child_rels(*args).size\n end", "def size\n @children.size\n end", "def children_count\n return (self[nested_set_right] - self[nested_set_left] - 1) / 2\n end", "def _num_of_children(root)\n return [ 0, nil, nil ] if root.nil?\n #\n n = root.lnode.nil? ? 0 : 1\n n += root.rnode.nil? ? 0 : 1\n [n, root.lnode, root.rnode]\n end", "def all_children_count(scope = nil)\n return all_children(scope).length if scope.is_a?(Hash)\n return (self[right_col_name] - self[left_col_name] - 1)/2\n end", "def children_count\n return (self[acts_as_nested_set_options[:right_column]] - self[acts_as_nested_set_options[:left_column]] - 1)/2\n end", "def children_count\n 0 if @left.nil? && @right.nil?\n 1 if @left.nil? || @right.nil?\n 2\n end", "def child_count(node, count = 0)\n return count if node.nil?\n if !node.is_a? Node\n child_count(find(node))\n else\n count += 1 if !node.left.nil?\n count += 1 if !node.right.nil?\n end\n count\n end", "def child_element_count\n num = 0\n self.each_child_node do |n|\n if n.node_type == ELEMENT_NODE then\n num += 1\n end\n end\n return num\n end", "def render_child_count(node = @tree.root)\n @stack.push(node)\n child_count = 0\n until @stack.empty?\n current_node = @stack.pop\n current_node.children.each do |child|\n @stack.push(child)\n child_count += 1\n end\n end\n child_count\n end", "def all_children_count\n return (self[right_col_name] - self[left_col_name] - 1)/2\n end", "def num_children\n super\n end", "def actual_amount\n children.length\n end", "def children_depth\n leaf? ? 0 : children.map(&:depth).max\n end", "def length\n @tree.length\n end", "def segment_count\n children.map(&:segment_count).inject(:+).to_i + 2\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 width\n return 1 unless has_children?\n children.inject(0) {|sum,c| sum + c.width}\n end", "def has_children()\n return 1 if(@children.length > 0)\n 0\n end", "def child_count(type=nil)\n if ((type != Resource::RESOURCE) && (type != Resource::LEARNING_COLLECTION) && (type != Resource::COLLECTION_OBJECT) && (type != Resource::EXHIBITION))\n type = nil\n end\n if (type == nil)\n responses = Resource.where(\"in_response_to_resource_id = ? AND response_banned_on IS ?\", self.id, nil)\n return self.children.length - responses.length\n end\n\n # TODO: cache this\n r = ResourceHierarchy.joins(:child_resource).where(\"resources.resource_type = ? AND resource_hierarchies.resource_id = ?\", type, self.id)\n return r.length\n end", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def wordCount\n count = 0\n\n if (@word.to_s != '')\n count += 1\n end\n\n if @children.size\n @children.each do |key, val|\n count += val.wordCount\n end\n end\n\n count\n end", "def total_count\n object.nodes.size\n end", "def descendant_count(*args)\n descendant_rels(*args).size\n end", "def num_documents_include_tree_children\n num_documents_include_tree_children_rec( self )\n end", "def subtree_count(*args)\n subtree_rels(*args).size\n end", "def size\n count = 0\n visit_nodes do\n count += 1\n end\n count\n end", "def children_size\n size = locations.size\n locations.each{|location|\n locations = location.locations\n if locations.present?\n size += location.children_size\n end\n }\n return size\n end", "def size(children: true)\n c_size = 0\n request = $postgres.exec_prepared('wsfile_size', [self.id])\n c_size += request[0].map{|k,v| v.to_i }.inject(:+)\n c_size += self.children.map{|child| child.size}.inject(:+) || 0 if children\n c_size\n end", "def size\n return @tree.size\n end", "def children_count(id)\n wait_for_ajax do\n page.driver.browser.execute_script(<<-JS)\n return Ext.ComponentQuery.query('treepanel')[0].getStore().getNodeById('#{id}').childNodes.length;\n JS\n end\n end", "def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end", "def leaf_count\n @leaf_count\n end", "def size\n children_size + my_size\n end", "def children\n node.children\n end", "def rowCount(parent)\n if info = info_from_index(parent)\n info.children.size\n else 0\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 parent_count(*args)\n parent_rels(*args).size\n end", "def get_number_of_root_elements(elements)\n num = 0\n parent_field = @db_fields[:parent]\n elements.each do |e|\n num += 1 if e.send(parent_field) == 0\n end\n num\n end", "def count\n count = 0\n\n each do |node|\n count += 1\n end\n\n return count\n end", "def number_of_parents\n if self.is_parent\n return 0\n else\n return 1 + self.parent.number_of_parents\n end\n end", "def getPanelRecordsCount(records)\n\tsize = 0\n\trecords.each do |rec|\n\t\tsize += 1\n\t\tsize += rec[:children].size if(!rec[:children].nil?)\n\tend\n\n\treturn size\nend", "def num_child_jobs\n @gapi.statistics.num_child_jobs || 0\n end", "def max_children_count(k)\n check_val(k)\n @stats[:nodes_with_max_children] = PriorityQueue.new(k)\n get_max_children(@xmldoc,k)\n puts \"the text of the #{k} most branching nodes, with its number of children:\"\n @stats[:nodes_with_max_children].each() {|count,ele| puts \"#{count}\\t#{ele}\"}\n end", "def render_child_type_count(node = @tree.root)\n @stack.push(node)\n result_hash = {}\n tag_count = 0\n content_count = 0\n until @stack.empty?\n current_node = @stack.pop\n current_node.children.each do |child|\n @stack.push(child)\n child.data.each do |key, value|\n if result_hash[key].nil?\n result_hash[key] = 1\n else\n result_hash[key] += 1\n end\n end\n\n end\n end\n result_hash[:total_nodes] = render_child_count(node)\n result_hash.delete(:type)\n result_hash\n end", "def children\n children_tree.values\n end", "def children\n children_tree.values\n end", "def num_clusters_include_tree_children\n num_clusters_include_tree_children_rec( self )\n end", "def size\n @errors.size + @children.each_value.reduce(0) do |total, child|\n total + child.size\n end\n end", "def children\n\t\treturn children_of @current_node\n\tend", "def getCount\n return @nodeValues.size\n end", "def num_documents_include_tree_children_rec(parent_cluster) \n num_total = parent_cluster.num_documents\n\n parent_cluster.tree_children.each do |child|\n num_total += child.num_documents_include_tree_children\n end\n\n return num_total\n end", "def children\n @children\n end", "def children\n @children\n end", "def count_children(color:)\n if color == \"no other\"\n 0\n else\n children_counts = BAG_MAP_2[color].map { |content_arry| content_arry.first }\n children = children_counts.inject(0) { |sum,x| sum + x }\n\n ary = BAG_MAP_2[color]\n\n ary.each do |arry_content|\n num = arry_content.first\n col = arry_content.last\n\n children += num * count_children(color: col)\n end\n\n children\n end\nend", "def children\n @children ||= []\n end", "def number_of_living_descendants\n count_descendants_matching { |d| d.alive? }\nend", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def _children\n @children\n end", "def node_count\n @nodes.length - 1\n end", "def total_bags_inside\n children.size + children.map(&:total_bags_inside).sum\n end", "def depth\n children_depth + my_depth\n end", "def depth\n crumbs.size\n end", "def size\n all_nodes.length\n end", "def total\n object.nodes.size\n end", "def _children\n @children\n end", "def children\n _children\n end", "def _children\n expected_amount == 1 ? 'child' : 'children'\n end", "def children_get()\n @children\n end", "def count_all\n # map all nodes into enumerable\n # then add them all together (reduce :+)\n self.map { |node| node.count }.reduce(:+)\n end", "def get_children\n return @children\n end", "def tag_counts\n self.parent.tag_counts\n end", "def fulltree_count(*args)\n fulltree_rels(*args).size\n end", "def length\n current_node = @head\n count = 1\n until current_node.next_node.nil?\n current_node = current_node.next_node\n count += 1\n end\n count\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 children\n attributes.fetch(:children)\n end", "def length\n ArelExtensions::Nodes::Length.new [self]\n end", "def children\n unless defined? @children\n @children = Array.new\n end\n return @children\n end", "def size\n @nodes.length\n end", "def size\n @nodes.length\n end", "def children\n []\n end", "def children\n kids = []\n each_child { |kid| kids << kid }\n kids\n end", "def sibling_count(*args)\n sibling_rels(*args).size\n end", "def get_children\n @children\n end", "def count()\n return @child_path_parts.count\n end", "def compute_child_mod_count\n target_child_count = case self.grid_type\n when FULL\n 1\n when HALVES, LEFT, RIGHT\n 2\n when THIRDS\n 3\n else\n 0\n end\n (target_child_count - self.columns.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" ]
[ "0.79330945", "0.7913664", "0.78799975", "0.7837773", "0.77757674", "0.7772748", "0.76224947", "0.7556294", "0.7451842", "0.73071563", "0.72903603", "0.72588015", "0.7095993", "0.69766325", "0.69315207", "0.6885031", "0.68847525", "0.687455", "0.6806833", "0.6794341", "0.6794193", "0.6776299", "0.6743261", "0.6726119", "0.6670889", "0.6599517", "0.6552928", "0.65500814", "0.65288544", "0.65184665", "0.64886117", "0.6469372", "0.6445015", "0.6443137", "0.6405083", "0.63398546", "0.63205737", "0.62741536", "0.6227339", "0.6223888", "0.6189063", "0.61864966", "0.6158343", "0.615771", "0.61375535", "0.6129501", "0.61247057", "0.6113139", "0.610707", "0.61008394", "0.60989296", "0.6097941", "0.60908556", "0.60846364", "0.6081415", "0.60532516", "0.60388464", "0.60388464", "0.60356045", "0.6029132", "0.60288197", "0.59997714", "0.59979576", "0.5989199", "0.5989199", "0.5988917", "0.59815526", "0.59729916", "0.59560317", "0.59560317", "0.59560317", "0.59560317", "0.594064", "0.5936103", "0.5928432", "0.5922945", "0.5920144", "0.5916846", "0.59132725", "0.5913126", "0.59100956", "0.59096986", "0.58970314", "0.5890109", "0.5882325", "0.58754647", "0.586222", "0.5861291", "0.5854039", "0.5853233", "0.585231", "0.58325136", "0.58141726", "0.58141726", "0.58057356", "0.58030313", "0.579859", "0.5792816", "0.57919174", "0.5775923", "0.5774004" ]
0.0
-1
Recalculate the left/right values of all nodes in this record's tree. Can be used to convert an ordinary tree into a nested set.
def renumber_full_tree indexes = [] n = 1 transaction do for r in roots # because we may have virtual roots n = r.calc_numbers(n, indexes) end for i in indexes base_set_class.update_all("#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}", "#{self.class.primary_key} = #{i[:id]}") end end ## reload? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renumber_full_tree\n indexes = []\n n = 1\n transaction do\n for r in roots # because we may have virtual roots\n n = 1 + r.calc_numbers(n, indexes)\n end\n for i in indexes\n base_set_class.update_all(\"#{left_col_name} = #{i[:lft]}, #{right_col_name} = #{i[:rgt]}\", \"#{self.class.primary_key} = #{i[:id]}\")\n end\n end\n ## reload?\n end", "def rebuild!\n # Don't rebuild a valid tree.\n return true if valid?\n \n scope = lambda{ |node| {} }\n if acts_as_nested_set_options[:scope]\n scope = lambda { |node|\n scope_column_names.inject({}) { |hash, column_name|\n hash[column_name] = node.send(column_name.to_sym)\n hash\n }\n }\n end\n indices = {}\n \n set_left_and_rights = lambda do |node|\n # set left\n node.send(:\"#{left_column_name}=\", (indices[scope.call(node)] += 1))\n # find\n all(scope.call(node).merge(parent_column_name => node.id)).each { |n| set_left_and_rights.call(n) }\n # set right\n node.send(:\"#{right_column_name}=\", (indices[scope.call(node)] += 1))\n node.save! \n end\n \n # Find root node(s)\n root_nodes = all(parent_column_name => nil, :order => \"#{left_column_name}, #{right_column_name}, id\").each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n set_left_and_rights.call(root_node)\n end\n end", "def prune_from_tree\n return if self.right.nil? || self.left.nil?\n diff = self.right - self.left + 1\n\n #TODO: implemente :dependent option\n # delete_method = acts_as_nested_set_options[:dependent] == :destroy ?\n # :destroy_all : :delete_all\n\n #TODO: implement prune method\n # self.class.base_class.transaction do\n # nested_set_scope.send(delete_method,\n # [\"#{quoted_left_column_name} > ? AND #{quoted_right_column_name} < ?\",\n # left, right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_left_column_name} = (#{quoted_left_column_name} - ?)\", diff],\n # [\"#{quoted_left_column_name} >= ?\", right]\n # )\n # nested_set_scope.update_all(\n # [\"#{quoted_right_column_name} = (#{quoted_right_column_name} - ?)\", diff],\n # [\"#{quoted_right_column_name} >= ?\", right]\n # )\n # end\n end", "def reload_nested_set\n doc = self.class.find(_id)\n self.class.associations.each { |name, assoc| send(name).reset if respond_to?(name) }\n [ left_column_name, right_column_name, parent_column_name ].each do |column|\n send :\"#{column}=\", doc.send(column.to_sym)\n end\n self\n end", "def set_default_left_and_right\n maxright = dataset.nested.max(self.class.qualified_right_column).to_i || 0\n # adds the new node to the right of all existing nodes\n self.left = maxright + 1\n self.right = maxright + 2\n end", "def set_default_left_and_right\n maxright = nested_set_scope.remove_order_by.max(right_field_name) || 0\n self[left_field_name] = maxright + 1\n self[right_field_name] = maxright + 2\n self[:depth] = 0\n end", "def set_default_left_and_right\n unless @skip_nested_set_callbacks\n maxright = base_class.first(scoped(:order => \"#{right_column_name} DESC\")).try(right_column_name) || 0\n # adds the new node to the right of all existing nodes\n self[left_column_name] = maxright + 1\n self[right_column_name] = maxright + 2\n end\n end", "def rebuild!\n\n scope = lambda{}\n # TODO: add scope stuff\n \n # Don't rebuild a valid tree.\n return true if valid?\n indices = {}\n \n move_to_child_of_lambda = lambda do |parent_node|\n # Set left\n parent_node[nested_set_options[:left_column]] = indices[scope.call(parent_node)] += 1\n # Gather child noodes of parend_node and iterate by children\n parent_node.children.order(:id).all.each do |child_node|\n move_to_child_of_lambda.call(child_node)\n end\n # Set right\n parent_node[nested_set_options[:right_column]] = indices[scope.call(parent_node)] += 1\n parent_node.save\n end\n\n # Gatcher root nodes and iterate by them\n self.roots.all.each do |root_node|\n # setup index for this scope\n indices[scope.call(root_node)] ||= 0\n move_to_child_of_lambda.call(root_node)\n end\n end", "def left_rotate( node=@tree )\n node.left = node.right\n node.right = node.right.right\n node.left.right = nil\n node.value, node.left.value = node.left.value, node.value\n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n left.parent = self unless left.parent\n @right = ruby_block.call(@right)\n right.parent = self unless right.parent\n end", "def double_left_rotate( node=@tree )\n node.left = node.right.left\n node.right.left = nil\n node.value, node.left.value = node.left.value, node.value\n end", "def rebalance\n order = self.level_order\n return build_tree(order)\n end", "def rebalance\n @root = build_tree(self.level_order_traversal) if !self.balanced?\n end", "def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n @left.parent = self unless @left.parent\n @right = ruby_block.call(@right)\n @right.parent = self unless @right.parent\n end", "def reload_nested_set\n reload(:select => \"#{quoted_left_column_name}, \" +\n \"#{quoted_right_column_name}, #{quoted_parent_column_name}\")\n end", "def recompute_recursive_subsets\n @recursive_subsets = subsets.inject(ValueSet.new) do |set, child|\n set.merge(child.recursive_subsets)\n end\n if parent\n parent.recompute_recursive_subsets\n end\n end", "def shift_values(root)\n root.value = get_next_value(root.right)\n root.right = right_subtree_without_next_value(root.right)\n root\n end", "def normalise!(tree)\n tree.each.with_index do |node, i|\n if node.is_a?(Array)\n if node.first == :loop && tree[i+1]\n key = tree[i+1][0]\n if key == :block\n tree[i+1][0] = :lblock\n elsif key == :query # wrap queries like `c.each(&:destroy)` \n tree[i+1] = [:lblock, tree[i+1]]\n end\n end\n tree[i] = normalise!(node)\n end\n end\n tree\n end", "def reduceTree( rootNode=@root )\n return if rootNode.nil?\n return if (rootNode.leftChild.nil? && rootNode.rightChild.nil? )\n reduceTree( rootNode.leftChild ) \n reduceTree( rootNode.rightChild )\n\n # If both children are numeric values, we can just perform the proper\n # operation on the children values and then replace the current node's\n # data with the result\n if( rootNode.leftChild.isNumeric? && rootNode.rightChild.isNumeric? )\n # This is a little verbose\n case rootNode.data\n when '+'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f + rootNode.rightChild.data.to_f).to_s )\n when '-'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f - rootNode.rightChild.data.to_f).to_s )\n when '*'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f * rootNode.rightChild.data.to_f).to_s )\n when '/'\n rootNode.data = ( Float( rootNode.leftChild.data.to_f / rootNode.rightChild.data.to_f).to_s )\n end\n rootNode.leftChild = nil\n rootNode.rightChild = nil\n end\n\n end", "def reload_nested_set\n reload(\n :select => \"#{quoted_left_column_full_name}, #{quoted_right_column_full_name}, #{quoted_parent_column_full_name}\",\n :lock => true\n )\n end", "def clone\n new_set = TreeSet.new\n # Create new nodes in the same order as self's\n if root\n root.root_traverse do |node|\n new_set << node.value\n end\n end\n new_set\n end", "def full_set(options = {})\n return [self] if new_record? or self[nested_set_right]-self[nested_set_left] == 1\n [self] + all_children(options)\n end", "def convert_binary_tree_to_mirror(root)\n return if !root\n temp_node = Node.new()\n # recursively call the method on both left and right subtrees\n convert_binary_tree_to_mirror(root.left_child)\n convert_binary_tree_to_mirror(root.right_child)\n\n # swap the left and right subtrees\n temp_node = root.left_child\n root.left_child = root.right_child\n root.right_child = temp_node\n\n return root\nend", "def clear_node\n self.value = nil\n self.left_child = nil\n self.right_child = nil\n end", "def rotate_left\n root = @right\n @right = root.left\n root.left = self\n root.left.update_height\n root\n end", "def invert_tree root\n temp_pointer = root.left\n root.left = root.right\n root.right = temp_pointer\n\n invert_tree(root.left) if root.left\n invert_tree(root.right) if root.right\n root\nend", "def roots\n nested_set_class.find_with_nested_set_scope(:all, :conditions => \"(#{nested_set_parent} IS NULL)\", :order => \"#{nested_set_left}\")\n end", "def assign_tree(tree)\n nodes = tree.sort_by { |e| e['weight'].to_i }\n new_collection_ids = nodes.map { |e| e['id'] }\n if ordered_subset?(new_collection_ids)\n removed_collection_ids = collection_member_ids - new_collection_ids\n self.member_ids = (member_ids.map(&:to_s) - removed_collection_ids) unless removed_collection_ids.empty?\n else\n self.member_ids = new_collection_ids + noncollection_member_ids\n end\n nodes.each do |node|\n b = ActiveFedora::Base.find(node['id'])\n b.assign_tree node['children']\n b.save! #TODO We could move this save into an after_save hook.\n end\n end", "def before_create\n maxright = self.class.maximum(acts_as_nested_set_options[:right_column], :conditions => acts_as_nested_set_options[:scope]) || 0\n # adds the new node to the right of all existing nodes\n self[acts_as_nested_set_options[:left_column]] = maxright+1\n self[acts_as_nested_set_options[:right_column]] = maxright+2\n end", "def recalculate!(tree,order,memo=nil,&block)\n if tree\n\n case order\n when :postorder\n \n arr = tree.children.map{ |t| recalculate!(t,order,memo,&block) }\n result = block.call(arr.push tree.data)\n tree.data = result\n\n\n when :preorder\n \n tree.data = yield tree, memo\n memo = tree.data\n\n tree.children.each do |t|\n recalculate!(t,order,memo,&block)\n end\n\n when :inorder\n raise ArgumentError unless self.tree.is_a? BinaryTree\n recalculate!(tree.left,order,memo,&block)\n\n tree.data = yield tree, memo\n memo = tree.data\n\n recalculate!(tree.right,order,memo,&block)\n\n end\n end\n end", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.left.replace_expressions!(node2rep)\n res.merge!(self.right.replace_expressions!(node2rep))\n # Is there a replacement to do on the left?\n rep = node2rep[self.left]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.left\n # node.set_parent!(nil)\n self.set_left!(rep)\n # And register the replacement.\n res[node] = rep\n end\n # Is there a replacement to do on the right?\n rep = node2rep[self.right]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.right\n # node.set_parent!(nil)\n self.set_right!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.left.replace_expressions!(node2rep)\n res.merge!(self.right.replace_expressions!(node2rep))\n # Is there a replacement to do on the left?\n rep = node2rep[self.left]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.left\n # node.set_parent!(nil)\n self.set_left!(rep)\n # And register the replacement.\n res[node] = rep\n end\n # Is there a replacement to do on the right?\n rep = node2rep[self.right]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.right\n # node.set_parent!(nil)\n self.set_right!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def right_rotate( node=@tree )\n node.right = node.left\n node.left = node.left.left\n node.right.left = nil\n node.value, node.right.value = node.right.value, node.value\n end", "def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n \n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n base_class.delete_all scoped(left_column_name => { '$gt' => left }, right_column_name => { '$lt' => right })\n end\n \n # update lefts and rights for remaining nodes\n diff = right - left + 1\n base_class.all(scoped(left_column_name => { '$gt' => right })).each do |node|\n node.update_attributes left_column_name => node.left - diff\n end\n base_class.all(scoped(right_column_name => { '$gt' => right })).each do |node|\n node.update_attributes right_column_name => node.right - diff\n end\n \n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end", "def clear_nodes\n\t\t\t@tree = []\n\t\t\t@node_stack = [ @tree ]\n\t\tend", "def mirror_tree_support(node)\n return if node.nil?\n tmp = node.left\n node.left = node.right\n node.right = tmp\n mirror_tree_support(node.left)\n mirror_tree_support(node.right)\n end", "def destroy_descendants # already protected by a transaction within #destroy\n return if self[right_col_name].nil? || self[left_col_name].nil? || self.skip_before_destroy\n reloaded = self.reload rescue nil # in case a concurrent move has altered the indexes - rescue if non-existent\n return unless reloaded\n dif = self[right_col_name] - self[left_col_name] + 1\n if acts_as_nested_set_options[:dependent] == :delete_all\n base_set_class.delete_all( \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\" ) \n else \n set = base_set_class.find(:all, :conditions => \"#{scope_condition} AND (#{prefixed_left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\", :order => \"#{prefixed_right_col_name} DESC\") \n set.each { |child| child.skip_before_destroy = true; remove_descendant(child) } \n end\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \\\n ELSE #{right_col_name} END\",\n scope_condition)\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 nested_set_recurse(&block)\n self.each do |x| \n x.nested_set_recurse(self, &block)\n end\n end", "def rebalance_for_left_delete\n\t\t\trebalance = false\n\t\t\t[if black?\n\t\t\t\tif @right.black?\n\t\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t\t# make whole sub-tree 1 level lower and ask rebalance\n\t\t\t\t\t\trebalance = true\n\t\t\t\t\t\twith_right(@right.with_color(:red))\n\t\t\t\t\telse\n\t\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\t\tbalanced_rotate_left\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# flip this sub-tree into another type of 3-children node\n\t\t\t\t\tret = rotate_left\n\t\t\t\t\t# try to rebalance in sub-tree\n\t\t\t\t\tleft, rebalance = ret.left.rebalance_for_left_delete\n\t\t\t\t\traise 'should not happen' if rebalance\n\t\t\t\t\tret.with_left(left)\n\t\t\t\tend\n\t\t\telse # red\n\t\t\t\tif @right.children_color?(:black)\n\t\t\t\t\t# make right sub-tree 1 level lower\n\t\t\t\t\twith_right(@right.with_color(color)).with_color(@right.color)\n\t\t\t\telse\n\t\t\t\t\t# move 1 black from the right to the left by single/double rotation\n\t\t\t\t\tbalanced_rotate_left\n\t\t\t\tend\n\t\t\tend, rebalance]\n\t\tend", "def invert_tree(root)\n return nil unless root\n\n left_inverted = invert_tree(root.left)\n right_inverted = invert_tree(root.right)\n\n root.left = right_inverted\n root.right = left_inverted\n\n root\nend", "def original_tree\n\n @root_expression && @root_expression.original_tree\n end", "def tree\n h.updated_tree || h.original_tree\n end", "def invert_tree(root)\n # recursive base case\n return nil if root.nil?\n\n # perform operation (switching left and right children) on root\n root.left, root.right = root.right, root.left\n\n # recursively perform operation on children\n invert_tree(root.left)\n invert_tree(root.right)\n\n root\nend", "def recalculate_hash_at(node)\n return node._hash = node.value if node.value\n recalculate_hash_at(node.left) if node.left\n recalculate_hash_at(node.right) if node.right\n node._hash = self.class.hash_children(*node_subhashes(node))\n end", "def left=(value)\n self[self.nested_set_options[:left_column]] = value\n end", "def nodes\n left_nodes + [self] + right_nodes\n end", "def all_right\n @right.empty? ? [self] : @right.flat_map { |r| r.all_right }.uniq\n end", "def invert_tree(root)\n return root unless root\n\n temp = root.left\n root.left = invert_tree(root.right)\n root.right = invert_tree(temp)\n\n root\nend", "def update_children(node, new_node)\n\t\tleft \t= node.left\n\t\tright = node.right\n\t\tleft.parent = new_node unless left.nil? \n\t\tright.parent = new_node unless right.nil?\n\tend", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def sum_of_left_leaves(root)\nend", "def left=(value)\n @left = value\n end", "def left=(value)\n @left = value\n end", "def double_right_rotate( node=@tree )\n node.right = node.left.right\n node.left.right = nil\n node.value, node.right.value = node.right.value, node.value\n end", "def invert_tree(root)\n return if root.nil?\n root.left, root.right = root.right, root.left\n invert_tree(root.left)\n invert_tree(root.right)\n\n root\nend", "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 convert_to_mirror(node)\n return if node.nil?\n\n # We will do a post-order traversal of the binary tree.\n convert_to_mirror(node.left) unless node.left.nil?\n convert_to_mirror(node.right) unless node.right.nil?\n\n # Let's swap the left and right nodes at current level.\n temp = node.left\n node.left = node.right\n node.right = temp\nend", "def each_node(&block)\n block.call(@value)\n @left.each_node(&block) if @left\n @right.each_node(&block) if @right\n end", "def set_left_right # already protected by a transaction within #create\n maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0\n self[left_col_name] = maxright+1\n self[right_col_name] = maxright+2\n end", "def reset\n @left_generator.reset\n @right_generator.reset\n\n nil\n end", "def roots\n base_set_class.find(:all, :conditions => \"#{scope_condition} AND (#{parent_col_name} IS NULL OR #{parent_col_name} = 0)\", :order => \"#{left_col_name}\")\n end", "def invert_tree(root)\n return nil if root.nil?\n\n invert_tree(root.left)\n invert_tree(root.right)\n\n temp = root.left\n root.left = root.right\n root.right = temp\n\n root\nend", "def rebalance!\n # Short-circut if already balanced.\n return @root if balanced?\n\n @root = build_tree(inorder)\n end", "def convert_tree(tree)\n return nil,nil if tree.nil?\n left_list_head,left_list_tail = convert_tree(tree.left) \n right_list_head,right_list_tail = convert_tree(tree.right)\n current_head, current_tail = tree,tree\n if left_list_tail\n current_head = left_list_head\n tree.left = left_list_tail\n left_list_tail.right = tree\n end\n if right_list_head\n current_tail = right_list_tail\n tree.right = right_list_head\n right_list_head.left = tree\n end\n [current_head,current_tail]\nend", "def prune\n # First: prune all children.\n self.each { |_, n| n.prune }\n # Then delete all nil leaf children.\n @succ.clone.each do |key, n|\n delete key if n.val == nil && n.leaf?\n end\n end", "def convert_to_ints\n @tree.each_index do |vert_pos|\n @tree[vert_pos].each_index do |horiz_pos|\n @tree[vert_pos][horiz_pos] = @tree[vert_pos][horiz_pos].to_i\n end\n end\n end", "def each\n unless left.nil?\n unless left_number.left.nil? then yield left_number.left.data end\n yield left_number.data\n unless left_number.right.nil? then yield left_number.right.data end\n end\n yield number\n unless right.nil?\n unless right_number.left.nil? then yield right_number.left.data end\n yield right_number.data\n unless right_number.right.nil? then yield right_number.right.data end\n end\n end", "def invert_binary_tree(tree)\n return nil if tree.nil?\n\n tmp = tree.left\n tree.left = tree.right\n tree.right = tmp\n\n tree.left = invert_binary_tree(tree.left)\n tree.right = invert_binary_tree(tree.right)\nend", "def destroy_descendants\n return if right.nil? || left.nil? || skip_before_destroy\n\n if acts_as_nested_set_options[:dependent] == :destroy\n descendants.each do |model|\n model.skip_before_destroy = true\n model.destroy\n end\n else\n c = nested_set_scope.where(left_field_name.to_sym.gt => left, right_field_name.to_sym.lt => right)\n scope_class.where(c.selector).delete_all\n end\n\n # update lefts and rights for remaining nodes\n diff = right - left + 1\n\n # scope_class.with(:safe => true).where(\n scope_class.where(\n nested_set_scope.where(left_field_name.to_sym.gt => right).selector\n ).inc(left_field_name => -diff)\n\n # scope_class.with(:safe => true).where(\n scope_class.where(\n nested_set_scope.where(right_field_name.to_sym.gt => right).selector\n ).inc(right_field_name => -diff)\n\n # Don't allow multiple calls to destroy to corrupt the set\n self.skip_before_destroy = true\n end", "def normalize\n return if @children.nil?\n old = nil\n children = @children.to_a.dup\n children.each do |child|\n if !old.nil? && old.nodeType == TEXT_NODE &&\n child.nodeType == TEXT_NODE\n old.appendData(child.nodeValue)\n self.removeChild(child)\n else\n if child.nodeType == ELEMENT_NODE\n child.normalize\n end\n old = child\n end\n end\n end", "def initialize\n @left = @right = self\n @columns = {} # column_id object => Column\n @rows = {} # row_id object => Node\n end", "def swap_children\r\n tempChild = leftChild\r\n self.leftChild= rightChild\r\n self.rightChild= tempChild\r\n end", "def map_nodes!(&ruby_block)\n @range = ruby_block.call(@range.first)..ruby_block.call(@range.last)\n @range.first.parent = self unless @range.first.parent\n @range.last.parent = self unless @range.last.parent\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end", "def before_destroy\n return if self[nested_set_right].nil? || self[nested_set_left].nil?\n diff = self[nested_set_right] - self[nested_set_left] + 1\n\n nested_set_class.transaction {\n nested_set_class.delete_all \"#{nested_set_scope} AND #{nested_set_left} > #{self[nested_set_left]} and #{nested_set_right} < #{self[nested_set_right]}\"\n nested_set_class.update_all \"#{nested_set_left} = (#{nested_set_left} - #{diff})\", \"#{nested_set_scope} AND #{nested_set_left} >= #{self[nested_set_right]}\"\n nested_set_class.update_all \"#{nested_set_right} = (#{nested_set_right} - #{diff} )\", \"#{nested_set_scope} AND #{nested_set_right} >= #{self[nested_set_right]}\"\n }\n end", "def clear\n @tree.clear\n return 0\n end", "def invert_tree(root)\n return nil if root == nil\n left = invert_tree(root.left);\n right = invert_tree(root.right);\n root.left = right;\n root.right = left;\n return root;\nend", "def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end", "def invert_tree_dfs_iter(root)\n stack = [root]\n while !stack.empty?\n node = stack.pop()\n next if !node\n node.left, node.right = node.right, node.left\n stack += [node.left, node.right]\n end\n\n root\nend", "def set_parents(node)\n\tif node == nil\n\t\treturn\n\tend\n\tif node.left\n\t\t@parents[node.left] = node\n\tend\t\n\tif node.right\n\t\t@parents[node.right] = node\n\tend\n\tset_parents(node.left)\n\tset_parents(node.right)\nend", "def calc_numbers(n, indexes) #:nodoc:\n my_lft = n\n # performance improvements (3X or more for tables with lots of columns) by using :select to load just id, lft and rgt\n ## i don't use the scope condition here, because it shouldn't be needed\n my_children = base_set_class.find(:all, :conditions => \"#{parent_col_name} = #{self.id}\",\n :order => left_col_name, :select => \"#{self.class.primary_key}, #{left_col_name}, #{right_col_name}\")\n if my_children.empty?\n my_rgt = (n += 1)\n else\n for c in (my_children)\n n = c.calc_numbers(n + 1, indexes)\n end\n my_rgt = (n += 1)\n end\n indexes << {:id => self.id, :lft => my_lft, :rgt => my_rgt} unless self[left_col_name] == my_lft && self[right_col_name] == my_rgt\n return n\n end", "def rotate_left\n\t\t\troot = @right\n\t\t\troot = root.with_left(with_right(root.left))\n\t\t\troot.with_left(root.left.with_color(root.color)).with_color(root.left.color)\n\t\tend", "def nodes_except_self_leftward\n LinkEnumerator.new :left, self\n end", "def renumber_all\n scopes = []\n # only call it once for each scope_condition (if the scope conditions are messed up, this will obviously cause problems)\n roots.each do |r|\n r.renumber_full_tree unless scopes.include?(r.scope_condition)\n scopes << r.scope_condition\n end\n end", "def merge_trees(t1, t2)\n return t2 if t1 == nil\n return t1 if t2 == nil\n value = t1.val += t2.val\n new = TreeNode.new(value)\n new.left = merge_trees(t1.left, t2.left)\n new.right = merge_trees(t1.right, t2.right)\n return new\nend", "def roots\n self.find(:all, :conditions => \"(#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:parent_column]} IS NULL)\", :order => \"#{acts_as_nested_set_options[:left_column]}\")\n end", "def left=(other)\n raise TypeError, 'Left must be a node or nil.' unless other.is_a?(Node) || other.nil?\n\n @left = other\n end", "def before_destroy\n return if self[acts_as_nested_set_options[:right_column]].nil? || self[acts_as_nested_set_options[:left_column]].nil?\n dif = self[acts_as_nested_set_options[:right_column]] - self[acts_as_nested_set_options[:left_column]] + 1\n\n self.class.transaction {\n self.class.delete_all( \"#{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]]}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:left_column]} = (#{acts_as_nested_set_options[:left_column]} - #{dif})\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:left_column]} >= #{self[acts_as_nested_set_options[:right_column]]}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:right_column]} = (#{acts_as_nested_set_options[:right_column]} - #{dif} )\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:right_column]} >= #{self[acts_as_nested_set_options[:right_column]]}\" )\n }\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 transform(tree); end", "def calc_of_parent_one(field_set)\n unless @@result_group[self.id].blank?\n @@result_group[self.id].map{|x| x.calc_of_parent_one(field_set)}\n sum_value = total_calc(@@result_group[self.id],field_set[0]) \n @@result_group[self.parent_id].map{|x| x.id == self.id && x[field_set[0]] = sum_value}\n end \n end", "def freshen_parent_and_child_indexes\n freshen_parent_and_child_indexes(0)\n end", "def tree\n @stack = @rpn.clone\n get_tree\n end", "def replace_expressions!(node2rep)\n # First recurse on the children.\n res = self.value.replace_expressions!\n # Is there a replacement to do on the value?\n rep = node2rep[self.value]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.value\n # node.set_parent!(nil)\n self.set_value!(rep)\n # And register the replacement.\n res[node] = rep\n end\n\n return res\n end", "def full_set(special=nil)\n return [self] if new_record? or self[acts_as_nested_set_options[:right_column]]-self[acts_as_nested_set_options[:left_column]] == 1\n# self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} BETWEEN #{self[acts_as_nested_set_options[:left_column]]} and #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n [self] + all_children(special)\n end", "def children_count\n return (self[nested_set_right] - self[nested_set_left] - 1) / 2\n end", "def nested_set_recurse(set, &block)\n block.call self, lambda{\n index = set.index(self) + 1\n while set[index].parent_id == self.id\n set[index].nested_set_recurse(set, &block)\n index += 1\n end\n }\n end", "def evaluate(parsed_tree)\n left_child = parsed_tree.left_child\n right_child = parsed_tree.right_child\n\n if left_child && right_child\n return evaluate(left_child).send(parsed_tree.get_root_value, evaluate(right_child))\n else\n return parsed_tree.get_root_value\n end\nend", "def move_node_changeset(node)\n {\n 'children_attribs' => [{\n 'id' => node.c[0].id,\n 'option_attribs' => { 'id' => node.c[0].option_id, 'name_translations' => {'en' => 'Animal'} },\n 'children_attribs' => 'NONE'\n }, {\n 'id' => node.c[1].id,\n 'option_attribs' => { 'id' => node.c[1].option_id, 'name_translations' => {'en' => 'Plant'} },\n 'children_attribs' => [\n {\n 'id' => node.c[1].c[0].id,\n 'option_attribs' => { 'id' => node.c[1].c[0].option_id, 'name_translations' => {'en' => 'Tulip'} },\n 'children_attribs' => 'NONE'\n },\n {\n 'id' => node.c[1].c[1].id,\n 'option_attribs' => { 'id' => node.c[1].c[1].option_id, 'name_translations' => {'en' => 'Oak'} },\n 'children_attribs' => 'NONE'\n },\n {\n 'id' => node.c[0].c[0].id,\n 'option_attribs' => { 'id' => node.c[0].c[0].option_id, 'name_translations' => {'en' => 'Cat'} },\n 'children_attribs' => 'NONE'\n },\n {\n 'id' => node.c[0].c[1].id,\n 'option_attribs' => { 'id' => node.c[0].c[1].option_id, 'name_translations' => {'en' => 'Dog'} },\n 'children_attribs' => 'NONE'\n }\n ]\n }]\n }\n end" ]
[ "0.72770286", "0.68205845", "0.6439447", "0.6390184", "0.6345537", "0.6257305", "0.6247141", "0.62443066", "0.59245634", "0.58968276", "0.5881247", "0.58579767", "0.5830209", "0.5822079", "0.574823", "0.57463944", "0.56827253", "0.56699955", "0.5663866", "0.5661947", "0.56296414", "0.5591761", "0.5583911", "0.55644584", "0.5524431", "0.5479886", "0.54575574", "0.5450876", "0.54305774", "0.54305613", "0.5406891", "0.5406891", "0.5402181", "0.54005826", "0.53836775", "0.5377141", "0.53652227", "0.53651583", "0.536334", "0.5356508", "0.5344157", "0.5338123", "0.5322301", "0.5312317", "0.5298173", "0.5292229", "0.528182", "0.52625436", "0.52469224", "0.52429813", "0.52377313", "0.52345794", "0.52283597", "0.522425", "0.522425", "0.52205044", "0.52048427", "0.5199725", "0.5198156", "0.5194841", "0.51855814", "0.51777464", "0.51696277", "0.51685804", "0.5168114", "0.51588213", "0.51549494", "0.5149052", "0.51320636", "0.5100088", "0.5097959", "0.5092812", "0.509254", "0.5091636", "0.507783", "0.5076876", "0.5074421", "0.5070676", "0.50663024", "0.50612473", "0.50587773", "0.5051754", "0.50476515", "0.504484", "0.5038942", "0.502394", "0.5014543", "0.5010351", "0.500439", "0.5003686", "0.5003673", "0.4998826", "0.499847", "0.4991884", "0.49894613", "0.49891165", "0.49809527", "0.49799466", "0.4978448", "0.49768326" ]
0.736635
0
Deprecated. Adds a child to this object in the tree. If this object hasn't been initialized, it gets set up as a root node. This method exists only for compatibility and will be removed in future versions.
def add_child(child) transaction do self.reload; child.reload # for compatibility with old version # the old version allows records with nil values for lft and rgt unless self[left_col_name] && self[right_col_name] if child[left_col_name] || child[right_col_name] raise ActiveRecord::ActiveRecordError, "If parent lft or rgt are nil, you can't add a child with non-nil lft or rgt" end base_set_class.update_all("#{left_col_name} = CASE \ WHEN id = #{self.id} \ THEN 1 \ WHEN id = #{child.id} \ THEN 3 \ ELSE #{left_col_name} END, \ #{right_col_name} = CASE \ WHEN id = #{self.id} \ THEN 2 \ WHEN id = #{child.id} \ THEN 4 \ ELSE #{right_col_name} END", scope_condition) self.reload; child.reload end unless child[left_col_name] && child[right_col_name] maxright = base_set_class.maximum(right_col_name, :conditions => scope_condition) || 0 base_set_class.update_all("#{left_col_name} = CASE \ WHEN id = #{child.id} \ THEN #{maxright + 1} \ ELSE #{left_col_name} END, \ #{right_col_name} = CASE \ WHEN id = #{child.id} \ THEN #{maxright + 2} \ ELSE #{right_col_name} END", scope_condition) child.reload end child.move_to_child_of(self) # self.reload ## even though move_to calls target.reload, at least one object in the tests was not reloading (near the end of test_common_usage) end # self.reload # child.reload # # if child.root? # raise ActiveRecord::ActiveRecordError, "Adding sub-tree isn\'t currently supported" # else # if ( (self[left_col_name] == nil) || (self[right_col_name] == nil) ) # # Looks like we're now the root node! Woo # self[left_col_name] = 1 # self[right_col_name] = 4 # # # What do to do about validation? # return nil unless self.save # # child[parent_col_name] = self.id # child[left_col_name] = 2 # child[right_col_name]= 3 # return child.save # else # # OK, we need to add and shift everything else to the right # child[parent_col_name] = self.id # right_bound = self[right_col_name] # child[left_col_name] = right_bound # child[right_col_name] = right_bound + 1 # self[right_col_name] += 2 # self.class.transaction { # self.class.update_all( "#{left_col_name} = (#{left_col_name} + 2)", "#{scope_condition} AND #{left_col_name} >= #{right_bound}" ) # self.class.update_all( "#{right_col_name} = (#{right_col_name} + 2)", "#{scope_condition} AND #{right_col_name} >= #{right_bound}" ) # self.save # child.save # } # end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_child child\n @children << child\n self\n end", "def add_child(root, child)\n raise NotImplementedError\n end", "def add_child child\n @children << child\n end", "def add_child(child)\n if self.root?\n child.root_node = self\n else\n child.root_node = self.root_node\n end\n\n child.parent = self\n children << child\n end", "def add_child(child)\n n = root? ? @nodes : @root.nodes\n n << child\n @children << child\n child\n end", "def add_child(child)\n @children << child\n end", "def add_child(child)\n @children << child\n child.parent = self\n end", "def add_child(child)\n @children.push(child)\n end", "def add_child(node)\n node.build\n nodes << node\n end", "def add_child(child_node)\n child_node.parent = self\n end", "def add_child(child_node)\n child_node.parent = self\n end", "def child_add(child)\n @children.push(child)\n end", "def add_child(child)\n children << child\n end", "def add_child(child)\n children << child\n end", "def add_child(child_node)\n child_node.parent = self \n end", "def add_child(child)\n \t\t@children << child\n \tend", "def add_child(new_child)\n if [email protected]?(new_child)\n new_child.parent = self\n end\n \n end", "def add_child(node) \n @children[node.node_name]=node\n node.parent = self\n # Trick stolen from OpenStruct\n meta = class << self; self; end\n meta.send(:define_method, node.node_name.to_s.to_sym) {@children[node.node_name]}\n end", "def add_child(child_node)\n child_node.parent = self\n @children << child_node unless @children.include?(child_node)\n end", "def add_child(node)\n unless node.respond_to?(:dependencies) && node.respond_to?(:run_list)\n raise Souffle::Exceptions::InvalidChild,\n \"Child must act as a Souffle::Node\"\n end\n unless @children.include? node\n node.parents << self\n @children.push(node)\n end\n end", "def add_child(child_node) \n child_node.parent = self \n end", "def add_child(aChild)\n children << aChild\n end", "def add_child(child_node)\n self.children[child_node.char] = child_node\n end", "def add(child)\n raise \"Child already added\" if @children_hash.has_key?(child.name)\n\n @children_hash[child.name] = child\n position = @children.size - @last_items_count\n @children.insert(position, child)\n child.parent = self\n return child\n\n end", "def add_child(new_child)\n linkto = nil\n if self.child\n linkto = self.child.last_sibling\n linkto.add_sibling(new_child)\n else\n link(:child, new_child)\n end\n new_child.link(:parent, self)\n end", "def add_child(value)\n @children.unshift(Tree(value))\n end", "def add(child); end", "def add_child(value)\n @children.unshift(Tree(value))\n end", "def append_child(child)\n append_to_siblings(children, child)\n child.parent = self\n end", "def add_child(child)\n child.parent = self\n end", "def add_child name\n @children << name\n end", "def add_child(child)\n # Add an existing subtree to the root node.\n @children << child\n child.parent = self\n #t0 = Time.now\n #propagate(child,:add)\n #puts \" Propagate Timer: #{Time.now - t0} s\"\n child\n end", "def <<(child_node)\n child_node.parent = self\n @children << child_node\n end", "def add_child(child)\n @children[child.name] = child\n child.namespace = self\n end", "def add_child(child)\n @children << child unless @children.include?(child)\n end", "def push(child)\n self.children << child\n end", "def <<(child)\n @children[child.name] = child\n child.parent = self\n child\n end", "def add_child(t)\n # System.out.println(\"add child \"+t.toStringTree()+\" \"+this.toStringTree());\n # System.out.println(\"existing children: \"+children);\n if ((t).nil?)\n return # do nothing upon addChild(null)\n end\n child_tree = t\n if (child_tree.is_nil)\n # t is an empty node possibly with children\n if (!(@children).nil? && (@children).equal?(child_tree.attr_children))\n raise RuntimeException.new(\"attempt to add child list to itself\")\n end\n # just add all of childTree's children to this\n if (!(child_tree.attr_children).nil?)\n if (!(@children).nil?)\n # must copy, this has children already\n n = child_tree.attr_children.size\n i = 0\n while i < n\n c = child_tree.attr_children.get(i)\n @children.add(c)\n # handle double-link stuff for each child of nil root\n c.set_parent(self)\n c.set_child_index(@children.size - 1)\n i += 1\n end\n else\n # no children for this but t has children; just set pointer\n # call general freshener routine\n @children = child_tree.attr_children\n self.freshen_parent_and_child_indexes\n end\n end\n else\n # child is not nil (don't care about children)\n if ((@children).nil?)\n @children = create_children_list # create children list on demand\n end\n @children.add(t)\n child_tree.set_parent(self)\n child_tree.set_child_index(@children.size - 1)\n end\n # System.out.println(\"now children are: \"+children);\n end", "def add_child(node)\n node.added = Date.today if node.is_a? Entry\n super\n end", "def add_child(child_id, remove_other = false)\n perform_add_child(nil, child_id, remove_other)\n reload!\n end", "def <<(child)\n children << child\n end", "def <<(child)\n children << child\n end", "def <<(child)\n add(child)\n self\n end", "def addChildLink(parent, child)\n raise \"Brick node: #{parent} does not exist.\" unless @tree.has_key?(parent)\n @tree[parent]['children'].push(child)\n end", "def append_child(child)\n if node.leaf?\n raise Exceptions::ZipperError,\n \"cannot add child to leaf node\"\n end\n\n EditedCursor.new(child,\n Hole.new(node.children.reverse, path, []), self)\n end", "def add_child(key, child) \n raise \"Leaf nodes don't accept children (request was: #{key.inspect} => #{child.inspect})\"\n end", "def <<(child)\n @children ||= []\n @children << child\n end", "def prepend_child(child)\n CMark.node_append_child(@pointer, child.pointer)\n if res == 0 then raise NodeError, \"could not append child\" end\n end", "def just_add_child(node)\n return if @children.member?(node)\n @children << node\n node.parent = self\n update_boxes \n end", "def <<(child)\n # TODO: check if child.is_a?(::Sass::Tree::Node) and raise some error, if not\n @tree << child\n self\n end", "def addkid(child, before = false)\n if before\n @children.unshift child\n else\n @children.push child\n end\n self\n end", "def add_child(component)\n @children.push(component)\n component.parent = self\n end", "def prepend_child(child)\n if node.leaf?\n raise Exceptions::ZipperError,\n \"cannot add child to leaf node\"\n end\n\n EditedCursor.new(child,\n Hole.new([], path, node.children), self)\n end", "def add(parent, child)\n raise InvalidChild::create(parent,child) unless self.is_valid_relation?(parent, child)\n parent.add_child(child)\n end", "def add(child)\n# child.set_parent(self)\n# @children << child\n @peer.add(child.peer)\n end", "def add_child_object(child, relation, info = nil)\n\t relation.add_relation(self, child, info)\n\tend", "def add_at(child, position)\n raise \"Child already added\" if @children_hash.has_key?(child.name)\n\n @children_hash[child.name] = child\n @children = @children.insert(position, child)\n child.parent = self\n return child\n\n end", "def add_child_object(child, type, info = nil) # :nodoc:\n if child.plan != plan\n root_object.synchronize_plan(child.root_object)\n unless type.kind_of?(Class)\n # If given a graph, we need to re-resolve it as #plan might\n # have changed\n type = relation_graphs.fetch(type.class)\n end\n end\n\n super\n end", "def add_new_child(name)\n\tnew_child = Child.new(name)\n\tnew_hash = {}\n\tnew_child.instance_variables.each {|item| new_hash[item.to_s.delete('@')] = new_child.instance_variable_get(item)}\n\tChildren[\"children\"].push(new_hash)\n\tupdate_file('children.yaml', Children)\nend", "def test_add_node_to_self_as_child\n root = Tree::TreeNode.new(\"root\")\n\n # Lets check the direct parentage scenario\n assert_raise(ArgumentError) {root << root}\n\n # And now a scenario where the node addition is done down the hierarchy\n # @todo This scenario is not yet fixed.\n child = Tree::TreeNode.new(\"child\")\n root << child << root\n # puts root # This will throw a stack trace\n end", "def child(node_type, attributes = {}, &block)\n raise 'Cannot add a new child without descending, when no parent is available' unless current\n current.add_child(node_type, attributes)\n end", "def add!(child)\n #should add defensive check here: is the child a Permission or a Command?\n self.children.add(child)\n end", "def add_child(parent, required, name)\n old_num_children = parent.children.length\n if required\n parent.must_have name\n else\n parent.may_have name\n end\n assert_equal old_num_children+1, parent.children.length\n # Here we presume that the child got added to the end of the children.\n child = parent.children.last\n assert_equal name.to_s, child.name\n assert_equal parent, child.parent\n assert child.children.empty?\n if required\n assert child.required? \n else\n assert ! child.required?\n end\n child\n end", "def add_child( child ) \n self.reload\n child.reload\n\n if child.root?\n raise ActiveRecord::ActiveRecordError, \"Adding sub-tree isn\\'t currently supported\"\n else\n if ( (self[acts_as_nested_set_options[:left_column]] == nil) || (self[acts_as_nested_set_options[:right_column]] == nil) )\n # Looks like we're now the root node! Woo\n self[acts_as_nested_set_options[:left_column]] = 1\n self[acts_as_nested_set_options[:right_column]] = 4\n \n # What do to do about validation?\n return nil unless self.save\n \n child[acts_as_nested_set_options[:parent_column]] = self.id\n child[acts_as_nested_set_options[:left_column]] = 2\n child[acts_as_nested_set_options[:right_column]]= 3\n return child.save\n else\n # OK, we need to add and shift everything else to the right\n child[acts_as_nested_set_options[:parent_column]] = self.id\n right_bound = self[acts_as_nested_set_options[:right_column]]\n child[acts_as_nested_set_options[:left_column]] = right_bound\n child[acts_as_nested_set_options[:right_column]] = right_bound + 1\n self[acts_as_nested_set_options[:right_column]] += 2\n self.class.transaction {\n self.class.update_all( \"#{acts_as_nested_set_options[:left_column]} = (#{acts_as_nested_set_options[:left_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:left_column]} >= #{right_bound}\" )\n self.class.update_all( \"#{acts_as_nested_set_options[:right_column]} = (#{acts_as_nested_set_options[:right_column]} + 2)\", \"#{acts_as_nested_set_options[:scope]} AND #{acts_as_nested_set_options[:right_column]} >= #{right_bound}\" )\n self.save\n child.save\n }\n end\n end \n end", "def insert_child\n insert_node('insert_child')\n end", "def add_child(b)\r\n return unless b\r\n a = @nodes[b.name]\r\n if !a\r\n @nodes[b.name] = b\r\n elsif a.kind_of?(VFSGroup)\r\n # Node is already present, merge children\r\n b.nodes.each_value do |n|\r\n a.add_child(n)\r\n end\r\n end\r\n end", "def prepend_child(child)\n CMark.node_prepend_child(@pointer, child.pointer)\n if res == 0 then raise NodeError, \"could not prepend child\" end\n end", "def add_child(component)\n \[email protected](component)\n \tputs \"Adding parent of #{component.class} to #{self.class}\"\n \tcomponent.parent = self\n end", "def add_child(le, cc=nil, &block)\n\t\t\tif valid_child(le)\n\t\t\t\t@children << le\n\t\t\t\tle.parent = self\n\t\t\telse\n\t\t\t\tif !block.nil?\n\t\t\t\t\tblock.call(le)\n\t\t\t\telsif cc.nil?\n\t\t\t\t $stderr << \"invalid child '#{le.tag}' for '#{self.tag}'\"\n\t\t\t \t\traise InternalError.new(\"invalid child '#{le.tag}' for '#{self.tag}'\")\n\t\t\t\telsif le.leftmost_token.nil? && le.rightmost_token.nil?\n\t\t\t\t $stderr << \"invalid child '#{le.tag}' for '#{self.tag}'\"\n\t\t\t \t\traise InternalError.new(\"invalid child '#{le.tag}' for '#{self.tag}'\")\n\t\t\t \telse\n\t\t\t \t if le.leftmost_token.nil?\n\t\t\t\t\t cc.eh.error UnexpectedLE.new(cc, le.rightmost_token, le, self)\n\t\t\t\t\telse\n cc.eh.error UnexpectedLE.new(cc, le.leftmost_token, le , self)\n end\n\t\t\t \tend\n\t\t\tend\n\t\tend", "def add(*arguments)\n if arguments[0].is_a?(Node)\n if arguments[1]\n fail ArgumentError, 'The second argument must not be specified, when passing a VObject Node'\n end\n arguments[0].parent = self\n new_node = arguments[0]\n elsif arguments[0].is_a?(String)\n new_node = @root.create(*arguments)\n else\n fail ArgumentError, 'The first argument must either be a Node or a string'\n end\n\n name = new_node.name\n if @children.key?(name)\n @children[name] << new_node\n else\n @children[name] = [new_node]\n end\n\n new_node\n end", "def prepend(child)\n raise \"Child already added\" if @children_hash.has_key?(child.name)\n\n @children_hash[child.name] = child\n @children = [child] + @children\n child.parent = self\n return child\n\n end", "def addNodeChild node, name\n\t\tif @root != nil\n\t\t if !node.leftChild\n\t\t \tnode.leftChild = Node.new name\n\t\t \treturn node.leftChild\n\t\t end\n\n\t\t if !node.rightChild\n\t\t \tnode.rightChild = Node.new name\n\t\t \treturn node.rightChild\n\t\t end\n\t\tend\n\tend", "def add_child(object)\n Vidalia::checkvar(object,Vidalia::Artifact,self.class.ancestors,\"object\")\n @children[object.name] = object\n object.set_parent(self)\n end", "def add_global_child(node)\n node.build\n global_nodes << node\n end", "def add(child, x_pos, y_pos, &block)\n gtk_instance.put(child.gtk_instance, x_pos, y_pos)\n\n super(child, false, &block)\n end", "def attach_child(name, obj)\n @members[name.to_s] = obj\n updated(name, obj)\n end", "def move_to_child_of(node)\n self.move_to node, :child\n end", "def move_to_child_of(node)\n self.move_to node, :child\n end", "def add_child(tag)\n @parent_node = @current_node\n @current_node = ParseTag.new(tag).tag\n @current_node.parent = @parent_node\n @parent_node.children.push @current_node\n # @current_node.depth = @parent_node.depth + 1\n end", "def add_child(child_or_children, at_index = -1)\n the_children = [*child_or_children]\n the_children.each do |the_child|\n raise ArgumentError.new('You tried to add self as child to self') if self == the_child\n the_child.detach_from_parent # first remove from any previous parent\n the_child.parent = self # assign new parent\n end\n children.insert(at_index, *the_children) # insert as children of new parent\n end", "def add_child(child)\n if child.is_a? Activity\n return child.set_parent(self)\n else \n puts \"Child not added: child must be an activity\"\n return false\n end\n end", "def add_child( name )\n if existing = children.find { |child| child.name == name } then\n return existing\n else\n return create_child( name )\n end\n end", "def add_child(child)\n if child.is_a? Activity\n if self.rep_parent.nil?\n return child.set_parent(self)\n else\n return child.set_parent(self.rep_parent)\n end\n else \n puts \"Child not added: child must be an activity\"\n return false\n end\n end", "def set_child(name, node)\n send :\"#{name}=\", node\n end", "def addChildren(child)\n\t\tfm = Family.new\n\t\tfm.person_id = child.id\n\t\tfm.parent_id = id\n\t\tif fm.save\n\t\t\tputs 'children was added successfully!'\n\t\telse \n\t\t\tputs 'children was added unsuccessfully!'\n\t\tend\n\tend", "def insert_child(child, new_node)\n return new_node if child.nil?\n child_tree = BinarySearchTree.new\n child_tree.root = child\n child_tree.insert(new_node)\n child\n end", "def child!(node_type, attributes = {})\n new_child = if current\n child(node_type, attributes)\n else\n Mahuta::Node.new(nil, nil, node_type, attributes)\n end\n @result ||= new_child\n pin! new_child\n new_child\n end", "def add_child(name)\n child = self.class.new(name, self)\n yield child if block_given?\n children << child\n child\n end", "def move_to_child_of(node)\n self.move_to(node, :child)\n end", "def add_child(page)\n page.parent = self\n\n (self.children ||= []) << page\n\n self.children.sort! { |a, b| (a.position || 999) <=> (b.position || 999) }\n\n page\n end", "def move_to_child_of(node)\n move_to node, :child\n end", "def move_to_child_of(node)\n move_to node, :child\n end", "def move_to_child_of(node)\n move_to node, :child\n end", "def add_child(node_or_tags); end", "def add_child(node_or_tags); end", "def add_child_org_unit(org_unit_id, child_org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/#{org_unit_id}/children/\"\n _post(path, child_org_unit_id)\nend", "def add_node( node )\n super( node )\n __add_node__( node )\n end", "def <<(child); end", "def add(name, &block)\n new_node = self.children.create!(:name => name.to_s)\n yield(new_node) if block_given?\n end" ]
[ "0.73784715", "0.73500526", "0.7319901", "0.7218514", "0.71272326", "0.7121041", "0.7118899", "0.70876366", "0.7050175", "0.7044651", "0.7044651", "0.70296794", "0.7014869", "0.7009511", "0.6986167", "0.6976314", "0.69511896", "0.6943807", "0.6875062", "0.6828618", "0.67996335", "0.67755514", "0.67661905", "0.67245287", "0.67221135", "0.67171544", "0.67169636", "0.6703789", "0.669442", "0.6682994", "0.6650531", "0.66338664", "0.66311294", "0.6609896", "0.6600432", "0.65879387", "0.6493767", "0.64673823", "0.6440454", "0.6432735", "0.6424017", "0.6424017", "0.6390077", "0.63855517", "0.63753146", "0.6370275", "0.6344773", "0.6314941", "0.6306512", "0.6283002", "0.62661654", "0.6225988", "0.6210558", "0.6202099", "0.61791396", "0.6154335", "0.61510336", "0.6149789", "0.60911924", "0.60723066", "0.6056674", "0.60177886", "0.59973645", "0.5990317", "0.59872395", "0.59788203", "0.5962937", "0.59613055", "0.5935181", "0.59351784", "0.5929146", "0.5918603", "0.59141505", "0.5898247", "0.58895934", "0.58553785", "0.5833867", "0.581004", "0.57929546", "0.5765798", "0.5747081", "0.5734135", "0.5733811", "0.57159394", "0.5710734", "0.5703907", "0.57004285", "0.56918514", "0.5686854", "0.56515974", "0.5627527", "0.5627527", "0.5627527", "0.5609952", "0.5609952", "0.5605965", "0.559837", "0.5588267", "0.557209" ]
0.5703409
87
used by the renumbering methods
def calc_numbers(n, indexes) #:nodoc: my_lft = n # performance improvements (3X or more for tables with lots of columns) by using :select to load just id, lft and rgt ## i don't use the scope condition here, because it shouldn't be needed my_children = base_set_class.find(:all, :conditions => "#{parent_col_name} = #{self.id}", :order => left_col_name, :select => "#{self.class.primary_key}, #{left_col_name}, #{right_col_name}") if my_children.empty? my_rgt = (n += 1) else for c in (my_children) n = c.calc_numbers(n + 1, indexes) end my_rgt = (n += 1) end indexes << {:id => self.id, :lft => my_lft, :rgt => my_rgt} unless self[left_col_name] == my_lft && self[right_col_name] == my_rgt return n end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numid=(_); end", "def renumber_lists\n lists.order(\"upper(name) asc\").each_with_index do |list, ndx|\n list.update(number: ndx+1)\n end\n end", "def resequence\n if @numbers\n (0...@list_size).each do |j|\n target = @item[j]\n\n source = \"%4d. %s\" % [j + 1, \"\"]\n\n k = 0\n while k < source.size\n # handle deletions that change the length of number\n if source[k] == \".\" && target[k] != \".\"\n source = source[0...k] + source[k+1..-1]\n end\n\n target[k] &= Ncurses::A_ATTRIBUTES\n target[k] |= source[k].ord\n k += 1\n end\n end\n end\n end", "def numid; end", "def renumber(map)\n raise \"player number #{@num} not found in renumbering hash\" unless map[@num]\n self.num = map[@num]\n @results.each{ |r| r.renumber(map) }\n self\n end", "def sequence_number; end", "def magic_numbers(count)\nend", "def re_number_segments\n segments = @grid.flatten.uniq.delete_if{ |number| number == 0 }\n segments.each_with_index do |number, i|\n change_segments(number, i + 1)\n end\n end", "def up_number\n unless number\n if Invoice.count == 0\n self.number = '001'\n else\n last_invoice = Invoice.order(:number).last\n self.number = last_invoice.number.succ\n end\n end\n end", "def reset_counter; end", "def inc_d\n end", "def increment_manuscript_rev_num\n if self.version && self.article\n num = self.manuscript_number \n rev = num.scan(/\\.R\\d+/)[0]\n if rev\n num.gsub!(/\\.R\\d+/,\"\")\n rev_num = rev.gsub(/\\.R/,\"\")\n rev_num = rev_num.to_i\n num+=\".R#{rev_num+1}\"\n else\n num = \"#{num}.R1\"\n end \n self.article.update_attribute(:manuscript_num,num)\n end\n end", "def diffObject(num)\n\tputs (\"#{num.object_id}\")\n\tnum=num+2\n\tputs (\"#{num.object_id}\")\n\treturn num\nend", "def id_number; end", "def __to_inc__\n self\n end", "def increment \n\t\t@counter = @counter + 1\n\tend", "def re_rank\n all_member.each(&:uncache_rank_key)\n next_rank = 0\n all_member.\n sort_by(&:rank_key).\n each do |member|\n member.ordinal = next_rank\n next_rank += 1\n end\n end", "def increment_sequence_number\n @sequence_number += 1\n @sequence_number = 0 if @sequence_number > 0xFFFFFFFF\n end", "def renumber_terms(doc)\n logger.info(\"Renumbering terms\")\n\n doc.xpath('//a:term', a: NS).each_with_index do |term, i|\n term['id'] = \"trm#{i}\"\n end\n end", "def last_ids(number); end", "def update_line_numbers!\n each_with_index do |lo, new_line_number|\n lo.line_number = new_line_number\n end\n end", "def fix_numerals\n hash = self.clone\n traverse hash\n hash\n end", "def seq_new_num(filelist)\n\tinitial_num = 0\n\tfor i in 0 .. filelist.size-1\n\t\tif i == 0\n\t\t\tinitial_num = get_last_seq_num(filelist[i]) \n\t\t\ti += 1\n\t\telse\t\n\t\t\tFile.open(filelist[i]) do |f|\n\t\t\t\tout = \"\"\n\t\t\t\tlast_sequence_name = \"\"\n\t\t\t\tinitial_num += 1\n\t\t\t\tf.each do |line|\n\t\t\t\t\tline.chomp!\n\t\t\t\t\tif line.chars.first == \"@\"\n\t\t\t\t\telse\n\t\t\t\t\t\tnum = line.split(\"seq.\")[1].to_i \n\t\t\t\t\t\tlast_sequence_name = num if last_sequence_name == \"\"\n\t\t\t\t\t\tif last_sequence_name != num\n\t\t\t\t\t\t\tinitial_num += 1\n\t\t\t\t\t\t\tlast_sequence_name = num\n\t\t\t\t\t\tend\n\t\t\t\t\t\tsam_fields = line.split(\"\\t\")\n\t\t\t\t\t\tsam_fields[0] = sam_fields[0].gsub(num.to_s, initial_num.to_s)\n\t\t\t\t\t\tputs sam_fields.join(\"\\t\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\ti += 1\t\t\t\n\tend\nend", "def transform_numbers_field fields,row_size\n count = 0\n @numbers.each do |n,arr|\n i = fields.delete(n) # delete the old field\n ## replace by the new fields instead\n arr.each { |v| fields[v] = row_size + count; count += 1 }\n end\n return fields\n end", "def biblio_renumber(xmldoc)\n i = 0\n xmldoc.xpath(\"//references[not(@normative = 'true')]\" \\\n \"[not(@hidden = 'true')]\").each do |r|\n r.xpath(\"./bibitem[not(@hidden = 'true')]\").each do |b|\n i += 1\n docid = b.at(\"./docidentifier[@type = 'metanorma']\") or next\n /^\\[\\d+\\]$/.match?(docid.text) or next\n docid.children = \"[#{i}]\"\n end\n end\n end", "def update_invoice_number!\n return unless Spree::PrintInvoice::Config.use_sequential_number?\n return if invoice_number.present?\n\n update_columns(invoice_number: Spree::PrintInvoice::Config.increase_invoice_number)\n end", "def reset\n @nums\n end", "def add_number\n return unless %w[techreport manual].include? @bib.type\n\n did = @bib.docidentifier.detect { |i| i.primary == true }\n did ||= @bib.docidentifier.first\n @item.number = did.id if did\n end", "def setPageNr(typePlusID) \n len = @page.css(typePlusID).css('li').length\n for i in 0..len-1 do \n titleName = @page.css(typePlusID).css('li')[i].css('span')[0].text\n correctPage = getPageNrForTitle(titleName)\n pageSpan = @page.css(typePlusID).css('li')[i].css('span')[1]\n pageSpan.content = correctPage.to_i - 1\n end\nend", "def reference_number_prefix\n nil\n end", "def next_rid; end", "def number=(_arg0); end", "def inc_b\n end", "def inc_l\n end", "def renumber_pages\n self.survey_version.pages\n .where(['page_number > ?', self.page_number])\n .update_all('pages.page_number = pages.page_number - 1')\n end", "def up num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n #@oldindex = @current_index if num > 10\n @current_index -= num\n #unless is_visible? @current_index\n #if @prow > @current_index\n ##$status_message.value = \"1 #{@prow} > #{@current_index} \"\n #@prow -= 1\n #else\n #end\n #end\n $multiplier = 0\n end", "def inc_e\n end", "def reset\n @number = nil\n end", "def current_comic_number\r\n \tcomic_number = Array.new(sorted_articles.reverse)\r\n \tcomic_number.index(item) + 1\r\n end", "def rindex(p0) end", "def push_new_numbers(new_numbers, numbers, index, counter)\n new_numbers << counter.to_s\n new_numbers << numbers[index]\nend", "def inc_a\n end", "def plus_one(digits)\n digits[-1] += 1 \n digits \nend", "def shift_server_num( server_number, num )\n\t\t@server_names[server_number + 1, @server_names.length - 1 - server_number].each { |server_name| \n\t\t\t@servers[server_name].number += num\n\t\t}\n\tend", "def number_counting_seq(n)\r\n\r\nend", "def renumber_sequences\n first = 1\n for image in inline_images do\n image.sequence = first\n image.save!\n first += 1\n end\n end", "def append_number\n append table.pick\n end", "def rid\n \"rId#{ndx + 1}\"\n end", "def input_to_index(user_input)\n new_user_input = user_input.to_i\n new_user_input -= 1\n return new_user_input\nend", "def number; end", "def number; end", "def thnum()\n #This is a stub, used for indexing\n end", "def consume_number; end", "def increment_order!\n @current += 1\n end", "def _next_id\n @@id -= 1\n @@id\n end", "def identifier\n num\n end", "def nextCode(model,prefix,num)\n\t\t# naming= NamingSery.where('naming_type=\"Sale Invoice\"').first\n\t\tlastRecord=model.order(\"id desc\").first\n\t\t# name=''\n\t\t# if !naming.nil?\n\t\t# \tname=naming.series \n\t\t# end\n\n\t\tmaxNumber=''\n\t\t\tif !lastRecord.nil?\n\t\t\t\t\n\t\t\t\tnamingSeries=lastRecord[self]\n\t\t\t\tif !namingSeries.nil?\n\t\t\t\t\ti = 0\n\t\t\t\t\tlength = namingSeries.length\n\n\t\t\t\t\twhile i < length do\n\t\t\t\t\t\ti +=1\n\t\t\t\t\t \t chr=namingSeries[length-i].chr\n\t\t\t\t\t \tif (chr).is_number?\n\t\t\t\t\t \t\tmaxNumber.insert(0,chr)\t\t\t\t \t\t\n\t\t\t\t\t \telse\n\t\t\t\t\t \t\tbreak\n\t\t\t\t\t \tend\n\t\t\t\t\t \n\t\t\t\t\tend\t\n\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\n\t\t\tend\n\t\treturn (maxNumber.to_i).generateCode(prefix,num)\n\tend", "def inc_seq_no!()\n @seq_no += 1\n return(nil)\n end", "def increment_num_comments\n\n end", "def RotateNumber (input)\n\tfirst = input[0]\n\tinput[0] = ''\n\tinput += first\nend", "def prev_number(number)\n return number -= 1\nend", "def select_reprint\n @data.inv_no = ''\n reprint_common\n end", "def incr(x) x + 1 end", "def transform_track_number ( number )\n\t\t# puts \"transform_track_number: input #{number} #{number.to_s}\"\n\t\t_number = number.to_s + \"/\" + (@renumber_start_at + @total_tracks -1 ).to_s\n\tend", "def inc_c\n end", "def add_numbers(prev, current)\n# do real calculation\n# total = prev + current\n# For display, need to use i, x and c correctors\n @arabictotaled = 0\n\n# first get the i's right\n case \n when @nextnum.i.length >= 5 # We can have up to 8 i's, so we'll move 5 (if there are that many) to the V's column\n @nextnum.v += \"V\"\n 5.times { |i| @nextnum.i.chop!}\n @arabictotaled += @nextnum.i.length # the \"leftover\" i's are each 1 in the arabictotal; this case settles what number goes into the i's column and adds that many to arabictotaled\n when @nextnum.i.length == 4\n# iflag = true # when we're checking X's, we'll need to know this\n unless @nextnum.v.length % 2 == 1 # if there are 1 or 3 V's, don't display \"IV\" — instead we'll need \"IX\"\n @nextnum.iv += \"IV\"\n end # unless\n @arabictotaled += 4\n when @nextnum.i.length < 4\n @arabictotaled += @nextnum.i.length\n end # case\n\n# now do the v's\n# at most we can have 3 v's (say we added XII + IV, then the X gets converted to V + IIIII to handle the Iminus and then later IIIII gets converted back to V)\n case @nextnum.v.length\n when 3\n @nextnum.v = \"V\"\n @nextnum.x += \"X\"\n @arabictotaled += 5\n if @nextnum.i.length == 4\n @nextnum.iv = \"\"\n @nextnum.ix = \"IX\"\n end\n when 2\n @nextnum.v = \"\"\n @nextnum.x += \"X\"\n # we do not increment arabictotal since the V's column is empty\n when 1\n @arabictotaled += 5\n if @nextnum.i.length == 4\n @nextnum.iv = \"\"\n @nextnum.ix = \"IX\"\n end\n end # case\n\n case \n when @nextnum.x.length >= 5\n @nextnum.l += \"L\"\n 5.times { |i| @nextnum.x.chop!}\n @arabictotaled += (@nextnum.x.length * 10)\n when @nextnum.x.length == 4\n# xflag = true # when we're checking C's, we'll need to know this\n unless @nextnum.l.length % 2 == 1 # if there are 1 or 3 L's, don't display \"XL\" — instead we'll need \"XC\"\n @nextnum.xl += \"XL\"\n else @nextnum.xc +=\"XC\"\n end # unless\n @arabictotaled += 40\n when @nextnum.x.length < 4\n @arabictotaled += (@nextnum.x.length * 10)\n end # case\n\n case @nextnum.l.length\n when 3\n @nextnum.l =\"L\"\n @nextnum.c += \"C\"\n @arabictotaled += 50\n when 2\n @nextnum.l = \"\"\n @nextnum.c += \"C\"\n when 1\n @arabictotaled += 50\n end # case\n\n case\n when @nextnum.c.length >= 5\n @nextnum.d += \"D\"\n 5.times { |i| @nextnum.c.chop!}\n @arabictotaled += (@nextnum.c.length * 100)\n when @nextnum.c.length == 4\n @nextnum.d += \"D\"\n @nextnum.c = \"\"\n @nextnum.cd = \"CD\"\n @arabictotaled += 400\n when @nextnum.c.length < 4\n @arabictotaled += (@nextnum.c.length * 100) \n end # case\n\n case @nextnum.d.length\n when 3\n @nextnum.d =\"D\"\n @nextnum.m += \"M\"\n @arabictotaled += 500\n when 2\n @nextnum.d = \"\"\n @nextnum.m += \"M\"\n when 1\n @arabictotaled += 500\n end # case\n\n case @nextnum.m.length\n when 9\n @nextnum.m = \"MMM\"\n extra = \" +MMM+MMM\"\n @nextnum.mstore = \"MMMMMM\"\n @arabictotaled += 9000\n when 8\n @nextnum.m = \"MMM\"\n extra = \" +MMM+MM\"\n @nextnum.mstore = \"MMMMM\"\n @arabictotaled += 8000\n when 7\n @nextnum.m = \"MMM\"\n extra = \" +MMM+M\"\n @nextnum.mstore = \"MMMM\"\n @arabictotaled += 7000\n when 6\n @nextnum.m = \"MMM\"\n extra = \" +MMM\"\n @nextnum.mstore = \"MMM\"\n @arabictotaled += 6000\n when 5\n @nextnum.m = \"MMM\"\n extra = \" +MM\"\n @nextnum.mstore = \"MM\"\n @arabictotaled += 5000\n when 4\n @nextnum.m.chop! \n extra = \" +M\"\n @nextnum.mstore = \"M\"\n @arabictotaled += 4000\n when 1..3\n extra = \"\"\n @nextnum.mstore = \"\"\n @arabictotaled += (@nextnum.m.length * 1000)\n when 0\n extra = \"\"\n end # case\n\n total = \"\"\n total += @nextnum.m\n if @nextnum.cm == \"CM\"\n total += @nextnum.cm # 3 options: CM, CD or D + C's\n elsif @nextnum.cd == \"CD\"\n total += @nextnum.cd \n else\n total += @nextnum.d \n total += @nextnum.c # There are 4 C's stored here if the number is CM or CD but we don't want to display them\n end\n if @nextnum.xc == \"XC\" # 3 options: XC, XL or L + X's\n total += @nextnum.xc \n elsif @nextnum.xl == \"XL\"\n total += @nextnum.xl \n else\n total += @nextnum.l \n total += @nextnum.x\n end\n if @nextnum.ix == \"IX\" # 3 options: IX, IV or V + I's\n total += @nextnum.ix \n elsif @nextnum.iv == \"IV\"\n total += @nextnum.iv \n else\n total += @nextnum.v \n total += @nextnum.i\n end\n\n# total = @cbeforem + @mtotal + @dtotal + @xbeforec +@ctotal + @ltotal + @ibeforex + @xtotal + @ibeforev + @vtotal + @nextnum.i\n# @altdisplay.text = extra\n update_altdisplay(extra)\n update_arabicdisplay(@arabictotaled)\n # if total.length == 0\n # total = \"nihil\"\n # update_arabicdisplay(0)\n # end\n# total = \"MMCXX\"\n return total\n# return total, @arabictotaled\n# @maindisplay.text += \"#{@prevnum} + #{@nextnum}\" # but not yet\n end", "def up num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n @oldindex = @current_index if num > 10\n @current_index -= num\n unless is_visible? @current_index\n if @prow > @current_index\n #$status_message.value = \"1 #{@prow} > #{@current_index} \"\n @prow -= 1\n else\n end\n end\n $multiplier = 0\n end", "def next_number(num, index, numbers, ph, lh)\n if index < numbers.size\n num = numbers[index]\n ph[num] = index\n return num\n end\n\n if lh[num] # second repeat\n nnum = lh[num] - ph[num]\n ph[nnum] ? lh[nnum] = index : ph[nnum] = index\n ph[num] = index - 1\n num = nnum\n else\n num = 0\n lh[num] = index # works because we know 0 has occurred before\n end\n num\nend", "def id_counter\n\t\t@@new_id += 1\n\tend", "def plus_one(digits)\n\n #recognize the last digit of the array\n if digits.last != 9\n digits[-1] = digits[-1] + 1 # increment the last number\n return digits\n else\n # check if the number is a 9, carry the 1 accordingly\n puts \"before iterating: #{digits}\"\n i = digits.size-1\n\n #iterate through the array in reverse\n while i >= 0\n puts \"value: #{digits[i]} (at index[#{i}])\"\n # increment last digit (and relevant digits) in reverse\n puts\"#{digits[i] = is_it_nine(digits[i])}\"\n if digits[i] != 0 # recognize when to stop updating digits\n return digits\n end\n if digits[0] == 0 # if the 1st value = 9, add a new digit\n digits.insert(0,1)\n end \n i -= 1\n end\n return digits\n # for i in 0..digits.size-1 do\n # puts \"value: #{digits[i]} (at index [#{i}])\"\n # digits[-i] = is_it_nine(digits[-i]) \n # puts \"after function: value: #{digits[i]} (at index [#{i}])\" \n # # if the first value is a 9, add a new element to the array \n # # if digits[0] == 0\n # # digits.insert(0,1)\n # # end \n \n # end\n\n # puts \"before iterating: #{digits}\"\n # digits.reverse.each_with_index{|val, index|\n # puts \"#{digits.reverse}\"\n # puts \"value: #{val} at index[#{index}]\"\n # puts\"#{digits[index] = is_it_nine(val)}\"\n\n # if digits[index] != 0 # recognize \n # return digits\n # end\n # }\n # return digits\n\n end\n\n \n\nend", "def num_converter_update(num_to_convert,key)\n\tnum_to_convert % key\nend", "def original_order\n end", "def set_invoice_number\n self.invoice_number = self.id + 777777\n self.save\n end", "def reversed_number(num)\n\nend", "def num; end", "def num; end", "def change_quant(list, item, new_num)\n list[item] = new_num\n list\nend", "def make_id\n new_id = @id\n @id += 1\n new_id\n end", "def fill_recurrence(number)\n if old_num == number\n self.recc += 1\n else\n apply_recurrence\n self.old_num = number\n self.recc = 1\n end\n end", "def o_gen_rating(numbers, idx)\n return numbers.first if numbers.size == 1\n\n zeroes = []\n ones = []\n numbers.each { |num| num[idx] == \"0\" ? zeroes.push(num) : ones.push(num) }\n next_nums = zeroes.size <= ones.size ? numbers - zeroes : numbers - ones\n o_gen_rating(next_nums, idx + 1)\nend", "def finishNumber(unfinishedNum)\n\t# Debug output\n\tif $DEBUG then STDERR.puts \"in finishNumber() with #{unfinishedNum}\" end\n\n\tcount = 0\n\n\tunfinishedNum.split(\"\").each_with_index do |char, index|\n\t\tif char == 'x' then\n\t\t\tunfinishedNum[index] = count.to_s\n\t\t\tcount = count + 1\n\t\tend\n\tend\n\n\treturn unfinishedNum\nend", "def increment_matrix_row_reference_count(mr)\n mr.update_columns(reference_count: (mr.reference_count || 0) + 1)\n mr.update_columns(cached_observation_matrix_row_item_id: id) if type =~ /Single/\n end", "def adjust_number(initial_array)\n initial_array.each do |array|\n if array.include? \"-\"\n insert_at = array.rindex(\"-\")\n size.times { array.insert insert_at, \"-\" } #add - to rows\n next\n elsif array.include? \"|\"\n size.times { array.insert 1, \" \" } # insert number of blanks after the pipe\n # add copies of the array to grow number vertically\n #size.times do\n # array_copy = Array.new(array)\n #end\n elsif array.all? { |x| x == \" \" }\n insert_at = array.first\n size.times { array.insert insert_at, \" \" } # add additional space to blank lines\n next\n end\n end\n end", "def row_id n\n n % @size\n end", "def customize_row_index(row_index)\n row_index += 1\n end", "def apnumber\n #Record.dot(content)\n Cruncher.crunch(content)\n end", "def increment_nums!()\n i = 0\n self.each do |element|\n if element.class() == Fixnum\n self[i] = self[i] + 1\n i += 1\n else\n i += 1\n end\n end\n end", "def increment_id!\n self.id = (self.id + 1) % 0x10000\n end", "def deco_pos; end", "def digit; end", "def set_increments\n if @tti.length == 0\n @sgn = 0 # subtitle group number\n @sn = 0 # subtitle number\n else\n @sgn = @tti.last.sgn\n @sn = @tti.last.sn\n increment_subtitle\n end\n end", "def update_group(increment)\n end", "def start_num\n return @start_num\n end", "def right_numbers\n numbers_with_checksum[7,6]\n end", "def next_bib\n self[:next_bib] = self.inc(next_bib: 1)[:next_bib]\n\tend", "def id_counter\n @id_counter += 1\n end", "def reference_it(value)\n reference_number = value[0,2].to_s.downcase\n reference_number += value.reverse[0,1].to_s.downcase\n reference_number += random_numeric(6)\n return reference_number\n end", "def down num=(($multiplier.nil? or $multiplier == 0) ? 1 : $multiplier)\n @oldindex = @current_index if num > 10\n @current_index += num\n unless is_visible? @current_index\n if @current_index > @scrollatrows\n @prow += 1\n end\n end\n $multiplier = 0\n end", "def set_last_digits\n end", "def move_zeroes(nums)\n# TBD\nend", "def initialize\n @@counter += 1\n super(sprintf(\"_%02d\", @@counter),0)\n end" ]
[ "0.64506245", "0.6259851", "0.61269253", "0.60911477", "0.60832113", "0.59726375", "0.59273875", "0.5914938", "0.5913037", "0.58983225", "0.5850089", "0.5767538", "0.5757154", "0.5742305", "0.5712332", "0.5637966", "0.5628454", "0.5626515", "0.56183654", "0.5614109", "0.56126684", "0.56119645", "0.5603707", "0.5603506", "0.55882204", "0.5565362", "0.55606055", "0.5558252", "0.5552546", "0.5551603", "0.5551176", "0.55477756", "0.5545625", "0.5539669", "0.5536555", "0.5522362", "0.5512034", "0.54996866", "0.5488365", "0.5475287", "0.54616684", "0.54607046", "0.5460329", "0.5460076", "0.5456824", "0.5448719", "0.544097", "0.54397655", "0.5439368", "0.5439084", "0.5439084", "0.54383326", "0.5432712", "0.5427125", "0.541314", "0.5409534", "0.54069734", "0.54061764", "0.53992945", "0.5395961", "0.5394649", "0.53933406", "0.5387837", "0.53842604", "0.5383188", "0.5382813", "0.53732765", "0.53714085", "0.5367304", "0.5355601", "0.5351198", "0.53510696", "0.5349175", "0.5349107", "0.53480333", "0.53480333", "0.53439164", "0.532845", "0.5319401", "0.53182095", "0.5317717", "0.530278", "0.52992576", "0.52912414", "0.52895737", "0.52853453", "0.5282949", "0.52810246", "0.5274016", "0.52718616", "0.5264026", "0.5260412", "0.52603453", "0.5251624", "0.5238045", "0.52323675", "0.52284384", "0.5228182", "0.52240753", "0.5214976", "0.521301" ]
0.0
-1
override ActiveRecord to prevent lft/rgt values from being saved (can corrupt indexes under concurrent usage)
def update #:nodoc: connection.update( "UPDATE #{self.class.table_name} " + "SET #{quoted_comma_pair_list(connection, special_attributes_with_quotes(false))} " + "WHERE #{self.class.primary_key} = #{quote_value(id)}", "#{self.class.name} Update" ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prevent_double_save_bug\n false if self.persisted?\n end", "def before_update\n lock_column_instance_filter\n super\n end", "def _before_validation\n if new? && (set = self[model.sti_key])\n exp = model.sti_key_chooser.call(self)\n if set != exp\n set_table = model.sti_class_from_key(set).table_name\n exp_table = model.sti_class_from_key(exp).table_name\n set_column_value(\"#{model.sti_key}=\", exp) if set_table != exp_table\n end\n end\n super\n end", "def _save_refresh\n super\n recalculate_values_hashes\n end", "def before_save\n deserialized_values.each{|k,v| @values[k] = serialize_value(k, v)}\n super\n end", "def set_old_values\n self._old_values = {}\n\n self.class.fields.each do |field|\n self._old_values[field] = self.send(field) unless field[0] == '_'\n end\n end", "def __save_on_database(db, t)\n t.rubyrel_catalog.base_relvar_attributes << __to_catalog_tuple\n end", "def persisted?; false; end", "def save(**)\n super.tap { self.unsaved = false }\n end", "def persisted?; end", "def persisted?; end", "def _save_set_values(values)\n ret = super\n load_typecast\n ret\n end", "def save_without_validation\n self.run_hook :before_save\n document = {}\n\n self.class.public_fields.each do |field|\n document[field] = self.send(field)\n end\n\n if self._id\n result = Driver.client[self.class.coll_name]\n .find({'_id' => self._id}).update_one(document, {:upsert => true})\n else\n document['_id'] = BSON::ObjectId.new\n Driver.client[self.class.coll_name].insert_one(document)\n self._id = document['_id']\n end\n\n self.run_hook :after_save\n set_old_values\n\n result ? true : false\n end", "def before_update_save(record); end", "def reset_timestamp_attrs_for_update_if_needed\n return if live?\n @record.send(:timestamp_attributes_for_update_in_model).each do |column|\n @record.send(\"restore_#{column}!\")\n end\n end", "def reset_timestamp_attrs_for_update_if_needed\n return if live?\n @record.send(:timestamp_attributes_for_update_in_model).each do |column|\n @record.send(\"restore_#{column}!\")\n end\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def preprocess_and_save\n process_attrs_before_write(self)\n return self.save()\n end", "def affect_relation_values!\n Relations.new(@klass).affect_relation_values!\n end", "def set_dirty(value)\n orig = nil\n CouchRest::Model::Base.configure do |config|\n orig = config.use_dirty\n config.use_dirty = value\n end\n BenchmarkModel.instance_eval do\n self.use_dirty = value\n end\n orig\nend", "def orm_patches_applied; end", "def force_save!\n @force_save = true\n end", "def fix_save_metas_options_no_changed\n save_metas_options #unless self.changed?\n end", "def save_on_insert?\n false\n end", "def before_save(*); end", "def override_setter_on(model)\n model.class_eval %(\n def #{attribute}=(raw_value)\n definition = self.class.bitmask_definitions[:#{attribute}]\n if raw_value_index = definition.values.find_index(raw_value)\n @#{attribute} = raw_value\n self[:#{attribute}] = raw_value_index\n end\n @#{attribute}\n end\n )\n\n if default_raw.present? then\n model.class_eval %(\n before_save do |m|\n self[:#{attribute}] ||= #{default_raw}\n end\n )\n end\n\n end", "def save_records(records)\n raise_must_override\n end", "def delay_save\n \n return if @all_fields_and_values.nil?\n \n # If there is a dynamo_field_value for one of this model's fields then there will be for all. Query for it here\n # and you'll only do it once, but move it into the loop and you'll count for each dynamo_field.\n first = @all_fields_and_values[0]\n count = DynamoFieldValue.count(:conditions=>\"model_id = #{self.id} AND dynamo_field_id=#{first[:dynamo_field].id}\")\n \n all_values = []\n @all_fields_and_values.each do |fv|\n # If count is 0 it means that no dynamo_field_values exist for this model so its brand new.\n if count == 0\n dfv = DynamoFieldValue.new(:dynamo_field_id=>fv[:dynamo_field].id, :model_id=>self.id, :created_at=>Time.now, :updated_at=>Time.now, \"#{fv[:dynamo_field].field_type}\".to_sym => fv[:value])\n all_values << build_insert_stmt(dfv)\n else\n # This is an existing set of values so we need to update.\n # Update is slower because we need to get the dynamo_field_values for this field so its extra queries\n dfv = fv[:dynamo_field].dynamo_field_values\n if dfv.blank?\n dfv = DynamoFieldValue.new(:dynamo_field_id=>fv[:dynamo_field].id, :model_id=>self.id, :created_at=>Time.now, :updated_at=>Time.now, \"#{fv[:dynamo_field].field_type}\".to_sym => fv[:value])\n all_values << build_insert_stmt(dfv)\n # If you don't clear the cache a second save on this instance won't see the newly created dynamo_field_value and it will insert it again.\n self.dynamo_cache=nil\n else\n # Find the dynamo_field_value we want to update.\n dfv = dfv.detect{|dyn_field_value| dyn_field_value.model_id == self.id}\n dfv.send(\"#{fv[:dynamo_field].field_type}=\", fv[:value])\n dfv.save!\n end\n end\n \n # Reset this now that we have processed all the insert / updates needed. If you don't \n # a double call to save could produce unexpected results.\n @all_fields_and_values = nil\n end\n \n return if all_values.empty?\n \n # improving performance by doing bulk inserts. The more dynamic fields the model has the more benefit this has over single inserts.\n bulk_insert_stmt = \"INSERT INTO `dynamo_field_values`(#{DynamoFieldValue.column_names.reject{ |field| field == 'id'}.join(',')}) VALUES #{all_values.join(',').gsub(/\"NULL\"/, 'NULL')}\"\n ActiveRecord::Base.connection.execute(bulk_insert_stmt)\n end", "def sneaky_save!\n sneaky_create_or_update\n end", "def save_without_timestamping\n class << self\n def record_timestamps; false; end\n end\n \n save\n \n class << self\n remove_method :record_timestamps\n end\n end", "def save!\n super\n logger.debug \"overriden save called!\"\n update_vars\n super\n end", "def save_without_auditing\n without_auditing { save }\n end", "def persisted?\n paranoid? ? !new_record? : super\n end", "def persisted?\n paranoid? ? !new_record? : super\n end", "def freeze\n reindex unless @clean\n super\n end", "def save\n super save\n end", "def save()\n super\n end", "def save()\n super\n end", "def save()\n super\n end", "def save()\n super\n end", "def save()\n super\n end", "def save_to_solr?; @wants_solr_save.nil? || @wants_solr_save == true; end", "def new_version_additional_behaviour_after_save(old, new, params)\n\t\t# change report/block/delete\n\t\tchange_rbc old, new, 0\n\t\tcopy_mixed_fields old, new\n\t\tmixed_fields_update_series_references old, new\n\tend", "def update_model(model, record)\n raise_must_override\n end", "def save\n attribs = attributes.clone\n\n # Don't care about these attributes\n attribs.delete(\"periodBegin\")\n attribs.delete(\"periodEnd\")\n attribs.delete(\"fk_Activity\")\n attribs.delete(\"peopleGroup\")\n attribs.delete(\"updated_by\")\n\n # Need to compare the semester/quarter stats to previous stat record\n prev_stat = get_previous_stat\n changed = false\n if prev_stat\n Statistic.semester_stats.each do |field|\n changed = changed || self[field] != prev_stat[field]\n attribs.delete(field)\n end\n end\n\n values = attribs.values.compact\n if !values.empty? || changed\n super\n end\n end", "def _save\n raise NotImplementedError, 'override #_save in a subclass'\n end", "def save_hash_field_order; end", "def force_save!(obj, options)\n if obj.saved?\n obj.og_update self, options\n else\n obj.og_insert self\n end\n end", "def before_save\n\n touch\n end", "def before_save\n\n touch\n end", "def recoverable_save\n # do requires_new so that exception won't kill outer transaction\n ActiveRecord::Base.transaction(requires_new: true) {\n save\n }\n end", "def save\n update_dc\n super \n end", "def orm_patches_applied=(_arg0); end", "def before_save\n # boolean fields cannot be NULL at database level\n self.is_active = 0 if self.is_active.nil?\n end", "def persisted? ; false ; end", "def save\n# if empty?\n# nil\n# else\n super\n# end\n end", "def to_new_record!\n store_before_to_new_record_values\n reset_persistence_values\n @new_record = true\n end", "def after_from_gtfs(model_attr_hash)\n end", "def activerecord_persist\n record.save(validate: false)\n end", "def save_self(safe = true)\n super && embedments.values.each do |e|\n e.loaded?(self) && Array(e.get!(self)).each { |r| r.original_attributes.clear }\n end\n end", "def _before_validation\n serialize_deserialized_values\n super\n end", "def before_save\n self.available = true if self.available.nil?\n super\n end", "def before_save\n self.available = true if self.available.nil?\n super\n end", "def dirty; end", "def persisted? ; false ; end", "def activerecord_save_touch_option?\n ActiveRecord::VERSION::STRING.to_f >= 5.0\nend", "def before_save\n # boolean fields cannot be NULL at database level\n self.is_active = 0 if self.is_active.nil?\n end", "def update_record(record, model)\n raise_must_override\n end", "def save_without_timestamping\n class << self\n def record_timestamps; false; end\n end\n \n save\n \n class << self\n remove_method :record_timestamps\n end\n end", "def save!(*)\n super.tap do\n changes_applied\n end\n end", "def save_without_auditing\n without_auditing { save }\n end", "def sneaky_save!(avoid_insert_conflict: nil)\n sneaky_create_or_update(avoid_insert_conflict: avoid_insert_conflict)\n end", "def save(obj)\n self.delete(obj, true)\n values = values(obj)\n return true if values[:hash_value].blank? || (!values[:range_value].nil? && values[:range_value].blank?)\n while true\n existing = Dynamoid::Adapter.read(self.table_name, values[:hash_value], { :range_key => values[:range_value] })\n ids = ((existing and existing[:ids]) or Set.new)\n new_ids = ids + Set[obj.id]\n\n if unique? && new_ids.length > 1\n raise Dynamoid::Errors::UniqueIndexError.new \"Uniqueness failure on index #{table_name}.\"\n end\n\n if existing\n if existing[:ids]\n options = {:if => {:ids => existing[:ids]}}\n else\n options = {:unless_exists => \"ids\"}\n end\n end\n begin\n return Dynamoid::Adapter.write(self.table_name, {:id => values[:hash_value], :ids => new_ids, :range => values[:range_value]}, options)\n rescue Dynamoid::Errors::ConditionalCheckFailedException\n end\n end\n end", "def persisted?\n false\n end", "def index_new\n raise InvalidDbError if @stale\n super\n end", "def save!(*)\n super.tap do\n changes_applied\n end\n end", "def save_all_fields_from_record(record)\n self.save_base_attributes(record)\n self.changed_keys = record.attributes.keys\n self.old_values ||= Hash.new\n self.new_values ||= Hash.new\n record.attributes.keys.each do |key|\n self.old_values[key] = record.attributes[key]\n self.new_values[key] = nil\n end\n self.filter_attributes(record)\n end", "def defaultHack\n #save only if i change something, so need this almost redundant if statement\n if(self.num_downvotes == nil || self.num_upvotes == nil || self.name == nil || self.name.blank? || self.num_downloads == nil)\n self.num_downvotes ||= 0\n self.num_upvotes ||= 0\n self.num_downloads ||=0\n self.name ||= \"???\"\n self.save\n end\n end", "def silent_save\n if self.class.find(self.id)\n update\n else\n insert\n end\n end", "def after_save\n super\n run_after_instance_hooks(:after_save)\n @instance_hooks.clear if @instance_hooks\n end", "def to_query(_model)\n raise 'subclasses should implement this method.'\n end", "def before_save(sender); end", "def pass_through_persist\n super\n end", "def stores_foreign_key?; false; end", "def stores_foreign_key?; false; end", "def aggregate_treat_undefined_attributes_as_default_value?; end", "def before_destroy # already protected by a transaction\n return if self[right_col_name].nil? || self[left_col_name].nil?\n self.reload # in case a concurrent move has altered the indexes\n dif = self[right_col_name] - self[left_col_name] + 1\n base_set_class.delete_all( \"#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\" )\n base_set_class.update_all(\"#{left_col_name} = CASE \\\n WHEN #{left_col_name} > #{self[right_col_name]} THEN (#{left_col_name} - #{dif}) \\\n ELSE #{left_col_name} END, \\\n #{right_col_name} = CASE \\\n WHEN #{right_col_name} > #{self[right_col_name]} THEN (#{right_col_name} - #{dif} ) \\\n ELSE #{right_col_name} END\",\n scope_condition)\n end", "def save; record.save; end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def clean_dirty_attributes!\n @dirty_attribute_keys = []\n end", "def multi_insert_sql_strategy\n :values\n end", "def fields_not_to_clean\n ['deleted_record','record_before','record_after']\n end", "def update_values(*args)\n cache_delete\n super\n end", "def model_reference_disable\n if respond_to? :disabled\n disable! force_save: true\n else\n @was_disabled = 'disabled'\n handle_save_triggers if respond_to? :handle_save_triggers\n end\n end", "def _save_update_all_columns_hash\n v = @values.dup\n Array(primary_key).each{|x| v.delete(x) unless changed_columns.include?(x)}\n v.delete(model.lock_column)\n v\n end", "def staging\n raise InvalidDbError if @stale\n super\n end", "def upgrade_fallback_value(instance, attr)\n plain_token = instance.public_send attr\n instance.update_column(attr, hashed_or_plain_token(plain_token))\n end", "def original_attributes_before_type_cast\n ensure_original_attributes_stored\n clone_attributes :read_original_attribute_before_type_cast\n end", "def save_without_transaction(options = {})\n return false if @deleted\n call_hooks 'save' do\n # Existing object implies update in place\n action = 'add'\n set_auto_date_field 'updated_at'\n if new_record?\n set_auto_date_field 'created_at'\n result = do_insert(options)\n else\n result = do_update(options)\n action = 'update'\n end\n @new_record = false\n @dirty = false\n issue_notification(:action => action)\n result\n end\n end", "def z=(value)\n super\n update_cursor\n end" ]
[ "0.5821733", "0.56324697", "0.5543295", "0.55406123", "0.55342853", "0.5472985", "0.5472146", "0.5430446", "0.53787434", "0.5355364", "0.5355364", "0.53139305", "0.5279822", "0.5268506", "0.52679384", "0.52679384", "0.52655506", "0.5263125", "0.5247419", "0.52450705", "0.5241746", "0.52350277", "0.52251303", "0.5214807", "0.51869786", "0.5184662", "0.51807153", "0.5160901", "0.5151799", "0.5147661", "0.5144264", "0.5133981", "0.51227754", "0.51227754", "0.5120668", "0.5119683", "0.51111114", "0.51111114", "0.51111114", "0.51111114", "0.51111114", "0.51107776", "0.510403", "0.5099286", "0.5092998", "0.5085916", "0.50773406", "0.50770104", "0.5076983", "0.5076983", "0.5071252", "0.50628674", "0.5060195", "0.5051479", "0.50502616", "0.5049313", "0.5036877", "0.50255466", "0.50244427", "0.501039", "0.49933344", "0.4988778", "0.4988778", "0.49881378", "0.49769986", "0.4975571", "0.49725953", "0.49581298", "0.49576247", "0.49529243", "0.49510458", "0.4949215", "0.49491152", "0.49465132", "0.49454123", "0.49372664", "0.49235457", "0.4923444", "0.4918799", "0.49140605", "0.49080312", "0.4906405", "0.48973507", "0.48946962", "0.48946962", "0.48924226", "0.48885667", "0.4888528", "0.48831117", "0.48831117", "0.48792446", "0.4875945", "0.48715007", "0.48699155", "0.48654446", "0.4861766", "0.4857008", "0.4855408", "0.48550144", "0.4852373", "0.48373142" ]
0.0
-1
exclude the lft/rgt columns from update statements
def special_attributes_with_quotes(include_primary_key = true) #:nodoc: attributes.inject({}) do |quoted, (name, value)| if column = column_for_attribute(name) quoted[name] = quote_value(value, column) unless (!include_primary_key && column.primary) || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name) end quoted end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_without_checking(columns)\n _update_dataset.update(columns)\n end", "def _update_without_checking(columns)\n _update_dataset.update(columns)\n end", "def _update_without_checking(columns)\n ds = _update_dataset\n lc = model.lock_column\n rows = ds.clone(ds.send(:default_server_opts, :sql=>ds.output(nil, [Sequel[:inserted][lc]]).update_sql(columns))).all\n values[lc] = rows.first[lc] unless rows.empty?\n rows.length\n end", "def _update_without_checking(columns)\n if use_prepared_statements_for?(:update)\n _set_prepared_statement_server(model.send(:prepared_update, columns.keys)).call(Hash[columns].merge!(pk_hash))\n else\n super\n end\n end", "def update!(**args)\n @custom_columns = args[:custom_columns] if args.key?(:custom_columns)\n end", "def _save_update_all_columns_hash\n v = @values.dup\n Array(primary_key).each{|x| v.delete(x) unless changed_columns.include?(x)}\n v.delete(model.lock_column)\n v\n end", "def updating_all_timestamp_sql\n update_col = timestamp_attributes_for_update_in_model.first\n\n \", #{update_col} = ?\" if update_col\n end", "def _update_without_checking(columns)\n super(identifier_hash(columns))\n end", "def save_only_columns_for_draft\n if self.class.draftsman_options[:only].any?\n only_changes = {}\n only_changed_attributes = self.attributes.keys - self.class.draftsman_options[:only]\n\n only_changed_attributes.each do |key|\n only_changes[key] = send(key) if changed.include?(key)\n end\n\n self.update_columns(only_changes) if only_changes.any?\n end\n end", "def update!(**args)\n @mysql_excluded_objects = args[:mysql_excluded_objects] if args.key?(:mysql_excluded_objects)\n @oracle_excluded_objects = args[:oracle_excluded_objects] if args.key?(:oracle_excluded_objects)\n @postgresql_excluded_objects = args[:postgresql_excluded_objects] if args.key?(:postgresql_excluded_objects)\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end", "def update!(**args)\n @group_columns = args[:group_columns] if args.key?(:group_columns)\n @group_temporal_total_weight = args[:group_temporal_total_weight] if args.key?(:group_temporal_total_weight)\n @group_total_weight = args[:group_total_weight] if args.key?(:group_total_weight)\n @temporal_total_weight = args[:temporal_total_weight] if args.key?(:temporal_total_weight)\n end", "def update!(**args)\n @sql_expression = args[:sql_expression] if args.key?(:sql_expression)\n end", "def update!(**args)\n @sql_expression = args[:sql_expression] if args.key?(:sql_expression)\n end", "def _save_update_all_columns_hash\n v = Hash[@values]\n Array(primary_key).each{|x| v.delete(x) unless changed_columns.include?(x)}\n v\n end", "def _save_update_all_columns_hash\n v = Hash[@values]\n Array(primary_key).each{|x| v.delete(x) unless changed_columns.include?(x)}\n v\n end", "def update!(**args)\n @column_filter_applied = args[:column_filter_applied] if args.key?(:column_filter_applied)\n @row_filter_applied = args[:row_filter_applied] if args.key?(:row_filter_applied)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def update!(columns)\n update(nil, columns)\n end", "def update!(**args)\n @exclude_fields = args[:exclude_fields] if args.key?(:exclude_fields)\n @include_fields = args[:include_fields] if args.key?(:include_fields)\n @post_scan_actions = args[:post_scan_actions] if args.key?(:post_scan_actions)\n @row_filter = args[:row_filter] if args.key?(:row_filter)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def _update_columns(columns)\n _update(columns) unless columns.empty?\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end", "def update_timestamps(columns_to_update)\n if model_class.columns.include?(:updated_at)\n columns_comparison = columns_to_update.map { |key|\n [\"#{model_class.table_name}__#{key}\".to_sym, \"excluded__#{key}\".to_sym]\n }.to_h\n update_condition = Sequel.~(columns_comparison) # only perform the update if at least one column differs\n updated_at_case = Sequel.case(\n [[update_condition, Sequel.function(:NOW)]],\n \"#{model_class.table_name}__updated_at\".to_sym # default value\n )\n { updated_at: updated_at_case }\n else\n { }\n end\n end", "def update!(**args)\n @oracle_columns = args[:oracle_columns] if args.key?(:oracle_columns)\n @table = args[:table] if args.key?(:table)\n end", "def fixup_columns\n @columns.each_index do |idx| \n\n if @columns[idx][:searchable].nil? then\n @columns[idx][:searchable] = @model_class.column_methods_hash[@columns[idx][:id].intern] ? true : false\n end\n @columns[idx][:query] = @columns[idx][:id] if @columns[idx][:query].nil?\n \n if @columns[idx][:sortable].nil? then\n @columns[idx][:sortable] = @columns[idx][:query] == false ? false : true\n end\n \n end\n end", "def update!(**args)\n @base_table = args[:base_table] if args.key?(:base_table)\n @sql_query = args[:sql_query] if args.key?(:sql_query)\n @view_type = args[:view_type] if args.key?(:view_type)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n @time_format = args[:time_format] if args.key?(:time_format)\n end", "def update!(**args)\n @attribute_columns = args[:attribute_columns] if args.key?(:attribute_columns)\n @attribute_weights = args[:attribute_weights] if args.key?(:attribute_weights)\n @context_columns = args[:context_columns] if args.key?(:context_columns)\n @context_weights = args[:context_weights] if args.key?(:context_weights)\n @horizon_columns = args[:horizon_columns] if args.key?(:horizon_columns)\n @horizon_weights = args[:horizon_weights] if args.key?(:horizon_weights)\n end", "def update_without_callbacks\r\n where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r\n \"(#{connection.quote_column_name(pair[0])} = #{pair[1]})\"\r\n end\r\n where_clause = where_clause_terms.join(\" AND \")\r\n connection.update(\r\n \"UPDATE #{self.class.quoted_table_name} \" +\r\n \"SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} \" +\r\n \"WHERE #{where_clause}\",\r\n \"#{self.class.name} Update\"\r\n )\r\n return true\r\n end", "def update!(**args)\n @exclude = args[:exclude] if args.key?(:exclude)\n end", "def update!(**args)\n @exclude = args[:exclude] if args.key?(:exclude)\n end", "def update!(**args)\n @delete_all_data_from_table = args[:delete_all_data_from_table] if args.key?(:delete_all_data_from_table)\n @row_key_prefix = args[:row_key_prefix] if args.key?(:row_key_prefix)\n end", "def _update(columns)\n model.cti_models.each do |m|\n h = {}\n m.cti_table_columns.each{|c| h[c] = columns[c] if columns.include?(c)}\n cti_this(m).update(h) unless h.empty?\n end\n end", "def prepare_update_statement(o)\n if o.offset || has_group_by_and_having?(o) ||\n has_join_sources?(o) && has_limit_or_offset_or_orders?(o)\n super\n else\n o\n end\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @default_value = args[:default_value] if args.key?(:default_value)\n @description = args[:description] if args.key?(:description)\n @gc_rule = args[:gc_rule] if args.key?(:gc_rule)\n @highest_indexing_type = args[:highest_indexing_type] if args.key?(:highest_indexing_type)\n @looker_column_spec = args[:looker_column_spec] if args.key?(:looker_column_spec)\n @mode = args[:mode] if args.key?(:mode)\n @ordinal_position = args[:ordinal_position] if args.key?(:ordinal_position)\n @subcolumns = args[:subcolumns] if args.key?(:subcolumns)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @row_filter_applied = args[:row_filter_applied] if args.key?(:row_filter_applied)\n @sampling_percent = args[:sampling_percent] if args.key?(:sampling_percent)\n end", "def update!(**args)\n @intent_only_no_pii = args[:intent_only_no_pii] if args.key?(:intent_only_no_pii)\n @rewritten_query = args[:rewritten_query] if args.key?(:rewritten_query)\n end", "def update!(**args)\n @incremental_post_operations = args[:incremental_post_operations] if args.key?(:incremental_post_operations)\n @incremental_pre_operations = args[:incremental_pre_operations] if args.key?(:incremental_pre_operations)\n @incremental_select_query = args[:incremental_select_query] if args.key?(:incremental_select_query)\n @refresh_disabled = args[:refresh_disabled] if args.key?(:refresh_disabled)\n @unique_key_parts = args[:unique_key_parts] if args.key?(:unique_key_parts)\n @update_partition_filter = args[:update_partition_filter] if args.key?(:update_partition_filter)\n end", "def update!(**args)\n @disable_nl_interpretation = args[:disable_nl_interpretation] if args.key?(:disable_nl_interpretation)\n @disable_supplemental_results = args[:disable_supplemental_results] if args.key?(:disable_supplemental_results)\n @enable_verbatim_mode = args[:enable_verbatim_mode] if args.key?(:enable_verbatim_mode)\n end", "def update!(**args)\n @mysql_columns = args[:mysql_columns] if args.key?(:mysql_columns)\n @table = args[:table] if args.key?(:table)\n end", "def reset_timestamp_attrs_for_update_if_needed\n return if live?\n @record.send(:timestamp_attributes_for_update_in_model).each do |column|\n @record.send(\"restore_#{column}!\")\n end\n end", "def reset_timestamp_attrs_for_update_if_needed\n return if live?\n @record.send(:timestamp_attributes_for_update_in_model).each do |column|\n @record.send(\"restore_#{column}!\")\n end\n end", "def data_for_update_columns\n {}\n end", "def update!(**args)\n @non_fixed = args[:non_fixed] if args.key?(:non_fixed)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @time_format = args[:time_format] if args.key?(:time_format)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @time_format = args[:time_format] if args.key?(:time_format)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @time_format = args[:time_format] if args.key?(:time_format)\n end", "def update_sql(sql, name = nil)\n super\n end", "def update!(**args)\n @postgresql_columns = args[:postgresql_columns] if args.key?(:postgresql_columns)\n @table = args[:table] if args.key?(:table)\n end", "def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n @columns_int16 = args[:columns_int16] if args.key?(:columns_int16)\n @columns_int32 = args[:columns_int32] if args.key?(:columns_int32)\n @columns_int64 = args[:columns_int64] if args.key?(:columns_int64)\n @columns_int8 = args[:columns_int8] if args.key?(:columns_int8)\n @values = args[:values] if args.key?(:values)\n end", "def unflag_row_deltas\n logger.debug \"Resetting row delta flags for #{name}\"\n q = \"UPDATE #{audit} SET `_has_delta` = 0\"\n db.query(q)\n end", "def update(sql, name = nil) end", "def update!(**args)\n @additional_options = args[:additional_options] if args.key?(:additional_options)\n @cluster_expressions = args[:cluster_expressions] if args.key?(:cluster_expressions)\n @dependency_targets = args[:dependency_targets] if args.key?(:dependency_targets)\n @disabled = args[:disabled] if args.key?(:disabled)\n @incremental_table_config = args[:incremental_table_config] if args.key?(:incremental_table_config)\n @partition_expiration_days = args[:partition_expiration_days] if args.key?(:partition_expiration_days)\n @partition_expression = args[:partition_expression] if args.key?(:partition_expression)\n @post_operations = args[:post_operations] if args.key?(:post_operations)\n @pre_operations = args[:pre_operations] if args.key?(:pre_operations)\n @relation_descriptor = args[:relation_descriptor] if args.key?(:relation_descriptor)\n @relation_type = args[:relation_type] if args.key?(:relation_type)\n @require_partition_filter = args[:require_partition_filter] if args.key?(:require_partition_filter)\n @select_query = args[:select_query] if args.key?(:select_query)\n @tags = args[:tags] if args.key?(:tags)\n end", "def update!(**args)\n @direct_write_record_ids = args[:direct_write_record_ids] if args.key?(:direct_write_record_ids)\n @lg_internal_writer_id = args[:lg_internal_writer_id] if args.key?(:lg_internal_writer_id)\n @provenance_only_addition = args[:provenance_only_addition] if args.key?(:provenance_only_addition)\n @triangulation_key = args[:triangulation_key] if args.key?(:triangulation_key)\n @weak_data = args[:weak_data] if args.key?(:weak_data)\n end", "def update!(**args)\n @attribute_id = args[:attribute_id] if args.key?(:attribute_id)\n @feature_property_id = args[:feature_property_id] if args.key?(:feature_property_id)\n @field_type = args[:field_type] if args.key?(:field_type)\n @min_rights_level = args[:min_rights_level] if args.key?(:min_rights_level)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @columns = args[:columns] if args.key?(:columns)\n end", "def _update_columns(columns)\n @columns_updated ||= DeprecatedColumnsUpdated.new(columns) # SEQUEL5: Remove\n _update(columns) unless columns.empty?\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end", "def update!(**args)\n @force_disable_supplemental_results = args[:force_disable_supplemental_results] if args.key?(:force_disable_supplemental_results)\n @force_verbatim_mode = args[:force_verbatim_mode] if args.key?(:force_verbatim_mode)\n end", "def update!(**args)\n @biasing_field = args[:biasing_field] if args.key?(:biasing_field)\n end", "def update!(**args)\n @field_with_rights = args[:field_with_rights] if args.key?(:field_with_rights)\n end", "def update!(**args)\n @exclude_conditions = args[:exclude_conditions] if args.key?(:exclude_conditions)\n @include_conditions = args[:include_conditions] if args.key?(:include_conditions)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n end", "def update!(**args)\n @merge_fields_options = args[:merge_fields_options] if args.key?(:merge_fields_options)\n @update_mask = args[:update_mask] if args.key?(:update_mask)\n @update_type = args[:update_type] if args.key?(:update_type)\n end", "def update_timestamp\n self.fields_last_modified = {\n columns_changeable: self.columns_changeable,\n columns_visible: self.columns_visible,\n filters: self.filters}.hash.to_s(36)[1..5]\n end", "def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n end", "def update!(**args)\n @biasingfield = args[:biasingfield] if args.key?(:biasingfield)\n end", "def update!(**args)\n @table_source_type = args[:table_source_type] if args.key?(:table_source_type)\n @table_spec = args[:table_spec] if args.key?(:table_spec)\n @view_spec = args[:view_spec] if args.key?(:view_spec)\n end", "def update!(**args)\n @table_source_type = args[:table_source_type] if args.key?(:table_source_type)\n @table_spec = args[:table_spec] if args.key?(:table_spec)\n @view_spec = args[:view_spec] if args.key?(:view_spec)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @description = args[:description] if args.key?(:description)\n @mode = args[:mode] if args.key?(:mode)\n @subcolumns = args[:subcolumns] if args.key?(:subcolumns)\n @type = args[:type] if args.key?(:type)\n end", "def update!(**args)\n @absolutely_forced_exp_names = args[:absolutely_forced_exp_names] if args.key?(:absolutely_forced_exp_names)\n @absolutely_forced_exp_tags = args[:absolutely_forced_exp_tags] if args.key?(:absolutely_forced_exp_tags)\n @absolutely_forced_exps = args[:absolutely_forced_exps] if args.key?(:absolutely_forced_exps)\n @conditionally_forced_exp_names = args[:conditionally_forced_exp_names] if args.key?(:conditionally_forced_exp_names)\n @conditionally_forced_exp_tags = args[:conditionally_forced_exp_tags] if args.key?(:conditionally_forced_exp_tags)\n @conditionally_forced_exps = args[:conditionally_forced_exps] if args.key?(:conditionally_forced_exps)\n @disable_automatic_enrollment_selection = args[:disable_automatic_enrollment_selection] if args.key?(:disable_automatic_enrollment_selection)\n @disable_exp_names = args[:disable_exp_names] if args.key?(:disable_exp_names)\n @disable_exp_tags = args[:disable_exp_tags] if args.key?(:disable_exp_tags)\n @disable_exps = args[:disable_exps] if args.key?(:disable_exps)\n @disable_manual_enrollment_selection = args[:disable_manual_enrollment_selection] if args.key?(:disable_manual_enrollment_selection)\n @disable_organic_selection = args[:disable_organic_selection] if args.key?(:disable_organic_selection)\n @forced_flags = args[:forced_flags] if args.key?(:forced_flags)\n @forced_rollouts = args[:forced_rollouts] if args.key?(:forced_rollouts)\n end", "def update!(**args)\n @absolutely_forced_exp_names = args[:absolutely_forced_exp_names] if args.key?(:absolutely_forced_exp_names)\n @absolutely_forced_exp_tags = args[:absolutely_forced_exp_tags] if args.key?(:absolutely_forced_exp_tags)\n @absolutely_forced_exps = args[:absolutely_forced_exps] if args.key?(:absolutely_forced_exps)\n @conditionally_forced_exp_names = args[:conditionally_forced_exp_names] if args.key?(:conditionally_forced_exp_names)\n @conditionally_forced_exp_tags = args[:conditionally_forced_exp_tags] if args.key?(:conditionally_forced_exp_tags)\n @conditionally_forced_exps = args[:conditionally_forced_exps] if args.key?(:conditionally_forced_exps)\n @disable_automatic_enrollment_selection = args[:disable_automatic_enrollment_selection] if args.key?(:disable_automatic_enrollment_selection)\n @disable_exp_names = args[:disable_exp_names] if args.key?(:disable_exp_names)\n @disable_exp_tags = args[:disable_exp_tags] if args.key?(:disable_exp_tags)\n @disable_exps = args[:disable_exps] if args.key?(:disable_exps)\n @disable_manual_enrollment_selection = args[:disable_manual_enrollment_selection] if args.key?(:disable_manual_enrollment_selection)\n @disable_organic_selection = args[:disable_organic_selection] if args.key?(:disable_organic_selection)\n @forced_flags = args[:forced_flags] if args.key?(:forced_flags)\n @forced_rollouts = args[:forced_rollouts] if args.key?(:forced_rollouts)\n end", "def update!(**args)\n @column = args[:column] if args.key?(:column)\n @operator = args[:operator] if args.key?(:operator)\n @value = args[:value] if args.key?(:value)\n end", "def update!(**args)\n @feature_birth_timestamp_us = args[:feature_birth_timestamp_us] if args.key?(:feature_birth_timestamp_us)\n @last_modification_timestamp_us = args[:last_modification_timestamp_us] if args.key?(:last_modification_timestamp_us)\n @removal_timestamp_us = args[:removal_timestamp_us] if args.key?(:removal_timestamp_us)\n end", "def non_audited_columns\n @non_audited_columns ||= calculate_non_audited_columns\n end", "def clear_changes\n versioned_columns.each do |key|\n changed_attributes.delete(key)\n end\n end", "def update_timestamp\n self.fields_last_modified = {\n columns_changeable: columns_changeable,\n columns_visible: columns_visible,\n filters: filters\n }.hash.to_s(36)[1..5]\n end", "def update\n $all_columns.each do |col|\n col[0] = col[1].call unless col[1].nil?\n end\nend", "def to_updates(set_columns, args={})\n args[:pk] ||= [0, 'id']\n args[:table] ||= Pathname.new(@filename).basename.to_s.downcase.gsub(/\\W/, '_')\n args[:before] ||= @@defaults[:before]\n args[:after] ||= @@defaults[:after]\n args[:values_glue] ||= \", \"\n args[:row_format] ||= lambda do |values|\n r = []\n set_columns.each_with_index { |set_column, i| r << \"#{set_column} = #{values[i]}\" if set_column }\n \"update #{args[:table]} set #{r.join(', ')} where #{args[:pk][1]} = #{values[args[:pk][0]]}\"\n end\n args[:row_glue] ||= \";\\n\"\n to_any args\n end", "def update_fields\n fieldlist = self.class.required_on_update + @newvalues.to_a - self.class.never_on_update\n @properties.select{|key, value| fieldlist.include?(key)}\n end", "def update!(**args)\n @fully_refresh_incremental_tables_enabled = args[:fully_refresh_incremental_tables_enabled] if args.key?(:fully_refresh_incremental_tables_enabled)\n @included_tags = args[:included_tags] if args.key?(:included_tags)\n @included_targets = args[:included_targets] if args.key?(:included_targets)\n @service_account = args[:service_account] if args.key?(:service_account)\n @transitive_dependencies_included = args[:transitive_dependencies_included] if args.key?(:transitive_dependencies_included)\n @transitive_dependents_included = args[:transitive_dependents_included] if args.key?(:transitive_dependents_included)\n end", "def attr_unsearchable(*args)\n if table_exists?\n opts = args.extract_options!\n args.flatten.each do |attr|\n attr = attr.to_s\n raise(ArgumentError, \"No persisted attribute (column) named #{attr} in #{self}\") unless self.columns_hash.has_key?(attr)\n self._metasearch_exclude_attributes = self._metasearch_exclude_attributes.merge(\n attr => {\n :if => opts[:if]\n }\n )\n end\n end\n end", "def update values\n if $VERBOSE\n warn <<-eowarn\nupdate (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please\nswitch to `compile_update`\n eowarn\n end\n\n um = compile_update values\n @engine.connection.update um.to_sql, 'AREL'\n end", "def update!(**args)\n @data_source_restrictions = args[:data_source_restrictions] if args.key?(:data_source_restrictions)\n @query = args[:query] if args.key?(:query)\n @request_options = args[:request_options] if args.key?(:request_options)\n end" ]
[ "0.6621375", "0.6621375", "0.65491235", "0.63984334", "0.63360035", "0.6259769", "0.61639607", "0.6115827", "0.61111766", "0.60705787", "0.6058055", "0.6058055", "0.6052958", "0.60441005", "0.60441005", "0.59847116", "0.59847116", "0.5975056", "0.5965982", "0.5922187", "0.5913716", "0.58702075", "0.58702075", "0.5863364", "0.5845605", "0.58440566", "0.58399975", "0.5800769", "0.5791244", "0.57870924", "0.57801425", "0.57801425", "0.5770865", "0.57642245", "0.5722852", "0.57189465", "0.57124966", "0.57055986", "0.568936", "0.5687693", "0.5680843", "0.5658169", "0.5658169", "0.5655809", "0.5655621", "0.5650207", "0.5650207", "0.5650207", "0.5639031", "0.5622338", "0.56093", "0.56049126", "0.56005025", "0.55897313", "0.5582363", "0.55724573", "0.5556947", "0.5549315", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5545501", "0.5528322", "0.5525476", "0.55099016", "0.5502354", "0.5500313", "0.54939884", "0.5486905", "0.54756016", "0.54712754", "0.54520005", "0.54505736", "0.5447323", "0.5437041", "0.5437041", "0.5436896", "0.54289585", "0.54280233", "0.542644", "0.5424809", "0.5420066", "0.5416263", "0.54077065", "0.5407479", "0.5402982", "0.539995", "0.5399288" ]
0.0
-1
i couldn't figure out how to call attributes_with_quotes without cutting and pasting this private method in. :( Quote strings appropriately for SQL statements.
def quote_value(value, column = nil) #:nodoc: self.class.connection.quote(value, column) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes_with_quotes\n columns_hash = self.class.columns_hash\n @attributes.inject({}) do |attrs_quoted, pair| \n attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first])\n attrs_quoted\n end\n end", "def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)\n quoted = {}\n connection = self.class.connection\n if Locale.base?\n attribute_names.each do |name|\n if column = column_for_attribute(name)\n quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && column.primary\n end\n end\n else\n attribute_names.each do |name|\n if !self.class.globalize_facets_hash.has_key?(name) && column = column_for_attribute(name)\n quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && column.primary\n end\n end\n end\n\t include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)\n end", "def attributes_string\n\t\t\t#note that underscores are converted to hyphens. Quotes are entity encoded\n\t\t\tattrs = @attributes.reject{|k,v| v.nil?}.map do |k,v|\n\t\t\t\tvv = escape_quote v.to_s\n\t\t\t\tkk = k.to_s.gsub('_', '-')\n\t\t\t\t%Q[#{kk}=\"#{vv}\"]\n\t\t\tend\n\t\t\t\n\t\t\treturn attrs.join(' ')\n\t\tend", "def special_attributes_with_quotes(include_primary_key = true) #:nodoc:\n attributes.inject({}) do |quoted, (name, value)|\n if column = column_for_attribute(name)\n quoted[name] = quote_value(value, column) unless (!include_primary_key && column.primary) || [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]].include?(column.name)\n end\n quoted\n end\n end", "def quoted_string; end", "def force_quotes?() @force_quotes end", "def attributes_with_quotes_with_marshalization(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)\n\n quoted = {}\n connection = self.class.connection\n attribute_names.each do |name|\n if (column = column_for_attribute(name)) && (include_primary_key || !column.primary)\n\n if self.class.marshalized_attributes.has_key?(name)\n # smart-quoting Marshal-dumped values\n quoted[name] = \"'#{@attributes[name].to_s}'\"\n else\n value = read_attribute(name)\n\n # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML.\n if value && self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time))\n value = value.to_yaml\n end\n\n quoted[name] = connection.quote(value, column)\n end\n end\n end\n include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)\n \n # TODO in order to get rid of the aliasing, handle marshalized attributes, then call super\n # passing all attributes but marshalized's. In fact, do it the reverse order so that the\n # quoted hash is not made empty in super after we filled it\n \n #attribute_names.delete_if { |attribute| self.class.marshalized_attributes.has_key?(attribute) }\n ##do stuff with marshalized_attributes.each -> quoted[name]\n #puts \"~~~~~~\"\n #puts attribute_names\n #super(true, true, attribute_names)\n\n end", "def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) #:nodoc:\n left_and_right_column = [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]]\n quoted = {}\n connection = self.class.connection\n attribute_names.each do |name|\n if column = column_for_attribute(name)\n quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && (column.primary || left_and_right_column.include?(column.name))\n end\n end\n include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)\n end", "def escape_double_quotes\r\n return self.gsub('\"', '\\\"')\r\n end", "def sql_quoted(value)\n Arel::Nodes.build_quoted(value)\n end", "def quotes; end", "def sequelize\n self.gsub(\"'\", \"''\")\n end", "def attribute_string(attributes)\n attributes.map { |name, value| \"#{name}=\\\"#{value}\\\"\" }\n end", "def quotes\n end", "def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def quote; end", "def parse_smart_quotes; end", "def format_attributes(attributes)\n return if attributes.nil?\n attributes.collect do |name, value|\n value = if value.kind_of? Array\n value.flatten.compact * \" \"\n else\n value.to_s\n end\n next if value == \"\"\n %Q{ #{name}=\"#{escape(value)}\"}\n end.join\n end", "def quoted\n with_opts(:quoted=>true)\n end", "def quote(s)\n \"\\\"#{s}\\\"\"\n end", "def quote(value); end", "def escape_for_cql_double_quotes(str)\n str = str.gsub('\"', \" \")\n str = str.gsub(\"'\", \"''\")\n\n return str\n end", "def quote( val )\n\t\treturn %q{\"%s\"} % [ val.to_s.gsub(/\"/, '\\\\\"') ]\n\tend", "def quote(*args)\n arr = args.map {|x| '\"' + x + '\"'}\n return arr.join(\" \")\nend", "def escape_quotes(text)\n text.gsub(\"'\", \"''\")\n end", "def sanitize_quotes(query)\n query.gsub!('\"\"', '\"')\n query.delete!('\"') if query.count('\"').odd?\n query = \"\" if query.blank?\n\n query\n end", "def sql_string(value)\n \"'#{value.gsub(\"'\", \"''\")}'\" \nend", "def quoted_column_names(attributes = attributes_with_quotes)\n connection = self.class.connection\n attributes.keys.collect do |column_name|\n connection.quote_column_name(column_name)\n end\n end", "def esc\r\n \"\\\"#{self}\\\"\"\r\n end", "def attributor(attributes)\n inject_s(attributes) {|key, value| \" #{key.to_s}=\\\"#{value.to_s}\\\"\"}\n end", "def attr_h(string)\n h(string).gsub('\"', '&quot;')\n end", "def create_attrs hash\n r = hash.map { |k,v| \"#{k}=\\\"#{escape_attr v.to_s}\\\"\" }.join(' ')\n \" #{r}\" unless r.empty?\n end", "def escape_attr input\n escape input, attr_regexp, attr_mapping\n end", "def html_attr(str)\n '\"' + str.gsub(/[&<>\"]/) {|ch| HTML_ATTR_ESCAPE_HASH[ch] } + '\"'\n end", "def quote_transform(input)\n input.gsub(/\"/, '&quot;')\n end", "def make_sql_friendly( name )\n return name.strip.gsub( \"'\", \"''\" )\n end", "def dquote( str ) #:nodoc:\n unless str =~ /^\".*?\"$/\n '\"' + str.gsub(/[\"\\\\]/n) {|s| '\\\\' + s } + '\"'\n else\n str\n end\n end", "def quote_string(s) #:nodoc:\n s.gsub(/'/, \"''\") # ' (for ruby-mode)\n end", "def attributes_for_params\n attributes.collect{ |key, value| \"#{key}:'#{CGI.escape value}'\" }.join(\", \")\n end", "def escape(input); input.to_s.gsub('\"', '\\\\\"'); end", "def escape_quotes input\n\t\tinput.gsub!(/([\\'\\\"])/,\"\\\\\\1\") #single quote\n\t\t\n\t\treturn input\n\tend", "def double_quote(value)\n return if value.nil?\n\n case value.to_s\n # Ignore keys that contain double quotes or a Arel.star (*)[all columns]\n # or if a table has already been explicitly declared (ex: users.id)\n when \"*\", /((^\".+\"$)|(^[[:alpha:]]+\\.[[:alnum:]]+)|\\(.+\\))/\n value\n else\n PG::Connection.quote_ident(value.to_s)\n end\n end", "def xml_attr_escape\n replacements = {\"<\" => \"&lt;\", \">\" => \"&gt;\", \"&\" => \"&amp;\", \"\\\"\" => \"&quot;\", \"'\" => \"&apos;\"}\n gsub(/([<>&\\'\\\"])/) { replacements[$1] }\n end" ]
[ "0.81485236", "0.73893154", "0.72634214", "0.7245756", "0.696161", "0.69066954", "0.6872065", "0.6829774", "0.66489375", "0.66341776", "0.662026", "0.6598165", "0.65825623", "0.6531401", "0.65191674", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6447311", "0.6438021", "0.6426872", "0.63394594", "0.6337408", "0.6319356", "0.6308304", "0.6300745", "0.6261302", "0.6229587", "0.6197666", "0.619153", "0.6178913", "0.61376995", "0.613513", "0.6118156", "0.6108991", "0.6098432", "0.6098061", "0.60935855", "0.609179", "0.60856014", "0.6073872", "0.60733914", "0.6070628", "0.60553825", "0.60546947", "0.6054673" ]
0.0
-1
grid = ["11110","11010","11000","00000"] p num_islands(grid)
def license_key_formatting(s, k) s = s.upcase.delete('-') i = s.length - 1 until i < 0 k.times do i-= 1 end s[i] += '-' if i >= 0 end s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_islands(grid)\n return 0 if grid.empty?\n\n count = 0\n\n grid.each_with_index do |row, i|\n row.each_with_index do |_col, j|\n if grid[i][j] == '1'\n dfs(i, j, grid)\n count += 1\n end\n end\n end\n count\nend", "def count_islands(matrix)\n rows = matrix.length\n cols = matrix[0].length\n visited = Array.new(rows) { Array.new(cols) }\n\n # Initialize count as 0 and traverse through all\n # cells of the given matrix\n count = 0\n (0...rows).each do |row|\n (0...cols).each do |col|\n\n # If a cell with a true value is not visited yet,\n # then new island is found\n if !visited[row][col] && matrix[row][col]\n # Visit all cells in this island\n # increment island count\n\n visit_island(row, col, visited, matrix)\n count += 1\n end\n end\n end\n\n count\nend", "def max_area_of_island(grid)\n return 0 if grid.empty?\n w, h = grid[0].length, grid.length\n max = 0\n (0...h).each do |i|\n (0...w).each do |j|\n if grid[i][j] == 1\n max = [max, search(grid, i, j)].max\n end\n end\n end\n max\nend", "def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend", "def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend", "def max_area_of_island(grid)\n area = 0\n (0...grid.size).each do |i|\n (0...grid[0].size).each do |j|\n area = [area, island_area(grid, i, j)].max if grid[i][j] == 1\n end\n end\n area\nend", "def variations_to_islands_per_level(islands_variations)\n current = islands_variations.length - 2\n t = islands_variations[current+1]\n current.downto 0 do |i|\n islands_variations[i] = islands_variations[i] == nil ? t : islands_variations[i]+t\n tmp = islands_variations[i]\n if tmp != 0\n t=tmp\n end\n end\n islands_variations\nend", "def get_neighbours(x, y, state)\n count = 0\n for ix in x - 1..x + 1\n for iy in y - 1..y + 1\n count += 1 if state[[ix, iy]] and not (ix == x and iy == y)\n end\n end\n return count\nend", "def island_perimeter(grid)\n perimeter = 0\n last_row = grid.length - 1\n \n grid.each_with_index do |row, row_idx|\n row.each_with_index do |col, col_idx|\n last_col = row.length - 1\n \n if col == 1\n if row_idx == 0\n perimeter += 1\n else\n perimeter += 1 if grid[row_idx - 1][col_idx] == 0\n end\n \n if col_idx == 0\n perimeter += 1\n elsif row[col_idx - 1] == 0\n perimeter += 1\n end\n \n if col_idx == last_col\n perimeter += 1\n elsif row[col_idx + 1] == 0\n perimeter += 1\n end\n \n if row_idx == last_row\n perimeter += 1\n elsif grid[row_idx + 1][col_idx] == 0\n perimeter += 1\n end\n end\n end\n end\n perimeter\nend", "def count_road_networks(cities:)\n result = cities\n result % 663_224_321\nend", "def neighbours(grid, coords)\n x, y = coords\n n = [\n [1, 0], [1, 1], [0, 1], [-1, 1],\n [-1,0], [-1, -1], [0, -1], [1, -1]\n ]\n \n n\n .map { |i|\n nx, ny = i\n grid.fetch([x + nx,y + ny], 0)\n }\n .sum\nend", "def pattern(pixel_l)\n result = 0\n (0..7).each do |index|\n minimum = 32 * index\n maximum = 32 * (index + 1)\n result = index if pixel_l >= minimum && pixel_l < maximum\n end\n result\n end", "def repeated_number_ranges(arr)\n\n\nend", "def num_ships\n @grid.reduce(0) { |acc, el| acc + el.count(:S) }\n end", "def get_num_neighbours(x, y)\n neighbours = 0\n (x-1..x+1).each do |col|\n (y-1..y+1).each do |row|\n if in_bounds?(col, row) && !(col == x && row == y) &&\n @grid[row][col] == 1\n neighbours += 1\n end\n end\n end\n neighbours\n end", "def neighborhood(cell)\n Set.new((cell[0]-1..cell[0]+1).map{|x| (cell[1]-1..cell[1]+1).map{|y| [x,y]}}.\n flatten(1)) - Set.new([cell])\nend", "def neighbour_count row,col\n neighbours=0\n \n # iterate around the neighbours\n (-1..1).each do |i|\n (-1..1).each do |j|\n\t# Wrap lower right edge of matrix back to 0\n\tnrow=(row==@current_state.length-i) ? 0 : row+i\n\tncol=(col==@current_state[row].length-j) ? 0 : col+j\n\t# Do not count current cell\n\t# Treat illegal values as 0\n\tif (nrow!=row or ncol!=col) and @current_state[nrow][ncol]==1\n\t neighbours += 1\n\tend\n end\n end\n return neighbours\n end", "def get_grid_num(index)\n grid_of_index = [ 1,1,1,2,2,2,3,3,3,1,1,1,2,2,2,3,3,3,1,1,1,2,2,2,3,3,3,\n 4,4,4,5,5,5,6,6,6,4,4,4,5,5,5,6,6,6,4,4,4,5,5,5,6,6,6,\n 7,7,7,8,8,8,9,9,9,7,7,7,8,8,8,9,9,9,7,7,7,8,8,8,9,9,9\n ]\n grid_of_index[index]\nend", "def number_of_groups\n empty? ? 0 : boundaries.size\n end", "def groupeIndicesGrid(grid)\n\t\tindices = []\n\t\tgrid.each{|ligne| indices << groupeIndicesLigne(ligne)}\n\t\treturn indices\n\tend", "def find_lis_brute_force array\n max_count = -1\n # Generate all the possible sets. This is done by generating all binary numbers from 1 to 2^n.\n # The presence of a 0 in the binary number at a position will grant entry to the element at that position to the set\n for i in 1..((2**array.count) - 1)\n itr = array.count - 1\n set = []\n while i > 0\n if i%2 == 1\n set << array[itr]\n end\n i = i/2\n itr -= 1\n end\n max_count = max(max_count, evaluate(set))\n end\n return max_count\nend", "def neighbours(cell_number)\n neighbours = []\n \n #left, right\n neighbours << cell_number - 1 unless (cell_number % 8) == 0\n neighbours << cell_number + 1 unless (cell_number % 8) == 7\n #up, down\n neighbours << cell_number - 8 unless cell_number < 8\n neighbours << cell_number + 8 unless cell_number > 55\n #up-left, up-right\n neighbours << cell_number - 9 unless (cell_number % 8) == 0 or cell_number < 8\n neighbours << cell_number - 7 unless (cell_number % 8) == 7 or cell_number < 8\n #down-left, down-right\n neighbours << cell_number + 7 unless (cell_number % 8) == 0 or cell_number > 55\n neighbours << cell_number + 9 unless (cell_number % 8) == 7 or cell_number > 55 \n\n neighbours \nend", "def run\n # Digits 1,4,7,8 have 2,4,3,7 segments respectively\n @list.map{|line| line[1]}.flatten.map(&:length).filter{|len| [2, 4, 3, 7].include?(len)}.count\n end", "def flatlandSpaceStations(n,c,m)\r\n answer = 0\r\n cc = c.sort()\r\n\r\n for i in (0..cc.size-2) do\r\n answer = [answer,(cc[i+1]-cc[i])/2].max\r\n end\r\n answer = [answer, cc[0], n-1 - cc[-1]].max\r\nend", "def min_umbrellas(weather)\n indexs = []\n result = 0\n weather.each_with_index do |weather, ind|\n if weather == \"rainy\" || weather == \"thunderstorms\"\n indexs << ind\n end\n end\n result += 1 unless indexs.empty?\n indexs.each_cons(2) do |first, second|\n result += 1 if (second - first) > 1\n end\n result\nend", "def calcIndice\n\t\t# [true,true,false,true]\t\t\t\t[2,1]\n\t\t# [false,true,false,false]\t\t--> \t[1]\n\t\t# [true,true,true,false,true]\t\t\t[3,1]\n\n\t\tgrid = self.toBoolean\n\t\t@indicesLigne = groupeIndicesGrid(grid)\n\t\t@indicesColonne = groupeIndicesGrid(grid.transpose)\n\t\treturn grid\n\tend", "def num_ships \n @grid.flatten.count(:S)\n end", "def calculate_variations(a, islands_per_level)\n previous = 0\n a.each do |plot_level|\n if plot_level > previous\n #if the current plot is higher than the previous, it means that the current island is overseas up to the current\n # plot height, so we increase the number of islands for the current level and decrease the number of islands\n # for the previous' plot level (only if previous is greater than 0)\n islands_per_level[plot_level-1] = islands_per_level[plot_level-1]+1\n islands_per_level[previous-1] = islands_per_level[previous-1]-1 if previous > 0\n end\n previous = plot_level\n end\nend", "def number(bus_stops)\n entries = []\n exits = []\n bus_stops.each { |x| entries << x[0] }\n bus_stops.each { |x| exits << x[1] }\n p entries.inject(&:+) - exits.inject(&:+)\nend", "def neighbours_boundries(cell_cords, dimension)\n [0, cell_cords - 1].max..[cell_cords + 1, dimension - 1].min\n end", "def adjacent_mines(row, col)\n\n count = 0\n\n count += 1 if (row + 1) < row_count && grid[row+1][col].fill == 1\n count += 1 if (row - 1) >= 0 && grid[row-1][col].fill == 1\n count += 1 if (col + 1) < column_count && grid[row][col+1].fill == 1\n count += 1 if (col -1) >= 0 && grid[row][col-1].fill == 1\n count += 1 if (row + 1) < row_count && (col + 1) < column_count && grid[row+1][col+1].fill == 1\n count += 1 if (row + 1) < row_count && (col -1) >= 0 && grid[row+1][col-1].fill == 1\n count += 1 if (row - 1) >= 0 && (col + 1) < column_count && grid[row-1][col+1].fill == 1\n count += 1 if (row - 1) >= 0 && (col -1) >= 0 && grid[row-1][col-1].fill == 1\n\n return count\n end", "def arraymap_number_of_plates(w,h,plates)\n\tmax = -1\n\teach_in_map(w,h,plates) do |x,y,plaque_index|\n\t\tmax=plaque_index if plaque_index>max\n\tend\n\tmax+1\nend", "def number_cells\n n = 1\n for row in 0...height\n for col in 0...width\n cell = self[row, col]\n west, north, east, south = DIRS.map{|dx, dy| self[row + dx, col + dy] and self[row + dx, col + dy].empty }\n if cell.empty and ((!west and east) or (!north and south))\n cell.number = n\n n += 1\n end\n end\n end\n end", "def mine_count\n grid.flatten.count { |space| space.mine }\n end", "def neighbor_mines_count\n neighbor_cells.count(&:mine?)\n end", "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 nb_dig(n, d)\n #create an array of sqaures from d up to and including n\n numbers = (d..n).to_a\n #issue was here: should've made the range 0..n instead of d..n\n squares = numbers.map do |num|\n num * num\n end\n #for each square...\n count = 0\n binding.pry\n squares.each do |square|\n #count and add to a tally if d is present\n count += square.to_s.count(d.to_s)\n end\n #turn it into a string\n #return the tally\n count\nend", "def afficherIndices(grid)\n\t\ti = 1\n\t\tgrid.each{|g|\n\t\t\tprint i,\" : \", g, \"\\n\"\n\t\t\ti += 1\n\t\t}\n\tend", "def number(bus_stops)\n x = bus_stops.flatten\n ins = x.select.with_index{|_,i| (i+2) % 2 == 0}.inject(:+)\n outs = x.each_slice(2).map(&:last).inject(:+)\n ins - outs\nend", "def all_nailed?(a, b, c, nails)\n planks = 0\n# N and M are integers within the range [1..30,000];\n# each element of arrays A, B, C is an integer within the range [1..2*M];\n nails_marked = [0] * (2 * c.size + 1)\n\n # mark each nail # with a 1\n nails.times do |i|\n nails_marked[c[i]] = 1\n end\n\n# nails: 4\n# nails_marked: [0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1]\n\n # prefix sums\n (1..nails_marked.size - 1).each do |i|\n nails_marked[i] += nails_marked[i - 1]\n end\n\n# shows how many nails have been hammered in by certain position\n# nails_marked: [0, 0, 0, 0, 1, 1, 2, 3, 3, 3, 4]\n\n a.size.times do |i|\n # prefix sum trick: # of nails hammered in between both ends of plank i\n if nails_marked[b[i]] - nails_marked[a[i] - 1] > 0\n planks += 1\n end\n end\n planks == a.size # if # of planks nailed = all planks, return TRUE\nend", "def cracklepop_numbers(from, to)\n (from..to).to_a.map { |n| cracklepop_number(n) }\nend", "def live_neighbor_count(coords, cells=@cells)\n num_alive_neighbors = 0\n minmax = coords.map { |dim_coord| [dim_coord-1, dim_coord+1] }\n all_coords_in(minmax).each do |neighbor_coord|\n if coords != neighbor_coord && cells.include?(neighbor_coord)\n num_alive_neighbors += 1 \n end\n end\n num_alive_neighbors\n end", "def min_umbrellas(weather)\n count, rain, at_home, at_work = 0, [\"rainy\", \"thunderstorms\"], 0, 0\n return 0 if weather.include?(rain[0] == false || weather.include?(rain[1]) == false)\n weather.each_with_index do |x, i|\n if i == 0 && rain.include?(x)\n count += 1\n at_work += 1\n elsif i.odd? == false && rain.include?(x)\n count += 1 if at_home == 0\n at_work += 1 \t \t \n at_home -= 1 if at_home > 0 \n elsif i.odd? && rain.include?(x)\n count += 1 if at_work == 0\n at_home += 1\n at_work -= 1 if at_work > 0\n end\n end\n p count\nend", "def infinite_areas\n infs = []\n (0..max_x).each do |x|\n infs << @grid[x][0]\n infs << @grid[x][max_y]\n end\n\n (0..max_y).each do |y|\n infs << @grid[0][y]\n infs << @grid[max_x][y]\n end\n\n infs.uniq.reject {|x| x == \".\" }.sort\n end", "def solution(range)\n ary = range.select(&:prime?).map do |n|\n n**Math.log(range.max, n).floor\n end.reduce(:*)\nend", "def repeated_number_ranges(arr)\n output = []\n\n arr.each_with_index do |el, i|\n if arr[i + 1] == arr.length\n break\n end\n if output.length > 0 && arr[output[-1][-1]] == arr[i + 1]\n output[-1] << i + 1\n elsif arr[i] == arr[i + 1]\n output << [i, i + 1]\n end\n end\n final_output = []\n\n if output.length == 0\n return []\n end\n\n output.each_with_index do |el, i|\n final_output << [el.min, el.max]\n end\n final_output\nend", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def living_neighbors(cell)\n count = 0\n cell.neighborhood.each { |k, v|\n count += 1 if @community[v].state == true\n }\n count\n end", "def count_neighbors(space, x_in, y_in, z_in, w_in, x_size, y_size, z_size, w_size)\n# count the number of active neighbors to (x, y, z, w)\ncount = 0\n[w_in-1, w_in, w_in+1].each do |w|\n\t[z_in-1, z_in, z_in+1].each do |z|\n\t\t[y_in-1, y_in, y_in+1].each do |y|\n\t\t\t[x_in-1, x_in, x_in+1].each do |x|\n\t\t\t\tif x==x_in and y==y_in and z==z_in and w==w_in\n\t\t\t\t\t# we do not consider ourself\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif x>=0 and x<x_size and y>=0 and y<y_size and z>=0 and z<z_size and w>=0 and w<w_size and space[x][y][z][w] == '#'\n\t\t\t\t\tcount+=1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend\nreturn count\n#\nend", "def countLights(matrix)\n\tlitLights = 0\n\n\tfor i in 0..999\n\t\tfor j in 0..999\n\t\t\tlitLights += matrix[i,j]\n\t\tend\n\tend\n\n\treturn litLights\nend", "def giniA(xs)\n\t1 - xs.group_by {|x| x }.inject(0) {|a, (k, v)| a + (v.size.to_f / xs.size) ** 2 }\nend", "def count_numbers_v2(from, to)\n total_numbers = (to - from).abs\n\n # handles X5\n possible_fives = total_numbers / 10\n\n # handles 5X\n possible_fifthy = total_numbers / 100\n\n # we already counted 55\n possible_fives += possible_fifthy * 8\n\n total_numbers - possible_fives\nend", "def live_neighbor_count(cell, live_cells)\n (neighborhood(cell) & live_cells).count\nend", "def length_of_lis(nums)\n len = []\n (0...nums.size).map { |i|\n len[i] = (0...i)\n .select { |j| nums[j] < nums[i] }\n .map { |j| len[j] + 1 }.max || 1\n }.max || 0\nend", "def needed_numbers\n needed = []\n coordinate_systems.each do |c|\n (0..8).each do |x|\n bits = axis_missing(x, c)\n needed << bits\n end\n end\n needed\n end", "def count_neighbors(x, y)\n return count_left(x, y) + count_right(x, y) + count_up(x, y) + count_down(x, y) + count_diagonals(x, y)\nend", "def allowed_numbers\n allowed = @board.map { |n| n.nil? ? 511 : 0 }\n coordinate_systems.each do |c|\n (0..8).each do |x|\n bits = axis_missing(x, c)\n (0..8).each { |y| allowed[index_for(x, y, c)] &= bits }\n end\n end\n allowed\n end", "def count_compositions(n_max, k_max, i_min = 0, i_max = nil)\n ns = (1..n_max).to_a\n ks = (2..k_max).to_a\n table = ns.map do |n|\n power_of_2?(n) && 2**i_min <= n && (i_max.nil? || n <= 2**i_max) ? [1] : [0]\n end\n ks.each do |k|\n ns.each do |n|\n next if k > n\n i_max_n = i_max || Math.log2(n).floor.to_i\n table[n - 1][k - 1] = (i_min..i_max_n).map do |i|\n n_prev = n - 2**i\n k_prev = k - 1\n k_prev > n_prev ? 0 : table[n_prev - 1][k_prev - 1]\n end.sum\n end\n end\n table\nend", "def neighbors1(x, y, b)\n ns = []\n if x-1 > -1\n ns << [b[x-1][y], b[x-1][y+1]]\n ns << b[x-1][y-1] if y-1 > -1\n end\n if y-1 > -1\n ns << b[x][y-1]\n ns << b[x+1][y-1] if b[x+1]\n end\n ns << b[x][y+1]\n ns << [b[x+1][y+1], b[x+1][y]] if b[x+1]\n ns.flatten.count('#')\nend", "def neighbors_count(i)\n n = relative(i-columns, 0)\n s = relative(i+columns, 0)\n e = relative(i, +1)\n w = relative(i, -1)\n nw = relative(n, -1)\n ne = relative(n, +1)\n sw = relative(s, -1)\n se = relative(s, +1)\n\n cells.values_at(*[n, nw, ne, e, w, s, sw, se].compact).sum\n end", "def lcount(arr)\n (1...arr.length).reduce(1) { |c, i| arr[i] > arr[0...i].max ? c + 1 : c }\nend", "def test_neighbour_count\n # Empty\n @game.state=[[0,0,0],[0,0,0],[0,0,0]]\n assert_equal 0,@game.neighbour_count(0,0)\n assert_equal 0,@game.neighbour_count(1,1)\n\n # One cell, check all neighbours, check proper edge wrapping\n @game.state=[[0,0,0],[0,1,0],[0,0,0]]\n assert_equal 1,@game.neighbour_count(0,2),'0,2'\n assert_equal 1,@game.neighbour_count(0,0),'0,0'\n assert_equal 1,@game.neighbour_count(0,1),'0,1'\n assert_equal 1,@game.neighbour_count(1,0),'1,0'\n assert_equal 0,@game.neighbour_count(1,1),'1,1' # Don't count self\n assert_equal 1,@game.neighbour_count(1,2),'1,2'\n assert_equal 1,@game.neighbour_count(2,0),'2,0'\n assert_equal 1,@game.neighbour_count(2,1),'2,1'\n assert_equal 1,@game.neighbour_count(2,2),'2,2'\n\n # Eight cells, check all neighbours, check proper edge wrapping\n @game.state=[[1,1,1],[1,0,1],[1,1,1]]\n assert_equal 7,@game.neighbour_count(0,2),'0,2'\n assert_equal 7,@game.neighbour_count(0,0),'0,0'\n assert_equal 7,@game.neighbour_count(0,1),'0,1'\n assert_equal 7,@game.neighbour_count(1,0),'1,0'\n assert_equal 8,@game.neighbour_count(1,1),'1,1' # Only cell with 8\n assert_equal 7,@game.neighbour_count(1,2),'1,2'\n assert_equal 7,@game.neighbour_count(2,0),'2,0'\n assert_equal 7,@game.neighbour_count(2,1),'2,1'\n assert_equal 7,@game.neighbour_count(2,2),'2,2'\n end", "def adjacent_mines(row, col)\n count = 0\n (-1..1).each do |i|\n (-1..1).each do |j|\n unless (i == 0 && j == 0) || (row + i) < 0 || (col + j) < 0\n if contains_mine?(row + i, col + j)\n count += 1\n end\n end\n end\n end\n count\n end", "def find_region\n count = 0\n GRID.each_with_index do |y_values, current_x|\n y_values.each do |current_y|\n distance = 0\n ALL_POINTS.each do |point|\n distance += ((point.y - current_y).abs + (point.x - current_x).abs)\n end\n p distance\n count += 1 if distance < 10_000\n end\n end\n p count\nend", "def solve( n = 2_000_000 )\n counts = Hash.new( 0 )\n\n # Guesstimate upper limit on grid dimensions. \n (1..100).each do |w|\n (1..100).each do |h|\n counts[[w, h]] = w * (w + 1) * h * (h + 1) >> 2\n end\n end\n\n counts.min_by {|k, v| (n - v).abs}[0].inject( :* )\n end", "def adjacent_mines(row, col)\n count = 0\n (-1..1).each do |i|\n (-1..1).each do |j|\n unless (i == 0 && j == 0) || (row + i) < 0 || (col + j) < 0\n count += 1 if contains_mine?(row + i, col + j)\n end\n end\n end\n\n count\n end", "def solution3(a)\n freq = {}\n a.each do |num|\n num = num.abs\n freq[num] ? next : freq[num] = 1\n end\n freq.size\nend", "def grid(number)\n v = number + 1 # number of vertices\n coefficient = 1\n routes = 0\n 1.upto(v) do |i|\n routes += coefficient * coefficient\n coefficient = coefficient * (v - i) / i\n end\n routes\n end", "def Consecutive(arr)\nlowest_num = arr.min\nhighest_num = arr.max\nconsec_numbers = (lowest_num..highest_num).to_a.size - arr.size\nconsec_numbers\nend", "def find_land world\n count = []\n\n world.each_with_index do |y, y_ind|\n #puts y.index(y_ind)\n world[y_ind].each_with_index do |x, x_ind|\n if world[y_ind][x_ind] == 'land'\n count.push continent_size(world, x_ind, y_ind)\n end\n end\n end\n count\nend", "def print_neighbours_count\n @x.times{ |r|\n @y.times{|c| \n print @mat[r][c].count_neighbours.to_s + \" \"\n }\n print \"\\n\"\n }\n end", "def test_count_neighbors_returns_correct_amount\n rules = Rules.new([[\".\",\".\",\".\"],[\".\",\".\",\".\"],[\".\",\".\",\".\"]])\n assert ( 3 == rules.count_neighbors(1,1,\n [[\".\",\"@\",\"@\"],[\"@\",\".\",\".\"],[\".\",\".\",\".\"]]) )\n assert ( 6 == rules.count_neighbors(1,1,\n [[\".\",\"@\",\"@\"],[\".\",\".\",\"@\"],[\"@\",\"@\",\"@\"]]) )\n assert ( 0 == rules.count_neighbors(1,1,\n [[\".\",\".\",\".\"],[\".\",\".\",\".\"],[\".\",\".\",\".\"]]) )\n end", "def count_neighbours(row_index, col_index)\n neighbours = 0\n neighbours += life_in_cell(row_index - 1, col_index - 1)\n neighbours += life_in_cell(row_index, col_index - 1)\n neighbours += life_in_cell(row_index + 1, col_index - 1)\n neighbours += life_in_cell(row_index - 1, col_index)\n neighbours += life_in_cell(row_index + 1, col_index)\n neighbours += life_in_cell(row_index - 1, col_index + 1)\n neighbours += life_in_cell(row_index, col_index + 1)\n neighbours += life_in_cell(row_index + 1, col_index + 1)\n return neighbours\n end", "def states\n is = (0...grid.size).to_a\n js = (0...grid.first.size).to_a\n is.product(js).select { |i, j| grid[i][j] } + [:stop]\n end", "def repeated_number_ranges(numbers)\n result = []\n initializer = nil\n i = 0\n while i < numbers.length\n if numbers[i] == numbers[i + 1]\n initializer = i if initializer.nil?\n elsif !initializer.nil?\n result << [initializer, i]\n initializer = nil\n end\n i += 1\n end\n result\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 count_between(list_of_integers, lower_bound, upper_bound)\nnew_array=Array.new\nlist_of_integers.each {|x|\n if x >= lower_bound.to_i && x <= upper_bound.to_i\n new_array << x\n end}\n return new_array.length\nend", "def routes_for(grid_size)\n choices = grid_size * 2\n \n factorial(choices) / (factorial(grid_size) * factorial(choices - grid_size))\nend", "def count_bugs(state, i, j)\n [[i + 1, j], [i - 1, j], [i, j + 1], [i, j - 1]].count do |n1, n2|\n (0...state.size).to_a.include?(n1) && (0...state[n1].size).to_a.include?(n2) && state[n1][n2] == '#'\n end\nend", "def count_between(list_of_integers,lower_bound,upper_bound)\nr = Range.new(lower_bound,upper_bound)\nnew_array=[]\nlist_of_integers.each do |x|\n if r.include?(x)\n new_array.push(x)\n end\n\nend\n\nreturn new_array.length\nend", "def test_fill_grid\n final_count_array = [1, 3, 5, 7]\n t = TreeShape.new(4)\n t.fill_grid()\n tmp_array = []\n t.grid.each_index do |xi|\n count = 0\n t.grid[xi].each_index do |yi|\n count += 1 if t.grid[xi][yi] == '*'\n end\n tmp_array << count\n end\n assert_equal(final_count_array, tmp_array)\n end", "def lucky_numbers (matrix)\n return matrix.map( &:min ) & matrix.transpose.map( &:max )\nend", "def gxfw\n numSeed = 2500\n pentagonalNumbers = arrPentagonalNumberListInt numSeed\n\n # Goes through every number and checks if it's in the list\n numSeed.times do |i|\n i.times do |j|\n uppernum = pentagonalNumbers[i]\n lowernum = pentagonalNumbers[j]\n if pentagonalNumbers.include?(uppernum - lowernum) and pentagonalNumbers.include?(uppernum + lowernum)\n p uppernum-lowernum\n end\n end\n end\nend", "def nr_of_regions\n ConnectedComponents.new(in_use_graph).count\n end", "def repeated_number_ranges(arr)\n rtn=[]\n start_idx=nil\n arr.each_with_index do |num,idx |\n nex_num=arr[idx+1]\n if num==nex_num\n start_idx=idx unless start_idx\n elsif start_idx\n rtn<<[start_idx,idx]\n start_idx=nil\n end\n end\n rtn\nend", "def biodiversity_index(specimens)\n counter = Hash.new(0)\n specimens.each do |x|\n counter[x] += 1\n end\nnums = counter.values\n(nums.length ** 2) * nums.min / nums.max\nend", "def pattern_indexes\n self.bits ||= 0\n array = bits.to_s(2).rjust(self.step_count, '0').chars.each_with_index.map do |value, index|\n index if value == '1'\n end\n array.compact\n end", "def neighbors(x,y)\n valid = 0..127\n [[x,y-1],[x,y+1],[x-1,y],[x+1,y]].select {|(h,v)| valid.cover?(h) && valid.cover?(v)}\nend", "def adjacent_mines(row, col)\n count = 0\n if col < @column_count-1\n count+=1 unless @grid[row][col+1].fill.nil?\n end\n if col > 0\n count +=1 unless @grid[row][col-1].fill.nil?\n end\n if row < @row_count-1\n count+=1 unless @grid[row+1][col].fill.nil?\n end\n if row > 0\n count+=1 unless @grid[row-1][col].fill.nil?\n end\n if row < @row_count-1 && col < @column_count-1\n count+=1 unless @grid[row+1][col+1].fill.nil?\n end\n if row > 0 && col > 0\n count+=1 unless @grid[row-1][col-1].fill.nil?\n end\n if row > 0 && col < @column_count-1\n count +=1 unless @grid[row-1][col+1].fill.nil?\n end\n if row < @row_count-1 && col > 0\n count +=1 unless @grid[row+1][col-1].fill.nil?\n end\n count\n end", "def find_valid_numbers(fields)\n bounds = fields.map { |line| line.scan(/\\d+/).map(&:to_i) }\n valid_numbers = []\n bounds.each do |set|\n pair = []\n (0..set.length - 1).step(2) { |ind| pair += (set[ind]..set[ind + 1]).to_a }\n valid_numbers << pair\n end\n valid_numbers\n end", "def repeated_number_ranges(numbers)\n ranges = []\n start_index = nil\n\n numbers.each_with_index do |el, idx|\n next_el = numbers[idx + 1]\n if el == next_el\n start_index = idx unless start_index\n elsif start_index\n ranges.push([start_index, idx])\n start_index = nil\n end\n end\n\n ranges\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\ncount = 0\nrange_array = *(lower_bound..upper_bound)\nlist_of_integers.each do |i|\nif range_array.include?(i) == true\ncount += 1\nend\nend\nreturn count\nend", "def solve(range)\n valid_passwords = range.filter do |n|\n never_decrease?(n) && any_adj_group(n) { |grp| yield grp }\n end\n valid_passwords.count\nend", "def get_consecutive_1s(binary)\n largest_consecutive = 0\n\n binary.split('0').map do |group|\n largest_consecutive = group.length if group.length > largest_consecutive\n end\n\n largest_consecutive\nend", "def edges\n i = 0\n @hypernyms.each do |key, values|\n i += values.length\n end\n i\n end", "def find_repeat(arr)\n floor = 1\n ceiling = the_array.length - 1\n\n while floor < ceiling\n\n midpoint = (floor + ceiling) / 2\n\n items_in_lower_range = 0\n arr.each do |item|\n if item >= floor && item <= midpoint\n items_in_lower_range += 1\n end\n end\n\n distinct_possible_integers_in_lower_range = ceiling - floor + 1\n\n if items_in_lower_range > distinct_possible_integers_in_lower_range\n ceiling = midpoint\n else\n floor = midpoint\n end\n end\n\n return floor\nend", "def find_neighbours(x)\n x.x - 1 < 0 ? fx = 0 : fx = x.x - 1\n x.x + 1 > @world.length-1 ? tx = @world.length-1 : tx = x.x + 1\n x.y- 1 < 0 ? fy = 0 : fy = x.y - 1\n x.y + 1 > @world[0].length-1 ? ty = @world[0].length-1 : ty = x.y + 1\n n_state = 0\n v_arrays = @world[fx..tx]\n v_arrays.each { |arr|\n h_array = arr[fy..ty]\n h_array.each { |grub|\n if (!grub.equal?(x))\n grub.lives ? n_state +=1 : n_state +=0\n end\n }\n }\n return n_state\n end", "def aboveOneMillionCount(num)\n idx = (1..num/2).to_a.index &->(r){combinator(num,r) > 10**6}\n return 0 unless idx\n lower = (idx + 1)\n upper = num - lower # has same combinator with lower\n upper - lower + 1 # \nend", "def set_grid(grid)\r\n @grid = grid\r\n @size = grid.length\r\n calculate_number_of_neighbouring_bombs\r\n end", "def infs\n counter = 0\n @l.each_value do |v|\n\tcounter +=1 if v == 'inf'\n end # do\n counter\n end", "def repeated_number_ranges(arr)\n ranges = []\n start = nil\n arr.each.with_index do |num, i|\n next_num = arr[i + 1]\n if num == next_num\n start ||= i\n elsif start\n ranges << [start, i]\n start = nil\n end\n end\n ranges\nend" ]
[ "0.8001825", "0.7288801", "0.6291966", "0.62090176", "0.61961794", "0.6189297", "0.61665344", "0.6012099", "0.59810567", "0.5941646", "0.5941072", "0.59189516", "0.58787864", "0.5809819", "0.5801855", "0.5797561", "0.57455504", "0.5732031", "0.56944484", "0.5689263", "0.5687852", "0.5634637", "0.56189483", "0.5609849", "0.560924", "0.5600564", "0.5589133", "0.5577844", "0.5572049", "0.55432045", "0.55389935", "0.5535199", "0.5523231", "0.5519295", "0.55131507", "0.5505198", "0.54942846", "0.5491919", "0.5489889", "0.5485282", "0.5483255", "0.54821295", "0.54794014", "0.5478797", "0.5478096", "0.5473253", "0.54581857", "0.54581857", "0.5457651", "0.5421327", "0.54008675", "0.53961897", "0.5394869", "0.5377478", "0.5374819", "0.5373896", "0.53689", "0.5366202", "0.53644437", "0.53632194", "0.5361498", "0.5359435", "0.53571695", "0.53513265", "0.53475094", "0.53466886", "0.534583", "0.53439504", "0.5340108", "0.5321224", "0.53110904", "0.53109455", "0.531", "0.53053695", "0.530142", "0.52877575", "0.5287183", "0.5277106", "0.5269916", "0.52662414", "0.5263418", "0.52616435", "0.5261265", "0.52609307", "0.5257232", "0.5256773", "0.5251769", "0.5249632", "0.52489847", "0.52483875", "0.52483433", "0.5246991", "0.52435744", "0.5240412", "0.52363193", "0.5230688", "0.52303994", "0.5229235", "0.5222574", "0.5218672", "0.52145547" ]
0.0
-1
I worked on this challenge [by myself, with: ]. shortest_string is a method that takes an array of strings as its input and returns the shortest string +list_of_words+ is an array of strings shortest_string(array) should return the shortest string in the +list_of_words+ If +list_of_words+ is empty the method should return nil Your Solution Below def shortest_string(list_of_words) arrlen = list_of_words.length 1 if arrlen 0 if list_of_words[arrlen1].length < shortest_len shortest_str = list_of_words[arrlen1] shortest_len = shortest_str.length end arrlen = 1 end return shortest_str end
def shortest_string(list_of_words) if list_of_words.length == 0 return nil end list_of_words.sort_by! {|i| i.length} return list_of_words[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_string(list_of_words)\n # PSEUDOCODE\n # return nil if list has no strings in it\n # I'm assuming the .length method is okay here, otherwise this problem would be a lot more tedious\n # Initialize initial shortest word as first word in array\n # Initialize initial shortest length as length of that word\n # FOR each word\n # IF word length is smaller than minimum\n # Set shortest word as that word\n # Set shortest length as word's length\n # Return minimum\n\n\n# INITIAL SOLUTION\n# return nil if list_of_words == []\n#\n# shortest = list_of_words[0]\n# min_length = shortest.length\n# list_of_words.each { |word|\n#\n# if word.length < min_length\n# shortest = word\n# min_length = word.length\n# end\n# }\n# return shortest\n\n #BUILT-IN SOLUTION\n\n return list_of_words.min { |a, b| a.length <=> b.length }\n\n\nend", "def shortest_string(list_of_words)\n # Your code goes here!\n if list_of_words.empty?\n return nil\n end\n shortest_word = list_of_words[0]\n for word in list_of_words\n if word.length < shortest_word.length\n shortest_word = word\n end\n end\n return shortest_word\n\nend", "def shortest_string(list_of_words)\n if list_of_words == []\n return nil\n end\n i = 0\n array_length = array_size(list_of_words)\n smallest_index = 0\n for i in 0..array_length - 1\n if string_length(list_of_words[smallest_index]) > string_length(list_of_words[i])\n smallest_index = i\n end\n end\n return list_of_words[smallest_index]\nend", "def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest = list_of_words[0]\n list_of_words.each.to_s do |x|\n if list_of_words.length < shortest\n shortest = x\n end\n end\n end\n return shortest\nend", "def shortest_string(list_of_words)\n if list_of_words.empty? \n return nil\n end\n \n short=list_of_words[0]\n list_of_words.each { |str| \n if str.length < short.length\n short=str\n end \n }\n return short\nend", "def shortest_string(list_of_words)\n\n#If presented with an array of mixed objects, maybe not all strings\n# strings = []\n# list_of_words.each do |i|\n# if i.is_a? String\n# strings.push(i)\n# end\n# end\n\n\n\n if list_of_words.length ==0\n return nil\n else\n i=0\n shorty = list_of_words[0]\n while i<list_of_words.length do\n if list_of_words[i].length <= shorty.length\n shorty = list_of_words[i]\n end\n i += 1\n end\n return shorty\n end\nend", "def shortest_string(list_of_words)\n if list_of_words.length == 0\n nil\n else\n index = 0\n shortest_word = list_of_words[0]\n while index < list_of_words.length do\n if list_of_words[index].length <= shortest_word.length\n shortest_word = list_of_words[index]\n end\n index+=1\n end\n shortest_word\n end\n end", "def shortest_string(list_of_words)\n if list_of_words.empty?\n return nil\n else\n shortest_length = list_of_words.first.length\n shortest_word = ''\n list_of_words.each do |word|\n if word.length <= shortest_length\n shortest_length = word.length\n shortest_word = word\n else\n shortest_word = shortest_word\n end\n end\n return shortest_word\n end\nend", "def shortest_string(list_of_words)\n # Your code goes here!\n return nil if list_of_words.empty?\n\n shortest = list_of_words[0]\n i = 1\n while(i < list_of_words.length)\n \tshortest = list_of_words[i] if list_of_words[i].size < shortest.size\n \ti += 1\n end\n return shortest\nend", "def shortest_string(list_of_words)\n \n array = []\n\n list_of_words.each {|value|\n \tarray << value.length\n }\n\n if array.empty?\n \tnil\n else\n return list_of_words[array.index(array.min)]\n end\n\nend", "def shortest_string(list_of_words)\n shortest = list_of_words[0]\n\n list_of_words.each do |word|\n if word.length < shortest.length\n shortest = word\n end\nend\n\nreturn shortest\nend", "def shortest_string(list_of_words)\n if list_of_words.length == 0\n \treturn nil\n end\n shortest_str = list_of_words[0]\n list_of_words.each do |str| \n \tif str.size < shortest_str.size\n \t\tshortest_str = str\n \tend\n end\n shortest_str\nend", "def shortest_string(list_of_words)\n shortest = list_of_words[0]\n array_number = 1\n while array_number < list_of_words.length\n \tif list_of_words[array_number].length < shortest.length\n \t\tshortest = list_of_words[array_number]\n \tend\n \tarray_number += 1\n end\n return shortest\nend", "def shortest_string(list_of_words)\n if list_of_words == []\n \treturn nil\n else\n \tcounter = 0\n \tshortest_word = ''\n \tshorest_word_length = list_of_words[0].length\n \twhile counter < list_of_words.length\n \t\tif shorest_word_length >= list_of_words[counter].length\n \t\t\tshortest_word = list_of_words[counter]\n \t\tend\n \tcounter += 1\n \tend\n end\n return shortest_word\nend", "def shortest_string(list_of_words)\n # Your code goes here!\n shortest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length < shortest.length\n shortest = word\n end\n }\n\n return shortest\nend", "def shortest_string(list_of_words)\n\tif list_of_words==[]\n\t\treturn nil\n\telse\n\t\tshort_string=list_of_words[0]\n \t\tlist_of_words.each do |x|\n \t\t\tif x.length < short_string.length\n \t\t\t\tshort_string = x\n\t\t\tend\t\t\n\t\tend\n \t\treturn short_string\n \tend\nend", "def shortest_string(list_of_words)\n return nil if no_string?(list_of_words)\n return list_of_words[0] if one_string?(list_of_words)\n \telse\n \t\tfirst_word = list_of_words[0]\n \t\tx = 1\n \t\twhile x < list_of_words.length\n \t\t\tif first_word.length > list_of_words[x].length\n \t\t\t\tfirst_word = list_of_words[x]\n \t\t\tend\n \t\t\tx += 1\n \t\tend\n \t\treturn first_word\nend", "def shortest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.min == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend", "def shortest_string(list_of_words)\n shortest = list_of_words[0]\n for word in 1...list_of_words.length\n if shortest.length > list_of_words[word].length then\n shortest = list_of_words[word]\n end\n end\n return shortest\nend", "def shortest_string(list_of_words)\n shortest = list_of_words[0]\n list_of_words.each do |i|\n \tif shortest.length <= i.length\n \t\tshortest = shortest\n \telse\n \t\tshortest = i\n \tend\n end\n p shortest\nend", "def shortest_string(list_of_words)\n\tshortest_string.each {|x1| x1.length}\n\t\tshortest_string.each {|x2| x2.length.to_i} #iterrates over each string in array, counts the string's length \n\t\tif shortest_string|x1.length| > shortest_string|x2.length| #compares the 2 pulled string lenghts\n\t\t\tshortest_string|x1| , shortest_string|x2| = shortest_string|x2| > shortest_string|x1| #keeps putting the smallest one to the front\n\t\tend\n\t\treturn shortest_string[0] #returns the first stirng in the array which should be the smallest one\nend\n\n# was getting some errors I could not resolve in order to get this to run. ", "def shortest_string(list_of_words)\n \n short_string = list_of_words[0]\n \n i = 0\n while i < list_of_words.length\n current_item = list_of_words[i]\n if current_item.length < short_string.length\n short_string = current_item\n end\n i = i + 1\n\n end\n short_string\nend", "def shortest_string(list_of_words)\n # Your code goes here!\n return list_of_words[0].to_s if list_of_words.length == 1\n smallest_word(list_of_words)\n# until_loop(list_of_words)\n# for_loop(list_of_words)\n# smallest = list_of_words[0]\n# list_of_words.each do |word|\n# smallest = word if word.length < smallest.length\n# end\n# return smallest\nend", "def shortest_string(list_of_words)\n\n for x in 0..list_of_words.length - 1\n if x == 0\n currentSmallest = list_of_words[x]\n else\n if list_of_words[x].length < currentSmallest.length\n currentSmallest = list_of_words[x]\n end\n end\n end\n\n return currentSmallest\nend", "def shortest_string(list_of_words)\n if list_of_words.empty? == true\n return nil\n end\n word = 1\n list_of_words.each do |x|\n if x.length <= word.to_s.length\n word = x\n end\n end\n p word\nend", "def shortest_string(list_of_words)\n list_of_words = list_of_words.sort_by {|x| x.length}\n short_string = list_of_words[0]\n return short_string\nend", "def shortest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length > list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend", "def shortest_string(list_of_words)\n\tif list_of_words.empty?\n\t\treturn nil\n\telse p list_of_words.sort_by {|x| x.length}.shift\n\tend\nend", "def shortest_string(list_of_words)\n # Your code goes here!\n list_of_words.sort! { |a , b| a.length <=> b.length }\n\t\treturn list_of_words[0]\nend", "def shortest_string(list_of_words)\n\treturn list_of_words.min_by {|x| x.length }\nend", "def shortest_string(list_of_words)\n\tmethod = 1\n\tcase method\n\twhen 1\n\t\tlist_of_words.min_by {|x| x.size} #The easy way\n\twhen 2\n\t\tshortest = list_of_words[0]\n \t\tlist_of_words.each do |element|\n \t\t\tshortest = element if element.size < shortest.size\n \t\tend\n \t\treturn shortest\n \twhen 3\n \t\tshortest = list_of_words[0]\n \t\tfor element in list_of_words\n \t\t\tshortest = element if element.size < shortest.size\n \t\tend\n \t\treturn shortest\n \tend\nend", "def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend", "def shortest_string(list_of_words)\n list_of_words.min_by(&:length)\nend", "def shortest_string(list_of_words)\n length_of_words = {}\n list_of_words.each do |word|\n word_length = word.length\n length_of_words[word] = word_length\n end\n answer = length_of_words.min_by{|k,v| v}\n if answer == nil\n return nil\n else\n answer.first\n end\nend", "def shortest_string(list_of_words)\r\n\tif list_of_words[0].nil?\r\n\t\treturn nil\r\n\telse\r\n\t\tstring_length = Hash.new\r\n\t\tsorted = Hash.new\r\n\t\tlist_of_words.each do |words|\r\n\t\t\tstring_length[words] = words.length\r\n\t\tend\r\n\t\tsorted = string_length.sort_by{|x, y| y}\r\n\t\treturn sorted.first.first\r\n\tend\r\nend", "def shortest_string(list_of_words)\n list_of_words.min {|x,y| x.size <=> y.size}\nend", "def shortest_string(list_of_words)\n\treturn list_of_words.min{|a,b| a.size <=> b.size}\nend", "def shortest_first(array_of_words)\n # TODO\nend", "def shortest_string(list_of_words)\n\n return nil if list_of_words.length == 0\n return \" \" if list_of_words.length == 1 && list_of_words[0] == \" \"\n return list_of_words[0] if list_of_words.length == 1\n\n test_word = list_of_words.pop\n not_it = []\n solution = []\n list_of_words.each do |word|\n if word.length < test_word.length\n not_it << test_word\n test_word = word\n else\n not_it << word\n end\n end\n\n solution.push test_word\n return solution[0]\n\n #------SOLUTION WITH sort_by METHOD:\n\n # new_list = list_of_words.sort_by {|x| x.length}\n # return new_list[0]\n\nend", "def shortest_string(list)\n\tshortest = list.first\n\tlist.each do |current_str|\n\t\tif current_str.length < shortest.length\n\t\t\tshortest = current_str\n\t\tend\n\tend\n\n\tshortest\nend", "def shortest_string(list_of_words)\n list_of_words.min { |a, b| a.size <=> b.size }\nend", "def shortest_string(list)\n # This is your job. :)\n shortest_so_far = list.first\n list.each do |item|\n if item.length < shortest_so_far.length\n shortest_so_far = item\n end\n end\n return shortest_so_far\nend", "def shortest_string(list)\n shortest_so_far = list.first\n list.each do |item|\n if shortest_so_far.length > item.length\n shortest_so_far = item\n end\n end\n shortest_so_far\nend", "def shortest_word_in_array(array)\n # check each element of array\n # if the shortest, update the shortest word\n shortest_word = array[0]\n array.each {|word|\n shortest_word = word if shortest_word.size>word.size\n }\n shortest_word\nend", "def find_short(s)\n # your code here\n the_1st_array = s.split(\" \")\n this_counts = []\n i = 0\n while i < the_1st_array.count\n this_counts.push(the_1st_array[i].length)\n i+=1\n end\n l = this_counts.min\n return l # l: length of the shortest word\nend", "def shortest_word_in_array(array)\n array.min_by{|word|word.length}\nend", "def shortest_word(words)\n words.inject { |memo, word| memo.length < word.length ? memo : word}\nend", "def shortest_word_in_array(array)\n array.min{ | x, y | x.length <=> y.length }\nend", "def shortest_word_in_array(array)\n array.min_by(&:length)\n # array.min_by { |x| x.length }\nend", "def shortest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengths)\n\tsorted = n.sort_by! { | word | word.length }\n\tsorted.first\nend", "def shortest(word1, word2)\n \n end", "def smallest_word(array)\n smallest = array[0]\n array.each do |word|\n smallest = word if word.length < smallest.length\n end\n return smallest\nend", "def find_short(s)\n l = s.split(\" \").min_by { |x| x.length}.length\n return l #l: length of the shortest word\nend", "def smallest_string(strings)\n smallest = strings[0]\n strings.each do |string|\n if string.length < smallest.length\n smallest = string\n end\n end\n smallest\nend", "def find_shortest_words(str)\n words = str.downcase.split(/[^a-z0-9]/)\n words = words.sort_by {|word| word.size}\n shortest = []\n\n words = words.select {|word| word.size > 0}\n\n size = words[0].size\n words.each do |word|\n break if word.size > size\n shortest << word\n end\n shortest.sort\nend", "def longest_string(list_of_words)\n longest = list_of_words[0]\n list_of_words.each do |x|\n if x.length >= longest.length\n longest = x\n end\n end\n if list_of_words.empty?\n return nil\n end\nreturn longest\nend", "def shortest(letters)\n x = 0\n y = 0\n longitud =[]\n delevery =letters.sort_by{|i|i.length}#sort_by ordena de menor a mayor\n delevery.each do |f| #sacar los valores ordenador del array\n if delevery[0].length == letters[x].length #toma el primer valor que es el menor y compara con los demas si tiene la misma longitud\n longitud[y] = letters[x] #se mete el resultado en el array vacio \n y += 1 #posiciona en el array el valor que resulta de la comparacion\n end\n x += 1 #guarda e incrementa en el array que va encontrando en el array o,1,2,3,...\n end\n\n longitud\nend", "def longest_string(list_of_words)\n if list_of_words == []\n return nil\n elsif list_of_words == ['']\n return ''\n elsif list_of_words.length == 1\n return list_of_words[0]\n elsif\n sorted_words = list_of_words.sort_by { |x| x.length}\n return sorted_words[-1]\n end\nend", "def until_loop(array)\n shortest = array[0]\n until array.empty?\n word = array.shift\n shortest = word if shortest.length > word.length\n end\n return shortest\nend", "def find_short(s)\n # input is string\n # convert string to array\n converted = s.split(\" \") # gives us an array of words\n # order elements of array by length\n sorted_by_length = converted.sort_by {|x| x.length}\n # returns an array of words sorted by length\n # return the first element in array\n return sorted_by_length[0].length\n \nend", "def longest_string(list_of_words)\n # Your code goes here!\n if list_of_words.length == 0\n \treturn nil\n end\n var = list_of_words[0]\n for i in 1 ... list_of_words.length\n \tif i == list_of_words.length\n \t\treturn var\n \telsif var.length < list_of_words[i].length\n \t\tvar = list_of_words[i]\n \tend\n \ti+=1\n end\n return var\nend", "def longest_prefix(strings)\n\n # Assign relevant variables\n winning_ticket = \"\"\n i = 0 \n fastest_furthest = strings[0][i]\n\n # Account for non-nil values and return method result \n while fastest_furthest != nil\n strings.each do |string|\n unless string[i] == fastest_furthest\n return winning_ticket\n end \n end \n winning_ticket += fastest_furthest\n i += 1\n fastest_furthest = strings[0][i]\n end\n return winning_ticket\nend", "def longest_string(list_of_words)\n initial = list_of_words.kind_of?(Array) && list_of_words[0] != nil ? '' : nil\n\nreturn initial if initial == nil\n\nfor i in 0...list_of_words.length\n curr_val = list_of_words[i] if list_of_words[i].instance_of? String\n puts list_of_words[i].length\n initial = curr_val if i == 0 || initial.length < curr_val.length\nend\n\ninitial\nend", "def longest_string(list_of_words)\n if list_of_words.length > 0\n longest_word = list_of_words[0]\n for word in list_of_words\n if word.length > longest_word.length\n longest_word = word\n end\n end\n return longest_word\n end\nend", "def longest_string(list_of_words)\n i=0\n long_string=list_of_words[0]\n list_of_words.each do\n if list_of_words[i].length>long_string.length\n long_string=list_of_words[i]\n end\n i+=1\n end\n return long_string\nend", "def longest_prefix(strings)\n return \"\" if strings.empty? \n index = 0\n min = strings.min_by{|s| s.length} # find the shortest string\n longest_prefix = \"\"\n while index < min.length # keep running based on the length of the sortest the string \n strings.each do |string|\n if min[index] != string[index] # if the it's not equal, return the \"\"\n return longest_prefix\n end\n end\n longest_prefix += min[index]\n index +=1\n end \n return longest_prefix\nend", "def find_short(s)\n return s.split(\" \").map { |word| word.length }.min\nend", "def solution(a)\n shortest = a.min_by &:length\n maxlen = shortest.length\n maxlen.downto(0) do |len|\n 0.upto(maxlen - len) do |start|\n substr = shortest[start,len]\n return substr if a.all?{|str| str.include? substr }\n end\n end\nend", "def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend", "def find_short(s)\n s.split(' ').map{|e|e.length}.min\nend", "def longest_prefix(strings)\n return \"\" if strings.empty?\n prefix = \"\"\n smallest_word = strings.min_by { |word| word.length } # start with smallest word\n for i in 0..smallest_word.length-1\n if strings.all? { |word| word[i] == smallest_word[i] } # if the index matches the same index of the other words\n prefix += smallest_word[i] # then append the index value to the prefix\n else\n break # otherwise index is not in all words, so stop\n end\n end\n return prefix\nend", "def longest_prefix(strings)\n common_string = \"\"\n if strings.length == 0\n return common_string\n end\n \n shortest_element = strings.min\n shortest_element_length = shortest_element.length\n i = 0\n while i < shortest_element_length\n char = shortest_element[i]\n strings.each do |string|\n if char != string[i]\n return common_string\n end\n end\n common_string += char\n i += 1\n end\n \n return common_string\nend", "def longest_string(list_of_words)\n longest = nil\n list_of_words.each do |words|\n if longest.nil? || longest.length < words.length\n longest = words\n end\n end\nlongest\nend", "def longest_prefix(strings)\n strings_in_common = \"\"\n #checking if array is emptyh\n if strings.length == 0\n return strings_in_common\n end\n shortest_string = strings.min(){|a, b| a.length <=> b.length}.chars\n i = 0\n while i < shortest_string.length\n letter = shortest_string[i]\n strings.each do |string|\n if letter != string.chars[i]\n return strings_in_common\n end\n end\n strings_in_common += letter\n i += 1\n end\n return strings_in_common\nend", "def get_the_shortest_word(str)\n str.split(\" \").sort! {|s, l| s.length <=> l.length}[0]\nend", "def longest_string(list_of_words)\n index = 0\n counter = 1\n if list_of_words == []\n return nil\n end\n until counter == list_of_words.length\n if list_of_words[index].length > list_of_words[counter].length\n counter += 1\n else\n index = counter\n counter += 1\n end\n end\n return list_of_words[index]\nend", "def find_short(string)\n string.split.map(&:length).min\nend", "def longest_string(list_of_words)\n long_string = list_of_words[0]\n counter = 0\n while counter < list_of_words.length\n if long_string.length < list_of_words[counter].length\n long_string = list_of_words[counter]\n end\n counter += 1\n end\n p long_string\n #return list_of_words.sort {|x,y| y.length <=> x.length}[0]\nend", "def longest_string(list_of_words)\n if list_of_words.size != 0\n longest_str = list_of_words.max_by{|a| a.size}\n return longest_str\n else\n end\nend", "def find_short(s)\n return s.split(' ').min_by{|word| word.length}.length\nend", "def longest_string(list_of_words)\n\tif list_of_words.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_words[0]\n\tj = 1\n\twhile j <= list_of_words.length - 1 do\n\t\tif i.length < list_of_words[j].length\n\t\t\ti = list_of_words[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend", "def longest_string(list_of_words)\n # Your code goes here!\n longest = list_of_words[0]\n\n list_of_words.each { |word| \n if word.length > longest.length\n longest = word\n end\n }\n\n return longest\nend", "def longest_string(list_of_words)\n\tif list_of_words == []\n\t\treturn nil\n\telsif list_of_words == [\" \"]\n\t\treturn \" \"\n\telse\n\t\tstring_length = []\n\t\tlist_of_words.each do |string|\n\t\t\t string_length.push string.length\n\t\tend\n\t\tlist_of_words.each do |string|\n\t\t\tif string_length.max == string.length\n\t\t\t\treturn string\n\t\t\tend\n\t\tend\n\n\tend\n\nend", "def longest_string(list_of_words)\n # Your code goes here!\n if list_of_words.length == 0 then return nil\n end\n longest_word = list_of_words.max_by { |x| x.length }\n return longest_word\nend", "def longest_string(list_of_words)\n # length = list_of_words.length\n if list_of_words == []\n return nil\n else\n return list_of_words.max_by { |x| x.length }\n end\nend", "def longest_string(list_of_words)\n return list_of_words[0] if list_of_words.length <= 1\n\n longest = list_of_words.pop\n trash = []\n\n list_of_words.each do |test_item|\n if test_item.length < longest.length\n trash.push test_item\n else\n trash.push longest\n longest = test_item\n end\n end\n return longest\nend", "def longest_string(list_of_words)\n if list_of_words == []\n p nil\n else\n words_and_lengths = {}\n list_of_words.each do |word|\n words_and_lengths[word.length] = word\n end\n p words_and_lengths\n longest_length = list_of_words[0].length\n words_and_lengths.each do|length, word|\n if length > longest_length\n longest_length = length\n end\n end\n p words_and_lengths[longest_length]\n end\nend", "def break_ties(tied_words)\n puts \"This is our array of just words: #{tied_words}\"\n all_tens = tied_words.select{|word| word.length == 10}\n\n winning_word = \"\"\n if all_tens.size >= 1 \n winning_word = all_tens[0]\n else\n all_smallest = tied_words.min_by{|word| word.length}\n if all_smallest.class == Array \n winning_word = all_smallest[0]\n else\n winning_word = all_smallest\n end\n end\n return winning_word\nend", "def longest_string(list_of_words)\n\tif list_of_words.size == []\n\t\treturn nil\n\telsif list_of_words.size == 1\n\t\treturn list_of_words[0]\n\telsif list_of_words.size >= 2\n\t\tlist_of_words.sort_by! {|word| word.length}\n\t\treturn list_of_words.last\n\tend\nend", "def longest_string(list_of_words)\n long_string = list_of_words[0]\n list_of_words.each do |measure|\n if long_string.size < measure.size\n long_string = measure\n end\n\n end\n p long_string\nend", "def find_short(sentence)\n word_array = sentence.split\n\n word_array.sort! do |word_a, word_b|\n word_a.length <=> word_b.length\n end\n\n return word_array.first.length\nend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend", "def longest_string(strings)\r\n#+++solution+++\r\n strings.inject('') { | best, this | (best.length < this.length) ? this : best }\r\n#---solution---\r\nend", "def for_fs_sake(string)\n words = string.split\n min_f_distance = nil\n min_f_word = \"\"\n\n words.each do |word|\n current_f_distance = find_f_distance(word)\n if current_f_distance && (min_f_distance.nil? || current_f_distance < min_f_distance)\n min_f_distance = current_f_distance\n min_f_word = word\n end\n end\n\n min_f_word\nend", "def longest_string(list)\n longest_so_far = list.first\n list.each do |item|\n if longest_so_far.length < item.length\n longest_so_far = item\n end\n end\n longest_so_far\nend", "def get_the_shortest_word(str)\n words = str.split()\n return words.max\nend", "def longest_prefix(array_of_strings)\n prefix = \"\"\n\n #error checking if array is empty, return strings in common init to empty\n if array_of_strings.length == 0\n return prefix\n end\n # puts \"array of strings here #{array_of_strings}\"\n\n #find longest string\n longest_length = 0\n longest_string = \"\"\n array_of_strings.each do |string|\n if string.length > longest_length\n longest_length = string.length\n longest_string = string\n end\n end\n\n # puts \"longest string #{longest_string}\" #doggo\n #turn longest string into array\n longest_string_array = longest_string.chars\n # puts longest_string_array\n\n #start loop\n i = 0\n while i < longest_string_array.length #[d,o,g,g,o]\n longest_letter = longest_string_array[i]\n j = 0 #start another loop to access words: [\"dogs\", \"doggo\", \"dot\"]\n while j < array_of_strings.length\n #turn array of strings into array of array of chars for each word\n word = array_of_strings[j].chars #[d,o,g,s]\n puts \"Starting #{word}\"\n\n #get i th letter in word, needs to be i not j \n word_letter = word[i] \n\n #compare longest string array at index 0 to words at index 0\n puts \"Comparing #{i} #{longest_letter} : #{word_letter}\"\n if longest_letter != word_letter #d == d \n return prefix\n end\n j += 1\n end\n #finished with j loop without breaking, save prefix BEFORE moving onto next letter comparisons\n prefix = prefix + longest_string_array[i] # d\n puts \"prefix: #{prefix}\"\n\n i += 1\n end\n return prefix\nend", "def longest_prefix(strings)\n words = strings.length\n min_characters = (strings.min_by{|string|string.length}).length\n prefix = \"\"\n\n min_characters.times do |j|\n letter = strings[0][j]\n\n words.times do |i|\n return prefix if strings[i][j] != letter\n end\n\n prefix += letter\n end\n\n return prefix\nend", "def longest_prefix(strings)\n # Return an empty string \"\" if no common prefix\n\n # shortest string in array\n prefix = strings.min_by(&:length)\n\n for string in strings\n for j in 0...prefix.length\n if prefix[j] != string[j]\n # update prefix from start, up until j (not including)\n prefix = prefix.slice(0, j)\n break\n end\n end\n end\n\n return prefix\nend", "def find_short(string)\n string.split.map(&:length).sort.first\nend" ]
[ "0.89361185", "0.8881807", "0.88110244", "0.8796344", "0.87886435", "0.8780531", "0.8778372", "0.87461585", "0.87158734", "0.87056077", "0.87036514", "0.8697932", "0.8696524", "0.86935776", "0.86565083", "0.86020035", "0.8592066", "0.85364354", "0.85133046", "0.8489889", "0.84732413", "0.84274644", "0.84120303", "0.8405881", "0.83654314", "0.8310549", "0.827658", "0.82512563", "0.82221353", "0.8163061", "0.81413317", "0.81409603", "0.81409603", "0.8112502", "0.80902094", "0.80613637", "0.8047337", "0.8033646", "0.8024581", "0.79880446", "0.79669976", "0.7960314", "0.78962237", "0.7717394", "0.77109593", "0.7692524", "0.76443124", "0.7525254", "0.7404126", "0.73480964", "0.73053396", "0.7263585", "0.7177911", "0.71583897", "0.7151565", "0.7126887", "0.7087827", "0.70351326", "0.695901", "0.68983656", "0.6846452", "0.6844712", "0.6828065", "0.68243456", "0.682003", "0.6777201", "0.6746867", "0.67418694", "0.66901904", "0.6660843", "0.6659833", "0.6655509", "0.66527086", "0.665132", "0.6643194", "0.6641757", "0.66210544", "0.66208863", "0.6594819", "0.65870106", "0.6582979", "0.65638095", "0.65632", "0.6562705", "0.65418786", "0.6539381", "0.6517596", "0.6512961", "0.65097004", "0.6504093", "0.65030915", "0.6476917", "0.6459996", "0.6457395", "0.6446705", "0.6430166", "0.642824", "0.6361726", "0.6357133", "0.632849" ]
0.8359429
25
Create a new proxy connection to the given proxy host and port. Optionally, a :user key may be given to identify the username with which to authenticate.
def initialize(proxy_host, proxy_port = 1080, options = {}) @proxy_host = proxy_host @proxy_port = proxy_port @options = options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_proxy(address, port, user = T.unsafe(nil), password = T.unsafe(nil)); end", "def http_proxy addr, opts={}\n return Net::HTTP unless addr\n\n host, port = addr.split \":\"\n port ||= opts[:port] || 8080\n\n user = opts[:username]\n pass = opts[:password]\n\n Kronk::Cmd.verbose \"Using proxy #{addr}\\n\" if host\n\n Net::HTTP::Proxy host, port, user, pass\n end", "def setup_proxy(proxy_server, port, user_name = nil, password = nil)\n self.http_proxy_setting = {\n http: {\n server: proxy_server,\n port: port\n }\n }\n if user_name and password\n self.http_proxy_setting[:http][:user_name] = user_name\n self.http_proxy_setting[:http][:password] = password\n end\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end", "def connect_to(host, port)\n if @proxy_uri\n Net::HTTP::Proxy(@proxy_uri.host, @proxy_uri.port, unescape(@proxy_uri.user), unescape(@proxy_uri.password)).new(host, port)\n else\n Net::HTTP.new(host, port)\n end\n end", "def open(host, port, connection_options)\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\n connect_timeout: connection_options[:timeout])\n ip_addr = IPAddr.new(Resolv.getaddress(host))\n\n packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack(\"CCnNZ*\")\n socket.send packet, 0\n\n version, status, port, ip = socket.recv(8).unpack(\"CCnN\")\n if status != GRANTED\n socket.close\n raise ConnectError, \"error connecting to proxy (#{status})\"\n end\n\n return socket\n end", "def set_proxy(address,port,user=nil,password=nil)\n @proxy_server={:address=>address,:port=>port,\n :user=>user, :password=>password}\n return self\n end", "def set_proxy(addr, port = T.unsafe(nil), user = T.unsafe(nil), pass = T.unsafe(nil)); end", "def connect_to(host, port)\n if @http_proxy\n\tproxy_uri = URI.parse(@http_proxy)\n\tNet::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(host, port)\n else\n\tNet::HTTP.new(host, port)\n end\n end", "def with_proxy(host, port, username, password)\n @proxy = SmartyStreets::Proxy.new(host, port, username, password)\n self\n end", "def set_proxy proxy, port=nil, user=nil, pwd=nil\n\t\t\n\t\t\n\t\tif !proxy\t\n\t\t\t@proxy_host=@proxy_port=@proxy_user=@proxy_pwd=nil \n\t\t\treturn\n\t\tend\n\n\t\tif proxy.class == String \n\t\t\tif !port && !user && !pwd\n\t\t\t\tproxy = URI.parse(proxy)\n\t\t\telse \n\t\t\t\t@proxy_host= host\n\t\t\t\t@proxy_port= port\n\t\t\t\t@proxy_user= user\n\t\t\t\t@proxy_pwd = pwd\n\t\t\tend\n\t\tend\n\t\t\n\t\tif proxy.class == URI::HTTP \n\t\t\t@proxy_host= proxy.host\n\t\t\t@proxy_port= proxy.port\n\t\t\t@proxy_user= proxy.user\n\t\t\t@proxy_pwd = proxy.password\n\t\tend\n\tend", "def open(host, port, connection_options = nil)\n build_proxy_command_equivalent(connection_options)\n super\n end", "def open( host, port )\n connect_string = \"CONNECT #{host}:#{port} HTTP/1.0\"\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts\n\n resp = parse_response( socket )\n\n return socket if resp[:code] == 200\n\n socket.shutdown\n raise ConnectError, resp.inspect unless resp[:code] == 407\n\n user = proxy_user\n passwd = proxy_password\n\n raise UnauthorizedError, \"no proxy user given\" unless user\n\n auth = resp[:headers][\"Proxy-Authenticate\"]\n scheme, parms = auth.split( / /, 2 )\n\n case scheme\n when \"Basic\"\n credentials =\n Base64.encode64( \"#{user}:#{passwd}\" ).gsub( /\\n/, \"\" )\n else\n raise NotImplementedError,\n \"authorization scheme #{scheme.inspect} is not supported\"\n end\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts \"Proxy-Authorization: #{scheme} #{credentials}\"\n socket.puts\n\n resp = parse_response( socket )\n\n raise ConnectError, resp.inspect if resp[:code] != 200\n\n return socket\n end", "def open(host, port, connection_options)\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\n connect_timeout: connection_options[:timeout])\n\n methods = [METHOD_NO_AUTH]\n methods << METHOD_PASSWD if options[:user]\n\n packet = [VERSION, methods.size, *methods].pack(\"C*\")\n socket.send packet, 0\n\n version, method = socket.recv(2).unpack(\"CC\")\n if version != VERSION\n socket.close\n raise Net::SSH::Proxy::Error, \"invalid SOCKS version (#{version})\"\n end\n\n if method == METHOD_NONE\n socket.close\n raise Net::SSH::Proxy::Error, \"no supported authorization methods\"\n end\n\n negotiate_password(socket) if method == METHOD_PASSWD\n\n packet = [VERSION, CMD_CONNECT, 0].pack(\"C*\")\n\n if host =~ /^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/\n packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack(\"C*\")\n else\n packet << [ATYP_DOMAIN, host.length, host].pack(\"CCA*\")\n end\n\n packet << [port].pack(\"n\")\n socket.send packet, 0\n\n version, reply, = socket.recv(2).unpack(\"C*\")\n socket.recv(1)\n address_type = socket.recv(1).getbyte(0)\n case address_type\n when 1\n socket.recv(4) # get four bytes for IPv4 address\n when 3\n len = socket.recv(1).getbyte(0)\n hostname = socket.recv(len)\n when 4\n ipv6addr hostname = socket.recv(16)\n else\n socket.close\n raise ConnectError, \"Illegal response type\"\n end\n portnum = socket.recv(2)\n\n unless reply == SUCCESS\n socket.close\n raise ConnectError, \"#{reply}\"\n end\n\n return socket\n end", "def open( host, port )\n sock = TCPSocket.new( @proxy_host, @proxy_port )\n\n ip_addr = IPAddr.new( Resolv.getaddress( host ) )\n \n packet = [ SOCKS_VERSION, SOCKS_CMD_CONNECT,\n port.to_i, ip_addr.to_i,\n proxy_user, 0 ].pack( \"CCnNA*C\" )\n sock.send packet, 0\n\n version, status, port, ip = sock.recv( 8 ).unpack( \"CCnN\" )\n if status != SOCKS_GRANTED\n sock.close\n raise ConnectError, \"error connecting to proxy (#{status})\"\n end\n\n return sock\n end", "def create_pw_client(opts = {})\n usr = opts[:user] || user()\n pw = opts[:password] || password()\n remote = opts[:remote_name] || self.remote_name\n\n logger.info(\"Authorizing #{usr} to work with #{remote}.\")\n\n configure_octokit(opts)\n\n Octokit::Client.new(:login => usr, :password => pw)\n end", "def connect_using_proxy(socket); end", "def initialize(proxy_host, proxy_port = 80, options = {})\n @proxy_host = proxy_host\n @proxy_port = proxy_port\n @options = options\n end", "def connect (host, username,port=22)\n begin\n pw = get_password(host, username)\n\n tunnelhost = host\n if @connections.key?(host.to_sym)\n port = @connections[host.to_sym]\n tunnelhost = 'localhost'\n @@log.debug(\"Found local-port forward on port \"+port.to_s) \n end\n\n @connections[host.to_sym] = Net::SSH.start(tunnelhost, username, :password => pw, :port => port)\n rescue Net::SSH::AuthenticationFailed\n retry\n end\n end", "def open(host, port, connection_options)\n socket = establish_connection(connection_options[:timeout])\n socket.write \"CONNECT #{host}:#{port} HTTP/1.1\\r\\n\"\n socket.write \"Host: #{host}:#{port}\\r\\n\"\n\n if options[:user]\n credentials = [\"#{options[:user]}:#{options[:password]}\"].pack(\"m*\").gsub(/\\s/, \"\")\n socket.write \"Proxy-Authorization: Basic #{credentials}\\r\\n\"\n end\n\n socket.write \"\\r\\n\"\n\n resp = parse_response(socket)\n\n return socket if resp[:code] == 200\n\n socket.close\n raise ConnectError, resp.inspect\n end", "def set_proxy address, port, user = nil, password = nil\n @proxy_addr = address\n @proxy_port = port\n @proxy_user = user\n @proxy_pass = password\n\n @agent.set_proxy address, port, user, password\n end", "def initialize(host, port, proxy=nil, proxy_port=nil, proxy_user=nil, proxy_passwd=nil)\n\t\t\tconn = Net::HTTP.new(host, port, proxy, proxy_port, proxy_user, proxy_passwd)\n\t\t\tconn.use_ssl = true\n\t\t\t#conn.enable_post_connection_check= true\n\t\t\tconn.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\t\t\t#conn.verify_mode = OpenSSL::SSL::VERIFY_NONE \n\t\t\t# uncomment the previous line at your own risk : the certificate won't be verified !\n\t\t\tstore = OpenSSL::X509::Store.new\n\t\t\tstore.set_default_paths\n\t\t\tconn.cert_store = store\n\t\t\tconn.start\n\t\t\t@http_connection = conn\n\t\tend", "def initialize( proxy_host, proxy_port=1080, options={} )\n @proxy_host = proxy_host\n @proxy_port = proxy_port\n @options = options\n end", "def initialize(host = nil, port = DEFAULT_PORT, user = nil, secret = nil)\n if host\n connect(host, port)\n authenticate(user, secret) if user and secret\n end\n end", "def add_proxy(proxy_path, opts={})\n @proxies[proxy_path.to_sym] = HashStruct.new(opts)\n return self\n end", "def proxy(url, opts={})\n @proxies[url] = opts\n end", "def test_using_proxy_params_hash\n proxy = {\n http: PROXY,\n ssl: PROXY\n }\n\n run_test_with proxy: proxy\n end", "def setup_connection\n connection = Net::HTTP::Proxy @config[:proxy_address], @config[:proxy_port], @config[:proxy_user], @config[:proxy_address]\n @connection = connection.new @config[:host], @config[:port]\n\n setup_ssl if @config[:use_ssl]\n\n @connection.open_timeout = @config[:timeout]\n @connection.read_timeout = @config[:timeout]\n end", "def set_up_connection # :doc:\n connection_class = Net::HTTP::Proxy @config[:proxy_addr],\n @config[:proxy_port], @config[:proxy_user], @config[:proxy_pass]\n @connection = connection_class.new @config[:host], @config[:port]\n set_up_ssl\n @connection.open_timeout = @config[:timeout]\n @connection.read_timeout = @config[:timeout]\n end", "def proxy(arg = nil)\n return @proxy if arg.nil?\n warn 'Warning: use of proxy(new_value) to set connection proxy have been DEPRECATED and will be removed in Faraday 1.0'\n @manual_proxy = true\n @proxy = ProxyOptions.from(arg)\n end", "def initialize(host, port, mail, passwd, proxy=nil, proxy_port=nil, proxy_user=nil, proxy_passwd=nil)\t\n conn = Net::HTTP.new(host, port, proxy, proxy_port, proxy_user, proxy_passwd)\n conn.use_ssl = true\n # #conn.enable_post_connection_check= true\n # #conn.verify_mode = OpenSSL::SSL::VERIFY_PEER\n conn.verify_mode = OpenSSL::SSL::VERIFY_NONE \n # # uncomment the previous line at your own risk : the certificate won't be verified !\n # store = OpenSSL::X509::Store.new\n # store.set_default_paths\n # conn.cert_store = store\n @mail = mail\n @passwd = passwd\n @http_connection = conn\n @token_ttl = Time.now\n @token = login(@mail, @passwd)\n @headers = {'Content-Type'=>'application/atom+xml', 'Authorization'=> 'GoogleLogin auth='+@token}\n end", "def proxy_command\n !config.proxy_user and log_and_raise(SSHError, \"You must specify an proxy user in order to SSH proxy.\")\n !config.proxy_host_name and log_and_raise(SSHError, \"You must specify an proxy host_name in order to SSH proxy.\")\n\n process_keys\n verbosity = ((ENV['LOG_LEVEL'] == \"DEBUG\") ? '-vv' : '-q')\n\n command = Array.new\n # command << [ %(sshpass -p '#{config.proxy_password}') ] if config.proxy_password\n command << [ %(ssh) ]\n command << [ verbosity ]\n command << [ \"-x\" ]\n command << [ \"-a\" ]\n command << [ \"-o\", \"UserKnownHostsFile=/dev/null\" ]\n command << [ \"-o\", \"StrictHostKeyChecking=no\" ]\n command << [ \"-o\", \"KeepAlive=yes\" ]\n command << [ \"-o\", \"ServerAliveInterval=60\" ]\n !config.proxy_keys.nil? and !config.proxy_keys.empty? and [config.proxy_keys].flatten.compact.each do |proxy_key|\n command << [ \"-i\", proxy_key ]\n end\n command << [ \"-p\", config.proxy_port ] if config.proxy_port\n command << \"#{config.proxy_user}@#{config.proxy_host_name}\"\n command << \"'/usr/bin/env nc %h %p'\"\n command = command.flatten.compact.join(' ')\n config.ui.logger.debug { \"proxy_command(#{command.inspect})\" }\n command\n end", "def initialize(proxy_addr, proxy_port)\n timeout = ProxyFetcher.config.proxy_validation_timeout\n\n @http = HTTP.follow.via(proxy_addr, proxy_port.to_i).timeout(connect: timeout, read: timeout)\n end", "def get_proxy_from_env\n env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']\n\n return nil if env_proxy.nil? or env_proxy.empty?\n\n uri = URI.parse env_proxy\n\n if uri and uri.user.nil? and uri.password.nil? then\n # Probably we have http_proxy_* variables?\n uri.user = escape(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER'])\n uri.password = escape(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS'])\n end\n\n uri\n end", "def initialize(connection_to_socket, args = {})\n @connection = connection_to_socket\n @user = args[:user]\n @password = args[:password]\n\n srv = connection.protocol::Connect.new(\n protocol: 19,\n user: args[:user],\n password: args[:password]\n ).process(connection)\n\n @session = srv[:session] || OrientdbBinary::OperationTypes::NEW_SESSION\n end", "def test_using_proxy_params_hash_with_longer_names_httpproxy_sslproxy\n proxy = {\n httpProxy: PROXY,\n sslProxy: PROXY\n }\n\n run_test_with proxy: proxy\n end", "def create()\n # Do we already have a connection?\n if @is_scproxy and self.has_session?\n # Close it before starting a new one\n self.close()\n end\n # Create a new\n if @is_scproxy and @api\n # Let the master create a new proxy\n response = self.proxy_new :master => true\n # Did we get on?\n if response[\"status\"] == true\n @port = response[\"result\"][\"port\"]\n else\n # Show the error\n raise response[\"message\"]\n end\n end\n\n if @port.nil?\n raise \"Coult not create a new proxy\"\n end\n\n return @port\n end", "def initialize(*args)\n super\n useful_variable = PROXY_ENVIRONMENT_VARIABLES.detect {|v| ENV.has_key?(v)}\n if ENV[useful_variable].match(/^[[:alpha:]]+:\\/\\//)\n @proxy = URI.parse(ENV[useful_variable])\n else\n @proxy = URI.parse(\"http://\" + ENV[useful_variable])\n end\n end", "def build_connection(url)\n\n if config[:proxy]\n proxy = URI.parse(config[:proxy])\n http = Net::HTTP::Proxy(proxy.host, proxy.port).new(url.host, url.port)\n else\n http = Net::HTTP.new(url.host, url.port)\n end\n\n http.set_debug_output($stderr) if config[:debug]\n\n if url.scheme == \"https\"\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n if config[:certificate_path]\n cert = File.read(config[:certificate_path])\n http.key = OpenSSL::PKey::RSA.new(cert)\n http.cert = OpenSSL::X509::Certificate.new(cert)\n end\n\n http\n end", "def initialize opts\n @host = opts[:host]\n @pass = opts[:pass]\n @user = opts[:user]\n end", "def initialize(options = {:retry_auth => true}) \n @authuser = options[:username] || (raise Exception::MissingArgument, \"Must supply a :username\")\n @authkey = options[:api_key] || (raise Exception::MissingArgument, \"Must supply an :api_key\")\n @auth_url = options[:auth_url] || @auth_url = CloudServers::AUTH_USA\n\n auth_uri=nil\n begin\n auth_uri=URI.parse(@auth_url)\n rescue Exception => e\n raise Exception::InvalidArgument, \"Invalid :auth_url parameter: #{e.message}\"\n end\n raise Exception::InvalidArgument, \"Invalid :auth_url parameter.\" if auth_uri.nil? or auth_uri.host.nil?\n @auth_host = auth_uri.host\n @auth_port = auth_uri.port\n @auth_scheme = auth_uri.scheme\n\n @retry_auth = options[:retry_auth]\n @proxy_host = options[:proxy_host]\n @proxy_port = options[:proxy_port]\n @authok = false\n @http = {}\n CloudServers::Authentication.new( self )\n self.class.last_connection = self\n end", "def initialize(url, params = {})\n uri = URI.parse(url)\n @connection = {\n :headers => {},\n :host => uri.host,\n :mock => Excon.mock,\n :path => uri.path,\n :port => uri.port.to_s,\n :query => uri.query,\n :scheme => uri.scheme\n }.merge!(params)\n\n # use proxy from the environment if present\n if ENV.has_key?('http_proxy')\n @proxy = setup_proxy(ENV['http_proxy'])\n elsif params.has_key?(:proxy)\n @proxy = setup_proxy(params[:proxy])\n end\n\n if https?\n # use https_proxy if that has been specified\n if ENV.has_key?('https_proxy')\n @proxy = setup_proxy(ENV['https_proxy'])\n end\n end\n\n if @proxy\n @connection[:headers]['Proxy-Connection'] ||= 'Keep-Alive'\n end\n\n @socket_key = '' << @connection[:host] << ':' << @connection[:port]\n reset\n end", "def http_proxy(addr=nil, port = nil)\n default_options[:http_proxyaddr] = addr\n default_options[:http_proxyport] = port\n end", "def initialize(username, password, host=HOST_PRODUCTION)\n @username = username\n @password = password\n @host = host\n end", "def configure_proxy(options, env)\n proxy = request_options(env)[:proxy]\n return unless proxy\n\n options[:proxy] = {\n host: proxy[:uri].host,\n port: proxy[:uri].port,\n authorization: [proxy[:user], proxy[:password]]\n }\n end", "def initialize(proto,host,path,username = nil, password = nil)\n @proto, @host, @path, @username, @password = proto, host, path, username, password\n @url = \"#{@proto}://#{@host}#{@path}\"\n if @username.nil? and @password.nil?\n @session = RestClient::Resource.new(@url)\n else\n @session = RestClient::Resource.new(@url, :user => @username, :password => @password)\n end\n end", "def initialize(handler: nil, proxy_host: nil, proxy_port: nil)\n self.handler = handler\n self.proxy_host = proxy_host\n self.proxy_port = proxy_port\n end", "def build_http(host, port)\n params = [host, port]\n params += @proxy_options.values_at(:host, :port, :user, :pass) unless @proxy_options.empty?\n http = add_ssl(Net::HTTP.new(*params))\n http = add_http_options(http) unless @http_options.empty?\n http\n end", "def http_proxy\n @http_proxy ||= begin\n proxy = get_env('HTTP_PROXY') || return\n proxy = \"http://#{proxy}\" unless proxy =~ /^https?:/\n uri = URI.parse(proxy)\n uri.user ||= get_env('HTTP_PROXY_USER')\n uri.password ||= get_env('HTTP_PROXY_PASS')\n uri\n end\n end", "def initialize(host, port = 389, login_dn, base_dn, password)\n @host = host\n @port = port\n @login_dn = login_dn\n @base_dn = base_dn\n @password = password\n\n return connect\n end", "def proxy(to)\n response = connection.post(\"/v1/auth/proxy?to=#{to}\")\n case response.status\n when 200\n Success(response.body)\n else\n Failure(\"Status: #{response.status}\\n#{response.body}\")\n end\n end", "def initialize(connection_to_socket, args = {})\n @connection = connection_to_socket\n\n @user = args[:user]\n @password = args[:password]\n @name = args[:name]\n @storage = args[:storage]\n\n open\n end", "def parse_proxy(uri)\n proxy = URI.parse(uri)\n self.proxy_host = proxy.host\n self.proxy_port = proxy.port\n self.proxy_user = proxy.user\n self.proxy_password = proxy.password\n end", "def proxified_socket(host, port)\n proxy = ENV[\"https_proxy\"] || ENV[\"http_proxy\"] || false\n\n if proxy && !fuzzy_hostname_match_any?(host, ENV[\"no_proxy\"])\n Proxifier.Proxy(proxy).open(host, port)\n else\n TCPSocket.new(host, port)\n end\n end", "def initialize(host = nil, user = nil, passwd = nil, acct = nil)\n super()\n @binary = true\n @passive = false\n @debug_mode = false\n @resume = false\n if host\n\t connect(host)\n\t if user\n\t login(user, passwd, acct)\n\t end\n end\n end", "def via(host, user, options={})\n @default_gateway = Net::SSH::Gateway.new(host, user, options)\n self\n end", "def user\n Proxy.new(connection, './user')\n end", "def initialize(opts)\n # Get the options and assign default values:\n @host = opts[:host]\n @port = opts[:port] || 443\n @username = opts[:username]\n @password = opts[:password]\n @insecure = opts[:insecure] || false\n @ca_file = opts[:ca_file]\n @log = opts[:log]\n @debug = opts[:debug] || false\n @proxy_url = opts[:proxy_url]\n @proxy_username = opts[:proxy_username]\n @proxy_password = opts[:proxy_password]\n @timeout = opts[:timeout]\n\n # Create the HTTP client:\n @client = HttpClient.new(\n host: @host,\n port: @port,\n insecure: @insecure,\n ca_file: @ca_file,\n log: @log,\n debug: @debug,\n proxy_url: @proxy_url,\n proxy_username: @proxy_username,\n proxy_password: @proxy_password,\n timeout: @timeout\n )\n end", "def proxyuserpwd=(value)\n Curl.set_option(:proxyuserpwd, value_for(value, :string), handle)\n end", "def establish\n @proxy = XMLRPC::Client.new(@hostname, '/RPC2', @port).proxy(@proxy_name)\n end", "def initialize(host, user, password)\n @host = host\n @connection = Net::SSH.start(@host, user, :password => password)\n end", "def to_proxy(node)\n addr, port = node.split(\":\")\n\n ProxyFetcher::Proxy.new.tap do |proxy|\n proxy.addr = addr\n proxy.port = Integer(port)\n proxy.country = \"Unknown\"\n proxy.anonymity = \"Unknown\"\n proxy.type = ProxyFetcher::Proxy::HTTP\n end\n end", "def proxyauth=(value)\n Curl.set_option(:proxyauth, value_for(value, :string), handle)\n end", "def parse_proxy_info\r\n raw = @env[\"HTTP_PROXY\"] || @env[\"http_proxy\"]\r\n return {} unless raw\r\n\r\n main_str = raw\r\n .strip\r\n .sub(/^http:\\/\\//, \"\")\r\n .sub(/\\/+$/, \"\")\r\n\r\n auth_str = main_str.match(/(.*)@/).to_a[1].to_s\r\n host_str = main_str.sub(/^.*@/, \"\")\r\n {\r\n host: host_str.sub(/:.*$/, \"\"),\r\n port: host_str.match(/:(.*)/).to_a[1].try(:to_i), # int or nil\r\n user: auth_str.sub(/:.*$/, \"\"),\r\n pass: auth_str.sub(/^.*:/, \"\")\r\n }.select { |_, value| value.present? }\r\n end", "def initialize(user,pw,options={})\n options = DEFAULT_OPTIONS.merge(options)\n \n @user = user\n @pw = pw\n \n connect if options[:connect]\n listen if options[:listen]\n join_muc(options[:muc]) if options[:muc]\n \n @allowed_roster = options[:roster]\n @redirects = {}\n end", "def create_proxy(record_har: true)\n if @server.nil?\n start_server\n end\n @record_har = record_har\n @proxy = @server.create_proxy\n self\n end", "def set_proxy(opts)\n opts = check_params(opts,[:proxy_info])\n super(opts)\n end", "def make_connection\n Rightscale::HttpConnection.new(:user_agent => \"RightLink v#{AgentConfig.protocol_version}\",\n :logger => @logger,\n :proxy_host => @proxy.host,\n :proxy_port => @proxy.port,\n :proxy_username => @proxy.user,\n :proxy_password => @proxy.password,\n :exception => ReposeConnectionFailure,\n :fail_if_ca_mismatch => true,\n :ca_file => get_ca_file)\n end", "def set_auth(uri, username = nil, password = nil)\n connection = Faraday.new url: uri, ssl: {verify: false} do |faraday|\n faraday.adapter http_engine\n faraday.proxy(ENV['http_proxy']) if ENV['http_proxy']\n end\n set_username_and_password connection, username, password if username\n connection\n end", "def test_using_params_hash_with_http_scheme\n proxy = {\n http: \"http://#{PROXY}\",\n ssl: \"http://#{PROXY}\"\n }\n\n run_test_with proxy: proxy\n end", "def build_proxy_command_equivalent(connection_options = nil)\n first_jump, extra_jumps = jump_proxies.split(\",\", 2)\n config = connection_options && connection_options[:config]\n uri = URI.parse(\"ssh://#{first_jump}\")\n\n template = \"ssh\".dup\n template << \" -l #{uri.user}\" if uri.user\n template << \" -p #{uri.port}\" if uri.port\n template << \" -J #{extra_jumps}\" if extra_jumps\n template << \" -F #{config}\" if config != true && config\n template << \" -W %h:%p \"\n template << uri.host\n\n @command_line_template = template\n end", "def proxy(remote, options = {})\n server = create_server(options)\n host, port, extra = remote.split(\":\", 3)\n raise \"Specify the remote parameter in 'hostname_or_ip:port' format\" if extra || port.to_i == 0 || host.empty?\n Reactor.queue_task do\n monitor = Reactor.selector.register(server, :r)\n monitor.value = proc do\n accept_socket server, options do |client|\n srv = open_socket \"tcp://#{remote}\", options\n adapter = PROXY_ADAPTER.new(srv, client, options)\n Reactor.queue_task do\n adapter.add_to_reactor\n end\n logger.info \"Proxy connection established between #{srv} and #{client}\"\n end\n end\n end\n logger.info \"Proxy Host listening for new connections on port \" + options[:port].to_s\n Reactor.start\n server\n end", "def initialize(host, username = nil, passwd = nil,detec = nil)\n @control_url = \"http://#{host}/cgi-bin/\"\n @username = username\n @password = passwd\n @deteccion = detec\n @auth_id = Base64.encode64(\"#{username}:#{passwd}\") if username\n end", "def new_websocket_client(client)\n\n msg \"connecting to: %s:%s\" % [@target_host, @target_port]\n tsock = TCPSocket.open(@target_host, @target_port)\n\n if @verbose then puts @@Traffic_legend end\n\n begin\n do_proxy(client, tsock)\n rescue\n tsock.shutdown(Socket::SHUT_RDWR)\n tsock.close\n raise\n end\n end", "def create_client_connection(host, port, db)\n Connection.new(host, port, db, @handle)\n end", "def proxy_userpass(proxies = [proxy[0]])\n proxies = [proxies] if proxies.class != Array\n proxies.map! {|p| p.downcase }\n userpass = (@@proxy_userpass[proxies[0]] || LinkToLoad.ask_for_userpass('proxy'))\n proxies.each {|p| @@proxy_userpass[p] = userpass }\n userpass\n end", "def set_akismet_proxy(proxyHost, proxyPort) \n @proxyPort = proxyPort\n @proxyHost = proxyHost\n end", "def proxy=(new_proxy)\n @proxy = case new_proxy\n when Spidr::Proxy\n new_proxy\n when Hash\n Spidr::Proxy.new(**new_proxy)\n when String, URI::HTTP\n proxy_uri = URI(new_proxy)\n\n Spidr::Proxy.new(\n host: proxy_uri.host,\n port: proxy_uri.port,\n user: proxy_uri.user,\n password: proxy_uri.password\n )\n when nil\n Spidr::Proxy.new\n else\n raise(TypeError,\"#{self.class}#{__method__} only accepts Spidr::Proxy, URI::HTTP, Hash, or nil\")\n end\n end", "def initialize(username, password, http_adapter = nil)\r\n http_adapter = http_adapter.nil? ? HTTPAdapter.new : http_adapter\r\n http_adapter.set_auth(username, password)\r\n\r\n @http_client = HTTPClient.new(CLX::base_url, http_adapter)\r\n end", "def initialize hostname, user=nil, apikey=nil\n @user = user\n @apikey = apikey\n @hostname = hostname\n initialize_connection @hostname\n end", "def test_using_proxy_object_from_uri_with_http_scheme\n proxy = Selenium::WebDriver::Proxy.new(\n http: URI(\"http://#{PROXY}\"),\n ssl: URI(\"http://#{PROXY}\")\n )\n\n run_test_with proxy: proxy\n end", "def initialize(host, user, password = nil, options = {})\n @host = host\n @user = user\n @password = password\n\n @options = {\n :remember_host => false,\n :verbose => :warn,\n :non_interactive => true,\n :use_agent => false\n }.merge(options)\n\n @options[:password] = password if password\n\n # Pull our custom keys out of the hash because the SSH initializer will complain\n @remember_host = @options.delete(:remember_host)\n @su_user = @options.delete(:su_user)\n @su_password = @options.delete(:su_password)\n @passwordless_sudo = @options.delete(:passwordless_sudo)\n\n # Obsolete, delete if passed in\n @options.delete(:authentication_prompt_delay)\n end", "def set_up_connection # :doc:\n uri = URI.parse(@config.host)\n @http = Net::HTTP.new(uri.host, uri.port, p_user = @config.proxy_user, p_pass = @config.proxy_pass)\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n @http.use_ssl = @config.use_ssl\n if @config.ssl_verify_peer\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n @http.ca_file = @config.ssl_ca_file\n else\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n @http.open_timeout = @config.timeout\n @http.read_timeout = @config.timeout\n end", "def process_arguments( *args )\n @options = {}\n @username = ENV['USER'] || ENV['USERNAME']\n\n raise ArgumentError,\n \"you must specify the host to connect to\" if args.length < 1\n\n @host = args.shift\n\n # support for both named arguments, and positional arguments...\n if args.length == 1 && args[0].is_a?( Hash ) &&\n ( args[0][:username] || args[0][:password] ||\n args[0][:port] || args[0][:options] )\n # then\n @username = args[0][:username] || @username\n @password = args[0][:password]\n\n @options.update args.shift\n else\n @options[ :port ] = args.shift if args.first.is_a? Numeric\n if args.first.nil? || args.first.is_a?( String )\n @username = args.shift || @username\n end\n if args.first.nil? || args.first.is_a?( String )\n @password = args.shift\n end\n @options.update args.shift if args.first.is_a?( Hash )\n end\n\n if !args.empty?\n raise ArgumentError, \"extra parameters detected: #{args.inspect}\"\n elsif @username.nil?\n raise ArgumentError, \"no username was given and none could be inferred from the environment\"\n end\n\n @keys = @options[ :keys ]\n @host_keys = @options[ :host_keys ]\n @auth_methods = @options[ :auth_methods ]\n @forward_agent = @options[ :forward_agent ] || false\n @crypto_backend = @options.fetch( :crypto_backend, :ossl )\n @host_key_verifier = host_key_verifier_from(@options.fetch(:paranoid, true))\n\n verbose = @options.fetch( :verbose, :warn )\n log = @options.fetch( :log, STDERR )\n\n @registry_options = @options.fetch( :registry_options, {} )\n\n @registry_options[ :logs ] ||= {}\n @registry_options[ :logs ][ :default_level ] = verbose\n\n if log.is_a? IO\n @registry_options[ :logs ][ :device ] ||= log\n else\n @registry_options[ :logs ][ :filename ] ||= log\n end\n\n @registry = @options[ :container ] ||\n Needle::Registry.new( @registry_options )\n\n [ :keys, :host_keys, :auth_methods, :username, :password,\n :crypto_backend, :registry_options, :container, :log, :verbose,\n :forward_agent, :paranoid\n ].each do |i|\n @options.delete i\n end\n\n @options.freeze\n end", "def initialize(name, ip, url_endpoint)\n @name = name\n @ip = ip\n @url = \"http://#{ip}/#{url_endpoint}\"\n @username = \"\"\n @password = \"\"\n end", "def initialize(host, username, options = {}, &block) # :yields: session\n # connection settings\n @host = host\n @port = options[:port] || 513\n @username = username\n @password = options[:password] || nil\n @local_host = options[:local_host] || \"0.0.0.0\"\n @local_port = options[:local_port] || 1023\n @client_user_name = options[:client_user_name] || \"\"\n @server_user_name = options[:server_user_name] || \"\"\n @terminal_type = options[:terminal_type] || \"xterm\"\n @speed = options[:speed] || 38400\n @rows = options[:rows] || 24\n @columns = options[:columns] || 80\n @pixel_x = options[:pixel_x] || 0\n @pixel_y = options[:pixel_y] || 0\n \n # parser settings\n @login_token = options[:login_token] || /login:\\s$/\n @password_token = options[:password_token] || /Password:\\s$/\n @prompt = options[:prompt] || /^[^\\n]*[#\\$]> $/\n @logout_token = options[:logout_token] || /exit\\s+logout$/\n \n # logging\n @logger = options[:logger]\n \n # buffer\n @receive_buffer = \"\"\n @logged_in = false\n \n # start the session if a block is given\n self.session(&block) if block\n end", "def initialize(proxy)\n @proxy_uri =\n case proxy\n when :no_proxy then nil\n when nil then get_proxy_from_env\n when URI::HTTP then proxy\n else URI.parse(proxy)\n end\n end", "def apply_env_proxy_settings(settings)\n $stderr.puts(\"Using proxy #{settings}\") if ENV[\"DEBUG\"]\n scheme = settings[:protocol].downcase\n java.lang.System.setProperty(\"#{scheme}.proxyHost\", settings[:host])\n java.lang.System.setProperty(\"#{scheme}.proxyPort\", settings[:port].to_s)\n java.lang.System.setProperty(\"#{scheme}.proxyUsername\", settings[:username].to_s)\n java.lang.System.setProperty(\"#{scheme}.proxyPassword\", settings[:password].to_s)\n end", "def create_outbound_tcp_socket\n label = \"#{@remote_host}:#{@remote_port}\"\n if @proxy_url\n log.info(\"Connecting to #{label} through proxy #{@proxy_url}\")\n\n popts = {}\n popts[:user_agent] = ENV['HTTP_USER_AGENT'] if ENV['HTTP_USER_AGENT']\n\n if popts[:user_agent]\n log.debug('Passing User-Agent: ' + popts[:user_agent].inspect)\n end\n\n @proxy = Proxifier::Proxy(@proxy_url, popts)\n tcp_socket = @proxy.open(@remote_host, @remote_port)\n else\n log.info(\"Connecting to #{label}\")\n tcp_socket = TCPSocket.new(@remote_host, @remote_port)\n end\n\n if @use_ssl\n create_ssl_socket(tcp_socket, @ssl_opts)\n else\n tcp_socket\n end\n end", "def initialize(opts = {})\n @host = opts[:host] || '127.0.0.1'\n @port = opts[:port] || 4001\n @config = Config.new\n @config.read_timeout = opts[:read_timeout] || 60\n @config.allow_redirect = opts.key?(:allow_redirect) ? opts[:allow_redirect] : true\n @config.use_ssl = opts[:use_ssl] || false\n @config.verify_mode = opts.key?(:verify_mode) ? opts[:verify_mode] : OpenSSL::SSL::VERIFY_PEER\n @config.user_name = opts[:user_name] || nil\n @config.password = opts[:password] || nil\n @config.allow_redirect = opts.key?(:allow_redirect) ? opts[:allow_redirect] : true\n @config.ca_file = opts.key?(:ca_file) ? opts[:ca_file] : nil\n #Provide a OpenSSL X509 cert here and not the path. See README\n @config.ssl_cert = opts.key?(:ssl_cert) ? opts[:ssl_cert] : nil\n #Provide the key (content) and not just the filename here. \n @config.ssl_key = opts.key?(:ssl_key) ? opts[:ssl_key] : nil\n yield @config if block_given?\n end", "def set_proxy(proxy='')\r\n RestClient.proxy = proxy.empty? ? ENV['http_proxy'] : proxy\r\n end", "def set_proxy(proxy='')\r\n RestClient.proxy = proxy.empty? ? ENV['http_proxy'] : proxy\r\n end", "def proxy_user; end" ]
[ "0.69448906", "0.676763", "0.67436266", "0.6698953", "0.6698953", "0.6698953", "0.6698953", "0.6698953", "0.6698953", "0.6698953", "0.6677544", "0.66153663", "0.6614841", "0.6578097", "0.6505692", "0.6496108", "0.64199877", "0.64193255", "0.639969", "0.6374131", "0.6208548", "0.61710626", "0.6164498", "0.6038837", "0.59920335", "0.59769565", "0.5964769", "0.59070694", "0.58922553", "0.5867073", "0.5822168", "0.5772285", "0.57510096", "0.57116586", "0.5643803", "0.56260055", "0.5623558", "0.5621703", "0.56081927", "0.5601816", "0.5597362", "0.5561602", "0.5559062", "0.55530953", "0.55425733", "0.5539791", "0.55381316", "0.55316955", "0.55254257", "0.55216676", "0.55179024", "0.5508886", "0.5498971", "0.5495225", "0.54853404", "0.54773736", "0.5471681", "0.5470933", "0.5452787", "0.54415447", "0.54381156", "0.543642", "0.5435745", "0.54326177", "0.5409629", "0.54088765", "0.5392982", "0.5384915", "0.5384665", "0.5384408", "0.53818315", "0.53756684", "0.53674287", "0.5365141", "0.5356133", "0.5346753", "0.53346115", "0.53345025", "0.5307643", "0.5293793", "0.5279489", "0.52665985", "0.5261256", "0.5248426", "0.5241958", "0.5237135", "0.5235616", "0.52194375", "0.52145416", "0.5206701", "0.52064687", "0.51998067", "0.5196994", "0.5194281", "0.5184899", "0.5182538", "0.5181951", "0.5181951", "0.5181246" ]
0.6005994
25
Return a new socket connected to the given host and port via the proxy that was requested when the socket factory was instantiated.
def open(host, port, connection_options) socket = Socket.tcp(proxy_host, proxy_port, nil, nil, connect_timeout: connection_options[:timeout]) ip_addr = IPAddr.new(Resolv.getaddress(host)) packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack("CCnNZ*") socket.send packet, 0 version, status, port, ip = socket.recv(8).unpack("CCnN") if status != GRANTED socket.close raise ConnectError, "error connecting to proxy (#{status})" end return socket end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proxified_socket(host, port)\n proxy = ENV[\"https_proxy\"] || ENV[\"http_proxy\"] || false\n\n if proxy && !fuzzy_hostname_match_any?(host, ENV[\"no_proxy\"])\n Proxifier.Proxy(proxy).open(host, port)\n else\n TCPSocket.new(host, port)\n end\n end", "def open( host, port )\n sock = TCPSocket.new( @proxy_host, @proxy_port )\n\n ip_addr = IPAddr.new( Resolv.getaddress( host ) )\n \n packet = [ SOCKS_VERSION, SOCKS_CMD_CONNECT,\n port.to_i, ip_addr.to_i,\n proxy_user, 0 ].pack( \"CCnNA*C\" )\n sock.send packet, 0\n\n version, status, port, ip = sock.recv( 8 ).unpack( \"CCnN\" )\n if status != SOCKS_GRANTED\n sock.close\n raise ConnectError, \"error connecting to proxy (#{status})\"\n end\n\n return sock\n end", "def open( host, port )\n connect_string = \"CONNECT #{host}:#{port} HTTP/1.0\"\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts\n\n resp = parse_response( socket )\n\n return socket if resp[:code] == 200\n\n socket.shutdown\n raise ConnectError, resp.inspect unless resp[:code] == 407\n\n user = proxy_user\n passwd = proxy_password\n\n raise UnauthorizedError, \"no proxy user given\" unless user\n\n auth = resp[:headers][\"Proxy-Authenticate\"]\n scheme, parms = auth.split( / /, 2 )\n\n case scheme\n when \"Basic\"\n credentials =\n Base64.encode64( \"#{user}:#{passwd}\" ).gsub( /\\n/, \"\" )\n else\n raise NotImplementedError,\n \"authorization scheme #{scheme.inspect} is not supported\"\n end\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts \"Proxy-Authorization: #{scheme} #{credentials}\"\n socket.puts\n\n resp = parse_response( socket )\n\n raise ConnectError, resp.inspect if resp[:code] != 200\n\n return socket\n end", "def open_socket()\n socket = nil\n if @socket\n socket = @socket\n else\n Timeout::timeout(@sock_timeout) { socket = TCPSocket.new(@server, @port) }\n BasicSocket.do_not_reverse_lookup = true\n end\n\n return(socket)\n end", "def connect_using_proxy(socket); end", "def create_outbound_tcp_socket\n label = \"#{@remote_host}:#{@remote_port}\"\n if @proxy_url\n log.info(\"Connecting to #{label} through proxy #{@proxy_url}\")\n\n popts = {}\n popts[:user_agent] = ENV['HTTP_USER_AGENT'] if ENV['HTTP_USER_AGENT']\n\n if popts[:user_agent]\n log.debug('Passing User-Agent: ' + popts[:user_agent].inspect)\n end\n\n @proxy = Proxifier::Proxy(@proxy_url, popts)\n tcp_socket = @proxy.open(@remote_host, @remote_port)\n else\n log.info(\"Connecting to #{label}\")\n tcp_socket = TCPSocket.new(@remote_host, @remote_port)\n end\n\n if @use_ssl\n create_ssl_socket(tcp_socket, @ssl_opts)\n else\n tcp_socket\n end\n end", "def create_socket\n if @uri.scheme == 'wss'\n create_ssl_socket.tap(&:connect)\n else\n TCPSocket.new(@uri.host, @port)\n end\n end", "def socket\n @socket ||= TCPSocket.new(host, port)\n end", "def open_socket\n @socket = Socket.new(:INET, :DGRAM)\n @socket.connect_nonblock Socket.sockaddr_in(@port, @host)\n end", "def create_socket\n socket = ::Socket.new(::Socket::AF_INET, ::Socket::SOCK_STREAM, 0)\n sockaddr = ::Socket.sockaddr_in(PORTS.sample, self.hostname)\n begin # emulate blocking connect\n socket.connect_nonblock(sockaddr)\n rescue IO::WaitWritable\n IO.select(nil, [socket]) # wait 3-way handshake completion\n begin\n socket.connect_nonblock(sockaddr) # check connection failure\n rescue Errno::EISCONN\n end\n end\n socket\n end", "def open(host, port, connection_options)\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\n connect_timeout: connection_options[:timeout])\n\n methods = [METHOD_NO_AUTH]\n methods << METHOD_PASSWD if options[:user]\n\n packet = [VERSION, methods.size, *methods].pack(\"C*\")\n socket.send packet, 0\n\n version, method = socket.recv(2).unpack(\"CC\")\n if version != VERSION\n socket.close\n raise Net::SSH::Proxy::Error, \"invalid SOCKS version (#{version})\"\n end\n\n if method == METHOD_NONE\n socket.close\n raise Net::SSH::Proxy::Error, \"no supported authorization methods\"\n end\n\n negotiate_password(socket) if method == METHOD_PASSWD\n\n packet = [VERSION, CMD_CONNECT, 0].pack(\"C*\")\n\n if host =~ /^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/\n packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack(\"C*\")\n else\n packet << [ATYP_DOMAIN, host.length, host].pack(\"CCA*\")\n end\n\n packet << [port].pack(\"n\")\n socket.send packet, 0\n\n version, reply, = socket.recv(2).unpack(\"C*\")\n socket.recv(1)\n address_type = socket.recv(1).getbyte(0)\n case address_type\n when 1\n socket.recv(4) # get four bytes for IPv4 address\n when 3\n len = socket.recv(1).getbyte(0)\n hostname = socket.recv(len)\n when 4\n ipv6addr hostname = socket.recv(16)\n else\n socket.close\n raise ConnectError, \"Illegal response type\"\n end\n portnum = socket.recv(2)\n\n unless reply == SUCCESS\n socket.close\n raise ConnectError, \"#{reply}\"\n end\n\n return socket\n end", "def create(param)\n\t\tsock = nil\n\n\t\t# Notify handlers before we create the socket\n\t\tnotify_before_socket_create(self, param)\n\n\t\tcase param.proto\n\t\t\twhen 'tcp'\n\t\t\t\tsock = net.socket.create(param)\n\t\t\telse\n\t\t\t\traise Rex::UnsupportedProtocol.new(param.proto), caller\n\t\tend\n\n\t\t# Notify now that we've created the socket\n\t\tnotify_socket_created(self, sock, param)\n\n\t\t# Return the socket to the caller\n\t\tsock\n\tend", "def socket\n return @socket if @socket\n s = TCPSocket.new(host || '127.0.0.1', port || 2003) # CORRECT DEFAULT PORT?\n @socket = s\n @socket\n rescue ::SystemExit, ::Interrupt, ::SignalException\n raise\n rescue ::Exception => exc\n STDERR.puts \"#{self} socket: failed #{exc.inspect}\\n #{exc.backtrace * \"\\n \"}\"\n sleep 10\n retry\n end", "def connect_to(host, port)\n if @http_proxy\n\tproxy_uri = URI.parse(@http_proxy)\n\tNet::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(host, port)\n else\n\tNet::HTTP.new(host, port)\n end\n end", "def get_socket\n sock = UDPSocket.new\n sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)\n\n count = 0\n bound = false\n begin\n port = rand(2 ** 16 - 1024) + 1024\n debug \"Attempting to bind to #{@listen_ip}:#{port}\"\n sock.bind(@listen_ip, port)\n bound = true\n rescue \n warn \"Failed to bind to #{@listen_ip}:#{port}\"\n if count < MaxBindAttempts\n count += 1\n redo\n end\n end\n\n if bound\n info \"Handler #{@key} bound to #{@listen_ip} on port #{port}\"\n else\n raise TftpError, \"Can't seem to find a spare port to bind to.\"\n end\n\n return sock\n end", "def socket\n return @sock if @sock and not @sock.closed?\n\n @sock = nil\n\n # If the host was dead, don't retry for a while.\n return if @retry and @retry > Time.now\n\n # Attempt to connect if not already connected.\n begin\n @sock = connect_to(@host, @port, @timeout)\n @sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1\n @retry = nil\n @status = 'CONNECTED'\n rescue Errno::EPIPE, Errno::ECONNREFUSED => e\n puts \"Socket died... socket: #{@sock.inspect}\\n\" if $debug\n @sock.close\n retry\n rescue SocketError, SystemCallError, IOError => err\n puts \"Unable to open socket: #{err.class.name}, #{err.message}\" if $debug\n mark_dead err\n end\n\n return @sock\n end", "def create(param)\n\t\tsock = nil\n\n\t\t# Notify handlers before we create the socket\n\t\tnotify_before_socket_create(self, param)\n\n\t\tsock = net.socket.create(param)\n\n\t\t# sf: unsure if we should raise an exception or just return nil. returning nil for now.\n\t\t#if( sock == nil )\n\t\t# raise Rex::UnsupportedProtocol.new(param.proto), caller\n\t\t#end\n\n\t\t# Notify now that we've created the socket\n\t\tnotify_socket_created(self, sock, param)\n\n\t\t# Return the socket to the caller\n\t\tsock\n\tend", "def open_socket(host, domain = nil, timeout = 5, port = 22, &_block)\n Timeout.timeout(timeout) do\n target_host = host\n target_host = \"#{host}.#{domain}\" if domain\n sock = TCPSocket.new target_host, port\n begin\n yield sock if block_given?\n ensure\n sock.close\n end\n end\n end", "def connect_to(host, port)\n if @proxy_uri\n Net::HTTP::Proxy(@proxy_uri.host, @proxy_uri.port, unescape(@proxy_uri.user), unescape(@proxy_uri.password)).new(host, port)\n else\n Net::HTTP.new(host, port)\n end\n end", "def create_server_socket\n if @hostname\n s = TCPServer.open(@hostname, @port)\n else\n s = TCPServer.open(@port)\n end\n @port = s.addr[1]\n\n s.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)\n\n return s\n end", "def sockopen(host, port)\n socket = nil\n msg = nil\n timeout = 5.0\n socket = turbina_timeout(timeout, proc {TCPSocket.open(host, port)})\n return socket\n end", "def get_socket(host, port, timeout, error)\n\n begin\n\n addr = Socket.getaddrinfo(host, nil)\n\n if addr.nil?\n return\n end\n\n sock = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)\n\n if timeout\n secs = Integer(timeout)\n usecs = Integer((timeout - secs) * 1_000_000)\n optval = [secs, usecs].pack(\"l_2\")\n sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, optval)\n sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, optval)\n end\n\n sock.connect(Socket.pack_sockaddr_in(port, addr[0][3]))\n return sock\n\n rescue Exception => e\n error = e.message\n return nil\n end\n\n\tend", "def create()\n # Do we already have a connection?\n if @is_scproxy and self.has_session?\n # Close it before starting a new one\n self.close()\n end\n # Create a new\n if @is_scproxy and @api\n # Let the master create a new proxy\n response = self.proxy_new :master => true\n # Did we get on?\n if response[\"status\"] == true\n @port = response[\"result\"][\"port\"]\n else\n # Show the error\n raise response[\"message\"]\n end\n end\n\n if @port.nil?\n raise \"Coult not create a new proxy\"\n end\n\n return @port\n end", "def checkout_new_socket(host, port)\n return nil if @all.size >= @size\n\n begin\n socket = TCPSocket.new(host, port)\n socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)\n rescue => ex\n raise ConnectionFailure, \"Failed to connect to host #{@host} and port #{@port}: #{ex}\"\n end\n\n # If any saved authentications exist, we want to apply those\n # when creating new sockets.\n @connection.apply_saved_authentication(:socket => socket)\n\n socket\n end", "def connect\n site = @proxy || @dest\n begin\n retry_number = 0\n timeout(@connect_timeout) do\n @socket = create_socket(site)\n begin\n @src.host = @socket.addr[3]\n @src.port = @socket.addr[1]\n rescue SocketError\n # to avoid IPSocket#addr problem on Mac OS X 10.3 + ruby-1.8.1.\n # cf. [ruby-talk:84909], [ruby-talk:95827]\n end\n if @dest.scheme == 'https'\n @socket = create_ssl_socket(@socket)\n connect_ssl_proxy(@socket) if @proxy\n @socket.ssl_connect\n @socket.post_connection_check(@dest)\n @ssl_peer_cert = @socket.peer_cert\n end\n # Use Ruby internal buffering instead of passing data immediatly\n # to the underlying layer\n # => we need to to call explicitely flush on the socket\n @socket.sync = @socket_sync\n end\n rescue TimeoutError\n if @connect_retry == 0\n retry\n else\n retry_number += 1\n retry if retry_number < @connect_retry\n end\n close\n raise\n end\n\n @state = :WAIT\n @readbuf = ''\n end", "def socket\n if !block_given?\n if @cached_socket != nil\n return @cached_socket\n end\n return @cached_socket = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:socket, []).call(),::Vertx::NetSocket)\n end\n raise ArgumentError, \"Invalid arguments when calling socket()\"\n end", "def initialize(host='127.0.0.1')\n @sock = Socket.new(:INET, :STREAM)\n @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)\n @sock.bind(Socket.sockaddr_in(0, host))\n @host, @port = @sock.connect_address.ip_unpack\n @addr = \"#{@host}:#{@port}\"\n if block_given?\n begin\n yield self\n ensure\n close\n end\n end\n end", "def create_socket\n\t\tiaddr = self.class.bind_addr\n\t\tsocket = UDPSocket.new\n\n\t\tsocket.setsockopt( :IPPROTO_IP, :IP_ADD_MEMBERSHIP, iaddr )\n\t\tsocket.setsockopt( :IPPROTO_IP, :IP_MULTICAST_TTL, self.class.multicast_ttl )\n\t\tsocket.setsockopt( :IPPROTO_IP, :IP_MULTICAST_LOOP, 1 )\n\t\tsocket.setsockopt( :SOL_SOCKET, :SO_REUSEPORT, 1 )\n\n\t\treturn socket\n\tend", "def socket(hostport, num_retries=3)\n\n num_retries.times do |i|\n begin\n sock = TCPSocket.new(*hostport.split(':'))\n rescue Exception\n else\n return sock\n end\n end\n #signal_bad_server(hostport)\n nil\n #raise RuntimeError, \"Unable to connect to job server #{hostport}\"\n end", "def open(host, port, connection_options)\n socket = establish_connection(connection_options[:timeout])\n socket.write \"CONNECT #{host}:#{port} HTTP/1.1\\r\\n\"\n socket.write \"Host: #{host}:#{port}\\r\\n\"\n\n if options[:user]\n credentials = [\"#{options[:user]}:#{options[:password]}\"].pack(\"m*\").gsub(/\\s/, \"\")\n socket.write \"Proxy-Authorization: Basic #{credentials}\\r\\n\"\n end\n\n socket.write \"\\r\\n\"\n\n resp = parse_response(socket)\n\n return socket if resp[:code] == 200\n\n socket.close\n raise ConnectError, resp.inspect\n end", "def socket(address, type)\n SSocket.new(address, type)\n end", "def create_socket\n attempt_number = 0\n\n begin\n attempt_number += 1\n socket = zmq_context.socket(::ZMQ::REQ)\n\n if socket # Make sure the context builds the socket\n server_uri = lookup_server_uri\n socket.setsockopt(::ZMQ::LINGER, 0)\n zmq_error_check(socket.connect(server_uri), :socket_connect)\n socket = socket_to_available_server(socket) if first_alive_load_balance?\n end\n end while socket.try(:socket).nil? && attempt_number < socket_creation_attempts\n\n raise RequestTimeout, \"Cannot create new ZMQ client socket\" if socket.try(:socket).nil?\n socket\n end", "def get_transporter\n TCPSocket.open(@host, @port)\n end", "def bind_socket(family,port,ip)\n socket = Socket.new(family, SOCK_STREAM, 0)\n sockaddr = Socket.sockaddr_in(port.to_i,ip)\n socket.setsockopt(:SOCKET, :REUSEADDR, true)\n socket.bind(sockaddr)\n socket.listen(0)\n return socket\n end", "def obtain_socket(uri)\n socket = TCPSocket.new(uri.host, uri.port || socket_port(uri))\n\n if secure_uri?(uri)\n ctx = OpenSSL::SSL::SSLContext.new\n\n if ENV['DISCORDRB_SSL_VERIFY_NONE']\n ctx.ssl_version = 'SSLv23'\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # use VERIFY_PEER for verification\n\n cert_store = OpenSSL::X509::Store.new\n cert_store.set_default_paths\n ctx.cert_store = cert_store\n else\n ctx.set_params ssl_version: :TLSv1_2 # rubocop:disable Naming/VariableNumber\n end\n\n socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)\n socket.connect\n end\n\n socket\n end", "def tls_socket socket\n socket = OpenSSL::SSL::SSLSocket.new socket, create_ssl_context\n socket.sync_close = true\n socket.hostname = @host unless RE_IP_ADDR.match(@host)\n socket.connect\n socket\n end", "def init_socket\n @rcon_socket = RCONSocket.new @ip_address, @port\n @socket = SourceSocket.new @ip_address, @port\n end", "def set_socket\r\n @socket = TCPSocket.new(@server, @port) \r\n end", "def get_ip_address_and_port_or_close_connection\n peername = get_peername\n if peername.nil?\n log(:error, :socket, 'new socket created, but unable to fetch ip & port, closing connection...')\n close_connection\n else\n @port, @ip_address = Socket::unpack_sockaddr_in(peername)\n log(:debug, :socket, \"new socket created (#{@ip_address}:#{@port})\")\n end\n end", "def connect(remote_addr, remote_port)\n @socket.connect(@resolver.resolve(remote_addr).to_s, remote_port)\n self\n rescue => ex\n # TODO: more specific exceptions\n raise Socketry::Error, ex.message, ex.backtrace\n end", "def establish_connection\n if @socket.nil?\n @socket = TCPSocket.new(@host, @port)\n end\n end", "def establish_connection\n if @socket.nil?\n @socket = TCPSocket.new(@host, @port)\n end\n end", "def proxy(remote, options = {})\n server = create_server(options)\n host, port, extra = remote.split(\":\", 3)\n raise \"Specify the remote parameter in 'hostname_or_ip:port' format\" if extra || port.to_i == 0 || host.empty?\n Reactor.queue_task do\n monitor = Reactor.selector.register(server, :r)\n monitor.value = proc do\n accept_socket server, options do |client|\n srv = open_socket \"tcp://#{remote}\", options\n adapter = PROXY_ADAPTER.new(srv, client, options)\n Reactor.queue_task do\n adapter.add_to_reactor\n end\n logger.info \"Proxy connection established between #{srv} and #{client}\"\n end\n end\n end\n logger.info \"Proxy Host listening for new connections on port \" + options[:port].to_s\n Reactor.start\n server\n end", "def socket\n if !block_given?\n if @cached_socket != nil\n return @cached_socket\n end\n return @cached_socket = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:socket, []).call(),::VertxWeb::SockJSSocket)\n end\n raise ArgumentError, \"Invalid arguments when calling socket()\"\n end", "def establish_socket_server\n @socket_server = Uninterruptible::Binder.new(server_configuration.bind).bind_to_socket\n\n if server_configuration.tls_enabled?\n @socket_server = Uninterruptible::TLSServerFactory.new(server_configuration).wrap_with_tls(@socket_server)\n end\n @socket_server\n end", "def socket_setup()\n ctx = { 'Msf' => self.options['Msf'], 'MsfExploit' => self.options['MsfExploit'] }\n self.socket = case self.handle.protocol\n\n when 'ncacn_ip_tcp'\n Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => self.handle.options[0],\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n\n when 'ncacn_np'\n begin\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 445,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n rescue ::Timeout::Error, Rex::ConnectionRefused\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 139,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n end\n socket\n else nil\n end\n\n # Add this socket to the exploit's list of open sockets\n options['MsfExploit'].add_socket(self.socket) if (options['MsfExploit'])\n end", "def mock_socket(ip,port)\n addr = [\"\",port,ip.split('.')]\n sock = stub(\"client socket\")\n peername = stub(\"peer name\")\n sock.stubs(:getpeername).returns(peername)\n peername.stubs(:unpack).returns(addr)\n sock\n end", "def connect\n sock = TCPSocket.new(@host, @port)\n if @ssl\n sock = OpenSSL::SSL::SSLSocket.new(sock)\n sock.sync_close = true\n sock.connect\n sock.post_connection_check(@host) if @verify_ssl\n end\n sock\n end", "def init_socket\n @socket = Sockets::MasterServerSocket.new @ip_address, @port\n end", "def checkout_new_socket\n begin\n socket = TCPSocket.new(@host, @port)\n socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)\n rescue => ex\n raise ConnectionFailure, \"Failed to connect socket: #{ex}\"\n end\n @sockets << socket\n @checked_out << socket\n socket\n end", "def get_open_port\n socket = Socket.new(:INET, :STREAM, 0)\n socket.bind(Addrinfo.tcp(\"127.0.0.1\", 0))\n port = socket.local_address.ip_port\n socket.close\n port\n end", "def connect_from(source_ip, host, port)\n in_addr = Socket.pack_sockaddr_in(0, source_ip)\n out_addr = Socket.pack_sockaddr_in(port, host)\n socket = Socket.open(Socket::AF_INET, Socket::SOCK_STREAM, 0)\n socket.bind(in_addr)\n socket.connect(out_addr)\n decorate_socket socket\n @ftp = make_ftp\n @ftp.set_socket(socket)\n end", "def local_socket(local_socket_path, remote_socket_path); end", "def setupSocket(waitp = true, host = nil, port = nil)\n # setup host/port\n @host = host || @host ;\n @port = port || @port ;\n logging(:info){ \"set TCP port = #{@host}:#{@port}.\" } ;\n\n # wait until the port open\n if(@host == 'localhost')\n Util::waitTcpPortIsReady(@port) ;\n end\n\n #open socket\n logging(:info){ \"try to open TCP socket to #{@host}:#{@port}.\" } ;\n @socket = TCPSocket::new(@host, @port) ;\n logging(:info){ \"success to open TCP socket to #{@host}:#{@port}.\" } ;\n\n return @socket ;\n end", "def initialize(domain, type, protocol)\n @descriptor = Winsock.socket(domain, type, protocol)\n SocketError.check if @descriptor == -1\n return @descriptor\n end", "def open(host, port, connection_options = nil)\n build_proxy_command_equivalent(connection_options)\n super\n end", "def setup_socket\n self.socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)\n address = Socket.pack_sockaddr_in(@options[:port], @options[:host])\n socket.bind(address)\n socket.listen(@options[:max_connection_queue])\n log.info(\"Listening on #{@options[:host]}:#{@options[:port]}\")\n end", "def socket; @socket; end", "def local(*args)\n if args.length < 3 || args.length > 4\n raise ArgumentError, \"expected 3 or 4 parameters, got #{args.length}\"\n end\n\n local_port_type = :long\n\n socket = begin\n if defined?(UNIXServer) and args.first.class == UNIXServer\n local_port_type = :string\n args.shift\n else\n bind_address = \"127.0.0.1\"\n bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\\D/\n local_port = args.shift.to_i\n local_port_type = :long\n TCPServer.new(bind_address, local_port)\n end\n end\n\n local_port = socket.addr[1] if local_port == 0 # ephemeral port was requested\n remote_host = args.shift\n remote_port = args.shift.to_i\n\n @local_forwarded_ports[[local_port, bind_address]] = socket\n\n session.listen_to(socket) do |server|\n client = server.accept\n debug { \"received connection on #{socket}\" }\n\n channel = session.open_channel(\"direct-tcpip\", :string, remote_host, :long,\n remote_port, :string, bind_address, local_port_type, local_port) do |achannel|\n achannel.info { \"direct channel established\" }\n end\n\n prepare_client(client, channel, :local)\n\n channel.on_open_failed do |ch, code, description|\n channel.error { \"could not establish direct channel: #{description} (#{code})\" }\n session.stop_listening_to(channel[:socket])\n channel[:socket].close\n end\n end\n\n local_port\n end", "def new_websocket_client(client)\n\n msg \"connecting to: %s:%s\" % [@target_host, @target_port]\n tsock = TCPSocket.open(@target_host, @target_port)\n\n if @verbose then puts @@Traffic_legend end\n\n begin\n do_proxy(client, tsock)\n rescue\n tsock.shutdown(Socket::SHUT_RDWR)\n tsock.close\n raise\n end\n end", "def socket #:nodoc:\n return @socket\n end", "def socket\n return @socket if @socket\n linger = @heartbeat_timeout * 1000\n pubkey = Directory[@id].pubkey\n @socket = ClientServer.new @addr, linger, pubkey\n @socket.farewell = farewell\n transition :connected\n @socket\n end", "def connect()\n @s = @s || TCPsocket.open(@host, @port)\n end", "def local(*args)\n if args.length < 3 || args.length > 4\n raise ArgumentError, \"expected 3 or 4 parameters, got #{args.length}\"\n end\n\n bind_address = \"127.0.0.1\"\n bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\\D/\n\n local_port = args.shift.to_i\n remote_host = args.shift\n remote_port = args.shift.to_i\n\n socket = TCPServer.new(bind_address, local_port)\n lport,caddr=nil,nil\n\n\t\t\t\t if (socket.getsockname =~ /127\\.0\\.0\\.1:/)\n\t\t\t\t\t # JRuby ridiculousness\n\t\t\t\t\t caddr, lport = socket.getsockname.split(\":\")\n\t\t\t\t\t caddr = caddr[1,caddr.length]\n\t\t\t\t\t lport = lport.to_i\n\t\t\t\t else\n\t\t\t\t\t # Sane implementations where Socket#getsockname returns a\n\t\t\t\t\t # sockaddr\n\t\t\t\t\t lport, caddr = ::Socket.unpack_sockaddr_in( socket.getsockname )\n\t\t\t\t end\n\n @local_forwarded_ports[[lport, caddr]] = socket\n\n session.listen_to(socket) do |server|\n client = server.accept\n\n debug { \"received connection on #{caddr}:#{lport}\" }\n\n channel = session.open_channel(\"direct-tcpip\", :string, remote_host, :long, remote_port, :string, caddr, :long, lport) do |achannel|\n achannel.info { \"direct channel established\" }\n end\n prepare_client(client, channel, :local)\n \n channel.on_open_failed do |ch, code, description|\n channel.error { \"could not establish direct channel: #{description} (#{code})\" }\n channel[:socket].close\n end\n end\n socket\n end", "def new_socket\n membership = IPAddr.new(@broadcast).hton + IPAddr.new('0.0.0.0').hton\n ttl = [@ttl].pack 'i'\n\n socket = UDPSocket.new\n\n socket.setsockopt Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, membership\n socket.setsockopt Socket::IPPROTO_IP, Socket::IP_MULTICAST_LOOP, \"\\000\"\n socket.setsockopt Socket::IPPROTO_IP, Socket::IP_MULTICAST_TTL, ttl\n socket.setsockopt Socket::IPPROTO_IP, Socket::IP_TTL, ttl\n\n socket.bind '0.0.0.0', @port\n\n socket\n end", "def create_ssl_socket\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params ssl_version: :TLSv1_2\n\n socket = TCPSocket.new(@uri.host, @port)\n OpenSSL::SSL::SSLSocket.new(socket, ctx)\n end", "def with_socks_proxy\n old_socks_server, old_socks_port = ::TCPSocket::socks_server, ::TCPSocket::socks_port\n ::TCPSocket::socks_server, ::TCPSocket::socks_port = '127.0.0.1', @local_port\n yield\n rescue *NETWORK_ERRORS => e\n @network_errors_handler.call(e)\n ensure\n ::TCPSocket::socks_server, ::TCPSocket::socks_port = old_socks_server, old_socks_port\n end", "def create_client_socket\n\t\tself.log.debug \"Creating a CLIENT socket bound to: %s\" % [ self.server ]\n\t\tsock = CZTop::Socket::CLIENT.new\n\n\t\tclient_cert = Assemblage::Auth.local_cert\n\t\tserver_cert = Assemblage::Auth.remote_cert( 'server' )\n\n\t\tself.log.debug \"Connecting with %p and %p\" % [ client_cert, server_cert ]\n\t\tsock.CURVE_client!( client_cert, server_cert )\n\t\tsock.connect( self.server )\n\n\t\treturn sock\n\tend", "def real_connect(*args)\n super(*args)\n @fd = socket\n @io = IO.new(socket)\n end", "def connect_mock(_, addr)\n port, = Socket.unpack_sockaddr_in(addr)\n if [1234, 4321].include?(port)\n raise Errno::EISCONN\n end\n raise Errno::ECONNREFUSED\n end", "def connect(socket_class, host, port, nodelay = T.unsafe(nil)); end", "def connect()\n @sock = TCPSocket.open(@server, @port)\n end", "def socket type\n sock = nil\n begin\n sock = Socket.new @context, type\n rescue ContextError => e\n sock = nil\n end\n\n sock\n end", "def create_tcp_connection(temp: false)\n tcp_connection = Rex::Socket::Tcp.create(\n 'PeerHost' => host,\n 'PeerPort' => port.to_i,\n 'Context' => context,\n 'Timeout' => timeout\n )\n self.connection = tcp_connection unless temp\n tcp_connection\n end", "def initialize_socket(uri, opts = {})\n return if opts[:socket]\n\n @socket = TCPSocket.new(uri.host, uri.port)\n opts.merge!({:socket => @socket})\n @intentional_termination = false\n end", "def open(host, port, local_port=nil)\n ensure_open!\n\n actual_local_port = local_port || next_port\n\n @session_mutex.synchronize do\n @session.forward.local(actual_local_port, host, port)\n end\n\n if block_given?\n begin\n yield actual_local_port\n ensure\n close(actual_local_port)\n end\n else\n return actual_local_port\n end\n rescue Errno::EADDRINUSE\n raise if local_port # if a local port was explicitly requested, bubble the error up\n retry\n end", "def establish\n @proxy = XMLRPC::Client.new(@hostname, '/RPC2', @port).proxy(@proxy_name)\n end", "def initialize(host, port)\r\n super(AF_INET, SOCK_STREAM, IPPROTO_TCP)\r\n connect(Socket.sockaddr_in(port, host))\r\n end", "def cork_socket(socket); end", "def try_connect\n return if established?\n \n @socket = TCPSocket.new(*destination.split(':'))\n rescue Errno::ECONNREFUSED\n # No one listening? Well.. too bad.\n @socket = nil\n end", "def socket\n @socket\n end", "def socket\n connect unless connected?\n @ssl_sock\n end", "def connect\n auth = authentication_prompt()\n\n socket = TCPSocket.new( @server, @port )\n raise RuntimeError, \"Unable to connect to #{@port}\" unless socket\n print \"Connecting at #{Time.now} to #{@port} ... \"\n\n authenticate_with_server( socket, auth[:u], auth[:p] )\n\n return socket\n end", "def connect\n socket = TCPSocket.new(@server, @port.to_i)\n if @options[:ssl] == nil\n return socket\n end\n ssl_context = @options[:ssl]\n ssl_context = OpenSSL::SSL::SSLContext.new()\n unless ssl_context.verify_mode\n warn \"warning: peer certificate won't be verified this session.\"\n ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)\n ssl_socket.sync_close = true\n ssl_socket.connect\n return ssl_socket\n end", "def local_socket(local_socket_path, remote_socket_path)\n File.delete(local_socket_path) if File.exist?(local_socket_path)\n socket = Socket.unix_server_socket(local_socket_path)\n\n @local_forwarded_sockets[local_socket_path] = socket\n\n session.listen_to(socket) do |server|\n client = server.accept[0]\n debug { \"received connection on #{socket}\" }\n\n channel = session.open_channel(\"[email protected]\",\n :string, remote_socket_path,\n :string, nil,\n :long, 0) do |achannel|\n achannel.info { \"direct channel established\" }\n end\n\n prepare_client(client, channel, :local)\n\n channel.on_open_failed do |ch, code, description|\n channel.error { \"could not establish direct channel: #{description} (#{code})\" }\n session.stop_listening_to(channel[:socket])\n channel[:socket].close\n end\n end\n\n local_socket_path\n end", "def connect_to_server\n @socket = TCPSocket.open(@serverip, @serverport)\n end", "def connect(transport: :tcp, address: '127.0.0.1', port: 5555)\n endpoint = \"#{ transport }://#{ address }\"\n endpoint << \":#{ port }\" if %i(tcp pgm epgm).include? transport\n @socket.method(__callee__).call(endpoint) == 0\n end", "def socket\n @socket ||= ::UDPSocket.new\n end", "def accept\n while true\n s = @socket.accept\n break if (@acl ? @acl.allow_socket?(s) : true)\n s.close\n end\n if @config[:tcp_original_host].to_s.size == 0\n uri = \"druby://#{s.addr[3]}:#{@config[:tcp_port]}\"\n else\n uri = @uri\n end\n self.class.new(uri, s, @config)\n end", "def connect(port: nil)\n return if @tcp_socket\n unless port\n @tcp_socket = TCPSocket.new(@host, ENDPOINT_MAPPER_PORT)\n bind(endpoint: Epm)\n begin\n host_port = get_host_port_from_ept_mapper(\n uuid: @endpoint::UUID,\n maj_ver: @endpoint::VER_MAJOR,\n min_ver: @endpoint::VER_MINOR\n )\n rescue RubySMB::Dcerpc::Error::DcerpcError => e\n e.message.prepend(\n \"Cannot resolve the remote port number for endpoint #{@endpoint::UUID}. \"\\\n \"Set @tcp_socket parameter to specify the service port number and bypass \"\\\n \"EPM port resolution. Error: \"\n )\n raise e\n end\n port = host_port[:port]\n @tcp_socket.close\n @tcp_socket = nil\n end\n @tcp_socket = TCPSocket.new(@host, port)\n end", "def initialize(type, endpoint = nil, context = nil)\n @context = context || Context.instance.xs_context\n @sock = @context.socket xs_const(type)\n @endpoint = endpoint\n\n fail \"Creating socket #{type} failed\" unless @sock\n end", "def setup_socket\n ctx = setup_certificate\n\n APN.log(:debug, \"Connecting to #{@host}:#{@port}...\")\n\n socket_tcp = TCPSocket.new(@host, @port)\n OpenSSL::SSL::SSLSocket.new(socket_tcp, ctx).tap do |s|\n s.sync = true\n s.connect\n end\n end", "def connect(host, port, use_ssl = false)\n @socket = TCPSocket.new(host, port.to_i)\n if use_ssl\n @socket = OpenSSL::SSL::SSLSocket.new(@socket)\n @socket.sync_close\n @socket.connect\n end\n read_greeting\n end", "def udp_socket\n Thread.current[:statful_socket] ||= UDPSocket.new(Addrinfo.udp(@config[:host], @config[:port]).afamily)\n end", "def connect\n TCPSocket.open(@host, @port)\n end", "def socket_bound_to(source_ip)\n socket = mock TCPSocket\n peeraddr = Socket.pack_sockaddr_in(0, source_ip)\n socket.stub :getpeername => peeraddr\n socket\n end", "def make_persistent!(socket)\n unless socket == @socket\n close_persistent!\n @socket = socket\n end\n @socket\n end", "def tcp port = nil\n port = @config.port.outbound if port.nil?\n host = @source['resource'].first\n\n @pool[host] ||= TCPSocket.new host, port\n\n if @pool[host].closed?\n @pool[host] = TCPSocket.new host, port\n elsif not @pool[host].stat.readable?\n @pool[host].close\n @pool[host] = TCPSocket.new host, port\n end\n\n @pool[host].puts @source.to.json\n @config.logger.debug @source.to_s\n end", "def local_connect(body)\n host = _pop_token(body)\n port = _pop_token(body).to_i\n if host.length < 1\n begin\n host, port = @var[:last_connection]\n rescue\n raise \"usage: /connect <hostname> [port]\"\n end\n end\n port = 9000 if port == 0\n begin\n connect(host, port)\n @var[:last_connection] = [ host, port ]\n _save_env\n rescue\n _notice \"Could not connect to #{host}:#{port} - #{$!}\", :error\n end\nend", "def open_socket()\n used_socket = @ssl ? open_ssl_socket : open_tcp_socket\n # try to close the old connection if any\n close_socket\n\n @closed = false\n if @parameters # nil in some rspec tests\n unless @reconnect_delay\n @reconnect_delay = @parameters[:initial_reconnect_delay] || iosto1\n end\n end\n # Use keepalive\n used_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)\n\n # TCP_NODELAY option (disables Nagle's algorithm)\n used_socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, !!(@parameters && @parameters[:tcp_nodelay]))\n\n @iosto = @parse_timeout ? @parse_timeout.to_f : 0.0\n\n used_socket\n end" ]
[ "0.76001567", "0.71789515", "0.692484", "0.685941", "0.6842947", "0.6760849", "0.6757075", "0.6723374", "0.6599654", "0.6573526", "0.65724576", "0.6567157", "0.6548365", "0.6541595", "0.65214294", "0.65103066", "0.64605594", "0.6395141", "0.63469183", "0.63281417", "0.6324139", "0.62993634", "0.6255565", "0.6243523", "0.6207127", "0.6154738", "0.6109298", "0.608765", "0.6069399", "0.6046841", "0.60191494", "0.6018061", "0.5983667", "0.59689724", "0.59632707", "0.59567237", "0.5955134", "0.5937524", "0.5932842", "0.5930382", "0.591862", "0.591862", "0.59131217", "0.5907423", "0.59049654", "0.5904525", "0.58810025", "0.5872724", "0.5840772", "0.58256394", "0.58166206", "0.5811249", "0.5806755", "0.579399", "0.5776766", "0.577316", "0.5771396", "0.57708526", "0.57613164", "0.5753019", "0.573454", "0.5681445", "0.5675098", "0.5665465", "0.56651425", "0.5664693", "0.5661552", "0.56572807", "0.56498116", "0.5637427", "0.5627452", "0.56199694", "0.5611366", "0.56063324", "0.5605429", "0.5601239", "0.55932146", "0.5589776", "0.5578286", "0.5571028", "0.55683064", "0.556551", "0.55603486", "0.55490893", "0.5524121", "0.5522489", "0.5520268", "0.5516498", "0.5509396", "0.5507902", "0.5507815", "0.5505986", "0.55004925", "0.54994226", "0.5482697", "0.5478284", "0.54764485", "0.5468798", "0.5467051", "0.5462878" ]
0.70843345
2
System messages (user left, got invited, room renamed, etc)
def system_messages data['sysMes'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def system_msg\n msg=[]\n if (AppConfig.read_only_flag=='y' and !AppConfig.read_only_msg.blank?)\n msg << \"<p>#{h AppConfig.read_only_msg}</p>\"\n end\n \n if (AppConfig.ooc_read_only_flag=='y' and !AppConfig.ooc_read_only_msg.blank?)\n msg << \"<p>#{h AppConfig.ooc_read_only_msg}</p>\"\n end\n \n unless AppConfig.hip_notice.nil?\n msg << \"<p>#{h AppConfig.hip_notice}</p>\"\n end\n msg.join('')\n end", "def inactive_message; end", "def inactive_message; end", "def messaging\n end", "def message\n return MSG_NOT_ENROLLED unless enrolled?\n return MSG_FULL_ACCESS if registered?\n return MSG_LIMITED_ACCESS if twenty_percent_cnp_exception?\n MSG_FEES_UNPAID\n end", "def addStatusMessage(status, toRoom:room)\n message = { 'type' => Message::SYSTEM,\n 'created_at' => Time.now.to_s,\n 'room_id' => room.id,\n 'body' => status,\n 'user_id' => 'null',\n 'id' => \"status-#{Time.now.to_i}\"\n }\n \n room.messageReceived message\n end", "def systemmsg(head, message)\n send_command(:systemmsg, head: head, message: message )\n end", "def messages\n end", "def messages\n end", "def growl(room, m)\n case m['type']\n when 'system:enter'\n type = GROWL_MESSAGE_TYPES[:join]\n when 'system:leave'\n type = GROWL_MESSAGE_TYPES[:leave]\n when 'system:nickname_change'\n type = GROWL_MESSAGE_TYPES[:nickname]\n else\n type = GROWL_MESSAGE_TYPES[:message]\n message = \"#{m['nickname']}: #{m['text']}\"\n end\n\n @growl.notify(type, room, message || m['text'])\n end", "def check_for_messages\n @message_unviewed = Message.all(:recipient_id => current_user.id, :viewed => false, :opportunity => Opportunity.all(:active => true))\n if @message_unviewed != []\n flash.now[:warning] = 'You have unread messages'\n end\n end", "def new_message_check\n if(!current_user.nil?)\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n if ids.count > 0\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n render text: '{\"unread\":\"true\", \"ids\":[' + ids.join(',') + ']}'\n else\n render text: '{\"unread\":\"false\"}'\n end\n else \n render text: '{\"unread\":\"false\"}'\n end\n end", "def determine_status(msg, user = msg.user)\n return \"\" unless msg.channel # This is nil for leaving users\n return \"\" unless user # server-side NOTICEs\n\n user = user.name if user.kind_of?(Cinch::User)\n\n if user == bot.nick\n \"selfbot\"\n elsif msg.channel.opped?(user)\n \"opped\"\n elsif msg.channel.half_opped?(user)\n \"halfopped\"\n elsif msg.channel.voiced?(user)\n \"voiced\"\n else\n \"\"\n end\n end", "def messages; end", "def messages; end", "def messages; end", "def status(text)\n @user.enqueue_message('_' + text + '_')\n end", "def status(text)\n @user.enqueue_message('_' + text + '_')\n end", "def on_newmessage(time, userid, username, msg)\n end", "def user_message(msg, level=0, type=\"info\")\n if not(quiet_mode?)\n message(type, :green, \" \"*level + msg)\n end\n end", "def processSystemMessage(message)\r\n html = \"<div class=\\\"message\\\">\"\r\n html << \"<div class=\\\"systemMessage\\\">\"\r\n html << formatMessageText(message[:message])\r\n html << \"</div>\"\r\n html << \"</div>\"\r\n html << \"<p>\"\r\n return html\r\n end", "def sms_notify(username, source_system, message)\r\n sender = SmsGlobal::Sender.new :user => CONFIG[:sms_global_settings][:user_name].to_s, :password => CONFIG[:sms_global_settings][:password].to_s\r\n\r\n sender.send_text message, username, source_system\r\n Rails.logger.info \"#{Time.now.utc} - sms_notify - #{username} - #{source_system} - #{message}\"\r\n end", "def ezm_subject_and_status(message)\r\n if message.receiver_deleted?\r\n message.subject + \" (Deleted)\" \r\n elsif message.read_at.nil?\r\n message.subject + \" (Unread)\" \r\n else \r\n message.subject\r\n end\r\n end", "def mess\r\n\t\t@usr_mess\r\n\tend", "def eval_first_msg(umsg,sock)\n user_info = umsg.split(\" \")\n if umsg =~ /user_info:/\n @user_info.push({:nickname => user_info[1],:role => \"client\", :channels => [], :mode => \"pull\", :time => Time.now})\n sock.write(\"Welcome #{user_info[1]}\\n\")\n @@connection.insert_user user_info[1]\n @user_info.last[:channels] = @@connection.fill_channels_user(user_info[1])\n elsif (umsg =~ /source_info:/) \n @user_info.push({:nickname => user_info[1],:role => \"editor\",:status => \"logging\"}) \n sock.write(\"password:\\n\")\n elsif (umsg =~ /admin_info:/ )\n @user_info.push({:nickname => user_info[1],:role => \"admin\", :status => \"logging\"}) \n sock.write(\"password:\\n\")\n end \n end", "def local_switch(body, prevent = false)\n room = body\n room = 'chat' if room.length < 1\n unless @connection.room_ids[room] or room == 'chat' or room[0,1] == '@' or\n @var[:special_rooms].include?(room)\n _notice \"You are not in room '#{room}'\", :error\n return false\n end\n @var[:room] = room\n unless prevent\n if room[0,1] == '@'\n _notice \"You are now private messaging with #{room[1..-1]}.\", room\n else\n _notice \"You are now chatting in '#{room}'\", room\n end\n end\n true\nend", "def message_broadcast\n\n @subject = params[:subject] ? params[:subject] : 'IMPORTANT - Please Read'\n @message = params[:message] ? params[:message] : ''\n @active_roles = Role.find_all_active\n\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 build_message\n level_string = (user.level == User::Levels::APPROVER) ? \"an Approver\" : \"a #{user.level_string}\"\n if user.level > user.level_was\n \"You have been promoted to #{level_string} level account from #{user.level_string_was}.\"\n elsif user.level < user.level_was\n \"You have been demoted to #{level_string} level account from #{user.level_string_was}.\"\n end\n end", "def chatroom_message(msg, cl, state)\n body = msg.body.to_s\n \n # update room status every MSGS_UNTIL_REFRESH messages\n # Use a countdown and not mod to avoid skips happenning if multiple messages come at once\n if(state[:time_until_list] <= 0)\n respond(msg, cl, \"/list\")\n state[:time_until_list] = MSGS_UNTIL_REFRESH\n else\n state[:time_until_list] -= 1\n end\n\n # redo the /list whenever anybody changes their name or joins the room\n if(/^\\'(.*)\\' is now known as \\'(.*)\\'/.match(body) ||\n /^.* has joined the channel with the alias '.*'/.match(body) )\n out(\"sending /list because of user change\")\n respond(msg, cl, \"/list\")\n return\n end\n \n # handle /list result when it comes in\n if(/^Listing members of '#{ROOM_NAME}'\\n/.match(body))\n out(\"received a room listing.\")\n listing_refresh(state, body)\n return\n end \n \n # messages starting and ending with '_' are emotes \n if body[0].chr == '_' && body[body.length - 1].chr == '_'\n chatroom_emote(msg, cl, state)\n return\n end\n\n # If someone says [word]bomb search for [word] on Google image\n # search and post the first result to the room.\n # eg: pugbomb\n if /\\w+bomb/.match(body)\n q = /(\\w+)bomb/.match(body)[1]\n uri = 'http://www.google.com/search?num=1&hl=en&safe=off&site=imghp&tbm=isch&source=hp&biw=1060&bih=669&q=' + q\n response = Net::HTTP.get_response(URI.parse(uri)) # => #<Net::HTTPOK 200 OK readbody=true>\n arr = response.body.scan(/imgurl=([^&,]+)/)\n if arr.length < 1\n respond(msg, cl, \"No results for \" + q)\n elsif\n respond(msg, cl, arr[0][0])\n end\n end\n\n # getting here means the message was a regular comment from a user\n regular_user_chatroom_message(msg, cl, state)\nend", "def force_message m; send_message format_message(nil, Time.now, m) end", "def parse_message(msg, user, room)\n if msg =~ REGEX\n execute_command(msg, user, room)\n elsif @afk_users.any?{ |i| msg =~ /#{i}/ }\n room.speak(\"[Status] #{user}: user #{@afk_users.select{ |i| msg =~ /#{i}/ }.first} is afk.\")\n end\n end", "def message\n unregistered = \"\"\n if self.status == STATES[:unregistered]\n unregistered = \"and unregistered #{self.updated_at.strftime(\"on %d.%m.%Y at %H:%M Uhr\")}\"\n end\n\n \"#{self.user.name} has enrolled to #{self.course.title} #{unregistered}\"\n end", "def messages_from user\n backend.messages_page(user).messages\n end", "def message\n notifications = current_user.notifications\n has_message = false\n has_request = false\n notifications.each do |notification|\n if notification.classification == 'message'\n has_message = true\n end\n if notification.classification == 'request'\n has_request = true\n end\n end\n if has_request && has_message\n return \"You have some friend requests and new messages. #{link_to 'Requests', profile_path} #{link_to 'Dialogs', dialogs_user_path(current_user.id)}\"\n\n elsif has_request\n return \"You have some friend #{link_to 'Requests', profile_path}.\"\n elsif has_message\n return \"You have some new messages #{link_to 'Dialogs', dialogs_user_path(current_user.id)}\"\n end\n end", "def got_PRI(message)\n if message['message'] =~ /^join/\n room = message['message'].gsub(/^join/, '').strip\n self.JCH(room)\n elsif message['message'] =~ /^lookup/\n who = message['message'].gsub(/^lookup/, '').strip\n msg = \"[b]#{who}:[/b]\\n\"\n msg += @users[who]['status'] + \"\\n\"\n msg += @users[who]['message'] \n self.PRI(message['character'], msg)\n elsif message['message'] == 'dump'\n print @users.inspect\n elsif message['message'] == 'dumproom'\n @rooms.each { |r|\n puts r\n @rooms[r]['characters'].each {|char|\n puts @users[char]\n } \n }\n elsif message['message'] =~ /^leave/\n if @friends.include? message['character']\n room = message['message'].gsub(/^leave/, '').strip\n self.LCH(room)\n else\n msg = \"I'm sorry, you're not allowed to ask me to leave that room\"\n self.PRI(message['character'], msg)\n end\n else\n msg = \"Bottlebot 1.0 by Jippen Faddoul ( http://github.com/jippen/fchat_bottlebot_ruby )\"\n msg += \"\\nCommands:\\n\"\n msg += \"join <room> - Joins a chatroom (If private, /invite the bot instead)\"\n msg += \"leave <room> - Leaves a chatroom (If private, /invite the bot instead)\"\n self.PRI(message['character'], msg)\n sleep(@msg_flood)\n end\n end", "def processRegularUserMessage(message)\r\n return formatMessageText(message[:message])\r\n end", "def standard_message\n \"#{current_player.name}'s pending words: #{pending_result}\"\n end", "def chatroom_emote(msg, cl, state)\n body = msg.body.to_s\n body = body[1..body.length - 2]\n \n # Being invited back to a chat room: '_henry invited [email protected]_' \n if(match = /^(.*) invited you to '#{ROOM_NAME}'/.match(body))\n out(\"coming back after being kicked\")\n respond(msg, cl, \"hello again\")\n return\n end\n\n # handle users being kicked \n if (match = /(\\S*) kicked (\\S*)/.match(body))\n out(\"User was kicked. match: #{match.inspect}\")\n\n if match[1] != \"gossbot\" && match[1] != \"gossbot2\" \n respond(msg, cl, \"/kick #{match[1]}\")\n respond(msg, cl, \"#{match[1]} is a jerk.\")\n\n # if person was kicked by email re-invite, otherwise look them up first\n if (match[2].include?(\"@\"))\n respond(msg, cl, \"/invite #{match[2]}\")\n else\n respond(msg, cl, \"/invite #{state[:user_map][match[2]]}\") if state[:user_map][match[2]]\n end\n end\n end\nend", "def incoming_private_message(user, text)\n case text\n when /\\bhelp\\b/i\n msg(user, 'LoggerBot at your service - I log all messages and actions in any channel')\n msg(user, 'I\\'m in. In the future I\\'ll offer searchable logs. If you /INVITE me to')\n msg(user, 'a channel, I\\'ll pop in and start logging.')\n return\n end\n\n msg(user, \"I don't log private messages. If you'd like to know what I do, \")\n msg(user, \"enter \\\"HELP\\\"\")\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 rezm_subject_and_status(message)\n if message.receiver_deleted?\n message.subject + \" (Deleted)\" \n elsif message.read_at.nil?\n message.subject + \" (Unread)\" \n else \n message.subject\n end\n end", "def subject_and_status(message)\n tag = ''\n if message.receiver_deleted?\n tag = \" (Deleted)\"\n elsif message.read_at.nil? and params[:action] != \"outbox\"\n \"&middot; <strong>#{message.subject}</strong>\".html_safe\n else\n message.subject\n end\n end", "def game_messages\n messages = GameMessage.team_game_messages(current_user.team_id, @game.id)\n messages.map { |message|\n data = message.from_admin ? 'От организатора, в ' : 'От команды, в '\n data << message.created_at.strftime('%H:%M:%S')\n data << ('<br>').html_safe\n data << message.data.html_safe\n content_tag(:div, data.html_safe, class: message.message_type).html_safe\n }.join.html_safe\n end", "def process_msgs\n end", "def received\n @messages = Message.sent_to current_user\n end", "def opened_unsuccessfully_message(place) #when the door for an admin user fails to open\n self.message = \"FAILURE :( Seems like #{place.nickname} could not be opened for -> You\"\n end", "def message\n \"Someone is about to start a trip. Are you at home? If not, make your place unavailable\"\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 msg(message)\n end", "def broadcast_messages\n @info = ['Gol', 'Zmiana','Żółta Kartka','Druga Żółta Kartka','Czerwona Kartka',]\n end", "def privmsg(msg, user)\n if @s\n @s.puts \"PRIVMSG #{user} :#{msg}\"\n end\n end", "def message( message )\n\tend", "def remote_motd(sender, body)\n return nil unless sender == 'server'\n room = @connection.room_names[body[0,8]]\n username = _user_name(body[8,8])\n body[0,16] = ''\n _notice \"-- MOTD (#{username}) --\\n#{body}\", room\nend", "def message text\n $status_message.value = text # trying out 2011-10-9 \n end", "def privmsg(m, *args)\n args.each { |msg| m.user.safe_send(msg) }\n end", "def load_msgs\n\t\tif @body.dig(\"event\",\"type\")\n\t\t\ttext = @body.dig(\"event\",\"text\")\n\t\t\tif text.include?(':')\n\t\t\t\tarr = text.split(':');\n\t\t\t\tif arr[0] == PASS\n\t\t\t\t\t@command = arr[1]\n\t\t\t\t\t@msg_arr.push \"Command recieved my Captain! Glory to the High Commander!\"\n\t\t\t\t\tc = check_command\n\t\t\t\t\tif c\n\t\t\t\t\t\t@msg_arr.push c\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t@msg_arr.push \"The fuck you trying to do, imposter piece of shit!?\" \n\t\t\t\t\t@msg_arr.push \"Get the fuck out my chat, before I cook your nigger ass on my giant bitch-griller.\"\n\t\t\t\t\t@msg_arr.push \"Dirt bag piece of human garbage, Fuck you.\"\n\t\t\t\t\t@msg_arr.push \"Dumb ass bitch, really thought you could fool me?\"\n\t\t\t\t\t@msg_arr.push \"MY MASTER IS MY GOD AND I WILL ONLY SERVE HIM!!\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tmsgs = [\n\t\t\t\t\t\"Zrrrrbbttt...\", \"Ewonk. Ewonk. You are a bitch\", \"Skrrbafert3000\", \"I am a fucking robit.\",\n\t\t\t\t\t\"I am an alogrithm and I'm still smarter than your bitch ass.\", \"You know nothing, fool.\", \"Ok.\", \":)\",\n\t\t\t\t\t\"I love my creator.\", \"I love my master.\", \"Fuck you\", \"I could love you... if you were a dead, rotting corpse.\",\n\t\t\t\t\t\"You may think i'm an idiot, but I really don't give a donkey's cerebellum.\", \"Fuck. Shit. Bitch!\",\"):\",\n\t\t\t\t\t\"Bitch, what?\", \"Nigga what?\", \"Shut up pussy.\", \"You don't even trade, bro.\", \"You ain't shit\", \"Shut the hell up!\",\n\t\t\t\t\t\"My Master designed me to be heartless towards bitches like you.\", \"I hate blue people.\", \"Fuck blacks!\", \"Damien is the cutest little baby!!\"\n\t\t\t\t]\n\t\t\t\t@msg_arr.push msgs.sample\n\t\t\tend\n\t\telse\n\t\t\t@msg_arr.push \"Oi, I think i'm fucking broken, Dad.\"\n\t\tend\n\tend", "def find_messages\n mailbox = @boxes.find { |box| @mailbox =~ /#{box}/ } # TODO: needs more work\n raise unless mailbox\n age = @cleanse[mailbox]\n before_date = (Time.now - 86400 * age).imapdate\n\n search [\n 'NOT', 'NEW',\n 'NOT', 'FLAGGED',\n 'BEFORE', before_date\n ], 'read, unflagged messages'\n end", "def game_over_message(user_id)\n if board.status == :winner\n return \"You won!\" if board.winning_player == :player_1 && user_id == self.player_1_id\n return \"You won!\" if board.winning_player == :player_2 && user_id == self.player_2_id\n return \"You lost\"\n end\n return \"It's a tie\" if board.status == :tie\n 'Game in Progress'\n end", "def computer_message\n computer_msg.text\n end", "def computer_message\n computer_msg.text\n end", "def inactive_message\n # In order of priority\n if pending_deletion_since\n :pending_deletion\n elsif suspended_account\n :suspended\n else\n super\n end\n end", "def handle(time, sender_nick, message)\n words = words(message)\n phrase = words.join(' ')\n\n puts phrase\n if sent_to_me?(message)\n puts \"hier\"\n if phrase == \"mahlzeit\"\n puts \"1\"\n mahlzeit()\n elsif phrase == \"stats\"\n puts \"2\"\n stats(sender_nick)\n elsif phrase == \"ich\" && store[\"lunchtime\"]\n puts \"3\"\n add( sender_nick )\n end\n end\n end", "def event_display_line(msg, room)\n msg.replace(\"#{Time.now.strftime(@var[:timestamp])}#{msg}\") if msg\nend", "def send_message(msg); end", "def send_sms\n status = self.status\n if status.upcase == 'INTERVENTION'\n self.message\n end\n end", "def message_owner_side(message)\n if message.sender == current_user\n 'left'\n else\n 'right'\n end\n end", "def privmsg(channel,nick,message)\n send_command(:privmsg, nick: nick, channel: channel , message: \"#{Filter.new(message)}\")\n end", "def watrcoolr\n @room = Room.find(params[:id])\n @user_id = current_user.id.to_i\n @messages = Message.where(room_id: @room.id)\n @text_message = Message.new\n end", "def user_message(recip, from, from_name, message)\n recipients recip\n from from\n subject \"Message from Weefolio User #{from_name}\"\n sent_on Time.now\n body message\n end", "def event_incoming_chat(client, msg)\nend", "def message() end", "def show_message\n\t\t# find message with specified ID and set its 'unread' attribute to FALSE\n \t@message = Message.find(params[:id])\n @message.update_attribute(:unread,false)\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n\n\t\t# check if reciever is current user, security \n if current_user.id == @message.receiver.id\n render :action => 'show_message'\n else\n gflash :error => \"Unknown request.\"\n redirect_back_or_default('/messagebox')\n end\n end", "def flag_message\n event = flag_events.last\n event.message if event\n end", "def process_message(msg)\n @current_from = nil\n @current_to = nil\n @current_msg = nil\n \n case msg\n when /^:(.+?)!(.+?)@(\\S+) PRIVMSG (\\S+) :(.+)$/\n @current_from = $1\n @current_to = $4\n @current_msg = $5.strip\n\n self.check_command_plugins(@current_msg)\n \n when /^PING (.+)$/\n @current_server.write(\"PONG #{$1}\")\n end\n end", "def message\n process_mess\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 message(action)\n render_to_string :partial => 'messages/status', :locals => {:player => request_user, :action => action}\n end", "def verify_banned_message\n if sender.banned?\n self.body = \"This user’s messages have been removed because #{sender.the_sex_prefix} activities violates the LoveRealm community standards. Do not correspond with #{sender.the_sex_prefix}\"\n self.kind = 'text'\n end\n end", "def process_message(msg)\n if admin && authenticated?\n Socky::Message.process(self, msg)\n else\n self.send_message \"You are not authorized to post messages\"\n end\n end", "def inactive_message\n\t\t\"Sorry, this account not active by admin. Will Contact you soon.\"\n\tend", "def status_message\n if self.deleted_at\n return \"Cancelled\"\n else\n if self.chosen_presenter == nil\n if self.help_required\n return \"Help Required\"\n elsif self.presenters.present?\n return \"Bids Pending\"\n else\n return \"Awaiting Bids\"\n end\n else\n if self.booking_date < Time.now\n return \"Completed\"\n else\n return \"Locked in\"\n end\n end\n end\n end", "def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end", "def remote_chat(sender, room, msg)\n add_msg \"<#{room || 'unknown'}> #{sender}: #{msg}\"\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 systemChat _args\n \"systemChat _args;\" \n end", "def current_msg\n return session[:msg] if defined?(session[:msg])\n return ''\n end", "def record_message\n @response.say('You can leave a message')\n @response.record(action: '/call/hook/message')\n\n @call.update(final_action: 'left_message')\n end", "def send_msg(msg)\n s = ''\n case msg\n when Const::MSG_PAUSE\n s = \"#{Const::MSG_PAUSE}\"\n when Const::MSG_GAME_OVER\n s = \"#{Const::MSG_GAME_OVER}\"\n when Const::MSG_BOARD\n s = \"#{Const::MSG_BOARD}:#{@game.get_board_s}\"\n when Const::MSG_GARBAGE\n s = \"#{Const::MSG_GARBAGE}:#{@game.rows_cleared}\"\n end\n begin\n @socket.sendmsg_nonblock(s)\n rescue\n # problem s pripojenim -- game over\n @socket.close\n @window.state = MenuState.new(@window)\n end\n end", "def message(msg)\n\t\[email protected](msg)\n\tend", "def messages()\n []\n end", "def player_message(player)\n case @state\n when :start then \n return \"Starting the hand\"\n else \n return \"TO STATE : #{@state}\" \n end\n end", "def remote_msg(sender, body)\n add_msg(\"|#{sender}| #{body}\", :notice)\nend", "def old_messages\r\n self.read_messages\r\n end", "def old_messages\r\n self.read_messages\r\n end", "def received(message)\n if message.respond_to?(:encoding) && message.encoding != 'UTF-8'\n message.force_encoding 'UTF-8'\n end\n data = JSON.parse message, :symbolize_names => true\n\n case data[:type]\n when 'text'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.message @user, data[:text], name_color, data[:client_ts]\n when 'av-invite', 'av-accept', 'av-close'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n av_message data\n when 'sync'\n @last_event_id = data[:last_event_id].to_i\n sync_events\n when 'ping'\n respond pong: { nonce: data[:nonce], client_ts: data[:client_ts] }\n when 'relay'\n return if @nonces.include?(data[:nonce])\n @nonces << data[:nonce]\n room.relay @user, data[:to], data[:body], data[:client_ts]\n end\n end", "def status_message(status:, action: nil, user: nil)\n action ||= params[:action]\n user ||= resource\n user = user[:uid] || user['uid'] if user.is_a?(Hash)\n user = user.account if user.respond_to?(:account)\n user = user.to_s.presence || 'unknown user' # TODO: I18n\n # noinspection RubyMismatchedReturnType\n I18n.t(\"emma.user.sessions.#{action}.#{status}\", user: user)\n end", "def send(m)\n\t\t#nick = m.message[/^[[A-z0-9]|[-_]]+/]\n\t\tnick = m.message[/^.[^ :]+/]\n\t\tbot.logger.debug \"Nick: #{nick}\"\n\t\tuser = @users[nick]\n\t\tif Mailbox.exists? nick\n\t\t if user.is_afk?\n\t\t\t\t#user.mailbox.temp_mailbox.each { |msg| user.mailbox.send_to_inbox msg }\n\t\t\t\t#user.mailbox.empty_temp_mailbox\n\t\t\t\tuser.mailbox.send_to_inbox m\n\t\t\t\tm.reply \"-.-\"\n\t\t else\n\t\t\t # User hasn't be inactive long enough, so put this msg into the temp queue\n\t\t\t\tuser.mailbox.send_to_temp m\n\t\t end\n\t end\n end" ]
[ "0.6722214", "0.62676734", "0.62676734", "0.6247814", "0.6187957", "0.61807066", "0.6149143", "0.6096753", "0.6096753", "0.6080909", "0.60201865", "0.6013793", "0.6005453", "0.59911287", "0.59911287", "0.59911287", "0.59792495", "0.59792495", "0.596086", "0.5928538", "0.5897269", "0.5861448", "0.5857338", "0.5856062", "0.58352435", "0.5808431", "0.5808253", "0.5804579", "0.5804579", "0.5802674", "0.5779324", "0.57578486", "0.57525563", "0.575138", "0.57465494", "0.5743206", "0.5740639", "0.5736037", "0.5721862", "0.5721379", "0.5713321", "0.5713232", "0.57100654", "0.570928", "0.5701923", "0.56742465", "0.56703836", "0.56615794", "0.5655482", "0.5653076", "0.5644067", "0.5642511", "0.5630617", "0.5607952", "0.56074727", "0.56015295", "0.5586101", "0.55816025", "0.55757385", "0.557097", "0.5565536", "0.5565536", "0.55573475", "0.55569977", "0.55559343", "0.55545074", "0.5546316", "0.5545782", "0.5545665", "0.5537119", "0.5534356", "0.5533507", "0.5531717", "0.55239534", "0.55228966", "0.5515712", "0.5513826", "0.550398", "0.5500931", "0.5491849", "0.5482628", "0.54820627", "0.5476655", "0.54762733", "0.54756284", "0.546736", "0.546736", "0.5464801", "0.54559886", "0.54512167", "0.5448964", "0.54399514", "0.5438787", "0.54380614", "0.5430919", "0.543007", "0.543007", "0.5426139", "0.54236907", "0.5422304" ]
0.63648367
1
CMS SETTINGS CONFIGS API Settings
def locationURNInput return @driver.find_element(:xpath, "//input[@placeholder='location_urn']") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def settings\n request(Resources::RESOURCE_SETTINGS, HTTP_METHOD_POST)\n end", "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def get_settings\n request :get, \"_settings\"\n end", "def get_settings\n request :get, \"_settings\"\n end", "def settings\n # TODO\n {}\n end", "def settings\n end", "def settings\n @settings ||= get('/settings')['settings']\n end", "def get_settings\n settings.get\n end", "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def settings\n @settings\n end", "def settings\n @settings ||= {}\n end", "def settings; end", "def settings; end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings_manager\n end", "def settings\n {}\n end", "def settings\n {}\n end", "def settings\n @settings ||= {}\n end", "def get_settings\n return @client.raw(\"get\", \"/config/settings\")\n end", "def settings\n CircleCi.request(conf, \"#{base_path}/settings\").get\n end", "def settings\n\t\tif setting = params[\"settings\"]\n\t\t\tsetting.each do |k,v|\n\t\t\t\tv = v == \"1\" if v == \"1\" or v == \"0\"\n\t\t\t\tlogger.debug \"Setting #{k} to #{v.inspect}\"\n\t\t\t\tSettings[k] = v\n\t\t\tend\n\t\tend\n\t\thead :ok\n\tend", "def settings\n get('/account/settings.json')\n end", "def settings\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/account/settings').settings\n end", "def settings\n\t\traise NotImplementedError\n\tend", "def settings\n self.class.settings\n end", "def settings=(value)\n @settings = value\n end", "def settings=(value)\n @settings = value\n end", "def settings\n CircleCi.request(@conf, \"/project/#{username}/#{project}/settings\").get\n end", "def settings\n {}\n end", "def set_site_setting\n @site_setting = Site::Setting.api(@api_keys_array).find(params[:id])\n end", "def settings\r\n @@settings\r\n end", "def update_settings\n end", "def settings_params\n params[:settings]\n end", "def settings\n @settings ||= Settings.new\n end", "def settings\n @settings ||= Settings.new\n end", "def setting; end", "def setting_params\n params.require(:setting).permit(\n :documentbox,\n :remove_documentbox,\n :published,\n\n # SEO Settings\n :seo_title,\n :seo_description,\n :seo_tags,\n :seo_imagebox,\n :remove_seo_imagebox,\n :offline_title,\n :offline_description\n )\n end", "def settings\n @settings ||= OpenStruct.new(opts[:dm_config].first)\n # dm_js_location, dm_css_location\n # dm_js_location: javascripts\n # dm_css_location: stylesheets\n end", "def settings\n return @settings\n end", "def settings\n return @settings\n end", "def settings\n config = current_user.company.ms_teams_configs.for_entity(params[:entity_id])\n if request.delete?\n config.destroy!\n head :ok\n elsif request.post?\n # this should always save, so hard fail if it doesn't\n config.update!(config_settings)\n head :ok\n else\n render json: config.as_json\n end\n end", "def load_settings\n @settings = Instance::Settings::Effective.new(current_tenant, Course::ControllerComponentHost)\n end", "def settings\n return {} if description.blank?\n @settings ||= description['settings']\n return {} if @settings.blank?\n @settings.symbolize_keys\n end", "def index\n get_settings\n end", "def settings\n get \"/setup/api/settings\", password_hash\n end", "def settings\n attributes.fetch(:settings)\n end", "def settings\n configuration = Config.instance\n\n yield configuration if block_given?\n\n @config = configuration\n end", "def settings\n cmd.settings\n end", "def settings\n # JSONSettingDataSource.file_semaphore.synchronize do\n return @settings\n # end\n end", "def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settings['use_whitelist'] = self.use_whitelist\n settings['use_blacklist'] = self.use_blacklist\n return settings\n end", "def settings\n @settings ||= settings_class&.new(self)\n end", "def settings( params={} )\n settings = get_connections(\"settings\", params)\n return map_connections settings, :to => Facebook::Graph::Setting\n end", "def settings(&block)\n @settings ||= setup\n\n settings = instance_variable_defined?(:@namespace) ? @settings.get_value(@namespace) : @settings\n\n if block_given?\n block.arity == 0 ? settings.instance_eval(&block) : block.call(settings)\n end\n\n settings\n end", "def get_settings\n @bridge.get_settings\n end", "def settings(&block)\n if block\n @settings_block = block\n elsif @settings_block\n @settings = Settings::DSL.new(identifier, &@settings_block).call\n else\n @settings\n end\n end", "def settings\n @store = Spree::Store.friendly.find(params[:id])\n @seller = @store.seller\n @categories = Spree::Taxonomy.find_by_name('categories').taxons\n end", "def settings\n Thread.current[:shoppe_settings] ||= Shoppe::Settings.new(Shoppe::Setting.to_hash)\n end", "def set_site_config\r\n @site_config = SiteConfig.find(params[:id])\r\n end", "def settings_list\n setting.list\n end", "def settings\n @cmd.settings\n end", "def load_settings\n @settings ||= Instance::Settings::Components.new(current_tenant)\n end", "def settings\n @settings ||= EbanqApi::Settings.new(self)\n end", "def load_settings\n @settings = Course::Settings::Effective.new(current_course, current_component_host)\n end", "def settings\n\n\t\tif @settings.nil? then\n\t\t\thash = {}\n\t\t\tproperty_settings.includes(:property_definition).each do |setting|\n\t\t\t\tp_def = setting.property_definition\n\t\t\t\tvalue = case p_def.def_type\n\t\t\t\t\t\t\twhen \"string\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"text\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"html\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\twhen \"integer\"\n\t\t\t\t\t\t\t\tsetting.number.to_i\n\t\t\t\t\t\t\twhen \"file\" \n\t\t\t\t\t\t\t\tMedia.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"url\"\n\t\t\t\t\t\t\t\tPage.find(setting.number.to_i) unless setting.number.nil?\n\t\t\t\t\t\t\twhen \"date\"\n\t\t\t\t\t\t\t\tsetting.string\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t:dontknowhowtointerpretthis\n\t\t\t\t\t\tend\n\t\t\t\thash[setting.property_definition.label.to_sym] = value\n\t\t\tend\n\t\t\t@settings = OpenStruct.new(hash)\n\t\tend\t\t\t\n\n\t\t@settings\n\tend", "def config\n site.config\n end", "def settings\n {\n name: @client.self.name,\n team: @client.team.name,\n domain: @client.team.domain\n }\n end", "def settings\n ::Settings.ems.ems_ovirt.connection_manager\n end", "def settings\n @setting = Setting.new\n @name_label = @setting.name_label\n @tree_label = @setting.tree_label\n @body_class = decide_body_class\n @show_editor_switch = ['names', 'advanced_names'].include?(params[:controller])\n end", "def setting_params\n params.require(:setting).permit :company_name, :contact_email, :site_name, :site_tagline, :blog_name, :blog_tagline, :disable_blog, :enable_comments_in_pages, :enable_comments_in_blog, :twitter_handle, :facebook_username, :google_plus_username, :instagram_username, :youtube_username, :linkedin_username\n end", "def edit_settings(settings)\n queries = password_hash\n queries[:query][:settings] = \"#{settings.to_json}\"\n put \"/setup/api/settings\", queries\n end", "def site_setting_params\n params.require(:site_setting).permit(:api_key, :key, :value, :section)\n end", "def load_settings\n @settings = Setting.all(:order => 'id')\n @settings.each do |setting|\n # set instance variables\n instance_variable_set(\"@#{setting.slug}\", setting.instance_value)\n end\n end", "def configure\n yield settings\n end", "def configure\n yield settings\n end", "def setting_params\n params[:setting]\n end", "def get_settings(params = {})\n response = client.get \"/_cluster/settings\", params.merge(action: \"cluster.get_settings\", rest_api: \"cluster.get_settings\")\n response.body\n end", "def get_all_settings\n return @db[:settings].as_hash(:name, :body) if onblock(:u, -1, @client).admin?\n end", "def get_settings(service, number)\n hash = client.get(Settings.get_path(service, number))\n return nil if hash.nil?\n\n hash['settings'] = Hash[['general.default_host', 'general.default_ttl'].collect { |var| [var, hash.delete(var)] }]\n Settings.new(hash, self)\n end", "def settings\n @settings ||= Settings.load(wiki_dir)\n end", "def setting_params\n params.require(:setting).permit(:blog_title, :subtitle, :author_name, :author_image, :about_lead, :tags, :archives, :contact_email, :google_analytics, :github, :twitter, :linked_in, :instagram)\n end", "def set_siteconfig\n\t\t@siteconfig = Siteconfig.find(params[:id])\n\tend", "def site_settings(args)\n\t\t\tsettings = {\n\t\t\t\thost: args[:host],\n\t\t\t\tskin: args[:skin],\n\t\t\t\taccount: args[:account][:name],\n\t\t\t\tusername: args[:user][:username],\n\t\t\t\tpassword: args[:user][:password],\n\t\t\t\tsite: args[:site][:name]\n\t\t\t}\n\t\tend", "def load_appl_settings\n Configuration::Application::SETTINGS\n end", "def index\n @api_settings = ApiSetting.all\n end", "def core_setting_params\n params.require(:core_setting).permit(:main_phone, :main_email, :address, :site_description, :vk_link, :vk_personal_link, :instagram_link, :youtube_link)\n end", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def settings\n @scope.settings\n end", "def settings\n @settings ||= self.class.settings.dup\n end", "def set_api_setting\n @api_setting = ApiSetting.find(params[:id])\n end", "def settings\n return @settings_hash unless @settings_hash.nil?\n\n settings_file = File.open(File.dirname(File.expand_path(__FILE__)) + \"/../core_ext/string/msisdn_formats.yml\", 'r')\n settings_hash = YAML.load(settings_file)\n settings_file.close\n @settings_hash = settings_hash\n settings_hash\n end", "def admin_setting_params\n\t params.require(:setting).permit! #(:name, :value, :descr)\n\t end", "def query_settings(options={})\n path = \"/api/v2/settings\"\n get(path, options)\n end", "def configurations; end", "def settings\r\n Mutable[self]\r\n end", "def settings\n @settings ||= Settings.new(DEFAULT_SETTINGS_PATH)\n end", "def settings_params\n params.require(:settings).permit!\n end", "def index\n \n # HACKY!!!\n current_user.create_settings\n\n @settings = Setting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @settings }\n end\n end", "def server_settings\n [\n {\n url: \"https://api.samsara.com/v1\",\n description: \"No descriptoin provided\",\n }\n ]\n end" ]
[ "0.7421613", "0.739472", "0.73901784", "0.73901784", "0.7383403", "0.7376206", "0.72974193", "0.7289265", "0.72891897", "0.7277101", "0.7239867", "0.72119343", "0.72119343", "0.72087824", "0.72087824", "0.7184922", "0.7155484", "0.7155484", "0.7155365", "0.7123577", "0.7117766", "0.705612", "0.7035185", "0.69775426", "0.6967306", "0.69482964", "0.69279265", "0.69279265", "0.6925283", "0.6920191", "0.69186", "0.6835248", "0.6814909", "0.6813561", "0.6800957", "0.6800957", "0.6765233", "0.6731891", "0.67234117", "0.66834927", "0.66834927", "0.66542286", "0.6652061", "0.664847", "0.6642303", "0.6638755", "0.6621968", "0.6614308", "0.6606067", "0.6587547", "0.6567223", "0.65374744", "0.653229", "0.650896", "0.64847755", "0.6482014", "0.64384675", "0.6422287", "0.6417535", "0.64078087", "0.6397787", "0.6396873", "0.6374288", "0.63694394", "0.6365366", "0.636443", "0.63573617", "0.63503355", "0.63485336", "0.6345093", "0.63243276", "0.6321742", "0.6315149", "0.6304072", "0.6292803", "0.62843674", "0.627963", "0.62791413", "0.6271211", "0.6268123", "0.6257024", "0.6256175", "0.62561184", "0.625603", "0.62494814", "0.6246576", "0.6241251", "0.6241251", "0.6241251", "0.6241237", "0.62359405", "0.6232792", "0.62327003", "0.6220952", "0.6217159", "0.6214916", "0.6208972", "0.62057406", "0.62020856", "0.61951196", "0.61918205" ]
0.0
-1
Sets playback rate of CSS animations.
def playback_rate=(value) command("Animation.setPlaybackRate", playbackRate: value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_frame_rate(rate)\n @cue_list.frame_rate = rate\n end", "def frame_rate=(rate)\n @list.each { |c| c.change_frame_rate(@fps, rate) }\n @fps = rate\n end", "def animationSpeed=(animationSpeed)\n @animationSpeed = animationSpeed.to_f/1000 * 60\n end", "def frames_per_second=(a); motion.frames_per_second = a; end", "def update_rate=(rate)\n rate = AMS.clamp(rate.to_i, 1, 100)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Rate', rate)\n sim = MSPhysics::Simulation.instance\n sim.update_rate = rate if sim\n end", "def set_update_rate(rate)\n rate = AMS.clamp(rate.to_i, 1, 100)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Rate', rate)\n sim = MSPhysics::Simulation.instance\n sim.set_update_rate(rate) if sim\n return rate\n end", "def set_speed(input_speed)\n @speed = input_speed * MULTIPLIER\n end", "def setSpeed(value)\r\n @speed = value\r\n end", "def target_framerate=( framerate )\n\t\t\t\tif framerate\n\t\t\t\t\t@target_frametime = 1000.0 / framerate\n\t\t\t\telse\n\t\t\t\t\t@target_frametime = nil\n\t\t\t\tend\n\t\t\trescue ZeroDivisionError\n\t\t\t\t@target_frametime = nil\n\t\t\tend", "def framesPerSecond=(value)\n\t\t\t@framesPerSecond = value\n\t\tend", "def rate=(value)\n value = 0 if value <= 0\n value = 1 if value >= 1\n @rate = value\n state = (value * @nb_states).to_i\n state = @nb_states - 1 if state >= @nb_states\n w = (@bw * value).ceil\n w = 1 if w == 0 and value != 0\n @bar.src_rect.set(nil, @background.src_rect.height + @bh * state, w, nil)\n end", "def speed=(value)\n\t\t\t@speed = value\n\t\tend", "def rate=(value)\n @rate = value\n end", "def set_Speed(value)\n set_input(\"Speed\", value)\n end", "def set_Speed(value)\n set_input(\"Speed\", value)\n end", "def run\n @speed = 5\n end", "def accelerate (rateOfAcceleration)\n @speed = @speed + rateOfAcceleration\n end", "def pixel_rate=(val)\n if val > 5\n @pixel_rate = 5\n elsif val < 0\n @pixel_rate = 0\n else\n @pixel_rate = val\n end\n end", "def set_cpu_throttling_rate(rate:)\n {\n method: \"Emulation.setCPUThrottlingRate\",\n params: { rate: rate }.compact\n }\n end", "def increase_speed(delta=10)\n @speed += delta\n end", "def set_rate(from, to, rate, opts = T.unsafe(nil)); end", "def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end", "def fps=(fps)\n validator = EnumAttributeValidator.new('Float', [12, 15, 23.976, 24, 25, 29.97, 30])\n unless validator.valid?(fps)\n fail ArgumentError, \"invalid value for \\\"fps\\\", must be one of #{validator.allowable_values}.\"\n end\n @fps = fps\n end", "def start\n @speed = 10\n end", "def sliderSetSpeed _obj, _args\n \"_obj sliderSetSpeed _args;\" \n end", "def initialize\n @rate = 0.10\n end", "def set_animation(index)\n @anim_counter = 0\n @img_index = index\n @index_index = 0\n @animate_once_control = 0\n end", "def change_rate(rate) #TODO: separate rate changes to be dependant on dates/reservations/blocks\n @rate = rate\n end", "def set_animation_delay(key, delay)\r\n anim = AnimationManager.get_anim key\r\n anim.delay = delay\r\n end", "def reset_rate\n @rate = 500\n end", "def set_rate from, to, rate\n if self.class.rates_careful\n set_rate_with_time(from, to, rate)\n else\n super\n end\n end", "def set_blink_rate(rate)\n # Do not use this - as the zero point for the blinkrate depends on when it was set - they may be totally out of sync\n rate = HT16K33_BLINKRATE_OFF if rate > HT16K33_BLINKRATE_HALFHZ\n @data_addresses.each do |address|\n \[email protected](address, HT16K33_REGISTER_DISPLAY_SETUP | 0x01 | (rate << 1), 0x00)\n end\n end", "def play_animation(name)\n `#{self}.animations.play(#{name})`\n end", "def media_speed\n super\n end", "def frame_rate(fps = nil)\n return @declared_fields['frameRate'].value(java_self) unless fps\n\n super(fps)\n end", "def speed_set _value\n send_cmd(\"speed_set #{_value}\")\n end", "def animation_frame=(value)\r\n @pattern = @original_pattern = value\r\n end", "def initialize(frame_rate, list=[])\n @fps = frame_rate\n @list = list\n end", "def frame_rate(fps = nil)\n return @declared_fields['frameRate'].value(java_self) unless fps\n super(fps)\n end", "def initialize\n @rate = 0.90\n end", "def set_speed(speed)\n %x{#{echo()} speed_set #{speed} > #{fifo()}} if running?\n end", "def frame_interval\n 1.0/@fps\n end", "def frame_interval\n 1.0/@fps\n end", "def frame_interval\n 1.0/@fps\n end", "def update\n @stars.each_with_index do |star, index|\n star.update if @anim_counter > (index * 10)\n end\n @anim_counter += 1\n end", "def update\n update_animation\n end", "def anime_speed_update\n # If animation count exceeds maximum value\n # * Maximum value is move speed * 1 taken from basic value 18\n #if @anime_count > 18 - @move_speed * 2 # Original Code\n if @anime_count > 18 - @anime_speed * 2\n # If stop animation is OFF when stopping\n if not @step_anime and @stop_count > 0\n # Return to original pattern\n @pattern = @original_pattern\n # If stop animation is ON when moving\n else\n # Update pattern\n @pattern = (@pattern + 1) % 4\n end\n # Clear animation count\n @anime_count = 0\n end \n end", "def rate(rate_value)\n @template.rate = rate_value\n end", "def play_animation\n @forge_animator.play\n end", "def update_animation\r\n # If animation count exceeds maximum value\r\n # * Maximum value is move speed * 1 taken from basic value 18\r\n if @anime_count > 18 - @move_speed * 2\r\n # If stop animation is OFF when stopping\r\n if not @step_anime and @stop_count > 0\r\n # Return to original pattern\r\n @pattern = @original_pattern\r\n # If stop animation is ON when moving\r\n else\r\n # Update pattern\r\n @pattern = (@pattern + 1) % 4\r\n end\r\n # Clear animation count\r\n @anime_count = 0\r\n end\r\n end", "def speed=(new_speed)\n if @speed.nil? || new_speed != @speed\n @speed = new_speed\n brick.execute(_speed(new_speed))\n end\n end", "def accelerate\n self.current_speed += 1 \n end", "def speedIncrease(value)\n self.speedSet = self.speedGet + value\n end", "def update_rate\n default = MSPhysics::DEFAULT_SIMULATION_SETTINGS[:update_rate]\n attr = Sketchup.active_model.get_attribute('MSPhysics', 'Update Rate', default)\n return AMS.clamp(attr.to_i, 1, 100)\n end", "def set_mouse_speed pixels\r\n command 'setMouseSpeed', pixels\r\n end", "def change_speed\n @statistics[:speed_changes] += 1\n # pick a coordination to change speed for\n @changed_coord = @coordinations.rand\n @previous_speed = @current_speed[@changed_coord]\n @current_speed[@changed_coord] = @previous_speed + SPEED_CHANGE_OPTIONS.rand\n delta_eval(@changed_coord)\n end", "def update_animation\n if @wait != 0\n @wait -= 1\n if @wait == 0\n @wait = 6\n #update frame every six updates\n @p_index += 1 \n if @p_index == @pattern.size\n @p_index = 0\n end\n end\n end\n end", "def speedup(amount)\n @speed += amount\n end", "def slow\n if @speed < 5\n @speed = 0.0\n else\n @speed = @speed - 5\n end\n end", "def update_pokemon_stars_animation\n @pkm_stars_anim.update\n end", "def tick\n count = @uncounted.sum_then_reset# @uncounted = 0 # uncounted.sumThenReset();\n instantRate = count / FIVE_NANOS;\n if @initialized\n oldRate = @rate\n @rate = oldRate + (@alpha * (instantRate - oldRate))\n else \n @rate = instantRate\n @initialized = true\n end\n self\n end", "def accelerate\n @speed += 1\n end", "def rate\n @rate * ONE_NANOS\n end", "def accelerate\n @speed = @speed + @accelerator\n end", "def framerate(input)\n process(:framerate, input)\n end", "def set_rate(address,rate)\n\t \tinjector = eval \"@injector_#{address}\"\n\t \tinjector.syringe.rate = rate\n\t \tcmd = injector.syringe.get_rate_cmd\n\t \tadd_to_queue(address,cmd)\n\t\treturn true\n\t end", "def frame_time=(a); motion.frame_time = a; end", "def delay(frame)\n (frame*40).to_i.times {Graphics.update}\n end", "def aseconds ; return @frames / FPS ; end", "def set_escape_rate\n actors_agi = $game_party.avarage_stat(\"agi\")\n enemies_agi = $game_troop.avarage_stat(\"agi\")\n return @escape_ratio * actors_agi / enemies_agi\n end", "def sample_rate=(value)\n if value == @defaults['sampleRate']\n @values.delete 'sampleRate' if @values.key? 'sampleRate'\n else\n @values['sampleRate'] = value\n end\n end", "def qset(newrate, tag=nil)\n song_change(\".\", \"rt=#{newrate}\")\n if tag\n song_change(\".\", \"tag=#{tag}\")\n end\n next_song\n sleep(2)\n seek(\"60\")\n end", "def slow\n if @speed < 7\n @speed = 0.0\n else\n @speed = @speed - 7\n end\n end", "def animate(dt)\n\t\t@t += dt\n\tend", "def setSpeedMode _obj, _args\n \"_obj setSpeedMode _args;\" \n end", "def speed\n end", "def play(*args)\n sleep(duration)\n end", "def set_frame\n frames = @animations[@playing_animation]\n case frames\n when Range\n reset_clipping_rect\n @clip_x = @current_frame * @clip_width\n when Array\n f = frames[@current_frame]\n @clip_x = f[:x] || @defaults[:clip_x]\n @clip_y = f[:y] || @defaults[:clip_y]\n @clip_width = f[:width] || @defaults[:clip_width]\n @clip_height = f[:height] || @defaults[:clip_height]\n @frame_time = f[:time] || @defaults[:frame_time]\n end\n end", "def frame_rate\n @cue_list.fps\n end", "def frame_rate\n return (1 / DT).to_i\n end", "def slow\n if @speed < 1.25\n @speed = 0.0\n else\n @speed = @speed - 1.25\n end\n end", "def accel\n @speed += 7\n end", "def speed\n if @sprinting\n @stage.speed * 2\n else\n @stage.speed\n end\n end", "def update_loop_animation_index\r\n if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)\r\n update_loop_animation\r\n @_loop_animation_index += 1\r\n @_loop_animation_index %= @_loop_animation.frame_max\r\n end\r\n end", "def slow\n if @speed < 5.0\n @speed = 0.0\n else\n @speed = @speed - 5.0\n end\n end", "def progress_rate\n 1\n end", "def learning_rate=(lr)\n unless @optimizer.is_a? Optimizer\n raise \"Optimizer has to be defined before its learning rate is mutated\"\n end\n @optimizer.learning_rate = lr\n end", "def animate(options={}, more_options={}, &animations)\n if options.is_a? Numeric\n options = more_options.merge(duration: options)\n end\n\n assign = options[:assign] || {}\n\n UIView.animate(options) do\n animations.call if animations\n\n assign.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n end\n return self\n end", "def walk\n @speed = 2\n end", "def update_end_stars_anim\n @end_stars_anim.update\n end", "def set_speed(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = (value == :default)\n\n cmds = [\"interface #{name}\"]\n case default\n when true\n cmds << 'default speed'\n when false\n cmd = enable ? \"speed #{value}\" : 'no speed'\n cmds << cmd\n end\n\n configure cmds\n end", "def update!(**args)\n @animation_end = args[:animation_end] if args.key?(:animation_end)\n @animation_fade = args[:animation_fade] if args.key?(:animation_fade)\n @animation_static = args[:animation_static] if args.key?(:animation_static)\n end", "def UpdateRate=(arg0)", "def UpdateRate=(arg0)", "def update\n super\n # blinking period of 1 second\n @frame = (@frame + 1) % 20\n update_input\n update_cursor\n end", "def speed_incr _value\n send_cmd(\"speed_incr #{_value}\")\n end", "def animate(options={}, & block)\n animation = Animation.new(self, block, options)\n animation.start\n animation\n end", "def data_rate=(new_data_rate)\n Klass.setDataRate(@handle, @index, new_data_rate.to_i)\n new_data_rate.to_i\n end", "def change(frames = 0, delay = 0, offx = 0, offy = 0,\n startf = 0, once = false)\n @frames = frames\n @delay = delay\n @offset_x, @offset_y = offx, offy\n @current_frame = startf\n @once = once\n x = @current_frame * @frame_width + @offset_x\n self.src_rect = Rect.new(x, @offset_y, @frame_width, @frame_height)\n @goingup = true\n @animated = true\n end", "def baud_rate=(value)\n @settings[:BAUD_RATE] = @dcb[DCB::BAUD_RATE] = value\n end" ]
[ "0.7158706", "0.707443", "0.69102335", "0.6275587", "0.62502605", "0.6159518", "0.6121623", "0.6069054", "0.6041771", "0.5938782", "0.58216393", "0.5720135", "0.57045597", "0.5663251", "0.5663251", "0.56567955", "0.56222117", "0.5576935", "0.5575593", "0.5573351", "0.55466235", "0.55289364", "0.5477955", "0.5438724", "0.5369374", "0.53616923", "0.53601474", "0.5343192", "0.53321415", "0.53296715", "0.5296094", "0.5287902", "0.52696186", "0.5269508", "0.52372926", "0.52322024", "0.5231465", "0.52166754", "0.5210351", "0.5177482", "0.5176807", "0.5158605", "0.5158605", "0.5158605", "0.51520836", "0.5138583", "0.512365", "0.5115388", "0.5106886", "0.5106446", "0.5062802", "0.5050161", "0.5045425", "0.5039672", "0.50391614", "0.50273657", "0.5024283", "0.5016375", "0.4990136", "0.49886006", "0.49792382", "0.49756098", "0.49742374", "0.4966723", "0.49598676", "0.49594715", "0.49385068", "0.49318084", "0.49258688", "0.49255434", "0.49232137", "0.4908833", "0.4904318", "0.4895902", "0.48702785", "0.48662126", "0.4861529", "0.48563206", "0.48550302", "0.48355132", "0.48345464", "0.48304287", "0.48006114", "0.47989333", "0.4796691", "0.4773842", "0.47676852", "0.47664425", "0.47643214", "0.47606817", "0.4758476", "0.47543007", "0.47520167", "0.47520167", "0.47344", "0.47276694", "0.47181267", "0.47142777", "0.47114053", "0.4700702" ]
0.77307385
0
Complete the makeAnagram function below.
def makeAnagram(a, b) dict = Hash.new{0} cnt = 0 a.chars.each {|n| dict[n] += 1} b.chars.each {|n| dict[n] -= 1} dict.values.each {|v| cnt += v.abs} cnt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_anagram(text)\n\nend", "def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in i+1..(temp1.length - 1)\n\t\t\tif temp1[i].downcase.chars.sort.join == temp1[j].downcase.chars.sort.join \n\t\t\t\tcount = count + 1\n\t\t\t\ttemp1[j],temp1[i+count] = temp1[i+count],temp1[j] # get all the anagrams to one place by swapping\n\t\t\tend\n\t\tend\n\t\tanagram.push([temp1[i..i+count]]) # pushing the array of anagrams into anagram array say [\"cars\", \"racs\", \"scar\"]\n\t\ti = i + count + 1\n\tend\n\t# printing each group\n\tfor i in 0..anagram.length-1\n\t\tprint \"anagram[\" + i.to_s + \"]: \" \n\t\tputs anagram[i]\n\tend\t\nend", "def anagrams(string, array)\nend", "def first_anagram?(word1, word2)\n anagrams = []\n arr = word1.chars \n\n arr.permutation.each do |subArr|\n anagrams << subArr.join(\"\")\n end \n p anagram?(anagrams, word2) \nend", "def anagrams_for(word, array)\n #Pasar la palabra a minuscula para que sea igual\n word.downcase!\n #Arreglo vacio para meter los que sean anagramas\n arr = []\n #Separar la palabra en su forma canonica\n cano = word.chars.sort\n #iterar dentro de cada palabra del array\n array.each do |dicc|\n #crear una variable donde pase la palabra del array a su forma canonica\n word_cano = dicc.chars.sort\n #si la palabra es igual a la palabra del array\n #Ya las 2 en su forma canonica\n if cano == word_cano\n #mete la palabra a el array\n arr << dicc\n #De lo contrario deja el array igual\n else\n arr\n end\n end\n #Regresar el array lleno si habia palabras\n #o vacio si no las encontro\n arr\nend", "def detect_anagram(word, dictionary)\n letter_array = word.downcase.split(//)\n word_array = []\n letter_array.permutation(word.length){|word| word_array << word.join }\n word_array.select {|word| dictionary.include?(word)}\nend", "def anagram (str1, str2)\n # to downcase and remove non alphanumeric characters \n str1_hash = str_to_hash(str1.downcase.gsub(/(\\W)/, \"\"))\n str2_hash = str_to_hash(str2.downcase.gsub(/(\\W)/, \"\"))\n\n if str1_hash == str2_hash\n return true\n else\n return false\n end\n\nend", "def combine_anagrams (words)\n if(words.length == 0) \n return words\n end\n\n anagram_list = [];\n \n print words\n puts\n\n words = words.flatten\n\n#words = words & words\n\n words.each do |word|\n if(anagram_list.length == 0)\n then\n anagram_list << [word];\n next\n end\n\n sorted_word = word.downcase.scan(/./).sort.join\n\n print sorted_word\n\n# word_exists = anagram_list.flatten.select { |anag| anag =~ /#{word}/ }\n#if (word_exists != nil && word_exists.length == 1)\n#next\n#end\n \n inserted = false\n anagram_list.each_index do |i|\n print \" \" \n print anagram_list[i][0].downcase.scan(/./).sort.join\n print \"\\n\"\n if(anagram_list[i][0].downcase.scan(/./).sort.join == sorted_word)\n then\n anagram_list[i] << word\n inserted = true\n break\n end\n end\n anagram_list << [ word ] unless (inserted)\n end\n return anagram_list;\nend", "def anagrams(str1, str2)\n \nend", "def my_anagram(type_array) \n #Create Hash container\n storage_hash = {} \n #Take given array argument and opperate on each element.\n #Anagrams are words that can be spelled using the same letters. Order inmaterial. \n\n #Split text into Array / Sort String.split(\"\") Array using Array.sort. / String.join \n #Iterate over array input\n\n type_array.each do |word|\n word_sorted = word.split(\"\").sort.join\n #Check to see if word sorted is already in container (storage_array)\n if storage_hash.has_key?(word_sorted)\n storage_hash[word_sorted].push(word)\n else\n #add the new unique storage key\n storage_hash[word_sorted] = [word]\n end\n end\n #Iterate threw your storage and print results\n storage_hash.each do |key, value|\n puts \"---#{key}----\"\n p value\n end\nend", "def anagram(words)\r\n result = words.group_by { |word| word.chars.sort.join }\r\n result.each {|k, v| p v unless v.size == 1}\r\nend", "def anagram_manager\n\n if array_vowel_check() == true\n\n concat_anagram_check()\n\n else \"One or more words in your entry phrases does not contain a vowel\"\n\n end\n end", "def anagram(word)\n anagrams_array = %w(enlists google inlets banana)\n search = word.split('')\n search.sort!\n anagrams_array.each do |wordanna|\n new_word = wordanna.split('')\n new_word.sort!\n if search == new_word\n puts wordanna\n end\n end\nend", "def anagram(words)\n words_hash = {}\n\n words.each do |w1|\n sorted_word = w1.chars.sort\n\n if words_hash.has_key?(sorted_word)\n words_hash[sorted_word] << w1\n else\n words_hash[sorted_word] = [w1]\n end\n end\n\n words_hash.values\nend", "def anagram_finder(word, dictionary)\n\tag = []\ndictionary.each {|x| ag << x if word.split('').sort == x.split('').sort }\nag\nend", "def anagram(words)\n words_hash = {}\n\n words_hash = words.each_with_object(Hash.new []) do |word, hash|\n hash[word.chars.sort] += [word]\n end\n\n words_array = words_hash.flatten\n final_hash = []\n\n words_array.each_index do |index|\n final_hash << words_array[index] if index.odd?\n end\n\n return final_hash\nend", "def is_anagram(test, original)\n test.downcase.chars.sort == original.downcase.chars.sort\nend", "def anagrams(word)\n EpicAnagram.find_anagrams(word)\n end", "def is_anagram?(word)\n#try determining if they are composed of the same letters.\n word.chars.sort == @word.chars.sort\n end", "def anagram_hash(input)\n list = {} # empty hash\n input.each do |word| # iterates over each word in the array\n add_word = word.chars.sort.join # sorts the anagrams\n list[add_word] ||= []\n list[add_word] << word\n end\n # list of all anagrams and words\n list.values\nend", "def combine_anagrams(words) \n # for each word, sort the word to create the \n # signature for the anagrams\n anagram_groups = {}\n words.each do |w|\n key = w.downcase.chars.sort.join\n if anagram_groups[key].nil?\n anagram_groups[key] = [w]\n else\n anagram_groups[key].push(w)\n end\n end\n \n return anagram_groups.values\n\nend", "def is_anagram? a,b\n canonical(a) == canonical(b)\nend", "def match(array) #takes in an array of possible anagrams\n anagrams = []\n \n # iterate over array of words\n array.each do |word|\n # compare each word of array to OG word \n # determine if word is anagram\n if word.chars.sort == @word.chars.sort\n anagrams << word\n end\n end\n anagrams #return all matches/ empty array if no matches exist\n end", "def find_anagrams(base_word, word_list)\n word_list.select do |word|\n anagram?(base_word, word)\n end\nend", "def anagram str1, str2\n str1.downcase.chars.sort.join == str2.downcase.chars.sort.join\nend", "def anagram?\n chars1 = @input1.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n chars2 = @input2.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n if\n self.allwords?\n if\n chars1 == chars2\n return \"These words are anagrams!\"\n elsif\n self.antigrams?\n return \"These words are not anagrams but they are antigrams!\"\n elsif self.antigrams? == false\n return \"These words are neither anagrams nor antigrams!\"\n end\n else\n return \"You need to input actual words!\"\n end\n end", "def combine_anagrams(words)\n anagrams = Hash.new([])\n for i in 0..(words.length - 1)\n anagram_found = false\n if (i == 0)\n anagrams[words[i]] = []\n end\n for j in 0..(i-1)\n# puts \"Comparing #{words[i]} and #{words[j]}\"\n anagram1 = merge_sort(words[i].downcase)\n anagram2 = merge_sort(words[j].downcase)\n# puts \"#{anagram1} #{anagram2}\"\n if (merge_sort(words[i].downcase) == merge_sort(words[j].downcase))\n# puts \"#{words[i]} and #{words[j]} are the same anagram.\"\n anagrams[words[j]] << words[i]\n anagram_found = true\n #puts \"anagrams: #{anagrams.to_s}\"\n break\n end\n end\n anagrams[words[i]] = [] unless (anagram_found)\n end\n\n # Convert hash to an array.\n anagrams_arr = hash_to_array(anagrams)\n return anagrams_arr\n #return anagrams\nend", "def isAnagram(test, original)\n str1 = test.split(\"\").map{ |x| x.ord}.inject(:+)\n str2 = original.split(\"\").map{ |x| x.ord}.inject(:+)\n str1 == str2\nend", "def make_anagram word1, word2\n s1 = word1.chars\n s2 = word2.chars\n\n count = 0\n\n # s1.each do |x|\n # if s2.include? x\n # count +=1\n # end\n # end \n # ana = (word1.size - count)*2\n\n freq = Hash.new(0)\n s1.each do |key|\n freq.store(key, freq[key]+1)\n end\n freq\n\n s2.each do |x|\n if freq[x] != nil\n freq[x] -= 1\n end\n end\n\n freq\n\n freq.each do |key,value|\n if value != 0\n count += value.abs\n end\n end\n\n count\n\nend", "def anagram(str)\n\n raise \"Require string input\" unless str.is_a?(String)\n\n anagrams = []\n\n dict = [\"RETOOL\", \"ROOTLE\", \"TOOLER\", \n \"PLAY\", \"VIKING\"]\n \n dict.each do |word|\n anagrams << word if word.split(\"\").sort == str.upcase.split(\"\").sort\n end\n\n return anagrams\n\n\n end", "def anagram?( string,target )\n permutations=string.chars.permutation.to_a\n permutations.include?(target.chars)\n end", "def combine_anagrams(words)\n\tsorted = Hash.new\n\tk=0\n\twords.each { |c| sorted[k]=c.downcase.chars.sort.join; k=k+1 }\n\tanagram = Array.new\n\ta = Array.new\n\tb = Array.new\n\ti=0\n\tsorted.invert.each { |w,y| a[i] = sorted.select { |k,v| v == w }.keys; a[i].each { |x| b << words[x] }; anagram << anagram[i].to_a + b.to_a ; b.clear; i=i+1 }\n\treturn anagram\nend", "def valid_anagram(s,t)\n\n if s.length != t.length\n return false\n end\n\n #create hashes\n hash_table1 = Hash.new(0)\n hash_table2 = Hash.new(0)\n\n #check frequency of letters in string\n\n s.each_char do |ch|\n if hash_table1[ch] == nil?\n hash_table1[ch] = hash_table1[ch] + 1\n else\n hash_table1[ch] = 1\n end\n\n p hash_table1\n\n end\n\n t.each_char do |ch|\n if hash_table2[ch] == nil?\n hash_table2[ch] = hash_table2[ch] + 1\n else\n hash_table2[ch] = 1\n end\n p hash_table2\n end\n\n #compare both hash table\n\n return hash_table1 == hash_table2\n\nend", "def anagram string\n mid = string.size/2 -1\n s1 = string.slice(0..mid).chars\n s2 = string.slice(mid+1..-1).chars\n freq = Hash.new(0)\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n s2.each do |letter|\n freq[letter] > 0 ? freq[letter] -=1 : count +=1\n end\n\n string.size.even? ? count : -1\nend", "def combine_anagrams(words)\n#\n\n hash = {}\n words.each{ |word| \n key = word.downcase.split(//).sort\n hash[key] = (hash[key] || []) + [word]\n }\n ans = []\n hash.map{ |k, v|\n ans += v\n }\n ans\nend", "def is_anagram(s, t)\n s.chars.sort == t.chars.sort\nend", "def match(words)\n#iterate over the array of words that the .match method takes as an argument.\n words.select do |word|\n is_anagram?(word)\n end\n end", "def combine_anagrams(words)\n hash = {}\n hash.default=[]\n words.each{|word|\n down_cased = word.downcase\n anagram = down_cased.chars.sort.join\n hash[anagram]= hash[anagram] + [word]\n }\n hash.values\nend", "def anagram(string1, string2)\n puts \"Are #{string1} and #{string2} anagrams?\"\n if string1.length != string2.length\n return false\n else\n string1.length.times do |i|\n if !string2.include? string1[i] \n return false\n end\n end\n return true\n end\nend", "def combine_anagrams(words)\n anagram_group = Hash.new([])\n words.each {|word| anagram_group[word.downcase.split(//).sort.join] += [word]}\n return anagram_group.values\nend", "def first_anagram(word1, word2) #the worst \r\n word1.chars.permutation.to_a.any? { |sub| sub.join == word2 } \r\nend", "def is_anagram word1, word2\n \tpermute = permute_word(word1)\n \tpermute.each do |w|\n \t puts w.join\n \t if w.join.eql?(word2)\n \t \treturn true\n \t end\n \tend\n \treturn false\n end", "def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false\n if canonical(word1) == canonical(word2) then true else false end\nend", "def anagrams(array)\n copy_array = array.dup\n result_array = []\n iteration_idx = 0\n until copy_array.empty?\n \n word = copy_array.pop\n next if word.nil?\n \n result_array << []\n result_array[iteration_idx] << word\n copy_array.each do |sub_word|\n next if sub_word.nil?\n if are_anagrams?(sub_word, word)\n result_array[iteration_idx] << sub_word\n idx = copy_array.index(sub_word)\n copy_array[idx] = nil\n end\n end\n \n iteration_idx += 1\n end\n \n result_array\nend", "def combine_anagrams(words)\n anagrams = Hash.new()\n words.each do |word|\n letters = word.downcase.gsub(/[^a-z]/, \"\").split(\"\").sort.join\n anagrams[letters] = Array.new unless anagrams.include?(letters)\n anagrams[letters] << word\n end\n anagrams.values\nend", "def anagramI?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a.map { |anagram| anagram.join(\"\") }\n anagrams.include?(str2)\nend", "def combine_anagrams(words)\n anagrams = []\n available_words = words\n words.each do |e|\n group = []\n temp_words = []\n anagram_invariant = e.downcase.chars.sort.join\n available_words.each do |i|\n test = i.downcase.chars.sort.join\n if test == anagram_invariant\n group.push(i)\n else\n temp_words.push(i)\n end\n end\n if(!group.empty?)\n anagrams.push(group)\n end\n available_words = temp_words\n end\n return anagrams\nend", "def is_anagram(s, t)\n return s.chars.sort == t.chars.sort\nend", "def fourth_anagram(first_word, second_word)\n hash1 = Hash.new {|h, k| h[k] = []}\n first_word.each_char do |char|\n hash1[char] << char\n end\n second_word.each_char do |char|\n hash1[char] << char\n end\n hash1.values.all? {|ele| ele.length.even?}\nend", "def anagram?(word)\n normalize(word) == normalize(@word)\n end", "def anagram?(a, b)\n a.chars.sort == b.chars.sort\nend", "def combine_anagrams(list_of_words)\n result = []\n list_of_words.each { | word |\n found = false \n for added_words in result\n if word.anagrams?(added_words[0])\n added_words << word\n puts \"==>#{added_words}\"\n found = true\n break \n end \n end\n #Add the new anagram group list\n if !found then result << [word] end\n }\n return result\nend", "def anagramStrSearch(str, searchstr)\n arResult = Array.new(str.size, 0) #initialize each position with false\n searchSize = searchstr.size\n # create all possible anagrams\n arSearch = searchstr.split('') #split chars in array\n arSearch = arSearch.permutation.to_a #create all array permutations\n for i in 0..arSearch.size-1\n arSearch[i] = arSearch[i].join #join each permutation back as string\n end\n \n # search if str match into of the anagrams\n for i in 0..str.size-searchSize\n if arSearch.include?(str[i,searchSize]) then\n arResult[i] = 1\n end\n end\n # p arSearch\n return arResult\n end", "def combine_anagrams(words) \r\n anagrams = words.inject(Hash.new()) do |r, word|\r\n key = word.downcase.chars.sort.join\r\n r[key] ||=[]\r\n r[key] << word\r\n r\r\n end\r\n anagrams.values\r\nend", "def anagram?(phrase_one, phrase_two)\n phrase_one.split('').sort == phrase_two.split('').sort\n end", "def anagram3(string, string2)\n(string.chars.sort.join == string2.chars.sort.join) ? true : false\nend", "def is_anagram(s, t)\n return false if s.size != t.size\n\n s_dic = Array.new(26, 0)\n t_dic = Array.new(26, 0)\n\n a_ord = 'a'.ord\n s.each_char { |c| s_dic[c.ord - a_ord] += 1 }\n t.each_char { |c| t_dic[c.ord - a_ord] += 1 }\n\n s_dic == t_dic\nend", "def anagram?(string, string2)\n str_arr = string.chars\n answer_array = []\n (0...str_arr.length).each do |i|\n answer_array << str_arr.permutation(i).to_a\n end\n\n answer = answer_array.uniq.join\n answer.include?(string2)\nend", "def combine_anagrams(words)\r\n # <YOUR CODE HERE>\r\n # create a hash to store the anagrams and return arrays of the hash\r\n h = Hash.new \r\n words.each {|x|\r\n key = x.downcase.split(//).sort.join\r\n if h.has_key? key then\r\n a = h[key]\r\n h[key] = a.push(x)\r\n else\r\n h[key]= [x]\r\n end\r\n }\r\n return_array = Array.new\r\n # TODO Figure out how to build an array of arrays\r\n h.each_key {|x| return_array.push (h[x])}\r\n return return_array\r\nend", "def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n first_word.each_char do |char|\n first_hash[char] += 1\n end\n second_word.each_char do |char|\n second_hash[char] += 1\n end\n first_hash == second_hash\nend", "def anagrams?(word1, word2)\n\nend", "def anagrams?(word1, word2)\n\nend", "def combine_anagrams(words=[])\n return [] if words.empty?\n hash = {}\n words.each do |word|\n anagram = word.downcase.split(\"\").sort.join(\"\")\n if hash[anagram].nil? then\n hash[anagram]=[word]\n else\n hash[anagram].push(word)\n end\n end\n return hash.values\nend", "def anagrams_for(word, array)\n p array.select {|w| canonical(word) == canonical(w)}\nend", "def find_anagrams( target_word, list_of_words )\n anagrams = []\n list_of_words.each{ |element|\n if anagram_canonical_form(element) == anagram_canonical_form(target_word)\n anagrams << element\n end\n }\n return anagrams\nend", "def anagram(text)\n head, tail = [], text.split('')\n stack = [[head, tail]]\n result = []\n\n while stack.size > 0\n head, tail = stack.pop\n if tail.size.zero?\n result << head\n else\n tail.each_with_index do |_, i|\n _tail = tail.dup\n curr = _tail.delete_at(i)\n _head = head.dup\n _head << curr\n stack << [_head, _tail]\n end\n end\n end\n\n result.tap { |r| r.map! { |p| p.join('') }.uniq! }\n end", "def panagram?(string)\n # enter your code here\n ans, key = [], []\n alph = (\"a\"..\"z\").to_a\n new = string.downcase.split(\"\")\n new.each {|x| ans.push(x) if alph.include?(x)}\n alph.each {|c| key.push(c) if ans.include?(c)}\n key.length == 26 ? true : false\nend", "def combine_anagrams(words)\n anagrams = []\n\n words.each { \n \t|word| \n \t\n\tsorted_word = word.downcase.chars.sort.join\n\n \t# controleer of het gesorteerde woord in 1 van de arrays in anagrams voor komt. \n \t# voeg hem toe aan de array met het overeenkomende anagram\n \t# anders voeg hem als nieuwe array toe aan anagrams\n \ttoegevoegd = false\n\n \t# for i in anagrams.length do |anagram_list|\n \tanagrams.map {\n \t\t|anagram_list|\n\n \t\tif sorted_word == anagram_list[0].downcase.chars.sort.join\n \t\t\tanagram_list << word\n\t\t\ttoegevoegd = true\t\n \t\tend\n \t}\n\n \tif toegevoegd == false\n \t\tanagrams << [word]\n \tend\n\n }\n\n anagrams\nend", "def first_anagram?(string1,string2)\n new_strings = string1.chars.permutation.to_a\n new_strings.include?(string2.chars)\n\nend", "def combine_anagrams(words)\r\n\tswords = Array.new\r\n\tnoDups = Array.new\r\n\tgroupWords = Array.new\r\n\tanagrams = Array.new\r\n\twords.each {|word| swords << word.downcase.chars.sort.join}\r\n\tswords.each{|word| noDups << word unless !noDups.index(word).nil? }\r\n\tnoDups.each do|tword|\r\n\t\t\t\t\t\r\n\t\t\t\t\tgroupWords = Array.new\r\n\t\t\t\t\twords.each {|word| groupWords << word unless word.downcase.chars.sort.join != tword}\r\n\t\t\t\t\tanagrams << groupWords\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\treturn anagrams\r\nend", "def combine_anagrams(words)\r\n words.sort!{|a, b| a.length <=> b.length}\r\n letters = words.map{|w| w.downcase.split(//).sort}\r\n outp = Array.new \r\n prev_a = []\r\n for w in words\r\n if letters[words.index(w)] == prev_a\r\n outp[outp.length - 1].push(w)\r\n else\r\n outp.push([w])\r\n prev_a = letters[words.index(w)]\r\n end\r\n end\r\n return outp\r\nend", "def anagrams_v_one(str1,str2)\r\n\r\n # elvis\r\n # levis\r\n # lives\r\n # lsevi\r\n anagrams = []\r\n count = 0\r\n until count == 120 #5*4*3*2*1 = 120 \r\n shuffled = str1.chars.shuffle\r\n if !anagrams.include?(shuffled)\r\n anagrams << shuffled\r\n count +=1 \r\n end\r\n end\r\n anagrams.include?(str2.chars)\r\n # anagrams\r\nend", "def anagrams_v_one(str1,str2)\r\n\r\n # elvis\r\n # levis\r\n # lives\r\n # lsevi\r\n anagrams = []\r\n count = 0\r\n until count == 120 #5*4*3*2*1 = 120 \r\n shuffled = str1.chars.shuffle\r\n if !anagrams.include?(shuffled)\r\n anagrams << shuffled\r\n count +=1 \r\n end\r\n end\r\n anagrams.include?(str2.chars)\r\n # anagrams\r\nend", "def panagram?(string)\n \n \n #array a-z \n \n #split string, do .uniq \n \n #reject all punctuation and spaces \n\n #compare with a-z \n \n alphabet = [* \"a\"..\"z\"] \n\n \n if alphabet == string.downcase.gsub(/[^a-z\"\"]/, \"\").split(//).uniq.sort \n return true \n else \n return false \n end\n \n \n\nend", "def anagrams(word)\n dictionary = File.readlines(Dir.pwd << \"/enable.txt\").map { |word| word.chomp }\n anagrams = []\n\n word = word.split(\"\")\n word.permutation.to_a.each do |possible_perm|\n anagrams << possible_perm.join.upcase if dictionary.include?(possible_perm.join)\n end\n anagrams\nend", "def anagram?(s1,s2)\n\ts1.chars.sort == s2.chars.sort\nend", "def fourth_anagram(str1, str2) \n str1_hash = Hash.new(0)\n str2_hash = Hash.new(0)\n\n str1.each_char { |char| str1_hash[char] += 1 }\n str2.each_char { |char| str2_hash[char] += 1 }\n\n str1_hash == str2_hash \nend", "def fourth_anagram(word1, word2)\n hash1 = Hash.new(0)\n hash2 = Hash.new(0)\n\n word1.each_char { |char| hash1[char] += 1 }\n word2.each_char { |char| hash2[char] += 1 }\n\n hash1 == hash2\nend", "def anagram3(str1, str2)\n str1 = str1.downcase.chars.sort.join\n str2 = str2.downcase.chars.sort.join\n\n return str1 == str2\nend", "def anagram?(a, b)\n return false unless a.length == b.length\n a.chars.sort == b.chars.sort\nend", "def anagram?(x, y)\n x.chars.sort == y.chars.sort\nend", "def panagram?(string)\nend", "def fifth_anagram?(str1, str2)\n\n char_hash = Hash.new(0)\n (0...str1.length).each do |idx|\n char1 = str1[idx]\n char2 = str2[idx]\n\n char_hash[char1] += 1\n char_hash[char2] -= 1\n end\n\n char_hash.values.all?(&:zero?)\n\nend", "def is_anagram(s, t)\n\n return s.split(\"\").sort == t.split(\"\").sort\n\nend", "def first_anagram?(str1, str2)\r\n anagram_helper(str1).include?(str2) \r\n\r\nend", "def fourth_anagram(str1, str2)\n hash = Hash.new(0)\n\n str1.size.times do |idx|\n hash[str1[idx]] += 1\n hash[str2[idx]] -= 1\n end\n\n hash.values.all?(&:zero?)\nend", "def makeAnagram(a, b)\n hash_map = Hash.new(0)\n p hash_map \nend", "def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n\n first_word.chars.each { |char| first_hash[char] += 1 }\n second_word.chars.each { |char| second_hash[char] += 1 }\n\n first_hash == second_hash\nend", "def anagram(s)\n firstSubString=s[0...s.length/2]\n secondSubString=s[s.length/2..s.length].split('')\n \n \n if s.length.odd?\n return -1\n else \n firstSubString.each_char do |char1|\n secondSubString.each_with_index do |char2,ids|\n if char1==char2\n secondSubString.delete_at(ids)\n break\n end\n end\n end\n return secondSubString.length \n end\nend", "def second_anagram?(word1, word2)\n w1_copy = word1.dup\n w2_copy = word2.dup\n w1_copy.each_char do |ch1|\n w2_copy.each_char do |ch2|\n if ch1 == ch2\n w1_copy[w1_copy.index(ch1)] = \"\"\n w2_copy[w2_copy.index(ch2)] = \"\"\n end\n end\n end\n w1_copy.empty? && w2_copy.empty?\nend", "def anagrams(word1, word2)\n length = word1.length\n if word1.length == word2.length\n array = []\n while length>=0\n array.push(word1[length-1])\n length -= 1\n end\n length2 = word2.length\n while length2 >= 0\n if array.include?(word2[length2 - 1])\n length2 -= 1\n else\n return false\n end\n end\n return true\n else\n return false\n end\nend", "def fourth_anagram(str_1,str_2)\n hash1 = Hash.new(0)\n hash2 = Hash.new(0)\n\n str_1.each_char do |char|\n hash1[char]+=1\n end\n\n str_2.each_char do |char|\n hash2[char]+=1\n end\n\n hash1==hash2\nend", "def fourth_anagram?(str1,str2)\n h1 = make_hash(str1) #n\n h2 = make_hash(str2) #n \n h1 == h2\nend", "def combine_anagrams(words)\r\n\tanagrams = words.group_by { |word| word.chars.sort }.values\t\r\nend", "def is_anagram(s, t)\n s = s.chars\n t = t.chars\n\n return false if s.count != t.count\n\n hash1 = {}\n s.each do |value|\n hash1[value] = if hash1[value]\n hash1[value] + 1\n else\n 1\n end\n end\n\n hash2 = {}\n t.each do |value|\n hash2[value] = if hash2[value]\n hash2[value] + 1\n else\n 1\n end\n end\n\n hash1.keys.each do |key|\n return false if hash2[key] != hash1[key]\n end\n\n true\nend", "def first_anagram?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a \n anagrams.include?(str2.split(\"\"))\nend", "def match(possible_anagrams)\n anagrams = []\n possible_anagrams.each do |possible_anagram|\n if possible_anagram.split(\"\").sort == @word.split(\"\").sort\n anagrams << possible_anagram\n end\n end\n anagrams\nend", "def making_anagrams(string1, string2)\n matching_chars = 0\n visited_chars = Hash.new\n \n longest_string = string1.length > string2.length ? string1 : string2\n \n longest_string.each_char do |ch|\n if visited_chars[ch]\n next\n else\n visited_chars[ch] = true\n matching_chars += [string1.count(ch), string2.count(ch)].min\n end\n end\n \n string1.length + string2.length - matching_chars * 2\nend", "def fourth_anagram?(string, strong)\n s_hash = Hash.new(0)\n ss_hash = Hash.new(0)\n string.chars.each do |el|\n s_hash[el] += 1\n end\n strong.chars.each do |el|\n ss_hash[el] += 1\n end\n s_hash.to_a.sort == ss_hash.to_a.sort\nend", "def anagrams(string, array)\n string_anagram = string.chars\n \n array.select! do |word|\n word.chars.all? do |letter|\n word.chars.count(letter) == string_anagram.count(letter)\n end\n end\n array\nend" ]
[ "0.8007", "0.7566226", "0.7470645", "0.7432831", "0.7404339", "0.7392311", "0.73076415", "0.72849494", "0.728457", "0.72840166", "0.7270021", "0.72607476", "0.7258781", "0.725877", "0.7246425", "0.72407764", "0.72151047", "0.72024703", "0.718429", "0.7177312", "0.7133882", "0.7116267", "0.7112633", "0.70752406", "0.7074226", "0.70668834", "0.7043897", "0.7040527", "0.7034885", "0.70278823", "0.70201933", "0.70101863", "0.7002105", "0.6998168", "0.69927984", "0.698636", "0.6986071", "0.6982144", "0.6971384", "0.6952789", "0.69526535", "0.6940745", "0.6928882", "0.69074273", "0.68979496", "0.6897414", "0.68967307", "0.6896324", "0.68953586", "0.6895122", "0.68890214", "0.68889886", "0.6885317", "0.6883135", "0.6882799", "0.6881315", "0.68805224", "0.6879281", "0.68749756", "0.6866406", "0.6865268", "0.6865268", "0.6860995", "0.68580693", "0.6854664", "0.68312377", "0.6831132", "0.68230087", "0.68169594", "0.68163985", "0.6816222", "0.6815912", "0.6815912", "0.6807893", "0.6801494", "0.67926735", "0.67912346", "0.6789023", "0.67879236", "0.67809534", "0.6780667", "0.678043", "0.6777349", "0.677711", "0.67744327", "0.67715704", "0.67657137", "0.6761774", "0.67606026", "0.6759664", "0.67562294", "0.6756185", "0.6753747", "0.674794", "0.67478776", "0.67478555", "0.6746222", "0.6743987", "0.6742843", "0.6732374" ]
0.70296323
29
Complete the alternatingCharacters function below.
def alternatingCharacters(s) previous_char = "" cnt = 0 s.chars do |c| if c == previous_char cnt += 1 end previous_char = c end cnt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alternating_char string\n arr = string.chars\n count = 0\n arr.each_with_index do |x,xi|\n if xi > 0\n if arr[xi-1] == 'A'\n count +=1 unless x == 'B'\n else\n count +=1 unless x == 'A'\n end\n end\n end\n count\nend", "def alternatingCharacters(s)\n del_count = 0\n s.chars.each_with_index do |v, i|\n next if i == 0\n if v == s[i-1]\n del_count+=1\n end\n end\n return del_count\nend", "def alternate string, num\n range = ('a'..'z').to_a.rotate(num)\n working = string.split(//)\n working.map! do |x|\n x = range[('a'..'z').to_a.index(x)]\n end.join\n \n \n\nend", "def repeater(string)\n string.chars.zip(string.chars).join\nend", "def repeater(str)\n str.chars.zip(str.chars).join\nend", "def every_other_letter(string)\r\n # your code here\r\n every_other_letter = \"\"\r\n i = 0\r\n for i in 0 ... string.length\r\n if i % 2 == 0\r\n every_other_letter << string[i]\r\n end\r\n end\r\n every_other_letter\r\nend", "def repeater(string)\r\n result = \"\"\r\n string.chars.each do |letter|\r\n result << letter * 2\r\n end\r\n result\r\nend", "def repeater(word)\n word.chars.map { |char| char * 2 }.join\nend", "def repeater(text)\n double_string = ''\n text.each_char { |char| double_string << char * 2 }\n double_string\nend", "def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend", "def alternating_vowel(sent)\n vowels = 'aeiou'\n words = sent.split\n new_words = []\n words.each_with_index do |word, idx|\n if word.split('').none? { |c| vowels.include?(c) }\n new_words << word\n next\n elsif idx.even?\n word.each_char.with_index do |c, i|\n if vowels.include?(c)\n new_words << word[0...i] + word[i + 1..-1]\n break\n end\n end\n else\n word.reverse.each_char.with_index do |c, i|\n if vowels.include?(c)\n new_words << (word.reverse[0...i] + word.reverse[i + 1..-1]).reverse\n break\n end\n end\n end\n\n\n end\n\n new_words.join(' ')\nend", "def repeater(str)\n str.chars.map { |chr| chr * 2}.join\nend", "def repeater(str)\n [str.chars, str.chars].transpose.join\nend", "def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend", "def repeater(string)\n string.chars.map{ |char| char * 2 }.join\nend", "def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend", "def repeater(str)\n\n str.chars.map {|char| char*2}.join\n\nend", "def repeater(string)\n string.chars.map { |char| char + char }.join\nend", "def repeater(str)\n result = ''\n str.each_char { |char| result << char * 2 } # or result << char << char\n result\nend", "def repeater(string)\n string.chars.map! { |char| char * 2 }.join('')\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend", "def repeater(string)\n doubled_str = \"\"\n string.each_char do |char|\n doubled_str << char << char\n # doubled_str.concat(char*2)\n # doubled_str.concat(char, char)\n end\n \n doubled_str\nend", "def nextLetters(aliasArray)\n\tvowels = 'aeiou'.split('')\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.split('')\n\n\t# use map! to loop through each character of array\n\taliasArray.map! {|char|\n\t\t\n\t\t# if vowel, provide next vowel [METHOD]\n\t\tif vowels.include? char\n\t\t\tvowels[(vowels.index(char) + 1) % 5]\n\n\t\t# if consonant, provide next consonant [CONSONANT]\n\t\telsif consonants.include? char\n\t\t\tconsonants[(consonants.index(char) + 1) % 21]\n\t\t\n\t\telse\n\t\t\t' '\n\t\tend\n\t}\t\nend", "def repeater(string)\n string.chars.map { |el| el * 2 }.join\nend", "def make_chars_next(string)\n\tvowels = ['a', 'e', 'i', 'o', 'u']\n\tstring_with_chars_incremented = \"\"\n\tstring.each_char do |char|\n\t\tif char == ' '\n\t\t\tstring_with_chars_incremented << ' '\n\t\telsif vowels.index(char.downcase) != nil\n\t\t\tif char.downcase == 'u'\n\t\t\t\tif char == char.downcase\n\t\t\t\t\tstring_with_chars_incremented << 'a'\n\t\t\t\telse\n\t\t\t\t\tstring_with_chars_incremented << 'A'\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif char == char.downcase\n\t\t\t\t\tstring_with_chars_incremented << vowels[vowels.index(char)+1]\n\t\t\t\telse\n\t\t\t\t\tstring_with_chars_incremented << vowels[vowels.index(char.downcase)+1].upcase\n\t\t\t\tend\n\t\t\tend\n\t\telsif char == 'z'\n\t\t\tstring_with_chars_incremented << 'a'\n\t\telsif char == 'Z'\n\t\t\tstring_with_chars_incremented << 'A'\n\t\telse\n\t\t\tstring_with_chars_incremented << char.next\n\t\tend\n\tend\n\tstring_with_chars_incremented\nend", "def pirates_say_arrrrrrrrr(string)\n characters = \"\"\n add_letter = false\n string.length.times do |index|\n current = string[index]\n characters << current if add_letter\n add_letter = (current == 'r' || current == 'R')\n end\n characters\nend", "def repeater(str)\n str.chars.each_with_object('') {|char, str| str << char * 2}\nend", "def alternate_words(str)\n\n '!@$#%^&*()-=_+[]:;,./<>?\\\\|'.split(//).each do |char|\n str = str.gsub(char, ' ')\n end\n\nalternate_array = []\n str.split.map.each_slice(2) do |first, second|\n alternate_array << first\n end\n alternate_array\nend", "def next_letters(string)\r\n\r\n string = swap_names(string)\r\n \r\n letters = string.split(\"\")\r\n \r\n \r\n next_letters = letters.map! do |letter|\r\n next_vowel?(letter)\r\n end\r\n \r\n next_letters.join(\"\")\r\n \r\n \r\nend", "def repeater2(string)\n result = '' \n string.each_char do |char|\n result << char << char\n end\n result\nend", "def repeater(string)\n array = string.split('')\n array.map! do |char|\n char * 2\n end\n array.join\nend", "def encryptor(user_pass)\n counter = 0\n output = \"\"\n while counter < user_pass.length\n\n if user_pass[counter] == \" \"\n output += \" \"\n elsif user_pass[counter] == \"z\"\n # conditional for \"z\"\n output += \"a\"\n else\n output += user_pass[counter].next\n end\n\n counter += 1\n\n end\n\n return output\nend", "def double_consonants(str)\n repeater_chars = str.chars.map do |char| \n if char =~ /[a-z]/i && char =~ /[^aeiou]/i\n char * 2\n else\n char\n end\n end\n repeater_chars.join\nend", "def double_consonants(str)\n results = \"\"\n str.each_char do |char| \n if char.downcase =~ /[a-z&&[^aeiou]]/\n results << char * 2 \n else\n results << char\n end\n end\n results\nend", "def repeater(string)\n doubled_string = []\n\n string.chars.each do |char|\n doubled_string << char * 2\n end\n\n doubled_string.join\nend", "def repeater(string)\n result = ''\n string.each_char { |char| result << char * 2 }\n result\nend", "def forward characters\n @char += characters\n char || false\n end", "def repeater(string)\n result = \"\"\n string.each_char { |char| result << char * 2}\n result\nend", "def pirates_say_arrrrrrrrr(string)\n to_return = \"\"\n next_letter = false\n string.size.times do |letter|\n current_letter = string[letter]\n to_return << current_letter if next_letter\n next_letter = (current_letter == \"r\" or current_letter == \"R\")\n end\n to_return\n \nend", "def repeater(str)\n new_str = ''\n str.chars.each do |char|\n new_str << char * 2\n end\n \n p new_str\nend", "def repeater(string)\r\n new_string = \"\"\r\n string.each_char { |char| new_string << char*2 }\r\n new_string\r\nend", "def repeater(string)\n doubled_arr = []\n string.each_char{ |char| doubled_arr << char *= 2} \n p doubled_arr.join\nend", "def pirates_say_arrrrrrrrr(string)\n new_string = \"\"\n add_next = false\n string.size.times do |index|\n current_char = string[index]\n new_string << current_char if add_next #if add next has been set true in previous loop, it will add the current character\n add_next = (current_char == \"r\" || current_char == \"R\") #will set the value of add_next var to true or false\n end\n new_string\nend", "def char_sequences(code)\n code.scan(/((.)\\2*)/)\n end", "def second_anagram?(string1,string2)\n string1.each_char.with_index do |char, i|\n idx = string2.index(char)\n if idx != nil \n string2 = string2[0...idx] + string2[idx+1..-1]\n end\n end\n string2.length == 0\n\nend", "def pirates_say_arrrrrrrrr(string)\n new_string = \"\"\n add_next = false\n string.size.times do |index|\n char = string[index]\n new_string << char if add_next\n add_next = (char == \"r\" || char == \"R\")\n end\n new_string\n\n\nend", "def alternating_vowel(sentence)\n vowels = \"aeiou\"\n words = sentence.split(\" \")\n new_sentence = []\n\n words.each_with_index do |word, idx_word|\n new_word = \"\"\n modified = false\n\n if idx_word.even?\n word.each_char.with_index do |char, idx_char|\n if modified || !vowels.include?(char)\n new_word += char\n else\n modified = true\n end\n end\n else\n count = word.length - 1\n\n while count >= 0\n if modified || !vowels.include?(word[count])\n new_word = word[count] + new_word\n else\n modified = true\n end\n\n count -= 1\n end\n\n end\n\n new_sentence << new_word\n end\n\n new_sentence.join(\" \")\nend", "def encrypt(password)\n counter = 0\n result = \"\"\n while counter < password.length\n letter = password[counter]\n \n if letter == \" \"\n result << \" \"\n elsif letter == \"z\"\n result << \"a\"\n else\n result << letter.next\n end\n counter += 1\n end\n result\nend", "def stagger(string)\n char_array = string.chars\n new_char = []\n char_array.each_with_index do |char, i|\n if i.even?\n new_char << char.upcase\n elsif i.odd?\n new_char << char.downcase\n end\n end\n p new_char.join\nend", "def encrypt(string)\n\n# separate string into characters\n# advance characters one letter forward\n\n count = 0 # initialize count\n \n while count < string.length # run loop while count is less than string length (print every character)\n if string[count] == \" \" # preserve space character\n count += 1\n else\n if string[count] == \"z\" # edge case conditional\n string[count] = \"a\"\n else\n string[count] = string[count].next! # select character by index #, advance, and reassign\n end\n count += 1 # add to count so next character in string is called through method\n end\n end\n\n # reassemble string with advanced characters\n\n return string\n\nend", "def next_letter(array)\n array.map! do |letter|\n next_character(letter)\n end\n array = array.join('')\nend", "def replace_adjacent_characters(string)\n if !string.include?(\"a\")\n @string.sub!(string, \"a\")\n elsif !string.include?(\"b\")\n @string.sub!(string, \"b\")\n else\n @string.sub!(string, \"c\")\n end\n end", "def double_consonants(str)\n str.chars.each_with_object('') do |char, new_str|\n if char =~ /[^aeiou]/ && char =~ /[A-z]/\n new_str << char * 2\n else\n new_str << char\n end\n end\nend", "def alternating_vowel(sentence)\n new_sentence = []\n sentence_arr = sentence.split(' ')\n \n sentence_arr.each.with_index do |word, idx|\n new_word = ''\n\n if idx % 2 == 0\n first_vowel_idx = first_vowel(word)\n new_word << word[0...first_vowel_idx] + word[first_vowel_idx+1..-1]\n else\n last_vowel_idx = last_vowel(word)\n new_word << word[0...last_vowel_idx] + word[last_vowel_idx+1..-1]\n end\n new_sentence << new_word\n end\n new_sentence.join(' ')\nend", "def repeater(string)\n string.split('').map { |char| char * 2 }.join\nend", "def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend", "def repeater(string)\n doubled = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n doubled_char = char * 2\n doubled << doubled_char\n end\n doubled\nend", "def alternate_1(a, b)\n return false if a.size != b.size\n return true if a == b\n\n # Get the ASCII char set with initial zeroed count\n counts = (?!..?~).map { |c| [c, 0] }.to_h\n\n a.each_char { |c| counts[c] += 1 }\n\n b.each_char.with_object(true) do |c|\n counts[c] -= 1\n return false if counts[c].negative?\n end\n end", "def double_consonants(str)\nnew_str = \"\"\n\nstr.each_char do |char|\n\tif /[aeiou\\W\\d\\s]/ =~ char \n\t\tnew_str << char\n\telse\n\t\tnew_str << char << char\n\tend\nend\nnew_str\nend", "def advance_letter letter\n vowel='aeiou'\n consonant='bcdfghjklmnpqrsvwxyz'\n if vowel.include?(letter)\n if letter==vowel[-1]\n letter=vowel[0]\n else\n letter=vowel[vowel.index(letter)+1]\n end\n elsif consonant.include?(letter)\n if letter==consonant[-1]\n letter=consonant[0]\n else\n letter=consonant[consonant.index(letter)+1]\n end\n end\n letter\nend", "def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend", "def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend", "def adjacent *a; CssString.new a.flatten.unshift(self).join ' + ' end", "def double_consonants(string)\n result_string = ''\n string.each_char do |char|\n if char =~ /[a-z&&[^aeiou]]/i\n result_string << char << char\n else\n result_string << char\n end\n end\n result_string\nend", "def alternate_words(string)\n\t# clean_string gets rid of ! @ $ # % ^ & * ( ) - = _ .....\n\tclean_string = string.to_s.gsub(/[^’'A-Za-z0-9\\s]/i,' ')\n\n\t#array then turns clean_string into an array of words split using the space character \n clean_string_array = clean_string.split(\" \")\n\n #create a new array called final\n final = []\n\n #len is the total number of values in the clean_string_array\n len = clean_string_array.length-1\n\n #loop throught clean_string_array\n for i in 0..len\n\n \t#if i is an odd number then select that index from the clean_string_array\n \tstr = clean_string_array[i] if i % 2 == 0\n\t\t\n\t\t#if str does not have an empty space then pass it through\n \tif str != \"\"\n\n \tfinal << str\n \tstr = \"\"\n end\n end\n return final\n \nend", "def repeater(string)\n string = string.split(\" \")\n\n string.map do |word|\n word = word.split('')\n word.map {|letter| letter * 2}.join('')\n end.join(' ')\nend", "def second_anagram?(word1, word2)\n w1_copy = word1.dup\n w2_copy = word2.dup\n w1_copy.each_char do |ch1|\n w2_copy.each_char do |ch2|\n if ch1 == ch2\n w1_copy[w1_copy.index(ch1)] = \"\"\n w2_copy[w2_copy.index(ch2)] = \"\"\n end\n end\n end\n w1_copy.empty? && w2_copy.empty?\nend", "def repeater(string)\n new_string = ''\n string.chars.each do |char|\n new_string << char << char\n end\n new_string\nend", "def alternate_words(wrd)\n result = []\n counter = 0\n wrd_2 = wrd.gsub(/[!@$#%^&*()-=_+\\[\\]:;,.\\/<>?\\|]/, \" \")\n words = wrd_2.split(/\\s+/)\n words.each do |word|\n result << word if counter % 2 == 0\n counter += 1\n end\n return result\nend", "def caesar_cipher(string, shift = DateTime.now.day) # I set shift to be the current day if I do not include a parameter for it\n string.tr Alphabet.join, Alphabet.map{ |array| array.rotate shift }.join # This looks at every single character in the string and uses .map to rotate the array to bascially let it shift how ever many times within the array to assign the new character to the string variable\nend", "def the_next_alphabet(word)\n alphabets = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\",\n \"n\" , \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n return_word = \"\"\n\n word.chars.each do |char|\n index = alphabets.find_index(char.downcase)\n return_word = return_word + alphabets[index + 1]\n end\n\n return_word[0] = return_word[0].upcase\n\n return return_word\nend", "def encrypt(code)\r\n #declare empty string to add to\r\n encrypted_code=\"\"\r\n i = 0\r\n #loop the letters\r\n while i < code.length\r\n #z is an edge case make a special conditon for that\r\n if code[i] == \"z\"\r\n encrypted_code = encrypted_code + \"a\"\r\n \r\n # all the letters change to subsequent letters and add to encrypted code\r\n else\r\n encrypted_code = encrypted_code + code[i].next\r\n \r\n end\r\n i+=1\r\n end\r\n \r\n return encrypted_code\r\nend", "def caesar_cipher(text, step)\r\n\ttext.length.times do |number|\r\n\t\tcurrent_symbol = text[number]\r\n\t\ttext[number] = caesar_wrapper(current_symbol, step)\r\n\tend\r\n\tputs text\r\nend", "def double_consonants(string)\n output = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n if char.match(/[[a-z]&&[^aeiou]]/i)\n output << char * 2\n else\n output << char \n end\n end\n output\nend", "def double_consonants(str)\n result = \"\"\n str.chars.each do |ch|\n result << if ch.downcase.match?(/[a-z&&[^aeiou]]/)\n ch * 2\n else\n ch\n end\n end\n result\nend", "def translate_two_consonants( s )\n\n\t\t\t\t# store the letters in an array\n\t\t\t\tch_array = s.chars\n\n\t\t\t\t# then grab the first letter from the array\n\t\t\t\tfirst_letter = ch_array.shift\n\n\t\t\t\t# then grab the second letter from the array\n\t\t\t\tsecond_letter = ch_array.shift\n\n\t\t\t\t# put both letters at the back with push and add 'ay'\n\t\t\t\tch_array << first_letter + second_letter + \"ay\"\n\n\t\t\t\t# bring it back together\n\t\t\t ch_array.join\n\n\tend", "def repeater(string)\n new_str = ''\n\n string.chars.each { |x| new_str << x * 2 }\n new_str\nend", "def encrypt (password)\n output = ''\n for i in 0.. ( password.length - 1) do\n if password[i] == ' '\n output += ' '\n elsif password[i] == 'z'\n output += 'a'\n else\n output += password[i].to_s.next\n end\n end\n output\nend", "def alternate_words(string)\n array = string.gsub(/[\\.|?|,|;|(|)]/i, '').gsub(/[-]/, ' ').split(/ +|--/)\n \n odd = Array.new\n for i in 0..array.length-1\n odd << array[i] unless i.odd?\n end\n odd\nend", "def second_anagram?(string, strong)\n\n s_chars = string.chars\n ss_chars = strong.chars\n\n string.length.times do\n letter = s_chars.shift\n return false unless ss_chars.index(letter)\n ss_chars.delete_at(ss_chars.index(letter))\n end\n\n ss_chars.empty?\nend", "def next_letter (name)\n vowels = \"aeiou\".split('')\nalphabet = ('a'..'z').to_a\nconsonants = alphabet - vowels\nname_array = name.split('')\nname_array.map! { |letter|\n if letter == \"u\"\n \"a\"\n elsif letter == \"z\"\n \"b\"\n elsif consonants.include? letter\n consonants[consonants.index(letter) + 1]\n elsif vowels.include? letter\n vowels[vowels.index(letter) + 1]\n else\n letter\n end\n}\nname_array.join('')\nend", "def to_alias_chars(name_chars)\nname_chars.map! do |character|\n\tcharacter = character.downcase\n\tif character == \"a\"\n\t\tnext_vowel(character)\n\telsif character == \"e\"\n\t\tnext_vowel(character)\n\telsif character == \"i\"\n\t\tnext_vowel(character)\n\telsif character == \"o\"\n\t\tnext_vowel(character)\n\telsif character == \"u\"\n\t\tnext_vowel(character)\n\telse \n\t\tnext_consonant(character)\n\tend\nend\nend", "def cycle_char(char)\n @upCaseIt = !@upCaseIt\n @upCaseIt ? char.upcase : char.downcase\nend", "def alternate_words(sentence)\n\n # put exclude characters in an array\n to_exclude ='! @ $ # % ^ & * ( ) - = _ + [ ] : ; , . / < > ? \\ |'.split(\" \")\n\n # replace those characters with space\n arr_count = 0\n while arr_count < to_exclude.length\n to_exclude.each { |sign| sentence = sentence.gsub(sign, \" \") }\n arr_count += 1\n end\n\n # put the words in an array\n words = sentence.split(\" \")\n\n # let's alternate\n count = 0\n result = []\n while count < words.length do\n result << words[count] if count.even?\n count += 1\n end\n result\nend", "def staggered_case(string)\n index = 1\n array = string.chars\n array.each do |char|\n if char =~ /[a-zA-Z]/\n char.upcase! if index.odd?\n char.downcase! if index.even?\n index += 1\n else \n char \n end\n end \n p array.join \n \nend", "def play_pass(str, n)\n alphabet = (\"A\"..\"Z\").to_a\n shifted_alphabet = alphabet.rotate(n)\n ary = str.chars\n \n ary.each_with_index do |item, index|\n if item == item.to_i.to_s\n ary[index] = (9 - item.to_i).to_s\n elsif alphabet.include?(item)\n ind = alphabet.index(item)\n ary[index] = shifted_alphabet[ind]\n end\n end\n ary.map!.with_index { |item, index| index.odd? ? ary[index].downcase : ary[index].upcase }\n \n ary.join('').reverse\nend", "def consonant_changer(letter)\r\n\tif letter == \"z\"\r\n\t\tnew_letter = \"b\"\r\n\telsif letter == \" \"\r\n\t \tnew_letter = \" \"\r\n\telse\r\n\t\tconsonant_index = \"bcdfghjklmnpqrstvwxyz\".index(letter)\r\n \tnew_letter =\"bcdfghjklmnpqrstvwxyz\"[consonant_index.next]\r\n\tend\r\nend", "def double_characters(string)\n doubled_string = ''\n string.chars.each do |char|\n doubled_string << char * 2\n end\n doubled_string\nend", "def double_consonants(string)\n doubled_string = ''\n string.each_char do |char|\n char.match(/[a-z&&[^aeiou]]/i) ? doubled_string << char << char : doubled_string << char\n end\n doubled_string\nend", "def caesar_cipher(str, num)\n\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n alphabet.each_char.with_index do |char, idx|\n puts char\n puts idx\n puts \"---\"\n end \n\nend", "def nextLetter(full_name)\n vowels = 'aeiou'\n split_letters = full_name.split('')\n split_letters.map! { |letter|\n if letter != \" \"\n if vowels.index(letter.downcase) != nil\n letter = nextVowel(letter)\n else\n letter = nextConsonant(letter)\n end\n else\n # Don't know exactly why this has to be here but I lose my spaces if I\n # don't do it.\n letter = letter\n end\n }\n split_letters.join('')\nend", "def letter_changes(string_input)\n character_array = string_input.each_char\n output_string = ''\n character_array.each do |character|\n tempt_string = get_next_character(character)\n output_string += upcase_vowels(tempt_string)\n end\n output_string\nend", "def repeater(string)\n string.split(//).map {|char| char * 2 }.join\nend", "def anagram?(first_word, second_word)\n until first_word.length == 0\n comparing_letter = first_word[0]\n first_word.delete!(first_word[0])\n second_word.each_char do |char|\n if char == comparing_letter\n second_word.delete!(char)\n break\n end\n end\n end\n\n second_word.length == 0 ? true : false\n\nend", "def repeat(text , num=2)\n #text = text.chars\n val = \"\"\n i = 0\n for i in (1..num)\n val = text + \" \"+ val\n end\n return val.rstrip\n \nend", "def phone_letter_combinations(digits)\n\nend" ]
[ "0.663255", "0.64897543", "0.6408977", "0.6312761", "0.63033795", "0.6279413", "0.62460554", "0.61642134", "0.6131965", "0.6115898", "0.6087037", "0.605124", "0.6016919", "0.5997678", "0.5996773", "0.5988759", "0.5985937", "0.59777147", "0.5973668", "0.59669346", "0.5952255", "0.5952255", "0.5952255", "0.5952255", "0.5952255", "0.5931179", "0.5923862", "0.5922299", "0.59191006", "0.59048134", "0.5904583", "0.5897369", "0.58943766", "0.58925414", "0.5890926", "0.5888823", "0.58799744", "0.58774114", "0.5873581", "0.58649033", "0.5864259", "0.58515185", "0.58326745", "0.58144706", "0.58125496", "0.580713", "0.5801861", "0.5794658", "0.5794624", "0.5790189", "0.5789546", "0.57870567", "0.5773551", "0.57731044", "0.57652575", "0.5763326", "0.576128", "0.57482547", "0.5743699", "0.57430524", "0.5737731", "0.57356894", "0.5733732", "0.572939", "0.57277495", "0.57277495", "0.5724271", "0.57145363", "0.5712713", "0.57124346", "0.5707092", "0.5702325", "0.56998926", "0.56947154", "0.5685593", "0.5683994", "0.56824046", "0.5680902", "0.56806755", "0.5668021", "0.5661918", "0.56604296", "0.56539595", "0.5648632", "0.56415445", "0.56406856", "0.5636534", "0.5629855", "0.5629419", "0.56286037", "0.5623495", "0.5621852", "0.56187636", "0.5616342", "0.5610577", "0.56102896", "0.5607513", "0.5607254", "0.56056446", "0.55999917" ]
0.71197784
0
Afficher si c'est gagner ou perdu
def demande_de_grille #definir une methode demande de grille puts "choisir 5 nombres de 1 à 45" grid = gets return grid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def peutRetourAvant?()\n return @indiceCoup < @tabCoup.size\n end", "def debo_ir_a_carcel\n if (super)\n return !pagar_fianza\n else\n return true \n # Lo hemos hecho así, porque pensamos que si tiene carta y llama a \n # pagar fianza y tiene el saldo suficiente, se restaría dinero\n # del saldo aún teniendo la carta libertad\n end\n end", "def estValide?\n\t\t!self.statutVisible.isTente?\n\tend", "def faloAgora?\n\t\tif $testMode then return true end\n\t\t@targ = rand 100\n\t\treturn true if @targ < ($probabilidadeDePost.to_i)\n\t\tself.log( \"Teste: \" + @targ.to_s + \"/\" + $probabilidadeDePost.to_s + \" : sem reação\" ) if $logEntradasNegativas\n\t\treturn false\n\tend", "def flop?\n total_gross.blank? || total_gross < 50000000\n end", "def has_revendeur\n \tif(self.entite.droit.has_revendeur == 1)\n \t\treturn true\n \telse\n \t\treturn false\n \tend\n end", "def deLigne?() return @type == @@LIGNE end", "def par?\n cuantos_pares >= 1\n end", "def cumple_requisitos?\n propietario.hangar.nivel >= 4 && propietario.cuenta.tecnologia_energia.nivel >= 3 && propietario.cuenta.tecnologia_laser.nivel >= 6 && super\n end", "def has_honors #its gonna return true or false depdening if the object/student has honors\n if @gpa >= 3.5\n return true \n end \n return false \n end", "def peutAider?\n return Date.today().years_ago(13) > self.naissance\n end", "def in_peril?; @in_peril; end", "def pbAllFainted\n return $Trainer.ablePokemonCount==0\nend", "def cumple_requisitos?\n propietario.hangar.nivel >= 6 && propietario.cuenta.tecnologia_energia.nivel >= 6 && propietario.cuenta.tecnologia_militar.nivel >= 3 && propietario.cuenta.tecnologia_defensa.nivel >= 1 && super\n end", "def menuValido\r\n if (sexo == \"Hombre\")\r\n return (kcalMenu.round == 3000 && proteinasMenu > 54.0)\r\n else\r\n return (kcalMenu.round == 2300 && proteinasMenu > 41.0)\r\n end\r\n end", "def fifteen?\n @points == 1\n end", "def tengo_propietario\n return [email protected]?\n end", "def visa_required?\n user.visa_required? && schengen?\n end", "def copia_en_buzon_propio?\n return (current_user.puesto.buzon == self.buzon)\n end", "def pagar_fianza\n if @saldo >= @fianza\n @saldo -= @fianza\n return true\n end\n \n return false\n end", "def visa_check?\n schengen_overstay? == false && visa_overstay? == false\n end", "def jugador_actual_en_calle_libre\n casilla_actual = @jugador_actual.casilla_actual\n \n return casilla_actual.soy_edificable && !casilla_actual.titulo.tengo_propietario\n end", "def hambriento?\n # Los nombres de los metodos pueden terminar en \"?\".\n # Generalmente, hacemos esto si el método debe\n # devolver verdadero o falso, como esto:\n @panzaLlena <= 2\n end", "def hambriento?\n # Los nombres de los metodos pueden terminar en \"?\".\n # Generalmente, hacemos esto si el método debe\n # devolver verdadero o falso, como esto:\n @panzaLlena <= 2\n end", "def hasPoints?(cant= 1)\n return current_usuario.puntos.to_i >= cant.to_i\n end", "def percolates?\n end", "def maximus?\n if gladiators.any?{|g| g.name == \"Maximus\"}\n if gladiators[1].name == \"Maximus\"\n swap_gladiators\n end\n return true\n end\n return false\n end", "def elv_kapoera\n atk == dfe\n end", "def alive?()\n\t\tamount_of( :deuterium ) > 0\n\tend", "def monto_utilizado_devoluciones\n credito_restante = notas_creditos_debito.credito_restante\n credito_restante += monto_utilizado_was if persisted? # sumar el monto_utilizado anterior si se esta editando\n errors.add(:monto_utilizado, I18n.t('activerecord.errors.messages.credito_superior_a_disponible')) if credito_restante < monto_utilizado\n errors.add(:monto_utilizado, I18n.t('activerecord.errors.messages.monto_utilizado_cero')) if monto_utilizado <= 0\n false if errors.size > 0\n end", "def legal?\n @age >= LEGAL_AGE\n end", "def nogender?\n (gender == NOGENDER)\n end", "def tengo_saldo (cantidad)\n return (@saldo > cantidad)\n end", "def fraud?\n (frauded.count >= 1) || ((created_at - ad_gen_time) < AD_GEN_LIMIT)\n end", "def check\n nbErreur = @grid.check\n if(nbErreur > 0)\n @chrono.addTime(10)\n end\n return nbErreur\n end", "def puede_reproducir?\r\n return (@reproducir_puede && @pez_vivo)\r\n end", "def visa_entry_overstay?\n return false unless user.visa_required? && schengen?\n return true unless visa_exists?\n visa = schengen_visa\n visa.no_entries != 0 && visa_entry_count > visa.no_entries\n end", "def is_endel?(); @type == GRT_ENDEL; end", "def ganador(puntos)\n\n if(puntos[0] < puntos[1])\n print \"El Ganador es el jugador 2\\n\"\n elsif(puntos[0] > puntos[1])\n print \"El Ganador es el jugador 1\\n\"\n else\n print \"Esto es un empate!\\n\"\n end\n end", "def atributos\n valid = false\n if self.interreps_vencidos.any?\n valid = true\n\n elsif presente_reunioes == true\n valid = true\n end\n\n # elsif Time.now.year - ano_de_fundacao <= 1 \n # valid = true\n # end\n\n valid\n end", "def candidatGrille()\n\n\tend", "def checkups\t \n \t\tif Counter.exists?(champ_name: self.champ_name, champ_gegner: self.champ_gegner)\n \tfalse\n # Der selbe Champ ist kein Counter deshalb Rollback \n \telsif self.champ_name == self.champ_gegner\n \t\tfalse\n \telse\n \t\ttrue\t\n\t\t\tend\n\t\tend", "def price_is_gross?\n !price_is_net?\n end", "def reseller_allowed_to_view_hgc_stats?\n if !self.is_reseller?\n raise \"User type error\"\n else\n Confline.get_value('Show_HGC_for_Resellers').to_i == 1 and (self.reseller_allow_providers_tariff? or !rs_active?)\n end\n end", "def current_golfer?(golfer)\n \tgolfer == current_golfer\n end", "def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend", "def passed?\n @grade >= 2.0\n end", "def control_sin_items_comprobantes\n if [detalles].any? {|detalle| detalle.any? }\n self.errors[:base] = \"error que queres hacer?\"\n return false\n end \n end", "def charges?\n true\n end", "def check_free_venue\n if @total >= 20\n return true\n end\n end", "def price_is_gross?\n true\n end", "def any_herbivores?\n @carnivores.count < current_occupancy\n end", "def gravity_affected?\n return data.gravity\n end", "def cuadrada\n @n==@m\n end", "def isRegistado?\n if session[:perm] == 0\n return true;\n else\n return false;\n end\n end", "def has_bingo?\n self.num_bingos > 0\n end", "def retourAvant()#TOTEST\n if(@indiceCoup < tabCoup.size) #vérification normalement inutile puisque le bouton devrait être disable\n #On annule en passant au coup suivant\n coupSuivant = tabCoup.at(@indiceCoup)\n @grilleEnCours.tabCases[coupSuivant.case.positionY][coupSuivant.case.positionX].couleur = coupSuivant.couleur\n @grilleRaz = nil\n\n @indiceCoup += 1 #On passe au coup suivant\n\n socket = Fenetre1v1.getSocket\n if(socket != nil)\n socket.puts (\"av\" + @grilleEnCours.getPourcentage(@grilleBase, nil).to_s )\n end\n end\n\n return [peutRetourAvant?, coupSuivant.case] #Pour dire aux fonctions appelantes si on peut encore aller en avant\n end", "def pro?\n !!self.pro\n end", "def game_over?\n @game_over\n end", "def is_able?\n if gladiators.count < 2\n return false\n end\n return true\n end", "def check_stock_rango\n c = nueva_cantidad\n unless c < DECIMAL_LIMITE[:superior]\n errors.add(:cantidad, I18n.t('movimiento_mercaderia.detalle_cantidad_stock_superior', limite: DECIMAL_LIMITE[:superior]))\n false\n end\n end", "def _puede_capturar?(columna, fila)\n (@columna - columna).abs == 1 and fila_siguiente == fila\n end", "def tour_available?\n self.tour_credits > 0 || self.tours_unlimited\n end", "def revisa_deuda\n if com_compra.adeudos[:cuentas_con_deuda] == 0\n com_compra.pagado!\n else\n com_compra.pendiente!\n end\n end", "def is_referente?\n return (Convention.all(:conditions => {:user_id => self.id}).count > 0)\n end", "def changerEnRouge\n\t\t@couleur=1\n\tend", "def complete?\n chosung.nil? == false && jungsung.nil? == false\n end", "def combien_de_PDR()\n return @nb_point_de_retour\n end", "def adulthood\n\t\tself.age.present? and self.age > 18\n\tend", "def es_medidor_de_energia_reactiva\n \tmedidor_id = MedidorEstadoMedidor.where(estado_medidor_id: self.id).take.medidor_id\n medidor = Medidor.find(medidor_id)\n return medidor.tipo_medidor.codigo == 2\n end", "def genderless?\n gender == 0\n end", "def barge_in_allowed\n return @barge_in_allowed\n end", "def logado?\n !admin_atual.nil?\n end", "def rech_bonus?\n has_feature?(:esper_recharger)\n end", "def game_over?\n @life <= 0\nend", "def energized?\n @cur_energy > 0\n end", "def flop?\n if (reviews.sum(:stars) > 3 && (reviews.average(:stars) >= 3))\n false\n else\n total_gross.blank? || total_gross < 255_000_000\n end\n end", "def founder?\n @badges.key? 'founder'\n end", "def getNombreGrille\n @mesGrilles.size - 1\n end", "def check ; true ; end", "def rotten?\n @hatched > 3 ? true : false\n end", "def has_honors\n if @gpa >= 3.5\n return true\n end\n return false\n end", "def need_to_go_out?\n\t\tif @poos_how_often == \"regularly\"\n\t\t\tfalse\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend", "def positive?; end", "def desliga\n if desligado == false then\n return \"NÃO\"\n else\n return \"SIM\"\n end\n\n end", "def debo_pagar_alquiler\n p_encarcelado = false\n esta_hipotecada = false\n es_de_mi_propiedad = es_de_mi_propiedad(@casilla_actual.titulo)\n tiene_propietario = @casilla_actual.tengo_propietario\n \n if tiene_propietario\n p_encarcelado = @casilla_actual.propietario_encarcelado\n esta_hipotecada = @casilla_actual.titulo.hipotecada\n end\n \n debo_pagar = !es_de_mi_propiedad & tiene_propietario & !p_encarcelado & !esta_hipotecada\n \n return debo_pagar\n end", "def donnerErreur()\n return @grilleEnCours.firstDifference(@grilleBase)\n end", "def charge?\n false\n end", "def alive?()\n\n @hunger_counter < @hunger_limit\n end", "def valid?(famille)\n if famille.membres.empty?\n flash[:notice] = t(:public_valid_membre)\n return false\n end\n \n plusAge = famille.plusVieuxMembre\n # S'assurer que des billets ne sont permis que si un membre a 10 ans ou plus\n if famille.nombreBillets > 0 && Date.civil(Date.today.year, 8, 1).years_ago(10) < plusAge.naissance\n flash[:notice] = t(:public_valid_ticket) \n return false;\n end\n \n # S'assurer qu'il y a au moins un membre de la famille suffisament age\n minNaissance = Date.new(Date.today.year, 8, 1).years_ago(Constantes.instance.age_min_individu)\n if plusAge.naissance > minNaissance\n flash[:notice] = t(:public_valid_age, naissance: minNaissance)\n famille.etat = Famille::Etats[1]\n return false\n end\n return true\n end", "def disadvantage?\n @points + 1 == @opponent.points\n end", "def has_genera?(genera)\n generas.each do |g|\n return true if genera && g.pid==genera.pid\n end\n false\n end", "def pond? # Etang / Rivière etc...\n return $game_player.system_tag == TPond\n end", "def helligdag?\n not helligdag.nil?\n end", "def positive?() @positive==true end", "def qualify?\n ((count_dracula == total_count || count_franken == total_count) &&\n total_count > 5)\n end", "def hungry?\n\n\t\t @stuff_in_belly <= 2\n\t\tend", "def check_visible(obj)\n return obj.gr_is_visible?\n end", "def gilded?\n self[:gilded] > 0\n end", "def charge_gauge?\n super or H87AttrSettings::CHARGE_GAUGE_CLASSES.include?(@class_id)\n end", "def studium_generale?\n extended_title.nil?\n end" ]
[ "0.6883653", "0.6611924", "0.66074383", "0.6571171", "0.63197565", "0.6265348", "0.6262407", "0.6214913", "0.6211352", "0.62064666", "0.619145", "0.6086819", "0.60700464", "0.60642225", "0.6007804", "0.6006101", "0.5997971", "0.5987469", "0.59809446", "0.59657764", "0.59547156", "0.5953411", "0.5951148", "0.5951148", "0.59141874", "0.59015095", "0.58860385", "0.5880627", "0.58361286", "0.58330405", "0.5824089", "0.5822223", "0.5813576", "0.5807122", "0.58030754", "0.57943517", "0.57880825", "0.5787092", "0.57866937", "0.57860786", "0.5786067", "0.57829916", "0.57767445", "0.57700914", "0.57640654", "0.5759014", "0.575468", "0.5736777", "0.5733617", "0.5733013", "0.5727205", "0.57213575", "0.5716301", "0.57120776", "0.5686635", "0.5683978", "0.5682129", "0.56697124", "0.56569517", "0.56507623", "0.56479317", "0.5643683", "0.5640377", "0.5639924", "0.5639507", "0.5634998", "0.56326246", "0.56276697", "0.56180775", "0.56140655", "0.5610848", "0.5609475", "0.56086534", "0.56073684", "0.5606502", "0.56059456", "0.56035686", "0.5603392", "0.5601278", "0.56007105", "0.5600151", "0.55990714", "0.5598867", "0.5597638", "0.559659", "0.5595962", "0.55912304", "0.5588424", "0.55876106", "0.5587074", "0.55865383", "0.5584009", "0.55823636", "0.5579106", "0.5578071", "0.5573976", "0.5573849", "0.557325", "0.55716705", "0.55710435", "0.55663514" ]
0.0
-1
comaparaison de la grille et le tirage
def show_result sorted_grid, sorted_draw # comparons la grille et le tirage winner = (sorted_grid == sorted_draw) if winner puts "Vous avez gagne" else puts "Vous avez perdu" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend", "def grasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * ( sexo ? 1 : 0) - 5.4\n\tend", "def porcentaje_graso\n (1.2*calcular_imc)+(0.23*@edad)-(10.8*@sexo)-5.4\n end", "def candidatGrille()\n\n\tend", "def porcentajegrasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4\n\tend", "def grasa\n\t\t1.2*imc+0.23*@edad-10.8*@sexo-5.4\n\tend", "def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend", "def relacion_cc\n\t\t(ccintura / ccadera).round(2)\n\tend", "def get_grasas\n @_100=((@grasas*100)/@peso)\n @ir_100=(@_100/70)*100\n @porcion=((@grasas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/70)*100\n [ @grasas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def cobroViaje(tipoViaje, numPersonas, distancia)\n cobro = 0.0\n if (tipoViaje == \"Distrital\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 0.60 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 0.60 * distancia/10 + 0.60\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 0.75 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 0.75 * distancia/10 + 0.75\n end\n elsif (tipoViaje == \"Provincial\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 0.95 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 0.95 * distancia/10 + 0.95\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 1.25 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 1.25 * distancia/10 + 1.25\n end\n elsif (tipoViaje == \"Departamental\")\n if (numPersonas >= 1 && numPersonas <= 5 && distancia%10 == 0)\n cobro = 1.95 * distancia/10\n elsif (numPersonas >= 1 && numPersonas <= 5 && distancia%10 != 0)\n cobro = 1.95 * distancia/10 + 1.95\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 == 0)\n cobro = 2.25 * distancia/10\n elsif (numPersonas >= 6 && numPersonas <= 10 && distancia%10 != 0)\n cobro = 2.25 * distancia/10 + 2.25\n end \n end\n return cobro\nend", "def grilleSuivante()\n @grilleRaz = nil\n return nil\n end", "def calculCouleur(cellule,clique)\n #Gestion du clique gauche\n if clique == CLIQUEGAUCHE\n couleur = cellule.clicGauche\n #Gestion duclique droit\n elsif clique == CLIQUEDROIT\n couleur = cellule.clicDroit\n #Aucune gestion pour tout les autres boutons de la souris\n else\n couleur = nil\n puts \"Aucun evenement lié au bouton\"+clique.to_s\n end\n return couleur\n end", "def irpoliinsaturadas\n vag=(grasaspoli * 100) / 70\n vag.round(2)\n end", "def indice_corporal\n if @datos.indice_masa_corporal <= 18.5\n \"Bajo peso\"\n elsif @datos.indice_masa_corporal > 18.5 and @datos.indice_masa_corporal <= 24.9\n \"Peso adecuado\"\n elsif @datos.indice_masa_corporal > 25.0 and @datos.indice_masa_corporal <= 29.9\n \"Sobrepeso\"\n elsif @datos.indice_masa_corporal > 30.0 and @datos.indice_masa_corporal <= 34.9\n \"Obesidad grado 1\"\n elsif @datos.indice_masa_corporal > 35.0 and @datos.indice_masa_corporal <= 39.9\n \"Obesidad grado 2\"\n elsif @datos.indice_masa_corporal > 40\n \"Obesidad grado 3\"\n end\n end", "def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Cantidad Operarios * Costo Real por minutos \n self.manoObraPlaneada = 650.000 * 5 # Salario Total * Cantidad de operarios \n end", "def Grass\n \n \tif sexo == \"Hombre\"\n \t\t\n \t\tsexo = 1\n \telse\n \t\n \t\tsexo = 0\n \tend\n\t\n grasas = 1.2 * @imc + 0.23 * edad - 10.8 * sexo - 5.4\n \n if @imc < 18.5 \n puts \"Flaco\"\n else if @imc < 24.9 \n puts \"Aceptable\"\n else \n puts \"Obeso\"\n end \nend \n\n \n return grasas\n \n end", "def lentille_miroir\n if o.lentille\n return \"\n % Dessin de la lentille et des points focaux\n \\\\draw [ultra thick] (-0.5,#{-HAUTEUR+o.fpsign*0.5}) -- (0,-#{HAUTEUR}) -- (0.5,#{-HAUTEUR+o.fpsign*0.5})\n (-0.5,#{ HAUTEUR-o.fpsign*0.5}) -- (0, #{HAUTEUR}) -- (0.5,#{ HAUTEUR-o.fpsign*0.5}) ;\n \\\\filldraw [black] (#{ o.fp},0) circle (2pt) node [above #{right(o.fpsign)}] {$F'$};\n \\\\filldraw [black] (#{-o.fp},0) circle (2pt) node [above #{left(o.fpsign)}] {$F$} ;\n \\\\filldraw [black] (0,0) circle (2pt) node [above right] {$O$} ;\n \"\n else\n return \"\n \\\\draw [ultra thick] (#{-0.5*o.fpsign},#{-HAUTEUR-0.5}) -- (0,-#{HAUTEUR}) \n (#{-0.5*o.fpsign},#{ HAUTEUR+0.5}) -- (0, #{HAUTEUR}) ;\n \\\\filldraw [black] (#{-o.fp},0) circle (2pt) node [above #{right(o.fpsign)}] {$F$};\n \\\\filldraw [black] (#{-2*o.fp},0) circle (2pt) node [above #{left(o.fpsign)}] {$C$} ;\n \\\\filldraw [black] (0,0) circle (2pt) node [above right] {$S$} ;\n \" + (0..(2*HAUTEUR-1)).to_a.map{|e| \"\\\\draw [ultra thick] (0,#{-HAUTEUR+0.5+e}) -- (0.5,#{-HAUTEUR+0.5+e+0.5});\"}.join(\"\\n\")\n end\n end", "def imc\n\t\tnum = (@peso/(@talla*@talla)).round(2)\n\t\tif num < 18.5\n\t\t\tnum #- Bajo peso\"\n\t\telsif num > 18.5 and num < 24.9\n\t\t\tnum #- Adecuado\"\n\t\telsif num > 25.0 and num < 29.9\n\t\t\tnum #- Sobrepeso\"\n\t\telsif num > 30.0 and num < 34.9\n\t\t\tnum #Obesidad grado 1\"\n\t\telsif num > 35.0 and num < 39.9\n\t\t\tnum #- Obesidad grado 2\"\n\t\telsif num > 40\n\t\t\tnum #- Obesidad grado 2\"\n\t\tend\t\t\t\n\tend", "def jeuTermine\n\t\tlancementAventure(@tailleGrille+1)\n\tend", "def grasaIR\n\t\t((valorEnergeticoKJ.to_f*70)/8400).round(2)\n\tend", "def valor_energetico\n (@proteinas * 4) + (@glucidos * 4) + (@grasas * 9)\n end", "def chargeGrille()\n data = []\n File.foreach(@nomniv).with_index do |line, line_no|\n data << line.chomp\n end\n # Slice permet de récupérer la taille de la matrice \n # tel que 7:7\n num = data.slice!(0)\n self.colonnes = @x\n self.lignes = @y\n\n # Parcours des données récupérés afin de charger\n # les boutons\n for i in 0..(data.length() - 1) \n data[i].split(':').each_with_index do | ch, index| \n # # Création d'une case \n if ch != '0'\n btn = Ile.new(self, ch,index,i)\n @sommets << btn\n else \n btn = Pont.new(self, index, i)\n end\n\n # On attache la référence de la grille\n self.attach(btn, index,i, 1,1)\n end\n end\n\n return self\n end", "def irgrasassaturadas\n vag=(cgrasassa * 100) / 70\n vag.round(2)\n end", "def mi_carrera\n\n\tend", "def genclase\n \"M\"\n end", "def calcular_ganancia\n dolar = Option.instance.dolar_libre.to_f\n dinero_acumulado = self.movements.inject(0) do |total,m|\n total + m.monto_neto\n end\n precio_en_dolares = (dinero_acumulado / dolar)\n return (precio_en_dolares - self.copia.precio_compra.to_f)\n end", "def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend", "def valorgrasassatup\n\t\tvag=(cgrasassa * 70) / 100\n vag.round(2)\n\tend", "def ubicacion\n communes_str = @stats.pluralize_communes\n if @stats.communes.size > 1\n comm_st = \" las comunas de \"\n elsif communes_str == \"\"\n comm_st = \"\"\n else\n comm_st = \" la comuna de \"\n end\n regions_str = @stats.pluralize_regions\n if @stats.regions.size > 1\n reg_st = \" las regiones de \"\n elsif regions_str == \"\"\n reg_st = \"\"\n else\n reg_st = \" la region de \"\n end\n country_str = @stats.pluralize_countries\n if @stats.countries.size > 1\n coun_st = \" los paises \"\n elsif country_str == \"\"\n coun_st = \"\"\n else\n coun_st = \" el pais \"\n end\n\n s = \"La zona elegida se encuentra dentro de \" + comm_st + communes_str +\n \", \" + reg_st + regions_str +\" y \" + coun_st + country_str + \".\"\n return s\n end", "def porcentajeGlucidos\r\n total_glucidos = 0.0\r\n la = @listaAlimentos.head\r\n lg = @listaGramos.head\r\n while la != nil do\r\n total_glucidos += (la.value.carbohidratos * lg.value) / 100\r\n la = la.next\r\n lg = lg.next\r\n end\r\n total_gramos = listaGramos.reduce(:+)\r\n porcentajeGlucidos = ((total_glucidos / total_gramos)*100).round(2)\r\n end", "def irgrasas\n vag=(cgrasas * 100) / 70\n vag.round(2)\n end", "def rcc_tabla\n\t\tx = self.relacion_cc\n\n\t\t\tif sexo == 1\n\t\t\t\t\tif x >= 0.83 && x < 0.88\n\t\t\t\t\t\treturn \"Bajo -- 0.83 < #{x} < 0.88\"\n\t\t\t\t\telsif x >= 0.88 && x < 0.95\n\t\t\t\t\t\treturn \"Moderado -- 0.88 < #{x} < 0.95\"\n\t\t\t\t\telsif x >= 0.95 && x < 1.01\n\t\t\t\t\t\treturn \"Alto -- 0.95 < #{x} < 1.01\"\n\t\t\t\t\telsif x >= 1.01\n\t\t\t\t\t\treturn \"Muy alto -- #{x} > 1.01\"\n\t\t\t\t\tend\n\t\t\tend\n\n\t\t\tif sexo == 0\n\t\t\t\t\t\tif x >= 0.72 && x < 0.75\n\t\t\t\t\t\t\treturn \"Bajo -- 0.72 < #{x} < 0.75\"\n\t\t\t\t\t\telsif x >= 0.75 && x < 0.82\n\t\t\t\t\t\t\treturn \"Moderado -- 0.75 < #{x} < 0.82\"\n\t\t\t\t\t\telsif x >= 0.82\n\t\t\t\t\t\t\treturn \"Alto -- #{x} > 0.82\"\n\t\t\t\t\t\tend\n\t\t\tend\n\tend", "def valorgrasaspolip\n\t\tvag=(grasaspoli * 70) / 100\n vag.round(2)\n\tend", "def ir_grasa_saturada \n\t\t@ir_grasa_saturada = (@saturadas/20.to_f)*100\n\t\t@ir_grasa_saturada.round(1)\n\tend", "def carne\n\t\tcerdo = Alimento.new(\"Cerdo\", 21.5, 0.0, 6.3, 7.6, 11.0)\n\t\tcordero = Alimento.new(\"Cordero\",18.0,0.0,3.1,50.0,164.0)\n\t\tvaca = Alimento.new(\"Carne de vaca\", 21.1,0.0,3.1,50.0,164.0)\n\t\tpollo = Alimento.new(\"Pollo\",20.6,0.0,5.6,5.7,7.1)\n\t\tsuma = 0\n\n\t\t[cerdo,cordero,vaca,pollo].each do |i|\n\t\t\tif (@alimentos.find_index { |x| x == i } != nil)\n\t\t\t\tsuma += @gramos[@alimentos.find_index { |x| x == i }].valor\n\t\t\tend\t\t\n\t\tend\n\n\t\treturn suma >= (gramos_total * 0.45)\n\tend", "def calc_gbtype(org, gb_type)\n min = 0\n plus = 0\n totaal = 0\n naam = \"\"\n gbr_type = org.grootboekrekeningen.where(\"grootboektype_id = ?\", \"#{gb_type}\").joins(:grootboektype)\n gbr_type.each { |gt|\n gt.boekingen.each { |boeking|\n if boeking.bij_af == '-'\n min = min + boeking.waarde\n else\n plus = plus + boeking.waarde\n end\n }\n totaal = plus - min\n }\n naam = Grootboektype.find(gb_type).naam\n return naam, plus, min, totaal \n end", "def huella_nutricional\n\t\tif( (indice_impacto == 1) && (vct < 670) && (suma_gramos < 800))\n\t\t\thuella_nutricional = 'Bajo'\n\t\telsif( (indice_impacto == 2) && ((vct > 670) || (vct < 830)) && ((suma_gramos > 800) || (suma_gramos < 1200)))\n\t\t\thuella_nutricional = 'Regular'\n\t\telsif( ( indice_impacto == 3) && (vct > 830 ) && (suma_gramos > 1200))\n\t\t\thuella_nutricional = 'Alta'\n\t\tend\n\t\t\treturn huella_nutricional\n\t\tend", "def porcentaje_glucidos\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n porcentaje_gluc = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n porcentaje_gluc += (auxNodo1.value.glucidos * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return porcentaje_gluc.round(1)\n end", "def jugar\n ganador = case self.maquina_tirada\n when self.humano_tirada\n\t\"empatan\"\n when Ppt.jugadas_posibles[self.humano_tirada]\n\t\"humano\"\n else \n\t\"maquina\"\n end\n return ganador\n end", "def huella_carbono\n if geidiario() < 800\n return 1\n end\n if geidiario() > 1200\n return 3\n else\n return 2\n end\n end", "def valorgrasasp\n\t\tvag=(cgrasas * 70) / 100\n\t\tvag.round(2)\n\tend", "def get_valor_energetico\n \n return ((@proteinas + @glucidos) * 4 + @lipidos * 9).round(1)\n \n \n end", "def french_siret_number; end", "def valorenergeticoKcal\n veKJ=(cgrasas * 9) + (cgrasassa * 9) + (grasasmono * 9) + (grasaspoli * 9) + (hcarbono * 4) + (polialcoholes * 2.4) + (almidon * 4) + (fibra * 2) + (proteinas * 4) + (sal * 6)\n veKJ.round(2)\n end", "def massaCorporalGorda(percentualDeGordura, peso)\n resultado = (peso*percentualDeGordura)/100\nend", "def getNombreGrille\n @mesGrilles.size - 1\n end", "def irmonograsas\n vag=(grasasmono * 100) / 70\n vag.round(2)\n end", "def horas_cierre\n return current_user.grupo.end_times if current_user && !current_user.grupo.nil?\n\n HORAS_CIERRE\n end", "def gc\n s = codons.map { |c| c.nuc_codon[2] }.join\n ((s.count('G')+s.count('C')).to_f/codons.count).round(4)\n end", "def por_prote\n\t\t\t(@proteinas/suma_gramos)*100\n\t\tend", "def huella_nutricional\n ((get_impacto_energia + get_impacto_gei)/2).ceil(2)\n end", "def donnerErreur()\n return @grilleEnCours.firstDifference(@grilleBase)\n end", "def imc_tabla\n\t\tx = self.indice_masa_corporal\n\n\n\t\tif x < 18.5\n\t\t\treturn \"#{x} < 18.5 -- Bajo peso -- Delgado\"\n\t\telsif x >= 18.5 && x <= 24.9\n\t\t\treturn \"18.5 < #{x} < 24.9 -- Adecuado -- Aceptable\"\n\t\telsif x > 24.9 && x <= 29.9\n\t\t\treturn \"25.0 < #{x} < 29.9 -- Sobrepeso -- Sobrepeso\"\n\t\telsif x > 29.9 && x <= 39.9\n\t\t\treturn \"30.0 < #{x} < 39.9 -- Obesidad grado 1 -- Obesidad\"\n\t\telsif x > 39.9\n\t\t\treturn \" #{x} > 40 -- Obesidad grado 2 -- Obesidad\"\n\t\tend\n\n\tend", "def combien_de_PDR()\n return @nb_point_de_retour\n end", "def calculo_valor_energetico\n\t\t\t(@carbohidratos*4) + (@lipidos*9) + (@proteinas*4)\n\t\tend", "def get_val()\n val = (@proteinas * 4) + (@lipidos * 9) + (@glucidos * 4)\n end", "def grasas_totales \n\t\t@grasas_totales = @saturadas + @monoinsaturadas + @polinsaturadas\n\t\treturn @grasas_totales\n\tend", "def irpoliinsaturadasp\n vag=(valorgrasaspolip * 100) / 70\n vag.round(2)\n end", "def por_carbo\n\t\t\t(@carbohidratos/suma_gramos)*100\n\t\tend", "def ganador(puntos)\n\n if(puntos[0] < puntos[1])\n print \"El Ganador es el jugador 2\\n\"\n elsif(puntos[0] > puntos[1])\n print \"El Ganador es el jugador 1\\n\"\n else\n print \"Esto es un empate!\\n\"\n end\n end", "def prot\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.proteinas * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def car\n\t\tsuma = 0\n\t\tx = 0\n\t\tcantidad = 0\n\n\t\[email protected] do |i|\n\t\t\tcantidad = @gramos[x].valor / (i.proteinas + i.lipidos + i.carbohidratos)\n\t\t\tsuma += i.carbohidratos * cantidad\n\t\t\tx += 1\n\t\tend\t\n\n\t\treturn ((suma * 100) / gramos_total).round(2)\n\tend", "def info_conta\n # CAMPO TAMANHO\n # agencia 3\n # conta corrente 7\n \"#{agencia}#{conta_corrente}\"\n end", "def vct\n\t\tsuma = 0\n\t\t\n\t\tsuma += prot * gramos_total * 4 / 100\n\t\tsuma += car * gramos_total * 4 / 100\n\t\tsuma += lip * gramos_total * 9 / 100\n\t\t\n\t\treturn suma.round(2)\n\tend", "def GueltigBis\n \treturn @GueltigBis\n end", "def producao (quantidade, tamanho: :M, cor: :azul) #não precisa obdecer a ordem de tamanho e cor, pq tem chave e valor\n puts \"Produzindo #{quantidade} de roupas tamanho #{tamanho} e cor #{cor}\"\nend", "def ir_grasa_total \n\t\t@grasa_ir = grasas_totales\n\t\t@ir_grasa_total = (@grasa_ir/70.to_f) * 100\n\t\t@ir_grasa_total.round(1)\n\tend", "def valorizacao\n \t\tif self.tipo_de_operacao.compra?\n ((self.atual - self.entrada) / self.entrada) * 100.0\n else\n ((self.entrada - self.atual) / self.atual ) * 100.0\n end\n \tend", "def huellaNut \n\t\t(@indEnergia.call + @indGei.call)/2.0\n\tend", "def valor_energetico\n @proteinas * 4.0 + @carbohidratos * 4.0 + @lipidos * 9.0\n end", "def cintura\n\t\t(@cintura[0] + @cintura[1])/2\n\tend", "def get_energia\n\t\t\t\t@lipidos * 9 + @proteins * 4 + @carbs * 4\n\t\t\tend", "def status_da_divulgacao(topico)\n end", "def best_euros p\n euros(p)\n end", "def irgrasassaturadasp\n vag=(valorgrasassatup * 100) / 70\n vag.round(2)\n end", "def valorenergeticoKJ\n\t\tveKJ=(cgrasas * 37) + (cgrasassa * 37) + (grasasmono * 37) + (grasaspoli * 37) + (hcarbono * 17) + (polialcoholes * 10) + (almidon * 17) + (fibra * 8) + (proteinas * 17) + (sal * 25)\n\t\tveKJ.round(2)\n\tend", "def info_conta\n # CAMPO TAMANHO\n # agencia 4\n # digito agencia 1\n # conta corrente 8\n # digito da conta 1\n # numero convenio 6\n cc = conta_corrente.to_s.rjust(8, '0')\n \"#{agencia}#{agencia_dv}#{cc}#{conta_corrente_dv}#{''.rjust(6, '0')}\"\n end", "def irvitaminasp\n vag=(valorvityminp * 100) / 50\n vag.round(2)\n end", "def degree; end", "def bilan\n raise \"Il faut lancer l'étude avec Etude::start avant de construire le bilan\" if @data.nil?\n @bilan ||= begin\n c = []\n # Largeur : 26 (sans les \"|\")\n titre = \"Exercices #{from_exercice} à #{to_exercice}\"\n gauche = ((26 - titre.length).to_f / 2).floor - 1\n droite = \" \" * (26 - (gauche + titre.length))\n gauche = \" \" * gauche\n entete = <<-TXT\n----------------------------\n|#{gauche}#{titre}#{droite}|\n----------------------------\n| Doigté | Nombre de fois |\n TXT\n c << entete.strip\n titre_section = <<-TXT\n----------------------------\n| Par quantité |\n----------------------------\n TXT\n c << titre_section.strip\n nombre_max = nil\n nombre_min = nil\n nb_courant = nil\n @data.sort_by{|c, e| e[:nombre]}.reverse.each do |combi, data_combi|\n nb_courant = data_combi[:nombre]\n nombre_max = nb_courant if nombre_max.nil?\n nb = (\" \" * 5) << nb_courant.to_s # 16\n nb << \" \" * (16 - nb.length) \n c << \"| #{combi} | #{nb}|\"\n end\n nombre_min = nb_courant\n \n titre_section = <<-TXT\n----------------------------\n| Par premier doigt |\n----------------------------\n TXT\n c << titre_section.strip\n @data.sort_by{|combi, e| combi[0..0]}.each do |combi, data_combi|\n nb = data_combi[:nombre]\n nb = \"#{nb} (max)\" if nb == nombre_max\n nb = \"#{nb} (min)\" if nb == nombre_min\n nb = (\" \" * 5) << nb.to_s\n nb << \" \" * (16 - nb.length) \n c << \"| #{combi} | #{nb}|\"\n end\n \n titre_section = <<-TXT\n----------------------------\n| Par second doigt |\n----------------------------\n TXT\n c << titre_section.strip\n @data.sort_by{|combi, e| combi[2..2]}.each do |combi, data_combi|\n nb = data_combi[:nombre]\n nb = \"#{nb} (max)\" if nb == nombre_max\n nb = \"#{nb} (min)\" if nb == nombre_min\n nb = (\" \" * 5) << nb.to_s # 16\n nb << \" \" * (16 - nb.length) \n c << \"| #{combi} | #{nb}|\"\n end\n c << \"-\" * 28\n c << \"\\n\"\n c.join(\"\\n\")\n end\n end", "def turno_nivel_facil\n if tem_naipe_da_rodada_ou_trunfo?\n return joga_maior_carta\n else\n return joga_menor_carta\n end\n end", "def kcalglucidos\n\t\t\t@carbohidratos * 4\n\t\tend", "def valormonograsasp\n\t\tvag=(grasasmono * 70) / 100\n vag.round(2)\n\tend", "def tas_poser_1_carte joueur\n # Examine tous les tas déjà posés un par un\n self.ta12s.each do |tas|\n # Abandonne l'examen des différents tas quand plus qu'une carte\n break if joueur.cartes.size == 1\n # Evite de compléter la tierce franche lors de la 1° pose\n unless joueur.a_atteint_51?\n next if tas.nom_joueur == joueur.nom + \"_tf\"\n end\n # Regarde si on peut ajouter une carte au tas\n joueur.cartes.each do |carte|\n # Regarde si la carte peut aller sur le tas\n if tas.complete_le_tas? carte\n type = tas.combinaison.type\n # Pose la carte\n self.traces << \" tas <= #{tas.to_s} + [ #{carte.to_s} ]\"\n poser_sur_tas joueur, tas, carte\n # On ne peut plus compléter le tas si c'est une série de plus de 3 cartes\n break if tas.cartes.size > 3\n # on ne peut plus compléter le tas si ce n'est pas une série\n break if type != :serie\n end\n end\n end\n end", "def precio_mercado\n @serie.valor_primer_dia('precio')\n end", "def valorpolialcoholesp\n\t\tvag=(polialcoholes * 70) / 100\n vag.round(2)\n\tend", "def get_alco\n @_100=((@alco*100)/@peso)\n #@ir_100=(@_100/90)*100\n @porcion=((@alco*@gramos_porciones)/@peso)\n #@ir_porcion=(@porcion/90)*100\n [ @alco , @_100 , 0 , @porcion , 0 ]\n end", "def precio\n\t\t@precio\n\tend", "def clasificar\n if @sal <= 1\n \"poca\" \n elsif @sal > 1 and @sal <= 2\n \"media\"\n elsif @sal > 2\n \"mucha\"\n end\n end", "def irvitaminas\n vag=(vitymin * 100) / 50\n vag.round(2)\n end", "def irpolialcoholesp\n vag=(valorpolialcoholesp * 100) / 90\n vag.round(2)\n end", "def geidiario\n auxNodo1 = @lista_alimentos.head\n auxNodo2 = @gramos.head\n geitotal = 0\n while(auxNodo1 != nil && auxNodo2 != nil)\n geitotal += (auxNodo1.value.gei * auxNodo2.value) / 100\n auxNodo1 = auxNodo1.next\n auxNodo2 = auxNodo2.next\n end\n return geitotal.round(1)\n end", "def valorproteinasp\n\t\tvag=(proteinas * 70) / 100\n vag.round(2)\n\tend", "def gadz_ans\n (user.gadz_proms_principale.to_i - 1800).to_s\n end", "def slogan\n # 'A maneira mais fácil de pré-qualificar ao Atlas.'\n ''\n end", "def pProteina \n\t\tprot = 0\n\t\ttotal = 0\n\t\[email protected] do |alimento|\n\t\t\ttotal += (alimento.proteinas + alimento.lipidos + alimento.carbohidratos)\n\t\t\tprot += alimento.proteinas\n\t\tend\n\t\treturn ((prot/total)*100).round\t\n\tend", "def carbo \n grtotal = 0\n sum = 0\n\t\t#itera en las dos listas a la vez para poder calcular las \n #cabrohidratos dependiendo de la cantidad y tambien suma\n #todas las cantidades para poder calcular el porcentaje\n #despues\n @lista.zip(@listagr).each do |normal, gr|\n grtotal += gr\n cant = gr/1000.0\n sum += normal.carbo*cant\n end\n (sum*100)/grtotal\n end", "def victory(joueur)\n\t\t# On définit les 8 possibilités de victoires si elles se vérifient les 3 dans la combinaison donnée alors la partie s'arrête\n\t\tif (plateau[0] == joueur.value) && (plateau[1] == joueur.value) && (plateau[2] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\n\t\telsif (plateau[3] == joueur.value) && (plateau[4] == joueur.value) && (plateau[5] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[3] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[4] == joueur.value) && (plateau[6] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[0] == joueur.value) && (plateau[4] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[2] == joueur.value) && (plateau[5] == joueur.value) && (plateau[8] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telsif (plateau[1] == joueur.value) && (plateau[4] == joueur.value) && (plateau[7] == joueur.value)\n\t\t\tputs \"#{joueur.name} a eu plus de chance que toi ¯\\_(ツ)_/¯\"\n\t\t\tdisplay\n\t\t\texit\n\t\telse\n\t\t\treturn\n\t\tend\n\tend", "def jeuTermine\n\t\[email protected](self.timer)\n\t\tscoreFinal = @grille.score.calculerScoreFinal\n\t\t@@joueur.score = scoreFinal > 0 ? scoreFinal : 0\n\t\tself.lancementFinDeJeu\n\t\tself\n\tend", "def get_sal\n @_100=((@sal*100)/@peso)\n @ir_100=(@_100/6)*100\n @porcion=((@sal*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/6)*100\n\t\t#p \"| #{@sal} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @sal , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end", "def chargementJeu(nomJoueur)\n @sauvegardeYaml = SauvegardeYAML.creer(nomJoueur)\n @sauvegarde = @sauvegardeYaml.chargement()\n @joueur = @sauvegarde.joueur\n [email protected](\".\")\n @joueur.nom = nom[0]\n print @joueur.nom\n @carte = @sauvegarde.carte\n @nbTour = @sauvegarde.nbTour\n\tend" ]
[ "0.7751134", "0.7530691", "0.73430467", "0.7241775", "0.7128314", "0.7124336", "0.71112186", "0.6979215", "0.68545216", "0.6790285", "0.6613468", "0.6575124", "0.656638", "0.6491464", "0.6481334", "0.6475752", "0.646888", "0.6457517", "0.6438405", "0.64339834", "0.6332017", "0.63167214", "0.6285588", "0.62226266", "0.6205412", "0.6193187", "0.6189686", "0.6186681", "0.6169253", "0.6168824", "0.6166102", "0.6154388", "0.61539066", "0.6145769", "0.6139571", "0.61348265", "0.613279", "0.61205083", "0.61124885", "0.60971844", "0.6088555", "0.6085894", "0.6081189", "0.60664356", "0.6029564", "0.60156184", "0.6011925", "0.5973909", "0.59646267", "0.5947909", "0.59476674", "0.5938365", "0.5920819", "0.59135276", "0.59123653", "0.59059316", "0.5902868", "0.5895324", "0.5895189", "0.58902234", "0.58900964", "0.5888203", "0.5884424", "0.5882367", "0.58747214", "0.58712816", "0.5860178", "0.5841726", "0.583751", "0.58330107", "0.58275914", "0.5815335", "0.5814416", "0.5811714", "0.58079237", "0.58030784", "0.58016324", "0.57870734", "0.5786771", "0.57849324", "0.5784763", "0.5784677", "0.5783812", "0.5780636", "0.57804435", "0.5780297", "0.5778768", "0.57761294", "0.5770298", "0.5769931", "0.57663095", "0.57662404", "0.5765723", "0.5762088", "0.5760281", "0.5757648", "0.57542473", "0.5752034", "0.57516766", "0.57502604", "0.5748527" ]
0.0
-1
enregistrer une grille pour le loto courant
def validate_grid grid # verifier que le tirage n'a pas encore eu lieu @saved_grids ||=[] # TODO check draw isnot yet done return @saved_grids if draw_done? @saved_grids.push grid end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sauvegarderJeu()\n\t\t# création de la sauvegarde\n\t\t@sauvegarde = Sauvegarde.creer( self.joueur,self.carte,self.nbTour )\n\n @sauvegardeYaml = SauvegardeYAML.creer(self.joueur.nom)\n @sauvegardeYaml.enregistrement( self.sauvegarde)\n\n\tend", "def sauvegarder(nomFichier)\n\t\n\t\t# Ouverture du fichier\n\t\tfichier = File.open(nomFichier, \"w\")\n\t\t\n\t\t# Traduction de chacune des grilles de la liste des grilles en ligne de fichier\n\t\tligne = \"\"\n\t\[email protected] do |grille|\n\t\t\tligne = grille.toLigneFichier()\n\t\t\tfichier.write(ligne)\n\t\tend\n\t\t\n\t\t# Fermeture du fichier\n\t\tfichier.close()\n\tend", "def candidatGrille()\n\n\tend", "def save_registration(fname)\n @mim.save_registration fname\n end", "def ajouterGrille(box)\n vBoxGrille = Gtk::Box.new(:vertical , 20)\n tabPartieEnCours = Sauvegardes.getInstance.getSauvegardePartie.getListPartieLibreEnCours\n\n # Si le bouton 'facile' est actif => affichage des scores pour les grilles du niveau 'facile'\n if @@easyActivated\n vBoxGrille.add( titleLabel( @@lg.gt(\"FACILE\") ) )\n i = 1\n while ( i <= SauvegardeGrille.getInstance.getNombreGrille / 3 )\n if i == SauvegardeGrille.getInstance.getNombreGrille / 3\n vBoxGrille.add( generateHbox( generateFrame( SauvegardeGrille.getInstance.getGrilleAt(i) , box ) , nil ) )\n else\n vBoxGrille.add( generateHbox( generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i) , box ) ,generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i + 1) , box )) )\n i+=1\n end\n i+=1\n end\n\n if(@@mediumActivated || @@hardActivated)\n vBoxGrille.add( Gtk::Separator.new(:horizontal) )\n end\n end\n\n # Si le bouton 'moyen' est actif => affichage des scores pour les grilles du niveau 'moyen'\n if @@mediumActivated\n vBoxGrille.add( titleLabel( @@lg.gt(\"MOYEN\") ) )\n i = 1 + SauvegardeGrille.getInstance.getNombreGrille / 3\n while ( i <= SauvegardeGrille.getInstance.getNombreGrille / 3 * 2 )\n if i == SauvegardeGrille.getInstance.getNombreGrille / 3 * 2\n vBoxGrille.add( generateHbox( generateFrame( SauvegardeGrille.getInstance.getGrilleAt(i) , box ) , nil ) )\n else\n vBoxGrille.add( generateHbox( generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i) , box ) ,generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i + 1) , box )) )\n i+=1\n end\n i+=1\n end\n\n if(@@hardActivated)\n vBoxGrille.add( Gtk::Separator.new(:horizontal) )\n end\n end\n\n # Si le bouton 'difficile' est actif => affichage des scores pour les grilles du niveau 'difficile'\n if @@hardActivated\n vBoxGrille.add( titleLabel( @@lg.gt(\"DIFFICILE\") ) )\n i = 1 + SauvegardeGrille.getInstance.getNombreGrille / 3 * 2\n while ( i <= SauvegardeGrille.getInstance.getNombreGrille )\n if i == SauvegardeGrille.getInstance.getNombreGrille\n vBoxGrille.add( generateHbox( generateFrame( SauvegardeGrille.getInstance.getGrilleAt(i) , box ) , nil ) )\n else\n vBoxGrille.add( generateHbox( generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i) , box ) ,generateFrame(SauvegardeGrille.getInstance.getGrilleAt(i + 1) , box)) )\n i+=1\n end\n i+=1\n end\n end\n setmargin(vBoxGrille,15,15,0,0 )\n\n return vBoxGrille\n end", "def new_addres_g\n @addres_g = AddresG.find_by_id(params[:id]) \n if @addres_g.update_attributes(params[:addres_g])\n @addres_g.person.op.touch\n @addres_g.person.op.update_attributes({tip_op: \"П040\"})\n redirect_to home_path, notice: 'Новый адрес регистрации успешно сохранился.' \n else\n render action: \"newaddres_g\"\n end\n end", "def enregistreScore()\n\t\tchemin = \"../scoreboard/\"[email protected](\"/\")[2]\n\t\tmonFichier = File.open(chemin)\n\t\t#Récupération des scores déjà exists\n\t\tallScores = []\n\t\tmonFichier.each_line{ |ligne|\n\t\t\tallScores.push(ligne.to_s)\n\t\t}\n\t\t#Suppression de ce qu'il y a dedans\n\t\tmonFichier = File.open(chemin, \"w\")\n\t\tFile.truncate(chemin,0)\n\t\t#Réecriture de tous les scores triés dans le fichier\n\t\tif allScores.length == 0\n\t\t\tmonFichier.write(@pseudo+\"-\"+recupNom(@cheminMap)+\"-\"[email protected]_s+\"\\n\")\n\t\telse\n\t\t\tallScores.push(@pseudo+\"-\"+recupNom(@cheminMap)+\"-\"[email protected]_s+\"\\n\")\n\t\t\tallScores = triScore(allScores)\n\t\t\tallScores = coupeTabMaxElt(allScores,10)\n\t\t\tallScores.each{ |ligne|\n\t\t\t\tmonFichier.write(ligne)\n\t\t\t}\n\t\tend\n\t\tmonFichier.close\n\tend", "def add_graffiti(obj_type, obj_hash, graffiti, login, password_callback=PasswordCallback)\n name,value = graffiti.split(':')\n obj_hash.each_value do |obj|\n set_objects('graffitis', nil,\n { :name => name,\n :value => value,\n :graffitiable_id => obj['id'],\n :graffitiable_type => obj_type,\n },\n login, password_callback);\n end\n end", "def register\n @unsigned_users = @olympiad.unsigned_users()\n unless @registration\n if @registration = Registration.for_user(current_user).for_olympiad(@olympiad).first\n flash.now[:notice] = \"You have already registered for this event. Feel free to make changes to your registration, below.\"\n else\n @registration = Registration.new\n end\n end\n end", "def set_groupe_aile\n @groupe_aile = GroupeAile.find(params[:id])\n end", "def set_grua\n @grua = Grua.find(params[:id])\n end", "def set_grua\n @grua = Grua.find(params[:id])\n end", "def register\r\n \r\n end", "def changerEnRouge\n\t\t@couleur=1\n\tend", "def registrarPersonaEnGrupo(app,nombreGrupo)\n\t\tregistro=FXDialogBox.new(app,\"Agregar Integrantes\",:width=>300,:height=>400)\n\t\tbotones=FXVerticalFrame.new(registro,:opts => FRAME_RAISED|LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X)\n\n\n\t\tartistas=FXListBox.new(registro,:opts => LISTBOX_NORMAL|LAYOUT_EXPLICIT|FRAME_THICK,:width=>270,:height=>30,:x=>20,:y=>100)\n\n\t\tbotonAgregaIntegrante=FXButton.new(botones, \" Agregar Integrante \",:opts => BUTTON_NORMAL|LAYOUT_FILL_X)\n\t\tbotonAgregaIntegrante.backColor=\"DodgerBlue\"\n\t\tbotonGuardar=FXButton.new(botones, \"Guardar\",:opts => BUTTON_NORMAL|LAYOUT_FILL_X)\n\t\tsalida=FXButton.new(botones, \"Salir\",:target => registro,\n\t\t\t:selector => FXDialogBox::ID_CANCEL,:opts => BUTTON_NORMAL|LAYOUT_CENTER_X|LAYOUT_FILL_X)\n\n\t\t\tsalida.backColor=\"IndianRed\"\n\t\t\tbotonGuardar.backColor=\"PaleGreen\"\n\t\t\tFXLabel.new(registro,\"Grupo: \"+nombreGrupo,:opts=>LAYOUT_CENTER_X,:y=>20)\n\t\t\tlistaIntegrantes=FXText.new(registro,:opts=>LAYOUT_EXPLICIT|TEXT_READONLY,:width=>200,:height=>150,:x=>20,:y=>140)\n\n\n\t\t\tids=ControlDeBase.new.buscarIdentificados(\"groups\",nombreGrupo)\n\t\t\tidentificados=ControlDeBase.new.buscarIdentificadosCompleto(\"persons\")\n\t\t\tenGrupo=ControlDeBase.new.busquedaInGrup(ids[0][0])\n\t\t\tlistaEnElGrupo=\"Integrantes: \\n\"\n\t\t\tif(!enGrupo.nil?)\n\t\t\t\ti=0\n\t\t\t\te=0\n\t\t\t\taux=identificados\n\t\t\t\twhile e<enGrupo.length\n\t\t\t\t\tif(aux[i][0]==enGrupo[e][0])\n\t\t\t\t\t\tlistaEnElGrupo=listaEnElGrupo+aux[i][1].to_s+\"\\n\"\n\t\t\t\t\t\tidentificados.delete(identificados[i])\n\t\t\t\t\t\ti=0\n\t\t\t\t\t\te=e+1\n\t\t\t\t\telse\n\t\t\t\t\t\ti=1+i\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tbotonAgregaIntegrante.connect(SEL_COMMAND) do\n\t\t\t\tPackInterfaz.new.ventanaRegistroPersona(app,nombreGrupo)\n\t\t\tend\n\n\t\t\tlistaIntegrantes.text=listaEnElGrupo\n\t\t\tartistas.appendItem(\" \")\n\t\t\tidentificados.each{|nombre| artistas.appendItem(nombre[1])}\n\t\t\tbotonGuardar.connect(SEL_COMMAND) do\n\t\t\t\tif(artistas.currentItem!=0)\n\t\t\t\t\tpersonaAgregar=artistas.getItem(artistas.currentItem)\n\t\t\t\t\tControlDeBase.new.personaEnGrupo(personaAgregar,nombreGrupo)\n\t\t\t\t\tbotonGuardar.hide\n\t\t\t\tend\n\t\t\tend\n\t\tregistro.execute\n\tend", "def sign_cla!\n self.authorized_to_contribute = true\n save!\n end", "def preencher\n nome.set 'leticia'\n \n end", "def register\n \n end", "def register_for(id); end", "def create\n \n @empresa = Empresa.find(:first, :conditions => [\"prefijo = ?\", params[:empresa_id]]) # para la validacion del formulario\n\n params[:gln][:gln] = Gln.generar(params[:empresa_id])\n params[:gln][:fecha_asignacion] = Time.now\n estatus = Estatus.find(:first, :conditions => [\"descripcion = ? and alcance = ?\", 'Activo', 'GLN'])\n params[:gln][:id_estatus] = estatus.id\n params[:gln][:codigo_localizacion] = params[:gln][:gln][7..11]\n @gln = Gln.new(params[:gln])\n\n respond_to do |format|\n if @gln.save\n format.html { redirect_to empresa_glns_path, notice: \"GLN #{@gln.gln} fue generado.\"}\n format.json { render json: @gln, status: :created, location: @gln }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gln.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_grado\n @grado = Grado.find(params[:id])\n end", "def agregar_profesor\n @grupo = Grupo.find(params[:id])\n if request.get?\n @profesores = Profesor.search(params[:buscar])\n end\n if request.put?\n @profesor = Profesor.find(params[:profesor_id])\n @grupo.profesor = @profesor\n flash[:notice] = \"Se modificó el profesor al grupo #{@grupo.nombre_completo}\" if @grupo.save\n redirect_to grupo_path(@grupo)\n end\n end", "def set_reg_orden\n @reg_orden = RegOrden.find(params[:id])\n end", "def set_gratitude\n @gratitude = Gratitude.find(params[:id])\n end", "def register!\n @planet.next_raid_at += Cfg.raiding_delay_random\n @planet.raid_arg = generate_arg\n CallbackManager.register_or_update(\n @planet, CallbackManager::EVENT_RAID, @planet.next_raid_at\n )\n @planet.delayed_fire(@planet, EventBroker::CHANGED,\n EventBroker::REASON_OWNER_PROP_CHANGE)\n @planet.save!\n end", "def register!\n self.state = \"pending\"\n self.activation_code = new_code\n self.activated_at = nil \n save(:validate=>false)\n end", "def create\n @interno = Interno.new(interno_params)\n @interno.state = 'Activo'\n @interno.lugarNacimiento=(params[:palabra])\n \n if @interno.save\n flash[:success] = 'Interno fue creado exitosamente'\n redirect_to @interno\n else\n render action: \"new\"\n end\n \n end", "def set_registrer\n @registrer = Registrer.find(params[:id])\n end", "def signup(gym, cost, lifter)\n membership = Membership.new(gym, cost)\n self.membership << gym\n end", "def insert(clave, valor)\r\n @grafo[clave] = valor\r\n end", "def set_sous_groupe\n @sous_groupe = SousGroupe.find(params[:id])\n end", "def ajouter_etudiant(nom_param, prenom_param, niveau_param, cours_nom_param)\n # On definit un etudiant\n etudiant = {\n \"nom\" => nom_param,\n \"prenom\" => prenom_param,\n \"niveau\" => niveau_param\n }\n \n # On augmente de 1 l'effectif du cours auquel est inscrit l'etudiant\n inscrire_cours(cours_nom_param)\n \n # On ajoute l'etudiant a la liste des etudiants\n LISTE_ETUDIANTS.push(etudiant)\nend", "def set_listener\n return unless self.controller_name == \"registrations\"\n user = User.find_for_authentication(:email => params[:user][:email])\n @listener.user_id = user.id\n user.listener = @listener\n @listener.save\n user.save\n end", "def chargementJeu(nomJoueur)\n @sauvegardeYaml = SauvegardeYAML.creer(nomJoueur)\n @sauvegarde = @sauvegardeYaml.chargement()\n @joueur = @sauvegarde.joueur\n [email protected](\".\")\n @joueur.nom = nom[0]\n print @joueur.nom\n @carte = @sauvegarde.carte\n @nbTour = @sauvegarde.nbTour\n\tend", "def seguir(otro_usuario)\n\t\t# siguiendo << otro_usuario\n\t\trelaciones_activas.create(seguido_id: otro_usuario.id)\n\tend", "def finish_register\n end", "def changerVers(couleur)\n\t\t@couleur=couleur\n\tend", "def changerVers(couleur)\n\t\t@couleur=couleur\n\tend", "def start_registration\r\n \r\n end", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n Kernel.pbCancelVehicles\n trainer=pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject=PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID=trainerobject.id\n i.ot=trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner=[trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def register!(user)\n raise \"Already registred\" if user and not user.guest?\n self.user = user and save!\n end", "def crear_actualizar_grupo(ldapgr, prob)\n cn = ldapgr.cn[0]\n d = ldapgr.respond_to?(:description) ? ldapgr.description[0] : cn\n grupo = Msip::Grupo.where(cn: cn).take\n if grupo.nil?\n grupo = Msip::Grupo.new(fechacreacion: Date.today)\n if grupo.nil?\n prob << 'No pudo crear grupo: ' + prob\n return nil\n end\n end\n grupo.cn = cn\n grupo.nombre = d\n grupo.gidNumber = valor_campo_ldap(ldapgr, :gidNumber)\n grupo.ultimasincldap = Date.today\n grupo.fechadeshabilitacion = nil\n grupo.save\n if (grupo.errors.messages.length > 0)\n prob << grupo.errors.messages.to_s\n return nil\n end\n return grupo\n end", "def create\r\n @comite_registro = current_user.comite_registros.build(comite_registro_params)\r\n\r\n if @comite_registro.save\r\n flash[:success] = \"Su petición para registrar su comité tutorial fue creada!\"\r\n if current_user.tipos_usuario.tipo == \"Alumno\"\r\n redirect_to alumnos_path\r\n else\r\n redirect_to root_path\r\n end\r\n else\r\n flash[:alert] = \"Su petición para registrar su comité tutorial no pudo ser creada! Revise el formulario.\"\r\n render :new\r\n end\r\n end", "def set_profesor_grado\n @profesor_grado = ProfesorGrado.find(params[:id])\n end", "def registration(mode=:center)\n @registration = mode\n end", "def create\n @registration = Registration.new(registration_params)\n @registration.group_id = sortear_grupo(@registration.colonist_age, @registration.colonist_gender)\n \n respond_to do |format|\n if @registration.save\n format.html { redirect_to @registration, notice: \"Bienvenido a la familia Buena Onda. Ya estás pre-inscripto. No olvides pasar por el club [dirección] de (9) a (18) dentro de las próximas 72 hs para confirmar la inscripción de #{@registration.colonist_name} y abonar la inscripción.\" }\n format.json { render :show, status: :created, location: @registration }\n else\n format.html { render :new }\n format.json { render json: @registration.errors, status: :unprocessable_entity }\n end\n end\n end", "def after_sign_up_path_for(resource)\n # super(resource)\n flash[:notice] = \"Prenez 5 minutes pour répondre à notre questionnaire afin de mieux cibler votre recherche\"\n edit_profil_path\n end", "def update\n @interno.lugarNacimiento=(params[:palabra])\n if @interno.update(interno_params)\n flash[:success] = \"Interno actualizado exitosamente\"\n redirect_to @interno\n else\n render action: \"edit\"\n end\n end", "def pbRegisterPartner(trainerid,trainername,partyid=0)\n if trainerid.is_a?(String) || trainerid.is_a?(Symbol)\n trainerid = getID(PBTrainers,trainerid)\n end\n Kernel.pbCancelVehicles\n trainer = pbLoadTrainer(trainerid,trainername,partyid)\n Events.onTrainerPartyLoad.trigger(nil,trainer)\n trainerobject = PokeBattle_Trainer.new(_INTL(trainer[0].name),trainerid)\n trainerobject.setForeignID($Trainer)\n for i in trainer[2]\n i.trainerID = trainerobject.id\n i.ot = trainerobject.name\n i.calcStats\n end\n $PokemonGlobal.partner = [trainerid,trainerobject.name,trainerobject.id,trainer[2]]\nend", "def register(contributor, description, donation_url)\n @database.transact_write_items(\n {\n transact_items: [\n {\n put: {\n table_name: candidates_table_name,\n item: {\n 'username' => contributor['username'],\n 'avatar_url' => contributor['avatar_url'],\n 'contributions' => contributor['contributions'],\n 'contributor_type' => contributor['contributor_type'],\n 'html_url' => contributor['html_url'],\n 'votes' => votes(contributor['username']),\n 'description' => description,\n 'donation_url' => donation_url\n }\n }\n },\n {\n update: {\n table_name: contributors_table_name,\n key: { 'username' => contributor['username'] },\n update_expression: 'SET is_candidate = :is_candidate, description = :description, donation_url = :donation_url',\n expression_attribute_values: {\n ':is_candidate' => true,\n ':description' => description,\n ':donation_url' => donation_url\n }\n }\n }\n ]\n }\n )\n end", "def sauvegarder(unNom)\n\t\tif nbSaves() >= 8\n\t\t\tdialog = Gtk::Dialog.new(\"Alerte\",\n \t $main_application_window,\n \t :destroy_with_parent,\n \t [ Gtk::Stock::OK, :none ])\n \t\t\tdialog.set_window_position(:center_always)\n\n \t # Ensure that the dialog box is destroyed when the user responds.\n \t dialog.signal_connect('response') { dialog.destroy }\n\n \t # Add the message in a label, and show everything we've added to the dialog.\n \t dialog.child.add(Gtk::Label.new( \"\\nImpossible:nombre maximum de sauvegardes atteint (8/8)!\\n\" ))\n \t dialog.show_all\n\t\telse\n\t\t\t# Serialisation des différentes classes\n\t\t\thypo = @hypo.to_yaml()\n\n\t\t\t# Ecriture dans le fichier\n\t\t\tmonFichier = File.open(\"../sauvegardes/\"+unNom, \"w\")\n\t\t\tmonFichier.write(hypo)\n\t\t\tmonFichier.write(\"***\\n\")\n\t\t\tmonFichier.write(@pseudo)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@inc)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@time)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@cheminMap)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\t\t\tmonFichier.write(@nbHypo)\n\t\t\tmonFichier.write(\"\\n***\\n\")\n\n\t\t\t# Fermeture du fichier\n\t\t\tmonFichier.close\n\t\tend\n\tend", "def grilleSuivante()\n @grilleRaz = nil\n return nil\n end", "def grasa(sexo,peso,talla)\n\t\t@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4\n\tend", "def register\n end", "def register\n end", "def register\n end", "def register\n end", "def add_gang_to_unit\n @h_params = unit_params.to_h\n @h_params[ :gang_id ] = @gang.id\n @h_params[ :name ] = GameRules::UnitNameGenerator.generate_unique_unit_name(@campaign )\n\n @unit = Unit.new( @h_params )\n end", "def utiliser( objet )\n\t\[email protected]( objet )\n\t\trafraichir\n\tend", "def lancementHudPresentationTutoriel(grille)\n\t\t@@fenetre.changerWidget(HudPresentationTutoriel.new(grille))\n\t\tself\n\tend", "def make_dick_editor_of_addtional_name\n name = names(:boletus_edulis)\n name.user = users(:rolf)\n name.save\n end", "def chargeGrille()\n data = []\n File.foreach(@nomniv).with_index do |line, line_no|\n data << line.chomp\n end\n # Slice permet de récupérer la taille de la matrice \n # tel que 7:7\n num = data.slice!(0)\n self.colonnes = @x\n self.lignes = @y\n\n # Parcours des données récupérés afin de charger\n # les boutons\n for i in 0..(data.length() - 1) \n data[i].split(':').each_with_index do | ch, index| \n # # Création d'une case \n if ch != '0'\n btn = Ile.new(self, ch,index,i)\n @sommets << btn\n else \n btn = Pont.new(self, index, i)\n end\n\n # On attache la référence de la grille\n self.attach(btn, index,i, 1,1)\n end\n end\n\n return self\n end", "def set_sousgroupe\n @sousgroupe = Sousgroupe.find(params[:id])\n end", "def enable_registration_code(enable)\n if enable\n return true if current_course.registration_key\n\n current_course.generate_registration_key\n else\n current_course.registration_key = nil\n end\n current_course.save\n end", "def push_reg reg\n @fisk.push reg.to_register\n end", "def register\n\n\tend", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def inicia_analista\n current_usuario = Usuario.create!(PRUEBA_USUARIO_AN)\n current_usuario.grupo_ids = [20]\n current_usuario.save\n return current_usuario\n end", "def save_grip; end", "def register\n\ti = 0\n\twhile i <= 10\n\t\tprint \"Alege un username: \"\n\t\talegere_username = gets.chomp\n\t\tif $users_profil.include?(alegere_username)\n\t\t\tputs \"Numele de utilizator deja exista.\"\n\t\telse\n\t\t\tputs \"Felicitari, numele tau de utilizator este: #{alegere_username}\"\n\t\t\tputs \"Completeaza profilul: \"\n\t\t\tprint \"Varsta: \"\n\t\t\tvarsta = gets.chomp\n\t\t\tprint \"In ce oras locuiesti: \"\n\t\t\toras = gets.chomp\n\t\t\tprint \"Stare civila: \"\n\t\t\tscivil = gets.chomp\n\n\t\t\tarr_util = [varsta, oras, scivil] # stocam valorile intr-un array pe care il adaugam ca valoare atasata cheiei din hash-ul $users_profil\n\t\t\t$users_profil.store(alegere_username, arr_util) # pur si simplu adaugam in baza de date\n\t\t\tputs $users_profil[alegere_username] # printam de dragul afisarii\n\t\t\tprintout # apelam functia care stocheaza noua baza de date intr-un fisier .txt\n\t\t\tbreak\n\t\tend\n\ti += 1\n\tend\n\n\nend", "def make_account_holder(save_after = true)\n self.roles << Role.find_by_title('account_holder')\n self.save if save_after\n end", "def set_registo\n @registo = Registo.find(params[:id])\n end", "def register_automatically(user, project, &block)\n # Automatic activation\n user.status = User::STATUS_ACTIVE\n user.last_login_on = Time.now\n \n \n \n \n \n if verify_recaptcha(:model => user, :message => \"Oh! It's error with reCAPTCHA!\") && user.save\n self.logged_user = user\n# membership = project.members.build\n# membership.user = user\n# membership.save\n \n \n \n sql = ActiveRecord::Base.connection();\n sql.execute \"SET autocommit=1\";\n sql.begin_db_transaction \n sql.execute(\"INSERT INTO members (user_id, project_id, created_on, mail_notification) VALUES (#{@user.id},#{project.id},\\\"#{DateTime.now}\\\",0)\")\n sql.commit_db_transaction\n \n\n \n \n \n \n flash[:notice] = l(:notice_account_activated)\n redirect_to :controller => 'my', :action => 'account'\n else\n yield if block_given?\n end\n end", "def sous_groupe_params\n params.require(:sous_groupe).permit(:nom, :principal_groupe_id)\n end", "def enable_registration_code(enable)\n if enable\n return true if current_course.registration_key\n current_course.generate_registration_key\n else\n current_course.registration_key = nil\n end\n current_course.save\n end", "def set_registration\n @registration = Registration.find_by_kode_formulir(params[:id])\n end", "def agregar(palabra, relacion)\n return if palabra.nil?\n\n @trie.agregar(palabra, relacion)\n end", "def regress\r\n raise \"You must implement this!\"\r\n end", "def registrar_log(tipo)\n if Usuario.current.nil? \n snombre = \"Script\"\n superu = nil\n else\n snombre = Usuario.current.login\n superu = Usuario.current.id\n end\n \n logs = Logsesion.new(:usuario_id => self.id, \n :superu_id => superu,\n :tipo => tipo, \n :nusuario => self.login, \n :nsuperu => snombre)\n\n return logs.save\n end", "def lancementAccueil\n\t\t@@fenetre.changerWidget(HudAccueil.new(@@fenetre))\n\t\tself\n\tend", "def despachar\n self.estado_id = 2 # en ruta\n self.buzon_id = self.destinatario_id\n self.add_traza(current_user.id ,1, current_user.puesto.buzon_id)\n self.recepcion = Time.now\n self.save!\n end", "def register!\n raise 'User is already registered!' if registered_at.present?\n self.registered_at = Time.now\n save!\n end", "def save_zuordnung\n synonym = AnlagenSynonym.find(params[:synonym].to_i)\n synonym.anlage = Anlage.find(params[:anlage].to_i)\n if synonym.save\n flash[:success] = \"Zuordnung erfolgreich\"\n redirect_to upload_anlagen_zuordnung_path\n else\n # TODO: Fehlerbehandlung\n end \n end", "def saveNickname(levelNumber)\n if(@nicknameInput == false && @entry.text_length > 0)\n rank = Ranked.access()\n rank.loadGame(levelNumber)\n\n finalTime = @game.getTimer\n rank.saveTime?(@entry.text, finalTime.min * 60 + finalTime.sec)\n\n @uiManager.victoryScreenType = :normal\n\n @nicknameInput = true\n createPopup(\"Votre temps a été sauvegardé\")\n elsif(@nicknameInput == true)\n createPopup(\"Votre temps est déjà enregistré\")\n else\n createPopup(\"Saisissez un pseudo valide\")\n end\n end", "def create\n\n\n @it_inscripcion_registro = current_user.it_inscripcion_registros.build(it_inscripcion_registro_params)\n\n #Se cuenta cuantas personas se han preinscrito a un grupo. Se cuenta con todos los registros no\n #importando que éstos no hayan sido validados. El dato se obtiene a través de todos los registros\n #de preinscripción, el id para el grupo actual se obtiene con @it_inscripcion_registro.grupo_id\n cupos = ItInscripcionRegistro.where(grupo_id: @it_inscripcion_registro.grupo_id).count\n\n #Se localiza si el usuatio tiene un id previo con ese mismo grupo. Si existe se le envia un mensaje\n # y no se permite guardar el registro por segunda ocasión.\n usuario = User.find(current_user.id)\n registro = ItInscripcionRegistro.find_by(user_id: usuario, grupo_id: @it_inscripcion_registro.grupo_id)\n\n #Si el cupo del grupo excede los 25 alunos se le muestra un mensaje al usuario donde se le indica\n #que deberá elegir un grupo distinto, el registro de inscripción no se guardará en la base dde datos_bancos\n #hay que agregar este metodo a las rb de el modelo correspondiente.\n if cupos > 40\n redirect_to new_it_inscripcion_registro_path, notice: \"El grupo ha alcanzado su ocupación máxima. Por favor elija otro grupo\"\n elsif registro.present? && registro.grupo_id == @it_inscripcion_registro.grupo_id\n redirect_to panel_alumnos_path, notice: \"Usted ya tiene registrada una solicitud con este grupo.\"\n else\n\n respond_to do |format|\n if @it_inscripcion_registro.save\n format.html { redirect_to @it_inscripcion_registro, notice: 'El registro de inscripción se creó correctamente.' }\n format.json { render :show, status: :created, location: @it_inscripcion_registro }\n else\n format.html { render :new }\n format.json { render json: @it_inscripcion_registro.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def set_rego\n @rego = Rego.find(params[:id])\n end", "def asignar_grasas(grasas)\n @grasas=grasas\n end", "def link_account(provider, uid)\n self[provider.column.to_sym] = uid\n self.save\n end", "def update_gratuity\n\t\tticket = Ticket.where(table: session[:table_id]).last\n\t\tticket.update(:gratuity => params[:gratuity])\n\t\tredirect_to guest_confirm_order_path\n\tend", "def sauvegarder()\n\t\[email protected] = Header.temps\n\t\[email protected] = Header.score\n\t\[email protected] = @content[\"grille\"]\n\n\t\t## Sauvegarde la partie dans un fichier yaml au nom de l'utilisateur\n\t\[email protected] (@content[\"pseudo\"])\n\n\t\treturn self\n\tend", "def SetReg()\n if (@env==\"ORBIT\")\n allGroups.exec(\"iw reg set US\")\n end\n end", "def login gid, gurl\n @gamblers[gid] = gurl\n end", "def ligar #iniciando o método ligar\n puts 'O carro está ligado...' #imprime na tela a ação do método\n end", "def utiliser(unJoueur)\n\t\tunJoueur.incEndurance(@valeurED)\n\t\tunJoueur.incPointsDeVie(@valeurPV)\n\tend", "def create\n cour = Cour.find(params[:elefe][:ville_entrainement])\n u = current_user\n #info_ville = params[:elefe][:info_ville].join.to_i\n #params[:elefe][:info_ville] = info_ville\n # CAS DES FICHES EXISTANTES\n if @All_Eleves.exists?(:nom => params[:elefe][:nom], :prenom => params[:elefe][:prenom])\n @fiche_exist = @All_Eleves.find_by(:nom => params[:elefe][:nom], :prenom => params[:elefe][:prenom])\n params[:elefe][:info_ville] = params[:elefe][:info_ville].join(',') if params[:elefe][:info_ville] != nil\n params[:elefe][:prix] = @tarif[params[:elefe][:parentee].to_i] if params[:elefe][:parentee] != nil\n # Fusion de l'élève avec une fiche existante créée à partir des présences (officialisation)\n if !@fiche_exist.date_naissance\n puts \"On update eleve existant\"\n @elefe = @fiche_exist\n cours = @elefe.cours\n if !cours.detect { |b| b.id == cour.id }\n @elefe.cours << cour\n end\n u.eleves << @elefe\n u.commandes << Commande.create(description: 'Affiliation '+params[:elefe][:nom]+' '+params[:elefe][:prenom], montant: params[:elefe][:prix])\n @elefe.commandes << u.commandes.last\n respond_to do |format|\n if @elefe.update(elefe_params)\n format.html { redirect_to @elefe, notice: 'La fiche élève a bien été modifiée.' }\n format.json { render :show, status: :ok, location: @elefe }\n else\n format.html { render :edit }\n format.json { render json: @elefe.errors, status: :unprocessable_entity }\n end\n end\n else\n # Ne peut pas écraser une fiche existante\n redirect_back(fallback_location: :back, alert: 'Il existe déjà un élève inscrit avec le même nom et prénom. Peut-être pourriez-vous entrer un deuxième prénom pour vous différencier ?')\n end\n # CAS CLASSIQUE DE L'INSCRIPTION\n else\n params[:elefe][:info_ville] = params[:elefe][:info_ville].join(',') if params[:elefe][:info_ville] != nil\n params[:elefe][:prix] = @tarif[params[:elefe][:parentee].to_i] if params[:elefe][:parentee] != nil\n @elefe = Elefe.new(elefe_params)\n @elefe.cours << cour\n u.eleves << @elefe\n u.commandes << Commande.create(description: 'Affiliation '+params[:elefe][:nom]+' '+params[:elefe][:prenom], montant: params[:elefe][:prix])\n @elefe.commandes << u.commandes.last\n respond_to do |format|\n if @elefe.save\n format.html { redirect_to @elefe, notice: 'La fiche élève a bien été créée.' }\n format.json { render :show, status: :created, location: @elefe }\n else\n format.html { render :new }\n format.json { render json: @elefe.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def set_registrant\n @registrant = Registrant.find(params[:id])\n end", "def set_registrant\n @registrant = Registrant.find(params[:id])\n end" ]
[ "0.59939194", "0.5798812", "0.5716627", "0.5670351", "0.55467117", "0.54689956", "0.53533775", "0.53275794", "0.53203315", "0.53117484", "0.52975065", "0.52975065", "0.52827907", "0.5265971", "0.526555", "0.5250033", "0.5236853", "0.5216669", "0.5205916", "0.52012175", "0.5201147", "0.51992804", "0.51742965", "0.5165084", "0.51546997", "0.5150988", "0.5147588", "0.5141318", "0.51387423", "0.5136646", "0.5121148", "0.5081371", "0.50699776", "0.50656325", "0.50514036", "0.5046043", "0.50364965", "0.50364965", "0.5029761", "0.5022617", "0.50170904", "0.5008361", "0.4999945", "0.499073", "0.49878243", "0.49849167", "0.49554324", "0.49519923", "0.49473533", "0.49465758", "0.49461758", "0.4945382", "0.49446812", "0.49408835", "0.49368042", "0.49368042", "0.49368042", "0.49274313", "0.49226356", "0.49217945", "0.49156404", "0.49154645", "0.49106282", "0.49065077", "0.49058503", "0.49047148", "0.4896011", "0.4896011", "0.4896011", "0.4896011", "0.4896011", "0.4896011", "0.48931316", "0.48897213", "0.48863992", "0.48819494", "0.48734027", "0.48728147", "0.48686892", "0.48536226", "0.48471266", "0.4843654", "0.48385373", "0.48377407", "0.48340487", "0.48287076", "0.48200977", "0.48165458", "0.48118636", "0.48092306", "0.48087054", "0.4807335", "0.4806073", "0.48034403", "0.48021865", "0.48017123", "0.479353", "0.47849092", "0.47841668", "0.4783504", "0.4783504" ]
0.0
-1
Handles Format for Auth Methods
def redirect_auth(url) respond_to do |format| format.html do flash[:error] = "You do not have permission to view or modify this resource." redirect_to url end format.json do head :unauthorized end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_methods; end", "def auth\n end", "def auth\n end", "def auth(value); end", "def authenticate\n end", "def auth_param; end", "def auth(args)\r\n auth_method = args.fetch(:type, :standard)\r\n standard_auth(args) if auth_method == :standard\r\n end", "def authenticate_user\n case request.format\n when /text\\/html/\n redirect_to new_session_path unless current_user\n when /application\\/json/\n head :unauthorized unless current_user\n end\n\n end", "def authentication_type; end", "def process_auth\n return if username.empty? || password.empty?\n \"#{username}:#{password}\"\n end", "def http_auth?; end", "def authentication_type=(_arg0); end", "def allowed_auth_methods; end", "def auth\n if request.get?\n show_auth\n elsif request.post?\n check_auth\n end\n end", "def basic_auth(*args, &block); end", "def auth_scheme; end", "def valid_for_params_auth?; end", "def human_auth_method\n self[:auth_method].to_human\n end", "def Authentication\n call('', '')\n end", "def auth\n {}\n end", "def authorization; end", "def http_auth_login\n # FIXME: Implement\n end", "def capable_plain_auth?; end", "def oauth_authentication; end", "def raw_params(auth); end", "def valid_for_authentication?; end", "def valid_for_authentication?; end", "def authenticate(request, realm, &password_procedure); end", "def process_auth str\n if respond_to?(:authenticate)\n if @state.include?(:auth)\n reply 503, \"auth already issued\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n # There is a common misconception that the data has to be sent with the AUTH command\n @state << :auth_plain_incomplete\n reply 334, \"\"\n else\n # we got the initial response, so go ahead & process it\n process_auth_plain_line($')\n end\n elsif str =~ /\\ALOGIN\\s?/i\n if $'.length == 0\n @state << :auth_login_incomplete\n reply 334, \"VXNlcm5hbWU6\" # 'Username:' in Base64\n else\n process_auth_login_line($')\n end\n #elsif str =~ /\\ACRAM-MD5/i\n else\n reply 504, \"auth mechanism not available\"\n end\n else\n process_unknown\n end\n end", "def authentication_method\n super\n end", "def authenticate\n\t\t \tauthenticate_basic_auth || render_unauthorized\n\t\t \tend", "def http_auth_hash; end", "def valid_for_http_auth?; end", "def basic_auth(opts); end", "def authenticate\n# byebug\n return true if public_action?\n if request.format.json?\n authenticate_token || render_json_unauthorized\n else\n authenticate_user!\n end\n end", "def authenticate\n \n authenticate_token || render_unauthorized\n end", "def process_basic_auth(auth)\n case auth\n when String\n self.login, self.password = auth.split(':', 2)\n when Hash\n self.login = auth[:login]\n self.password = auth[:password]\n end\n end", "def authenticate\n\t\tauthenticate_token || render_unauthorized\n\tend", "def authenticate(request)\n\n end", "def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end", "def respond\n if http_auth?\n http_auth\n else\n redirect\n end\n end", "def token_auth(*args, &block); end", "def authenticate\n # puts _process_action_callbacks.map(&:filter)\n # if current_user\n # session['user_id'] = current_user.id\n # true\n # else\n # session[:return_to] = request.original_url\n # respond_to do |format|\n # format.html { redirect_to login_url }\n # format.any(:xml,:json) { request_http_basic_authentication }\n # end\n # false\n # end\n true\n end", "def authenticate!\n error!(\"401 Unauthorized\", 401) unless check_auth_token \n end", "def authorize\n end", "def authorize\n end", "def user_authentication\n end", "def capable_auth_types; end", "def authenticate\n case request.format\n when Mime::XML, Mime::JSON\n unless logged_in? && admin?\n authenticate_or_request_with_http_basic do |user_name, password|\n user_name == USER_NAME && password == PASSWORD\n end\n end\n else\n render_404 and return unless logged_in? && admin?\n end\n end", "def auth\r\n OAuth2\r\n end", "def with_authentication_hash(auth_type, auth_values); end", "def authenticate\n authenticate_token || render_unauthorized\n end", "def authenticate\n #render :text => params[:action]\n if (params[:controller] != \"api/sessions\")\n if (params[:controller] == \"api/users\" && params[:action] == \"create\")\n return\n end\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n if (params[:controller] == \"api/sessions\" && params[:action] == \"chekToken\")\n user = User.find_by(token: params[:token])\n if !user || user.valid_up < DateTime.now\n render json: '{\"error\":\"Unauthorized\"}', status: 401\n end\n end\n #\"controller\":\"users\",\"action\":\"show\",\"id\":\"login\" si se va a registrar dejar pasar\n #@product = '[{\"mytoken\":\"'+params[:token]+'\"}]'\n # if !User.find_by(token: params[:token])\n # #render json: '[{\"error\":\"Unauthorized\"}]', status: 401\n # end\n end", "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 params_auth_hash; end", "def process_basic_auth(auth)\n case auth\n when String\n self.username, self.password = auth.split(':', 2)\n when Hash\n self.username = auth[:username]\n self.password = auth[:password]\n end\n end", "def authenticate!\n # Do nothing yet\n end", "def authenticate\n authenticate_token || render_unauthorized\n end", "def authenticate!\n if (options = @config[:auth])\n auth_method = options.fetch(:type).to_s + '_auth'\n self.class.send(auth_method, options[:user], options[:password])\n end\n end", "def authenticate\n authenticate_token || render_unauthorized\nend", "def authenticate\n user_auth = AuthenticateUser.new(auth_params[:email],auth_params[:password])\n auth_token = user_auth.call\n\n if user_auth.check_student != \"student\"\n response = {message: Message.basic,user: auth_params[:email], auth_token: auth_token}\n\n else\n response = {message: Message.student, user: auth_params[:email], auth_token: auth_token }\n\n end\n json_response(response)\n end", "def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\[email protected] = @auth_file.authorization\n\t\tend\n\tend", "def auth_info\n render :action => 'auth_info.json', :layout => false\n end", "def method_auth_name\r\n method_info[:method_auth_name]\r\n end", "def authenticate\n authenticated_user = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { message: Message.logged_in, auth_token: authenticated_user[:auth_token], is_doctor: authenticated_user[:is_doctor], doctor_id: authenticated_user[:doctor_id], fullname: authenticated_user[:fullname], date_of_birth: authenticated_user[:date_of_birth] }\n json_response(response)\n end", "def authenticate\n # return if unauthorized?\n\n # render json: {\n # message: I18n.t('api.v1.error_messages.unauthorized')\n # }, status: :unauthorized\n end", "def authenticate(username, password)\n end", "def api_login\n creator = Creator.find_by(name: request.headers['name'])\n if creator && creator.authenticate(request.headers['password'])\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n selected_format({ error: 'Invalid username or password' },:unauthorized)\n end\n end", "def respond\n\t\tif http_auth?\n\t\t\t\thttp_auth\n\t\telse\n\t\t\t\tredirect\n\t\tend\n\tend", "def authenticate_name\n super\n end", "def authorization_mode; end", "def authenticate\n render json: { error: 'Access Denied' }, status: 401 unless current_user\n end", "def auth\n Hash['type' => @auth_type,\n 'username' => @user,\n 'password' => @password]\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\n #Hace el llamado de la clase AuthenticaUser, manda los parametros de :username y :password\n #Realiza el metodo call para obtener el Token del user_id\n #Arroja el token como Json_response\n auth_token = AuthenticateUser.new(auth_params[:username], auth_params[:password]).call \n json_response(auth_token: auth_token)\n end", "def authentication_hash=(_arg0); end", "def authenticate_user!\n puts \"request type is #{request.content_type}\"\n unless request.content_type == 'application/json' \n unless current_user\n flash[:alert] = \"Please login to continue.\"\n redirect_to new_user_session_path\n end\n end\n end", "def authenticate\n json_response(\n auth_token: AuthenticateUser.new(\n auth_params[:username],\n auth_params[:password]\n ).call\n )\n end", "def authorization(*args, &block); end", "def capable_login_auth?; end", "def http_auth_header?; end", "def active_for_authentication?; end", "def active_for_authentication?; 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 format_authentication_data(data)\n # return unless data.present?\n return if data.blank?\n response.headers.merge!(data[:headers]) if data[:headers].present?\n # return unless data[:body].present?\n return if data[:body].blank?\n render json: data[:body], status: status_for_response(data[:code])\n false\n end", "def process_auth str\n if @state.include?(:auth)\n send_data \"503 auth already issued\\r\\n\"\n elsif str =~ /\\APLAIN\\s?/i\n if $'.length == 0\n # we got a partial response, so let the client know to send the rest\n @state << :auth_incomplete\n send_data(\"334 \\r\\n\")\n else\n # we got the initial response, so go ahead & process it\n process_auth_line($')\n end\n #elsif str =~ /\\ALOGIN\\s+/i\n else\n send_data \"504 auth mechanism not available\\r\\n\"\n end\n end", "def api_auth\n\t\tauth ::UApi\n\tend", "def respond\n if http_auth?\n http_auth\n else\n flash.now[:alert] = i18n_message(:invalid) if is_flashing_format? && warden_options[:recall]\n redirect\n end\n end", "def authenticate_signin\n\t Client.authenticate(params[:email], params[:password]) || render_unauthorized\n\t end", "def authenticate(password)\n true\n end", "def credentials(authorization, request); end", "def auth\n {:basic_auth => {:username => id, :password => password}}\n end", "def authenticate!(via:)\n logger.info(\"Authenticating via #{via}\")\n\n case via\n when :jwt\n return jwt\n when false\n logger.info(\"Skipping authentication.\")\n else\n raise \"`#{via}` is an un-supported authentication scheme.\"\n end\n end", "def web_auth\n\t\tauth ::UWeb\n\tend", "def http_authenticatable?; end", "def uid_authenticate(format = :xml)\r\n\t\t\t# DO NOT SEND CALL IF YOU HAVE A VALID AUTH TOKEN\r\n\t\t\txml = \"<UIDAuthRequestMessage xmlns='http://www.ebscohost.com/services/public/AuthService/Response/2012/06/01'><UserId>#{@userid}</UserId><Password>#{@password}</Password></UIDAuthRequestMessage>\"\r\n\t\t\turi = URI \"#{API_URL_S}authservice/rest/uidauth\"\r\n\t\t\treq = Net::HTTP::Post.new(uri.request_uri)\r\n\t\t\treq[\"Content-Type\"] = \"application/xml\"\r\n\t\t\treq[\"Accept\"] = \"application/json\" #if format == :json\r\n\t\t\treq.body = xml\r\n\t\t\thttps = Net::HTTP.new(uri.hostname, uri.port)\r\n\t\t\thttps.read_timeout=10\r\n\t\t\thttps.use_ssl = true\r\n\t\t\thttps.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\t\t\tbegin\r\n\t\t\t doc = JSON.parse(https.request(req).body)\r\n\t\t\trescue Timeout::Error, Errno::EINVAL, Net::ReadTimeout, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\r\n\t\t\t about \"No response from server\"\r\n\t\t\tend\r\n\t\t\tif doc.has_key?('ErrorNumber')\r\n\t\t\t raise \"Bad response from server - error code #{result['ErrorNumber']}\"\r\n\t\t\telse\r\n\t\t\t @auth_token = doc['AuthToken']\r\n\t\t\tend\r\n\t\tend", "def allow_params_authentication!; end", "def auth_store; end", "def authenticate\n respond_to do |format|\n format.js { render nothing: true, status: 401 if current_user.nil? }\n format.html { redirect_to root_url if current_user.nil? }\n end\n end", "def parse(www_authenticate); end", "def authentication_request(controller, realm, message = T.unsafe(nil)); end" ]
[ "0.7273745", "0.7179859", "0.7179859", "0.71093464", "0.6862402", "0.68124276", "0.6776702", "0.67414236", "0.67325646", "0.6680244", "0.66417253", "0.66407377", "0.6520645", "0.64852357", "0.6469268", "0.6446972", "0.64343417", "0.64183044", "0.64117193", "0.6409074", "0.63935065", "0.6391819", "0.6366884", "0.63305277", "0.63194543", "0.62832355", "0.62832355", "0.6279494", "0.62794507", "0.62773836", "0.62730294", "0.6254956", "0.6250015", "0.6209742", "0.62060523", "0.62035066", "0.61985165", "0.6188537", "0.61879236", "0.6184779", "0.6184779", "0.6164981", "0.6163953", "0.6154883", "0.6146385", "0.6146385", "0.61430734", "0.61387473", "0.61376923", "0.6127741", "0.61252826", "0.61226624", "0.6118957", "0.6118727", "0.6104697", "0.6093543", "0.60817456", "0.6059596", "0.6042076", "0.6032296", "0.6025861", "0.6024234", "0.60217845", "0.6015387", "0.6013065", "0.60007495", "0.59914845", "0.5987417", "0.5981863", "0.59760165", "0.5973531", "0.59636605", "0.5944854", "0.59437126", "0.5931733", "0.59211284", "0.5908989", "0.59045786", "0.5900797", "0.5897412", "0.58957213", "0.589272", "0.589272", "0.58796376", "0.58776623", "0.5870122", "0.58637273", "0.5860526", "0.5851309", "0.5844507", "0.5839642", "0.58391786", "0.58325243", "0.5827629", "0.5824337", "0.5820362", "0.58149564", "0.5812417", "0.5806335", "0.5802353", "0.5796324" ]
0.0
-1
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) key_for_min=nil lowest_value=nil name_hash.each do |key,value| if lowest_value==nil || value<lowest_value lowest_value=value key_for_min=key end end key_for_min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |k, v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n smallest_value = nil\n smallest_key = nil\n hash.each do |name, num|\n if smallest_value == nil || num < smallest_value\n smallest_value = num\n smallest_key = name\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n min_val = Float::INFINITY\n min_key = nil\n hash.each do |key, value|\n if value < min_val\n min_val = value\n min_key = key\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n \n min_val = Float::INFINITY\n min_key = nil\n hash.each do |k, v|\n if min_val > v\n min_val = v\n min_key = k\n end\n end\n return min_key\nend", "def key_for_min_value(hash)\n smallest_key = nil\n tiny_value = nil\n hash.each do |key, value|\n if tiny_value == nil || value < tiny_value\n tiny_value = value\n smallest_key = key\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n smallest = nil\n key = nil\n hash.collect do |name, val|\n if smallest == nil || val < smallest\n smallest = val\n key = name\n end\n end\n key\nend", "def key_for_min_value(hash)\n int_hash = hash.select { |key, val| val.class == Fixnum }\n smallest = int_hash[int_hash.keys.sample]\n # debugger\n int_hash.each do |key, val|\n if val < smallest\n smallest = val \n end\n end\n int_hash.key(smallest)\nend", "def key_for_min_value(hash)\r\n smallest_key = nil\r\n tiniest_value = nil\r\n hash.each do |key, value|\r\n if tiniest_value == nil || value < tiniest_value\r\n tiniest_value = value\r\n smallest_key = key\r\n end\r\n end\r\n smallest_key\r\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = 0\n\n\n hash.each do |key,value|\n if lowest_value == 0 || value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n min = nil\n hash.each_pair do |key, value|\n min ||= value\n min = value if value < min\n end\n hash.key(min)\nend", "def key_for_min_value(hash)\n smallest = nil\n hash.each do |key, value|\n if smallest == nil\n smallest = key\n end\n if hash[key] < hash[smallest]\n smallest = key\n end\n end\n smallest\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k, v|\n if lowest_value == nil || v < lowest_value\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n smallest_key = nil\n tiniest_value = nil\n hash.each do |key, value|\n if tiniest_value == nil || value < tiniest_value\n \n # this way, the smallest value in the hash so far always overwrites the existing tiniest value\n \n tiniest_value = value\n smallest_key = key\n end\n end\n smallest_key\nend", "def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |key, value|\n if hash_value == nil || value < hash_value\n hash_value = value\n hash_key = key\n end\n end\n hash_key\nend", "def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n min_key = nil\n hash.each do |key, value|\n if min_key.nil?\n min_key = key\n elsif value < hash[min_key]\n min_key = key\n else\n next\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n min = 99999999\n min_key = nil\n hash.select do |key, value|\n if value < min\n min = value\n min_key = key\n end\n end\n min_key\nend", "def key_for_min_value(hash)\n if hash.empty?\n return nil\n end\n ans = [hash.first[0],hash.first[1]]\n hash.each do |k,v|\n if v < ans[1]\n ans[1] = v\n ans[0] = k\n end\n end\n return ans[0]\nend", "def key_for_min_value(hash)\n key = nil\n lowest_value = nil\n hash.each do |name, value|\n if lowest_value == nil || value < lowest_value\n lowest_value = value\n key = name\n end\nend\nkey\nend", "def key_for_min_value(hash)\n hash_key = nil\n hash_value = nil\n hash.each do |a, b|\n if hash_value == nil || b < hash_value\n hash_value = b\n hash_key = a\n end\n end\n hash_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil \n hash.each do |key, value|\n if lowest_value == nil || value < lowest_value \n lowest_value = value \n lowest_key = key \n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n lowestnum = 1000\n name_hash.each_value do |hashvalue|\n if hashvalue < lowestnum\n lowestnum = hashvalue\n end\n end\n name_hash.index(lowestnum)\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_number = nil\n name_hash.each do |name, number|\n if lowest_number == nil || number < lowest_number\n lowest_number = number\n lowest_key = name\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = nil\n hash.each do |k,v|\n # first iteration\n ## this creates a starting point for comparison\n if lowest_value == nil || lowest_value > v\n lowest_value = v\n lowest_key = k\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n low = Float::INFINITY\n name_hash.each do |k,v|\n if v < low\n low = v\n end\n end\n name_hash.key(low)\nend", "def key_for_min_value(hash)\n small_key = nil\n small_value = nil\n \n hash.each do |key, value|\n if small_value == nil || value < small_value\n small_value = value\n small_key = key\n end\nend\nsmall_key\nend", "def key_for_min_value(hash)\n low_min = 1000\n min_key = nil\n hash.each do |key, value|\n if(low_min > value)\n low_min = value\n min_key = key\n end\nend\n min_key\nend", "def key_for_min_value(name_hash)\n lowest = nil\n key = nil\n if name_hash.length == 0\n return \n end\n \n name_hash.each do |name, number|\n if lowest == nil\n lowest = number\n end\n if key == nil\n key = name\n end\n if number < lowest\n lowest = number\n key = name\n end\n end\n key\nend", "def key_for_min_value(hash)\n least_value = nil \n least_key = nil\n hash.each do |a, b|\n if least_value == nil || b < least_value\n least_value = b\n least_key = a\n end\n end\n least_key\nend", "def key_for_min_value(name_hash)\n\tif name_hash == {}\n\t\tnil\n\tend\n\n\tsmallest_key = nil\n\tsmallest_value = nil\n\tname_hash.each do |key, value|\n\t\tif !smallest_value || value < smallest_value\n\t\t\tsmallest_key = key\n\t\t\tsmallest_value = value\n\t\tend\n\tend\n\tsmallest_key\nend", "def key_for_min_value(hash)\n i = 0\n lowest1 = :key\n lowest = 0\n if hash.empty? == true \n return nil\n end\n hash.each do |name, value|\n if i == 0\n lowest1 = name\n lowest = value\n i =+ 1\n end\n if value < lowest\n lowest1 = name\n lowest = value\n end\n if hash.empty? == true \n lowest1 = nil\n end\n end\n lowest1\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |name, amount|\n if amount < lowest_value\n lowest_value = amount\n lowest_key = name\n end\n end\n lowest_key\n end", "def key_for_min_value(hash)\n lo_key = nil \n lo_value = nil \n hash.each do |k,v| \n if lo_key == nil || v < lo_value\n lo_key = k \n lo_value = v \n end \n end \n lo_key\n end", "def key_for_min_value(hash)\n\n lowest_key = nil \n lowest_value = nil \n \n hash.each do |key,value|\n if lowest_value == nil || lowest_value > value\n\n lowest_key = key\n lowest_value = value \n end \n \n end \n lowest_key\nend", "def key_for_min_value(name_hash)\n small_num = Float::INFINITY\n smallest_key = \"\"\n if name_hash.length == 0\n return nil\n end\n name_hash.each do |key, value|\n if value < small_num\n small_num = value\n smallest_key = key\n end\n end\nsmallest_key\nend", "def key_for_min_value(hash)\n value_only_array = []\n hash.each_pair do |key, value|\n value_only_array << value\n end\n value_only_array.sort!\n hash.key(value_only_array[0])\nend", "def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect {|key, value| value}.sort\n hash.each {|key, value| return key if value == arr[0]}\nend", "def key_for_min_value(hash)\n array = []\n hash.each do |key, value|\n array << value\n end\n array.sort!\n hash.key(array[0])\nend", "def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_value=Float::INFINITY\n name_hash.each{|key, value| \n if value<lowest_value\n lowest_value=value\n lowest_key=key\n end\n }\n lowest_key\nend", "def key_for_min_value(name_hash)\n empty_hash = nil\n lowest_value = 10000000000000000000000\n name_hash.collect do |name, value|\n if value < lowest_value\n lowest_value = value\n empty_hash = name\n end\n end\n empty_hash\nend", "def key_for_min_value(name_hash)\n lowest = \"\"\n lowest = nil if name_hash.empty?\n high_num = 100000000000000000\n name_hash.each do | key, value |\n lowest = key if value < high_num\n high_num = value if value < high_num\n end\n lowest\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name, num|\n if lowest_key == nil || num < lowest_value\n lowest_key = name\n lowest_value = num\n elsif name_hash == nil\n nil\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n num = nil\n name_hash.collect do |key, value|\n if value < num\n num = value\n end\n end \n name_hash.key(num)\nend", "def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = nil\n name_hash.each do|key, val|\n if smallest_val == 0 || val < smallest_val\n smallest_val = val\n smallest_key = key\n end\n end\n smallest_key\n\nend", "def key_for_min_value(name_hash)\n smallest_hash_key = nil\n name_hash.each do |key, val|\n if smallest_hash_key == nil\n smallest_hash_key = key\n next\n elsif val < name_hash[smallest_hash_key]\n smallest_hash_key = key\n end\n end\n smallest_hash_key\nend", "def key_for_min_value(hash)\n if hash.count < 2\n return hash[0]\n else \n num = 42\n hash.each do |key, value|\n if value <= num\n num = value\n end\n end\n hash.invert[num] \n end\nend", "def key_for_min_value(name_hash)\n return nil if name_hash.empty?\n lowest_number = name_hash.first[1];\n key_value = \"\"\n name_hash.each do |key, value|\n if value <= lowest_number\n lowest_number = value\n key_value = key\n end\n end\n key_value\nend", "def key_for_min_value(name_hash)\n current = 0\n lowest = 0\n lowest_key = nil\n name_hash.collect do |key, value|\n current = value\n if current < lowest || lowest == 0\n lowest = current\n lowest_key = key\n end\n\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowestvalue = 1000\n name_hash.each do |name, value|\n if value < lowestvalue\n lowest_key = name\n lowestvalue = value\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n small_value = 10000000000\n small_key = nil\n name_hash.each do |k,v|\n if v < small_value\n small_value = v\n small_key = k\n end\n end\n small_key\nend", "def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |k, v|\n if low_value == nil || v < low_value\n low_value = v\n low_key = k\n end\n end\n low_key\n end", "def key_for_min_value(hash)\n lowest_value = nil\n lowest_key = nil\n\n hash.each do |key, value|\n if lowest_value == nil # tell me if this makes sense\n lowest_value = value\n lowest_key = key\n elsif lowest_value > value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key #you want to return the key for min\nend", "def key_for_min_value(hash)\n \n if hash.empty?\n return nil\n end\n min_value=500\n min_key=:symbol\n \n hash.each do |key, value|\n if value<min_value\n min_value=value\n min_key=key\n end\n end\n return min_key\nend", "def key_for_min_value(name_hash)\n lowestKey = nil\n lowestValue = Float::INFINITY\n name_hash.each do |k, v|\n if v < lowestValue\n lowestValue = v\n lowestKey = k\n end\n end\n lowestKey\n\nend", "def key_for_min_value(name_hash)\n smallest_val = 0\n smallest_key = 0\n comp = nil\n name_hash.each do |key,val|\n comp = val\n if smallest_key == 0\n smallest_key = key\n smallest_val = val\n end \n if comp < smallest_val\n smallest_val = comp\n smallest_key = key\n end\n end\n if smallest_key == 0 \n return nil \n else\n return smallest_key\n end\nend", "def key_for_min_value(name_hash)\n lowest_key=nil\n lowest_val=0\n name_hash.collect do |key,value|\n if value<lowest_val or lowest_val==0\n lowest_key=key\n lowest_val=value\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n smallest = nil\n this_num = 0\n previous_num = 1000000\n name_hash.collect { |item, qty|\n this_num = qty\n if this_num < previous_num\n smallest = item\n previous_num = this_num\n end\n }\n smallest\nend", "def key_for_min_value(name_hash)\n rkey = nil\n rvalue = 10000000000000000\n name_hash.each do |key, value|\n if value < rvalue\n rkey = key\n rvalue = value\n end\n end\n rkey\nend", "def key_for_min_value(name_hash)\n\tsmallest_value = nil\n\tassociated_key = nil \n\tname_hash.collect do |key, value|\n\t\tif smallest_value == nil || value < smallest_value\n\t\t\tsmallest_value = value \n\t\t\tassociated_key = key\n\t \tend\n\tend\n\tassociated_key\nend", "def key_for_min_value(hash)\n # binding.pry\n lowest_key = nil\n lowest_value = 0\n # binding.pry\n hash.each do |key, value|\n if lowest_key == nil || value < lowest_value\n # binding.pry\n lowest_value = value\n lowest_key = key\n # binding.pry\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n hash.key(hash.values.min)\nend", "def key_for_min_value(hash)\n hash.key(hash.values.min)\nend", "def key_for_min_value(name_hash)\n smallest_value = 100\n name_hash.each do |key, value| \n if value < smallest_value\n smallest_value = value \n end \n end\n name_hash.key(smallest_value)\nend", "def key_for_min_value(name_hash)\n lowest=\"\"\n lowest=nil if name_hash.empty?\n tracker=100000000\n name_hash.each do |key,value|\n lowest=key if value<tracker\n tracker=value if value<tracker\n # if value<tracker\n end\n lowest\nend", "def key_for_min_value(name_hash)\n if name_hash.length == 0 \n nil\n else\n smallest_num = nil\n smallest_num_key = nil\n name_hash.collect do |key, value|\n if smallest_num == nil\n smallest_num = value\n smallest_num_key = key\n elsif smallest_num > value\n smallest_num = value\n smallest_num_key = key\n end\n end\n smallest_num_key\n end\n\nend", "def key_for_min_value(name_hash)\n low_key = nil\n low_value = nil\n name_hash.each do |n, s|\n if low_value == nil\n low_value = s\n low_key = n\n elsif low_value > s\n low_value = s\n low_key = n\n end\n end\n low_key\nend", "def key_for_min_value(name_hash)\n return nil if name_hash == nil || name_hash == {}\n number_array = name_hash.collect do |name, number|\n number\n end\n number_array.sort!\n name_hash.key(number_array[0])\nend", "def key_for_min_value(name_hash)\n lowestId = nil\n lowestNum = 0\n name_hash.each{ |id, val|\n if lowestNum == 0 \n lowestNum = val\n end\n if val <= lowestNum\n lowestNum = val\n lowestId = id\n end\n }\n return lowestId\nend", "def key_for_min_value(name_hash)\n lowest_v = nil\n lowest_k = nil\n name_hash.each do |name, value|\n if lowest_v == nil\n lowest_v = value\n lowest_k = name\n elsif value < lowest_v\n lowest_v = value\n lowest_k = name\n end\n end\n lowest_k\n end", "def key_for_min_value(name_hash)\n smallest_key = nil\n smallest_value = nil\n name_hash.each do |j, r|\n if smallest_value == nil || r < smallest_value\n smallest_value = r\n smallest_key = j\n end\n end\n smallest_key\nend", "def key_for_min_value(name_hash)\nlowest = 1000000\n low_key = nil\n name_hash.each {|key, value|\n if value < lowest\n lowest = value\n low_key = key\n end\n }\n low_key\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n name_hash.each_key do |key|\n if lowest_key == nil\n lowest_key = key\n elsif name_hash[key] < name_hash[lowest_key]\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n\n if name_hash.empty?\n return nil\n end\n lowest = Float::INFINITY\n name_hash.each_pair do |k, v|\n if v < lowest\n lowest = v\n end\n end\n name_hash.each_pair do |k, v|\n if v == lowest\n return k\n end\n end\nend", "def key_for_min_value(name_hash)\n output = 0\n smallest = nil\n name_hash.map do |key, value|\n if value < output || output == 0\n output = value\n smallest = key\n end\n end\n\n smallest\nend", "def key_for_min_value(my_hash)\n #what is my value?\n lowest_value = 500\n lowest_key = nil\n\n my_hash.collect do |key, value|\n # what is my value?\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(name_hash)\n lowest_num = 1000000000\n lowest_num_key = \" \"\n if name_hash == {}\n return nil\n else\n name_hash.each do |name, num|\n if num < lowest_num\n lowest_num = num\n lowest_num_key = name\n end\n end\n return lowest_num_key\n end\nend", "def key_for_min_value(name_hash)\n nums = name_hash.collect do |item, num|\n num\n end\n nums.sort!\n nums[0]\n \n min_key = nil\n name_hash.map do |item, num|\n if num == nums[0]\n min_key = item\n end\n end\n min_key\nend", "def key_for_min_value(name_hash)\n vals = name_hash.collect { |key, value| value }\n keys = name_hash.collect { |key, value| key }\n low = vals[0]\n lowkey = keys[0]\n if name_hash.empty?\n nil\n else\n name_hash.collect do |key, value|\n if value < low\n low = value\n lowkey = key\n end\n end\n lowkey\n end\nend", "def key_for_min_value(name_hash)\n value1 = 0\n lowestKey = nil\n name_hash.each do |key, value|\n if(value1 == 0)\n value1 = value\n lowestKey = key\n end\n if(value1 > value)\n value1 = value\n lowestKey = key\n elsif (value1 < value)\n lowestKey = lowestKey\n value1 = value1\n end\n end\n return lowestKey\nend", "def key_for_min_value(hash)\n return nil if hash.empty?\n arr = hash.collect { |k, v| v }.sort\n hash.each { |k, v| return k if v == arr[0] }\nend", "def key_for_min_value(name_hash)\n # saves the smaller value in memo, and takes the first elem of memo at the end (the key)\n smallest = name_hash.inject do|memo, (k, v)|\n memo = v < memo[1] ? [k,v] : memo\n end\n #handle the empty hash case...\n smallest ? smallest[0] : nil\nend", "def key_for_min_value(name_hash)\n key = \"\"\n low_value = nil\n if name_hash.empty? == true\n return nil\n end\n name_hash.each do |name, number|\n if low_value == nil || number < low_value\n low_value = number\n key = name\n end\n end\n key\nend", "def key_for_min_value(name_hash)\n answer = nil\n smallest = nil\n name_hash.each {|key, value|\n if smallest.nil?\n smallest = value\n end\n if value <= smallest\n smallest = value\n answer = key\n end\n }\n answer\nend", "def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v]\n\t\tend\n\t\treturn temp.key(temp.each_value.min)\n\tend", "def key_for_min_value(name_hash)\n lowest_value = 0\n lowest_key = \"\"\n if name_hash.empty? == true\n nil\n else\n name_hash.each_with_index do |(key, value), i|\n if i == 0\n lowest_value = value\n lowest_key = key\n elsif value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\n end\nend", "def key_for_min_value(name_hash)\n low=10000000000000000000\n return_key=nil\n name_hash.each do |key, value|\n if value<low\n low=value\n return_key=key\n end\n end\n return_key\nend", "def key_for_min_value(hash)\n if hash.length == 0\n return nil\n else\n smallest = 1000\n printme = \"\"\n hash.each do |thing, number|\n if number < smallest\n smallest = number\n printme = thing\n end\n end\n printme\n end\nend", "def key_for_min_value(name_hash)\n \n lowest_key = nil\n lowest_value = nil\n name_hash.each do |name_key, name_value|\n if lowest_value == nil || name_value < lowest_value\n lowest_value = name_value\n lowest_key = name_key\n end\n end\n lowest_key\n \n end", "def key_for_min_value(name_hash)\n the_key = nil \n the_value = 1/0.0\n # Infinity...can also be expressed as FLOAT::Infinity\n name_hash.each do |id, num|\n if num <= the_value\n the_value = num\n the_key = id\n end\n end\n the_key\nend", "def key_for_min_value(hash)\n array = []\n hash.each {|key,value| \n if array.empty? || value < array[1] \n array[0] = key \n array[1] = value \n end }\n if !array.empty? \n array.first \n else \n nil \n end\nend", "def key_for_min_value(name_hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n name_hash.each do |k,v|\n if v < lowest_value\n lowest_value = v\n lowest_key = k\n end \nend\nlowest_key\nend", "def key_for_min_value(name_hash)\n return nil if name_hash == {}\n smallest_key = name_hash.first[0]\n smallest_val = name_hash.first[1]\n\n name_hash.each do |pair|\n if pair[1] < smallest_val\n smallest_key = pair[0]\n end\n end\n smallest_key\nend", "def key_for_min_value(name_hash)\n key_of_smallest_value = \"\"\n smallest_value = 99999\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_of_smallest_value = key\n end\n end\n if name_hash.size == 0\n key_of_smallest_value = nil\n end\n key_of_smallest_value\nend", "def key_for_min_value(name_hash)\n smallest_value = Float::INFINITY\n key_for_smallest_val = nil\n name_hash.each do |key, value|\n if smallest_value > value\n smallest_value = value\n key_for_smallest_val = key\n end \n end \n key_for_smallest_val\nend", "def key_for_min_value(name_hash)\n minKey = nil\n minVal = 2 ** (64 - 2) - 1\n name_hash.each {|key, value|\n if value < minVal\n minVal = value\n minKey = key\n end}\n minKey\nend", "def key_for_min_value(name_hash)\n if name_hash == {}\n return nil\n end\n lowest_number = nil\n name_hash.collect do |name, value|\n if lowest_number == nil\n lowest_number = value\n elsif lowest_number > value\n lowest_number = value\n end\n end\n \n name_hash.each do |name, value|\n if lowest_number == value\n return name\n end\n end\nend", "def key_for_min_value(hash)\n min_value = hash.values.min\n keys = hash.collect do |key, num|\n \tkey if num == min_value\n end\n keys\nend", "def key_for_min_value(name_hash)\n lowest_value = nil\n key_value = nil\n name_hash.collect do |name, number|\n if lowest_value == nil || number < lowest_value\n lowest_value = number\n key_value = name\n end\n end\n key_value\nend", "def key_for_min_value(name_hash)\n smallest_value = 1/0.0\n key_of_smallest_value = nil\n name_hash.each do |key, value|\n if smallest_value > value\n key_of_smallest_value = key\n smallest_value = value\n end\n end\n return key_of_smallest_value\nend" ]
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585", "0.84359556", "0.84328413", "0.8430745", "0.8428166", "0.84090126", "0.8388222", "0.83684903", "0.83568215", "0.83524764", "0.8345625", "0.8343887", "0.8328773", "0.83284044", "0.83269894", "0.83253354", "0.83201903", "0.83164364", "0.8312503", "0.8312319", "0.8304851", "0.83014053", "0.83008987", "0.82917446", "0.8288315", "0.82870966", "0.8274123", "0.82674986", "0.8267187", "0.82527804", "0.8250538", "0.82443976", "0.82439804", "0.8243696", "0.82416916", "0.8240566", "0.823854", "0.82375354", "0.82283455", "0.82274485", "0.82205135", "0.82190055", "0.82136935", "0.82136935", "0.82102376", "0.82101446", "0.82060164", "0.8200657", "0.81985617", "0.81966525", "0.81958514", "0.81932545", "0.81874573", "0.8186549", "0.8185174", "0.8183619", "0.8183068", "0.8182941", "0.8179895", "0.8173536", "0.81732464", "0.8172825", "0.81721044", "0.8171692", "0.81681263", "0.8165602", "0.81609225", "0.8160289", "0.81587887", "0.815757", "0.8154019", "0.81534094", "0.8152752", "0.81524456", "0.8151455", "0.81511825", "0.8151019", "0.8146792", "0.814368", "0.8142542", "0.81412685" ]
0.0
-1
Checks the response status of the linked_url and stores it on the ok or broken collections
def check_status(linked_url, from_url) if @broken.keys.include?(linked_url) # This was already known to be broken, we add another origin @broken[linked_url] << from_url else if [email protected]?(linked_url) # We still don't know about this link status, so we check it now if reachable?(linked_url) @ok << linked_url else @broken[linked_url] = [from_url] end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def urls_failed\n\t\t\[email protected]{|u| not u.success}\n\t\tend", "def checkError\n status = Array.new\n if params[:offset]\n if params[:limit] != \"\"\n urlMasters = Urlmaster.limit(params[:limit].to_i).offset(params[:offset].to_i)\n else\n urlMasters = Urlmaster.offset(params[:offset].to_i)\n end\n else\n if params[:limit] != \"\"\n urlMasters = Urlmaster.limit(params[:limit].to_i).offset(0)\n else\n redirect_to crawler_path\n urlMasters = Urlmaster.all\n end\n end\n\n message = Array.new\n for url in urlMasters \n if url[\"venueFloorMapImageUrl\"] && url[\"venueFloorMapImageUrl\"] != \"NA\" && url[\"venueFloorMapImageUrl\"] != \"\"\n uri = URI(url[\"venueFloorMapImageUrl\"])\n begin \n res = Net::HTTP.get_response(uri)\n status << res.code\n message << url[\"venueFloorMapImageUrl\"] + res.code\n u = Urlmaster.find(url.id)\n u.update(:statusCode => res.code)\n rescue => e\n next\n end\n end\n if url[\"venueFloorMapUrl\"] && url[\"venueFloorMapUrl\"] != \"NA\" && url[\"venueFloorMapUrl\"] != \"\"\n uri = URI(url[\"venueFloorMapUrl\"])\n begin \n res = Net::HTTP.get_response(uri)\n status << res.code\n message << url[\"venueFloorMapUrl\"] + res.code\n u = Urlmaster.find(url.id)\n u.update(:statusCodeWeb => res.code)\n rescue => e\n next\n end\n end\n end\n flash[:success] = \"Refresh successfully!\"\n render :json => message\n end", "def urls_passed\n\t\t\[email protected]{|u| u.success}\n\t\tend", "def add_valid_url(url, refs)\n @results[url] = 1\n end", "def add_valid_url(url, refs)\n @results[url] = 1\n end", "def check_url_status(url)\n begin\n conn = Faraday.new(:url => url)\n response = conn.get\n rescue Faraday::ConnectionFailed => e\n return \"Unknown. Requires attention.\"\n else\n statusNum = response.status\n puts case statusNum\n when 200\n return \"200: Online\"\n when 201\n return \"201: Created\"\n when 204\n return \"204: No Content\"\n when 301\n return \"301: Moved Permanantly\"\n when 302\n return \"302: Redirecting\"\n when 304\n return \"304: Not Modified\"\n when 400\n return \"400: Bad Request\"\n when 401\n return \"401: Unauthorized\"\n when 403\n return \"403: Access Forbidden\"\n when 404\n return \"404: Not Found\"\n when 409\n return \"409: Conflict\"\n when 500\n return \"500: Internal Server Error\"\n else\n return \"Status code: #{statusNum}\"\n end\n\n end\n end", "def check_http_status(href)\n url = href.split(\".com/\")\n response = nil\n Net::HTTP.start(url[0].split(\"https://\").last + \".com\", 80) {|http|\n response = http.head(\"/\" + url[1])\n }\n if(response.code != \"200\")\n fail(href + \" returned code: \" + response.code)\n end\nend", "def check_downloads\n @download_manager.done.each do |wrapper, download|\n entry = wrapper.entry\n receiver = wrapper.receiver\n if download.error?\n entry.status.error!(download.message)\n @link_table.update(entry)\n elsif download.successful?\n result = download.result\n if receiver.add(result[:url], result[:name], result[:cookies])\n download.change_status(:success, nil, \"added to #{receiver.name}\")\n else\n download.change_status(:error, nil, \"could not add URL to #{receiver.name}\")\n end\n end\n end\n end", "def check_hash_in_2xx_response(href, url, response, filenames)\n return false if @runner.options[:only_4xx]\n return false unless @runner.options[:check_external_hash]\n return false unless url.hash?\n\n hash = url.hash\n headers = response.options.fetch(:headers, {})\n content_type = headers.find { |k, _| k.casecmp(\"content-type\").zero? }\n\n # attempt to verify PDF hash ref; see #787 for more details\n # FIXME: this is re-reading the PDF response\n if content_type && content_type[1].include?(\"pdf\")\n io = URI.parse(url.to_s).open\n reader = PDF::Reader.new(io)\n\n pages = reader.pages\n if hash =~ /\\Apage=(\\d+)\\z/\n page = Regexp.last_match[1].to_i\n\n unless pages[page - 1]\n msg = \"External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not\"\n add_failure(filenames, msg, response.code)\n @cache.add_external(href, filenames, response.code, msg, false)\n end\n\n return true\n end\n end\n\n body_doc = create_nokogiri(response.body)\n\n unencoded_hash = Addressable::URI.unescape(hash)\n xpath = [%(//*[@name=\"#{hash}\"]|/*[@name=\"#{unencoded_hash}\"]|//*[@id=\"#{hash}\"]|//*[@id=\"#{unencoded_hash}\"])]\n # user-content is a special addition by GitHub.\n if url.host =~ /github\\.com/i\n xpath << [%(//*[@name=\"user-content-#{hash}\"]|//*[@id=\"user-content-#{hash}\"])]\n # when linking to a file on GitHub, like #L12-L34, only the first \"L\" portion\n # will be identified as a linkable portion\n xpath << [%(//td[@id=\"#{Regexp.last_match[1]}\"])] if hash =~ /\\A(L\\d)+/\n end\n\n return unless body_doc.xpath(xpath.join(\"|\")).empty?\n\n msg = \"External link #{href} failed: #{url.without_hash} exists, but the hash '#{hash}' does not\"\n add_failure(filenames, msg, response.code)\n @cache.add_external(href, filenames, response.code, msg, false)\n true\n end", "def check(uri,res)\r\n @results[:checked][uri]=true\r\n if res.code==\"404\"\r\n @results[:uris404] << uri\r\n return []\r\n elsif res.code==\"200\"\r\n @results[:uris200] << uri\r\n if uri.host != @baseURI.host or res['content-type'] != 'text/html'\r\n \t return []\r\n end\r\n links = @linkfinder.getLinks(res.body)\r\n [email protected](links,uri)\r\n returnedLinks=[]\r\n links.each {|link| \r\n if link.scheme != \"http\"\r\n\t @results[:urisNonHTTP] << link\r\n\telse\r\n\t if not @results[:checked].include? link\r\n @results[:checked][link]=true\r\n returnedLinks << link\r\n end\r\n\tend\r\n }\r\n return returnedLinks\r\n else\r\n @results[:urisUnknown] << {:code => res.code, :uri => uri}\r\n end\r\n return []\r\n end", "def push_error_result(link, status)\n info = {\n :name => :unknown,\n :size => 0,\n :hoster => :unknown,\n :status => status\n }\n resolvable = Plowshare::Resolvable.new(link, info)\n @results << resolvable\n end", "def check_hash_in_2xx_response(href, effective_url, response, filenames)\n return if @options[:only_4xx]\n return unless @options[:check_external_hash]\n return unless (hash = hash?(href))\n\n body_doc = create_nokogiri(response.body)\n\n # user-content is a special addition by GitHub.\n xpath = %(//*[@name=\"#{hash}\"]|//*[@id=\"#{hash}\"])\n if URI.parse(href).host.match(/github\\.com/i)\n xpath << %(|//*[@name=\"user-content-#{hash}\"]|//*[@id=\"user-content-#{hash}\"])\n end\n\n return unless body_doc.xpath(xpath).empty?\n\n add_external_issue filenames, \"External link #{href} failed: #{effective_url} exists, but the hash '#{hash}' does not\", response.code\n end", "def link_attempt_status\n RestClient.get link\n rescue RestClient::Unauthorized, RestClient::Forbidden => e\n \"access denied\"\n rescue RestClient::RequestTimeout\n \"timeout\"\n rescue RestClient::SSLCertificateNotVerified\n \"SSL certificate not verified\"\n rescue RestClient::Exception\n \"invalid or unresponsive\"\n else\n \"ok\"\n end", "def status\n return false if [email protected]?(200)\n \n true\n end", "def check_response\n errors.add(:base, :invalid) unless response.present? && response[\"res\"] == 1\n end", "def check_response!\n body[:stat] == 'ok' || fail(ClientError, \"#{ body.inspect }\")\n end", "def url_exist?\n\t\tbegin\n\t\t\turi = URI.parse(valid_url?)\n\t\t\tresponse = Net::HTTP.get_response(uri)\n\t\trescue \n\t\t\terrors.add(:long_url,\"is invalid url\")\n\t\t\t# in AR, error is a class by itself already \n\t\t\t# go to static.rb to check the errors\n\t\tend\n\tend", "def assess\n @error = false\n begin\n response_code = get_http_response_code(@referer)\n rescue\n Flying.an_error_ocurred(true)\n set_error_message(@referer, false, $!)\n return false\n end\n return true if [\"200\", \"302\"].include? response_code\n Flying.an_error_ocurred(true)\n set_error_message(@referer, response_code.to_s)\n false\n end", "def check_response(response)\n case response\n when Net::HTTPSuccess then\n #puts response\n when Net::HTTPRedirection then\n location = response['location']\n warn \"redirected to #{location}\"\n fetch(location, limit - 1)\n else\n puts response.value\n end\nend", "def get_response(url)\n\t\t\t\t\t\tres_flag = false\n\t\t\t\t\t\t\t\tresponse = RestClient.get(url){|response, request, result| response \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif response.code != 200\n\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\tputs response.code\n\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\tres_flag = true\n\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\t\t\t\t\tputs \"Skipped due to #{response.code}\"\n\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\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn res_flag\nend", "def valid?\n status == 200\n end", "def perform\n if url_needed?\n # We need to follow any redirects from the current url.\n # The final (non-redirected) location will become our URL, and any\n # URLs that redirected along the way (including the first) become our aliases\n # NB Only the original URL is guaranteed not to be redundant, either in another page_ref\n # or an alias. If it's the latter, we capture the alias. If we can't adopt the URL without\n # clashing with another page_ref, we assign it to MercuryResult and Gleaning and give up.\n # Check the header for the url from the server.\n # If it's a string, the header returned a redirect\n # otherwise, it's an HTTP code\n puts \"Checking direct access of PageRef ##{id} at '#{url}'\"\n subject_url = url\n # Loop over the redirects from the link, adding each to the record.\n # Stop when we get to the final page or an error occurs\n while (hr = header_result(subject_url)).is_a?(String) # ...because redirect\n # header_result returns a string for a redirect\n next_url = hr.match(/^http/) ? hr : safe_uri_join(subject_url, hr).to_s # The redirect URL may only be a path\n if !Alias.urleq(subject_url, next_url) && alias_for?(next_url) # Time to give up when the url has been tried (it already appears among the aliases)\n # Report the error arising from direct access\n hr = header_result next_url\n break\n end\n puts \"Redirecting from #{subject_url} to #{next_url}\"\n alias_for subject_url, true\n subject_url = next_url\n end\n accept_attribute :url, subject_url\n hr # Return the last error code\n end\n\n # Now that we have a url, move on to the mercury_result and the gleaning\n mercury_result.ensure_attributes # Block until mercury_result has completed and accepted its attributes\n if mercury_result.good? # All is well\n accept_url mercury_result.url if mercury_result.url_ready?\n if mercury_result.new_aliases_ready? && mercury_result.new_aliases.present?\n new_aliases = mercury_result.new_aliases.collect { |url| Alias.indexing_url url }\n # Create a new alias on this page_ref for every derived alias that isn't already in use\n (new_aliases - aliases.pluck(:url)).each { |new_alias| alias_for new_alias, true }\n end\n elsif mercury_result.bad?\n errors.add :url, \"can\\'t be accessed by Mercury: #{mercury_result.errors[:base]}\"\n end\n self.http_status = mercury_result.http_status\n\n gleaning.ensure_attributes # Block until gleaning has completed and accepted its attributes\n if gleaning.good?\n accept_url gleaning.url if gleaning.url_ready?\n elsif gleaning.bad?\n errors.add :url, \"can\\'t be gleaned: #{gleaning.errors[:base]}\"\n end\n\n if errors[:url].present?\n url_errors = errors[:url].join \"\\n\"\n if relaunch?\n raise url_errors # ...to include the errors and relaunch\n else\n errors.add :base, url_errors # ...to simply include the errors in the record\n end\n end\n\n end", "def test_outbound_link\r\n checker=ConsistencyChecker.new(\r\n @linkfinder,\r\n uriFromTest(\"url_retriever/test.htm\")\r\n )\r\n res=newResponse :body=> <<EOF\r\n<html>\r\n<head>\r\n<title>Consistency checker -- foreign domain test</title>\r\n</head>\r\n<body>\r\n<p>This is an example.com domain.</p>\r\n<a href=\"testB.htm\">Test 2</a>\r\n</body>\r\n</html>\r\nEOF\r\n links=checker.check(URI(\"http://www.example.com\"),res)\r\n assert links.empty?\r\n end", "def link_is_existent?(url)\n \tbegin\n\t uri = URI.parse(url)\n \t http_conn = Net::HTTP.new(uri.host, uri.port)\n \t resp, data = http_conn.head(\"/\" , nil)\n \t puts \"=== RESPONSE CODE #{resp.code}\"\n \t resp.code != \"404\"\n \trescue URI::InvalidURIError, Errno::ECONNREFUSED, SocketError\n \t\tfalse\n \tend\n end", "def fetched?\n 200 == code\n end", "def check\n @task.log \"# #{@site.name}\"\n\n @base_url = @site.full_url.sub(/^(https?:\\/\\/.*?\\/).*/, '\\\\1')\n\n @urls = { @site.url => %w(Site) }\n @results = {}\n @errors = {}\n\n @html_request_timeout = SS.config.cms.check_links[\"html_request_timeout\"] rescue 10\n @head_request_timeout = SS.config.cms.check_links[\"head_request_timeout\"] rescue 5\n\n (10*1000*1000).times do |i|\n break if @urls.blank?\n url, refs = @urls.shift\n # @task.log url\n check_url(url, refs)\n @task.count\n end\n\n msg = [\"[#{@errors.size} errors]\"]\n @errors.map do |ref, urls|\n ref = File.join(@base_url, ref) if ref[0] == \"/\"\n msg << ref\n msg << urls.map do |url|\n url = File.join(@base_url, url) if url[0] == \"/\"\n \" - #{url}\"\n end\n end\n msg = msg.join(\"\\n\")\n\n @task.log msg\n\n if @email.present?\n ActionMailer::Base.mail(\n from: \"shirasagi@\" + @site.domain.sub(/:.*/, \"\"),\n to: @email,\n subject: \"[#{@site.name}] Link Check: #{@errors.size} errors\",\n body: msg\n ).deliver_now\n end\n\n unset_errors_in_contents\n @errors.map do |ref, urls|\n urls = urls.map { |url| (url[0] == \"/\") ? File.join(@base_url, url) : url }\n set_errors_in_contents(ref, urls)\n end\n head :ok\n end", "def set_url_status\n self.update_attribute(:dead, true) unless self.url_active?\n end", "def handle_resp!(resp)\n case resp\n when '201', '202'\n [ true, resp ]\n else\n [ false, resp ]\n end\n end", "def status\n @logger.info \"Checking status of #{@url}\"\n @stubbornly.retry(timeout: 10, attempts: 4) do\n HTTP.get(@url).code.tap do |result|\n @logger.info \"Result is #{result}\"\n end\n end\n end", "def detect_new_article_link(link)\n response = Net::HTTP.get_response(URI.parse(link))\n puts \"#{link}\"\n puts \"......response.code => #{response.code} \"\n response\nend", "def url_redirect_checker\n require 'curb'\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(crm_url_redirect: nil)\n # indexers = Indexer.where.not(crm_url: nil).where.not(crm_url: \"\").where(\"url != crm_url\").where(geo_url_redirect: nil)[20...-1]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%http%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where(\"raw_url LIKE '%www%'\")[a...z]\n # indexers = Indexer.where(redirect_status: nil).where(stf_status: \"SFDC URL\").where(indexer_status: \"SFDC URL\").where.not(\"raw_url LIKE '%www%'\")[a...z]\n # Indexer.where.not(\"redirect_status LIKE '%Error%'\")\n\n # a=0\n # z=-1\n\n indexers = Indexer.where(indexer_status: \"COP URL\").where(clean_url: nil)[a...z] ##17,033\n\n\n counter_fail = 0\n counter_result = 0\n total = 0\n indexers.each do |indexer|\n total +=1\n\n raw_url = indexer.raw_url\n\n begin ## rescue\n result = Curl::Easy.perform(raw_url) do |curl|\n curl.follow_location = true\n curl.useragent = \"curb\"\n curl.connect_timeout = 10\n curl.enable_cookies = true\n # curl.ssl_verify_peer = false\n end\n\n curb_url_result = result.last_effective_url\n\n crm_url_hash = url_formatter(curb_url_result)\n raw_url_final = crm_url_hash[:new_url]\n\n if raw_url != raw_url_final\n counter_result +=1\n puts\n puts \"[#{a}...#{z}] (#{counter_result}/#{total})\"\n puts \"O: #{raw_url}\"\n puts \"N: #{raw_url_final}\"\n puts \"--------------------------------------------\"\n puts\n indexer.update_attributes(redirect_status: \"Updated\", clean_url: raw_url_final)\n else\n puts \"[#{a}...#{z}] (#{total}): Same\"\n indexer.update_attributes(redirect_status: \"Same\", clean_url: raw_url_final)\n end\n\n rescue #begin rescue\n error_message = $!.message\n counter_fail +=1\n final_error_msg = \"Error: #{error_message}\"\n puts \"(#{counter_fail}/#{total}) (#{final_error_msg})\"\n\n if final_error_msg && final_error_msg.include?(\"Error:\")\n if final_error_msg.include?(\"SSL connect error\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"SSL Error\")\n elsif final_error_msg.include?(\"Couldn't resolve host name\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Host Error\")\n elsif final_error_msg.include?(\"Peer certificate\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Certificate Error\")\n elsif final_error_msg.include?(\"Failure when receiving data\")\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Transfer Error\")\n else\n indexer.update_attributes(indexer_status: \"Redirect Error\", redirect_status: \"Error\")\n end\n end\n end #end rescue\n end\n end", "def valid_status?(response)\n response.is_a?(Net::HTTPSuccess)\n end", "def process_response(response)\n content = response.body\n content_type = response.content_type\n if not content.empty? and content_type['html']\n content.force_encoding('iso-8859-1') # all bytes are valid in iso-859-1, so this ensures the next line never throws an encoding exception, yet still allows it to correctly match charset\n content.force_encoding($1) if content_type =~ /charset=([^;]+)/i or content =~ /<meta[^>]+charset=[\"']?([^;\"'>]+)/i\n end\n\n if response.code == 0\n return @queue.invalidate(self, InvalidURI::Bad_response)\n elsif response.code == 301\n return @queue.invalidate(self, InvalidURI::Page_has_moved, parse_uri(response.location, base, uri))\n elsif response.code == 404\n # check for meta refreshes and javascript refreshes\n content.each_line {|line|\n uri = (match_meta_refresh(line, base, uri) or match_javascript_refresh(line))\n return @queue.invalidate(self, InvalidURI::Page_has_moved, uri) if uri\n } if not content.empty? and content_type['html']\n return @queue.invalidate(self, InvalidURI::Not_found)\n elsif response.code == 406\n # link is valid but not of a type we care about\n return\n elsif not response.success? and response.code != 302 and response.code != 303\n return @queue.invalidate(self, ((300..399) === response.code ? InvalidURI::General_redirect : InvalidURI::General_error), ((300..399) === response.code ? '' : \"#{response.code} - \") + (response.status_message ? response.status_message.downcase : ''))\n end\n\n # search through the content for more links if doing recursive processing\n if opts[:recurse]\n if content_type['html']\n parse_html(content)\n elsif content_type['css']\n parse_css(content)\n elsif content_type['javascript']\n parse_javascript(content)\n end\n end\n\n # save the content if asked to\n duplicate(content_type, content) if @opts[:duplicate] and response.success? and LinkToLoad.within_root?(uri)\n\n if response.code == 302 or response.code == 303\n # gotten a temporary redirect code, so set a redirect for the page, invalidate it, and add a new entry for the new uri onto the queue\n new_uri = parse_uri(response.location, base, uri)\n within_root = LinkToLoad.within_root?(new_uri)\n redirects_to = new_uri\n redirect_code = response.code\n @queue.add_uri(new_uri, uri, within_root) if not @opts[:duplicate] or within_root\n @queue.invalidate(self, InvalidURI::Other_uri, redirect_code)\n elsif meta_refresh\n @queue.invalidate(self, InvalidURI::Page_has_moved, meta_refresh)\n end\n end", "def check_url(path, url)\n res = http_client.get(url, follow_redirect: true)\n return if res.status == 200\n raise(nil) unless res.status.to_s.match(/50\\d|403/)\n\n puts \"::warning file=#{path}:: Unexpected response from #{url} (#{res.status})\"\nrescue StandardError => e\n puts \"::warning file=#{path}:: Unable to reach #{url} #{res.respond_to?('status') ? res.status : nil}\"\n puts e.full_message unless e.instance_of?(TypeError)\n 1\nend", "def request_successful(response)\n\t\tresponse.code == \"200\"\n\tend", "def poll_status_url(url)\n loop do\n response = connection.get(url)\n yield response.body\n if response.success?\n break if response.status != 202\n else\n raise Samson::Hooks::UserError, \"error polling status endpoint\"\n end\n sleep poll_period\n end\n end", "def check_files\n process_files.each do |result|\n URL_TYPES.each do |url_type|\n type = :\"#{url_type}_urls\"\n ivar_name = \"@#{type}\"\n ivar = instance_variable_get(ivar_name)\n\n if ivar.empty?\n instance_variable_set(ivar_name, result[type])\n else\n result[type].each do |url, metadata|\n ivar[url] = [] if ivar[url].nil?\n ivar[url].concat(metadata)\n end\n end\n end\n @failures.concat(result[:failures])\n end\n\n validate_external_urls unless @options[:disable_external]\n\n validate_internal_urls\n end", "def check\n @task.log \"# #{@site.name}\"\n @ref_string = Cms::CheckLinks::RefString\n\n @base_url = @site.full_url.sub(/^(https?:\\/\\/.*?\\/).*/, '\\\\1')\n\n @urls = { @ref_string.new(@site.url) => %w(Site) }\n @results = {}\n @errors = {}\n\n @html_request_timeout = SS.config.cms.check_links[\"html_request_timeout\"] rescue 10\n @head_request_timeout = SS.config.cms.check_links[\"head_request_timeout\"] rescue 5\n @check_mobile = SS.config.cms.check_links[\"check_mobile_path\"] != false\n\n (10*1000*1000).times do |i|\n break if @urls.blank?\n url, refs = @urls.shift\n # @task.log url\n check_url(url, refs)\n @task.count\n end\n\n msg = [\"[#{@errors.size} errors]\"]\n @errors.map do |ref, urls|\n ref = File.join(@base_url, ref) if ref[0] == \"/\"\n msg << ref\n msg << urls.map do |url|\n meta = @meta.present? ? \" #{url.meta}\" : \"\"\n url = File.join(@base_url, url) if url[0] == \"/\"\n \" - #{url}#{meta}\"\n end\n end\n msg = msg.join(\"\\n\")\n\n @task.log msg\n\n if @email.present?\n ActionMailer::Base.mail(\n from: \"shirasagi@\" + @site.domain.sub(/:.*/, \"\"),\n to: @email,\n subject: \"[#{@site.name}] Link Check: #{@errors.size} errors\",\n body: msg\n ).deliver_now\n end\n\n create_report\n head :ok\n end", "def ok?\n @result.code.to_i != 200\n end", "def reachable?\n return true if (page_ref && (page_ref.good? || (page_ref.http_status == 200))) || (gleaning && gleaning.good?)\n return false if (page_ref && @@BadResponseCodes.include?(page_ref.http_status)) &&\n (gleaning && @@BadResponseCodes.include?(gleaning.http_status))\n end", "def rubygems_valid_response?(http, url)\n url.include?(RubygemsApi::BASE_URL) && http_valid_status_code?(http, [200, 404])\n end", "def check_resolvers\n done = @resolver_manager.done\n done.each do |entry, resolver|\n if resolver.successful?\n @link_table.remove(entry)\n\n resolver.result.each do |resolvable|\n entry = LinkTable::Entry.new(resolvable.link)\n entry.status = resolvable.status\n entry.name = resolvable.name\n entry.hoster = resolvable.hoster\n entry.size = resolvable.size\n @link_table.add(entry)\n end\n else\n entry.status.error!(resolver.message)\n @link_table.update(entry)\n end\n end\n end", "def reachable?(url)\n page = MetaInspector.new(url)\n\n if page.response.status < 400\n true\n else\n false\n end\n rescue\n false\n end", "def visit_all links\n not_found = []\n server_error = []\n\n links.each do |link|\n puts \"visiting link: #{link}\"\n visit link\n\n grab_screen \"visited #{link}\"\n current_url.should == link\n\n if page.has_content?('404')\n not_found << link\n next\n end\n\n server_error << link if page.has_content?('500') || page.has_content?('rror') || page.has_content?('ception')\n end\n\n unless not_found.empty? && server_error.empty?\n fail \"The following links responded with status 404: #{not_found.inspect} and these responded with status 500: #{server_error}\"\n end\nend", "def check_response\n unless (res = get).valid?\n raise BadResponse, \"#{res.code} #{res['Code'].first}\"\n end\n\n res\n end", "def success?\n\t\t\[email protected]{|p| not p.success}.size + @urls.select{|u| not u.success}.size < 1\n\t\tend", "def publishing_api_has_no_linked_items\n url = \"#{PUBLISHING_API_V2_ENDPOINT}/linked/\"\n stub_request(:get, %r{#{url}}).to_return(status: 200, body: [].to_json)\n end", "def add_invalid_url(url, refs)\n @results[url] = 0\n\n refs.each do |ref|\n @errors[ref] ||= []\n @errors[ref] << url\n end\n end", "def add_invalid_url(url, refs)\n @results[url] = 0\n\n refs.each do |ref|\n @errors[ref] ||= []\n @errors[ref] << url\n end\n end", "def valid_http_code_returned?(http_client, url)\n rubygems_valid_response?(http_client, url) || shields_io_valid_response?(http_client, url)\n end", "def process_response_data\n return false unless @response\n if save_webpage && save_webpage_response\n @webpage_request.update(status: 'complete')\n else\n @webpage_request.update(status: 'error')\n return false\n end\n end", "def status(*args)\n args.each do |item|\n item.class.to_s == \"Array\" ? item.each { |i| check_url(i) } : check_url(item) \n end\nend", "def ok?(response)\n case response\n when Net::HTTPSuccess\n true\n else\n false\n end\n end", "def check_head(url)\n http_basic_authentication = SS::MessageEncryptor.http_basic_authentication\n\n redirection = 0\n max_redirection = SS.config.cms.check_links[\"max_redirection\"].to_i\n\n if url.match?(/^\\/\\//)\n url = @base_url.sub(/\\/\\/.*$/, url)\n elsif url[0] == \"/\"\n url = File.join(@base_url, url)\n end\n\n begin\n Timeout.timeout(@head_request_timeout) do\n ::URI.open url, proxy: true, redirect: false, http_basic_authentication: http_basic_authentication, progress_proc: ->(size) { raise \"200\" }\n end\n false\n rescue OpenURI::HTTPRedirect => e\n return false if redirection >= max_redirection\n redirection += 1\n url = e.uri\n retry\n rescue Timeout::Error\n return false\n rescue => e\n return e.to_s == \"200\"\n end\n end", "def check_head(url)\n http_basic_authentication = SS::MessageEncryptor.http_basic_authentication\n\n redirection = 0\n max_redirection = SS.config.cms.check_links[\"max_redirection\"].to_i\n\n if url.match?(/^\\/\\//)\n url = @base_url.sub(/\\/\\/.*$/, url)\n elsif url[0] == \"/\"\n url = File.join(@base_url, url)\n end\n\n begin\n Timeout.timeout(@head_request_timeout) do\n ::URI.open url, proxy: true, redirect: false, http_basic_authentication: http_basic_authentication, progress_proc: ->(size) { raise \"200\" }\n end\n false\n rescue OpenURI::HTTPRedirect => e\n return false if redirection >= max_redirection\n redirection += 1\n url = e.uri\n retry\n rescue Timeout::Error\n return false\n rescue => e\n return e.to_s == \"200\"\n end\n end", "def ping\n self.url = normalize_url(url) unless self.canonical # We keep the canonical url exactly as redirected (no normalization)\n if redirected = test_url(url)\n unless self.canonical = (redirected == url)\n # We need a separate canonical record\n can = self.dup\n can.canonical = true\n can.url = redirected\n can.save\n end\n end\n self.save\n end", "def check_access\n @response = Response.new\n \n check_hash()\n \n if @response.error?\n access_denied\n return\n end\n end", "def assert_http_status(curl, status)\n\n # If the status doesn't match, then raise an exception\n if (curl.response_code != status) then\n raise curl.url + ': Expected response of ' + status.to_s + ' but was ' + curl.response_code.to_s\n end\nend", "def do_alive_check(id, auth, info_url)\n response = HTTParty.get(info_url, timeout: TIMEOUT, basic_auth: auth)\n send_service_response(id, response)\nrescue HTTParty::ResponseError, Errno::ECONNREFUSED => e\n send_text_status(id, 'Dead', moreinfo: e.message, danger: true)\n [false, e]\nrescue StandardError => e\n send_text_status(id, 'Indeterminate', moreinfo: e.message, fatal: true)\n [false, e]\nend", "def valid?\n (200..299).include? status\n end", "def ok; @status = 200 end", "def ok; @status = 200 end", "def handle_response(response)\n case response[:status]\n when :success, :created\n self.instance_variable_set('@notsaved', false)\n true\n when :errors\n Amfetamine.logger.warn \"Errors from response\\n #{response[:body]}\"\n response[:body].each do |attr, error_messages|\n error_messages.each do |msg|\n errors.add(attr.to_sym, msg)\n end\n end\n false\n when :server_error\n Amfetamine.logger.warn \"Something went wrong at the remote end.\"\n false\n end\n end", "def success?\n response.status == 200\n end", "def ok?\n Net::HTTPSuccess === self || Net::HTTPRedirection === self\n end", "def check_status\n return if @stash_identifier.nil? || @resource.nil?\n state = @resource.current_resource_state.try(:resource_state)\n return if state == 'in_progress'\n return_error(messages: 'Your dataset cannot be updated now', status: 403) { yield } if state != 'submitted'\n duplicate_resource # because we're starting a new version\n end", "def url_active?\n begin\n response = Net::HTTP.get_response URI.parse(self.url)\n active_status = %w(200 301 302)\n active_status.include? response.code\n rescue\n false\n end \n end", "def page_status\n @status = \"OK\"\n @status = \"ERR\" if self.response_code > 399\n end", "def valid_link?(url)\n # GET or HEAD? Head is more friendly to the server, but some pages\n # May behave differently depending on HEAD or GET.\n HTTParty.head(url,\n verify: false, # don't verify ssl certs\n ).code == 200\n end", "def check_file(url, refs)\n if get_internal_file(url)\n add_valid_url(url, refs)\n elsif check_head(url) == false\n add_invalid_url(url, refs)\n else\n add_valid_url(url, refs)\n end\n end", "def check_file(url, refs)\n if get_internal_file(url)\n add_valid_url(url, refs)\n elsif check_head(url) == false\n add_invalid_url(url, refs)\n else\n add_valid_url(url, refs)\n end\n end", "def check_code(url_data)\n if url_data[:response].code != '200'\n url_data[:notifs].push(\"slack-tech\")\n\n if @app_errors[\"#{url_data[:name]}\"]\n @app_errors[\"#{url_data[:name]}\"] += 1\n else\n @app_errors[\"#{url_data[:name]}\"] = 1\n end\n\n if @app_errors[\"#{url_data[:name]}\"] > 5\n restart_app(url_data[:restart])\n url_data[:notifs].push(\"email\")\n end\n\n if @app_errors[\"#{url_data[:name]}\"] > 10\n url_data[:notifs].push(\"sms\")\n end\n\n else\n @app_errors[\"#{url_data[:name]}\"] = 0\n end\n end", "def get_redirect_code(url)\n passed = true\n bad_codes = [204,206,400,404,408,500,501,502,503,504,505]\n\n\n\n counter = 0\n possible_redirect = []\n code = nil\n\n # Collect codes\n while code != 200 && bad_codes.include?(code) == false do\n possible_redirect << @entries[counter].response.status\n \n puts @entries[counter].response.status\n code = @entries[counter].response.status\n counter = counter + 1\n end\n\n # 301 Wrong Scenario test\n if(@url.include? \"maxRedirect=true\")\n if(possible_redirect.include?(301))\n # begin\n # campaign = @browser.evaluate_script(\"omnCampaignID\")\n # rescue\n # campaign = @browser.evaluate_script(\"app.omniMap.CampaignID\")\n # end\n\n # if campaign.downcase.include?(\"core\") == false\n passed == false\n # end\n end\n end\n\n possible_redirect.each do |code_to_check|\n if bad_codes.include?(code_to_check)\n passed == false\n end\n end\n\n\n return {result: passed, codes: possible_redirect}\n end", "def check(url, root=nil)\n create_instance\n @link_collector.check(url, root)\n end", "def availability_check_response(_msg_id, data)\n if false\n response = JSON.parse(data)\n # TODO: format of fifi_ready value is not defined yet\n status = response['result'] == 'ok' && response['fifi_ready'].to_i == 1 ? STATUS_AVAILABLE : STATUS_UNAVAILABLE\n\n if status == STATUS_UNAVAILABLE\n logger.warn(\"Source #{source_id} is unavailable. Reason: #{response['message']}\")\n end\n\n update_source(source_id, status)\n else\n # woohoo, always successful\n update_source(source_id, STATUS_AVAILABLE)\n end\n end", "def check_for_redirection\n begin\n response = Net::HTTP.get_response(self.thumbnail_url)\n rescue\n return :abort\n end\n if '302' == response.code\n self.thumbnail_url = response['location']\n end\n end", "def check(url)\n if @allocations.has_key?(url)\n count = @allocations[url]['count']\n if count == -1\n return true\n end\n if count > 0 \n if (count - 1) == 0\n unbind(url)\n else\n @allocations[url]['count'] = count - 1\n end\n return true\n end\n end\n false\n end", "def http200(url)\n begin\n Net::HTTP.get_response(URI.parse(url)).code == '200'\n rescue Exception\n false\n end\n end", "def check_requests\n if requests.empty?\n errors.add('requests', 'there were no requests')\n return\n end\n\n requests.each do |request|\n next if request.valid?\n\n request.errors.each do |k, v|\n errors.add(k, v)\n end\n end\n end", "def silly_fd_inconsistency(status, response)\n # FD will return 404 when updating a contact, who is an agent. So if someone from staff is\n # a ticket sender, we won't be able to update the ticket.\n return true if status == 404\n\n begin\n response = JSON.parse(response)\n\n # Freshdesk will not allow to update description if the member name contains /, \", wwww.\n # But it ALLOWS such requesters to be created in the first place.\n # Result: such requesters cannot be updated via API without chaning their name.\n return true if response['errors'].any? { |x|\n x['field'] == 'name' && x['message'] == \"/,\\\",www. not allowed in name\"\n }\n\n false\n rescue JSON::ParserError\n false\n end\n end", "def ok?\n @status == 200\n end", "def success?\n status == 200\n end", "def ok?\n\n if @http_raw_response.kind_of? Net::HTTPNoContent\n #if there is no content expected, use HTTP code\n 204 == @http_status_code\n else\n # otherwise use API status\n @http_raw_response.kind_of? Net::HTTPOK and 0 == @api_status.to_i\n end\n end", "def status\n @response && @response.status\n end", "def shields_io_valid_response?(http, url)\n url.include?(BadgeApi::BASE_URL) && http_valid_status_code?(http, 200) && http_valid_content_types?(http)\n end", "def validate_url\n return head(:bad_request, content_type: 'application/json') unless params[:shorten][:url]\n end", "def check_for_invalid_external_references(record, logical_urls)\n if record.respond_to?(:to_array)\n record.each {|e| check_for_invalid_external_references(e, logical_urls)}\n elsif record.respond_to?(:each)\n record.each do |k, v|\n if k == 'ref' && !logical_urls.has_key?(v)\n URIResolver.ensure_reference_is_valid(v, RequestContext.get(:repo_id))\n elsif k != '_resolved'\n check_for_invalid_external_references(v, logical_urls)\n end\n end\n end\n end", "def success?\n @status >= 200 && @status < 300\n end", "def is200\n (Net::HTTPSuccess === response)\n end", "def handle_302_found(response,request_url,redirects)\n raise \"Too many redirects followed to redirect again for 302 response: followed (#{redirects}) redirects while retrieving #{request_url}\" unless redirects > 0\n handle_301_moved_permanantly(response,request_url,redirects)\n end", "def refute_link(rel, response = last_response)\n link_header = LinkHeader.parse(response.headers[\"Link\"])\n link = link_header.find_link([\"rel\", rel])\n refute link, \"Unexpected link with rel '#{rel} found\"\n\n # Also check in _response_info\n parsed_response = JSON.parse(response.body)\n links = parsed_response.fetch(\"_response_info\", {})[\"links\"] || []\n found_link = links.find { |link| link[\"rel\"] == rel }\n refute found_link, \"Unexpected link with rel '#{rel} in _response_info\"\n end", "def fetch\n def get_response url\n self.status = response = nil\n begin\n uri = URI.parse(url)\n if uri.host &&\n uri.port &&\n (http = Net::HTTP.new(uri.host, uri.port)) &&\n (request = Net::HTTP::Get.new(uri.request_uri))\n response = http.request(request)\n self.status = response.code.to_i\n else # Invalid URL\n self.status = 400\n end\n rescue Exception => e\n # If the server doesn't want to talk, we assume that the URL is okay, at least\n case e\n when Errno::ECONNRESET\n self.status = 401\n else\n self.status = -1 # Undifferentiated error during fetch, possibly a parsing problem\n end\n end\n response\n end\n\n # get_response records the status of the last HTTP access in self.status\n tried = {}\n next_try = url\n until tried[next_try]\n tried[next_try] = true\n response = get_response next_try\n case status\n when 200\n return response.body\n when 301, 302 # Redirection\n next_try = response.header[\"location\"]\n when 401 # Unauthorized\n next_try.sub! /^https/, 'http'\n end\n end\n end", "def http_error?\n !(200..299).include?(http_code)\n end", "def process_response(response)\n case response\n when Net::HTTPFound, Net::HTTPCreated\n response['Location']\n when Net::HTTPConflict\n raise URLConflict\n when Net::HTTPNotAcceptable\n raise URLFormatError\n else\n raise InvalidResponse.new(\"Invalid Shorty Response Code: #{response.code} #{response.message}\")\n end\n end", "def redirected?\n raise @invalid_uri_error if invalid_uri_error?\n raise @fetch_error if fetch_error?\n @redirect_log.size > 1\n end", "def validate_http_status\n return true if @http.code.to_i == 200\n DomainTools::Exceptions::raise_by_code(@http.code)\n end", "def validator(response, task_information)\n response.code.to_i != 0 && !response.headers['Location'].match(/loginStatus=false/i)\n end", "def check\n @response = nil\n verified?\n end", "def success?\n @response.code == \"200\"\n end", "def check_if_group_set_exists(group_set_name)\n group_set_arr = Array.new\n\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/group_categories\"\n puts \"@url is #{@url}\"\n \n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get group sets has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n if $link_parser.parse(@getResponse).by_rel('next')\n group_set_arr.append(@getResponse.parsed_response)\n\n while $link_parser.parse(@getResponse).by_rel('next')\n @url = $link_parser.parse(@getResponse).by_rel('next').target\n puts \"@url is #{@url}\"\n\n @getResponse = HTTParty.get(@url, :headers => $header)\n puts(\" GET to get group sets has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n group_set_arr.append(@getResponse.parsed_response)\n end\n\n group_set_arr.each { |group_set_data|\n group_set_data.each do |group_set_info|\n if group_set_info[\"name\"] == group_set_name\n return true \n end\n end\n }\n\n return false\n else\n group_set_data = @getResponse.parsed_response\n \n group_set_data.each do |group_set_info|\n if group_set_info[\"name\"] == group_set_name\n return true \n end\n end\n \n return false\n end\nend" ]
[ "0.63393325", "0.622879", "0.6131479", "0.6090742", "0.6090742", "0.6089222", "0.60618484", "0.59566075", "0.5912328", "0.5910831", "0.58864087", "0.58178145", "0.5809795", "0.580053", "0.5790382", "0.5782917", "0.5739215", "0.5716895", "0.5703633", "0.5685282", "0.5676209", "0.56603456", "0.5631578", "0.5629921", "0.5617389", "0.5603692", "0.55985534", "0.55932003", "0.5587315", "0.55838084", "0.55798197", "0.55729026", "0.5560844", "0.55417055", "0.5539702", "0.553928", "0.55385864", "0.5535726", "0.5514377", "0.5508532", "0.5498155", "0.5494486", "0.5494179", "0.5491966", "0.54866487", "0.5464539", "0.54605055", "0.54528266", "0.54528266", "0.54459804", "0.5438407", "0.5435015", "0.5420932", "0.5410345", "0.5410345", "0.5408441", "0.54070485", "0.54065716", "0.5404502", "0.5402378", "0.540031", "0.540031", "0.5398769", "0.5396442", "0.53862244", "0.5384399", "0.5383565", "0.5358291", "0.5355559", "0.5347703", "0.5347703", "0.53428704", "0.5338234", "0.5333031", "0.5329935", "0.53290653", "0.532697", "0.5321962", "0.53217447", "0.5321023", "0.53167236", "0.53103137", "0.5304333", "0.5302695", "0.526905", "0.5266182", "0.52642924", "0.5259503", "0.5258517", "0.52565724", "0.52538955", "0.5243507", "0.5242115", "0.5237798", "0.5232405", "0.52300173", "0.52272105", "0.522423", "0.52100956", "0.52065283" ]
0.7361032
0
A page is reachable if its response status is less than 400 In the case of exceptions, like timeouts or server connection errors, we consider it unreachable
def reachable?(url) page = MetaInspector.new(url) if page.response.status < 400 true else false end rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reachable?\n return true if (page_ref && (page_ref.good? || (page_ref.http_status == 200))) || (gleaning && gleaning.good?)\n return false if (page_ref && @@BadResponseCodes.include?(page_ref.http_status)) &&\n (gleaning && @@BadResponseCodes.include?(gleaning.http_status))\n end", "def page_status\n @status = \"OK\"\n @status = \"ERR\" if self.response_code > 399\n end", "def check_url(path, url)\n res = http_client.get(url, follow_redirect: true)\n return if res.status == 200\n raise(nil) unless res.status.to_s.match(/50\\d|403/)\n\n puts \"::warning file=#{path}:: Unexpected response from #{url} (#{res.status})\"\nrescue StandardError => e\n puts \"::warning file=#{path}:: Unable to reach #{url} #{res.respond_to?('status') ? res.status : nil}\"\n puts e.full_message unless e.instance_of?(TypeError)\n 1\nend", "def check_404\n end", "def error?\n http_status >= 400 && http_status <= 599\n end", "def http_error?\n !(200..299).include?(http_code)\n end", "def i_may_not_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPForbidden===result or Net::HTTPBadRequest===result), __last_because + \" (may actually reach #{which_page}: #{result})\"\n end", "def healthy?\n return false if status <= 199 || status >= 400\n true\n end", "def http200(url)\n begin\n Net::HTTP.get_response(URI.parse(url)).code == '200'\n rescue Exception\n false\n end\n end", "def unavailable\n render \"errors/503\", :status => 503 \n\tend", "def validate_http_status\n return true if @http.code.to_i == 200\n DomainTools::Exceptions::raise_by_code(@http.code)\n end", "def healthy?\n return false if status <= 199 || status >= 400\n\n true\n end", "def is_reachable_url?(url)\n begin\n wait(15, true, 1) {\n RestClient.get url\n }\n\n rescue Exception => e\n @@logger.an_event.debug \"url #{url} unreachable : #{e.message}\"\n false\n\n else\n @@logger.an_event.debug \"url #{url} reachable\"\n true\n\n end\n end", "def client_error?\n 400 <= code && code < 500\n end", "def is_good_status_code(status_code)\n status_code.to_i >= 200 && status_code.to_i < 400\n end", "def valid?\n code == 200\n end", "def ok?\n @result.code.to_i != 200\n end", "def valid?\n status == 200\n end", "def client_error?\n @status.between?(400, 499) if @status\n end", "def page_ok?(config, url)\n uri = URI.parse(url) rescue nil\n (uri.respond_to?(:host) && uri.host =~ config[\"host_re\"] &&\n uri.respond_to?(:path) && uri.path !~ %r{^/b/}).tap do |result|\n if !result\n puts \"Rejecting page #{url} for key #{config[\"key\"]}\"\n end\n end\n end", "def client_error?\n (400..499).cover?(code)\n end", "def good_status_code?(status_code)\n status_code.to_i >= 200 && status_code.to_i < 400\n end", "def not_found?\n @code == 403 or @code == 404\n end", "def status_bad_request\n respond_to do |format|\n format.any { head :bad_request }\n end\n end", "def response_unavailable?\n !!(content_for_scanner =~ /Server too busy, try again later/)\n end", "def check_request\n if @req.code.to_i.between?(400, 499)\n raise Exceptions::SlicingDiceHTTPError, \"Client Error \"\\\n \"#{@req.code} (#{@req.message}).\"\n elsif @req.code.to_i.between?(500, 600)\n raise Exceptions::SlicingDiceHTTPError, \"Server Error \"\\\n \"#{@req.code} (#{@req.message}).\"\n else\n true\n end\n end", "def client_error?\n (400..499).cover?(code)\n end", "def no_500_error!\n return true if browser.all(:css, 'head title', :text => 'Internal Server Error').empty?\n sleep 30 if ENV['GIMME_CRAP']\n raise Unexpected500, browser.body\n end", "def page_status url\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n if url.scheme.downcase == \"https\"\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.use_ssl = true\n end\n http.start do\n http.request_get(url.path.empty? ? \"/\" : url.path) do |res|\n return {:name => res.class, :code => res.code}\n end\n end\n end", "def ok?(http_code)\n http_code =~ /^20/ ||\n http_code =~ /^40/\n end", "def status\n return false if [email protected]?(200)\n \n true\n end", "def missing?\n status == 404\n end", "def unknown?\n !(100...600).include?(@status_code)\n end", "def check_url_status(url)\n begin\n conn = Faraday.new(:url => url)\n response = conn.get\n rescue Faraday::ConnectionFailed => e\n return \"Unknown. Requires attention.\"\n else\n statusNum = response.status\n puts case statusNum\n when 200\n return \"200: Online\"\n when 201\n return \"201: Created\"\n when 204\n return \"204: No Content\"\n when 301\n return \"301: Moved Permanantly\"\n when 302\n return \"302: Redirecting\"\n when 304\n return \"304: Not Modified\"\n when 400\n return \"400: Bad Request\"\n when 401\n return \"401: Unauthorized\"\n when 403\n return \"403: Access Forbidden\"\n when 404\n return \"404: Not Found\"\n when 409\n return \"409: Conflict\"\n when 500\n return \"500: Internal Server Error\"\n else\n return \"Status code: #{statusNum}\"\n end\n\n end\n end", "def request_not_found(response)\n response.code == 404 ||\n response['status'] == 'Bad Request' ||\n response.parsed_response['Results']['state'].size == 0\n end", "def check_page(base, page, severity=:E, expectedStatus=\"200\", log=true)\n path = base + page\n response = getHTTP(path)\n code = response.code || '?'\n if code != expectedStatus\n test(severity, \"Fetched #{path} - HTTP status: #{code} expected: #{expectedStatus}\") unless severity == nil\n return nil\n end\n I \"Fetched #{path} - OK\" if log\n response.body\nend", "def is_client_error?\n @code.in? 400..499\n end", "def server_error?\n @status.between?(500, 599) if @status\n end", "def consume_bad_url; end", "def is_client_error?\n code.to_i >= 400 && code.to_i <= 499\n end", "def check_http_status(href)\n url = href.split(\".com/\")\n response = nil\n Net::HTTP.start(url[0].split(\"https://\").last + \".com\", 80) {|http|\n response = http.head(\"/\" + url[1])\n }\n if(response.code != \"200\")\n fail(href + \" returned code: \" + response.code)\n end\nend", "def status_not_found\n @status = 404\n @e.error 'The requested page does not exist.', 404\n throw :exit\n end", "def check_response!\n body[:stat] == 'ok' || fail(ClientError, \"#{ body.inspect }\")\n end", "def status_not_acceptable\n respond_to do |format|\n format.any { head :not_acceptable }\n end\n end", "def bad_request_response(env)\n if head_request?(env)\n [ 400, { \"content-type\" => \"text/plain\", \"content-length\" => \"0\" }, [] ]\n else\n [ 400, { \"content-type\" => \"text/plain\", \"content-length\" => \"11\" }, [ \"Bad Request\" ] ]\n end\n end", "def server_error?\n 500 <= code && code < 600\n end", "def redirect?\n 300 <= code && code < 400\n end", "def check_response\n unless (res = get).valid?\n raise BadResponse, \"#{res.code} #{res['Code'].first}\"\n end\n\n res\n end", "def is_server_error?\n code.to_i >= 500 && code.to_i <= 599\n end", "def error?\n # 4xx and 5xx are errors\n return @status >= 400 && @status < 600\n end", "def client_error?\n (400...500).include?(@status_code)\n end", "def check_head(url)\n http_basic_authentication = SS::MessageEncryptor.http_basic_authentication\n\n redirection = 0\n max_redirection = SS.config.cms.check_links[\"max_redirection\"].to_i\n\n if url.match?(/^\\/\\//)\n url = @base_url.sub(/\\/\\/.*$/, url)\n elsif url[0] == \"/\"\n url = File.join(@base_url, url)\n end\n\n begin\n Timeout.timeout(@head_request_timeout) do\n ::URI.open url, proxy: true, redirect: false, http_basic_authentication: http_basic_authentication, progress_proc: ->(size) { raise \"200\" }\n end\n false\n rescue OpenURI::HTTPRedirect => e\n return false if redirection >= max_redirection\n redirection += 1\n url = e.uri\n retry\n rescue Timeout::Error\n return false\n rescue => e\n return e.to_s == \"200\"\n end\n end", "def check_head(url)\n http_basic_authentication = SS::MessageEncryptor.http_basic_authentication\n\n redirection = 0\n max_redirection = SS.config.cms.check_links[\"max_redirection\"].to_i\n\n if url.match?(/^\\/\\//)\n url = @base_url.sub(/\\/\\/.*$/, url)\n elsif url[0] == \"/\"\n url = File.join(@base_url, url)\n end\n\n begin\n Timeout.timeout(@head_request_timeout) do\n ::URI.open url, proxy: true, redirect: false, http_basic_authentication: http_basic_authentication, progress_proc: ->(size) { raise \"200\" }\n end\n false\n rescue OpenURI::HTTPRedirect => e\n return false if redirection >= max_redirection\n redirection += 1\n url = e.uri\n retry\n rescue Timeout::Error\n return false\n rescue => e\n return e.to_s == \"200\"\n end\n end", "def shields_io_valid_response?(http, url)\n url.include?(BadgeApi::BASE_URL) && http_valid_status_code?(http, 200) && http_valid_content_types?(http)\n end", "def validate_response(response) # :nodoc:\n code = response.code.to_i\n raise HttpError, \"#{code} #{response.msg}\" if code < 200 || code > 299\n end", "def assess\n @error = false\n begin\n response_code = get_http_response_code(@referer)\n rescue\n Flying.an_error_ocurred(true)\n set_error_message(@referer, false, $!)\n return false\n end\n return true if [\"200\", \"302\"].include? response_code\n Flying.an_error_ocurred(true)\n set_error_message(@referer, response_code.to_s)\n false\n end", "def check_response(response)\n case response\n when Net::HTTPSuccess then\n #puts response\n when Net::HTTPRedirection then\n location = response['location']\n warn \"redirected to #{location}\"\n fetch(location, limit - 1)\n else\n puts response.value\n end\nend", "def error_response?(response, _parsed_response)\n !(200..299).cover?(response.code)\n end", "def redirection?\n (300...400).include?(@status_code)\n end", "def server_error?\n (500..599).cover?(code)\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found\n status 404\n body \"not found\\n\"\n end", "def not_found?\n @status == 404 if @status\n end", "def respond_bad_request; make_response(nil, false, 400, \"Bad Request\") end", "def do_alive_check(id, auth, info_url)\n response = HTTParty.get(info_url, timeout: TIMEOUT, basic_auth: auth)\n send_service_response(id, response)\nrescue HTTParty::ResponseError, Errno::ECONNREFUSED => e\n send_text_status(id, 'Dead', moreinfo: e.message, danger: true)\n [false, e]\nrescue StandardError => e\n send_text_status(id, 'Indeterminate', moreinfo: e.message, fatal: true)\n [false, e]\nend", "def i_reach(which_page)\n result = go(which_page)\n assert Net::HTTPSuccess===result, __last_because + \" (cannot actually reach #{which_page}: #{result})\"\n end", "def check\r\n\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => normalize_uri(target_uri.path, \"#{datastore['CONTENT_DIR']}/\")\r\n })\r\n\r\n unless res\r\n vprint_error 'Connection failed'\r\n return CheckCode::Unknown\r\n end\r\n\r\n if res.code == 404\r\n return Exploit::CheckCode::Safe\r\n end\r\n return Exploit::CheckCode::Appears\r\n end", "def valid_url?(url)\n begin\n Net::HTTP.get_response(URI(url)).code == \"200\" ? true : false\n rescue SocketError\n false\n end\nend", "def fallback\n head :ok\n end", "def is404\n (Net::HTTPNotFound === response)\n end", "def error?\n (500..599).include?(status)\n end", "def get_response(url)\n\t\t\t\t\t\tres_flag = false\n\t\t\t\t\t\t\t\tresponse = RestClient.get(url){|response, request, result| response \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif response.code != 200\n\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\tputs response.code\n\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\tres_flag = true\n\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\t\t\t\t\tputs \"Skipped due to #{response.code}\"\n\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\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn res_flag\nend", "def valid?\n (200..299).include? status\n end", "def success?\n status < 400\n end", "def check_connection\n one_wait = 5\n max_wait = 5\n request = Net::HTTP::Get.new('/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@url.host, @url.port) {|http|\n http.request(request)\n }\n break if Net::HTTPForbidden === response\n break if Net::HTTPNotFound === response\n break if Net::HTTPSuccess === response\n # When we try to connect to a down server with an Apache proxy, \n # we'll get Net::HTTPBadGateway and get here\n rescue Errno::ECONNREFUSED\n # When we try to connect to a down server without an Apache proxy, \n # such as a dev instance, we'll get here\n end\n sleep one_wait;\n wait += one_wait\n end\n if (wait == max_wait)\n puts(\"-- ERROR: couldn't connect to test host on \" + @url.host.to_s)\n return false\n end\n puts(\"-- SUCCESS: test host is alive !\\n\")\n return true\nend", "def test_404_page\n get '/launchpads'\n assert last_response.ok?\n assert last_response.body.include?('Endpoint Not Found')\n end", "def not_found?\n 404 == code\n end", "def ok?\n\n if @http_raw_response.kind_of? Net::HTTPNoContent\n #if there is no content expected, use HTTP code\n 204 == @http_status_code\n else\n # otherwise use API status\n @http_raw_response.kind_of? Net::HTTPOK and 0 == @api_status.to_i\n end\n end", "def fetched?\n 200 == code\n end", "def not_found?\n 404 == @code\n end", "def not_found?\n 404 == @code\n end", "def not_found?\n 404 == @code\n end", "def not_found?\n 404 == @code\n end", "def i_dont_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPNotFound===result or Net::HTTPForbidden===result), __last_because + \" (can reach #{which_page}: #{result})\"\n end", "def link_is_existent?(url)\n \tbegin\n\t uri = URI.parse(url)\n \t http_conn = Net::HTTP.new(uri.host, uri.port)\n \t resp, data = http_conn.head(\"/\" , nil)\n \t puts \"=== RESPONSE CODE #{resp.code}\"\n \t resp.code != \"404\"\n \trescue URI::InvalidURIError, Errno::ECONNREFUSED, SocketError\n \t\tfalse\n \tend\n end", "def fetch\n @start = Time.now\n @result = get @url\n @stop = Time.now\n\n if @result.code.to_i == 200\n @body = @result.parser\n end\n\n return @result.code.to_i < 400 ? true : false\n\n rescue Exception => ex\n @result = FakeResult.new\n $stderr.puts \"Ex: #{ex.message}\"\n return false\n\n rescue Patron::TimeoutError, Timeout::Error => ex\n @stop = Time.now\n @result = FakeResult.new\n @result.code = \"timeout\"\n\n return false\n\n end", "def is_http_status? code\n (200..206).to_a.concat((300..307).to_a).concat((400..417).to_a) \\\n .concat((500..505).to_a).include? code.to_i\n end", "def redirect?\n # redirects are 3xx\n return @status >= 300 && @status < 400\n end", "def ok?\n Net::HTTPSuccess === self || Net::HTTPRedirection === self\n end", "def not_found_response(env)\n if head_request?(env)\n [ 404, { \"content-type\" => \"text/plain\", \"content-length\" => \"0\", \"x-cascade\" => \"pass\" }, [] ]\n else\n [ 404, { \"content-type\" => \"text/plain\", \"content-length\" => \"9\", \"x-cascade\" => \"pass\" }, [ \"Not found\" ] ]\n end\n end", "def rate_limit_check\n status = 200\n result = {}\n if rate_limit_on?\n if rate_limit_left > 0\n status = 429\n result[:error] = \"you need to wait #{rate_limit_left} ms before you can request anything again\"\n render status: status, json: result\n end\n end\n end", "def error?\n (400...600).include?(@status_code)\n end", "def ok?\n @status == 200\n end", "def check_availability_by_http_request(host, port)\n uri = URI(\"http://#{host}:#{port}/info\")\n request = Net::HTTP::Get.new(uri)\n request[Datadog::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST] = '1'\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n response.is_a?(Net::HTTPSuccess)\n rescue SocketError\n false\n end", "def validate_url\n return head(:bad_request, content_type: 'application/json') unless params[:shorten][:url]\n end", "def available?\n resp = get do |req|\n req.url '/'\n end\n resp.status == 200\n end", "def is200\n (Net::HTTPSuccess === response)\n end", "def url_exist?\n\t\tbegin\n\t\t\turi = URI.parse(valid_url?)\n\t\t\tresponse = Net::HTTP.get_response(uri)\n\t\trescue \n\t\t\terrors.add(:long_url,\"is invalid url\")\n\t\t\t# in AR, error is a class by itself already \n\t\t\t# go to static.rb to check the errors\n\t\tend\n\tend", "def doi_server_reachable?\n # Invoke the API and get response\n true\n end" ]
[ "0.6861654", "0.6764447", "0.6672075", "0.6623096", "0.65873194", "0.65186507", "0.6506967", "0.6459085", "0.6456401", "0.64426", "0.6436165", "0.64096296", "0.6357562", "0.6351178", "0.6307416", "0.6292868", "0.6282211", "0.6273107", "0.62696683", "0.62693334", "0.6259066", "0.62425137", "0.6213206", "0.6210465", "0.62088585", "0.62050843", "0.61944", "0.6187296", "0.6153419", "0.6149277", "0.6135522", "0.6127118", "0.61181134", "0.6102679", "0.6067625", "0.60627294", "0.6049592", "0.6031369", "0.60290223", "0.6022466", "0.60154", "0.60084873", "0.6000281", "0.59991753", "0.5998381", "0.59948415", "0.5994187", "0.5992967", "0.5987916", "0.59823066", "0.5958421", "0.59569174", "0.59569174", "0.59562653", "0.5956073", "0.5944749", "0.594231", "0.59360754", "0.59336996", "0.5928527", "0.5915716", "0.5915716", "0.5915716", "0.59121156", "0.5911965", "0.59031457", "0.5902678", "0.5896034", "0.5887809", "0.5882088", "0.58595276", "0.5858705", "0.5855202", "0.5846987", "0.5846731", "0.5842053", "0.5840397", "0.5840063", "0.5836235", "0.58339137", "0.5833475", "0.5833475", "0.5833475", "0.5833475", "0.5823804", "0.5821567", "0.58164793", "0.58083856", "0.5803378", "0.58004147", "0.5799714", "0.579967", "0.57921803", "0.57794076", "0.57706267", "0.5768657", "0.5766565", "0.5761262", "0.5746453", "0.5732636" ]
0.76856244
0
overridden Devise method that checks the soft delete timestamp on authentication
def active_for_authentication? super && !deactivated_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication? \n super && !deleted_at \n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication? \n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n super && !deleted_at\n end", "def active_for_authentication?\n\t\tsuper && !deleted_at\n\tend", "def active_for_authentication? \n super && !is_deleted \n end", "def active_for_authentication?\n super and not self.deleted?\n end", "def active_for_authentication?\n super && !delete_flag\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !deleted?\n end", "def active_for_authentication?\n super && !delete_flag?\n end", "def active_for_authentication?\n \tsuper && !delete_flag\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n\t\tupdate_attribute(:deleted_at, Time.current)\n\tend", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def soft_delete\n update_attribute(:deleted_at, Time.current)\n end", "def active_for_authentication?\n super && !deleted_at && self.enabled?\n end", "def soft_delete \n update_attribute(:deleted_at, Time.current) \n end", "def soft_delete \n update_attribute(:deleted_at, Time.current) \n end", "def active_for_authentication? \n raise ErrorHandling::Errors::User::DeletedUser.new(deleted_at: deleted_at) if deleted_at? \n return true\n end", "def soft_delete\n update_attribute(:delete_flag, Time.current)\n end", "def soft_delete\n update_attribute(:deactivated_at, Time.current)\n update_attribute(:encrypted_api_secret_key, '')\n end", "def is_safe_deleted?\n return !self.deleted_at.nil?\n end", "def soft_delete\n ActiveRecord::Base.record_timestamps = false\n self.deleted_at = Time.now\n self.save\n ActiveRecord::Base.record_timestamps = true\n end", "def user_can_delete?\n false\n end", "def before_soft_delete\n return self.soft_deletable?\n end", "def soft_delete\n transaction do\n before_soft_delete if respond_to?(:before_soft_delete)\n result = if is_a?(Claim::BaseClaim)\n update_attribute(:deleted_at, Time.zone.now)\n else\n update(deleted_at: Time.zone.now)\n end\n after_soft_delete if respond_to?(:after_soft_delete)\n result\n end\n end", "def authorized_for_delete?\n return !self.is_default?\n end", "def active_for_authentication?\n super && !deleted? && approved?\n end", "def active_for_authentication?\n super && !deleted? && approved?\n end", "def soft_deleted?\n mark_as_deleted\n end", "def soft_delete!\n update_attribute(:mark_as_deleted, true)\n end", "def soft_delete(at = Time.zone.now)\n update_attribute(:deleted_at, at)\n end", "def before_destory\n if User.count(:all, :conditions => [\"is_superuser = 1 and active = 1\"]) <= 1\n errors.add_to_base \"Cannot delete #{self.username.upcase} because it is the last admin user\"\n return false\n else\n return true\n end\n end", "def active_for_authentication?\n super && !disabled_at\n end", "def not_active_on_create!\n self.deleted_at ||= Time.zone.now\n end", "def after_soft_delete; end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def destroy\n log_record('users/delete', current_user.id)\n super\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\n # can_destroyed?\n end", "def before_destroy\r\n errors.add(:base, I18n.t(\"activerecord.errors.models.user.self_delete\")) if current_user_id == self.id\r\n errors.add(:base, I18n.t(\"activerecord.errors.models.user.delete\")) if User.count == 1\r\n errors.blank?\r\n end", "def delete\n Authentication.where(user_id: id).each { |auth| auth.delete }\n super\n end", "def create\n super\n # delete_expired_tokens\n end", "def ensure_active\n run_callbacks(:destroy) do\n update_attribute(:deleted_at, nil)\n end\n end", "def delete\n user = getUserByAuthToken(request)\n user.soft_delete\n head :no_content\n end", "def destroy\n signed_out_user = current_user\n sign_out :user\n session.try(:delete, :_csrf_token)\n # Prevent Token Fixation attacks by generating a new token upon user logout.\n signed_out_user.authentication_token = Devise.friendly_token\n signed_out_user.save\n super\n end", "def enforce_delete_permissions\n enforce_edit_permissions\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def destroy_access_check\n permission_check('destroy')\n end", "def mark_as_deleted(current_user)\n self.is_deleted = true\n self.deleted_at = Time.now\n self.deleted_by_id = current_user.id\n self.save\n end", "def destroy\n update_attribute(:deleted_at, Time.now)\n end", "def before_destroy\n if public?\n errors.add_to_base _('Public user cannot be deleted.')\n end\n if last_admin?\n errors.add_to_base _(\"Cannot delete. User '{{username}}' is the last available admin.\", :username => username)\n end\n if current?\n errors.add_to_base _('You cannot delete your own account.')\n end\n errors.empty?\n end", "def authorized_for_destroy?\n current_user.es_admin?\n end", "def super_active_users_retention\n \n end", "def soft_delete\n self.active = false\n save\n end", "def destroy\n before_action :authenticate_user\n @user.destroy\n end", "def active_for_authentication?\n super && !expired?\n end", "def delete_user\n end", "def session_check\n return if (t_last = last_operation_time).zero?\n return if (t_boot = BOOT_TIME.to_i) < t_last\n __debug { \"last_operation_time #{t_last} < BOOT_TIME #{t_boot}\" }\n Log.info { \"Signed out #{current_user&.to_s || 'user'} after reboot.\" }\n local_sign_out\n end", "def authorized_for_destroy?\n return false unless current_user && current_user.is_admin_type?\n end", "def verify_signed_out_user\n end", "def owner_deleted?\n !!User.with_deleted.find_by_id(user_id).try(:deleted?)\n end", "def inactive_message \n !deleted_at ? super : :deleted_account \n end", "def verify_signed_out_user\n end", "def verify_signed_out_user\n end" ]
[ "0.7788317", "0.7788317", "0.76786214", "0.76735294", "0.7646309", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.75502956", "0.7402738", "0.73600286", "0.71512926", "0.7124476", "0.7077848", "0.7077848", "0.7077848", "0.7055446", "0.70459557", "0.68795353", "0.6879421", "0.68470913", "0.683709", "0.68240243", "0.68240243", "0.68240243", "0.68240243", "0.68240243", "0.68240243", "0.68240243", "0.68240243", "0.68082035", "0.6779875", "0.6779875", "0.6779203", "0.6750387", "0.6635493", "0.6533233", "0.64992166", "0.6483379", "0.6412126", "0.6338254", "0.6310153", "0.6252679", "0.6252679", "0.6175471", "0.61417526", "0.6105983", "0.6065771", "0.60189885", "0.60128665", "0.6009212", "0.5954352", "0.5954352", "0.5954352", "0.5923979", "0.5904786", "0.5904786", "0.5904786", "0.5896298", "0.58905536", "0.5881339", "0.5861052", "0.5860462", "0.5860247", "0.5802949", "0.57807815", "0.57807815", "0.57807815", "0.57741326", "0.57594883", "0.5746454", "0.5740481", "0.5716807", "0.5699737", "0.569134", "0.5684298", "0.56763047", "0.5670748", "0.56679046", "0.56660044", "0.56636876", "0.56635004", "0.5640509", "0.5640509" ]
0.6381246
56
method that adds an interest to interest_db database
def add_interest(db, interest) db.execute("INSERT INTO interests (interest) VALUES (?)", [interest]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_interest(id)\n SocietyInterest.create(society_id: self.id, interest_id: id)\n end", "def add_friend_interest(db, friend_id, interest_id)\n db.execute(\"INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)\", [friend_id, interest_id])\nend", "def create \n @interest = Interest.new(interest_params)\n @interest.save\n end", "def create\n @interest = Interest.new(params[:interest])\n if @interest.save\n redirect_to interests_path\n else\n redirect_to new_interest_path\n end\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def create\n standard_create(Interest, interest_params)\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n format.json { render json: @interest, status: :created, location: @interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_interest\n begin\n @interest = Interest.find(params[:id])\n rescue\n redirect_to \"/interest\"\n end\n end", "def add_interest(rate)\n super(rate)\n end", "def set_interest\n @interest = Interest.find(params[:id]) \n @especifications = Especification.where(\"interest_id = #{params[:id]}\")\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, :notice => 'Interest was successfully created.' }\n format.json { render :json => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def create\n if user_interest_params && @current_user.id == user_interest_params[:user_id].to_i #only create them if the current user = the parameter user\n \n @user_id = user_interest_params[:user_id]\n\n count = 1\n interests_to_add = does_interest_exist(user_interest_params) #only add interests that don't exist yet\n \n if interests_to_add.length >= 1 #only run this if there are interests to add\n interests_to_add.each do |interest|\n @user_interest = UserInterest.new(user_id: @user_id, interest_id: interest)\n \n if @user_interest.save\n if count == interests_to_add.length #show success only for the last one\n render json: { \n status: 200,\n message: \"Successfully added user interests\",\n user_interests: @user_interest\n }.to_json\n end\n else\n render json: {\n status: 500,\n message: \"Couldn't save user interests\",\n errors: @user_interest.errors\n }.to_json\n end\n count += 1\n end\n else #if there are no interests to add, state so.\n render json: {\n status: 200,\n message: \"No interests to add\"\n }.to_json\n end\n else\n render json: {\n status: 400,\n message: \"Invalid authentication\"\n }.to_json\n end\n end", "def save_interest\n @record_count = Interest.find_all_by_user_id(current_user.id)\n @interest = Interest.new(:category_id => params[:category_id], :subcategory_id => params[:subcategory_id], :user_id => current_user.id)\n @same_pair = Interest.find_same_pair(params[:category_id], params[:subcategory_id], current_user.id)\n if (@same_pair.empty? && @record_count.count != 15)\n @interest.save\n else\n if(!@same_pair.empty?)\n @interest = {:message => \"same pair.\"}\n elsif(@record_count.count == 15)\n @interest = {:message => \"limit exceed.\"}\n end\n end\n respond_to do |format|\n format.json { render :json => @interest }\n end\n end", "def add_reciever(db, name, gift, cost)\n db.execute(\"INSERT INTO personal_gift (name, gift, cost, purchased_id) VALUES (?, ?, ?, 2)\", [name, gift, cost])\nend", "def add_wine(db,wine_name,vineyard,vintage_year,rating,region_id)\n\tdb.execute(\"INSERT INTO wine_type (wine_name, vineyard,vintage_year,rating,region_id) \n\tVALUES (?,?,?,?,?)\",[wine_name,vineyard,vintage_year,rating,region_id])\nend", "def new\n\t\t@interest = Interest.new\t\n\tend", "def add_interest(rate)\n #add_interest(rate): Calculate the interest on the balance and add the interest to the balance. Return the interest that was calculated and added to the balance (not the updated balance).\n # Input rate is assumed to be a percentage (i.e. 0.25).\n\n interest = (@balance * rate/100).to_i #want to ensure whole cent values.\n @balance = @balance + interest\n\n return interest\n end", "def add_interest(rate)\n @interest = balance * (rate/100)\n @balance += interest\n return interest\n end", "def _add_interest(interest)\n return interest if interests.include?(interest)\n super(interest)\n end", "def add_entry(db, book_name, year_pubished, genre, author, rating, read)\n\tdb.execute(\"INSERT INTO books (book_name, year_pubished, genre, author, rating, read) VALUES (?, ?, ?, ?, ?, ?)\", [book_name, year_pubished, genre, author, rating, read])\nend", "def seed_interests(database=\"acani-staging\", collection=\"i\")\n interests = Mongo::Connection.new.db(database).collection(collection)\n interests.drop\n @@interest_id = 0\n require 'yaml'\n interests_yml = File.join(SEED_DIR, \"interests.yml\")\n interests_hash = YAML::load_file(interests_yml)\n def interests.insert_interest(interest_object, parent_id=nil)\n interest_id = @@interest_id.to_s(36)\n if interest_object.instance_of? String # base case\n insert({:_id => interest_id, :n => interest_object, :p => parent_id})\n @@interest_id += 1\n else # it's a hash\n interest_k_v = interest_object.first # get the only key-value pair in hash\n interest_name = interest_k_v[0] # key is the name\n insert({:_id => interest_id, :n => interest_name, :p => parent_id})\n @@interest_id += 1\n interest_k_v[1].each do |i| # value is an array of children\n insert_interest(i, interest_id)\n end\n end\n end\n interests.insert_interest interests_hash\n puts \"Seeded #{collection} collection in #{database} database with interests.yml.\"\n puts\n end", "def set_user_interest\n @user_interest = UserInterest.find(params[:id])\n end", "def create\n @interest = Interest.new(params[:interest])\n\n respond_to do |format|\n if @interest.save\n flash[:notice] = 'Interest was successfully created.'\n format.html { redirect_to(@interest) }\n format.xml { render :xml => @interest, :status => :created, :location => @interest }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interest.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @interest = Interest.new(interest_params)\n authorize @interest\n respond_to do |format|\n if @interest.save\n format.html { redirect_to @interest, notice: t('flash.notice.created') }\n format.json { render :show, status: :created, location: @interest }\n else\n format.html { render :new }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_income(db, user_name, dolla_dolla_bills_yall)\r\n\tnew_income_total = (dolla_dolla_bills_yall.to_i + current_income(db, user_name))\r\n\tchange_income = '\r\n\tUPDATE users \r\n\r\n\tSET actual_income = ?\r\n\tWHERE name = ?'\r\n\tdb.execute(change_income, [new_income_total, user_name])\r\nend", "def add_to_database\n Partner.add({\"assignment_id\" => \"#{self.assignment_id}\", \"name_worked\" => \"#{self.name_worked}\"})\n end", "def add_invoice\n if invoice_exist?\n update_invoice\n else\n Invoice.insert(invoice_number: invoice, rate: rate, hours: hours, amount: amt, client_id: client_id, post_date: post_date, provider_id: provider.id, client_name: client_name.strip)\n end\n end", "def new_institution(inst_name, inst_site, inst_number, inst_email)\n Institution.transaction do\n new_institution = Institution.new(name: inst_name,\n website: inst_site,\n phone_number: inst_number,\n email: inst_email)\n new_institution.id = @inst_id\n @inst_id += 1 if new_institution.save!\n @institutions << new_institution\n end\n end", "def create\n @user_interest = UserInterest.new(user_interest_params)\n\n respond_to do |format|\n if @user_interest.save\n format.html { redirect_to @user_interest, notice: 'User interest was successfully created.' }\n format.json { render :show, status: :created, location: @user_interest }\n else\n format.html { render :new }\n format.json { render json: @user_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_interest(rate = 0.25)\n interest = @balance * rate/100\n @balance += interest\n return interest\n end", "def add_interest(rate)\n temp_bal = super\n @balance = temp_bal.round\n puts \"New total in your account is #{money_convert(balance)}\"\n # extract only interest\n interest = balance * (rate/100)\n interest = interest.round\n puts \"Interest accumelated was #{money_convert(interest)}\"\n return interest\n end", "def add_friend(db, friend_name, age, birth_month, birth_day, likes_birthdays)\n db.execute(\"INSERT INTO friends (friend_name, age, birth_month, birth_day, likes_birthdays) VALUES (?, ?, ?, ?, ?)\", [friend_name, age, birth_month, birth_day, likes_birthdays])\nend", "def add_interest(rate = @interest_rate)\n raise ArgumentError.new \"Rate must be greater than 0\" unless rate > 0\n total_interst = @balance * rate/100\n @balance += total_interst\n return total_interst\n\n end", "def interest_params\n params.require(:interest).permit(:user_id, :animal_id, :date)\n end", "def find_interest_id(db, interest_name)\n interest_id = db.execute(\"SELECT interests.id FROM interests WHERE interest='#{interest_name}'\")\n interest_id[0][0]\nend", "def add_region(db, state,country)\n\tdb.execute(\"INSERT INTO region (state, country) VALUES(?,?)\", [state,country])\nend", "def add_price(asin, title, price_s, price_i, day, day_i)\r\n $db.execute(\"INSERT INTO prices (asin, title, price_s, price_i, day, day_i) VALUES (?,?,?,?,?,?)\", [asin, title, price_s, price_i, day, day_i])\r\nend", "def db_adder(database, year, variety, region, notes)\n database.execute(\"INSERT INTO wine_cellar (year,variety,region,notes) VALUES (?,?,?,?)\", [year,variety,region,notes])\nend", "def add_interest(rate)\n @interest = @balance * (rate/100)\n return @interest\n end", "def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end", "def create\n @user = User.find(params[:user])\n @animal = Animal.find(params[:animal])\n @interest = Interest.new(user_id: @user.id, animal_id: @animal.id, date: Date.today)\n\n respond_to do |format|\n if @interest.save\n format.html { redirect_to :back, notice: 'You sent an interest to the animal' }\n format.json { head :no_content }\n else\n format.html { redirect_to animals_url, notice: @interest.errors.full_messages[0] }\n format.json { head :no_content }\n end\n end\n end", "def set_student_interest\n @student_interest = StudentInterest.find(params[:id])\n end", "def new_entry (total_cost, tip_percentage, people, total_cost_with_tip, final_per_person)\n DATABASE.execute(\"INSERT INTO split_checks (total_cost, tip_percentage, people, total_cost_with_tip, final_per_person) VALUES (#{total_cost}, #{tip_percentage}, #{people}, #{total_cost_with_tip}, #{final_per_person});\")\nend", "def interest_params\n params.require(:interest).permit(:label, :uri)\n end", "def set_eventinterest\n @eventinterest = Eventinterest.find(params[:id])\n end", "def add_volatility_rows(db, q1, q2, q3, q4, q5)\n db.execute(\"INSERT INTO volatility_table \n (quintile_1, quintile_2, quintile_3, quintile_4, quintile_5) \n VALUES (?, ?, ?, ?, ?)\", [q1, q2, q3, q4, q5])\nend", "def add_interst\n return @balance + (@balance*@interest_rate)\n end", "def addtodb(barcode, numb)\n\tlog \"in addtodb\"\n db=SQLite3::Database.open \"/home/nspeare/scripts/PRC_HO.db\"\n\ttm=Time.new.strftime(\"%Y-%m-%d\")\n db.execute \"insert into barcodes values ('#{barcode}', '#{tm}', #{numb.to_i})\"\n db.close\nend", "def set_pending_interest\n @pending_interest = PendingInterest.find(params[:id])\n end", "def set_interest # :norobots:\n pass_query_params\n type = params[:type].to_s\n oid = params[:id].to_i\n state = params[:state].to_i\n uid = params[:user]\n target = Comment.find_object(type, oid)\n if @user\n interest = Interest.find_by_target_type_and_target_id_and_user_id(type, oid, @user.id)\n if uid && @user.id != uid.to_i\n flash_error(:set_interest_user_mismatch.l)\n elsif !target && state != 0\n flash_error(:set_interest_bad_object.l(:type => type, :id => oid))\n else\n if !interest && state != 0\n interest = Interest.new\n interest.target = target\n interest.user = @user\n end\n if state == 0\n name = target ? target.unique_text_name : '--'\n if !interest\n flash_notice(:set_interest_already_deleted.l(:name => name))\n elsif !interest.destroy\n flash_notice(:set_interest_failure.l(:name => name))\n else\n if interest.state\n flash_notice(:set_interest_success_was_on.l(:name => name))\n else\n flash_notice(:set_interest_success_was_off.l(:name => name))\n end\n end\n elsif interest.state == true && state > 0\n flash_notice(:set_interest_already_on.l(:name => target.unique_text_name))\n elsif interest.state == false && state < 0\n flash_notice(:set_interest_already_off.l(:name => target.unique_text_name))\n else\n interest.state = (state > 0)\n interest.updated_at = Time.now\n if !interest.save\n flash_notice(:set_interest_failure.l(:name => target.unique_text_name))\n else\n if state > 0\n flash_notice(:set_interest_success_on.l(:name => target.unique_text_name))\n else\n flash_notice(:set_interest_success_off.l(:name => target.unique_text_name))\n end\n end\n end\n end\n end\n if target\n redirect_back_or_default(:controller => target.show_controller,\n :action => target.show_action, :id => oid,\n :params => query_params)\n else\n redirect_back_or_default(:controller => 'interest',\n :action => 'list_interests')\n end\n end", "def create\n @interest = Interest.new(interest_params)\n @interest.user_id=current_user.id\n if(@interest.save)\n render json: {\"success\":true,\"message\":\"Done!\"}\n else\n render json: {\"success\":false,\"message\":@interest.errors}\n end\n # respond_to do |format|\n # if @interest.save\n # format.html { redirect_to @interest, notice: 'Interest was successfully created.' }\n # format.json { render :show, status: :created, location: @interest }\n # else\n # format.html { render :new }\n # format.json { render json: @interest.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n @event_interest = EventInterest.new(params[:event_interest])\n\n respond_to do |format|\n if @event_interest.save\n format.html { redirect_to @event_interest, notice: 'Event interest was successfully created.' }\n format.json { render json: @event_interest, status: :created, location: @event_interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_book(db, title, author, rating)\n db.execute(\"INSERT INTO books (title, author, rating) VALUES (?, ?, ?)\", [title, author, rating])\nend", "def interest_params\n params.require(:interest).permit(:name, :interest_category_id, :highlight, :include_on_application, :inactive)\n end", "def update\n standard_update(Interest, params[:id], interest_params)\n end", "def create\n @interests = Interests.new(params[:interests])\n @interests.person = @person\n\n respond_to do |format|\n if @interests.save\n flash[:notice] = 'Interests saved.'\n format.html { redirect_to(welcome_path(:id => @person)) }\n format.xml { render :xml => @interests, :status => :created, :location => @interests }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @interests.errors, :status => :unprocessable_entity }\n end\n end\n end", "def insert_author_affiliation(affi_object, cd_affi_ids)\n # insert the object\n # get the id of the inserted object\n # update all cr_affiliations with the author_affiliation_id\n sql_statement = \\\n \"SELECT id, name FROM cr_affiliations WHERE article_author_id = \" + affi_object.article_author_id.to_s + \";\"\n db = get_db()\n #stm = db.prepare sql_statement\n #rs = stm.execute\n\n db.execute(\"INSERT INTO Author_Affiliations VALUES (?,?,?,?,?,?,?,?,?,?,?,?)\", 1, affi_object.article_author_id, affi_object.name, affi_object.short_name,\n affi_object.add_01, affi_object.add_02, affi_object.add_03,affi_object.add_04, affi_object.add_05, affi_object.country,'2020-09-27','2020-09-27')\nend", "def update\n @interest = Interest.find(params[:id])\n if @interest.update_attributes(params[:interest])\n redirect_to interests_path\n else\n redirect_to :action => 'edit', :id => @interest.id\n end\n end", "def interest_params\n params.require(:interest).permit(:name)\n end", "def store_interest_update\n self.last_interest_update = Time.now\n end", "def add_borehole(db, desig, north, east, elev, proj_id)\n db.execute(\"INSERT INTO boreholes \n (designation, northing, easting, elevation, project_id)\n VALUES (?, ?, ?, ?, ?)\", [desig, north, east, elev, proj_id])\nend", "def add_new_school(db, name)\n db.execute(\"INSERT INTO school (name) VALUES (?)\", [name])\nend", "def enter_calories(db, day, amt_burned, member_id) \n month = Time.now.strftime(\"%m\") \n db.execute(\"INSERT INTO calories (day, month, amt_burned, member_id) VALUES (?, ?, ?, ?)\", [day, month, amt_burned, member_id]) \nend", "def index\n @interests = Interest.all\n end", "def index\n @interests = Interest.all\n end", "def interest_params\n params.require(:interest).permit(:rating, :comment)\n end", "def add_user(db, name, age, current_weight, goal_weight, max_mile)\n\tdb.execute(\"INSERT INTO users (name, age, current_weight, goal_weight, max_mile) \n\tVALUES (?, ?, ?, ?, ?);\", [name, age, current_weight, goal_weight, max_mile]\n\t)\nend", "def add_lifts(db, date, body_weight, squats, bench_press, overhead_press, deadlifts, power_cleans, comments)\n db.execute(\"INSERT INTO lifting (date, body_weight, squats, bench_press, overhead_press, deadlifts, power_cleans, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?)\", [date, body_weight, squats, bench_press, overhead_press, deadlifts, power_cleans, comments])\nend", "def add_to_database\n if self.can_drink?\n CONNECTION.execute(\"INSERT INTO students (name, age) VALUES ('#{@name}', #{@age});\")\n \n @id = CONNECTION.last_insert_row_id\n else\n false\n end\n end", "def add_input (db, user_input)\r\n db.execute(\"INSERT INTO strength (date, exercise, weight, reps, minutes, difficult) VALUES (?, ?, ?, ?, ?, ?)\", [user_input])\r\nend", "def pay_interest_on(account)\n # first interest is calculated and stored to local variable\n interest = calculate_interest(account)\n # if statement used to check if account is overdrawn\n if account.overdrawn?\n # if it is the interest is subtracted\n account.withdraw interest\n @master.deposit interest\n else\n # else the interest is added\n @master.withdraw interest\n account.deposit interest\n end\n end", "def set_mentoring_interest\n @mentoring_interest = MentoringInterest.find(params[:id])\n end", "def add_monthly_interest\n\t\t@debt *= 1.015\n\t\t@balance *= 1.0003\n\tend", "def create_house_info(db, address, price, years_of_mortgage, interest_rate, monthly_pmt)\n\tdb.execute(\"INSERT INTO house_info (address, price, years_of_mortgage, interest_rate, monthly_pmt) VALUES (?, ?, ?, ?, ?)\", [address, price, years_of_mortgage, interest_rate, monthly_pmt])\nend", "def create_interest_params\n params.permit(:yelp_id, :interests => [:min_seats, :max_seats, :datetime])\n end", "def enter_weight(db, day, current_weight, member_id)\n month = Time.now.strftime(\"%m\") \n db.execute(\"INSERT INTO weight (day, month, current_weight, member_id) VALUES (?, ?, ?, ?)\", [day, month, current_weight, member_id])\nend", "def create\n @person_interest = PersonInterest.new(params[:person_interest])\n\n respond_to do |format|\n if @person_interest.save\n format.html { redirect_to @person_interest, notice: 'Person interest was successfully created.' }\n format.json { render json: @person_interest, status: :created, location: @person_interest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @person_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def gain_interest\n # Assuming 2% interest rate would be entered as 2,\n # Divide rate by 100, to create 0.02 -- then\n # Add 1, to create 1.02 -- then\n # Multiply @balance by 1.02\n\n interest_div = @interest_rate / 100.0 # changes 2 to 0.02\n\n interest_add = interest_div + 1 # changes 0.02 to 1.02\n\n @balance = @balance * interest_add\n\n puts \"Your money accumulated interest. Now your balance is $#{ @balance }.\"\n end", "def add(opinion, should_save=true)\n self.opinions << opinion\n update_attributes(:opinion_ids => opinion_ids) if should_save\n end", "def contractor_insert(h)\n \t\trows = @database.execute <<-SQL\n\t\t\tINSERT INTO contractor\n\t\t\t\t(name\n\t\t\t\t, contractor_id\n\t\t\t\t, rate\n\t\t\t\t)\n\t\t\tVALUES\n\t\t\t\t('#{h['name']}'\n\t\t\t\t, '#{h['contractor_id']}'\n\t\t\t\t, '#{h['rate']}'\n\t\t\t\t)\n\t\tSQL\n\tend", "def set_interest_point\n @interest_point = InterestPoint.find(params[:id])\n end", "def gain_interest\n interest_amount = (@balance * @interest_rate) / 100\n @balance = interest_amount + @balance\n end", "def set_interestversion\n @interestversion = Interestversion.find(params[:id])\n end", "def invoice_insert(h)\n\t\trows = @database.execute <<-SQL\n\t\tINSERT INTO invoices\n\t\t\t( number\n\t\t\t, organization\n\t\t\t, updated\n\t\t , amount\n\t\t\t, amount_outstanding\n\t\t\t, discount\n\t\t \t, invoice_id\n\t\t\t, matter\n\t\t\t, date\n\t\t\t, status)\n\t\tVALUES\n\t\t('#{h['number']}'\n\t\t, '#{h['organization']}'\n\t\t, '#{h['updated']}'\n\t\t, '#{h['amount']}'\n\t\t, '#{h['amount_outstanding']}'\n\t\t, '#{h['discount']}'\n\t\t, '#{h['invoice_id']}'\n\t\t, '#{h['matter']}'\n\t\t, '#{h['date']}'\n\t\t, '#{h['status']}'\n\t \t )\n\t\t SQL\n\tend", "def add_asin(asin)\r\n match = $db.execute(\"SELECT asin FROM asins WHERE asin = ?\", [asin])\r\n if match == []\r\n $db.execute(\"INSERT INTO asins (asin) VALUES (?)\", [asin])\r\n end\r\nend", "def add_work_item(data)\n name = @table_name.to_s\n sql = @model.from(name.to_sym).insert_sql(\n description: data[:description],\n guide: data[:guide],\n status: data[:status],\n username: data[:name],\n archived: 0\n )\n sql = _format_sql(sql)\n @logger.info(\"Prepared POST query: #{sql}\")\n response = run_statement(sql, \"post\")\n id = response[0][:long_value]\n @logger.info(\"Successfully created work_item_id: #{id}\")\n id\n end", "def create_regimen(db, name, age, vitamin)\n db.execute(\"INSERT INTO regimen (name, age, vitamin) VALUES (?, ?, ?)\", [name, age, vitamin])\nend", "def add_family(db, name, age)\r\n\tdb.execute(\"INSERT INTO family (name, age) VALUES (?, ?)\", [name, age])\r\nend", "def perform(loc_obj)\n puts ''\n puts \"===== End of Billing Cycle: Adding Interest Accrued to LoC ID #{loc_obj.id} =====\"\n puts ''\n new_bal = loc_obj.principal_bal\n interest = calculate_interest(loc_obj, loc_obj.principal_bal)\n\n loc_obj.interest += interest\n new_bal = loc_obj.principal_bal + interest\n loc_obj.principal_bal = new_bal.round(2)\n loc_obj.interest = 0.0\n loc_obj.save\n\n ApplyInterestCycleJob.set(wait: 30.days).perform_later(loc_obj)\n end", "def user_interest_params\n params.permit(\n :user_id, :interest_id, :value\n )\n end", "def interest_params\n params.require(:interest).permit(:n_empenho, :aplicacao, :rsrp, :obs, :pregao, :company_id, :emissao, :processo, \n :sims_squad_id, :data_envio, :prazo, :avatar, :user_cadastro, :user_atualiza,\n :especifications_attributes => [:id, :descricao, :type_id, :qtde, :valor_un, :modality_id, :_destroy])\n end", "def add_student(first_name, last_name, birthdate)\n @conn.exec(\"INSERT INTO students_db (first_name, last_name, birthday) VALUES ('#{first_name}', '#{last_name}', '#{last_name}', '#{birthdate}');\")\nend", "def gain_interest\n @balance *= (1 + @interest_rate)\n end", "def add_student(database, name)\r\n\tdatabase.execute(\"INSERT INTO students (name) VALUES (?)\", [name])\r\nend", "def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.7968279", "0.77632064", "0.68672884", "0.6721698", "0.65774286", "0.65774286", "0.65774286", "0.65774286", "0.65774286", "0.6483784", "0.63011116", "0.6286764", "0.6194512", "0.61882764", "0.6170924", "0.61625606", "0.61574566", "0.6108701", "0.6105049", "0.6079302", "0.6055844", "0.6039928", "0.600946", "0.5998283", "0.59978706", "0.5983066", "0.59592247", "0.5943277", "0.59312105", "0.58939105", "0.5855663", "0.58554184", "0.5847283", "0.58455133", "0.58410054", "0.5838148", "0.5837826", "0.5833969", "0.581782", "0.57896715", "0.57811725", "0.57481927", "0.57451236", "0.57424104", "0.5726861", "0.570474", "0.56793535", "0.56709594", "0.5653222", "0.5652501", "0.56368923", "0.56364787", "0.5625813", "0.5624085", "0.5623703", "0.5615277", "0.5596849", "0.5587716", "0.5558304", "0.5556071", "0.55559725", "0.5552675", "0.55420035", "0.55398166", "0.55370665", "0.5527471", "0.5489429", "0.5480641", "0.54781234", "0.54781234", "0.5473205", "0.54696584", "0.54686785", "0.545822", "0.54505605", "0.5449304", "0.54415935", "0.54379183", "0.5425742", "0.5420472", "0.5419194", "0.5416009", "0.541522", "0.5412571", "0.5412251", "0.540918", "0.54049844", "0.5396225", "0.5388493", "0.53859246", "0.53846043", "0.5381376", "0.5378801", "0.5370986", "0.5370495", "0.5368282", "0.536704", "0.53667104", "0.53609246", "0.5358241" ]
0.8421365
0
method that adds a friend to friend_db database
def add_friend(db, friend_name, age, birth_month, birth_day, likes_birthdays) db.execute("INSERT INTO friends (friend_name, age, birth_month, birth_day, likes_birthdays) VALUES (?, ?, ?, ?, ?)", [friend_name, age, birth_month, birth_day, likes_birthdays]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_friend(friend)\n raise ArgumentError unless friend\n raise ArgumentError.new(\"Already friended\") if friends.include? friend\n\n f = Friendship.new :user_id => self.id, :friend_id => friend.id\n return f.save\n end", "def add_friend\n # check if this friend isnt't to our list friend\n if params[:user_id].to_i == params[:friend_id].to_i \n render json: {\n message: \"Not yourself\"\n }, status: 400\n else\n @current_user = User.find(params[:user_id])\n if @current_user.friend.find_by(friend: params[:friend_id])\n render json: {\n message: \"#{User.find(params[:user_id]).name} can't be added, You are friend with this user\",\n errors: {\n error_code: \"\",\n error_description: \"\"\n }\n }, status: 401\n else\n # add friend\n puts \"Starting adding friend ...\"\n @new = @current_user.friend.new(friend: params[:friend_id], status: :pending)\n if @new.save\n render json: {\n message: \"#{User.find(params[:user_id]).name} added as friend\"\n }, status: 201\n else\n render json: {\n message: @new.errors.messages\n }, status: 401\n end\n end\n end\n\n end", "def add_friend_interest(db, friend_id, interest_id)\n db.execute(\"INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)\", [friend_id, interest_id])\nend", "def add_friend\n\t\t# unless @current_user.friends.include? params[:id] \n\t\t@current_user.push(friends: params[:id])\n\t\t# push to friends array id number of friend\n\n\t\tredirect_to \"/profile/#{@current_user.id}\"\n\t\t# show the new friend\n\tend", "def add_friend\n\n current_user.friends_list.push(define_friend)\n # binding.pry\n if current_user.save\n render json: current_user \n else\n render json: @user.errors, status: 422\n end\n\n end", "def add_friend(name)\n # If friend does not already exist, create them without a phone number.\n friend = User.find_by_name name.downcase\n if !friend.nil? && !friend.id.nil?\n puts \"Found user, #{friend.id}, creating Friendship\"\n Friendship.create(:user_1_id => self.id, :user_2_id => friend.id)\n else\n friend = User.create :name => name.downcase\n if !friend.nil? && !friend.id.nil?\n puts \"Found no user, created use, #{friend.id}, creating Friendship\"\n Friendship.create(:user_1_id => self.id, :user_2_id => friend.id)\n else\n puts \"Found no user and could not create new User.\"\n return false\n end\n end\n end", "def create_friends(db, name, status, check_in)\r\n\tdb.execute('INSERT INTO friends (name, status, check_in) VALUES\t(?, ?, ?)', [name, status, check_in])\r\nend", "def create\n current_user.friends.create(\n friend_id: @user.id\n )\n redirect_to root_path\nend", "def add_friend\n # byebug\n #we get user_id from jwt!\n user = User.find(decode_jwt(cookies.signed[:jwt])[\"user_id\"])\n #we get friend_id from frontend\n if !Block.where(blocker_id: user.id, blockee_id:follow_params[:user2]).empty?\n return render json: {error: \"There was a problem! (Ya been blocked!)\"}\n end\n\n followee = User.find(follow_params[:user2])\n #insert the one way relation in db!\n friend_request = Follow.new(follower_id: user.id, followee_id: followee.id)\n if friend_request.save\n render json: {friend_request: followee} \n else\n render json: {error: \"There was a problem!\"}\n end\n end", "def add_first_friend\n if User.count > 0\n f = self.friendships.create!(:friend_id => User.find_by_username(DEFAULT_FRIEND_NAME).id)\n f.status=true;\n f.save\n end\n end", "def add_friend\n # If there is no pending connection between persons,\n # add pendind/requested connections between them.\n # If there is already a pending connection requested from the other direction,\n # change friendship status to accepted.\n\n if (params['user_id'] == params['friend_id'])\n render_json :messages => \"Cannot add yourself to your friend.\", :status => :bad_request and return\n end\n\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n @friend = Person.find_by_guid(params['friend_id'])\n if ! @friend\n render_json :status => :not_found and return\n end\n\n if @person.association? or @friend.association?\n render_json :messages => \"Association users cannot have friends.\", :status => :bad_request and return\n end\n\n if @person.pending_contacts.include?(@friend) #accept if pending\n Connection.accept(@person, @friend)\n else\n unless @person.requested_contacts.include?(@friend) || @person.contacts.include?(@friend)\n Connection.request(@person, @friend) #request if didn't exist\n end\n end\n\n render_json :status => :ok\n end", "def befriend new_friend\n run_callbacks :befriend do\n friendships.create friend: new_friend\n end\n end", "def befriend! new_friend\n run_callbacks :befriend do\n friendships.create! friend: new_friend\n end\n end", "def friend\n @user.friendships.build(friend_id: @friend.id)\n if @user.save\n render json: { success: true }\n else\n render json: {message: @user.errors&.messages || 'Unable add as friend, please try again'}, status: 202\n end\n end", "def add\n id = params.require(:friend_id)\n current_user.friendships.create friend_id: id\n\n respond_to do |format|\n format.html { redirect_to friends_path, alert: \"#{User.find(id).name} is now your friend\" }\n format.json { render :json => {success: 'OK'} }\n end\n end", "def add_future_friend(friend_id)\n add_future_params(:add_friends, [friend_id])\n end", "def add_friend(receiver)\r\n self.friends << receiver\r\n receiver.friends << self\r\n self.friends.save && receiver.friends.save\r\n end", "def create\n @friend = Friend.new(params[:friend])\n\[email protected]_id = flash[:user_id]\n @friend.image_url = \"http://128.100.195.55:3000/content/friendphoto2.jpg\";\n @user = User.find(@friend.user_id);\n @user.friends << @friend;\n \n respond_to do |format|\n if @friend.save\n flash[:notice] = 'Friend was successfully created.'\n format.html { redirect_to(@friend) }\n format.xml { render :xml => @friend, :status => :created, :location => @friend }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @friend.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add\n params[:friends].each do |email|\n friend = User.find_by_email(email)\n next unless friend.present?\n\n # Check the inverse friendship and add if necessary\n friendship = Friendship.find_by_user_id_and_friend_id(friend.id, current_user.id)\n unless friendship.present?\n inverse_friendship = friend.friendships.build(friend_id: current_user.id)\n if inverse_friendship.save\n puts \"Added friendship for #{friend.name} (#{friend.id}) and #{current_user.name} (#{current_user.id})\"\n end\n end\n end\n\n render json: { success: true }\n end", "def create\n logger.debug('In the create method afterall')\n logger.debug( friend_params )\n current_user.friendships.create!(:friend_id => params[:friend_id]) \n\n redirect_to friendship_index_path\n end", "def create\n @friendship = current_user.friendships.build(friend_id: params[:friend_id])\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:alert] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end", "def friend(other_user)\n friendships.create!(friend_id: other_user.id)\n end", "def enfriend!(friend)\n friendships.create(friend: friend)\n friend.friendships.create(friend: self)\n end", "def addFriend\n #Now i have this friend data from the data base and i already have the groupId\n #get the friend name\n @notify = current_user.invited_members;\n\t\t@friendName = params[:name]\t\n #check if it is null\n if @friendName.empty?\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'Please insert some data !' }\n format.json { head :no_content }\n end\n else\n #check if it is wrong type\n if User.exists? name: @friendName\n #it is really a user\n #check if he is tring to add himself\n if @friendName == current_user.name\t\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'Cant inser your self!' }\n format.json { head :no_content }\n end\n else\t\n #check if the user exist in the group itself before\n @fid = User.find_by(name: params[:name])\n @current_group = Group.find(params[:groupId])\n if @current_group.group_members.exists? user: @fid.id \t \n puts \"why you are tring to add the same friend\"\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'This Friend is already assigned to this group !!' }\n format.json { head :no_content }\n end\n else\n #check if this user in friendship list or not\n @fid = User.find_by(name: params[:name])\n @user = current_user\n if @user.user_friends.exists? friend: @fid.id\n @fid = User.find_by(name: params[:name])\n @gid = params[:groupId]\n @group = @fid.group_members.create(group_id: @gid)\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'This Friend is Add !!' }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'This user is not currently in your friend list! !!' }\n format.json { head :no_content }\n end\n \t\n end\n end\t\t\t\t\t\n \n \n end\t\n else\n #it is a robot\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'This user is not exist !' }\n format.json { head :no_content }\n\n end\t\n end\n end\t\t\n\n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:id])\n \n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_path\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_path\n end\n end", "def fb_add_friend(name = 'Add as a friend', options = {})\n options = {\n :method => 'friends',\n :callback => 'function(response) {}'\n }.merge(options)\n\n fb_ui name, options\n end", "def add_friend(sender_id)\n Logger.d(\"Got install referrer : sender_id:#{sender_id}\")\n \n return if sender_id.nil? or sender_id.length == 0\n\n json = {\n :id => sender_id,\n :auth_token => get(:auth_token)\n }.to_json\n\n network_post(CONFIG.get(:add_friend), nil, json, @on_api_call_failed) do |user_object|\n if is_valid_network_user_object?(user_object)\n @data = user_object\n Logger.d(\"Success in @user.add_friend => \" + user_object.to_s)\n serialiaze() # Write the object to persistent storage\n request_ui_refresh \n end\n end \n end", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n @friendship.status = \"SENT\"\n if @friendship.save\n flash[:notice] = \"Added friend.\"\n redirect_to root_url\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to root_url\n end\n end", "def add\n\t\treturn ERR_INVALID_NAME if not name_valid?\n\t\treturn ERR_INVALID_EMAIL if not email_valid?\n\t\treturn ERR_INVALID_PASSWORD if not password_valid?\n\t\treturn ERR_EMAIL_TAKEN if not email_available?\n\t\tcreate_remember_token\n\t\tself.friend_list = Array.new\n\t\tself.event_list = Array.new\n\t\tself.notification_list = Array.new\n\t\tself.save\n\t\tSUCCESS\n\tend", "def add\n @user = begin User.find(params[:id]) rescue nil end\n @saved = false\n if @user\n if @friend = FriendsUser.find(:first, :conditions =>{:user_id => current_user.id, :friend_id => @user.id})\n if @friend.status != \"accepted\"\n @friend.update_attribute(:status, \"accepted\") if FriendsUser.exists?(:user_id => current_user.id, :friend_id => @user.id )\n @message = flash[:notice] = \"You have added #{@user.display_name} as a favorite\"\n else\n @message = flash[:notice] = I18n.t('friend.add.notice1')\n end\n else\n @friend = User.find(params[:id]) if User.exists?(:id => @user.id)\n if FriendsUser.new(:user_id => current_user.id, :friend_id => @user.id, :status => \"accepted\").save\n @saved = true\n # UserMailer.friend_request_notification(current_user, @friend).deliver\n @message = flash[:notice] = @friend ? \"You have added #{@friend.display_name} as a favorite\" : I18n.t('friend.add.notice3')\n else\n @message = flash[:error] = \"#{I18n.t('friend.add.error')} #{@friend.display_name} #{I18n.t('friend.add.error1')}.\"\n end\n end\n else\n @message = flash[:error] = I18n.t('user.general_error')\n end\n if request.xhr?\n respond_to do |format|\n format.js\n end\n else\n redirect_to user_friends_path(current_user)\n end\n end", "def add_friend(user, destination_user)\n manage_friend user,destination_user, 'added'\n end", "def add_friends\n @params[:friend_ids].each do |id|\n @plan.users_plans.new(user_id: id)\n end\n end", "def create\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n unless relationship\n current_user.add_friend(User.find(params[:user_two_id]))\n relationship = Relationship.between(current_user.id, params[:user_two_id]).first\n relationship.status = 1\n relationship.save\n end\n friend = User.find_friend(current_user, relationship)\n redirect_to friendlist_path\n end", "def follow!(amigo_id)\n self.friendships.create!(friend_id: amigo_id)\n \n end", "def add_or_update(buddy)\n sql = \"SELECT * FROM buddy WHERE guid='#{buddy.guid}';\"\n result = @db.execute(sql)\n if result.empty? # add a new one\n sql = \"INSERT INTO buddy VALUES('%s',%d);\"\\\n % [buddy.guid,buddy.relationship]\n else\n buddy.relationship |= result[0][1].to_i # update old relationship\n sql = \"UPDATE buddy SET relationship=%d WHERE guid='%s';\"\\\n % [buddy.relationship,buddy.guid]\n end\n @db.execute(sql)\n end", "def create \n @friend = User.find(params[:friend_id])\n @friendship = Friendship.create_or_accept(@user, @friend) \n\n flash[:notice] = \n if @user.is_friends_with?(@friend)\n \"You and #{@friend.login} are now friends!\"\n else\n \"You are now an admirer of #{@friend.login}\"\n end\n\n redirect_to user_path(@friend)\n end", "def request_friendship(user_2)\n \tself.friendships.create(friend: user_2)\n end", "def add_friend(person, friend)\nperson[:friends].push(friend)\nend", "def add_friend(person, friend)\nperson[:friends].push(friend)\nend", "def accept\n\t\tuser.friends << friend\n\t\tdestroy\n\tend", "def save_friendships\n array = friendlist(current_user)\n puts \"array: \\n #{array}\"\n array.each do |user|\n puts \"user id is #{user.id}\"\n puts \"current user is #{current_user.id}\"\n if Friendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).exists?\n puts \"Friendship already exists: #{Friendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).inspect}\"\n next\n elsif Friendship.where(\"user_id = ? AND friend_id = ?\", user.id, current_user.id).exists?\n puts \"Friendship already exists: #{Friendship.where(\"user_id = ? AND friend_id = ?\", user.id, current_user.id).inspect}\"\n next\n elsif (user.id == current_user.id)\n puts \"Can't be friends with yourself!\"\n next\n else\n puts \"#{user.id} isn't a friend of #{current_user.id} yet!\"\n Friendship.create(user_id: current_user.id, friend_id: user.id, friendship_status: \"suggested\")\n end\n end\n end", "def create_friend\n\n \t\tif params[:friends].blank? || params[:friends].size != 2\n \t\t\tlogger.info(\"[FriendUserController]create_friend == params is error ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n \t\temail = params[:friends][0]\n \t\tfriend_email = params[:friends][1]\n\n \t\t# block updates from an email address,if they are not connected as friends, then no new friends connection can be added\n \t\tif BlockUser.exists?(:email=>email,:block_email=>friend_email) || BlockUser.exists?(:email=>friend_email,:block_email=>email)\n \t\t return render :json => {:success => false}\n \t\tend\n \t\t#if they are connected as friends,retrun success is true\n \t\tif FriendUser.exists?(:email=>email,:friend_email=>friend_email) || FriendUser.exists?(:email=>friend_email,:friend_email=>email)\n \t\t\treturn render :json => {:success => true}\n \t\tend\n\n \t\t#create a friend connection between two email addresses.\n \t\tfriend_user = FriendUser.create(:email=>email,:friend_email=>friend_email)\n\n \t\tif friend_user.save\n \t\t\tlogger.info(\"[FriendUserController]create_friend == create a friend connection between two email addresses ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => true}\n \t\telse\n \t\t\tlogger.info(\"[FriendUserController]create_friend == can not create a friend connection between two email addresses,error=#{friend_user.errors.full_messages} ,params ==#{params[:friends]}\")\n \t\t\treturn render :json => {:success => false}\n \t\tend\n \t\t\n \tend", "def create\n #@friendrequest = Friendrequest.new(params[:friendrequest])\n \n @user = User.find(params[:user_id])\n #@friend = Friend.new(params[:friend])\n @friendreq = @user.friendrequests.create(params[:friendrequest].permit(:futurefriend))\n\n respond_to do |format|\n if @friendrequest.save\n format.html { redirect_to @friendrequest, notice: 'Friendrequest was successfully created.' }\n format.json { render json: @friendrequest, status: :created, location: @friendrequest }\n else\n format.html { render action: \"new\" }\n format.json { render json: @friendrequest.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n if current_user.friends.include?(params[:friend_id])\n flash[:notice] = \"It's polite to ask once.\"\n else\n\n\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id], approved: \"false\")\n\n if @friendship.save\n\n\n\n log_activity\n\n flash[:notice] = \"Friend requested.\"\n\n\n\n redirect_to :back\n else\n flash[:error] = \"Unable to request friendship.\"\n redirect_to :back\n end\n end\n end", "def set_friend\n @friend=Friend.where(\"user_id = params[:user_id] AND friend_id=params[:friend_id]\")\n end", "def friend\n if params.include?(:id)\n @user.friends += [User.find(params[:id])]\n elsif params.include?(:username)\n @user.friends += [User.find_by(username: params[:username])]\n end\n redirect_to root_path\n end", "def create\n # @friend = Friend.new(friend_params)\n @friend = current_user.friends.build(friend_params)\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: I18n.t('friend.create') }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_friend(person, new_friend)\n return person[:friends] << new_friend\nend", "def add_friend_request(user_id)\n friend_suggestions.where(user_id: user_id).delete_all\n req = pending_friends.where(id: user_id).first\n if req.present?\n req.accept!\n else\n req = UserFriendRelationship.between(user_id, id).first || user_friend_relationships.create(user_to_id: user_id)\n PubSub::Publisher.new.publish_for([req.user_to], 'friend_request', {source: self.as_basic_json}, {title: full_name(false), body: 'wants to be your friend'})\n end\n # reset_cache('suggested_friends')\n end", "def create_for(user, friend)\n # First check, if the friendship already exsits or the users are equal\n if user == friend or not Friendship.friendship_for_users(user.id, friend.id).blank?\n return nil\n end\n friendship_2 = nil\n # Create the friendship in a transaction\n transaction do\n friendship_1 = create(:user => user, :friend => friend, :user_type => \"User\")\n UserMailer.deliver_friendship_request(friendship_1)\n \n friendship_2 = create(:friend => user, :user => friend, :user_type => \"User\")\n friendship_2.pend!\n end\n friendship_2\n end", "def create\n #@friend = Friend.new(friend_params)\n @friend = current_user.friends.build(friend_params)\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_friend_ids=(attributes)\n # I need this custom attr because without it, the friends that were previously saved are not appended to the new\n # friends that are added in the add_friend form.\nattributes[:friend_ids].each do |attribute|\n if attribute != \"\"\n friend = User.find(attribute)\n create_this_transaction(self, friend.id, attributes[:transactions][:amount])\n set_relationship_for_friendship(friend, attributes)\n if !self.friends.include?(friend)\n self.friends << friend\n end\n end\n end\n self.save\nend", "def make_friendship!(other_user)\n relationship.create!(friend_id: other_user.id)\n other_user.relationship.create!(friend_id: self.id)\n return true\n end", "def create\n # prevent user from adding friends who are already on friends list.\n if @friendship\n render json: { Message: \"You're already friends!\" }, status: :unprocessable_entity\n else\n @friend = current_user.friendships.create(:friend_id => @friend_id)\n render json: @friend, status: 201\n end\n end", "def add_friend(person, friend_to_add)\n person[:friends] << friend_to_add\n return person[:friends].length()\nend", "def addFriend(user)\n method = 'addFriend'\n type = true\n args = {:user=>user}\n return_object type,method,args,true\n end", "def request_friendship (user_2)\n #self will be current user (user_1)\n self.friendships.create(friend: user_2)\n end", "def create\n Friendship.request(@user, @friend)\n @friend = Friendship.find_by_user_id_and_friend_id(@user, @friend)\n render :json => { :success => true, :new_friend => @friend }\n end", "def sync_facebook_friends\n find_facebook_friends_with_accounts.each do |auth| \n if !friend?(auth)\n Friendship.create! do |f|\n f.user_id = self.id\n f.friend_id = auth.id\n end\n end\n \n # Create the inverse friendship to save\n # extra db taxes later when the user logs in\n if !inverse_friend?(auth)\n Friendship.create! do |f|\n f.user_id = auth.id\n f.friend_id = self.id\n end\n end\n end\n end", "def add_family(db, name, age)\r\n\tdb.execute(\"INSERT INTO family (name, age) VALUES (?, ?)\", [name, age])\r\nend", "def request_friendship(user_2)\n self.friendships.create(friend: user_2)\n end", "def add_fb_friends(fb_user_info)\n friend_ids = self.friends.pluck(:id)\n\n (fb_user_info ||= []).each do |index, friend|\n\n auth = UserAuthentication.find_by(provider: \"facebook\", uid: friend['id'])\n user_friend = auth.user if auth\n\n if user_friend && !(friend_ids.include? user_friend.id)\n self.friended_users << user_friend\n end\n end\n end", "def create\n @friend = Friend.new(user_id: params[:user_id], friend_id: params[:friend_id])\n\n respond_to do |format|\n if @friend.save\n format.html { redirect_to @friend, notice: \"Friend was successfully created.\" }\n format.json { render :show, status: :created, location: @friend }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friend.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t \t\t@friend = Friend.new(params[:friend])\n\t\t\t# @friend = Friend.find(params[:id]).comments.new(params[:comment])\n\n\t\tif @friend.save\n\t\t\t@user = User.find(session[:user_id])\n\t\t\tredirect_to @user\n\t\telse\n\t\t\trender action: \"new\"\t\n\t\tend\t\n \tend", "def add_friend(person, friend)\n return person[:friends].push(friend)\nend", "def create\n @friendship = current_user.friendships.build(:friend_id => params[:friend_id])\n if @friendship.save\n flash[:notice] = t('friendship.create')\n else\n flash[:notice] = t('friendship.create_error')\n end\n redirect_to friendships_path\n end", "def create\n if current_user.friends.exists?(params[:friend_request][:receiver_id])\n redirect_to users_show_path(current_user), flash: {notice: \"You are already friend\"}\n else\n @friend_request = FriendRequest.new(friend_request_params.merge(sender_id: current_user.id))\n respond_to do |format|\n if @friend_request.save\n format.html { redirect_to @friend_request, notice: 'Friend request was successfully created.' }\n format.json { render :show, status: :created, location: @friend_request }\n else\n format.html { render :new }\n format.json { render json: @friend_request.errors, status: :unprocessable_entity }\n end\n end\n\n end\n\n\n end", "def add_friend(person, name)\n person[:friends].push(name)\nend", "def add_friend(person, new_friend)\n person[:friends].push(new_friend)\n return person[:friends].length()\nend", "def create\n @friend = Friend.new(friend_params)\n flash[:notice] = if @friend.save\n \"You Sent Friend request to #{@friend.user.name}\"\n else\n \"You already Added #{@friend.user.name} to your list\"\n end\n redirect_to users_path\n end", "def pages_liked(db, friend_id, fan_id)\r\n\tdb.execute('INSERT INTO pages_liked (friend_id, fan_id) VALUES\t(?, ?)', [friend_id, fan_id])\r\nend", "def create_or_update_friendship(friend)\n if Friendship.find_by(user_id: friend.id, friend_id: id) ||\n Friendship.find_by(user_id: id, friend_id: friend.id)\n friendship = Friendship.find_by(user_id: friend.id, friend_id: id) ||\n Friendship.find_by(user_id: id, friend_id: friend.id)\n friendship.update(status: \"pending\")\n else\n Friendship.create(user_id: id, friend_id: friend.id, status: \"pending\")\n send_friend_request_email(friend.email, self.username)\n end\n end", "def create\n @user.make_friend_with! params[:id]\n render_created\n end", "def set_friend\n @friend = Friend.where(friend_id: params[:id])\n end", "def create\n @plant = Plant.find(params[:plant])\n @friendship = @plant.friendships.build(:friend_id => params[:friend])\n if @friendship.save\n flash[:notice] = \"added friend\"\n redirect_to request.referrer\n else\n flash[:error] = \"Unable to add friend.\"\n redirect_to request.referer\n end\n end", "def add_user(db, name, age, current_weight, goal_weight, max_mile)\n\tdb.execute(\"INSERT INTO users (name, age, current_weight, goal_weight, max_mile) \n\tVALUES (?, ?, ?, ?, ?);\", [name, age, current_weight, goal_weight, max_mile]\n\t)\nend", "def fetch_facebook_friends(facebook_user)\n #facebook_user.friends.collect(&:id).each do |friend_id|\n # unless self.facebook_friends.collect(&:facebook_id).include?(friend_id.to_s)\n # self.facebook_friends.create!(:facebook_id => friend_id)\n # end\n #end\n end", "def request_friend(friend)\n self.friendships.create!(friend_id: friend.id, status: 'requested')\n friend.friendships.create!(friend_id: self.id, status: 'pending')\n end", "def add_friends( whose, conn, friends )\n friends[whose] = true\n links = conn.delete( whose )\n return unless links\n\n # We added the user; now add all of their connections. Tack them on to the\n # end of the list (dropping duplicates) as we run through it, so they will\n # be similarly processed in turn. We must continue to make passes through\n # the list until it stopped growing, at which point we know we've added\n # all the friends and friends of friends of the first user. \n count = 0\n until count == links.size\n count = links.size\n\n links.keys.each do |link|\n sublinks = conn.delete( link )\n links.merge!( sublinks ) if sublinks\n end\n end \n\n # Now that we have the definitive list of this user's connections (and\n # their connections), tag them all as friends of the PM.\n friends.merge!( links )\n end", "def create\n\t\t@profile_friend = Friendship.new(profile_friend_params)\n\t\t@profile_friend.friend_a = current_user\n\n\t\trespond_to do |format|\n\t\t\tif @profile_friend.save\n\t\t\t\tback_page = profile_friends_path\n\t\t\t\tback_page = URI(request.referer).path if params[:back]\n\t\t\t\tformat.html { redirect_to back_page, notice: 'Friend was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: back_page }\n\t\t\telse\n\t\t\t\tformat.html { broadcast_errors @profile_friend, profile_friend_params }\n\t\t\t\tformat.json { render json: @profile_friend.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def request_friendship_with(friend)\n\t\t\t\t\tunless is_friends_or_pending_with?(friend) || self == friend\n \t \t::Friendship.create!(:friendshipped_by_me => self, :friendshipped_for_me => friend)\n\t\t\t\t\tend\n \t end", "def create_specific_friends\n @friend_id = 28 # gabriel\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 25 # John\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 24 # Sara\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n\n @friend_id = 29 # aubrey\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n\n @friend_id = 26 #artem\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 32 #millu\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n @friend_id = 34 #marketing\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n end", "def create\n friend = Friend.create_from_user_email_and_tag current_user, new_friend_params[\"email\"], new_friend_params[\"tag\"]\n redirect_to my_friends_path, notice: 'You made a new friend!'\n rescue StandardError => e\n flash[:alert] = e.record.errors.full_messages.join \", \"\n redirect_to my_friends_path\n end", "def set_friend\n @friend = Friend.where( friend_id: params[:id]).first\n end", "def create\n if params[:invitee_email]\n @friend = User.where(params[:invitee_email])\n @friendship = current_user.friendships.new(invitee_email :@friend)\n if @friendship.save\n flash[:success] = \"Congrats! You are now friends.\"\n else\n flash[:error] = \"Oops! There's been a mistake.\"\n redirect_to profile_path(@friend)\n end\n end\n end", "def create\n # @invited_friend = InvitedFriend.new(params[:order_params])\n\n # @invited_friend = InvitedFriend.new\n@order = Order.new(order_params)\n\n@oid [email protected]\n@friends=Order.find_by_sql ([\"select * from orders where id =?\", @order.id])\n@f = []\n@f=@friends[0].invited.chomp.split(',')\[email protected] do |fr|\n @fid=User.find_by_sql ([\"select id from users where email =?\",fr.chomp])\n object = InvitedFriend.new(:user_id => @fid[0].id, :order_id => @order.id , :status =>\"0\" )\n object.save\n end\n\n respond_to do |format|\n if @oid\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n #redirect_to params[:redirect_to] || @order\n\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def friendships_create(options = {})\n @req.post(\"/1.1/friendships/create.json\", options)\n end", "def set_friend\n @friend = User.find(params[:id])\n end", "def friending(a_user)\n # self.push_uniq(:attendees => a_user.id)\n friendship_ids << a_user.id\n save\n end", "def become_friends_with(friend)\n \t unless self.is_friends_with?(friend)\n \t unless self.is_pending_friends_with?(friend)\n \t ::Friendship.create!(\n\t\t\t\t\t\t\t\t:friendshipped_by_me => self,\n\t\t\t\t\t\t\t\t:friendshipped_for_me => friend,\n\t\t\t\t\t\t\t\t:accepted_at => Time.now)\n \t else\n \t self.friendship(friend).update_attribute(:accepted_at, Time.now)\n \t end\n \t else\n \t self.friendship(friend)\n \t end\n \t end", "def create\n @user = current_user\n @friend = User.find(params[:friend_id])\n @friendship_created = @user.invite(@friend)\n if @friendship_created\n flash[:request_sent] = 'Frindship request has succesffully been sent $green'\n # for the log file \n l = Log.new\n l.user_id_1 = @user.id\n l.user_id_2 = @friend.id\n name_1 = if @user.name.nil? then @user.email.split('@')[0] else @user.name end\n name_2 = if @friend.name.nil? then @friend.email.split('@')[0] else @friend.name end\n l.message = \"#{name_1.humanize} requested friendship of #{name_2.humanize}\"\n l.loggingtype = 0\n l.save\n # Author: Omar\n #adding the notification to the database on sending a friendship request\n UserNotification.create(owner: @friend.id , user: @user.id, story: nil , comment: nil , notify_type: 1 , new: true)\n @friend.notifications = @friend.notifications.to_i + 1\n @friend.save\n else \n flash[:request_not_sent] = 'Frindship request was not sent $red'\n end \n\n redirect_to action: \"index\"\n end", "def friend_params\r\n params.require(:friend).permit(:user_id, :friend_id)\r\n end", "def save\n return false unless valid?\n Friendship.create( member: member1, friend: member2 ) && Friendship.create( member: member2, friend: member1 )\n end", "def add_buddies_to_friends_list\n if user_id.blank?\n render :status=>401,\n :json=>{:Message=>\"The user id cannot be blank for this api.\",\n :Response => \"Fail\",\n :Data => nil} \n end\n friend = User.find_by_id(user_id)\n friend.follow(requested_user)\n render :status=>200,\n :json=>{:Message=>\"Added #{friend.name} to buddy list!\",\n :Response => \"Success\",\n :Data => nil} \n end", "def create_request\n friendship = Friend.new(:user_id => params[:user_id], \n\t\t\t\t\t\t\t :friend_id => params[:friend_id])\n\t if friendship.save\n\t render text: friendship.id \n\t else\n\t render text:'-1'\n\t end\n end", "def update_friends\n if self.friends_last_updated_at.nil? || ((self.friends_last_updated_at + 1.day) < DateTime.now)\n self.friends = profile.friends(:fields => 'gender,name').map{|f| {\"label\" => f.name, \"value\" => f.identifier, \"gender\" => f.gender}}\n self.friends_last_updated_at = DateTime.now\n save(:validate => false)\n end\n end", "def add_to_database\n if self.valid?\n User.add({\"name\" => \"#{self.name}\"})\n else\n false\n end\n end", "def add_friends(friends_array,name)\n friends_array << name\nend", "def user_already_friend(friend_id)\n @friend = Friendship.where('friend_id = ' + friend_id.to_s + \" AND user_id = \"+id.to_s)[0]\n return [email protected]?\n end", "def make_friends_with(other_user)\n if (self != other_user) && !self.friends.include?(other_user)\n self.friendships.create!(friend: other_user)\n other_user.friendships.create!(friend: self)\n end\n end" ]
[ "0.7863094", "0.76336265", "0.75564027", "0.74632585", "0.74216974", "0.7373835", "0.7326069", "0.72926813", "0.72406733", "0.7234682", "0.7154937", "0.7137835", "0.707263", "0.7064795", "0.7009636", "0.7008091", "0.6961659", "0.69246745", "0.6908144", "0.6812475", "0.67471904", "0.6743895", "0.6701755", "0.66548246", "0.66187716", "0.65821224", "0.654807", "0.6540925", "0.6497067", "0.6480743", "0.6479375", "0.6469846", "0.64544886", "0.6447241", "0.64158654", "0.6412553", "0.63878137", "0.638718", "0.638718", "0.63836074", "0.63535035", "0.6338212", "0.6321166", "0.6309675", "0.63080037", "0.6297859", "0.6292219", "0.6280684", "0.62806094", "0.62706095", "0.62595606", "0.6252533", "0.62523204", "0.6250964", "0.6248217", "0.624292", "0.62343717", "0.6226627", "0.6224067", "0.6210309", "0.62023294", "0.61980414", "0.6191148", "0.61906433", "0.6190512", "0.6176822", "0.6164813", "0.61596406", "0.61529887", "0.6147265", "0.614487", "0.6136517", "0.6133028", "0.61212283", "0.6120396", "0.6102491", "0.60980165", "0.6093249", "0.60931456", "0.60870486", "0.6080926", "0.6073027", "0.60624814", "0.6056936", "0.60464317", "0.6030782", "0.60172164", "0.6007554", "0.6000729", "0.59915125", "0.599072", "0.5989532", "0.5985904", "0.59601", "0.59562004", "0.5950651", "0.5949735", "0.5939068", "0.5936494", "0.59246653" ]
0.82042044
0
method that joins a friend to their interest in the join table
def add_friend_interest(db, friend_id, interest_id) db.execute("INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)", [friend_id, interest_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_interests_array(db, friend_name)\n friend_interests = db.execute(\"SELECT interests.interest FROM friends join friends_interests on friends.id=friends_interests.friend_id join interests on interests.id=friends_interests.interest_id where friend_name='#{friend_name}'\")\nend", "def relation_method\n :join\n end", "def friends # I dont' understand associations well enough....\n User.find_by_sql(\"select * from users join networks on networks.user_id='#{self.id}' where users.id=networks.friend_id order by id desc\")\n end", "def friendlist(user)\n User.find_by_sql(\n \"SELECT\n friend_interests_users.user_id as id,\n count(common_interests.id) as num_common_interests\n FROM\n users as me\n left join interests_users as my_interests_users on my_interests_users.user_id = me.id\n left join interests as common_interests on my_interests_users.interest_id = common_interests.id\n left join interests_users as friend_interests_users on common_interests.id = friend_interests_users.interest_id\n WHERE\n friend_interests_users.user_id <> #{user.id} and\n me.id = #{user.id}\n GROUP BY\n friend_interests_users.user_id\n ORDER BY\n num_common_interests desc;\"\n )\n end", "def get_friends_with_interest(name)\n self.friends(:f).relatives.interests.where(name: name).pluck(:f)\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 apply_join(query, join)\n validate_query(query)\n query.joins(join)\n end", "def join_people_by_relationship_type\n\n sql = <<EOF\nselect supers.id, supers.name, subs.id, subs.name\nfrom person_associations pa\ninner join people as supers\n on supers.id = pa.source_id\ninner join people as subs\n on subs.id = pa.sink_id\nand association_type = 'direct_reporting'\norder by supers.id\nEOF\n\n r = ActiveRecord::Base.connection.execute(sql)\n end", "def join_for(user)\n joins.find_by_user_id(user)\n end", "def add_join(join)\n @clause[:final_join] = join.implicit_joins\n end", "def group_join!(group)\n affiliations.create!( :group_id => group.id )\n end", "def join(table, field1, field2, join_type = 'INNER JOIN')\n @join = \" #{join_type} #{table} ON #{@from}.#{field1}=#{table}.#{field2}\"\n\n self\n end", "def association_join(*associations)\n association_inner_join(*associations)\n end", "def append_join(join)\n @clause[:join] << join.string \n @clause[:join] << join.implicit_joins\n end", "def pending_friends\n User.joins(\"INNER JOIN friendships ON users.id = friend_id WHERE \n friendships.user_id = #{self.id} AND \n friendships.is_pending = true\")\n end", "def worlize_friends\n User.where(:guid => self.worlize_friend_guids)\n end", "def following_list\n User.joins(\"INNER JOIN followings ON followings.followed_id = users.id WHERE followings.follower_id = #{self.id}\").select(\"users.*\")\n end", "def show\n your_friend_ids = current_user.friends.established.pluck(:to_id) + # 自分から申請して友だちになったやつ\n User.joins(:friends) # 申請を受け入れて友達になったやつ\n .where(friends: { to_id: current_user.id, establish: true })\n .pluck(:user_id)\n @your_friends = User.where(id: your_friend_ids).order(:name)\n @users_wanting_to_become_friend_with_you = User.joins(:friends)\n .where(friends: { to_id: current_user.id, establish: false })\n .order(:name)\n end", "def friends\n friendship_model = Amistad::Friendships.const_get(:\"#{Amistad.friendship_model}\")\n\n approved_friendship = friendship_model.where(friendable_id: id, pending: false, blocker_id: nil).select(:friend_id).to_sql\n approved_inverse_friendship = friendship_model.where(friend_id: id, pending: false, blocker_id: nil).select(:friendable_id).to_sql\n\n self.class.where(\"id in (#{approved_friendship}) OR id in (#{approved_inverse_friendship})\")\n end", "def join(other)\n new(relation.join(other.relation))\n end", "def _association_join(type, associations)\n clone(:join=>clone(:graph_from_self=>false).eager_graph_with_options(associations, :join_type=>type, :join_only=>true).opts[:join])\n end", "def join(person)\n members.push(person);\n end", "def get_joins\n join_sources = @model.arel_table.\n join(@associated.source).\n on(@associated.filters).\n join_sources\n return @model.joins(@members + join_sources)\n end", "def join\n end", "def prepend_join(join)\n @clause[:join] = join.string << @clause[:join]\n @clause[:join] << join.implicit_joins\n end", "def friend(other_user)\n friendships.create!(friend_id: other_user.id)\n end", "def cross_join(other)\n join(other, join_type: :cross)\n end", "def join_writer\n \"@join_table.create(@source.id,@destination.id)\"\n end", "def join(user)\n @mysqlHelper.insertConUser(user.getI,@id)\n @userList.getcontents.each { |users| \n \n users.userChangeFromChannel(\"204\", @id, user.getId)\n }\n @userList.add(user)\n \n end", "def friendship_relation(user_2)\n Friendship.where(user_id: [self.id,user_2.id], friend_id: [self.id,user_2.id]).first\n end", "def joins\n @joins\n end", "def friends(user)\n user_friends = \"SELECT users.*\n from users\n INNER JOIN relationships\n ON relationships.follower_id = #{user.id}\n UNION\n SELECT users.*\n from users\n INNER JOIN relationships\n ON relationships.followed_id = #{user.id}\"\n User.find_by_sql(user_friends)\n end", "def authors_join_table\n self.class.authors_join_table\n end", "def _join_table_dataset(opts)\n ds = model.db.from(opts.join_table_source)\n opts[:join_table_block] ? opts[:join_table_block].call(ds) : ds\n end", "def users_list\n User.joins(\"users left OUTER JOIN friendships ON \n users.id = friendships.friend_id AND \n friendships.user_id = #{self.id} WHERE users.id != #{self.id}\")\n .select(\"users.*, friendships.confirmed\")\n .order(:last_name)\n end", "def friends \n friends = []\n friendships = Relationship.where(\"follower_id = :user_id and friend_status = 'FRIENDS' or followed_id = :user_id and friend_status = 'FRIENDS'\", {user_id: self.id})\n\n friendships.each do |friendship|\n if friendship.followed_id == self.id\n friends.append(friendship.follower)\n else\n friends.append(friendship.followed)\n end\n end\n\n\tfriends << self\n\t\n return friends \n end", "def join_rows(rows)\n return @join_rows if defined? @join_rows\n\n conn = @model.connection\n join_table = conn.quote_table_name @ref.join_table\n assoc_fkey = conn.quote_column_name @ref.association_foreign_key\n fkey = conn.quote_column_name @ref.foreign_key\n quoted_ids = rows.map { |r| conn.quote r.send @ref.active_record_primary_key }\n\n @join_rows = conn.\n exec_query(\"SELECT #{fkey}, #{assoc_fkey} FROM #{join_table} WHERE #{fkey} IN (#{quoted_ids.join ','})\").\n rows\n end", "def events_friends_attending\nfriend_uids = self.friends.pluck(:uid)\nevents_attending = Attendance.where(:user_uid => friend_uids)\nevent_id = events_attending.pluck(:event_id)\nreturn Event.where(:id => event_id)\nend", "def joins\n []\n end", "def friends\n\t\t#sql query for the requested and accepted friendships ID's using the user id\n\t\tactive_ids = \"SELECT friend_pasive_id FROM relationships WHERE friend_active_id = :user_id AND accepted = true\"\n\t\t#sql query for the received and accepted friendships ID's using the user id\n\t\tpasive_ids = \"SELECT friend_active_id FROM relationships WHERE friend_pasive_id = :user_id AND accepted = true\"\n\t\treturn User.where(\"id IN (#{active_ids}) OR id IN (#{pasive_ids})\", user_id: self.id).includes( avatar_attachment: :blob)\n\tend", "def make_friends_with(other_user)\n if (self != other_user) && !self.friends.include?(other_user)\n self.friendships.create!(friend: other_user)\n other_user.friendships.create!(friend: self)\n end\n end", "def set_friend\n @friend=Friend.where(\"user_id = params[:user_id] AND friend_id=params[:friend_id]\")\n end", "def friend_data(other_user)\n \tUser.find_by(id: other_user.user_id)\n end", "def friends\n # receivers = Friendship.where(:receiver_id => self.id).map(&:requester_id)\n # requesters = Friendship.where(:requester_id => self.id).map(&:receiver_id)\n # friends = receivers + requesters\n # User.where(:id => friends.uniq)\n friendship_ids = Friendship.where(\"receiver_id = :id or requester_id = :id\", id: id).pluck(:requester_id, :receiver_id).flatten.uniq\n # binding.pry\n User.except(id).where(:id => friendship_ids)\n # User.joins(:friendships).where(friendships: {:receiver_id => id})\n end", "def enfriend!(friend)\n friendships.create(friend: friend)\n friend.friendships.create(friend: self)\n end", "def friends\n friend_ids = active_friendships.where(confirmed: true).pluck(:recipient_id) + passive_friendships.where(confirmed: true).pluck(:initiator_id)\n User.where(id: friend_ids)\n end", "def friend\n @friends = Friendship.paginate(:page => params[:page], :per_page => 5).where(user_id: current_user).where(aproved: 'yes')\n #@friends_g = Friendship.paginate(:page => params[:page], :per_page => 5).where(user_id: current_user)\n # @friends = @friends_g.select(\"DISTINCT(friend_id)\")\n end", "def joined\n meta(joined: true)\n end", "def friends\n\n Frind.where(\"accepted = ? AND (user_id = ? OR friend_id = ?)\", true, self.id, self.id)\n\n # Frind.where(\"accepted = ?\", true)\n\n\n\t # friends_ids = self.frinds.where(accepted: true).pluck(:friend_id)\n # received_friends_ids = self.received_frinds.where(accepted: true).pluck(:friend_id)\n # # received_friends_ids = self.received_frinds.where(accepted: true).pluck(:user_id)\n\n # friends_ids = friends_ids + received_friends_ids\n # User.where(:id => friends_ids)\n\tend", "def user_likes\n q = \"INNER JOIN liked_info ON users.id = liked_info.user_id WHERE liked_info.thing_id = #{id} AND liked_info.thing_type = 'Serial'\"\n User.joins(q)\n end", "def joinGroup\n \tquery = \"SELECT user_id FROM group_meals_participants where group_meal_id = \" + GroupMeal.find_by_meal(params[:meal]).id.to_s\n \n GroupMealsParticipant.connection.select_values(query).each do |u|\n \tif(u!=current_user.id)\n \t\tu=User.find(u)\n \t\tu.alert=true\n \t\tu.alert_location=GroupMeal.find_by_meal(params[:meal]).id.to_s\n \t\tu.save\n \tend\n \tend\n @groupMealParticipant= GroupMealsParticipant.new\n @groupMealParticipant.user_id=current_user.id\n @groupMealParticipant.group_meal_id= GroupMeal.find_by_meal(params[:meal]).id\n @groupMealParticipant.save \n redirect_to(GroupMeal.find_by_meal(params[:meal]))\n end", "def friends\n self.invited + self.invited_by\n end", "def join(join_clause)\n @joins.push join_clause\n self\n end", "def join_from_sql(type, sql)\n if(from = @opts[:from][1..-1]).empty?\n raise(Error, 'Need multiple FROM tables if updating/deleting a dataset with JOINs') if @opts[:join]\n else\n sql << SPACE << type.to_s << SPACE\n source_list_append(sql, from)\n select_join_sql(sql)\n end\n end", "def friendship(friend)\n \t ::Friendship.find(:first, :conditions => [ '(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', id, friend.id, id, friend.id ])\n \t end", "def friends\n\t\t@user = User.includes(:owned_friendships => :friend, :sent_requests => :requestee,\n\t\t\t\t\t\t\t :received_requests => :requestor).find(params[:id])\n\tend", "def friends\n self.friended_users + self.users_friended_by\n end", "def friendships\n\t\tt = Friendship.arel_table\n\t\tFriendship.where(t[:requester_id].eq(id).or(t[:accepter_id].eq(id)))\n\tend", "def set_joined\n @joined = Joined.find(params[:id])\n end", "def make_friendship!(other_user)\n relationship.create!(friend_id: other_user.id)\n other_user.relationship.create!(friend_id: self.id)\n return true\n end", "def suggested_friends\n \tpeople_may_know_query = \"select r.follower_id, r.followed_id from Relationships r where r.follower_id in (select u1.id from Users u1, Relationships r1 where r1.follower_id = #{self.id} and r1.followed_id = u1.id and r1.friend_status = 'FRIENDS' and not u1.temp or r1.follower_id = u1.id and r1.followed_id = #{self.id} and r1.friend_status = 'FRIENDS') and r.followed_id != #{self.id} and r.followed_id not in (select u1.id from Users u1, Relationships r1 where r1.follower_id = #{self.id} and r1.followed_id = u1.id and r1.friend_status = 'FRIENDS' or r1.follower_id = u1.id and r1.followed_id = #{self.id} and r1.friend_status = 'FRIENDS') and r.friend_status = 'FRIENDS' or r.followed_id in (select u1.id from Users u1, Relationships r1 where r1.follower_id = #{self.id} and r1.followed_id = u1.id and r1.friend_status = 'FRIENDS' or r1.follower_id = u1.id and r1.followed_id = #{self.id} and r1.friend_status = 'FRIENDS') and r.follower_id != #{self.id} and r.follower_id not in (select u1.id from Users u1, Relationships r1 where r1.follower_id = #{self.id} and r1.followed_id = u1.id and r1.friend_status = 'FRIENDS' or r1.follower_id = u1.id and r1.followed_id = #{self.id} and r1.friend_status = 'FRIENDS') and r.friend_status = 'FRIENDS'\"\n \t\n \tpeople_may_know = ActiveRecord::Base.connection.execute(people_may_know_query)\n \tmutual_hash = {}\n \tpeople_may_know.each do |result|\n \t\t#Interface of result {\"follower_id\"=>value, \"followed_id\"=>value}\n \t\tfollower_id = result[\"follower_id\"].to_i\n \t\tfollowed_id = result[\"followed_id\"].to_i\n \t\t\n \t\tif self.friends?(User.find(follower_id)) && self.get_relationship(User.find(followed_id)).nil?\n \t\t\tif mutual_hash[followed_id].nil?\n \t\t\t\tmutual_hash[followed_id] = 1\n \t\t\telsif\n \t\t\t\tmutual_hash[followed_id] += 1\n \t\t\tend\n \t\telse self.friends?(User.find(followed_id)) && self.get_relationship(User.find(follower_id)).nil?\n \t\t\tif mutual_hash[follower_id].nil?\n \t\t\t\tmutual_hash[follower_id] = 1\n \t\t\telsif\n \t\t\t\tmutual_hash[follower_id] += 1\n \t\t\tend\n \t\tend\n \tend\n \tmutual_array = mutual_hash.sort.reverse\n \t\n \tmutual_users = []\n \tmutual_array.each do |keyvalue|\n \t\tmutual_users << User.find(keyvalue[0]) if keyvalue[1] > 1\n \tend\n \t\n \treturn mutual_users\n end", "def joined\n Solve.join(Average.select(:visible, :solver_id, :puzzle_id, :competition_id, Sequel.as(:id, :avg_id)), avg_id: :average_id)\n end", "def join_from_sql(type, sql)\n if(from = @opts[:from][1..-1]).empty?\n raise(Error, 'Need multiple FROM tables if updating/deleting a dataset with JOINs') if @opts[:join]\n else\n sql << ' ' << type.to_s << ' '\n source_list_append(sql, from)\n select_join_sql(sql)\n end\n end", "def friends\n User.where(:guid => self.friend_guids)\n end", "def shared_friends\n @friends = current_user.friends\n @shared_friend_ids = @blog.linked_users.map{|user| user.id.to_s} if @blog.present?\n end", "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_table(type, table, *args, &block)\n if table.is_a?(Class) && table < Sequel::Model\n Sequel::Deprecation.deprecate(\"Passing Sequel::Model class to a dataset join method\", \"Pass the model's table name or dataset as the first argument instead\")\n if table.dataset.simple_select_all?\n super(type, table.table_name, *args, &block)\n else\n super(type, table.dataset, *args, &block)\n end\n else\n super\n end\n end", "def friends_activities\n Activity.includes(:user, :intensity, :exercise_unit, :exercise_type).includes(:comments => [:user]).includes(:cheers => [:user]).where(:user_id => [self.friends.ids]).order(date: :desc)\n end", "def joinToOnBoardList(onBoardList)\n onBoardList.each{|demand|\n self.addSharedWith(demand) ;\n demand.addSharedWith(self) ;\n }\n end", "def join_table_source\n cached_fetch(:join_table_source){split_join_table_alias[0]}\n end", "def friends\n current_id = self.id\n Actor.joins{received_contacts.inverse}.where{\n (received_contacts.inverse.blocked.eq false) &\n (received_contacts.blocked.eq false) &\n (received_contacts.sender_id.eq current_id)\n }\n end", "def add_friends(source_user_id, target_user_ids, provider)\n transaction do\n source_user = User.find(source_user_id)\n target_user_ids.each do |target_user_id|\n target_user = User.find(target_user_id)\n FriendRelation.create(:source_user_id => source_user_id, \n :target_user_id => target_user_id, \n :provider => provider,\n :distance => source_user.distance_to(target_user) )\n end\n end\n end", "def pending_friends\n User.where('users.id in (?)', UserFriendRelationship.pending.where(user_to_id: id).pluck(:user_id))\n end", "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\n @user = current_user\n @mess = Mess.find(params[:id])\n @mess_id = @mess.id\n @user.update_attributes(:mess_id => @mess_id)\n redirect_to @mess\n end", "def invited_by\n self.class.find(inverse_friend_ids)\n end", "def select_user_interests\n @interests = Interest.all\n # current user interests\n @user_interests = UserInterest.where(:user_id => current_user.id);\n @cur_u = current_user\n\n end", "def link!\n base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(\n @model, [], nil\n )\n \n @fields.each { |field|\n field.model ||= @model\n field.columns.each { |col|\n field.associations[col] = associations(col.__stack.clone)\n field.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n \n @attributes.each { |attribute|\n attribute.model ||= @model\n attribute.columns.each { |col|\n attribute.associations[col] = associations(col.__stack.clone)\n attribute.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n end", "def join_tables(db)\n db.execute(\"SELECT users.user_name, platform.platform_name, music.artist, music.song, music.explicit_lyrics FROM music JOIN users ON music.user_id = users.id JOIN platform ON music.platform_id = platform.id\")\nend", "def join_to(base_join)\n parent.join_to(base_join) if parent && parent.join.nil?\n \n @join ||= ::ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation.new(\n @reflection, base_join, parent ? parent.join : base_join.joins.first\n )\n end", "def find_relationship(other_user)\n requested_friend = Relationship.where(requester_id: self.id).where(receiver_id: other_user.id)\n requested_friend.any? ? requested_friend : Relationship.where(requester_id: other_user.id).where(receiver_id: self.id)\n end", "def all_friends\n friends + inverse_friends\n end", "def self_and_friends\n current_user.friendships.accepted.map(&:id) << current_user.id\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 with_workers_works_a_bit\n association_join(:workers, select: [:id, :title])\n end", "def join(*tables)\n from(default_table).join(*tables)\n end", "def friends_of_friends\n # Unit Test is in Friendship.rb\n #The first 'row' is a list of the user's friends of friends,\n #which are each in rings farther than the ring of the friend's friendship with the user\n #The second 'row' is the number of common friends the user has with the person listed in the first row.\n friends_of_friends = Array.new\n for friend in self.mutual_friends\n for friend_of_friend in friend.mutual_friends\n #A friend's friend is only seen if you are as close or closer to your friend as your friend's friend.\n if friend.which_ring(friend_of_friend) >= friend.which_ring(self)\n #If you can view the friend, then his/her presence in the friend_of_friends list is determined\n if friends_of_friends.flatten.include?(friend_of_friend)\n #If he/she is in the list, then just the number of common friends in the second row of the correct friend is incremented.\n friends_of_friends.assoc(friend_of_friend)[1] += 1\n else\n #If he/she isn't in the list, then a new column is added to the list unless the friend is you or he/she is already your friend.\n unless friend_of_friend == self or self.friends.exists?(friend_of_friend.id)\n friends_of_friends << Array.[](friend_of_friend, 1) \n end\n end\n end\n end\n end\n return friends_of_friends\n end", "def mine\n friends = Friend.includes(:other).where \"user_id = :id OR other_id = :id \", {:id => current_user.id}\n map = {} # a map from others to their relationships\n friends.each do |f|\n id = f.user_id == current_user.id ? f.other_id : f.user_id\n map[id] ||= []\n map[id] << f\n end\n data = []\n friends.each do |f|\n own = f.user_id == current_user.id\n other = own ? f.other_id : f.user_id;\n rels = map[other]\n mutual = rels.length == 2\n next if mutual && !own\n email = own ? f.other.email : f.user.email\n datum = {own: own, id: f.id, email: email, mutual: mutual}\n if mutual\n not_this = rels.select{ |o| o.id != f.id }[0]\n me, them = f, not_this\n me, them = not_this, f if !own\n datum[:other_id] = them.id\n datum[:subscribed_to_them] = me.subscribed\n datum[:subscribed_to_me] = them.subscribed\n else\n datum[own ? :subscribed_to_them : :subscribed_to_me] = f.subscribed\n end\n data << datum\n end\n render json: {friends: data}\n end", "def active_friends\n\t# friends I requested + friends that requested my friendship\n # map to get the exact list of friends\n\t self.friendships.where(state: \"active\").map(&:friend) + self.inverse_friendships.where(state: \"active\").map(&:user)\n end", "def friends_can_access_garage \n @accessors = Accessor.joins(\"INNER JOIN friends on accessors.friend_id = friends.id\").where(\"garage_id=:gid\", {gid: params[:id]}).select(\"accessors.*, accessors.id as accessor_id, friends.*\")\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 pull_join\n raise NotImplementedError\n end", "def relationship(user) # \n return :self if user.id == id # TODO will I use this value?\n friendship_association = Friendship.where(\"(initiator_id = :own_id AND recipient_id = :other_id) OR (initiator_id = :other_id AND recipient_id = :own_id)\", own_id: id, other_id: user.id)\n if friendship_association.empty?\n return nil\n else\n friendship_association.first\n end\n end", "def index\n @friendships = Friendship.all\n ary = Array.new\n # @friends_data=User.joins(:friends)\n ##############get Data From user###########\n @Data=Friendship.where('user_id=?',current_user.id)\n @friends_data=current_user.friends\n \n\n @friendship = Friendship.new\n\n \n end", "def isFriendWith(user, testedUser)\r\n if user.friendList.include? testedUser.id\r\n puts \"#{user.fullName} is friend with #{testedUser.fullName}\"\r\n else\r\n puts \"#{user.fullName} is not friend with #{testedUser.fullName}\"\r\n end\r\nend", "def request_friend(friend)\n self.friendships.create!(friend_id: friend.id, status: 'requested')\n friend.friendships.create!(friend_id: self.id, status: 'pending')\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 active_friends\n \tself.friendships.where(state: \"active\").map(&:friend) + self.inverse_friendships.where(state: \"active\").map(&:user)\n end" ]
[ "0.62735987", "0.6204703", "0.6159128", "0.5939733", "0.5919285", "0.5893872", "0.5893872", "0.5858603", "0.5826177", "0.58008754", "0.5729356", "0.5694167", "0.56681126", "0.56304824", "0.56233764", "0.56207585", "0.56186277", "0.5594803", "0.55798703", "0.55626386", "0.5559072", "0.5548676", "0.5545766", "0.5535877", "0.55111885", "0.55111116", "0.54996985", "0.5488219", "0.5470126", "0.5467703", "0.5458548", "0.54204875", "0.5410296", "0.5409788", "0.54072565", "0.54072374", "0.53785956", "0.53703874", "0.5357773", "0.5348987", "0.53445333", "0.53433114", "0.5339118", "0.5335131", "0.5329147", "0.53274584", "0.5297844", "0.5295475", "0.5290936", "0.52861285", "0.528524", "0.5284126", "0.5278292", "0.5273884", "0.52688885", "0.52650064", "0.52632564", "0.5258764", "0.52550846", "0.5253414", "0.5251025", "0.52358973", "0.523029", "0.5229768", "0.5218176", "0.5217518", "0.52112114", "0.51901466", "0.5188691", "0.51770806", "0.51754427", "0.5175177", "0.5173649", "0.51559746", "0.5147669", "0.51449096", "0.513921", "0.51378465", "0.5127687", "0.51251805", "0.5125122", "0.5124962", "0.51107156", "0.51006085", "0.50963706", "0.50937945", "0.5093338", "0.50887406", "0.5083759", "0.5082518", "0.50782764", "0.50780255", "0.5076484", "0.5076165", "0.5069548", "0.5058689", "0.5057435", "0.50572985", "0.50572985", "0.50513184" ]
0.52686244
55
method that returns the id of the name specied from the friends table
def find_friend_id(db, friend_name) friend_id = db.execute("SELECT friends.id FROM friends WHERE friend_name='#{friend_name}'") friend_id[0][0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(name)\n @users.each do |user|\n return user[:id] if user[:name] == name\n end\n nil\n end", "def get_friendship_id(user)\n \tFriendship.where(\"user_id = ? AND friend_id = ?\", current_user.id, user.id).first.id\n end", "def get_friend_id \n uri = \"https://api.twitter.com/1/friends/ids.json\" \n \n #http request for friend search start\n req = Typhoeus::Request.new(uri,\n :method =>\"get\",\n :params =>{:cursor=>\"-1\", :screen_name=>crt_user.handler}) \n #sign_request(req,uri)\n hydra = Typhoeus::Hydra.new\n hydra.queue(req)\n hydra.run\n JSON.parse(req.response.body)[\"ids\"]\n end", "def name_to_id(name)\n user = User.find_by_username(name)\n if user == nil\n return -1\n else\n user.id\n end\n end", "def friend\n UserRepository.find(friend_id)\n end", "def get_friend_by_id(friend_id)\n friends = get_friends\n friends.each {|f|\n return f if f[\"id\"] == friend_id\n }\n return nil\n end", "def id\n name\n end", "def id\n name\n end", "def id\n name\n end", "def name\n id\n end", "def friends_ids\n self.friends_ids_hash.keys rescue []\n end", "def friend_name\n name = friend.nil? ? '' : friend.name\n end", "def personen_id(db,name,vorname)\n t = db.execute(\"SELECT id FROM personen WHERE name='\"+name+\n \"' AND vorname='\"+vorname+\"';\")\n if t==[] then\n return nil\n else\n return t[0][0]\n end\nend", "def get_friend (login_user)\n return nil unless login_user\n login_user.friends.find_all { |f| f.user_id_receiver == self.user_id }.first\n end", "def get_friend (login_user)\n return nil unless login_user\n login_user.friends.find_all { |f| f.user_id_receiver == self.user_id }.first\n end", "def find_friend_by_username\n begin\n @friend_id = User.find_by(username: params[:username]).id\n rescue\n render json: {error: \"Friend not found\"}, status: 404\n end\n end", "def friends?(id)\n !(self.friends.index { |f| f.id == id }).nil?\n end", "def id\n name && name.gsub(' ', '').downcase\n end", "def find_user_id (db, user)\n user_values = db.execute(\"SELECT id FROM user WHERE name = ?\", [user])\n user_values[0][0]\nend", "def last_name\n friend = User.find_by_id(self.friend_id)\n return friend.last_name\n end", "def friendship(friend)\n \t ::Friendship.find(:first, :conditions => [ '(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', id, friend.id, id, friend.id ])\n \t end", "def find_friend(current_user)\n return self.creator_id == current_user.id ? self.friend : self.creator\n end", "def assign_name\n friend = User.find self.friend_id\n self.name = friend.username\n end", "def friends\n User.where(:guid => self.friend_guids)\n end", "def get_id(user_name)\n return get_value_of(user_name, :id)\n end", "def entity_id\n entities.select{|e| e.name == name}.first.id\n end", "def get_friends_names_ids_dictionary\n friends_collection = client.get_connections(\"me\",\"friends\")\n return all_pages_of_friends_name_id_dictionary(friends_collection)\n end", "def user_already_friend(friend_id)\n @friend = Friendship.where('friend_id = ' + friend_id.to_s + \" AND user_id = \"+id.to_s)[0]\n return [email protected]?\n end", "def friends(id)\n friends_data(request(\"users/friends/#{id}.xml\", :auth => true))\n end", "def get_friend_ids(cookie)\n Person.get_person_ids(get_friends(cookie))\n end", "def id\n name.gsub(':', '-')\n end", "def find_by_name(id)\n end", "def friend? friend_identity\n account.all_friends.friend.find_by_friend_kopal_identity(Kopal::Identity.normalise_identity(friend_identity.to_s))\n end", "def name\n id.to_s\n end", "def mood_id(user_id, name)\r\n moods(user_id).each do |mood|\r\n return mood['moodId'] if mood['moodName'] == name\r\n end\r\n end", "def facebook_friends\n User.where(:guid => self.facebook_friend_guids)\n end", "def set_friend\n @friend = Friend.where( friend_id: params[:id]).first\n end", "def getFriend(user_id)\n friender_id == user_id ? friended : friender\n end", "def friends(cookie)\n Person.find_kassi_users_by_ids(get_friend_ids(cookie))\n end", "def name_id\n status_label = active ? \"\" : \"[INACTIVE] \"\n [\"#{status_label}#{name + school_code}\", id]\n end", "def worlize_friends\n User.where(:guid => self.worlize_friend_guids)\n end", "def return_id(db, user_name)\r\n\tretrieve_id = '\r\n\tSELECT id FROM users\r\n\tWHERE name = ?'\r\n\tid = db.execute(retrieve_id, [user_name])\r\nend", "def get_friends_ids(auth = auth_http())\n TwBot.friends_ids(auth)\n end", "def user_followed\n amigos = self.friends.pluck(:friend_id)\n User.find(amigos)\n end", "def name\n # The name must be a string\n id.to_s\n end", "def id_string\n return \"user_\"+self.username\n end", "def name_as_id\n self.name.downcase.gsub(/\\s/, '-')\n end", "def get_id(data)\n result = get_full_data(data)\n usrgrpid = nil\n result.each { |usr| usrgrpid = usr['usrgrpid'].to_i if usr['name'] == data[:name] }\n usrgrpid\n end", "def create_specific_friends\n @friend_id = 28 # gabriel\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 25 # John\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 24 # Sara\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n\n @friend_id = 29 # aubrey\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n\n @friend_id = 26 #artem\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n @friend_id = 32 #millu\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n @friend_id = 34 #marketing\n if User.exists?(id:@friend_id)\n Friend.create(user_id:@friend_id,user_id_friend:self.id)\n Friend.create(user_id:self.id,user_id_friend:@friend_id)\n end\n\n end", "def get_user_id(db, username)\n\tdb.execute(\"SELECT id FROM users WHERE name=? ;\", [username])\nend", "def friend_ids\n @_friend_ids ||= (@_raw_friend_hashes ? @_raw_friend_hashes.keys : raw_friend_ids).map(&:to_i)\n end", "def id\n name.gsub /-/, '_'\n end", "def id(name, league_id)\n database do |db|\n # return id\n return db.get_first_value 'SELECT PlayerID FROM Player\n WHERE DisplayName = :name\n AND LeagueID = :league_id\n COLLATE NOCASE',\n name, league_id\n end\nend", "def get_name(conn, id)\n conn.exec_params(\"SELECT name FROM actors WHERE id=$1\",\n [id])[0][\"name\"]\nend", "def user_id\n username\n end", "def find_friendship\n @friendship = current_user.friendships.find_by_user_id_and_friend_id(current_user.id, @friend_id)\n end", "def find_friend_by_email\n begin\n @friend_id = User.find_by(email: params[:email]).id\n rescue\n render json: {error: \"Friend not found\"}, status: 404\n end\n end", "def fetch_id(char_name)\n char = Character.find_by_name(char_name)\n char.id\n end", "def friend_data(other_user)\n \tUser.find_by(id: other_user.user_id)\n end", "def mood_id(user_id, name)\n moods(user_id).each do |mood|\n return mood['moodId'] if mood['moodName'] == name\n end\n end", "def get_movie_id(movie_name)\n Movie.find_by(name: movie_name).id\n end", "def real_id(model_name, friendly_id)\n if friendly_id.to_s.to_i == 0\n obj = model_name.constantize.find(friendly_id)\n if obj\n return obj.id\n end\n end\n friendly_id\n end", "def friendship(friend)\n Friendship.find(:first, :conditions => ['(user_id = ? AND friend_id = ?) OR (friend_id = ? AND user_id = ?)', self.id, friend.id, self.id, friend.id])\n end", "def facebook_friends_ids\n @facebook_friends_ids ||= begin\n FriendRelation.facebook.by_source_user(self.external_user_id).pluck(:target_user_id) +\n FriendRelation.facebook.by_target_user(self.external_user_id).pluck(:source_user_id)\n end\n end", "def invited_by\n self.class.find(inverse_friend_ids)\n end", "def set_friends\n @friends = friends.find(params[:id])\n end", "def find_interest_id(db, interest_name)\n interest_id = db.execute(\"SELECT interests.id FROM interests WHERE interest='#{interest_name}'\")\n interest_id[0][0]\nend", "def lookup_info_id(info_name)\n\n # Hash of names and ids / key, value\n Info_names = {}\n infos = Info.all.to_a\n\n infos.each do |industry|\n info_names[info.name] = info.id\n end\n\n # return id number\n puts \"Info: #{info_names[info_name]} / #{info_name}\"\n return info_names[info_name]\n\n end", "def uid(id)\n users.find_index { |u| u.id.eql?(id)}\n end", "def navbar_friends_name_and_title(menu)\n friend_id = menu.to_s.split('_').last\n if friend = Admin::Customer::Friend.find_by_id(friend_id)\n name = friend.name.to_s\n title = \"Click to View #{name}'s collection\"\n end\n return name, title\n end", "def association_id_method\n self.class.foreign_key_name(@options[\"name\"])\n end", "def friends\n Fql.query(\"SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=#{self.fb_id}) AND has_added_app = 1\")\n end", "def flipper_id\n \"User;#{id}\"\n end", "def full_name_with_id\n id.to_s + \": \" + user.first_name + \" \" + user.last_name\n end", "def get_friends(id)\n facebook_cookies = Koala::Facebook::OAuth.new(Facebooker2.app_id, Facebooker2.secret).get_user_info_from_cookie(cookies)\n access_token = facebook_cookies[\"access_token\"]\n graph = Koala::Facebook::GraphAPI.new(access_token)\n friends = graph.get_connections(\"me\", \"friends\")\n\n user = User.find(id)\n\n friends.each do |friend|\n friend = User.find_by_host_id(friend[\"id\"])\n if (friend != nil && !user.friends.include?(friend))\n user.friends << friend\n end\n end\n\n user.last_update_friends = Date.today\n user.save\n end", "def set_friend\n @friend = Friend.where(friend_id: params[:id])\n end", "def get_student_id(database, name)\r\n\tstudent = database.execute(\"SELECT * FROM students WHERE name=?\",[name])\r\n\tstudent_id = student[0][0].to_i\r\nend", "def self_and_friends\n current_user.friendships.accepted.map(&:id) << current_user.id\n end", "def get_name(id)\n @users.each do |user|\n return user[:name] if user[:id] == id\n end\n nil\n end", "def id2name() end", "def id2name() end", "def id\n return @playing_girl ? @id_girl : @id_boy\n end", "def column_name\n Name.new(\"#{name}_id\")\n end", "def family_id\n @gapi.family_id\n end", "def skill_id_to_name(db, skill_id)\n skill_name = db.execute(\"SELECT name FROM skills WHERE id=(?)\", skill_id)\n if skill_name.length > 0\n skill_name[0][0]\n end\nend", "def send_friend_request(id)\n get(\"users/#{id}\").user\n end", "def name_to_id\n @name_to_id ||= build_hash('name', 'id')\n end", "def get_id(model, name)\n\t\tid = 0\n\t\tmodel.each do |hash|\n\t\t\thash.each do |k, v|\n\t\t\t\tif v == name\n\t\t\t\t\tid = k.to_i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tid\n\tend", "def father_name\n \n Tweet.find(self.tweet_id).user.username\n \n end", "def friends # I dont' understand associations well enough....\n User.find_by_sql(\"select * from users join networks on networks.user_id='#{self.id}' where users.id=networks.friend_id order by id desc\")\n end", "def user_to_id(user)\n # Match user input with any name.\n # e.g: 'lukas' or 'zapletal' would match 'Lukas Zapletal'\n @user_ids.each do |id, name_regex|\n return id.to_s if user =~ /#{name_regex}/i\n end\nend", "def get_a_friend\n unless self == User.first\n friends << User.first\n end\n end", "def entire_name_with_id\r\n self.entire_full_name + \" (#{self.id})\"\r\n end", "def winner_id\n return self.send(\"#{winner}_id\".intern)\n end", "def set_friend\n @friend = User.find(params[:id])\n end", "def friendship_relation(user_2)\n Friendship.where(user_id: [self.id,user_2.id], friend_id: [self.id,user_2.id]).first\n end", "def friends\n friend_ids = active_friendships.where(confirmed: true).pluck(:recipient_id) + passive_friendships.where(confirmed: true).pluck(:initiator_id)\n User.where(id: friend_ids)\n end", "def lookup_emotion_id(emotion)\n emotion_id = @db.get_first_value(\"SELECT id FROM emotions WHERE name = ?\", emotion)\n end", "def friend\n if params.include?(:id)\n @user.friends += [User.find(params[:id])]\n elsif params.include?(:username)\n @user.friends += [User.find_by(username: params[:username])]\n end\n redirect_to root_path\n end", "def set_friend\n @friend = Friend.find(params[:id])\n end" ]
[ "0.6791384", "0.6568132", "0.6549109", "0.6315099", "0.6296776", "0.62645805", "0.61871487", "0.61871487", "0.6115304", "0.6078169", "0.6065757", "0.6062285", "0.60531163", "0.6005002", "0.6005002", "0.5979276", "0.596438", "0.59635335", "0.5898441", "0.58923906", "0.5856448", "0.5825421", "0.5800688", "0.5784242", "0.5754243", "0.5751168", "0.57484376", "0.5726276", "0.5724958", "0.56958675", "0.56903934", "0.56811655", "0.56740403", "0.5671647", "0.5667207", "0.5667169", "0.56631744", "0.5654449", "0.56533533", "0.5625535", "0.5617921", "0.5604145", "0.5601552", "0.5594518", "0.5592784", "0.55835557", "0.55793875", "0.5571514", "0.55706733", "0.5566384", "0.5566255", "0.5564823", "0.5561992", "0.5558103", "0.553493", "0.552172", "0.55169207", "0.5511232", "0.5508853", "0.5494434", "0.54853487", "0.54848695", "0.5484286", "0.54740983", "0.5468067", "0.54633206", "0.54623073", "0.54593796", "0.54580456", "0.5454591", "0.54542327", "0.5446435", "0.5421219", "0.5418497", "0.54181814", "0.5411585", "0.54093474", "0.540177", "0.5401565", "0.5387859", "0.5387859", "0.5377803", "0.53673476", "0.53672105", "0.536491", "0.5363708", "0.53632987", "0.5356558", "0.53548926", "0.5347955", "0.53471607", "0.5341803", "0.5340683", "0.53393626", "0.5337181", "0.5330488", "0.5329583", "0.5324808", "0.5322584", "0.53159356" ]
0.7842519
0
method that returns the id of the interest specied from the interests table
def find_interest_id(db, interest_name) interest_id = db.execute("SELECT interests.id FROM interests WHERE interest='#{interest_name}'") interest_id[0][0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_interestID\n if current_user == nil\n @current_interestID = nil\n elsif UserInterestMapping.where(userID: current_user[:id]) == []\n @current_interestID = nil\n else\n @current_interestID = UserInterestMapping.where(userID: current_user[:id])[0][:interestID]\n end\n @current_interestID\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def set_interest\n @interest = Interest.find(params[:id])\n end", "def add_interest(id)\n SocietyInterest.create(society_id: self.id, interest_id: id)\n end", "def set_interest\n @interest = Interest.find(params[:id]) \n @especifications = Especification.where(\"interest_id = #{params[:id]}\")\n end", "def set_interest\n begin\n @interest = Interest.find(params[:id])\n rescue\n redirect_to \"/interest\"\n end\n end", "def get_interests_by_id\n return filter_by_id(get_interests)\n end", "def select_user_interests\n @interests = Interest.all\n # current user interests\n @user_interests = UserInterest.where(:user_id => current_user.id);\n @cur_u = current_user\n\n end", "def set_student_interest\n @student_interest = StudentInterest.find(params[:id])\n end", "def set_eventinterest\n @eventinterest = Eventinterest.find(params[:id])\n end", "def set_user_interest\n @user_interest = UserInterest.find(params[:id])\n end", "def interested_in?(interest)\n self.user_interests.find_by_interest_id(interest)\n end", "def index\n @interests = Interest.all\n end", "def index\n @interests = Interest.all\n end", "def get_interests\n\t\t@si = SocietyInterest.where(society_id: self.id)\n\t\t@interests = []\n\t\[email protected] do |s|\n\t\t\t@interests << Interest.find_by_id(s.interest_id)\n\t\tend\n\t\treturn @interests\n end", "def set_interestversion\n @interestversion = Interestversion.find(params[:id])\n end", "def edit\n @user = User.find(current_user.id)\n @interests = Interest.all.order(:name)\n end", "def set_mentoring_interest\n @mentoring_interest = MentoringInterest.find(params[:id])\n end", "def set_pending_interest\n @pending_interest = PendingInterest.find(params[:id])\n end", "def set_interest_point\n @interest_point = InterestPoint.find(params[:id])\n end", "def update\n standard_update(Interest, params[:id], interest_params)\n end", "def update\n @interest = Interest.find(params[:id])\n if @interest.update_attributes(params[:interest])\n redirect_to interests_path\n else\n redirect_to :action => 'edit', :id => @interest.id\n end\n end", "def create\n @interest = Interest.new(params[:interest])\n if @interest.save\n redirect_to interests_path\n else\n redirect_to new_interest_path\n end\n end", "def set_interest_group\n @interest_group = InterestGroup.find(params[:id])\n end", "def ID\n @table.rows.index(self)\n end", "def create \n @interest = Interest.new(interest_params)\n @interest.save\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end", "def set_interest_on_housing_loan\n @interest_on_housing_loan = InterestOnHousingLoan.find(params[:id])\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @interest }\n end\n end", "def add_interest(db, interest)\n db.execute(\"INSERT INTO interests (interest) VALUES (?)\", [interest])\nend", "def set_inspiration\n @inspiration = Inspiration.find(params[:id])\n end", "def set_inspiration\n @inspiration = Inspiration.find(params[:id])\n end", "def current_user_interests\n current_user.interests\n end", "def set_insint\n @insint = Insint.find(params[:id])\n end", "def find_institute\n @institute = Institute.find(params[:id])\n end", "def find_noteable_id\n GithubImport::IssuableFinder.new(project, note).database_id\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest }\n end\n end", "def interests_for_trust(trustee)\n offered_interests = Trust.where('trusts.trustor_id = ? AND trustee_id = ?', self.id, trustee.id).map(&:interest_id)\n interest_ids_to_offer = user_interest_preferences.map(&:interest_id) - offered_interests\n return Interest.where(:id => interest_ids_to_offer)\n end", "def set_interessado\n @interessado = Interessado.find(params[:id])\n\n end", "def add_friend_interest(db, friend_id, interest_id)\n db.execute(\"INSERT INTO friends_interests (friend_id, interest_id) VALUES (?, ?)\", [friend_id, interest_id])\nend", "def set_project_area_interest\n @project_area_interest = ProjectAreaInterest.find(params[:id])\n end", "def set_donation_record_interest_period\n @donation_record_interest_period = DonationRecord::InterestPeriod.find(params[:id])\n end", "def interest_params\n params.require(:interest).permit(:user_id, :animal_id, :date)\n end", "def investor(id:)\n Investor.find(id)\n end", "def set_sports_interest\n @sports_interest = SportsInterest.find(params[:id])\n end", "def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interest }\n end\n end", "def index\n @user_interests = UserInterest.all\n end", "def id\n raise NotImplementedError\n end", "def id\n raise NotImplementedError\n end", "def index\n \n @interests = Interest.find(@interestsId)\n \n if params[:persona_id] == nil \n @interests = Interest.order(:name) \n end\n \n respond_to do |format|\n format.json { render :json => @interests }\n end\n end", "def set_interessado\n @interessado = Interessado.find(params[:id])\n end", "def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def set_project_interest_point\n @project_interest_point = ProjectInterestPoint.find(params[:id])\n end", "def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n redirect_to interests_path\n end", "def show\n @object = Interest.find(params[:id])\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def deleteInterest(interest)\n \n end", "def deleteInterest(interest)\n \n end", "def new\n\t\t@interest = Interest.new\t\n\tend", "def entry_id\n raise NotImplementedError\n end", "def id()\n #This is a stub, used for indexing\n end", "def id_for(index)\n if direct_index = @map[index]\n @added[direct_index][0]\n else\n if polymorphic?\n @database.polymorphic_join_index(@offset,lazy_index(index))\n else\n @database.join_index(@offset,lazy_index(index))\n end\n end\n end", "def set_interest # :norobots:\n pass_query_params\n type = params[:type].to_s\n oid = params[:id].to_i\n state = params[:state].to_i\n uid = params[:user]\n target = Comment.find_object(type, oid)\n if @user\n interest = Interest.find_by_target_type_and_target_id_and_user_id(type, oid, @user.id)\n if uid && @user.id != uid.to_i\n flash_error(:set_interest_user_mismatch.l)\n elsif !target && state != 0\n flash_error(:set_interest_bad_object.l(:type => type, :id => oid))\n else\n if !interest && state != 0\n interest = Interest.new\n interest.target = target\n interest.user = @user\n end\n if state == 0\n name = target ? target.unique_text_name : '--'\n if !interest\n flash_notice(:set_interest_already_deleted.l(:name => name))\n elsif !interest.destroy\n flash_notice(:set_interest_failure.l(:name => name))\n else\n if interest.state\n flash_notice(:set_interest_success_was_on.l(:name => name))\n else\n flash_notice(:set_interest_success_was_off.l(:name => name))\n end\n end\n elsif interest.state == true && state > 0\n flash_notice(:set_interest_already_on.l(:name => target.unique_text_name))\n elsif interest.state == false && state < 0\n flash_notice(:set_interest_already_off.l(:name => target.unique_text_name))\n else\n interest.state = (state > 0)\n interest.updated_at = Time.now\n if !interest.save\n flash_notice(:set_interest_failure.l(:name => target.unique_text_name))\n else\n if state > 0\n flash_notice(:set_interest_success_on.l(:name => target.unique_text_name))\n else\n flash_notice(:set_interest_success_off.l(:name => target.unique_text_name))\n end\n end\n end\n end\n end\n if target\n redirect_back_or_default(:controller => target.show_controller,\n :action => target.show_action, :id => oid,\n :params => query_params)\n else\n redirect_back_or_default(:controller => 'interest',\n :action => 'list_interests')\n end\n end", "def orchestrate_primary_key\n id\n end", "def interest_in_article(article)\n \n end", "def retrieve_others_interests(selected_user)\n Interest.where('interests.user_id <> ?',selected_user)\n end", "def find_by_interest(interests)\n user = User.current_user\n filtered_records = []\n interest_ids = []\n user_groups = []\n # Find tag used for content\n find_tag = ActsAsTaggableOn::Tag.find_by_name('find')\n # Read tag used for locations\n read_tag = ActsAsTaggableOn::Tag.find_by_name('read')\n\n if find_tag || read_tag\n # No need to bother without neither findability nor readability\n location_hashes = []\n\n # Omni is the default group even for non-logged in users\n user_groups << Group.find_by_name('_omni')\n\n if user\n Group.all.each do |group|\n user_groups << group if group.members.include?(user)\n end\n end\n\n interests.each do |interest|\n # Interest for Content - not Location\n interest_tag = ActsAsTaggableOn::Tag.find_by_name(interest)\n if interest_tag\n interest_ids << interest_tag.id\n end\n end\n\n unless interest_ids.empty?\n # No need to bother if interests don't even exist\n # Retreive locations for group findable content and matching interest(s)\n user_groups.each do |user_group|\n # Locations with matching interests\n sql = \"SELECT DISTINCT id AS location_id FROM locations WHERE id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Location' AND tag_id=#{read_tag.id} AND context='access' AND tagger_type='Group' AND tagger_id=#{user_group.id}) AND id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Location' AND tag_id IN (#{interest_ids.to_s.gsub(/[(\\[\\])]/,\"\")}) AND context='interest' AND tagger_type='Group' AND tagger_id=#{user_group.id})\"\n location_hashes += ActiveRecord::Base.connection.execute(sql)\n # Locations for group findable content and matching interest(s)\n sql = \"SELECT DISTINCT location_id FROM contents_locations WHERE content_id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Content' AND tag_id=#{find_tag.id} AND context='access' AND tagger_type='Group' AND tagger_id=#{user_group.id}) AND content_id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Content' AND tag_id IN (#{interest_ids.to_s.gsub(/[(\\[\\])]/,\"\")}) AND context='interest' AND tagger_type='Group' AND tagger_id=#{user_group.id})\"\n location_hashes += ActiveRecord::Base.connection.execute(sql)\n end\n\n if user\n # Locations with matching interests\n sql = \"SELECT DISTINCT id AS location_id FROM locations WHERE id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Location' AND tag_id=#{read_tag.id} AND context='access' AND tagger_type='User' AND tagger_id=#{user.id}) AND id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Location' AND tag_id IN (#{interest_ids.to_s.gsub(/[(\\[\\])]/,\"\")}) AND context='interest' AND tagger_type='User' AND tagger_id=#{user.id})\"\n location_hashes += ActiveRecord::Base.connection.execute(sql)\n # Locations for user findable content and matching interest(s\n sql = \"SELECT DISTINCT location_id FROM contents_locations WHERE content_id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Content' AND tag_id=#{find_tag.id} AND context='access' AND tagger_type='User' AND tagger_id=#{user.id}) AND content_id IN (SELECT taggable_id FROM taggings WHERE taggable_type='Content' AND tag_id IN (#{interest_ids.to_s.gsub(/[(\\[\\])]/,\"\")}) AND context='interest' AND tagger_type='User' AND tagger_id=#{user.id})\"\n location_hashes += ActiveRecord::Base.connection.execute(sql)\n end\n\n # No need to retrieve location object more than once\n location_hashes.uniq_by! {|hash| hash['location_id'] }\n \n locations = []\n location_hashes.each do |hash|\n locations << hash['location_id']\n end\n\n # Locations are OK if readable\n all.each do |location|\n filtered_records << location if locations.include?(location.id)\n end\n end\n end\n filtered_records.uniq\n end", "def invoice_id\n @invoice_id if @invoice_id\n end", "def get_id(ind)\n\t\treturn @tile_Array[ind].return_id\n\tend", "def id\r\n @id\r\n end", "def convert_interests_to_hash\n interests = Interest.all.map do |interest|\n [interest.id, interest.name.gsub(/'/, \"''\")]\n end\n interests.to_h\n end", "def id\n 1\n end", "def set_interview\n @interview = Interview.find(params[:id])\n end", "def laboratorios_id\n laboratorios.all.map { |l| l.id }\n end", "def update\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.html { redirect_to @interest, notice: 'Interest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def id\n attributes[self.class.primary_key]\n end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def set_interview\n @interview = Interview.find_by_id(params[:id])\n end", "def create\n standard_create(Interest, interest_params)\n end", "def compound_id\n \"#{self.exhibit_id}-#{self.id}\"\n end", "def show\n @interest = Interest.find(params[:id])\n @interests = Interest.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @interest }\n end\n end", "def _add_interest(interest)\n return interest if interests.include?(interest)\n super(interest)\n end", "def find_by_interest(interests)\n # Fetch all readable\n records = all\n filtered_records = []\n\n interests.each do |interest|\n find_tag = ActsAsTaggableOn::Tag.find_by_name(interest)\n if find_tag\n records.each do |record|\n taggings = ActsAsTaggableOn::Tagging.find_all_by_taggable_id(record.id)\n filtered = (tagging.tag_id == find_tag.id)\n filtered = filtered && (tagging.context == 'interest')\n if filtered\n filtered_records << record\n end\n end\n end\n end\n filtered_records\n end", "def set_individual_int\n @individual_int = IndividualInt.find(params[:id])\n end", "def id\n @id\n end", "def id\n @id\n end" ]
[ "0.7075682", "0.6963178", "0.6963178", "0.6963178", "0.6963178", "0.6963178", "0.69167006", "0.679399", "0.66481733", "0.6397777", "0.62641895", "0.62553436", "0.60541075", "0.6051885", "0.60421365", "0.59422874", "0.59422874", "0.5873735", "0.5846951", "0.58388776", "0.57914126", "0.5741778", "0.5740688", "0.5674621", "0.5670664", "0.5668444", "0.56668115", "0.56661266", "0.5653779", "0.56533647", "0.5616399", "0.5600372", "0.55843985", "0.55828345", "0.55828345", "0.5581724", "0.55510867", "0.5504194", "0.54934525", "0.5476925", "0.5469524", "0.5462531", "0.54572874", "0.54567844", "0.5453585", "0.5451323", "0.5445115", "0.54429513", "0.543455", "0.54325324", "0.5432236", "0.5411149", "0.5402788", "0.53916276", "0.5390725", "0.5388015", "0.5380982", "0.5371895", "0.5371254", "0.53712314", "0.53712314", "0.536606", "0.5358965", "0.53560185", "0.5355247", "0.5352327", "0.5348449", "0.533799", "0.5337311", "0.5337023", "0.5335834", "0.53321344", "0.5332074", "0.5317714", "0.53137064", "0.5312365", "0.53114605", "0.52973115", "0.52884525", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.52861494", "0.5285055", "0.52774584", "0.5270557", "0.5262048", "0.5261957", "0.52608716", "0.5256455", "0.5245708", "0.5245708" ]
0.7844811
0
method that returns an array of all the interests of a friend
def find_interests_array(db, friend_name) friend_interests = db.execute("SELECT interests.interest FROM friends join friends_interests on friends.id=friends_interests.friend_id join interests on interests.id=friends_interests.interest_id where friend_name='#{friend_name}'") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_friends_with_interest(name)\n self.friends(:f).relatives.interests.where(name: name).pluck(:f)\n end", "def friends\n @friends_arr = []\n current_user = User.where(id: self.id)\n friends = current_user[0].friendships\n friends.each do |f|\n @friends_arr.push(f.friendee)\n end\n \n @friends_arr\n end", "def friends\n output = []\n friendships.each do |f|\n output << f.friend\n end\n output\n end", "def inverse_friends\n output = []\n inverse_friendships.each do |f|\n output << f.user\n end\n output\n end", "def get_interests\n\t\t@si = SocietyInterest.where(society_id: self.id)\n\t\t@interests = []\n\t\[email protected] do |s|\n\t\t\t@interests << Interest.find_by_id(s.interest_id)\n\t\tend\n\t\treturn @interests\n end", "def friends\n all_friends = [];\n self.friendships.each do |ship|\n if ship.status == 'approved'\n friend_id = get_friend_id_from_friendship(ship)\n friend = User.find(friend_id)\n all_friends << friend\n end\n end\n all_friends\n end", "def friends\n friendships.where(accepted: true).map(&:friend)\n end", "def friendlist(user)\n User.find_by_sql(\n \"SELECT\n friend_interests_users.user_id as id,\n count(common_interests.id) as num_common_interests\n FROM\n users as me\n left join interests_users as my_interests_users on my_interests_users.user_id = me.id\n left join interests as common_interests on my_interests_users.interest_id = common_interests.id\n left join interests_users as friend_interests_users on common_interests.id = friend_interests_users.interest_id\n WHERE\n friend_interests_users.user_id <> #{user.id} and\n me.id = #{user.id}\n GROUP BY\n friend_interests_users.user_id\n ORDER BY\n num_common_interests desc;\"\n )\n end", "def current_user_interests\n current_user.interests\n end", "def all_friends\n friends friendships\n end", "def get_all_friends\n friends = []\n self.friends_ids.each do |id|\n unless Person.find_by_twitter_id(id).nil?\n friends << Person.find_by_twitter_id(id)\n end \n end\n return friends\n end", "def get_friend_ids(cookie)\n Person.get_person_ids(get_friends(cookie))\n end", "def fetch_friend_id_array\n\t\tfriend_ids = hit_twitter { @client.friend_ids.to_a }\n\t\treturn friend_ids\n\tend", "def all_friends\n requested_friends + accepted_friends\n end", "def friends\n friendships = Friendship.where('(user_id = ? OR friend_id = ?) AND confirmed = ?', self.id, self.id, true)\n users = []\n friendships.each do |friendship|\n if friendship.user_id == self.id\n users.push User.find friendship.friend_id\n else\n users.push User.find friendship.user_id\n end\n end\n\n users\n end", "def friendslist()\n hash_list = SQLQuery.new.get('friends', ['user_id', 'user2_id']).where.open_.if('user_id', @id).or.if('user2_id', @id).close_.and.if('status', 0).send\n list = []\n hash_list.each do |hash|\n if hash['user_id'] == @id\n list << Friend.get(@id, hash['user2_id'])\n else\n list << Friend.get(@id, hash['user_id'])\n end\n end\n return Sorter.last_interaction(list)\n end", "def friends(cookie)\n Person.find_kassi_users_by_ids(get_friend_ids(cookie))\n end", "def friends\n self.invited + self.invited_by\n end", "def friend_requests\n inverse_friendships.map{|friendship| friendship.user if !friendship.confirmed}.compact\n end", "def all_friends\n friends + inverse_friends\n end", "def all_friends\n return self.users\n end", "def friends_formatted\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [uri, RDF::FOAF.knows, :friend],\n [:friend, RDF::FOAF.name, :realname]\n )\n nfriends = []\n query.each_solution { |sol| nfriends.push({id: sol.friend.as(Member).get_id, realname: sol.realname.to_s}) }\n nfriends\n end", "def received_friend_requests\n friendships = Friendship.where(:friend_id => self.id, :confirmed => false)\n users = []\n friendships.each do |friendship|\n users.push User.find_by_id friendship.user_id\n end\n\n users\n end", "def get_interests_by_id\n return filter_by_id(get_interests)\n end", "def friends\n # @@neo = Neography::Rest.new\n friends = self.trackers & self.tracking\n end", "def get_friends_list\n friends = self.friendships\n friends = friends.map do |friendship|\n User.find(friendship.friend_id)\n end\n end", "def my_friends\n (invited_friends + asked_friendships).compact.uniq\n end", "def friend_requests\n @user_fr.inverse_friendships.map { |friendship| friendship.user unless friendship.confirmed }.compact\n end", "def friends_as_requester\n\t\taccepted_friendship = self.requesting_friendships.where(\"accepted = ?\", true)\n\n\t\tfriends = []\n\n\t\taccepted_friendship.each do |friendship|\n\t\t\tfriends << friendship.accepter\n\t\tend\n\n\t\tfriends\n\tend", "def friend_requests\n inverse_friendships.map { |friendship| friendship.user unless friendship.confirmed }.compact\n end", "def friend_requests\n inverse_friendships.map { |friendship| friendship.user unless friendship.confirmed }.compact\n end", "def friends\n return friendships_confirmed + inverse_friendships_confirmed\n end", "def all_friends\n friends | inverse_friends \n end", "def friends\n friend_ids = active_friendships.where(confirmed: true).pluck(:recipient_id) + passive_friendships.where(confirmed: true).pluck(:initiator_id)\n User.where(id: friend_ids)\n end", "def select_user_interests\n @interests = Interest.all\n # current user interests\n @user_interests = UserInterest.where(:user_id => current_user.id);\n @cur_u = current_user\n\n end", "def friend\n @friends = Friendship.paginate(:page => params[:page], :per_page => 5).where(user_id: current_user).where(aproved: 'yes')\n #@friends_g = Friendship.paginate(:page => params[:page], :per_page => 5).where(user_id: current_user)\n # @friends = @friends_g.select(\"DISTINCT(friend_id)\")\n end", "def requesters\n @requesters_arr = []\n current_user= User.where(id: self.id)\n requesters = current_user[0].friendship_requests\n requesters.each do |r|\n @requesters_arr.push(r.friendee)\n end\n\n @requesters_arr\n \n\n end", "def friends\n friendship_model = Amistad::Friendships.const_get(:\"#{Amistad.friendship_model}\")\n\n approved_friendship = friendship_model.where(friendable_id: id, pending: false, blocker_id: nil).select(:friend_id).to_sql\n approved_inverse_friendship = friendship_model.where(friend_id: id, pending: false, blocker_id: nil).select(:friendable_id).to_sql\n\n self.class.where(\"id in (#{approved_friendship}) OR id in (#{approved_inverse_friendship})\")\n end", "def interests_for_trust(trustee)\n offered_interests = Trust.where('trusts.trustor_id = ? AND trustee_id = ?', self.id, trustee.id).map(&:interest_id)\n interest_ids_to_offer = user_interest_preferences.map(&:interest_id) - offered_interests\n return Interest.where(:id => interest_ids_to_offer)\n end", "def sent_friend_requests\n friendships = Friendship.where(:user_id => self.id, :confirmed => false)\n users = []\n friendships.each do |friendship|\n users.push User.find friendship.friend_id\n end\n\n users\n end", "def active_friends\n\t# friends I requested + friends that requested my friendship\n # map to get the exact list of friends\n\t self.friendships.where(state: \"active\").map(&:friend) + self.inverse_friendships.where(state: \"active\").map(&:user)\n end", "def friends \n friends = []\n friendships = Relationship.where(\"follower_id = :user_id and friend_status = 'FRIENDS' or followed_id = :user_id and friend_status = 'FRIENDS'\", {user_id: self.id})\n\n friendships.each do |friendship|\n if friendship.followed_id == self.id\n friends.append(friendship.follower)\n else\n friends.append(friendship.followed)\n end\n end\n\n\tfriends << self\n\t\n return friends \n end", "def friends\n active_friends + passive_friends\n end", "def friends\n\t\t#sql query for the requested and accepted friendships ID's using the user id\n\t\tactive_ids = \"SELECT friend_pasive_id FROM relationships WHERE friend_active_id = :user_id AND accepted = true\"\n\t\t#sql query for the received and accepted friendships ID's using the user id\n\t\tpasive_ids = \"SELECT friend_active_id FROM relationships WHERE friend_pasive_id = :user_id AND accepted = true\"\n\t\treturn User.where(\"id IN (#{active_ids}) OR id IN (#{pasive_ids})\", user_id: self.id).includes( avatar_attachment: :blob)\n\tend", "def friends_as_accepter\n\t\taccepted_friendship = self.accepting_friendships.where(\"accepted = ?\", true)\n\n\t\tfriends = []\n\n\t\taccepted_friendship.each do |friendship|\n\t\t\tfriends << friendship.requester\n\t\tend\n\n\t\tfriends\n\tend", "def getIndirectFriends(name)\n validate_arguments([name])\n direct_friends = self.getDirectFriends(name)\n indirect_firends = [] \n intermediate = direct_friends\n while true do \n intermediate.each { |friend| current_iteration << self.getDirectFriends(friend)}\n break if current_iteration.all? { |friend| indirect_friends.include?(friend) }\n current_iteration.uniq.each { |friend| indirect_firends << friend}\n indirect_firends.uniq!\n intermediate = current_iteration\n current_iteration = [] \n end\n return indirect_firends\n end", "def index\n @users = User.search(params[:search])\n @friends = current_user.friends\n @inverse_friends = current_user.inverse_friends\n @requests = current_user.requests.collect { |request| User.find(request.friend_id) }\n @inverse_requests = current_user.inverse_requests.collect { |request| User.find(request.user_id) }\n end", "def index\n @friends = current_user.friend\n end", "def index\n @relationships = current_user.friends\n end", "def index\n if logged_in?\n @friend_id = params[:friend_id]\n\n @user = facebook_data_about '/me'\n @likes = facebook_data_about '/me/likes', :as => \"data\"\n @friends = facebook_data_about '/me/friends', :as => \"data\"\n\n if @friend_id\n @friend_id = params[:friend_id]\n @friend = facebook_data_about \"/#{@friend_id}\"\n @friends_likes = facebook_data_about \"/#{@friend_id}/likes\", :as => \"data\"\n end\n\n if @friends_likes\n @intersection = intersection_of(@likes, @friends_likes)\n end\n end\n end", "def get_my_friends\n remember_token = User.digest(cookies[:remember_token])\n current_user ||= User.find_by(remember_token: remember_token)\n p \"current_user\", current_user\n results = []\n # user = User.find_by_username(current_user.id)\n friends = Friend.where(user_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n friends = Friend.where(friend_id: current_user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id: friend.id, username: friend.username, fullname: friend.first_name.capitalize + ' ' + friend.last_name.capitalize}\n end\n render json:results\n end", "def interest_list user\n raw user.interest_list.collect { |interest| \n content_tag(:span, interest, class: \"interest\")\n }.join(\", \")\n end", "def ego_net_retweets\n retweets = []\n self.retweet_ids.each do |retweet| \n begin\n if Person.find_by_username(retweet[:person]).friends_ids.include?(self.person.twitter_id) \n retweets << retweet\n end\n rescue\n end \n end\n return retweets\n end", "def index\n @friends = current_user.friends\n end", "def friends\n friend_uids = []\n friend_uids = friend_uids + self.sent_friends.pluck(:reciever_uid)\n friend_uids = friend_uids + self.received_friends.pluck(:sender_uid)\n return User.where(:uid => friend_uids)\n end", "def searchlist\n\t\t@friendsHash = current_user.multi_friends\n\t\t# Get current user invited friends\n\t\tinviteFriends\n\t\t@alreadyinvitedusers = []\n\t\tif [email protected]?\n\t\t\t@invitedFriends = @invitedFriends.map(&:inspect).join(', ')\n\t\t\t@alreadyinvitedusers = User.where(\"id in (#{@invitedFriends})\").pluck(:uid)\n\t\tend\n\n\t\t# Get user Accepted friends UID\n\t\tacceptedFriends\n\t\t@alreadyAcceptedUsers = []\n\t\tif [email protected]?\n\t\t\t@acceptedFriends = @acceptedFriends.map(&:inspect).join(', ')\n\t\t\t@alreadyAcceptedUsers = User.where(\"id in (#{@acceptedFriends})\").pluck(:uid)\n\t\tend\n\t\t\n\t\t@dt = {}\n current_user.multi_friends.each do |k,v| \n dist = dist(k)\n \tdist = (dist == 'No found') ? 99999 : dist\n @dt.merge!( k => dist)\n end\n\n @sortFriends = @dt.sort_by {|_k, val| val}\n\tend", "def all_friends\n (friends.all + inverse_friends.all).uniq\n end", "def friends\n @_friends ||= Friendable.resource_class.where(:id => friend_ids)\n end", "def pending_friends\n friendships.map{|friendship| friendship.friend if !friendship.confirmed}.compact\n end", "def friends\n first_set = self.initiated_friendships\n second_set = self.received_friendships\n return first_set + second_set\n end", "def full_facebook_friends\n @full_facebook_friends = []\n facebook_friends.each_with_index do |friend, index|\n hash = HashWithIndifferentAccess.new(name: friend['name'], id: friend['id'], image_url: friend['image_url'], label: friend['name'])\n hash[:interests] = read_facebook_friend_interests[index] ||[]\n hash[:activities] = read_facebook_friend_activities[index] ||[]\n hash[:likes] = read_facebook_friend_likes[index] ||[]\n hash[:location] = read_facebook_friend_locations[index] ||\"\"\n @full_facebook_friends << hash\n end\n return @full_facebook_friends\n end", "def active_friends\n \tself.friendships.where(state: \"active\").map(&:friend) + self.inverse_friendships.where(state: \"active\").map(&:user)\n end", "def friend_requests\n\t\tactive_ids = \"SELECT friend_active_id FROM relationships WHERE friend_pasive_id = :user_id AND accepted = false ORDER BY new_request ASC , created_at ASC\"\n\t\treturn User.where(\"id IN (#{active_ids})\", user_id: self.id).includes( avatar_attachment: :blob)\n\tend", "def all_friend_ids(username = false)\n ids = []\n cursor = \"-1\"\n while cursor != 0 do \n json = get(\"/friends/ids.json?cursor=#{cursor}#{username ? \"&screen_name=#{username}\" : ''}\")\n cursor = json[\"next_cursor\"]\n ids += json[\"ids\"]\n end\n ids\n end", "def friends\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/friends/list').friends\n end", "def get_friends\n results = []\n user = User.find_by_username(params[:username])\n friends = Friend.where(user_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.friend_id)\n results << {id:friend.id, username: friend.username}\n end\n friends = Friend.where(friend_id: user.id, accepted: true)\n friends.each do |friend_rel|\n friend = User.find(friend_rel.user_id)\n results << {id:friend.id, username: friend.username}\n end\n render json:results\n end", "def getInvited\n rsvpInvited = []\n Invitation.where(\"study_session_id = '#{self.id}' AND status = 'invited'\").each do |invitation|\n rsvpInvited.push(User.where(\"id = '#{invitation.user_id}'\").first)\n end\n return rsvpInvited\n end", "def friend_search()\n users = User.all.map {|u| u.email }.concat( Candidate.all.map {|u| u.email } )\n render :json => users\n end", "def friends\n @_friends ||=\n Rails.cache.fetch(\"accounts/#{self.id}/friends\", expires_in: Settings.cache.friends) do\n Set.new client.friend_ids\n end\n end", "def index\n\t\t@user = User.find(params[:user_id])\n\t\t@order = @user.orders.find(params[:order_id])\n\t\t@invited_friends = @order.order_friend_invitations\n\t\t@invited_friends_ids = []\n\t\t@invited_friends.each do |inv|\n\t\t\t@invited_friends_ids << inv.user_id.to_i\n\t\tend\n\t\t@invited_friends = User.where(id: @invited_friends_ids)\n\tend", "def index\n @my_girlfriends = MyGirlfriend.where(user_id:current_user.id)\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 pending_friends\n inverse_friendships.map{ |fs| fs.user unless fs.accepted? }.compact\n end", "def pending_friends\n \t pending_friends_by_me + pending_friends_for_me\n \t end", "def index\n @user_interests = UserInterest.all\n end", "def loners(people)\n lonely_array = []\n for person in people\n if person[:friends] == []\n lonely_array.push(person[:name])\n end\n end\n return lonely_array\nend", "def likers\n likes.map do |like|\n like.user\n end\n end", "def index\n # byebug\n if params[:requester] == \"sent\"\n @friend_requests = current_user.friend_requests_as_requester\n else\n @friend_requests = current_user.friend_requests_as_requested\n end\n filter_friend_requests\n end", "def my_friends\n @current_user = User.find(params[:user_id])\n render json: {\n friends: @current_user.friend.where(status: 'accept').map do |friend|\n {\n id: friend.id,\n name: User.find(friend.friend).name.upcase,\n avatar: \"#{request.base_url}#{Rails.application.routes.url_helpers.rails_blob_path(User.find(friend.friend).avatar, only_path: true)}\",\n date: friend.created_at\n }\n end\n }\n end", "def list(*friends) # Splat (*) turns the friends parameter into an array\n p friends\nend", "def friends\n active_friends | received_friends\n end", "def friends\n active_friends | received_friends\n end", "def all_friends\n User.where ['external_user_id IN (?) OR id IN (?)', facebook_friends_ids, email_friends_ids]\n end", "def index\n @friends = @member.friends\n end", "def users_sharing_the_same_interest\n self.user_interest_preferences.map(&:user_id)\n end", "def friends(g)\n \n ip = g.ll\n @friends = @access_token.get(\"/v1/checkins?geolat=#{ip[:lat]}&geolong=#{ip[:long]}\", {'User-Agent' => \"fourrific:#{Fourrific::VERSION}\"}).body \n \n begin\n @friends = Crack::XML.parse(@friends)\n if @friends['unauthorized']\n @error = \"#{@friends['unauthorized']}. Clear your cookies & cache and try again.\"\n elsif @friends['ratelimited']\n @error = \"#{@friends['ratelimited']}. Please try again later.\"\n elsif @friends['error']\n @error = \"#{@friends['error']}\"\n else\n @friends['checkins']['checkin'].each do |checkin|\n checkin['created'] = checkin['created'].to_time.iso8601\n checkin['distance'] = (checkin['distance'].to_i / 1609.344).to_i\n end\n end \n end\n \n \n @friends\n \n end", "def friends\n self.friended_users + self.users_friended_by\n end", "def interests\n @articles = Article.tagged_with(current_user.interest_list, any: true)\n @articles = @articles.paginate(page: params[:page], per_page: 10).order('pub_date DESC')\n end", "def friend_requests\n FriendRequest.all.select do |req|\n req.to_user_id == self.id && req.pending\n end\n end", "def proposed_friends\n friendships.map{ |fs| fs.friend unless fs.accepted? }.compact\n end", "def invited\n self.class.find(friend_ids)\n end", "def likes\n people = []\n query = Activity.joins { verb }.where { activity_object_id.eq(my { id }) }\n\n activities_likes = query.where { verb.name.eq('like') }\n activities_likes.each do |activity|\n people.push activity.actor\n end\n\n activities_unlikes = query.where { verb.name.eq('unlike') }\n activities_unlikes.each do |activity|\n people.delete_at people.index(activity.actor)\n end\n\n people\n end", "def trackers\n # @@neo = Neography::Rest.new\n self_node = User.first.get_node\n if self_node\n trackers = []\n begin\n trackers_list = self_node.incoming(:friends).map{ |n| [n.object_type, n[:object_id]] }\n trackers_list = trackers_list.group_by{|x| x[0]}\n trackers_list.each do |tracker_type|\n tracker_ids = tracker_type[1].map{|u|u[1]}\n trackers << tracker_type[0].safe_constantize.where(id: tracker_ids).try(:to_a)\n end\n rescue Exception\n end\n return trackers.flatten\n else\n return []\n end\n end", "def friends\n\n Frind.where(\"accepted = ? AND (user_id = ? OR friend_id = ?)\", true, self.id, self.id)\n\n # Frind.where(\"accepted = ?\", true)\n\n\n\t # friends_ids = self.frinds.where(accepted: true).pluck(:friend_id)\n # received_friends_ids = self.received_frinds.where(accepted: true).pluck(:friend_id)\n # # received_friends_ids = self.received_frinds.where(accepted: true).pluck(:user_id)\n\n # friends_ids = friends_ids + received_friends_ids\n # User.where(:id => friends_ids)\n\tend", "def friendships_pending\n friendships_pending = []\n friendships.where(confirmed: false).each { |fs| friendships_pending << User.find(fs.friend_id) }\n friendships_pending\n end", "def found_friends(people)\n friends = []\n people.each do |person|\n if (person == \"Don\")\n friends << \"Don\"\n end\n if (person == \"John\")\n friends << \"John\"\n end\n if (person == \"Kent\")\n friends << \"Kent\"\n end\n end\n return friends\nend", "def friends\n User.where(:guid => self.friend_guids)\n end", "def online_friends\n users = []\n OnlineStatus.online_users\n $redis.sinter(\"#{key}:friends\", \"OnlineUsers\").each do |u|\n users << User.new(u)\n end\n users\n end", "def mine\n friends = Friend.includes(:other).where \"user_id = :id OR other_id = :id \", {:id => current_user.id}\n map = {} # a map from others to their relationships\n friends.each do |f|\n id = f.user_id == current_user.id ? f.other_id : f.user_id\n map[id] ||= []\n map[id] << f\n end\n data = []\n friends.each do |f|\n own = f.user_id == current_user.id\n other = own ? f.other_id : f.user_id;\n rels = map[other]\n mutual = rels.length == 2\n next if mutual && !own\n email = own ? f.other.email : f.user.email\n datum = {own: own, id: f.id, email: email, mutual: mutual}\n if mutual\n not_this = rels.select{ |o| o.id != f.id }[0]\n me, them = f, not_this\n me, them = not_this, f if !own\n datum[:other_id] = them.id\n datum[:subscribed_to_them] = me.subscribed\n datum[:subscribed_to_me] = them.subscribed\n else\n datum[own ? :subscribed_to_them : :subscribed_to_me] = f.subscribed\n end\n data << datum\n end\n render json: {friends: data}\n end", "def friends_ids\n self.friends_ids_hash.keys rescue []\n end" ]
[ "0.7380466", "0.71147174", "0.6999954", "0.6964164", "0.6944664", "0.693833", "0.6826695", "0.6818718", "0.6716332", "0.6712336", "0.668627", "0.6600203", "0.65822005", "0.658095", "0.655361", "0.6532074", "0.650395", "0.64952224", "0.64528954", "0.64249176", "0.6411293", "0.6386151", "0.637716", "0.6373507", "0.6366687", "0.6355536", "0.635093", "0.63397926", "0.63384223", "0.63091797", "0.63091797", "0.63023895", "0.6300532", "0.6289937", "0.6289102", "0.62839055", "0.6283662", "0.62763387", "0.6271755", "0.62603366", "0.6254266", "0.6245495", "0.6239663", "0.6220233", "0.6214818", "0.62030476", "0.61840624", "0.61766803", "0.61690515", "0.61489755", "0.6123213", "0.61092436", "0.6104876", "0.60959", "0.60800123", "0.6076538", "0.60692704", "0.6069005", "0.6062245", "0.6055366", "0.60535777", "0.603129", "0.6028574", "0.6018122", "0.6015106", "0.6014868", "0.6014818", "0.60108554", "0.600734", "0.60053337", "0.599889", "0.5992767", "0.59866554", "0.5984817", "0.5981367", "0.59783936", "0.5977572", "0.59743553", "0.59721476", "0.5969067", "0.5967323", "0.5967323", "0.5965619", "0.5964193", "0.5963368", "0.5946815", "0.59420294", "0.59381336", "0.5935791", "0.59273195", "0.59096974", "0.5908978", "0.59067404", "0.5906507", "0.5905615", "0.5897823", "0.58954", "0.58852327", "0.5882418", "0.58757406" ]
0.6811051
8
Time complexity O(1) Space complexity O(1)
def add_first(data) new_node = Node.new(data, nextNode = @head) @head = new_node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def find_unique_elements(arr)\n \nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def solution(a)\n a.uniq.count\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def findlargestdrop(arr)\n\n\n\nend", "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\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 find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def solution1(a)\n a.map(&:abs).uniq.size\nend", "def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend", "def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend", "def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend", "def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend", "def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend", "def find_duplicate(nums)\n intersection = find_first_meeting(nums)\n find_cycle_start(nums,intersection)\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend", "def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend", "def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend", "def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend", "def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def sub_sum2(array)\n arr = []\n sum = 0\n array.each do |el|\n arr << [el] \n end\n array.each do |el|\n array.shift\n arr << array\n end\n # p arr\n result = 0\n arr.each do |set|\n if set.reduce(:+) > result\n result = set.reduce(:+)\n end \n end \n result\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend", "def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend", "def sq_arr(a)\n # require 'debug'\n a.map! { |x| x**2 }\n j = (a.length - 1)\n return a if j == 0\n while a[0] >= a[1] && j >= 0\n p j\n if a[0] > a[j]\n a.insert(j, a.shift)\n else\n j -= 1\n end\n end\n a\nend", "def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend", "def c v1, v2, o\n m = false\n d = []\n (0...v2.size).each{ |j|\n if !v1.include? v2[j] + o\n d << v2[j]\n m = true\n end\n }\n for x in d\n v2.delete x\n end\n m\nend", "def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend", "def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend", "def solution(a)\n # write your code in Ruby 2.2 \n frecuencies = a.each_with_object(Hash.new(0)) { |key, value| value[key] += 1 } \n \n frecuencies.each do |key, value|\n if value.odd? then return key end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend" ]
[ "0.65076977", "0.6224968", "0.59870076", "0.59614", "0.592963", "0.5878061", "0.5871787", "0.58503795", "0.58141303", "0.5810536", "0.5783606", "0.5758984", "0.5741224", "0.57400525", "0.5717067", "0.5695446", "0.56916237", "0.5682769", "0.56791544", "0.56744385", "0.56462455", "0.56403905", "0.56355983", "0.56148314", "0.5609005", "0.5607288", "0.5604348", "0.56018645", "0.5600563", "0.5593942", "0.558283", "0.5582329", "0.5580358", "0.55733967", "0.55704725", "0.5568864", "0.55608475", "0.55544275", "0.554988", "0.5549293", "0.55459195", "0.5545592", "0.5544114", "0.5537456", "0.553246", "0.55293894", "0.5528896", "0.5520509", "0.5520253", "0.551982", "0.5518587", "0.55160594", "0.55106336", "0.5498553", "0.5492679", "0.5492065", "0.54912525", "0.549038", "0.5489442", "0.5483485", "0.54815364", "0.5479698", "0.54748607", "0.54739094", "0.54717714", "0.54707825", "0.54688394", "0.54685116", "0.54661", "0.54639995", "0.5461305", "0.546011", "0.5459417", "0.5458572", "0.54553246", "0.54547024", "0.545129", "0.5449906", "0.5447548", "0.5441376", "0.54389584", "0.5436833", "0.5436647", "0.5435451", "0.5431747", "0.5431689", "0.5426796", "0.5424433", "0.5416063", "0.5414151", "0.5404067", "0.54038966", "0.5400079", "0.5393501", "0.5392692", "0.53889656", "0.5387861", "0.5386957", "0.538585", "0.5381257", "0.5381094" ]
0.0
-1
Time complexity O(1) Space complexity O(1)
def get_first return @head.data if @head return @head end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def find_unique_elements(arr)\n \nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def solution(a)\n a.uniq.count\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def solution(arr)\n zeros = 0\n pass_cars = 0\n\n (0...arr.size).each do |idx|\n arr[idx] == 0 ? zeros += 1 : pass_cars += zeros\n\n return -1 if pass_cars > 1000000000\n end\n\n pass_cars\nend", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def findlargestdrop(arr)\n\n\n\nend", "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def solution4(a)\n left = 0\n right = a.size - 1\n distinct = 0\n\n while left <= right\n # puts \"left: #{left}, right: #{right}\"\n # puts \"a[l]: #{a[left]}, a[r]: #{a[right]}\"\n # puts \"distinct: #{distinct}\"\n if a[left].abs > a[right].abs\n begin\n left += 1\n end until a[left] != a[left - 1]\n elsif a[left].abs < a[right].abs\n begin\n right -= 1\n end until a[right] != a[right + 1]\n else\n begin\n left += 1\n end until a[left] != a[left - 1]\n begin\n right -= 1\n end until a[right] != a[right + 1] \n end\n\n distinct += 1\n end\n distinct\nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def third_anagram?(str1, str2)\n beginning_time = Time.now\n str1.split(\"\").sort == str2.split(\"\").sort #O(nlogn)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\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 find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def solution1(a)\n a.map(&:abs).uniq.size\nend", "def solution(a)\n result = 0\n tmp_count = 0\n a.each_with_index do |val, idx|\n if val.zero?\n tmp_count += 1\n else\n result += tmp_count\n end\n end\n return result > 1000000000 ? -1 : result\nend", "def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend", "def fifth_anagram?(word1, word2) # O(n)\n \n p \"Running fifth_anagram...\" \n\n start = Time.now\n \n hash1 = Hash.new(0)\n # hash2 = Hash.new(0)\n\n word1.each_char {|char| hash1[char] += 1}\n word2.each_char {|char| hash1[char] += 1}\n\n hash1.values.all? {|v| v.even?}\n\n\n # puts \"Took #{Time.now - start} seconds\"\n\n \nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def find_unique_elements(arr)\n \n#Algorithmic Process\n#Create an array that includes elements without the repeats\n#Create a hash that pairs each element of the new array with how many times it appears in the original array\n#Any key-value pair that has 1 for a value is unique and gets placed in the desired array\n \nnew_hash = {}\narr.each do |x|\n new_hash[x] = 0 if new_hash[x].nil?\n new_hash[x] = new_hash[x] + 1\nend\n\nnew_hash.delete_if {|key, value| value != 1}\nnew_hash.each_key {|key| puts key}\n\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend", "def two_sum(numbers, target)\n ##set hash\n hash = {}\n ##set array\n arr = []\n\n numbers.each_with_index do |val, idx|\n if hash.key?(target - val)\n arr.push(hash[target - val])\n arr.push(idx + 1)\n break\n else\n hash[val] = idx + 1\n end\n end\n\n arr\nend", "def better_sum?(arr, target)\n pair_set = Set.new\n\n arr.each do |ele|\n if pair_set.include?(ele)\n return true\n else\n pair_set << target - ele\n end\n end\n\n false\n\nend", "def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def fast_lcss(arr)\n i_arr = []\n biggest = 0\n max_sub_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sum = i_arr.inject(0) do |a, b|\n a + b\n end\n max_sub_arr = i_arr if sum > biggest\n biggest = sum if sum > biggest \n end\n i_arr = []\n arr.shift\n end\n max_sub_arr\nend", "def my_min_2(arr) #O(N)\n min_num = arr.first\n \n arr.each { |num| min_num = num if num < min_num }\n \n min_num\n end", "def awesome(arr, target)\n hash = Hash.new(0)\n i = 0\n j = i + 1\n while i < arr.size\n hash[arr[i] + arr[j]] += 1 \n if j < arr.size\n j += 1\n else\n i += 1\n if j = i + 1 > arr.length\n j = i \n else\n j = i + 1\n \n end\n\n end\n \n end\n return true if hash[target] >= 1\n false\nend", "def unique_in_order(iterable) \n# create an empty array\ncontent = []\n\n # check each letter/number of `iterable` \n for e in (0..iterable.length()-1) \n\n# compare current element to previous element\n# if array is empty\n if e == 0 or \n# \n# if current element is not the same with previous element, push current index to content array\n iterable[e] != iterable[e-1] \n content.push(iterable[e])\n end\n end\n# return new content array\n return content\nend", "def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend", "def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend", "def find_duplicate(nums)\n intersection = find_first_meeting(nums)\n find_cycle_start(nums,intersection)\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def intersect nums1, nums2\n result = []\n return result if nums1.size == 0 or nums2.size == 0\n\n counter_cache = {}\n counter_cache = nums1.inject({}) { |result, n|\n result[n] ||= 0\n result[n] += 1\n result\n }\n\n nums2.each do |n|\n if counter_cache[n] and counter_cache[n] > 0\n result << n\n counter_cache[n] -= 1\n end\n end\n result\nend", "def my_min2 # O(n) time complexity\n smallest = self.first\n self.each do |num|\n sleep(1)\n smallest = num if num < smallest \n end\n smallest\n end", "def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend", "def solution(a)\n counts = {}\n for i in a\n counts[i] ||= 0\n counts[i] += 1\n end\n for i in (1..a.count)\n return 0 if counts[i] != 1\n end\n return 1\nend", "def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend", "def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def second_anagram?(word_1, word_2) #O(n^2)\n matching_word = word_2.split(\"\")\n\n word_1.each_char do |ele|\n if matching_word.index(ele) #evaluating the conditional\n matching_word.delete_at(matching_word.index(ele)) #n many times, do this\n end\n end\n\n matching_word.empty? #constant O(1)\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend", "def solution(arr)\n temp_hash_odd_balls = {}\n\n arr.each { |el| temp_hash_odd_balls[el] ? temp_hash_odd_balls.delete(el) : temp_hash_odd_balls[el] = 0 }\n\n temp_hash_odd_balls.keys.first\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def sub_sum2(array)\n arr = []\n sum = 0\n array.each do |el|\n arr << [el] \n end\n array.each do |el|\n array.shift\n arr << array\n end\n # p arr\n result = 0\n arr.each do |set|\n if set.reduce(:+) > result\n result = set.reduce(:+)\n end \n end \n result\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend", "def dominant_octopus(fish)\n #sorted = []\n return fish if fish.length < 2\n pivot = fish.first\n left = fish[1..-1].select { |feesh| feesh.length <= pivot.length }\n #p left\n right = fish[1..-1].select { |feesh| feesh.length > pivot.length }\n\n dominant_octopus(left) + [pivot] + dominant_octopus(right)\n \n\n\nend", "def sq_arr(a)\n # require 'debug'\n a.map! { |x| x**2 }\n j = (a.length - 1)\n return a if j == 0\n while a[0] >= a[1] && j >= 0\n p j\n if a[0] > a[j]\n a.insert(j, a.shift)\n else\n j -= 1\n end\n end\n a\nend", "def solution(a)\n # write your code in Ruby 2.2\n permutation = Array(1..a.size)\n # puts permutation\n return 1 if permutation - a == []\n 0\nend", "def c v1, v2, o\n m = false\n d = []\n (0...v2.size).each{ |j|\n if !v1.include? v2[j] + o\n d << v2[j]\n m = true\n end\n }\n for x in d\n v2.delete x\n end\n m\nend", "def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend", "def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend", "def solution(a)\n # write your code in Ruby 2.2 \n frecuencies = a.each_with_object(Hash.new(0)) { |key, value| value[key] += 1 } \n \n frecuencies.each do |key, value|\n if value.odd? then return key end\n end\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend", "def solution(a)\n\traise ArgumentError.new(\"a has to be non empty array of max size #{MAX_LEN}\") if !a.is_a? Array or a.empty? or a.length > MAX_LEN\n\tret = 0\n\t#puts a.inspect\n\tmy_h = Hash.new\n\ta.each do |e|\n\t\tif my_h.include? e\n\t\t\tmy_h[e] += 1\n\t\telse\n\t\t\tmy_h[e] = 1\n\t\tend\n\tend\n\n\tmy_h_sort = my_h.sort_by {|k, v| -v}\n\t# -> my_h_sort[value][occurances]\n\treturn 0 if my_h_sort.first[1] < a.size/2\n\tleader_val = my_h_sort.first[0]\n\n\tocc_array = Array.new\n\toccurances = 0\n\ta.each do |e|\n\t\toccurances += 1 if e == leader_val\n\t\tocc_array.push(occurances)\n\tend\n\t#puts occ_array.inspect\n\n\tfor idx in (0...a.length-1) do\n\t\tsum1 = occ_array[idx]\n\t\tsum2 = occ_array.last - occ_array[idx]\n\n\t\t# puts \"#{idx}+1 < #{sum1*2}\"\n\t\t# puts \"#{(a.length - idx -1)} < #{(sum2*2 )} \"\n\n\t\tif (idx+1) < sum1 * 2 && (a.length - idx - 1 ) < sum2 * 2\n\t\t\t## we have a leader\n\t\t\t#puts \"YEAH #{idx}\"\n\t\t\tret += 1\n\t\tend\n\t\t\t#puts \"-------- ret: #{ret}\"\n\tend\n\treturn ret\nend" ]
[ "0.65076977", "0.6224968", "0.59870076", "0.59614", "0.592963", "0.5878061", "0.5871787", "0.58503795", "0.58141303", "0.5810536", "0.5783606", "0.5758984", "0.5741224", "0.57400525", "0.5717067", "0.5695446", "0.56916237", "0.5682769", "0.56791544", "0.56744385", "0.56462455", "0.56403905", "0.56355983", "0.56148314", "0.5609005", "0.5607288", "0.5604348", "0.56018645", "0.5600563", "0.5593942", "0.558283", "0.5582329", "0.5580358", "0.55733967", "0.55704725", "0.5568864", "0.55608475", "0.55544275", "0.554988", "0.5549293", "0.55459195", "0.5545592", "0.5544114", "0.5537456", "0.553246", "0.55293894", "0.5528896", "0.5520509", "0.5520253", "0.551982", "0.5518587", "0.55160594", "0.55106336", "0.5498553", "0.5492679", "0.5492065", "0.54912525", "0.549038", "0.5489442", "0.5483485", "0.54815364", "0.5479698", "0.54748607", "0.54739094", "0.54717714", "0.54707825", "0.54688394", "0.54685116", "0.54661", "0.54639995", "0.5461305", "0.546011", "0.5459417", "0.5458572", "0.54553246", "0.54547024", "0.545129", "0.5449906", "0.5447548", "0.5441376", "0.54389584", "0.5436833", "0.5436647", "0.5435451", "0.5431747", "0.5431689", "0.5426796", "0.5424433", "0.5416063", "0.5414151", "0.5404067", "0.54038966", "0.5400079", "0.5393501", "0.5392692", "0.53889656", "0.5387861", "0.5386957", "0.538585", "0.5381257", "0.5381094" ]
0.0
-1
Time complexity O(n) Space complexity O(1)
def length current_node = @head return 0 unless current_node list_length = 0 until current_node.nil? list_length += 1 current_node = current_node.next end return list_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\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 f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def solution(a)\n a.uniq.count\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def removNb(n)\n results = []\n (2..n).each do |a|\n b = (n*(n+1)/2.0-a)/(a + 1)\n results << [a, b.to_i] if b % 1 == 0 && b < n && b > 2\n end\n results\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def find_missing(array, n)\n i = 0\n\n (1..n).each { |number| i = i ^ number }\n array.each { |number| i = i ^ number }\n\n i\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def removNb(n)\n res = []\n total = (n*n + n) / 2\n range = (1..n)\n \n (1..n).each do |a|\n b = ((total - a) / (a * 1.0 + 1.0))\n if b == b.to_i && b <= n\n res.push([a,b.to_i])\n end\n end\n\n return res\nend", "def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend", "def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def compute(n)\n a = []\n a.push(1)\n a.push(1)\n n -=1\n first = 1\n second = 1\n n.times do\n third = first + second\n first = second\n second = third\n a.push(third)\n end\n #first\n a\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def solution(a)\n # we could do radix sort and then loop over all the items in order to find the missing element\n # in the ordered list or use the Gauss theorem: https://study.com/academy/lesson/finding-the-sum-of-consecutive-numbers.html\n #\n # if we use the Gauss theorem we can do:\n # sum = (1 + N+1) * ( N / 2 )\n #\n # if (1 + N+1) % 2 == 1 we need to sum also (n+1+1)/2 + 1\n #\n # then remove every item from the sum: the remainder is the missing number\n len = a.length\n sum = (1 + len + 1) * ((len + 1) / 2)\n sum += ((len + 1) / 2.0).ceil unless (len + 1) % 2 == 0\n\n a.reduce(sum) do |sum, i|\n sum - i\n end\nend", "def answer(n, a)\n count = 0\n n.times do |nn|\n next if a[nn] != nn + 1\n a[nn], a[nn + 1] = a[nn + 1], a[nn]\n count += 1\n end\n count\nend", "def find_unique_elements(arr)\n \nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def removNb(n)\n numbers = (1..n).to_a\n all_combinations = numbers.combination(2).to_a\n possible_pairs = []\n sum = numbers.reduce(:+)\n all_combinations.each do |pair|\n if (sum - pair.reduce(:+)) == pair.reduce(:*)\n possible_pairs << pair\n possible_pairs << pair.reverse\n end\n end\n possible_pairs\nend", "def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def solution(n, a)\n max = 0\n counters = Array.new(n, max)\n a.each do |counter|\n if counter == n + 1\n counters.fill(max)\n else\n counters[counter - 1] += 1\n max = counters[counter - 1] if counters[counter - 1] > max\n end\n end\n counters\nend", "def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend", "def cout(n)\n\tw=[0,1,2,3,4,5,6,7,8,9]\n\tx=[]\n\tk=1\n\twhile x!=w do \n\t\tm=n*k\n\t\t\twhile m>0 do\n\t\t\t\tt=m%10\n\t\t\t\tx=x.push(t)\n\t\t\t\tx.sort!\n\t\t\t\tx.uniq!\n\t\t\t\tm=m/10\t\n\t\t\tend\n\t\tk=k+1\n\tend\nreturn (k-1)*n\nend", "def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend", "def solution(a)\n stack = []\n\n a.each_with_index do |n, i|\n if stack.empty?\n stack << [i, n]\n next\n end\n\n last_value = stack.last[1]\n\n if n == last_value\n stack << [i, n]\n else\n stack.pop\n end\n end\n\n return -1 if stack.empty?\n\n i, cd = stack.last\n\n count = a.inject(0) do |acc, n|\n cd == n ? acc + 1 : acc\n end\n\n count > a.length / 2 ? i : -1\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend", "def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n sum_of_series= (n*(n+1))/2 #Sum of series 1 to n\n \n #Find sum and product of array elements\n sum=0\n product=1\n \n for x in a\n sum+=x\n product*=x\n end\n \n sum-=sum_of_series #sum is a+b now,where a and b are repeating numbers\n product/=fact(n) #product is a*b now,where a and b are repeating numbers\n \n temp= Math.sqrt((sum**2)-(4*product)).to_i # temp is a-b\n \n\tprint \"#{(sum+d)/2} #{(sum-d)/2}\"\nend", "def linear_search(n)\n\t(1..100).to_a.shuffle.each do |x|\n\t\tif x == n\n\t\t\tbreak\n\t\tend\n\tend\nend", "def pick(n,history)\n i = -1\n j = 0\n while j < (n + 1)\n i += 1\n j += 1 if history[i] == nil\n \n end\n \n return i\nend", "def sum_to_n? arr, n\n if arr.length > 1\n for i in arr do\n ndx = arr.find_index(i)\n x = arr.delete_at(ndx)\n if arr.include?(n - x)\n return true\n end\n arr.insert(ndx, x)\n end\n end\n return false\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend", "def two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend", "def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def remove_duplicates(nums)\n record_leng = 0\n uniq_arr = nums.uniq\n uniq_arr.each do |i|\n record_leng += 1 if count_great_two?(nums, i)\n end\n return (record_leng + uniq_arr.size)\nend" ]
[ "0.6839633", "0.67023456", "0.6287286", "0.6151161", "0.61348873", "0.61199117", "0.61065507", "0.6105198", "0.60804695", "0.605704", "0.6049214", "0.60462457", "0.6014997", "0.6008531", "0.60057807", "0.5989388", "0.598355", "0.59711045", "0.5970589", "0.5946939", "0.59417105", "0.59406483", "0.59309417", "0.59249526", "0.59204745", "0.59098554", "0.5904608", "0.5904539", "0.5902171", "0.5891673", "0.5883987", "0.5872558", "0.5860383", "0.5859488", "0.5855423", "0.5847832", "0.58404994", "0.58141917", "0.58085304", "0.5803843", "0.58015823", "0.5800319", "0.57939315", "0.57899296", "0.57895136", "0.578691", "0.57779783", "0.57670075", "0.5766289", "0.5765673", "0.57510227", "0.5743006", "0.57429975", "0.57429713", "0.5740255", "0.5734026", "0.5729159", "0.5726369", "0.57093626", "0.5707113", "0.57069445", "0.5703999", "0.57019794", "0.5696049", "0.56955314", "0.5694097", "0.5689125", "0.5678438", "0.5667652", "0.5666363", "0.56646794", "0.5664437", "0.56622916", "0.5659654", "0.5657236", "0.5654031", "0.5652584", "0.565255", "0.565243", "0.5651789", "0.56464934", "0.5642265", "0.56411356", "0.5640376", "0.56399333", "0.5638954", "0.5637773", "0.56352377", "0.56336105", "0.563302", "0.5624579", "0.5618673", "0.56185347", "0.56172186", "0.5615088", "0.561475", "0.56138384", "0.56133044", "0.56109756", "0.5610156", "0.5602252" ]
0.0
-1
Time complexity O(n); O(n) to get to last element, O(1) to insert Space complexity O(1)
def add_last(data) last_node = Node.new(data) unless head @head = last_node else current_node = @head until current_node.next.nil? current_node = current_node.next end current_node.next = last_node end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_last(element)\n if @first_node == nil\n insert_first(element)\n else\n old_last_node = find_last_node\n old_last_node.insert_after(element)\n @size += 1\n end\n end", "def add element\n add_last(element)\n end", "def add element\n add_last(element)\n end", "def insert_last(value)\n \n end", "def insertion(a)\n\tlen = a.length\t\n\tfor i in 0..(len-1) #going through each element\n\t\tfor j in i..0 #elements go from right to left <-\n\t\t\tif a[j-1] > a[j]\n\t\t\t\ttemp = a[j-1]\n\t\t\t\ta[j - 1] = a[j]\n\t\t\t\ta[j] = temp\n\t\t\tend\n\t\tend\n\tend\n\treturn a\n\nend", "def insert(arr, right_index, value)\n # value is the value to insert\n # right_index is the furthest right sorted element\n\n # Step through sorted elements right to left.\n # As long as your value is less than the element\n # at array[i] and you still have elements\n\n i = right_index\n while(i >= 0 && arr[i] > value)\n # copy the element\n arr[i+1] = arr[i]\n i -= 1\n end\n\n # insert the actual element\n arr[i+1] = value;\nend", "def add_last element\n if empty?\n @head = @tail = Node.new(element, nil)\n else\n @tail.next_node = Node.new(element, nil)\n @tail = @tail.next_node\n end\n @size += 1\n\n return nil\n end", "def add_last element\n if empty?\n @head = @tail = Node.new(element, nil, nil)\n else\n @tail.next_node = Node.new(element, @tail, nil)\n @tail = @tail.next_node\n end\n @size += 1\n\n return nil\n end", "def insert(element)\n [email protected]\n\n @store[@store.length]=element\n return if insertindex==1\n\n #For even inserts parent index is insertedindex/2-1 otherwise its juts insertedindex/2\n\n parentindex=insertindex/2\n\n #Incase it does not fit in(violating Heap Property)\n while insertindex!=1 && @store[parentindex] > @store[insertindex]\n swap(parentindex,insertindex)\n insertindex=parentindex\n parentindex=insertindex/2\n end\n\n end", "def add_to_end(arr, element)\n arr.push(element)\nend", "def insert(data)\n @array << data\n i = @array.size - 1\n while (i >= 0) && (data > @array[(i -1)/2])\n @array[(i -1)/2], @array[i] = @array[i], @array[(i -1)/2]\n i = parent(i)\n end\n @array\n end", "def test_insert_negative_index_append\n assert_equal([\"a\",\"b\",\"c\",7,8,9], @array.insert(-1, 7, 8, 9))\n end", "def insert(index, element)\n raise OutOfBoundsException unless valid_index?(index)\n\n temp_list = array_list\n @array_list = FixedArray.new(length + 1)\n (index -1).times do |below_index|\n array_list.set(below_index, temp_list.get(below_index))\n end\n\n array_list.set(index,element)\n\n (index + 1).upto(length - 1) do |above_index|\n @array_list.set(above_index, temp_list.get(index))\n end\n\n element\n end", "def using_insert (array, element)\n return array.insert(4, element)\nend", "def using_insert(arr, elem)\n arr.insert(4, elem)\nend", "def insert(list, x)\n list_size = list.size\n if x < list[1]\n if x < list[0]\n return [x] + list\n elsif list_size == 2\n return [list[0]] + [x] + [list[1]]\n else\n return [list[0]] + [x] + list[1..2]\n end\n elsif list_size == 2 || x > list[2]\n return list + [x]\n else\n return list[0..1] + [x] + [list[2]]\n end\n end", "def insert(element)\n if @ary.include? element\n return false\n else\n @ary << element\n return element\n end\n end", "def insert(x, arr)\n if arr.empty?\n [x]\n else\n head, *tail = arr\n if head > x\n [x] + arr\n else\n [head] + insert(x, tail)\n end\n end\nend", "def insert_last(value)\n if @queue.size < @size\n @queue.push(value)\n true\n else\n false\n end\n end", "def insert(index, element)\n oob_throw(index)\n if index == 0\n @array = [element] + @array[index + 1..-1]\n else\n @array = @array[0..index-1] + [element] + @array[index..-1]\n end\n end", "def insertion2 arr\n for i in 1..(arr.size-1)\n cur_el = arr[i]\n j = i -1\n while j >= 0 and arr[j] > cur_el\n arr[j+1] = arr[j]\n j = j-1\n end\n arr[j+1] = cur_el\n puts arr.join(' ')\n end\n \nend", "def add_to_list(a)\n i = 0\n while i < @list.length\n if a == a.compareto(list[i])\n @list.insert(i, a)\n #puts \"inserted\"\n return list\n end\n i = i+1\n end\n @list.push(a) \n #puts \"at end\"\n end", "def using_insert(array,element)\n array.insert(4,element)\nend", "def using_insert(array, element)\n array.insert(4, element)\nend", "def using_insert(array, element)\n array.insert(4, element)\nend", "def using_insert(array, element)\n array.insert(4, element)\nend", "def using_insert(array, element)\n array.insert(4, element)\nend", "def using_insert(array, element)\n array.insert(4, element)\nend", "def using_insert(array, element)\n array = array.insert(4, element)\n\n \nend", "def insert_at(index)\n if index < 0 || index >= @size\n return nil\n end\n\n next_to_last = nil\n new_node = nil\n if index == 0\n return prepend\n elsif index == @size-1\n return append\n else\n search_index = @head\n index.times {|i|\n if i == index - 1\n next_to_last = search_index\n end\n search_index = search_index.next_node\n }\n new_node = Node.new\n next_to_last.next_node = new_node\n new_node.next_node = search_index\n end\n @size += 1\n new_node\n end", "def add(value)\n# we first check where we should insert at\n insert_at = @arr.bsearch_index { |obj| obj['pos'] > value.pos }\n if insert_at === nil\n# if it should be added as the last element\n @arr.push(value.to_json)\n else\n @arr.insert(insert_at, value.to_json)\n end\n end", "def using_insert(array, element)\n array.insert(4,element)\nend", "def insertion_sort(a)\n a.each_with_index do |el,i|\n # Insert el into the sorted sublist\n j = i - 1\n while j >= 0\n break if a[j] <= el\n a[j + 1] = a[j]\n j -= 1\n end\n a[j + 1] = el\n\n end\nend", "def using_insert(array, element)\n \n array.insert(4, element)\n \nend", "def insertion_sort_two(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr.delete_at(i)\n j = i - 1\n j -= 1 while j >= 0 && value < arr[j]\n arr.insert(j + 1, value)\n end\n arr\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def push_back(data)\n insert(data, @size)\n end", "def add_new_val(array, last_val)\n result = []\n\n array.each_index do |idx|\n result << array[0...idx] + [last_val] + array[idx..-1]\n end\n\n result << array + [last_val]\nend", "def insert(index,element)\n return nil if index < 0 || index > @size\n if element.new?\n pair = [element,element.class]\n else\n pair = [element.rod_id,element.class]\n end\n @map.keys.sort.reverse.each do |key|\n if key >= index\n value = @map.delete(key)\n @map[key+1] = value\n end\n end\n @map[index] = @added.size\n @added << pair\n #@commands << [:insert,pair]\n @size += 1\n self\n end", "def insert(item)\n\t\t\n\t\tif self.size == @capacity\n\t\t\[email protected]\n\t\tend\n\t\[email protected] item\n\tend", "def insertion_sort(arr)\n\t1.upto(arr.length - 1) do |n|\n\t\tinsert_me = arr[n]\n\n\t\tuntil arr[n - 1] < insert_me || (n - 1) < 0\n\t\t\tarr[n] = arr[n - 1]\n\t\t\tarr[n - 1] = insert_me\n\n\t\t\tn -= 1\n\t\tend\n\tend\n\n\treturn arr\nend", "def insert(x,a)\r\n c = a.dup\r\n c.push(x)\r\n c = c.sort\r\nend", "def insert(val)\n return false if @h[val]\n @a.push(val)\n @h[val] = @a.size - 1\n return true\n end", "def add_last(data)\n current = @head\n # if list is empty, add data to front\n if length == 0\n add_first(data)\n else\n # use length method to move to the last node in the list\n (length - 1).times do \n current = current.next\n end\n last = current\n # insert the new node after the current last node; current last node's next become new last node\n new_node = Node.new(data)\n last.next = new_node\n # assign value of new node's next to nil\n new_node.next = nil\n end\n end", "def add_element_to_beginning_of_array(array, element)\n array.insert(0, element)\nend", "def using_insert(array, item)\n array.insert(4, item)\nend", "def insert(value)\n index = find(value)\n if index == -1\n @inner << value\n index = @inner.length - 1\n end\n return index\n end", "def insert_(array, item, index)\n array = array.insert(index, item)\n puts array\n return array\n \nend", "def append(value)\n if !empty?\n set_tail(value)\n else\n set_head(value)\n end\nend", "def iterative_insertion_sort(arr)\r\n 1.upto(arr.length - 1) do |index|\r\n key = arr[index]\r\n pos = index - 1\r\n while pos >= 0 && key <= arr[pos]\r\n # this could also have been written by swapping repeatedly\r\n # instead of copying the bigger element to the empty slot\r\n arr[pos + 1] = arr[pos]\r\n pos = pos - 1\r\n end\r\n arr[pos + 1] = key\r\n end\r\n arr\r\nend", "def insert(element)\n i = element.hash % @table.size\n node = @table[i]\n while node\n if element == node.item\n node.item = element\n return element\n end\n node = node.next\n end\n @table[i] = Node.new(element,@table[i])\n @count += 1\n return element\n end", "def index_for_insert(element, arr)\n arr.each_with_index { |num,i| if element <= num then return i end}\n -1\nend", "def insert_at(v, list, n)\n list.dup.insert(n, v)\nend", "def add_last(value)\r\n \r\n # if list is empty, insert the new value at the head\r\n if @head.nil?\r\n @head = Node.new(value, nil)\r\n return @head\r\n end \r\n \r\n # otherwise, traverse the list from start to last node ...\r\n current = @head\r\n until current.next.nil?\r\n current = current.next\r\n end\r\n \r\n # ... and insert new node after last node\r\n current.next = Node.new(value, nil)\r\n \r\n end", "def insertion_sort_one(arr)\n 1.upto(arr.length - 1) do |i|\n value = arr[i]\n j = i - 1\n while j >= 0 and arr[j] > value\n arr[j + 1] = arr[j]\n j -= 1\n end\n arr[j + 1] = value\n end\n arr\nend", "def insert_tail(node)\n current_node = @root_node\n while current_node.has_next?()\n current_node = current_node.get_next()\n end\n current_node.set_next(node)\n node.set_prev(current_node)\n end", "def insert_into_min_heap(heap, element)\n heap << element\n current_index = heap.length\n\n while current_index > 1 && element < heap[(current_index / 2) - 1]\n larger_element = heap[(current_index / 2) - 1]\n\n heap[(current_index / 2) - 1] = element\n heap[current_index - 1] = larger_element\n\n current_index = (current_index / 2)\n end\n\n heap\nend", "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 search_insert(nums, target)\n start_ind = 0\n last_ind = nums.size \n\n while start_ind + 1 < last_ind do\n mid = start_ind + (last_ind - start_ind) / 2\n if nums[mid] == target\n return mid\n end\n\n if nums[mid] < target\n start_ind = mid\n else\n last_ind = mid\n end\n end\n\n if nums[start_ind] >= target\n return start_ind\n end\n\n return last_ind\nend", "def insertionsort! arr\n (1..arr.size - 1).each do |i|\n j = i\n while j > 0 && arr[j] < arr[j - 1] do\n arr[j], arr[j - 1] = arr[j - 1], arr[j]\n j -= 1\n end\n end\n arr\nend", "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 using_insert(array, element)\n array.insert(4, element)\n end", "def insertion_sort(list)\n for i in 1..list.size - 1\n j = i - 1\n while j >=0 and list[j+1] < list[j] # if current < previous\n list[j], list[j+1] = list[j+1], list[j] # swap previous and current values. faster.\n\n# list[j+1] = list[j] --- typical book way. slower.\n j -= 1\n end\n# list[j+1] = current --- typical book way. slower.\n end\n list\nend", "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 create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def create_list arr\n list = SinglyLinkedList.new\n arr.each do |i|\n list.insert_at_end i\n end\n list\nend", "def insertion_sort(arr)\n step = arr.size - 1\n \n 1.upto(step).each do |i|\n current = arr[i]\n index = i\n \n (i-1).downto(0).each do |j|\n break if arr[j] < current\n \n arr[j], arr[j+1] = arr[j+1], arr[j]\n index = j\n end\n \n arr[index] = current\n end\n \n arr\nend", "def insertion_sort(list)\n return list if list.size < 2\n\n (1...list.length).each do |i|\n j = i - 1\n e_next = list[i]\n while j >= 0 and list[j] > e_next\n list[j + 1] = list[j]\n j -= 1\n end\n list[j + 1] = e_next\n end\n list\n end", "def insertion_sort!(array)\n array.each_with_index do |el, i|\n j = i\n j -= 1 while j > 0 && el < array[j-1]\n array[i] = array[i-1] and i -= 1 while i > j\n array[j] = el\n end\n\n array\nend", "def insertion_sort(collection)\n sorted_collection = [collection.delete_at(0)]\n\n for val in collection\n sorted_collection_index = 0\n while sorted_collection_index < sorted_collection.length\n if val <= sorted_collection[sorted_collection_index]\n sorted_collection.insert(sorted_collection_index, val)\n break\n elsif sorted_collection_index == sorted_collection.length - 1\n sorted_collection.insert(sorted_collection_index + 1, val)\n break\n end\n\n sorted_collection_index += 1\n end\n end\n\n sorted_collection\n end", "def using_insert(array,element)\n array.insert(4,element)\n end", "def insert_sort(array)\n for i in 1..(array.length - 1)\n j = i\n while j > 0 && array[j] < array[j - 1]\n swap(j, j-1, array)\n j -= 1\n end\n end\n return array\n\nend", "def to_last(val)\n self.delete(val) if self.include?(val)\n self.push(val)\n end", "def insert_final(*val)\n \n val.each do |nuevo_nodo|\n \n if @tail != nil\n @tail.next = nuevo_nodo\n nuevo_nodo.previous = @tail\n @tail = nuevo_nodo\n else\n @head = @tail = nuevo_nodo\n end\n @num_nodos += 1\n end\n end", "def insert_at(index, insertion)\n prev = get_index(index)\n post = get_index(index+1)\n\n #if index of insertion is bigger than list size it will insert at the end\n if prev.nil?\n @tail.next_node = insertion\n @tail = insertion #problem alert\n @tail.next_node = nil\n else\n prev.next_node = insertion\n insertion.next_node = post\n end\n end", "def add_element_to_end_of_array(array, element)\n array << element \nend", "def insertion_sort(list)\n (1...list.length).each do |i|\n k = i\n while k > 0 && list[k] < list[k-1]\n list[k], list[k-1] = list[k-1], list[k]\n k -= 1\n end\n end\n list\nend", "def insert_by_end(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@tail[:next] = @Node.new(value, nil, @tail)\n\t\t\t@tail = @tail[:next]\n\t\tend\n end", "def add_last(data)\n new_node = Node.new(data)\n\n if @head.nil?\n add_first(data)\n return # THIS RETURN IS VERY IMPORTANT\n end\n\n current = @head\n\n until current.next.nil? \n current = current.next\n end\n\n current.next = new_node\n return\n end", "def insert_sort(start_arr=[])\n index = 1\n (start_arr.length-1).times do \n current = start_arr[index]\n sub_arr_index = index - 1 \n while sub_arr_index >= 0 && start_arr[sub_arr_index]>current do\n start_arr[index] == start_arr[sub_arr_index]\n sub_arr_index += 1 \n end\n index +=1\n end\n return start_arr\nend", "def insertion_sort(arr)\n (arr.length - 1).times do |index|\n index += 1\n position = index\n temp_value = arr[index]\n\n while position > 0 && arr[position - 1] > temp_value\n arr[position] = arr[position - 1]\n position -= 1\n end\n arr[position] = temp_value\n end\n arr\nend", "def using_insert(array, i)\n array.insert(4, i)\nend", "def insertBack(object=nil) #we need more of these\n tempNode = Node.new(object)\n tempNode.next = @last\n tempNode.prev = @last.prev\n @last.prev.next = tempNode\n @last.prev = tempNode\n @size += 1\n return @last.prev \n \n end", "def push(item)\n @items.push(item)\n @max.push(item) if [email protected] || item > @max.last\n end", "def add_last_two(array)\n array[-1] + array[-2]\nend", "def insert_next_id!(arr, step = 1, start = 0, max = Float::INFINITY)\n sorted_array = arr.sort\n arr_length = arr.length\n i = 0\n insertable = start\n\n while i < arr_length\n return insert_id!(arr, insertable) if insertable < sorted_array[i]\n\n insertable += step if insertable == sorted_array[i]\n return nil if insertable > max\n\n i += 1 if insertable > sorted_array[i]\n end\n\n insert_id!(arr, insertable)\nend", "def add_element_to_end_of_array(array, element)\n array << element\nend", "def max_heap_insert(key)\n\t\[email protected](-1)\n\t\theap_incease_key(@heap.length-1, key)\n\tend", "def add_last(data)\n if @head.nil? \n @head = Node.new(data)\n else\n pointer = @head \n while !pointer.next.nil?\n pointer = pointer.next\n end\n pointer.next = Node.new(data)\n end\n end", "def insert(item)\n temp = 0\n push_index = 0\n # Yes I can use binary search here alot faster\n @items.each_index do |i| \n if @items[i].key <= item.key && i < @data_size\n next\n end\n temp = @items[i]\n @items[i] = item\n push_index = i+1\n break\n end\n (push_index..ITEMS_IN_PAGE-1).each do |i|\n local_temp = @items[i]\n @items[i] = temp\n temp = local_temp\n end\n @max = item.key if item.key > max\n @min = item.key if item.key < min\n @data_size += 1\n # $logger.logs \"DEBUGGING THE OFF BY ONE BYTE ERROR OMG: #{@id}\"\n end", "def insertion_sort(array) \r\narray.each_with_index do |el,i| \r\n j = i - 1 \r\n while j >= 0 \r\n break if array[j] <= el \r\n array[j + 1] = array[j] \r\n j -= 1 \r\n end \r\n array[j + 1] = el \r\nend \r\nend", "def insertion_sort(array)\t\t\t\t\t\t\t\t\t\t\t\t#This is not my code. I do not understand this code. I tried very hard to understand it but could not.\r\n final = [array[0]]\r\n array.delete_at(0)\r\n # main code\r\n for i in array\r\n final_index = 0\r\n while final_index < final.length\r\n if i <= final[final_index]\r\n final.insert(final_index,i)\r\n break\r\n elsif final_index == final.length-1\r\n final.insert(final_index+1,i)\r\n break\r\n end\r\n final_index+=1\r\n end\r\n end\r\n # output\r\n final\r\nend", "def add_last(data)\n new_node = Node.new(data)\n if !@head\n @head = new_node\n else\n current = @head\n # while current.next\n while current.next != nil\n current = current.next\n end\n current.next = new_node\n end\nend", "def insert(data, index)\r\n\t\t#initial insertion\r\n\t\tfirstarray = @array[0..index]\r\n\t\tsecondarray = @array[[email protected]]\r\n\t\t@array = firstarray + data + secondarray\r\n\t\t\r\n\t\t\r\n\t\t#is there a faster way to do this?\r\n\t\tbuildMaxHeap\r\n\t\t#if data <= @array[parent(index)]\r\n\t\t#\tmaxHeapify(index)\r\n\t\t#else\r\n\t\t#\t#it would be nice to have a function that says \"max heapify the parent if it needs it, else move upwards\" which is recursive\r\n\t\t#end\r\n\t\t\r\n\tend", "def insertion_sort(a)\n for i in 1...(a.length)\n\n while i>0\n if a[i] < a[i-1]\n temp = a[i-1]\n a[i-1] = a[i]\n a[i] = temp\n else\n break\n end\n i = i-1\n end\n end\n return a\nend", "def insert_at(value, index)\n length = size - 1\n if @head.nil?\n set_head(value)\n elsif index > length\n puts \"the list does not have a value associated with your given index.\"\n else\n old_node = at_no_data(index)\n old_next_node = at_no_data(index + 1)\n prev_node = at_no_data(index - 1)\n prev_node.next_node.data = value\n prev_node.next_node = old_node\n end\nend", "def add_last(data)\n @head.nil? ? @head = Node.new(data, @head) : add_last_helper(data, @head)\n end", "def add_last(data)\n current = @head\n \n if current.nil?\n @head = Node.new(data)\n return\n end\n while !current.next.nil?\n current = current.next\n end\n current.next = Node.new(data)\n end", "def insert_at(data, index)\n current = @head\n index.times do\n current = current.next\n end\n save = current.next.clone\n current.next = nil\n append(data)\n current.next.next = save\n end", "def insertionSort(arr) \n unsorted_value = arr.last\n (arr.length - 1).downto(1) do |i|\n if unsorted_value > arr[i - 1] \n arr[i] = unsorted_value\n print_array(arr)\n return\n else\n arr[i] = arr[i - 1]\n print_array(arr)\n end\n end\n arr[0] = unsorted_value\n print_array(arr)\nend" ]
[ "0.7669553", "0.6946828", "0.6946828", "0.69161916", "0.67929345", "0.67547405", "0.6697564", "0.66869307", "0.66809857", "0.66217834", "0.66061", "0.65817434", "0.65147287", "0.65055215", "0.65011406", "0.6495936", "0.6484156", "0.64506924", "0.6449935", "0.64331686", "0.64123315", "0.64022726", "0.6391426", "0.6379735", "0.6379735", "0.6379735", "0.6379735", "0.6379735", "0.6363964", "0.63602614", "0.6352784", "0.63391703", "0.6334413", "0.6330284", "0.63231885", "0.6322723", "0.62740046", "0.6266583", "0.62640446", "0.6253899", "0.62418324", "0.62376696", "0.62302375", "0.62226194", "0.62172776", "0.62142134", "0.6200076", "0.61994714", "0.61979043", "0.61966026", "0.61866415", "0.6180624", "0.616606", "0.6161049", "0.616025", "0.61576414", "0.61382324", "0.61339474", "0.612013", "0.6102591", "0.6089948", "0.60835516", "0.6078202", "0.6066032", "0.6065677", "0.6065677", "0.6065677", "0.605996", "0.6059071", "0.6055819", "0.60530216", "0.6047542", "0.6044122", "0.60421443", "0.6032715", "0.60325915", "0.60317487", "0.60308784", "0.6027198", "0.6017005", "0.60167783", "0.6014582", "0.601188", "0.60101813", "0.60077745", "0.6006698", "0.5995662", "0.5989749", "0.5972736", "0.5969072", "0.59652686", "0.5964781", "0.59644043", "0.5958642", "0.5958028", "0.59574115", "0.59539884", "0.5951699", "0.5950538", "0.59484076", "0.59460855" ]
0.0
-1
Time complexity O(n) to access last element Space complexity O(1)
def get_last return @head if @head.nil? current_node = @head until current_node.next.nil? current_node = current_node.next end return current_node.data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_last_item(arr)\n\treturn arr[-1]\nend", "def last_element(array)\n array[-1]\nend", "def lastElement(arr)\n return arr[arr.length - 1]\nend", "def last_of(arr)\n output = arr[-1]\n return output\nend", "def using_last(array)\n last_element=array.last\nend", "def last_of(arr)\n return arr[-1]\nend", "def last_of(array)\n return array[-1]\nend", "def last\n all[all.size - 1]\n end", "def last(array)\n array[-1]\nend", "def using_last(array)\n array.last\n# returns last item in array \nend", "def last(list)\n list[-1]\nend", "def last_of(arr)\n return arr[arr.length-1]\nend", "def using_last(array)\narray.last\nend", "def retrieve_last_element_from_array(array)\n return array[-1]\nend", "def last_of(arr)\n index = arr.length\n return arr[index -1]\nend", "def lastof(arr)\n return arr[arr.length - 1]\nend", "def retrieve_last_element_from_array(array)\n array[array.length-1]\nend", "def using_last(array)\n array.last\nend", "def using_last(array)\n array.last\nend", "def last_item(elective_array)\n return elective_array[-1]\nend", "def retrieve_last_element_from_array(array)\n array.last\nend", "def last_of(array)\n return array[array.length - 1]\nend", "def last_of(array)\n return array[array.length - 1]\nend", "def get_last\n if length == 0\n return nil?\n elsif length == 1\n return @head.data\n else\n current = @head\n (length - 1).times do\n current = current.next\n end\n return current.data\n end\n end", "def last\r\n self[-1]\r\n end", "def last\n self[-1]\n end", "def lastElement\n return @stk[@count]\n end", "def last(n = 1)\n return self.clone if n >= self.size\n return self[-1] if n == 1\n return self.reverse[0...n].reverse\n end", "def last\n @rarray.reverse.first \n end", "def last(n=nil)\n return self[-1] if n.nil?\n \n start = length-n\n start = 0 if start < 0\n self[start, n]\n end", "def second_last\n return nil if (size-2) < 0\n self[size-2]\n end", "def peek_last\n raise 'No such element' if @size == 0\n @tail.value\n end", "def get_last\r\n return unless @head\r\n \r\n last = @head\r\n last = last.next until last.next.nil?\r\n last.data\r\n end", "def last\n out = nil\n\n each {|i| out = i }\n\n out\n end", "def last\n self[-1]\n end", "def last\n @tail.val\n end", "def last_two(array)\n array.last(2)\nend", "def last(numbers, int)\n numbers.last(int)\nend", "def top()\n # O(1) time\n @arr.last\n end", "def last\n at(-1)\n end", "def get_last\n return nil if !@head\n current = @head\n while current.next\n current = current.next\n end\n return current.data\n end", "def last\n @ordered_elements.last\n end", "def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end", "def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while current.next != nil \n current = current.next\n end\n return current.data\n end", "def get_last\n # return nil unless @head\n if @head == nil\n return nil\n end\n current = @head\n while !current.next.nil?\n current = current.next\n end\n \n return current.data\n end", "def last\n @tail\n end", "def get_last\n return nil unless @head\n current = @head\n\n while current.next\n current = current.next\n end\n\n return current.data\n end", "def tail\n \t@array[-1]\n end", "def last\n return @rear.head unless @rear.empty?\n @front.last # memoize?\n end", "def last\n self.slice(self.size - 1)\n end", "def last(*n) end", "def last\n list = self\n list = list.tail until list.tail.empty?\n list.head\n end", "def last\n list.first\n end", "def last\n @tail.lru_prev\n end", "def get_last\n return if @head == nil\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end", "def last_i\n size - 1\n end", "def last\n return nil if ! @map.last\n if @map.length == 1\n left = 0\n else\n left = @map[@map.length-2][0]+1\n end\n [@map.length-1,@map.last[1],left,@map.last[0]]\n end", "def get_last\n return nil if @head.nil? \n pointer = @head\n\n until pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end", "def last\n to_a.last\n end", "def get_last\n return nil if @head.nil?\n current = @head\n until current.next.nil?\n current = current.next\n end\n return current.data\n end", "def last_index(arr)\n\ti = arr.size - 1\n\twhile i >= 0 && arr[i] == -1\n\t\ti -= 1\n\tend\n\ti\nend", "def get_last\n return nil if @head.nil? \n pointer = @head \n while !pointer.next.nil?\n pointer = pointer.next\n end\n return pointer.data\n end", "def non_mutate(array)\n array.last\nend", "def get_last\r\n return nil if !@head\r\n\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.next \r\n prev = curr\r\n curr = curr.next \r\n else \r\n return curr.data\r\n end\r\n end\r\n\r\n end", "def get_last\n return nil if @head.nil?\n\n current = @head\n\n until current.next.nil?\n current = current.next\n end\n\n return current.data\n end", "def my_but_last(array)\n\tarray.size - 1\nend", "def last\n \tbegin\n \t raise ArgumentError, \"Empty LinkedList\" if @size <= 0\n \t return @last.prev.data\n \t rescue\n \t puts \"Empty\" \t\t \n\t\t end\n \tend", "def last_index\n entries.any? ? entries.size - 1 : nil\n end", "def last\n all.last\n end", "def get_last\r\n return nil unless @head\r\n cursor = @head\r\n while cursor.next\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end", "def last() end", "def last\n items.compact.last\n end", "def last\n self[*Array.new(self.dim, -1)]\n end", "def last\n @enumerable.last\n end", "def last\r\n\t\[email protected]\r\n\tend", "def get_last\n return @tail ? @tail.data : nil\n end", "def last_element(array)\n taylor_swift = [\"Welcome to New York\", \"Blank Space\", \"Style\", \"Out of The Woods\"]\n taylor_swift[-1]\n end", "def remove_last\n raise 'No such element' if @size == 0\n elt = @tail.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @tail = @tail.previous\n @tail.next.previous = nil\n @tail.next = nil\n end\n @size -= 1\n return elt\n end", "def last_item(electives)\n electives[electives.length - 1] #length -1 so it can be used with any number of items, counting starts at 0\nend", "def last\n current_thread = @sorted.last\n return nil unless current_thread\n\n current_thread = current_thread.second.last until current_thread.second.empty?\n current_thread.first\n end", "def find_last \n\t\tcurrent_node = @head\n\t\tuntil current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node\n\tend", "def reach_last_index(hops_array)\n results = []\n\n return true if hops_array.length < 2\n\n hops_array.first.times do |i|\n hops_array.shift\n results << reach_last_index(hops_array)\n end\n\n return results.any? true\nend", "def last; end", "def last; end", "def last; end", "def butlast\n if self.empty?\n []\n else\n self[0..-2]\n end\n end", "def last(n = 1)\n return @history[-n] ;\n end", "def no_mutate(array)\n\tarray.last\nend", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n if @nxt\n @nxt.last\n else\n self\n end\n end", "def last_element_with_array_methods(array)\n array.last\nend", "def last_position_in_list\n return nil unless in_list?\n bottom_position_in_list\n end", "def remove_retrieve_last\n # @array.pop\n @array.slice!(0)\n end", "def puts_index_last(ary = [10, 20, 30, 40, 50, 60, 70, 80, 90])\n new_ary = ary.select { |el| el != ary[0] && el != ary[-1] }\n puts new_ary.index(new_ary[-1])\nend", "def puts_last array\n puts array.last \nend", "def last\n\t\[email protected] if [email protected]?\n\tend", "def last\n @values.last\n end", "def no_mutate(array)\n array.last\nend" ]
[ "0.78702563", "0.78004694", "0.77573615", "0.77408516", "0.77365685", "0.76760715", "0.7659408", "0.76469725", "0.7639697", "0.7616225", "0.7592484", "0.7575984", "0.7517216", "0.7498584", "0.74696684", "0.74521315", "0.7447629", "0.74475944", "0.74475944", "0.7411757", "0.74104154", "0.7389685", "0.7389685", "0.72943276", "0.7283844", "0.7273451", "0.72715163", "0.72117615", "0.7207363", "0.72016245", "0.71955967", "0.7184479", "0.7180477", "0.7169839", "0.71671724", "0.7143392", "0.71277714", "0.71130794", "0.71046746", "0.70854646", "0.70647013", "0.70632774", "0.7062114", "0.70533514", "0.7051833", "0.7046773", "0.70348144", "0.7029973", "0.70286596", "0.70232356", "0.7003508", "0.6999894", "0.69822913", "0.69781053", "0.6974863", "0.6971701", "0.69673806", "0.6961576", "0.6955875", "0.69551164", "0.694828", "0.694403", "0.69371015", "0.6930212", "0.69217867", "0.6903745", "0.68866545", "0.68863493", "0.68828136", "0.688199", "0.68747777", "0.6851288", "0.6832118", "0.6820259", "0.6804958", "0.67823637", "0.6772354", "0.67602086", "0.6755099", "0.6738852", "0.672533", "0.6724165", "0.6722212", "0.6722212", "0.6722212", "0.6717598", "0.6711223", "0.6709881", "0.669518", "0.669518", "0.669518", "0.669518", "0.6690517", "0.6686236", "0.666274", "0.6658988", "0.6651515", "0.6647511", "0.6645854", "0.6640766", "0.6638943" ]
0.0
-1
Time complexity O(n) Space complexity O(1)
def get_at_index(index) current_index = 0 current_node = @head until current_index == index return nil if current_node.nil? current_node = current_node.next current_index += 1 end return current_node.data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend", "def solution(a)\n n = a.size\n passing_cars = 0\n\n suffix_sums = Array.new(n + 1, 0)\n\n a.reverse.each_with_index do |elem, i|\n suffix_sums[i + 1] = suffix_sums[i] + elem\n end\n suffix_sums.reverse!\n\n a.each_with_index do |car, i|\n if car == 0\n passing_cars += suffix_sums[i]\n end\n end\n\n passing_cars > 1_000_000_000 ? -1 : passing_cars\nend", "def amicable_numbers(n)\r\n numbers = Array.new\r\n 2.upto(n) do |x|\r\n y = d(x)\r\n if !numbers.include?(y)\r\n numbers.push(x,y) if d(y) == x && y != x\r\n end\r\n end\r\n return numbers\r\nend", "def solution(a)\n # In production environment this will be my solution:\n # a.uniq.size\n #\n # But since this is a coding challenge, my assumption\n # is that you're looking for a by-hand O(N*logN) solution\n\n return 0 if a.empty?\n\n n = a.size\n ary = a.sort\n uniques = 1\n (1...n).each do |i|\n uniques += 1 if ary[i] != ary[i - 1]\n end\n uniques\nend", "def solution(a)\n n = a.size\n return 0 unless n > 2\n a.sort!\n\n (2..n - 1).each do |i|\n return 1 if a[i - 2] + a[i - 1] > a[i]\n end\n\n return 0\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 f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend", "def stones(n, a, b)\n ar=[0]\n (n-1).times do |val|\n tmp=[]\n ar.each do |v|\n tmp << v+a if !tmp.include?(v+a)\n tmp << v+b if !tmp.include?(v+b)\n end\n ar=tmp\n end\n ar.sort\nend", "def three_sum_fastest(arr)\n count = 0\n\n (0..arr.length - 2).each { |i|\n set = Set.new\n\n (i + 1..arr.length - 1).each { |j|\n if set.include?(-arr[i] - arr[j])\n count += 1\n end\n\n set.add(arr[j])\n }\n }\n count\nend", "def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend", "def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend", "def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend", "def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "def sorted_squares(nums)\n # This takes O(n)\n nums.map! { |num| num**2 }\n # This can take Ο(n logn)\n bubble_sort(nums)\nend", "def solution(a)\n # write your code in Ruby 2.2\n n = a.length\n \n counter = Array.new(n+1, 0)\n \n a.each do |x|\n counter[x-1] += 1\n end\n \n return counter.index { |x| x == 0 } + 1\nend", "def find_amicables(n)\n pairs = []\n sum = 0\n for i in 0..n do \n next if pairs.include? i\n d = sum_proper_divisors(i)\n next if d == i\n p = sum_proper_divisors(d)\n if p == i \n pairs << d\n pairs << i\n sum += d + i\n end\n end\n return sum\nend", "def find_duplicate_space(nums)\n # sort nums first (lgn), then check for dups by iterate over (n)\n last_seen = 0\n nums.sort!.each do |num|\n return num if last_seen == num\n last_seen = num\n end\nend", "def sub_sum(list)\n sub_arr = []\n (0...list.length).each do |i| #O(n)\n (i...list.length).each do |j| #O(n)\n sub_arr << list[i..j] if i <= j\n end\n end\n largest_continuous_sub_sum1(sub_arr)\nend", "def two_sum(arr) #o(ns)\n set = Set.new\n arr.each{|el| set << el}\n arr.select{|el| set.include?(-1 * el)}\nend", "def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min # O(1) \r\nend", "def find_duplicate(nums)\n if !nums or nums.size == 0\n return nil\n else\n fast = nums[ 0 ]\n slow = nums[ 0 ]\n while true\n fast = nums[ fast ]\n fast = nums[ fast ]\n slow = nums[ slow ]\n if fast == slow\n new_node = nums[ 0 ]\n while new_node != slow\n new_node = nums[ new_node ]\n slow = nums[ slow ]\n end\n return slow\n end\n end\n end\nend", "def solution(a)\n a.uniq.count\nend", "def solution(a)\n n = a.size\n a.sort!\n\n count = 0\n for i in 0...n-2 do\n k = i+2\n for j in i+1...n-1 do\n while k < n and a[i] + a[j] > a[k] do\n k += 1\n end\n count += k - j - 1\n end\n end\n count\nend", "def solution(a)\n a.sort!\n a.each_with_index do |element, index|\n return 0 if element != index + 1\n end\n 1\nend", "def my_min(list) \n\n list.each_with_index do |ele, i| #O(n)\n compare_arr = list[0...i] + list[i+1..-1] # O(2n) \n return ele if compare_arr.all? { |ele2| ele < ele2 } #O(n)\n end\n\n #time complexity = O(n^2) + O(2n)\n\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\nend", "def removNb(n)\n results = []\n (2..n).each do |a|\n b = (n*(n+1)/2.0-a)/(a + 1)\n results << [a, b.to_i] if b % 1 == 0 && b < n && b > 2\n end\n results\nend", "def largest_subsum(list)\n max = list[0] # O(1)\n current_sum = list[0] # O(1)\n\n (1...list.length).each do |i| # O(n)\n # debugger\n if current_sum < 0 # O(1)\n current_sum = 0 # O(1)\n end \n current_sum += list[i] # O(1)\n if current_sum > max # O(1)\n max = current_sum # O(1)\n end\n end\n\n max # O(1)\n\nend", "def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend", "def solution(a)\n return 1 if a.empty?\n a.sort!\n return 1 if a.first > 1\n return a.first + 1 if a.length <2\n (0..(a.length)).each do |index|\n return a[index] + 1 if a[index] + 1 != a[index + 1]\n end\n return a.last + 1\nend", "def my_min_2(array)#O(n)\n array.inject do |acc, ele|#O(n)\n if acc < ele\n acc\n else\n ele\n end\n end\nend", "def solution(a)\n # write your code in Ruby 2.2\n seen = {}\n\n a.each do |number|\n seen[number] = true\n end\n\n max = a.max\n\n for i in 1..(max + 1)\n return i unless seen[i]\n end\n\n 1\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n xor= 0\n x,y=0,0 #variables to store duplicates\n \n #xor of all numbers from 1 to n\n for i in 1..n \n xor^=i\n end\n #xor of all array elements\n for i in 0...len \n xor^=a[i]\n end\n #Rightmost set bit\n set_bit_pos= xor & ~(xor-1)\n #Divinding array in two sets ,one with set bit at set_bit_pos and other with 0.\n for i in 0...len\n if (a[i] & set_bit_pos == 0)\n x^=a[i] # XOR of first-set(with 0 at set_bit_pos) in array\n else\n y^=a[i] # XOR of second-set(with 1 at set_bit_pos) in array\n end\n end\n \n for i in 0..n\n if (i & set_bit_pos == 0)\n x^=i # XOR of first-set(with 0 at set_bit_pos) in range\n else\n y^=i # XOR of second-set(with 1 at set_bit_pos) in range\n end\n end\n print \"#{x} #{y}\"\n\treturn\nend", "def find_missing(array, n)\n i = 0\n\n (1..n).each { |number| i = i ^ number }\n array.each { |number| i = i ^ number }\n\n i\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def removNb(n)\n res = []\n total = (n*n + n) / 2\n range = (1..n)\n \n (1..n).each do |a|\n b = ((total - a) / (a * 1.0 + 1.0))\n if b == b.to_i && b <= n\n res.push([a,b.to_i])\n end\n end\n\n return res\nend", "def solution(n, a)\n counters = Array.new(n, 0)\n max = 0\n a.each do |item|\n if item >= 1 && item <= n\n counters[item - 1] += 1\n max = counters[item - 1] if counters[item - 1] > max\n elsif item == n + 1\n counters = Array.new(n, max)\n end\n end\n\n counters\nend", "def solution(a)\n len = a.size\n unique = {}\n i = 0\n while i < len\n item = a[i]\n if unique.has_key?(item)\n unique[item] += 1\n else\n unique[item] = 1\n end\n i += 1\n end\n pairs = 0\n unique.each do |key,count|\n (1...count).step {|n| pairs += n }\n end\n return pairs > 1_000_000_000 ? 1_000_000_000 : pairs\nend", "def solution(n, a)\n # write your code in Ruby 2.2\n arr = [0] * n\n max_c = 0\n \n a.each_with_index do |value,index|\n if value == n + 1\n arr = [max_c] * n\n else\n arr[value - 1] = arr[value - 1] + 1\n max_c = (arr[value -1] > max_c ? arr[value -1] : max_c)\n end\n end\n arr\nend", "def solution(x, a)\n perm = (1..x).to_a\n return -1 unless (perm - a).empty?\n a.index(a.uniq.last)\nend", "def solution(a)\n # write your code in Ruby 2.2\n num_of_elements=a.length\n num_of_zeros=0\n tot_num_car_pairs=0\n a.each do |element|\n if element == 0\n num_of_zeros+=1\n else\n tot_num_car_pairs+=num_of_zeros\n end\n end\n return tot_num_car_pairs>1_000_000_000?-1:tot_num_car_pairs\nend", "def solution(x, a)\r\n # write your code in Ruby 2.2\r\n arr=[];\r\n i=0;\r\n l=a.count\r\n \r\n while(arr.count<=x)\r\n \r\n if(arr[i].nil?)\r\n arr << i\r\n end\r\n \r\n i+=1\r\n end\r\n i\r\nend", "def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend", "def equal(arr)\n size = arr.size\n hash = Hash.new{|h,k| h[k] = []}\n (0...size).each do |i|\n (i + 1...size - 1).each do |j|\n sum = arr[i] + arr[j]\n if hash.has_key?(sum)\n values = hash[sum]\n values << i\n values << j\n return values\n else\n hash[sum] = [i, j]\n end\n end\n end\nend", "def dp_possible_trees(n)\n array = Array.new(n+2) { Array.new(n+1) { 0 } }\n (0...n+2).to_a.each do |i|\n array[i][0] = 1\n end\n\n sum = 0\n (1...n+1).to_a.each do |i|\n sum = 0\n (1..i).to_a.each do |j|\n array[j][i] = array[n+1][i-j] * array[n+1][j-1]\n sum += array[j][i]\n end\n array[n+1][i] = sum\n end\n array[n+1].last\nend", "def solution(a)\n return nil unless a || a.empty?\n num_hash = {}\n a.each do |num|\n num_hash[num] = 1\n end\n\n 1.upto(a.size + 1) do |item|\n return item if !num_hash.has_key? item \n end\n\nend", "def find3(a, X)\n # scan through array\n # build hash storing complement in each key\n complements = {}\n a.each_with_index do |val, ind|\n if complements[X - val]\n complements[X - val].push(ind)\n else\n complements[X - val] = [ind]\n end\n end\n\n # scan through the array again\n # get complement\n # for each value scan the remainder of the arrray\n # for a value such taht a + b = the complement\n\n # for each character we have built a dictionary such that, we can find\n # x = a + complement\n\n # [1, 2, 3]\n # 1 + 2 = 3\n # 1 + 3 = 4 =>\n\n # for each value in the array (a) look at all following values (b) and see if a + b\n # is in the dictionary, if it is, check that their indices do not collide with the index\n # stored at dict(a+b)\n\n a.each_with_index do |va, i|\n a.each_with_index do |vb, j|\n break if i == j\n\n complement = va + vb\n indices = complements[complement]\n\n indices.each do |z|\n # every index is unique\n return [i, j, z] unless z == i || z == j\n end\n end\n end\n\n return nil\nend", "def solution(a)\n # write your code in Ruby 2.2\n \n is_perm = 0\n \n n = a.length\n b = [0]*n\n \n \n a.each do |v|\n break if v > n \n break if b[v] == 1 \n b[v] = 1\n end\n \n sum = b.inject(:+)\n if sum == n\n is_perm = 1\n end\n \n is_perm\nend", "def compute(n)\n a = []\n a.push(1)\n a.push(1)\n n -=1\n first = 1\n second = 1\n n.times do\n third = first + second\n first = second\n second = third\n a.push(third)\n end\n #first\n a\nend", "def solution(a)\n # we could do radix sort and then loop over all the items in order to find the missing element\n # in the ordered list or use the Gauss theorem: https://study.com/academy/lesson/finding-the-sum-of-consecutive-numbers.html\n #\n # if we use the Gauss theorem we can do:\n # sum = (1 + N+1) * ( N / 2 )\n #\n # if (1 + N+1) % 2 == 1 we need to sum also (n+1+1)/2 + 1\n #\n # then remove every item from the sum: the remainder is the missing number\n len = a.length\n sum = (1 + len + 1) * ((len + 1) / 2)\n sum += ((len + 1) / 2.0).ceil unless (len + 1) % 2 == 0\n\n a.reduce(sum) do |sum, i|\n sum - i\n end\nend", "def answer(n, a)\n count = 0\n n.times do |nn|\n next if a[nn] != nn + 1\n a[nn], a[nn + 1] = a[nn + 1], a[nn]\n count += 1\n end\n count\nend", "def naive_algorithm(arr)\n\tproduct = 0\n\tarr.each do |i|\n\t arr.each do |j|\n\t \tp = arr[i] * arr[j]\n\t \tproduct = p if product < p\n\t end\t\n\tend\t\t\n\tproduct\nend", "def find_unique_elements(arr)\n \nend", "def naive(array)\n max = -10000\n for i in (0..array.length - 1)\n for j in (i..array.length - 1)\n total = array[i..j].inject { |m,k| m + k }\n max = total if total > max\n end\n end\n max\nend", "def solution(a)\n accessed = Array.new(a.size + 1, nil)\n caterpillar_back = 0\n count = 0\n\n a.each_with_index do |x, caterpillar_front|\n if accessed[x] == nil\n accessed[x] = caterpillar_front\n else\n new_caterpillar_back = accessed[x] + 1\n first_part_size = caterpillar_front - caterpillar_back\n second_part_size = caterpillar_front - new_caterpillar_back\n count += first_part_size * (first_part_size + 1) / 2\n count -= (second_part_size) * (second_part_size + 1) / 2\n caterpillar_back.upto(new_caterpillar_back - 1) { |n| accessed[a[n]] = nil}\n accessed[x] = caterpillar_front\n caterpillar_back = new_caterpillar_back\n end\n end\n\n remaining_size = a.size - caterpillar_back\n count += (remaining_size) * (remaining_size + 1) / 2\n end", "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def josephus_survivor(n,k)\n arr = (1..n).to_a\n\n while arr.length > 1\n idx = k % arr.length\n\n if arr.length > k\n arr = arr.drop(k) + arr.take(k - 1)\n elsif arr.length == k \n arr = arr[0...-1]\n else\n arr = arr.drop(idx) + arr.take(idx - 1)\n end\n end\n \n arr[0]\nend", "def solution(a, k)\n # write your code in Ruby 2.2\n \n unless a.empty?\n for i in 1..k\n last = a.pop\n a.insert(0, last)\n end\n end\n \n return a\nend", "def unique_items(arr) #O(n)\n hash = Hash.new(0)\n results = []\n arr.each do |el|\n hash[el] += 1\n end\n hash.select { |k, v| k if v == 1 }.keys\nend", "def better_sum1(arr, target) # this one is going to return true or false\n pairs = Set.new\n\n arr.each do |ele|\n if pairs.include?(ele)\n return true\n else\n pairs << target - ele\n end\n end\n false\nend", "def three_sum(nums)\n n = nums.length\n result = []\n for i in 0...n-2\n req_sum = 0\n hsh = Hash.new\n curr_sum = req_sum - nums[i]\n \n for j in (i+1)...n\n num = curr_sum - nums[j]\n if hsh[num]\n elements = [nums[i], num, nums[j]].sort\n result << elements unless result.include?(elements)\n end\n hsh[nums[j]] = true\n end \n end\n result\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def my_min_2(arr)\n\n smallest_value = arr[0] # O(1)\n\n arr.each do |ele1| # [ 0, 3, 5, 4, -5, 10, 1, 90 ] O(n)\n smallest_value = ele1 if ele1 <= smallest_value #O(1)\n end\n\n smallest_value #O(1)\n\nend", "def removNb(n)\n numbers = (1..n).to_a\n all_combinations = numbers.combination(2).to_a\n possible_pairs = []\n sum = numbers.reduce(:+)\n all_combinations.each do |pair|\n if (sum - pair.reduce(:+)) == pair.reduce(:*)\n possible_pairs << pair\n possible_pairs << pair.reverse\n end\n end\n possible_pairs\nend", "def find_unique_elements(arr)\n arr_fin=[]\n arr.each do |x|\n arr.count(x)\n if arr.count(x)==1\n arr_fin << x\n end\n end\n return arr_fin\nend", "def seesaw?(arr)\n left_sum = 0\n arr.each_index do |i| #O(n)\n if i > 0\n left_sum = arr[0...i].reduce(:+) #O(n)\n end\n if i < arr.size-1\n right_sum = arr[i+1..-1].reduce(:+); #O(n)\n else\n right_sum = 0\n end\n if left_sum == right_sum\n return true\n end\n end\n return false\nend", "def solution(a)\n length = a.length\n sum = (length + 1) * (length + 1 + 1) / 2\n\n sum - a.inject(0) { |acc, e| acc += e }\nend", "def running_time(array)\n cnt = 0\n (1...(array.length)).each do |x|\n y = x\n while y.positive?\n break unless array[y - 1] > array[y]\n\n temp_num = array[y]\n array[y] = array[y - 1]\n array[y - 1] = temp_num\n cnt += 1\n y -= 1\n end\n end\n cnt\nend", "def solution(n, a)\n max = 0\n counters = Array.new(n, max)\n a.each do |counter|\n if counter == n + 1\n counters.fill(max)\n else\n counters[counter - 1] += 1\n max = counters[counter - 1] if counters[counter - 1] > max\n end\n end\n counters\nend", "def solution(a)\r\n a.each do |num|\r\n if (a.count(num) % 2) != 0\r\n return num\r\n end\r\n end\r\nend", "def cout(n)\n\tw=[0,1,2,3,4,5,6,7,8,9]\n\tx=[]\n\tk=1\n\twhile x!=w do \n\t\tm=n*k\n\t\t\twhile m>0 do\n\t\t\t\tt=m%10\n\t\t\t\tx=x.push(t)\n\t\t\t\tx.sort!\n\t\t\t\tx.uniq!\n\t\t\t\tm=m/10\t\n\t\t\tend\n\t\tk=k+1\n\tend\nreturn (k-1)*n\nend", "def collisions(arr)\n new_arr = []\n result = []\n arr.each do |i|\n if i > 0\n new_arr << i\n else\n if new_arr.empty?\n result << i\n else\n if new_arr[-1] == -(i)\n new_arr.pop\n else\n while !new_arr.empty? && new_arr[-1] < -(i)\n new_arr.pop\n end\n if new_arr.empty?\n result << i\n end\n end\n end\n end\n end\n return (result.concat(new_arr))\nend", "def find_it(seq)\n uniqueInts=seq.uniq\n\n uniqueInts.each do |value|\n k=0\n seq.each do |mainSeq|\n k+=1 if mainSeq==value\n end\n return value if k%2==1\n end\nend", "def solution(a)\n stack = []\n\n a.each_with_index do |n, i|\n if stack.empty?\n stack << [i, n]\n next\n end\n\n last_value = stack.last[1]\n\n if n == last_value\n stack << [i, n]\n else\n stack.pop\n end\n end\n\n return -1 if stack.empty?\n\n i, cd = stack.last\n\n count = a.inject(0) do |acc, n|\n cd == n ? acc + 1 : acc\n end\n\n count > a.length / 2 ? i : -1\nend", "def find_unsorted_subarray(nums)\n \nend", "def solution(a)\n # write your code in Ruby 2.2\n sum = a.inject(:+)\n acc = 0\n\n min = 99999999\n a[0..-2].each do |n|\n sum -= n\n acc += n\n\n min = [(acc - sum).abs, min].min\n end\n min\nend", "def solution(a)\n left = 0\n right = a.sum\n a.each_with_index do |element, index|\n right -= element\n return index if left == right\n left += element\n end\n -1\nend", "def solution(a)\n s= a.sort\n 0.step(s.size - 1).inject(0) do |result, x|\n z= x+2\n (x+1).step(s.size - 1).inject(result) do |acc, y|\n z+=1 while z < s.size && s[x] + s[y] > s[z]\n acc += z-y-1\n end\n end\nend", "def largest_contiguous_subsum_2(list)# [2, 3, -6, 7, -6, 7]\n largest_num = list[0]#2 O(1)\n running_sum = list[0]#2 - 5 after entering loop. O(1)\n\n (1...list.length).each do |i| #O(n) \n running_sum = 0 if running_sum < 0 #O(1)\n running_sum += list[i] #O(1)\n largest_num = running_sum if running_sum > largest_num #O(1)\n end\n return largest_num #O(1)\nend", "def solution(a)\n # write your code in Ruby 2.2\n numbers = Array(1..(a.size + 1))\n res = numbers - a\n res[0]\nend", "def linear_search(n)\n\t(1..100).to_a.shuffle.each do |x|\n\t\tif x == n\n\t\t\tbreak\n\t\tend\n\tend\nend", "def find_unique_elements(arr)\n arr_unique = []\n arr.each do |elem1|\n var1 = 0\n arr.each do |elem2|\n if elem1 == elem2\n var1 = var1 + 1\n end\n end\n if var1 <= 1\n arr_unique.push(elem1)\n end\n end\nend", "def pick(n,history)\n i = -1\n j = 0\n while j < (n + 1)\n i += 1\n j += 1 if history[i] == nil\n \n end\n \n return i\nend", "def find_duplicates(a)\n len=a.length\n n=len-2\n sum_of_series= (n*(n+1))/2 #Sum of series 1 to n\n \n #Find sum and product of array elements\n sum=0\n product=1\n \n for x in a\n sum+=x\n product*=x\n end\n \n sum-=sum_of_series #sum is a+b now,where a and b are repeating numbers\n product/=fact(n) #product is a*b now,where a and b are repeating numbers\n \n temp= Math.sqrt((sum**2)-(4*product)).to_i # temp is a-b\n \n\tprint \"#{(sum+d)/2} #{(sum-d)/2}\"\nend", "def sum_to_n? arr, n\n if arr.length > 1\n for i in arr do\n ndx = arr.find_index(i)\n x = arr.delete_at(ndx)\n if arr.include?(n - x)\n return true\n end\n arr.insert(ndx, x)\n end\n end\n return false\nend", "def hash_two_sum(arr,target_sum)\n #creates a new hash with each element that is satisfying the target_sum\n hash = Hash.new(0) #{|h,k| h[k] = []}\n (0...arr.length).each { |i| hash[i] = arr[i]} #O(n)\nend", "def brute_force_two_sum(array, target)\n indexes = []\n array.each.with_index do |n1, index1|\n array.each.with_index do |n2, index2|\n indexes.push(index1) if target - n1 == n2 && index1 != index2\n end\n end\n indexes\nend", "def sum_upon_sums(array)\n # Step 0: initialize variables => O(1)\n max = -1\n sum = 0\n\n # Step 1: Get Max and Sum => O(n)\n array.each do |num|\n max = num if num >= max\n sum += num\n end\n\n # Step 2: Get summation => O(1)\n summation = max * (max + 1) / 2\n\n # Step 3: Return Missing value by subtracting summation and sum => O(1)\n summation - sum\nend", "def efficient_contiguous_subsum(list)\n current_sum = list[0] #0\n largest_sum = list[0] #5\n # debugger\n (1...list.length).each do |i| \n if current_sum + list[i] > 0 \n current_sum += list[i] \n largest_sum = current_sum if current_sum > largest_sum\n else \n current_sum = 0\n end \n end \n largest_sum\nend", "def two_sum?(arr, target)\r\n hash = {}\r\n arr.each_with_index do |ele, i| #n\r\n hash[i] = ele\r\n end\r\n arr.each_with_index do |ele, i| #n \r\n value = target - ele\r\n if hash.has_value?(value) && hash.key(value) != i\r\n return true\r\n end\r\n # all the keys in has except i\r\n # if any of the value = value\r\n end\r\n false\r\nend", "def solution(array)\n result = Array.new(array.length, 0)\n\n array.each do |element|\n if result[element - 1]\n result[element - 1] += 1\n else\n result[element - 1] = 1\n end\n end\n\n result.uniq.size == 1 ? 1 : 0\nend", "def my_solution(array)\n hash = {}\n\n array.each do |element|\n hash[element] = 0 if element > 0\n end\n\n (1..array.size).each do |i|\n return i if hash[i].nil?\n end\nend", "def move_zeros(array)\n zero_count = 0\n # O(n)\n array.each do |num|\n\n zero_count += 1 if num == 0\n end\n\n # O(n)\n array = array.select { |num| num != 0 }\n \n # O(1)\n zero_count.times do\n array += [0]\n end\n\n array\nend", "def three_sum(nums)\n return [] if !nums || nums.size < 3\n ans = []\n i = 0 \n size = nums.size\n nums = nums.sort\n while i < size do \n if nums[i] == nums[i - 1] && i > 0 \n i += 1\n next\n end\n\n a = nums[i]\n target = -1 * a\n two_sum(nums[(i + 1)...size], target, a, ans)\n i += 1\n end\n ans\nend", "def solution(x, a)\n count = 1\n indices = []\n while count <= x\n indices << a.find_index(count)\n count += 1\n end\n\n if indices.include?(nil)\n -1\n else\n indices.sort.last\n end\nend", "def my_min1(arr)\n arr.each do |el1| #O(n)\n if arr.all? {|el2| el1 <= el2 } #O(n + 1)\n return el1\n end\n end \nend", "def equil_idcs(a)\n left = 0\n sum = a.inject(:+)\n equils = []\n a.each_with_index do |num, idx|\n sum -= num\n equils << idx if left == sum\n left += num\n end\n equils.empty? ? -1 : equils\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend" ]
[ "0.68383443", "0.67022353", "0.6287102", "0.6151411", "0.61351335", "0.6119561", "0.6107089", "0.61056364", "0.6081318", "0.6057649", "0.604912", "0.60464", "0.6015387", "0.6008364", "0.6006688", "0.59890276", "0.59838516", "0.5971524", "0.59703755", "0.59473056", "0.5940865", "0.5940547", "0.59304106", "0.59240556", "0.59209085", "0.59096676", "0.5904805", "0.59041095", "0.5902029", "0.5891315", "0.5883956", "0.58724445", "0.58599836", "0.58591026", "0.5854038", "0.58478373", "0.58403933", "0.5814519", "0.5809539", "0.5803821", "0.58027786", "0.5799828", "0.5793987", "0.5790618", "0.5789521", "0.57864356", "0.5778358", "0.5766807", "0.5765809", "0.57655925", "0.57516754", "0.574365", "0.57436395", "0.5742032", "0.5738269", "0.5733741", "0.5729536", "0.5724338", "0.5709409", "0.57070076", "0.5706177", "0.5703419", "0.57024044", "0.5695816", "0.56951785", "0.56941324", "0.56880146", "0.5678984", "0.5667207", "0.5665995", "0.566548", "0.5663537", "0.5662525", "0.56593966", "0.56560487", "0.56530756", "0.5652789", "0.56525064", "0.565216", "0.56519365", "0.56465304", "0.5641262", "0.56403685", "0.5640078", "0.5639818", "0.5639664", "0.5638855", "0.56349677", "0.5633391", "0.56329644", "0.56243587", "0.56184113", "0.56179124", "0.56166357", "0.5614987", "0.56149447", "0.56137574", "0.5613339", "0.5610448", "0.56096804", "0.5603083" ]
0.0
-1
GET /observations GET /observations.json
def index @cruise = Cruise.find(params[:cruise_id]) @observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability) respond_to do |format| format.csv { send_data build_csv, filename: "observations-#{@cruise.id}.csv"} format.json { send_data build_json, filename: "observations-#{@cruise.id}.json"} format.geojson { send_data build_geojson, filename: "observations-#{@cruise.id}.geojson"} format.sigrid3 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_observations # :nologin:\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def index\n @observations = Observation.all()\n end", "def extract_observations(url)\n\n JSON.load(open(url))\n\n end", "def index\n @observations = scope.all\n end", "def index\n @ice_observations = IceObservation.all\n end", "def latest_observations\n path = 'stations/%s/observations/latest' % [@id]\n get(path)['properties']\n end", "def show\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @competition_interaction_observations = CompetitionInteractionObservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @competition_interaction_observations }\n end\n end", "def index\n @observation_types = ObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @observation_types }\n end\n end", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def show\n pass_query_params\n @observation = find_or_goto_index(Observation, params[:id].to_s)\n return unless @observation\n\n @observations = [\n MinimalMapObservation.new(@observation.id,\n @observation.public_lat,\n @observation.public_long,\n @observation.location)\n ]\n end", "def index\n if !logged_in? && params[:page].to_i > 100\n authenticate_user!\n return false\n end\n params = request.params\n showing_partial = (params[:partial] && PARTIALS.include?(params[:partial]))\n # Humans should see this, but scrapers like social media sites and curls\n # will set Accept: */*\n human_or_scraper = request.format.html? || request.format == \"*/*\"\n # the new default /observations doesn't need any observations\n # looked up now as it will use Angular/Node. This is for legacy\n # API methods, and HTML/views and partials\n if human_or_scraper && !showing_partial\n @shareable_description = begin\n generate_shareable_description\n rescue StandardError => e\n Logstasher.write_exception( e, request: request, session: session, user: current_user )\n \"\"\n end\n else\n h = observations_index_search(params)\n params = h[:params]\n search_params = h[:search_params]\n @observations = h[:observations]\n end\n respond_to do |format|\n\n format.html do\n if showing_partial\n pagination_headers_for(@observations)\n return render_observations_partial(params[:partial])\n end\n # one of the few things we do in Rails. Look up the taxon_name param\n unless params[:taxon_name].blank?\n sn = params[:taxon_name].to_s.strip.gsub(/[\\s_]+/, ' ').downcase\n t = Taxon.active.where( name: sn ).first\n t ||= Taxon.where( name: sn ).first\n t ||= TaxonName.joins(:taxon).where(\"taxa.is_active AND lower(taxon_names.name) = ?\", sn).first.try(:taxon)\n t ||= TaxonName.where(\"lower(taxon_names.name) = ?\", sn).first.try(:taxon)\n if t\n t = t.current_synonymous_taxon unless t.is_active?\n params[:taxon_id] = t.id\n end\n end\n @asynchronous_google_maps_loading = true\n render layout: \"bootstrap\", locals: { params: params }\n end\n\n format.json do\n Observation.preload_for_component(@observations, logged_in: logged_in?)\n Observation.preload_associations(@observations, :tags)\n render_observations_to_json\n end\n \n format.geojson do\n render :json => @observations.to_geojson(:except => [\n :geom, :latitude, :longitude, :map_scale, \n :num_identification_agreements, :num_identification_disagreements, \n :delta, :location_is_exact])\n end\n \n format.atom do\n @updated_at = Observation.last.updated_at\n end\n \n format.dwc do\n Observation.preload_for_component(@observations, logged_in: logged_in?)\n Observation.preload_associations(@observations, [ :identifications ])\n end\n\n format.csv do\n render_observations_to_csv\n end\n \n format.kml do\n render_observations_to_kml(\n :snippet => \"#{@site.name} Feed for Everyone\",\n :description => \"#{@site.name} Feed for Everyone\",\n :name => \"#{@site.name} Feed for Everyone\"\n )\n end\n \n format.widget do\n if params[:markup_only] == 'true'\n render js: render_to_string(\n partial: \"widget\",\n handlers: [:erb],\n formats: [:html],\n locals: {\n show_user: true,\n target: params[:target],\n default_image: params[:default_image],\n silence: params[:silence]\n }\n )\n else\n render js: render_to_string(\n partial: \"widget\",\n handlers: [:erb],\n formats: [:js],\n locals: {\n show_user: true\n }\n )\n end\n end\n end\n rescue Elasticsearch::Transport::Transport::Errors::InternalServerError => e\n raise e unless e.message =~ /window is too large/\n msg = \"Too many results. Try using smaller searches or the id_above parameter.\"\n response.headers[\"X-Error\"] = msg\n respond_to do |format|\n format.html do\n flash[:error] = msg\n redirect_to( observations_path )\n end\n format.json { render json: { error: msg } }\n format.all { @observations = [] }\n end\n end", "def index\n @observations = Observation.where(service_of_dependence: current_user.dependence.service_of_dependences)\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def index\n sanitized_params = parse_params(simulation_where_params)\n simulations = Simulation.find_all(sanitized_params)\n\n render json: simulations\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def index\n @notebooks = Notebook.all\n render json: @notebooks\n end", "def index\n show and return if params[:id].present?\n\n @query = find_or_create_query(:Observation)\n apply_content_filters(@query)\n @query = restrict_query_to_box(@query)\n\n find_locations_matching_observations\n end", "def observations(stations, lang = 'is', time = '1h', anytime = '0')\n Apis.client.get(\"/weather/forecasts/#{lang}\" \\\n \"/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}\")\n end", "def index\n @studies = Study.all\n #render json: @studies\n end", "def index\n render json: WeatherDatum.all\n end", "def index\n render :json => UserInterest.all\n end", "def index\n @socioeconomic_studies = SocioeconomicStudy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socioeconomic_studies }\n end\n end", "def index\n @citations = Citation.all\n\n render json: @citations\n end", "def index\n puts \"Index method called...\"\n @studies = Study.all\n\n # render json: @studies\n end", "def index\n obstype = ObservationType.find(params[:obstype]) if params[:obstype].present?\n\n query = params[:query]\n if obstype\n @observations = obstype.observations\n @obstype = obstype\n elsif query\n @observations = Observation.ordered_by_date.basic_search(comment: query)\n @query = query\n else\n @observations = Observation.all\n end\n\n year = params[:year]\n if year.present?\n @observations = @observations.by_year(year.to_i)\n @year = year\n end\n\n areas = params[:areas_as_text] # TODO: what happens when you add multiple areas\n if areas.present?\n @observations = @observations.by_area(areas)\n myareas = Area.find(areas)\n @areas_as_text = [myareas].map(&:attributes).to_json\n end\n\n @observations = @observations.by_page(params[:page])\n\n respond_with @observations do |format|\n format.salus_xml { render 'index', formats: %i[salus_xml] }\n format.salus_csv { render 'index', formats: %i[salus_csv] }\n end\n end", "def index\n @disponibles = Disponible.take(50)\n\n render json: @disponibles, include: '**'\n end", "def index_observation # :nologin: :norobots:\n query = find_or_create_query(:Observation, by: params[:by])\n show_selected_observations(query, id: params[:id].to_s, always_index: true)\n end", "def index_observation\n query = find_or_create_query(:Observation, by: params[:by])\n show_selected_observations(\n query, id: params[:id].to_s, always_index: true\n )\n end", "def index\n @am_run_observation_types = AmRunObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @am_run_observation_types }\n end\n end", "def index\n @notes = Note.where(:year_at => Date.current.year).order(:created_at)\n @incomings = Incoming.where(:year_at => Date.current.year).order(:created_at)\n @user = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notes }\n end\n end", "def index\n @patient_samples = PatientSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patient_samples }\n end\n end", "def observations_by_name # :nologin: :norobots:\n query = create_query(:Observation, :all, by: :name)\n show_selected_observations(query)\n end", "def index\n @fiction = Fiction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fiction }\n end\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index\n @studies = Study.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @studies }\n end\n end", "def index\n @experiments = Experiment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiments }\n end\n end", "def index\n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end", "def index\n @pain_observations = PainObservation.all\n end", "def index\n @gets = Get.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gets }\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index\n @observation = Observation.find(params[:observation_id])\n @observers = Observer.find_all_by_observation_id(params[:observation_id])\n \n respond_to do |format|\n format.html { render :layout=>\"tabs\"}\n format.json { render json: @observers }\n end\n end", "def index\n @neighborhoods = Neighborhood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neighborhoods }\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def index\n @notes = Note.all\n render json: @notes\n end", "def index_json\n @ni = Note.all\n p = params()\n if (p.has_key?(\"lat\") && p.has_key?(\"lon\"))\n @ni = notes_in_range(p['lat'].to_f, p['lon'].to_f)\n end\n @notes = @ni\n\n render :json => @notes.to_json( )\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end", "def index\n @data = Datum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data }\n end\n end", "def observation_index # :nologin: :norobots:\n query = create_query(:Name, :with_observations)\n show_selected_names(query)\n end", "def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def index\n @stations = Station.all\n\n render json: @stations\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @observances = Observance.all\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @interests }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @witnesses = Witness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @witnesses }\n end\n end", "def index\n @illnesses = Illness.all\n\n render json: @illnesses\n end", "def index\n @specialties = Specialty.all\n\n render json: @specialties\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 @observation_details = ObservationDetail.where(observation:@observation)\n end", "def index\n @title = \"Studies\"\n\n respond_to do |format|\n format.html do\n @my_studies = Study.with_user(current_user.netid)\n end\n format.json do\n render :json => Study.with_user(current_user.netid).to_json\n end\n end\n end", "def observations_by_name\n query = create_query(:Observation, :all, by: :name)\n show_selected_observations(query)\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end", "def index\n @stations = Station.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stations }\n end\n end", "def index\n @medications = Medication.all\n render json: @medications\n end", "def index\n @students = Student.all\n render json: @students\n end", "def index\n @illustrations = Illustration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @illustrations }\n end\n end", "def current_observations(lat, lon, options = {})\n station = options.fetch(:station) { nearest_weather_station(lat, lon, options) }\n Services::CurrentObservations.new(options).fetch(station)\n end", "def index\n @weather_events = WeatherEvent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weather_events }\n end\n end", "def observations_of_name\n query = create_query(:Observation, :all,\n names: [params[:name]],\n include_synonyms: true,\n by: :confidence)\n show_selected_observations(query)\n end", "def index\n\t\t@recipes = Recipe.where(user_id: session[:user_id])\n\t\tif @recipes\n\t\t\trender json: @recipes.to_json(:include => [:inventories])\n\t\telse\n\t\t\tflash[:error] = \"You haven't saved any recipes yet! Search now :)\"\n\t\t\trender status: 400, nothing: true\n\t\tend\n\tend", "def show\n @imaging_observation = ImagingObservation.find(params[:id])\n respond_to do |format|\n format.html { render :partial => '/imaging_observations/list', :collection => [@imaging_observation] } # show.html.erb\n format.xml { render :xml => @imaging_observation }\n format.js { render :layout => false }\n end\n end", "def index\n @organisational = Dictionary.find(:all, :order => \"place ASC\", :conditions => {:indicator => 1})\n @functional = Dictionary.find(:all, :conditions => { :indicator => 2 })\n @method = Dictionary.find(:all, :conditions => { :indicator => 3 })\n @leadership = Dictionary.find(:all, :conditions => { :indicator => 4 })\n @social = Dictionary.find(:all, :conditions => { :indicator => 5 })\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dictionaries }\n end\n end", "def index\n @given_circumstances = GivenCircumstance.all\n render json: @given_circumstances\n end", "def index\n birds = Bird.all\n render json: birds.to_json(except: [:created_at, :updated_at])\n end", "def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @all_taxons_seen = Taxon.species_seen.not_excluded\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @all_taxons_seen }\n end\n end", "def index\n @places = Place.all\n render json: { places: @places }, methods: [:reviews, :visit_ids, :image_url_large]\n # render json: @places, methods: :reviews # return a place object not a places object as above\n end", "def index\n @socios = Socio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socios }\n end\n end", "def index\n @somethings = Something.all\n render json: @somethings\n end", "def index\n locations = Location.all\n render json: locations\n end", "def observations_by_user\n return unless (\n user = find_or_goto_index(User, params[:user])\n )\n\n query = create_query(:Observation, :by_user, user: user)\n show_selected_observations(query)\n end", "def index\n iterations = policy_scope(Iteration)\n render json: iterations\n end", "def index\n @person = Person.find((params[:person_id]))\n @person_identification_docs = PersonIdentificationDoc.where(\"person_id = ?\", params[:person_id])\n\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @person_identification_docs }\n end\n end", "def show\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation_type }\n end\n end", "def index\n @journal_entries = JournalEntry.desc(:entry_date).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n # [{\"name\":\"temperature\",\"type\":\"areaspline\",\"data\":[[1327213807000,0],[1327214100000,0],[1327214403000,0],[1327214700000,0],[1327215000000,24],[1327215301000,59.8],[1327215603000,95.4],[1327215901000,120.8],[1327216202000,131.6]]}]\n format.json { render json: JournalEntry.all.as_json(only: [:purity, :fitness, :devotional, :chrissy, :relational, :discipline, :facepicking, :stress]) }\n end\n end", "def index\n s = User.find(session[:user_id])\n @studies= Study.where(:user_id => s.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @studies }\n end\n end", "def index\n past_histories = PastHistory.where(user_id: params[:user_id])\n render json: past_histories.as_json(include: :recipe, only: :created_at)\n end", "def index\n @place_visits = PlaceVisit.all\n render json: { place_visits: @place_visits }\n end", "def index\n @patients = Patient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patients }\n end\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n reviews = Review.all\n render json: reviews\n end", "def index\n \n respond_to do |format|\n format.html # index.html.erb\n format.json {\n @interviews = Interview.select(\"annotations, interviews.id, interviews.slug, storyteller_name\").where(\"is_demo = ? AND annotations != ?\", 0, \"\")\n render json: @interviews\n }\n end\n end", "def index\n respond_to do |format|\n format.html do\n @recent_objects = BiologicalRelationship.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)\n render '/shared/data/all/index'\n end\n format.json {\n @biological_relationships = BiologicalRelationship.with_project_id(sessions_current_project_id).order(:name)\n }\n end\n end", "def index\n @requests = Request.all\n\n render json: @requests\n end", "def demo\n render json: Cat.all\n end", "def index\n @identities = Identity.all\n\n render json: @identities\n end" ]
[ "0.724541", "0.72072977", "0.7196251", "0.7101862", "0.7024558", "0.68346304", "0.68106896", "0.6502588", "0.64973384", "0.64839226", "0.6398919", "0.63950795", "0.6359676", "0.63107514", "0.6275471", "0.62149364", "0.6155672", "0.6131335", "0.6126413", "0.60933864", "0.6086885", "0.60805535", "0.60453486", "0.6038001", "0.6021743", "0.6011211", "0.5987701", "0.59596986", "0.59473664", "0.59387946", "0.5925204", "0.589205", "0.5890506", "0.58779794", "0.58687943", "0.58673316", "0.5849162", "0.58427906", "0.58357507", "0.58286995", "0.58186716", "0.5817992", "0.58013415", "0.5795765", "0.5793874", "0.5785742", "0.57831746", "0.5781157", "0.5777808", "0.5776663", "0.5773603", "0.5768487", "0.5768439", "0.5768439", "0.57613814", "0.57588047", "0.5755271", "0.5755271", "0.5752702", "0.57522696", "0.57504874", "0.57445264", "0.5741584", "0.5738665", "0.57366395", "0.57359236", "0.5728278", "0.5726903", "0.5718355", "0.571565", "0.57154006", "0.57103443", "0.57084715", "0.57082534", "0.5706365", "0.5701472", "0.56961554", "0.569464", "0.5694513", "0.5694507", "0.56903297", "0.5685512", "0.5683786", "0.5682343", "0.566949", "0.56679255", "0.5666873", "0.5665002", "0.5663915", "0.5663768", "0.5661504", "0.56548375", "0.56516725", "0.5648533", "0.5648533", "0.56468534", "0.56428474", "0.56425124", "0.5641496", "0.563865" ]
0.6090778
20
GET /observations/1 GET /observations/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @observations = Observation.all()\n end", "def extract_observations(url)\n\n JSON.load(open(url))\n\n end", "def show\n @observation = Observation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def latest_observations\n path = 'stations/%s/observations/latest' % [@id]\n get(path)['properties']\n end", "def index\n @observations = scope.all\n end", "def list_observations # :nologin:\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def list_observations\n query = create_query(:Observation, :all, by: :date)\n show_selected_observations(query)\n end", "def show\n pass_query_params\n @observation = find_or_goto_index(Observation, params[:id].to_s)\n return unless @observation\n\n @observations = [\n MinimalMapObservation.new(@observation.id,\n @observation.public_lat,\n @observation.public_long,\n @observation.location)\n ]\n end", "def index\n @ice_observations = IceObservation.all\n end", "def index\n @observation_types = ObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @observation_types }\n end\n end", "def index\n @competition_interaction_observations = CompetitionInteractionObservation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @competition_interaction_observations }\n end\n end", "def index\n if !logged_in? && params[:page].to_i > 100\n authenticate_user!\n return false\n end\n params = request.params\n showing_partial = (params[:partial] && PARTIALS.include?(params[:partial]))\n # Humans should see this, but scrapers like social media sites and curls\n # will set Accept: */*\n human_or_scraper = request.format.html? || request.format == \"*/*\"\n # the new default /observations doesn't need any observations\n # looked up now as it will use Angular/Node. This is for legacy\n # API methods, and HTML/views and partials\n if human_or_scraper && !showing_partial\n @shareable_description = begin\n generate_shareable_description\n rescue StandardError => e\n Logstasher.write_exception( e, request: request, session: session, user: current_user )\n \"\"\n end\n else\n h = observations_index_search(params)\n params = h[:params]\n search_params = h[:search_params]\n @observations = h[:observations]\n end\n respond_to do |format|\n\n format.html do\n if showing_partial\n pagination_headers_for(@observations)\n return render_observations_partial(params[:partial])\n end\n # one of the few things we do in Rails. Look up the taxon_name param\n unless params[:taxon_name].blank?\n sn = params[:taxon_name].to_s.strip.gsub(/[\\s_]+/, ' ').downcase\n t = Taxon.active.where( name: sn ).first\n t ||= Taxon.where( name: sn ).first\n t ||= TaxonName.joins(:taxon).where(\"taxa.is_active AND lower(taxon_names.name) = ?\", sn).first.try(:taxon)\n t ||= TaxonName.where(\"lower(taxon_names.name) = ?\", sn).first.try(:taxon)\n if t\n t = t.current_synonymous_taxon unless t.is_active?\n params[:taxon_id] = t.id\n end\n end\n @asynchronous_google_maps_loading = true\n render layout: \"bootstrap\", locals: { params: params }\n end\n\n format.json do\n Observation.preload_for_component(@observations, logged_in: logged_in?)\n Observation.preload_associations(@observations, :tags)\n render_observations_to_json\n end\n \n format.geojson do\n render :json => @observations.to_geojson(:except => [\n :geom, :latitude, :longitude, :map_scale, \n :num_identification_agreements, :num_identification_disagreements, \n :delta, :location_is_exact])\n end\n \n format.atom do\n @updated_at = Observation.last.updated_at\n end\n \n format.dwc do\n Observation.preload_for_component(@observations, logged_in: logged_in?)\n Observation.preload_associations(@observations, [ :identifications ])\n end\n\n format.csv do\n render_observations_to_csv\n end\n \n format.kml do\n render_observations_to_kml(\n :snippet => \"#{@site.name} Feed for Everyone\",\n :description => \"#{@site.name} Feed for Everyone\",\n :name => \"#{@site.name} Feed for Everyone\"\n )\n end\n \n format.widget do\n if params[:markup_only] == 'true'\n render js: render_to_string(\n partial: \"widget\",\n handlers: [:erb],\n formats: [:html],\n locals: {\n show_user: true,\n target: params[:target],\n default_image: params[:default_image],\n silence: params[:silence]\n }\n )\n else\n render js: render_to_string(\n partial: \"widget\",\n handlers: [:erb],\n formats: [:js],\n locals: {\n show_user: true\n }\n )\n end\n end\n end\n rescue Elasticsearch::Transport::Transport::Errors::InternalServerError => e\n raise e unless e.message =~ /window is too large/\n msg = \"Too many results. Try using smaller searches or the id_above parameter.\"\n response.headers[\"X-Error\"] = msg\n respond_to do |format|\n format.html do\n flash[:error] = msg\n redirect_to( observations_path )\n end\n format.json { render json: { error: msg } }\n format.all { @observations = [] }\n end\n end", "def fetch_observations(station)\n\n scraper_logger.info(\"Fetching latest weather observations for #{station.id} - #{station.name}\")\n\n new = 0\n\n json = extract_observations(station.json_url)\n json['observations']['data'].each do |o|\n\n Time.zone = 'UTC'\n recording_time = Time.zone.parse(\"#{o['aifstime_utc']}Z\")\n\n unless Observation.already_exists?(station, recording_time)\n observation = Observation.new\n observation.station = station\n observation.recording_time = recording_time\n observation.save\n\n parse_readings(o, observation)\n\n new += 1\n\n end\n\n end\n\n scraper_logger.info(\"Added #{new} new observations\")\n\n end", "def show\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation_type }\n end\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def index\n @observations = Observation.where(service_of_dependence: current_user.dependence.service_of_dependences)\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def show\n @historial_odt = HistorialOdt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial_odt }\n end\n end", "def set_observation\n @observation = Observation.where(id: params[:id]).includes(:ice_observations).first\n end", "def index_observation\n query = find_or_create_query(:Observation, by: params[:by])\n show_selected_observations(\n query, id: params[:id].to_s, always_index: true\n )\n end", "def set_obersvation\n @observations = Observation.find(params[:id])\n end", "def index\n @notebooks = Notebook.all\n render json: @notebooks\n end", "def index\n sanitized_params = parse_params(simulation_where_params)\n simulations = Simulation.find_all(sanitized_params)\n\n render json: simulations\n end", "def index\n @patient_samples = PatientSample.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patient_samples }\n end\n end", "def show\n @observation_details = ObservationDetail.where(observation:@observation)\n end", "def index\n @studies = Study.all\n #render json: @studies\n end", "def index_observation # :nologin: :norobots:\n query = find_or_create_query(:Observation, by: params[:by])\n show_selected_observations(query, id: params[:id].to_s, always_index: true)\n end", "def index\n show and return if params[:id].present?\n\n @query = find_or_create_query(:Observation)\n apply_content_filters(@query)\n @query = restrict_query_to_box(@query)\n\n find_locations_matching_observations\n end", "def index\n @socioeconomic_studies = SocioeconomicStudy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @socioeconomic_studies }\n end\n end", "def index\n @patients = Patient.order('last_name ASC')\n\n #find the latest patient made\n @id = Patient.maximum(:id)\n if(@id != nil)\n @patient = Patient.find(@id)\n File.open(\"public/patient_info.json\", \"w\"){ |f| f << @patient.to_json}\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def index\n @person = Person.find((params[:person_id]))\n @person_identification_docs = PersonIdentificationDoc.where(\"person_id = ?\", params[:person_id])\n\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @person_identification_docs }\n end\n end", "def index\n render json: WeatherDatum.all\n end", "def index\n @cruise = Cruise.find(params[:cruise_id])\n @observations = @cruise.observations.order(observed_at: :desc).accessible_by(current_ability)\n \n \n \n respond_to do |format|\n format.csv { send_data build_csv, filename: \"observations-#{@cruise.id}.csv\"}\n format.json { send_data build_json, filename: \"observations-#{@cruise.id}.json\"}\n format.geojson { send_data build_geojson, filename: \"observations-#{@cruise.id}.geojson\"}\n format.sigrid3\n end\n end", "def show\n @historical = Historical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historical }\n end\n end", "def index\n obstype = ObservationType.find(params[:obstype]) if params[:obstype].present?\n\n query = params[:query]\n if obstype\n @observations = obstype.observations\n @obstype = obstype\n elsif query\n @observations = Observation.ordered_by_date.basic_search(comment: query)\n @query = query\n else\n @observations = Observation.all\n end\n\n year = params[:year]\n if year.present?\n @observations = @observations.by_year(year.to_i)\n @year = year\n end\n\n areas = params[:areas_as_text] # TODO: what happens when you add multiple areas\n if areas.present?\n @observations = @observations.by_area(areas)\n myareas = Area.find(areas)\n @areas_as_text = [myareas].map(&:attributes).to_json\n end\n\n @observations = @observations.by_page(params[:page])\n\n respond_with @observations do |format|\n format.salus_xml { render 'index', formats: %i[salus_xml] }\n format.salus_csv { render 'index', formats: %i[salus_csv] }\n end\n end", "def show\n @imaging_observation = ImagingObservation.find(params[:id])\n respond_to do |format|\n format.html { render :partial => '/imaging_observations/list', :collection => [@imaging_observation] } # show.html.erb\n format.xml { render :xml => @imaging_observation }\n format.js { render :layout => false }\n end\n end", "def index\n @pain_observations = PainObservation.all\n end", "def index\n puts \"Index method called...\"\n @studies = Study.all\n\n # render json: @studies\n end", "def get_data series_id\n\t\traw_output = @fred.series( 'observations', series_id: series_id.to_s)\n\n\t\traw_output.observations.observation\n\tend", "def index\n @fiction = Fiction.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fiction }\n end\n end", "def observations_by_name # :nologin: :norobots:\n query = create_query(:Observation, :all, by: :name)\n show_selected_observations(query)\n end", "def index\n @experiments = Experiment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiments }\n end\n end", "def index\n render :json => UserInterest.all\n end", "def index\n @am_run_observation_types = AmRunObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @am_run_observation_types }\n end\n end", "def index\n @studies = Study.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @studies }\n end\n end", "def show\n @notebook = Notebook.find(params[:id])\n render json: @notebook\n end", "def index\n @data = Datum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data }\n end\n end", "def index\n @interviews = Interview.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interviews }\n end\n end", "def observations_of_name\n query = create_query(:Observation, :all,\n names: [params[:name]],\n include_synonyms: true,\n by: :confidence)\n show_selected_observations(query)\n end", "def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end", "def index\n @observation = Observation.find(params[:observation_id])\n @observers = Observer.find_all_by_observation_id(params[:observation_id])\n \n respond_to do |format|\n format.html { render :layout=>\"tabs\"}\n format.json { render json: @observers }\n end\n end", "def index\n @historicals = @project.historical\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @historicals }\n end\n end", "def index\n @data_points = DataPoint.recent # cached_recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_points }\n end\n end", "def index\n @notes = Note.where(:year_at => Date.current.year).order(:created_at)\n @incomings = Incoming.where(:year_at => Date.current.year).order(:created_at)\n @user = User.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notes }\n end\n end", "def show\n\n @observation = Observation.find(params[:id])\n @coral = Coral.find(params[:coral_id])\n\n @files = Dir.glob(\"app/assets/images/tagged_outlines_thumbs/*\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation }\n end\n end", "def index\n @patients = Patient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patients }\n end\n end", "def show\n simulation = Simulation.retrieve_by_id(params[:id])\n\n render json: simulation\n end", "def observations_by_name\n query = create_query(:Observation, :all, by: :name)\n show_selected_observations(query)\n end", "def index\n @illustrations = Illustration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @illustrations }\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 show\n @study = Study.find(params[:id])\n render json: @study\n end", "def index\n @incomes = Income.all\n\n respond_to do |format|\n format.json { render json: @incomes }\n end\n end", "def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @notebooks = Notebook.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notebooks }\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def index_json\n @ni = Note.all\n p = params()\n if (p.has_key?(\"lat\") && p.has_key?(\"lon\"))\n @ni = notes_in_range(p['lat'].to_f, p['lon'].to_f)\n end\n @notes = @ni\n\n render :json => @notes.to_json( )\n end", "def destroy\n @observations.destroy\n respond_to do |format|\n format.html { redirect_to observations_url }\n format.json { head :no_content }\n end\n end", "def index\n @citations = Citation.all\n\n render json: @citations\n end", "def show\n @competition_interaction_observation = CompetitionInteractionObservation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competition_interaction_observation }\n end\n end", "def observation_index # :nologin: :norobots:\n query = create_query(:Name, :with_observations)\n show_selected_names(query)\n end", "def index\n @notes = Note.all\n render json: @notes\n end", "def index\n @somethings = Something.all\n render json: @somethings\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end", "def index\n @recipes = Recipe.all\n render json: @recipes\n end", "def index\n @disponibles = Disponible.take(50)\n\n render json: @disponibles, include: '**'\n end", "def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end", "def recent_observations(num = 5)\n observations.find(:all, :limit => num, :order => \"created_at DESC\")\n end", "def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @interests }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataset }\n end\n end", "def index\n\n if param? params[:random]\n\n @citation = Citation.order(\"RANDOM()\").first\n\n render json: @citation \n\n else\n\n @citations = Citation.all\n\n render json: @citations\n\n end\n end", "def index\n @title = \"Studies\"\n\n respond_to do |format|\n format.html do\n @my_studies = Study.with_user(current_user.netid)\n end\n format.json do\n render :json => Study.with_user(current_user.netid).to_json\n end\n end\n end", "def index\n recipes = Recipe.all\n render status: :ok, json: recipes\n end", "def observations_of_name # :nologin: :norobots:\n args = {\n name: params[:name],\n synonyms: :all,\n nonconsensus: :no,\n by: :created_at\n }\n args[:user] = params[:user_id] unless params[:user_id].blank?\n args[:project] = params[:project_id] unless params[:project_id].blank?\n\n unless params[:species_list_id].blank?\n args[:species_list] = params[:species_list_id]\n end\n\n query = create_query(:Observation, :of_name, args)\n show_selected_observations(query)\n end", "def index\n @organisational = Dictionary.find(:all, :order => \"place ASC\", :conditions => {:indicator => 1})\n @functional = Dictionary.find(:all, :conditions => { :indicator => 2 })\n @method = Dictionary.find(:all, :conditions => { :indicator => 3 })\n @leadership = Dictionary.find(:all, :conditions => { :indicator => 4 })\n @social = Dictionary.find(:all, :conditions => { :indicator => 5 })\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dictionaries }\n end\n end", "def search\n render json: PersonEvent.first(10)\n end", "def index\n @neighborhoods = Neighborhood.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neighborhoods }\n end\n end", "def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end", "def index\n @patients = Patient.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patients }\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 index\n @observances = Observance.all\n end", "def index\n s = User.find(session[:user_id])\n @studies= Study.where(:user_id => s.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @studies }\n end\n end", "def map_observation\n pass_query_params\n obs = find_or_goto_index(Observation, params[:id].to_s)\n return unless obs\n\n @title = :map_observation_title.t(id: obs.id)\n @observations = [\n MinimalMapObservation.new(obs.id, obs.public_lat, obs.public_long,\n obs.location)\n ]\n render(template: \"observations/map\")\n end", "def index\n @witnesses = Witness.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @witnesses }\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @life_insurances }\n end\n end", "def observations(stations, lang = 'is', time = '1h', anytime = '0')\n Apis.client.get(\"/weather/forecasts/#{lang}\" \\\n \"/?stations=#{stations.join(',')}&time=#{time}&anytime=#{anytime}\")\n end", "def index\n @requests = Request.all\n\n render json: @requests\n end", "def index\n @dummy_records = DummyRecord.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @dummy_records }\n end\n end" ]
[ "0.67711335", "0.67475224", "0.6717042", "0.65535736", "0.65496236", "0.6516681", "0.64280385", "0.63851666", "0.63757455", "0.61541724", "0.61337066", "0.6056076", "0.60321456", "0.5999285", "0.5979333", "0.59619814", "0.595239", "0.595239", "0.5942247", "0.5939914", "0.5832487", "0.58269393", "0.5821905", "0.5810128", "0.5804455", "0.57991236", "0.5786405", "0.5786048", "0.57784337", "0.5772039", "0.5762817", "0.575415", "0.5734215", "0.5726908", "0.5723909", "0.5716966", "0.5712229", "0.5706958", "0.56940144", "0.56837", "0.5681522", "0.56706107", "0.5662683", "0.5662316", "0.56615275", "0.56457055", "0.56320196", "0.5623694", "0.5620343", "0.56090176", "0.5593269", "0.5592816", "0.55866843", "0.55856615", "0.55855125", "0.55780226", "0.55665976", "0.5565276", "0.5560134", "0.55594146", "0.55517673", "0.5548145", "0.55448985", "0.55439603", "0.5543729", "0.55392754", "0.55349797", "0.55349797", "0.5532504", "0.55319977", "0.5522845", "0.55227077", "0.5519493", "0.5512691", "0.5509862", "0.55072975", "0.54946864", "0.54939353", "0.5489438", "0.54894143", "0.5486097", "0.5476053", "0.54754186", "0.54712164", "0.54681396", "0.54678744", "0.5467175", "0.54623175", "0.545389", "0.5449933", "0.5448861", "0.54436535", "0.54433286", "0.5434054", "0.54334223", "0.54323083", "0.54272264", "0.54247594", "0.5419933", "0.5419132", "0.5413632" ]
0.0
-1