query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
after_save callback to handle group_ids
def update_courses unless course_ids.nil? self.enrollments.each do |e| e.destroy unless course_ids.include?(e.course_id.to_s) course_ids.delete(e.course_id.to_s) end course_ids.each do |c| self.enrollments.create(:course_id => c) unless c.blank? @cse = Course.find(c) @cse.assignments.each do |assignment| Gradation.create(:assignment_id => assignment.id, :student_id => self.id, :course_id => c) end reload self.course_ids = nil end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_save\n api.group_save(self)\n end", "def before_save\n prepare_attributes\n find_song_groups!\n end", "def save_groups\n self.groups.each { |c| if c.destroy_association? then c.destroy else c.save end }\n self.added_groups.each { |c| c.save unless c.nil? } unless self.added_groups.nil?\n end", "def group_save(group)\n raise NotImplementedError\n end", "def set_group_belonging\n #group_number = self.id % 4\n #self.update_attributes(group: group_number)\n self.update_attributes(group: 1)\n end", "def after_store\n if group_owner?\n self.stored_group_notification_count = group_notification_count\n self.stored_group_member_notifier_count = group_member_notifier_count\n self.stored_group_members = group_members.as_json\n self.stored_group_members.each do |group_member|\n # Cast Time and DateTime field to String to handle Dynamoid unsupported type error\n group_member.each do |k, v|\n group_member[k] = v.to_s if v.is_a?(Time) || v.is_a?(DateTime)\n end\n end\n save\n else\n group_owner.after_store\n end\n end", "def group_id\n super\n end", "def after_create entity_group\n ueg=entity_group.user_entity_groups.build\n ueg.user=entity_group.creator\n ueg.save\n end", "def after_update_group\n\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller || self.changed.blank?\n\n current_user = PublicActivity.get_controller.current_user\n\n self.create_activity :update, owner: current_user,organization_id: self.organization_id, params: {:detail => I18n.t('logs.update_group', group_name: self.name)}\n\n end", "def add_group!( group )\n save if add_group( group )\n end", "def save\n \n transaction do |transaction|\n check_usergroups! if self.usergroups and (not self.usergroups.empty?)\n super\n update_aspects\n transaction.commit\n end\n\n end", "def before_destroy\n default = Group.find(:first, \n :conditions => [\"template_id = ? and name = '_default'\", \n self.template_id])\n if (default.is_default?)\n self.fields.each do |f|\n f.group_id = default.id\n f.save\n end\n #trigger a save to (hopefully) refresh the data for AS\n default.save\n end\n end", "def after_save(record)\n \n end", "def after_create_group\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller || self.changed.blank?\n\n current_user = PublicActivity.get_controller.current_user\n\n self.create_activity :create, owner: current_user,organization_id: self.organization_id, params: {:detail => I18n.t('logs.create_group', group_name: self.name)}\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group_ids\n @attributes[:group_ids]\n end", "def group\n object.group.id\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def group_id\n @attributes[:group_id]\n end", "def child_group_ids\n child_groups.map(&:id)\n end", "def save_group(user)\n ActiveRecord::Base.transaction do\n save\n @user_group = UserGroup.new\n @user_group.user_id = user.id\n @user_group.group_id = id\n @user_group.save\n @member = GroupMember.new\n @member.e_mail = user.email\n @member.group_id = id\n @member.save\n end\n end", "def group_ids\n @group_ids ||= current_user.group_ids\n end", "def group_ids\n groups.pluck(:id)\n end", "def after_create_save(record); end", "def save_group_visibilities(group_ids)\n groups.clear\n if group_ids\n selected_groups = Group.find(group_ids)\n selected_groups.each do |group|\n groups << group\n end\n end\n end", "def postprocess(groups)\n end", "def group_ids\n groups.map{|g| g.id}\n end", "def group_id\n \tregisterable.class.name == \"Group\" ? registerable.id : nil\n end", "def set_group\n @group = Group.find_by(id: params[:id],user_id: current_handle_user.id)\n end", "def after_save_hook\n execute_hooks_for(:after, :save)\n end", "def document_collection_group_ids=(ids)\n if new_record?\n raise(StandardError, \"cannot assign document collection to an unsaved edition\")\n end\n\n document.document_collection_group_ids = ids\n end", "def watcher_group_ids_with_uniq_ids=(group_ids)\n if group_ids.is_a?(Array)\n group_ids = group_ids.uniq\n end\n send :watcher_group_ids_without_uniq_ids=, group_ids\n end", "def update_groups\n unless group_ids.nil?\n self.groups_members.each do |m|\n m.destroy unless group_ids.include?(m.group_id.to_s)\n group_ids.delete(m.group_id.to_s)\n end\n group_ids.each do |g|\n self.groups_members.create(:group_id => g) unless g.blank?\n end\n reload\n self.group_ids = nil\n end\n end", "def after_save(&block)\n after_saves << block\n end", "def after_create(group_announcement)\n expire_group_announcement(group_announcement)\n end", "def group_ids=(ids)\n ids.each do |group_id|\n if group_id.presence\n group = ::Burlesque::Group.find(group_id)\n self.groups << group unless self.groups.include?(group)\n end\n end\n\n to_deletes = []\n self.groups.each do |group|\n to_deletes << group unless ids.include?(group.id) or ids.include?(group.id.to_s)\n end\n\n to_deletes.each do |group|\n self.groups.delete(group) if self.group?(group)\n end\n end", "def save\n deleted! if @deleted\n # If there is an ID, update that entry\n if @id\n Cli.edit_group( @id, name: @name )\n else # If no ID, that means this is a new entry\n Cli.add_group( @name )\n set_id_after_save\n end\n self\n end", "def update_group(increment)\n end", "def group_id\n get_info[:groupID]\n end", "def add_group(group_id)\n\t\t\n\t\t# ADD ERROR CHECKING HERE FOR INVALID GROUP -> TEST\n\n\t\tself.group_list |= [group_id]\n\t\tself.update_attribute(:group_list, self.group_list)\n\t\t\n\tend", "def save(*args)\n\t grouping_too = self.new_record?\n\t res = super\n\t self.groupings.create(competition: self, name: self.fullname(),\n\t\t\t\t\tbracket_grouping: self.playoffbracket) if grouping_too\n\t res # return result of call to super\n\tend", "def add_groups(group_ids = [])\n g = self.groups.pluck(:id)\n self.promotion_groups.where(group_id: g - group_ids).destroy_all\n (group_ids - g).each do |g_id|\n self.promotion_groups.create(group_id: g_id)\n end\n end", "def keep(persist_attribs)\n persist_attribs[:id] = persist_attribs[:group_id]\n super\n end", "def ungrouped_gallery_ids=(new_ids)\n new_ids -= ['']\n new_ids = new_ids.map(&:to_i)\n group_gallery_ids = gallery_groups.joins(:gallery_tags).except(:order).pluck('distinct gallery_tags.gallery_id')\n new_chargals = []\n transaction do\n characters_galleries.each do |char_gal|\n gallery_id = char_gal.gallery_id\n if new_ids.include?(gallery_id)\n # add relevant old galleries, making sure added_by_group is false\n char_gal.added_by_group = false\n new_chargals << char_gal\n new_ids.delete(gallery_id)\n elsif group_gallery_ids.include?(gallery_id)\n # add relevant old group galleries, added_by_group being true\n char_gal.added_by_group = true\n new_chargals << char_gal\n group_gallery_ids.delete(gallery_id)\n else\n # destroy joins that are not in the new set of IDs\n char_gal.destroy\n end\n end\n new_ids.each do |gallery_id|\n # add any leftover new galleries\n new_chargals << CharactersGallery.new(gallery_id: gallery_id, character_id: id, added_by_group: false)\n end\n # leftover galleries from gallery groups will be added by that model\n self.characters_galleries = new_chargals\n if persisted?\n self.update_attributes(characters_galleries: new_chargals)\n else\n self.assign_attributes(characters_galleries: new_chargals)\n end\n end\n end", "def after_save\n songs = @song_groups.sort_by{ |group| cost_of group }.first\n\n # Sort em\n direction = final - initial > 0 ? :asc : :desc\n songs = songs.sort_by(&facet)\n songs = songs.reverse if direction == :desc\n\n songs.each_with_index do |song, position|\n MrEko::PlaylistEntry.create(:playlist_id => self.id, :song_id => song.id, :position => position)\n end\n end", "def save!(*args)\n\t grouping_too = self.new_record?\n\t res = super\n\t self.groupings.create!(competition: self, name: self.fullname(),\n\t\t\t\t\tbracket_grouping: self.playoffbracket) if grouping_too\n\t res # return result of call to super\n\tend", "def refresh_ce_group!\n self.save! if refresh_ce_group\n end", "def delete_related_groups\n \n end", "def create\n cu = User.find params[:user_id]\n\n @group = Group.new(params[:group])\n cu.groups << @group\n\n case params[:group_type].to_i\n when 1\n @group.groupable = ArtistGroup.create\n\n if defined?(params[:instr_id]) && (not params[:instr_id].nil?)\n m = Membership.where \"group_id = #{@group.id}\n AND userable_id = #{cu.id}\n AND userable_type = 'User'\"\n params[:instr_id].each do |i|\n m.first.instruments << Instrument.find(i)\n end\n end\n when 2\n @group.groupable = FanGroup.create :artist_group => ArtistGroup.find(params[:art_group_id].to_i)\n when 3\n @group.groupable = HostGroup.create\n end\n\n\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Die Gruppe wurde erfolgreich angelegt.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def setGroupId _obj, _args\n \"_obj setGroupId _args;\" \n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n # byebug\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find_by(cod_id: params['id'])\n end", "def adjust_after_save\n # The record is in @record, do what you will, this follows a save and reload (so the id should be present)\n # This might be rendered mostly unnecessary if you allow the parent to create and update new children,\n # which I think is reasonably possible most of the time\n end", "def new group_identifier, object_identifier_or_array = []\n groups.store self.class.identifierize(group_identifier), self.class.identifier_collect(object_identifier_or_array)\n end", "def admin_group_ids\n @attributes[:admin_group_ids]\n end", "def set_group\n #@group = Group.find(params[:id])\n end", "def after_update_save(record); end", "def set_groups_field\n @groups_field = GroupsField.find(params[:id])\n end", "def set_search_group_id\n self.search_group_id = 2\n end", "def set_group\n data[:group]\n end", "def create_group_locations_list group_id\n @group = Group.find(group_id, :include => :locations)\n\n # you can only create an event for a location\n # this is already attached to this group\n @group_locations_list = @group.locations.uniq.map { |location|\n [ location.name, location.id ]\n }\n end", "def after_save_new_order\n end", "def save\n con = Group.open_connection\n\n if (self.groupid)\n # update\n sql = \"UPDATE groups SET groupname='#{self.groupname}', grouptype='#{self.grouptype}' WHERE groupid = #{self.groupid}\"\n else\n # add\n sql = \"INSERT INTO groups (groupname, grouptype) VALUES ('#{self.groupname}', '#{self.grouptype}')\"\n end\n #\n #\n con.exec(sql)\n #\n end", "def set_group_id(opts)\n opts = check_params(opts,[:group_id])\n super(opts)\n end", "def after_save(&block)\n @hooks ||= {}\n @hooks[\"after_save\".to_sym] = block\n end", "def add_to_group\n if request.post?\n @user_id = params[:user_id]\n @group = params[:group_ids]\n @created_g_u= Array.new\n @group.each do |g|\n #g_user = GroupUser.find(:all,:conditions=>[\"user_id=#{@user_id.to_i} and group_id=#{g.to_i}\"])\n group_user = GroupUser.create(:user_id=>@user_id.to_i,:group_id=>g.to_i)# if g_user.blank?\n @created_g_u << group_user if group_user.id\n end\n @notice = \"Successfully added to group.\"\n respond_to do |format|\n format.js\n end\n \n else\n render :partial=>\"add_to_group_form\", :locals=>{:user=>@login_user,:user_id=>params[:id]}, :layout=>false\n end\n end", "def save_task_groups(task, params)\n @task.task_groups = params[:task_groups].map {|gp| TaskGroup.find(gp)} if params[:task_groups]\n @task.save\n end", "def before_save(sender); end", "def setup_group\n self.status = 'pending'\n make_slug\n self.valid? && self.save! ? true : false\n end", "def assigned_groups=(array_hash)\n # Find new groups (but no duplicates)\n self.added_groups = []\n array_hash.each do |h|\n unless groups.detect { |c| c.id.to_s == h[:id] } || self.added_groups.detect { |f| f.id.to_s == h[:id] }\n c = !h[:id].blank? ? Group.find(h[:id]) : Group.new({:page_object => self})\n c.attributes = h.reject { |k,v| k == :id } # input values, but don't try to overwrite the id\n self.added_groups << c unless c.nil?\n end\n end\n # Delete removed groups\n groups.each do |c|\n if h = array_hash.detect { |h| h[:id] == c.id.to_s }\n c.attributes = h.reject { |k,v| k == :id }\n else\n c.destroy_association = 1\n end\n end\n end", "def record!\n find_or_build_event_group\n update_event_group_attributes\n send_notifications_for_event_group\n \n @event_group.archived = false\n @event_group.save\n @event_group.events.create(event_params)\n @event_group\n end", "def key\n 'groupid'\n end", "def groups\r\n save_default_group(params)\r\n delete_group(params)\r\n end", "def set_group\n @group = current_store.groups.find(params[:group_id])\n end", "def set_group\n @group = Group.friendly.find(params[:id])\n end", "def after_save\n super\n if self.ah_id =~ /==$/\n self.update(:ah_id=>\"AH#{self.id}\")\n end\n end", "def store_group(uuid)\n Uploadcare::Group.store(uuid)\n end", "def group_ids=(values)\n values ||= []\n values = [ values ] unless values.is_a?(::Array)\n values = values.reject{|v| v.blank?}.map{|v| v.to_i}\n self.groups = Incline::AccessGroup.where(id: values).to_a\n end", "def group_ids=(values)\n values ||= []\n values = [ values ] unless values.is_a?(::Array)\n values = values.reject{|v| v.blank?}.map{|v| v.to_i}\n self.groups = Incline::AccessGroup.where(id: values).to_a\n end", "def before_saving\n self.save_to_gallery(self.file, self.filename, self.photo_gallery_id, self.user_id)\n# self.save\n# end\n end", "def groupID _args\n \"groupID _args;\" \n end", "def add_to_group group_identifier, object_identifier_or_array\n group = self.get group_identifier\n group += identifier_collect(object_identifier_or_array)\n return group\n end", "def set_group\n @group = Group.with_attached_logo.includes(:conversations).friendly.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def set_group\n @group = Group.find(params[:id])\n end", "def refresh_ce_group\n return false if ce_group_valid?\n\n group_id = existing_ce_group || add_ce_group\n return false unless group_id\n\n write_attribute :group_id, group_id\n true\n end", "def update\n# debug(params[:group][:right_ids] Pour faire un debuggage dans le controlleur\n @group = Group.find(params[:id])\n @group.rights.clear\n\n #Mise à jour de droits que possède un groupe\n params[:group][:right_ids] ||= []\n params[:group][:right_ids].each do |right|\n if !(right.blank?)\n @group.add_right(Right.find_by_id(right))\n end\n end\n\n respond_to do |format|\n if @group.update(group_params)\n\n format.html { redirect_to @group, notice: t('group.updated_msg') }\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 after_save\n save_tags\n end", "def set_group\n @group = Group.friendly.find(params[:comment][:group_id])\n end", "def associate_records_to_groups\n put_isos_into_iso_group\n put_agents_into_iso_group\n put_merchants_into_iso_group\n end", "def set_group\n @group = Enrollment.find(params[:id])\n end", "def set_group_event\n @group_event = GroupEvent.find(params[:id])\n end" ]
[ "0.66786563", "0.6583159", "0.64804435", "0.63517076", "0.62737626", "0.61839855", "0.6181366", "0.6084062", "0.60247976", "0.59588283", "0.5953746", "0.5943064", "0.5938133", "0.5905705", "0.5875486", "0.5875486", "0.5875486", "0.58388996", "0.5815351", "0.5815351", "0.5815351", "0.5786338", "0.5729256", "0.5692638", "0.5689601", "0.5664184", "0.5646404", "0.564436", "0.5636924", "0.5608868", "0.55735064", "0.5557347", "0.55467606", "0.5538874", "0.5534645", "0.553299", "0.5505523", "0.5502106", "0.5482185", "0.5469249", "0.54555994", "0.5444229", "0.54401016", "0.5417425", "0.54063034", "0.54003334", "0.53782654", "0.5374848", "0.5369953", "0.53693646", "0.5353013", "0.5345851", "0.5341615", "0.5333267", "0.5332063", "0.5326896", "0.5324138", "0.5322891", "0.53205216", "0.5317841", "0.53120816", "0.53115547", "0.53105986", "0.53012747", "0.5300509", "0.52999204", "0.5295293", "0.5275582", "0.527058", "0.52667713", "0.5263058", "0.524792", "0.5243604", "0.52432173", "0.52278686", "0.52212435", "0.5214835", "0.5210993", "0.5208187", "0.52070206", "0.52041864", "0.52041864", "0.5192569", "0.5191418", "0.5189905", "0.5184669", "0.51841384", "0.51841384", "0.51841384", "0.51841384", "0.51841384", "0.51841384", "0.51841384", "0.51841384", "0.51821", "0.5178122", "0.5174052", "0.5172032", "0.51668274", "0.51602614", "0.5157038" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def article_params params.require(:category).permit(:title, :description, :weight) 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 /persona_punto_venta GET /persona_punto_venta.json
def index @persona_punto_venta = PersonaPuntoVentum.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end", "def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def create\n @persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params)\n\n respond_to do |format|\n if @persona_punto_ventum.save\n format.html { redirect_to @persona_punto_ventum.punto_venta, notice: 'Persona punto ventum was successfully created.' }\n format.json { render :show, status: :created, location: @persona_punto_ventum }\n else\n format.html { render :new }\n format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona_punto_ventum.update(persona_punto_ventum_params)\n format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona_punto_ventum }\n else\n format.html { render :edit }\n format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id)\n @persona_punto_ventum.destroy\n respond_to do |format|\n format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @pun = Pun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pun }\n end\n end", "def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @persona }\n end\n end", "def index\n @puntajes = Puntaje.order('created_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n @paciente = @persona.perstable\n #aqui deben ir los datos del paciente tambien\n end", "def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end", "def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end", "def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end", "def tipospolen\n\n @info_polens = InfoPolen.collection.aggregate(\n { \"$group\" => { \"_id\" => \"$TIPOS_POLINICOS\" } },\n { \"$sort\" => {\"_id\" => 1} }\n )\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def huertopublico\n @huerto = Huerto.find_by_agrupacion(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end", "def show\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n @users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @personas = Persona.all\n @users = User.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def show\n @unp = Unp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unp }\n end\n end", "def show\n @objet = Objet.find(params[:id])\n @personnage = @objet.personnage\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @objet }\n end\n end", "def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end", "def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end", "def show\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje_mision }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def show\n @vehicule_perso = VehiculePerso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vehicule_perso }\n end\n end", "def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end", "def show\n @alumno = Alumno.find(params[:id])\n\n render json: @alumno.as_json(include: :persona)\n end", "def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end", "def 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 @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end", "def index\n @tipos_personas = TipoPersona.all\n end", "def index\n @prueba_jsons = PruebaJson.all\n end", "def index\n @persona = Persona.find(params[:persona_id])\n @info_extra_paciente = @persona.info_extra_pacientes.all\n format.html { render :show }\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def show\n @puestos_entidad = PuestosEntidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puestos_entidad }\n end\n end", "def new\n @pun = Pun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pun }\n end\n end", "def show\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfilnegocio }\n end\n end", "def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end", "def show\n @partecipanti_gruppo = PartecipantiGruppo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipanti_gruppo }\n end\n end", "def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.json { render json: @persona }\n end\n end", "def index\n @protectoras = Protectora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @protectoras }\n end\n end", "def show\n\t\t \t\tpersona = Persona.find(params[:id])\n\t\t \t\trender json: {status: 'SUCCESS', message:'Loaded persona', data:persona},status: :ok\n\t\t \tend", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @persona }\n format.json { render :json => @persona.to_json }\n end\n end", "def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end", "def index\n @personas = Persona.all\n end", "def index\n @personas = Persona.all\n end", "def index\n @personas = Persona.all\n end", "def index\n authorize! :index, Por, :message => 'Acceso denegado.'\n @pors = @campus.pors.paginate(:per_page => 3, :page => params[:page])\n\t\t@points = @pors\n\t\t@point_name = \"por\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render \"points/index.json.erb\" } # index.json.erb\n end\n end", "def show\n @apunte = Apunte.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apunte }\n end\n end", "def index\n\n @people = Person.filter(params.slice(:name_like))\n @people = @people.where([\"union_id = ?\", current_person.union_id]) if request.format.json? && !owner?\n @people = @people.where(\"not invited_by_id is null\").order([:last_name, :first_name, :id])\n \n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n if params[:estado]\n @municipios = Uf.find(params[:estado]).municipios\n else\n @municipios = Uf.first.municipios\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end", "def index\n @profesors = Profesor.all\n # if @profesors!= nil\n#render json: @profesors\n#else\n# @profesors= '{\"exito\",false,\"no se encontraron profesores\"}'\n\n render json: @profesors\n # end\n end", "def index\n @personas_proyectos = PersonaProyecto.all\n end", "def new\n @ventas_presupuesto = Ventas::Presupuesto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end", "def geoportal\n if p = @especie.proveedor\n if p.snib_id.present? && p.snib_reino.present?\n # Catch the response\n begin\n response = RestClient.get \"#{CONFIG.geoportal_url}&rd=#{p.snib_reino}&id=#{p.snib_id}\", :timeout => 10, :open_timeout => 10\n render json: [] unless response.present?\n rescue => e\n render json: []\n end\n\n render json: response\n\n else\n render json: []\n end\n else\n render json: []\n end\n\n end", "def show\n @pinglun = Pinglun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinglun }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @municipio_de_la_preparatoria_o_universidad_de_origens = MunicipioDeLaPreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipio_de_la_preparatoria_o_universidad_de_origens }\n end\n end", "def show\n @controlpersona = Controlpersona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @controlpersona }\n end\n end", "def show\n @profesor_pertenece_asignatura = ProfesorPerteneceAsignatura.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profesor_pertenece_asignatura }\n end\n end", "def index\n @ventas = Venta.order(\"fecha desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas }\n end\n end", "def show\n @perfil_transaccione = PerfilTransaccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfil_transaccione }\n end\n end", "def show\n @partecipante = Partecipante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipante }\n end\n end", "def show\n @patrocinio = Patrocinio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patrocinio }\n end\n end", "def show\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @persona_vinculada = PersonaVinculada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona_vinculada }\n end\n end", "def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end", "def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end", "def index\n @telefonos = @persona.telefonos.find(:all, :order => \"tipo ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @telefonos }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @personas_vinculadas = PersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas_vinculadas }\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end", "def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end", "def show\n @pruning = Pruning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pruning }\n end\n end", "def show\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipomedalla }\n end\n end", "def set_paciente\n @persona = Persona.find(params[:id])\n @paciente = @persona.perstable\n end", "def show\n @personerium = Personerium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personerium }\n end\n end", "def show\n @telefononegocio = Telefononegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @telefononegocio }\n end\n end", "def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end", "def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end", "def index\n @propuestas = Propuesta.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @propuestas }\n end\n end", "def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end", "def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end", "def set_punto\n @punto = Punto.find(params[:id])\n end", "def show\n respond_to do |format|\n people = @mob.user_idz.split(',').map{|i| User.find(i).name }.join(', ')\n format.json { render json: @mob.attributes.merge(people: people, users: @mob.users, date: Time.now.strftime('%-m/%-d/%Y')) }\n end\n end", "def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end", "def index\n @participante_videoconferencia = ParticipanteVideoconferencium.all\n render json: @participante_videoconferencia\n end", "def show\n @ventas_seguimiento = Ventas::Seguimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_seguimiento }\n end\n end", "def index\n @ofertas = Oferta.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @ofertas }\n end\n end", "def index\n #paciente_by_nutriologo = Paciente.where(nutriologo_id: session[:nutriologo_id])\n @pacientes = Persona.paciente\n # Se opto por crear un scope, de esta forma ya se manda a llamar solo esl scope como muestra arriba. el scope esta definido en el modelo\n # persona.perstable <= esto obtiene el registro que concide con el id seleccionado algo como Paciente.where(id:\n end", "def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end", "def get_pokemon_JSON\n r = \n {\n :p1 => JSON.parse(self.pokeserver(self.p1)), \n :p2 => JSON.parse(self.pokeserver(self.p2)), \n :p3 => JSON.parse(self.pokeserver(self.p3)), \n :p4 => JSON.parse(self.pokeserver(self.p4)), \n :p5 => JSON.parse(self.pokeserver(self.p5)), \n :p6 => JSON.parse(self.pokeserver(self.p6)) \n }\n \n JSON.generate(r)\n end" ]
[ "0.684093", "0.6608203", "0.65238965", "0.6478566", "0.63313097", "0.61472183", "0.61254483", "0.6094465", "0.60358447", "0.6015532", "0.5965137", "0.59626883", "0.5922764", "0.5922764", "0.59172255", "0.5873233", "0.5862093", "0.58567005", "0.58518165", "0.5837091", "0.58153343", "0.5797872", "0.5776022", "0.5719032", "0.5707713", "0.56848", "0.5660383", "0.56534207", "0.5644646", "0.56435865", "0.56397545", "0.56341445", "0.56070924", "0.56060857", "0.5602765", "0.55647266", "0.5556257", "0.5554613", "0.55544806", "0.5549304", "0.5544885", "0.552421", "0.55156076", "0.5513445", "0.5512206", "0.55121106", "0.5510316", "0.549274", "0.5474917", "0.5472359", "0.5454603", "0.5454603", "0.5454603", "0.5454213", "0.54537594", "0.54503226", "0.545003", "0.5442745", "0.543938", "0.54315555", "0.54267806", "0.5425843", "0.54255176", "0.54255176", "0.54255176", "0.54195607", "0.54192364", "0.5419094", "0.54190105", "0.5416163", "0.5414871", "0.5414276", "0.54120934", "0.5406412", "0.5406243", "0.53995264", "0.5398658", "0.5398658", "0.5391563", "0.5382746", "0.5382746", "0.53783774", "0.537075", "0.5360726", "0.534265", "0.53422517", "0.53410566", "0.53361934", "0.53344274", "0.5329323", "0.5326184", "0.532488", "0.5320062", "0.5319921", "0.53195244", "0.5314477", "0.5311944", "0.53112525", "0.5308821", "0.5302765" ]
0.70606333
0
GET /persona_punto_venta/1 GET /persona_punto_venta/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @persona_punto_venta = PersonaPuntoVentum.all\n end", "def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end", "def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end", "def create\n @persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params)\n\n respond_to do |format|\n if @persona_punto_ventum.save\n format.html { redirect_to @persona_punto_ventum.punto_venta, notice: 'Persona punto ventum was successfully created.' }\n format.json { render :show, status: :created, location: @persona_punto_ventum }\n else\n format.html { render :new }\n format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def update\n respond_to do |format|\n if @persona_punto_ventum.update(persona_punto_ventum_params)\n format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona_punto_ventum }\n else\n format.html { render :edit }\n format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @persona }\n end\n end", "def show\n @pun = Pun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pun }\n end\n end", "def show\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ventas_presupuesto }\n end\n end", "def show\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pto }\n end\n end", "def destroy\n @punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id)\n @persona_punto_ventum.destroy\n respond_to do |format|\n format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n @paciente = @persona.perstable\n #aqui deben ir los datos del paciente tambien\n end", "def index\n @puntajes = Puntaje.order('created_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def show\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje }\n end\n end", "def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end", "def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end", "def show\n @unp = Unp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unp }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n @users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @personas = Persona.all\n @users = User.all\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def index\n @ventas_presupuestos = Ventas::Presupuesto.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ventas_presupuestos }\n end\n end", "def show\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n render json: @tipo_pregunta\n end", "def show\n @objet = Objet.find(params[:id])\n @personnage = @objet.personnage\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @objet }\n end\n end", "def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end", "def show\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje_mision }\n end\n end", "def tipospolen\n\n @info_polens = InfoPolen.collection.aggregate(\n { \"$group\" => { \"_id\" => \"$TIPOS_POLINICOS\" } },\n { \"$sort\" => {\"_id\" => 1} }\n )\n\n respond_to do |format|\n format.html #{ redirect_to info_polens_url }\n format.json { render json: @info_polens }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas }\n end\n end", "def show\n @vehicule_perso = VehiculePerso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vehicule_perso }\n end\n end", "def huertopublico\n @huerto = Huerto.find_by_agrupacion(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @huerto }\n end\n end", "def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end", "def show\n @alumno = Alumno.find(params[:id])\n\n render json: @alumno.as_json(include: :persona)\n end", "def show\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @premio }\n end\n end", "def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end", "def show\n @pologeno = Pologeno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pologeno }\n end\n end", "def index\n @tipos_personas = TipoPersona.all\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.json { render json: @persona }\n end\n end", "def show\n @personerium = Personerium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personerium }\n end\n end", "def show\n\t\t \t\tpersona = Persona.find(params[:id])\n\t\t \t\trender json: {status: 'SUCCESS', message:'Loaded persona', data:persona},status: :ok\n\t\t \tend", "def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end", "def show\n @controlpersona = Controlpersona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @controlpersona }\n end\n end", "def show\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @persona }\n format.json { render :json => @persona.to_json }\n end\n end", "def show\n @perfilnegocio = Perfilnegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfilnegocio }\n end\n end", "def new\n @pun = Pun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pun }\n end\n end", "def index\n @personas = Persona.all\n end", "def index\n @personas = Persona.all\n end", "def index\n @personas = Persona.all\n end", "def index\n @persona = Persona.find(params[:persona_id])\n @info_extra_paciente = @persona.info_extra_pacientes.all\n format.html { render :show }\n end", "def index\n\n @people = Person.filter(params.slice(:name_like))\n @people = @people.where([\"union_id = ?\", current_person.union_id]) if request.format.json? && !owner?\n @people = @people.where(\"not invited_by_id is null\").order([:last_name, :first_name, :id])\n \n respond_to do |format|\n format.html \n format.json \n end\n end", "def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end", "def 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 @pinglun = Pinglun.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pinglun }\n end\n end", "def show\n @person = people_type.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @person }\n end\n end", "def show\n @pruning = Pruning.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pruning }\n end\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 @personnage = Personnage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personnage }\n end\n end", "def index\n @protectoras = Protectora.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @protectoras }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def new\n @persona = Persona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @persona }\n end\n end", "def index\n @prueba_jsons = PruebaJson.all\n end", "def show\n @puestos_entidad = PuestosEntidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puestos_entidad }\n end\n end", "def show\n @persons_release = PersonsRelease.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persons_release }\n end\n end", "def show\n @partecipanti_gruppo = PartecipantiGruppo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipanti_gruppo }\n end\n end", "def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def show\n @person_info = PersonInfo.find(params[:id])\n\n render json: @person_info\n end", "def show\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n # format.html # show.html.erb\n format.json { render json: @pessoa }\n end\n end", "def index\n @type_people = TypePerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @type_people }\n end\n end", "def show\n @partecipante = Partecipante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipante }\n end\n end", "def index\n authorize! :index, Por, :message => 'Acceso denegado.'\n @pors = @campus.pors.paginate(:per_page => 3, :page => params[:page])\n\t\t@points = @pors\n\t\t@point_name = \"por\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render \"points/index.json.erb\" } # index.json.erb\n end\n end", "def show\n @patrocinio = Patrocinio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patrocinio }\n end\n end", "def show\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @persona_vinculada = PersonaVinculada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @persona_vinculada }\n end\n end", "def show\n @apunte = Apunte.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apunte }\n end\n end", "def index\n \t@people = Person.all\n respond_to do |format|\n format.json { render json: @people, status: :ok }\n end\n end", "def show\n \t@person = Person.find(params[:id])\n respond_to do |format|\n format.json { render json: @person, status: :ok }\t\n end \t \t\n end", "def show\n @perfil_transaccione = PerfilTransaccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @perfil_transaccione }\n end\n end", "def show\n @person = get_person(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @person }\n end\n end", "def show\n @person = get_person(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @person }\n end\n end", "def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end", "def index\n @personas_proyectos = PersonaProyecto.all\n end", "def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end", "def show\n respond_to do |format|\n people = @mob.user_idz.split(',').map{|i| User.find(i).name }.join(', ')\n format.json { render json: @mob.attributes.merge(people: people, users: @mob.users, date: Time.now.strftime('%-m/%-d/%Y')) }\n end\n end", "def index\n if params[:estado]\n @municipios = Uf.find(params[:estado]).municipios\n else\n @municipios = Uf.first.municipios\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end", "def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end", "def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end", "def show\n @person = Person.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @person }\n end\n end", "def show\n @profesor_pertenece_asignatura = ProfesorPerteneceAsignatura.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @profesor_pertenece_asignatura }\n end\n end", "def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end", "def get_pokemon_JSON\n r = \n {\n :p1 => JSON.parse(self.pokeserver(self.p1)), \n :p2 => JSON.parse(self.pokeserver(self.p2)), \n :p3 => JSON.parse(self.pokeserver(self.p3)), \n :p4 => JSON.parse(self.pokeserver(self.p4)), \n :p5 => JSON.parse(self.pokeserver(self.p5)), \n :p6 => JSON.parse(self.pokeserver(self.p6)) \n }\n \n JSON.generate(r)\n end", "def show\n @preguntum = Preguntum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preguntum }\n end\n end", "def index\n @people_tasks = TasksPerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @people_tasks }\n end\n end", "def show\n @uniprot = Uniprot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uniprot }\n end\n end", "def index\n @telefonos = @persona.telefonos.find(:all, :order => \"tipo ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @telefonos }\n end\n end", "def index\n @people = search Person.involved_in(@conference)\n\n respond_to do |format|\n format.html { @people = @people.paginate page: page_param }\n format.json\n end\n end", "def index\n @profesors = Profesor.all\n # if @profesors!= nil\n#render json: @profesors\n#else\n# @profesors= '{\"exito\",false,\"no se encontraron profesores\"}'\n\n render json: @profesors\n # end\n end", "def index\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @personas_vinculadas = PersonaVinculada.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @personas_vinculadas }\n end\n end", "def show\n @volunteer = Volunteer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volunteer }\n end\n end", "def show\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipomedalla }\n end\n end", "def show\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @territorio }\n end\n end" ]
[ "0.6965732", "0.6760657", "0.64742833", "0.6366154", "0.625891", "0.6249492", "0.62033063", "0.61494434", "0.603441", "0.6034205", "0.6033833", "0.6009075", "0.59869224", "0.59651387", "0.59385586", "0.5905865", "0.5905865", "0.58713806", "0.58698404", "0.5848847", "0.58486456", "0.582775", "0.58237356", "0.5809134", "0.57988554", "0.57822", "0.57549995", "0.57267386", "0.5725935", "0.5706799", "0.57018167", "0.5699256", "0.5681894", "0.5677718", "0.56332886", "0.5632147", "0.56260335", "0.5620493", "0.5610883", "0.5598159", "0.55912167", "0.5586037", "0.5573663", "0.5560357", "0.5560357", "0.5560357", "0.55589056", "0.555733", "0.5548351", "0.5547832", "0.5547324", "0.5534344", "0.5527071", "0.55268234", "0.55268186", "0.5522398", "0.55223215", "0.55223215", "0.55223215", "0.55198646", "0.55192727", "0.55143046", "0.55138654", "0.55131906", "0.5509777", "0.5509086", "0.5507084", "0.5501152", "0.5486876", "0.5484593", "0.54771566", "0.54695904", "0.54683226", "0.5465022", "0.5461981", "0.545587", "0.54537594", "0.54537594", "0.5449824", "0.5446951", "0.5441821", "0.54388165", "0.5435609", "0.5430099", "0.5430099", "0.5429907", "0.54298997", "0.5426122", "0.54211384", "0.54196465", "0.5417737", "0.54173785", "0.54152685", "0.5403184", "0.54017824", "0.53998846", "0.53925014", "0.5385263", "0.53850365", "0.5384826", "0.53840977" ]
0.0
-1
POST /persona_punto_venta POST /persona_punto_venta.json
def create @persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params) respond_to do |format| if @persona_punto_ventum.save format.html { redirect_to @persona_punto_ventum.punto_venta, notice: 'Persona punto ventum was successfully created.' } format.json { render :show, status: :created, location: @persona_punto_ventum } else format.html { render :new } format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end", "def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end", "def update\n respond_to do |format|\n if @persona_punto_ventum.update(persona_punto_ventum_params)\n format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona_punto_ventum }\n else\n format.html { render :edit }\n format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ventas_presupuesto = Ventas::Presupuesto.new(params[:ventas_presupuesto])\n @ventas_presupuesto.vendedor = current_user.id\n\n respond_to do |format|\n if @ventas_presupuesto.save\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully created.' }\n format.json { render json: @ventas_presupuesto, status: :created, location: @ventas_presupuesto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id)\n @persona_punto_ventum.destroy\n respond_to do |format|\n format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @reuniao = Reuniao.new(reuniao_params)\n @pautum=Pautum.new\n @reuniao.pautum =@pautum\n @reuniao.atum=Atum.new\n @reuniao.status=\"Preparação\"\n @pautum.status=\"Preparação\"\n \n respond_to do |format|\n if @reuniao.save\n @pautum.titulo=@reuniao.titulo\n @pautum.save\n format.html { redirect_to @reuniao, notice: 'Reuniao was successfully created.' }\n format.json { render :show, status: :created, location: @reuniao }\n else\n format.html { render :new }\n format.json { render json: @reuniao.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @persona_punto_venta = PersonaPuntoVentum.all\n end", "def create\n\n @vendedor = Vendedor.new(vendedor_params)\n if vendedor_params[\"punto_venta_id\"].nil?\n @vendedor.punto_venta_id = current_user.punto_venta_id\n end\n if current_user.punto_venta.vendedors.order(:avance).last == nil\n @vendedor.avance = 1\n else\n @vendedor.avance = current_user.punto_venta.vendedors.order(:avance).last.avance.to_i + 1\n end\n \n if Persona.where(:cuit => params[:persona][:cuit]).first == nil\n @persona = Persona.new(persona_params)\n else\n @persona= Persona.where(:cuit => params[:persona][:cuit]).first\n @persona.tipo_documento_id=params[:persona][:tipo_documento_id]\n @persona.numero_documento=params[:persona][:numero_documento]\n @persona.apellido=params[:persona][:apellido]\n @persona.nombre=params[:persona][:nombre]\n @persona.domicilio=params[:persona][:domicilio]\n @persona.telefono=params[:persona][:telefono]\n @persona.fecha_nacimiento=params[:persona][:fecha_nacimiento]\n @persona.email=params[:persona][:email]\n end\n \n \n #el numero de vendedor debe ser unico\n respond_to do |format|\n if @persona.save\n @vendedor.persona_id=@persona.id\n if @vendedor.save\n\n if @vendedor.persona.user != nil and @vendedor.persona.user.has_role? :punto_venta\n format.html { redirect_to current_user.punto_venta, notice: 'Vendedor creado.' }\n\n else\n format.html { redirect_to @vendedor, notice: 'Vendedor creado..' }\n format.json { render :show, status: :created, location: @vendedor }\n end\n \n else\n if @persona.user != nil and @persona.user.has_role? :punto_venta\n flash[:error] = @vendedor.errors.messages.first[1][0]\n \n format.html { redirect_to vendedor_cambiar_rol_path(persona: @persona.id)} \n format.json { render json: @vendedor.errors, status: :unprocessable_entity }\n else\n format.html { render :new }\n format.json { render json: @vendedor.errors, status: :unprocessable_entity }\n end\n end\n else\n if @persona.user != nil and @persona.user.has_role? :punto_venta\n flash[:error] = @persona.errors.messages.first[1][0]\n \n format.html { redirect_to vendedor_cambiar_rol_path(persona: @persona.id)} \n format.json { render json: @persona.errors, status: :unprocessable_entity }\n else\n format.html { render :new }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n \n end\n end", "def create\n @punto = Punto.new(punto_params)\n @punto.creador = current_user.id\n @punto.modificador = current_user.id\n\n respond_to do |format|\n if @punto.save\n format.html { redirect_to @punto, notice: 'Punto was successfully created.' }\n format.json { render :show, status: :created, location: @punto }\n else\n format.html { render :new }\n format.json { render json: @punto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pun = Pun.new(params[:pun])\n\n respond_to do |format|\n if @pun.save\n format.html { redirect_to @pun, notice: 'Pun was successfully created.' }\n format.json { render json: @pun, status: :created, location: @pun }\n # format.js { render :action => 'ajax/pun_create' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pun.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estado_persona = EstadoPersona.new(estado_persona_params)\n @estado_persona.estado_id = params[:estado_persona][:estado_id]\n @estado_persona.vendedor_id = params[:estado_persona][:vendedor_id]\n @estado_persona.fecha_inicio = params[:estado_persona][:fecha_inicio]\n\n respond_to do | format|\n if @estado_persona.save\n format.html { redirect_to @estado_persona, notice: 'Estado creado con exito.' }\n format.json { render :show, status: :created, location: @estado_persona }\n else\n format.html { render :new }\n format.json { render json: @estado_persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #params[:estudiante][:persona] = Persona.find_by_nombre_completo(params[:estudiante][:persona])\n @estudiante = Estudiante.new(params[:estudiante])\n\n # Asociar persona a estudiante\n #begin\n @estudiante.persona_id = params[:persona][:id]\n #rescue\n #end\n\n respond_to do |format|\n if @estudiante.save\n format.html { redirect_to @estudiante, notice: 'Estudiante creado' }\n format.json { render json: @estudiante, status: :created, location: @estudiante }\n else\n format.html { render action: \"new\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end", "def create\n @persona = Persona.new(params[:persona])\n \n respond_to do |format|\n if @persona.save\n format.json { render :json => @persona,\n :status => :created, :location => @persona }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def create\n @paciente = Paciente.new(paciente_params)\n @persona = @paciente.personas.new(persona_params)\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to pacientes_url, notice: 'Datos del paciente fueron guardados' }\n else\n format.html { render :new }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def punto_params\n params.require(:punto).permit(:activo, :modificador, :creador, :descripcion, :puntos, :tipo, :punteado)\n end", "def create\n @puntaje = Puntaje.new(params[:puntaje])\n\n respond_to do |format|\n if @puntaje.save\n format.html { redirect_to @puntaje, notice: 'El puntaje ha sido registrado con exito. ' }\n CustomLogger.info(\"Un nuevo puntaje: #{@puntaje.puntaje.to_i.inspect} correspondiente a la tarea: #{@puntaje.planificacion_tarea.inspect} del alumno: #{@puntaje.alumno.user_full_name.inspect} , Descripcion:#{@puntaje.descripcion.inspect} ha sido registrado por el usuario: #{current_user.full_name.inspect}, #{Time.now}\")\n format.json { render json: @puntaje, status: :created, location: @puntaje }\n else\n atributos\n format.html { render action: \"new\" }\n CustomLogger.error(\"Se ha producido un error al querer registrar el puntaje: #{@puntaje.puntaje.to_i.inspect} y sus demas atributos, por el usuario: #{current_user.full_name.inspect}, #{Time.now}\")\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pregoestitulo = Pregoestitulo.new(pregoestitulo_params)\n\n pregao = Pregao.where('data = ?', @pregoestitulo.date).first\n\n if pregao.blank?\n pregao = Pregao.new\n pregao.data = @pregoestitulo.date\n pregao.flagativo = true\n pregao.save\n end\n\n @pregoestitulo.pregao_id = pregao.id\n\n respond_to do |format|\n if @pregoestitulo.save\n format.html { redirect_to @pregoestitulo, notice: 'Título incluído com sucesso.' }\n format.json { render :show, status: :created, location: @pregoestitulo }\n else\n format.html { render :new }\n format.json { render json: @pregoestitulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end", "def create\n @persona = Persona.new(params[:persona])\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to @persona, notice: 'la Persona fue creada exitosamente.' }\n format.json { render json: @persona, status: :created, location: @persona }\n else\n format.html { render action: \"new\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @votacion = Votacion.new(votacion_params)\n @votacion.etapa = \"Previa a la votación.\"\n respond_to do |format|\n if @votacion.save\n format.html { redirect_to @votacion, notice: 'La votación se creo correctamente.' }\n format.json { render :show, status: :created, location: @votacion }\n else\n format.html { render :new }\n format.json { render json: @votacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts 'AQQQQQUUUUUUUIIIIII'\n json = ActiveSupport::JSON.decode(params[:pessoa])\n puts json\n @pessoa = Pessoa.new(json)\n # @address = Address.new(params[:address])\n\n # @client.addresses = @address\n\n respond_to do |format|\n if @pessoa.save\n format.html { redirect_to @pessoa, notice: 'Pessoa was successfully created.' }\n format.json { render json: @pessoa, status: :created, location: @pessoa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def punish_params\n params.require(:punish).permit(:name, :faults, :fault_date, :status, :complete_date)\n end", "def create\n @palabra = Palabra.new(params[:palabra])\n @palabra.significados = params[:significados] \n respond_to do |format|\n if @palabra.save\n format.html { redirect_to @palabra, notice: 'La palabra fue guardada correctamente.' }\n format.json { render json: @palabra, status: :created, location: @palabra }\n else\n format.html { render action: \"new\" }\n format.json { render json: @palabra.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pocetna = Pocetna.new(pocetna_params)\n\n respond_to do |format|\n if @pocetna.save\n format.html { redirect_to @pocetna, notice: \"Pocetna was successfully created.\" }\n format.json { render :show, status: :created, location: @pocetna }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @pocetna.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_ventum = TipoVentum.new(tipo_ventum_params)\n\n respond_to do |format|\n if @tipo_ventum.save\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_ventum }\n else\n format.html { render :new }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @puntaje = Puntaje.new(params[:puntaje])\n\n respond_to do |format|\n if @puntaje.save\n format.html { redirect_to @puntaje, notice: 'Puntaje was successfully created.' }\n format.json { render json: @puntaje, status: :created, location: @puntaje }\n else\n atributos\n format.html { render action: \"new\" }\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @przedmiot = Przedmiot.new(params[:przedmiot])\n @przedmiot.user_id = current_user.id\n respond_to do |format|\n if @przedmiot.save\n format.html { redirect_to @przedmiot, notice: 'Przedmiot został dodany.' }\n format.json { render json: @przedmiot, status: :created, location: @przedmiot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @przedmiot.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_persona = TipoPersona.new(tipo_persona_params)\n\n respond_to do |format|\n if @tipo_persona.save\n format.html { redirect_to @tipo_persona, notice: 'Tipo persona was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_persona }\n else\n format.html { render :new }\n format.json { render json: @tipo_persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evento = Evento.new(evento_params)\n @evento.usuario_curso_id = @perfil.id\n respond_to do |format|\n if @evento.save\n ApplicationMailer.novo_evento(@evento).deliver \n format.html { redirect_to @evento, notice: 'Evento cadastrado com sucesso!' }\n format.json { render :show, status: :created, location: @evento }\n else\n format.html { render :new }\n format.json { render json: @evento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona = Persona.new(params[:persona])\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to @persona, notice: 'Persona was successfully created.' }\n format.json { render json: @persona, status: :created, location: @persona }\n else\n format.html { render action: \"new\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # Crear nuevo voto\n @voto = Voto.new(params[:voto])\n\n # Asociarlo con el usuario\n @voto.usuario_id = current_usuario.id\n\n # Asociarlo con la Pregunta o Respuesta\n votable_type = params[:voto][:votable_type]\n votable_id = params[:voto][:votable_id]\n if votable_type=='Pregunta'\n @voto.votable = Pregunta.find(votable_id)\n else\n @voto.votable = Respuesta.find(votable_id)\n end\n\n respond_to do |format|\n if @voto.save\n resp = {\n :votos_total => @voto.votable.votos_total,\n :votos_menos => @voto.votable.votos_menos,\n :votos_mas => @voto.votable.votos_mas\n }\n format.json { render json: resp, status: :created, location: @voto }\n else\n format.json { render json: @voto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ponte = Ponte.new(ponte_params)\n\n respond_to do |format|\n if @ponte.save\n format.html { redirect_to pontes_url, notice: 'Ponte criada com sucesso.' }\n format.json { render :show, status: :created, location: @ponte }\n else\n format.html { render :new }\n format.json { render json: @ponte.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ponderacion = Ponderacion.new(ponderacion_params)\n\n respond_to do |format|\n if @ponderacion.save\n format.html { redirect_to @ponderacion, notice: 'Ponderacion was successfully created.' }\n format.json { render :show, status: :created, location: @ponderacion }\n else\n format.html { render :new }\n format.json { render json: @ponderacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tomaturno = Tomaturno.new(tomaturno_params)\n\n respond_to do |format|\n if @tomaturno.save\n format.html { redirect_to @tomaturno, notice: 'Tomaturno was successfully created.' }\n format.json { render :show, status: :created, location: @tomaturno }\n else\n format.html { render :new }\n format.json { render json: @tomaturno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @prueba = Prueba.new(prueba_params)\n\n cantidadAlmacenada = @prueba.cantidad_almacenada\n cantidadDesechada = @prueba.cantidad_desechada\n\n @prueba.cantidad = cantidadAlmacenada + cantidadDesechada \n\n respond_to do |format|\n if @prueba.save\n\n @etiqueta = Etiqueta.new\n\n etiquetaAnalisis = @prueba.etiqueta.etiqueta\n idAnalisis = @prueba.id\n idAnalisisString = idAnalisis.to_s\n\n @etiqueta.etiqueta = etiquetaAnalisis + idAnalisisString + \"-\"\n @etiqueta.formato_id = 2\n @etiqueta.save\n\n format.html { redirect_to etiqueta_mostrar_path(@etiqueta.id), notice: 'Prueba was successfully created.' }\n format.json { render :show, status: :created, location: @prueba }\n else\n format.html { render :new }\n format.json { render json: @prueba.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @actividad = Actividad.new(params[:actividad])\n respond_to do |format|\n if @actividad.save \n @actividad.visitadors.each do |v|\n pu = PuntuacionesActividad.new(:actividad_id => @actividad.id, :visitador_id => v.id, :puntuacion => @actividad.puntuacion)\n pu.save\n end\n format.html { redirect_to @actividad, notice: 'Actividad was successfully created.' }\n format.json { render json: @actividad, status: :created, location: @actividad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @actividad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ventaganancium = Ventaganancium.new(ventaganancium_params)\n\n respond_to do |format|\n if @ventaganancium.save\n format.html { redirect_to @ventaganancium, notice: 'Ventaganancium was successfully created.' }\n format.json { render :show, status: :created, location: @ventaganancium }\n else\n format.html { render :new }\n format.json { render json: @ventaganancium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unp = Unp.new(params[:unp])\n\n respond_to do |format|\n if @unp.save\n format.html { redirect_to @unp, notice: 'Unp was successfully created.' }\n format.json { render json: @unp, status: :created, location: @unp }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pto = Pto.new(params[:pto])\n\n respond_to do |format|\n if @pto.save\n format.html { redirect_to \"/thanks.html\", notice: 'Pto was successfully created.' }\n format.json { render json: @pto, status: :created, location: @pto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vehicule_perso = VehiculePerso.new(params[:vehicule_perso])\n\n respond_to do |format|\n if @vehicule_perso.save\n format.html { redirect_to @vehicule_perso, :notice => 'Le véhicule personnel a bien été ajouté' }\n format.json { render :json => @vehicule_perso, :status => :created, :location => @vehicule_perso }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @vehicule_perso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @basico_persona_juridica = Basico::PersonaJuridica.new(basico_persona_juridica_params)\n\n respond_to do |format|\n if @basico_persona_juridica.save\n format.html { redirect_to @basico_persona_juridica, notice: 'Persona juridica was successfully created.' }\n format.json { render :show, status: :created, location: @basico_persona_juridica }\n else\n format.html { render :new }\n format.json { render json: @basico_persona_juridica.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona = Persona.find(params[:persona_id])\n @info_extra_paciente = @persona.info_extra_pacientes.new(info_extra_paciente_params)\n respond_to do |format|\n if @info_extra_paciente.save\n format.html { redirect_to @persona, notice: 'Informacion de Contacto agregada.' }\n format.json { render :show, status: :created, location: @persona }\n else\n format.html { render :new }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ventum = Ventum.new(ventum_params)\n @ventum.estado =false\n respond_to do |format|\n if @ventum.save\n format.html { redirect_to @ventum, notice: 'Ventcreada satisfactoriamente.' }\n format.json { render :show, status: :created, location: @ventum }\n else\n format.html { render :new }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @venta = Venta.new(params[:venta])\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render json: @venta, status: :created, location: @venta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @alumno = Alumno.new(params[:alumno])\n\n respond_to do |format|\n if @alumno.save\n render json: @alumno.as_json(include: :persona), status: :created, location: @alumno\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end", "def create\n @pouzivatel = Pouzivatel.new(pouzivatel_params)\n\n respond_to do |format|\n if @pouzivatel.save\n format.html { redirect_to @pouzivatel, notice: 'Pouzivatel was successfully created.' }\n format.json { render :show, status: :created, location: @pouzivatel }\n else\n format.html { render :new }\n format.json { render json: @pouzivatel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pago = Pago.new(params[:pago])\n\n respond_to do |format|\n if @pago.save\n format.html { render :text => @pago.attributes.merge( :saldo => @pago.saldo ).to_json }\n format.xml { render :xml => @pago, :status => :created, :location => @pago }\n else\n format.html { render :action => \"new\", :status => :unprocessable_entity }\n format.xml { render :xml => @pago.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n tp = tumor_params\n tp[:tipo_tumor], ad, p = tipo(tp)\n if p == nil\n p=0\n end\n @tumor = Tumor.new(tp)\n respond_to do |format|\n if @tumor.save\n format.html { redirect_to @tumor, notice: 'Se registro con exito con tipo de tumor => '+tp[:tipo_tumor].capitalize+\n '.<>Arbol de decision:<>'+\n ad+'<>Con un grado de acierto de: '+\n p.to_s+\n ' y un porcentaje de acierto de 83.19%' }\n format.json { render :show, status: :created, location: @tumor }\n else\n format.html { render :new }\n format.json { render json: @tumor.errors, status: :unprocessable_entity }\n end\n end\n end", "def tpevent_params\n params.require(:tpevent).permit(:name)\n end", "def create\n @pergunta = @topico.perguntas.new(pergunta_params)\n\n respond_to do |format|\n if @pergunta.save\n format.html { redirect_to set_path, notice: 'Pergunta criada com sucesso.' }\n format.json { render action: 'show', status: :created, location: @pergunta }\n else\n format.html { render action: 'new' }\n format.json { render json: @pergunta.errors, status: :unprocessable_entity }\n end\n end\n end", "def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end", "def create\n @profesor = Profesor.new(profesor_params)\n\n if @profesor.save\n render json: @profesor, status: :created, location: @profesor\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end", "def peso_params\n params.require(:peso).permit(:fecha, :peso, :usuario_id)\n end", "def create\n @persona = Persona.new(persona_params)\n\n respond_to do |format|\n if @persona.save\n format.html { redirect_to @persona, notice: 'Datos personales registrados exitosamente.' }\n format.json { render :show, status: :created, location: @persona }\n else\n format.html { render :new }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @puesto = Puesto.new(puesto_params)\n\n respond_to do |format|\n if @puesto.save\n format.html { redirect_to @puesto, notice: 'Puesto Creado.' }\n format.json { render :show, status: :created, location: @puesto }\n else\n format.html { render :new }\n format.json { render json: @puesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def provedor_params\n params.require(:provedor).permit(:uf, :municipio, :microRegiao, :razaoSocial, :numAto, :termo, :endereco, :telefone)\n end", "def create\n\t\n\t@precio_boleto = PrecioBoleto.new(precio_boleto_params)\n\n\trespond_to do |format|\n\tif @precio_boleto.save\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Nuevo Precio de boleto fue creado exitosamente.' }\n\t\tformat.json { render action: 'show', status: :created, location: @precio_boleto }\n\telse\n\t\tformat.html { render action: 'new' }\n\t\tformat.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n\tend\n\tend\nend", "def create\n @pru = Pru.new(pru_params)\n\n respond_to do |format|\n if @pru.save\n format.html { redirect_to @pru, notice: 'Pru was successfully created.' }\n format.json { render :show, status: :created, location: @pru }\n else\n format.html { render :new }\n format.json { render json: @pru.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @persona = Persona.find(params[:persona_id])\n @persona_nota_seguimiento = PersonaNotaSeguimiento.new(persona_nota_seguimiento_params)\n @persona_nota_seguimiento.persona = @persona\n @persona_nota_seguimiento.usuario = current_usuario\n if @persona_nota_seguimiento.save\n redirect_to @persona, notice: 'Guardado Correctamente.'\n else\n render :new\n end\n end", "def create\n @puestos_entidad = PuestosEntidad.new(params[:puestos_entidad])\n\n respond_to do |format|\n if @puestos_entidad.save\n format.html { redirect_to @puestos_entidad, notice: 'Puestos entidad was successfully created.' }\n format.json { render json: @puestos_entidad, status: :created, location: @puestos_entidad }\n else\n format.html { render action: \"new\" }\n format.json { render json: @puestos_entidad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n session[:empresa_id] = current_empressa.try(:empresa_id)\r\n \r\n @oportunidade = Oportunidade.new(oportunidade_params)\r\n \r\n respond_to do |format|\r\n if @oportunidade.save\r\n ahoy.track \"Oportunidade Criada\", {language: \"Ruby\", curso: @oportunidade.curso, created_at: @oportunidade.created_at}\r\n format.html { redirect_to oportunidades_path(@oportunidade, empresa_id: @oportunidade.empresa_id), notice: 'Oportunidade criada com sucesso.' }\r\n format.json { render oportunidades_path, status: :created, location: @oportunidade }\r\n else\r\n session[:pidioma]=@oportunidade.pidioma\r\n session[:ptipo]=@oportunidade.ptipo\r\n format.html { render :new, locals: { pidioma: @oportunidade.pidioma, ptipo: @oportunidade.ptipo}}\r\n format.json { render json: @oportunidade.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @precio_boleto = PrecioBoleto.new(precio_boleto_params)\n\n respond_to do |format|\n if @precio_boleto.save\n format.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully created.' }\n format.json { render action: 'show', status: :created, location: @precio_boleto }\n else\n format.html { render action: 'new' }\n format.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipocuentum = Tipocuentum.new(tipocuentum_params)\n\n respond_to do |format|\n if @tipocuentum.save\n format.html { redirect_to @tipocuentum, notice: 'Tipocuentum was successfully created.' }\n format.json { render :show, status: :created, location: @tipocuentum }\n else\n format.html { render :new }\n format.json { render json: @tipocuentum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @folevent = Folevent.new(folevent_params)\n\n respond_to do |format|\n if @folevent.save\n format.html { redirect_to :back, notice: 'Vous suivez desormais cette événement' }\n format.json { render :show, status: :created, location: @folevent }\n else\n format.html { render :back }\n format.json { render json: @folevent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipotermo = Tipotermo.new(tipotermo_params)\n\n respond_to do |format|\n if @tipotermo.save\n format.html { redirect_to @tipotermo, notice: 'Tipotermo was successfully created.' }\n format.json { render :show, status: :created, location: @tipotermo }\n else\n format.html { render :new }\n format.json { render json: @tipotermo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pologeno = Pologeno.new(params[:pologeno])\n\n respond_to do |format|\n if @pologeno.save\n format.html { redirect_to @pologeno, notice: 'Pologeno was successfully created.' }\n format.json { render json: @pologeno, status: :created, location: @pologeno }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pologeno.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pedidos_has_prato = PedidosHasPrato.new(pedidos_has_prato_params)\n\n respond_to do |format|\n if @pedidos_has_prato.save\n format.html { redirect_to @pedidos_has_prato, notice: 'Pedidos has prato was successfully created.' }\n format.json { render :show, status: :created, location: @pedidos_has_prato }\n else\n format.html { render :new }\n format.json { render json: @pedidos_has_prato.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @concepto_de_pago = ConceptoDePago.new(concepto_de_pago_params)\n #@plazo = @concepto_de_pago.diferencia \n # @concepto_de_pago.plazoRecordatorio = Chronic.parse(@concepto_de_pago.diferencia, :now => @concepto_de_pago.fechaVencimiento)\n\n respond_to do |format|\n if @concepto_de_pago.save\n format.html { redirect_to @concepto_de_pago, notice: 'Concepto de pago fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @concepto_de_pago }\n else\n format.html { render :new }\n format.json { render json: @concepto_de_pago.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @post = Post.create(post_params)\n puts \"LLLLLOOOOOOOLLLLLL\"\n puts current_usuario.to_json\n @post = current_usuario.posts.create(post_params)\n \n @post.sangre = current_usuario.tipoDeSangre\n\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, :notice => 'Premio was successfully created.' }\n format.json { render :json => @premio, :status => :created, :location => @premio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_pensum = TipoPensum.new(params[:tipo_pensum])\n\n respond_to do |format|\n if @tipo_pensum.save\n format.html { redirect_to @tipo_pensum, notice: 'Tipo pensum was successfully created.' }\n format.json { render json: @tipo_pensum, status: :created, location: @tipo_pensum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_pensum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dia_evento = DiaEvento.new(dia_evento_params)\n\n if @dia_evento.save\n render json: @dia_evento, status: :created, location: @dia_evento\n else\n render json: @dia_evento.errors, status: :unprocessable_entity\n end\n end", "def create\n @servico_evento = Servico::Evento.new(servico_evento_params)\n\n respond_to do |format|\n if @servico_evento.save\n format.html { redirect_to @servico_evento, notice: 'Evento was successfully created.' }\n format.json { render action: 'show', status: :created, location: @servico_evento }\n else\n format.html { render action: 'new' }\n format.json { render json: @servico_evento.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_punto\n @punto = Punto.find(params[:id])\n end", "def create\n @peticion_servicio_ti = Peticion::ServicioTi.new(params[:peticion_servicio_ti])\n\n respond_to do |format|\n if @peticion_servicio_ti.save\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Guardado Correctamente.' }\n format.json { render json: @peticion_servicio_ti, status: :created, location: @peticion_servicio_ti }\n else\n format.html { render action: \"new\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pet = Pet.find(params[:id]) \n @solicitud = Solicitud.new(solicitud_params)\n @solicitud.id = current_user.id \n @solicitud.id_pet = @pet.id\n respond_to do |format|\n if @solicitud.save\n solicitud = Solicitud.find(@solicitud.id)\n user = User.find(current_user.id)\n #user.follow(solicitud) Esto no porque crea tuplas duplicadas y mal en followers\n format.html { redirect_to @solicitud, notice: 'Tu solicitud ha sido guardada' }\n format.json { render :show, status: :created, location: @solicitud }\n else\n format.html { render :new }\n format.json { render json: @solicitud.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tiponovedad = Tiponovedad.new(tiponovedad_params)\n\n respond_to do |format|\n if @tiponovedad.save\n format.html { redirect_to @tiponovedad, notice: 'Tiponovedad was successfully created.' }\n format.json { render :show, status: :created, location: @tiponovedad }\n else\n format.html { render :new }\n format.json { render json: @tiponovedad.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n id = current_user.uid\n @percorso = Percorso.find(params[:percorso])\n @partecipanti = Partecipanti.new(percorso: @percorso.id, utente: id)\n\n respond_to do |format|\n if @partecipanti.save\n conn = Bunny.new\n conn.start\n ch = conn.create_channel\n x = ch.topic(\"#{@percorso.id}\")\n queue = ch.queue(\"#{@percorso.id}#{id}\")\n queue.bind(x, :routing_key => \"all\")\n queue.bind(x, :routing_key => \"#{id}\")\n ch.close\n conn.close\n format.html { redirect_to percorso_path(percorso), notice: 'Adesso fai parte di questo percorso!.' }\n format.js {}\n format.json { render :show, status: :created, location: @partecipanti }\n else\n format.html { render :new }\n format.json { render json: @partecipanti.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nota_progreso = NotaProgreso.new(nota_progreso_params)\n \n @nota_progreso.historia_clinica_id = @historia_clinica.id\n\n\n\n\n respond_to do |format|\n if @nota_progreso.save\n format.html { redirect_to paciente_historia_clinica_nota_progreso_path(@paciente, @historia_clinica, @nota_progreso), notice: 'Nota de Evolución creada Satisfactoriamente.' }\n\n format.json { render :show, status: :created, location: @nota_progreso }\n else\n format.html { render :new }\n format.json { render json: @nota_progreso.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @panneau = Panneau.new(panneau_params)\n\n respond_to do |format|\n if @panneau.save\n format.html { redirect_to @panneau, notice: 'Panneau was successfully created.' }\n format.json { render :show, status: :created, location: @panneau }\n else\n format.html { render :new }\n format.json { render json: @panneau.errors, status: :unprocessable_entity }\n end\n end\n end", "def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end", "def pouzivatel_params\n params.require(:pouzivatel).permit(:nick, :heslo)\n end", "def create\n @tipovestuario = Tipovestuario.new(tipovestuario_params)\n\n respond_to do |format|\n if @tipovestuario.save\n format.html { redirect_to @tipovestuario, notice: 'Tipovestuario was successfully created.' }\n format.json { render :show, status: :created, location: @tipovestuario }\n else\n format.html { render :new }\n format.json { render json: @tipovestuario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipomedalla = Tipomedalla.new(params[:tipomedalla])\n\n respond_to do |format|\n if @tipomedalla.save\n format.html { redirect_to @tipomedalla, notice: 'Tipomedalla was successfully created.' }\n format.json { render json: @tipomedalla, status: :created, location: @tipomedalla }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipomedalla.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @venta = Venta.new(venta_params)\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render :show, status: :created, location: @venta }\n else\n format.html { render :new }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @estadia = Estadia.new(estadia_params)\n\n #Quando cria uma estadia nova, seta a data como a hora corrente\n @estadia.data_entrada = Time.now\n #ocupa a vaga\n @estadia.vaga.ocupada = true\n\n respond_to do |format|\n if @estadia.vaga.save && @estadia.save\n format.html { redirect_to @estadia, notice: 'Estadia was successfully created.' }\n format.json { render :show, status: :created, location: @estadia }\n else\n format.html { render :new }\n format.json { render json: @estadia.errors, status: :unprocessable_entity }\n end\n end\n end", "def ponte_params\n params.require(:ponte).permit(:descricao, :geom)\n end", "def create\n @vrsta_inventara = VrstaInventara.new(vrsta_inventara_params)\n\n respond_to do |format|\n if @vrsta_inventara.save\n format.html { redirect_to vrsta_inventaras_url, notice: 'Vrsta inventara je uspješno stvorena.' }\n format.json { render :show, status: :created, location: @vrsta_inventara }\n else\n format.html { render :new }\n format.json { render json: @vrsta_inventara.errors, status: :unprocessable_entity }\n end\n end\n end", "def persona_params\n params.require(:persona).permit(:pers_documentoIdentidad, :pers_nombres, :pers_apellidos, :pers_alias, :pers_sexo, :pers_pesoCorporal, :pers_paisOrigen, :pers_fechaNacimiento, :pers_estadoCivil, :pers_direccionDomicilio, :pers_ciudadDomicilio, :pers_telefonoPersonal1, :pers_telefonoPersonal2, :pers_correoElectrPersonal, :pers_correoElectrLaboral, :pers_perfilLaboral, :sucursalEmpresaId, :empresaCargo, :pers_telefonoLaboral1, :pers_telefonoLaboral2, :pers_estadoRegistro)\n end", "def create\n @panneau = Panneau.new(panneau_params)\n\n respond_to do |format|\n if @panneau.save\n format.html { redirect_to \"/panneaus?editable=true&ville=#{@panneau.ville}\", notice: 'Panneau was successfully created.' }\n format.json { render :show, status: :created, location: @panneau }\n else\n format.html { render :new }\n format.json { render json: @panneau.errors, status: :unprocessable_entity }\n end\n end\n end", "def painel_params\n params.require(:painel).permit(:nome_app, :tipo_evento, :qtd_evento)\n end", "def create\n @statuspagamento = Statuspagamentoe.new(params[:statuspagamentoe])\n\n respond_to do |format|\n if @statuspagamento.save\n format.html { redirect_to @statuspagamento, notice: 'Statuspagamentoe was successfully created.' }\n format.json { render json: @statuspagamento, status: :created, location: @statuspagamento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @statuspagamento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @depoevento = Depoevento.new(params[:depoevento])\n\n respond_to do |format|\n if @depoevento.save\n format.html { redirect_to @depoevento, notice: 'Depoevento was successfully created.' }\n format.json { render json: @depoevento, status: :created, location: @depoevento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @depoevento.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @platoon = Platoon.new(platoon_params)\n\n respond_to do |format|\n if @platoon.save\n format.html { redirect_to @platoon, notice: 'Platoon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @platoon }\n else\n format.html { render action: 'new' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @premio = Premio.new(params[:premio])\n\n respond_to do |format|\n if @premio.save\n format.html { redirect_to @premio, notice: 'Premio was successfully created.' }\n format.json { render json: @premio, status: :created, location: @premio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @venta = Venta.new(venta_params)\n @venta.libro_venta_id = @l_ventas.id\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to new_venta_path, notice: 'Venta was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @notadedebito = Notadedebito.find(params[:notadedebito_id])\n @renglon_notadebito = @notadedebito.renglon_notadebitos.create(params[:renglon_notadebito])\n\n respond_to do |format|\n if @renglon_notadebito.save\n format.html { redirect_to @notadebito, notice: 'Renglon notadebito was successfully created.' }\n format.json { render json: @renglon_notadebito}\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_notadebito.errors}\n end\n end\n end", "def create\n @protectora = Protectora.new(params[:protectora])\n\n respond_to do |format|\n if @protectora.save\n format.html { redirect_to @protectora, notice: 'Protectora was successfully created.' }\n format.json { render json: @protectora, status: :created, location: @protectora }\n else\n format.html { render action: \"new\" }\n format.json { render json: @protectora.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @os_tarefa = OsTarefa.new(os_tarefa_params)\n\n respond_to do |format|\n if @os_tarefa.save\n if @os_tarefa.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_tarefa.ordem_servico.id.to_s, notice: 'A Tarefa foi criado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_tarefa, notice: 'A Tarefa foi criado(a)' }\n format.json { render :show, status: :created, location: @os_tarefa }\n end\n else\n format.html { render :new }\n format.json { render json: @os_tarefa.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7436393", "0.7049305", "0.6603138", "0.6143716", "0.60707164", "0.59953636", "0.595887", "0.59437424", "0.5839788", "0.575266", "0.57334405", "0.5713411", "0.5705717", "0.56932175", "0.5684104", "0.56136143", "0.5607358", "0.559614", "0.5584539", "0.55763674", "0.5553745", "0.554812", "0.5545984", "0.5529878", "0.5518464", "0.5507438", "0.54735446", "0.5469144", "0.5468787", "0.5463533", "0.5458807", "0.54583174", "0.54467326", "0.5443389", "0.54339695", "0.54272", "0.5421769", "0.54184204", "0.54111236", "0.5408283", "0.5405738", "0.54045576", "0.5401446", "0.5393744", "0.53909665", "0.5389756", "0.53874546", "0.53793764", "0.53685516", "0.5368322", "0.5367909", "0.536512", "0.5364888", "0.53582054", "0.53475463", "0.53427523", "0.5334718", "0.5332304", "0.53318506", "0.5325121", "0.53250957", "0.53224534", "0.53191155", "0.53103286", "0.53077346", "0.5297389", "0.5297189", "0.5295676", "0.52927315", "0.5290599", "0.5287183", "0.5282885", "0.5282283", "0.5275367", "0.52705383", "0.5267808", "0.5262514", "0.52625006", "0.5259533", "0.5258023", "0.52558076", "0.52557784", "0.5245055", "0.5244908", "0.5244598", "0.5242838", "0.5241033", "0.52359986", "0.52319515", "0.52315146", "0.52292615", "0.5228202", "0.52247983", "0.522328", "0.52215266", "0.52214426", "0.52193415", "0.521902", "0.5216413", "0.5211193" ]
0.7563744
0
PATCH/PUT /persona_punto_venta/1 PATCH/PUT /persona_punto_venta/1.json
def update respond_to do |format| if @persona_punto_ventum.update(persona_punto_ventum_params) format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' } format.json { render :show, status: :ok, location: @persona_punto_ventum } else format.html { render :edit } format.json { render json: @persona_punto_ventum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to personas_path, notice: 'Persona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona_tipo = PersonaTipo.find(params[:id])\n\n respond_to do |format|\n if @persona_tipo.update_attributes(params[:persona_tipo])\n format.html { redirect_to @persona_tipo, notice: 'Tipo de participante actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_persona.update(tipo_persona_params)\n format.html { redirect_to @tipo_persona, notice: 'Tipo persona was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_persona }\n else\n format.html { render :edit }\n format.json { render json: @tipo_persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona.update(persona_params)\n format.html { redirect_to @persona, notice: 'Persona was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona }\n else\n format.html { render :edit }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona.update(persona_params)\n format.html {redirect_to personas_url, notice: 'Persona was successfully updated.'}\n format.json {render :show, status: :ok, location: @persona}\n else\n format.html {render :edit}\n format.json {render json: @persona.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @persona.update(persona_params)\n format.html { redirect_to @persona, notice: 'Datos personales actualizados exitosamente.' }\n format.json { render :show, status: :ok, location: @persona }\n else\n format.html { render :edit }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #parametros_autocomplete!(params[:estudiante][:persona])\n @estudiante = Estudiante.find(params[:id])\n \n begin\n @estudiante.persona_id = params[:persona][:id]\n rescue\n end\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to @estudiante, notice: 'Estudiante actualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n\n respond_to do |format|\n if @ventas_presupuesto.update_attributes(params[:ventas_presupuesto])\n format.html { redirect_to @ventas_presupuesto, notice: 'Presupuesto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ventas_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @person = @profissional.person\n if @person.update(profissional_params[:person_attributes])\n if profissional_params[:specialization].present?\n @profissional.update_attributes(:specialization => profissional_params[:specialization])\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { render :show, status: :ok, location: @profissional }\n else\n format.html { render :edit }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end", "def persona_punto_ventum_params\n params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id)\n end", "def update\n @persona = Persona.find(params[:persona_id])\n respond_to do |format|\n if @persona.info_extra_pacientes.update(info_extra_paciente_params)\n format.html { redirect_to @info_extra_paciente, notice: 'Info extra actualizada.' }\n format.json { render :show, status: :ok, location: @info_extra_paciente }\n else\n format.html { render :edit }\n format.json { render json: @info_extra_paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n if @personaje.update_attributes(params[:personaje])\n format.html { redirect_to @personaje, notice: 'Personaje was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n #@persona.attributes = params[:persona] if params[:persona]\n \n if @persona.update_attributes(params[:persona])\n format.html { redirect_to(@persona, :notice => 'Persona was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @persona.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_persona_punto_ventum\n @persona_punto_ventum = PersonaPuntoVentum.find(params[:id])\n end", "def update\n @paciente = Paciente.find(params[:id])\n\n @upersona = @paciente.personas.last\n @paciente_edit = @upersona.perstable\n respond_to do |format|\n if @paciente_edit.update(params[:paciente].permit(:domicilio, :civil, :nss, :edad, :peso, :talla, :imc, :t_sangre, :persona))\n format.html { redirect_to pacientes_path , notice: 'Paciente was successfully updated.' }\n format.json { render :show, status: :ok, location: pacientes_path }\n else\n format.html { render :edit }\n format.json { render json: @paciente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Данные клиента обновлены.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @estado_persona.update(estado_persona_params)\n format.html { redirect_to @estado_persona, notice: 'Se ha editado el Estado con exito.' }\n format.json { render :show, status: :ok, location: @estado_persona }\n else\n format.html { render :edit }\n format.json { render json: @estado_persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to(admin_path(@persona), :notice => t('adminactualizado')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @persona.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:persona_id])\n respond_to do |format|\n if @persona.info_contacto.update(info_contacto_params)\n format.html { redirect_to @info_contacto, notice: 'Info contacto was successfully updated.' }\n format.json { render :show, status: :ok, location: @info_contacto }\n else\n format.html { render :edit }\n format.json { render json: @info_contacto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @persona_proyecto.update(persona_proyecto_params)\n format.html { redirect_to @persona_proyecto, notice: 'Persona proyecto was successfully updated.' }\n format.json { render :show, status: :ok, location: @persona_proyecto }\n else\n format.html { render :edit }\n format.json { render json: @persona_proyecto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n @person.delete_offices\n @person.delete_addresses\n @person.delete_phone_numbers\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person.update_attributes(params[:person])\n respond_with(@person)\n end", "def update\n respond_to do |format|\n if @punto.update(punto_params) and @punto.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @punto, notice: 'Punto was successfully updated.' }\n format.json { render :show, status: :ok, location: @punto }\n else\n format.html { render :edit }\n format.json { render json: @punto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: t('.update_ok') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Cadastro atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n if current_user\n if current_user.user?\n current_user.person_id = @person.id\n current_user.save\n end\n end\n format.html { redirect_to @person, notice: 'Uppgifterna uppdaterades. Tack' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @people.update(people_params)\n format.html { redirect_to root_path(@people), notice: 'VIP ' + @people.name.to_s + ' foi atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @people }\n else\n format.html { render :edit }\n format.json { render json: @people.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vehicule_perso = VehiculePerso.find(params[:id])\n\n respond_to do |format|\n if @vehicule_perso.update_attributes(params[:vehicule_perso])\n format.html { redirect_to @vehicule_perso, :notice => 'Le véhicule personnel a bien été modifié' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @vehicule_perso.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n if @personaje_mision.update_attributes(params[:personaje_mision])\n format.html { redirect_to @personaje_mision, notice: 'Personaje mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje_mision.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @pocetna.update(pocetna_params)\n format.html { redirect_to @pocetna, notice: \"Pocetna was successfully updated.\" }\n format.json { render :show, status: :ok, location: @pocetna }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @pocetna.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @personel.update(personel_params)\n format.html { redirect_to @personel, notice: 'Personel was successfully updated.' }\n format.json { render :show, status: :ok, location: @personel }\n else\n format.html { render :edit }\n format.json { render json: @personel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to people_path, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n #@persona = Persona.find(:all, :conditions => {:screen_name => params[:id] }).first\n\n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.html { redirect_to persona_path(@persona.screen_name), notice: 'Persona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @controlpersona = Controlpersona.find(params[:id])\n\n respond_to do |format|\n if @controlpersona.update_attributes(params[:controlpersona])\n format.html { redirect_to @controlpersona, notice: 'Controlpersona was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @controlpersona.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Tipo\n respond_to do |format|\n if @tipo.update(tipo_params)\n log(\"Se ha editado la nomina #{@lt}\", 1)\n format.html { redirect_to tipos_path, notice: 'Los datos de la nómina fueron actualizados exitosamente.' }\n format.json { head :no_content }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n populate_attributes(@person, params[:person])\n respond_to do |format|\n \n if @person.save && @person.identifiable_entries.each(&:save!)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n if @puntaje.update_attributes(params[:puntaje])\n format.html { redirect_to @puntaje, notice: 'Puntaje was successfully updated.' }\n format.json { head :no_content }\n else\n atributos\n format.html { render action: \"edit\" }\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n errors = {}\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if params[:person]\n begin\n if @person.json_update_attributes(params[:person])\n render_json :entry => @person.to_hash(@user, @client) and return\n end\n rescue NoMethodError => e\n errors = e.to_s\n end\n end\n\n render_json :status => :bad_request, :messages => @person.errors.full_messages\n @person = nil\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end", "def update\n @pto = Pto.find(params[:id])\n\n respond_to do |format|\n if @pto.update_attributes(params[:pto])\n format.html { redirect_to @pto, notice: 'Pto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poligono.update(poligono_params)\n format.html { redirect_to @poligono, notice: 'Poligono was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poligono.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @detalle_ot_presupuesto.update(detalle_ot_presupuesto_params)\n format.html { redirect_to @detalle_ot_presupuesto, notice: 'Detalle ot presupuesto was successfully updated.' }\n format.json { render :show, status: :ok, location: @detalle_ot_presupuesto }\n else\n format.html { render :edit }\n format.json { render json: @detalle_ot_presupuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient].except(:person_attributes))\n format.html { redirect_to people_url, notice: 'Patient was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @request_person.update(request_person_params)\n format.html { redirect_to @request_person, notice: 'Request person was successfully updated.' }\n format.json { render :show, status: :ok, location: @request_person }\n else\n format.html { render :edit }\n format.json { render json: @request_person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prospecto_telefono.update(prospecto_telefono_params)\n format.html { redirect_to @prospecto_telefono, notice: 'Prospecto telefono was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto_telefono }\n else\n format.html { render :edit }\n format.json { render json: @prospecto_telefono.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ponte.update(ponte_params)\n format.html { redirect_to pontes_url, notice: 'Ponte atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @ponte }\n else\n format.html { render :edit }\n format.json { render json: @ponte.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\trespond_to do |format|\n\tif @precio_boleto.update(precio_boleto_params)\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n\t\tformat.json { head :no_content }\n\telse\n\t\tformat.html { render action: 'edit' }\n\t\tformat.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n\tend\n\tend\nend", "def update\n @person_info = PersonInfo.find(params[:id])\n\n if @person_info.update(person_info_params(params[:person_info]))\n head :no_content\n else\n render json: @person_info.errors, status: :unprocessable_entity\n end\n end", "def update\n @pessoa = Pessoa.find(params[:id])\n\n respond_to do |format|\n if @pessoa.update_attributes(params[:pessoa])\n format.html { redirect_to pessoas_path, notice: 'Pessoa atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pessoa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ventum.update(ventum_params)\n format.html { redirect_to @ventum, notice: 'Venta fue modificado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\n if @os_tarefa.update(os_tarefa_params)\n #se as situacao da tarefa nao for aceita, altera a ordem_servico_pagamento para null\n if(@os_tarefa.situacao!=OsTarefa.situacoes[0] && @os_tarefa.situacao!=OsTarefa.situacoes[1])\n\n @os_tarefa.ordem_servico_pagamento=nil\n @os_tarefa.save\n end\n\n if @os_tarefa.ordem_servico.id!=nil\n format.html { redirect_to \"/ordem_servicos/\"+@os_tarefa.ordem_servico.id.to_s, notice: 'A Tarefa foi atualizado(a)' }\n format.json { head :no_content }\n else\n format.html { redirect_to @os_tarefa, notice: 'A Tarefa foi atualizado(a)' }\n format.json { render :show, status: :ok, location: @os_tarefa }\n end\n else\n format.html { render :edit }\n format.json { render json: @os_tarefa.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_pregunta = TipoPregunta.find(params[:id])\n\n if @tipo_pregunta.update(params[:tipo_pregunta])\n head :no_content\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tasks_person = TasksPerson.find(params[:id])\n\n respond_to do |format|\n if @tasks_person.update_attributes(params[:tasks_person])\n format.html { redirect_to @tasks_person, notice: 'Tasks person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tasks_person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n set_associations\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prato.update(prato_params)\n format.html { redirect_to @prato, notice: 'prato atualizado.' }\n format.json { render :show, status: :ok, location: @prato }\n else\n format.html { render :edit }\n format.json { render json: @prato.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repuesto.update(repuesto_params)\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully updated.' }\n format.json { render :show, status: :ok, location: @repuesto }\n else\n format.html { render :edit }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @basico_persona_juridica.update(basico_persona_juridica_params)\n format.html { redirect_to @basico_persona_juridica, notice: 'Persona juridica was successfully updated.' }\n format.json { render :show, status: :ok, location: @basico_persona_juridica }\n else\n format.html { render :edit }\n format.json { render json: @basico_persona_juridica.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tiposveiculo.update(tiposveiculo_params)\n format.html { redirect_to tiposveiculos_url, notice: 'Tipo de Veículo editado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tiposveiculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html do\n redirect_to @person, notice: 'Person was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json do\n render json: @person.errors, status: :unprocessable_entity\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n track_activity @person\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render layout: 'form', action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @repuesto_servicio.update(repuesto_servicio_params)\n format.html { redirect_to @repuesto_servicio, notice: 'Repuesto o servicio fue actualizado con éxito.' }\n format.json { render :show, status: :ok, location: @repuesto_servicio }\n else\n format.html { render :edit }\n format.json { render json: @repuesto_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to admin_person_url(@person), notice: 'Person was successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: \"Person was successfully updated.\" }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @person.update(person_params)\n format.html { redirect_to @person, notice: \"#{@person.name} was successfully updated.\" }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @precio_boleto.update(precio_boleto_params)\n format.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @precio_boleto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_ventum.update(tipo_ventum_params)\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_ventum }\n else\n format.html { render :edit }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end", "def pupdate\n @event = Event.find(params[:id])\n respond_to do |format|\n if @event.update_attributes(JSON.parse(params[:event]))\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { head :no_content}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def 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 @user_person = UserPerson.find(params[:id])\n\n respond_to do |format|\n if @user_person.update_attributes(params[:user_person])\n format.html { redirect_to @user_person, notice: 'User person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_person.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6947051", "0.67096686", "0.66256475", "0.66102594", "0.65836143", "0.65129006", "0.6438746", "0.6425371", "0.64011145", "0.63980716", "0.6397051", "0.6367387", "0.6359711", "0.63567084", "0.63453615", "0.6291125", "0.6271334", "0.62678224", "0.6223979", "0.6216488", "0.6215972", "0.6184314", "0.6171592", "0.6168832", "0.6161344", "0.6159483", "0.61566585", "0.6131963", "0.612593", "0.61221105", "0.6120911", "0.60903716", "0.60803735", "0.6058402", "0.6057517", "0.6052201", "0.604976", "0.6047577", "0.6046489", "0.6035276", "0.6020925", "0.6018412", "0.6016456", "0.60099506", "0.60092574", "0.6005597", "0.6004088", "0.6002741", "0.6002741", "0.6002741", "0.59960175", "0.5983973", "0.5978169", "0.5974378", "0.5972985", "0.59726655", "0.5961088", "0.5959971", "0.5957773", "0.5955462", "0.5952065", "0.5952065", "0.5952065", "0.5952065", "0.5952065", "0.59518754", "0.59478587", "0.59474766", "0.5943914", "0.5940348", "0.5939725", "0.59373164", "0.59373164", "0.5936775", "0.59342486", "0.59332246", "0.59328264", "0.59321487", "0.5930615", "0.59301704", "0.59290975", "0.59290975", "0.59290975", "0.59290975", "0.59290975", "0.59290975", "0.59290975", "0.59290975", "0.5928967", "0.5928288", "0.592311", "0.5922562", "0.5918707", "0.59171015", "0.59075457", "0.59074694", "0.5906979", "0.5904464", "0.5896842", "0.58942837" ]
0.73514277
0
DELETE /persona_punto_venta/1 DELETE /persona_punto_venta/1.json
def destroy @punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id) @persona_punto_ventum.destroy respond_to do |format| format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona_tipo = PersonaTipo.find(params[:id])\n @persona_tipo.destroy\n\n respond_to do |format|\n format.html { redirect_to persona_tipos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to personas_url, notice: 'Datos personales eliminados exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personaje = Personaje.find(params[:id])\n @personaje.destroy\n\n respond_to do |format|\n format.html { redirect_to personajes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_persona.destroy\n respond_to do |format|\n format.html { redirect_to tipos_personas_url, notice: 'Tipo persona was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to administradores_path, notice: 'Persona was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estado_persona.destroy\n respond_to do |format|\n format.html { redirect_to estado_personas_url, notice: 'Se ha eliminado el estado.' }\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 @basico_persona_juridica.destroy\n respond_to do |format|\n format.html { redirect_to basico_persona_juridicas_url, notice: 'Persona juridica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url, notice: 'Клиент удален из базы.' }\n format.json { head :no_content }\n end\n end", "def destroy_by_body\n @person = Person.find(person_delete_param[:id])\n id = @person.id\n\n if @person.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error deleting person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to(personas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @ventas_presupuesto = Ventas::Presupuesto.find(params[:id])\n @ventas_presupuesto.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_presupuestos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n idPer = params[:id]\n person = Persona.find(idPer)\n person.borrado = Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n person.save\n respond_to do |format|\n format.html {redirect_to personas_url, notice: 'La Persona fue eliminado correctamente'}\n format.json {head :no_content}\n end\n\n\n end", "def destroy\n @personaje_mision = PersonajeMision.find(params[:id])\n @personaje_mision.destroy\n\n respond_to do |format|\n format.html { redirect_to personaje_misions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.html { redirect_to(emple_path) }\n format.xml { head :ok }\n end\n end", "def destroy\n @detalle_ot_presupuesto.destroy\n respond_to do |format|\n format.html { redirect_to detalle_ot_presupuestos_url, notice: 'Detalle ot presupuesto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona.cargo.update(disponible: true)\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to personas_url, notice: 'Persona was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona_proyecto.destroy\n respond_to do |format|\n format.html { redirect_to personas_proyectos_url, notice: 'Persona proyecto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url, notice: 'Uppgifterna om personen raderades.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @controlpersona = Controlpersona.find(params[:id])\n @controlpersona.destroy\n\n respond_to do |format|\n format.html { redirect_to controlpersonas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @people.destroy\n respond_to do |format|\n format.html { redirect_to people_url, notice: 'Persona eliminada con éxito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n id = @person.id\n\n if @person.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error deleting person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n track_activity @person\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @biometria.destroy\n respond_to do |format|\n format.html { redirect_to index_biometria_path(params[:paciente_id]), notice: 'Biometria elimino correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vehicule_perso = VehiculePerso.find(params[:id])\n @vehicule_perso.destroy\n\n respond_to do |format|\n format.html { redirect_to vehicule_persos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find((params[:person_id]))\n @person_identification_doc = PersonIdentificationDoc.find(params[:id])\n @person_identification_doc.destroy\n\n respond_to do |format|\n format.html { redirect_to person_person_identification_docs_path, :notice => 'Documentação excluída.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personel.destroy\n respond_to do |format|\n format.html { redirect_to personels_url, notice: 'Personel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personel.destroy\n respond_to do |format|\n format.html { redirect_to personels_url, notice: 'Personel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datoscontacto = Datoscontacto.find(params[:id])\n @datoscontacto.destroy\n\n respond_to do |format|\n format.html { redirect_to datoscontactos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @emu_person.destroy\n respond_to do |format|\n format.html { redirect_to emu_people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy_persona\n persona.destroy\n end", "def destroy\n @persona = Persona.find(params[:persona_id])\n @info_extra_paciente = @persona.info_extra_pacientes.find(params[:id])\n @info_extra_paciente.destroy\n respond_to do |format|\n format.html { redirect_to @persona, notice: 'Contacto Eliminado' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_ventum.destroy\n respond_to do |format|\n format.html { redirect_to tipo_venta_url, notice: 'Tipo ventum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @painel.destroy\n respond_to do |format|\n format.html { redirect_to painels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @paciente = Paciente.find(params[:id])\n @paciente.destroy\n\n respond_to do |format|\n format.html { redirect_to paciente_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = people_type.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to :action => \"index\" }\n format.json { head :ok }\n end\n end", "def destroy\n @puntaje = Puntaje.find(params[:id])\n @puntaje.destroy\n\n respond_to do |format|\n format.html { redirect_to puntajes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_personal.destroy\n respond_to do |format|\n format.html { redirect_to datos_personals_url, notice: 'Datos personal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to admin_people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @odontologia1 = Odontologia1.find(params[:id])\n @odontologia1.destroy\n\n respond_to do |format|\n format.html { redirect_to odontologia1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @antropo.destroy\n respond_to do |format|\n format.html { redirect_to antropos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nota_tecnica.destroy\n respond_to do |format|\n format.html { redirect_to nota_tecnicas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @visit_person.destroy\n respond_to do |format|\n format.html { redirect_to visit_people_url, notice: 'Visit person was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona.destroy\n redirect_to personas_url, notice: t('action.delete')\n end", "def destroy\n @personnage = Personnage.find(params[:id])\n @personnage.destroy\n\n respond_to do |format|\n format.html { redirect_to personnages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @anteproyecto_observacion.destroy\n respond_to do |format|\n format.html { redirect_to anteproyecto_observaciones_url, notice: 'Anteproyecto observacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n head :no_content\n end", "def destroy\n @person.destroy\n head :no_content\n end", "def destroy\n @ordem_servico.destroy\n respond_to do |format|\n format.html { redirect_to ordem_servicos_url, notice: t('messages.cadastro_removido') }\n format.json { head :no_content }\n end\n end", "def destroy\n @puestos_entidad = PuestosEntidad.find(params[:id])\n @puestos_entidad.destroy\n\n respond_to do |format|\n format.html { redirect_to puestos_entidads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estatuto = Estatuto.find(params[:id])\n @estatuto.destroy\n\n respond_to do |format|\n format.html { redirect_to estatutos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_agressor.destroy\n respond_to do |format|\n format.html { redirect_to tipo_agressores_url, notice: @@msgs }\n format.json { head :no_content }\n end\n end", "def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @people.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Um VIP ' + @people.name.to_s + ' foi deletado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @apunte = Apunte.find(params[:id])\n @apunte.destroy\n\n respond_to do |format|\n format.html { redirect_to apuntes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n @historial_odt.destroy\n\n respond_to do |format|\n format.html { redirect_to historial_odts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @poligono.destroy\n respond_to do |format|\n format.html { redirect_to poligonos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estudiante = Estudiante.find(params[:id])\n @estudiante.destroy\n\n respond_to do |format|\n format.html { redirect_to estudiantes_url, :notice => \"#{@estudiante.persona.nombre_completo} eliminado\" }\n format.json { head :no_content }\n end#do\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @ventaganancium.destroy\n respond_to do |format|\n format.html { redirect_to ventaganancia_url, notice: 'Ventaganancium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sims_biga_vehicle_person.destroy\n respond_to do |format|\n format.html { redirect_to sims_biga_vehicle_people_url, notice: t('flash.notice.destroied.') }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @ventum.destroy\n respond_to do |format|\n format.html { redirect_to venta_url, notice: 'Se ha eliminado la venta exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if current_user.nil?\n redirect_to(log_in_path) and return\n end\n\n @persona_vinculada = PersonaVinculada.find(params[:id])\n @persona_vinculada.destroy\n\n respond_to do |format|\n format.html { redirect_to personas_vinculadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipomedalla = Tipomedalla.find(params[:id])\n @tipomedalla.destroy\n\n respond_to do |format|\n format.html { redirect_to tipomedallas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona = Persona.find(params[:persona_id])\n @info_contacto = @persona.info_contactos.find(params[:id])\n @info_contacto.destroy\n respond_to do |format|\n format.html { redirect_to @persona, notice: 'Contacto Eliminado' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ventum.destroy\n respond_to do |format|\n format.html { redirect_to venta_url, notice: 'Venteliminada satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pessoa = Pessoa.find(params[:id])\n @pessoa.destroy\n\n respond_to do |format|\n format.html { redirect_to pessoas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pinglun = Pinglun.find(params[:id])\n @pinglun.destroy\n\n respond_to do |format|\n format.html { redirect_to pingluns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alumno.destroy\n respond_to do |format|\n format.html { redirect_to grupos_path }\n format.json { head :no_content }\n end\n end" ]
[ "0.76277345", "0.7387782", "0.7387782", "0.7387782", "0.7385074", "0.7275049", "0.7166503", "0.7151515", "0.71326953", "0.712416", "0.7103515", "0.7092933", "0.7063283", "0.70572364", "0.70177877", "0.6998521", "0.6980156", "0.6980139", "0.69677246", "0.69669056", "0.6955762", "0.6947532", "0.69399625", "0.69338006", "0.6933653", "0.69202685", "0.69178575", "0.69155973", "0.69039774", "0.6902824", "0.69018275", "0.6896053", "0.6884257", "0.6884257", "0.6884257", "0.6884257", "0.6884257", "0.68795824", "0.6860768", "0.6857903", "0.6857903", "0.6857369", "0.6854276", "0.68521184", "0.6848995", "0.6845488", "0.6838754", "0.6838754", "0.6838754", "0.6829788", "0.6829788", "0.6829788", "0.6829788", "0.68268275", "0.6824952", "0.682432", "0.6823864", "0.6819661", "0.681917", "0.6816678", "0.68165964", "0.68158704", "0.6814657", "0.6814626", "0.6813644", "0.680743", "0.6806978", "0.68059665", "0.6802287", "0.6801379", "0.67998564", "0.67996025", "0.67996025", "0.67936945", "0.67920655", "0.67822266", "0.67778665", "0.6773102", "0.6772801", "0.6771362", "0.6771303", "0.677129", "0.67703396", "0.67698586", "0.67698586", "0.6765991", "0.67646635", "0.6761686", "0.6756132", "0.67556167", "0.67553043", "0.67552334", "0.6755029", "0.675114", "0.6750113", "0.674784", "0.6747811", "0.6746745", "0.674408", "0.67427886" ]
0.7592983
1
Use callbacks to share common setup or constraints between actions.
def set_persona_punto_ventum @persona_punto_ventum = PersonaPuntoVentum.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 persona_punto_ventum_params params.require(:persona_punto_ventum).permit(:persona_id, :punto_venta_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def valid_params_request?; end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def filtering_params\n params.permit(:email)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "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 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 droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\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.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.6291174", "0.62905735", "0.6283171", "0.6242344", "0.62403613", "0.6218049", "0.62143815", "0.62104696", "0.61949855", "0.6178671", "0.6176147", "0.6173327", "0.6163395", "0.6153005", "0.6151833", "0.6147288", "0.61224324", "0.6118827", "0.61075264", "0.61054534", "0.6092497", "0.6080082", "0.60710967", "0.60627776", "0.60219413", "0.60175914", "0.60153484", "0.60107356", "0.60081726", "0.60081726", "0.60013986", "0.6000165", "0.59978646", "0.59936947", "0.59925723", "0.5992084", "0.59796256", "0.5967569", "0.5960056", "0.59589803", "0.5958441", "0.5958401", "0.5952607", "0.5952406", "0.5944409", "0.59391016", "0.593842", "0.593842", "0.5933845", "0.59312123", "0.5926475", "0.59248453", "0.59179676", "0.59109294", "0.59101623", "0.5908172", "0.59058356", "0.5899052", "0.5897749", "0.5896101", "0.58942914", "0.58939576", "0.5892063", "0.5887407", "0.588292", "0.58797663", "0.587367", "0.58681566", "0.5868038", "0.5866578", "0.58665025", "0.58655846", "0.58640826", "0.5863465", "0.5862226", "0.586065", "0.58581287", "0.5854443", "0.5854172", "0.58507544", "0.5849934" ]
0.0
-1
Eval if the current expression is already a number
def isFloat? !!Float(exp) rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expr(str)\n return unless str\n eval(str, Math.bind) || 0\n rescue SyntaxError, NameError\n cfg_err(\"#{str} is not number\")\n end", "def is_number? expr\n return false if expr.nil?\n expr = \"#{expr}\" # we need this condition in case the expr is a number\n expr.match /^(\\d+|\\d+\\.\\d+)$/ # since match() is defined only for strings\nend", "def eval_expression(expression)\n if expression.count(\"a-zA-Z\") > 0\n result = \"Incorrect expression or Number\"\n else\n expression = expression.gsub('/', '*1.0/') if expression.include?(\"/\")\n result = eval(expression).round(2)\n end\n result\n end", "def is_number? token\n Float(token) && true rescue false\n end", "def special_number?(literal)\n literal.is_a?(Sass::Script::Value::String) && literal.value =~ /(calc|var)\\(/\n end", "def number?(x)\n return false unless /\\d+/ =~ x\n # the .0 syntax was deprecated but still works with the Float() function\n x = \"0\"+x if x[0] == \".\"\n # We will also support exponentiation in literals\n if x.include? \"^\"\n num, exp = x.split \"^\"\n x, y = __number(num), __number(exp)\n return x**y if x && y\n else\n __number x\n end\n end", "def numeric?\n self.command =~ /^\\d+$/\n end", "def eval(n)\n case n\n when Sum[e1 = _, e2 = _] then eval(e1) + eval(e2)\n when Number[n = _] then n\n end\nend", "def is_number?(variable)\n true if Float(variable) rescue false\n end", "def operand?(str)\n\t\ttrue if Float(str) rescue false\n end", "def is_number?(input)\n true if Float(input) rescue false\n end", "def is_number(num)\n true if Float(num) rescue false\nend", "def is_numeric?(val)\n Float val rescue false\n end", "def is_number?(i)\n true if Float(i) rescue false\nend", "def is_number?(i)\n true if Float(i) rescue false\nend", "def check_number_operand(operator, operand)\n unless operand.is_a?(Float)\n raise LoxRuntimeError.new(operator, \"Operand must be a number.\")\n end\n end", "def numeric(x)\n true if Float(x) rescue false\n end", "def eval_expression\n if @input.to_i.zero?\n @input = eval(@input).to_s\n else\n @input = eval(@input).to_f.to_s\n end\n @output.text = @input\n end", "def could_not_eval(line_num)\n puts \"Line #{line_num}: Couldn't evaluate expression\"\n end", "def of_number(val)\n val > 0\n end", "def is_number(input)\n \t\tinput.to_f == input\n\tend", "def is_number?\n is_float? || is_integer?\n end", "def try_eval(expr)\n eval_expr(expr)\n end", "def numeric_check(first_num)\n Float(first_num) != nil rescue false\nend", "def eval_num(num)\n if num <= 50\n puts \"#{num} is 50 or less\"\n else\n puts \"#{num} is 51 or above\"\n end\nend", "def is_number()\n res = super(context,self)\n return res\n end", "def number?(value)\n value.is_a?(Numeric)\n end", "def of_number(val)\n val > 0\n end", "def evaluate(bindings = {})\n stack = []\n @expr.split.each do |token|\n case token\n when /\\A\\d+\\z/\n number = Number.new(token)\n stack.push(number)\n when \"+\"\n right = stack.pop(1)\n left = stack.pop(1)\n value.add(left, right)\n end\n end\n stack.pop\n end", "def is_number? string\n true if Float(string) rescue false\nend", "def is_number? string\n \t\ttrue if Float(string) rescue false\n\tend", "def is_number?(str)\n true if Float(str) rescue false\n end", "def numeric?\n !!(self =~ /\\A[0-9]+\\.*[0-9]*\\z/)\n end", "def is_number(string)\r\n\ttrue if Float(string) rescue false\r\nend", "def numeric?\n\t\treturn all? {|x| Math.Is_Numeric?(x)}\n\tend", "def is_numeric?\n begin Float(self)\n true \n end\n rescue\n false\n end", "def number?(num)\n integer?(num) || float?(num)\nend", "def isNum(c)\r\n\tInteger(c) rescue return false\r\n\treturn true\r\nend", "def is_self_evaluating(exp)\n [Number, Boolean, Sstring].any?{|c| exp.instance_of?(c)}\n end", "def ensure_number(wannabe_number)\n\n wannabe_number or raise(NilEvaluationError)\n\n if wannabe_number.is_a?(String)\n get_value_from_variable(wannabe_number)\n\n elsif wannabe_number.respond_to?(:number)\n wannabe_number.number\n\n else\n wannabe_number\n end\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def operand?(str)\n #true if str contains only [0-9]\n 0 == (str =~ /^\\d+$/)\n end", "def is_number? string\n true if Float(string) rescue false\n end", "def eval_test(str)\n # check if input contains any non-valid characters\n return str if str!= str.split(/[^0-9\\s\\/*+\\-()]/).join\n # check if first character of input will break the eval\n return str if str[0] =~ /[\\/*+\\-]/\n begin\n # return number elements of the input as floats, so they eval as the user intended\n # ACTUALLY WANT TO LEAVE THE non-numbers in the array, but can't use .split to do that with the following syntax\n # str_nums = str.split(/[\\s\\/*+\\-()]/)\n # str_nums.each { |n| n = n.to_f }\n # print str_nums\n # str.each do |substr|\n # substr = substr.to_f if is_number(substr)\n # puts substr.class\n # end\n return eval(str)\n rescue\n return str\n end\n end", "def number?\n lookahead?([:T_INT, :T_FLOAT])\n end", "def is_numeric?(value)\n !!Float(value) rescue false \n end", "def IS_NUMBER(value)\n value.first.is_a?(Numeric)\n end", "def is_number?(string)\n true if Float(string) rescue false #need to understand this\nend", "def can_be_numeric?\n type == :numeric\n end", "def numeric?(num)\n !!Float(num) rescue false\nend", "def is_number(str)\n true if Float(str)\nrescue StandardError\n false\nend", "def is_numeric(val)\n\t\treturn Integer(val).is_a? Integer rescue false\n\tend", "def is_numeric?(s)\n !!Float(s) rescue false\n end", "def operand?(str)\n return str.to_i != 0;\n end", "def is_number?(string)\n true if Float(string) rescue false\n end", "def is_digit?(input)\n !!Float(input) rescue false\nend", "def try_a_number(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end", "def accept(evaluator)\n evaluator.number(self)\n end", "def is_number?(string)\n true if Float(string) rescue false\n end", "def evaluate(runtime=\"0\")\n\t\t\t@attributes.runtime = BigDecimal(runtime)\n\t\t\tresult = @expression.evaluate()\n\t\t\tinitialize_solver(@expression.expressionCache)\n\n\t\t\t# Catch Not A Number or Infinite cases\n\t\t\tif(result.nan?() or result.infinite?()) then\n\t\t\t\tresult = BigDecimal(\"0\")\n\t\t\tend\n\n\t\t\treturn(result)\n\t\tend", "def eval(_)\n value\n end", "def is_numeric?\n self.match(/^[0-9]+$/)\n end", "def test_valid_eval\n assert_equal [11, 'valid'], @eval.evaluate([5, 6, '+'])\n end", "def is_number?(string)\n # catch and return false if it isn't an integer\n true if Float(string) rescue false \nend", "def is_a_number?(word)\n Integer(word) rescue false\nend", "def check_expr(expr)\n stack = []\n\n expr.each do |e|\n if e.is_a? Fixnum\n stack.push e\n else\n b = stack.pop\n a = stack.pop\n\n case e\n when '+' then stack.push(a + b)\n when '*' then stack.push(a * b)\n when '-' then\n return false if b > a\n stack.push(a - b)\n else\n return false if b == 0 or a % b != 0\n stack.push(a / b)\n end\n end\n end\n\n stack.pop == @hand.target_card\n end", "def numeric?\n val.numeric?\n end", "def evaluator(str,binding)\n a_value = 123\n eval(str,binding) #outputs 321\nend", "def is_numeric(o)\n true if Integer(o) rescue false \n end", "def is_numeric(o)\n true if Integer(o) rescue false \n end", "def valid_number?(num)\n integer?(num) || float?(num)\nend", "def evaluate(expr = '', locals: {})\n eval(expr, local_vars(binding, locals))\n rescue NoMethodError, TypeError => ex\n nil\n end", "def evaluate(_interpreter, arg_stack)\n args = arg_stack.pop\n\n return @cached unless @cached.nil?\n\n raise BASICRuntimeError.new(:te_args_no_match, @name) unless\n match_args_to_signature(args, @signature1)\n\n res = if content_type == :integer\n args[0].floor.to_int\n else\n args[0].floor\n end\n\n @cached = res if @constant && $options['cache_const_expr']\n res\n end", "def calc(expr)\n expr.split.each_with_object([]) { |e, a|\n if e.match(/\\d+/)\n a << e.to_f\n else\n y, x = a.pop, a.pop\n a << x.send(e, y)\n end\n }.last || 0\nend", "def is_a_number?(s)\n \ts.to_s.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n\tend", "def first_number_function \n puts \"What is the first number?\"\n print \"> \"\n first_number = gets.strip \n if first_number =~ /-?\\d+\\.?\\d*/\n puts \"Accepted\"\n @first_number = first_number.to_f \n operator_function \n else puts \"Must enter a number.\"\n first_number_function \n end \nend", "def numeric?(object)\n \t\ttrue if Integer(object) rescue false\n \tend", "def eval(expr, *rest) end", "def numeric?\n true\n end", "def factor\n case\n when scan(/\\(/) then expr.tap { scan(/\\)/) }\n else number\n end\n end", "def numeric?(numberInput)\n numberInput = numberInput.to_s\n if numberInput =~ /^[-+]?[0-9]*\\.?[0-9]+$/\n \n return true\n else\n return false\n end\nend", "def is_numeric?(s)\n !!Float(s) rescue false\n end", "def is_number(value) #method\n if is_bool(value)\n false\n elsif value[0] == \"\\\"\"\n false\n else\n true\n end\n end", "def checkifnumber?(obj)\n obj = obj.to_s unless obj.is_a? String\n /\\A[+-]?\\d+(\\.[\\d]+)?\\z/.match obj\nend", "def _is_numeric?(str)\n Float(str) != nil rescue false\n end", "def number?\n #just regex\n #most likely faster\n #than exception handling\n match = /\\b[0-9]+([.]{1}[0-9]+){0,1}\\b/.match(self)\n if match.nil?\n return false\n else\n return match[0]==self\n end\n end", "def number?\n !!strip.match(/^-?\\d\\.?\\d*$/)\n end", "def not_a_number?(n)\n \tn.to_s.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? true : false\n end", "def number?\n\t\ttrue if Float(string) rescue false\n\tend", "def number?(obj)\n obj = obj.to_s unless obj.is_a? String\n /\\A[+-]?\\d+(\\.[\\d]+)?\\Z/.match obj\nend", "def primary\r\n if consume(\"(\")\r\n node = expr()\r\n expect(\")\")\r\n return node\r\n end\r\n\r\n new_num(expect_number())\r\nend", "def sys_eval_check\n begin\n q = @db_connection.query(\"SELECT COUNT(*) FROM mysql.func WHERE name='sys_eval';\")\n q.each do |x|\n if x[0].to_i == 0\n return false\n else\n return true\n end\n end\n rescue Mysql::Error => e\n print_error(\"Problem Checking for SYS_EVAL() function!\")\n puts \"\\t=> \".white + \"#{e}\".light_red\n return false\n end\n end", "def checkifnumber?(obj)\n obj = obj.to_s unless obj.is_a? String\n /\\A[+-]?\\d+(\\.[\\d]+)?\\z/.match obj\n end", "def test_numeric\n assert_equal(true, RpnCalc.new.numeric?('0'))\n assert_equal(true, RpnCalc.new.numeric?('0.0'))\n assert_equal(true, RpnCalc.new.numeric?('-0'))\n assert_equal(true, RpnCalc.new.numeric?('-0.0'))\n assert_equal(false, RpnCalc.new.numeric?('A'))\n assert_equal(false, RpnCalc.new.numeric?('-E'))\n assert_equal(false, RpnCalc.new.numeric?(nil))\n end", "def is_num?(num)\n !!Integer(num)\n rescue ArgumentError, TypeError\n false\n end", "def elegant_calc(expr)\n expr.split.each_with_object([]) { |e, a|\n if e.match(/\\d+/)\n a << e.to_f\n else\n y, x = a.pop, a.pop\n a << x.send(e, y)\n end\n }.last || 0\nend", "def is_a_number?(num)\n is_integer?(num) || is_float?(num)\nend", "def set_evaluation(token, evaluation, line, file_read)\n val = token.upcase.ord\n if integer?(token)\n evaluation.push(token)\n elsif (val < 91) & (val > 64) & check_variables([token])\n variable_process(token, evaluation, line, file_read)\n else\n perform_op(token, evaluation, line, file_read)\n end\n end", "def evaluate?\n false\n end" ]
[ "0.7315698", "0.7027335", "0.6626165", "0.6408532", "0.6296418", "0.62816715", "0.6209894", "0.61475843", "0.6131619", "0.6125184", "0.6049057", "0.602493", "0.6009801", "0.5955635", "0.5955635", "0.5930307", "0.59297365", "0.5915375", "0.58854157", "0.58832747", "0.5882503", "0.58799094", "0.5876033", "0.58750796", "0.58732826", "0.58701235", "0.5859692", "0.584965", "0.5849278", "0.58099055", "0.58092207", "0.5798838", "0.5790933", "0.5784686", "0.5781275", "0.57794535", "0.57700664", "0.57652897", "0.5762946", "0.5761623", "0.5753104", "0.5751853", "0.5751853", "0.5733329", "0.571076", "0.57087785", "0.57051784", "0.5702257", "0.57016915", "0.5699178", "0.5690771", "0.56646246", "0.5663195", "0.56575114", "0.56560117", "0.5646921", "0.5638742", "0.56355184", "0.5630017", "0.56264955", "0.5619759", "0.561745", "0.5607243", "0.560272", "0.5601779", "0.55840534", "0.55788934", "0.5578467", "0.5575384", "0.5573943", "0.55730295", "0.557249", "0.5564151", "0.5562685", "0.55553293", "0.5553031", "0.5549191", "0.5545504", "0.55366105", "0.5535447", "0.55337256", "0.5527185", "0.55246496", "0.5522101", "0.55191964", "0.5513557", "0.55127233", "0.5511946", "0.5511246", "0.5503258", "0.5501938", "0.5498639", "0.5494165", "0.54926664", "0.5487839", "0.54757595", "0.546897", "0.54676443", "0.5463774", "0.54552644", "0.5447269" ]
0.0
-1
Returns the string with the expression
def to_s return @exp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @expression.to_s\n end", "def to_s\n template = indirect? ? \"[%s]\" : \"%s\"\n return template % expr_to_s\n end", "def to_s\n operator_string + \" \" + @expression.to_s\n end", "def expr_to_s\n buf = ''\n each_term do |term|\n if term[:operator]\n buf << term[:operator]\n end\n buf << term[:token]\n end\n buf\n end", "def to_s\n\n s = \"\\n\\n==== #{self.class} ====\"\n\n find_expressions.each do |fexp|\n\n s << \"\\n\"\n if fexp.kind_of?(RawExpression)\n s << \"*raw\"\n else\n s << \" \"\n end\n s << fexp.fei.to_s\n end\n s << \"\\n==== . ====\\n\"\n\n s\n end", "def expr_eval_to_s\n if @last_eval_state.nil?\n return \"<unevaluated>\"\n end\n \n str = ''\n if @offset\n str << \"#{@offset < 0 ? '-' : ''}0x#{@offset.abs.to_s(16)}\"\n end\n \n if @last_eval_state[:special] || @last_eval_state[:register]\n if @offset\n str << '+'\n end\n if @last_eval_state[:special]\n str << @last_eval_state[:special_tok]\n elsif @last_eval_state[:register]\n str << @last_eval_state[:reg_tok]\n end \n end\n \n str\n end", "def expression; end", "def exp_text\n @exp.to_s\n end", "def evaluate_expression(expression, eval_string = '')\n if expression.is_a? Yarpler::Models::Expression\n eval_string << evaluate_expression_inner(expression).to_s\n elsif expression.is_a? Yarpler::Models::Field\n obj = @problem.objects[expression.variable].get_value(expression.attribute)\n if (obj.is_a? Yarpler::Models::Relation)\n obj = @problem.objects[obj.to.first.to_s].id\n end\n eval_string << obj.to_s\n elsif expression.is_a? Yarpler::Models::Literal\n eval_string << expression.value.to_s\n else\n fail Yarpler::Exceptions::InvalidWhereExpression.new, 'Where Expression is illegal'\n end\n eval_string\n end", "def to_s\n return \"exp(#{self.arg.to_s})\"\n end", "def expression\n Fast.expression(@pattern)\n end", "def evaluate_expression_inner(expression)\n expression_string = evaluate_expression(expression.left)\n expression_string << ' ' + expression.operator.to_s + ' '\n expression_string << evaluate_expression(expression.right)\n expression_string\n end", "def to_s\n identifier = \"#{fieldx}_#{value}\".downcase.gsub(/\\W/,'_')\n \"#{operator}#{identifier}\"\n end", "def to_string(expression)\n\t\t\tif expression.is_a? Array\n\t\t\t\texpression.map { |exp| to_string(exp) }\n\t\t\t\treturn \"(\" + expression.join(\" \") + \")\"\n\t\t\telse\n\t\t\t\treturn expression.to_s\n\t\t\tend\n\t\tend", "def evaluate(expression)\n eval(expression).inspect\nend", "def expression_result_str\n case expression_result\n when 0 then \"False\"\n when 1 then \"True\"\n when 2 then \"Error\"\n end\n end", "def to_s\n rule.embed + operator\n end", "def to_s\n \"(#{@x})^(#{@y})\"\n end", "def expression(operator, val)\n val = (val.is_a?(String) || val.is_a?(Symbol)) ? \"'#{val}'\" : val\n \"#{@attr} #{operator} #{val}\"\n end", "def expression\n return additive_expression\n end", "def create_equation\n equation =''\n for i in 0..(@operands.size-1)\n if i==0\n equation << @operands[i].to_s\n else\n #binding.pry\n equation << @operators[@operator_value[i-1]].to_s\n equation << @operands[i].to_s\n end\n end\n equation\n end", "def expression\n super\n end", "def print_expression(expression)\n string = ''\n if expression.is_a? Yarpler::Models::Forall\n range = expression.range.to_s\n range=range.tr(\",[]\", '')\n string << \"[#{expression} #{expression.variable} for #{range}]->\" + print_expression(expression.expression)\n elsif expression.is_a? Yarpler::Models::Cardinality\n string << \"[#{expression}]\\n\"\n string << \"[#{expression}]->\" + print_expression(expression.element)\n elsif expression.is_a? Yarpler::Models::Field\n string << \"[#{expression} #{expression.variable}.#{expression.attribute}]\\n\"\n elsif expression.is_a? Yarpler::Models::Literal\n string << \"[#{expression} #{expression.value}]\\n\"\n elsif expression.is_a? Yarpler::Models::Instance\n string << \"[#{expression} #{expression.variable}]\\n\"\n elsif expression.is_a? Yarpler::Models::CountFunction\n string << \"[#{expression}} for #{expression.range.variable}.#{expression.range.attribute} ]\\n\"\n string << \"[#{expression}} for #{expression.range.variable}.#{expression.range.attribute} ]--\" + print_expression(expression.where)\n elsif expression.is_a? Yarpler::Models::SumValueFunction\n string << \"[#{expression}} #{expression.attribute} of #{expression.set.variable}.#{expression.set.attribute} ]\\n\"\n elsif expression.is_a? Yarpler::Models::Expression\n string << \"[#{expression} #{expression.operator}]\\n\"\n string << \"[#{expression} #{expression.operator}]->\" + print_expression(expression.left)\n string << \"[#{expression} #{expression.operator}]->\" + print_expression(expression.right)\n else\n puts expression.class.to_s + ' missing.'\n end\n string\n end", "def to_s; \"<Operand: #{to_source}>\"; end", "def sql_string\n StringExpression.new(self.op, *self.args)\n end", "def get_display_expression(sequence)\n sequence.inject('') do |string, summand|\n if summand.to_s.start_with?('1')\n summand.to_s\n elsif summand > 0\n string + ' + ' + summand.to_s\n else\n string + ' - ' + summand.abs.to_s\n end\n end\nend", "def to_s\n # Wrap the expression on the left/right in parentheses if the operation of\n # the expression on the left/right has a lower precedence than this\n # Expression's, e.g. 2 * (3 + 5) because without parentheses it becomes 6 +\n # 5\n [@left, @right].each do |operand|\n if operand.class == Expression\n operand.do_parens = (has_lower_precedence?(operand) or ! operand.is_associative?)\n end\n end\n string = \"#{@left} #{@operator} #{@right}\"\n # Wrap in parentheses if necessary\n string = \"(#{string})\" if @do_parens\n return string\n end", "def compile_expression\n write_tag '<expression>'\n compile_term\n compile_term while match('+', '-', '<', '/', '=', '>', '&', '|', '*')\n write_tag '</expression>'\n end", "def expression\n node_parts.last\n end", "def to_s\n format 'evaluate %s', tag_name(@recursive_name)\n end", "def compile(exp)\n \"\\\"#{compile!(exp)}\\\"\"\n end", "def to_s\n\t\t\"()\"\n\tend", "def expr()\n #This is a stub, used for indexing\n end", "def to_s\n evaluated_message.to_s\n end", "def parsed_expression\n return @parsed_expression\n end", "def fetch_expression (exp)\n\n fetch(exp)[0]\n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def eval_expression\n @input = eval(@input).to_s\n @output.text = @input\n end", "def get_bre_expression_as_string_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RuleEngineRulesApi.get_bre_expression_as_string ...\"\n end\n # resource path\n local_var_path = \"/bre/rules/expression-as-string\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'expression'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RuleEngineRulesApi#get_bre_expression_as_string\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def compile_to_c\n operator_c_string + \"(\" + @expression.compile_to_c + \")\"\n end", "def to_str\n prefix = named? ? \"?<#{id}>\" : ''\n atomic = no_backtrack ? '?>' : ''\n if child.is_a?(Regex::NonCapturingGroup)\n # Minor optimization\n suffix = child.child.to_str\n else\n suffix = child.to_str\n end\n \"(#{atomic}#{prefix}#{suffix})\"\n end", "def to_s\n \"(#{@op.to_s} #{@first.to_s} #{@second.to_s})\"\n end", "def expression_from(node)\n case node\n when Parser::AST::Node\n children_expression = node.children.map(&method(:expression_from)).join(' ')\n \"(#{node.type}#{' ' + children_expression if node.children.any?})\"\n when nil, 'nil'\n 'nil'\n when Symbol, String, Numeric\n '_'\n end\n end", "def to_s\n '!' + rule.embed\n end", "def to_s\n '!' + rule.embed\n end", "def extract_expression(text)\n if text =~ /^\\s*(?:if|elsif|unless)\\s+/\n text.gsub!(/^\\s*(?:if|elsif|unless)\\s+/,'')\n text.gsub!(/\\s+then\\s*$/, '')\n elsif text =~ /^\\s*(?:until|while)\\s+/\n text.gsub!(/^\\s*(?:until|while)\\s+/,'')\n text.gsub!(/\\s+do\\s*$/, '')\n elsif text =~ /^\\s*return\\s+/\n # EXPRESION in: return EXPRESSION\n text.gsub!(/^\\s*return\\s+/,'')\n elsif text =~ /^\\s*case\\s+/\n # EXPRESSION in: case EXPESSION\n text.gsub!(/^\\s*case\\s*/,'')\n elsif text =~ /^\\s*def\\s*.*\\(.+\\)/\n text.gsub!(/^\\s*def\\s*.*\\((.*)\\)/,'[\\1]')\n elsif text =~ /^\\s*[A-Za-z_][A-Za-z0-9_\\[\\]]*\\s*=[^=>]/\n # RHS of an assignment statement.\n text.gsub!(/^\\s*[A-Za-z_][A-Za-z0-9_\\[\\]]*\\s*=/,'')\n end\n return text\n end", "def expression\n @expression ||= :mp\n end", "def get_bre_expression_as_string(opts = {})\n data, _status_code, _headers = get_bre_expression_as_string_with_http_info(opts)\n return data\n end", "def operator_c_string\n operator_string + \" \"\n end", "def term_to_str(coeff, exp)\n term_str = \"\"\n coeff = coeff.abs\n term_str = coeff.to_s unless coeff == 1 && exp > 0\n term_str += \"X\" if exp > 0\n term_str += \"^\" + exp.to_s if exp > 1\n term_str\n end", "def operator_ruby_string\n operator_string + \" \"\n end", "def sql_of( expr, dataset)\n dataset.send :literal_expression_append, rv=String.new, expr\n rv\n end", "def parse_expression(expr); end", "def to_s\n if Prefix===prefix\n s = symbol ? \"#{prefix.symbol}#{symbol}\" : \"#{prefix.name}#{term})\"\n else\n s = symbol ? \"#{symbol}\" : \"#{term}\"\n end\n if power != 1\n s = s + (power > 0 ? \"^#{power}\" : \"#{power}\")\n end\n s\n end", "def to_s\n \"#{@lhs} -> #{rhs_str}\"\n end", "def find_exp(input, variable, expression); end", "def complete_expression?(str); end", "def to_s\n unless Semantic.in_function\n SodaLogger.error('return can only be used inside a function definition')\n end\n \"#{Indentation.get}return #{@expression};\"\n end", "def expr \n\n\t$cst.add_branch(\"Expr\")\n\t\n\tcase scout_token\n\twhen \"T_DIGIT\"\n\t\tintexpr\n\twhen \"T_QUOTE\"\n\t\tstringexpr\n\twhen \"T_LPAREN\", \"T_BOOLEAN\"\n\t\tboolexpr\n\twhen \"T_ID\"\n\t\tid\n\telse\n\t\traise FaultyTokenError.new(\"T_DIGIT, T_QUOTE, T_LPAREN, or T_ID\", $tokens[$index])\n\tend\n\t\n\t$cst.ascend\n\t\nend", "def expression\n comma\n end", "def eval_expression(expression)\n if expression.count(\"a-zA-Z\") > 0\n result = \"Incorrect expression or Number\"\n else\n expression = expression.gsub('/', '*1.0/') if expression.include?(\"/\")\n result = eval(expression).round(2)\n end\n result\n end", "def to_s\n return @to_s if @to_s\n parsed = parse_operation\n if parsed\n @to_s = \"#{model}/#{parsed}\"\n else\n @to_s = regex_name(sql)\n end\n end", "def eval_expression\n # Shoes.show_log\n @numbers = @input.split(\" \")\n @first_number = @numbers.shift.to_f\n @numbers.unshift(@first_number)\n\n @last_number = @numbers.pop.to_f\n @numbers.push(@last_number.to_s)\n\n @input = @numbers.join\n @input = eval(@input).to_s\n @output.text = @input\n end", "def to_s\n\t\t# self.log.debug \"stringifying filter %p\" % [ self ]\n\t\tfiltercomp = self.component.to_s\n\t\tif filtercomp[0] == ?(\n\t\t\treturn filtercomp\n\t\telse\n\t\t\treturn '(' + filtercomp + ')'\n\t\tend\n\tend", "def eval_expression\n eval(expression, binding)\n end", "def expressions; end", "def get_equation(n)\n eval \"@yp#{n}\"\n end", "def compile_to_ruby\n operator_ruby_string + \"(\" + @expression.compile_to_ruby + \")\"\n end", "def expression\n n = term\n while next_token == '+' || next_token == '-'\n op = consume\n m = term\n n = case op\n when '+'\n n + m\n when '-'\n n - m\n else\n nil\n end\n end\n n\n end", "def __expr_part__(value, negating = false)\n ::String.__expr_part__(self, value, negating)\n end", "def to_expr\n return self.return_value\n end", "def exp(str); end", "def exp(str); end", "def to_s\n \"#{property_name} #{operator} #{url_value}\"\n end", "def eval_expression\n if @input.to_i.zero?\n @input = eval(@input).to_s\n else\n @input = eval(@input).to_f.to_s\n end\n @output.text = @input\n end", "def operator_to_string\n {\n \"+\" => 'plus', \n \"-\" => 'minus'\n }\n end", "def __extract_pd_expression__(source_line)\n source_line.to_s.strip\n end", "def stringexpr \n\t\n\t$cst.add_branch(\"StringExpr\")\n\t\n\tmatch_token(\"T_QUOTE\", $tokens[$index])\n\tcharList\n\tmatch_token(\"T_QUOTE\", $tokens[$index])\n\n\t$cst.ascend\n\t\nend", "def to_s\n '&' + rule.embed\n end", "def build_formula()\n res = @expr\n keys = @map.keys\n\n # Ordre important !!!\n keys = keys.sort_by { |object| object.length }.reverse\n\n keys.each do |k|\n v = @map[k]\n res = res.gsub(k.to_s,v.to_s)\n end\n\n return res\n\n end", "def source\n \"5+5+5\"\n end", "def exp(str) # :nodoc:\n Parslet::Expression.new(str).to_parslet\n end", "def to_zpl_string\n \"^#{ @name }#{ @params.join(',') }\"\n end", "def to_s\n \"(#{[' ', '+'][value]})\"\n end", "def to_s\n\t\t\treturn '!' + @filter.to_s\n\t\tend", "def process_xstr(exp)\n command = exp.shift\n return \"rb_funcall(rb_mKernel, rb_intern(\\\"`\\\"), 1, rb_str_new2(#{command.inspect}))\"\n end", "def name\n if active\n expr.descending ? \"#{expr.expression}_desc\" : \"#{expr.expression}_asc\"\n else\n expr.expression\n end.to_s\n end", "def to_s\n str = \"#{Indentation.get}case #{@expression}:\\n\"\n Indentation.indent { str << \"#{block}\\n#{Indentation.get}break;\" }\n str\n end", "def to_output(expr)\n\t\tif expr.kind_of? Array\n\t\t\texpr.map { |x| to_output(x) + \" \"}.join[0..-2]\n\t\telse\n\t\t\texpr.to_s\n\t\tend\n\tend", "def process_str(exp)\n str = exp.shift\n resultify(str.inspect)\n end", "def d(expression)\n result = binding.of_caller(1).eval(expression.to_s)\n inspection = result.inspect\n if result.inspect.length < 50\n sout = \"\\t<#{result.class.name}> #{expression} = #{inspection}\" \n else\n sout = \"\\n<#{result.class.name}> #{expression} =\\n\"\n sout += inspection + \"\\n\\n\" \n end\n DebugPrint.out(sout)\n end", "def to_s\n \"executed `#{@command.to_s.ellipsisize}'\"\n end", "def to_s(exp)\n if exp.is_a?(Array)\n \"( #{exp.map{ |t| to_s(t) }.join(' ')} )\"\n else\n exp.to_s\n end\n end", "def evaluate_equation(string)\n actual_result = eval(string.chars.join(''))\n actual_result\n end", "def add_expression_result_escaped(code)\n with_buffer{@src << ' << ' << @escapefunc << '((' << code << '))'}\n end", "def to_s\n rule\n end", "def to_s\n 'rule: ' + @symbol.to_s\n end", "def guessed_string(equation, actual_result, expected_result)\n guessed_string = equation + ' = ' + actual_result.to_s + \" (#{((expected_result)-(actual_result)).abs})\"\n guessed_string\n end", "def orginize_equation\n gsub!(' ','')\n ##TODO:: orginaize \n end" ]
[ "0.7602983", "0.73803777", "0.71119624", "0.68511164", "0.68256235", "0.67675394", "0.6749405", "0.659083", "0.6572321", "0.65316355", "0.65053385", "0.6425547", "0.6419921", "0.64164835", "0.63943785", "0.63750696", "0.6351578", "0.6273584", "0.6247334", "0.62367016", "0.6233826", "0.6225668", "0.6204296", "0.61980695", "0.61939424", "0.6192114", "0.6190948", "0.61714536", "0.61495036", "0.60996515", "0.6097212", "0.59844", "0.59350264", "0.59325683", "0.59296983", "0.5927833", "0.5926357", "0.5926357", "0.5917661", "0.59028363", "0.58951", "0.5878417", "0.5863061", "0.5855416", "0.58383715", "0.58383715", "0.5827783", "0.58254194", "0.58163786", "0.5809356", "0.5799279", "0.5797951", "0.5796141", "0.5794483", "0.5780328", "0.57609576", "0.5749075", "0.57487524", "0.57356167", "0.57327086", "0.5727159", "0.5722897", "0.56994593", "0.5690768", "0.5690404", "0.5688891", "0.5688656", "0.56881434", "0.5686803", "0.56691545", "0.56667125", "0.5657064", "0.5656014", "0.5656014", "0.5652647", "0.5647377", "0.56191236", "0.56169134", "0.55960625", "0.5595974", "0.5594441", "0.5589502", "0.55845785", "0.55838996", "0.5579561", "0.55782956", "0.5576647", "0.55720633", "0.5568213", "0.5559232", "0.55540067", "0.55429786", "0.55418885", "0.5538591", "0.5530827", "0.5513557", "0.55086446", "0.5498841", "0.54924506", "0.54819196" ]
0.6759765
6
Return the float point of the expression, otherwise raise an error
def to_f if isFloat? then value = exp.to_f return value elsif exp == "Infinity" then return @@MAX_VALUE elsif exp == "-Infinity" then return @@MIN_VALUE else raise "Non-float conversion in expression: " + exp end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Float(p0) end", "def to_float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = TO_FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 313:11: 'float:'\n match( \"float:\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n end", "def match_float( val )\n\t\treturn Float( val ) rescue nil\n\tend", "def ret_f\n result = 0.0\n func = get_func(Fiddle::TYPE_FLOAT)\n if func\n result = func.call(*@args).to_f\n end\n result\n end", "def on_float(ast_node, context)\n return ast_node.children[0]\n end", "def handle_float(float, lineno_column)\n Literal.new float.to_f\n end", "def numeric?; float?; end", "def get_float(node)\n node.content.squish.gsub(/[^\\d\\.]+/, '').to_f if node.present? && node.content.present?\n end", "def isFloat?\n !!Float(exp) rescue false\n end", "def get_float(key)\n get(key, \"f\")\n end", "def float?\n @kind == :float_lit || @kind == :float_exp_lit\n end", "def test_set_x_as_float\n obj = Geom::Point3d.new\n obj.x = 1000.0\n result = obj.x\n expected = 1000.0\n assert_equal(expected, result, 'Expected does not match result.')\n end", "def function_call_statement_float\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n\n value = nil\n\n\n relation_type = nil\n name = nil\n args = nil\n chain = nil\n\n\n begin\n # at line 113:3: (relation_type= ( '.' | '::' ) name= IDENT (args= function_arguments )? chain= function_call_statement_float |)\n alt_29 = 2\n look_29_0 = @input.peek( 1 )\n\n if ( look_29_0 == T__43 || look_29_0 == T__46 )\n alt_29 = 1\n elsif ( look_29_0 == CLOSE || look_29_0.between?( IDENT, IF ) || look_29_0 == NL || look_29_0 == RETURN || look_29_0 == WHILE || look_29_0.between?( T__31, T__33 ) || look_29_0.between?( T__35, T__42 ) || look_29_0.between?( T__44, T__45 ) || look_29_0.between?( T__47, T__54 ) )\n alt_29 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n\n raise NoViableAlternative( \"\", 29, 0 )\n\n end\n case alt_29\n when 1\n # at line 113:5: relation_type= ( '.' | '::' ) name= IDENT (args= function_arguments )? chain= function_call_statement_float\n relation_type = @input.look\n\n if @input.peek(1) == T__43 || @input.peek(1) == T__46\n @input.consume\n @state.error_recovery = false\n\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n mse = MismatchedSet( nil )\n raise mse\n\n end\n\n\n name = match( IDENT, TOKENS_FOLLOWING_IDENT_IN_function_call_statement_float_856 )\n # at line 113:47: (args= function_arguments )?\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == T__34 )\n alt_28 = 1\n end\n case alt_28\n when 1\n # at line 113:47: args= function_arguments\n @state.following.push( TOKENS_FOLLOWING_function_arguments_IN_function_call_statement_float_860 )\n args = function_arguments\n @state.following.pop\n\n end\n @state.following.push( TOKENS_FOLLOWING_function_call_statement_float_IN_function_call_statement_float_865 )\n chain = function_call_statement_float\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = FunctionCallStatementEval.new(name.text, args)\n value.relation_type = relation_type.text\n value.chain = chain unless chain.nil?\n \n # <-- action\n end\n\n\n when 2\n # at line 119:19: \n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = nil \n # <-- action\n end\n\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n\n end\n\n return value\n end", "def is_float(answer)\n float_answer = answer.to_f\n if float_answer == 0.0\n float_answer = nil\n end\n [float_answer, \"#{answer} must be a valid float.\"]\nend", "def to_Float\n begin\n fl = Float stripn\n return fl\n rescue ArgumentError\n return false\n end\n end", "def float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 27 )\n\n\n\n type = FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 192:8: INTEGER '.' INTEGER\n integer!\n\n match( 0x2e )\n\n integer!\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__, 27 )\n\n\n end", "def literal_float(value)\n if value.finite?\n super\n elsif value.nan?\n \"'NaN'\"\n elsif value.infinite? == 1\n \"'Infinity'\"\n else\n \"'-Infinity'\"\n end\n end", "def type_float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 35 )\n\n\n\n type = TYPE_FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 211:13: 'float'\n match( \"float\" )\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__, 35 )\n\n\n end", "def float3?(input)\n Float(input) rescue false\nend", "def get_float\n get(4).unpack('f')\n end", "def test_print_start_float\n assert_raises(StandardError) { print_start(1.2) } # pass\n end", "def parse_float(value)\n Float(value.to_s.gsub(',','.'))\n rescue ArgumentError\n nil\n end", "def post_process_float( val )\n\t\t\treturn Float( val.to_s )\n\t\tend", "def number_f\n return @number_f\n end", "def float\n r = little? ? @data.byteslice(@pos, 4).unpack('e')[0] : @data.byteslice(@pos, 4).unpack('g')[0]\n @pos += 4\n r\n end", "def get_float(pos=nil)\n if pos.class == Fixnum && !block_given?\n return @j_del.java_method(:getFloat, [Java::int.java_class]).call(pos)\n end\n raise ArgumentError, \"Invalid arguments when calling get_float(pos)\"\n end", "def positive_float(value, epsilon: nil)\n result = to_float(value) or return\n result if epsilon ? (result > +epsilon) : result.positive?\n end", "def check_for_float(company)\n float(company) unless\n company.floated? ||\n (initial_offering.percentage_owned(company) > BigDecimal.new('0.5'))\n end", "def validate_float(inFloat) \n\t returnValue = []\n\t if nil == inFloat\n\t\t returnValue << \"cannot be null \"\n\t else\n\t\t begin \n\t\t\t Float(inFloat)\n\t\t\t returnValue = nil \n\t\t rescue Exception => err \n\t\t\t returnValue = \" #{err.message }\" \n\t\t end \n\t end\n\t returnValue\n end", "def parse_float\n float = @tokens.next\n\n [object_ref, float]\n end", "def expect_float(value, field, subfield)\n return true if value.blank?\n return true if value.is_a?(Float)\n errors.add(field, \"#{subfield} must be a float if present\")\n false\n end", "def efg\n return 0.0 if fg.zero? || fga.zero?\n\n ((fg.to_f + 0.5 * three_p.to_f)/fga).round(3)\n end", "def to_f\n case @kind\n when :float_lit, :float_exp_lit,\n :integer_lit, :integer_exp_lit,\n :single_string_lit, :double_string_lit\n @value.to_f\n else\n self.to_i.to_f\n end\n end", "def to_f\n if @last == 0\n raise ZeroDivisionError\n else\n @first.to_f / @last\n end\n end", "def float?\n !!Float(self)\n rescue ArgumentError, TypeError\n false\n end", "def prec_f() end", "def on_float(token)\n log \"FLOAT: '#{token}'\"\n super(token)\n end", "def to_float(value)\n return Float(value) rescue Float::NAN\n end", "def value_to_float(value)\n if @slop.strict?\n begin\n Float(value.to_s)\n rescue ArgumentError\n raise InvalidArgumentError, \"#{value} could not be coerced into Float\"\n end\n else\n value.to_s.to_f\n end\n end", "def float?(object)\n return true if Float(object)\n rescue \n return false\nend", "def operand?(str)\n\t\ttrue if Float(str) rescue false\n end", "def farenheit\n self.to_f\n end", "def test_float_literal\n check(C::FloatLiteral, <<-EOS)\n |1.0\n EOS\n end", "def exp(input, name: nil)\n check_allowed_types(input, FLOATING_POINT_TYPES)\n _op(:exp, input, name: name)\n end", "def eround(decimal_points = 0)\n (\"%.#{decimal_points}e\" % self).to_f\n end", "def add_float_message_to_errors(field)\n @errors << {message: \"#{field} must be an Float.\", variable: \"#{field}\"}\n end", "def float?\n !!strip.match(/^-?\\d+\\.\\d+$/)\n end", "def exp(input, name: nil)\n check_allowed_types(input, FLOATING_POINT_TYPES)\n _op(:exp, input, nil, name: name)\n end", "def eval_expression(expression)\n if expression.count(\"a-zA-Z\") > 0\n result = \"Incorrect expression or Number\"\n else\n expression = expression.gsub('/', '*1.0/') if expression.include?(\"/\")\n result = eval(expression).round(2)\n end\n result\n end", "def f(x)\n 0.4 * x + 1\nend", "def parse_float attr_name, xpath\n v = parse_value xpath\n v = v.to_f if v.respond_to?(:to_f)\n send(\"#{attr_name}=\", v)\n end", "def decimal\n if denominator.to_i == 0\n puts \"ERROR\"\n else\n x = numerator.to_f/denominator.to_f\n puts x\n end\n end", "def test_set_y_as_float\n obj = Geom::Point3d.new\n obj.y = 1000.0\n result = obj.y\n expected = 1000.0\n assert_equal(expected, result, 'expected does not match result.')\n end", "def round_float(fp_number, d_place)\n assert_nothing_raised do\n return (fp_number * 10**d_place).round.to_f / 10**d_place\n end\n end", "def to_f\n Float(value)\n end", "def to_float(string)\n string.to_f\n rescue\n 0.0\n end", "def check_real(field_info, field)\n if should_be_float?(field_info, field) && !float?(field)\n add_float_message_to_errors(field)\n end\n end", "def on_call_number(context, expression = nil)\n convert = nil\n\n if expression\n exp_retval = process(expression, context)\n\n if exp_retval.is_a?(XML::NodeSet)\n convert = first_node_text(exp_retval)\n\n elsif exp_retval == true\n convert = 1.0\n\n elsif exp_retval == false\n convert = 0.0\n\n elsif exp_retval\n convert = exp_retval\n end\n else\n convert = context.first.text\n end\n\n return to_float(convert)\n end", "def float_or_nil(str)\n return nil if IGNORE_LIST.include?(str)\n return nil if str == -1\n Float(str || '')\n rescue ArgumentError\n nil\n end", "def float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 2)\n\n type = FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 11:3: ( ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+ ( EXPONENT )? | DECIMAL EXPONENT )\n alt_5 = 2\n alt_5 = @dfa5.predict(@input)\n case alt_5\n when 1\n # at line 11:5: ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+ ( EXPONENT )?\n # at line 11:5: ( '-' )?\n alt_1 = 2\n look_1_0 = @input.peek(1)\n\n if (look_1_0 == ?-) \n alt_1 = 1\n end\n case alt_1\n when 1\n # at line 11:5: '-'\n match(?-)\n\n end\n # at file 11:10: ( '0' .. '9' )+\n match_count_2 = 0\n loop do\n alt_2 = 2\n look_2_0 = @input.peek(1)\n\n if (look_2_0.between?(?0, ?9)) \n alt_2 = 1\n\n end\n case alt_2\n when 1\n # at line 11:11: '0' .. '9'\n match_range(?0, ?9)\n\n else\n match_count_2 > 0 and break\n eee = EarlyExit(2)\n\n\n raise eee\n end\n match_count_2 += 1\n end\n\n match(?.)\n # at file 11:26: ( '0' .. '9' )+\n match_count_3 = 0\n loop do\n alt_3 = 2\n look_3_0 = @input.peek(1)\n\n if (look_3_0.between?(?0, ?9)) \n alt_3 = 1\n\n end\n case alt_3\n when 1\n # at line 11:27: '0' .. '9'\n match_range(?0, ?9)\n\n else\n match_count_3 > 0 and break\n eee = EarlyExit(3)\n\n\n raise eee\n end\n match_count_3 += 1\n end\n\n # at line 11:38: ( EXPONENT )?\n alt_4 = 2\n look_4_0 = @input.peek(1)\n\n if (look_4_0 == ?E || look_4_0 == ?e) \n alt_4 = 1\n end\n case alt_4\n when 1\n # at line 11:38: EXPONENT\n exponent!\n\n end\n\n when 2\n # at line 12:5: DECIMAL EXPONENT\n decimal!\n exponent!\n\n end\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 2)\n\n end", "def test_float9\n token, value, rest = @c.lex(\" 0xabcdef.123p-17L boondocks\")\n assert_equal(:float, token)\n assert_equal('0xabcdef.123p-17L', value)\n assert_equal(' boondocks', rest)\n end", "def float(address)\n raise ArgumentError, \"the ipaddress: #{address} is not a valid ipaddress\" unless ipv4? address\n raise ArgumentError, \"the ipaddress: #{address} does not exist\" unless float? address\n networking.list_floating_ips.body['floatingips'].select { |float| float if float['floating_ip_address'] == address }.first\n end", "def convert_float(str)\n return nil if !str\n str.gsub! /[^0-9.]/, \"\"\n neg = str.match /\\((.*?)\\)/\n float = str.to_f\n neg ? -float : float\n end", "def numeric_check(first_num)\n Float(first_num) != nil rescue false\nend", "def float?(string)\n b = Float(string.tr(',', '.'))\n return b\nrescue ArgumentError\n return false\nend", "def get_float\n raise EOFError if @position + 4 > @size\n uval = @response[@position, 4].unpack('N*').first;\n @position += 4\n return ([uval].pack('L')).unpack('f*').first\n end", "def expf(f)\n typedecl f: Float, foreign: Float\n Math.exp(f)\n end", "def test_002_convert_float2\r\n\tresult = convert_float( '')\r\n\tassert close_enough( 0.0, result )\r\n end", "def assert_flequal(exp, actual, msg='')\r\n if exp == 0.0\r\n error = 1e-7\r\n else\r\n error = exp.abs/1e7\r\n end\r\n \r\n assert((exp - actual).abs < error, \r\n \"#{msg} Expected #{'%f' % exp} got #{'%f' % actual}\")\r\n end", "def to_float(value)\n return value.to_f if value.is_a?(Numeric)\n value = value.to_s if value.is_a?(Symbol)\n value.to_f if value.is_a?(String) && value.match?(NUMBER_PATTERN)\n end", "def test_float9\n token, value, rest = @c.lex(\" 0xabcdef.123p-17boondocks\")\n assert_equal(:float, token)\n assert_equal('0xabcdef.123p-17', value)\n assert_equal(' boondocks', rest)\n end", "def /(other)\n if other.is_a?(Value)\n other = other.to_f\n end\n if other.is_a?(Numeric)\n to_f / other\n else\n raise \"Unexpected argument (#{other.inspect})\"\n end\n end", "def float(limit = nil)\n Validation.new { |d| d.is_a?(Float) && in_range?(d, limit) }\n end", "def square_float(x)\n return x ** 2\nend", "def float_from_integral_significand_exponent(s,e)\n Float.context.Num(s,e)\nend", "def to_float_or_int(v)\n v.match('\\.').nil? ? Integer(v) : Float(v)\n end", "def _floatify(str, increment = true)\n if (( inf = str.to_s.match(/^([+-])?inf/i) ))\n (inf[1] == \"-\" ? -1.0 : 1.0) / 0.0\n elsif (( number = str.to_s.match(/^\\((-?\\d+)/i) ))\n number[1].to_i + (increment ? 1 : -1)\n else\n Float str.to_s\n end\n rescue ArgumentError\n raise Redis::CommandError, \"ERR value is not a valid float\"\n end", "def integer_or_float(x)\n if x.include?(\".\")\n return x.to_f\n else\n return x.to_i\n end\nend", "def get_float\n get_int.to_f / RAW_FLT_MAX\n end", "def typecast_value_float(value)\n Float(value)\n end", "def float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 34 )\n\n \n # - - - - main rule block - - - -\n # at line 344:5: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )? | '.' ( '0' .. '9' )+ ( EXPONENT )? | ( '0' .. '9' )+ EXPONENT )\n alt_12 = 3\n alt_12 = @dfa12.predict( @input )\n case alt_12\n when 1\n # at line 344:9: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( EXPONENT )?\n # at file 344:9: ( '0' .. '9' )+\n match_count_6 = 0\n while true\n alt_6 = 2\n look_6_0 = @input.peek( 1 )\n\n if ( look_6_0.between?( 0x30, 0x39 ) )\n alt_6 = 1\n\n end\n case alt_6\n when 1\n # at line 344:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_6 > 0 and break\n eee = EarlyExit(6)\n\n\n raise eee\n end\n match_count_6 += 1\n end\n\n match( 0x2e )\n # at line 344:25: ( '0' .. '9' )*\n while true # decision 7\n alt_7 = 2\n look_7_0 = @input.peek( 1 )\n\n if ( look_7_0.between?( 0x30, 0x39 ) )\n alt_7 = 1\n\n end\n case alt_7\n when 1\n # at line 344:26: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n break # out of loop for decision 7\n end\n end # loop for decision 7\n # at line 344:37: ( EXPONENT )?\n alt_8 = 2\n look_8_0 = @input.peek( 1 )\n\n if ( look_8_0 == 0x45 || look_8_0 == 0x65 )\n alt_8 = 1\n end\n case alt_8\n when 1\n # at line 344:37: EXPONENT\n exponent!\n\n end\n\n when 2\n # at line 345:9: '.' ( '0' .. '9' )+ ( EXPONENT )?\n match( 0x2e )\n # at file 345:13: ( '0' .. '9' )+\n match_count_9 = 0\n while true\n alt_9 = 2\n look_9_0 = @input.peek( 1 )\n\n if ( look_9_0.between?( 0x30, 0x39 ) )\n alt_9 = 1\n\n end\n case alt_9\n when 1\n # at line 345:14: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_9 > 0 and break\n eee = EarlyExit(9)\n\n\n raise eee\n end\n match_count_9 += 1\n end\n\n # at line 345:25: ( EXPONENT )?\n alt_10 = 2\n look_10_0 = @input.peek( 1 )\n\n if ( look_10_0 == 0x45 || look_10_0 == 0x65 )\n alt_10 = 1\n end\n case alt_10\n when 1\n # at line 345:25: EXPONENT\n exponent!\n\n end\n\n when 3\n # at line 346:9: ( '0' .. '9' )+ EXPONENT\n # at file 346:9: ( '0' .. '9' )+\n match_count_11 = 0\n while true\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0.between?( 0x30, 0x39 ) )\n alt_11 = 1\n\n end\n case alt_11\n when 1\n # at line 346:10: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_11 > 0 and break\n eee = EarlyExit(11)\n\n\n raise eee\n end\n match_count_11 += 1\n end\n\n exponent!\n\n end\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 34 )\n\n end", "def /(right)\n if @value.kind_of?(Integer) || @value.kind_of?(Float)\n return (@value / right)\n else\n raise OEDLIllegalCommandException.new(\"/\", \"Illegal operation, Experiment Property '#{@name}' not a float or integer.\")\n end\n end", "def /(right)\n if @value.kind_of?(Integer) || @value.kind_of?(Float)\n return (@value / right)\n else\n raise OEDLIllegalCommandException.new(\"/\", \"Illegal operation, Experiment Property '#{@name}' not a float or integer.\")\n end\n end", "def float\n little? ? read(4).unpack1('e') : read(4).unpack1('g')\n end", "def is_valid_float_param(param_name)\n # this is the equivalent one-liner ruby-style\n # true if Float params[param_name] rescue false\n begin\n Float(params[param_name])\n return true\n rescue\n return false\n end\n end", "def numeric(x)\n true if Float(x) rescue false\n end", "def fractional; end", "def non_negative_float(value, epsilon: nil)\n result = to_float(value) or return\n result unless epsilon ? (result < -epsilon) : result.negative?\n end", "def get_vertex_value(x)\n raise\n end", "def test_that_px_return_is_accurate\n end", "def ∞ℂ; ::Float::INFINITY_COMPLEX; end", "def tokenize_float_literal\n advance # Pass the .\n\n until( /[0-9eE]/.match( cchar ).nil? )\n if cchar == 'e' || cchar == 'E'\n return tokenize_exponent_literal\n end\n advance\n end\n capture_token( :float_literal )\n end", "def float?\n self.class.float?(self)\n end", "def test_set_z_as_float\n obj = Geom::Point3d.new\n obj.z = 1000.0\n result = obj.z\n expected = 1000.0\n assert_equal(expected, result, 'expected does not match result.')\n end", "def ret_d\n result = 0.0\n func = get_func(Fiddle::TYPE_DOUBLE)\n if func\n result = func.call(*@args).to_f\n end\n result\n end", "def float?(str)\n true if Float(str) rescue false\n end", "def float(name, options={})\n param(:float, name, options)\n end", "def test_NilClass_InstanceMethod_to_f\n\t\tassert_equal(0.0, nil.to_f)\n\tend", "def is_float?\n\t\tFloat(self) != nil rescue false\n\tend", "def assert_floatable *args\n args.each do |var|\n assert do\n var.not_nil? && var.is_a?(Numeric)\n end\n end\n end" ]
[ "0.6644832", "0.6538606", "0.65259284", "0.6385289", "0.6373016", "0.63188416", "0.6293305", "0.62895405", "0.62686646", "0.61740994", "0.61555135", "0.6135612", "0.6124431", "0.60668963", "0.606103", "0.6043514", "0.59881836", "0.5977649", "0.59574723", "0.5941438", "0.59347737", "0.5926709", "0.5925244", "0.5886259", "0.5877105", "0.58729875", "0.5869346", "0.58233553", "0.5807989", "0.5788201", "0.5787576", "0.5785777", "0.5783608", "0.5780924", "0.57762605", "0.5767901", "0.57612216", "0.5749196", "0.5748077", "0.5739968", "0.5733528", "0.5730014", "0.5692538", "0.56873137", "0.56873006", "0.56726843", "0.5671477", "0.5658617", "0.56430924", "0.5634755", "0.56240714", "0.56181866", "0.56100976", "0.56080997", "0.55995536", "0.5598832", "0.55901814", "0.55901796", "0.55880964", "0.5567275", "0.55478317", "0.5546692", "0.5540988", "0.55278945", "0.55226773", "0.550772", "0.55064476", "0.5492268", "0.54918313", "0.54828703", "0.54814696", "0.5477585", "0.5477128", "0.547353", "0.54710054", "0.5465487", "0.54614174", "0.5459003", "0.54576325", "0.54515743", "0.5449593", "0.54485804", "0.54485804", "0.5443167", "0.54421294", "0.5439317", "0.5431749", "0.54272175", "0.54206556", "0.54177535", "0.5413228", "0.53988796", "0.5398604", "0.5386738", "0.53839135", "0.5378257", "0.5378227", "0.53703666", "0.5366361", "0.5360139" ]
0.65456533
1
First step: Get OAuth2 Authorization code Once you created a Twitch application you can call this method with your own client_id and client_secret to generate a link to authorize the script to access your Twitch account. After completing the process you will be redirected to a URL including the OAuth2 Authorization Code
def generate_login_link Twitch::Client.new( client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET', scopes: ["channel:manage:broadcast"], token_type: :user ) rescue TwitchOAuth2::Error => e puts e.metadata[:link] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize\n return credentials if credentials\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n authorizer.get_and_store_credentials_from_code(\n user_id: user_id,\n code: code,\n base_url: OOB_URI\n )\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\"\n puts url\n puts \"\"\n puts \"paste code here:\"\n code = gets\n\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def get_auth_tokens(code)\n oauth_client = TwitchOAuth2::Client.new(\n client_id: 'YOUR_CLIENT_ID',\n client_secret: 'YOUR_CLIENT_SECRET',\n scopes: [\"channel:manage:broadcast\"]\n )\n\n puts oauth_client.token(token_type: :user, code: code)\nend", "def authenticate\n oauth2_client = Qbo.get_client\n callback = Setting.host_name + \"/qbo/oauth_callback/\" \n grant_url = oauth2_client.auth_code.authorize_url(redirect_uri: callback, response_type: \"code\", state: SecureRandom.hex(12), scope: \"com.intuit.quickbooks.accounting\")\n redirect_to grant_url\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code( user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize_url\n client = OAuth2::Client.new(client_id, client_secret, :site => oauth_url)\n client.auth_code.authorize_url(:redirect_uri => redirect_uri)\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\nend", "def authorize\n\tclient_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\tuser_id = 'default'\n\n\tcredentials = authorizer.get_credentials(user_id)\n\treturn credentials unless credentials.nil?\n\n\turl = authorizer.get_authorization_url(base_url: OOB_URI)\n\tputs 'Open the following URL in the browser and enter the ' \\\n\t\t \"resulting code after authorization:\\n#{url}\"\n\tcode = gets\n\n\treturn authorizer.get_and_store_credentials_from_code(\n\t\tbase_url: OOB_URI,\n\t\tuser_id: user_id,\n\t\tcode: code,\n\t)\n\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\r\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(base_url: OOB_URI)\r\n puts 'Open the following URL in the browser and enter the ' \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the \" \\\r\n \"resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI\r\n )\r\n end\r\n credentials\r\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\n end", "def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n\r\n # launch default browser to approve request of initial OAuth2 authorization\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n\r\n credentials\r\nend", "def authorize\n client_id = create_client_id\n token_store = create_token_store\n\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n Rails.logger.debug do\n 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n end\n Rails.logger.debug url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id:, code:, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n credentials = authorizer.get_credentials('default')\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n\n server = WEBrick::HTTPServer.new(Port: 3000)\n server.mount_proc('/oauth2callback') do |req, res|\n code = req.query['code']\n credentials = authorizer.get_and_store_credentials_from_code(user_id: 'default', code: code, base_url: OOB_URI)\n res.body = 'Authorization successful. You can close this window and return to the terminal.'\n server.shutdown\n end\n\n warn('Open the following URL in your browser and authorize the app:')\n warn(url)\n server.start\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = ask \"code?: \"\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n ##FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n if !File.exist?(CLIENT_SECRETS_PATH)\n puts \"Error: OAuth2認証用のsecretファイルが見つかりませんでした\"\n puts \"以下のURLからこのプロジェクト用のsecretを作成し、'client_secret.json'というファイル名でこのディレクトリに保存してください。\"\n puts\n puts \"https://console.developers.google.com/start/api?id=sheets.googleapis.com\"\n exit 1\n end\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"以下のURLにWebブラウザでアクセスし、認証を行った後、表示されるコードを入力してください:\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = $stdin.readline()\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def oauth_url_authorize\n return \"#{$SETTINGS[:oauth_server_url_authorize]}?response_type=code&client_id=#{$SETTINGS[:oauth_client_id]}&scope=ALL&redirect_uri=#{oauth_redirect_uri}\" \n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization:\\n' + url\n code = $stdin.gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def callback\n\n client = Signet::OAuth2::Client.new(client_options)\n client.code = params[:code]\n\n response = client.fetch_access_token!\n\n session[:authorization] = response\n redirect_to '/leagues/calendar/events/federicobucci504@gmail.com'\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(self.credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: self.token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def authorize\r\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\r\n\r\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\r\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\r\n authorizer = Google::Auth::UserAuthorizer.new(\r\n client_id, SCOPE, token_store)\r\n user_id = 'default'\r\n credentials = authorizer.get_credentials(user_id)\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url(\r\n base_url: OOB_URI)\r\n puts \"Open the following URL in the browser and enter the \" +\r\n \"resulting code after authorization\"\r\n puts url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(\r\n user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n credentials\r\nend", "def oauth2_callback\n # Swap Auth token for an access token\n token = oauth2_client.auth_code.get_token(params[:code])\n\n # Remember the access token\n session[:access_token] = token.token\n redirect_to repo_index_path\n end", "def authorize\n\n # redirect to kpass for authorization (and authentication if they're not\n # signed in.)\n # \n \n\n authorize_url = \"#{ENV['KPASS_ENDPOINT']}/oauth/authorize?app_id=#{ENV['KPASS_APP_ID']}\"\n redirect_to authorize_url\n end", "def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end", "def authorize_url\n @oauth_client.auth_code.authorize_url(:redirect_uri => @redirect_uri, :scope => site_url)\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\\n\"\n puts url\n print \"\\nCode: \"\n code = gets\n puts\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def get_request_auth_code_url\n URI.encode(\"https://#{@subdomain}.zendesk.com/oauth/authorizations/new?response_type=code&redirect_uri=#{@redirect_uri}/&client_id=#{@unique}&scope=read%20write\")\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def exchange_code(authorization_code)\n\t\tclient_secrets = Google::APIClient::ClientSecrets.load(CLIENT_SECRET_PATH)\n client = client_secrets.to_authorization \n client.update!(redirect_uri: 'postmessage')\n client.code = authorization_code\n \n\t begin\n\t # client.authorization.fetch_access_token!\n\t client.fetch_access_token!\n\t return client\n\t rescue Signet::AuthorizationError\n\t raise CodeExchangeError.new(nil)\n\t end\n\tend", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' +\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.\n new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.\n new(client_id, SCOPE, token_store)\n credentials = authorizer.\n get_credentials(CONFIGURATION[\"calendar\"][\"user_id\"])\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \"\\\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: CONFIGURATION[\"calendar\"][\"user_id\"],\n code: code,\n base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n \n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\n end", "def get_authorization_url\n $LOG.i \"requesting authorization URL\"\n \n @oauth2_client.auth_code.authorize_url(:redirect_uri => @config.redirect_uri)\n end", "def oauth\n request_token = @oauth_consumer.get_request_token\n authorize_url = request_token.authorize_url(:oauth_consumer_key => \n Netflix::Client.consumer_key)\n Launchy.open(authorize_url)\n puts \"Go to browser, a page has been opened to establish oauth\"\n printf \"Pin from Netflix:\"\n pin = gets.chomp\n access_token = request_token.get_access_token(:oauth_verifier => pin)\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(@credentials_path)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @token_path)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @scope, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: @oob_uri)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @oob_uri\n )\n end\n credentials\n end", "def authorize\n\tFileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n\tclient_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n\ttoken_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n\tauthorizer = Google::Auth::UserAuthorizer.new(\n\t\tclient_id, SCOPE, token_store)\n\tuser_id = 'default'\n\tcredentials = authorizer.get_credentials(user_id)\n\tif credentials.nil?\n\t\turl = authorizer.get_authorization_url(\n\t\t\tbase_url: OOB_URI)\n\t\tputs \"Open the following URL in the browser and enter the \" +\n\t\t\"resulting code after authorization\"\n\t\tputs url\n\t\tcode = STDIN.gets\n\t\tcredentials = authorizer.get_and_store_credentials_from_code(\n\t\t\tuser_id: user_id, code: code, base_url: OOB_URI)\n\tend\n\tcredentials\nend", "def authorization_url\n url = \"#{host}/OAuth2AccessRequest.action?response_type=code&client_id=#{@client_id}\"\n url += \"&redirect_uri=#{Addressable::URI.escape(@redirect_uri)}\" if @redirect_uri\n url += \"&state=#{@state}\" if @state\n url\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n # client_id = Google::Auth::ClientId.from_hash(Rails.application.config.gdrive_secrets)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(\n client_id, SCOPE, token_store\n )\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: OOB_URI\n )\n puts 'Open the following URL in the browser and enter the ' \\\n 'resulting code after authorization'\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def get_access\n path = '/v3/oauth/authorize'\n data = \"consumer_key=#{Consumer_key}&code=#{Token}\"\n return pocket_api(path,data)\nend", "def step2\n initialize_vars\n url = \"#{@oauth_vars[:token_url]}?code=#{params[:code]}&grant_type=authorization_code&client_id=#{@oauth_vars[:client_id]}&client_secret=#{@oauth_vars[:client_secret]}&response_type=code&redirect_uri=#{@redirect_uri}\"\n rep = JSON.parse(get_json_from_https(url))\n session[:access_token] = rep[\"access_token\"]\n\n do_API_call\n end", "def codeExchange(code)\n # Upgrade the code into a token object.\n $authorization.code = code\n $authorization.fetch_access_token!\n $client.authorization = $authorization\n\n # TODO: move into verify_token function\n id_token = $client.authorization.id_token\n encoded_json_body = id_token.split('.')[1]\n\n # Base64 must be a multiple of 4 characters long, trailing with '='\n encoded_json_body += (['='] * (encoded_json_body.length % 4)).join('')\n json_body = Base64.decode64(encoded_json_body)\n body = JSON.parse(json_body)\n\n # You can read the Google user ID in the ID token.\n # \"sub\" represents the ID token subscriber which in our case\n # is the user ID. This sample does not use the user ID.\n gplus_id = body['sub']\n puts \"User ID: \"\n puts gplus_id.inspect\n\n # Serialize and store the token in the user's session.\n token_pair = TokenPair.new\n token_pair.update_token!($client.authorization)\n\n puts token_pair.inspect\nend", "def callback\n access_token = client.web_server.get_access_token(params[:code], :redirect_uri => oauth_callback_url)\n \n current_user.update_attribute(:oauth2_token, access_token.token)\n flash[:notice] = \"Authorized successfully!\"\n \n redirect_to root_url\n end", "def oauth\n if params[:code]\n token_response = get_user_tokens(params[:code])\n signup_or_login(token_response)\n end\n\n render json: params\n end", "def authorization_url\n uri = URI(OAUTH_URL)\n uri.query = {\n client_id: client_id,\n redirect_uri: redirect_uri,\n scope: scope_url,\n response_type: 'code',\n access_type: 'offline'\n }.to_param\n\n uri.to_s\n end", "def oauth_authorize\n redirect_to facebook_client.authorize(oauth_callback_url)\n end", "def authorize\n FileUtils.mkdir_p(File.dirname(@CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(@CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: @CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, @SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(\n base_url: @OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization\"\n puts url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: @OOB_URI)\n end\n credentials\n end", "def authenticate!\n @client = Octokit::Client.new\n url = @client.authorize_url(CLIENT_ID)\n redirect url\nend", "def authorize_application\n # init auth state and oauth url..enter wormhole\n oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET, GIFT_AUTH_CALLBACK)\n encoded_auth_state = create_auth_state\n oauth_url = create_oauth_url(oauth.oauth_callback_url, encoded_auth_state)\n redirect_to(:action => \"exit_portal\", :url => oauth_url) and return\n end", "def authorize(callback_url, code)\n data = open(\"#{BASE_URL}/oauth/access_token?client_id=#{app_id}&redirect_uri=#{CGI.escape callback_url}&client_secret=#{app_secret}&code=#{CGI.escape code}\").read\n \n # The expiration date is not necessarily set, as the app might have\n # requested offline_access to the data\n match_data = data.match(/expires=([^&]+)/)\n @expires = match_data && match_data[1] || nil\n \n # Extract the access token\n @access_token = data.match(/access_token=([^&]+)/)[1]\n end", "def authorize(callback_url, code)\n data = open(\"#{BASE_URL}/oauth/access_token?client_id=#{app_id}&redirect_uri=#{CGI.escape callback_url}&client_secret=#{app_secret}&code=#{CGI.escape code}\").read\n \n # The expiration date is not necessarily set, as the app might have\n # requested offline_access to the data\n match_data = data.match(/expires=([^&]+)/)\n @expires = match_data && match_data[1] || nil\n \n # Extract the access token\n @access_token = data.match(/access_token=([^&]+)/)[1]\n end", "def authorize_cli\n authenticate_user!\n if params[:response_type].nil?\n params[:response_type] = \"code\"\n end\n @authorizer = OAuth::Provider::Authorizer.new current_user, true, params\n client_application = ClientApplication.find_by_key(params[:client_id])\n statsd = StatsManager.new\n statsd.feedAuthorizeMetric(current_user, client_application)\n render :text => @authorizer.code.token\n end", "def authorize interactive\n FileUtils.mkdir_p(File.dirname(CREDENTIALS_PATH))\n client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil? and interactive\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n code = ask(\"Open the following URL in the browser and enter the resulting code after authorization\\n\" + url)\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI)\n end\n credentials\nend", "def oauth_callback\n if params[:state].present?\n oauth2_client = Qbo.get_client\n # use the state value to retrieve from your backend any information you need to identify the customer in your system\n redirect_uri = Setting.host_name + \"/qbo/oauth_callback/\"\n if resp = oauth2_client.auth_code.get_token(params[:code], redirect_uri: redirect_uri)\n \n # Remove the last authentication information\n Qbo.delete_all\n \n # Save the authentication information \n qbo = Qbo.new\n qbo.company_id = params[:realmId]\n \n # Generate Access Token & Serialize it into the database\n access_token = OAuth2::AccessToken.new(oauth2_client, resp.token, refresh_token: resp.refresh_token)\n qbo.token = access_token.to_hash\n qbo.expire = 1.hour.from_now.utc\n \n if qbo.save!\n redirect_to qbo_sync_path, :flash => { :notice => \"Successfully connected to Quickbooks\" }\n else\n redirect_to plugin_settings_path(:redmine_qbo), :flash => { :error => \"Error\" }\n end\n \n end\n end\n end", "def get_new_access_token\n client, auth = google_api_client_auth\n print(\"1. Open this page:\\n%s\\n\\n\" % auth.authorization_uri)\n print(\"2. Enter the authorization code shown in the page: \")\n system( 'open \"'+auth.authorization_uri+'\"' )\n auth.code = $stdin.gets.chomp\n auth.fetch_access_token!\n auth.access_token\n end", "def authorize_url(params={})\n # response_type param included by default by using the OAuth 2.0\n # auth_code strategy\n # client_id param included automatically by the OAuth 2.0 gem\n params[:state] ||= state\n params[:redirect_uri] ||= \"http://localhost\"\n oauth2_client.auth_code.authorize_url(params)\n rescue OAuth2::Error => e\n raise LinkedIn::Errors::UnauthorizedError.new(e.code), e.description\n end", "def authorize_code(authorization_code)\n client.authorization.code = authorization_code\n client.authorization.fetch_access_token!\n client.authorization.refresh_token ||= oauth_data[:refresh_token]\n oauth_data[:refresh_token] = client.authorization.refresh_token\n end", "def authorize(token_path, scope)\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: token_path\n authorizer = Google::Auth::UserAuthorizer.new client_id, scope, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize_browser(token=nil)\n client_id = \"adapter\"\n @usrname = \"user\"\n pwd = \"1234\"\n grt_type = \"password\"\n\n query = \"response_type=code&scope=openid%20profile&client_id=adapter&redirect_uri=http://127.0.0.1:8081/auth\"\n http_path = \"http://localhost:8081/auth/realms/master/protocol/openid-connect/auth\" + \"?\" + query\n url = URI(http_path)\n http = Net::HTTP.new(url.host, url.port)\n request = Net::HTTP::Get.new(url.to_s)\n #request[\"authorization\"] = 'bearer ' + token\n\n response = http.request(request)\n # p \"RESPONSE\", response.body\n\n File.open('codeflow.html', 'wb') do |f|\n f.puts response.read_body\n end\nend", "def authorize\n redirect \"https://accounts.spotify.com/authorize/?client_id=#{ENV['clientid']}&response_type=code&redirect_uri=#{$redirect_uri_base}%2Fcallback%23playlist&scope=playlist-modify-public%20playlist-modify-private%20user-read-private&state=34fFs29kd09\"\nend", "def create_client_from_outhAccount(scope, oob_uri, user_id, oauth_cred_file)\n #oob_uri = 'urn:ietf:wg:oauth:2.0:oob'\n #user_id = 'eyemole@gmail.com'\n client_id = Google::Auth::ClientId.from_file(oauth_cred_file)\n token_store = Google::Auth::Stores::FileTokenStore.new(:file => 'tokens.yaml')\n authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: oob_uri )\n #Launchy.open(url)\n puts \"Open this URL in Browser and enter the code you got from browser below\"\n puts \"URL: #{url}\"\n print \"enter the code you got from browser here and press Enter: \"\n # code = gets\n code = STDIN.gets.chomp\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: oob_uri)\n end\n blogger = Google::Apis::BloggerV3::BloggerService.new\n blogger.authorization = credentials\n return blogger\nend", "def oauth_access\n client = Fitgem::Client.new({:consumer_key => @consumer_key, :consumer_secret => @consumer_secret})\n\n request_token = client.request_token\n token = request_token.token\n secret = request_token.secret\n\n puts \"Go to http://www.fitbit.com/oauth/authorize?oauth_token=#{token} and then enter the verifier code below and hit Enter\"\n verifier = gets.chomp\n\n access_token = client.authorize(token, secret, { :oauth_verifier => verifier })\n\n puts \"Verifier is: \"+verifier\n puts \"Token is: \"+access_token.token\n puts \"Secret is: \"+access_token.secret\n\n token = access_token.token\n secret = access_token.secret\n user_id = '3B8C8S'\n\n client = Fitgem::Client.new({:consumer_key => @consumer_key, :consumer_secret => @consumer_secret, :token => token, :secret => secret, :user_id => user_id})\n access_token = client.reconnect(token, secret)\n # Pass client to runner here\n client\n end", "def exchange_code(authorization_code)\n client = Google::APIClient.new\n client.authorization = client_secrets\n client.authorization.code = authorization_code\n\n begin\n client.authorization.fetch_access_token!\n return client.authorization\n rescue Signet::AuthorizationError\n raise CodeExchangeError.new(nil)\n end\nend" ]
[ "0.6999043", "0.6935346", "0.69292057", "0.6870849", "0.6834623", "0.68290114", "0.6819623", "0.6817486", "0.6813613", "0.6813613", "0.6813613", "0.6813613", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.6810486", "0.68061507", "0.6803647", "0.67969096", "0.67969096", "0.6786476", "0.67727333", "0.6753433", "0.6753433", "0.67436016", "0.67430955", "0.67420036", "0.67260104", "0.6710875", "0.6707963", "0.6706231", "0.669251", "0.66912675", "0.66870177", "0.66825867", "0.66538954", "0.6650144", "0.6639923", "0.6627934", "0.6620492", "0.66128504", "0.65995425", "0.6597393", "0.6594954", "0.6593446", "0.6593446", "0.6593446", "0.6593446", "0.6593446", "0.6593446", "0.6578815", "0.6564006", "0.6545958", "0.6534581", "0.652318", "0.6516267", "0.6507883", "0.65029675", "0.64860517", "0.64488226", "0.64454395", "0.64251", "0.6411052", "0.64059544", "0.6402278", "0.63995254", "0.63965255", "0.6394581", "0.6381389", "0.6374448", "0.6371377", "0.63641465", "0.636403", "0.63567454", "0.63447255", "0.6343092", "0.6331431", "0.6329529", "0.6303689", "0.6297781", "0.6297781", "0.6296765", "0.6295983", "0.6283695", "0.6274147", "0.62643784", "0.6262807", "0.6262577", "0.62595063", "0.62511206", "0.6247893", "0.62348706", "0.62296236" ]
0.6419732
69
Second step: Get OAuth2 Access and Refresh tokens With the Authorization code obtained in the previous step, you can get the access_token and the refresh_token
def get_auth_tokens(code) oauth_client = TwitchOAuth2::Client.new( client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET', scopes: ["channel:manage:broadcast"] ) puts oauth_client.token(token_type: :user, code: code) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def step2\n initialize_vars\n url = \"#{@oauth_vars[:token_url]}?code=#{params[:code]}&grant_type=authorization_code&client_id=#{@oauth_vars[:client_id]}&client_secret=#{@oauth_vars[:client_secret]}&response_type=code&redirect_uri=#{@redirect_uri}\"\n rep = JSON.parse(get_json_from_https(url))\n session[:access_token] = rep[\"access_token\"]\n\n do_API_call\n end", "def get_access_tokens(authorization_grant_code)\n # headers = { 'Content-Type': 'application/x-www-form-urlencoded' } # turns out didn't need this\n params = {\n 'grant_type': 'authorization_code',\n 'access_type': 'offline',\n 'code': authorization_grant_code,\n 'client_id': client_id,\n 'redirect_uri': redirect_uri\n }\n response = HTTParty.post(\n 'https://api.tdameritrade.com/v1/oauth2/token',\n body: params\n )\n\n if response.status == 200\n @access_token = response[\"access_token\"]\n @refresh_token = response[\"refresh_token\"]\n end\n\n response\n end", "def get_access_token(authz_code = nil)\n if @config.grant_type == 'client_credentials'\n $LOG.i \"getting access token\"\n\t @access_token = @oauth2_client.client_credentials.get_token\n $LOG.i \"got access token\", @access_token\n else\n $LOG.i \"getting access and refresh token pair\"\n\t @access_token = @oauth2_client.auth_code.get_token(authz_code, :redirect_uri => @config.redirect_uri)\n $LOG.i \"got access and refresh token pair\", @access_token\n end\n\n\trefresh_config_from_access_token\n\n\t@access_token\n end", "def oauth2_callback\n # Swap Auth token for an access token\n token = oauth2_client.auth_code.get_token(params[:code])\n\n # Remember the access token\n session[:access_token] = token.token\n redirect_to repo_index_path\n end", "def access_token\n creds = JSON.parse(File.read(FILE_CREDS))\n authorization = Google::Auth::UserRefreshCredentials.new(\n client_id: creds['installed']['client_id'],\n client_secret: creds['installed']['client_secret'],\n scope: SCOPE,\n refresh_token: refresh_token,\n expires_at: (Time.now+100).utc,\n grant_type: 'authorization_code')\n authorization.fetch_access_token!\n authorization.access_token\nend", "def authenticate\n # if valid_access_token?\n # fetch_access_token\n # else\n get_new_access_token\n # end\n end", "def authorize_code(authorization_code)\n client.authorization.code = authorization_code\n client.authorization.fetch_access_token!\n client.authorization.refresh_token ||= oauth_data[:refresh_token]\n oauth_data[:refresh_token] = client.authorization.refresh_token\n end", "def fetch_access_token\n client.unauthenticated_request(:POST, '/v1/security/oauth2/token',\n grant_type: 'client_credentials',\n client_id: client.client_id,\n client_secret: client.client_secret)\n end", "def get_tokens\n\t\tresource = \"/oauth/access_token\"\n\t\t\n\t\tbegin\n\t\t\tresponse = @connection.post resource do |request|\n\t\t\t\trequest.params['client_id'] = @api_key\n\t\t\t\trequest.params['client_secret'] = @secret_key\n\t\t\t\trequest.params['grant_type'] = @grant_type\n\t\t\t\trequest.params['scope'] = @scope\n\t\t\tend\n\t\t\t\n\t\t\tresult = process_response(response)\n\t\t\t\n\t\t\tif result[:access_token].nil? || result[:refresh_token].nil?\n\t\t\t\traise RuntimeError, \"Unable to complete oauth: #{response[:error]}\"\n\t\t\telse \n\t\t\t\t@access_token = result[:access_token]\n\t\t\t\t@refresh_token = result[:refresh_token]\n\t\t\tend\n\t\trescue => e\n\t\t\traise RuntimeError, e.to_s\n\t\tend\n\tend", "def get_access_token(auth_code)\n @access_token = @oauth_client.auth_code.get_token(auth_code, :redirect_uri => @redirect_uri)\n @token = @access_token.token\n @refresh_token = @access_token.refresh_token\n @token_expires_at = @access_token.expires_at\n end", "def get_tokens\n resource = \"/oauth/access_token\"\n\n begin\n response = @connection.post resource do |request|\n request.params['client_id'] = @api_key\n request.params['client_secret'] = @secret_key\n request.params['grant_type'] = @grant_type\n request.params['scope'] = 'SPEECH,STTC,TTS'\n end\n\n result = process_response(response)\n\n if result[:access_token].nil? || result[:refresh_token].nil?\n raise RuntimeError, \"Unable to complete oauth: #{response[:error]}\"\n else\n @access_token = result[:access_token]\n @refresh_token = result[:refresh_token]\n end\n rescue => e\n raise RuntimeError, e.to_s\n end\n end", "def fetch_tokens(auth_code, save=false)\n\t\t@client ||= api_client()\n @client.authorization.code = auth_code\n @client.authorization.fetch_access_token!\n\n self.refresh_token = @client.authorization.refresh_token\n \tself.access_token = @client.authorization.access_token\n \tself.expires_in = @client.authorization.expires_in\n \tself.issued_at = @client.authorization.issued_at\n\n \tself.save() if save\n\tend", "def request_tokens(auth_code)\n @token = @oauth_client.auth_code.get_token auth_code, redirect_uri: @url\n tokens\n end", "def oauth_complete(code)\n # Let's compile the API URL we're calling.\n url = PUTIO_BASE_URL + \"/oauth2/access_token?client_id=%i&client_secret=%s&grant_type=authorization_code&redirect_uri=%s&code=%s\" % [@client_id, @application_secret, @redirect_uri, code]\n \n # And call it.\n response = Curl::Easy.perform(url) do |req|\n req.headers['Accept'] = 'application/json'\n end\n\n # Use Crack to parse the JSON\n response = JSON.parse(response.body_str)\n\n # And use Hashie to present it.\n response = Hashie::Mash.new(response)\n\n # Save it locally.\n @access_token = response.access_token\n\n # Return it\n response\n end", "def find_oauth_access_token\n end", "def get_new_refresh_token\n\t\tclient = OAuth2::Client.new(\n\t\t\tCLIENT_ID, CLIENT_SECRET,\n\t\t\t:site => \"https://accounts.google.com\",\n\t\t\t:token_url => \"/o/oauth2/token\",\n\t\t\t:authorize_url => \"/o/oauth2/auth\")\n\n\t\tauth_url = client.auth_code.authorize_url(\n\t\t\t:redirect_uri => \"http://localhost\",\n\t\t\t:scope =>\n\t\t\t\"https://docs.google.com/feeds/ \" +\n\t\t\t\"https://docs.googleusercontent.com/ \" +\n\t\t\t\"https://spreadsheets.google.com/feeds/\")\n\n\t\tputs auth_url\n\n\t\tprint \"authorization code:\"\n\t\tauthorization_code = STDIN.gets.chomp\n\n\t\tcmd = \"curl -d client_id=#{CLIENT_ID} -d client_secret=#{CLIENT_SECRET} -d redirect_uri=http://localhost -d grant_type=authorization_code -d code=#{authorization_code} https://accounts.google.com/o/oauth2/token\"\n\t\tJSON.parse( `#{cmd}` )[\"refresh_token\"]\n\tend", "def get_new_access_token\n client, auth = google_api_client_auth\n print(\"1. Open this page:\\n%s\\n\\n\" % auth.authorization_uri)\n print(\"2. Enter the authorization code shown in the page: \")\n system( 'open \"'+auth.authorization_uri+'\"' )\n auth.code = $stdin.gets.chomp\n auth.fetch_access_token!\n auth.access_token\n end", "def get_access_token(code:, redirect_uri: nil)\n query = {\n code: code,\n client_id: @client_id,\n client_secret: @client_secret,\n redirect_uri: redirect_uri\n }.compact\n response = HTTParty.get(\"https://slack.com/api/oauth.v2.access\", query: query)\n JSON.parse(response.body, symbolize_names: true)\n end", "def authorize_code(authorization_code)\n api_client.authorization.code = authorization_code\n api_client.authorization.fetch_access_token!\n\n result = api_client.execute!(:api_method => settings.oauth2.userinfo.get)\n user = User.first_or_create(:email => result.data.email)\n api_client.authorization.refresh_token = (api_client.authorization.refresh_token || user.refresh_token)\n if user.refresh_token != api_client.authorization.refresh_token\n user.refresh_token = api_client.authorization.refresh_token\n user.save\n end\n session[:user_id] = user.id\nend", "def obtain_tokens(fqdn, client_id, client_secret, scope, tokens_file)\n read_tokens(tokens_file)\n \n response = RestClient.post \"#{fqdn}/oauth/access_token\", :grant_type => 'client_credentials', :client_id => client_id, :client_secret => client_secret, :scope => scope\n\t\n from_json = JSON.parse(response.to_str)\n @access_token = from_json['access_token']\n @refresh_token = from_json['refresh_token']\n write_tokens(tokens_file)\nend", "def get_access\n path = '/v3/oauth/authorize'\n data = \"consumer_key=#{Consumer_key}&code=#{Token}\"\n return pocket_api(path,data)\nend", "def get_google_access_token(oauth)\n client = Google::APIClient.new(application_name: oauth[:app_name], application_version: oauth[:app_version])\n auth = client.authorization\n auth.client_id = oauth[:client_id]\n auth.client_secret = oauth[:client_secret]\n auth.scope = 'https://www.googleapis.com/auth/drive https://spreadsheets.google.com/feeds/'\n auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'\n if File.exist? TOKEN_CACHE\n auth.refresh_token = YAML.load(File.read(TOKEN_CACHE))\n else\n print(\"1. Open this page:\\n%s\\n\\n\" % auth.authorization_uri)\n print('2. Enter the authorization code shown: ')\n open_browser(auth.authorization_uri)\n auth.code = $stdin.gets.chomp\n end\n auth.fetch_access_token!\n File.open(TOKEN_CACHE, 'w') {|f| f.write(YAML.dump(auth.refresh_token)) }\n auth.access_token\nend", "def get_access_token_from_auth_code(auth_code, client_id, client_secret, redirect_uri, environment = nil)\n environment ||= \"mypurecloud.com\"\n\n tokenFormData = {\n \"grant_type\" => \"authorization_code\",\n \"code\" => auth_code,\n \"redirect_uri\" => redirect_uri\n }\n\n tokenResponse =JSON.parse RestClient.post \"https://#{client_id}:#{client_secret}@login.#{environment}/token\", tokenFormData\n\n return tokenResponse['access_token'];\n end", "def get_access_token()\n url = URI.parse(TOKEN_ENDPOINT)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n req = Net::HTTP::Post.new(url.path)\n req.basic_auth(@clientId, @clientSecret)\n req.set_form_data({'grant_type' => 'client_credentials'})\n res = http.request(req)\n JSON.parse(res.body)['access_token']\n end", "def fetch_token(code, redirect_uri)\n @access_token_obj = @auth_client.auth_code.get_token(code, {\n :redirect_uri => redirect_uri,\n :token_method => :post\n })\n end", "def oauth_data(code:)\n res = uphold_conn.post do |req|\n req.url UPHOLD_AUTHENTICATION_PATH\n req.headers['Authorization'] = ActionController::HttpAuthentication::Basic.encode_credentials(client_id, client_secret)\n req.respond_to? :json, content_type: /\\b(?i:json)$/\n req.headers['Content-Type'] = 'application/x-www-form-urlencoded'\n req.body = URI.encode_www_form({code: code, grant_type: 'authorization_code'})\n end\n JSON.parse(res.body, symbolize_names: true).tap do |body|\n @access_token = body[:access_token]\n end\n end", "def get_access_token\n uri = URI.parse(@token_url)\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n auth = Base64.encode64(@login + ':' + @password).gsub(\"\\n\", \"\")\n req['Authorization'] = \"Basic #{auth}\"\n send = 'grant_type=client_credentials'\n req.body = send\n res = http.request(req)\n if res.code == \"200\"\n data = res.body\n result = JSON.parse(data)\n @access_token = result['access_token']\n else\n puts \"Invalid getting access token\"\n exit\n end\n end", "def get_token\n oauth = LinkedIn::OAuth2.new\n url = oauth.auth_code_url\n visit url\n\n form = find('form', class: 'grant-access')\n within form do\n fill_in('session_key-oauth2SAuthorizeForm', with: Rails.configuration.linkedin_email)\n fill_in('session_password-oauth2SAuthorizeForm', with: Rails.configuration.linkedin_password)\n end\n\n find(\"input[type=submit]\").hover\n find(\"input[type=submit]\").trigger(:click)\n\n print \"fetching code\"\n count = 0\n while !page.current_url.include?('code=')\n count += 1\n print \".\" if count & 50 == 0\n end\n\n puts\n url = page.current_url\n code = CGI.parse(URI.parse(url).query)['code'].first\n\n acess_token = oauth.get_access_token(code)\n puts acess_token\n end", "def exchange_code(authorization_code)\n client = Google::APIClient.new\n client.authorization = client_secrets\n client.authorization.code = authorization_code\n\n begin\n client.authorization.fetch_access_token!\n return client.authorization\n rescue Signet::AuthorizationError\n raise CodeExchangeError.new(nil)\n end\nend", "def obtain_access_token(authorization_code_or_refresh_token, scope = nil)\n # Authorization codes always start with \"O\" and refresh tokens always start with \"R\".\n if authorization_code_or_refresh_token[0] == \"O\"\n data = { \"grant_type\" => \"authorization_code\", \"code\" => authorization_code_or_refresh_token }\n data[\"redirect_uri\"] = @redirect_uri unless @redirect_uri.nil?\n elsif authorization_code_or_refresh_token[0] == \"R\"\n data = { \"grant_type\" => \"refresh_token\", \"refresh_token\" => authorization_code_or_refresh_token }\n data[\"scope\"] = scope unless scope.nil?\n end\n return query_api(\"/auth/token\", data)\n end", "def obtain_access_token(authorization_code_or_refresh_token, scope = nil)\n # Authorization codes always start with \"O\" and refresh tokens always start with \"R\".\n if authorization_code_or_refresh_token[0] == \"O\"\n data = { \"grant_type\" => \"authorization_code\", \"code\" => authorization_code_or_refresh_token }\n data[\"redirect_uri\"] = @redirect_uri unless @redirect_uri.nil?\n elsif authorization_code_or_refresh_token[0] == \"R\"\n data = { \"grant_type\" => \"refresh_token\", \"refresh_token\" => authorization_code_or_refresh_token }\n data[\"scope\"] = scope unless scope.nil?\n end\n return query_api(\"/auth/token\", data)\n end", "def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: Rails.application.secrets.FORGE_CLIENT_ID,\n client_secret: Rails.application.secrets.FORGE_CLIENT_SECRET,\n grant_type:'client_credentials',scope:'data:read data:write bucket:create'\n \n })\n return JSON.parse(response.body)['access_token']\n end", "def refresh_token(code=nil)\n body = {}\n body[:code] = code unless code.nil?\n\n @client.client_credentials.get_token(\n headers: { 'Authorization' => 'Basic' })\n end", "def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend", "def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: CLIENT_ID, client_secret: CLIENT_SECRET, grant_type:'client_credentials',scope:'data:read data:write bucket:create' })\n return JSON.parse(response.body)['access_token']\nend", "def get_credentials_from_code options = {}\n user_id = options[:user_id]\n code = options[:code]\n scope = options[:scope] || @scope\n base_url = options[:base_url]\n credentials = UserRefreshCredentials.new(\n client_id: @client_id.id,\n client_secret: @client_id.secret,\n redirect_uri: redirect_uri_for(base_url),\n scope: scope\n )\n credentials.code = code\n credentials.fetch_access_token!({})\n monitor_credentials user_id, credentials\n end", "def get_token(code)\n uri = URI.parse(URL[\"oauth_access\"])\n params = { :client_id => CLIENT_ID,\n :client_secret => CLIENT_SECRET,\n :code => code\n }\n uri.query = URI.encode_www_form( params )\n return JSON.parse(uri.open.read)\n end", "def get_access_token(auth_code, redirect_uri)\n json = post('/oauth2/token', nil, {'client_id' => client_id, 'client_secret' => client_secret, 'redirect_uri' => redirect_uri, 'code' => auth_code })\n raise WepayClient::Exceptions::AccessTokenError.new(\"A problem occurred trying to get the access token: #{json.inspect}\", json[:error_code]) unless json.has_key?(:access_token)\n json\n end", "def get_access(params: nil, host:)\n result = TokenAdapter.new.(client_id: ENV['CLIENT_ID'],\n secret: ENV['CLIENT_SECRET'],\n code: params[:code],\n code_verifier: extract_verifier(params),\n redirect_uri: redirect_callbacks_url(host: host))\n {id_token: validate_id_token(result[\"id_token\"]), result: result}\n end", "def codeExchange(code)\n # Upgrade the code into a token object.\n $authorization.code = code\n $authorization.fetch_access_token!\n $client.authorization = $authorization\n\n # TODO: move into verify_token function\n id_token = $client.authorization.id_token\n encoded_json_body = id_token.split('.')[1]\n\n # Base64 must be a multiple of 4 characters long, trailing with '='\n encoded_json_body += (['='] * (encoded_json_body.length % 4)).join('')\n json_body = Base64.decode64(encoded_json_body)\n body = JSON.parse(json_body)\n\n # You can read the Google user ID in the ID token.\n # \"sub\" represents the ID token subscriber which in our case\n # is the user ID. This sample does not use the user ID.\n gplus_id = body['sub']\n puts \"User ID: \"\n puts gplus_id.inspect\n\n # Serialize and store the token in the user's session.\n token_pair = TokenPair.new\n token_pair.update_token!($client.authorization)\n\n puts token_pair.inspect\nend", "def get_access_token(code, _options = {})\n conn = Faraday.new(url: base_url) do |faraday|\n faraday.request :url_encoded\n faraday.adapter Faraday.default_adapter\n end\n params = access_token_params(code)\n conn.post do |req|\n req.url \"/api/oauth2/token\"\n req.body = params\n req.headers[\"Accept\"] = \"application/json\"\n end\n end", "def exchange_token(request)\n Rails.logger.debug \"Auth : #{$authorization}\"\n $authorization.code = request.body.read\n $authorization.fetch_access_token!\n $client.authorization = $authorization\n\n # Verify the issued token matches the user and client.\n oauth2 = $client.discovered_api('oauth2','v2')\n tokeninfo = JSON.parse($client.execute(oauth2.tokeninfo,\n :access_token => $client.authorization.access_token,\n :id_token => $client.authorization.id_token).response.body)\n\n # Serialize and store the token in the user's session.\n token_pair = GooglePlusSignInHelper::TokenPair.new\n token_pair.update_token!($client.authorization)\n\n return tokeninfo, token_pair\n end", "def get_auth_token\n log_step \"start\", \"get_auth_token\"\n login_url = \"https://login.microsoft.com\"\n token_url = \"#{login_url}/#{@tenant}/oauth2/token?api-version=1.0\"\n body = {\n client_id: @client_id,\n client_secret: @client_secret,\n grant_type: 'client_credentials',\n resource: @resource\n }\n response = HTTParty.post \"#{token_url}\", body: body\n @access_token = response['access_token']\n log_step 'auth_token', @access_token\nend", "def get_access_token\n @oauth_access_token = oauth_request.get_access_token\n @authenticated_user_uri = oauth_consumer.token_request_response[\"Content-Location\"]\n end", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend", "def access_token\n Rails.cache.fetch(\"googl_access_token\", expires_in: 50.minutes) do \n request = { query: { client_id: ENV['GOOGL_CLIENT_ID'],\n client_secret: ENV['GOOGL_CLIENT_SECRET'],\n refresh_token: ENV['GOOGL_REFRESH_TOKEN'],\n grant_type: \"refresh_token\"} }\n\n result = self.class.post(\"/oauth2/v3/token\", request)\n\n result.parsed_response[\"access_token\"]\n end\n end", "def get_token_from_code(auth_code)\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_url => '/common/oauth2/v2.0/token')\n # :authorize_url => \"/auth/office365/callback\")\n \n token = client.auth_code.get_token(auth_code,\n :redirect_uri => office365_callback_url,\n :scope => SCOPES.join(' '))\n end", "def get_token_from_code(auth_code)\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => \"https://login.microsoftonline.com\",\n :authorize_url => \"/common/oauth2/authorize\",\n :token_url => \"/common/oauth2/token\")\n\n token = client.auth_code.get_token(auth_code,\n :redirect_uri => authorize_url,\n :resource => 'https://outlook.office365.com')\n\n access_token = token\n end", "def get_token\n begin\n @response = RestClient.post(\n @consumer[:token_request_url],\n client_id: @consumer[:client_id],\n client_secret: @consumer[:client_secret],\n grant_type: @consumer[:grant_type],\n resource: @consumer[:resource]\n )\n\n @consumer[:token] = 'Bearer ' + JSON.parse(@response)['access_token']\n @consumer[:token_expiry] = JSON.parse(@response)['expires_on']\n rescue => error\n puts(\"ERROR - Token Request Failed - #{error}\")\n end\n @consumer[:token]\n end", "def get_access_token_from_API()\n # eventbrite embeds access code in the link it \"returns\"\n \taccess_code = extract_access_code_from_link()\n\n # once user allows access, exchange for access token\n access_token_JSON = exchange_code_for_token( access_code ) \n access_token = parse_for_access_token( access_token_JSON )\n return access_token\n end", "def exchange_oauth_tokens\n end", "def update_token\n client.authorization.update_token!(oauth_data)\n if client.authorization.refresh_token && client.authorization.expired?\n client.authorization.fetch_access_token!\n end\n end", "def access_token\n @access_token ||= ShakeTheCounter::Authentication.renew_access_token(client_id: id, client_secret: secret, refresh_token: refresh_token)[\"access_token\"]\n end", "def request_access_token(code, params={})\n params[:redirect_uri] ||= \"http://localhost\"\n opts = {}\n opts[:mode] = :query\n opts[:param_name] = \"oauth2_access_token\"\n @access_token = oauth2_client.auth_code.get_token(code, params, opts)\n rescue OAuth2::Error => e\n raise LinkedIn::Errors::UnauthorizedError.new(e.code), e.description\n end", "def oauth_access_token\n session[:access_token]\n end", "def get_new_token\n auth = 'Basic ' + Base64.strict_encode64( session[:client_id] + \":\" + session[:client_secret]).chomp\n \n rcResultJson = RestClient.post(\n session[:token_url],\n {\n grant_type: 'refresh_token', \n refresh_token: session[:refresh_token], \n },\n {\n :Authorization => auth\n }\n )\n rcResult = JSON.parse(rcResultJson)\n\n session[:patient_id] = rcResult[\"patient\"]\n session[:access_token] = rcResult[\"access_token\"]\n session[:refresh_token] = rcResult[\"refresh_token\"]\n session[:token_expiration] = (Time.now.to_i + rcResult[\"expires_in\"].to_i )\n rescue StandardError => exception\n # binding.pry \n err = \"Failed to refresh token: \" + exception.message\n redirect_to root_path, alert: err\n end", "def get_new_token\n binding.pry \n auth = 'Basic ' + Base64.strict_encode64( session[:client_id] +\":\"+session[:client_secret]).chomp\n \n rcResultJson = RestClient.post(\n session[:token_url],\n {\n grant_type: 'refresh_token', \n refresh_token: session[:refresh_token], \n },\n {\n :Authorization => auth\n }\n )\n rcResult = JSON.parse(rcResultJson)\n\n session[:patient_id] = rcResult[\"patient\"]\n session[:access_token] = rcResult[\"access_token\"]\n session[:refresh_token] = rcResult[\"refresh_token\"]\n session[:token_expiration] = Time.now.to_i + rcResult[\"expires_in\"].to_i \n rescue => exception\n binding.pry \n err = \"Failed to refresh token\"\n redirect_to root_path, flash: { error: err }\n end", "def get_access_token\n # Get the current token hash from session\n token_hash = session[:azure_token]\n\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_url => '/common/oauth2/v2.0/token')\n\n token = OAuth2::AccessToken.from_hash(client, token_hash)\n\n # Check if token is expired, refresh if so\n if token.expired?\n new_token = token.refresh!\n # Save new token\n session[:azure_token] = new_token.to_hash\n access_token = new_token.token\n else\n access_token = token.token\n end\n end", "def fetch_access_token(code)\n access_token = @oauth.auth_code.get_token(\n code,\n redirect_uri: @redirect_uri\n )\n { gocardless_access_token: access_token.token,\n gocardless_organisation_id: access_token['organisation_id'] }\n end", "def access_token\n @access_token ||= begin\n if oauth_options[:oauth_verifier]\n request_token.get_access_token(:oauth_verifier => oauth_options[:oauth_verifier])\n else\n request_token.get_access_token\n end\n end\n end", "def fetch_access_token\n uri = URI.parse Sendible::API::URL + \"/v1/auth?app_id=#{CGI.escape(Sendible.application_id)}&access_key=#{CGI.escape(access_key)}\"\n get = Net::HTTP::Get.new(uri.request_uri)\n response = Net::HTTP.start(uri.host, uri.port) do |http|\n http.request(get)\n end\n response.body\n end", "def get_access_token(code)\n @code = code\n @access_token ||= client.web_server.get_access_token( @code, :redirect_uri => callback_url)\n end", "def oauth2_access_token(code, options={})\n query = {\n :client_id => Config.client_id,\n :client_secret => Config.client_secret,\n :grant_type => 'authorization_code',\n :redirect_uri => Config.redirect_uri,\n :code => code\n }\n return send_request(:POST, PATH[:oauth2_access_token], query, false, options)\n end", "def request_token(code)\n params = {\n code: code,\n client_id: client_id,\n client_secret: client_secret,\n redirect_uri: redirect_uri,\n grant_type: 'authorization_code'\n }.to_param\n\n header = { 'Content-Type' => 'application/x-www-form-urlencoded' }\n uri = URI(TOKEN_URL)\n net_http = Net::HTTP.new(uri.host, uri.port)\n net_http.use_ssl = true\n request = Net::HTTP::Post.new(uri.request_uri, header)\n request.body = params\n response = net_http.request(request)\n if response.code == '200'\n data = JSON.load(response.body)\n @access_token = data['access_token']\n @refresh_token = data['refresh_token']\n @expires_in = data['expires_in']\n else\n raise StandardError.new(response.body)\n end\n end", "def create\n client.authorization_code = params[:code]\n access_token = client.access_token!\n puts access_token\n end", "def get_token (params)\n client = OAuth2::Client.new(params[:APP_ID], params[:APP_SECRET], :site => params[:OAUTH_URL])\n\n begin\n token = client.password.get_token(params[:USER_EMAIL], params[:USER_PASSWD], :scope => params[:SCOPE]).token\n rescue => e\n puts \"Error: Can't get oauth token, check credentials for '#{params[:NAME]}'\"\n puts \"#{e.message}\"\n abort \"Aborting script\"\n end\n return token\nend", "def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n # Build our params hash\n params = {\n client_id: @client_id,\n client_secret: @client_secret,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\n end", "def authorize(callback_url, code)\n data = open(\"#{BASE_URL}/oauth/access_token?client_id=#{app_id}&redirect_uri=#{CGI.escape callback_url}&client_secret=#{app_secret}&code=#{CGI.escape code}\").read\n \n # The expiration date is not necessarily set, as the app might have\n # requested offline_access to the data\n match_data = data.match(/expires=([^&]+)/)\n @expires = match_data && match_data[1] || nil\n \n # Extract the access token\n @access_token = data.match(/access_token=([^&]+)/)[1]\n end", "def authorize(callback_url, code)\n data = open(\"#{BASE_URL}/oauth/access_token?client_id=#{app_id}&redirect_uri=#{CGI.escape callback_url}&client_secret=#{app_secret}&code=#{CGI.escape code}\").read\n \n # The expiration date is not necessarily set, as the app might have\n # requested offline_access to the data\n match_data = data.match(/expires=([^&]+)/)\n @expires = match_data && match_data[1] || nil\n \n # Extract the access token\n @access_token = data.match(/access_token=([^&]+)/)[1]\n end", "def get_access_token_json\n HTTParty.post(get_request_access_token_url)\n end", "def access_token\n end", "def data_acc_token(code, client_id, client_secret, grant_type=\"authorization_code\", redirect_uri=REDIRECT_URL)\n \"client_id=#{client_id}&client_secret=#{client_secret}&grant_type=#{grant_type}&code=#{code}&redirect_uri=#{redirect_uri}\"\n end", "def get_access_token\n token_hash = Hash.new\n token_obj = get_access_token_json\n if token_obj.response.code.to_i == 200\n response_json = JSON.parse token_obj.response.body\n token_hash[\"access_token\"]= response_json[\"access_token\"]\n token_hash[\"token_type\"]= response_json[\"token_type\"]\n end\n return token_hash\n end", "def exchange_code(authorization_code)\n\t\tclient_secrets = Google::APIClient::ClientSecrets.load(CLIENT_SECRET_PATH)\n client = client_secrets.to_authorization \n client.update!(redirect_uri: 'postmessage')\n client.code = authorization_code\n \n\t begin\n\t # client.authorization.fetch_access_token!\n\t client.fetch_access_token!\n\t return client\n\t rescue Signet::AuthorizationError\n\t raise CodeExchangeError.new(nil)\n\t end\n\tend", "def authorize\r\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\r\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\r\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\r\n user_id = \"default\"\r\n credentials = authorizer.get_credentials user_id\r\n\r\n # launch default browser to approve request of initial OAuth2 authorization\r\n if credentials.nil?\r\n url = authorizer.get_authorization_url base_url: OOB_URI\r\n puts \"Open the following URL in the browser and enter the resulting code after authorization:\\n\" + url\r\n code = gets\r\n credentials = authorizer.get_and_store_credentials_from_code(user_id: user_id, code: code, base_url: OOB_URI)\r\n end\r\n\r\n credentials\r\nend", "def fetch_tokens(auth_code)\n\n\t\t# Authenticated access code provided, fetch tokens\n\t\tdrop_box_session = DropboxSession.deserialize(auth_code)\n\t\t\t\n begin\n drop_box_session.get_access_token\n rescue DropboxError => e\n Rails.logger.info(\"Oh..no.. DropBox second step broke.\") \n return false\n end\n\n Rails.logger.info(\"DropBox OAuth Token: #{drop_box_session.serialize}\")\n\n # Update tokens\n self.session_token = drop_box_session.serialize \n self.save\n\tend", "def get_oauth_token(authorization_code, current_user, query_params = nil)\n begin\n client_auth = DropboxOAuth2Flow.new(APP_CONFIG['oauth']['dropbox']['client_id'], APP_CONFIG['oauth']['dropbox']['client_secret'], APP_CONFIG['oauth']['dropbox']['redirect_url'], {:dropbox_auth_csrf_token => query_params[:state]}, :dropbox_auth_csrf_token)\n access_token, user_id, url_state = client_auth.finish(query_params)\n rescue\n return false\n end\n \n # Dropbox doesnt seem to support the oauth token refresh and no doc's explaining when tokens expire.\n saved = OauthDriveToken.create_or_update(:user => current_user, \n :access_token => access_token, \n :refresh_token => 'not_supported',\n :client_number => user_id, \n :expires_at => Time.now,\n :provider_number => APP_CONFIG['oauth']['dropbox']['provider_number'])\n saved\n end", "def get_access_token\n\t\treturn @credentials.get_access_token\n\tend", "def refresh_access_token\n\t\t\t\trequire \"open-uri\"\n\t\t\t\trequire \"net/http\"\n\t\t\t\trequire \"openssl\"\n\t\t\t\trequire \"base64\"\n\n\t\t\t\turi = URI.parse(\"#{self.add_on.jive_url}/oauth2/token\")\n\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\thttp.use_ssl = true\n\n\t\t\t\trequest = Net::HTTP::Post.new(uri.request_uri)\n\t\t\t\trequest.basic_auth self.add_on.client_id, self.add_on.client_secret\n\t\t\t\trequest.set_form_data({\n\t\t\t\t\t\"refresh_token\" => \"#{self.refresh_token}\",\n\t\t\t\t\t\"grant_type\" => \"refresh_token\",\n\t\t\t\t})\n\n\t\t\t\tresponse = http.request(request)\n\t\t\t\tjson_body = JSON.parse(response.body)\n\n\t\t\t\tif (response.code.to_i != 200)\n\t\t\t\t\traise RuntimeError, json_body[\"error\"].to_s.upcase\n\t\t\t\tend\n\n\t\t\t\tself.access_token = json_body[\"access_token\"]\n\t\t\t\tself.expires_in = json_body[\"expires_in\"]\n\t\t\t\tself.expires_at = json_body[\"expires_in\"].to_i.seconds.from_now\n\t\t\t\tself.save\n\t\t\tend", "def get_oauth_access_token(session_code)\n result = Octokit.exchange_code_for_token(session_code, CLIENT_ID, CLIENT_SECRET)\n result[:access_token]\n end", "def tokeninfo(token)\n $client.authorization.update_token!(token)\n oauth2 = $client.discovered_api('oauth2','v2')\n\n puts $client.execute(oauth2.tokeninfo, token).response.body\nend", "def process_callback(params,session)\n args = {}\n args.merge!({:oauth_verifier => params[:oauth_verifier], :request_token => session[:request_token], :request_token_secret => session[:request_token_secret]})\n args.merge!({:code => params[:code]}) if params[:code]\n @access_token = self.get_access_token(args)\n end", "def exchange_code_for_token(api, client, auth_code)\n client.auth_code.get_token(auth_code, redirect_uri: api.oauth_redirect)\n rescue OAuth2::Error => e\n fail_with_oauth_error(\n \"Failed to exchange auth_code for token (code=#{e.response.status})\",\n e.response\n )\n end", "def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end", "def refresh(access_token)\n new_access_token = access_token.client.access_token!\n expires = Time.zone.at(decode_id_token(new_access_token.id_token).exp).to_datetime\n\n {\n access_token: new_access_token.access_token,\n expires_at: expires\n }\n rescue Rack::OAuth2::Client::Error\n # Refresh token was expired\n {}\n end", "def get_token_from_code(auth_code)\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_url => '/common/oauth2/v2.0/token')\n\n token = client.auth_code.get_token(auth_code,\n :redirect_uri => authorize_url,\n :scope => SCOPES.join(' '))\n end", "def refresh_tokens\n\t\tbegin\n\t\t\t\n\t\t\tresp = $c.initiate_auth({\n\t\t\t auth_flow: \"REFRESH_TOKEN\",\n\t\t\t auth_parameters: {\n\t\t\t \"REFRESH_TOKEN\" => self.refresh_token,\n\t\t\t \"SECRET_HASH\" => calculate_cognito_hmac\n\t\t\t },\n\t\t\t client_id: ENV[\"COGNITO_CLIENT_ID\"]\n\t\t\t})\n\t\t\t\n\t\t\tself.access_token = resp[:authentication_result][:access_token]\n\t\t\tself.refresh_token = resp[:authentication_result][:refresh_token]\n\t\t\tself.token_expires_at = Time.now + (resp[:authentication_result][:expires_in]).seconds\n\t\t\tself.save\n\t\t\t#session[:user] = self\n\t\trescue => e\n\t\t\te.to_s\n\t\tend\t\n\tend", "def get_access_token_from_code(code,redirect_url)\n @access_token ||= client.auth_code.get_token(code, :redirect_uri => redirect_url, :parse => :query)\n end", "def update_token\n params = {\n client_id: client_id,\n client_secret: client_secret,\n grant_type: 'refresh_token',\n refresh_token: refresh_token\n }\n request(:post, 'oauth2/token', params, true)\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file(CREDENTIALS_PATH)\n token_store = Google::Auth::Stores::FileTokenStore.new(file: TOKEN_PATH)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts 'Open the following URL in the browser and enter the ' \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = 'default'\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\n end", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI,\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def authorize\n client_id = Google::Auth::ClientId.from_file CREDENTIALS_PATH\n token_store = Google::Auth::Stores::FileTokenStore.new file: TOKEN_PATH\n authorizer = Google::Auth::UserAuthorizer.new client_id, SCOPE, token_store\n user_id = \"default\"\n credentials = authorizer.get_credentials user_id\n if credentials.nil?\n url = authorizer.get_authorization_url base_url: OOB_URI\n puts \"Open the following URL in the browser and enter the \" \\\n \"resulting code after authorization:\\n\" + url\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n credentials\nend", "def oauth_check_authorization\n code = params[:code]\n session[:access_token] = facebook_client.check_authorization code,\n :redirect_uri => oauth_callback_url\n end" ]
[ "0.80101806", "0.78447646", "0.7616425", "0.7357725", "0.7316766", "0.7306432", "0.7303253", "0.72949505", "0.7294063", "0.7265035", "0.723964", "0.7234714", "0.7213684", "0.71711695", "0.7160982", "0.7092467", "0.7078341", "0.7074919", "0.7053377", "0.7053071", "0.7024346", "0.70008403", "0.69886804", "0.69845146", "0.698224", "0.69707686", "0.69652575", "0.6960406", "0.695426", "0.6944834", "0.6944834", "0.6920634", "0.69100755", "0.69081223", "0.68937445", "0.68905544", "0.6884235", "0.68840814", "0.68700343", "0.68634444", "0.68591386", "0.6857091", "0.68555284", "0.6855376", "0.6846975", "0.6841087", "0.68351567", "0.682222", "0.6811004", "0.6806179", "0.67943805", "0.67882115", "0.678451", "0.6778806", "0.6770345", "0.67667526", "0.67551035", "0.6741704", "0.6739279", "0.6737206", "0.67369413", "0.6730868", "0.6725275", "0.6719887", "0.67161953", "0.6700403", "0.6696813", "0.66883606", "0.66880846", "0.66856986", "0.66856986", "0.6672313", "0.6672171", "0.6667856", "0.6663713", "0.6652508", "0.664877", "0.66385084", "0.6618412", "0.6613822", "0.66104615", "0.66026133", "0.660032", "0.65985984", "0.65985465", "0.657273", "0.656578", "0.6560315", "0.65578824", "0.6552426", "0.6545364", "0.6542226", "0.6541187", "0.65396166", "0.65396166", "0.65396166", "0.65396166", "0.65388453", "0.65353566", "0.65353566", "0.6530743" ]
0.0
-1
Third step: Get your user_id from your login name
def get_user_id(login) twitch_client = Twitch::Client.new( client_id: 'YOUR_CLIENT_ID', client_secret: 'YOUR_CLIENT_SECRET', access_token: 'YOUR_ACCESS_TOKEN', refresh_token: 'YOUR_REFRESH_TOKEN', scopes: ["channel:manage:broadcast"], token_type: :user ) puts twitch_client.get_users(login: login) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(user_name)\n return get_value_of(user_name, :id)\n end", "def get_user_id(username)\n # .........\n end", "def get_user_id\n # TODO: #6. Complete the function to return your user id\n user_id = 'Put your user ID here'\n end", "def user_id\n username\n end", "def user_id_for(user)\n find(user.id, user.login)\n end", "def user_login_to_id(login)\n user = user_from_login(login)\n return user[\"id\"]\n end", "def login\n self.user_id ? user.login : self.name\n end", "def get_login\r\n if ((self.user_id) && (self.user_id > 0))\r\n return self.user.name\r\n else\r\n return false\r\n end\r\n end", "def get_user_id_by_login(login)\n @user = User.find(:first ,:select=>\"id\",:conditions=>[\"login='#{login}'\"])\n if !@user.nil?\n return @user.id\n else\n return 0\n end\n end", "def extract_user_id(username)\n username[2..-2]\n end", "def get_username_id(username)\n #puts \"#{@curl} -X GET '#{@url}/people/username/#{username}'\" if @debug\n user_details = Jive_ruby_api.cleanse_security_string(`#{@curl_get_prefix} '#{@url}/people/username/#{username}'`)\n\n #Turn the string into a json object\n user_details = JSON.parse(user_details)\n return user_details['id']\n end", "def get_user_id(reaktoruser_id)\n IdStore.get(:reaktoruser, reaktoruser_id)\n end", "def uid\n return nil unless user_id\n user_id.split('/').first\n end", "def uid\n return nil unless user_id\n user_id.split('/').first\n end", "def get_user_id(db, username)\n\tdb.execute(\"SELECT id FROM users WHERE name=? ;\", [username])\nend", "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 user_id\n return link.split(\"/\")[2]\n end", "def db_login(db_connection)\n sql = 'SELECT username FROM user_logins WHERE user_id=$1'\n result = db_connection.exec_params(sql, [ id ])\n result.values.first.first\n end", "def auth_user_id\n auth[:user_id]\n end", "def user_id\n raise \"Implement in Client or Advocate\"\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 user_id\n @logged_in_user = User.find_by(id: params[:id])\n @user_id = @logged_in_user.id\n end", "def getUserID\n if signed_in? \n if params[:id].empty?\n uid = current_user.id\n else\n uid = params[:id]\n end\n @user = User.find(uid)\n else\n redirect_to pages_home_path\n end\n end", "def get_userid()\n user_info = call_myspace_api(:user_info, :v1_json => true)\n user_info['userId'].to_s\n end", "def extract_user_id(params)\n User.find_by_id(params[:user_id]) || User.find_by_email(params[:email]) || nil\n end", "def get_userid()\r\n user_info = @context.call_myspace_api(:user_info, :v1_json => true)\r\n user_info['userId'].to_s\r\n end", "def identify_the_user\n \t@current_user = User.find_by_id(session[\"user_id\"])\n end", "def user_id\n instance_variable_get(:@prepared_arguments).dig(:user_id)\n end", "def logged_in_user_id\n session[:user_id]\n end", "def user_id\n config.present? ? config[:user_id] : ''\n end", "def login_user(user_id)\n session[:user_gid] = users(user_id).to_global_id.to_s\n end", "def user_id; config[:user_id]; end", "def userid\n \treturn session[:userid]\n \tend", "def id_string\n return \"user_\"+self.username\n end", "def find_user_id\n if (params[:user_id])\n return params[:user_id].to_i\n else\n return params[:id].to_i\n end\n end", "def lab_user_id\n plaintext_id = \"#{@view_options[:channel]}:#{user_or_session_id}\"\n Digest::SHA1.base64digest(storage_encrypt(plaintext_id)).tr('=', '')\n end", "def user_id; 1; end", "def auth_user_id\n session[:current_user_id] unless session[:current_user_id].nil?\n end", "def user_id\n if (id = (@opts[:user_id] || @opts['user_id'])) && id.respond_to?(:to_s)\n if (id = id.to_s).size > 0 && id != '0'\n return id\n end\n end\n end", "def get_id(name)\n @users.each do |user|\n return user[:id] if user[:name] == name\n end\n nil\n end", "def username\n account = github_accounts.first || slack_accounts.first\n account ? account.username : id\n end", "def get_and_store_username\n @user = User.find_by_id(session[:current_user_id])\n if !@user\n redirect_to logins_path()\n end\n end", "def get_login_by_user_id(user_id)\n\t@user = User.find(:first ,:select=>\"login\",:conditions=>[\"id=#{user_id}\"])\n return @user.login\n end", "def get_userid(user_page)\n\t\tpp user_page.body\n\t\tuserid_xpath = '(//input[@name=\"profile_user\"]/@value)[1]'\n\t\tid = user_page.parser.xpath(userid_xpath)\n\n\t\tid.text\n\tend", "def user_id\n # The user id can't be handled by the method_missing magic from\n # OctocatHerder::Base, since the id method returns the object\n # id.\n @raw['id']\n end", "def userid_from_username(username)\n data = JSON(open(\"http://api.twitter.com/1/users/show/#{username}.json\").read)\n data[\"id\"]\n end", "def get_user_id(user)\n if user.id < 10\n return \"USR0\" + user.id.to_s\n else\n return \"USR\" + user.id.to_s\n end\n end", "def user\n return Etc.getlogin\n end", "def user_id\n unless @user_id.nil? || @user_id == 0\n @user_id\n else\n read_attribute(:user_id) # TODO: Might need to cache result\n end\n end", "def get_username(user_id)\n return User.find(user_id).username\n end", "def user_login\n @raw['user']['login']\n end", "def hubssolib_get_user_id\n user = self.hubssolib_current_user\n user ? user.user_id : nil\n end", "def user_id_parameter\n \"#{user_parameter}_id\".to_sym\n end", "def get_user_id\n if current_user\n @user = User.find(current_user.id)\n end\nend", "def get_username_by_user_id(user_id)\n User.find(user_id).username\n end", "def get_username_by_user_id(user_id)\n User.find(user_id).username\n end", "def get_user_name(user_id)\n if self.is_api then\n user = begin \n HuiMain.plugin_data.find_one(\"_id\" => BSON::ObjectId(user_id))\n rescue BSON::InvalidObjectId\n nil\n end\n if user then \n user[\"name\"]\n else\n nil\n end\n else # not api\n session[:current_user_name]\n end\n end", "def current_user_id\n info['user']['id']\n end", "def user_id\n @raw['user']['id']\n end", "def login_name\n @login_name ||= begin\n url = \"https://qbo.intuit.com/qbo1/rest/user/v2/#{@realm_id}\"\n response = @oauth.request(:get, url)\n if response && response.code.to_i == 200\n xml = parse_xml(response.body)\n xml.xpath(\"//qbo:QboUser/qbo:LoginName\")[0].text\n end\n end\n end", "def get_external_id_by_user_id(id)\n get_user_by_id(id)[\"external_user_id\"]\n end", "def get_user_login\n user = User.first(:id => self.user_id )\n return user.login if user\n return nil\n end", "def user_id\n @user_id ||= self.user ? self.user.to_global_id : nil\n end", "def getUser login\n return false if !@usrData\n @usrData[login]\n end", "def get_username\n user_response = Faraday.get \"https://api.github.com/user\", {}, {'Authorization'=>\"token #{self.access_token}\", 'Accept' => 'application/json'}\n user_json = JSON.parse(user_response.body)\n user_json[\"login\"]\n end", "def user_name\n self.user.login\n end", "def user_name\n self.user.login\n end", "def user_id\n decoded_token.first['user_id']\n end", "def get_username_for_id(user_id)\n return $db.execute(\"SELECT username FROM users WHERE user_id = ?\", user_id)[0][\"username\"]\nend", "def get_user_login\n #self.network_login.blank? ? self.login : self.network_login.split('-',2)[1]\n self.get_network_login.blank? ? \"\" : self.get_network_login.gsub(self.primary_network.coded_name+'-', '') rescue ''\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 getusername()\r\n return getvalue(SVTags::USER_ID)\r\n end", "def get_userid\n request.cookies['userid']\n end", "def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end", "def get_user_from_id(user_id)\n \t\tuser = nil\n \t\tunless user_id.blank?\n\t \t\tcol = :email\n\t \t\tif CONFIG[:enable_username?]\n\t \t\t\tunless is_email(user_id)\n\t \t\t\t\tcol = :username\n\t \t\t\tend\n\t \t\tend\n#\t \t\tp \"Finding user by col: #{col}, user_id = #{user_id}\"\n\t \t\tuser = User.find_by(col => user_id.downcase)\n\t \tend\n\t \tuser\n \tend", "def actual_user\n User.find_by_id(session[:user_id])\n end", "def user_get(name)\n execute(\"id -P #{name}\") do |result|\n fail_test \"failed to get user #{name}\" unless /^#{name}:/.match?(result.stdout)\n\n yield result if block_given?\n result\n end\n end", "def current_user_id\n if request.headers && request.headers['Authorization']\n token = request.headers['Authorization'].split(' ')[1] #[Bearer <token>]\n begin\n decoded_token = JWT.decode(token, 'this should be in .env', true, algorithm: 'HS256')\n if decoded_token\n user_id = decoded_token[0]['user_id'] #[{ \"user_id\"=>\"2\" }, { \"alg\"=>\"HS256\" }]\n end\n rescue JWT::DecodeError\n nil\n end\n end\n end", "def get_brew_user_id\n brew_command_parse_response(\"call getLoggedInUser\")['id']\n end", "def get_user_id(username)\n pglimit = 100\n res = @conn.get(\"/api/v1/users&limit=#{pglimit}\")\n usercount = res['count'].to_i\n id = user_data_from_results(res, username, 'uid')\n return id if id\n\n pages = (usercount / pglimit) + 1\n 2.upto(pages) do |i|\n res = @conn.get(\"/api/v1/users&limit=#{pglimit}?page=#{i}\")\n id = user_data_from_results(res, username, 'uid')\n return id if id\n end\n nil\n end", "def user_id\n payload = authenticate!(via: :jwt)\n return payload[\"user\"]\n end", "def find_user\n @user = User.with_username(params[:id]).first\n end", "def user_id\n self.title_and_name\n end", "def sign_in identifier\n User.find_by(login: identifier) || User.find_by(email: identifier)\n end", "def login_name\n return @login_name\n end", "def find_by_id\n User.find_by_id(@username_or_id)\n end", "def login_as(user)\n session[:user_id] = users(user).id\n end", "def login( user )\n session[:user_id] = user ? user.id : nil\n end", "def get_user_id_for_username(username)\n user_id = $db.execute(\"SELECT user_id FROM users WHERE username = ?\", username)\n if user_id != []\n return user_id.first[\"user_id\"]\n else\n return false\n end\nend", "def current_user_id\n session[:user_id]\n end", "def id\n @data[:user_id]\n end", "def query_id(token, login)\n query = %{\n query ($login: String!) {\n user (login: $login) {\n id\n }\n }\n }\n\n vars = { login: login }\n Github.query(token, query, vars).dig('data', 'user', 'id')\nend", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def provider\n return nil unless user_id\n user_id.split('/').last\n end", "def author_login\r\n user.login if user\r\n end", "def get_ldap_id\n\t\tself.id = Devise::LDAP::Adapter.get_ldap_param(self.username,\"uidnumber\").first\n end", "def db_user(db_connection, user_id)\n sql = 'SELECT * FROM users WHERE id=$1;'\n db_connection.exec_params(sql, [ user_id ]).first\n end", "def extract_identity(uri)\n return $1.downcase if uri =~ %r[/user/([a-zA-Z_1-9-]*)] || uri =~ %r[://([a-zA-Z_1-9-]*)?\\.#{AppConfig.host(request.host)}] || uri =~ %r[://(.*?)/?$]\n return nil\n end", "def _user? name\n\t\tuid = Sdb[:_user].filter(:name => name).get(:uid)\n\t\tuid ? uid : nil\n\tend", "def get_user_id_from_token\n if request.headers['Authorization'].present?\n @token = request.headers['Authorization'].split(' ').last\n @payload ||= AuthToken.decode(@token)\n if @payload && @payload[:user_id]\n return @payload[:user_id]\n end\n end\n return nil\n end", "def find_by_id!\n User.find(@username_or_id)\n end" ]
[ "0.77812105", "0.7765688", "0.76521385", "0.75913304", "0.7541599", "0.738873", "0.7376876", "0.7328339", "0.7315179", "0.7283882", "0.71611977", "0.7157964", "0.7137468", "0.7137468", "0.7124738", "0.7108057", "0.7098127", "0.7092423", "0.7087813", "0.70851034", "0.7057295", "0.7038226", "0.69937605", "0.6961612", "0.69304293", "0.69224274", "0.69197637", "0.6900143", "0.6893757", "0.6891529", "0.6884991", "0.6884172", "0.68840814", "0.6881522", "0.68762004", "0.68687046", "0.68644744", "0.68601197", "0.68414664", "0.6837309", "0.68336076", "0.6822162", "0.68116874", "0.6806105", "0.6785839", "0.6748665", "0.6747763", "0.674329", "0.67399377", "0.67375046", "0.6731008", "0.67267907", "0.6717533", "0.6716638", "0.67120427", "0.67120427", "0.67101884", "0.67054987", "0.6703287", "0.6700042", "0.6696622", "0.6693105", "0.6688111", "0.66682214", "0.6661553", "0.66495353", "0.66495353", "0.66488546", "0.6636561", "0.6627634", "0.66273654", "0.662363", "0.6616352", "0.6611665", "0.66107166", "0.6603387", "0.6590759", "0.6585206", "0.6584934", "0.65830946", "0.65761834", "0.6575072", "0.6561494", "0.6554538", "0.65509933", "0.6545739", "0.6543581", "0.6543094", "0.65401345", "0.65380216", "0.6536739", "0.65357393", "0.65354913", "0.65354913", "0.6527003", "0.6517361", "0.65161026", "0.65156007", "0.65105116", "0.6509756", "0.6505954" ]
0.0
-1
GET /dom0s GET /dom0s.json
def index @dom0s = Dom0.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend", "def get_json\n html = Nokogiri::HTML(@page)\n text = open(\"https://theintercept.com/api/requestSIDDocuments/?orderBy=publishedTime&orderDirection=desc&perPage=2000\").read\n documents = JSON.parse(text)[\"documents\"][\"edges\"].map{|d| d[\"node\"]}\n \n documents.each do |doc|\n @output.push(parse_json(doc))\n end\n\n return JSON.pretty_generate(@output)\n end", "def set_dom0\n @dom0 = Dom0.find(params[:id])\n end", "def dom0_params\n params[:dom0]\n end", "def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end", "def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end", "def service_document\n response = get(@url.to_s)\n response.body\n end", "def create\n @dom0 = Dom0.new(dom0_params)\n\n respond_to do |format|\n if @dom0.save\n format.html { redirect_to @dom0, notice: 'Dom0 was successfully created.' }\n format.json { render :show, status: :created, location: @dom0 }\n else\n format.html { render :new }\n format.json { render json: @dom0.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @space = Space.where(:wiki_name => params[:space_id])[0]\n @documents = @space.documents.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documents }\n format.json { render :json => @documents.to_json }\n end\n end", "def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\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 index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nodes }\n end\n end", "def index\n\t\t@domains = Domain.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @domains }\n\t\tend\n\tend", "def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end", "def root; get(\"\"); end", "def index\n @stories = Story.all\n render json: @stories, root: false\n end", "def destroy\n @dom0.destroy\n respond_to do |format|\n format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end", "def index\n @pages = Page.all\n render json: @pages\n end", "def index\n @poms = Pom.all\n\n respond_to do |format|\n # just poms\n format.json { render json: @poms, :except => [:created_at, :updated_at]}\n end\n end", "def index\n @laws = Law.ordered_roots\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @laws }\n end\n end", "def json_stores\n @_json_stores ||= doc.xpath(\"/html/body/script[@class='tiddlywiki-tiddler-store']\")\n end", "def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end", "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def index\n @tree_elements =TreeElement.all\n ret= get_tree @tree_elements\n render :json => ret\n\n end", "def index\n @title = \"All Nodes\"\n @nodes = Node.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nodes }\n end\n end", "def index\n @jsons = Json.all\n end", "def index\n @division_syns = DivisionSyn.all\n\n render json: @division_syns\n end", "def fetch_opendap_urls\n ous_response = fetch_ous_response(params)\n\n # TODO: Render errors after OUS is moved to CMR and supports error responses\n render json: ous_response.fetch('items', []), layout: false\n end", "def index\n @curriculums = Curriculum.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@curriculums) }\n\t\tend\n end", "def index\n @spaces = Space.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spaces }\n end\n end", "def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\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 @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end", "def index\n @services = @page.services.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @services }\n end\n end", "def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end", "def index\n render json: Space.all\n end", "def index\n @dns_device_assocs = DnsDeviceAssoc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dns_device_assocs }\n end\n end", "def index\n render json: WeatherDatum.all\n end", "def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end", "def index\n @papers = Paper.all\n\n render json: @papers\n end", "def index\n @parsed_sites = ParsedSite.all\n\n render json: @parsed_sites\n end", "def index\n @search = Quirk.accessible_by(current_ability).search(params[:search])\n @quirks = @search.result(:order => 'name', :include=>[:servers])\n if request.xhr?\n render :partial => 'listing'\n else\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quirks }\n format.json { render :json => @quirks}\n end\n end\n end", "def index\n #@world_maps = WorldMap.all\n\n respond_to do |format|\n format.html # index.erb.erb\n format.json { render json: @world_maps }\n end\n end", "def index\n @data_collections = DataCollection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_collections }\n end\n end", "def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end", "def index\n @devices = Device.all\n render json: @devices\n end", "def index\n @urls = @site.urls.paginate(:page => params[:page])\n render json: @urls\n end", "def list\n get('/')\n end", "def index\n @qus = Qu.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @qus }\n end\n end", "def index\n @retain_nodes = RetainNode.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retain_nodes }\n format.json { render :json => @retain_nodes }\n end\n end", "def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end", "def get(url, elem = nil)\n ret = REXML::Document.new(http_get(url))\n if elem\n ary = []\n ret.root.elements.each(\"//#{elem}\") do |e|\n hash = {}\n e.attributes.each { |key, val| hash[key] = val }\n ary << hash\n end\n ret = ary\n end\n ret\n end", "def index\n @node = Fedora.rest('rest/')\n end", "def index\n @locations = Location.roots.order(:location_name) \n render :json => @locations #Using Location serializer by default\n end", "def index\n @page_objects = PageObject.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page_objects }\n format.tson { render :json => @page_objects }\n end\n end", "def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end", "def index\n @devices = Device.all.includes(:browsers)\n json_response(@devices, :ok, [:browsers])\n end", "def all\n @cache ||= Request.get('/data')\n\n end", "def index\n @pubs = Pub.all\n\n render json: @pubs\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 @sections = Section.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sections }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.xml { render :xml => @chords.to_xml(:skip_types => true, :methods => [:symbols_list], :except => [:id, :parent_id, :chord_quality_id]) }\n\t\t\tformat.js { render :text => @chords.to_json(:except => [:id, :parent_id, :chord_quality_id]) }\n end\n end", "def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end", "def index\n @d_loggers = DLogger.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @d_loggers }\n end\n end", "def everything\n raw = JSON.parse(`curl -sX GET 'https://api.nirvanahq.com/?api=rest&appid=gem&authtoken=#{@token}&method=everything&since=0'`)\n raw['results']\n end", "def index\n @map_nodes = Map::Node.paginate(:page => params[:page], :per_page => 64)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @retain_node_selectors = RetainNodeSelector.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @retain_node_selectors }\n end\n end", "def test2\n uri = 'http://dbhack1.nescent.org/cgi-bin/phylows.pl/phylows/tree/TB:1999'\n # @x = Net::HTTP.get_response(URI.parse(uri)).body\n @d = Nexml::Document.new(:url => uri)\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 @djs = Dj.all\n end", "def demos\n get_records \"demo\", \"/demos\"\n end", "def update\n respond_to do |format|\n if @dom0.update(dom0_params)\n format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' }\n format.json { render :show, status: :ok, location: @dom0 }\n else\n format.html { render :edit }\n format.json { render json: @dom0.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def index\n\t\t@jquery = InitHelper.new( gon )\n\t\t@data_sets = DataSet.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @data_sets }\n\t\tend\n\tend", "def index\n @jsons = Json.all\n\n\n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def index(cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(@resource_uri)\n end", "def index(cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(@resource_uri)\n end", "def index\n @nodes = Node.admin\n response.headers['Content-Range'] = @nodes.count\n render json: @nodes.reorder(id: :asc).as_json(admin: true)\n end", "def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end", "def index\n @contents = Content.all\n render json: @contents\n end", "def index\n @studies = Study.all\n #render json: @studies\n end", "def splash()\n\t\t@request.add('/')\n\t\t@request.add('/var/widgets.json?callback=define')\n\t\t@request.add('/system/me?_charset_=utf-8')\n\t\t@request.add('/tags/directory.tagged.json?_charset_=utf-8&_=1342651726188')\n\t\t@request.add('/var/search/activity/all.json?items=12&_charset_=utf-8&_=1342651726197')\n\t\t@request.add('/var/search/public/random-content.json?page=0&items=10&tag=&type=c&_charset_=utf-8&_=1342651726201')\n\t\t@request.add('/var/templates/worlds.2.json?_charset_=utf-8')\n end", "def index\n @divisions = Division.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @divisions }\n end\n end", "def repo_docs_for(uuid)\n string_response = make_request_for('repo_solr_docs', uuid)\n convert_to_json_docs(string_response) if string_response\n end", "def index\n #Page.all is fine for small sets of data, for larger sets pagination would be best\n @pages = data_cache('pages', 10.minutes) do\n Page.all\n end\n respond_to do |format|\n format.json { render action: 'index', status: :ok, location: api_pages_url(@pages) }\n format.xml { render xml: @pages, location: api_pages_url(@pages) }\n end\n end", "def index\n\t\t@direccions = Direccion.where(:personas_id => session[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @direccions }\n\t\tend\n\tend" ]
[ "0.6123326", "0.581122", "0.5674552", "0.5660206", "0.5556566", "0.5537444", "0.5526527", "0.5493284", "0.546806", "0.5455959", "0.5452535", "0.544711", "0.54072374", "0.53764915", "0.5340168", "0.5336084", "0.53206885", "0.52866936", "0.52781004", "0.52780795", "0.5273331", "0.5253115", "0.52440757", "0.52330434", "0.5229509", "0.5226024", "0.52223307", "0.5217138", "0.52141607", "0.5211522", "0.5209868", "0.5196922", "0.51861805", "0.51816684", "0.5179657", "0.51785827", "0.5176716", "0.5175375", "0.51603293", "0.51577777", "0.51519096", "0.51493335", "0.51417583", "0.5135798", "0.51299196", "0.5123474", "0.51209456", "0.5118063", "0.5116195", "0.5115885", "0.51106566", "0.5109756", "0.5104704", "0.51032853", "0.5096611", "0.5093442", "0.50923264", "0.5091078", "0.5087189", "0.50862396", "0.5082172", "0.5081738", "0.5079626", "0.50789356", "0.50763667", "0.50751364", "0.5075125", "0.50729245", "0.5071518", "0.5070865", "0.5069446", "0.5068161", "0.5067377", "0.5063432", "0.506093", "0.5060665", "0.505947", "0.5058455", "0.5056312", "0.50537103", "0.5053469", "0.5053469", "0.50528765", "0.5052405", "0.5045911", "0.5045911", "0.5045911", "0.5045911", "0.5045911", "0.5045911", "0.5045911", "0.50451946", "0.50451946", "0.50407517", "0.5034115", "0.5031544", "0.5031147", "0.5025969", "0.5025834", "0.5024907" ]
0.7176695
0
GET /dom0s/1 GET /dom0s/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dom0s = Dom0.all\n end", "def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend", "def set_dom0\n @dom0 = Dom0.find(params[:id])\n end", "def dom0_params\n params[:dom0]\n end", "def service_document\n response = get(@url.to_s)\n response.body\n end", "def create\n @dom0 = Dom0.new(dom0_params)\n\n respond_to do |format|\n if @dom0.save\n format.html { redirect_to @dom0, notice: 'Dom0 was successfully created.' }\n format.json { render :show, status: :created, location: @dom0 }\n else\n format.html { render :new }\n format.json { render json: @dom0.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_json\n html = Nokogiri::HTML(@page)\n text = open(\"https://theintercept.com/api/requestSIDDocuments/?orderBy=publishedTime&orderDirection=desc&perPage=2000\").read\n documents = JSON.parse(text)[\"documents\"][\"edges\"].map{|d| d[\"node\"]}\n \n documents.each do |doc|\n @output.push(parse_json(doc))\n end\n\n return JSON.pretty_generate(@output)\n end", "def index\n @distros = getmydata(\"Distro\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distros }\n end\n end", "def root; get(\"\"); end", "def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end", "def index\n\n get_collections\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deities }\n format.js {}\n end\n end", "def index\n @space = Space.where(:wiki_name => params[:space_id])[0]\n @documents = @space.documents.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @documents }\n format.json { render :json => @documents.to_json }\n end\n end", "def test2\n uri = 'http://dbhack1.nescent.org/cgi-bin/phylows.pl/phylows/tree/TB:1999'\n # @x = Net::HTTP.get_response(URI.parse(uri)).body\n @d = Nexml::Document.new(:url => uri)\n end", "def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end", "def get(url, elem = nil)\n ret = REXML::Document.new(http_get(url))\n if elem\n ary = []\n ret.root.elements.each(\"//#{elem}\") do |e|\n hash = {}\n e.attributes.each { |key, val| hash[key] = val }\n ary << hash\n end\n ret = ary\n end\n ret\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def index\n @node = Fedora.rest('rest/')\n end", "def get_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Get.new(uri)\n run(uri, req)\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end", "def index\n @pages = Page.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: Page.roots.map{|r| r.node}}\n end\n end", "def index\n @dossiers = Dossier.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dossiers }\n end\n end", "def update\n respond_to do |format|\n if @dom0.update(dom0_params)\n format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' }\n format.json { render :show, status: :ok, location: @dom0 }\n else\n format.html { render :edit }\n format.json { render json: @dom0.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @dom0.destroy\n respond_to do |format|\n format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nodes }\n end\n end", "def get(url, elem = nil)\n # check last request time, if it was too recent, then wait\n sleep 1.0 if @last_request && (Time.now.to_i - @last_request) < 1\n @last_request = Time.now.to_i\n \n # get result and parse it\n ret = REXML::Document.new(http_get(url))\n \n # if we got something, then parse it\n if elem\n ary = []\n ret.root.elements.each(\"//#{elem}\") do |e|\n hash = {}\n e.attributes.each { |key, val| hash[key] = val }\n ary << hash\n end\n ret = ary\n end\n\n # return result\n ret\n end", "def index\n @interno_unidads = InternoUnidad.all\n render json: @interno_unidads\n end", "def index\n @tree_elements =TreeElement.all\n ret= get_tree @tree_elements\n render :json => ret\n\n end", "def index\n @tipo_denuncia = TipoDenuncium.all\n\n render json: @tipo_denuncia\n end", "def index\n hash = cookies[:city_hash]\n @city = City.find_by(city_hash: hash)\n @units = @city.units\n\n render json: @units, status: :ok\n end", "def index\n json_response(@device.browsers)\n end", "def index\n @title = \"All Nodes\"\n @nodes = Node.order(:id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nodes }\n end\n end", "def fetch\n\t\tbegin\n\t\t\tresponse = RestClient.get(@url,:user_agent => @user_agent.get_user_agent)\n\t\t\tdoc = Nokogiri::HTML(response)\n\t\t\treturn doc\n\t\trescue Exception => e\n\t\t\tLogWriter.error(e)\n\t\t\tthrow e\n\t\tend\n\tend", "def index\n\t\t@domains = Domain.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @domains }\n\t\tend\n\tend", "def index\n @devices = Device.all.includes(:browsers)\n json_response(@devices, :ok, [:browsers])\n end", "def document\n json = Net::HTTP.get_response URI.parse(query_string(@query))\n json.body\n end", "def get_document(depth: nil, pierce: nil)\n {\n method: \"DOM.getDocument\",\n params: { depth: depth, pierce: pierce }.compact\n }\n end", "def orchio_get\n if cache.enabled? and response = cache_request.get(id)\n if response.header.status == :cache\n doc = response.body.document\n end\n else\n response = client.send_request :get, inst_args if response.nil?\n doc = Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n ))\n end\n Result.new(\n status: orchio_status(response, 200),\n response: response,\n results: [ doc ]\n )\n end", "def demos\n get_records \"demo\", \"/demos\"\n end", "def index\n @foros = Foro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foros }\n end\n end", "def serv_json\n \"http://api.dribbble.com/shots/popular?page=1\"\n end", "def get_inf(url)\n\turi = URI.parse(url)\n\tresponse = Net::HTTP.get_response(uri)\n\tJSON.parse(response.body)\nend", "def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end", "def index\n @qus = Qu.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @qus }\n end\n end", "def index\n @services = @page.services.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @services }\n end\n end", "def index\n get('')\n end", "def index\n @search = Quirk.accessible_by(current_ability).search(params[:search])\n @quirks = @search.result(:order => 'name', :include=>[:servers])\n if request.xhr?\n render :partial => 'listing'\n else\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @quirks }\n format.json { render :json => @quirks}\n end\n end\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 @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 fetch(vin)\n if File.exist?(\"spec/data/#{vin}.xml\")\n doc = LibXML::XML::Document.file(\"spec/data/#{vin}.xml\")\n elsif Lynr.cache.include?(vin)\n doc = LibXML::XML::Document.string(Lynr.cache.read(vin))\n elsif Lynr.features.dataone_decode\n response = fetch_dataone(vin).tap { |resp| Lynr.cache.write(vin, resp) }\n doc = LibXML::XML::Document.string(response)\n else\n doc = LibXML::XML::Document.new\n node = LibXML::XML::Node.new 'query_response'\n doc.root = node\n end\n doc.find_first(\"//query_response[@identifier='#{vin}']\")\n end", "def show\n json = self.as_json(only: [:created_at, :version])\n json['url'] = doi_url\n json\n end", "def index\n @poms = Pom.all\n\n respond_to do |format|\n # just poms\n format.json { render json: @poms, :except => [:created_at, :updated_at]}\n end\n end", "def show\n json_response(@browser)\n end", "def index\n @dns_device_assocs = DnsDeviceAssoc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dns_device_assocs }\n end\n end", "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def index\n @infrastructures = getmydata(\"Infrastructure\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @infrastructures }\n end\n end", "def index\n render json: WeatherDatum.all\n end", "def index\n @division_syns = DivisionSyn.all\n\n render json: @division_syns\n end", "def index\n @spaces = Space.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spaces }\n end\n end", "def json_at(url)\n JSON.parse(open(url).read, symbolize_names: true)[:objects]\nend", "def index\n @pages = Page.all\n render json: @pages\n end", "def index\n @dinos = Dino.where(query_params)\n render json: @dinos\n end", "def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend", "def 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 @devices = Device.all\n render json: @devices\n end", "def index\n\t\t@jquery = InitHelper.new( gon )\n\t\t@data_sets = DataSet.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @data_sets }\n\t\tend\n\tend", "def root\n get '/'\n end", "def get_info(id)\n url = \"http://www.omdbapi.com/?i=#{id}&y=&plot=short&r=json\"\n return_result(url)\n end", "def index\n @stories = Story.all\n render json: @stories, root: false\n end", "def show\n @denuncium = Denuncium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @denuncium }\n end\n end", "def retrieve_docs_from_host1\n apis = {}\n host = @doc_urls[:doc_base1][%r{^https?:\\/\\/[^\\/]+}]\n apis_received = open(@doc_urls[:doc_base1], @api_docs, &:read).scan(/<a class=\"swagger-list--item-link\" href=\"\\/(.+?)\".*?>\\s*(.+?)\\s*<\\/a>/i)\n \n apis_received.each do |path, title|\n begin\n api = { path: \"#{@doc_urls[:doc_base1]}#{path}\",\n title: title.sub(/\\s*\\(.+?\\)$/, ''),\n deprecated: title.include?('(Deprecated)') }\n\n fetched_path = open(api['path'], Options, &:read).scan(%r{url:\\s*'(.+?)'})\n api[:path] = \"#{host}#{fetched_path}\"\n apis[api[:title]] = api\n rescue OpenURI::HTTPError\n # Some log here\n end\n end\n\n apis\n end", "def root\n get \"/\"\n end", "def root\n get \"/\"\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end", "def index\n @dolgnosts = Dolgnost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dolgnosts }\n end\n end", "def index\n @omatsuris = Omatsuri.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @omatsuris }\n format.json { render :json => @omatsuris }\n end\n end", "def json_stores\n @_json_stores ||= doc.xpath(\"/html/body/script[@class='tiddlywiki-tiddler-store']\")\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 show\n simulation = Simulation.retrieve_by_id(params[:id])\n\n render json: simulation\n end", "def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end", "def index\n render json: Space.all\n end", "def index\n @curriculums = Curriculum.all\n respond_to do |format|\n\t\t\tformat.html { render :index }\n\t\t\tformat.json { render json: Oj.dump(@curriculums) }\n\t\tend\n end", "def set_dominio\n @dominio = Dominio.find(params[:id])\n end", "def index(cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(@resource_uri)\n end", "def index(cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(@resource_uri)\n end", "def query\n\n JSON.parse(Net::HTTP.get(self.build_uri))\n\n end", "def index\n @urls = Url.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @urls }\n end\n end", "def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end", "def swapi_fetch(url)\n JSON.parse(open(url).read)\nend", "def index\n @divisions = Division.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @divisions }\n end\n end", "def get_root_modules(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/root/\"\n _get(query_string)\nend", "def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end", "def index\n @dia_eventos = DiaEvento.all\n render json: @dia_eventos\n end", "def index\n @dbh_measurements = DbhMeasurement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dbh_measurements }\n end\n end", "def index\n @jsons = Json.all\n end", "def index\n hardware = Hardware.all\n render json: hardware.to_json(:except => [:id])\n end", "def index\n @djs = Dj.all\n end", "def index\n\t\t@direccions = Direccion.where(:personas_id => session[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @direccions }\n\t\tend\n\tend" ]
[ "0.6847571", "0.63628334", "0.6062485", "0.57496095", "0.5734541", "0.5715196", "0.55990005", "0.5503167", "0.55026585", "0.5459096", "0.5449624", "0.5447301", "0.5413397", "0.53878415", "0.5377644", "0.5362374", "0.53560823", "0.53488183", "0.5337409", "0.5337409", "0.5332752", "0.53227216", "0.5315562", "0.531304", "0.52876866", "0.5268874", "0.5259371", "0.5237024", "0.5212933", "0.5211724", "0.520646", "0.52005994", "0.51880455", "0.5177392", "0.51469195", "0.51455027", "0.5139255", "0.51261634", "0.5122962", "0.5120082", "0.5119404", "0.5113923", "0.5113397", "0.5101034", "0.5099949", "0.5098414", "0.5097201", "0.5093446", "0.5083042", "0.50823593", "0.507406", "0.50712395", "0.5064983", "0.50639004", "0.50512093", "0.5050479", "0.50423187", "0.50416327", "0.5040791", "0.50375557", "0.5035434", "0.50319433", "0.5030177", "0.50245595", "0.50164205", "0.5015921", "0.5013084", "0.5004835", "0.50046444", "0.5004337", "0.50026184", "0.49979436", "0.49970725", "0.49949557", "0.49949557", "0.49855325", "0.4984434", "0.49817023", "0.49815336", "0.49778187", "0.49776435", "0.4977173", "0.4976993", "0.49751252", "0.49742508", "0.4973857", "0.49715638", "0.49715638", "0.49697953", "0.49684498", "0.49669892", "0.49652603", "0.49625075", "0.49604052", "0.49581346", "0.49575022", "0.49568328", "0.49504384", "0.49490604", "0.494831", "0.49472862" ]
0.0
-1
POST /dom0s POST /dom0s.json
def create @dom0 = Dom0.new(dom0_params) respond_to do |format| if @dom0.save format.html { redirect_to @dom0, notice: 'Dom0 was successfully created.' } format.json { render :show, status: :created, location: @dom0 } else format.html { render :new } format.json { render json: @dom0.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dom0_params\n params[:dom0]\n end", "def index\n @dom0s = Dom0.all\n end", "def destroy\n @dom0.destroy\n respond_to do |format|\n format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def set_dom0\n @dom0 = Dom0.find(params[:id])\n end", "def update\n respond_to do |format|\n if @dom0.update(dom0_params)\n format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' }\n format.json { render :show, status: :ok, location: @dom0 }\n else\n format.html { render :edit }\n format.json { render json: @dom0.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end", "def create\n @municipio_dominio = MunicipioDominio.new(params[:municipio_dominio])\n\n respond_to do |format|\n if @municipio_dominio.save\n format.html { redirect_to @municipio_dominio, :notice => 'Municipio dominio was successfully created.' }\n format.json { render :json => @municipio_dominio, :status => :created, :location => @municipio_dominio }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @municipio_dominio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n megam_rest.post_node(to_hash)\n end", "def create_doi\n response = RestClient.post DoiConfig.url_for_creating_doi, data, :content_type => 'text/plain'\n return response\n end", "def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end", "def create\n @paper = Paper.new(paper_params)\n\t respond_to do |format|\n if @paper.save\n filename = @paper.userdoc.path \n puts filename \n response = RestClient.post('http://maui-indexer.appspot.com/mauiapp',\n :document => File.new(filename,\"rb\"),\n :domain => \"keywords\")\n doc = Nokogiri::HTML(response)\n keywords = \"\"\n doc.css(\"#keywords a\").each do |k|\n keywords << k << ' '\n end\n puts keywords \n textfile = `pdftotext #{filename} -`\n ref =[]\n #textfile.reverse_each do|s|\n #if s.upcase == \"REFERENCES\\n\"\n #break\n #end\n #ref << s\n #end\n #ref.reverse_each do |s|\n # puts s\n #end\n url = \"http://wikipedia-miner.cms.waikato.ac.nz/services/wikify?source=\" + URI::encode(keywords.force_encoding('ASCII-8BIT')) + \"&minProbability=0.1\"\n doc = Nokogiri::XML(open(url))\n topics = []\n doc.css(\"detectedTopic\").each do |t|\n puts t\n topics << t[:title]<<t[:weight] \n end\n puts topics\n @paper.keywords = keywords\n @paper.topics = topics\n\nkeywords.gsub!(\" \",\"%20\")\nkeywords = keywords.chomp('+')\nurl = \"https://api.mendeley.com:443/search/catalog?query=\"+keywords+\"&view=all&limit=100\"\nhtml = open(url, \"Authorization\" => \"Bearer #{session[:mendeley_token]}\").read\ndocs = JSON.parse(html)\nsession = Neo4j::Session.open(:server_db, 'http://localhost:7474')\n\ndocs.each do |d|\n puts \"ID: \" + d[\"id\"]\n authors = [] \n begin\n d[\"authors\"].each do |a|\n authors << a[\"first_name\"] + \" \" + a[\"last_name\"]\n end\n rescue \n authors = []\n end\n docnode = Neo4j::Node.create({id: d[\"id\"], title: d[\"title\"], type: d[\"type\"], authors: authors, year: d[\"year\"], month: d[\"month\"], day: d[\"day\"], source: d[\"source\"], keywords: d[\"keywords\"], accessed: d[\"accessed\"], reader_count: d[\"reader_count\"], abstract: d[\"abstract\"]}, :PAPER)\n begin\n reader_count_by_academic_status = []\n d[\"reader_count_by_academic_status\"].each do |key, value|\n docnode[key.to_sym] = value\n reader_count_by_academic_status << key\n end\n docnode[:reader_count_by_academic_status] = reader_count_by_academic_status\n rescue\n #academic status details not found\n end\n\n begin \n reader_count_by_country =[]\n d[\"reader_count_by_country\"].each do |key, value|\n docnode[key.to_sym] = value\n reader_count_by_country << key\n end\n docnode[:reader_count_by_country] = reader_count_by_country\n rescue\n #country details not found \n end\n begin\n reader_count_by_subdiscipline = []\n d[\"reader_count_by_subdiscipline\"].each do |key,value|\n docnode[key.to_sym] = value.values.inject(:+)\n reader_count_by_subdiscipline << key\n end\n docnode[:reader_count_by_subdiscipline] = reader_count_by_subdiscipline\n rescue\n #subdiscipline details not found \n end\nend\n\n\n # puts `ruby ~/rails_project/maui_rest.rb \"#{@paper.userdoc.path}\"`\n @paper.save \n format.html { redirect_to @paper, notice: 'Paper was successfully created.' }\n format.json { render :show, status: :created, location: @paper }\n else\n format.html { render :new }\n format.json { render json: @paper.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_d3_key d3_key\n log_file = \"log/\" + d3_key + \"-\" + Time.now.utc.to_s.gsub(/\\s/, \"-\")\n `mkdir -p log`\n `mkdir -p tmp`\n \n `curl --user-agent \"#{USER_AGENT}\" -v --cookie tmp/cookie --cookie-jar tmp/cookie2 -d \"gameKey=#{d3_key}\" https://us.battle.net/account/management/add-game.html 2>&1 >> #{log_file}`\n puts \"posted d3 key: #{d3_key}, posted_at: #{Time.now.to_s}\"\n nil\nend", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x| \n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x| \n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/2001/XMLSchema-instance\"\n xml.root.add_namespace \"xsd\", \"http://www.w3.org/2001/XMLSchema\"\n # for challengeResponses/response\n xml.each_element(\"//response\") do |x|\n x.add_namespace \"v11\", \"http://schema.intuit.com/platform/fdatafeed/challenge/v1\"\n x.name = \"v11:response\"\n end\n # for challengeResponses root\n xml.each_element(\"//challengeResponses\") do |x|\n x.add_namespace \"v1\", \"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\"\n x.name = \"challengeResponses\"\n end\n end", "def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end", "def post\n _root_document\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def post(url_variables:, body:)\n ensure_service_document\n\n end", "def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend", "def create\n @domino = Domino.new(params[:domino])\n\n respond_to do |format|\n if @domino.save\n flash[:notice] = 'Domino was successfully created.'\n format.html { redirect_to(@domino) }\n format.xml { render :xml => @domino, :status => :created, :location => @domino }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domino.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end", "def test2\n uri = 'http://dbhack1.nescent.org/cgi-bin/phylows.pl/phylows/tree/TB:1999'\n # @x = Net::HTTP.get_response(URI.parse(uri)).body\n @d = Nexml::Document.new(:url => uri)\n end", "def create\n @quest_tree = QuestTree.new(params[:quest_tree])\n\n respond_to do |format|\n if @quest_tree.save\n format.html { redirect_to @quest_tree, notice: 'Quest tree was successfully created.' }\n format.json { render json: @quest_tree, status: :created, location: @quest_tree }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quest_tree.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @svgpost = Svgpost.new(params[:svgpost])\n\n respond_to do |format|\n if @svgpost.save\n format.html { redirect_to @svgpost, notice: 'Svgpost was successfully created.' }\n format.json { render json: @svgpost, status: :created, location: @svgpost }\n else\n format.html { render action: \"new\" }\n format.json { render json: @svgpost.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\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 @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n neo = Neography::Rest.new\n city = neo.create_node(params[:city])\n redirect_to cities_path\n end", "def test_post_sample_traces\n header 'Content-Type', 'application/json'\n\n (0..4).each do |i|\n data = File.read \"sample-traces/#{i}.json\"\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n assert last_response.ok?\n end\n end", "def create\n response = @page.parse_url\n render json: response\n end", "def post(path, form_data=nil)\n parse_json do |parser|\n @http_client.post(path, form_data) {|chunk| parser << chunk }\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def create\n\n params[:elements].values.each do |elem|\n puts 'el', elem\n elem_to_save = Element.create (elem)\n @design.elements << elem_to_save\n end\n\n\n respond_to do |format|\n if @design.id\n format.html { redirect_to edit_design_path(@design), notice: 'Design was successfully created.' }\n format.json { render :json => @design}\n else\n format.html { render :new }\n format.json { render json: @design.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def create\n @director = Director.find(params[:director_id])\n @soaps = @director.soaps.create(soap_params)\n redirect_to director_path(@director)\n\n\n end", "def get_json\n html = Nokogiri::HTML(@page)\n text = open(\"https://theintercept.com/api/requestSIDDocuments/?orderBy=publishedTime&orderDirection=desc&perPage=2000\").read\n documents = JSON.parse(text)[\"documents\"][\"edges\"].map{|d| d[\"node\"]}\n \n documents.each do |doc|\n @output.push(parse_json(doc))\n end\n\n return JSON.pretty_generate(@output)\n end", "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def post_inventories(name,description, organization=1,variables='')\n dprint \"/api/v1/hosts\"\n resp = @rest['/api/v1/hosts'].post({\n :name => name,\n :description => description,\n :organization => organization,\n :variables => variables\n })\n dprint resp\n\n #[XXX] Theoretical what this is at this point - need to see \n # actual response\n JSON.parse(resp)[\"results\"]\n end", "def create\n @documentos_simposio = DocumentosSimposio.new(documentos_simposio_params)\n\n respond_to do |format|\n if @documentos_simposio.save\n format.html { redirect_to @documentos_simposio, notice: 'Documentos simposio was successfully created.' }\n format.json { render :show, status: :created, location: @documentos_simposio }\n else\n format.html { render :new }\n format.json { render json: @documentos_simposio.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dataelement = Dataelement.new(params[:dataelement])\n\n respond_to do |format|\n if @dataelement.save\n format.html { redirect_to @dataelement, notice: 'Dataelement was successfully created.' }\n format.json { render json: @dataelement, status: :created, location: @dataelement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dataelement.errors, status: :unprocessable_entity }\n end\n end\n end", "def json\n fields = dataset.dataset_fields\n e_doc = Hpricot(open(url))\n data = {\"id\"=> id, \"url\"=> url }\n fields.each do |field|\n p field\n data[field.name] = (e_doc/field.css).text.strip\n end\n puts data.inspect \n \n data.to_json \n end", "def create\n @initial_survey = InitialSurvey.new(initial_survey_params)\n cookies[:user] = @initial_survey.user\n\n respond_to do |format|\n if @initial_survey.save\n format.html { redirect_to new_simulation_path, notice: 'Initial survey was successfully created.' }\n format.json { render :show, status: :created, location: @initial_survey }\n else\n format.html { render :new }\n format.json { render json: @initial_survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n res = self.class.post('/', body: attrs)\n res.created?\n end", "def create\n @word_root = WordRoot.new(word_root_params)\n\n respond_to do |format|\n if @word_root.save\n format.html { redirect_to @word_root, notice: 'Word root was successfully created.' }\n format.json { render :show, status: :created, location: @word_root }\n format.js\n else\n format.html { render :new }\n format.json { render json: @word_root.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end", "def generate_tags\n uri = URI.parse(\"https://api.thomsonreuters.com/permid/calais\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n post_body = []\n post_body << \"<Document><Body>\"\n # stip html\n post_body << ActionView::Base.full_sanitizer.sanitize(params[:desc])\n # no strip\n # post_body << params[:desc]\n post_body << \"</Body></Document>\"\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field(\"Content-Type\",\"text/xml\")\n request.add_field(\"outputFormat\",\"application/json\")\n #request.add_field(\"outputFormat\",\"text/n3\") \n request.add_field(\"x-ag-access-token\",\"fY7WUM3GGCXHm9ATOhtzhrvlWX8oPo5X\")\n request.body = post_body.join\n # request[\"Content-Type\"] = \"multipart/form-data, boundary=#{BOUNDARY}\"\n\n render :json => http.request(request).body\n end", "def post payload, path = \"\" \n make_request(path, \"post\", payload)\n end", "def new\n @paper = Paper.new\n @document = @paper.documents.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper }\n end\n end", "def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if @node.save\n cookies[:last_node_id] = @node.id \n format.html { redirect_to @node, notice: 'node created!' }\n format.json { render json: @node, status: :created, location: @node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @track = Track.new(track_params)\n\n respond_to do |format|\n if @track.save\n if @nodes\n @nodes.each do |node_data|\n node_data['track'] = @track\n Node.create(node_data)\n end\n end\n format.html { redirect_to @track, notice: 'Track was successfully created.' }\n format.json { render :show, status: :created, location: @track }\n else\n format.html { render :new }\n format.json { render json: @track.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params = paper_params\n authors = params.delete(:authors).split(\",\").map do |aname|\n Author.find_or_create_by(name: aname.strip)\n end\n\n awards = params.delete(:awards).split(\",\").map do |abody|\n Award.find_or_create_by(body: abody.strip, year: paper_params[:year])\n end\n\n @paper = Paper.new(params)\n @paper.authors = authors\n @paper.awards = awards\n\n respond_to do |format|\n if @paper.save\n format.js { render json: @paper }\n else\n format.js { render json: { error: @paper.errors } }\n end\n end\n end", "def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end", "def create\n @u_ser = USer.new(params[:u_ser])\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render json: @u_ser, status: :created, location: @u_ser }\n else\n format.html { render action: \"new\" }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @domicile_type_section = DomicileTypeSection.new(params[:domicile_type_section])\n\n respond_to do |format|\n if @domicile_type_section.save\n format.html { redirect_to(@domicile_type_section, :notice => 'Domicile type section was successfully created.') }\n format.xml { render :xml => @domicile_type_section, :status => :created, :location => @domicile_type_section }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domicile_type_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def post(attrs = nil)\n attrs ||= attributes\n\n execute_request('POST') do |uri, headers|\n HTTP.http_client.post(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end", "def create\n @dataset = Dataset.new(params[:dataset])\n prep_dataset_form\n @dataset.save!\n publish_press_item(\"New dataset added: #{@dataset.title}\")\n\n respond_to do |wants|\n flash[:notice] = 'Dataset was successfully created.'\n wants.html { redirect_to(@dataset) }\n wants.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend", "def create\n if request.format.js?\n @schicht = Schicht.new(schicht_params)\n # Transform date to utc (compatibility with offline version)\n @schicht.datum = DateTime.new(@schicht.datum.year, @schicht.datum.month, @schicht.datum.day)\n @schicht.benutzer = current_user\n @schicht.objekt = current_objekt\n @schicht.wachbuch_eintrag = WachbuchEintrag.create\n @schicht.save\n else\n doc = Nokogiri::XML(request.body.read)\n sNode = doc.xpath('elwak/schicht')[0]\n @schicht = parseSchicht(sNode)\n end\n respond_to do |format|\n format.xml {render :xml => '<?xml version=\"1.0\" encoding=\"UTF-8\"?><success />'}\n format.js {render action: 'save_success'}\n end\n end", "def post(request_opts = {})\n store_result(http(request_opts).post(resolved_path, @attrs))\n end", "def create\n @location = Geolocation.new(params[:geolocation])\n @scene = Scene.new(:title => params[:title])\n @location.scenes << @scene\n @location.save\n @scene.save\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully create.'}\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\"}\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @u_ser = USer.new(u_ser_params)\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render :show, status: :created, location: @u_ser }\n else\n format.html { render :new }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, data=nil)\n request(:post, path, data)\n end", "def create\n @odist = Odist.new(odist_params)\n\n respond_to do |format|\n if @odist.save\n format.html { redirect_to @odist, notice: 'Odist was successfully created.' }\n format.json { render :show, status: :created, location: @odist }\n else\n format.html { render :new }\n format.json { render json: @odist.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def criar_sobrevivente\n @suvivor = Sobrevivente.create(\n name: params[:name], genero: params[:genero], idade: params[:idade],\n lat: params[:lat], lon: params[:lon],\n agua: params[:agua], comida: params[:comida], medicamento: params[:medicamento],\n municao: params[:municao]\n )\n render json: @suvivor\n end", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if @node.save!\n format.html { redirect_to @node, notice: 'Встречная продажа создана' }\n format.json { render json: @node, status: :created, location: @node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend", "def POST; end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create\n divesite = Divesites.new(divesite_params)\n if divesite.save\n render json: divesite\n else\n render json: {message: divesite.errors}, status: 400\n end\n end", "def create\n @website = Website.new(create_params)\n @website.save!\n # create default values\n @website.create_default\n @website.save!\n \n @websites = Website.all\n .order(created_at: :desc)\n respond_to do |format|\n format.js\n end\n end", "def create\n @samochod = Samochod.new(samochod_params)\n\n respond_to do |format|\n if @samochod.save\n format.html { redirect_to @samochod, notice: 'Samochod was successfully created.' }\n format.json { render :show, status: :created, location: @samochod }\n else\n format.html { render :new }\n format.json { render json: @samochod.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @obj = Node.new(params[:node])\n\n respond_to do |format|\n if @obj.save\n format.html { redirect_to @obj, notice: 'Node was successfully created.' }\n format.json { render json: @obj, status: :created, location: @obj }\n else\n format.html { render action: \"new\" }\n format.json { render json: @obj.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @root_collection = RootCollection.new(root_collection_params)\n\n respond_to do |format|\n if @root_collection.save\n format.html { redirect_to @root_collection, notice: 'Root collection was successfully created.' }\n format.json { render :show, status: :created, location: @root_collection }\n else\n format.html { render :new }\n format.json { render json: @root_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def post #:doc:\n end", "def serialize!\n\t\t\t@namespaces=raw_doc.root.namespaces if @namespaces.nil?\n\t\t\t@authors=[]\n\t\t\t@raw_doc=raw_doc.at('./xmlns:entry',@namespaces) if raw_doc.at('./xmlns:entry',@namespaces)\n\t\t\t@title=text(raw_doc.at('./xmlns:title',@namespaces))\n\t\t\t@id=text(raw_doc.at('./xmlns:id',@namespaces))\n\t\t\t@summary=text(raw_doc.at('./xmlns:summary',@namespaces))\n\t\t\td=text(raw_doc.at('./xmlns:updated',@namespaces))\n\t\t\t@updated=DateTime.parse(d) unless d.nil?\n\t\t\td=text(raw_doc.at('./xmlns:published',@namespaces))\n\t\t\t@published=DateTime.parse(d) unless d.nil?\n\n\t\t\t@authors=raw_doc.xpath('./xmlns:author',@namespaces).collect do |author|\n\t\t\t\t{\n\t\t\t\t\t:name => text(author.at('./xmlns:name',@namespaces)),\n\t\t\t\t\t:uri => text(author.at('./xmlns:uri',@namespaces)),\n\t\t\t\t\t:email => text(author.at('./xmlns:email',@namespaces))\n\t\t\t\t}\n\t\t\tend\n\n\t\t\t@links=OPDS::Support::LinkSet.new @browser\n\t\t\traw_doc.xpath('./xmlns:link',@namespaces).each do |n|\n\t\t\t\ttext=nil\n\t\t\t\ttext=n.attributes['title'].value unless n.attributes['title'].nil?\n\t\t\t\tlink=n.attributes['href'].value\n\t\t\t\ttype=n.attributes['type'].value unless n.attributes['type'].nil?\n\t\t\t\tprice=nil\n\t\t\t\tcurrency=nil\n\t\t\t\t@namespaces['opds']||='http://opds-spec.org/2010/catalog'\n\t\t\t\ttypes=n.search('.//opds:indirectAcquisition',@namespaces).map{|b| b['type']}\n\t\t\t\ttype=[type,types].flatten.compact unless types.nil? || types.empty?\n\t\t\t\toprice=n.at('./opds:price',@namespaces)\n\t\t\t\tif oprice\n\t\t\t\t\tprice=text(oprice)\n\t\t\t\t\tcurrency=oprice.attributes['currencycode'].value unless oprice.attributes['currencycode'].nil?\n\t\t\t\tend\n\n\t\t\t\tunless n.attributes['rel'].nil?\n\t\t\t\t\tn.attributes['rel'].value.split.each do |rel|\n\t\t\t\t\t\t@links.push(rel,link,text,type,price,currency)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t@links.push(nil,link,text,type,price,currency)\n\t\t\t\tend\n\t\t\tend\n\t\t\t@dcmetas=Hash.new\n\t\t\tprefs=@namespaces.reject{|_,v| !%W[http://purl.org/dc/terms/ http://purl.org/dc/elements/1.1/].include?v}\n\t\t\tprefs.keys.map{|p| p.split(':').last}.each do |pref|\n\t\t\t\traw_doc.xpath('./'+pref+':*',@namespaces).each do |n|\n\t\t\t\t\t@dcmetas[n.name]=[] unless @dcmetas[n.name]\n\t\t\t\t\t@dcmetas[n.name].push [n.text, n]\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t@categories=raw_doc.xpath('./xmlns:category',@namespaces).collect do |n|\n\t\t\t\t[text(n.attributes['label']),text(n.attributes['term'])]\n\t\t\tend\n\n\t\t\t@content=raw_doc.at('./xmlns:content',@namespaces).to_s\n\t\t\t\n\t\t\t@contributors=raw_doc.xpath('./xmlns:contributor',@namespaces).collect do |auth|\n\t\t\t\t{\n\t\t\t\t\t:name => text(raw_doc.at('./xmlns:contributor/xmlns:name',@namespaces)),\n\t\t\t\t\t:uri => text(raw_doc.at('./xmlns:contributor/xmlns:uri',@namespaces)),\n\t\t\t\t\t:email => text(raw_doc.at('./xmlns:contributor/xmlns:email',@namespaces))\n\t\t\t\t}\n\t\t\tend\n\n\t\t\t@rights=text(raw_doc.at('./xmlns:rights',@namespaces))\n\t\t\t@subtitle=text(raw_doc.at('./xmlns:rights',@namespaces))\n\n\t\tend", "def create\n @nodo = Nodo.new(nodo_params)\n\n respond_to do |format|\n if @nodo.save\n #format.html { redirect_to @nodo, notice: 'Nodo was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @nodo }\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n else\n format.html { render action: 'new' }\n format.json { render json: @nodo.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n puts session[:_csrf_token]\n @departments = Department.all\n render json: @departments, status: :ok\n end", "def create(object, path = nil)\n to_ostruct(post(sanitize!(path), object.to_json))\nend", "def create\n @wod = Wod.new(wod_params)\n\n if @wod.save\n render json: @wod, status: :created\n else\n render json: @wod.errors, status: :unprocessable_entity\n end\n end", "def post_data; end", "def create\n @kingdom = Kingdom.new(params[:kingdom])\n\n respond_to do |format|\n if @kingdom.save\n flash[:notice] = 'Kingdom was successfully created.'\n format.html { redirect_to(@kingdom) }\n format.xml { render :xml => @kingdom, :status => :created, :location => @kingdom }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @kingdom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend", "def index\n json = HTTParty.get(\"https://api.typeform.com/v1/form/WaIffL?key=f486f2db8f1249c077a08b582bc3efe0a2617668\").body\n\n @jsontests = JSON.parse(json)\n\n end", "def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end", "def post(path, opts = {})\n request(:post, path, opts).body\n end", "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def post url\n Timeout.timeout(60) do\n puts \"POST: #{url}\" if config[:debug]\n \n tags = (Hpricot(open(\"http://del.icio.us/url/check?url=#{CGI.escape(url)}\"))/\n '#top-tags'/'li')[0..10].map do |li| \n (li/'span').innerHTML[/(.*?)<em/, 1]\n end.join(\" \")\n puts \"POST-TAGS: #{tags}\" if config[:debug]\n \n description = begin\n Timeout.timeout(5) do \n (((Hpricot(open(url))/:title).first.innerHTML or url) rescue url)\n end\n rescue Timeout::Error\n puts \"POST: URL timeout\" if config[:debug]\n url\n end\n \n query = { :url => url, :description => description, :tags => tags, :replace => 'yes' }\n\n http = Net::HTTP.new('api.del.icio.us', 443) \n http.use_ssl = true \n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.start do |http|\n post_url = '/v1/posts/add?' + query.map {|k,v| \"#{k}=#{CGI.escape(v)}\"}.join('&')\n puts \"POST: post url #{post_url}\" if config[:debug]\n req = Net::HTTP::Get.new(post_url, {\"User-Agent\" => \"Kirby\"})\n req.basic_auth config[:delicious_user], config[:delicious_pass]\n http.request(req)\n end.body\n\n puts \"POST: #{response.inspect}\" if config[:debug]\n end\n rescue Exception => e\n puts \"POST: #{e.inspect}\" if config[:debug]\n end", "def post(attributes, header = {})\n return new(attributes) if ApiKits.config.mock\n url = \"#{ApiKits.config.api_uri}#{self.resource_path}\"\n response = ApiKits::Dispatcher.post(url, { self.root_node.to_sym => attributes }, header)\n build(response, url)\n end", "def create_doc\n\t\theaders = {:content_type => 'application/xml'}\n\t\turi = CGI.escape(\"/\" + rand(2).to_s() + \"/\" + rand(10).to_s() + \"/\" + rand(1000000).to_s() + \".xml\")\n\t\tresponse = @resource[\"/documents/\" + uri].put('<stuff xmlns=\"stuff\">' + uri + '</stuff>', headers)\n\t\treturn uri\n\tend", "def post_api(path, params = {})\n current_session.post(\"#{$settings.url}/#{path}\", params, {\n 'HTTP_X_CSRF_BYPASS' => 'yes'\n })\n last_response.body ? Oj.load(last_response.body) : nil\n end", "def postEntityDocument( entity_id, name, filedata)\n params = Hash.new\n params['entity_id'] = entity_id\n params['name'] = name\n params['filedata'] = filedata\n return doCurl(\"post\",\"/entity/document\",params)\n end", "def targetURI\n \"http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/domimplementationcreatedocumenttype02\"\n end", "def post(url, query = nil, headers = nil)\n headers = headers ? @headers.merge(headers) : @headers\n #Log.t(\"POST: #{url}\\n#{query.inspect}\\n#{headers.inspect}\")\nres = @client.post(URI.join(@base, url), query, headers) rescue nil\n\t#puts \"*******************************************\"\n\t#puts res.inspect\n if res != nil\n\t@responseHeaders = res.header\n Nokogiri::HTML(res.body)\n else\n Nokogiri::HTML('')\n end\n end", "def create\n @node_incident = NodeIncident.new(params[:node_incident])\n\n respond_to do |format|\n if @node_incident.save\n format.html { redirect_to @node_incident, :notice => 'Node incident was successfully created.' }\n format.json { render :json => @node_incident, :status => :created, :location => @node_incident }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @node_incident.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @homeroom = Homeroom.new(homeroom_params)\n\n respond_to do |format|\n if @homeroom.save\n format.html { redirect_to @homeroom, notice: 'Homeroom was successfully created.' }\n format.json { render :show, status: :created, location: @homeroom }\n else\n format.html { render :new }\n format.json { render json: @homeroom.errors, status: :unprocessable_entity }\n end\n end\n end", "def couchdb_post(urn, host = '127.0.0.1', options = @@default_options)\n query_couchdb(urn, 'POST', host, options)\n end", "def create\n @iot_datum = IotDatum.new(iot_datum_params)\n\n respond_to do |format|\n if @iot_datum.save\n format.html { redirect_to @iot_datum, notice: 'Iot datum was successfully created.' }\n format.json { render :show, status: :created, location: @iot_datum }\n else\n format.html { render :new }\n format.json { render json: @iot_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @paper = Paper.new(paper_params)\n\n respond_to do |format|\n if @paper.save\n format.html { redirect_to \"/trabalhos\", notice: 'Trabalho criado com sucesso.' }\n format.json { render :show, status: :created, location: @paper }\n else\n format.html { render :new }\n format.json { render json: @paper.errors, status: :unprocessable_entity }\n end\n end\n end", "def build_dom(entries); end", "def create_node_with_props data\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n 'Content-Type' => 'application/json',\n }\n post_request 'node', data, headers\n end" ]
[ "0.57373255", "0.571542", "0.56012785", "0.551812", "0.54482204", "0.5268613", "0.5030848", "0.49307495", "0.4899661", "0.48912323", "0.4800201", "0.47533327", "0.4743312", "0.47391972", "0.4730478", "0.4728335", "0.47194347", "0.47138953", "0.47062275", "0.46899125", "0.46721894", "0.46639696", "0.46371752", "0.46292385", "0.4615859", "0.45961532", "0.45837092", "0.45674798", "0.4560752", "0.45596334", "0.45486104", "0.45423582", "0.45414335", "0.45360926", "0.4526577", "0.452221", "0.45196238", "0.45184937", "0.45097673", "0.45012602", "0.44935024", "0.44923145", "0.44908023", "0.44825068", "0.44802532", "0.4463883", "0.44614217", "0.4453335", "0.4451828", "0.44514546", "0.44494185", "0.44332108", "0.44315898", "0.44301736", "0.44291055", "0.4423972", "0.4422403", "0.44185844", "0.44171017", "0.44167686", "0.44159475", "0.44133094", "0.4409139", "0.44064134", "0.44027779", "0.43987983", "0.43974775", "0.43970627", "0.43956286", "0.43936852", "0.43911588", "0.4390916", "0.43875763", "0.4382524", "0.43811342", "0.43805128", "0.437534", "0.43746293", "0.4374073", "0.43622205", "0.43602923", "0.4358879", "0.43558946", "0.43557003", "0.435404", "0.43535668", "0.4352788", "0.43520325", "0.43519756", "0.43509424", "0.43493238", "0.43465072", "0.4344968", "0.4343801", "0.4343792", "0.4341074", "0.43407422", "0.43402869", "0.43390736", "0.433127" ]
0.71896154
0
PATCH/PUT /dom0s/1 PATCH/PUT /dom0s/1.json
def update respond_to do |format| if @dom0.update(dom0_params) format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' } format.json { render :show, status: :ok, location: @dom0 } else format.html { render :edit } format.json { render json: @dom0.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def patch!\n request! :patch\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, opts = {})\n request(:patch, path, opts).body\n end", "def patch(path, **args); end", "def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end", "def patch\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update(data = :object || :json)\n end", "def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end", "def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\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 respond_with []\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update!\n request_ids.shift\n return unless request_ids.empty?\n\n @@patcher ||= %x{snabbdom.init([\n snabbdom_attributes.default,\n snabbdom_class.default,\n snabbdom_eventlisteners.default,\n snabbdom_props.default,\n snabbdom_style.default,\n ])}\n node = @root.render\n @@patcher.call(@root.node, node)\n @root.node = node\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.xml { head :method_not_allowed }\n format.json { head :method_not_allowed }\n end\n end", "def update\n @modified_document = ModifiedDocument.find(params[:id])\n \n if @modified_document.update(modified_document_params)\n render json: @modified_document, status: :ok \n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update\n put :update\n end", "def put!\n request! :put\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @idiom = Idiom.find(params[:id])\n\n respond_to do |format|\n if @idiom.update_attributes(params[:idiom])\n format.html { redirect_to @idiom, notice: 'Idiom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @idiom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end", "def update(path)\n output { patch(path, params) }\n end", "def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch; end", "def patch; end", "def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end", "def update!(sobject, attrs)\n id = attrs.has_key?(:Id) ? attrs.delete(:Id) : attrs.delete('Id')\n raise 'Id field missing.' unless id\n api_patch \"sobjects/#{sobject}/#{id}\", attrs\n true\n end", "def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end", "def patch(attrs = nil)\n attrs ||= attributes.changed_attributes\n\n execute_request('PATCH') do |uri, headers|\n HTTP.http_client.patch(\n uri,\n body: adapter.serialize(attrs),\n header: headers.merge(CONTENT_TYPE_HEADERS)\n )\n end\n end", "def update\n # cyber-dojo.sh does actual [update]\nend", "def update_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}/_update\")\n req = Net::HTTP::Post.new(uri)\n req.body = { \"doc\": document }.to_json\n run(uri, req)\n end", "def update\n @person = Person.find(params[:id])\n\n populate_attributes(@person, params[:person])\n respond_to do |format|\n \n if @person.save && @person.identifiable_entries.each(&:save!)\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: document.errors, status: 422\n end\n\n end", "def update!(**args)\n @content = args[:content] if args.key?(:content)\n @derived_struct_data = args[:derived_struct_data] if args.key?(:derived_struct_data)\n @id = args[:id] if args.key?(:id)\n @json_data = args[:json_data] if args.key?(:json_data)\n @name = args[:name] if args.key?(:name)\n @parent_document_id = args[:parent_document_id] if args.key?(:parent_document_id)\n @schema_id = args[:schema_id] if args.key?(:schema_id)\n @struct_data = args[:struct_data] if args.key?(:struct_data)\n end", "def update\n @consulta = Consulta.find(params[:id])\n\n if @consulta.update(params[:consulta])\n head :no_content\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end", "def update\n 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(model, id, opts = {})\n name = model_name(model)\n do_restful_action(\"update\", name) do\n self.nagyo[\"#{name}/#{URI.encode(id)}/edit\"].put(:format => :js, name => opts)\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n @documento = Documento.find(params[:id])\n\n respond_to do |format|\n if @documento.update_attributes(params[:documento])\n format.html { redirect_to @documento, notice: 'Documento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @obj = Node.find(params[:id])\n\n respond_to do |format|\n if @obj.update_attributes(params[:node])\n format.html { redirect_to @obj, notice: 'Node was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @obj.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.json { render json: { status: :not_implemented } }\n end\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n\n sub_obj_non_attributes = study_params.select { |key| !key.to_s.match(/_attributes$/) }\n\n @study = Study.find(session[:current_study_id])\n\n \n if ! sub_obj_non_attributes.empty?\n @study.update(sub_obj_non_attributes.to_h.except('_destroy', 'id', 'rec_id', 'updated', 'rec_delete'))\n end\n \n traverse_study_attr(study_params.select { |key| key.to_s.match(/_attributes$/)}, @study)\n \n respond_to do |format|\n format.html { redirect_to study_steps_path}\n format.json { render action: 'show', status: :created, location: @study }\n\n end\n\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to root_url , notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person = Person.find(params[:id])\n @person.delete_offices\n @person.delete_addresses\n @person.delete_phone_numbers\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, notice: 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @specie = Specie.find(params[:id])\n\n respond_to do |format|\n if @specie.update_attributes(params[:specie])\n format.html { redirect_to @specie, notice: 'Specie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specie.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend", "def update\n fn = params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/')\n File.open(fn,'w+') { |f| \n f.puts params[:content]\n }\n respond_to do |format|\n format.json { render json: { success: true} }\n end\n end", "def update attrs\n put '', :body => {self.class.api_name => self.class.opts_to_query_opts(attrs)}\n end", "def update_doi\n response = RestClient.post \"#{DoiConfig.url_for_updating_doi}#{doi}\", sanitize_data, :content_type => 'text/plain; charset=UTF-8', :content_length => sanitize_data.size, :accept => 'text/plain'\n return response\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update\n @municipio_dominio = MunicipioDominio.find(params[:id])\n\n respond_to do |format|\n if @municipio_dominio.update_attributes(params[:municipio_dominio])\n format.html { redirect_to @municipio_dominio, :notice => 'Municipio dominio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @municipio_dominio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n head :ok\n end", "def update\n respond_to do |format|\n if @document.update_attributes(name: document_params[:name], lab_id: document_params[:lab_id])\n format.html { redirect_to documents_url, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: documents_url }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @request_for_change.set_manager(force: true)\n @request_for_change.set_security_officer(force: true)\n\n respond_to do |format|\n if @request_for_change.update(request_for_change_params)\n format.html { redirect_to edit_request_for_change_path(@request_for_change), notice: 'Request for change was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @request_for_change.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @camp.update(camp_params)\n format.html { redirect_to @camp, notice: \"#{@camp.name} was revised in the system.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.jdson { render json: @camp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n params[:document][:version] = ENV[\"VERSION\"]\r\n params[:document][:username] = current_user.username\r\n @document = Document.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @document.update_attributes(document_params)\r\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @document.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n if @metodo.update_attributes(params[:metodo])\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n # format.json { head :no_content }\n format.json { render jbuilder: @document }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n Rails.logger.info \"Before update\"\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n Rails.logger.info \"After update\"\n end", "def update\n respond_to do |format|\n if @docs_ponto.update(docs_ponto_params)\n format.html { redirect_to :back }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docs_ponto.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(uri, options = T.unsafe(nil)); end", "def update\n @id = params[:id]\n @resource = ActiveFedora::Base.find(@id)\n raise ActiveFedora::ObjectNotFoundError if not @resource\n\n authorize! :edit, @resource\n\n raise \"Resource doesn't support DOI functionality\" if not @resource.respond_to? :doi\n raise \"Cannot mint DOI for this resource\" if (@resource.respond_to? :can_mint_doi?) && !@resource.can_mint_doi?\n\n errors = @resource.validate_doi_metadata\n if errors.any?\n raise RuntimeError.new(errors.join('\\n'))\n end\n\n mint_doi @resource\n\n redirect_to @resource\n\n end", "def update\n\t\t# Left empty intentionally.\n\tend", "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 put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.64772713", "0.634038", "0.6260748", "0.6077363", "0.6016408", "0.6016157", "0.58441067", "0.5841534", "0.5798322", "0.5798322", "0.57883316", "0.57657605", "0.57232183", "0.5708018", "0.56785774", "0.56506515", "0.56330734", "0.5627697", "0.56198543", "0.5617977", "0.5613254", "0.5609591", "0.56042933", "0.5590719", "0.55860186", "0.55781674", "0.5571789", "0.5568129", "0.55495167", "0.55495167", "0.5537357", "0.5533993", "0.5533516", "0.5531156", "0.55242145", "0.5520444", "0.5514857", "0.55062646", "0.55054325", "0.55009025", "0.55008006", "0.5499829", "0.5499829", "0.54946846", "0.5486453", "0.5485305", "0.5484898", "0.5484306", "0.54624754", "0.5457508", "0.544771", "0.54471356", "0.5444387", "0.5439739", "0.54362166", "0.5432818", "0.5431476", "0.54306054", "0.54303896", "0.54196864", "0.5419432", "0.5418378", "0.54170555", "0.54162246", "0.5415957", "0.54087234", "0.54066396", "0.54066396", "0.5405969", "0.54048896", "0.5403612", "0.53985316", "0.5396227", "0.5392836", "0.5390466", "0.53893286", "0.5388713", "0.5386806", "0.5383464", "0.5373117", "0.5373117", "0.5370148", "0.5369669", "0.5366764", "0.53631324", "0.5357103", "0.53550774", "0.5352536", "0.5350794", "0.53496134", "0.5348347", "0.53470826", "0.5346204", "0.53426445", "0.53318816", "0.53318626", "0.5331033", "0.5331033", "0.53267723", "0.5325246" ]
0.6755568
0
DELETE /dom0s/1 DELETE /dom0s/1.json
def destroy @dom0.destroy respond_to do |format| format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete\n delete_from_server single_url\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "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 RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n request(:delete)\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end", "def delete(path)\n request(:delete, path)\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def delete(path)\n request 'DELETE', path\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def delete(url)\n do_request(\"delete\", url)\n end", "def delete\n api_client.delete(url)\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end", "def delete\n @client.delete_document(@path)\n end", "def delete(path)\n\t\trequest(path, :delete)\n\tend", "def test_delete1()\n key = \"_Delete1\"\n c = Scalaroid::JSONConnection.new(url = Scalaroid::DEFAULT_URL)\n rdht = Scalaroid::ReplicatedDHT.new(conn = c)\n sc = Scalaroid::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n\n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n\n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n\n c.close()\n end", "def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def delete\n client.delete(url)\n @deleted = true\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def deleteEntityDocument( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/document\",params)\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete!\n\t\t\tClient.delete @root\n\t\tend", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete(path)\n with_remote do |http|\n http.delete(path)\n end\n end", "def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end", "def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end", "def delete_now\n revisions.each do |rev_id| \n CouchDB.delete( \"#{uri}?rev=#{rev_id}\" )\n end\n true \n end", "def delete(path, payload = nil)\n req = Net::HTTP::Delete.new(path)\n action(req, payload)\n end", "def delete!\n request! :delete\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def delete(_url)\n # do nothing since we can't find the key by url\n end", "def destroy\n @asthenium.destroy\n respond_to do |format|\n format.html { redirect_to asthenia_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def destroy\n @nodo.destroy\n respond_to do |format|\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n end\n end", "def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end", "def delete\n api(\"Delete\")\n end", "def delete(oid)\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n head :no_content\n end", "def destroy\n Dojo.find(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to '/', notice: 'Dojo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, opts = {})\n request(:delete, path, opts).body\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end", "def delete(type, id)\n http_delete @target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\", @auth_header, @zone\n end", "def destroy\n @datastore = Datastore.find(params[:id])\n @datastore.destroy\n\n respond_to do |format|\n format.html { redirect_to datastores_url }\n format.json { head :no_content }\n end\n end", "def testDelete1()\n key = \"_Delete1\"\n c = Scalaris::JSONConnection.new(url = Scalaris::DEFAULT_URL)\n rdht = Scalaris::ReplicatedDHT.new(conn = c)\n sc = Scalaris::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n \n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n \n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n \n c.close()\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datashows = Datashow.find(params[:id])\n @datashows.destroy\n\n respond_to do |format|\n format.html { redirect_to(datashows_url) }\n format.xml { head :ok }\n end\n end", "def delete(container_name, file_name)\n validate_path_elements(container_name, file_name)\n\n client.request(\n method: :delete,\n path: \"#{container_name}/#{file_name}\",\n expected: 204\n )\n end", "def delete!\n Recliner.delete(uri)\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def delete(path, params = {})\n request(:delete, path, params)\n end", "def deleteEntityWebsite( 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/website\",params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end", "def delete(path, params={})\n request(:delete, path, params)\n end" ]
[ "0.6924843", "0.68064195", "0.66468406", "0.661468", "0.6569856", "0.6568001", "0.6556821", "0.65491503", "0.6527892", "0.6527892", "0.6527892", "0.6527892", "0.65258557", "0.65239805", "0.6523552", "0.6518982", "0.64959806", "0.64850986", "0.64850986", "0.647416", "0.6471033", "0.6452738", "0.6445475", "0.6445013", "0.644236", "0.6424042", "0.63999474", "0.6398087", "0.6393404", "0.63785774", "0.6378071", "0.63641465", "0.6354054", "0.6350307", "0.63416934", "0.63416934", "0.633837", "0.63193375", "0.63176185", "0.63054585", "0.6300124", "0.6295373", "0.6294404", "0.6287366", "0.62859565", "0.6280402", "0.6279031", "0.62697434", "0.6255238", "0.6247582", "0.624356", "0.624356", "0.62298775", "0.62285227", "0.6214978", "0.6211385", "0.6202875", "0.62020063", "0.61993235", "0.61993235", "0.6198667", "0.6193981", "0.6184618", "0.61740524", "0.6170094", "0.6166518", "0.6161918", "0.615173", "0.61470807", "0.61457115", "0.61352307", "0.6134811", "0.61326253", "0.61308134", "0.6125954", "0.6125504", "0.6124825", "0.61226463", "0.6117504", "0.61154085", "0.6110724", "0.6105147", "0.6095851", "0.6095577", "0.6093615", "0.6092226", "0.6086298", "0.60803336", "0.6078832", "0.60763425", "0.6075338", "0.6075338", "0.6075338", "0.6075191", "0.60723716", "0.60723716", "0.60723716", "0.60723716", "0.60723716", "0.60723716" ]
0.7263812
0
Use callbacks to share common setup or constraints between actions.
def set_dom0 @dom0 = Dom0.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 dom0_params params[:dom0] 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
Optionally add a hash of extra data, called info, to this exception. You can also add the engine's execution context, if available.
def initialize(msg, info = {}, execution_context: nil) super(msg) @info = info @execution_context = execution_context ? execution_context.dup : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_additional_data\n if Rails.application.secrets[:sentry_dsn].present?\n Raven.user_context(\n id: current_user&.id,\n email: current_user&.email,\n ip_address: request.ip\n )\n\n Raven.tags_context(\n domain: current_account&.domain,\n account_prefix: current_account&.account_prefix\n )\n\n # You can also set extra context using `Raven.extra_context`\n # Raven.extra_context app: url, environment: Rails.env, time: Time.now\n else\n request.env[\"exception_notifier.exception_data\"] = { user: current_user, account: current_account }\n end\n end", "def enter_exception_context(exception); end", "def append(*args)\n super\n rescue NotStored\n rescue Error => e\n log_exception e\n end", "def setup_exception_context(ex, _pry_, options={})\n _pry_.last_exception = ex \n _pry_.backtrace = (ex.backtrace || [])\n\n PryStackExplorer.frame_manager(_pry_).user[:exception] = ex\n PryStackExplorer.frame_manager(_pry_).user[:inline_exception] = !!options[:inline]\n end", "def append_info(text, options={})\n options[:category] ||= EventCategories::NONE # Do not event by default\n send_request('append_info', normalize_options(text, options))\n end", "def extra\n {\n identifier_type: raw_info[\"identifierType\"],\n method: raw_info[\"method\"],\n assurance_level: raw_info[\"assuranceLevel\"],\n status: raw_info[\"status\"]\n }\n end", "def lookup_error_extras(exception)\n extras = super\n extras = extras.merge(:error_identifier => error_identifier) if error_identifier\n extras\n end", "def exception_details(e, msg); end", "def extra; @extra; end", "def add_raven_extra_context(env)\n Raven.extra_context(\n original_status: env.status,\n original_body: env.body,\n original_method: env.method,\n original_url: env.url\n )\n end", "def add_extra_data(data)\n=begin\n data[:extra] = {\n password: 'mypass',\n host: 'myhost',\n port: 'myport',\n }\n=end\n return data\n end", "def add_infos(hash)\n self.custom_attributes.merge!(hash)\n end", "def track_exception(exception, extra = {})\n process_exception(exception, sentry: true, extra: extra)\n end", "def extra_context(options = nil)\n context.extra.merge!(options || {})\n yield if block_given?\n context.extra\n ensure\n context.extra.delete_if { |k, _| options.keys.include? k } if block_given?\n end", "def add_context( object=nil, **fields )\n\t\tself.log.debug \"Adding context from %p\" % [ object || fields ]\n\t\tcurrent_context = @context_stack.value.last or return\n\n\t\tif object\n\t\t\tobject_fields = self.fields_from_object( object )\n\t\t\tfields = fields.merge( object_fields )\n\t\tend\n\n\t\tcurrent_context.merge!( fields )\n\tend", "def info(msg, request=nil)\n super(with_extra_request_info(msg, request))\n end", "def exception_data\n exception_service.merge(\n error_class: @exception.class.to_s,\n message: @exception.respond_to?(:message) ? @exception.message : exception.inspect,\n backtrace: @exception.respond_to?(:backtrace) ? (@exception.backtrace || []).join(\"\\n\") : nil,\n cause: @exception.respond_to?(:cause) ? @exception.cause : nil\n )\n end", "def prepend(*args)\n super\n rescue NotStored\n rescue Error => e\n log_exception e\n end", "def extra=(extra)\n unless extra.kind_of?(Hash)\n raise(InvalidMetadata, \"extra must be a Hash\")\n end\n @extra = extra\n end", "def hubssolib_set_exception_data(e)\n HubSsoLib::Crypto.encode_object(e.message, request.remote_ip)\n end", "def additional_info\n nil\n end", "def define_additional_data\n hash = options[:additional_data]\n if !hash.to_h.empty?\n hash.each do |k,v|\n define_singleton_method(k) do\n instance_variable_get(:\"@#{k}\") || \n instance_variable_set(:\"@#{k}\", v.respond_to?(:call) ? v.call(env) : v)\n end\n end\n end\n end", "def append_info(text, options={})\n send_audit(:kind => :info, :text => text, :category => options[:category])\n end", "def annotate_exception!(exception)\n location = pathname.to_s\n location << \":#{@__LINE__}\" if @__LINE__\n\n exception.extend(Sprockets::EngineError)\n exception.sprockets_annotation = \" (in #{location})\"\n end", "def add_extra(extra)\n @extras.merge!(extra)\n end", "def method_missing(_method, *_args, &_block)\n ext = @ext[_method]\n return super if ext.nil?\n instance_exec(*_args, &exc)\n end", "def add_extra(key, value)\n @extras[key] = value\n end", "def track_and_raise_exception(exception, extra = {})\n process_exception(exception, sentry: true, extra: extra)\n\n raise exception\n end", "def exception_with_data(e, code, msg, data = {})\n\n OstKycSdkRuby::Util::Result.exception(\n e, {\n error: code,\n error_message: msg,\n data: data\n }\n )\n\n end", "def exception_context(exception)\n context(:exception => exception.class.to_s)\n end", "def run_install_hook_with_add_info(*args)\n run_install_hook_without_add_info(*args)\n store_info_to_yml\n end", "def add_meta!(options)\n flow_file = OrigenTesters::Flow.callstack.last\n called_from = caller.find { |l| l =~ /^#{flow_file}:.*/ }\n if called_from\n # Splitting on ':' when file names are included will yield a different index for everything in Windows\n called_from.gsub!(flow_file, '')\n called_from = called_from.split(':')\n options[:source_file] = flow_file # called_from[0]\n options[:source_line_number] = called_from[1].to_i\n end\n end", "def error_context(opts, code_desc = nil, extra = {})\n ctx = {}\n ctx[:opts] = opts\n ctx[:job] = self.class\n ctx[:message] = code_desc if code_desc\n ctx.merge!(extra) if extra != nil\n ctx\n end", "def in_exception_context?; end", "def context\n @context ||= [{'server' => hostname, 'type' => 'exception'}]\n end", "def on_extra(&block)\n @on_extra = block\n end", "def message\n debug_info = [\n @instance.mapping.database_model,\n @instance.mapping.salesforce_model,\n @instance.id,\n ]\n\n \"[#{debug_info.join('|')}] #{base_exception.message}\"\n end", "def add_info(info)\n self.info.push info\n end", "def info(*args, &block)\n add_with_options(INFO, *args, &block)\n end", "def addcontext(message, obj = nil)\n obj ||= @lexer\n\n message += \" on line #{obj.line}\"\n if file = obj.file\n message += \" in file #{file}\"\n end\n\n message\n end", "def track_and_raise_for_dev_exception(exception, extra = {})\n process_exception(exception, sentry: true, extra: extra)\n\n raise exception if should_raise_for_dev?\n end", "def append_info_to_payload(payload)\n super\n\n # Use the request ID generated by the aamzon ALB, if available\n payload[:request_id] = request.headers.fetch(\"X-Amzn-Trace-Id\", request.request_id)\n payload[:remote_ip] = request.remote_ip\n payload[:user_agent] = request.user_agent\n end", "def extra; end", "def add_context(context)\n context[:library] = { :name => \"analytics-ruby\", :version => Segment::Analytics::VERSION.to_s }\n end", "def notice_extra_data(message, duration, key)\n return unless builder\n segment = builder.current_segment\n if segment\n if key != :sql\n segment[key] = self.class.truncate_message(message)\n else\n # message is expected to have been pre-truncated by notice_sql\n segment[key] = message\n end\n append_backtrace(segment, duration)\n end\n end", "def exception\n @context[:exception]\n end", "def exception_data(deliverer = nil)\n if deliverer\n write_inheritable_attribute(:exception_data, deliverer)\n else\n read_inheritable_attribute(:exception_data)\n end\n end", "def exception_data(deliverer = nil)\n if deliverer\n write_inheritable_attribute(:exception_data, deliverer)\n else\n read_inheritable_attribute(:exception_data)\n end\n end", "def log_exception(exception, extra = {})\n process_exception(exception, extra: extra)\n end", "def add_context(context)\n context[:library] = 'analytics-ruby'\n end", "def log_context\n {}.with_indifferent_access\n end", "def additional_info(header, method)\n if opts.content?\n \": \" + colorize_code(matched_method_lines(header, method))\n else\n \"\"\n end\n end", "def additional_info\n section = __method__\n output = get_nagios_var(\"NAGIOS_#{@state_type}OUTPUT\")\n # Output is formmated like: Current value: 18094.25, warn threshold: 100.0, crit threshold: 1000.0\n add_text(section, \"Additional Info:\\n #{unescape_text(output)}\\n\\n\") if output\n output_match = output.match(/Current value: (?<current_value>[^,]*), warn threshold: (?<warn_threshold>[^,]*), crit threshold: (?<crit_threshold>[^,]*)/)\n if output_match\n add_html(section, \"Current value: <b><font color='red'>#{output_match['current_value']}</font></b>, warn threshold: <b>#{output_match['warn_threshold']}</b>, crit threshold: <b><font color='red'>#{output_match['crit_threshold']}</font></b><br><br>\")\n else\n add_html(section, \"<b>Additional Info</b>:<br> #{output}<br><br>\") if output\n end\n\n elasticsearch_section section\n\n graphs_section section\n end", "def err_extra_kv (args, usage)\n message= \"Extra options:\\n\"\n args.each() {|k,v| message = message + \" --#{k}=#{v}\\n\"}\n message = message + usage\n raise message\n end", "def extra_args; end", "def update!(**args)\n @stack_trace = args[:stack_trace] if args.key?(:stack_trace)\n end", "def update!(**args)\n @stack_trace = args[:stack_trace] if args.key?(:stack_trace)\n end", "def update!(**args)\n @stack_trace = args[:stack_trace] if args.key?(:stack_trace)\n end", "def update!(**args)\n @stack_trace = args[:stack_trace] if args.key?(:stack_trace)\n end", "def pass_it_on(exception, env, request = {:params => {}}, params = {}, session = {}, verbose = false)\n begin\n case self.class.exception_notifiable_pass_through\n when :hoptoad then\n HoptoadNotifier.notify(exception, sen_hoptoad_request_data(env, request, params, session))\n logger.info(\"[PASS-IT-ON] HOPTOAD NOTIFIED\") if verbose\n else\n logger.info(\"[PASS-IT-ON] NO\") if verbose\n #Do Nothing\n end\n rescue\n #Do Nothing\n logger.info(\"[PASS-IT-ON] FAILED\") if verbose\n end\n end", "def record_exception(e = nil, error_message = nil, attributes: {})\n current_span = OpenTelemetry::Trace.current_span\n current_span.status = OpenTelemetry::Trace::Status.error(error_message || e.message)\n current_span.record_exception(e, attributes: format_attributes(attributes))\n end", "def report(e, other = {})\n if raise_errors?\n squash_context(exception_info(e), other) # surface problems squashing\n raise e\n else\n report!(e, other)\n end\n end", "def method_missing(method, *)\n raise InsufficientContext.new(method)\n end", "def add_hook_context( context )\n\n case context\n when :before_include, :before_extend, :after_include, :after_extend\n case @cluster.instance\n when ::Class\n unless @cluster.instance <= ::Module\n raise ::RuntimeError, 'Include/Extend execution hooks cannot be created for classes.'\n end\n end\n when :subclass\n case @cluster.instance\n when ::Class\n when ::Module\n raise ::RuntimeError, 'Subclass execution hooks cannot be created for modules.'\n end\n end\n \n @hook_contexts[ context ] = true\n \n return self\n \n end", "def add_custom_log_attributes(params)\n record_api_supportability_metric(:add_custom_log_attributes)\n\n if params.is_a?(Hash)\n NewRelic::Agent.agent.log_event_aggregator.add_custom_attributes(params)\n else\n NewRelic::Agent.logger.warn(\"Bad argument passed to #add_custom_log_attributes. Expected Hash but got #{params.class}.\")\n end\n end", "def hotfix_information\n super\n end", "def exception_info(e)\n backtrace = Array(e.backtrace)[0, 500]\n\n res = {\n 'class' => e.class.to_s,\n 'message' => e.message,\n 'backtrace' => backtrace.join(\"\\n\"),\n 'rollup' => Digest::MD5.hexdigest(\"#{e.class}#{backtrace[0]}\")\n }\n\n if original = (e.respond_to?(:original_exception) && e.original_exception)\n remote_backtrace = []\n remote_backtrace << original.message\n if original.backtrace\n remote_backtrace.concat(Array(original.backtrace)[0,500])\n end\n res['remote_backtrace'] = remote_backtrace.join(\"\\n\")\n end\n\n res\n end", "def enter_exception(ex, options={})\n hooks = Pry.config.hooks.dup\n hooks.delete_hook(:before_session, :default)\n hooks.add_hook(:before_session, :set_exception_flag) do |_, _, _pry_|\n setup_exception_context(ex, _pry_, options)\n end.add_hook(:before_session, :manage_intercept_recurse) do\n PryExceptionExplorer.intercept_object.disable! if PryExceptionExplorer.inline? && !PryExceptionExplorer.intercept_object.intercept_recurse?\n end.add_hook(:after_session, :manage_intercept_recurse) do\n PryExceptionExplorer.intercept_object.enable! if !PryExceptionExplorer.intercept_object.active?\n end.add_hook(:before_session, :display_exception) do |_, _, _pry_|\n _pry_.run_command \"cat --ex\"\n end\n \n Pry.start binding, :call_stack => ex.exception_call_stack, :hooks => hooks\n end", "def call(env)\n super\n rescue\n logger.error do\n \"#{$!.class.name} - #{$!.message} (#{$!.backtrace.first})\"\n end\n raise\n end", "def method_missing(method_name, *args) #:nodoc:\n if @extra_options.has_key? method_name\n @extra_options[method_name]\n else\n super method_name, *args\n end\n end", "def info(_message)\n raise NotImplementedError.new\n end", "def set_encrypted_extra_data\n return if @extra_data.blank?\n\n kms_login_client = Aws::Kms.new('entity_association', 'general_access')\n r = kms_login_client.decrypt(GeneralSalt.get_user_activity_logging_salt_type)\n return unless r.success?\n\n d_salt = r.data[:plaintext]\n\n r = LocalCipher.new(d_salt).encrypt(@extra_data)\n return unless r.success?\n\n @e_extra_data = r.data[:ciphertext_blob]\n end", "def on_engine_command(e, who, cmd, arg)\n pre = '<Engine>'\n @log.info(\"#{pre} Command: #{who}: cmd = #{cmd}, arg = #{arg}.\")\n end", "def add_trace_field(name, value)\n self.active_trace_context[name] = value\n # TODO right now this will only add the field to all spans *started* after\n # this call, which unfortunately excludes the actual active span when the\n # call was made. One way to fix this is to change .span_for_existing_event\n # to add fields from .active_trace_context _after_ the yield (in a\n # begin/ensure block) instead of before.\n end", "def add(level, message = nil, progname = nil, &block)\n progname ||= default_options['facility']\n\n if message.nil?\n if block_given?\n message = yield\n else\n message = progname\n progname = default_options['facility']\n end\n end\n\n message_hash = { 'facility' => progname }\n\n if message.is_a?(Hash)\n # Stringify keys.\n message.each do |k,v|\n message_hash[k.to_s] = message[k]\n end\n else\n message_hash['short_message'] = message\n end\n\n if message.is_a?(Exception)\n message_hash.merge!(self.class.extract_hash_from_exception(message))\n end\n\n notify_with_level(level, message_hash)\n end", "def exc_msg_and_response(exc, response = T.unsafe(nil)); end", "def usage_tracker_context=(data)\n unless request.env[key].blank?\n unless Rails.env.test? && !caller.grep(/test\\/functional/).blank?\n UsageTracker.log 'WARNING: overwriting context data!'\n end\n end\n\n request.env[key] = data\n end", "def extract_information_from(env)\n exception = env['action_dispatch.exception']\n exception_wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)\n @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.name]\n @message = exception.message\n @status_code = exception_wrapper.status_code\n end", "def send(method, *args)\n super\n rescue StandardError => e\n args[1].debug \"#{e}\\n #{e.backtrace.first}\" # args[1] is the logger\n end", "def on_engine_command(e, who, cmd, arg)\n pre = '<Engine>'\n @log.debug(\"#{pre} Command: #{who}: cmd = #{cmd}, arg = #{arg}.\")\n end", "def additional_data=(value)\n @additional_data = value\n end", "def usage_tracker_context=(data)\n unless request.env[key].blank?\n unless Rails.env.test? && !caller.grep(/test\\/functional/).blank?\n UsageTrackerMiddleware.log 'WARNING: overwriting context data!'\n end\n end\n\n request.env[key] = data\n end", "def additional_data=(value)\n @additional_data = value\n end", "def parse_extra_args(extra = {})\n raise NotImplementedError,\n \"This Rhizome Equipment Type (#{type}) does not have extra arguments\"\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def update!(**args)\n @error_message = args[:error_message] if args.key?(:error_message)\n @error_type = args[:error_type] if args.key?(:error_type)\n @script_stack_trace_elements = args[:script_stack_trace_elements] if args.key?(:script_stack_trace_elements)\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def additional_data=(value)\n @additional_data = value\n end", "def serializable_hash(options = {})\n super(options).merge!(\n 'position' => self.position,\n '_type' => self.context_type,\n 'id' => self.id\n )\n end", "def wrap(error, method, path, params, request, response)\n\n class << error; attr_accessor :_details; end\n error._details = ErrorDetails.new(method, path, params, request, response)\n\n error\n end", "def wrapped_exception; end", "def exception_hook=(val); @rye_exception_hook = val; end", "def additional_data=(value)\n @additional_data = value\n end" ]
[ "0.6149127", "0.58971643", "0.5712527", "0.56362426", "0.5394363", "0.53489006", "0.5314257", "0.5285059", "0.52544266", "0.5241559", "0.5232666", "0.52249277", "0.5220711", "0.5209646", "0.51642823", "0.5163865", "0.51624244", "0.513955", "0.5135657", "0.51325256", "0.51273304", "0.5119632", "0.5109821", "0.510748", "0.5104981", "0.51030385", "0.5093404", "0.5073553", "0.5071652", "0.50703144", "0.5033079", "0.50310826", "0.5004567", "0.50038195", "0.49828383", "0.4982752", "0.4977553", "0.4977324", "0.4969032", "0.49686655", "0.49567622", "0.49470243", "0.49446577", "0.4907524", "0.49038616", "0.49018887", "0.4893025", "0.4893025", "0.48752284", "0.48692635", "0.48604718", "0.4820077", "0.4804003", "0.48025203", "0.47947478", "0.47909635", "0.47909635", "0.47909635", "0.47909635", "0.477139", "0.47586152", "0.47493085", "0.47459882", "0.4731394", "0.473125", "0.470965", "0.47040337", "0.4703029", "0.46901664", "0.46803072", "0.46747336", "0.4664152", "0.46581852", "0.46547323", "0.46520162", "0.4650422", "0.4647905", "0.46411163", "0.46409604", "0.46384653", "0.4635762", "0.4624785", "0.4623611", "0.46203464", "0.46167445", "0.46167445", "0.46148378", "0.46141472", "0.46141472", "0.46141472", "0.46141472", "0.46141472", "0.46141472", "0.46141472", "0.46141472", "0.46043932", "0.46033746", "0.46005684", "0.4598736", "0.4597437" ]
0.46475872
77
Reading order U, L, R, D
def adjacent(x, y, map) [[x, y - 1], [x - 1, y], [x + 1, y], [x, y + 1]].select do |x, y| (0..map.length-1).cover?(y) && (0..map[0].length-1).cover?(x) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def book_reading_order\n return 'right-to-left' if stub_object_type.include?('rtl') || stub_object_type.include?('r-l')\n\n 'left-to-right'\n end", "def read_u4\n (read_u1 << 24) | read_u3\n end", "def read(str)\n if self.instance_of?(DUID)\n super\n case type\n when 1\n DUID_LLT.new.read(str)\n when 2\n DUID_EN.new.read(str)\n when 3\n DUID_LL.new.read(str)\n else\n self\n end\n else\n private_read str\n end\n end", "def read() end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read; end", "def read(pos)\n end", "def read_backwards\n\t\t_read(EVENTLOG_SEQUENTIAL_READ | EVENTLOG_BACKWARDS_READ)\n\tend", "def read\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n begin\n # at line 908:3: ( iread | fread | cread )\n alt_30 = 3\n case look_30 = @input.peek( 1 )\n when T__49 then alt_30 = 1\n when T__50 then alt_30 = 2\n when T__51 then alt_30 = 3\n else\n raise NoViableAlternative( \"\", 30, 0 )\n end\n case alt_30\n when 1\n # at line 909:5: iread\n @state.following.push( TOKENS_FOLLOWING_iread_IN_read_1471 )\n iread\n @state.following.pop\n\n when 2\n # at line 910:7: fread\n @state.following.push( TOKENS_FOLLOWING_fread_IN_read_1479 )\n fread\n @state.following.pop\n\n when 3\n # at line 911:7: cread\n @state.following.push( TOKENS_FOLLOWING_cread_IN_read_1487 )\n cread\n @state.following.pop\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n end\n \n return \n end", "def read_u2\n (read_u1 << 8) | read_u1\n end", "def read\n @read ||= read_from(closest)\n end", "def read\nend", "def reader; end", "def read(*args, **kwd); end", "def read\n @lines.shift\n end", "def read_u3\n (read_u1 << 16) | read_u2\n end", "def readlines(*several_variants)\n #This is a stub, used for indexing\n end", "def read(*args)\n #This is a stub, used for indexing\n end", "def read_record\n n_read = 0\n tu = @file.read INT_SIZE\n return nil if tu.nil? || tu.bytesize < INT_SIZE\n if (tu == (ZERO_BYTE_ASCII_8BIT * INT_SIZE))\n # empty record. skip this page.\n @file.seek(PAGE_SIZE - INT_SIZE, IO::SEEK_CUR)\n return nil\n end\n n_read += tu.bytesize\n t = tu.unpack(PACK_UINT).first\n\n return nil if @file.eof?\n lu = @file.read INT_SIZE\n return nil if lu.nil? || lu.bytesize < INT_SIZE\n n_read += lu.bytesize\n l = lu.unpack(PACK_UINT).first\n\n if false # l == 7016996765293437281\n puts \"*************** #{__FILE__} #{__LINE__} *************\"\n puts \"at: #{@file.tell}\"\n end\n\n if l > MAX_VALUE_SIZE\n raise ParseError.new \"Read size that exceeds the maximum size for a value.\"\n end\n\n k = nil\n begin\n k = @file.read l\n rescue NoMemoryError => e\n # puts \"*************** #{__FILE__} #{__LINE__} *************\"\n # puts \"#{e.message} at #{l}\"\n raise\n end\n\n return nil if k.nil? || k.bytesize < l\n n_read += k.bytesize\n d = if t != WRITE_TYPE_INDEXES[:array]\n [t, k]\n else\n asu = @file.read INT_SIZE\n return nil if asu.nil? || asu.bytesize < INT_SIZE\n n_read += asu.bytesize\n as = asu.unpack(PACK_UINT).first\n [t, k, as]\n end\n return nil if d.nil?\n\n v = nil\n\n raw_v = nil\n case d[0]\n when WRITE_TYPE_INDEXES[:array]\n a = []\n d[2].times do |i|\n raw_v, b_read = read_value_s\n n_read += b_read\n break if raw_v.nil?\n a.push(raw_v)\n end\n v = a\n when WRITE_TYPE_INDEXES[:hash], WRITE_TYPE_INDEXES[:set]\n raw_v, b_read = read_value_s\n return nil if raw_v.nil?\n n_read += b_read\n v = MultiJson.decode(raw_v)\n when WRITE_TYPE_INDEXES[:string]\n v, b_read = read_value_s\n return nil if v.nil?\n n_read += b_read\n when WRITE_TYPE_INDEXES[:counter]\n v, b_read = read_value_i\n return nil if v.nil?\n n_read += b_read\n end\n\n pages_read = n_read / PAGE_SIZE\n remainder = (n_read % PAGE_SIZE)\n if remainder > 0\n @file.seek((PAGE_SIZE - remainder), IO::SEEK_CUR)\n pages_read += 1\n end\n\n [d, v, pages_read]\n end", "def read_rest\n read(self.size-@position)\n end", "def read_sequence (seq)\n g = 0\n a = 0\n t = 0\n c = 0\n # testen, ob uebergebenes Objekt einzelne Zeichen zurueckgeben kann\n if not seq.respond_to?(\"each_char\")\n return nil\n end\n # iteration ueber alle Symbole (in Großschreibweise) und Ermittlung\n # der absoluten Haeufigkeit der Basen\n seq.each_char do |base|\n base.upcase!\n if base == \"G\"\n g += 1\n elsif base == \"A\"\n a += 1\n elsif base == \"T\"\n t += 1\n elsif base == \"C\"\n c += 1\n else\n return nil\n end\n end\n return g,a,t,c\nend", "def read\n end", "def read\n end", "def read\n end", "def read\n end", "def read_details\r\n read_detail while peek == 'LX'\r\n self\r\n end", "def read_header\n @ch = case STDIN.readline.chomp\n when \"P5\" then 1\n when \"P6\" then 3\n else 0\n end\n while (sz0 = STDIN.readline) =~ /^#/ do\n end\n sz = sz0.chomp.split\n @xreso = sz[0].to_i\n @yreso = sz[1].to_i\n @col = STDIN.readline.chomp.to_i\nend", "def read\n end", "def read(*rest) end", "def read(*rest) end", "def read_multi(*names); end", "def read_long(signed = false, mut = :STD, order = :BIG)\n val = 0\n case order\n when :BIG\n (BYTE_SIZE * 7).downto(0) { |div| ((div % 8).zero? and div.positive?) ? val |= read_byte(signed) << div : next }\n val |= read_byte(signed, mut)\n when :LITTLE\n (0).upto(BYTE_SIZE * 7) { |div| ((div % 8).zero? and div.positive?) ? val |= read_byte(signed) << div: next }\n val |= read_byte(signed, mut)\n end\n val\n end", "def read\n \n end", "def read(length = nil)\n #This is a stub, used for indexing\n end", "def read(entry); end", "def read_factor\n return nil if !valid? || @database_type != :voldemort\n\n @read_factor\n end", "def read_data\n\t\tindex = 0\n\t\torders = []\n\t\tCSV.parse(@data_file.read()) do |row|\n\t\t\tif index == 0\n\t\t\t\t#header row\n\t\t\t\t@columns = parse_columns(row[0])\n\t\t\t\t# p @columns\n\t\t\telse\n\t\t\t\t# p row[0]\n \t\t\tdata = row[0].split(\"\\t\")\n \t\t\torders << parse_order(data) \n\t\t\tend\n \t\tindex += 1\n\t\tend\n\t\treturn orders\n\tend", "def read(n)\n end", "def adj_read_bases\n # mapping quality after '^' symbol is substituted\n # to avoid splitting at non indel + or - characters\n # read ends marking by '$' symbol is substituted\n # insertion and deletion marking by '*' symbol is substituted\n self.read_bases.gsub!(/\\^./, '')\n self.read_bases.delete! '$'\n self.read_bases.delete! '*'\n # warn about reads with ambiguous codes\n # if self.read_bases.match(/[^atgcATGC,\\.\\+\\-0-9]/)\n # warn \"Ambiguous nucleotide\\t#{self.read_bases}\"\n # end\n end", "def read\n self.read_layout\n self.read_directories\n end", "def pos\n @read\n end", "def readRaw\n puts \"Reading raw data..\"\n # data = {uid => {iid => [hour1, hour2, ...]}}}\n data = {}\n while line = $stdin.gets do\n uid, iid, hour = line.chomp.split(',').map {|e| e.to_i}\n data[uid] = {} unless data.key?(uid)\n data[uid][iid] = [] unless data[uid].key?(iid)\n data[uid][iid] += [hour]\n end\n data.each_pair do |u, ihs|\n ihs.each_key {|i| ihs[i].uniq.sort}\n end\n return data\nend", "def read_data\n unpacker.read\n end", "def read()\r\n\t\t\tnodoNuevo1 = Tree::TreeNode.new(@numNodo.to_s + ' read', Nodo.new(@tokenList[@numNodo].lexema, @tokenList[@numNodo].token))\r\n\t\t\tmatch \"read\"\r\n\t\t\tif( @tokenList[@numNodo].token == \"id\" )\r\n\t\t\t\tnodoNuevo2 = Tree::TreeNode.new( @numNodo.to_s + ' ' + @tokenList[@numNodo].lexema, Nodo.new( @tokenList[@numNodo].lexema, @tokenList[@numNodo].token) )\r\n\t\t\t\tnodoNuevo1 << nodoNuevo2\r\n\t\t\t\tmatch @tokenList[@numNodo].lexema\r\n\t\t\t\tmatch \";\"\r\n\t\t\telse\r\n\t\t\t\t@hayError = true\r\n\t\t\t\t@mensaje_error = \"ERROR EN #{@tokenList[@numNodo].lexema} línea ##{@tokenList[@numNodo].lineNumber}, se esperaba un identificador\"\r\n\t\t\tend\r\n\t\t\treturn nodoNuevo1\r\n\t\tend", "def show\n @read = Read.find(params[:id])\n \n read_length = @read.reading.length;\n read1 = read_length / 2;\n read1 = read1.floor;\n read2 = read1.ceil;\n \n # will need to scan back to end of first word found to set the needed read1 point\n @reading1 = @read.reading[1,read1];\n @reading2 = @read.reading[read2,read_length];\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @read }\n end\n end", "def parse xdydz\n nums = xdydz.split 'd'\n case nums.length\n when 2\n arr = roll nums[1].to_i, nums[0].to_i\n when 3\n temp = roll nums[1].to_i, nums[0].to_i\n arr = temp.sort[nums[2].to_i..-1]\n else\n p \"1 or 2 'd's in roll requests please\" # excellent error handling\n end\n return arr\nend", "def read(_ = nil)\n as_hash(read_lines)[base_name]\n end", "def read_forwards\n\t\t_read(EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ)\n\tend", "def read_header\n\t@bytes_to_be_read = 0\n\tread_mt_header_string(MThd_BYTE_ARRAY, @skip_init) # \"MThd\"\n\n\t@bytes_to_be_read = read32()\n\tformat = read16()\n\tntrks = read16()\n\tdivision = read16()\n\n\theader(format, ntrks, division)\n\n\t# Flush any extra stuff, in case the length of the header is not 6\n\tif @bytes_to_be_read > 0\n get_bytes(@bytes_to_be_read)\n @bytes_to_be_read = 0\n\tend\n\n\treturn ntrks\n end", "def ur_to_ul\n a = 0\n x = 0\n edge3 = []\n\n # compute the index a < (12 choose 3) and the edge permutation\n (UR..BR).each do |j|\n if edge_permutation[j] <= UL\n a += n_choose_k(j, x + 1)\n edge3 << edge_permutation[j]\n x += 1\n end\n end\n\n # compute the index b < 3! for the permutation in edge3\n b = 0\n 2.downto(1).each do |j|\n k = 0\n while edge3[j] != j\n edge3 = rotateLeft(edge3, 0, j)\n k += 1\n end\n b = (j + 1) * b + k\n end\n\n (6 * a + b) & 0xffff\n end", "def read_state\n end", "def read_dr(reg_or_val, options = {})\n # Can't read the DR via J-Link\n end", "def readReferences\n @refA = readRawChannelLevel(REF_A)\n @refB = readRawChannelLevel(REF_B)\n end", "def parse_record(data)\n unpacked = data.unpack(\"a1a*\")\n return unpacked[0] == \"A\" ? Dir_A : Dir_B, unpacked[1].to_i\n end", "def reads\n (1..read_count).to_a\n end", "def read\n _read\n end", "def read characters\n forward characters\n end", "def read_file\n \t@readin = []\n file = File.open(@filename[@file_count], 'r')\n\t @readin = file.each.to_a\n\t # chop off the escaped characters (in this case: \\r\\n)\n @readin.map! {|s| s.chomp}\n # increment the file count\n @file_count += 1\n file.close\n # determine which file was read in\n # the files either have a \"W\" (for power) or \"Wh\" as the first line\n \tif @readin[0] =~ /Wh/\n \t\tparse_energy\n \telse @readin[0] =~ /W/\n \t\tparse_power\n \tend\n end", "def read_uint32\n read(4).unpack(UINT32).first\n end", "def read_ld_output_file(ldfile)\n snp_lds = Array.new\n\n begin\n File.open(ldfile, \"r\") do |file|\n file.each_line do |oline|\n oline.each_line(\"\\r\") do |line|\n next if line =~ /^\\n$/\n if line =~ /LOD/\n next\n end\n\n data=strip_and_split(line) \n snp_lds << SNPCombination.new(data[0], data[1], data[2], data[3], data[4])\n end\n end\n end\n rescue StandardError => e\n puts e\n exit(1)\n end\n return snp_lds\n\n end", "def read\n\t\t\t\t\tnil\n\t\t\t\tend", "def read_long; end", "def read_multi(names)\n names.map do |name|\n read(name)\n end\n end", "def value_read; end", "def not_test_read_head_part\r\n files_part1 = [\"9-14(15~20略).TXT\", \"33-39(21~32略).TXT\", \"40-43.txt\", \"44-47.txt\", \"48-55.TXT\",\r\n \"56-57概述结束.TXT\", \"58-59.TXT\"]\r\n files_part2 = Array.new\r\n #从60开始,到 471\r\n (60..471).to_a.each{ |i|\r\n files_part2 << i.to_s+\".TXT\"\r\n }\r\n read_from_files(files_part1 + files_part2)\r\n end", "def readSource\n if @source_in.nil?\n @source_in = open @dir+Pathname.new(@source)\n # fields titles\n head=@source_in.readline.strip\n @heads=head.split(/\\s*,\\s*/)\n @hoplang_cols_order = @heads.join ','\n end\n\n begin\n line=@source_in.readline.strip\n datas=line.split(/\\s*,\\s*/)\n\n i=0\n value={}\n @heads.each {|h|\n value[h]=datas[i]\n i+=1\n }\n value['__hoplang_cols_order'] = @hoplang_cols_order\n # now store variable!\n #varStore.set(@current_var, value)\n return value\n rescue EOFError\n hop_warn \"EOF.....\\n\"\n #varStore.set(@current_var, nil)\n return nil\n end\n line\n end", "def read\n @index += 1\n line = @last ? @last : @lines[@index]\n @last = nil\n line\n end", "def order; end", "def order; end", "def km_get_reacid(data)\n return data.map{|d| d.scan(/(?<r>R\\d{5})/)}.flatten.sort\nend", "def readWeights\n\ti=0\n\tFile.open(RISKS).each_line { |line|\n\t\tns = line.split\n\t\t@risks[ns[0]] = ns[1].to_i\n\t\ti = i+1\n\t}\n\tFile.open(SYS_FUN).each_line { |line|\n\t\tns = line.split\n\t\t@frisk[ns[0]] = ns[1].to_i\n\t\ti = i+1\n\t}\n\treturn i\nend", "def read(diagram)\n # Try to read captured pieces information from gnugo output.\n black_captured = /Black \\(X\\) has captured (\\d) pieces/.match(diagram)\n white_captured = /White \\(O\\) has captured (\\d) pieces/.match(diagram)\n\n if black_captured\n self.black.captured += black_captured.captures.first.to_i\n end\n if white_captured\n self.white.captured += white_captured.captures.first.to_i\n end\n\n diagram.gsub!(/Black.*/, '')\n diagram.gsub!(/White.*/, '')\n diagram.gsub!(/N O P/, '')\n diagram.gsub!(/[A-NP-WYZa-z0-9]/, '')\n diagram.gsub!(/[-| ():]/, '')\n diagram.strip().split(\"\\n\").each_with_index do |line, i|\n line.split(\"\").each_with_index do |char, j|\n coords = @letters[j] + (self.size.split('x')[0].to_i-i).to_s\n if char == \"X\"\n self.add_stone(coords, :black)\n elsif char == \"O\"\n self.add_stone(coords, :white)\n end\n end\n end\n end", "def read(*args)\n io.read(*args)\n end", "def read\n raise NotImplementedError\n end", "def readline\n end", "def read r\n if @m\n res = @m[r]\n return res if res\n \n # Falling back on IO.read - mmap failed\"\n @m = nil\n end\n \n @io.sysseek(r.first, IO::SEEK_SET)\n return @io.sysread(r.last-r.first+1)\n end", "def underbang_reader(key); end", "def read_plex stream, fc, lcb, cbdata, dataclass\n cItems = (lcb-4)/(4+cbdata)\n cps = []\n items = []\n idx = fc\n ci = 0\n while ci < cItems+1\n cps << stream[idx..idx+3].unpack('l')[0]\n idx+=4\n ci+=1\n end\n ci=0\n if cbdata>0\n while ci < cItems\n item = dataclass.new\n item.read(stream[idx..idx+cbdata-1])\n idx+=cbdata\n items << item\n ci+=1\n end\n end\n return cps, items\n end", "def read_u1\n read(1).first & 0xff\n end", "def read(&blk)\r\n\t\t\t## Preconditions:\r\n\t\t\t# NOTE: you can't grab a row or just read a line in roo, you have to ask\r\n\t\t\t# about the bounds and explcitly iter over the cell contents. \r\n\t\t\trow_start = @wbook.first_row\r\n\t\t\trow_stop = @wbook.last_row\r\n\t\t\tcol_start = @wbook.first_column\r\n\t\t\tcol_stop = @wbook.last_column\r\n\t\t\tif row_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start on the first row not #{row_start}\"\r\n\t\t\tend\r\n\t\t\tif col_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start in the first column not #{col_start}\"\r\n\t\t\tend \r\n\t\t\t# Main:\r\n\t\t\t# grab and parse headers\r\n\t\t\theaders = read_headers(col_stop)\r\n\t\t\t# read each row\r\n\t\t\t(2..row_stop).each { |i|\r\n\t\t\t\trow_data = (1..col_stop).collect { |j| @wbook.cell(i,j) } \r\n\t\t\t\trow_zip = headers.zip(row_data).flatten()\r\n\t\t\t\trow_hash = Hash[*row_zip]\r\n\t\t\t\trow_hash.each_pair { |k,v|\r\n\t\t\t\t\tmeth_name = \"convert_#{k}\"\r\n\t\t\t\t\tif (self.respond_to?(meth_name))\r\n\t\t\t\t\t\trow_hash[k] = self.send(meth_name, v)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\trow_hash[k] = convert(v)\r\n\t\t\t\t\tend\r\n\t\t\t\t}\r\n\t\t\t\tblk.call(row_hash)\r\n\t\t\t}\r\n\t\tend", "def read(&blk)\r\n\t\t\t## Preconditions:\r\n\t\t\t# NOTE: you can't grab a row or just read a line in roo, you have to ask\r\n\t\t\t# about the bounds and explcitly iter over the cell contents. \r\n\t\t\trow_start = @wbook.first_row\r\n\t\t\trow_stop = @wbook.last_row\r\n\t\t\tcol_start = @wbook.first_column\r\n\t\t\tcol_stop = @wbook.last_column\r\n\t\t\tif row_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start on the first row not #{row_start}\"\r\n\t\t\tend\r\n\t\t\tif col_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start in the first column not #{col_start}\"\r\n\t\t\tend \r\n\t\t\t# Main:\r\n\t\t\t# grab and parse headers\r\n\t\t\theaders = read_headers(col_stop)\r\n\t\t\t# read each row\r\n\t\t\t(2..row_stop).each { |i|\r\n\t\t\t\trow_data = (1..col_stop).collect { |j| @wbook.cell(i,j) } \r\n\t\t\t\trow_zip = headers.zip(row_data).flatten()\r\n\t\t\t\trow_hash = Hash[*row_zip]\r\n\t\t\t\trow_hash.each_pair { |k,v|\r\n\t\t\t\t\tmeth_name = \"convert_#{k}\"\r\n\t\t\t\t\tif (self.respond_to?(meth_name))\r\n\t\t\t\t\t\trow_hash[k] = self.send(meth_name, v)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\trow_hash[k] = convert(v)\r\n\t\t\t\t\tend\r\n\t\t\t\t}\r\n\t\t\t\tblk.call(row_hash)\r\n\t\t\t}\r\n\t\tend", "def read_wire_points(str)\n points = []\n point_dists = {}\n x, y, len = 0, 0, 0\n\n str\n .split(',')\n .map { |s| m=s.match(/([LRUD])(\\d+)/); point(m[1], m[2].to_i) }\n .each do |dir, dist|\n while dist > 0\n case dir\n when \"L\" then x -= 1\n when \"R\" then x += 1\n when \"U\" then y -= 1\n when \"D\" then y += 1\n end\n dist -= 1\n len += 1\n p = point(x,y)\n points << p\n point_dists[p] = len\n end\n end\n\n Wire.new(points, point_dists)\nend", "def read()\n\tloop {\n\t\t#puts (\"read list in : #{$reading}\")\n\t\trs, ws, es = IO.select($reading, nil, nil, 1)\n\t\tif (rs != nil)\n\t\t\trs.each { |r|\n\t\t\t\tmsg = r.gets\n\t\t\t\t#only reads in messages sent from a socket\n\t\t\t\tif (!(msg == nil))\n\t\t\t\t\tmsg_info = msg.split(\" \")\n\t\t\t\t\t#if msg_info[0] != \"LSP\"\n\t\t\t\t\t#puts(\"just recieved a message #{msg}\")\n\t\t\t\t\t#end\n\t\t\t\t\t#puts (\"just recieved a message #{msg}\")\n\t\t\t\t\tparseMsg(msg)\t\t\t\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\t\t\n\t}\nend", "def rovers_position\n @input.values_at(* @input.each_index.select {|i| i.odd?})\n end", "def read(&blk)\r\n\t\t\t## Preconditions:\r\n\t\t\t# NOTE: you can't grab a row or just read a line in roo, you have to ask\r\n\t\t\t# about the bounds and explcitly iter over the cell contents. \r\n\t\t\trow_start = @wbook.first_row\r\n\t\t\trow_stop = @wbook.last_row\r\n\t\t\tcol_start = @wbook.first_column\r\n\t\t\tcol_stop = @wbook.last_column\r\n\t\t\tif row_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start on the first row not #{row_start}\"\r\n\t\t\tend\r\n\t\t\tif col_start != 1\r\n\t\t\t\traise RuntimeError, \"data must start in the first column not #{col_start}\"\r\n\t\t\tend \r\n\t\t\t# Main:\r\n\t\t\t# grab and parse headers\r\n\t\t\t@headers = read_headers(col_stop)\r\n\t\t\t# read each row\r\n\t\t\t(2..row_stop).each { |i|\r\n\t\t\t\trow_data = (1..col_stop).collect { |j| @wbook.cell(i,j) } \r\n\t\t\t\trow_zip = @headers.zip(row_data).flatten()\r\n\t\t\t\trow_hash = Hash[*row_zip]\r\n\t\t\t\trow_hash.each_pair { |k,v|\r\n\t\t\t\t\tmeth_name = \"convert_#{k}\"\r\n\t\t\t\t\tif (self.respond_to?(meth_name))\r\n\t\t\t\t\t\trow_hash[k] = self.send(meth_name, v)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\trow_hash[k] = convert(v)\r\n\t\t\t\t\tend\r\n\t\t\t\t}\r\n\t\t\t\tblk.call(row_hash)\r\n\t\t\t}\r\n\t\tend", "def lut_read(name)\n return nil unless options = lut_options(name)# HACK\n\n if options[:use_cache]\n lut_read_from_cache(name)\n else\n lut_read_without_cache(name)\n end\n end", "def get_data3\n\tdata3 = File.read(\"mockchallenge3.txt\")\n\tarr = []\n\tsplit = data3.each_line { |line| arr << line.split(\" | \") }\n\tgender = arr.sort_by { |x| x[3] }\n\tmarr = []\n\tfarr = []\n\tgender.each { |x| if x[3] == \"M\" then marr << x else farr << x end }\n\tsortedmarr = marr.sort_by { |x| x[0] }\n\tsortedfarr = farr.sort_by { |x| x[0] }\n\tanswer = sortedfarr << sortedmarr\n\tprint answer\nend", "def detect_standard_refmode_readings fact_type, entity_role, value_role\n forward_reading = reverse_reading = nil\n fact_type.all_reading.each do |reading|\n if reading.text =~ /^\\{(\\d)\\} has \\{\\d\\}$/\n if reading.role_sequence.all_role_ref.detect{|rr| rr.ordinal == $1.to_i}.role == entity_role\n forward_reading = reading\n else\n reverse_reading = reading\n end\n elsif reading.text =~ /^\\{(\\d)\\} is of \\{\\d\\}$/\n if reading.role_sequence.all_role_ref.detect{|rr| rr.ordinal == $1.to_i}.role == value_role\n reverse_reading = reading\n else\n forward_reading = reading\n end\n end\n end\n trace :mode, \"Didn't find standard forward reading\" unless forward_reading\n trace :mode, \"Didn't find standard reverse reading\" unless reverse_reading\n [forward_reading, reverse_reading]\n end", "def read\n un_read(true, \"lue\")\n if @submission.wrong_to_read?\n @submission.wrong!\n end\n end", "def read_record(*args)\r\n\t\t\tnum,in_length=args\r\n\t\t\tif num.nil?\r\n\t\t\t\traise \"Number of the record must be defined when reading it\\n\"\r\n\t\t\tend\r\n\t\t\tif self.last_record>0 and num>self.last_record\r\n\t\t\t\tputs \"Can't read record #{num}, there is not so many of them\\n\"\r\n\t\t\tend\r\n\t\t\tif in_length.nil?\r\n\t\t\t\tin_length=@record_len\r\n\t\t\tend\r\n\t\t\tif in_length<0\r\n\t\t\t\tin_length=-@record_len\r\n\t\t\tend\r\n\t\t\toffset=self.get_record_offset(num)\r\n\t\t\treturn if offset.nil?\r\n\t\t\tself.read_from(offset,in_length)\r\n\t\tend", "def read_article\n\torig_article\n\tdancing_man\n\tin_chrome\n\tgo_back\n\tgo_back\nend", "def rd!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 51 )\n\n type = RD\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n d = nil\n\n\n \n # - - - - main rule block - - - -\n # at line 350:5: d= ( ( DIGIT )* ) '3' ( 'R' | 'r' ) ( 'D' | 'd' )\n # at line 350:7: ( ( DIGIT )* )\n # at line 350:8: ( DIGIT )*\n # at line 350:8: ( DIGIT )*\n while true # decision 3\n alt_3 = 2\n look_3_0 = @input.peek( 1 )\n\n if ( look_3_0 == 0x33 )\n look_3_1 = @input.peek( 2 )\n\n if ( look_3_1.between?( 0x30, 0x39 ) )\n alt_3 = 1\n\n end\n elsif ( look_3_0.between?( 0x30, 0x32 ) || look_3_0.between?( 0x34, 0x39 ) )\n alt_3 = 1\n\n end\n case alt_3\n when 1\n # at line 350:8: DIGIT\n digit!\n\n else\n break # out of loop for decision 3\n end\n end # loop for decision 3\n\n match( 0x33 )\n if @input.peek(1) == 0x52 || @input.peek(1) == 0x72\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n if @input.peek(1) == 0x44 || @input.peek(1) == 0x64\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 51 )\n\n end", "def read_data(uri)\n begin\n \topen_uri_or_path(uri) do |input|\n \t input.read\n \tend\n rescue\n \told_uri = uri\n \turi = uri.downcase\n \tretry if old_uri != uri\n \traise\n end\n end", "def read_uint_by_size(size)\n case size\n when 1\n read_uint8\n when 2\n read_uint16\n when 3\n read_uint24\n when 4\n read_uint32\n when 6\n read_uint48\n when 8\n read_uint64\n else\n raise \"Integer size #{size} not implemented\"\n end\n end", "def evaluateReading(reading)\n if reading.class != FluksoReading\n raise \"Must provide a FluksoReading instance.\"\n end\n if reading.watts < $CONFIG[:LOW_MEDIUM_BARRIER]\n @fsm.low_reading;\n elsif reading.watts < $CONFIG[:MEDIUM_HIGH_BARRIER]\n @fsm.medium_reading;\n else\n @fsm.high_reading;\n end\n @lastReadingTimestamp=reading.time\n end", "def read(_lines)\n raise NotImplementedError\n end" ]
[ "0.5643176", "0.553698", "0.55187225", "0.5505955", "0.5376297", "0.5376297", "0.5376297", "0.5376297", "0.5376297", "0.5376297", "0.5376297", "0.53163785", "0.53087866", "0.52546924", "0.52388155", "0.51963973", "0.51685804", "0.513574", "0.5117141", "0.5116897", "0.50997305", "0.5098246", "0.50727516", "0.5070132", "0.50669307", "0.50516814", "0.5033773", "0.5033773", "0.5033773", "0.5033773", "0.50140357", "0.50138855", "0.50078887", "0.50058126", "0.50058126", "0.5000775", "0.4986003", "0.4982844", "0.49800637", "0.49361756", "0.4921133", "0.49045968", "0.4892034", "0.4891559", "0.48879027", "0.48732486", "0.48705173", "0.48654604", "0.48496562", "0.48264", "0.48254168", "0.4819797", "0.48153895", "0.48108998", "0.48023343", "0.47957522", "0.47869873", "0.47751683", "0.47595716", "0.47594723", "0.47331393", "0.47298625", "0.47198653", "0.4717135", "0.47070405", "0.47027114", "0.4702003", "0.46971172", "0.46916026", "0.46834886", "0.4666635", "0.4663085", "0.46451676", "0.46451676", "0.46402687", "0.4635994", "0.46356955", "0.46321663", "0.4614186", "0.46124202", "0.46070126", "0.46057525", "0.46036285", "0.46026453", "0.45911363", "0.45911363", "0.45815226", "0.4580288", "0.45800546", "0.45795456", "0.45688388", "0.45611733", "0.45599836", "0.45515013", "0.45504192", "0.45499885", "0.45431978", "0.4542479", "0.4539765", "0.45359614", "0.45339203" ]
0.0
-1
Parse options, check arguments, then process the command
def run if parsed_options? && arguments_valid? puts "Start at #{DateTime.now}\n\n" if @options.verbose output_options if @options.verbose # [Optional] process_arguments process_command puts "\nFinished at #{DateTime.now}" if @options.verbose else output_usage end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_options\n end\n end", "def run\n if options_valid? && option_combinations_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def run\n\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n\n end", "def run\n if parsed_options? && arguments_valid? \n process_arguments \n process_command\n else\n output_usage\n end\n end", "def run\n \n if parsed_options?\n \n process_command\n end\n \n end", "def run\n\t\tif parsed_options? && arguments_valid?\n\t\t\toutput_options if @options[:verbose]\n\t\t\toutput_arguments if @options[:verbose]\n\t\t\tprocess_arguments\n\t\t\tprocess_command\n\t\telse\n\t\t\toutput_usage\n\t\tend\n\tend", "def run\n # puts arguments_valid?\n if parsed_options?\n puts \"Start at #{DateTime.now}\" if verbose?\n\n output_options if verbose?\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if verbose?\n else\n puts 'The options passed are not valid!'\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n if process_arguments == false\n return\n end\n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def process_options\n options.delete_if { |x,y| y.nil? }\n if options.empty?\n puts @optparse \n exit 0\n end\n options.each do |x,y|\n begin\n if y.to_s.match('^-')\n raise BoilerMakerErr.new(\"Bad args: \\\"#{y}\\\" is not a valid arg to option, \\\"--#{x}\\\". Use the -h flag for syntax help.\")\n end\n rescue => error\n puts error.message + \"\\n\"\n exit 1\n end\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def parse_options!(args)\n option_parser.parse!(args)\n\n if args.empty?\n abort(\"You must give exactly one command to execute.\")\n else\n @options.command = args.join(\" \")\n end\n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n\n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n # puts \"parsed_options? >>> #{parsed_options?}\"\n # puts \"arguments_valid? >>> #{arguments_valid?}\"\n if parsed_options? && arguments_valid?\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n process_arguments\n \n output_options if @options.verbose # [Optional]\n \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n \n if parsed_options? && arguments_valid? \n \n puts \"Start at #{DateTime.now}\\\n\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n os \n process_command\n \n puts \"\\\nFinished at #{DateTime.now}\" if @options.verbose\n \n else\n output_usage\n end\n \n end", "def run\n if parsed_options? && arguments_valid?\n log \"Start at #{DateTime.now}\\n\"\n output_options\n\n process_arguments\n process_command\n log \"Finished at #{DateTime.now}\"\n else\n output_usage\n end\n end", "def validate_and_parse_options\n # Checking ARGV validity *before* parse_options because parse_options\n # mangles ARGV in some situations\n if no_command_given?\n print_help_and_exit(1, NO_COMMAND_GIVEN)\n elsif no_subcommand_given?\n if (want_help? || want_version?)\n print_help_and_exit\n else\n print_help_and_exit(2, NO_COMMAND_GIVEN)\n end\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n process_arguments \n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose # [Optional]\n process_arguments \n process_command\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n Trollop::die \"user error, replace user and continue\"\n end\n end", "def run\n unless parsed_options? && arguments_valid? \n output_usage and return\n end\n \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n end", "def run\n\n if parsed_options? && arguments_valid? \n\n puts \"Start at #{Time.new.to_s}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n\n puts \"\\nFinished at #{Time.new.to_s}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def run\n if parsed_options? && arguments_valid?\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\\\n\\\\n\" if @options.verbose\n \n output_options if @options.verbose # [Optional]\n \n process_arguments \n process_command\n \n puts \"\\\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end\n end", "def run \n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\"\n process_arguments(@validoptions.args)\n puts \"Finished at #{DateTime.now}\"\n else\n raise BoilerMakerErr.new(\"Could not parse options. An unknown error has ocurred.\")\n exit $!\n end\n end", "def parse\n # Parse all arguments first\n option_parser.parse!(arguments)\n\n # Get the first argument, this is our command\n cmd = arguments.pop\n raise OptionParser::MissingArgument, 'command' unless cmd\n\n # Set the command if it's present\n options.command = cmd.to_sym\n end", "def run!\n trace = false\n require_program :version, :description\n\n global_option('-h', '--help', 'Help on any command', :hide => true)\n global_option('--version', 'Display version information', :hide => true)\n\n # special case --debug so all commands can output relevant info on it\n $terminal.debug = options_parse_debug\n\n # special case --trace because we need to use it in the runner\n trace = options_parse_trace\n\n # special case --version so it is processed before an invalid command\n options_parse_version\n\n # help is a special branch prior to command execution\n options_parse_help\n\n unless trace\n begin\n run_active_command\n rescue InvalidCommandError => e\n run_help(provided_arguments)\n rescue \\\n OptionParser::InvalidOption => e\n RHC::Helpers.error e.message\n 1\n rescue \\\n ArgumentError,\n OptionParser::ParseError => e\n\n help_bindings = CommandHelpBindings.new(active_command, commands, self)\n usage = RHC::HelpFormatter.new(self).render_command_syntax(help_bindings)\n message = case e\n when OptionParser::AmbiguousOption\n \"The option #{e.args.join(' ')} is ambiguous. You will need to specify the entire option.\"\n else\n e.message\n end\n\n RHC::Helpers.error message\n say \"#{usage}\"\n 1\n rescue RHC::Exception, RHC::Rest::Exception => e\n RHC::Helpers.error e.message\n e.code.nil? ? 128 : [1, (e.code || 1).to_i].max\n end\n else\n run_active_command\n end\n end", "def process_arguments\n if arguments_valid? \n process_command\n else\n raise ArgumentError\n end\n end", "def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end", "def process_command_line_options\r\n begin\r\n defer, found = \"\", false\r\n opts = GetoptLong.new(\r\n [ \"--help\", \"-h\", \"-?\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--load\", \"-l\", GetoptLong::REQUIRED_ARGUMENT ],\r\n [ \"--debug\", \"-d\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--quit\", \"-q\", GetoptLong::NO_ARGUMENT ],\r\n [ \"--words\", \"-w\", GetoptLong::NO_ARGUMENT ])\r\n\r\n # Process the parsed options\r\n opts.each do |opt, arg|\r\n unless found\r\n puts; found = true\r\n end\r\n\r\n case opt\r\n when \"--debug\"\r\n @debug = true\r\n when \"--load\"\r\n defer << \"load\\\"#{arg}\\\" \"\r\n when \"--quit\"\r\n defer << \")quit \"\r\n when \"--words\"\r\n defer << \")words \"\r\n else\r\n fail SilentExit\r\n end\r\n end\r\n\r\n puts if found\r\n rescue Exception => e\r\n puts\r\n puts \"fOOrth available options:\"\r\n puts\r\n puts \"--help -h -? Display this message and exit.\"\r\n puts \"--load -l <filename> Load the specified fOOrth source file.\"\r\n puts \"--debug -d Default to debug ON.\"\r\n puts \"--quit -q Quit after processing the command line.\"\r\n puts \"--words -w List the current vocabulary.\"\r\n puts\r\n raise SilentExit\r\n end\r\n\r\n defer\r\n end", "def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end", "def process_args\n @options = { sequence_num: nil, directory: nil, verbose: false }\n\n @optparse = OptionParser.new do |opts|\n opts.banner = 'Usage: Upload directory to MOA repository'\n\n @options[:sequence_num] = nil\n opts.on( '-s', '--seq SEQ', Integer, 'disk upload sequence number' ) do |seq|\n @options[:sequence_num] = seq\n end\n\n @options[:batch] = 1\n opts.on( '-b', '--batch BATCH', Integer, 'Start from batch number' ) do |batch|\n @options[:batch] = batch\n end\n\n @options[:batchsize] = BATCH_SIZE\n opts.on( '-n', '--batchsize BATCHSIZE', Integer, 'Set Batch Size (Default 5000 files)' ) do |batchsize|\n @options[:batchsize] = batchsize\n end\n\n @options[:directory] = nil\n opts.on( '-d', '--dir DIR', String, 'directory to upload' ) do |dir|\n @options[:directory] = dir\n end\n\n @options[:verbose] = false\n opts.on( '-v', '--verbose', 'Output more information' ) do\n @options[:verbose] = true\n end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n\n @optparse.parse!\n\n if @options[:directory].nil? || @options[:sequence_num].nil?\n puts @optparse\n exit(-1)\n end\nend", "def parse_opts\n if parse_argv\n apply_options\n true\n end\n end", "def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end", "def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end", "def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end", "def process_arguments\n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE') {|f|@options.file = File.expand_path(f)}\n opts.on('-o','--output FILE'){|f|@options.output = File.expand_path(f)}\n end\n \n opts_parse.parse!(@arguments) rescue return false\n \n return true\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def run\n\n if parsed_options? && arguments_valid? && client_configured?\n\n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n\n output_options if @options.verbose # [Optional]\n\n process_arguments\n process_command\n\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n\n else\n output_usage\n end\n\n end", "def handle_options\n parse_options(argv)\n if config[:version]\n show_version\n else\n show_help\n end\n exit 0\n end", "def parse_command_line\n prepend_environment_options\n options = options_with_defaults\n\n OptionParser.new do |parser|\n\n parser.on(\"-h\", \"--help\", \"Show help\") do |_help_requested|\n ARGV << 'h' # pass on the request to the command processor\n options.suppress_command_line_validation = true\n end\n\n parser.on('-i', '--input_dir DIR',\n \"Input directory containing source data files, default: '#{DEFAULT_INPUT_DIR}'\") do |v|\n options.input_dir = File.expand_path(v)\n end\n\n parser.on('-o', '--output_dir DIR',\n \"Output directory to which report files will be written, default: '#{DEFAULT_OUTPUT_DIR}'\") do |v|\n options.output_dir = File.expand_path(v)\n end\n\n parser.on('-r', '--receipt_dir DIR',\n \"Directory root from which to find receipt filespecs, default: '#{DEFAULT_RECEIPT_DIR}'\") do |v|\n options.receipt_dir = File.expand_path(v)\n end\n\n parser.on('-s', '--shell', 'Start interactive shell') do |v|\n options.interactive_mode = true\n end\n\n parser.on('-v', '--[no-]verbose', 'Verbose mode') do |v|\n options.verbose_mode = v\n end\n\n parser.on('-y', '--[no-]say', 'Say error messages.') do |v|\n options.say = v\n end\n\n parser.on('', '--[no-]receipts', 'Include report on existing and missing receipts.') do |v|\n options.do_receipts = v\n end\n end.parse!\n\n if options.verbose_mode\n puts \"Run Options:\"\n ap options.to_h\n end\n\n options\n end", "def main(command_line_options=ARGV)\n parser = Slop::Parser.new cli_flags\n arguments = parse_arguments(command_line_options, parser)\n\n if arguments.key?(:ce) || arguments.key?(:ci) || arguments.key?(:h)\n if arguments.key?(:ci)\n\n end\n if arguments.key?(:ce)\n\n end\n if arguments.key?(:h)\n puts cli_flags\n end\n exit\n end\n\n elsif set?(arguments, :port)\n puts portquiz arguments[:port]\n elsif set?(arguments, :down)\n puts is_it_up arguments[:down]\n end", "def run\n @arguments = ArgumentParser.get_arguments VALID_ARGUMENTS\n print_help if (@arguments[:options][:help])\n print_version if (@arguments[:options][:version])\n if (@arguments[:keywords][:export])\n handle_export\n elsif (@arguments[:keywords][:import])\n handle_import\n else\n print_help\n end\n end", "def parse_options(opts, args); end", "def run\n if parsed_options? && arguments_valid? \n puts \"Start at #{DateTime.now}\\n\\n\" if @options.verbose\n output_options if @options.verbose\n process_arguments \n start\n puts \"\\nFinished at #{DateTime.now}\" if @options.verbose\n else\n output_usage\n end \n end", "def parse_command_line\n OptionParser.new do |opts|\n opts.banner = \"Usage: ruby #{$0} [options]\"\n\n opts.on_head(\"-h\", \"--help\", \"Show this help message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"--verbose\", \"Show all progress messages (INFO, DEBUG, WARNING, ERROR)\") do\n Logger.verbose = true\n end\n\n opts.on(\"-q\", \"--quiet\", \"Only show WARNING and ERROR messages\") do\n Logger.quiet = true\n end\n\n opts.on(\"--console\", \"Open up a console to query the source via rbgccxml\") do\n @requesting_console = true\n end\n\n opts.on(\"--clean\", \"Force a complete clean and rebuild of this extension\") do\n @force_rebuild = true\n end\n\n end.parse!\n end", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend", "def run(args)\n opts.parse!(args)\n\n command = args.shift\n if command.nil?\n puts opts\n else\n meth = command.gsub(\"-\", \"_\").to_sym\n if respond_to?(meth)\n send(meth)\n else\n puts %(`#{command}` is not a #{opts.program_name} command. See `#{opts.program_name} --help` for a list of available commands.)\n end\n end\n end", "def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n\n process_result\n\n @options\n end", "def setup\n begin\n @options = OptParser.parse(ARGV)\n rescue ParserExceptions::MissingArgument\n exit(1)\n end\n\n end", "def options_parse\n # first, deal with all options\n opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{COMMAND} [options] <cn_tracker_export>\\n\"\n opts.banner += \"Convert CollabNet project tracker artifacts to Pivotal Tracker format\"\n\n opts.on(\"-h\", \"Show this message\") do\n puts opts\n exit\n end\n\n opts.on(\"-v\", \"Display this application's version and exit\") do\n puts \"#{COMMAND} version #{VERSION}\"\n exit\n end\n \n opts.on(\"-o <filename>\", \"Direct output to <filename> rather than the console\") do |filename|\n if File.exists?(filename) && (!File.writable?(filename) || File.directory?(filename))\n puts \"Specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n elsif !File.exists?(filename) && !File.writable?(File.dirname(filename))\n puts \"Location of specified filename '#{filename}' is not writable\\n\\n#{opts}\"\n exit\n end\n \n @options[:out] = filename\n end\n \n opts.on(\"-t < feature | chore | bug >\", \"The type of story to generate\") do |type|\n unless [ 'feature', 'chore', 'bug' ].include?(type)\n puts \"Type '#{type}' is invalid. Only 'feature', 'chore', or 'bug' are allowed.\"\n puts \"\\n#{opts}\"\n exit\n end\n @options[:story_type] = type\n end\n end\n \n # try parsing options, rescuing certain errors and printing friendly messages\n begin\n opts.parse!\n rescue OptionParser::InvalidOption => e\n puts \"#{e}\\n\\n#{opts}\"\n exit\n end\n \n # now, make sure that there are enough arguments left for required parameters\n case\n when ARGV.length < 1\n puts \"You must specify a CollabNet project tracker export (<cn_tracker_export>)\\n\\n#{opts}\"\n exit\n when !File.exists?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' does not exist\\n\\n#{opts}\"\n exit\n when !File.readable?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is not readable\\n\\n#{opts}\"\n exit\n when File.directory?(ARGV[0])\n puts \"Specified input file '#{ARGV[0]}' is a directory, not a file\\n\\n#{opts}\"\n exit\n end\n \n @options[:in] = ARGV[0]\n end", "def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end", "def execute(opt, argv)\n fail \"#{self.class.command} not implemented\"\n end", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def validate_argv\n if ARGV.empty? then\n ARGV << \"start\"\n else\n if not %w{start stop restart zap status}.include? ARGV.first then\n $stderr.puts \"ERROR: invalid command '#{ARGV.first}'\"\n $stderr.puts\n $stderr.puts @opt_parser.help()\n exit 1\n end\n end\n end", "def parse!( args )\n @args = args\n @options.grep!(args)\n end", "def execute\n cli_options = OptionManager.new.execute\n argv = parse_options(cli_options[:parser])\n \n return unless argv\n \n if [nil, ''].include? cli_options[:values][:cmd]\n env.ui.info cli_options[:parser]\n else\n with_target_vms(argv) do |machine|\n manage_machine(machine, cli_options) \n end\n end\n 0\n end", "def process_command\n # Make sure we are running from the correct directory\n puts \"Running from .. \" + Dir.pwd if $DEBUG\n\n # determing which action and forward accordingly\n method = \"cmd_\" + @arguments.shift\n if !respond_to? method\n puts \"do not have `#{method}' in my reportoire ..\"\n output_usage\n end\n send(method, *@arguments)\n rescue ArgumentError\n output_usage\n end", "def process_command_line(order = false, help = true)\n require 'getoptlong'\n require 'set'\n\n processor = option_processor.extend(Enumerable)\n order, help = order.values_at(:order, :help) if Hash === order\n\n processor.quiet = true\n processor.ordering = GetoptLong::REQUIRE_ORDER if order\n\n processor.each do |_option, _argument|\n options.set(_option.slice(2..-1), _argument)\n end\n\n require 'debug' if options.debug?\n return options unless options.help? and help\n\n print_usage\n exit 0\n end", "def parse_cmd_arguments( args ) # {{{\n\n original_args = args.dup\n options = OpenStruct.new\n\n # Define default options\n options.verbose = false\n options.colorize = false\n options.process = []\n options.sources = []\n options.debug = false\n options.db_path = \"data/databases/test.sqlite3\"\n options.db_type = \"sqlite3\"\n options.read = false\n options.automatic = false\n options.interval = 3600 # update normally only every hour\n options.rate = false\n options.username = \"\"\n options.manual_input = false\n options.joke_count = false\n options.random_intervals = false\n options.random_interval_time = 25\n\n pristine_options = options.dup\n\n opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{__FILE__.to_s} [options]\"\n\n opts.separator \"\"\n opts.separator \"General options:\"\n\n opts.on(\"-d\", \"--db-path PATH\", \"Use the database which can be found in PATH\") do |d|\n options.db_path = d\n end\n\n opts.on(\"-t\", \"--db-type TYPE\", \"Use the database of class TYPE (e.g. sqlite3)\") do |t|\n options.db_type = t\n end\n\n opts.on(\"-r\", \"--read\", \"Read jokes that are stored in the DB\") do |r|\n options.read = r\n end\n\n opts.on(\"-r\", \"--rate\", \"Rate jokes that are stored in the DB for user account\") do |r|\n options.rate = r\n end\n\n opts.on(\"-u\", \"--username OPT\", \"Use username OPT\") do |u|\n options.username = u\n end\n\n opts.on(\"-m\", \"--manual-input\", \"Input a joke manually to the Database\") do |m|\n options.manual_input = m\n end\n\n opts.on(\"-j\", \"--joke-count\", \"Count how many jokes we have in the Database\") do |j|\n options.joke_count = j\n end\n\n opts.on(\"-r\", \"--random-intervals\", \"Use random intervals when downloading to mask our usage pattern\") do |r|\n options.random_intervals = r\n end\n\n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n # Boolean switch.\n opts.on(\"-a\", \"--automatic\", \"Run automatically every #{options.interval.to_s} seconds unless the --interval option is given\") do |a|\n options.automatic = a\n end\n\n opts.on(\"-i\", \"--interval OPT\", \"Run every OPT seconds (works only with --automatic together)\") do |i|\n options.interval = i.to_i\n end\n\n # Set of arguments\n opts.on(\"-p\", \"--process OPT\", @configurations, \"Process one or more detected configuration (OPT: #{ @configurations.sort.join(', ') })\" ) do |d|\n options.process << d\n end\n\n # Set of arguments\n opts.on(\"-s\", \"--sources OPT\", @configurations, \"Use only these sources for read and rate (OPT: #{ @configurations.sort.join(', ') })\" ) do |d|\n options.sources << d\n end\n\n # Boolean switch.\n opts.on(\"-v\", \"--verbose\", \"Run verbosely\") do |v|\n options.verbose = v\n end\n\n opts.on(\"-d\", \"--debug\", \"Run in debug mode\") do |d|\n options.debug = d\n end\n\n # Boolean switch.\n opts.on(\"-q\", \"--quiet\", \"Run quietly, don't output much\") do |v|\n options.verbose = v\n end\n\n opts.separator \"\"\n opts.separator \"Common options:\"\n\n # Boolean switch.\n opts.on(\"-c\", \"--colorize\", \"Colorizes the output of the script for easier reading\") do |c|\n options.colorize = c\n end\n\n opts.on_tail(\"-h\", \"--help\", \"Show this message\") do\n puts opts\n exit\n end\n\n # Another typical switch to print the version.\n opts.on_tail(\"--version\", \"Show version\") do\n puts `git describe --tags`\n exit\n end\n end\n\n opts.parse!(args)\n\n # Show opts if we have no cmd arguments\n if( original_args.empty? )\n puts opts\n exit\n end\n\n options\n end", "def run\n \n return output_usage if not (parsed_options? && arguments_valid?) \n \n return do_stats if @options.stats\n return do_attach if @options.attach\n return do_detach if @options.detach\n \n end", "def cmd(options={})\n arguments\n end", "def process\n command = get_command()\n\n if command\n verify_command(command)\n else\n help\n end\n end", "def parse_command_line args\n args.options do |opt|\n opt.on(\"rutema v#{Version::STRING}\")\n opt.on(\"Options:\")\n opt.on(\"--config FILE\", \"-c FILE\",String,\"Loads the configuration from FILE\") { |config_file| @config_file=config_file}\n opt.on(\"--check\",\"Runs just the suite setup test\"){@check=true}\n #opt.on(\"--step\",\"Runs test cases step by step\"){@step=true}\n opt.on(\"--silent\",\"Suppresses console output (only for the default reporters)\") { @silent=true}\n opt.on(\"--bare\",\"No default reporters whatsoever\") { @bare=true}\n #opt.on(\"--color\",\"Adds color to the Console reporter\") { @color=true}\n opt.on(\"-v\", \"--version\",\"Displays the version\") { $stdout.puts(\"rutema v#{Version::STRING}\");exit 0 }\n opt.on(\"--help\", \"-h\", \"-?\", \"This text\") { $stdout.puts opt; exit 0 }\n opt.on(\"--debug\", \"-d\", \"Turn on debug messages\") { $DEBUG=true }\n opt.on(\"You can provide a specification filename in order to run a single test\")\n opt.parse!\n #and now the rest\n unless @config_file\n puts \"No configuration file defined!\\n\"\n $stdout.puts opt \n exit 1\n end\n if !args.empty?\n @test_identifier=args.shift\n end\n end\n end", "def _process_options(options); end", "def _process_options(options); end", "def parse_command\n log_and_exit read_template('help') if @input.empty?\n @command = @input.shift\n \n while @input.any?\n opt = @input.shift\n \n if opt =~ /^--(\\w+)(=(\"[^\"]+\"|[\\w]+))*/\n name = $1\n value = $3 ? $3.gsub(/\"/, \"\") : true\n @named_options[name] = value\n else\n @options << opt\n end\n end\n end", "def processCommandLineOptions\n if ARGV\n ARGV.each do |arg|\n if arg.index('=')\n setting, value = arg.split('=')\n setting = setting.chomp\n value = value.chomp.strip\n if setting == 'logLevel'\n value = value.upcase.gsub(/\\'/,'')\n level = LEVELS_TEXT.index(value.upcase)\n @currentLogLevel = level if level\n elsif setting == 'consoleLogging'\n @consoleLogging = value.downcase == 'true'\n elsif setting == 'logfile'\n @currentFileName = File.expand_path(value)\n end\n end\n end\n end\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@uploads.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\t@sites.push(site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end", "def _run(argv = [])\n execute(parse_options(argv))\n end", "def parse!(argv=ARGV, opts={})\n command = argv.shift\n case command\n when '--version', '-v'\n puts \"Aladdin #{Aladdin::VERSION}\"\n exit 0\n when nil, '--help', '-h'\n puts File.read USAGE\n exit 0\n else\n require_relative 'commands/new'\n require_relative 'commands/server'\n send command, argv, opts\n end\n rescue => e\n puts e.message\n puts File.read USAGE\n exit 1\n end", "def parse_args\n options = {}\n optparse = OptionParser.new do|opts|\n # Set a banner\n opts.banner = \"Usage: harness.rb [options...]\"\n\n options[:tests] = []\n opts.on( '-t', '--tests DIR/FILE', 'Execute tests in DIR or FILE (defaults to \"./tests\")' ) do|dir|\n options[:tests] << dir\n end\n\n options[:type] = 'skip'\n opts.on('--type TYPE', 'Select puppet install type (pe, git, skip) - default \"skip\"') do\n |type|\n unless File.directory?(\"setup/#{type}\") then\n puts \"Sorry, #{type} is not a known setup type!\"\n exit 1\n end\n options[:type] = type\n end\n\n options[:puppet] = 'git://github.com/puppetlabs/puppet.git#HEAD'\n opts.on('-p', '--puppet URI', 'Select puppet git install URI',\n \" #{options[:puppet]}\",\n \" - URI and revision, default HEAD\",\n \" just giving the revision is also supported\"\n ) do |value|\n options[:type] = 'git'\n options[:puppet] = value\n end\n\n options[:facter] = 'git://github.com/puppetlabs/facter.git#HEAD'\n opts.on('-f', '--facter URI', 'Select facter git install URI',\n \" #{options[:facter]}\",\n \" - otherwise, as per the puppet argument\"\n ) do |value|\n options[:type] = 'git'\n options[:facter] = value\n end\n\n options[:config] = nil\n opts.on( '-c', '--config FILE', 'Use configuration FILE' ) do|file|\n options[:config] = file\n end\n\n opts.on( '-d', '--dry-run', \"Just report what would be done on the targets\" ) do |file|\n $dry_run = true\n end\n\n options[:mrpropper] = FALSE\n opts.on( '--mrpropper', 'Clean hosts' ) do\n puts \"Cleaning Hosts of old install\"\n options[:mrpropper] = TRUE\n end\n\n options[:stdout_only] = FALSE\n opts.on('-s', '--stdout-only', 'log output to STDOUT but no files') do\n puts \"Will log to STDOUT, not files...\"\n options[:stdout_only] = TRUE\n end\n\n options[:quiet] = false\n opts.on('-q', '--quiet', 'don\\'t log output to STDOUT') do\n options[:quiet] = true\n end\n\n opts.on( '-h', '--help', 'Display this screen' ) do\n puts opts\n exit\n end\n end\n optparse.parse!\n return options\nend", "def run!\n if self.class.commands.include?(@command)\n run_command\n elsif @command.nil?\n puts \"Command required\"\n puts @parser\n exit 1\n else\n abort \"Unknown command: #{@command}. Use one of #{self.class.commands.join(', ')}\"\n end\n end", "def run\n input = OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"--debug\", \"Turn on debugging output.\") do |debug|\n $DEBUG = @options[:debug] = debug\n end\n\n opts.on(\"-n <path>\", \"--new\", \"Create a new Corrupt application.\") do |path|\n @options[:path] = path\n end\n\n opts.on(\"-v\", \"--version\", \"Print the version.\") do |v|\n output(Corrupt.to_version)\n exit\n end\n end\n\n begin\n @argv << '--help' if @argv.empty?\n input.parse!(@argv)\n take_action!\n rescue OptionParser::InvalidOption => error\n error(\"#{error}\\nTry passing '--help'\")\n rescue OptionParser::MissingArgument => error\n error(\"#{error}\\nTry passing '--help'\")\n end\n end", "def command_parse(argv)\n end", "def parse_args\n case ARGV[0]\n when '-a'\n # check that no arg was passed with the -a flag.\n if ARGV[1]\n puts \"Error, '-a' flag cannot accept additional arguments.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n parse_directory(File.expand_path(Dir.pwd))\n when '-d'\n ARGV.shift\n ARGV.each do |d|\n unless File.directory?(d)\n puts \"Error, #{d} is not a directory.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n end\n dirs = ARGV.map { |d| File.expand_path(d) }\n dirs.each { |d| parse_directory(d) }\n when \"-f\"\n ARGV.shift\n ARGV.each do |f|\n unless File.extname(f) == '.pp'\n puts \"Error, #{f} is not a '.pp' file\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end \n end\n ARGV.each { |f| PuppetFile.new(File.expand_path(f)) }\n when '-g'\n if ARGV[1]\n puts \"Error, '-g' flag cannot accept additional arguments.\"\n puts \"Run `validate-pp -h` for more info.\"\n exit!\n end\n parse_git_repo\n end\nend", "def process_args\n args = @args.dup\n @options[:operands] = nil\n unless args.length >= 2\n puts @opts\n exit 1\n end\n @options[:operands] = args.shift(2)\n @options[:output_filename] = args.shift unless args.empty?\n @options[:output] ||= @options[:output_filename] || $stdout\n\n run\n end", "def parse_arguments\n @cmd_line_arguments = {}\n\n @options = OptionParser.new do |opt|\n opt.on('-C', '--change-dir DIR', 'Change working directory to DIR') do |directory|\n @cmd_line_arguments[:working_directory] = directory\n end\n\n opt.on('-d', '--debug', 'Debug mode') do\n @cmd_line_arguments[:debug] = true\n end\n\n opt.on('-e', '--environment NAME', 'set environment to NAME') do |environment|\n @cmd_line_arguments[:environment] = environment\n end\n\n opt.on('-G', '--generate-json', 'Generate json files, which are commited to api') do\n @cmd_line_arguments[:generate_json_file] = true\n @cmd_line_arguments[:action] ||= :generate\n end\n\n opt.on('--generate-report', 'Generate report csv in output directory') do\n @cmd_line_arguments[:generate_report] = true\n end\n\n opt.on('-g', '--group NAME[,NAME]', Array, 'set groups') do |groups|\n @cmd_line_arguments[:groups] ||= []\n @cmd_line_arguments[:groups] += groups\n end\n\n opt.on('-j', '--job JOB[,JOB,...]', Array, 'Limit action to JOB, which is a regexpression') do |jobs|\n @selected_jobs += jobs\n end\n\n opt.on('-l', '--list', 'List available jobs') do\n @cmd_line_arguments[:action] = :list\n end\n\n opt.on('-p', '--project NAME', 'set project') do |project|\n @cmd_line_arguments[:project] = project\n end\n\n opt.on('-o', '--output-directory DIR', 'generate json file into DIR directory', 'default: ' + @config.output_directory) do |directory|\n @cmd_line_arguments[:output_directory] = directory\n end\n\n opt.on('-q', '--quiet', 'be quiet') do\n @cmd_line_arguments[:quiet] = true\n end\n\n opt.on('-r', '--run', 'Run all configured jobs or all jobs passed with -j') do\n @cmd_line_arguments[:action] = :run\n end\n\n opt.on('-R', '--report', 'show report') do\n @cmd_line_arguments[:report] = true\n end\n\n opt.on('-s', '--save-response', 'save respone in output directory') do\n @cmd_line_arguments[:save_response] = true\n end\n\n opt.separator \"\n\n Examples:\n # List all available jobs\n #{File.basename $0} -l\n\n # List all available jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -l\n\n # Run all configured jobs\n #{File.basename $0} -r\n\n # Run all configured jobs and show a report\n #{File.basename $0} -r --report\n\n # Run all configured jobs in a specific directory\n #{File.basename $0} -C api-helper -p LISU -r\n\n # Run Job_A and Job_B, which must configured in project.yml or group.yml\n #{File.basename $0} -r -j Job_A -j Job_B\n\n # Run all Jobs, which beginn with JOB\n #{File.basename $0} -r -j JOB.*\n\n # Run all Jobs, which contains with JOB\n #{File.basename $0} -r -j .*JOB.*\n\n # Generate json files, which are going to be requested, for all configured jobs\n #{File.basename $0} -G\n\n # Generate json file, which are going to be requested, for Job_A\n #{File.basename $0} -G -j Job_A\n\n # Run jobs for delti group and generate json files\n #{File.basename $0} -r -G -g delti\n\n Available template macros:\n\n Variables and Responses:\n response('<job_name>', '<name>') - return value from the response of a job (see examples)\n response('<job_name>', - return value from the response of a job in another group (must be run before)\n '<name>',\n group: '<group_name>')\n var('<name>', - return variable defined in Job in Vars section.\n default: nil, when default is set (not nil) and variable is undefined, return default\n ignore_error: false) when variable is undefined, do not throw an error\n\n Date and Time:\n now() - returns today (now) in seconds\n yesterday() - returns yesterday in iso8601\n time([<day_shift>[, format: <format>]]) - returns time in specificied format\n defaults: day_shift = 0, format = :seconds\n format:\n :seconds : return time in seconds\n :iso8601 : return timestamp in iso8601\n :iso8601utc : return timestamp in iso8601 (utc)\n\n Examples:\n # get variable test\n var('test')\n\n # get value pdfToken from register response\n response('Delti_Create_DE', 'pdfToken')\n\n # get value pdfToken from register response, where job name is defined as variable in cancel job\n response(var('CreateJob'), 'pdfToken')\n\n # get value token from GenerateToken response in group auth\n response('GenerateToken', 'token', group: 'auth')\n\n # return time of today in seconds\n time()\n\n # return timestamp of today in iso8601\n time(format: :iso8601)\n\n # return timestamp of yesterday in iso8601\n time(-1, format: :iso8601)\n\n # return timestamp of last year in iso8601\n time(-365, format: :iso8601)\n\n # return timestamp of tomorrow in iso8601\n time(1, format: :iso8601)\n\n # return credential\n credential('PROJECT_NAME_username')\n\n # return basic auth header value\n basicauth('PROJECT_NAME_username', 'PROJECT_NAME_password')\n \"\n end\n @options.parse!\n\n @config.insert 0, '<command_line>', @cmd_line_arguments\n\n unless File.directory?(@config.output_directory)\n Dir.mkdir @config.output_directory\n end\n\n Dir.chdir @config.working_directory\n end", "def parse_opts\n option_parser.parse(@argv)\n end", "def cmd(*cmd_args)\n\t\tsetup_opts = {}\n\t\tbegin\n\t\t\t@arguments.parser(*cmd_args) do |opt,idx,val|\n\t\t\t\tif opt == '-h'\n\t\t\t\t\t@arguments.usage\n\t\t\t\t\tKernel.exit(1)\n\t\t\t\tend\n\t\t\t\t@packet.each_header do |type|\n\t\t\t\t\ttype << \"_case\"\n\t\t\t\t\tsetup_opts.merge!(Parser::Case.new.send(type.to_sym,opt,val))\n\t\t\t\tend\n\t\t\tend\n\t\trescue\n\t\t\t@arguments.usage\n\t\t\tKernel.exit(1)\n\t\tend\n\t\tself.setup(setup_opts)\n\tend", "def handle_arguments(args)\n if input_file.nil?\n print_usage\n true\n else\n args.help || args.version\n end\n end", "def process(options); end", "def parse_command_line(gimmicode_arguments)\n begin\n OptionParser.new do |opts|\n opts.banner = $usage\n \n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on('-h', '--help [COMMAND]', 'Show this message or the help of the given command') do |h|\n if h == \"of\" or h == \"convert\"\n exec(\"#{$current_directory}/gimmicode-#{h} -h\")\n else\n puts opts\n puts \"\"\n puts \"Commands:\"\n puts \" of\\t\\tGet the codes of the given characters\"\n puts \" convert\\tConvert Unicode data readable by gimmicode of\"\n exit\n end\n end\n end.parse!(gimmicode_arguments)\n rescue OptionParser::ParseError => e\n puts e.message.capitalize\n puts $usage\n exit\n end\nend", "def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end", "def process(options = {})\n command = command_line(options)\n Kernel.system(command)\n end", "def parse_command_line(args)\n all_opts = OptionParser.new do |opts|\n opts.banner = \"Usage: #{PROGRAM_NAME} [OPTIONS] PASSWORD\"\n opts.separator ''\n\n opts.on(\n '-t',\n '--load-timeout [TIMEOUT_SECONDS]',\n Integer,\n 'Timeout in seconds to wait for',\n 'gitlab-rails console to load',\n 'and process the change.',\n \"Defaults to #{DEFAULT_LOAD_TIMEOUT} seconds.\"\n ) do |timeout|\n @options.load_timeout = timeout\n end\n\n opts.on(\n '-v',\n '--verbose',\n 'Print out debug info when processing.'\n ) do\n @options.debug = true\n end\n\n opts.on(\n '-h',\n '--help',\n 'Help Message'\n ) do\n puts opts\n @options.help_requested = true\n end\n end\n\n all_opts.parse!(args)\n\n unless @options.help_requested\n fail('ERROR: You must specify the password to set') if (ARGV.length < 1)\n\n @options.password = ARGV[0]\n fail('ERROR: Password cannot be empty') if @options.password.strip.empty?\n end\n end", "def run!(options = {})\n run_option_parser.parse!(ARGV.dup) unless ARGV.empty?\n @running = true\n super(options)\n end", "def validate_run_options(args, options)\n\n if (options.machine.empty?)\n $stderr.puts(\"You have to tag your benchmark data with the --machine flag.\\n\")\n exit!\n end\n\n if (options.experiment.empty?)\n $stderr.puts(\"You have to tag your benchmark data with the --experiment flag.\\n\")\n exit!\n end\n\n if options.coverage < 0 || options.coverage > 1.0\n $stderr.puts(\"Error in --coverage flag: Coverage must be in [0..1.0]\\n\")\n exit!\n end\n\n if options.repetitions < 1\n $stderr.puts(\"Error in --repetitions flag: Repetitions must be >= 1\\n\")\n exit!\n end\n\n if options.concurrency < 1\n $stderr.puts(\"Error in --concurrency flag: Concurrency must be >= 1\\n\")\n exit!\n end\n\n if options.timeout < 1\n $stderr.puts(\"Error in --timeout flag: Timeout must be >= 1 seconds\\n\")\n exit!\n end\n\n if args.empty?\n $stderr.puts(\"You have to specify a log file.\\n\")\n exit!\n end\n\n if args.length > 1\n $stderr.puts(\"You should only specify one log file. You specified #{args.length} logfiles.\\n\")\n exit!\n end\n\n if File.exist?(args[0])\n $stderr.puts(\"Logfile #{args[0]} already exists. You do not want to overwrite collected benchmark data.\\n\")\n exit!\n end\n\nend", "def handle\n return CLI.show(parser.help) if argv.empty? || %w[-h --help].any? { |h| argv.include?(h) }\n\n parser.parse!(argv)\n option[:arch] ||= Util.system_arch\n true\n end", "def parse(args = nil)\n\t\t\t\targs ||= {}\n\t\t\t\t# Create options\n\t\t\t\tnoat = [:bool, :action]\n\t\t\t\tsopts = @options.each_value.collect { |option| [option[:long], option[:short], noat.include?(option[:type]) ? GetoptLong::NO_ARGUMENT : GetoptLong::REQUIRED_ARGUMENT] }\n\n\t\t\t\topts = GetoptLong.new(*sopts)\n\t\t\t\topts.quiet = true\n\n\t\t\t\t# Parse option\n\t\t\t\tbegin\n\t\t\t\t\topts.each do |given, arg|\n\t\t\t\t\t\toptname = @options_map[given]\n\t\t\t\t\t\toption = @options[optname]\n\t\t\t\t\t\tvalue = nil\n\n\t\t\t\t\t\t# VALIDATE ARGUMENT DUE TO CASE\n\t\t\t\t\t\tcase option[:type]\n\t\t\t\t\t\t\twhen :string then\n\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\twhen :int then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d+)$/ then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_i(10)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@console.fatal(msg: \"Argument of option \\\"#{given}\\\" must be an integer.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :float then\n\t\t\t\t\t\t\t\tif arg.strip =~ /^(-?)(\\d*)(\\.(\\d+))?$/ && arg.strip() != \".\" then\n\t\t\t\t\t\t\t\t\tvalue = arg.to_f\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@console.fatal(msg: \"Argument of option \\\"#{given}\\\" must be a float.\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :choice then\n\t\t\t\t\t\t\t\tif @options[optname].choices.find_index { |choice| arg =~ choice } then\n\t\t\t\t\t\t\t\t\tvalue = arg\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@console.fatal(msg: \"Invalid argument (invalid choice) for option \\\"#{given}\\\".\", dots: false)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\twhen :list then\n\t\t\t\t\t\t\t\tvalue = arg.split(\",\")\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tvalue = true\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t@options[optname][:value] = value\n\t\t\t\t\tend\n\t\t\t\trescue StandardError => exception\n\t\t\t\t\tif exception.message =~ /.+-- (.+)$/ then\n\t\t\t\t\t\tgiven = $1\n\n\t\t\t\t\t\tif exception.is_a?(GetoptLong::InvalidOption) then\n\t\t\t\t\t\t\t@console.fatal(msg: \"Unknown option \\\"#{given}\\\".\", dots: false) if !args[:ignore_unknown]\n\t\t\t\t\t\telsif exception.is_a?(GetoptLong::MissingArgument) then\n\t\t\t\t\t\t\t@console.fatal(msg: \"Option \\\"-#{given}\\\" requires an argument.\", dots: false)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t@console.fatal(\"Unexpected error: #{exc.message}.\")\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# SET OTHER ARGUMENTS\n\t\t\t\t@args = ARGV\n\n\t\t\t\t# CHECK IF HELP WAS REQUESTED\n\t\t\t\tif self.provided?(\"help\") && !args[:ignore_help] then\n\t\t\t\t\tself.print_help\n\t\t\t\t\texit(0)\n\t\t\t\tend\n\n\t\t\t\t# NOW CHECK IF SOME REQUIRED OPTION WAS NOT SPECIFIED OR IF WE HAVE TO EXECUTE AN ACTION\n\t\t\t\t@inserted[:name].each do |key|\n\t\t\t\t\toption = @options[key]\n\n\t\t\t\t\tif option[:required] == true && option[:value] == nil then\n\t\t\t\t\t\t@console.fatal(msg: \"Required option \\\"#{option[:name]}\\\" not specified.\", dots: false)\n\t\t\t\t\telsif option[:value] == true && option[:type] == :action then\n\t\t\t\t\t\toption.action.call\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend", "def handle_options\n OptionParser.new do |opts|\n opts.banner = 'Travis CI Command Line Client'\n\n setup_help(opts) {|opts|\n opts.separator ''\n opts.separator 'Supported Options:'\n client_options().each {|option| opts.on(*option)}\n opts.on_tail('--help', '-h', '-H', 'display this help message.') do\n $stdout.print opts\n exit\n end\n }\n end.parse!\n end", "def handle_options\n opts = OptionParser.new do |opts|\n opts.on('-c', '--force-roku-command') { options.force_command = true }\n end.parse!\n end", "def command_run_options(c, str_opts)\n c.option '-c', '--categories [string]', String, str_opts.categories\n c.option '-d', '--dl-method [string]', String, str_opts.dl_method\n c.option '-n', '--number [integer]', Integer, str_opts.number\n c.option '-p', '--player [string]', String, str_opts.player\n c.option '-r', '--rng [string]', String, str_opts.rng\n end", "def parse_command_line &block\n data = {}\n\n OptionParser.new do |opts|\n opts.banner = \"Usage: #{File.basename($0)} [options]\"\n\n opts.on(\"-c CONFIG\", \"--conf CONFIG\", \"YAML config file\") do |config|\n data[\"config\"] = config\n end\n\n opts.on(\"-p PARAMS\", \"--params PARAMS\", \"Additional default options - key: value as JSON string, override values from config file\") do |params|\n data[\"params\"] = JSON.parse(params)\n end\n\n # process custom args, if given\n block.call(opts) if block_given?\n\n opts.on_tail('-h', '--help', 'display this help and exit') do\n puts opts\n exit\n# return nil\n end\n\n# begin\n opts.parse(ARGV)\n# rescue OptionParser::InvalidOption\n# # do nothing\n# end\n\n end\n\n @args = data\n end" ]
[ "0.8107569", "0.80522096", "0.802113", "0.79491603", "0.77211124", "0.7566804", "0.7491165", "0.73961675", "0.7347632", "0.73112714", "0.73112714", "0.73112714", "0.73112714", "0.73112714", "0.73112714", "0.7295674", "0.7289842", "0.72309864", "0.7212907", "0.7212537", "0.7207778", "0.71815354", "0.715909", "0.71283364", "0.71262616", "0.708106", "0.7052112", "0.70475453", "0.70279497", "0.70137763", "0.69112074", "0.6908312", "0.6886878", "0.6871928", "0.68551344", "0.6832658", "0.6831195", "0.68271625", "0.68271625", "0.68271625", "0.68255675", "0.68245155", "0.68104035", "0.6795679", "0.67947066", "0.67886454", "0.67866355", "0.67720795", "0.67634296", "0.6739737", "0.6739176", "0.6724659", "0.66875154", "0.66468525", "0.6645046", "0.6640649", "0.6607869", "0.66035974", "0.6600957", "0.65736395", "0.65682775", "0.6560619", "0.65485597", "0.6548145", "0.6537568", "0.65314174", "0.6513849", "0.6478075", "0.6477905", "0.6461533", "0.6461533", "0.646015", "0.64503706", "0.6447611", "0.6426028", "0.6395187", "0.6390176", "0.63755906", "0.63703895", "0.6368491", "0.6368224", "0.6365092", "0.63627094", "0.63584244", "0.6355818", "0.6351046", "0.6350345", "0.63453007", "0.63452417", "0.6345087", "0.634332", "0.6334325", "0.6332899", "0.63287187", "0.6317997", "0.6312007", "0.63115287", "0.6310334", "0.6307425", "0.6304731" ]
0.69872856
30
Performs postparse processing on options
def process_options @options.verbose = false if @options.quiet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _process_options(options); end", "def _process_options(options); end", "def parse_options; end", "def parse_options; end", "def parse!() options.parse!(self) end", "def process_options\n \n end", "def process_options\n \n end", "def process_options\n \n end", "def process_options\n \n end", "def parse_options(opts, args); end", "def parse_opts\n if parse_argv\n apply_options\n true\n end\n end", "def parse\n @opts = OptionParser.new { |opts| process_opts(opts) }\n @opts.parse!(@args)\n\n process_args\n\n @options\n end", "def parse_options=(_arg0); end", "def parse_options=(_arg0); end", "def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n\n process_result\n\n @options\n end", "def handle_options\n options.tdplib = ['tdplib']\n options.templates = []\n\n OptionParser.new do |opts|\n opts.banner = \"tdp [-f tdp_file] {options} targets...\"\n opts.separator \"\"\n opts.separator \"Options are ...\"\n\n opts.on_tail(\"-h\", \"--help\", \"-H\", \"Display this help message.\") do\n puts opts\n exit\n end\n\n standard_tdp_options.each { |args| opts.on(*args) }\n opts.environment('TDPOPT')\n end.parse!\n end", "def parse\n parser.parse(ARGV)\n @options\n rescue OptionParser::InvalidOption => e\n puts e\n puts parser\n #p @options\n exit(1)\n end", "def parse(args)\n @options = args\n end", "def options_parse(_options_parser)\n @calls << [:options_parse]\n end", "def parse_opts\n option_parser.parse(@argv)\n end", "def parse_options(opts, args)\n reset\n opts.parse!(args)\n rescue OptionParser::ParseError => err\n kill unrecognized_option(err)\n end", "def process(options); end", "def parse_options\n options = Trollop::options do\n version VERSION\n banner <<-EOS\nPostwhite is a policy server for Postfix MTA which filters incoming emails\nbased on per recipient whitelists managed by an email frontend.\n\nDocumentation:\n http://www.bitcetera.com/products/postwhite\n\nUsage:\n postwhite [options] {#{Postwhite::COMMANDS.join('|')}}\n\nOptions:\n EOS\n opt :'audit', \"Write audit information to log\", :default => false\n opt :'config-dir', \"Directory containing the configuration files\", :default => '/etc/postfix/postwhite'\n opt :'debug', \"Write debug information to log\", :default => false\n opt :'detach', \"Detach the daemon\", :default => false\n opt :'prefix', \"Use this prefix for all paths\", :default => '/'\n opt :'quiet', \"Don't output anything\", :default => false\n opt :'user', \"Run the server as this user\", :default => 'postwhite'\n stop_on Postwhite::COMMANDS\n end\n options[:command] = ARGV[0]\n options\n end", "def parse_additional_options(opts)\n end", "def parse_additional_options(opts)\n end", "def parse_yardopts_options(*args); end", "def process_options\n\t\t@options[:verbose] = false if @options[:quiet]\n\t\t@options[:getword] = false if @options[:random]\n\t\t@options[:add] = false if @options[:random] or @options[:getword]\n\tend", "def parse_options(argv=ARGV)\n argv = argv.dup\n argv = guess_and_switchify_arguments(argv)\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options_arguments.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n\n parse_block = \\\n Proc.new() do |*c|\n if c.empty? || c == [nil]\n c = true\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n else\n c = c.first\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n end\n puts filter_options_summary(opts.to_s) if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n\n # opts.send(:on, *[opt_method,*opt_args, parse_block])\n opt_args.unshift opt_method\n opt_args << parse_block\n opts.send(*opt_args)\n end\n end\n\n @opt_parser.summary_indent = @summary_indent if @summary_indent\n @opt_parser.summary_width = @summary_width if @summary_width\n\n @opt_parser.parse!(argv)\n @filtered_argv = argv\n\n # Deal with any required values\n fail = nil\n options_arguments.each do |opt_key, opt_value|\n next unless config[opt_key]\n # next if config[opt_key] == opt_value[:default]\n\n reqargs = []\n case opt_value[:requires]\n when nil\n when Proc\n begin\n result = opt_value[:requires].call(config)\n rescue \n reqargs << $!.message\n end\n reqargs << result if result.class == String\n when Array,Symbol\n required_opts = [opt_value[:requires]].flatten\n required_opts.each do |required_opt|\n reqargs << required_opt.to_sym unless config[required_opt.to_sym]\n end\n\n reqargs.map! do |opt|\n arg = (options_arguments[opt][:long_strip] || options_arguments[opt][:short_strip]).dup\n arg.gsub!(/^-+/,\"\") if arguments.keys.include?(opt)\n arg\n end\n end\n unless reqargs.empty?\n fail = true\n opt = (opt_value[:long_strip] || opt_value[:short_strip]).dup\n opt.gsub!(/^-+/,\"\") if arguments.keys.include?(opt_key)\n puts \"You must supply #{reqargs.join(\", \")} with #{opt}!\"\n end\n\n end\n if fail\n puts filter_options_summary(@opt_parser.to_s)\n exit 2\n end\n\n argv\n end", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n raise e if e.is_a?(SystemExit)\n\n $stderr.puts e.message\n exit 1\n end\n exit 0\n end", "def post_option_parser(configuration)\n # we could test or manipulate input values here\n if ARGV.length >= 1\n configuration[:command] = ARGV.shift \n end\n\n raise \"Action must be say_goodbye or get_towel\" unless [\"say_goodbye\", \"get_towel\"].include?(configuration[:command])\n end", "def extract_options!\n option_parser.order!(args)\n end", "def process_options(&block)\n self.option_processors ||= []\n option_processors << block\n self\n end", "def ___parse(ops)\n ARGV.getopts(ops).each { |k, v| self[k.to_sym] = v if v }\n # Parameters after options removeal\n @argv = ARGV.shift(ARGV.length)\n rescue OptionParser::ParseError\n raise(InvalidOPT, $ERROR_INFO)\n end", "def parse\n set_default_options\n lookup_and_execute_require_option(args)\n parse_options\n set_contents_template_from_args unless args.empty?\n check_mandatory! if options.check_mandatory_arguments\n options\n end", "def process_options\n options.delete_if { |x,y| y.nil? }\n if options.empty?\n puts @optparse \n exit 0\n end\n options.each do |x,y|\n begin\n if y.to_s.match('^-')\n raise BoilerMakerErr.new(\"Bad args: \\\"#{y}\\\" is not a valid arg to option, \\\"--#{x}\\\". Use the -h flag for syntax help.\")\n end\n rescue => error\n puts error.message + \"\\n\"\n exit 1\n end\n end\n end", "def parse(argv)\n options = parser.process!(argv)\n validate_options(options)\n Revamp.logger.level = Logger::INFO unless options[:verbose]\n options\n end", "def parse(argv=ARGV)\n argv = Array(argv)\n\n while @parse and entry = argv.shift\n # collect everything that is not an option\n if entry[0] != ?-\n @on_extra[entry]\n next\n end\n\n # this is a long option\n if entry[1] == ?-\n opt, arg = entry.split \"=\"\n process argv, entry, opt, arg\n next\n end\n\n # disambiguate short option group from short option with argument\n opt, arg, rest = split entry, 2\n\n # process first option\n option = process argv, entry, opt, arg\n next unless option and not option.arg?\n\n # process the rest of the options\n while rest.size > 0\n opt, arg, rest = split rest, 1\n opt = \"-\" + opt\n option = process argv, opt, opt, arg\n break if option.arg?\n end\n end\n\n @extra\n rescue ParseError => e\n puts self\n puts e\n exit 1\n end", "def process\n begin\n aux_option = remove_unwanted_chars(@_option)\n\n # unprocessed option list\n option_list = aux_option.split(%r{\\*/|\\];})\n\n option_list.each do |op|\n begin\n if op.to_s.index('=[') != nil\n ntec_option = NtecOption.new\n ntec_option.options = []\n\n # get option name\n ntec_option.name = op[0..op.index('=[')-1].strip\n\n # get unprocessed option\n unprocessed_option = op[op.index('=[')+2..op.length]\n\n # process option\n if (unprocessed_option.to_s.index('],')) == nil\n\n #removes [] if its just like this data=[[zczczxc]];\n unprocessed_option = process_item_list(unprocessed_option)\n\n ntec_option.options.push(unprocessed_option.strip) # return just one item...\n else\n # split option list [A], [b], [C]\n option_items = unprocessed_option.split(%r{\\],})\n\n option_items.each do |item|\n aux_item = item.strip\n\n if aux_item != ''\n processed_item = process_item_list(aux_item)\n ntec_option.options.push(processed_item)\n end\n end\n end\n @ntec_option_list.push(ntec_option)\n end\n\n rescue Exception => e\n puts 'Error processing option: ' + e.message\n end\n end\n\n rescue Exception => e\n throw 'Error processing options: ' + e.message\n end\n end", "def parse\n parse_options\n parse_target\n end", "def parse(args)\n begin \n opt_parser.parse!(args)\n rescue ::OptionParser::InvalidOption => e\n puts help\n exit(1)\n end\n options\n end", "def parse!( args )\n @args = args\n @options.grep!(args)\n end", "def parse_options(argv=ARGV)\n argv = argv.dup\n @opt_parser = OptionParser.new do |opts| \n # Set the banner\n opts.banner = banner \n \n # Create new options\n options.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |opt_key, opt_val| \n opt_args = build_option_arguments(opt_val)\n \n opt_method = case opt_val[:on]\n when :on\n :on\n when :tail\n :on_tail\n when :head\n :on_head\n else\n raise ArgumentError, \"You must pass :on, :tail, or :head to :on\"\n end\n \n parse_block = case opt_val[:boolean]\n when true\n Proc.new() do\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(true)) || true\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n when false\n Proc.new() do |c|\n config[opt_key] = (opt_val[:proc] && opt_val[:proc].call(c)) || c\n puts opts if opt_val[:show_options]\n exit opt_val[:exit] if opt_val[:exit]\n end\n end\n \n full_opt = [ opt_method ]\n opt_args.inject(full_opt) { |memo, arg| memo << arg; memo }\n full_opt << parse_block\n opts.send(*full_opt)\n end\n end\n @opt_parser.parse!(argv)\n \n # Deal with any required values\n options.each do |opt_key, opt_value|\n if opt_value[:required] && ! config[opt_key]\n reqarg = opt_value[:short] || opt_value[:long]\n puts \"You must supply #{reqarg}!\"\n puts @opt_parser\n exit 2\n end\n end\n \n argv\n end", "def parse_options(options)\n parsed_options = \"\"\n parsed_options << translate_option_key(:admin_email, \"ServerAdmin\", options)\n parsed_options << translate_option_key(:document_root, \"DocumentRoot\", options)\n parsed_options << translate_option_key(:aliases, \"ServerAlias\", options)\n parsed_options << translate_option_key(:directory_index,\"DirectoryIndex\", options)\n parsed_options << translate_option_key(:error_log, \"ErrorLog\", options)\n parsed_options << translate_option_key(:custom_log, \"CustomLog\", options)\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def parse\n # The options specified on the command line will be collected in *options*.\n # We set default values here.\n OptionParser.new { |options| parse_options options}.parse!(@args)\n @options\n end", "def parse arguments\n begin\n @option_parser.parse! arguments\n rescue StandardError => e\n puts @option_parser\n puts\n puts e.message\n exit(-1)\n end\n\n @options\n end", "def _normalize_options(options); end", "def parse(args)\n optparser = new_option_parser\n optparser.parse!(args)\n abort_missing_options(optparser)\n @options\n end", "def process_options\n fields = options[:fields]\n if fields && fields.size > 0 && !fields.include?(:_type)\n if fields.kind_of?(Hash)\n fields[:_type] = 1 if fields.first.last != 0 # Not excluding\n else\n fields << :type\n end\n options[:fields] = fields\n end\n options.dup\n end", "def parse_options\n @cl_non_options = @cl_parser.parse(ARGV)\n end", "def process_options(_options)\n if (command.default_to_help and _options.empty?) or _options[:help]\n usage\n exit(0)\n end\n self.class.options.each do |name,descriptor|\n short, required, default, type = descriptor.values_at(:short,:required,:default,:type)\n _options[name] ||= (_options[short]||default)\n _options.delete(short)\n if required and not _options[name]\n error(\"Missing required option --#{name}\")\n end\n end\n # TODO: add type conversion\n return _options\n end", "def process_options\n \n \n @options.verbose = false if @options.quiet\n end", "def parse_options(args)\n\t\t\t\tbegin\n\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t@options['verbose'] = false\n\t\t\t\t\t@options['rescan'] = false\n\t\t\t\t\t@options[:timeout] = 25\n\t\t\t\t\t@options[:directory] = nil\n\n\t\t\t\t\topts = OptionParser.new do |opt|\n\t\t\t\t\t\topt.banner = \"#{APP_NAME} v#{VERSION}\\nJacob Hammack\\n#{HOME_PAGE}\\n\\n\"\n\t\t\t\t\t\topt.banner << \"Usage: #{APP_NAME} <options>\"\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('File Options')\n\n\t\t\t\t\t\topt.on('-h HASH', '--search-hash HASH', 'Searches a single hash on virustotal.com') do |hash|\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-r HASH[,HASH]', '--rescan-hash HASH[,HASH]', 'Requests a rescan of a single hash, or multiple hashes (comma separated), by virustotal.com') do |hash|\n\t\t\t\t\t\t\t@options['rescan'] = true\n\t\t\t\t\t\t\t@hashes.push(hash)\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@files_of_hashes.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|\n\t\t\t\t\t\t\tif File.exists?(file)\n\t\t\t\t\t\t\t\tputs \"[+] Adding file #{file}\" if @options['verbose']\n\t\t\t\t\t\t\t\t@uploads.push(file)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tputs \"[!] #{file} does not exist, please check your input!\\n\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator(\"Url Options\")\n\n\t\t\t\t\t\topt.on('-s SITE', '--search-site SITE', 'Searches for a single url on virustotal.com') { |site|\n\t\t\t\t\t\t\t@sites.push(site)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\topt.separator('')\n\t\t\t\t\t\topt.separator('Output Options')\n\n\t\t\t\t\t\topt.on('-j', '--json-output', 'Print results as json to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :json\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-x', '--xml-output', 'Print results as xml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :xml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-y', '--yaml-output', 'Print results as yaml to stdout') do\n\t\t\t\t\t\t\t@options['output'] = :yaml\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--stdout-output', 'Print results as normal text line to stdout, this is default') do\n\t\t\t\t\t\t\t@options['output'] = :stdout\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Advanced Options'\n\n\t\t\t\t\t\topt.on('-c', '--create-config', 'Creates a skeleton config file to use') do\n\t\t\t\t\t\t\tcreate_config\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-d DIRECTORY', '--directory', 'Scans a directory recursively for files and submits the hashes') do |directory|\n\t\t\t\t\t\t\t@options[:directory] = directory\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('-p PROXY', '--proxy-server', 'Uses a specified proxy server') do |proxy|\n\t\t\t\t\t\t\t@options['proxy'] = proxy\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on('--[no-]verbose', 'Print verbose information') do |v|\n\t\t\t\t\t\t\t@options['verbose'] = v\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.separator ''\n\t\t\t\t\t\topt.separator 'Other Options'\n\n\t\t\t\t\t\topt.on('-v', '--version', 'Shows application version information') do\n\t\t\t\t\t\t\tputs \"#{APP_NAME} - #{VERSION}\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\topt.on_tail('-?', '--help', 'Show this message') { |help|\n\t\t\t\t\t\t\tputs opt.to_s + \"\\n\"\n\t\t\t\t\t\t\texit\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\n\t\t\t\t\tif ARGV.length != 0\n\t\t\t\t\t\topts.parse!\n\t\t\t\t\telse\n\t\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\trescue OptionParser::MissingArgument\n\t\t\t\t\tputs opts.to_s + \"\\n\"\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend", "def parse_options!(args, predefined={}, &block)\n Slop.parse!(args) do |opt|\n add_method_object_options(opt) if predefined[:method_object]\n\n yield opt\n opt.on :h, :help, \"This message\" do\n output.puts opt\n throw :command_done\n end\n\n end.tap do |opts|\n process_method_object_options(args, opts) if predefined[:method_object]\n end\n end", "def process_options\n @options.each do |option, value|\n if value == true && VALID_OPTIONS.include?(option)\n self.send(\"option_#{option}\")\n end\n end\n end", "def parse_options\n @options = {\n :environment => 'production',\n :config_path => ENV['CLOUD_CROWD_CONFIG'] || '.',\n :daemonize => false\n }\n @option_parser = OptionParser.new do |opts|\n opts.on('-c', '--config PATH', 'path to configuration directory') do |conf_path|\n @options[:config_path] = conf_path\n end\n opts.on('-p', '--port PORT', 'port number for server (central or node)') do |port_num|\n @options[:port] = port_num\n end\n opts.on('-e', '--environment ENV', 'server environment (defaults to production)') do |env|\n @options[:environment] = env\n end\n opts.on('-d', '--daemonize', 'run as a background daemon') do |daemonize|\n @options[:daemonize] = daemonize\n end\n opts.on('--days NUM_DAYS', 'grace period before cleanup (7 by default)') do |days|\n @options[:days] = days.to_i if days.match(/\\A\\d+\\Z/)\n end\n opts.on_tail('-v', '--version', 'show version') do\n require \"#{CC_ROOT}/lib/cloud-crowd\"\n puts \"CloudCrowd version #{VERSION}\"\n exit\n end\n end\n @option_parser.banner = BANNER\n @option_parser.parse!(ARGV)\n end", "def process_options ( argv )\n\t\ttag = Tag.new\n\t\trenumber = false\n\t\tforce = false\n\t\tpreserve = false\n\t\trenumber_start_at = 1\n\t\tdoexit = false\n\t\ttitle_default = \"@B, @N of @T\"\n\n\t\tbegin\n\t\t\targv.options{ |opt|\n\n\t\t\t\t# help message banner and usage instructions\n\t\t\t\topt.banner = \"A script by Chris Tessmer that Retracks all mp3 id3v2 tags.\\n\"\n\t\t\t\topt.banner += \"version #{SCRIPT_VERSION}, #{SCRIPT_VERSION_DATE}.\\n\"\n\t\t\t\topt.banner += \"\\n\"\n\t\t\t\topt.banner += \"Usage: mp3_retracker [options] file(s)\\n\"\n\t\t\t\topt.banner += \"\\n\"\n\n\t\t\t\t# Defing options\n\t\t\t\topt.on( \"Options:\" )\n\t\t\t\topt.on( \"--renumber [START NUMBER]\", \"-n\", Integer, \"renumber tracks\" ) { |n|\n\t\t\t\t\trenumber \t\t\t\t\t= true\n\t\t\t\t\trenumber_start_at = n || 1\n\n\t\t\t\t\tif ( renumber_start_at < 1 )\n\t\t\t\t\t\trenumber_start_at = 1\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\topt.on( \"--force\",\n\t\t\t\t\t\"-f\",\n\t\t\t\t\t\"Force 'yes' to all questions\")\t{\n\t\t\t\t\tforce = true }\n\t\t\t\topt.on( \"--album 'ALBUM'\" ,\n\t\t\t\t\t\"-b\",\n\t\t\t\t\tString,\n#\t\t\t\t\t\"sets the album name\") { |tag.album| }\n\t\t\t\t\t\"sets the album name\") { |b| tag.album = b || nil }\n\t\t\t\topt.on( \"--artist 'ARTIST'\" , \"-a\", String, \"sets the artist name\") {\n\t\t\t\t\t# |tag.artist| }\n\t\t\t\t\t|a| tag.artist = a || nil }\n\t\t\t\topt.on( \"--composer [COMPOSER]\" , \"-c\", String, \"sets the composer name (defaults to artist)\") { |c|\n\t\t\t\t tag.composer = c || nil\n\t\t\t\t\t}\n\t\t\t\topt.on( \"--genre 'GENRE'\" , \"-g\", String, \"sets the genre\") {\n\t\t\t\t\t# |tag.genre| }\n\t\t\t\t\t|g|\n\t\t\t\t\ttag.genre = g || nil }\n\t\t\t\topt.on( \"--title [TITLE]\", \"-t\", String, \"sets title (uses meta chars, default = \\\"#{title_default}\\\")\" ) {\n\t\t\t\t\t\t|t|\n\t\t\t\t\t\ttag.title = t || title_default\n\t\t\t\t\t}\n\t\t\t\topt.on( \"--year YEAR\", \"-y\", String, \"sets year\" ) {|y|\n\t\t\t\t\tif( y =~ /^\\d{4,4}$/ )\n\t\t\t\t\t\ttag.year = y\n\t\t\t\t\telse\n\t\t\t\t\t\traise \"Bad year '#{y}'- must be in four-digit (YYYY) numeric format.\"\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\topt.on( \"--website 'URL'\", \"-w\", String, \"sets website\" ) {\n\t\t\t\t\t# |tag.web_site| }\n\t\t\t\t\t|w| tag.web_site = w || nil }\n\t\t\t\topt.on( \"--album-artist 'ARTIST'\", \"-m\", String, \"sets album artist\" ) {\n\t\t\t\t\t# |tag.album_artist| }\n\t\t\t\t\t|m| tag.album_artist = m || nil }\n\t\t\t\topt.on( \"--retrack-defaults 'ALBUM'\", \"-x\", String, \"equivilant to -n -t -b ALBUM\" ){\n\t\t\t\t\t# |tag.album|\n\t\t\t\t\ttag.album\n\t\t\t\t\trenumber \t\t= true\n\t\t\t\t\trenumber_start_at \t= 1\n\t\t\t\t\ttag.title \t\t= title_default\n\t\t\t\t}\n\t\t\t\topt.on( \"--preserve-times\", \"-p\", \"preserves original file timestamps\" ) {\n\t\t\t\t\tpreserve = true }\n\t\t\t\topt.on( \"--help\", \"-h\", \"This text\" ) {\n\t\t\t\t\tputs opt\n\t\t\t\t\texit EXITSTATUS_COMPLETE\n\t\t\t\t}\n\n\t\t\t\t# Additional help message instructions:\n\t\t\t\topt.separator \"\"\n\t\t\t\topt.separator \"Meta Characters:\"\n\t\t\t\topt.separator \"\\t@N Track Number\"\n\t\t\t\topt.separator \"\\t@T Total Tracks\"\n\t\t\t\topt.separator \"\\t@B Album Name\"\n\t\t\t\topt.separator \"\"\n\t\t\t\topt.parse!\n\n\t\t\t\tif tag.composer.nil?\n\t\t\t\t\tif not tag.composer = tag.artist\n\t\t\t\t\t\traise \"Composer Requested with no Composer or Artist given.\"\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# Exit with help message if no arguments are given\n\t\t\t\tif ( argv.length == 0 )\n\t\t\t\t\tputs opt\n\t\t\t\t\tdoexit = true\n\t\t\t\tend\n\t\t\t}\n\n\t\trescue Exception => e\n\t\t\tif e.class != SystemExit\n\t\t\t\tSTDERR.puts \"\\n#{e.class}\"\n\t\t\t\tSTDERR.puts \"\\t#{e}\\n\"\n\t\t\t\tSTDERR.puts \"Since this messed up the arguments, I am ABORTING THE PROGRAM. Sorry.\\n\\n\"\n\t\t\tend\n\n\t\t\texit EXITSTATUS_ARG_ERROR\n\t\tend\n\n\t\t# Handle graceful exit (couldn't put in opt block because of rescue clause)\n\t\tif doexit\n\t\t\texit EXITSTATUS_COMPLETE\n\t\tend\n\n\t\tputs \"tag:\\n#{tag}\"\n\t\tt = TagRetracker.new( tag, renumber, force, preserve )\n\t\tt.renumber_start_at = renumber_start_at\n\t\tt\n\tend", "def parse(args, context)\n # The options specified on the command line will be collected in\n # *options*.\n\n @options = RestOptions.new(context)\n @args = OptionParser.new do |parser|\n @options.define_accepts(parser)\n\n @options.define_options(parser)\n parser.parse!(args)\n\n @options.validate_options\n @options.enrich_options\n end\n\n @options\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-metadata [options] <object-name> ...\\n\\n Cat objects metadata (to stdout)\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend", "def parse_options\n keys = @options.keys\n\n keys.each{ |k| instance_variable_set \"@#{k}\".to_sym, @options[k] if self.respond_to? k }\n parse_datasource_json\n end", "def process_options\n options = OpenStruct.new\n options.log = Logger::INFO\n options.daemonize = false\n begin\n OptionParser.new do |opts|\n opts.on(\"--debug\", \"Log all messages\") { |v| options.log = Logger::DEBUG }\n opts.on(\"--info\", \"Log all messages\") { |v| options.log = Logger::INFO }\n opts.on(\"--warn\", \"Log all messages\") { |v| options.log = Logger::WARN }\n opts.on(\"--error\", \"Log all messages\") { |v| options.log = Logger::ERROR }\n opts.on(\"--fatal\", \"Log all messages\") { |v| options.log = Logger::FATAL }\n opts.on(\"--daemonize\", \"Run as system daemon\") { |v| options.daemonize = true }\n end.parse!\n rescue OptionParser::InvalidOption => e\n LOG.warn(\"%06d\"%Process::pid) {\"#{e.inspect}\"}\n end\n options\n end", "def parse(args)\n @options = ScriptOptions.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n parser.parse!(args)\n end\n @options\n end", "def parse!(argv)\n\t\t$log.debug(\"#{self.class}.#{__method__}('#{argv.join(\" \")}'#{block_given? ? ',&block' : ''})\")\n\t\tif (argv.size == 0)\n\t\t\traise OptionParser::InvalidArgument, \"No arguments specified.\"\n\t\tend\n\n\t\t# @options is used to store recognized command-line args\n\t\t@options = Hash.new\n\t\twhile arg = argv.shift\n\t\t\tcase arg\n\t\t\twhen \"-cmd\"\n\t\t\t\t@command = argv.shift\n\t\t\twhen \"-debug\"\n\t\t\t\t$log.level = Logger::DEBUG\n\t\t\t\t$logerr.level = Logger::DEBUG\n\t\t\twhen \"-opt\"\n\t\t\t\t@options[:dataset] = argv.shift\n\t\t\twhen \"-path\"\n\t\t\t\t@options[:path] = argv.shift\n\t\t\twhen \"-target\"\n\t\t\t\t@options[:target] = argv.shift\n\t\t\twhen \"-log\"\n\t\t\t\tlevel = $log.level\n\t\t\t\tlog_path = argv.shift\n\t\t\t\t$log = Logger.new(log_path)\n\t\t\t\t$log.level = level\n\t\t\t\t$logerr = Logger.new(log_path)\n\t\t\t\t$logerr.level = level\n\t\t\telse\n\t\t\t\targv.unshift(arg)\n\t\t\t\tif block_given?\n\t\t\t\t\tunless (argv = yield(argv))\n\t\t\t\t\t\traise OptionParser::InvalidArgument, \"Unknown argument.\"\n\t\t\t\t\tend\n\t\t\t\telse break\n\t\t\t\tend\n\t\t\tend\t\t\n\t\tend\n\t\traise OptionParser::InvalidArgument, \"No command specified.\" unless @command\n\t\tunless (self.class::COMMANDS.include?(@command) && self.respond_to?(@command))\n\t\t\traise OptionParser::InvalidArgument, \"Unknown command '#{@command}' specified.\"\n\t\tend\n\t\treturn argv\n\tend", "def parse(args)\n @options = Options.new\n @args = OptionParser.new do |parser|\n @options.define_options(parser)\n begin\n parser.parse!(args)\n rescue OptionParser::InvalidOption => e\n puts e.message\n exit\n end\n end\n @options\n rescue OptionParser::MissingArgument => e\n puts e.message\n exit\n end", "def parse(argv=ARGV, options={}) # :yields: parser\n parse!(argv.dup, options)\n end", "def parse(args)\n arg_list = arg_groups(args)\n options = DEFAULT_OPTIONS.dup\n options[:exclude] += default_excludes\n options[:locations] = arg_list.shift\n\n arg_list.reject(&:empty?).each do |set|\n flag, *args = set\n args.map! { |arg| arg.delete(\"/\") } # \"log/\" => \"log\"\n\n case flag\n when '-f', '--flags' then options[:flags] += args\n when '-e', '--exclude' then options[:exclude] += args\n else puts \"Unknown argument: #{flag}\"\n end\n end\n\n options\n end", "def process_option (exp)\n\t\tscope {\n\t\t\tenv.current[:option] = true\n\n\t\t\tprocess(exp.shift)\n\t\t}\n\tend", "def parse_options(args)\n \n dopts = Spiderman::Crawler::DEFAULT_OPTS\n options = Hash.new\n\n opt_parser = OptionParser.new do |opts|\n opts.banner = 'Usage: spiderman [options]'\n opts.separator \"\"\n opts.separator \"Default values are given in parenthesis\"\n opts.separator \"\"\n opts.separator \"Specific options:\"\n\n opts.on(\"--url URL\", \"Setting the Base URL. (#{dopts[:base_url_string]})\") do |url|\n if url !~ Spiderman::Scraper::VALID_URL\n raise OptionParser::InvalidArgument, \"supports only http/https URLs\"\n end\n options[:base_url_string] = url\n end\n\n opts.on(\"--site\", \"-s\", \"Crawl single site only. (#{dopts[:site_only]})\") do\n options[:site_only] = true\n end\n\n opts.on(\"--depth N\", \"-d N\", Numeric, \"Maximum crawl depth, counting the Base URL. (#{dopts[:max_crawl_depth]})\") do |max_crawl_depth|\n if !(max_crawl_depth > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_crawl_depth] = max_crawl_depth\n end\n\n opts.on(\"--urls N\", \"-u N\", Numeric, \"Maximum number of urls to discover (#{dopts[:max_urls]})\") do |max_urls|\n if !(max_urls > 0)\n raise OptionParser::InvalidArgument, \"supports only numbers > 0\"\n end\n options[:max_urls] = max_urls\n end\n\n opts.separator \"\"\n opts.separator \"Common options:\"\n\n opts.on_tail('--verbose', \"Verbose output. (#{dopts[:verbose]})\") do\n options[:verbose] = true\n end\n\n opts.on_tail('--help', '-h', 'Show this message') do\n puts opts\n @end_program=true\n return\n end\n\n opts.on_tail('--version', '-v', 'Show version') do\n puts \"#{APPNAME}: version #{VERSION}\"\n @end_program=true\n return\n end\n end\n\n begin\n opt_parser.parse!(args)\n rescue => ex\n puts ex\n @end_program = true\n end\n\n options\n end", "def parse_options\n @options = {}\n @optparse = OptionParser.new do |opts|\n opts.banner = \"Usage: moa-getfacl [options] <object-name> ...\\n\\n Object Store ACL Listing\\n\\n\"\n\n # @options[:numeric] = false\n # opts.on( '-n', 'Display user IDs numerically' ) do\n # @options[:numeric] = true\n # end\n\n opts.on( '-?', '--help', 'Display this screen' ) do\n puts opts\n exit 0\n end\n end\n\n @optparse.parse!\nend", "def parse_options\n options[:markdown] = false\n o = OptionParser.new do |opts|\n opts.on('-m', '--markdown', 'Use Markdown Syntax') do\n options[:markdown] = true\n end\n opts.on('-l', '--html', 'Use HTML Syntax') do\n options[:html] = true\n end\n opts.on('-s', '--size PERCENTAGE', 'Image Size') do |value|\n options[:size] = value\n end\n opts.on('-t', '--title TITLE', 'Image Title') do |value|\n options[:title] = value\n end\n opts.on('-d', '--desc DESC', 'Image Title') do |value|\n options[:desc] = value\n end\n opts.on('-v', '--version', 'Print Version') do\n version\n quit\n end\n opts.on('-h', '--help', 'Print Help') do\n help\n quit\n end\n end\n begin\n o.parse!\n rescue OptionParser::MissingArgument => e\n puts \"Error: #{e.message}\"\n quit\n rescue OptionParser::InvalidOption => e\n puts \"Error: #{e.message}\"\n quit\n end\n end", "def parse_options(args)\n args.each do |arg|\n case arg\n when '-h', '--help' then @opts[:help] = true\n when '-un', '--user' then @opts[:user] = args.next(arg)\n when '-pw', '--pass' then @opts[:pass] = args.next(arg)\n when '-t', '--token' then @opts[:token] = args.next(arg)\n when '-g', '--get' then @opts[:get] = args.next(arg)\n when '-d', '--debug' then @opts[:debug] = true\n when '-r', '--random' then @opts[:get] = nil\n else next\n end\n end\n end", "def parse_options(_targets)\n []\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def parse\n # parse flag arguments\n @oparse.parse!(@argv) rescue(bail_args($!))\n @parsed=true\n\n # the overriding class may implement additional arguments from here\n end", "def parse_options\n @options = Slop.parse do\n banner \"ps2 [filename] [options]\\n\"\n \n on :name, 'Do not parse the name of the game from the ISO and use the given NAME instead.'\n on :code, 'Do not parse the code of the game from the ISO and use the given CODE instead.'\n on :scan, 'Scan the current or given DIRECTORY for ISO files and run ps2 on each, skipping failures. This ignores any other options.'\n on :version, 'Print the current version of ps2. This ignores any other options.'\n end\n \n @options.scan = Pathname.pwd if @options.scan == true\n end", "def parse_options\n if options[:version]\n say \"Vendorificator #{Vendorificator::VERSION}\"\n exit\n end\n\n # figure out verbosity\n @verbosity = self.options[:verbose].to_i\n @verbosity = 2 if @verbosity.zero?\n @verbosity = VERBOSITY_LEVELS.keys.select { |i| i < verbosity }.max unless VERBOSITY_LEVELS[@verbosity]\n end", "def end_options\n abstract!\n end", "def parse_specific_options(parser)\n parser.separator \"\"\n parser.separator \"Specific options:\"\n\n parser.on(\"-d\", \"--dry-run\", \"Run without pdf generation\") do |contents_template|\n options.task = :dry\n end\n\n parser.on(\"-m\", \"--merge-config [CONFIG]\",\n \"Merge config with key from .texasrc\") do |key|\n options.merge_config = key\n end\n\n parser.on(\"-n\", \"--new [NAME]\",\n \"Create new texas project directory\") do |name|\n options.task = :new_project\n options.check_mandatory_arguments = false\n options.load_local_libs = false\n options.new_project_name = name\n end\n\n parser.on(\"-r\", \"--require [LIBRARY]\", \"Require library before running texas\") do |lib|\n # this block does nothing\n # require was already performed by lookup_and_execute_require_option\n # this option is here to ensure the -r switch is listed in the help option\n end\n\n parser.on(\"--watch\", \"Watch the given template\") do |contents_template|\n options.task = :watch\n options.open_pdf = false\n end\n end", "def parse_options()\n\n options = {}\n\n ARGV.each_index do |index|\n case $*[index]\n when '-m' then options[:auto_connect] = false\n when '-v' then options[:verbose] = true\n when '-q' then options[:verbose] = false\n when '-t' then options[:log_truncate] = true\n when '-r' then options[:log_response] = false\n else\n ::Twiga.say_warn \"unknown option: #{arg}\"\n end # case\n\n $*.delete_at(index) # remove from command line\n\n end # do each cmd line arg\n \n return Kinokero::Cloudprint::DEFAULT_OPTIONS.merge(options)\n\n end", "def parse_options! #:nodoc:\n @options = { :recipes => [], :actions => [],\n :vars => {}, :pre_vars => {},\n :sysconf => default_sysconf, :dotfile => default_dotfile }\n\n if args.empty?\n warn \"Please specify at least one action to execute.\"\n warn option_parser\n exit\n end\n\n option_parser.parse!(args)\n\n coerce_variable_types!\n\n # if no verbosity has been specified, be verbose\n options[:verbose] = 3 if !options.has_key?(:verbose)\n\n look_for_default_recipe_file! if options[:default_config] || options[:recipes].empty?\n extract_environment_variables!\n\n options[:actions].concat(args)\n\n password = options.has_key?(:password)\n options[:password] = Proc.new { self.class.password_prompt }\n options[:password] = options[:password].call if password\n end", "def options args = ARGV, *a, &b\n @p = Parser.new(*a, &b)\n begin\n vals = @p.parse args\n args.clear\n @p.leftovers.each { |l| args << l }\n vals\n rescue CommandlineError => e\n $stderr.puts \"Error: #{e.message}.\"\n $stderr.puts \"Try --help for help.\"\n exit(-1)\n rescue HelpNeeded\n @p.educate\n exit\n rescue VersionNeeded\n puts @p.version\n exit\n end\n end", "def process_arguments\n @args << \"-h\" if(@args.length < 1)\n \n opts_parse = OptionParser.new do |opts|\n opts.on('-f','--file FILE','use the following local file') {|file| @options.file = File.expand_path(file)}\n opts.on('-p','--parse PARSE',\"sets which set of sider files to download #{@@sections.join(\"|\")}\") {|parse| @options.parse = parse}\n opts.on('-d','--download','download the file to be parsed') {@options.download = true}\n opts.on('-o','--output DIR','set the output directory') {|directory| @options.output = File.expand_path(directory)}\n opts.on('-h','--help',\"prints the help\"){puts opts; exit!}\n end\n \n opts_parse.parse!(@args) rescue raise \"There was an error processing command line arguments use -h to see help\"\n end", "def setup_options\n @parser.banner = BANNER\n\n @parser.on('-V', '--version', 'display version and exit') { show_version }\n @parser.on('-h', '--help', 'display help and exit') { show_help }\n @parser.on('-f', '--files=[file1.txt file2.txt ...]', Array, 'text files to read') { |o| @options.files = o }\n @parser.on('-n', '--number=NUM', Integer, 'number of results to show [default = 100]') do |n|\n @options.number = n\n end\n @parser.on('-v', '--verbose', 'verbose output') { @options.verbose = true }\n end", "def process_options\n @options.verbose = false if @options.quiet\n end", "def parse\n opts = OptionParser.new(&method(:set_options))\n opts.parse!(@args)\n return process_url if url_present?\n opts.help\n end", "def convert_options(opts); end", "def parse_option(obj, opt, argv)\n x = opt.sub(/^--/, '')\n #if obj.respond_to?(\"#{x}=\")\n obj.send(\"#{x}=\", true)\n #else\n # obj.option_missing(x, true)\n #end\n end", "def parse_options\n opts = Slop.parse(help: true, strict: true) do\n banner \"Usage: fixexts [options]\"\n\n # on 'c', 'codecs', 'List the availiable codecs'\n # on 'u=', 'use', 'Tool to use (ffmpeg, mencoder)', default: \"ffmpeg\"\n end\n\n [opts, ARGV]\nend", "def options(opt); end", "def options(opt); end", "def parse(args)\n arg_index = 0\n while arg_index < args.size\n arg = args[arg_index]\n\n if arg.start_with? '--'\n # Argument is a long option (eg: --verbose)\n op = arg[2,arg.length]\n value = nil\n\n # Check if the option and value are specified together (\"--op=value\")\n eql_index = op.index '='\n if !eql_index.nil?\n # Split \"op=value\" string and store\n value = op[eql_index+1, op.size]\n op = op[0, eql_index]\n end\n\n # Check if option is accepted\n raise \"Option '--#{op}' not accepted\" if !accepts? op\n\n # Remember that the option was specified\n data = @options[op]\n data.given = true\n\n # Check if given a value that wasn't expected\n if !data.has_value? && !eql_index.nil?\n raise \"Option '--#{op}' does not expect a value\"\n end\n \n # Get associated value\n if data.has_value?\n # If the option was not given as \"op=value\", get the next value.\n # Otherwise, save the value we stored before\n if eql_index.nil?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size\n raise \"Option '--#{op}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n else\n data.value = value\n end\n end\n\n elsif arg.start_with? '-'\n # Argument is a short option (eg: -a, -abc)\n op = arg[1,arg.length]\n \n # Make sure each character is accepted\n op.chars.each_with_index do |c,i|\n # Check for errors\n raise \"Option '-#{c}' not accepted\" if !accepts? c\n\n # Remember that the option was specified\n data = @options[c]\n data.given = true\n\n # Check for and save the option's values\n if data.has_value?\n # Get index of next value\n arg_index += 1\n # Make sure we actually have a value to save\n if arg_index >= args.size || i >= op.size\n raise \"Option '-#{c}' must be followed by a value\"\n end\n # Then save the value\n data.value = args[arg_index]\n end\n end\n\n else\n # Argument is a param (ie. not an option)\n @params << arg\n end\n\n # Increment argument index\n arg_index += 1\n end\n end", "def opt_parse # rubocop:disable Metrics/AbcSize\n case @options[:action]\n when 'create'\n build_looper('instances')\n when 'list'\n formatter(list)\n when 'delete'\n puts delete\n when 'get_ip'\n BmcAuthenticate.new(@options)\n attrcheck = { 'instance' => @options[:inst] }\n @validate.validate(@options, attrcheck)\n inst_details = AttrFinder.new(@instanceparameters)\n inst_details.options = @options\n inst_details.validate = @validate\n inst_ocid = inst_details.instance\n ips = list_instance_ip(@options[:compartment], inst_ocid)\n puts 'The private IP is ' + ips.at(0) + ' the public ip is ' + ips.at(1)\n when 'InstanceConsoleHistory'\n chist = InstanceConsoleHistory.new\n chist.options = @options\n chist.validate = @validate\n formatter(chist.list) \n else\n 'you have entered an incorrect value, correct values are get_ip, create, list, list_image, delete'\n end \n end" ]
[ "0.7552417", "0.7552417", "0.74314475", "0.74314475", "0.71792066", "0.7081571", "0.7081571", "0.7081571", "0.6974218", "0.68648267", "0.67707926", "0.67595637", "0.67076904", "0.67076904", "0.6699218", "0.66534525", "0.6587343", "0.65802133", "0.6535342", "0.6501349", "0.64867634", "0.6433459", "0.64133257", "0.64126384", "0.64126384", "0.6396731", "0.6346991", "0.6344778", "0.62393486", "0.62235683", "0.6207572", "0.620083", "0.61841303", "0.6179191", "0.61764866", "0.61542517", "0.6141669", "0.6093813", "0.60875106", "0.6086365", "0.60817057", "0.60756665", "0.60668296", "0.606308", "0.6045614", "0.6036925", "0.60361075", "0.6031536", "0.60205066", "0.60038155", "0.5998464", "0.5997457", "0.59887606", "0.5965479", "0.59375703", "0.5903354", "0.58945566", "0.5893228", "0.58885396", "0.5882619", "0.5875808", "0.5873754", "0.5872919", "0.5867897", "0.5858565", "0.58567435", "0.5849093", "0.58468455", "0.5834607", "0.5834583", "0.5824691", "0.58215356", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5819093", "0.5804574", "0.58003855", "0.57980144", "0.57877356", "0.5776235", "0.5773407", "0.57690996", "0.5768154", "0.5765085", "0.5735121", "0.5734986", "0.5734389", "0.57281667", "0.5726365", "0.572409", "0.571692", "0.5715226", "0.570523", "0.570422" ]
0.59495616
54
True if required arguments were provided
def arguments_valid? # TO DO - implement your real logic here true if @arguments.length == 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_missing_required_arg?\n !missing_required_arguments.empty?\n end", "def includes_arguments?\n !default_data.empty? || !flags.empty? ||\n !required_args.empty? || !optional_args.empty? ||\n !remaining_arg.nil? || flags_before_args_enforced?\n end", "def arguments_valid?\n true # no required arguments\n end", "def arguments_valid?\n # Should be no remaining arguments\n true if @arguments.length == 0\n end", "def arguments_valid?\n true \n end", "def arguments_passed?\n !!(ARGV[0] && ARGV[1] && ARGV[2])\n end", "def arguments_valid?\n # TO DO - implement some real logic here\n true if @arguments.length == 1 \n end", "def arguments_valid?\n # TO DO - implement your real logic here\n true if @arguments.length == 1 \n end", "def arguments_valid?\n true\n end", "def arguments_valid?\n true if @arguments.size > 1\n end", "def valid_arguments?\n arguments_passed? && right_type?\n end", "def arguments_valid?\n # TODO - implement your real logic here\n true # if @arguments.length == 1\n end", "def arguments_given?\n !@arguments.empty?\n end", "def arguments_valid?\n true if @arguments.size >= 1 \n end", "def arguments?\n arguments.any?\n end", "def argument_required?\n !short.to_s.match(SHORT_ARGUMENT_REQUIRED_RE).nil? ||\n !long.to_s.match(LONG_ARGUMENT_REQUIRED_RE).nil?\n end", "def valid_args?(args={})\n valid = false\n arguments.each do |name, argument|\n if argument[:required]\n return false if args[name] == nil\n end\n valid = argument.valid_input?(args[name])\n end\n return valid\n end", "def provides_arguments?\n true\n end", "def provides_arguments?\n true\n end", "def arguments?\n arguments.any?\n end", "def arguments_valid?\n # TO DO - implement your real logic here\n true if @arguments.length == 2\n end", "def valid?(setup)\n setup.args.length >= required_args && (max_args == -1 || setup.args.length <= max_args)\n end", "def arguments_valid?\n true\n end", "def arguments_valid?\n true \n # to do\n end", "def arguments_valid?\n true if ['install','list','uninstall'].include?(@arguments[0])\n end", "def arguments_valid?\n true if @arguments.length == 4\n end", "def arguments_valid?\n # TO DO - implement your real logic here\n true if (1..2).include? @arguments.length \n end", "def arguments_valid?\n true if @arguments.length == argv_length \n end", "def expects_argument?\n true\n end", "def arguments_valid?\n num = 0\n num += 1 if @options.stats\n num += 1 if @options.attach\n num += 1 if @options.detach\n return false if num > 1\n return true\n end", "def any_args?\n @any_args\n end", "def any_args?\n @any_args\n end", "def args_defined?\n @args_def && @args_def.args.size > 0\n end", "def args?\n\t\treturn !self.fields.empty?\n\tend", "def wrong_num_parameters?\n (ARGV.size != 1)\n end", "def required_args\n @required_args || 0\n end", "def provides_arguments?\n false\n end", "def allowed_arguments(arguments)\n return false if arguments.empty?\n\n arguments.each_child_node(:restarg).any? &&\n arguments.each_child_node(:kwarg, :kwoptarg, :kwrestarg).none?\n end", "def arguments_valid?\n true if @commands.length > 0\n end", "def arguments_valid?\n return false if (@options[:partition_class] and @options[:rmcls])\n\n if @options[:rmcls]\n return false unless (@options[:cls_file] and @options[:lrn_file])\n elsif @options[:partition_class]\n return false unless (@options[:cls_file] and @options[:name_file] and @options[:fasta_file])\n end\n true\n end", "def required_args_present?(metric, args)\n (@metrics[metric]['required'] - args.keys).empty?\n end", "def arguments_valid?\n # check the parameters have values\n return false unless @options.has_key?(:hcdFile)\n return false unless @options.has_key?(:etdFile) \n return false if @options[:mzArray].empty?\n return false unless (@options[:mzTolerance] > 0.0 || @options[:ppmTolerance] > 0.0 )\n # check the file exists\n return false unless File.file?(@options[:hcdFile])\n return false unless File.file?(@options[:etdFile])\n true\n end", "def check_arguments(params, *args)\n contains = true\n args.each do |arg|\n contains = false unless params.key? arg.to_sym\n end\n contains\n end", "def arguments_valid?\n # right now, there is no set of invalid arguments.\n # (can I really just say true here? I don't have to return something?)\n true unless (@options.set_status == true and @options.status == nil)\n end", "def required?\n true\n end", "def check_params; true; end", "def expects_argument?\n config[:argument] && config[:argument] != :optional\n end", "def arguments_valid?\n valid_args = true\n valid_args = false if @options.min > @options.max\n valid_args = false if @options.user && !@options.password\n valid_args = false if @options.password && !@options.user\n valid_args\n end", "def check_arguments\n convert_boolean_strings\n check_output\n check_log_level\n check_input_entry\n check_input_types\n end", "def arg_required(*args)\n args.each{|obj| raise ArgumentError, \"Argument cannot be nil\" if obj.nil? }\n end", "def args?\n\t\treturn !@form.empty?\n\tend", "def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend", "def check_params *required\n required.each{|p|\n params[p].strip! if params[p] and params[p].is_a? String\n if !params[p] or (p.is_a? String and params[p].length == 0)\n return false\n end\n }\n true\nend", "def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end", "def arguments_valid?\n \n # true if @arguments.length == 1 && (File.directory?(@options.output) || File.exists?(File.dirname(@options.output))) && File.directory?(@options.input)\n case @options.mode\n when \"queue\"\n true if File.directory?(@options.output)\n when \"crawl\"\n true if File.directory?(@options.output) && File.directory?(@options.input?)\n else\n true if @arguments.length == 1\n end\n end", "def arguments_valid?\n\t\tcase @arguments.length\n\t\twhen 0\n\t\t\traise(\"File does not exist or is not readable\") unless File.exist?(@dict_path) and File.readable?(@dict_path)\n\t\t\treturn true\n\t\twhen 1\n\t\t\treturn process_arguments\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def required?\n required.any?\n end", "def required_args\n args.select &:required\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n end\n rescue LoadError => bam\n @log.error bam\n exit\n end\n \n return true\n end", "def no_args_provided?\n @no_args_provided ||= no_args_provided\n end", "def parsed_arguments?\n return true if @arguments.empty?\n case @arguments.length\n when 1\n case @arguments[0]\n when 'setup'\n @options[:restore] = false\n when 'restore'\n @options[:restore] = true\n else\n return false\n end\n else\n return false\n end\n return true\n end", "def required_param_types_present?\n @required_param_types.each do |string|\n return false unless param_classname_present?(string)\n end\n return true\n end", "def validate_arguments\n if(!@options.parse || !@@sections.include?(@options.parse))\n @log.error \"select one of the following to parse: #{@@sections.join(\"|\")}\"\n exit!\n end\n \n if(!@options.download && !@options.file)\n @log.error \"Select either to download the file remotely or supply the given file\"\n exit!\n end\n \n if(!@options.output)\n @log.error \"supply an output directory with -o\"\n exit!\n end\n \n return true\n end", "def validate_args (args)\n\t# todo\nend", "def valid_arguments?\n begin\n if(@options.file)\n raise LoadError,\"The file you specified doesn't exist: #{@options.file}\" if File.exist?(@options.file) == false\n else\n @log.error \"Select a file using -f or --file FILE\"\n exit!\n end\n \n if(@options.output)\n # not going to worry about this one.\n else\n @log.error \"No output was specified select using -o or --output\"\n exit!\n end\n rescue LoadError => bam\n @log.error bam\n exit!\n end\n \n return true\n end", "def optional?\n required.empty? && required_keywords.empty?\n end", "def check_requirement!(*args)\n args_length = args.length\n required_length = @required.length\n\n if args_length < required_length\n raise ArgumentError, \"Wrong number of arguments \" \\\n \"(#{args_length} for #{required_length}). \" \\\n \"Expected `#{@required.join(', ')}` as required arguments, \" \\\n \"but got `#{args.join(\", \")}`.\"\n end\n end", "def required *args\n @required = args.first if args.size > 0\n end", "def validate_arguments()\n usage unless ARGV.count > 0\nend", "def argument_optional?\n !short.to_s.match(SHORT_ARGUMENT_OPTIONAL_RE).nil? ||\n !long.to_s.match(LONG_ARGUMENT_OPTIONAL_RE).nil?\n end", "def numerical_arg_size?\n !has_splat_args? && arg_size\n end", "def complete_args?\n @complete_args\n end", "def required?\n options[:required] == true\n end", "def valid_params?(*args)\n args.map { |a| return false if a.nil? || a.to_s.gsub(/\\s/, '').empty? }\n true\n end", "def required?\n @required\n end", "def required?\n\t\t@required\n\tend", "def includes_definition?\n includes_arguments? || runnable? || argument_parsing_disabled? ||\n includes_modules? || includes_description?\n end", "def required?(name); end", "def required?\n @required\n end", "def required?\n @required\n end", "def required?\n @required\n end", "def required?\n @required\n end", "def test_positive\n args = Arguments.new\n assert_equal false, args.check_args(5)\n end", "def required?\n @required == true\n end", "def ensure_params(*args)\n return catch(:truthy) {\n args.each do |arg|\n throw(:truthy, false) unless ensure_param(arg)\n end\n\n throw(:truthy, true)\n }\n end", "def setup_args_valid?(argsArr)\r\n if nil==argsArr[0] or argsArr[0]==\"\"\r\n return \"Bot token cannot be empty or nil.\"\r\n elsif nil==argsArr[1] or argsArr[1]==\"\"\r\n return \"Bot clientId cannot be empty or nil.\"\r\n elsif nil==argsArr[2]\r\n return \"Bot command prefix cannot be nil.\"\r\n end\r\n\r\n return nil\r\n end", "def check_args(args)\n args.count == 2 && args[0].to_i > 0 && args[1].to_i > 0\n rescue StandardError\n false\n end", "def required?\n (required == true)\n end", "def needed_params_present?(*ar_params)\n ar_params.flatten.all? { |e| params[e].present? }\n end", "def has_required?; end", "def may?(*args)\n true\n end", "def argument_types?(*value)\n true\n end", "def check_params\n true\n end", "def required?\n @required\n end", "def required?\n @required\n end", "def valid?(options)\n (@required_options - options.keys).size == 0\n end", "def required? #:nodoc:\n options[:required]\n end", "def arguments?\n @config.arguments == Cliqr::Config::ENABLE_CONFIG\n end" ]
[ "0.8533331", "0.84634876", "0.8193903", "0.79284185", "0.7852744", "0.78392625", "0.78328884", "0.782945", "0.7823655", "0.78031105", "0.7782608", "0.77764374", "0.77586794", "0.77535295", "0.7736395", "0.7735971", "0.7722972", "0.76806915", "0.76806915", "0.76514757", "0.76312226", "0.7618733", "0.7593075", "0.75791484", "0.75458986", "0.75398684", "0.74910593", "0.7480691", "0.7464224", "0.7430521", "0.7428264", "0.7428264", "0.74136907", "0.74043477", "0.740029", "0.7365185", "0.73586506", "0.73348457", "0.7326056", "0.73227197", "0.73099446", "0.7256976", "0.72430575", "0.7242848", "0.7139796", "0.7127573", "0.71265876", "0.71252406", "0.7105051", "0.7104962", "0.70973074", "0.70971763", "0.70969534", "0.7096757", "0.70767957", "0.7074191", "0.7051729", "0.70441276", "0.7003285", "0.7003285", "0.7003285", "0.70009655", "0.6997354", "0.6978416", "0.69758797", "0.6972839", "0.69644743", "0.6956575", "0.6935684", "0.6935593", "0.6913723", "0.6867249", "0.6862686", "0.6862021", "0.6849053", "0.68420655", "0.68288547", "0.681948", "0.68166625", "0.6813074", "0.6810447", "0.6810447", "0.6810447", "0.6810447", "0.6805196", "0.6803952", "0.6789096", "0.6779783", "0.6775208", "0.67728186", "0.6769283", "0.6767413", "0.67671025", "0.67644584", "0.6761478", "0.6759588", "0.6759039", "0.67577314", "0.67458624", "0.67393863" ]
0.7768861
12
Use a builtin term list dict: a key in DICTS
def augment_from_dict(dict) path = DICTS[dict.to_sym] || raise(InvalidDictionaryName, dict) @word_file = File.open path puts "#{self.class} will augment AppleSpell with words from #{path}" augment! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def characterization_terms(omdoc)\n h = {}\n omdoc.class.terminology.terms.each_pair do |key, target|\n # a key is a proxy if its target responds to proxied_term\n next unless target.respond_to? :proxied_term\n begin\n h[key] = omdoc.send(key)\n rescue NoMethodError\n next\n end\n end\n h.delete_if { |_k, v| v.empty? }\n end", "def characterization_terms(doc)\n h = {}\n\n doc.class.terminology.terms.each_pair do |key, _target|\n h[key] = doc.public_send(key)\n rescue NoMethodError\n next\n end\n\n h.compact\n end", "def index_ontology_terms_from_cache( doc, term_conf, cached_data )\n [:term,:term_name].each do |term_or_name|\n cached_data[term_or_name].each do |target|\n doc[ term_conf[\"idx\"][term_or_name.to_s].to_sym ].push( target )\n end\n doc[ term_conf[\"idx\"][\"breadcrumb\"].to_sym ].push( cached_data[term_or_name].join(\" | \") )\n end\n end", "def term_list(terms)\n ignored = params.keys - ['q', 'solr_document_id', 'action', 'controller']\n list_id = request.original_url\n term_list = IIIF::Presentation::Resource.new('@id' => list_id)\n term_list['@context'] = 'http://iiif.io/api/search/1/context.json'\n term_list['@type'] = 'search:TermList'\n term_list['terms'] = terms\n term_list['ignored'] = ignored\n term_list.to_ordered_hash(force: true, include_context: false)\n end", "def word_list\n # Returning only the terms of each definition as an array.\n list_of_terms = @words.map do |key, definition_instance|\n definition_instance.term\n end\n end", "def terms\n @term_hash.values\n end", "def above_fold_terms\n [:maker,\n :date_original,\n :date_published,\n :resource_type,\n :genre_string,\n :identifier,\n :rights,\n ]\n end", "def find_terms(doc)\n terms_match = @terms.select { |term| doc.join('').match(term.to_s) }\n\n terms_match.map do |term, definition|\n \"*[#{term}]: #{definition}\".delete(\"\\t\\r\\n\").squeeze(' ').strip\n end\nend", "def term_map\n\t\t\tterm_set = Hash.new(0)\n\t\t\tself.to_terms.each do |term|\n\t\t\t\tterm_set[term] = term_set[term] + 1\n\t\t\tend\n\t\t\tterm_set\n\t\tend", "def term_params\n if TERM_ADDITIONAL_FIELDS[params[:term]['controlled_vocabulary_string_key']].blank?\n addl_term_params = []\n else\n addl_term_params = TERM_ADDITIONAL_FIELDS[params[:term]['controlled_vocabulary_string_key']].map { |key, _value| key.to_sym }\n end\n params.require(:term).permit([:controlled_vocabulary_string_key, :value, :uri, :type, :authority] + addl_term_params)\n end", "def brief_terms\n [\n #:relation,\n :asset_type,\n :uid,\n :pref_label\n ]\n end", "def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end", "def terms_to_entrylists(terms, opts)\n norm_opts = @pgr.get_string_normalization_options\n # norm_opts value\n # { lowercased: dic[:lowercased], hyphen_replaced: dic[:hyphen_replaced], stemmed: dic[:stemmed] }\n trier = TEXT_TO_TRIE.new\n expanded_terms = {}\n expanded_IDs = {}\n\n # 1. Perform query expansion for each input term based on a given threshold. The output \n # is structured as follows.\n #\n # expanded_terms = { \n # \"an original input term 1\" => [ \n # {\n # :original_query => \"a normlaized input term 1\"}\n # :requested_query => \"a term similar to :original_query\",\n # :offset => a range object (absolute position within a given text),\n # :sim => 0.0~1.0\n # },\n # {\n # :original_query => \"a normlaized input term 1\"}\n # :requested_query => \"a term similar to :original_query\",\n # :offset => a range object (absolute position within a given text),\n # :sim => 0.0~1.0\n # },\n # ...\n # ],\n # ...\n # }\n # \n terms.uniq.each do |term|\n offsets = [(0...term.length)]\n norm_term = trier.normalize_term(\n term, norm_opts[:lowercased], norm_opts[:hyphen_replaced], norm_opts[:stemmed]\n )\n\n expanded_terms[term] = @qbuilder.expand_query(norm_term, offsets, opts[\"threshold\"], @ssr, @pgr)\n\n # Keep only top n similar terms to speed up ID search.\n if opts[\"top_n\"] > 0\n expanded_terms[term].sort! { |x, y| y[:sim] <=> x[:sim] }\n expanded_terms[term] = expanded_terms[term][0...opts[\"top_n\"]]\n end\n end\n\n # 2. Get a list of IDs for each term.\n expanded_terms.each do |ori_term, sim_terms|\n expanded_IDs[ori_term] = []\n \n # 2.1. Get a list of DB entries for an original \n sim_terms.each do |sim_term|\n entries = @pgr.get_entries_from_db(sim_term[:requested_query], :search_title)\n expanded_IDs[ori_term] += entries.collect do |entry|\n { uri: entry[:uri], sim: sim_term[:sim] } # URI, Similarity\n end\n end\n \n\n # The following two steps should be done above level since multiple dictionaries \n # can affect the order.\n \n # 2.2. Sort the list based on the similarity value.\n # expanded_IDs[ori_term].sort! { |x, y| y[:sim] <=> x[:sim] }\n\n # 2.3. Sort the result.\n #\n # if opts[\"top_n\"] > 0 and expanded_IDs[ori_term].size >= opts[\"top_n\"]\n # expanded_IDs[ori_term] = expanded_IDs[ori_term][0...opts[\"top_n\"]]\n # end\n end\n\n expanded_IDs\n end", "def person_relator_terms\n {\n \"aut\" => \"Author\",\n \"cre\" => \"Creator\",\n \"edt\" => \"Editor\",\n \"phg\" => \"Photographer\", \n \"mdl\" => \"Module leader\",\n \"spr\" => \"Sponsor\",\n \"sup\" => \"Supervisor\" \n }\n end", "def dictionary()\n word_list = {\n \"hello\" => \"hi\",\n \"to\" => \"2\",\n \"two\" => \"2\",\n \"too\" => \"2\",\n \"for\" => \"4\",\n \"four\" => \"4\",\n \"be\" => \"b\",\n \"you\" => \"u\",\n \"at\" => \"@\",\n \"and\" => \"&\"\n }\nend", "def map_keywords(keywords)\n keywords.inject({}) do |out, keyvalue|\n key, value = keyvalue\n out.merge({ KEYWORDS[key.to_sym], value.to_s })\n end\nend", "def term(**mapping)\n render(TERM, **mapping)\n end", "def __tkvariable_optkeys\n super() << 'listvariable'\n end", "def possible_keys(key); end", "def initialize(docid, terms_list)\n @docid, @term_hash = docid, to_term_hash(terms_list)\n end", "def lookups; end", "def _lex_trans_keys; end", "def _lex_trans_keys; end", "def _lex_trans_keys; end", "def _lex_trans_keys; end", "def semantic_search_map \n # Hash[] conveniently takes an array of k-v pairs. \n return Hash[\n search_field_definitions.collect do |field, defn|\n [ defn[:semantic].to_s, field ] if defn && defn[:semantic]\n end.compact \n ]\n end", "def primary_terms\n [:title, :description, :source, :rights_note]\n end", "def search_terms(resource)\n return nil unless resources.include? resource\n @data[resource][0].keys\n end", "def to_term_hash(term_array)\n term_array.inject({ }) { |result_hash, term| result_hash[term.word] = term; result_hash } \n end", "def secondary_terms\n []\n end", "def supported_terms\n term_help_messages.keys\n end", "def terms\n @terms ||= wayfinder.decorated_ephemera_terms.sort_by(&:label)\n end", "def term_candidates(cyc_id)\n return @term_cache[cyc_id] unless @term_cache[cyc_id].nil?\n @term_cache[cyc_id] = create_candidate_set(\"\",[@name_service.find_by_id(cyc_id)])\n end", "def look_up(term)\n # First, let's convert our user input to lowercase.\n term = term.downcase\n # If the word doesn't exist in my hash, let the user know.\n if !@words[term] \n return \"Sorry, I don't have a definition for \\\"#{term}\\\"...\"\n # Otherwise, spit out my definition. \n else\n @words[term].definition\n end\n\n end", "def index_ontology_terms( ontology_term_conf, doc, data_row_obj, map_data )\n ontology_term_conf.each do |term_conf|\n attribute = term_conf[\"attr\"]\n value_to_index = extract_value_to_index( attribute, data_row_obj[attribute], map_data[:attribute_map], { attribute => data_row_obj[attribute] } )\n \n if value_to_index and !value_to_index.gsub(\" \",\"\").empty?\n cached_data = @ontology_cache[value_to_index]\n if cached_data != nil\n index_ontology_terms_from_cache( doc, term_conf, cached_data )\n else\n index_ontology_terms_from_fresh( doc, term_conf, value_to_index )\n end\n end\n end\n end", "def semantic_search_keys \n semantic_search_map.keys\n end", "def secondary_terms\n []\n end", "def secondary_terms\n []\n end", "def secondary_terms\n []\n end", "def dig(*keys); end", "def ll_table\n\t\ttable = {}\n\t\tnon_terminals.each do |non_term|\n\t\t\ttable[non_term] = {}\n\t\t\tp_sets = predict_sets(non_term)\n\t\t\tp_sets.each_index do |i|\n\t\t\t\tp_sets[i].each do |term|\n\t\t\t\t\ttable[non_term][term] = i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn table\n\tend", "def set_keywords\n self.search_fields.keys.each do |namespace| \n self._keywords[namespace] = self.search_fields[namespace].map do |field|\n if field.is_a?(Hash) \n field.keys.map do |key|\n attribute = self.send(key)\n method = field[key] \n attribute = [attribute] if !attribute.is_a?(Array) \n method = [method] if !method.is_a?(Array)\n method.map {|m| attribute.map { |a| Util.keywords a.send(m), stem_keywords[namespace], ignore_list[namespace] } }\n end\n else \n value = self[field]\n value = [value] if !value.is_a?(Array)\n value.map {|v| Util.keywords(v, stem_keywords[namespace], ignore_list[namespace]) if v}\n end\n end.flatten.map(&:to_s).select{|f| not f.empty? }.uniq.sort\n \n end\n end", "def term_candidates(cyc_id)\n return @term_cache[cyc_id] unless @term_cache[cyc_id].nil?\n @term_cache[cyc_id] = create_candidate_set(\"\",[@name_service.find_by_id(cyc_id)])\n end", "def technical_stops_in tstops\n dict( tstops.map(&:city), :in )\n end", "def primary_terms\n terms - [:visibility, :collection_type_gid]\n end", "def term; end", "def words # utility\n @dict.keys.sort\n end", "def secondary_terms\n [:gw_affiliation, :date_created,\n :description, :keyword,\n :identifier, :contributor, :publisher, :language,\n :based_near, :related_url, :bibliographic_citation]\n end", "def keywords_for_index(_item)\n []\n end", "def spelling_list_params\n params.fetch(:spelling_list, {})\n end", "def extract_indexterms(terms)\n terms.each_with_object({}) do |t, v|\n term = t&.at(ns(\"./primary\"))&.children&.to_xml\n term2 = t&.at(ns(\"./secondary\"))&.children&.to_xml\n term3 = t&.at(ns(\"./tertiary\"))&.children&.to_xml\n index2bookmark(t)\n v[term] ||= {}\n v[term][term2] ||= {}\n v[term][term2][term3] ||= {}\n v[term][term2][term3][:xref] ||= []\n to = t[\"to\"] ? \"to='#{t['to']}' \" : \"\"\n v[term][term2][term3][:xref] << \"<xref target='#{t['id']}' #{to}pagenumber='true'/>\"\n end\n end", "def subject_map(terms, rel = :subjects)\n {\n :obj => :subject,\n :rel => rel,\n :map => {\n 'self::subfield' => proc { |subject, node|\n subject.publish = true\n subject.terms = terms.call(node)\n subject.source = node.parent.at_xpath(\"subfield[@code='2']\").inner_text unless node.parent.at_xpath(\"subfield[@code='2']\").nil?\n subject.vocabulary = '/vocabularies/1'\n subject.authority_id = set_auth_id(node) unless node.parent.at_xpath(\"subfield[@code='0']\").nil?\n }\n },\n :defaults => {\n :source => 'Source not specified'\n }\n }\n end", "def keywords\n @entries.keys.sort # sorts keys to alphabetical \n end", "def terms_with_values\n terms.select { |t| self[t].present? }\n end", "def translate_options(keys, scope)\n keys.map{|k| [t(k, :scope => scope), k]}\n end", "def termsig(*) end", "def add_term_and_term_list(term, term_list)\n\n\tterm_added = false\n\tnew_terms = term_list.terms.map { |tl_term|\n\t\tif (not term_added) and tl_term.same_literal_variables? term and tl_term.imaginary == term.imaginary\n\t\t\tterm_added = true\n\t\t\tTerm.new(term.line, term.col, magnitude: tl_term.magnitude + term.magnitude, imaginary: term.imaginary, lit_var_list: term.literal_variables)\n\t\telse\n\t\t\ttl_term\n\t\tend\n\t}\n\n\tif not term_added\n\t\tnew_terms.append(term)\n\tend\n\n\treturn TermList.new(term.line, term.col, new_terms)\t\nend", "def available_dictionary\n dictionary = [\"cat\", \"cats\",\"running\", \"run\", \"trance\", \"publish\", \"pub\"]\n return dictionary.join(\", \")\nend", "def camelize(term); end", "def set_term_search_instance_variables_from_options(options)\n @species_list = options[:species_list]\n @and_object = options[:object]\n @and_predicate = options[:predicate]\n # NOTE THAT YOU CANNOT HAVE TWO PREDICATES AND TWO OBJECTS!!!! (It's not\n # allowed in the UI, so I'm not accounting for it in the code)\n if @and_object.is_a?(Array)\n @term = TraitBank.term_as_hash(@and_object.first)\n @and_object = @and_object.size == 1 ? nil :\n TraitBank.term_as_hash(@and_object.last)\n\n @object = true\n elsif @and_predicate.is_a?(Array)\n @term = TraitBank.term_as_hash(@and_predicate.first)\n @and_predicate = @and_predicate.size == 1 ? nil :\n TraitBank.term_as_hash(@and_predicate.last)\n @object = false\n else\n # TODO: the whole \"object\" flag is LAME. Remove it entirely!\n @object = options[:object] && ! options[:predicate]\n if options[:predicate] && options[:predicate]\n @term = TraitBank.term_as_hash(options[:predicate])\n @and_predicate = nil\n @and_object = TraitBank.term_as_hash(options[:object])\n elsif options[:predicate]\n @term = TraitBank.term_as_hash(options[:predicate])\n @and_predicate = nil\n @and_object = nil\n else\n @term = TraitBank.term_as_hash(options[:object])\n @and_predicate = nil\n @and_object = nil\n end\n end\n @clade = options[:clade]\n end", "def terms\n end", "def find(input)\r\n if include?(input)\r\n Hash[input, (@@words[input])]\r\n elsif keywords.any? {|key| key.start_with?(input)}\r\n @@words.select {|key, value| key.start_with?(input)}\r\n else\r\n Hash.new\r\n end \r\nend", "def find_term_references(doc, terms)\n logger.info(\"+ Finding references to terms\")\n\n i = 0\n\n # sort terms by the length of the defined term, desc,\n # so that we don't find short terms inside longer\n # terms\n terms = terms.to_a.sort_by { |pair| -pair[1].size }\n\n # look for each term\n for term_id, term in terms\n doc.xpath('//a:body//text()', a: NS).each do |text|\n # replace all occurrences in this text node\n\n # unless we're already inside a def or term element\n next if ([\"def\", \"term\"].include?(text.parent.name))\n\n # don't link to a term inside its own definition\n owner = find_up(text, 'subsection')\n next if owner and owner.at_xpath(\".//a:def[@refersTo='##{term_id}']\", a: NS)\n\n while posn = (text.content =~ /\\b#{Regexp::escape(term)}\\b/)\n # <p>A delegation under subsection (1) shall not prevent the <term refersTo=\"#term-Minister\" id=\"trm357\">Minister</term> from exercising the power himself or herself.</p>\n node = doc.create_element('term', term, refersTo: \"##{term_id}\", id: \"trm#{i}\")\n\n pre = (posn > 0) ? text.content[0..posn-1] : nil\n post = text.content[posn+term.length..-1]\n\n text.before(node)\n node.before(doc.create_text_node(pre)) if pre\n text.content = post\n\n i += 1\n end\n end\n end\n end", "def terms_for_field(name)\n get_for_field(name).map(&:term).uniq\n end", "def _lex_trans_keys=(_arg0); end", "def _lex_trans_keys=(_arg0); end", "def _lex_trans_keys=(_arg0); end", "def _lex_trans_keys=(_arg0); end", "def nouns\n {\"cat\" => [\"cats\", \"cat\"], \"hero\" => [\"heroes\"]}\n end", "def edit_field_terms\n [:identifier, :title, :maker, :resource_type, :genre_string,\n :description, :extent, :rights,\n :publisher, :date_original, :date_published, :subject,\n :language, :related_url,\n :medium, :place_of_interview, :place_of_manufacture,\n :place_of_publication, :provenance]\n end", "def possible_words\n\t\t\t@dictionary.grep to_r\n\t\tend", "def terms\n raise NotImplementedError\n end", "def secondary_terms\n [:creator,\n :contributor,\n :keyword,\n :license,\n :publisher,\n :date_created,\n :subject,\n :language,\n :identifier,\n :based_near,\n :campus,\n :related_url,\n :resource_type]\n end", "def term_list\n terms = Array.new\n\n self.notes.each do |note|\n note.scrubbed_notes.each do |word|\n term_index = terms.index(word)\n if term_index.nil?\n terms.push(word)\n end\n end\n end\n terms\n end", "def term_id(category, term, select)\n s = term_str(category, term, select)\n i = $terms.index s\n unless i\n $terms << s\n i = $terms.size - 1\n end\n i += 3001\nend", "def keywords\n [self.keyword]\n end", "def terms\n\n end", "def terms\n\n end", "def indifferent_dig hsh, keys\n keys.reduce(hsh) do |nested, key|\n next nil unless nested\n\n case key\n when String\n nested.key?(key) ? nested[key] : nested[key.intern]\n when Symbol\n nested.key?(key) ? nested[key] : nested[key.to_s]\n else\n nested[key]\n end # case\n end # method reduce\n end", "def direct_hypernyms(word, part_of_speech)\n if Relations.map.keys.include? word\n return [word]\n else\n # look in wordnet\n synsets = @wordnet.lookup_synsets(word, part_of_speech) \n \n hypernyms = Set.new\n \n # get all hypernyms from wordnet\n synsets.each { |ss|\n ss.hypernyms.each { |synset|\n synset.words.each { |w|\n hypernyms << w.lemma\n }\n }\n }\n \n #check these with the mappings\n return hypernyms.to_a & Relations.map.keys.to_a\n end\n end", "def terms\n [self]\n end", "def method_missing name, *args, &block\n if terminology.key? name\n TermSet.new parent.document, self, name\n else\n super\n end\n end", "def term\n @term\n end", "def auto_complete_for_keyword_list\n auto_complete_responder_for_keyword params[:keyword][:list]\n end", "def dull_keywords\n (@@dull_keywords ||= Defaults.dull_keywords).flatten.uniq\n end", "def lut_keys\n lut_options.keys\n end", "def test_can_deref_element_in_dict_be_first_term_in_expression\n result = interpret 'd=dict(foo:,99);:d[foo:] + 1'\n assert_eq result, 100\n end", "def find_answer keyword={}\n keyword[:answer]\nend", "def build_chain\n i = distance(@word1, @word2) \n k = 0\n list = Array.new\n dict_list = make_list\n while i > 0\n j = 0 \n while j < dict_list.length\n #get a increasing edit distance from @word1 and a decreasing edit distance from wor2\n if (distance(@word1, dict_list[j]) <= k && distance(@word2, dict_list[j]) <= i)\n list.push dict_list[j]\n end\n j = j + 1\n end\n k = k + 1\n i = i - 1\n end\n list.push(@word2)\n end", "def terms\n\tend", "def lookup_dictionary(abbrev)\n results = []\n dictionary.each do |key, values|\n next if values.nil?\n matched_keys = values.keys.select { |k| k.to_s.casecmp(abbrev) == 0 }\n # => ['tbd', 'rhel'] ...\n matched_keys.each do |k|\n results << [k, values[k]]\n end\n end\n results.empty? ? false : results\n end", "def key_variants; end", "def put_concepts( id , title )\n @ct[id] = title\n words = title.scan(LanguageModel::PTN_TERM).map{|w|w.downcase}\n if words.length > MAX_WORDS_IN_TERM then $lgr.error(\"Length exceeded!\") end\n h = @ch #Current Position in Rec\n words.each_with_index do |w,i|\n w.downcase!\n if h[w] == nil #value doesn't exist\n if last_index?(words,i)\n h[w] = id\n else\n h = h[w] = { }\n end\n elsif h[w].class == Fixnum #terminal value exists (final word)\n if last_index?(words,i)\n return :exists\n else\n h = h[w] = { :_key_ => h[w] } #current concept is longer than existing concept\n end\n else #non-terminal value exists (h[w].class == Hash)\n h = h[w]\n end\n #p \"h: \"+h.inspect\n end#do\n #p \"@ch : \"+@ch.inspect\n end", "def search_param_terms\n\t\t\tp = params.permit(:terms, :order)\n\t\t\tp['terms']\n\t\tend", "def get_definitions\n Dictionary.find_by_word(word_id)\n end", "def build_controlled_vocabulary_map\n @controlled_vocab_map = {}\n\n for group, type_map in asset_map\n @controlled_vocab_map[group.to_s] = {}\n for type, attribute in type_map\n # We are assuming that a new-style datastream is going to be the final\n # object in the type-to-attribute value (i.e., in \"foo.bar.baz\", bar is\n # datastream, baz is attribute). With this assumption we can pull the\n # property definition to see if a class is registered, and if so,\n # figure out how to set up a controlled vocabulary query URI.\n objects = attribute.to_s.split(\".\")\n attribute = objects.pop\n property = objects.reduce(asset_class.new, :send).class.properties[attribute]\n\n # TODO: What does it mean if we have no property for a mapped\n # attribute? Likely a misconfiguration that the user cannot control.\n # We should send an error report somewhere here and silently move on,\n # as a browser error isn't going to be particularly useful :-/\n unless property\n raise \"Invalid attribute while building controlled vocabulary map: group => \" +\n \"#{group.inspect}, type => #{type.inspect}, attribute => #{attribute.inspect}\"\n end\n\n # Without a class, the data is simple and not something we try to\n # translate in any way\n next unless property[:class_name]\n\n # This is ugly - maybe we should have something more directly exposing the QA-friendly vocab parameter\n # (or create a map of param-to-class that each controlled vocab class registers and exposes)\n qa_class = property[:class_name]\n vocab_param = qa_class.to_s.sub(/^OregonDigital::ControlledVocabularies::/, \"\")\n next if vocab_param.blank?\n\n path = qa.search_path(:vocab => vocab_param, :q => \"VOCABQUERY\")\n @controlled_vocab_map[group.to_s][type.to_s] = path\n end\n end\n end", "def recursive_hypernyms(word, part_of_speech)\n if Relations.map.keys.include? word\n return [word]\n else\n # look in wordnet\n synsets = @wordnet.lookup_synsets(word, part_of_speech) \n \n hypernyms = Set.new\n \n synsets.each { |ss|\n ss.traverse(:hypernyms).each { |synset|\n synset.words.each { |w|\n hypernyms << w.lemma\n }\n }\n }\n \n #check these with the mappings\n return hypernyms.to_a & Relations.map.keys.to_a\n end\n end", "def terms\n @locations.map(&:term).uniq\n end", "def suggest\n Hash[@solr_data[:spellcheck]['suggestions']]['collation']\n end", "def named_keywords(key: 42)\n p key\nend", "def terms\n values.map(&:to_s)\n end" ]
[ "0.63485163", "0.6270822", "0.6042182", "0.5879882", "0.5841723", "0.5702244", "0.5678703", "0.55880183", "0.5579595", "0.5521153", "0.5458601", "0.54581356", "0.54553336", "0.5434672", "0.5431072", "0.53826547", "0.5373402", "0.537219", "0.5360896", "0.53560424", "0.5355689", "0.5354291", "0.5354291", "0.5354291", "0.5354291", "0.53530145", "0.53476155", "0.53357613", "0.5330862", "0.5313808", "0.52973133", "0.52931845", "0.5287125", "0.5276684", "0.52680457", "0.5252695", "0.5239115", "0.5239115", "0.5239115", "0.52272695", "0.5226218", "0.5222759", "0.52152747", "0.5206029", "0.52027184", "0.5199707", "0.51840687", "0.51602376", "0.51572937", "0.5154726", "0.5149122", "0.514189", "0.5140792", "0.51330084", "0.5128125", "0.5126715", "0.5115739", "0.5111478", "0.51110333", "0.5110697", "0.51081306", "0.50821245", "0.5082074", "0.50622123", "0.50609034", "0.50609034", "0.50609034", "0.50609034", "0.50553435", "0.50524", "0.50480586", "0.50380796", "0.5038043", "0.5036221", "0.5027832", "0.5021649", "0.5017858", "0.5017858", "0.49965417", "0.49941275", "0.498968", "0.49811333", "0.4980699", "0.49763164", "0.49742454", "0.4968167", "0.49580336", "0.49559945", "0.4955726", "0.49548978", "0.49505174", "0.49467754", "0.49436608", "0.49395692", "0.4926819", "0.49236923", "0.49231246", "0.4920929", "0.49173975", "0.49145737", "0.491029" ]
0.0
-1
Use a custom file of new line separated words. If the words Have spaces in them they'll be split path: absolute path to file
def augment_from_file(path) begin @word_file = File.open path rescue Errno::ENOENT => e puts "[#{self.class}] could not find new dictionary file at \"#{word_file}\"" exit 1 end puts "#{self.class} will augment AppleSpell with words from #{path}" augment! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate(file)\n words = file.split(\"\\n\")\n insert_words(words)\n end", "def add_words_from_text_file(file_path)\n words = []\n\n File.open(file_path, 'r') do |file|\n file.each do |line|\n words.push(line.chomp)\n end\n end\n\n add_words(words)\n end", "def load_words\n File.read(\"../scrabble word cheat/words.txt\").split(\"\\n\")\nend", "def line_maker\n @lines = File.readlines(path, chomp: true)\n end", "def line_processor\n open(\"tmp/insert_YourFileName_lines.txt\") do |f|\n f.each do |line| \n unless line =~ /^$/\n puts line.to_s.to_textual\n end\n end\n end\n \nend", "def generate_words\n ret = []\n\n File.open('enable.txt').each do |line|\n new_line = line\n # We don't care for the new line character in the game of hangman.\n new_line = new_line.delete(\"\\n\")\n ret << new_line\n end\n\n return ret\nend", "def read_word_file\n File.open(\"5desk.txt\").each { |line| @text_file << line }\n end", "def prepare_words(filename)\n @words = []\n File.readlines(filename).each do |line|\n line.split.each {|word| @words << word}\n end\n end", "def strings_to_lines_textualed\n strings = File.read(file_name)\n strings.extend Textual\n new = strings.to_textual\n end", "def wordlist(filename)\n wordlist = []\n File.foreach(filename) { |x| wordlist << x.delete!(\"\\r\\n\") }\n wordlist\nend", "def file_name\n file_name = (\"./tmp/database_doings/doing_phrases/insert_phrase_lines.txt\")\n end", "def scanner\n @sentences ||= File.open(@path) do |file|\n file.each_line.each_with_object([]) do |line, acc|\n stripped_line = line.strip\n\n unless stripped_line.nil? || stripped_line.empty?\n acc << line.split(' ').map do |word|\n word.split('/').first\n end.join(' ')\n end\n end\n end\n\n end", "def lex_en_plain_backslash_delimited_words; end", "def lex_en_plain_backslash_delimited_words; end", "def lex_en_plain_backslash_delimited_words; end", "def each_word(&block)\n File.open(@path) do |file|\n file.each_line do |line|\n yield line.chomp\n end\n end\n end", "def write_to_file file, *text\n text.flatten!\n\n File.open(File.expand_path(file), 'a+') do |file|\n full_text = (text * \"\\n\") + \"\\n\"\n\n unless file.read.include? full_text\n file.write full_text\n end\n end\n end", "def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end", "def seed_file(file, adjective)\n text=File.open(file).read\n text.each_line do |line|\n if Word.where(word: line.chomp).empty?\n Word.create(word: line.chomp, adjective: adjective)\n end\n end\nend", "def fichier_de_donnees_pour(nb_items)\n \"testdata/#{nb_items}Words.txt\"\nend", "def text_file_scan_and_rewrite(my_file_name)\n\n textfile = File.open(my_file_name, 'r+') #open file for read/write\n\n all_lines_from_file = textfile.read #read all the records in the file\n\n if word_position = all_lines_from_file =~ /word/ #check for \"word\" and if found note position in string\n all_lines_from_file.insert(word_position, 'inserted ') #put \"inserted \" in front of \"word\"\n textfile.rewind #reset to beginning of file\n textfile.puts all_lines_from_file #write new data to file\n end\n textfile.close\nend", "def not_test_add_marks_to_a_file\r\n TextFormatter.add_para_marks_to_a_file(DIR_OF_NEW+File::SEPARATOR+\r\n \tFILE_7) \r\n end", "def potential_lines(filename); end", "def read_word_file(file)\n\t\tFile.foreach(file) do |line|\n\t\t\tif(@@word.legal?(line.chomp)) # Check if current line/word is legal\n\t\t\t\tLEGAL_WORDS << line.chomp # Add line/word to array of legal words\n\t\t\tend\n end\n LEGAL_WORDS.freeze # Freeze LEGAL_WORDS to make it immutable\n\tend", "def add_line_to_file file_path,line\n return \"echo #{line} >> #{file_path}\"\n end", "def append(filepath, format = :to_s)\n # @formatter:off\n [\n self.public_send(format),\n Pathname.new(filepath).read.lstrip,\n ].join(\"\\n\")\n # @formatter:on\n end", "def add(word)\n @root.create_final_path(word.chars.reverse + [Path::DELIMITER])\n\n Word.new(word.chars).to_delimited_paths.each do |path|\n @root.create_final_path(path.letters)\n end\n\n self\n end", "def words\n scrabble_words = File.readlines(\"words.txt\")\n scrabble_words.map { |x| x.delete(\"\\n\") }\nend", "def main (max_char, prefix, suffix)\r\n # Variable Definitions\r\n input_folder = 'Original/' # Folder of original files\r\n output_folder = 'Wrapped/' # Folder of processed files\r\n file_name = '' # The name of the file (test.rb)\r\n file_path = '' # The path of the file (folder/test.rb)\r\n output_path = '' # The path of the output file\r\n original_arr = [] # The lines of the original file\r\n wordwrapped_arr = [] # The formatxted file lines\r\n # Check if USER VARIABLES are valid.\r\n check_user_variables()\r\n # Get the name of the file that will be word wrapped.\r\n file_name = get_input_file_name()\r\n # Concatenate the folder name and file name to give a path so that the\r\n # file can be searched for later.\r\n file_path = input_folder + file_name\r\n # Check that the file_path is valid, if not the program will exit.\r\n check_input_file(file_path)\r\n # Now that the file path is vaild, read the file contents and save to\r\n # the array.\r\n original_arr = read_input_file(file_path)\r\n # Check the original_arr and make sure that no comment line is longer than\r\n # the max specified \r\n wordwrapped_arr = word_wrap(original_arr, max_char)\r\n # Create a path for the output file to go\r\n output_path = create_output_path(output_folder, file_name, prefix, suffix)\r\n # Write the formatted array to the output file\r\n write_formatted_file(wordwrapped_arr, output_path)\r\n puts(\"Formatting Succeded.\")\r\nend", "def initialize\n self.word_list = []\n WORD_FILES.each do |word_file|\n contents = File.read(File.dirname(__FILE__)+word_file)\n self.word_list = word_list + contents.split(/\\n/)\n end\n end", "def normal_line(text)\n end", "def add_file(file) \n puts \"Reading file #{file}\" if ( $VERBOSE )\n words = Words.parse_file(file)\n if ( $VERBOSE )\n puts \"Read in #{words.length} words.\"\n puts \"Inserting words from file #{file}\"\n STDOUT.flush()\n end\n @mc.add_elems(words)\n end", "def space_file_parser\n @space_names = File.open(\"text_files/space.txt\").readlines.each do |line|\n if line.include?(\"\\n\")\n line.gsub!(/\\n/, '')\n else\n line\n end\n end\nend", "def create(filename, text); end", "def words_from_file(text_file)\n File.read(text_file).downcase.gsub(/[^a-z]/, \" \").split\nrescue\n puts \"Please provide the following file: #{text_file}\"\n exit\nend", "def words_from_file(text_file)\n File.read(text_file).downcase.gsub(/[^a-z]/, \" \").split\nrescue\n puts \"Give me #{text_file} and let's get the party started!\"\n exit\nend", "def create_dict(file)\n # Since wordlist is constant\n if File.file?(file)\n IO.readlines(file, chomp: true)\n else\n puts 'File not found!'\n end\n end", "def lex_en_interp_backslash_delimited_words; end", "def lex_en_interp_backslash_delimited_words; end", "def lex_en_interp_backslash_delimited_words; end", "def words_from_file(text_file)\n File.read(text_file).downcase.gsub(/[^a-z]/,\" \").split\nrescue\n puts \"Give me #{text_file} and let's get the party started\"\n exit\nend", "def add_sentence_to_catalogue_if_unique(template) # <= String\n all_sentences = File.readlines(\"sentences.txt\")\n unless all_sentences.include? \"#{template}\\n\"\n File.open(\"sentences.txt\", \"a+\") do |file|\n file << \"#{template}\\n\"\n end\n end\nend", "def load_lines file\n\n\t\tlines = Array.new\n\t\tlines = @file.split(\"\\n\")\n\n\t\t#fuck that, i dont like the dyanmic feed, just pre-parse it\n\t\tlines.map! do |line| #map overwrites the old array\n\t\t\tif line.include? '#'\n\t\t\t\tsplit = line.split '#'\n\t\t\t\t#puts split.to_s\n\t\t\t\tsplit.shift\n\t\t\telse\n\t\t\t\tline\n\t\t\tend\n\t\tend\n\n\t\t#removing blank lines\n\t\tlines.delete_if do |line|\n\t\t\ttrue if line.empty?\n\t\tend\n\n\t\tlines.each { |line| line.chomp! }\n\n\t\tlines\n\tend", "def lex_en_plain_backslash_delimited_words=(_arg0); end", "def lex_en_plain_backslash_delimited_words=(_arg0); end", "def lex_en_plain_backslash_delimited_words=(_arg0); end", "def words_from_file( f )\n result = Array.new\n File.foreach( f ) do | line |\n result << self.words_from_string( line )\n end\n result.flatten\n end", "def thaw_line(n, words, line_offset)\n line = \"\"\n line_length = words.size\n content_offset = line_offset\n okay = true\n loop do\n word = words.at(content_offset)\n break unless word\n ch_count = 5\n if line==\"\"\n if good_descriptor?(word)\n line_length = line_length(word)\n ch_count = 3\n else\n error \"Shard #{n}: Bad descriptor at #{content_offset}: #{word.inspect}\"\n okay = false\n end\n end\n chs = decode_characters(word, ch_count)\n if chs =~ /^(.*\\r).*$/\n line += $1\n break\n end\n line += chs\n content_offset += 1\n end\n return [content_offset, nil, false] unless line =~ /\\r/\n [content_offset, line, okay]\n end", "def add_file(path)\n File.readlines(path).each { |s| self << s.strip }\n nil\n end", "def unixWords(inputFile)\n\t\ttext = File.open(inputFile).read\n\t\twords = []\n\t\ttext.each_line do |line|\n\t\t\twords.push(line.gsub(\"\\n\",\"\"))\n\t\tend\n\t\treturn words\n\tend", "def filename\n \"words.txt\" if original_filename\n end", "def set_word_list\n word_list = []\n min_length = 5\n max_length = 12\n # Fixed external word_list file has only one word per line\n if File.exist? \"../word_list.txt\"\n File.open(\"../word_list.txt\").each do |line|\n line_clean = line.chomp\n if (line_clean.length >= min_length && line_clean.length <= max_length)\n word_list.push(line_clean)\n end\n end\n else\n word_list.push(\"FileWordListTextDoesNotExist\")\n end\n return word_list\n end", "def lex_en_plain_backslash_delimited; end", "def lex_en_plain_backslash_delimited; end", "def lex_en_plain_backslash_delimited; end", "def import\n print 'Import filename: '\n $stdout.flush\n file = gets.chomp\n fd = File.new(file, \"r\")\n itecky = file.rindex('.')\n raise 'missing dot in filename' if itecky == nil\n fname = file[0,itecky]\n fname.upcase!\n puts\n fd.each do\n |row|\n if row.strip.length == 0 or row[0,1] == '*' or row[0,1] == '#'\n next\n end\n row.chomp!\n items = row.split # deleni row na polozky oddelene mezerou\n nitems = items.length # pocet polozek\n raise \"only one word on the line\\n[#{row}]\" if nitems == 1\n if nitems == 2 # slovicka bez oddelovaci carky\n en = items[0]\n cz = items[1]\n else # slovicka a fraze s oddelovaci carkou\n i = row.index(' - ') # oddelovac anglickeho a ceskeho vyrazu\n raise \"missing ' - ' between English and Czech phrases\\n[#{row}]\" if i == nil\n en = row[0,i+1].strip # prvni cast radku - anglicka\n cz = row[i+3..-1].strip # druha cast radku - ceska\n end\n flag = false\n for iw in 0 ... $words.length do\n if $words[iw].fname == fname and\n ($words[iw].english == en or $words[iw].czech == cz) then\n flag = true\n break\n end\n end\n if flag == true then next end\n $words << Word.new(fname,0,0,en,cz)\n w = konverze($words.last.english + ' | ' + $words.last.czech)\n puts w\n end\n puts\n $stdout.flush\nend", "def separator(fname)\n f = File.open(fname)\n enum = f.each_char\n c = enum.next\n loop do\n case c[/\\r|\\n/]\n when \"\\n\" then break\n when \"\\r\"\n c << \"\\n\" if enum.peek == \"\\n\"\n break\n end\n c = enum.next\n end\n c[0][/\\r|\\n/] ? c : \"\\n\"\n end", "def add_word(word)\n word_hash = Digest::SHA1.hexdigest(word)\n word_file_path = ROOT_DATA_FOLDER + word_hash\n word_file = File.open(word_file_path, 'a+')\n words = word_file.readlines\n words.each {|word| word.sub! \"\\n\", ''} # remove trailing \\n\n word_index = words.index(word)\n\n if word_index.nil? # add new word to end of file with count = 1\n add_line_to_file(word_file_path, word)\n add_line_to_file(word_file_path, '1')\n else # add count to existing word by replacing count line in file\n word_count = words[word_index + 1].to_i\n add_line_to_file(word_file_path, (word_count + 1).to_s, word_index + 1)\n end\n word_file.close\n end", "def dictionary(dictionary_name)\n new_dictionary = File.open('diccionario.txt').read.split(\"\\n\")\n words = []\n new_dictionary.each do |e|\n words << e\n n = \"\"\n for i in 1..3\n n = n + i.to_s\n words << e + n\n end\n end\n File.write(\"#{dictionary_name}.txt\", words.join(\"\\n\"))\nend", "def initialize(word_list_file_path)\n word_list = ::File.readlines(word_list_file_path).map(&:chomp)\n @words = word_list.map(&:downcase)\n end", "def add_entry\n new_content = file_content MY_HOSTS_FILE\n open(HOSTS_FILE, 'a') do |f|\n f << \"\\n#{new_content}\\n\"\n end\nend", "def process_route(args, file_path)\n File.open(file_path, 'a') do |f|\n # write to file\n str = \"`#{args[0].upcase} #{args[1]}`\"\n f << str\n f << \"\\n\"\n end\n end", "def pick_catchphrase\n return File.readlines(File.dirname(__FILE__) + \"/static/catchphrases.txt\").sample.tr(\"\\n\",\"\")\nend", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def sub_line_ending_backslashes(file_text)\n backslash_replacement = '# TAILOR REMOVED BACKSLASH'\n file_text.gsub!(/\\\\\\s*\\n?$/, backslash_replacement)\n\n file_text\n end", "def parse_txt_file(filename)\n file_lines = []\n File.open(filename).each do |line|\n file_lines << line.chomp\n end\n file_lines\nend", "def prePendText fileName, newTxt\n f = File.open(fileName, \"r+\")\n inLines = f.readlines\n f.close\n\n fileModDate = File.mtime(fileName)\n\n time = Time.new\n month = Date::MONTHNAMES[Date.today.month]\n dayName = Date.today.strftime(\"%A\")\n date = [\"#{dayName} #{time.year}-#{month}-#{time.day}\"]\n outLines = [\"#{date[0]}: #{newTxt}\\n\"]\n # If it is a new day, then insert a seperator.\n if fileModDate.year != time.year || fileModDate.month != time.month || fileModDate.day != time.day\n outLines += [\"***********************************************\\n\\n\"]\n end\n\n outLines += inLines\n output = File.new(fileName, \"w\")\n outLines.each { |line| output.write line }\n output.close\nend", "def comma_file_parser\n @comma_names = File.open(\"text_files/comma.txt\").readlines.each do |line|\n if line.include?(\"\\n\") # removes '\\n' (line breaker)\n line.gsub!(/\\n/, '')\n else\n line\n end\n end\nend", "def list_2_file (list,file)\n\t\tputs \"Save list #{list} to plain file #{file}\" if @verbose\n\t\tbegin\n\t\t\tf = File.open(file, \"w\")\n\t\t\tlist.map do |ent|\n\t\t\t\t#ent.strip!\n\t\t\t\t# Append the unix line break\n\t\t\t\tf.write(\"#{ent}\\n\")\n\t\t\tend\n\t\t\tf.close\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for file #{file}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend", "def splitByFile\n outfile = nil\n stream = open(@filename)\n until (stream.eof?)\n line = stream.readline\n\n # we need to create a new file\n if (line =~ /--- .*/) == 0\n if (outfile) \n outfile.close_write\n end\n #find filename\n tokens = line.split(\" \")\n tokens = tokens[1].split(\":\")\n tokens = tokens[0].split(\"/\")\n filename = tokens[-1]\n filename << \".patch\"\n if File.exists?(filename)\n puts \"File #{filename} already exists. Renaming patch.\"\n appendix = 0\n while File.exists?(\"#{filename}.#{appendix}\")\n appendix += 1\n end\n filename << \".#{appendix}\"\n end\n outfile = open(filename, \"w\")\n outfile.write(line)\n else\n if outfile\n outfile.write(line)\n end\n end\n end\n end", "def append_idea idea\n open(\"#{FileName}.txt\", 'a') do |file|\n file.puts idea\n end\n\n File.read(\"#{FileName}.txt\")\nend", "def iterate_several_file file_path\n #Iterate file line by line\n result_lines_in_file = []\n reg = /.*#{@phrase_we_have_now}.*/\n file = File.open(file_path, \"r\") do |f|\n f.each_line do |line|\n if line.match?(reg)\n result_lines_in_file << line\n end\n end\n end\n result_lines_in_file\n end", "def file_path\n \"#{Rails.root}/lib/banned_words.yml\"\n end", "def translator(file)\n #Opens the file\n text = File.read(file)\n #Check the content for any non vocals -> adds an o and the non vocal instead\n replace = text.gsub!(/([bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ])/, '\\1o\\1')\n #Replace the original content with translated content\n File.open(file, \"w\") {|z| z.puts replace}\nend", "def insert_words\n #Large words only insert length > 5\n # TODO: refine with loop\n File.open(@config['words_config'][0]['name'], 'r') do |file|\n insert_list = []\n file.each do |line|\n # Filter letters\n if /^[a-z-]+$/ =~ (line)\n line.chop!\n line = line.gsub('-', '')\n if line.length > 5\n insert_list.push(line.downcase)\n end\n insert_list.push(line.downcase)\n end\n # Too much insert values will got error, so insert in bucket\n if insert_list.length >= @config['insert_bucket'].to_int\n insert_values(insert_list)\n insert_list = []\n end\n end\n insert_values(insert_list)\n end\n\n #Tiny words only insert length <= 5\n File.open(@config['words_config'][1]['name'], 'r') do |file|\n insert_list = []\n file.each do |line|\n # Filter letters\n if /^[a-z-]+$/ =~ (line)\n line.chop!\n line = line.gsub('-', '')\n if line.length <= 5\n insert_list.push(line.downcase)\n end\n end\n # Too much insert values will got error, so insert in bucket\n if insert_list.length >= @config['insert_bucket'].to_int\n insert_values(insert_list)\n insert_list = []\n end\n end\n insert_values(insert_list)\n end\n end", "def readlines(sep=$/) end", "def read_file\n\t\t\treturn 'wordlists/reverse_ip.txt'\n\t\tend", "def readlines(sep=$/) end", "def load_file(path)\n file_array = IO.readlines(path)\n file_array.map {|element| element.chomp}\nend", "def test_file_append()\n\t\t# test the empty file\n\t\tCfruby::FileEdit.file_append(@emptyfilename, \"new line\")\n\t\tlines = File.open(@emptyfilename, File::RDONLY).readlines()\n\t\tassert_equal(1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\n\t\t\n\t\t# test the multiline file\n\t\tCfruby::FileEdit.file_append(@multilinefilename, \"new line\")\n\t\tlines = File.open(@multilinefilename, File::RDONLY).readlines()\n\t\tassert_equal(@multilinefilecontents.split(\"\\n\").length+1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\t\t\n\tend", "def createBoard file\n\n\tbegin\n\t\tlines = IO.readlines(template)\n\t\n\trescue Exception => e\n\t\tputs e.message\n\t\tputs e.backtrace.inspect\n\tend\t\n\nend", "def load(fn) # :nodoc:\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, \" \")\n lines.each_line do |line|\n process_line(line)\n end\n end", "def pipe_file_parser\n @pipe_names = File.open(\"text_files/pipe.txt\").readlines.each do |line|\n if line.include?(\"\\n\")\n line.gsub!(/\\n/, '')\n else\n line\n end\n end\nend", "def load_words(file_name)\n words_loaded = []\n File.open(file_name).readlines.each do |line|\n words_loaded << line if line.length.between?(5, 12)\n end\n words_loaded\n end", "def import_ori(file_path)\n string = IO.read(file_path)\n array = string.split(\"\\n\")\n array.shift\n return array\n end", "def file_content\n self.lines.join\n end", "def file_to_a file_path_str, delimiter=\"\\n\"\n File.read(file_path_str).lines(separator=delimiter)\n end", "def find_custom\n File.open(@file, 'r') do |r|\n k = []\n k[0] = nil\n while line = r.gets do\n name_count = @name.count(\"A-z, \\s\")\n k << line[0..name_count]\n this_name = k.last\n \n if this_name == @name+\" \"\n selected_line = line\n the_name = this_name\n end\n end\n if selected_line == nil\n puts \"Shortcut not found '@#{@name}'\"\n exit 1\n else\n the_name_count = the_name.count(\"A-z, \\s\")\n line_count = selected_line.count(\"A-z, \\s, '/'\")\n selected_line[the_name_count..line_count-1]\n end\n end\n end", "def newline_check(file_name)\n # check if the file has no newline or multiple newlines\n lines = File.open(file_name, 'r').to_a\n # if the last character of the last line with code is a newline character AND there is additional text on that line, set hasSingleNewline to true; otherwise set it to false\n hasSingleNewline = lines.last[-1] == \"\\n\" && lines.last.length > 1\n # if there isn't already a single newline at the end of the file, call the process(text) method to add one in (or delete multiple ones and add a newline in)\n if !hasSingleNewline\n text = File.read(file_name)\n # re-write the file with the final file text returned by the process(text) method\n File.open(file_name, \"w\") { |file| file.puts process(text) }\n end\nend", "def process_lit_doc_lines(files_and_header_sizes, generated_file_path)\n files_and_header_sizes.each do |entry|\n entry[:file][:lines].each do |line|\n args = line.split(' ')\n\n File.open(generated_file_path, 'a') { |f| f << \"\\n\" }\n\n # args.shift(2) = remove first 2 entries in array\n case args[1]\n when '@h:'\n args.shift(2)\n header_size = entry[:file][:sizes][:h]\n process_header(args, generated_file_path, header_size)\n when '@r:'\n args.shift(2)\n process_route(args, generated_file_path)\n when '@b-model:'\n args.shift(2)\n process_body_model(args, generated_file_path)\n when '@res-model:'\n args.shift(2)\n process_response_model(args, generated_file_path)\n when '@b-serializer:'\n args.shift(2)\n process_body_serializer(args, generated_file_path)\n when '@res-serializer:'\n args.shift(2)\n process_response_serializer(args, generated_file_path)\n else\n args.shift\n process_markdown(args, generated_file_path)\n end\n end\n end\n end", "def load(fn)\n return if ! File.exists?(fn)\n lines = File.read fn\n lines.gsub!(/\\\\ /, SPACE_MARK)\n lines.gsub!(/#[^\\n]*\\n/m, \"\")\n lines.gsub!(/\\\\\\n/, ' ')\n lines.each_line do |line|\n process_line(line)\n end\n end", "def wordlist\n # Split defaults to splitting on white space\n File.read(File.expand_path('../data/subdomains.txt', __FILE__)).split\n end", "def get_spelling_words(file)\n lines = IO.readlines(file).map(&:chomp)\n review_word = false\n challenge_word = false\n words = []\n lines.each do |line|\n if md=line.match(/\\A(\\d+)\\.\\s+(\\w+)\\Z/)\n (num, word) = md.captures\n words << SpellingWord.new(num, word, review_word, challenge_word)\n elsif line.match(/\\AReview Words/)\n review_word = true\n challenge_word = false\n elsif line.match(/\\AChallenge Words/)\n challenge_word = true\n review_word = false\n end\n end\n words\nend", "def append_answer(pattern,template)\n # add new category in custom answers\n custom_path = \"#{Rails.root}/lib/aiml/custom_answers.aiml\"\n new_category = <<-CATEGORY\n <category>\n <pattern>#{pattern}</pattern>\n <template>\n #{template}\n </template>\n </category>\n </aiml>\nCATEGORY\n\n # remove last empty line\n file = File.open(custom_path)\n File.write(file, File.readlines(file).reject { |s| s.strip.empty? || s==\"\\n\" }.join)\n file.close\n # read lines, and replace last line\n lines = File.readlines(custom_path)\n lines[-1] = new_category << $/\n File.open(custom_path, 'w') { |f| f.write(lines.join); f.close }\n end", "def word_count_a_file(file_path)\n File.read(file_path).split(' ').length\n # had to create the file, text taken from https://www.lipsum.com/feed/html\nend", "def write_lines file_path, new_lines\n File.open(file_path, 'w') do |file|\n new_lines.each do |new_line|\n file.puts new_line\n end\n end\n end", "def LoadFile ()\n\t\n\tinput = \"\"\n\tFile.foreach(\"../Data Files/042-Words.txt\") {|x| input = x }\n\tnames = input.split(\",\")\n\t\n\treturn names;\nend", "def delegate_word(node)\n\tFile.open(\"input.txt\", \"r\").each_line do |l|\n\t\tline = l.downcase[0..-2].split(\"\")\n\t\t#For adding\n\t\tif(node.word.length + 1) == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\t\t#For removing\n\t\tif(node.word.length - 1) == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\t\t#For substiting\n\t\t#Checking to make sure they are the same length\n\t\tif node.word.length == line.length\n\t\t\tcompare_words(node, line)\n\t\tend\n\tend\nend", "def read_content(file)\n\t\tcontent = []\n\t\tfile.each do |f|\n\t\t\tif File.file?(f)\n\t\t\t\tFile.open(f, \"r\") do |f|\n\t\t\t\t\tword = \"\"\n\t\t\t\t\tf.each_line do |line|\n\t\t\t\t\t\tword += \"#{line}\"\n\t\t\t\t\tend\n\t\t\t\t\tcontent += [word]\n\t\t\t\tend\n\t\t\tend\t\t\t\n\t\tend\n\t\treturn calculate_content(content)\n\tend" ]
[ "0.64177763", "0.6314846", "0.62469465", "0.6236361", "0.621271", "0.61707276", "0.60696256", "0.59244746", "0.5914247", "0.5788779", "0.57681394", "0.5758809", "0.57059145", "0.57059145", "0.57059145", "0.5668894", "0.56483287", "0.5629003", "0.56061846", "0.55933905", "0.5569749", "0.5565213", "0.55524874", "0.5541626", "0.5533701", "0.5531477", "0.55246854", "0.5501151", "0.5486839", "0.5485249", "0.54732823", "0.5471141", "0.5462602", "0.5456758", "0.54550487", "0.5408228", "0.5407378", "0.5390367", "0.5390367", "0.5390367", "0.5390007", "0.53590834", "0.53580195", "0.53525245", "0.53525245", "0.53525245", "0.5349677", "0.5341089", "0.5337716", "0.5330517", "0.53169465", "0.53036976", "0.52822036", "0.52822036", "0.52822036", "0.5275207", "0.52623075", "0.5258846", "0.52551854", "0.5250369", "0.5247517", "0.52405417", "0.52111846", "0.520637", "0.520637", "0.51982933", "0.51931524", "0.51765597", "0.5170596", "0.51639116", "0.5161043", "0.5156655", "0.5152391", "0.51521295", "0.51504064", "0.5136781", "0.51262546", "0.5126029", "0.5125062", "0.51187485", "0.51151717", "0.51114154", "0.5101553", "0.50998867", "0.50910866", "0.50842535", "0.5079775", "0.5076006", "0.50497574", "0.5044643", "0.50415784", "0.5041316", "0.50410783", "0.5039887", "0.5038912", "0.50342315", "0.5033248", "0.5013911", "0.50136155", "0.50129044" ]
0.50888014
85
Insert assets into a gallery or uploader
def insert @fieldname = params[:fieldname] @uploader_id = params[:uploader_id] @assets = Assetabler::Asset.find(params[:asset_ids]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_assets\n num_files = params[:count].to_i\n \n @new_assets = []\n @new_assets_html = []\n num_files.times do |file_num|\n # recreate the file key from the current index\n file = params[\"file-\"+file_num.to_s]\n @asset = Asset.new(:name => file.original_filename)\n @asset.save\n @asset.save_file(file)\n \n @new_assets.push(@asset)\n # render the html to add to the page for the json response\n asset_html = render_to_string :partial => \"shared/asset.html.haml\", :locals => { :asset => @asset }\n @new_assets_html.push(asset_html)\n end\n\n respond_to do |format|\n format.html { redirect_to assets_url, notice: 'Asset was successfully created.' }\n format.json { render json: {:assets => @new_assets, :assets_html => @new_assets_html, status: :created} }\n end\n\n end", "def add_asset_to_stage\n if !params[:asset_ids].nil?\n @stage = Stage.find(session[:stage_id])\n asset_set = Set.new\n params[:asset_ids].each do |asset_id|\n asset_set.add(Asset.find(asset_id.to_i))\n end\n asset_set.each do |new_asset|\n @stage.assets.each do |current_asset|\n if current_asset.id == new_asset.id\n asset_set.delete(new_asset)\n break\n end\n end\n end\n \n asset_set.each do |asset|\n @stage.assets << asset\n end\n \n if @stage.save\n redirect_to :back, :notice =>\"Successfully added to the stage.\"\n else\n redirect_to :back, :error => \"Assets were not added to the stage.\"\n end\n else\n redirect_to :back, :alert => \"No assets were selected\"\n end\n end", "def attach_assets(content, thumbnail_url, poster_url, video_url)\n content.thumbnail.attach(io: open(thumbnail_url), filename: \"#{content.title.split.join}.jpeg\")\n content.poster.attach(io: open(poster_url), filename: \"#{content.title.split.join}poster.jpeg\")\n content.video.attach(io: open(video_url), filename: \"#{content.title.split.join}.mp4\")\nend", "def image_library\n @title = \"Insert image\"\n # Only interested in images\n get_files(params.merge({:key => 'Image'}))\n render :layout => 'admin_modal'\n end", "def bulk_upload_assets_interface\n user_id = current_user.id\n if !(UsersTagsDb.find_by_user_id(user_id).present?)\n logger.info \"#{'*'*30}No Tags Db Assigned.\"\n redirect_to :back, notice: \"No Tags DB is assigned.\"\n return\n end\n db = UsersTagsDb.find_by_user_id(current_user.id).tags_db\n logger.info \"Unavailable Meta Tags Session: #{session[:unavailable_meta_tags]}\"\n flash[:notice] = params[:notice] if params[:notice].present?\n @vdo_upload = VdoUpload.new\n end", "def insert_image_params\n unless @check_migration\n insert_into_file \"app/views/admin/images/insert.html.erb\",\n :after => 'image_dialog.init(<%= @callback.present? ? \"self.parent.#{@callback}\" : \"null\" %>' do\n \", '<%= params[:chunk] %>'\"\n end\n end\n end", "def assets; end", "def assets; end", "def assets; end", "def create_assets(groups, paths)\n paths.map do |path|\n file = File.open(dir + path)\n asset = Asset.choose_type(path.split('.').last)\n if path.include?('/')\n path, name = path_and_name(path)\n group = groups[path]\n else\n group = parent_group\n end\n asset.updater = Thread.current[:current_user]\n asset.creator = Thread.current[:current_user]\n asset.update_attributes(:file => file, :name => name, :asset_group_id => group.id)\n asset\n end\n end", "def add_assets(paths)\n copy_assets(paths)\n characterize_assets\n create_or_update_assets\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n \n if params[:avatars]\n #===== The magic is here ;)\n params[:avatars].each { |avatar|\n @location.assets.create(avatar: avatar)\n }\n end\n\n format.html { redirect_to @location, notice: 'Gallery was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\nend", "def add_to_asset_box(box, *items)\n box = (box.present? ? box.to_s : 'assets')\n boxes = box.pluralize\n items = [items].flatten.compact\n\n if items.present? && items.any? { |obj| !obj.kind_of?(Effective::Asset) }\n raise ArgumentError.new('add_to_asset_box expects one or more Effective::Assets, or an Array of Effective::Assets')\n end\n\n if box == boxes # If we're adding to a pluralized box, we want to add our attachment onto the end\n pos = attachments.select { |attachment| attachment.box == boxes }.last.try(:position).to_i + 1\n else # If we're adding to a singular box, we want our attachments to be on the front\n pos = attachments.to_a.find { |attachment| attachment.box == boxes }.try(:position).to_i\n\n # Push all the attachments forward\n attachments.each { |att| att.position = (att.position + items.length) if att.box == boxes }\n end\n\n # Build the attachments\n items.each_with_index do |item, x|\n attachment = self.attachments.build(:position => (pos+x), :box => boxes)\n\n attachment.attachable = self\n attachment.asset = item\n end\n\n attachments.to_a.sort_by! { |attachment| attachment.position }\n\n true\n end", "def complete_upload_image\n @dom_id = \"##{params[:photo][:dom_id]}\"\n\n @asset = Image.new(uploaded_asset_attributes.reverse_merge(uploaded_by: current_user))\n @asset.add_meta(params[:photo])\n @asset.save\n render template: \"/dash/chooser/complete_upload\"\n end", "def assets=(_arg0); end", "def assets=(_arg0); end", "def assets=(_arg0); end", "def create\n #debugger\n blog = blog_params[:name]\n @user = User.find(session[:user_id])\n\n params[:image][:attached_assets_attrs].each do |item|\n ImgGroup.post item[:asset], @user, blog\n end\n\n respond_to do |format|\n format.html { render action: 'done' }\n format.json { render text: 'All posted.', status: :created, location: @image }\n end\n end", "def insert\n @url_override = refinery.admin_images_path(request.query_parameters.merge(:insert => true))\n \n render :action => \"insert\"\n end", "def assets_for_post(assets)\n html, files, images = %(), %(), %()\n unless assets.empty?\n assets.each do |asset|\n if asset.same_type?('jpg') || asset.same_type?('png') || asset.same_type?('gif') || asset.same_type?('jpeg') \n images << build_list_assets_by_type_to_post(asset)\n elsif asset.same_type?('rar') || asset.same_type?('zip') || asset.same_type?('pdf') || asset.same_type?('txt')\n files << build_list_assets_by_type_to_post(asset, asset.type)\n end\n end \n end\n html << content_tag(:h3, \"Galeria de imagens\")\n html << content_tag(:ul, images.html_safe, :class => 'thumbnails gallery') unless images.empty?\n html << \"<hr />\".html_safe\n html << content_tag(:h3, \"Arquivos relacionados\")\n html << content_tag(:ul, files.html_safe, :class => 'thumbnails') unless files.empty?\n html.html_safe\n end", "def attach_files\n @parent = Work.find_by_friendlier_id!(params[:parent_id])\n authorize! :update, @parent\n\n current_position = @parent.members.maximum(:position) || 0\n\n files_params = (params[:cached_files] || []).\n collect { |s| JSON.parse(s) }.\n sort_by { |h| h && h.dig(\"metadata\", \"filename\")}\n\n files_params.each do |file_data|\n asset = Asset.new()\n\n if derivative_storage_type = params.dig(:storage_type_for, file_data[\"id\"])\n asset.derivative_storage_type = derivative_storage_type\n end\n\n asset.position = (current_position += 1)\n asset.parent_id = @parent.id\n asset.file = file_data\n asset.title = (asset.file&.original_filename || \"Untitled\")\n asset.published = @parent.published\n asset.save!\n end\n\n if @parent.representative_id == nil\n @parent.update(representative: @parent.members.order(:position).first)\n end\n\n redirect_to admin_work_path(@parent.friendlier_id, anchor: \"nav-members\")\n end", "def push_assets\n PUSH_ASSETS\n end", "def copy_assets; end", "def uploading_pictures\n end", "def add_content_asset(url, folder = nil)\n content_assets = self.mounting_point.resources[:content_assets]\n\n if (url =~ /^https?:\\/\\//).nil?\n url = URI.join(self.uri_with_scheme, url)\n else\n url = URI(url)\n end\n\n asset = Locomotive::Mounter::Models::ContentAsset.new(uri: url, folder: folder)\n\n content_assets[url.path] = asset\n\n asset.local_filepath\n end", "def add_content_asset(url, folder = nil)\n content_assets = self.mounting_point.resources[:content_assets]\n\n if (url =~ /^https?:\\/\\//).nil?\n url = URI.join(self.uri_with_scheme, url)\n else\n url = URI(url)\n end\n\n asset = Locomotive::Mounter::Models::ContentAsset.new(uri: url, folder: folder)\n\n content_assets[url.path] = asset\n\n asset.local_filepath\n end", "def upload\r\n \r\n end", "def add_asset_files(options)\n select_assets(options).each do |name, assets|\n next if name == 'config-file'\n assets.each {|file| file.add unless file.disabled? }\n end\n end", "def multiupload\n # this will be trigger the each time when a file is upload \n # binding.pry\n @ringtone = Ringtone.new\n a = params[:attachment].as_json()[0]\n @ringtone.name = a['original_filename']\n @ringtone.attachment = params[:attachment][0] # use console to look it \n @ringtone.tag_list = \"ToDo\"\n # binding.pry\n @ringtone.save\n \n respond_to do |format|\n format.js\n end\n end", "def create\n @asset = OtherAsset.new(params[:asset])\n asset_create('other', others_url)\n end", "def import(path)\n @path = path\n\n id = @media_asset.media_asset_id\n ext = @media_asset.extension.dup.downcase\n out_path = Aurita.project_path(:public, :assets, \"asset_#{id}.jpg\")\n \n @@logger.log \"Import #{path}, Image id: #{id}, extension: #{ext}\"\n @@logger.log \"Output path: #{out_path}\"\n begin\n # img = QuickMagick::ImageList.new(path) \n img = QuickMagick::Image.read(path) { |image| image.density = 150 }\n\n img = img.first if img.respond_to? :first\n img.write(out_path)\n rescue ::Exception => e\n @@logger.log \"IMAGE UP | Error: #{e.message} when trying to import file #{path}\"\n raise e\n end\n\n @media_asset[:width] = img.columns.to_i\n @media_asset[:height] = img.rows.to_i\n if img.rows.to_i > 0 then # prevent DbZ\n @media_asset[:ratio] = img.columns.to_f / img.rows.to_f\n end\n @media_asset.commit\n end", "def attach_multiple_images\n image_set = [image_path + 'book1.jpg',\n image_path + 'classic1.jpg',\n image_path + 'dolph1.jpeg',\n image_path + 'nat2.jpeg',\n image_path + 'nat5.jpeg',\n image_path + 'nat15.jpeg']\n\n js_script = 'fileList = Array();'\n image_set.count.times do |i|\n @page.execute_script <<-JS\n (\"fakeFileInput = window.$('<input/>').attr({id: 'fakeFileInput', name: 'file', type:'file', }).appendTo('body')\");\n JS\n @page.attach_file('file', image_set[i], visible: false)\n js_script = \"#{js_script} fileList.push(file#{i}.get(0).files[0]);\"\n end\n @page.execute_script <<-JS\n (\"var e = jQuery.Event('drop', { dataTransfer : { files : fileList } });$('.dropper')[0].dropper.listeners[0].events.drop(e)\");\n JS\n end", "def save\n if has_upload?\n @asset = Ingest::AssetFileAttacher.call(@asset, @upload)\n end\n\n @asset.save\n end", "def media_url_upload\n ar_object = Kernel.const_get(params[:ar_object_class]).find(params[:ar_object_id])\n ar_object.media_url = params[:media_url]\n if ar_object.save\n @messages = 'media updated'\n else\n @messages = 'Oups updating fleximage'\n ar_object.errors.each { |field, msg| puts \"********* field:#{field} --> #{msg}\" }\n end\n render :update do |page| \n page.replace(MainController.media_domid(ar_object),\n render(:partial => \"/main/media_editor\", :locals => {:title => params[:title], :ar_object => ar_object }))\n\t\tend\n end", "def add_asset(asset)\n @al_asset_group.addAsset(asset.al_asset)\n end", "def add_uploaded_file(shf_app)\n shf_app.uploaded_files << create(:uploaded_file, actual_file: File.open(UPLOAD_PNG_FILE))\n end", "def create\n @car = Car.find(params[:car_id])\n\n # This creates a single asset if the picture uploaded\n # is there is no multipart form_for in the html.erb\n #@asset = @car.assets.create(asset_params)\n\n # This creates assets for EACH image given a multipart\n # form_for assets in the html.erb\n num_images = asset_params[:image].size\n asset_params[:image].each_with_index do |image_asset, idx|\n image_num = idx + 1\n puts \"Adding image number #{image_num} / #{num_images}\"\n @asset = @car.assets.create({'image' => image_asset})\n\n # safety check\n break if image_num >= 500\n end\n\n redirect_to car_path(@car)\n\n end", "def image_url_upload\n ar_object = Kernel.const_get(params[:ar_object_class]).find(params[:ar_object_id])\n ar_object.image_file_url = params[:image_file_url]\n if ar_object.save\n @messages = 'fleximage updated'\n else\n @messages = 'Oups updating fleximage'\n ar_object.errors.each { |field, msg| puts \"********* field:#{field} --> #{msg}\" }\n end\n render :update do |page| \n page.replace(MainController.image_domid(ar_object),\n render(:partial => \"/main/image_editor\", :locals => {:title => params[:title], :ar_object => ar_object }))\n\t\tend\n end", "def add_files(*files)\n Rails.logger.info \"Adding #{files.map(&:upload_file_name).join(', ')} to bundle #{self.bundle_type}:#{self.id} in #{self.study.name}\"\n files.each do |file|\n file.update!(study_file_bundle_id: self.id)\n end\n additional_files = StudyFileBundle.generate_file_list(*files)\n self.original_file_list += additional_files\n self.save!\n Rails.logger.info \"File addition to bundle #{self.bundle_type}:#{self.id} successful\"\n end", "def add_file_to_database(name, path, size, owner)\n $db.execute(\"INSERT INTO files (owner_id, file_name, file_size, file_path, publicity) VALUES (?, ?, ?, ?, 0)\", [owner, name, size, path])\nend", "def before_save \n \n #\n # upload bundle image\n #\n if( @uploadfile )\n \n # clean up first all existing image files\n [\"jpeg\", \"gif\", \"png\"].each do |ext| \n f = fq_bundle_image_filename( ext )\n if File.exists?(f) \n File.delete(f)\n end\n end\n \n # write the upload file\n extention = @uploadfile.content_type.gsub(/^image\\//, '').downcase.chomp\n out = File.open( fq_bundle_image_filename( extention ), \"w\" )\n out.write( @uploadfile.read )\n out.close\n \n # integrate link in description\n desc = self.description \n # filter operations can be inserted later on\n updated_img_lnk = \"[[File:#{bundle_resouce_file_name}.#{extention}]]\"\n desc = desc.gsub( /\\[\\[file:.*?\\.((jpeg)|(jpg)|(png)|(gif))\\]\\]/i, updated_img_lnk )\n if( ! $~ )\n # if not already matched add link tag to the end of the description field\n desc << \"\\n\" + updated_img_lnk\n end\n self.description = desc\n end\n\n\n #\n # copy prompt sample for bundle description (/upload/audio)\n #\n if( @sample_file_id )\n audio_source = AudioSource.find_by_file_id( @sample_file_id, :conditions => { :bundle_source_id=>self.id } )\n logger.info( @sample_file_id )\n if( audio_source )\n # copy file\n audio_source = audio_source.fq_mp3_filename\n audio_target = \"public/upload/audio/\" + bundle_resouce_file_name + \".mp3\"\n \n %x[cp #{audio_source} #{audio_target}]\n sample_prompt_file_tag = \"[[File:#{bundle_resouce_file_name}.mp3]]\"\n \n # integrate prompt sample in description\n desc = self.description\n desc = desc.gsub( /\\[\\[file:.*?\\.((mp3))\\]\\]/i, sample_prompt_file_tag )\n\n if( ! $~ )\n # if not already matched add link tag to the end of the description field\n desc << \"\\n\" +sample_prompt_file_tag\n end\n \n self.description = desc \n end\n end\n\n end", "def upload\n\n current_user_id = params[:current_user_id]\n print current_user_id\n filename = params[:Filename]\n print filename\n filedata = params[:Filedata]\n print filedata\n galleryname = params[:gallery_name]\n print galleryname\n\n # Construct the gallery if necessary\n gallery = Gallery.find_by_title(galleryname)\n if gallery.nil?\n gallery = Gallery.new\n gallery.title = galleryname\n gallery.person_id = current_user_id\n gallery.save\n end\n \n picture = Picture.new\n picture.picture_file_name = filename\n picture.picture_file_data = filedata\n picture.title = \"\"\n picture.person_id = current_user_id\n picture.gallery_id = gallery.id\n picture.save\n \n end", "def upload\n end", "def upload\n end", "def images_add\n\n\t\tis_marketplace_moder_or_admin = (current_user.is?(:moderator_products) or current_user.is_admin?)\n\t\t\n\t\tif(params[:files].blank? && (!is_marketplace_moder_or_admin or params[:upload_urls].blank? or params[:upload_ids].blank?))\n\t\t\trender :json => {'files' => [{'error' => 'Не указаны файлы для загрузки.'}]}\n\t\t\treturn\n\t\tend\n\n\t\tuploads = {}\n\t\tuploads[:bChanges] = false\n\t\tuploads[:images_max_num] = PRODUCT_IMAGE_MAX_FILE_COUNT\n\t\t\n\t\tif(@product[:photo_ids].present?)\n\t\t\tn = @product[:photo_ids].count\n\t\t\tif(n != 0)\n\t\t\t\tprod_imgs = ProductsImage.select('id').where(id: @product[:photo_ids]).limit(uploads[:images_max_num]).find_all\n\t\t\t\tnn = prod_imgs.size\n\t\t\t\tif(n != nn)\n\t\t\t\t\tif(nn == 0)\n\t\t\t\t\t\t@product[:photo_ids] = []\n\t\t\t\t\telse\n\t\t\t\t\t\t@product[:photo_ids] = prod_imgs.map{|p| p.id}\n\t\t\t\t\tend\n\t\t\t\t\tbChanges = true\n\t\t\t\t\tn = nn\n\t\t\t\tend\n\t\t\tend\n\t\t\tuploads[:images_max_num] -= n if(n <= 5)\n\t\tend\n\t\t\n\t\tif(uploads[:images_max_num] > 0)\n\t\t\t\n\n\t\telse\n\t\t\trender :json => {'files' => [{'error' => 'Превышено максимальное число изображений для товара.'}]}\n\t\t\treturn\n\t\tend\n\t\t\n\t\tif(uploads[:uploaded_json_list].blank?)\n\t\t\tuploads[:uploaded_json_list] = [{'files' => [{'error' => 'Никаких изменений не произошло.'}]}]\n\t\tend\n\n\t\tif(uploads[:bChanges])\n\t\t\tActiveRecord::Base.connection.execute(\"UPDATE seller_products SET photo_ids = (SELECT ARRAY(SELECT DISTINCT UNNEST(photo_ids || ARRAY#{@product[:photo_ids]}::int[]))) WHERE id = #{@product[:id]}\")\n\t\tend\n\t\t\n\t\tret = {:status => (uploads[:bChanges] ? 'ok' : 'error'), :files => uploads[:uploaded_json_list]}\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html {\n\t\t\t\trender :json => ret,\n\t\t\t\t:content_type => 'text/html',\n\t\t\t\t:layout => false\n\t\t\t}\n\t\t\t\n\t\t\tformat.json { \n\t\t\t\trender :json => ret\n\t\t\t}\n\t\tend\n\t\t\n\tend", "def new\n @asset = @uploadable.assets.new\n end", "def new\n @asset = @uploadable.assets.new\n end", "def attach_asset_and_enqueue\n\n Core.log(\"============= RETRIEVING ASSET FOR ##{self.id}\")\n begin\n design_url = URI.parse(self.asset_url)\n rand_id = rand(999999).to_s\n tempfile = \"#{Rails.root}/tmp/\" + rand_id + '.jpg'\n error_file = \"#{Rails.root}/tmp/#{self.product.id}-#{self.id}-#{self.order.id}-error\" + '.jpg'\n Core.log(\"********** Creating Tempfile #{tempfile} **************\")\n tries = 0\n\n begin\n http = Net::HTTP.new(design_url.host, design_url.port)\n use_ssl = (design_url.port == 443) ? true : false\n http.use_ssl = use_ssl\n http.open_timeout = 15\n http.read_timeout = 30\n \n if design_url.query.blank?\n path = design_url.path\n else\n path = design_url.path + \"?\" + design_url.query\n end\n \n Core.log(\"*********** Image URL: #{self.asset_url} ****************\")\n request = Net::HTTP::Get.new(path)\n response = http.request(request)\n \n if response.kind_of?(Net::HTTPRedirection)\n Core.log \"============= WE GOT REDIRECTED! =====================\"\n design_url = URI.parse(response['location'])\n Core.log(\"*********** Image URL: #{design_url} ****************\")\n raise \"WE_GOT_REDIRECTED\"\n end\n\n Core.log(\"============= HTTP response code: #{response.code.inspect}, HTTP message: #{response.message.inspect}\")\n open(tempfile, \"wb\") {|file| file.write(response.body)}\n\n rescue\n Core.log(\"============= In the rescue HTTP response: #{response.inspect}\")\n tries += 1\n Core.log(\"============= RETRY NUMBER #{tries.to_s}: ASSET RETRIEVAL FOR ##{self.id}\")\n retry if tries < 3\n Core.log(\"============= RETRY: giving up on ASSET RETRIEVAL FOR ##{self.id}\")\n Core.log(\"*************** Deleting Tempfile #{tempfile} ******************\")\n File.delete(tempfile)\n end\n\n File.open(tempfile, 'rb') { |design| self.asset = design }\n asset_width = Paperclip::Geometry.from_file(tempfile).width.to_i\n asset_height = Paperclip::Geometry.from_file(tempfile).height.to_i\n\n self.asset_dimensions = \"#{asset_width}x#{asset_height}\"\n self.save\n\n=begin\n if self.order.source.name.upcase == \"SHUTTERFLY\" || self.order.source.shutterfly_partner\n file_type = %x[identify -format '%m' \"#{tempfile}\"].gsub!(\"\\n\", \"\")\n if file_type == \"PDF\"\n #save a copy for jessa's color comparisons\n target = \"#{Rails.root}/public/assets/uploaded_pdfs/\" + self.order.id.to_s + \"-\" + self.id.to_s + \"-original.pdf\"\n Core.log(\"*************** Copying Tempfile #{tempfile} to uploaded_pdf file #{target}******************\")\n FileUtils.cp(tempfile, target)\n end\n end\n=end\n\n\n Core.log(\"*************** Deleting Tempfile #{tempfile} ******************\")\n File.delete(tempfile)\n\n # Drop the attached asset in the queue to generate manufacturable assets.\n Core.enqueue(self)\n\n rescue Exception => e\n #don't move this line below self.update_attribute...causes self to change to a different object\n self.order.set_status('Asset Error(s)')\n Rails.logger.info \"\\n\\n****=====***** image upload failed with this error: #{e.inspect} ****=====*****\\n\\n\"\n Core.log(\"============= ERROR RETRIEVING ASSET FOR ##{self.id}\")\n OrderStatus.create(:order_id => order.id, :status => \"Error fetching asset ##{id}\")\n self.update_attribute(:asset_errors, true)\n Core.log(\"*************** Renaming Tempfile #{tempfile} => #{error_file} ******************\")\n File.rename(tempfile,error_file)\n end\n\n end", "def set_assets\n\n @custom_csses = []\n @custom_javascripts = []\n\n\n action_hash = {\"create\" => \"new\", \"update\" => \"edit\"}\n file_name = action_hash[action_name] ? action_hash[action_name] : action_name\n root = Rails.root.to_s\n\n @custom_csses << \"compiled/application.css\" # always include the layout css\n @custom_csses << \"compiled/#{controller_name}/#{file_name}.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/#{file_name}.css\")\n @custom_csses << \"compiled/#{controller_name}/all.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/all.css\")\n\n\n @custom_javascripts << \"#{controller_name}/#{file_name}.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/#{file_name}.js\") # && !(\"#{file_name}.js\" == \"consumer_index.js\")\n @custom_javascripts << \"#{controller_name}/all.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/all.js\")\n\n # a trick to include facebox in the (devise-owned) registrations controller\n include_facebox if controller_name == 'registrations' && action_name == 'edit'\n\n end", "def upload(opts = {})\n options = {\n var: \"upload_#{@@upload_counter}\"\n }\n @@upload_counter += 1\n @parts.push(upload: options.merge(opts))\n end", "def create\n @asset = Asset.new(params[:asset])\n \n if @asset.save\n @asset = Asset.find(@asset.id)\n @asset.update_attributes(params[:asset])\n \n if @asset.asset_content_type.include? \"image\"\n respond_to do |format|\n format.html { render }\n format.js { \n responds_to_parent do\n render :update do |page|\n page.insert_html :top, \"assets_list\", :partial => 'admin/galleries/assets/excerpt', :locals => { :excerpt => @asset }\n page.call('gallery.AssetCreate');\n end\n end\n } \n format.xml { render :xml => @asset.to_xml(attr_hash) }\n format.json { render :json => @asset.to_json(attr_hash) }\n end\n else\n respond_to do |format|\n @message = t('asset_must_be_image')\n format.html { \n flash[:error] = @message\n render\n }\n format.js { render :text => @asset.errors.to_json, :status => :unprocessable_entity }\n format.json { render :json => {:message => @message}, :status => :unprocessable_entity }\n format.xml { render :xml => {:message => @message}, :status => :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n @message = t('asset_create_failed')\n format.html { \n flash[:error] = @message\n render\n }\n format.js { render :text => @asset.errors.to_json, :status => :unprocessable_entity }\n format.json { render :json => {:message => @message}, :status => :unprocessable_entity }\n format.xml { render :xml => {:message => @message}, :status => :unprocessable_entity }\n end\n end\n \n end", "def js_add_new_file(object)\n update_page do |p|\n p.insert_html :bottom, 'files', :partial => 'file', :object => object\n end\n end", "def add_photos(album, user, attachments)\n if attachments.count > 0\n last_photo = nil\n photos = []\n current_batch = UploadBatch.get_current_and_touch( user.id, album.id )\n attachments.each do |fast_local_image|\n photo = Photo.new_for_batch(current_batch, {\n :id => Photo.get_next_id,\n :user_id => user.id,\n :album_id => album.id,\n :upload_batch_id => current_batch.id,\n :caption => fast_local_image[\"original_name\"],\n #create random uuid for this photo\n :source_guid => \"perftest:\"+UUIDTools::UUID.random_create.to_s})\n # use the passed in temp file to attach to the photo\n #todo this doesn't actually do the right thing because a bulk insert does not write the child object photo_info\n photo.file_to_upload = fast_local_image['filepath']\n photos << photo\n last_photo = photo\n end\n\n # bulk insert\n Photo.batch_insert(photos)\n\n # this should remain since only used\n # for timing test an we want the batch closed\n # since they are grouped together\n last_photo.upload_batch.close_immediate\n end\n end", "def create_thumbnails()\n # {{{\n begin\n @@logger.log('IMAGE UP | Importing image')\n image_renderer = @@image_renderer.new(@media_asset)\n \n id = @media_asset.media_asset_id\n ext = @media_asset.extension.dup.downcase\n path = Aurita.project_path(:public, :assets, \"asset_#{id}.#{ext}\")\n \n @@logger.log(\"IMAGE UP | Path is #{path}\")\n # Every image needs a jpeg base image (esp. needed for PDF): \n STDERR.puts \"Importing #{path} using #{image_renderer.class.inspect}\"\n image_renderer.import(path)\n image_renderer.create_image_variants(@@variants)\n\n if ext == 'pdf' then\n image_renderer.create_pdf_preview()\n elsif @media_asset.is_video? then\n dest = Aurita.project_path(:public, :assets, \"asset_#{id}.jpg\")\n # File.open(source, 'w')\n # system \"ffmpeg -i #{path} -ar 22050 -ab 32 -acodec mp3\n # -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ dest }\"\n system(\"ffmpeg -i '#{path}' -ss 00:00:10 -vframes 1 -f image2 -vcodec mjpeg '#{dest}'\")\n ext = 'jpg'\n end\n rescue ::Exception => e\n STDERR.puts('Error when trying to create image versions: ' << e.message)\n e.backtrace.each { |m| \n STDERR.puts(m)\n }\n end\n end", "def upload_photos\n portfolio = Portfolio.find_by_id(params[:portfolio][:portfolio_id])\n if params[:portfolio][:images].present?\n portfolio.images += params[:portfolio][:images]\n portfolio.save(validate: false)\n flash[:success] = 'Photo added successfully!.'\n end\n redirect_to partner_portfolio_path\n end", "def update_asset_settings!\n AssetSettings[:development].files[@file_id] = @sfiles.map(&:local_url)\n return unless AssetMapper.compile?\n\n AssetSettings[:production].files[@file_id] = @cloud_files.map(&:production_url)\n AssetSettings[:production].files[@file_id] << @tfile.production_url if @tfile.production_url\n\n AssetSettings[:local_assets].files[@file_id] = @cloud_files.map(&:local_url)\n AssetSettings[:local_assets][@file_id] << @tfile.local_url if @tfile.local_url\n end", "def add_extra_files(*files); end", "def hook_add_files\n @flavor.class.after_add_files do |files, resource_action, type|\n files.each do |file|\n actions_taken << \"#{resource_action} #{type} #{file}\"\n end\n end\n end", "def upload\n files_saved = 0\n # Build product images from upload\n\t\tparams[:file].each do |i|\n if i[:file_data] && !i[:file_data].blank?\n new_file = UserUpload.init(i[:file_data])\n if new_file.save\n files_saved += 1\n end\n end\n end\n \n flash[:notice] = \"#{files_saved} file(s) uploaded.\"\n \n if params[:modal]\n redirect_to :action => 'image_library' and return\n else\n redirect_to :action => 'index' and return\n end\n end", "def upload_text_assets(pages, access)\n asset_store.save_full_text(self, access)\n pages.each do |page|\n asset_store.save_page_text(self, page.page_number, page.text, access)\n end\n end", "def upload_files\n files_to_upload = local_compiled_assets.reject { |f| exists_on_remote?(f) }\n files_to_upload.each do |asset|\n upload_file(asset)\n end\n end", "def complete_upload_document\n @dom_id = \"##{params[:file][:dom_id]}\"\n\n @asset = Document.new(uploaded_asset_attributes.reverse_merge(uploaded_by: current_user))\n key = @asset.add_meta(params[:file])\n if @asset.save\n @asset.update_columns(media: key)\n end\n render template: \"/dash/chooser/complete_upload\"\n end", "def create\n ActiveRecord::Base.transaction do\n @album = Album.create!(album_params)\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activerecord-import\n params[:urls].each do |image_url|\n AlbumImage.create!(album_id: @album.id, url: image_url)\n end\n end\n\n render json: @album\n end", "def update\n begin\n @post.update(post_params)\n if params[:assets_images]\n params[:assets_images].each { |image|\n # Crea la imagen a partir del data\n data = StringIO.new(Base64.decode64(image[:data]))\n data.class.class_eval { attr_accessor :original_filename, :content_type }\n data.original_filename = image[:filename]\n data.content_type = image[:content_type]\n @post.assets.create(file: data)\n }\n end\n render json: \"Post was successfully updated.\", status: :ok\n rescue\n render json: \"error\", status: :unprocessable_entity\n end\n end", "def insert_chunk_admin_js\n js_admin_path = \"public/javascripts/refinery/admin.js\"\n unless @check_migration\n insert_into_file \"#{js_admin_path}\",\"\\n, chunk: null\", :after => \", callback: null\"\n insert_into_file \"#{js_admin_path}\", \",chunk\", :after => \", init: function(callback\" \n insert_into_file \"#{js_admin_path}\",\"\\n\\t\\tthis.chunk = chunk;\", :after => \"this.callback = callback;\"\n insert_into_file \"#{js_admin_path}\", \", this.chunk\", :after => \"this.callback(img_selected\"\n end\n end", "def image_upload_prep(artist)\n\n bk_image_name = \"Three_Repeater-\"+artist.url_slug+\"-\"\n @bucket = IMAGE_BUCKET\n\n @image_save_location = artist_save_image_url(@artist.url_slug)\n\n logger.info(\"save image location\")\n logger.info(@image_save_location)\n\n #bk_image_uplosd\n @bk_image_upload = render_to_string('shared/_s3_upload_form_image', :locals => {:image_name => bk_image_name, :image_type => \"bk_image\", :image_save_url =>@image_save_location}, :layout => false)\n\n #logo Upload\n @logo_image_upload = render_to_string('shared/_s3_upload_form_image', :locals => {:image_name => bk_image_name, :image_type => \"logo\", :image_save_url => @image_save_location}, :layout => false)\n\n #profile image upload\n @profile_image_upload = render_to_string('shared/_s3_upload_form_image', :locals => {:image_name => bk_image_name, :image_type => \"profile\", :image_save_url => @image_save_location}, :layout => false)\n\n logger.info \"bk form\"\n logger.info @bk_image_upload\n\n logger.info \"image upload form\"\n logger.info @logo_image_upload\n\n\n end", "def import\n files\n @files.each {|file|\n Song.create_from_filename(file)\n }\n end", "def create\n #unsere art_ids sind leider nicht uniq, darum kümmern wir uns hier\n mod_params = gallery_params\n unless gallery_params[\"art_ids\"].is_a? String\n mod_params[\"art_ids\"] = gallery_params[\"art_ids\"].uniq!\n end\n\n if gallery_params[\"thumbUrl\"].to_s == \"\"\n #Wenn kein Thumb gewählt worden ist, nehmen wir einfach das erste Bild\n if mod_params[\"thumbArt\"].to_s.chars.length == 0\n mod_params[\"thumbArt\"] = Art.find(mod_params[\"art_ids\"].first.to_i).id\n end\n end\n #galleryeintrag erzeugen\n @gallery = Gallery.new(mod_params)\n @gallery.user = current_user.id.to_s\n if @gallery.save\n redirect_to galleries_url, notice: 'Gallery was successfully created.'\n else\n render :new\n end\n end", "def create_or_update_assets\n # All files in assets folder\n glob_path = File.join(clone_location, assets_subdirectory, \"*.{#{file_extensions.join(',')}}\")\n assets_paths = Dir.glob(glob_path) # full paths\n\n # Get jhove output in order to get the mime type and size for each asset.\n version_control_agent.get({ location: File.join(metadata_subdirectory, JHOVE_OUTPUT_FILENAME) }, clone_location)\n jhove_output = Bulwark::JhoveOutput.new(File.join(clone_location, metadata_subdirectory, JHOVE_OUTPUT_FILENAME))\n\n # Updating or creating asset record for each asset file\n assets_paths.each do |asset_path|\n filename = File.basename(asset_path)\n asset = assets.find_or_initialize_by(filename: filename)\n asset.original_file_location = version_control_agent.look_up_key(File.join(assets_subdirectory, filename), clone_location)\n asset.size = jhove_output.size_for(filename) # In bytes\n asset.mime_type = MIME::Type.simplified(jhove_output.mime_type_for(filename))\n asset.save!\n end\n\n # Removing references to files that have been removed.\n asset_filenames = assets_paths.map { |a| File.basename(a) }\n assets.each do |asset|\n asset.destroy unless asset_filenames.include?(asset.filename)\n end\n end", "def create\n if !has_right?(:create)\n redirect_to :unauthorized\n return\n end\n @video_gallery = VideoGallery.new(params[:video_gallery])\n create_new_objects(:property => params[:property],\n \t\t\t\t\t\t\t\t\t :image_storage => params[:image_storage],\n \t\t\t\t\t\t\t\t\t :asset => params[:asset],\n \t\t\t\t\t\t\t\t\t :resource => @video_gallery) ### Add to all resources\n end", "def create \n resource = resource_class.new(resource_params)\n \n\n if params[:gallery]['image'].nil?\n\n redirect_to :back , notice: \"Нельзя опубликовать галерею без фото! Добавьте фото\"\n return\n \n end\n \n\n if resource.save\n \n params[:gallery]['image'].each do |a|\n @gallery_attachments = resource.gallery_attachments.create!(:image => a)\n end\n\n redirect_to(\n [namespace, resource],\n notice: translate_with_resource(\"create.success\"),\n )\n else\n render :new, locals: {\n page: Administrate::Page::Form.new(dashboard, resource),\n }\n end\n \n end", "def insert_into_model\n unless @check_migration\n @columns = []\n @column_name.each do |column|\n @columns << \":\" + column.to_s + \" => image_data['#{column}']\"\n end\n \n # Insert into image model\n insert_into_file \"app/models/image.rb\", :after => \"image_accessor :image\\n\" do\n \"\\thas_many :#{@plural_name}_images\\n\" +\n \"\\thas_many :#{@plural_name}, :through => :#{@plural_name}_images\\n\"\n end \n \n # Insert into object model\n insert_into_file \"app/models/#{@name}.rb\", :after => \"ActiveRecord::Base\\n\" do\n \"\\n\\thas_many :#{@plural_name}_images\\n\" +\n \"\\thas_many :images, :through => :#{@plural_name}_images\\n\" +\n \"\\n\\tdef images_attributes=(data)\n #{plural_class_name}Image.delete_all(:#{@name}_id => self.id)\n data.each_with_index do | ( k, image_data ), i |\n if image_data['id'].present?\n image_gallery = self.#{@plural_name}_images.new(\n :image_id => image_data['id'].to_i, \n :position => i, \n :chunk => image_data['chunk'], \n #{@columns.join(', ')}\n )\n self.#{@plural_name}_images << image_gallery\n end\n self.touch\n end\n end\\n\"\n end \n end\n end", "def create\n @asset = Asset.new(asset_params)\n @asset_owner = User.all\n @category = Category.all\n if @asset.save\n if !@asset.image.present?\n render :js => \"window.location = '/site_assets'\"\n else\n redirect_to assets_path, notice: 'Asset was successfully created.'\n end\n else\n render 'create_failure'\n end\n end", "def upload_images(dir = nil)\n include Hermes::Upload\n @catalog = Catalog.default\n proc = lambda {|file, folder| upload_image(file, :folder => folder) }\n directory = dir || @catalog.source\n process_folder(directory, proc) \n end", "def create\n @asset = @uploadable.assets.new(asset_params)\n if request.path.include? \"rooms\"\n if @asset.save\n redirect_to venue_rooms_path\n else\n render :new\n end\n else\n if @asset.save\n redirect_to @uploadable, notice: \"asset created.\"\n else\n render :new\n end\n end\n end", "def create_images(product)\n self.image_labels.each_with_index do |label, position|\n\n self.image_file_extensions.each do |extension|\n file_name = self.image_path + value('image') + '_' + label + extension\n next unless File.exist?(file_name)\n\n types = []\n\n unless self.image_types[position].nil?\n types = product_attribute_set.asset_types.where(code: self.image_types[position].split(',').map(&:strip))\n end\n\n image = Asset.new\n image.product = product\n image.store = self.store\n image.position = position\n image.label = label\n image.set_file(File.open(file_name))\n\n types.each do |type|\n image.asset_types << type\n end\n\n # save without sync to format with paperclip\n image.sync_needed = false\n image.save\n\n # save with sync to push to magento\n image.sync_needed = true\n image.save\n end\n end\n end", "def insert_image(path)\n execute_applescript('insert_image', slides_count, File.absolute_path(path), TEMPLATE_SLIDE_INDEX)\n end", "def upload\n\n\t\t@uploads = Idea.find(params[:id]).uploads\n\t\t@idea = params[:id]\n\t\t@idea_obj = Idea.find(@idea)\n\n\t\t# allows user to delete files\n\t\t@delete = true\n\n\t\t@path = [link_to_ideas, link_to_idea_uploads(@idea_obj)]\n\t\t@subnavigation = [active_link_to_idea_uploads(@idea_obj), link_to_idea(@idea_obj), link_to_show_all_ideas(\"Alle Ideen\", \"title\", \"ASC\", \"\", 0, 30)]\n\tend", "def add_images(gallery_name, image_url_list = [\"http://testimages.drupalgardens.com/sites/testimages.drupalgardens.com/files/styles/media_gallery_large/public/150x62XMasNeon.gif\"],_browser = @browser)\n Log.logger.info(\"Adding New Images into the Gallery.\")\n add_media_action(gallery_name, image_url_list, _browser)\n end", "def import\n self.files.each{ |filename| Song.create_from_filename(filename) }\n end", "def add_images( record )\n\n #save_if_new\n\n # different versions have moved images around from Prod to Variant\n owner = DataShift::SpreeHelper::get_image_owner(record)\n\n get_each_assoc.each do |image|\n\n #TODO - make this Delimiters::attributes_start_delim and support {alt=> 'blah, :position => 2 etc}\n\n path, alt_text = image.split(Delimiters::name_value_delim)\n\n path = @options[:image_prefix] + path\n\n puts \"DEBUG : Creating attachment #{path} (#{alt_text})\"\n # create_attachment(klass, attachment_path, record = nil, attach_to_record_field = nil, options = {})\n attachment = create_attachment(@@image_klass, path, nil, nil, :alt => alt_text)\n\n owner.images << attachment\n\n logger.debug(\"Product assigned Image from : #{path.inspect}\")\n end\n\n record.save\n\n end", "def add_photo_from_system\n @photo = Picture.new(params[:photos])\n if @photo.save\n @group_ids = params[:group_ids]\n @group_ids.each do |grp|\n SharedTab.create(:shareable_id=>@photo.id,:group_id=>grp.to_i,:shareable_type=>\"Picture\")\n end if !@group_ids.blank?\n flash[:notice] = \"Photo added successfully.\"\n end\n flash[:notice] = @photo.errors.first[1] if !@photo.errors.blank?\n redirect_to :back\n\n end", "def stage\n\n @tempdir = Dir.mktmpdir\n\n begin\n\n # Copy the assets into the temp dir.\n files = Dir.glob(\"#{File.dirname(@file_path)}/#{@file_base}.*\")\n FileUtils.cp(files, @tempdir)\n\n # Change into the temp dir.\n FileUtils.cd(@tempdir) do yield end\n\n ensure\n\n # Delete the copies.\n FileUtils.remove_entry @tempdir\n\n end\n\n end", "def add_vendor_files\n say_quietly \"Copying files...\"\n\n %w[auth backend frontend].each do |section|\n template \"vendor/assets/javascripts/archangel/#{section}.js\"\n template \"vendor/assets/stylesheets/archangel/#{section}.css\"\n end\n end", "def image_upload_prep(artist,song)\r\n\r\n\t\tlogger.info(\"in image prep\")\r\n\t\tlogger.info artist\r\n\t\tlogger.info song\r\n\r\n\t\tsong_image_name = \"Three_Repeater-\"+artist.url_slug+\"-\"+song.id.to_s+\"-\"\r\n\t\t@bucket = IMAGE_BUCKET\r\n\r\n\t\t@image_save_location = song_save_image_url(artist.url_slug,song.id.to_s)\r\n\r\n\t\t#song_image_uplosd\r\n\t\t@song_image_upload = render_to_string('shared/_s3_upload_form_image', :locals => {:image_name => song_image_name, :image_type => \"song_image\", :image_save_url => @image_save_location}, :layout => false)\r\n\r\n\tend", "def upload f, photoset\n return if !is_supported?(f)\n \n id = @flickr.photos.upload.upload_file(f, f, \"\", Array.new,\n false, false, false)\n if photoset_exist? photoset\n set_id = get_photoset_id(photoset)\n @flickr.photosets.addPhoto set_id, id\n else\n @flickr.photosets.create photoset, id\n end\n end", "def import\n files.each do |e|\n Song.create_from_filename(e)\n end\n end", "def create\n # @asset = @attachable.assets.new(params[:asset])\n @asset = @attachable.assets.build(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html {\n render :json => [@asset.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: {files: [@asset.to_jq_upload]}, status: :created, location: @upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_media(db, mediatype, title, rentLease, mediaconsumed)\r\n\tdb.execute('INSERT INTO media (mediatype, title, rentLease, mediaconsumed) VALUES (?, ?, ?, ?)', [mediatype, title, rentLease, mediaconsumed])\r\nend", "def attachments=(atts)\n atts.each do |attachment|\n if attachment[:id].blank?\n assets.build(attachment)\n else\n asset = assets.detect { |a| a.id == attachment[:id].to_i }\n end\n end \n end", "def attachments=(atts)\n atts.each do |attachment|\n if attachment[:id].blank?\n assets.build(attachment)\n else\n asset = assets.detect { |a| a.id == attachment[:id].to_i }\n end\n end \n end", "def attachments=(atts)\n atts.each do |attachment|\n if attachment[:id].blank?\n assets.build(attachment)\n else\n asset = assets.detect { |a| a.id == attachment[:id].to_i }\n end\n end \n end", "def attachments=(attachments)\n attachments.each do |attachment|\n assets.build(attachment)\n end\n end", "def upload\n self._create params[:upfile], params[:pictitle]\n end", "def add_image(pic, img_loc_text, stock_images=nil)\n pic.photo = File.open(Rails.root.join('db', 'images', get_stock_image(img_loc_text, stock_images)))\n pic\n end", "def import\n self.files.each do |stringthing|\n Song.create_from_filename(stringthing)\n end\n end", "def insert_link (fileArray, linkName, utilHash)\n\nend", "def add_files(source, files)\n files.each do |f|\n source.upload_file(f) if File.file?(f)\n end unless files.nil?\n end", "def upload(src, item, modify)\n if modify then\n # this is usually a format change, which can only be set on create.\n # So delete then create.\n remove(item[:rid])\n end\n r = create(item[:alias], item[:format])\n raise \"Create Failed: #{r}\" unless r.nil?\n end", "def add_file(file)\n uploader_to_add = PostImageUploader.new\n uploader_to_add.cache!(file)\n @uploaders.delete_if { |x| x.filename == file.original_filename }\n @uploaders << uploader_to_add\n end" ]
[ "0.61756617", "0.6154996", "0.61383945", "0.6001432", "0.60004574", "0.59871066", "0.5963862", "0.5963862", "0.5963862", "0.5954183", "0.59353906", "0.59330684", "0.5869575", "0.5823433", "0.5820491", "0.5820491", "0.5820491", "0.57837665", "0.57716024", "0.57602334", "0.5738106", "0.57306045", "0.5724507", "0.5680894", "0.5668907", "0.5668907", "0.5667553", "0.56606895", "0.56313473", "0.56091386", "0.55976975", "0.5590279", "0.55747426", "0.55685174", "0.5562975", "0.556069", "0.55548465", "0.55493355", "0.55477285", "0.5543113", "0.552401", "0.5514444", "0.5511541", "0.5511541", "0.55108637", "0.5504994", "0.5504994", "0.5502906", "0.5499557", "0.5483417", "0.54804766", "0.5475256", "0.54701114", "0.54680246", "0.54635626", "0.5460647", "0.5453451", "0.5450064", "0.54446685", "0.5443558", "0.54431856", "0.54320955", "0.5431764", "0.54280204", "0.5423261", "0.5405216", "0.53986347", "0.5386727", "0.53583896", "0.5347709", "0.53464425", "0.53421104", "0.53131473", "0.53043884", "0.53037477", "0.530337", "0.52991945", "0.52977693", "0.5293085", "0.5290093", "0.5275333", "0.5268745", "0.52671015", "0.526192", "0.5258337", "0.5256233", "0.5252714", "0.5252379", "0.5251908", "0.52503955", "0.52503955", "0.52503955", "0.5243559", "0.5241362", "0.5234462", "0.52154714", "0.52116275", "0.5209891", "0.5206406", "0.5205369" ]
0.68637425
0
Create a new asset
def create # Get the content type content_type = params[:file].content_type asset_params = {name: params[:file].original_filename, filename: params[:file]} # Create the appropriate model if content_type.split("/").first == "image" @asset = Assetabler::Image.new(asset_params) elsif content_type.split("/").first == "video" @asset = Assetabler::Video.new(asset_params) elsif content_type.split("/").first == "application" @asset = Assetabler::Document.new(asset_params) end # Return @fieldname = params[:fieldname] @uploader_id = params[:uploader_id] if @asset.errors.empty? and @asset.save render :create else render :error end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_asset\n @asset = Asset.new\n end", "def create\n @asset = OtherAsset.new(params[:asset])\n asset_create('other', others_url)\n end", "def create\n repo = assets_repo\n\n file = (params.has_key?(:file)) ? params[:file] : false\n @v_asset = repo.create file\n\n respond_to do |format|\n if @v_asset.save\n format.html { redirect_to @v_asset, notice: 'V asset was successfully created.' }\n format.json { render json: @v_asset, status: :created, location: @v_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @v_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\t\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render :show, status: :created, location: @asset }\n else\n format.html { render :new }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to assets_url, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(@asset, :notice => 'Asset was successfully created.') }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to edit_asset_path(@asset), notice: 'Asset was successfully created.' }\n format.json { render action: 'edit', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: I18n.t('controllers.create_success', name: @asset.class.model_name.human) }\n format.json { render json: @asset, status: :created, location: @asset }\n format.xml { render xml: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n format.xml { render xml: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = assets.build(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to user_asset_url(@asset) }\n format.xml { head :created, :location => user_asset_url(@asset) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors.to_xml }\n end\n end\n end", "def create\n @asset = @org.assets.build(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to [@asset.org, @asset], notice: 'Asset was successfully created.' }\n format.json { render :show, status: :created, location: [@asset.org, @asset] }\n else\n format.html { render :new }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @asset = Asset.create!(asset_params)\n render template: 'assets/show', status: :created\n rescue Exception => e\n render json: {:message=> e.to_s}.to_json, status: :internal_server_error\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n #format.html { redirect_to(@asset) }\n format.html { redirect_to(assets_url) }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_asset\n asset = AssetService.create(@context, unsafe_params)\n\n render json: { id: asset.uid }\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n # format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n flash[:notice] = 'Fotoet blev oprettet.'\n format.html { redirect_to assets_url, notice: 'Fotoet blev oprettet.' }\n format.json { render action: 'show', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@asset = Asset.new(params[:asset])\n\n\t\trespond_to do |format|\n\t\t\tif @asset.save\n\t\t\t\tformat.html { redirect_to @asset.page, notice: 'Boom, asset created.' }\n\t\t\t\t# format.json { render json: @asset, status: :created, location: @asset }\n\t\t\t\t# @template = render(:partial => 'assets/form', :locals => { :asset => @asset })\n\t\t\t\t# format.json { render json: @template, status: :created, location: @asset }\n\t\t\t\tformat.json { render :json => { :template => render_to_string(:partial => 'assets/form', :formats => [:html], :locals => { :asset => @asset }) } }\n\n\n\t\t\telse\n\t\t\t\tformat.html { render action: \"Create new asset\" }\n\t\t\t\tformat.json { render json: @asset.errors, status: :unprpcessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def create\n @asset = current_user.asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_file = AssetFile.new(asset_file_params)\n\n respond_to do |format|\n if @asset_file.save\n format.html { redirect_to @asset_file, notice: 'Asset file was successfully created.' }\n format.json { render :show, status: :created, location: @asset_file }\n else\n format.html { render :new }\n format.json { render json: @asset_file.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @e_asset = EAsset.new(e_asset_params)\n\n respond_to do |format|\n if @e_asset.save\n format.html { redirect_to @e_asset, notice: 'E asset was successfully created.' }\n format.json { render :show, status: :created, location: @e_asset }\n else\n format.html { render :new }\n format.json { render json: @e_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n @asset = Asset.create!(asset_param)\n json_response(@asset, :created)\n end", "def create(filename, repository, stored, copies, public_flag)\n path, file_meta, checksum = stored\n @asset_model.create! asset_id: asset_id(path),\n identifier: path,\n public: public_flag,\n filename: filename,\n media_type: media_type(file_meta, path),\n md5sum: checksum,\n repository: repository,\n file_metadata_sets: file_meta,\n copies: copies\n end", "def create\n @project_asset = ProjectAsset.new(params[:project_asset])\n\n respond_to do |format|\n if @project_asset.save\n format.html { redirect_to(@project, :notice => 'ProjectAsset was successfully created.') }\n format.xml { render :xml => @project_asset, :status => :created, :location => @project_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = current_user.assets.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n track_activity @asset\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to(admin_assets_url) }\n format.xml { render :xml => @asset, :status => :created, :location => admin_asset_url(@asset) }\n format.js { render :json => @asset, :status => 200, :location => admin_asset_url(@asset) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n format.js { render :json => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n format.html { redirect_to asset_url(@asset) } \n format.js # render create.rjs << added for P/C >>\n format.xml { head :created, :location => asset_url(@asset) }\n else\n format.html { render :action => \"new\" }\n format.js # render create.rjs << added for P/C >>\n format.xml { render :xml => @asset.errors.to_xml }\n end\n end\n end", "def create\n @c_asset = CAsset.new(params[:c_asset])\n\n authorize! :create, @c_asset\n respond_to do |format|\n if @c_asset.save\n format.html { redirect_to c_assets_path, :notice => 'C asset was successfully created.' }\n format.json { render :json => @c_asset, :status => :created, :location => @c_asset }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @c_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n @asset.parse_meta\n if @asset.id? && Asset.exists?(@asset.id)\n @asset = Asset.find(@asset.id)\n @asset.user_id = nil\n @asset.submitted = true\n @asset.revision = false\n @asset.approved = false\n @asset.checked_out = false\n success = @asset.update_attributes(params[:asset])\n else\n success = @asset.save\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render json: @asset, status: :created, location: @asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\t\t@asset.campaign_id = params[:campaign_id]\n\n file_dir = \"#{FILE_STORAGE_PATH}/#{@campaign.id}\"\n file_path = \"#{file_dir}/#{@asset.name}\"\n rescue_file_path = \"#{FILE_STORAGE_PATH}/#{@asset.name}\"\n\n if !File.exists?(file_dir) and !File.directory?(file_dir)\n Dir.mkdir(file_dir)\n if !File.exists?(file_dir)\n flash[:error] = \"Directory #{file_dir} creation failed. Uploading the file to the global storage area.\"\n file_path = rescue_file_path\n end\n end\n\n if @asset.save!\n\t\t @asset.path = file_path\n\t\t @asset.url = FILE_URL_TEMPLATE.sub(':campaign_id', @campaign.id.to_s).sub(':asset_id',@asset.id.to_s)\n\t\t File.open(file_path, \"wb\") do |f|\n\t\t\t f.write(params[:asset][:path].read) unless params[:asset][:path].nil?\n\t\t end\n end\n \n\t\trespond_to do |format|\n \tif @asset.save\n flash[:notice] = \"File #{@asset.name} has been successfully added to the campaign #{@campaign.name}.\"\n\t\t\t\tformat.html { redirect_to(campaign_assets_url([@campaign, @asset])) }\n\t format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n \tformat.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\t\n\tend", "def new\n @asset = @uploadable.assets.new\n end", "def new\n @asset = @uploadable.assets.new\n end", "def create\n @game_asset = GameAsset.new(game_asset_params)\n @game_asset.user_id = current_user.id\n @game_asset.make_public = false\n @game_asset.file_uploaded = false\n @game_asset.downloaded_times = 0\n\n respond_to do |format|\n if @game_asset.save\n format.html { redirect_to asset_file_upload_game_asset_path(@game_asset), notice: '素材の仮登録が完了しました。引き続き素材ファイルをアップロードして下さい。' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @attached_asset = AttachedAsset.new(params[:attached_asset])\n\n respond_to do |format|\n if @attached_asset.save\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully created.' }\n format.json { render json: @attached_asset, status: :created, location: @attached_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(file, name, project)\n\n asset = VAsset.new\n asset.v_project = project\n asset.v_user_data = project.v_user_data\n asset.path = userPath(name, asset.v_user_data)\n\n if asset.save\n File.open(asset.path, \"wb\") do |f|\n f.write file.read\n end\n end\n\n return asset\n end", "def create\n @primary_asset = PrimaryAsset.new(primary_asset_params)\n\n respond_to do |format|\n if @primary_asset.save\n format.html { redirect_to @primary_asset, notice: 'Primary asset was successfully created.' }\n format.json { render :show, status: :created, location: @primary_asset }\n else\n format.html { render :new }\n format.json { render json: @primary_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(asset_params)\n @asset_owner = User.all\n @category = Category.all\n if @asset.save\n if !@asset.image.present?\n render :js => \"window.location = '/site_assets'\"\n else\n redirect_to assets_path, notice: 'Asset was successfully created.'\n end\n else\n render 'create_failure'\n end\n end", "def create\n @fixed_asset = FixedAsset.new(fixed_asset_params)\n\n respond_to do |format|\n if @fixed_asset.save\n format.html { redirect_to @fixed_asset, notice: 'Fixed asset was successfully created.' }\n format.json { render :show, status: :created, location: @fixed_asset }\n else\n format.html { render :new }\n format.json { render json: @fixed_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n @countries = Country.find(:all)\n \n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_path(@asset), :notice => 'Asset was successfully created.') }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n format.html { render :action => :new, :notice => 'Asset was not created.' }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n record = Asset.new(params[:record])\n respond_to do |format|\n if record.save\n format.html \n format.json { render json: {} }\n else\n format.html { render action: \"new\" }\n format.json { render json: {} }\n end\n end\n end", "def create_asset_with_http_info(create_asset_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AssetsApi.create_asset ...'\n end\n # verify the required parameter 'create_asset_request' is set\n if @api_client.config.client_side_validation && create_asset_request.nil?\n fail ArgumentError, \"Missing the required parameter 'create_asset_request' when calling AssetsApi.create_asset\"\n end\n # resource path\n local_var_path = '/video/v1/assets'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\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(create_asset_request)\n\n # return_type\n return_type = opts[:debug_return_type] || 'AssetResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"AssetsApi.create_asset\",\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: AssetsApi#create_asset\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @asset = Resource.new(resource_params)\n \n if @asset.save\n redirect_to admin_resource_path(@asset), notice: 'Resource was successfully created.'\n else\n render action: 'new'\n end\n end", "def create\n @asset_item = AssetItem.new(params[:asset_item])\n\n respond_to do |format|\n if @asset_item.save\n flash[:notice] = 'AssetItem was successfully created.'\n format.html { redirect_to(asset_items_url) }\n format.xml { render :xml => @asset_item, :status => :created, :location => @asset_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(source, metadata = nil, &block)\n Asset.create(source, metadata) do |asset, error|\n if asset\n block.call(asset, error)\n self << asset\n else\n raise \"Asset creation failed. #{error}\"\n end\n end\n end", "def create\n @asset = Asset.find(params[:asset_id])\n \t@tag = @asset.tags.build(params[:tag])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(asset_manager_asset_tag_path(@asset, @tag), :notice => 'Tag was successfully created.') }\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag), :status => :created, :location => @tag }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @customer_asset = CustomerAsset.new(params[:customer_asset])\n\n respond_to do |format|\n if @customer_asset.save\n format.html { redirect_to @customer_asset, notice: 'Customer asset was successfully created.' }\n format.json { render json: @customer_asset, status: :created, location: @customer_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_request = AssetRequest.new(params[:asset_request])\n\n respond_to do |format|\n if @asset_request.save\n format.html { redirect_to @asset_request, notice: 'Asset request was successfully created.' }\n format.json { render json: @asset_request, status: :created, location: @asset_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = @uploadable.assets.new(asset_params)\n if request.path.include? \"rooms\"\n if @asset.save\n redirect_to venue_rooms_path\n else\n render :new\n end\n else\n if @asset.save\n redirect_to @uploadable, notice: \"asset created.\"\n else\n render :new\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n respond_to do |format|\n if @asset.save\n format.html { redirect_to(\"/admin/posts/#{@asset.post_id}\", :notice => 'Gravado com Sucesso') } \n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @asset_data = AssetData.new(asset_data_params)\n if @asset_data.save\n respond_with @asset_data, notice: 'Asset data was successfully created.'\n else\n render :new\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n\n if @asset.save\n respond_to do |format|\n format.html do\n render json: [@asset.to_jq_upload].to_json,\n content_type: 'text/html',\n layout: false\n end\n format.json do\n render json: [@asset.to_jq_upload].to_json\n end\n end\n else\n render json: [{ error: 'custom_failure' }], status: 304\n end\n end", "def create\n @asset_allocate = AssetAllocate.new(asset_allocate_params)\n\n respond_to do |format|\n if @asset_allocate.save\n format.html { redirect_to @asset_allocate, notice: 'Asset allocate was successfully created.' }\n format.json { render :show, status: :created, location: @asset_allocate }\n else\n format.html { render :new }\n format.json { render json: @asset_allocate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @faction_asset = FactionAsset.new(faction_asset_params)\n\n respond_to do |format|\n if @faction_asset.save\n format.html { redirect_to @faction_asset, notice: 'Faction asset was successfully created.' }\n format.json { render :show, status: :created, location: @faction_asset }\n else\n format.html { render :new }\n format.json { render json: @faction_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_asset\n \t\timage_params = params[:blog_asset] || {}\n \t\t@image = BlogAsset.new(image_params)\n \t\t@image.blog_post_id = image_params[:blog_post_id] # Can't mass-assign attributes of attachment_fu, so we'll set it manually here\n \t\t@image.save!\n \t\trender :text => @image.public_filename\n \tend", "def create\n @record = Asset.new(params[:@record])\n respond_to do |format|\n if @record.save\n format.html \n format.json { render json: {} }\n else\n format.html { render action: \"new\" }\n format.json { render json: {} }\n end\n end\n end", "def create\n if request.format == :xml\n super\n else\n passed_values = params[:asset]\n @asset = Asset.create(\n :g_u_i_d => passed_values[:g_u_i_d],\n :tag => passed_values[:tag],\n :name => passed_values[:name],\n :i_d_in_info_source => passed_values[:i_d_in_info_source],\n :status => \"1\",\n :model => Model.find_by_guid(passed_values[:model]),\n :manufacturer => Manufacturer.find_by_guid(passed_values[:manufacturer]),\n :serial_number => passed_values[:serial_number])\n Notification.create(\n :message => \"Created an Asset via HTML CRUD utility (create Asset form)\", \n :operation => \"Create\",\n :ccom_entity => @asset.guid,\n :about_user => User.find_by_id(session[:user_id]),\n :database => ActiveRegistry.find_database(session[:user_id])\n ) \n if object_type = ObjectType.find_by_guid(passed_values[:object_type])\n @asset.update_attributes(:object_type => object_type)\n else\n @asset.update_attributes(:object_type => ObjectType.undetermined)\n end\n \n ref_valid_network = ValidNetwork.find_by_guid(passed_values[:valid_network])\n valid_network = ref_valid_network.nil? ? nil : ref_valid_network.dup_entity(:gen_new_guids => true)\n @asset.update_attributes( :valid_network => valid_network)\n\n respond_to do |format|\n if @asset.save\n flash[:notice] = \"Asset was saved into database at #{@asset.last_edited}\"\n format.html { redirect_to(@asset) }\n else\n @types = get_all_asset(:object_type)\n @manufacturers = get_all_asset(:manufacturer)\n @models = get_all_asset(:model)\n @networks = define_networks()\n format.html { render :action => \"new\" }\n end\n end\n end\n end", "def create_asset(create_asset_request, opts = {})\n data, _status_code, _headers = create_asset_with_http_info(create_asset_request, opts)\n data\n end", "def new\n repo = assets_repo\n @v_asset = repo.new\n\n respond_to do |format|\n format.html new.html.erb\n format.json { render json: @v_asset }\n end\n end", "def create\n @barcode_asset = BarcodeAsset.new(barcode_asset_params)\n\n respond_to do |format|\n if @barcode_asset.save\n format.html { redirect_to @barcode_asset, notice: 'Barcode asset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barcode_asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @barcode_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @video = Video.new(params[:video])\n @asset = Asset.new(params[:asset])\n @video.asset = @asset\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to(@video, :notice => 'Video was successfully created.') }\n format.xml { render :xml => @video, :status => :created, :location => @video }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @video.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @bes_asset = BesAsset.new(bes_asset_params)\n fix_questions()\n respond_to do |format|\n if @bes_asset.save\n @bes_asset.proof.url # => '/url/to/file.png'\n @bes_asset.proof.current_path # => 'path/to/file.png'\n @bes_asset.proof_identifier # => 'file.png'\n\n\n format.html { redirect_to @bes_asset, notice: 'Asset was successfully created!' }\n format.json { render :show, status: :created, location: @bes_asset }\n else\n format.html { render :new }\n format.json { render json: @bes_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset = Asset.new(params[:asset])\n @home = Home.find(params[:home_id])\n @asset.home = @home\n \n respond_to do |format|\n if @asset.save\n flash[:notice] = 'Asset was successfully created.'\n # Expire the caches for main and thumb asset and delete if old asset present\n if (@home.asset)\n expire_page(asset_type_path(@home.asset, false)) # main\n expire_page(asset_type_path(@home.asset, true)) # thumb\n # Deleting the main asset internally deletes thumbnails in attachment_fu\n Asset.delete(@home.asset_id)\n end\n @home.asset = @asset # link home to new photo\n @home.save\n format.html { redirect_to(@home) }\n format.xml { render :xml => @asset, :status => :created, :location => @asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n if current_client\n @client_asset = current_client.client_assets.build(client_asset_params)\n else\n @client_asset = ClientAsset.new(client_asset_params)\n end\n\n respond_to do |format|\n if @client_asset.save\n format.html { redirect_to @client_asset, notice: 'Client asset was successfully created.' }\n format.json { render :show, status: :created, location: @client_asset }\n else\n format.html { render :new }\n format.json { render json: @client_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_image_asset(client, customer_id, image_url, image_name)\n # Creates an asset operation.\n operation = client.operation.create_resource.asset do |a|\n a.name = image_name\n a.type = :IMAGE\n a.image_asset = client.resource.image_asset do |image|\n image.data = open(image_url) { |f| f.read }\n end\n end\n\n # Issues a mutate request to add the asset.\n response = client.service.asset.mutate_assets(\n customer_id: customer_id,\n operations: [operation],\n )\n\n # Prints out information about the newly added asset.\n resource_name = response.results.first.resource_name\n puts \"A new image asset has been added with resource name: #{resource_name}\"\n\n resource_name\nend", "def create\n \n @admin_section = true\n @user_asset = UserAsset.new(params[:user_asset])\n\n respond_to do |format|\n if @user_asset.save\n format.html { redirect_to(@user_asset, :notice => 'File(s) were successfully uploaded.') }\n format.xml { render :xml => @user_asset, :status => :created, :location => @user_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @gallery_asset = GalleryAsset.new(params[:gallery_asset])\n\n respond_to do |format|\n if @gallery_asset.save\n flash[:notice] = 'GalleryAsset was successfully created.'\n format.html { redirect_to(@gallery_asset) }\n format.xml { render :xml => @gallery_asset, :status => :created, :location => @gallery_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gallery_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @archive_asset = @archive.archive_assets.build(archive_asset_params)\n if @archive_asset.save\n redirect_to archive_archive_assets_url(@archive),\n notice: flash_message(:create, model: ArchiveAsset)\n else\n render :new\n end\n end", "def create\n ethers, new_ethers = process_ethers(params[:asset])\n @asset = NetDevice.new(params[:asset])\n asset_create('network_item', network_url, ethers, new_ethers)\n end", "def create\n @asset = current_user.assets.new(asset_params)\n \n #Check if the current user has enough storage to upload the asset\n if(@asset.asset.size + calculate_storage(current_user) > (1024*1024*5))\n flash[:danger] = \"You do not have enough storage to upload this file! Please delete some files to free up space.\"\n redirect_to assets_path\n else\n \n #Check if the file saves sucessfully\n if @asset.save\n keyHash = symmetric_encrypt(@asset)\n \n #Key has to be created after asset creation, else asset has no id.\n keyHash = keyHash.merge(asset_id: @asset.id)\n Key.create(keyHash)\n \n flash[:success] = 'File was successfully uploaded'\n redirect_to assets_path\n else\n #Show error message if the save fails\n flash[:danger] = 'Error! File could not be uploaded'\n redirect_to assets_path\n end\n end\n end", "def create\n @admin_section = true\n\n @course_asset = CourseAsset.new(params[:course_asset])\n\n respond_to do |format|\n if @course_asset.save\n format.html { redirect_to(@course_asset, :notice => 'File(s) were successfully uploaded.') }\n format.xml { render :xml => @course_asset, :status => :created, :location => @course_asset }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @course_asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @misc_asset = MiscAsset.new(misc_asset_params)\n\n respond_to do |format|\n if @misc_asset.save\n format.html { redirect_to user_brand_path(current_user, @misc_asset.brand_id), notice: 'Misc asset was successfully created.' }\n format.json { render json: @misc_asset, status: :created, location: user_brand_path(current_user, @misc_asset.brand_id) }\n else\n format.html { redirect_to user_brand_path(current_user, @misc_asset.brand_id), notice: 'Misc asset was not saved.'}\n format.json { render json: @misc_asset.errors, status: :unprocessable_entity,location: user_brand_path(current_user, @misc_asset.brand_id) }\n end\n end\n end", "def create\n @assettrack = Assettrack.new(params[:assettrack])\n\n respond_to do |format|\n if @assettrack.save\n flash[:notice] = 'Assettrack was successfully created.'\n format.html { redirect_to(@assettrack) }\n format.xml { render :xml => @assettrack, :status => :created, :location => @assettrack }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @assettrack.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @asset_manage = AssetManage.new(asset_manage_params)\n @asset_manage.admin = current_admin\n \n respond_to do |format|\n if @asset_manage.save\n format.html { redirect_to @asset_manage, notice: 'Asset manage was successfully created.' }\n format.json { render :show, status: :created, location: @asset_manage }\n else\n format.html { render :new }\n format.json { render json: @asset_manage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @asset = @attachable.assets.new(params[:asset])\n @asset = @attachable.assets.build(asset_params)\n\n respond_to do |format|\n if @asset.save\n format.html {\n render :json => [@asset.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json { render json: {files: [@asset.to_jq_upload]}, status: :created, location: @upload }\n else\n format.html { render action: \"new\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @listing_asset = ListingAsset.new(listing_asset_params)\n\n respond_to do |format|\n if @listing_asset.save\n format.html { redirect_to @listing_asset, notice: 'Listing asset was successfully created.' }\n format.json { render :show, status: :created, location: @listing_asset }\n else\n format.html { render :new }\n format.json { render json: @listing_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @global_asset = GlobalAsset.new(global_asset_params)\n \n upload_hash = FileUploadUtil.uploadFile(params[:data_file], \"global_asset\", ['rar','pdf','word','zip','txt','sql'])\n if upload_hash[:status] == 'error'\n respond_to do |format|\n flash[:notice] = upload_hash[:msg]\n format.html { render action: \"new\" }\n format.json { render json: @global_asset.errors, status: :unprocessable_entity }\n end\n return\n end\n if !params[:data_file].nil?\n @global_asset.data_file_url = upload_hash[:file_name]\n @global_asset.data_content_type = upload_hash[:content_type]\n @global_asset.data_file_size = upload_hash[:file_size]\n @global_asset.width = upload_hash[:width]\n @global_asset.height = upload_hash[:height]\n @global_asset.user_id = @current_user.uid\n @global_asset.user_name = @current_user.name\n end\n \n respond_to do |format|\n if @global_asset.save\n format.html { redirect_to admin_global_asset_path(@global_asset), notice: 'Global asset was successfully created.' }\n format.json { render json: @global_asset, status: :created, location: @global_asset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @global_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n respond_to do |format|\n @asset_tag = AssetTag.new(asset_tag_params)\n puts @asset_tag.inspect\n\n if @asset_tag.save(validate: false)\n format.html { redirect_to @asset_tag, notice: 'Asset tag was successfully created.' }\n format.json { render :show, status: :created, location: @asset_tag }\n AssetTag.reindex\n else\n format.html { render :new }\n format.json { render json: @asset_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n format.xml { render xml: @asset }\n end\n end", "def create\n @asset_category = AssetCategory.new(asset_category_params)\n\n respond_to do |format|\n if @asset_category.save\n format.html { redirect_to @asset_category, notice: 'Asset category was successfully created.' }\n format.json { render :show, status: :created, location: @asset_category }\n else\n format.html { render :new }\n format.json { render json: @asset_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_asset_and_respond(item)\n item = create_asset(item)\n if item.save\n unless return_to_fancy_parent(item)\n flash[:notice] = \"#{t(item.class.name.underscore)} was successfully uploaded and saved.\"\n respond_to do |format|\n format.html { redirect_to params[:single_page] ?\n { controller: :single_pages, action: :show, id: params[:single_page] } \n : item }\n format.json { render json: item, include: json_api_include_param }\n end\n end\n else\n respond_to do |format|\n format.html { render action: 'new' }\n format.json { render json: json_api_errors(item), status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_state = AssetState.new(params[:asset_state])\n respond_to do |format|\n if @asset_state.save\n format.html { redirect_to system_asset_states_path, notice: 'Asset type was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create_external_asset_from_params\n attrs={}\n attrs.merge!({:namespace=>params[:namespace]}) if params[:namespace]\n attrs.merge!(:dsLabel=>params[:Filename]) if params[:Filename]\n ext_asset = ExternalAsset.new(attrs)\n uri = params[:dsLocation]\n uri = \"http://#{uri}\" unless uri.include?(\"://\")\n ext_asset.link_append({:dsLocation=>uri,:dsLabel=>params[:Filename], :mimeType=>mime_type(params[:Filename])})\n ext_asset.filename = params[:Filename]\n ext_asset.identifier = uri\n return ext_asset\n end", "def create\n @asset_loss = AssetLoss.new(asset_loss_params)\n\n respond_to do |format|\n if @asset_loss.save\n format.html { redirect_to @asset_loss, notice: 'Asset loss was successfully created.' }\n format.json { render :show, status: :created, location: @asset_loss }\n else\n format.html { render :new }\n format.json { render json: @asset_loss.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fixed_asset = FixedAsset.new(fixed_asset_params)\n\n respond_to do |format|\n if @fixed_asset.save\n TagMakerWorker.perform_async(\"fixed\", @fixed_asset.id)\n FixedAsset.reindex\n #this is a sad excuse for a loading spinner. we need to do this differently in production\n sleep 5\n new_asset_id = AssetTag.last.id\n puts new_asset_id\n format.html { redirect_to @fixed_asset, notice: 'Asset was successfully created!' }\n format.json { render :show, status: :created, location: @fixed_asset }\n else\n format.html { render :new, alert: \"there was an error\" }\n format.json { render json: @fixed_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.new\n @title = 'New Asset'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n end\n end", "def create\n @asset = Asset.new(asset_params)\n\n respond_to do |format|\n if @asset.save\n tokens = @asset.name.split\n num_elements = tokens.size\n tokens.each do |token|\n AssetTermIndex.create(term: token.downcase, origin_string_size: num_elements, asset_id: @asset.id)\n end\n format.html { redirect_to @asset, notice: 'Asset was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asset }\n else\n format.html { render action: 'new' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_asset(xero_tenant_id, asset, opts = {})\n data, _status_code, _headers = create_asset_with_http_info(xero_tenant_id, asset, opts)\n data\n end", "def new\n @artefact = Artefact.find(params[:artefact_id])\n @asset = @artefact.assets.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n end\n end", "def create_and_link_image_asset(client, customer_id, url, field_type, asset_name)\n operations = []\n temp_id = next_temp_id\n\n # Create the Image Asset.\n operations << client.operation.mutate do |m|\n m.asset_operation = client.operation.create_resource.asset do |a|\n a.resource_name = client.path.asset(customer_id, temp_id)\n # Provide a unique friendly name to identify your asset.\n # When there is an existing image asset with the same content but a different\n # name, the new name will be dropped silently.\n a.name = asset_name\n a.type = :IMAGE\n a.image_asset = client.resource.image_asset do |image_asset|\n image_asset.data = get_image_bytes(url)\n end\n end\n end\n\n # Create an AssetGroupAsset to link the Asset to the AssetGroup.\n operations << client.operation.mutate do |m|\n m.asset_group_asset_operation = client.operation.create_resource.\n asset_group_asset do |aga|\n aga.field_type = field_type\n aga.asset_group = client.path.asset_group(\n customer_id,\n ASSET_GROUP_TEMPORARY_ID,\n )\n aga.asset = client.path.asset(customer_id, temp_id)\n end\n end\n\n operations\nend", "def create\n @asset_scrapping_entry = AssetScrappingEntry.new(asset_scrapping_entry_params)\n\n respond_to do |format|\n if @asset_scrapping_entry.save\n format.html { redirect_to @asset_scrapping_entry, notice: 'Asset scrapping entry was successfully created.' }\n format.json { render :show, status: :created, location: @asset_scrapping_entry }\n else\n format.html { render :new }\n format.json { render json: @asset_scrapping_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_status = AssetStatus.new(asset_status_params)\n\n respond_to do |format|\n if @asset_status.save\n format.html { redirect_to @asset_status, notice: 'Asset status was successfully created.' }\n format.json { render :show, status: :created, location: @asset_status }\n else\n format.html { render :new }\n format.json { render json: @asset_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @wrong_data_asset = WrongDataAsset.new(wrong_data_asset_params)\n\n respond_to do |format|\n if @wrong_data_asset.save\n format.html { redirect_to @wrong_data_asset, notice: 'Wrong data asset was successfully created.' }\n format.json { render :show, status: :created, location: @wrong_data_asset }\n else\n format.html { render :new }\n format.json { render json: @wrong_data_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asset }\n end\n end", "def create_file(file_name, asset_path, update_source)\n response_name = \"#{response_name}\"\n # * 1) BASE URL\n base_url = 'https://dev-cascade.chapman.edu/api/v1/'.to_s\n\n # * 2) REST API ACTION\n # https://wimops.chapman.edu/wiki/WWW#Key_Links\n # https://www.hannonhill.com/cascadecms/latest/developing-in-cascade/rest-api/index.html\n rest_action = 'create/'.to_s # ! KEEP TRAILING SLASH\n\n # * 3) ASSET TYPE\n # this is easy to find in cascade's edit/preview url.\n # ie https://dev-cascade.chapman.edu/entity/open.act?id=7f74b81ec04d744c7345a74906ded22a&type=page\n asset_type = 'file/' # ! KEEP TRAILING SLASH\n\n # * 4) ASSET PATH OR ID\n # you can also use its path (ie \"Chapman.edu/_cascade/formats/modular/widgets/1-column\")... but.. whitespace.\n asset_path = \"#{asset_path}\" # ! NO TRAILING SLASH\n\n # * 5) SECRETS\n # set these in environment_variables.yml\n cascade_username = '?u=' + ENV['CASCADE_USERNAME']\n cascade_password = '&p=' + ENV['CASCADE_PASSWORD']\n cascade_api_key = '?apiKey=' + ENV['CASCADE_API_KEY']\n\n update_source = \"#{update_source}\"\n\n data = File.read(update_source)\n p data\n\n response_body = data\n\n url_post =\n base_url + rest_action + asset_type + asset_path + cascade_api_key\n\n # 👹Editing assets unfortunately requires PATH, SITENAME, ID. This can be obtained by reading the asset's response.body 👆\n # HTTParty.post(url_post, body: { asset: { xmlBlock: { xml: data, path: \"_cascade/blocks/html/0-write-test\", parentFolderId: parent_folder_id, siteName: \"Chapman.edu\", id: \"365ae5dec0a81e8a20b1d746fd3e0778\" } } }.to_json)\n\n p HTTParty.post(\n url_post,\n body: {\n \"asset\": {\n \"file\": {\n \"text\": data,\n \"rewriteLinks\": false,\n \"maintainAbsoluteLinks\": false,\n \"shouldBePublished\": true,\n \"shouldBeIndexed\": true,\n # \"lastPublishedDate\": \"Jul 15, 2020, 12:56:28 AM\",\n \"lastPublishedBy\": \"cbryant\",\n \"expirationFolderRecycled\": false,\n \"metadataSetId\": \"6fef14a3c04d744c610b81da9d165a27\",\n \"metadataSetPath\": \"Default\",\n \"metadata\": {},\n \"reviewOnSchedule\": false,\n \"reviewEvery\": 180,\n # \"parentFolderId\": \"fd5121b0c04d744c42ab23aa0aba0ba8\",\n \"parentFolderPath\": \"_assets\",\n # \"lastModifiedDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"lastModifiedBy\": \"mthomas\",\n # \"createdDate\": \"Feb 26, 2019, 1:05:39 PM\",\n # \"createdBy\": \"mthomas\",\n # \"path\": \"#{asset_path}#{file_name}\",\n # \"siteId\": \"6fef14a3c04d744c610b81dac0a8d082\",\n \"siteName\": \"Chapman.edu\",\n \"tags\": [],\n \"name\": file_name,\n # \"id\": \"2ba09c01c0a81e4b0015d01bfd25ea78\"\n }\n },\n \"success\": true\n }.to_json\n )\n # p \"🎉 View changes at https://dev-cascade.chapman.edu/entity/open.act?id=#{\n # asset_id\n # }&type=#{asset_type}\".chomp('/')\nend", "def create\n @course_asset_model_type = CourseAssetModelType.new(params[:course_asset_model_type])\n\n respond_to do |format|\n if @course_asset_model_type.save\n format.html { redirect_to @course_asset_model_type, notice: 'Course asset model type was successfully created.' }\n format.json { render json: @course_asset_model_type, status: :created, location: @course_asset_model_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @course_asset_model_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cassete = Cassete.new(cassete_params)\n\n respond_to do |format|\n if @cassete.save\n format.html { redirect_to @cassete, notice: 'Cassete was successfully created.' }\n format.json { render :show, status: :created, location: @cassete }\n else\n format.html { render :new }\n format.json { render json: @cassete.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @asset = Asset.find(params[:asset_id])\n \t@tag = @asset.tags.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => asset_manager_tag_path(@tag) }\n end\n end", "def create\n # JSONファイルから文字列を抽出する\n file = params['stage']['file']# Upされたファイルにアクセス\n \n p(\"file params:\")\n\n @jsonstring = file.read\n p(@jsonstring)\n @stage = Stage.new(:scene_data => @jsonstring, :title => params[:stage][:title])\n p(\"stage.scene_data:\")\n p(@stage.scene_data)\n #p(@stage.nothing)\n \n if params[:stage][:texture] != nil\n @textures = Texture.new(:data => params[:stage][:texture]['data'])\n @stage.textures << @textures\n end\n\n respond_to do |format|\n if @stage.save!\n format.html { redirect_to @stage, notice: 'Stage was successfully created.' }\n format.json { render action: 'show', status: :created, location: @stage }\n else\n format.html { render action: 'new' }\n format.json { render json: @stage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asset_category = AssetCategory.new(params[:asset_category])\n\n respond_to do |format|\n if @asset_category.save\n flash[:success] = 'Asset category was successfully created.'\n format.html { redirect_to(admin_asset_categories_url) }\n format.xml { render :xml => @asset_category, :status => :created, :location => @asset_category }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @asset_category.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_asset\n @asset = Asset.new(params[:asset])\n render :update do |page|\n if @asset.save\n page.replace_html 'form-errors', :text => ''\n page << \"Modalbox.hide();\"\n page.replace_html 'flash_box', :text => \"<p class='flash-msg'>#{t('flash_msg20')}</p>\"\n\n else\n page.replace_html 'form-errors', :partial => 'class_timings/errors', :object => @asset\n page.visual_effect(:highlight, 'form-errors')\n end\n end\n end", "def create\n @stage = Stage.new(params[:stage])\n\n respond_to do |format|\n if @stage.save\n format.html { redirect_to(asset_manager_stage_path(@stage), :notice => 'Stage was successfully created.') }\n format.xml { render :xml => @stage, :status => :created, :location => @stage }\n else\n format.html { render :action => :new }\n format.xml { render :xml => @stage.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.79199594", "0.7846794", "0.7725987", "0.7721308", "0.7702766", "0.768901", "0.7639895", "0.7614302", "0.75789064", "0.7523736", "0.7493198", "0.74887085", "0.74346286", "0.74309444", "0.73962104", "0.7307768", "0.7296089", "0.72891164", "0.72719765", "0.72710246", "0.72691846", "0.7228651", "0.7188451", "0.71823555", "0.7079296", "0.704835", "0.70186716", "0.70089394", "0.6979727", "0.6979727", "0.6961836", "0.695146", "0.69354343", "0.691321", "0.6897208", "0.6896378", "0.68823135", "0.6832714", "0.68181574", "0.6808517", "0.6802726", "0.67523", "0.67481905", "0.67462486", "0.6745942", "0.6722504", "0.6717864", "0.6699569", "0.6677234", "0.66669124", "0.66664994", "0.6639489", "0.66277874", "0.6602833", "0.659274", "0.65831906", "0.6567229", "0.6543374", "0.65364313", "0.6515664", "0.64880484", "0.64832985", "0.64654", "0.6445858", "0.64273286", "0.6399665", "0.6399628", "0.63920146", "0.63892025", "0.6353328", "0.6345306", "0.6339817", "0.63255155", "0.62869453", "0.62769586", "0.62746084", "0.6251322", "0.6250908", "0.624416", "0.624054", "0.6235448", "0.6219779", "0.62177557", "0.62059605", "0.6203002", "0.6194583", "0.6192819", "0.6188484", "0.6168746", "0.61373127", "0.6128304", "0.6128304", "0.6124299", "0.61193746", "0.6118119", "0.61147875", "0.61125445", "0.611077", "0.60934335", "0.6092066" ]
0.6479318
62
Edit an asset will return the edit form
def edit @asset = Assetabler::Asset.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n @asset = Asset.find(params[:id])\n end", "def edit_asset\n @asset = Asset.find(params[:id])\n end", "def show\n @asset = OtherAsset.find(params[:id])\n @content_title = @title = \"Editing #{@asset.title}\"\n @submit_value = \"Update\"\n asset_show\n end", "def edit\n @uploadable = @room\n @assets = @uploadable.assets\n @asset = Asset.new\n end", "def show\n @asset = NetDevice.find(params[:id])\n @content_title = @title = \"Editing #{@asset.title}\"\n @submit_value = \"Update\"\n asset_show\n end", "def edit\n # Renders the edit form\n end", "def edit\n\n end", "def show\n @asset = WirelessDevice.find(params[:id])\n @content_title = @title = \"Editing #{@asset.title}\"\n @submit_value = \"Update\"\n asset_show\n end", "def edit\n @item = Item.find_by_id( params[:id] )\n render :layout => 'form'\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html do\n flash[:notice] = 'Asset was successfully updated.'\n redirect_to(admin_assets_url)\n end\n format.xml { head :ok }\n format.js { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n format.js { render :json => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n \n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n flash[:notice] = 'Asset was successfully updated.'\n format.html { redirect_to(@asset) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @artefact = Artefact.find(params[:artefact_id])\n\n @asset = @artefact.assets.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(asset_params)\n format.html { redirect_to artefact_path(@artefact), notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to(@asset, :notice => 'Asset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit\r\n end", "def edit\n\n end", "def edit\n \n end", "def edit\r\n \r\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@asset = Asset.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @asset.update_attributes(params[:asset])\n\t\t\t\tformat.html { redirect_to @asset.page, notice: 'Boom, asset 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: @post.errors, status: :unprpcessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n #format.html { redirect_to @asset, notice: 'Asset was successfully updated.' }\n format.html { redirect_to assets_url, notice: 'Fotoet blev opdateret.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @e_asset.update(e_asset_params)\n format.html { redirect_to @e_asset, notice: 'E asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @e_asset }\n else\n format.html { render :edit }\n format.json { render json: @e_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_asset\n @asset = Asset.find(params[:id])\n @currency_type = currency\n\n render :update do |page|\n if @asset.update_attributes(params[:asset])\n @assets = Asset.find(:all, :conditions => 'is_deleted = 0')\n page.replace_html \"asset_list\", :partial => \"asset_list\"\n page << \"Modalbox.hide();\"\n page.replace_html 'flash_box', :text => \"<p class='flash-msg'>#{t('flash_msg21')}</p>\"\n else\n page.replace_html 'form-errors', :partial => 'class_timings/errors', :object => @asset\n page.visual_effect(:highlight, 'form-errors')\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to [@asset.org, @asset], notice: 'Asset was successfully updated.' }\n format.json { render :show, status: :ok, location: [@asset.org, @asset] }\n else\n format.html { render :edit }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asset.update(asset_params)\n format.html { redirect_to root_path, notice: 'Asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @asset.errors, status: :unprocessable_entity }\n end\n end\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 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 edit\n render\n end", "def edit\n render\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end", "def edit\n end" ]
[ "0.84800553", "0.83911324", "0.77883995", "0.7457932", "0.743196", "0.73515004", "0.73232806", "0.7302282", "0.7232861", "0.7217202", "0.7217202", "0.7217202", "0.7209364", "0.72051823", "0.71942514", "0.7173698", "0.7163836", "0.7160366", "0.715314", "0.71491045", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7147524", "0.7122444", "0.71154976", "0.7102862", "0.7098683", "0.7072081", "0.70598996", "0.70595807", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70589864", "0.70442706", "0.70442706", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885", "0.7037885" ]
0.8413417
1
Permitted params for the model
def permitted_params params.require(params[:asset_type].underscore.gsub('/', '_').to_sym).permit( :name, :filename, :body, :content_type, :width, :height, :asset_type, :ratio ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _params\n # params.require(:model).permit(:model:classname, :schema, :tablename, :name)\n params.require(:model).permit(:classname, :schema, :tablename, :name, :default_sort_field)\n end", "def params\n @_params\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params\n raise NotImplementedError\n end", "def params\n @params ||= {}\n end", "def params\n @params ||= {}\n end", "def params\n @params\n end", "def params\n @params\n end", "def params\n @params\n end", "def permitted_params\n []\n end", "def params\n _params\n end", "def model_params\n request.params[model.params_name]\n end", "def user_params\r\n end", "def params\n @params ||= {}\n end", "def params\n @params ||= {}\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 params\n @params\n end", "def all_params; end", "def user_params\n end", "def model_params\n params.\n require( :bill ).\n permit( :payee, :amount, :due_on, :note )\n end", "def initialize( params )\n super( Parametrization.permit( params, whitelist, model_name ) )\n @params = @params.with_indifferent_access # After building the internal params hash, make it a little friendlier.\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def record_params\n fields = resource.editable_fields.map(&:name)\n params.require(model.model_name.param_key.underscore.to_sym).permit(fields)\n end", "def model_params\n mn = @model.model_name.singular.to_sym\n # {user: {name: \"something\", other_column_name: \"somevalue\"}}\n return {} if params[mn].blank? # to allow create for empty items\n\n # params.require(:table_name).permit(:column_name1, :column_name2, etc., array_type: [], array_type2: [])\n params.require(mn).permit(permitted_columns)\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def model_params\n params.require(:group_organization_id)\n params.require(:model_type_name)\n params.require(:base_price)\n params.permit(:group_organization_id, :model_type_name, :base_price)\n end", "def attr_params\n params[:attr].permit(:name, :type, :value, :foreign_key, :ordinal, :group, :visible, :editable, :required, :input)\n end", "def model_params\n params.require(:model).permit(:id, :name, :dataset, :snippet, :image, :description, :accuracy, :algorithm, :organization, :size, :api_key, :endpoint,\n inputs_attributes: [:id, :name, :kind, :order, :_destroy],\n outputs_attributes: [:id, :name, :kind, :order, :default_value, :_destroy])\n end", "def attributes\n @params\n end", "def request_params; end", "def model_params\r\n params.require(:model).permit(:code, :title, :gender_id, :category_id, :price, :priority, :note)\r\n end", "def update_params\n raise 'Sovrascrivi in figli'\n end", "def model_params\n params.require(:model).permit(:brand_id, :creator_id, :name)\n end", "def model_params\n params.require(:model).permit(:name, :description, :vendor_id)\n end", "def instance_params\n info.params\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 resource_params\n params.require(model_name.underscore.intern).permit(*@model.column_names.map(&:intern))\n end", "def obj_params\n params.require(:data).require(:attributes)\n end", "def model_params\n\t\tparams.require(:competitor).permit(\n \t\t:first_name,\n \t\t:last_name,\n \t\t:address_line_1,\n \t\t:address_line_2,\n \t\t:city,\n \t\t:state,\n \t\t:zip,\n \t\t:grade,\n \t\t:email,\n :school_id,\n :team_id\n \t\t\t)\n\tend", "def my_model_params\n params[:my_model]\n end", "def params\n @params ||= { }\n end", "def user_params\nend", "def permitted_params(action, kind=nil)\n params.require(model_name).permit!\n end", "def params() request.params end", "def params\n @@params\n end", "def model_input_params\n params.require(:model_input).permit(:model_id, :input_id, :source_id, :units, :quantity, :actType)\n end", "def valid_params?; end", "def modify_new_model_params(model_params)\n\tend", "def params\n return self.class.params\n end", "def additional_permitted_params\n []\n end", "def extra_param_params\n params.require(:extra_param).permit(:title, :weight, :formula_id)\n end", "def params\n @params ||= self.class.params.dup\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def query_params; end", "def model_params\n params.require(:search_field).permit(:name, :title, :sort_order, :options)\n end", "def resource_params\n @resource_params ||= current_model_service.permit params\n end", "def model_params\n #params[:model][:model_products] ||= []\n params.require(:model).permit(:make_id, :material_id, :name, :price, :model_products)\n end", "def params=(_); end", "def parameters\n @params.extra_parameters\n end", "def allowed_params\n ALLOWED_PARAMS\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def initialize\n super()\n @params = {}\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def <%= singular_name %>_params\n params.require(:<%= singular_name %>).permit(<%= attributes_allowed %>)\n end", "def model_params\n \tparams.require(:model).permit(:name, :engine_size, :sold, :company_id)\n end", "def permit_params\n params.require(:permit).permit(:permit_type, :applicant_name, :start_date, :end_date, :address, :payload, :geometry)\n end", "def params\n @parameters\n end", "def model_params\n params.require(:model).permit(:code, :name, :brand_id, :manufacture_id, :body_type_id, :note)\n end", "def params\n { :only => self.attrs, :methods => self.methds }\n end", "def model_params\n params.require(:web_hook).permit(:url, :method, :model_type, :event_type, :auth_type, :auth_params, :default_params)\n end", "def model_params\n if Rails.version < '4.0'\n params[model_identifier]\n else\n params.require(model_identifier).permit(permitted_attrs)\n end\n end", "def resource_params\n raise NotImplementedError\n end", "def build_permitted_params\n super + [\n { date_of_work_attributes: permitted_time_span_params },\n { inscription_attributes: permitted_inscription_params },\n { additional_credit_attributes: permitted_additional_credit_params },\n after: [],\n artist: [],\n attributed_to: [],\n author: [],\n addressee: [],\n creator_of_work: [],\n contributor: [],\n editor: [],\n engraver: [],\n interviewee: [],\n interviewer: [],\n manner_of: [],\n school_of: [],\n manufacturer: [],\n photographer: [],\n printer: [],\n printer_of_plates: [],\n publisher: [],\n place_of_interview: [],\n place_of_manufacture: [],\n place_of_publication: [],\n place_of_creation: [],\n ]\n end", "def initialize\n @params = {}\n end", "def params\n { :only => self.attrs, :methods => self.methds }\n end", "def attrs\n if options[:permit]\n controller.params.require(model_name).permit(*call(:permit))\n else\n params_method = \"#{name}_params\"\n if controller.respond_to?(params_method, true)\n controller.send(params_method)\n else\n {}\n end\n end\n end", "def input_params\n self.params.input_param\n end", "def params\n controller.params\n end", "def model_params\n params.require(:model).permit(:name, :description, :image, :price)\n end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end" ]
[ "0.7467585", "0.7439998", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7380314", "0.7347787", "0.73304486", "0.73304486", "0.7325422", "0.7325422", "0.7325422", "0.7324478", "0.7310853", "0.72877604", "0.72685343", "0.721233", "0.721233", "0.71830153", "0.71727127", "0.7154309", "0.714902", "0.7060356", "0.7036508", "0.7033175", "0.7033175", "0.70245665", "0.7020624", "0.70092446", "0.70067984", "0.69959325", "0.69925076", "0.6972119", "0.69047993", "0.6898178", "0.6884967", "0.68788457", "0.687856", "0.68737745", "0.6864971", "0.6858929", "0.6856333", "0.68421406", "0.6837557", "0.683449", "0.6834124", "0.6823338", "0.6819224", "0.6819147", "0.68081844", "0.68018323", "0.6780195", "0.67749697", "0.6772175", "0.6766698", "0.67662394", "0.6752818", "0.6750907", "0.6741275", "0.67360926", "0.6735543", "0.6732022", "0.6727638", "0.6723254", "0.6712549", "0.67105806", "0.6694601", "0.6692996", "0.6688842", "0.6681349", "0.6680431", "0.667738", "0.66655564", "0.66573143", "0.6656896", "0.66561955", "0.66535217", "0.6652194", "0.66480905", "0.6631293", "0.6630062", "0.66296554", "0.6627901", "0.66270125", "0.66270125", "0.66270125", "0.66270125", "0.66270125" ]
0.0
-1
Performs a HTTP request method Request method (:get, :post, :put, :delete) url Target URL payload Delivery content format Delivery format
def request(method, url, payload, format) opts = { :method => method, :url => url, :payload => payload, :headers => {:content_type => CONTENT_TYPES[format]}, :timeout => TIMEOUT, :open_timeout => OPEN_TIMEOUT } RestClient::Request.execute(opts) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end", "def run_request(method, url, body, headers); end", "def invoke(options = {})\n defaults = { method: 'get'}\n options = defaults.merge(options)\n\n connection.send(options[:method].to_s.downcase) do |req|\n req.url options[:url]\n req.body = options[:body] if options.has_key?(:body)\n options[:params].each { |k,v| req.params[k] = v } if options.has_key?(:params)\n options[:headers].each { |k,v| req.headers[k] = v } if options.has_key?(:headers)\n end\n end", "def execute(url, method, options = {}, payload = nil)\n request, parser = prepare_and_split_options(url, method, options)\n # Prepare the payload if it is provided\n request[:payload] = payload_from_doc(payload, parser) if payload\n begin\n parse_response(RestClient::Request.execute(request), parser)\n rescue Exception => e\n if $DEBUG\n raise \"Error while sending a #{method.to_s.upcase} request #{uri}\\noptions: #{opts.inspect}\\n#{e}\"\n else\n raise e\n end\n end\n end", "def perform_request url, verb = :get, body = nil, options = {}\n options_id = options.inspect\n can_cache = [:post, :put].include?(verb) ? false : cached?\n if can_cache && result = store.get(\"#{clean_url(url)}#{options_id}\")\n return JSON.parse(result)\n end\n response = perform_rate_limited_request(url, verb, body, options)\n store.setex \"#{clean_url(url)}#{options_id}\", ttl, response.to_json if can_cache\n response\n end", "def http(method, url, options = {}, &block)\n case method.to_s.downcase\n when *%w(get put head post delete options patch)\n send method, url, options, &block\n else\n raise \"Invalid method: #{method}\"\n end\n end", "def request(http_method, path, params = {})\n response = connection.send(http_method) do |request|\n case http_method\n when :get, :delete\n request.url(path, params)\n when :post, :put\n request.path = path\n request.body = params unless params.empty?\n end\n end\n\n response.body['response']\n end", "def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end", "def send_request\n if payload\n payload_type = payload.is_a?(String) ? :body : :form\n\n @http.public_send(method, url, payload_type => payload, ssl_context: ssl_options)\n else\n @http.public_send(method, url, ssl_context: ssl_options)\n end\n end", "def perform_request(method,uri)\n url = BASE_URL + uri\n HTTParty.send(method,url)\n end", "def request_over_http(options, http_method, endpoint)\n if http_method == :get\n api_call = endpoint + \"?\" + options.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n URI.parse(api_call).read\n else\n Net::HTTP.post_form(URI.parse(endpoint), options).body\n end\n end", "def _request(url, type, key)\n url = URI(url)\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n req.add_field('X-Vermillion-Key', key)\n req.add_field('Accept', 'application/json')\n req.add_field('Cache-Control', 'no-cache')\n req.add_field('From', @config.get(:user))\n req.add_field('User-Agent', 'Vermillion Client 1.0')\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end", "def make_request(method, url, params = {})\n path = \"#{EbanqApi.base_url}/#{url}\"\n response = case method\n when :get then get(path, headers, params)\n when :post then post(path, headers, params)\n when :put then put(path, headers, params)\n when :delete then delete(path, headers)\n else raise 'Error'\n end\n process_raw_response(response)\n rescue RestClient::ResourceNotFound, SocketError, Errno::ECONNREFUSED => e\n raise e\n end", "def request(params)\n\n # Add auth header\n headers = params[:headers] || {}\n headers['x-vcloud-authorization'] = @auth_key if !@auth_key.nil? || !@auth_key.equal?('')\n\n # set connection options\n options = {:url => params[:url],\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers || {},\n :method => params[:method] || 'GET'\n }\n\n # connect\n res = RestClient::Request.execute options\n\n raise res if (res.code!=params[:expects] && res.code!=200)\n\n res\n\n\n end", "def http_call(payload); end", "def send_request(method, url)\n @response = client.run_request(method, url, @body, headers) do |req|\n req.params = params\n end\n end", "def request(verb, url, payload=nil, headers={})\n url = api_base_url + \"/\" + url\n\n headers = {\n :user_agent => USER_AGENT,\n :accept => :json,\n :accept_encoding => enable_gzip ? :gzip : nil\n }.merge(headers)\n\n opts = {\n :method => verb.to_s,\n :url => url,\n :user => api_key,\n :password => \"\",\n :headers => headers,\n :payload => payload,\n :verify_ssl => ssl_verify,\n }\n begin\n response = RestClient::Request.execute(opts)\n rescue RestClient::Exception => e\n begin\n r = MultiJson.decode(e.response)\n msg = r['message']\n code = r['code']\n rescue\n raise e\n end\n raise VeritableError.new(\"HTTP Error #{e.message} -- #{code}: #{msg}\", {'http_code' => e.message, 'api_code' => code, 'api_message' => msg})\n end\n return MultiJson.decode(response)\n end", "def perform_request(method, path, params, body)\n CONNECTION.run_request \\\n method.downcase.to_sym,\n path,\n ( body ? MultiJson.dump(body): nil ),\n {'Content-Type' => 'application/json'}\n end", "def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end", "def make_request(method, path, params = {}, headers = {})\n if [:post, :put, :patch].include?(method) \n send(method) do |r|\n r.headers.merge!(headers)\n r.url path\n r.body = params.delete(:body).to_json\n end\n else\n send(method, path, params, headers)\n end\n end", "def send_request(api_method, opts = {}, action = :get, endpoint = self.endpoint)\n\n opts.merge! method: api_method, api_key: key\n\n case action\n when :get\n url_string = endpoint + \"?\" + opts.collect{|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n url = URI.parse(url_string)\n req = Net::HTTP::Get.new url.request_uri\n\n Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == 'https') do |http|\n http.request req\n end\n when :post\n Net::HTTP.post_form URI.parse(endpoint), opts\n end\n end", "def request(op, path, data = nil)\n retry_count = 1\n # Save current data for exceptions in handle_response\n @path = @url + path\n @method = op\n @data = data\n begin\n handle_response case op\n when :get\n @server.get_content @path\n when :put\n @server.put @path\n when :delete\n @server.delete @path\n when :post\n @server.post @path, @data, POST_ENCODINGS\n end\n rescue Errno::ECONNRESET\n if retry_count > 0\n retry_count -= 1\n retry\n end\n raise\n end\n end", "def request(action, value=nil, message=nil, header=nil, parse_response=true)\n #param value : value to be concatenated to action path ex: GET host/path/value\n check_token\n hd = header || @headers\n method = action[:method]\n value = '' if !value\n path = action[:path]+value\n begin\n response = perform(method, path, message, hd)\n return parse_response(response) if parse_response\n return response\n rescue GDataError => e\n STDERR.puts \"Error occurred \", e\n return nil\n rescue Exception => e\n STDERR.puts \"Exception occurred \", e\n return nil\n end\n end", "def send_request(options)\n\n # construct our RESTful request URI\n uri = \"#{Base.base_uri}/api/#{options[:target]}\"\n uri += \"/#{options[:id]}\" if options.has_key?(:id)\n uri += \"/#{options[:what]}\" if options.has_key?(:what)\n uri += \".#{options[:how]}\" if options[:method] == \"get\"\n puts \"|--------------------- SEND_REQUEST ---------------------|\"\n puts \"| URI\"\n puts \"| #{uri}\"\n puts \"| Params\"\n puts \"| id => #{options[:id]}\"\n puts \"| what => #{options[:what]}\"\n puts \"| how => #{options[:how]}\"\n puts \"|--------------------- ------------ ---------------------|\"\n \n if @access_token.nil? \n return self.class.send(options[:method] || \"get\", uri, options)\n else\n return @access_token.send(options[:method] || \"get\", uri, options).body\n end\n \n end", "def request(method, path, params)\n response = connection.send(method) do |request|\n case method\n when :get\n request.url(path, params)\n when :put\n params.merge!({\"_method\" => 'put'})\n request.url(path,params)\n when :post\n request.url(path)\n request.body = params\n when :delete\n params.merge!({\"_method\" => 'delete'})\n request.url(path, params)\n end\n end\n \n Response.create(response.body)\n end", "def perform(arguments = {})\n case type.to_sym\n when :post, :get\n api.public_send(type, path, @arguments.merge(arguments))\n else\n raise ArgumentError, \"Unregistered request type #{request_type}\"\n end\n end", "def request(url, type)\n url = URI(URI.encode(url))\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end", "def http verb, path, params={}\n\n to_header = params.delete(:to_header)\n case verb.to_s.downcase\n\n when 'get' # use URL-encoded params for GET requests only\n if to_header\n to_header['Accept'] = MIME_TYPE\n request_opts = {method: verb, headers: to_header, params: params}\n else\n request_opts = {method: verb, headers: {'Accept' => MIME_TYPE}, params: params}\n end\n else # for everything else encode as JSON in the body\n encoded_param = Yajl::Encoder.encode params\n if to_header\n to_header['Content-type'] = MIME_TYPE\n request_opts = {method: verb, headers: to_header, body: encoded_param }\n else\n request_opts = {method: verb, headers: { 'Content-type' => MIME_TYPE }, body: encoded_param }\n\n end\n end\n\n request = Typhoeus::Request.new @base_url+path, request_opts\n\n @hydra.queue request\n\n RequestPromise.new(request).then do |response|\n # we always expect JSON from successful responses\n response_meta(response).merge Yajl::Parser.parse(response.body, symbolize_keys: true)\n end\n end", "def request(method, path, params)\n full_path = format_request_uri(path, params)\n request = VERB_MAP[method.to_sym].new(full_path)\n # TODO - Enable when supporting other HTTP Verbs\n # request.set_form_data(params) unless method == :get\n\n @logger.debug \"#{method.to_s.upcase} #{path}\"\n @http.request(request)\n end", "def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def send_request(target, payload = {}, id = '')\n if valid_endpoint?(target)\n send_post(get_path_for_endpoint(target, id), payload)\n else\n { 'error' => \"#{target} is not a valid endpoint\" }\n end\n end", "def run_request(method, url, body, headers)\n original_run_request(method, url, \"\", headers)\n end", "def request(verb, uri, opts = T.unsafe(nil)); end", "def execute_request(request:, payload:, api_config:)\n http_request = HTTPI::Request.new(request.url.try(:to_s))\n http_request.body = payload\n\n if api_config[:http_basic_username] && api_config[:http_basic_password]\n http_request.auth.basic(api_config[:http_basic_username], api_config[:http_basic_password])\n end\n\n http_request.auth.ssl.verify_mode = api_config[:ssl_verify_mode] || :peer\n http_request.open_timeout = api_config[:timeout] || 30\n http_request.read_timeout = api_config[:timeout] || 30\n\n if block_given?\n http_request = yield http_request\n end\n\n request.http_request = http_request\n\n begin\n response = HTTPI.request(request.action.http_method, http_request)\n request.http_response = response\n rescue => e\n raise RequestError.new(e, request)\n end\n\n if response.error?\n raise RequestError.new(\"#{request.action.http_method} #{request.url} returned #{response.code}\", request)\n end\n\n request\n end", "def request(method, path, options)\n response = connection.send(method) do |request|\n case method\n when :get\n formatted_options = format_options(options)\n request.url(path,formatted_options)\n when :post, :put\n request.headers['Content-Type'] = 'application/json'\n request.body = options.to_json unless options.empty?\n request.url(path)\n end\n end\n \n Response.create(response.body)\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def api_request(path, method, body)\n uri = call_uri(path)\n req = Net::HTTP.const_get(method)\n .new(uri,\n \"Content-Type\": 'application/json; charset=utf-8',\n \"Cache-Control\": 'no-cache')\n req.body = body\n Net::HTTP.new(uri.hostname, uri.port).start { |http| http.request(req) }\n end", "def generate_request(url, method, prepped_json = nil)\n uri = URI.parse url\n http = Net::HTTP.new uri.host, uri.port\n \n if uri.instance_of? URI::HTTPS\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n if method == 'post'\n request = Net::HTTP::Post.new uri.request_uri\n else\n request = Net::HTTP::Get.new uri.request_uri\n end\n request.add_field 'Content-Type', 'application/json'\n request.add_field 'Authorization', 'JWT ' + SiteSetting.moderator_json_web_token\n \n if prepped_json\n request.body = prepped_json\n end\n\n return http.request request\n end", "def make_rest_call(method, url, payload = nil, headers = nil)\n options = call_options_builder(method, url, payload, headers)\n RestClient::Request.execute(options)\n rescue => e\n raise e\n end", "def get(url); end", "def post url, payload\n RestClient::Request.execute(:method => :post, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def perform_request(request_method, path, options = {})\n Teamsupport::REST::Request.new(self, request_method, path, options).perform\n end", "def request(http_method, path, body = '', headers = {})\n puts \"#{http_method}: #{path} - [#{body}]\" if @http_debug\n @request_client.request(http_method, path, body, headers)\n end", "def get endpoint\n do_request :get, endpoint\n end", "def perform(method, path, body=nil, header=nil)\n\t\t\treq = Net::HTTPGenericRequest.new(method, !body.nil?, true, path)\n\t\t\treq['Content-Type'] = header['Content-Type'] if header['Content-Type']\n\t\t\treq['Authorization'] = header['Authorization'] if header['Authorization']\n\t\t\treq['Content-length'] = body.length.to_s if body\n\t\t\tresp = @http_connection.request(req, body)\n\t\t\treturn resp\n\t\tend", "def send_post_request(url, payload, content_type = 'application/json')\n # set the uri\n url = URI(url)\n\n # set http settings\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # set request\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = content_type\n request[\"cache-control\"] = 'no-cache'\n\n # set the payload\n request.body = payload\n\n # send the request and get whatever is the response\n response = http.request(request)\n\n # return the response by reading the body\n return response.read_body\n end", "def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end", "def request(method, path, options)\n conn = connection(options)\n conn.instance_variable_set(:@parallel_manager, options[:parallel_manager]) if options[:parallel_manager]\n #binding.pry\n response = conn.send(method) do |request|\n #path = formatted_path(path) unless options[:unformatted] # || default_request?\n params = get_params(options)\n case method\n when :get, :delete\n request.url(path, params)\n # binding.pry\n when :post, :put\n request.path = path\n #if options['fileData']\n # request.headers['Content-type'] = 'multipart/form-data'\n # request.body = options\n #else\n #request.headers['Content-Type'] = 'application/json; charset=utf-8'\n request.body = params unless params.empty?\n #end\n end\n if options[:parallel_manager]\n env = request.to_env(conn)\n conn.parallel_manager.responses[env[:url].to_s] = {}\n conn.parallel_manager.responses[env[:url].to_s]['env'] = env\n end\n end\n #\n #binding.pry\n options[:raw] ? response : response.body\n #binding.pry\n end", "def request(method, path, options, _raw = false)\n response = connection.send(method) do |request|\n request.headers[\"Accept\"] = \"application/json\"\n case method\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.params = options[:params] if options[:params]\n request.body = options[:body] if options[:body]\n end\n end\n\n raise NonSuccessResponse, response if response.status >= 400\n\n response\n end", "def execute_http_request(http_method, path, payload = nil)\n response = RestClient::Request.execute(method: http_method, url: path, payload: payload, headers: DEFAULT_HEADERS)\n # handle response using helper\n handle_response(response)\n end", "def httppost(url, corpNum, postData, action = '', userID = '', contentsType = '')\n\n headers = {\n \"x-pb-version\" => BaseService::POPBILL_APIVersion,\n \"Accept-Encoding\" => \"gzip,deflate\",\n }\n\n if contentsType == ''\n headers[\"Content-Type\"] = \"application/json; charset=utf8\"\n else\n headers[\"Content-Type\"] = contentsType\n end\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n if action.to_s != ''\n headers[\"X-HTTP-Method-Override\"] = action\n end\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, postData, headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise PopbillException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n end", "def request(method, path, params={}, opts={})\n options = { url: \"https://#{organization}\" }.merge(opts)\n response = connection(options).run_request(method, nil, nil, nil) do |request|\n if request.options.is_a?(Hash)\n request.options[:timeout] ||= options.fetch(:timeout, 10)\n request.options[:open_timeout] ||= options.fetch(:open_timeout, 10)\n elsif request.options.respond_to?(:timeout)\n request.options.timeout ||= options.fetch(:timeout, 10)\n request.options.open_timeout ||= options.fetch(:open_timeout, 10)\n end\n\n case method.to_sym\n when :delete, :get\n request.url(path, params)\n when :post, :put\n request.path = path\n request.body = MultiJson.dump(params) unless params.empty?\n end\n end\n options[:raw] ? response : response.body\n end", "def request(method, *args)\n path, resource, options = extract_request_args!(*args)\n\n # Do we need the session endpoint?\n url = path =~ /^\\/?sessions/ ? session_endpoint : endpoint\n\n response = connection(url, resource).send(method) do |request|\n case method\n when :get, :delete\n request.url(path, options)\n when :post, :put\n request.path = path\n request.body = options unless options.empty?\n end\n end\n response.body\n end", "def perform_request url\n response = self.class.get(url)\n raise NotFound.new(\"404 Not Found\") if response.respond_to?(:code) && response.not_found?\n raise InvalidAPIResponse.new(response[\"status\"][\"message\"]) if response.is_a?(Hash) && response[\"status\"]\n\n response\n end", "def run\n\n action Colors.grey(\"REQUEST \") + Colors.light_blue(\"#{options[:method].upcase} #{url}\")\n Console.instance.indent\n # run the request\n options[:ssl_verifypeer] = false\n options[:followlocation] = true\n\n Injector.decorate(options)\n\n # convert all headers keys to strings to avoid having symbols like :\"header\" when\n # declaring headers with colons instead of arrows\n if options.key?(:headers)\n new_opts = {}\n options[:headers].map do |k, v|\n new_opts[k.to_s] = v\n end\n options[:headers] = new_opts\n end\n\n if options.key?(:headers) and options[:headers].key?('Content-Type')\n ctype = options[:headers]['Content-Type']\n if ctype.include?('application/json')\n # automatically encode json content\n options[:body] = JSON.generate(options[:body], quirks_mode: true)\n end\n end\n\n\n\n self.response = Typhoeus::Request.new(url, options).run\n\n self.req_response = RequestResponse.new.tap { |r|\n r.raw_body = response.body\n r.headers = response.headers\n r.code = response.code\n r.total_time = response.total_time\n\n if !r.headers.nil? && r.headers.key?('Content-Type') && r.headers['Content-Type'].include?('application/json')\n r.body = JSON.parse(response.body)\n else\n r.body = response.body\n end\n }\n\n # reset assertion counter\n self.assert_no = 1\n\n # evaluate response against expectations\n begin\n instance_eval(&expectations)\n rescue AssertionException\n error error_msg + \" at #{expectations.source_location}\"\n raise RequestException\n rescue StandardError => e\n error 'Exception ' + e.message\n info e.backtrace.inspect\n _debug_info\n error error_msg\n raise RequestException\n ensure\n Console.instance.unindent\n end\n\n req_response\n\n end", "def request(method, path, params)\n params ||= {}\n uri = full_url(path)\n\n Trubl.logger.info(\"Trubl::Client #{method}-ing #{uri} with params #{params.merge(headers: headers)}\")\n response = HTTMultiParty.send(method, uri, params.merge(headers: headers))\n\n if !response.code =~ /20[0-9]/\n Trubl.logger.fatal(\"Trubl::Client #{response.code} #{method}-ing #{uri.to_s} #{response.parsed_response}\")\n else\n Trubl.logger.debug(\"Trubl::Client #{uri} response: #{response.body}\")\n end\n response.body.force_encoding(\"utf-8\") if response.body and response.body.respond_to?(:force_encoding)\n response\n end", "def request(method, args = {})\n params = args.merge({@method_param => method})\n params = params.merge(@default_params)\n endpoint = api_endpoint ? api_endpoint.base_url : @endpoint\n url = endpoint + URI.encode_www_form( params.reject{ |k,v| k == :force_update } )\n request_uri = URI.parse(url)\n response = nil\n begin\n MetaService.fetch_request_uri(args.merge(request_uri: request_uri, timeout: @timeout,\n api_endpoint: api_endpoint,\n user_agent: \"#{Site.default.name}/#{self.class}/#{SERVICE_VERSION}\"))\n rescue Timeout::Error\n raise Timeout::Error, \"#{@service_name} didn't respond within #{@timeout} seconds.\"\n end\n end", "def send_request(method: required('method'), path: nil, url: nil, body: nil,\n content_type: nil, encoding: nil, auth_type: :basic)\n req_type = case method\n when 'GET'\n :get\n when 'POST'\n :post\n when 'PUT'\n :put\n when 'DELETE'\n :delete\n else\n fail 'Method was not \"GET\" \"POST\" \"PUT\" or \"DELETE\"'\n end\n\n raise ArgumentError.new(\"path and url can't be both nil\") if path.nil? && url.nil?\n\n headers = {'User-Agent' => 'UARubyLib/' + Urbanairship::VERSION + ' ' + @key}\n headers['Accept'] = 'application/vnd.urbanairship+json; version=3'\n headers['Content-Type'] = content_type unless content_type.nil?\n headers['Content-Encoding'] = encoding unless encoding.nil?\n\n if @token != nil\n auth_type = :bearer\n end\n\n if auth_type == :bearer\n raise ArgumentError.new('token must be provided as argument if auth_type=bearer') if @token.nil?\n headers['X-UA-Appkey'] = @key\n headers['Authorization'] = \"Bearer #{@token}\"\n end\n\n url = \"https://#{@server}/api#{path}\" unless path.nil?\n\n debug = \"Making #{method} request to #{url}.\\n\"+ \"\\tHeaders:\\n\"\n debug += \"\\t\\tcontent-type: #{content_type}\\n\" unless content_type.nil?\n debug += \"\\t\\tcontent-encoding: gzip\\n\" unless encoding.nil?\n debug += \"\\t\\taccept: application/vnd.urbanairship+json; version=3\\n\"\n debug += \"\\tBody:\\n#{body}\" unless body.nil?\n\n logger.debug(debug)\n\n params = {\n method: method,\n url: url,\n headers: headers,\n payload: body,\n timeout: Urbanairship.configuration.timeout\n }\n\n if auth_type == :basic\n raise ArgumentError.new('secret must be provided as argument if auth_type=basic') if @secret.nil?\n params[:user] = @key\n params[:password] = @secret\n end\n\n response = RestClient::Request.execute(params)\n\n logger.debug(\"Received #{response.code} response. Headers:\\n\\t#{response.headers}\\nBody:\\n\\t#{response.body}\")\n Response.check_code(response.code, response)\n\n self.class.build_response(response)\n end", "def perform_action_url\n begin\n if @urls.has_key?('Action')\n return request(@urls['Action'], {}, {}, METHOD_GET)\n end\n rescue\n raise RETSException.new(\"Unable to follow action URL: '#{$!}'.\")\n end\n end", "def execute_manual_request\n http_method = params[:http_method]\n path = params[:path]\n headers = params[:headers]\n body = params[:body]\n params.each do |key, value|\n if key.start_with?(\"replace_\") && !key.end_with?(\"_by\")\n path.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n headers.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n body.gsub!(\"XXX#{value}XXX\",params[key + \"_by\"]) if params[key + \"_by\"] != \"\"\n end\n end\n if params[:task_id]\n @task = Task.find(params[:task_id])\n @regexpressions = @task.regexpressions\n end\n begin\n if @cloud\n if @cloud.api == \"Atmos\"\n @response, @headers, @url = atmos_request(http_method, path, headers, body)\n elsif @cloud.api == \"Amazon\"\n @response, @headers, @url = amazon_request(http_method, path, headers, body)\n elsif @cloud.api == \"Swift\"\n @response, @headers, @url = swift_request(http_method, path, headers, body)\n end\n else\n url = path\n uri = URI.parse(url)\n headers_to_send = Hash.new\n headers.split(\"\\n\").each do |row|\n hash = eval(row)\n headers_to_send[hash.keys.first.downcase] = hash.values.first.to_s\n end\n if params[:user] != \"\" && params[:password] != \"\"\n login = Base64.urlsafe_encode64(\"#{params[:user]}:#{params[:password]}\")\n headers_to_send[\"Authorization\"] = \"Basic #{login}\"\n end\n @response = http_request(url, uri.port, http_method, headers_to_send, body)\n @headers = headers_to_send\n end\n rescue Exception => e\n @exception = e\n end\n respond_to do |format|\n format.js { render 'shared/execute_manual_request' }\n end\n end", "def call_rest(action, url, headers, ref, body = nil)\n begin\n # change url based on if we have a ref or not\n if ref.nil?\n url = url\n else\n url = url + \"/\" + ref\n end\n\n # set params for api call\n params = {\n :method => action,\n :url => url,\n :verify_ssl => false,\n :headers => headers\n }\n\n # generate payload data\n params[:payload] = body if body\n log(:info, \"call_rest: Request URL: #{url}\")\n log(:info, \"call_rest: Request Action: #{action}\")\n log(:info, \"call_rest: Request Headers: #{headers.inspect}\")\n log(:info, \"call_rest: Request Payload: #{params[:payload]}\")\n\n # execute the request\n RestClient::Request.new(params).execute\n rescue => err\n # log and backtrace the error\n log(:error, \"[#{err}]\\n#{err.backtrace.join(\"\\n\")}\")\n log(:error, \"call_rest: #{err}. Returning nil.\")\n return nil\n end\nend", "def getHttp(fpUri,fpVerb=\"GET\",fpData=\"\")\n\t#@fpUserAgent = \"CMU/2.2 CFNetwork/672.0.8 Darwin/14.0.0\"\n\t@fpUserAgent = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0\"\n\n\thttp = Net::HTTP.new(fpUri.host, fpUri.port)\n\n\tcase fpUri.scheme.upcase\n\t\twhen \"https\".upcase\n\t\t\thttp.use_ssl = true\n\t\t \t# For signature checks it doesn't matter if a valid certificate is present.\n\t\t \thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE if fpUri.scheme.upcase == \"https\".upcase\n\t\telse\n\t\tend\n\n\tcase fpVerb.upcase\n\t\twhen \"Get\".upcase\n\t\t\t# For now forcing encoding to text as some devices being tested have broken compression implemented.\n\t\t\trequest = Net::HTTP::Get.new(fpUri,initheader = {'Accept-Encoding' => 'gzip, default, br', 'User-Agent' => @fpUserAgent}) if fpVerb.upcase == \"Get\".upcase\n\t\t\t# request = Net::HTTP::Get.new(fpUri) if fpVerb.upcase == \"Get\".upcase # Default Header\n\t\t\t\n\t\t\tputs \"GET #{fpUri}\"\n\n\t\twhen \"Post\".upcase\n\t\t\trequest = Net::HTTP::Post.new(fpUri.request_uri) if fpVerb.upcase == \"Post\".upcase\n\t\t\trequest.set_form_data(fpData) if fpVerb.upcase == \"Post\".upcase\n\t\t\n\t\telse\n\t\t\trequestFail = true\n\t\tend\n\n\tresponse = http.request(request) if !requestFail\n\treturn response\nend", "def make_request url, method: ::Rack::GET, body: nil, headers: []\n env = Testing.build_standard_env URI(url), headers\n env[::Rack::REQUEST_METHOD] = method\n env[::Rack::RACK_INPUT] = ::StringIO.new body if body\n ::Rack::Request.new env\n end", "def process_kong_request (url, method, payload)\n begin\n url = kong_url + url\n header = {\n 'Accept' => 'application/json, text/plain, */*',\n 'Content-Type' => 'application/json'\n }\n uri = URI.parse(URI.encode(url.strip))\n http = Net::HTTP.new(uri.host,uri.port)\n\n case method\n when :GET\n req = Net::HTTP::Get.new(uri, header) # GET Method\n when :POST\n req = Net::HTTP::Post.new(uri.path, header) # POST Method\n when :PUT\n req = Net::HTTP::Put.new(uri.path, header) # PUT Method\n when :PATCH\n req = Net::HTTP::Patch.new(uri.path, header) # PATCH Method\n when :DELETE\n req = Net::HTTP::Delete.new(uri.path, header) # DELETE Method\n else\n # Default Case\n end\n\n puts \"HTTP #{ method } to #{ uri.host}:#{ uri.port }. Body: #{ payload.to_json }\"\n body = \"#{ payload.to_json }\"\n res = http.request(req, body)\n if res.body\n JSON.parse(res.body) # Returned Data\n else\n {}\n end\n rescue Exception => e\n puts \"Exception: \" + e.message.to_s + \"\\n\" + e.backtrace_locations.join(\"\\n\") + \"}\"\n { message: e.to_s }.to_json\n end\n end", "def request(method, path, params = {})\n self.class.debug_output($stderr) if @debug\n setup_http_body(method, params)\n \n uri = base_api_uri + path\n response = self.class.send(method.to_sym, uri, @default_params)\n parse(response)\n end", "def request(kind, url, data, options)\n # options passed as optional parameter show up as an array\n options = options.first if options.kind_of? Array\n query_options = self.class.package_query_params(options)\n full_url = URI.parse(\"#{self.url}#{url}#{query_options}\")\n \n # create an object of the class required to process this method\n klass = Object.module_eval(\"::Net::HTTP::#{kind.to_s.capitalize}\", __FILE__, __LINE__)\n request = klass.new([full_url.path, full_url.query].compact.join('?'))\n request = apply_headers(request)\n # take passed data and encode it\n request.body = self.class.body_encoder(data) if data\n \n http = Net::HTTP.new(full_url.host, full_url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n http.read_timeout = 500\n response = http.start do |web|\n web.request(request)\n end\n return self.class.parse_response(response.code, response.body)\n end", "def http_get(payload)\n destination = URI(@collector_uri + '?' + URI.encode_www_form(payload))\n LOGGER.info(\"Sending GET request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Get.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"GET request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end", "def http_call(payload)\n response =\n log_http_call(payload) do\n http = payload[:http] || create_http_connection(payload[:uri])\n http.start do |session|\n if payload[:method] == :get\n session.get(payload[:uri].request_uri, payload[:header])\n else\n session.send(payload[:method], payload[:uri].request_uri, payload[:body], payload[:header])\n end\n end\n end\n handle_response(response)\n end", "def get_request(url)\n\n request = Net::HTTP::Get.new(url)\n request['content-type'] = 'application/x-www-form-urlencoded'\n request['accept'] = '*/*'\n return request\nend", "def http; end", "def post url, object = nil\n request url, HTTP::Post, object\n end", "def requestHelper(url, method = 'Get', body = nil)\n\n # Set header value\n header = {\n 'Content-Type': 'text/json',\n 'Content-Security-Policy': 'default-src *'\n }\n\n # Set the uri value based on the url sent through.\n uri = URI(url)\n # Format request\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n\n # Create new request based on method\n request = Net::HTTP.const_get(method.capitalize).new(uri.request_uri, header)\n request.body = body\n\n # Send the request\n http.request(request) do |response|\n puts uri\n yield(JSON.parse(response.body))\n end\n end", "def request(method, path, params)\n self.class.send(method, path, params)\n end", "def get(path, payload = nil)\n req = Net::HTTP::Get.new(path)\n action(req, payload)\n end", "def request(type, url, params = {})\n request = Request.new(type, url, params)\n make_request(request)\n\n update_history(request)\n end", "def perform_request(method, path, params={}, body=nil, headers=nil)\n client.perform_request method, path, params, body, headers\n end", "def perform(method, path, body=nil, header=nil)\n req = Net::HTTPGenericRequest.new(method, !body.nil?, true, path)\n req['Content-Type'] = header['Content-Type'] if header['Content-Type']\n req['Authorization'] = header['Authorization'] if header['Authorization']\n req['Content-length'] = body.length.to_s if body\n resp = @http_connection.request(req, body)\n return resp\n end", "def request(method, path, options, headers)\n headers.merge!({\n 'User-Agent' => user_agent,\n 'Accept' => 'application/vnd.urbanairship+json; version=3;',\n })\n\n response = connection.send(method) do |request|\n request.url(\"#{endpoint}#{path}/\")\n\n if [:post, :put].member?(method)\n request.body = options.to_json\n else\n request.params.merge!(options)\n end\n\n request.headers.merge!(headers)\n end\n\n Utils.handle_api_error(response) unless (200..399).include?(response.status)\n\n Utils.parse_message(response)\n end", "def get_request\n # Use our @http_object object's request method to call the\n # Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def request(method, path, *arguments)\n puts \"REQUEST #{path} #{arguments.inspect}\"\n uri = URI.parse( path )\n request_http = http\n if uri.host\n path = uri.request_uri #includes params unlike path()\n request_http = Net::HTTP.new(uri.host, uri.port) #ignores @timeout and @proxy\n else\n uri = site\n end\n puts \"URI #{uri.inspect}\"\n result = ActiveSupport::Notifications.instrument(\"request.active_resource\") do |payload|\n payload[:method] = method\n payload[:request_uri] = \"#{uri.scheme}://#{uri.host}:#{uri.port}#{path}\"\n payload[:result] = request_http.send(method, path, *arguments)\n end\n handle_response(result)\n rescue Timeout::Error => e\n raise TimeoutError.new(e.message)\n rescue OpenSSL::SSL::SSLError => e\n raise SSLError.new(e.message)\n end", "def request(method)\n unless ::HTTP::Request::METHODS.include? method\n raise NotSupportedError, \"http.rb does not support custom HTTP methods\"\n end\n response = begin\n @client.send(method, @request.url, :body => @request.body)\n rescue OpenSSL::SSL::SSLError\n raise SSLError\n end\n\n Response.new(response.code, response.headers.to_h, response.body.to_s)\n end", "def http( *args )\n p http_get( *args )\n end", "def request(method, path, params, options)\n params2 = prepare_params(params)\n url = URI::HTTP.build({:host => API_ENDPOINT, :path => path,\n :query => URI.encode_www_form(params2)})\n\n case method\n when :get\n req = Net::HTTP::Get.new url.request_uri\n when :post\n case options[:type]\n when :form\n req = Net::HTTP::Post.new url.path\n req.form_data = params\n when :multipart\n req = Net::HTTP::Post::Multipart.new url.path, params\n else\n # TODO: Revise\n req = Net::HTTP::Post.new url.request_uri\n end\n end\n\n res = Net::HTTP.start(url.host, url.port) do |http|\n http.request(req)\n end\n\n parse_response(res.body)\n end", "def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end", "def request(method, path, body = nil)\n Excon.send(method, @url, :path => path, :headers => web_proxy_headers, :body => body, :connect_timeout => @connect_timeout)\n end", "def request(method, path, params = {}, body = {}, headers = {})\n meta_headers = { authorization: decide_authorization(params), user_agent: request_user_agent }\n headers = if !headers.is_a?(Hash)\n meta_headers\n else\n headers.merge(meta_headers)\n end\n\n @transport.perform_request(method.to_s.upcase, path, params, body, headers)\n end", "def request(action, params = T.unsafe(nil), header = T.unsafe(nil), query = T.unsafe(nil)); end", "def consume_url; end", "def run_request(method, path, body, headers)\n klass = Net::HTTP.const_get(method.to_s.capitalize)\n req.klass.new(path, headers)\n req.body = body if body\n request(req)\n end", "def http_request(action, data, method_type = 'POST', binary_key = nil)\n\n uri = \"#{@api_uri}/#{action}\"\n if method_type != \"POST\" && (!method_type.is_a? String)\n uri += \"?\" + data.map{ |key, value| \"#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}\" }.join(\"&\")\n end\n\n req = nil\n\n _uri = URI.parse(uri)\n\n headers = {\n \"Content-Type\": \"text/json\",\n \"Api-Key\":\"#{@api_key}\"\n }\n\n if method_type == 'POST'\n req = set_up_post_request(\n _uri, data, headers, binary_key\n )\n\n else\n request_uri = \"#{_uri.path}?#{_uri.query}\"\n if method_type == 'DELETE'\n req = Net::HTTP::Delete.new(request_uri, headers)\n else\n req = Net::HTTP::Get.new(request_uri, headers)\n end\n end\n\n begin\n http = Net::HTTP::Proxy(@proxy_host, @proxy_port).new(_uri.host, _uri.port)\n\n if _uri.scheme == 'https'\n http.ssl_version = :TLSv1\n http.use_ssl = true\n http.set_debug_output $stderr\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @verify_ssl != true # some openSSL client doesn't work without doing this\n http.ssl_timeout = @opts[:http_ssl_timeout] || 5\n end\n http.open_timeout = @opts[:http_open_timeout] || 5\n http.read_timeout = @opts[:http_read_timeout] || 10\n http.close_on_empty_response = @opts[:http_close_on_empty_response] || true\n\n\n response = http.start do\n http.request(req)\n end\n\n rescue Timeout::Error, Errno::ETIMEDOUT => e\n raise UnavailableError, \"Timed out: #{_uri}\"\n rescue => e\n raise ClientError, \"Unable to open stream to #{_uri}: #{e.message}\"\n end\n\n response.body || raise(ClientError, \"No response received from stream: #{_uri}\")\n end", "def get path = \"\", payload = {}\n make_request(path, \"get\", payload)\n end", "def call\n resource = base_resource\n\n response = (\n case request_method\n when :get\n resource.get fill do |req|\n (req.body = source) if source\n end\n when :head\n resource.head fill\n when :delete\n resource.delete(fill) do |req|\n req.body = source if source\n end\n when :post\n resource.post(fill, source)\n when :put\n resource.put(fill, source)\n end\n )\n \n response\n end", "def send_get_request endpoint, params={}, api_key=nil, ssl=false #https://api.vpsmatrix.net/uploads/get_file_list\n uri = URI.parse(endpoint)\n uri.query = URI.encode_www_form(params)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if ssl\n req = Net::HTTP::Get.new(uri.path)\n req['authorization'] = \"Token token=#{api_key}\" if api_key\n http.request(req)\n end", "def request(url, body)\n #res = HTTParty.post(url, body: body, headers: {'Content-Type' => 'application/soap+xml; charset=\"utf-8\"'}, :verify => false)\n res = HTTParty.post(url, body: body, headers: {'Content-Type' => 'application/soap+xml; charset=\"utf-8\"'}, :verify => false)\n p \"response is: #{res}. response body is: #{res.body} for url: #{url}\"\n content = JSON.parse(res.body)\n end", "def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end", "def http_methods(path, http_verb, data = '', content_type = 'application/json')\n uri = URI(path.to_s)\n headers = {\n 'Content-Type' => 'application/json'\n }\n case http_verb\n when :get\n http_method = Net::HTTP::Get.new(uri, headers)\n http = Net::HTTP.new(uri.host, uri.port)\n return http.request(http_method)\n # return Net::HTTP.get(uri)\n when :put\n http_method = Net::HTTP::Put.new(uri, headers)\n when :post\n http_method = Net::HTTP::Post.new(uri, headers)\n when :delete\n http_method = Net::HTTP::Delete.new(uri, headers)\n else\n # Throw / log exception\n end\n # Request with body for Post/Put verbs and return response\n http_method.body = data.to_json unless data.nil?\n http = Net::HTTP.new(uri.host, uri.port)\n http.request(http_method)\n end", "def fetch(url, params, method=nil)\n if method && method == 'GET'\n url = build_get_uri(url, params)\n end\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n #http.use_ssl = true\n\n if method && method == 'GET'\n req = Net::HTTP::Get.new(uri.request_uri)\n elsif method && method == 'DELETE'\n req = Net::HTTP::Delete.new(uri.request_uri)\n elsif method && method == 'PUT'\n req = Net::HTTP::Put.new(uri.request_uri)\n req.set_form_data(params)\n else\n req = Net::HTTP::Post.new(uri.request_uri)\n req.set_form_data(params)\n end\n req.basic_auth(@id, @token)\n\n return http.request(req)\n end", "def request(verb, url, params={}, headers={})\n if (verb == :get) || (verb == :delete)\n resp = connection.run_request(verb, url, nil, headers) do |req|\n req.params.update(params)\n end\n else\n resp = connection.run_request(verb, url, params, headers)\n end\n\n case resp.status\n when 200...299\n Response.new(resp)\n when 302\n request(verb, resp.headers['location'], params, headers)\n when 400...599\n response = Response.new(resp)\n e = Error.new(response)\n raise e if options[:raise_errors]\n response.error = e\n response\n else\n raise Error.new(Response.new(resp)), \"Unhandled status code value of #{resp.status}\"\n end\n end", "def request(klass, path, data={})\n url = url(path)\n http = http(url)\n req = build_request(klass, url, data)\n resp = http.request(req) # send request\n load_json(resp)\n end", "def execute_http_request (method, url, args)\n @http_request = method, url.clone, args.clone\n self.http_response = HTTParty.send method, url, args\n Log.debug \"#{@http_response.request.http_method.to_s.split('::').last.upcase} - URL: #{@http_response.request.last_uri}\"\n Log.debug 'HEADER:'\n Log.debug http_response.request.options[:headers]\n # Log.debug @http_response.request.options[:body] if @http_response.request.options[:body]\n Log.debug 'BODY:' if http_response\n Log.debug http_response if http_response\n http_response\n end" ]
[ "0.68332547", "0.6700983", "0.6639594", "0.6551825", "0.65194184", "0.6514597", "0.6471604", "0.6460943", "0.63053584", "0.626688", "0.6263862", "0.62524426", "0.62160903", "0.62027645", "0.62000614", "0.6195601", "0.61842906", "0.6175784", "0.6171844", "0.61623764", "0.6160641", "0.6154923", "0.61531216", "0.61443084", "0.6127618", "0.6105761", "0.6095201", "0.6094292", "0.6084945", "0.608163", "0.60738236", "0.6068524", "0.6063174", "0.6056959", "0.6052322", "0.6050079", "0.6049196", "0.6048386", "0.6037271", "0.60201305", "0.60142756", "0.6006678", "0.5993169", "0.5987352", "0.59687144", "0.59681135", "0.59516495", "0.59511894", "0.5951099", "0.59372205", "0.5937171", "0.5934564", "0.59311825", "0.5931036", "0.5929849", "0.59261775", "0.592124", "0.592083", "0.59095865", "0.5908531", "0.5898885", "0.5897148", "0.58962893", "0.5896075", "0.5886766", "0.58853906", "0.5881005", "0.58788", "0.58759993", "0.5870478", "0.5869231", "0.5857529", "0.5854722", "0.58517194", "0.5847372", "0.5846959", "0.5844955", "0.58407354", "0.58282506", "0.58257663", "0.58246666", "0.5817859", "0.58110857", "0.5809704", "0.5808411", "0.580751", "0.5802117", "0.57994527", "0.57945174", "0.5790939", "0.5784812", "0.5782188", "0.57790774", "0.5776396", "0.57752335", "0.577424", "0.57698625", "0.576292", "0.5762897", "0.57580507" ]
0.72402686
0
Ex: to get substring you need to use regex scanning String1 = " " String1.scan( /])>/).last.first
def initialize(sym_str) # We get the name from the string first @nom = sym_str.split(" (").first # Then we get the parenthesis if it exists parenth_scan = sym_str.scan(/\(([^>]*)\)/) parenth = parenth_scan.first ? parenth_scan.first.first : nil if parenth # 2/1:3:4 @position = parenth.split("/").first # Scan for 1:3:4 to get the number parenth_sub = parenth.split("/").size == 2 ? parenth.split("/").last : "" @specifics = parenth_sub.split(":") else @position = -1 @specifics ||= [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def substring_up_to_match\n @matches.nil? ? nil : @buffer.match(expr_substring_to_match)[0]\n end", "def extract_string(range, strscan); end", "def first(string)\n return string[0]\nend", "def find_substring_4(string, substring)\n string.match(substring) ? string.match(substring).begin(0) :false\n end", "def substring_remainder\n if @matches.nil?\n @buffer\n else\n start_index = substring_up_to_match.length\n @buffer[start_index..-1]\n end\n end", "def cutinfo(string)\n inf=/\\024/=~string1\n inf=inf+2\n trans=string1[inf..-1]\nend", "def inner(str)\n str[str.rindex('(')..str.index(')')] rescue nil\nend", "def substrings_at_start2(str)\n result = []\n (0..str.size - 1).each { |idx| result << str[0..idx] }\n result\nend", "def function(str,start_position, end_position) #the method of return substring\n\tstr1=str.split(\"\")\n\tstr2=[]\n\tj=0\n\tfor i in start_position-1...end_position\n\t\tstr2[j]=str1[i]\n\t\tj+=1\n\tend\n\treturn str2\nend", "def substrings_at_start(string)\n array_of_strings = []\n split_string = string.split('')\n substring = ''\n split_string.each_index do |position|\n substring += split_string[position]\n array_of_strings << substring\n end\n array_of_strings\nend", "def middle_substring(str)\n mid = str.length/2\n if str.length%2==0\n return str[mid-1..mid]\n else\n return str[mid]\n end\nend", "def rest\n return self.string[self.pos..(self.string.size)] \n end", "def substrings(string)\n\nend", "def middle_substring(str)\n length = str.length\n if length.odd?\n str[length/2]\n else\n str[length/2-1,2]\n end\nend", "def substring(str)\n subs = []\n start_idx = 0\n 0.upto(str.length - 2) do |i1|\n 1.upto(str.length - 1) do |i2|\n subs << str[i1..i2] if i2 > i1\n end\n end\n subs\nend", "def get_first_half_of_string(string)\n string[0..(string.length-1)/2]\nend", "def substrings(string)\r\n \r\nend", "def get_first_half_of_string(string)\n string[0..(string.length - 1)/2]\nend", "def substrings_at_start(str)\n\n results = []\n\n str.chars.each_with_index do |ss, idx|\n results << str.slice(0..idx)\n end\n\n results\n\nend", "def substrings_at_start(string)\n string.split(\"\").map.with_index do |_, index|\n string[0..index]\n end\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |idx|\n result << string[0..idx]\n end\n p result\nend", "def first_token(string)\n str = string.match(@word)\n\n # Return if nothing matched.\n return nil, string if not str\n \n # If a create a new item with the data from regex. :tag is optional.\n token = Token.new(string[str.begin(:start)..str.end(:end)], str[:word], (str.names.include?('tag')? str[:tag] : nil))\n\n # puts \"TOKEN: #{token} // #{string[str.end(:end)..-1]}\"\n\n # Then return it with a section cut off the original string\n return token, string[str.end(:end)..-1]\n end", "def exclude_first(str)\n str.slice(1,str.length-1)\n end", "def find_substring(string, substring)\n\n sub_len = substring.length\n # 3\n str_len = string.length\n # 5\n i = 0\n\n\n (str_len - sub_len).times do\n # 2\n if string[i] == substring[0]\n if string[i..(i+sub_len-1)] == substring\n # sublen -1 because starting on first letter\n return true\n end\n end\n i += 1\n end\n\n false\nend", "def middle_substring(str)\n return str[str.length/2] if str.length % 2 != 0\n str[str.length/2-1] + str[str.length/2]\nend", "def customIndex(string , substring)\n if string.include?(substring)\n length=substring.length\n string.chars.each_with_index do |ele , index|\n sequence=string[index , length]\n return index if sequence==substring\n end\n else\n return nil\n end\nend", "def middle_substring(str)\n mid = str.length / 2\n str.length.even? ? str[mid-1..mid] : str[mid]\nend", "def substrings(str)\n str_arr = []\n 0.upto(str.length - 2) do |index|\n index.upto(str.length - 1) do |sub_endpoint|\n str_arr << substring(str, index, sub_endpoint ) unless index == sub_endpoint\n end\n end\n str_arr\nend", "def substrings_at_start(str)\n str.chars.map.with_index { |_, idx| str[0, idx + 1] }\nend", "def extract(regex)\n data = self.match(regex)\n return nil unless data\n if data.size > 2\n return *(data.to_a[1..-1])\n elsif data.size == 2\n return data[1]\n else\n return data[0]\n end\n end", "def middle_substring(str)\r\n # your code goes here\r\n x = str.length\r\n if x % 2 == 1\r\n return str[x/2]\r\n else\r\n str[x/2 - 1] + str[x/2]\r\n end\r\nend", "def substrings_at_start(str)\r\n chars = str.chars\r\n chars.each_with_object([]).with_index { |(el,memo), idx| memo << chars.take(idx+1).join('').to_s }\r\nend", "def substrings_at_start(str)\n results = []\n substring = ''\n \n str.chars.each do |char|\n substring += char\n results << substring\n end\n \n results\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0\r\n num_chars = 2\r\nend", "def get_version(str)\n\tmatches = str.match(VERSION_REGEX)\n\treturn matches[0].gsub(/[\\(\\)]/, '')\nend", "def substrings(string)\n result = []\n 0.upto(string.size-1) do |index1|\n index1.upto(string.size-1) do |index2|\n result << string[index1..index2]\n end \n end\n result\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |index|\n result << string[0..index]\n end\n result\nend", "def detect_string_inside_string(str)\n ary=str.split(/(\\\")/)\n inside,res=false,[\"\"]\n ary.each_index do |cpt|\n if ary[cpt]==\"\\\"\" and cpt>0 and ary[cpt-1][-1,1]!=\"\\\\\" #lookbehind \n if inside\n res[-1] += \"\\\"\" #end of the previous string\n res << \"\" unless cpt == ary.length-1 #new string\n else\n res << \"\\\"\" #beginning of a string\n end\n inside = !inside\n else\n res[-1]+=ary[cpt]\n end\n end\n return res\n end", "def similar_match str\n if !str || str == ''\n return Regexp.new('.*')\n end\n str_array = str.split('')\n reg_str = '(.*?)'\n str_array.each do |x| \n reg_str += \"#{x}(.*?)\"\n end\n\n return reg_str\n end", "def extract!(aValue=$/,aString=self)\n\t\tif aValue.is_a? String\n\t\t\tif i = aString.index(aValue)\n\t\t\t\taString[i,aValue.length] = ''\n\t\t\t\treturn aValue\n\t\t\telse\n\t\t\t\treturn nil\n\t\t\tend\n\t\telsif aValue.is_a? Regexp\n\t\t\tif md = aValue.match(aString)\n\t\t\t\taString[md.begin(0),md.end(0)-md.begin(0)] = ''\n\t\t\t\treturn md.to_s\n\t\t\telse\n\t\t\t\treturn nil\n\t\t\tend\n\t\telse\n\t\t\treturn aString\n\t\tend\n\tend", "def get_main_section(string)\n string.split(\"[End of section] \\n\")[2]\n end", "def middle_substring(str)\n mid = str.length / 2\n str.length.odd? ? str[mid] : str[mid-1..mid]\nend", "def get_middle(s)\n return s if s.size == 1 || s.size == 2\n get_middle(s[1..-2])\nend", "def middle_substring(str)\n middle_left = str.length / 2\n middle_right = middle_left - 1\n if str.length % 2 == 0\n return \"#{str[middle_right]}#{str[middle_left]}\"\n else\n return \"#{str[middle_left]}\"\n end\nend", "def get_middle(str)\n str.length.even? ? str.slice(str.length / 2 - 1, 2) : str.slice(str.length / 2)\nend", "def substrings(str)\n str.split(//).map.with_index { |_, idx| substrings_at_start(str[idx..-1]) }.flatten\nend", "def full_text_after_substring\n if include_substring?\n self.split( @substring )[1] || \"\"\n else\n self.unpack( \"U*\" )[ self.unpack( \"U*\" ).size/2+1..-1 ].pack( \"U*\" )\n end\n end", "def middle_substring(str)\n n = str.length / 2\n if str.length % 2 == 0\n str[(n-1)..(n)]\n else\n str[n]\n end\nend", "def substring(str, substr)\n\nend", "def substrings_at_start(string)\n string.chars.map.with_index { |_, index| string[0..index] }\nend", "def substrings(string)\n result = []\n 0.upto(string.length - 1) do |index|\n 1.upto(string.length - index) do |length|\n result << string[index,length]\n end\n end\n result\nend", "def get_first_half_of_string(string)\n half_string = (string.length.to_f/2).ceil\n string[0,half_string] \nend", "def middle_substring(str)\n\ta = str.chars\n\twhile (a.length >= 3)\n\t\ta.pop\n\t\ta.shift\n\tend\n\ta.join\nend", "def grab_sin(string)\n match = /\\s(\\d{3}-\\d{3}-\\d{3})(\\D|$)/.match(string)\n unless match == nil\n return match.captures[0].to_s\n end\n end", "def penultimate(string)\n new_string = string.split[-2] \nend", "def findARG(thing, index)\r\n\r\n aux = thing.strip.downcase\r\n result = aux.split\r\n\r\n first_word = result[0]\r\n second_word = result[1]\r\n\r\n len = first_word.length\r\n\r\n if index == 0 && first_word.start_with?(\"!\")\r\n target = first_word.slice(1..len)\r\n return target\r\n end\r\n\r\n if index == 1\r\n return second_word\r\n end\r\nend", "def find_string(string)\n array = string.split(\" \")\n (1...array.length).each do |i|\n if (array[i] == array[i-1] && array[i] != array[i+1]) || (array[i] == array[i+1] && array[i] != array[i-1])\n return array[i]\n end\n end\nend", "def find_longest_substring(string)\n matches = []\n (string.length/2).downto(0) do |length|\n max_shift = (string.length - length*2)\n matches = (0..max_shift).map do |shift|\n looking_for = string[(shift)..(shift+length-1)]\n looking_in = string[(shift+length)..-1]\n \n puts \"looking for:#{looking_for} in:#{looking_in}\" if VERBOSE\n (looking_in.include?(looking_for) || nil) && looking_for\n end\n return matches.compact.uniq.join(', ') if matches.compact.any?\n end\n return nil\nend", "def middle_substring(str)\n median = (str.size / 2)\n str.length.even? ? str[(median - 1)..median] : str[median]\nend", "def on_call_substring(context, haystack, start, length = nil)\n haystack_str = on_call_string(context, haystack)\n start_index = on_call_number(context, start).to_i - 1\n\n if length\n length_int = on_call_number(context, length).to_i - 1\n stop_index = start_index + length_int\n else\n stop_index = -1\n end\n\n return haystack_str[start_index..stop_index]\n end", "def rest\n @string[@pos..-1]\n end", "def substrings_at_start(string)\n sub_strings = []\n 1.upto(string.size) do |count|\n sub_strings << string[0, count]\n end\n\n sub_strings\nend", "def substrings(string)\n arr = []\n string.each_char.with_index do |char1, idx1|\n arr << char1\n \n idx2 = idx1 + 1\n while idx2 < string.length\n arr << string[idx1..idx2]\n \n idx2 += 1\n end\n \n end\n\n arr\nend", "def substrings_at_start(str)\n str.chars.map.with_index do |_, i|\n str[0..i]\n end\nend", "def custom_start(str, sub_str)\n str_plc, sub_len = str, sub_str.length\n #str_plc.slice(0, sub_len) == sub_str\n str_plc[0, sub_len] == sub_str\nend", "def get_first_half_of_string(string)\n\tnumber_of_characters = string.chars.count\n\thalf = (number_of_characters/2.0).ceil\n\tstring.slice(0, half)\nend", "def first_word(str); str.split.first end", "def substrings_at_start(string)\n substring = string\n results = []\n n = -1\n \n string.length.times do\n results << substring\n substring = substring.chop\n end\n \n results.reverse\nend", "def middle_substring(str)\n output_str = ''\n\n if str.length % 2 == 1\n odd_i = str.length / 2\n output_str += str[odd_i]\n else\n even_i1 = str.length / 2 - 1\n even_i2 = (str.length / 2)\n\n output_str += str[even_i1]\n output_str += str[even_i2]\n end\n\n output_str\nend", "def resume_builder(file_2data, regex)\n\t\t\tper = \"Not Found\"\n\n\t\t\tfor j in 0..file_2data.length-1\n\t\t\t\tif file_2data[j].match(regex)\n\t\t\t\t\tper = file_2data[j]\n\t\t\t\t\tper = per.split(\" \")[0]\n\t\t\t\t\treturn per\n\t\t\t\tend\n\t\t\tend\n\t\t\treturn per\n\t\tend", "def substrings_at_start(str)\n result_arr = []\n 0.upto(str.size-1) do |num|\n result_arr << str[0..num]\n end\n result_arr\nend", "def custIndex(string, substring)\n return nil unless string.include?(substring)\n length = substring.length\n string.chars.each_with_index do |char, index|\n sequence = string[index, length]\n return index if sequence == substring\n end\nend", "def substrings_at_start(str)\n str.each_char.map.with_index do |char, index|\n str[0..index]\n end\nend", "def middle_substring(str)\n mid = str.length / 2\n str.length.odd? ? str[mid] : str[mid - 1] + str[mid]\nend", "def remove_first(input, string); end", "def get_sandwich(str)\n\n (str.size - 2).times do |i|\n slice = str[i..(i + 4)]\n if slice == \"bread\"\n slice = str[5..(str.size-6)]\n return slice\n end\n end\nend", "def first_word(string)\n\treturn string.split.first \nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.length) { |n| result << string.slice(0, n) }\n result\nend", "def substrings_at_start(string)\n result = []\n index = 0\n while index < string.size\n result << string[0..index]\n index += 1\n end\n result\nend", "def substrings_at_start(string)\n result = []\n string.length.times { |idx| result << string[0..idx] }\n result\nend", "def substrings_at_start(string)\n string.size <= 1 ? [string] : [substrings_at_start(string.chop), string].flatten\nend", "def substrings_at_start(string)\n substrings = []\n 1.upto(string.length) do |index|\n substrings << string.slice(0, index)\n end\n substrings\nend", "def substrings_at_start(str)\n counter = 1\n array = str.chars\n return_array = []\n\n loop do\n break if counter > array.size\n return_array << array.take(counter).join\n counter += 1\n end\n return_array\nend", "def get_middle(string)\n half, remainder = string.size.divmod(2)\n middle = (half + remainder) - 1\n string.size.even? ? string[middle..(middle + 1)] : string[middle]\nend", "def substrings_at_start(string)\n substrings = []\n string.chars.each_with_index do | _, idx |\n substrings << string.slice(0..idx)\n end\n substrings\nend", "def grab_ssn(string)\n\tssn = /\\d{3}[^\\d]?\\d{2}[^\\d]?\\d{4}/\n\treturnString = \"\"\n\tif ssn =~ string\n\t\treturnString = string.scan(ssn)\n\t\treturn returnString[0]\n\telse\n\t\t#puts \"not match\"\n\t\treturn nil\n\tend\nend", "def last_index(str, char)\n \tarry = []\n\tstr.split(\"\").map.with_index do|i, indx|\n\tif i == char\n arry << indx\n end\n end\n return arry[-1]\nend", "def extract_as_str(result)\n if !result.nil? then\n init(result)\n val = @snippet[/>.+</].chop\n return val[1, val.size]\n end\n return nil\n end", "def substrings_at_start(string)\n results = []\n\n string.chars.each_with_index do |char, index|\n results << string.chars[0..index].inject(:+)\n end\n results\nend", "def substrings_at_start(str)\n result = []\n index = 0\n while index < str.size\n result << str[0..index]\n index += 1\n end\n result\nend", "def extract_from(data, pattern)\n matches = data.rstrip.scan pattern\n matches.first if matches.size == 1 && matches.first.size > 0\n end", "def penultimate(string)\nwords = string.split\nwords[-2]\nend", "def closest_string_in_front(key_string, sub_string)\n\n\t\tpositions = []\n\t\tlast_pos = nil\n\t\tmy_string = \" \" + to_str\n\t\tkey_pos = my_string.index(key_string)\n\t\tif key_pos.nil?\n\t\t\t#puts \"WARNING: closest_string_in_front PASSED A string THAT DID NOT INCLUDE key_string\"\n\t\t\treturn nil\n\t\telse\n\t\t\tmy_string = my_string.slice(0..key_pos+1)\n\t\tend\n\n\t\twhile (last_pos = my_string.index(sub_string, (last_pos ? last_pos + 1 : 0)))\n\t\t\tpositions << last_pos\n\t\tend\n\n\t\tif positions != []\n\t\t\treturn_string = my_string[key_pos-positions.map{|p| (p-key_pos).abs}.min..key_pos-1]\n\t\t\treturn return_string.match(sub_string).to_s\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend", "def without_end(str)\n str[1...str.length - 1]\n end", "def get_middle(string)\n if string.length.even?\n return string[string.length/2-1] + string[string.length/2]\n else\n return string[string.length/2]\n end\nend", "def pirates_say_arrrrrrrrr(string)\n resultArr = []\n\n string.split(\"\").each_index do |x|\n if (string[x].downcase === \"r\" && string[x+1] != nil)\n resultArr.push(string[x+1])\n end\n end\n\n return resultArr.join(\"\")\n\n\nend", "def extrapolate(text)\n case @type\n when :prefix\n return text[@value.length..text.length]\n when :suffix\n return text[0..-@value.length-1]\n when :dual\n return text[@value[0].length..-@value[1].length-1]\n when :regex\n return self.match(text)\n end\n end", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |index|\n result << string.slice(0, index)\n end\n result\nend", "def substrings_at_start(string)\n result = []\n string.size.times do |index|\n result << string.split(//).slice(0, index + 1).join\n end\n result\nend" ]
[ "0.6596665", "0.6487462", "0.61651033", "0.61589164", "0.6103066", "0.6094068", "0.60571665", "0.6043849", "0.5996793", "0.596414", "0.5895244", "0.58793586", "0.5854926", "0.5844705", "0.5834588", "0.5820077", "0.58106154", "0.5806086", "0.57965606", "0.579076", "0.5790085", "0.57837147", "0.5778462", "0.57723904", "0.5769667", "0.57582027", "0.57483244", "0.57371414", "0.5717118", "0.5707982", "0.5704867", "0.5701089", "0.5689999", "0.56840974", "0.5683187", "0.5681387", "0.5680764", "0.5680764", "0.5673946", "0.56661385", "0.5661554", "0.5656376", "0.56513685", "0.5648828", "0.56420064", "0.5623685", "0.5619066", "0.5618058", "0.56132567", "0.5611991", "0.5611237", "0.56087816", "0.5606488", "0.5602312", "0.5599578", "0.559425", "0.5584355", "0.5565344", "0.5562266", "0.5552658", "0.55525845", "0.55396914", "0.5520752", "0.5518461", "0.5515414", "0.55120885", "0.5511978", "0.55103505", "0.550339", "0.54999113", "0.54857445", "0.54756093", "0.5473782", "0.5470914", "0.5468809", "0.54675376", "0.5464739", "0.5463294", "0.5460936", "0.5460936", "0.5459197", "0.54527426", "0.545256", "0.54522014", "0.54521024", "0.5451956", "0.54512626", "0.54483104", "0.5443897", "0.5441522", "0.54366505", "0.5429148", "0.5425054", "0.54237634", "0.5422794", "0.54218715", "0.54204994", "0.541963", "0.54190546", "0.54183024", "0.5417946" ]
0.0
-1
GET /vitabus GET /vitabus.json
def index @vitabus = Vitabu.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\n end", "def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end", "def show\n @virus = Virus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @virus }\n end\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end", "def 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 index\n @vitaminas = Vitamina.all\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 @vampire = Vampire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vampire }\n end\n end", "def set_vitabus\n @vitabus = Vitabu.find(params[:id])\n end", "def show\n render json: @vat\n end", "def show\n @vrabat = Vrabat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vrabat }\n end\n end", "def show\n @vaccin = Vaccin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vaccin }\n end\n end", "def index\n @vacancies = Vacancy.all_vacancies# current_user.vacancies #\n render json: @vacancies\n end", "def index\n @ivas = Iva.all\n\n render json: @ivas\n end", "def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end", "def show\n @vocalium = Vocalium.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vocalium }\n end\n end", "def show\n vaga = Vaga.find(params[:id])\n render json: {status: 'SUCCESS', message:'Loaded vaga', data:vaga},status: :ok\n end", "def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end", "def index\n @vitimas = Vitima.all\n end", "def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vano }\n end\n end", "def show\n @volantino = Volantino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volantino }\n end\n end", "def new\n @vachana = Vachana.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vachana }\n end\n end", "def new\n @vachana = Vachana.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vachana }\n end\n end", "def index\n\t\tvendas = Venda.all\n\t\trender json: vendas, status: :ok\n\tend", "def index\n @viri = Virus.all\n end", "def index\n @vacations = User.find(params[:user_id]).vacations \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vacations }\n end\n end", "def show\n @vnic = Vnic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vnic }\n end\n end", "def index\n @vitricongviecs = Vitricongviec.all\n end", "def show\n @vitamin = Vitamin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vitamin }\n end\n end", "def show\n @tv = Tv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tv }\n end\n end", "def show\n survivor = Suvivor.find(params[:id])\n render json: {status: 'SUCCESS', message:'Survivor founded', data:survivor},status: :ok\n end", "def show\n @voc = Voc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voc }\n end\n end", "def show\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format| \n format.json { render json: @giang_vien }\n end\n end", "def index\n @admin_villages = Admin::Village.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_villages }\n end\n end", "def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end", "def show\n render json: @vdm\n end", "def index\n @participante_videoconferencia = ParticipanteVideoconferencium.all\n render json: @participante_videoconferencia\n end", "def vips\n request :get, '/vips'\n end", "def show\n @virus_characteristic = VirusCharacteristic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @virus_characteristic }\n end\n end", "def show\n @avert = Avert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @avert }\n end\n end", "def show\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voprosy }\n end\n end", "def create\n @vitabus = Vitabu.new(vitabus_params)\n\n respond_to do |format|\n if @vitabus.save\n format.html { redirect_to @vitabus, notice: 'Vitabu was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vitabus }\n else\n format.html { render action: 'new' }\n format.json { render json: @vitabus.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @videoconferencias = Videoconferencium.all\n render json: @videoconferencias\n end", "def votd\n require 'rss'\n\n votd = RSS::Parser.parse('https://www.biblegateway.com/usage/votd/rss/votd.rdf?31', false)\n\n render json: votd\n end", "def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end", "def show\n render json: @vehicle\n end", "def new\n @virus = Virus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @virus }\n end\n end", "def show\n render json: @diet, status: 200, root: true\n end", "def new\n @vampire = Vampire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vampire }\n end\n end", "def index\n @venta = Ventum.all\n end", "def index\n @venta = Ventum.all\n end", "def new\n @vrabat = Vrabat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vrabat }\n end\n end", "def show\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uset }\n end\n end", "def show\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kv }\n end\n end", "def show\n @v_user_datum = VUserData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_user_datum }\n end\n end", "def index\n @verbs = Verb.all\n\n render json: @verbs\n end", "def show\n @verbindung = Verbindung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbindung }\n end\n end", "def index\n @kifus = Kifu.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @kifus }\n end\n end", "def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def index\n @vdms = Vdm.all\n\n render json: @vdms\n end", "def show\n @cuentum = Cuentum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cuentum }\n end\n end", "def show\n render json: @iva\n end", "def show\n render json: @visit\n end", "def show\n render \"api/v1/bounties/show\"\n end", "def index\n results = []\n if params[:bbox]\n results = VAFacility.query(bbox: params[:bbox], type: params[:type], services: params[:services])\n end\n resource = Common::Collection.new(::VAFacility, data: results)\n resource = resource.paginate(pagination_params)\n render json: resource.data,\n serializer: CollectionSerializer,\n each_serializer: VAFacilitySerializer,\n meta: resource.metadata\n end", "def index\n allow :get\n expires_in 60.seconds\n\n nodes = @kavlan.nodes_vlan(params[:vlan_id])\n result = {\n 'total' => nodes.length,\n 'offset' => 0,\n 'items' => nodes.map { |n| { 'uid' => n, 'vlan' => params[:vlan_id] } },\n 'links' => links_for_collection\n }\n\n result['items'].each do |item|\n item['links'] = links_for_item(item)\n end\n\n render_result(result)\n end", "def index\n @verbindungs = Verbindung.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verbindungs }\n end\n end", "def show\n @nugget = Nugget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nugget }\n end\n end", "def index\n @registro_videoconferencia = RegistroVideoconferencium.all\n render json: @registro_videoconferencia\n end", "def show\n @vodka = Vodka.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vodka }\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 index\n @vets = Vet.all\n end", "def show\n @visit = Visit.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @visit }\n end\n end", "def index\n @plan_de_venta = PlanDeVentum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_de_venta }\n end\n end", "def index\n @venues = Venue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @venues }\n end\n end", "def index\n @venues = Venue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @venues }\n end\n end", "def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end", "def show\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ginasio }\n end\n end", "def index\n @vegetables = Vegetable.all\n end", "def show\n @uchronist = Uchronist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronist }\n end\n end", "def index\n @usages = get_usages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usages }\n end\n end", "def set_vitamina\n @vitamina = Vitamina.find(params[:id])\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 index\n @uvas = Uva.all\n end", "def show\n @utente = Utente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @utente }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @rua = Rua.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rua }\n end\n end", "def show\n vehicle=Vehicle.where(uid: params[:id]).first\n render :json => {\"vehicle\"=>vehicle }\n end", "def show\n @kuaibovideo = Kuaibovideo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kuaibovideo }\n end\n end", "def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend", "def show\n @vehicle = Vehicle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vehicle }\n end\n end", "def show\n @u_ser = USer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @u_ser }\n end\n end", "def show\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @livro }\n end\n end", "def new\n @vocalium = Vocalium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @vocalium }\n end\n end", "def show\n @situacion_revistum = SituacionRevistum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @situacion_revistum }\n end\n end" ]
[ "0.695314", "0.6797506", "0.6641814", "0.6636317", "0.6636317", "0.66190094", "0.65613353", "0.6548526", "0.65438986", "0.652484", "0.65126985", "0.65052944", "0.65038717", "0.6428445", "0.6414535", "0.6408994", "0.63224435", "0.6299798", "0.6285904", "0.6283811", "0.62795573", "0.62706846", "0.6237844", "0.62229306", "0.6218627", "0.6218627", "0.6218259", "0.6218054", "0.61892694", "0.61732906", "0.61689746", "0.6165374", "0.61616325", "0.61321807", "0.61307627", "0.612758", "0.6127191", "0.6111909", "0.60999215", "0.60992163", "0.6098603", "0.60898405", "0.60750586", "0.6065027", "0.6045348", "0.6043974", "0.59983206", "0.5997117", "0.59870166", "0.5986016", "0.5984579", "0.5982553", "0.5980508", "0.5980508", "0.5972273", "0.59653354", "0.59642744", "0.5962916", "0.5960677", "0.59566045", "0.59533155", "0.59521216", "0.5945589", "0.59385055", "0.59356153", "0.5931193", "0.5928567", "0.59264064", "0.5923944", "0.59237933", "0.5920036", "0.5919194", "0.5918995", "0.59152716", "0.59012425", "0.5897411", "0.58932", "0.58917886", "0.58917886", "0.5890747", "0.5890147", "0.588165", "0.588143", "0.5880256", "0.5877948", "0.5877822", "0.5875003", "0.5873496", "0.5871776", "0.5871776", "0.5871776", "0.58688605", "0.5866855", "0.5856488", "0.58414155", "0.583887", "0.5837223", "0.5832391", "0.5831561", "0.5828729" ]
0.7213476
0
GET /vitabus/1 GET /vitabus/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @vitabus = Vitabu.all\n end", "def index\n @vampires = Vampire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vampires }\n end\n end", "def vitals\n raise UserNotAuthenticated unless access_token\n\n get('records/vitals')\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 @virus = Virus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @virus }\n end\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n end", "def show\n @vampire = Vampire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vampire }\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 @vrabat = Vrabat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vrabat }\n end\n end", "def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end", "def show\n render json: @vat\n end", "def show\n @vaccin = Vaccin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vaccin }\n end\n end", "def show\n @vocalium = Vocalium.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vocalium }\n end\n end", "def show\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vano }\n end\n end", "def index\n @ivas = Iva.all\n\n render json: @ivas\n end", "def set_vitabus\n @vitabus = Vitabu.find(params[:id])\n end", "def index\n @vacancies = Vacancy.all_vacancies# current_user.vacancies #\n render json: @vacancies\n end", "def show\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbo }\n end\n end", "def show\n @vnic = Vnic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vnic }\n end\n end", "def index\n @vitaminas = Vitamina.all\n end", "def show\n @vitamin = Vitamin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vitamin }\n end\n end", "def show\n @voc = Voc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voc }\n end\n end", "def show\n @tv = Tv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tv }\n end\n end", "def show\n @volantino = Volantino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volantino }\n end\n end", "def show\n vaga = Vaga.find(params[:id])\n render json: {status: 'SUCCESS', message:'Loaded vaga', data:vaga},status: :ok\n end", "def index\n @vitimas = Vitima.all\n end", "def show\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voprosy }\n end\n end", "def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end", "def show\n #@restroom = Restroom.find(params[:id])\n @venue = client.venue(:query => params[:venue_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @restroom }\n end\n end", "def show\n @virus_characteristic = VirusCharacteristic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @virus_characteristic }\n end\n end", "def show\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format| \n format.json { render json: @giang_vien }\n end\n end", "def new\n @vachana = Vachana.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vachana }\n end\n end", "def new\n @vachana = Vachana.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vachana }\n end\n end", "def index\n @vacations = User.find(params[:user_id]).vacations \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vacations }\n end\n end", "def index\n\t\tvendas = Venda.all\n\t\trender json: vendas, status: :ok\n\tend", "def show\n vehicle=Vehicle.where(uid: params[:id]).first\n render :json => {\"vehicle\"=>vehicle }\n end", "def index\n @viri = Virus.all\n end", "def index\n @participante_videoconferencia = ParticipanteVideoconferencium.all\n render json: @participante_videoconferencia\n end", "def show\n @verbindung = Verbindung.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verbindung }\n end\n end", "def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end", "def index\n @vitricongviecs = Vitricongviec.all\n end", "def index\n @videoconferencias = Videoconferencium.all\n render json: @videoconferencias\n end", "def show\n @visit = Visit.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @visit }\n end\n end", "def show\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @veiculo }\n end\n end", "def show\n survivor = Suvivor.find(params[:id])\n render json: {status: 'SUCCESS', message:'Survivor founded', data:survivor},status: :ok\n end", "def show\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kv }\n end\n end", "def show\n @vswitch = Vswitch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vswitch }\n end\n end", "def show\n render json: @vdm\n end", "def index\n @admin_villages = Admin::Village.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_villages }\n end\n end", "def show\n @vodka = Vodka.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vodka }\n end\n end", "def show\n render json: @vehicle\n end", "def show\n @cuentum = Cuentum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cuentum }\n end\n end", "def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end", "def show\n @v_user_datum = VUserData.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_user_datum }\n end\n end", "def show\n @vehicle = Vehicle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vehicle }\n end\n end", "def new\n @vampire = Vampire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vampire }\n end\n end", "def show\n @uchronist = Uchronist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronist }\n end\n end", "def index\n @registro_videoconferencia = RegistroVideoconferencium.all\n render json: @registro_videoconferencia\n end", "def new\n @virus = Virus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @virus }\n end\n end", "def show\n render json: Festival.build_for(params[:id]).to_json\n end", "def index\n @verbindungs = Verbindung.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @verbindungs }\n end\n end", "def show\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_version }\n end\n end", "def show\n @visit = Visit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @visit }\n end\n end", "def new\n @vrabat = Vrabat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vrabat }\n end\n end", "def new\n @vint = Vint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vint }\n end\n end", "def index\n @vdms = Vdm.all\n\n render json: @vdms\n end", "def show\n @version = Version.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @version }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end", "def show\n @avert = Avert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @avert }\n end\n end", "def new\n @vocalium = Vocalium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @vocalium }\n end\n end", "def show\n @vertical = Vertical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vertical }\n end\n end", "def show\n @vhour = Vhour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vhour }\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 render \"api/v1/bounties/show\"\n end", "def index\n @vhours = Vhour.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vhours }\n end\n end", "def index\n @verbs = Verb.all\n\n render json: @verbs\n end", "def show\n @serv = Serv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @serv }\n end\n end", "def show\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uset }\n end\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def index\n @plan_de_venta = PlanDeVentum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_de_venta }\n end\n end", "def index\n @vets = Vet.all\n end", "def show\n render json: @visit\n end", "def show\n @situacion_revistum = SituacionRevistum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @situacion_revistum }\n end\n end", "def index\n @vehicles = Vehicle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vehicles }\n end\n end", "def show\n @livro = Livro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @livro }\n end\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 @vint = Vint.find(params[:id])\n @address = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vint }\n end\n end", "def show\n @vet_lab_type = VetLabType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vet_lab_type }\n end\n end", "def show\n @ginasio = Ginasio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @ginasio }\n end\n end", "def index\n @api_versions = ApiVersion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end", "def show\n @vaccine = Vaccine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vaccine }\n end\n end", "def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end", "def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end", "def show\n @rum = Rum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rum }\n end\n end", "def show\n @bruschettum = Bruschettum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bruschettum }\n end\n end", "def index\n @file_versions = FileVersion.all\n\n render json: @file_versions\n end", "def show\n @kuaibovideo = Kuaibovideo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kuaibovideo }\n end\n end", "def vips\n request :get, '/vips'\n end" ]
[ "0.71154535", "0.69438815", "0.68024874", "0.6783631", "0.6778577", "0.675284", "0.675284", "0.67367005", "0.6713769", "0.67051756", "0.66494787", "0.66378397", "0.6606909", "0.65858674", "0.65247554", "0.6500207", "0.6495198", "0.6492084", "0.6483729", "0.645896", "0.6447457", "0.64389426", "0.64284277", "0.638845", "0.6385624", "0.6363065", "0.63419336", "0.63381374", "0.63327754", "0.6332136", "0.6319603", "0.6311282", "0.6299223", "0.6299223", "0.62891537", "0.62801397", "0.6274808", "0.62741697", "0.6260646", "0.6251924", "0.62405455", "0.6240177", "0.6234678", "0.6234343", "0.6209112", "0.6208975", "0.62041235", "0.6190548", "0.61886626", "0.6179062", "0.6178417", "0.6164282", "0.61427474", "0.61368155", "0.6132587", "0.6131171", "0.6126107", "0.61233574", "0.6121074", "0.6116613", "0.61164737", "0.6112097", "0.6111003", "0.6110095", "0.6105465", "0.6104941", "0.61005276", "0.6096558", "0.60900474", "0.60900474", "0.60900474", "0.60900426", "0.6087499", "0.60823685", "0.6077214", "0.6075844", "0.6071276", "0.60711575", "0.6067638", "0.60653275", "0.60635805", "0.60545236", "0.6045122", "0.60440207", "0.6043096", "0.6039318", "0.6038149", "0.60372734", "0.6036386", "0.6032123", "0.6029332", "0.60289717", "0.60284406", "0.6025404", "0.60202456", "0.60074365", "0.60067034", "0.6002841", "0.6000423", "0.59965473", "0.59929186" ]
0.0
-1
POST /vitabus POST /vitabus.json
def create @vitabus = Vitabu.new(vitabus_params) respond_to do |format| if @vitabus.save format.html { redirect_to @vitabus, notice: 'Vitabu was successfully created.' } format.json { render action: 'show', status: :created, location: @vitabus } else format.html { render action: 'new' } format.json { render json: @vitabus.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @vitamina = Vitamina.new(vitamina_params)\n\n respond_to do |format|\n if @vitamina.save\n format.html { redirect_to @vitamina, notice: 'Vitamina was successfully created.' }\n format.json { render :show, status: :created, location: @vitamina }\n else\n format.html { render :new }\n format.json { render json: @vitamina.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uva = Uva.new(uva_params)\n\n respond_to do |format|\n if @uva.save\n format.html { redirect_to @uva, notice: 'Uva was successfully created.' }\n format.json { render :show, status: :created, location: @uva }\n else\n format.html { render :new }\n format.json { render json: @uva.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @curriculum_vitae = findable_curriculum_vitaes.new(curriculum_vitae_params)\n\n respond_to do |format|\n if @curriculum_vitae.save\n format.html { redirect_to @curriculum_vitae, notice: I18n.t('controllers.curriculum_vitaes.create.success') }\n format.json { render :show, status: :created, location: @curriculum_vitae }\n else\n format.html { render :new }\n format.json { render json: @curriculum_vitae.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vestimentum = Vestimentum.new(vestimentum_params)\n\n respond_to do |format|\n if @vestimentum.save\n format.html { redirect_to @vestimentum, notice: 'Vestimentum was successfully created.' }\n format.json { render :show, status: :created, location: @vestimentum }\n else\n format.html { render :new }\n format.json { render json: @vestimentum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vachana = Vachana.new(params[:vachana])\n\n respond_to do |format|\n if @vachana.save\n format.html { redirect_to @vachana, notice: 'Vachana was successfully created.' }\n format.json { render json: @vachana, status: :created, location: @vachana }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vachana.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vachana = Vachana.new(params[:vachana])\n\n respond_to do |format|\n if @vachana.save\n format.html { redirect_to @vachana, notice: 'Vachana was successfully created.' }\n format.json { render json: @vachana, status: :created, location: @vachana }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vachana.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vrabat = Vrabat.new(params[:vrabat])\n\n respond_to do |format|\n if @vrabat.save\n format.html { redirect_to @vrabat, notice: 'Vrabat was successfully created.' }\n format.json { render json: @vrabat, status: :created, location: @vrabat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vrabat.errors, status: :unprocessable_entity }\n end\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def vitabus_params\n params.require(:vitabus).permit(:Name, :title, :dateborrowed)\n end", "def create\n @ventaganancium = Ventaganancium.new(ventaganancium_params)\n\n respond_to do |format|\n if @ventaganancium.save\n format.html { redirect_to @ventaganancium, notice: 'Ventaganancium was successfully created.' }\n format.json { render :show, status: :created, location: @ventaganancium }\n else\n format.html { render :new }\n format.json { render json: @ventaganancium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vitima = Vitima.new(vitima_params)\n\n respond_to do |format|\n if @vitima.save\n format.html { redirect_to @vitima, notice: 'Vitima was successfully created.' }\n format.json { render :show, status: :created, location: @vitima }\n else\n format.html { render :new }\n format.json { render json: @vitima.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vampire = Vampire.new(params[:vampire])\n\n respond_to do |format|\n if @vampire.save\n format.html { redirect_to @vampire, notice: 'Vampire was successfully created.' }\n format.json { render json: @vampire, status: :created, location: @vampire }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vampire.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @giang_vien = GiangVien.new(params[:giang_vien])\n\n respond_to do |format|\n if @giang_vien.save \n format.json { render json: @giang_vien, status: :created, location: @giang_vien }\n else \n format.json { render json: @giang_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @virus = Virus.new(params[:virus])\n\n respond_to do |format|\n if @virus.save\n format.html { redirect_to @virus, notice: 'Virus was successfully created.' }\n format.json { render json: @virus, status: :created, location: @virus }\n else\n format.html { render action: \"new\" }\n format.json { render json: @virus.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n venture = Venture.new(venture_params)\n\n if venture.save \n render json: {venture: venture}, status: :created\n else\n render json: {status: 'Error', message: 'Venture not saved', data: venture.errors}, status: :unprocessable_entity\n end\n end", "def create\n vaga = Vaga.new(vaga_params)\n if vaga.save\n render json: {status: 'SUCCESSO', message:'Vaga adicionada com sucesso!', data:vaga},status: :ok\n else\n render json: {status: 'ERRO', message:'Houve um erro ao adicionar a vaga.', data:vaga.errors},status: :unprocessable_entity\n end\n end", "def create\n @vet = Vet.new(params[:vet])\n\n respond_to do |format|\n if @vet.save\n format.html { redirect_to @vet, notice: 'Vet was successfully created.' }\n format.json { render json: @vet, status: :created, location: @vet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vibe = Vibe.new(vibe_params)\n\n respond_to do |format|\n if @vibe.save\n format.html { redirect_to @vibe, notice: 'Vibe was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vibe }\n else\n format.html { render action: 'new' }\n format.json { render json: @vibe.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vano = Vano.new(params[:vano])\n\n respond_to do |format|\n if @vano.save\n format.html { redirect_to @vano, notice: 'Vano was successfully created.' }\n format.json { render json: @vano, status: :created, location: @vano }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @visto = Visto.new(visto_params)\n\n\n respond_to do |format|\n if @visto.save\n format.html { redirect_to @visto, notice: 'Visto was successfully created.' }\n format.json { render :show, status: :created, location: @visto }\n else\n format.html { render :new }\n format.json { render json: @visto.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vocalium = Vocalium.new(params[:vocalium])\n\n respond_to do |format|\n if @vocalium.save\n format.html { redirect_to @vocalium, :notice => 'Vocalium was successfully created.' }\n format.json { render :json => @vocalium, :status => :created, :location => @vocalium }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @vocalium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_vitabus\n @vitabus = Vitabu.find(params[:id])\n end", "def create\n @vitricongviec = Vitricongviec.new(vitricongviec_params)\n\n respond_to do |format|\n if @vitricongviec.save\n format.html { redirect_to admin_vitricongviecs_url, notice: 'Vitricongviec was successfully created.' }\n format.json { render :show, status: :created, location: @vitricongviec }\n else\n format.html { render :new }\n format.json { render json: @vitricongviec.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vinyl = Vinyl.new(vinyl_params)\n\n respond_to do |format|\n if @vinyl.save\n format.html { redirect_to @vinyl, notice: 'Vinyl was successfully created.' }\n format.json { render :show, status: :created, location: @vinyl }\n else\n format.html { render :new }\n format.json { render json: @vinyl.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tv = Tv.new(params[:tv])\n\n respond_to do |format|\n if @tv.save\n format.html { redirect_to @tv, notice: 'Tv was successfully created.' }\n format.json { render json: @tv, status: :created, location: @tv }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vet = Vet.new(vet_params)\n\n respond_to do |format|\n if @vet.save\n format.html { redirect_to @vet, notice: 'Vet was successfully created.' }\n format.json { render :show, status: :created, location: @vet }\n else\n format.html { render :new }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vongdau = Vongdau.new(vongdau_params)\n\n respond_to do |format|\n if @vongdau.save\n format.html { redirect_to @vongdau, notice: 'Vongdau was successfully created.' }\n format.json { render :show, status: :created, location: @vongdau }\n else\n format.html { render :new }\n format.json { render json: @vongdau.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @verfugbarkeit = Verfugbarkeit.new(verfugbarkeit_params)\n\n respond_to do |format|\n if @verfugbarkeit.save\n format.html { redirect_to @verfugbarkeit, notice: 'Verfugbarkeit was successfully created.' }\n format.json { render :show, status: :created, location: @verfugbarkeit }\n else\n format.html { render :new }\n format.json { render json: @verfugbarkeit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n\t\t\t\tsurvivor = Survivor.new(survivor_create_params)\r\n\t\t\t\tsurvivor.abducted = false\r\n\t\t\t\tsurvivor.abduction_reports = 0\r\n\t\t\t\tif survivor.save\r\n\t\t\t\t\trender json: {status: 'SUCCESS', message:'Survivor Registrado', data:survivor},status: :ok\r\n\t\t\t\telse\r\n\t\t\t\t\trender json: {status: 'ERROR', message:'Survivor não registrado com sucesso', data:survivor.erros},status: :unprocessable_entity\r\n\t\t\t\tend\r\n\t\t\tend", "def create\n @venta = Venta.new(params[:venta])\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render json: @venta, status: :created, location: @venta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @unova = Unova.new(unova_params)\n\n respond_to do |format|\n if @unova.save\n format.html { redirect_to @unova, notice: 'Unova was successfully created.' }\n format.json { render :show, status: :created, location: @unova }\n else\n format.html { render :new }\n format.json { render json: @unova.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @virus = Virus.new(virus_params)\n\n respond_to do |format|\n if @virus.save\n format.html { redirect_to @virus, notice: 'Virus was successfully created.' }\n format.json { render action: 'show', status: :created, location: @virus }\n else\n format.html { render action: 'new' }\n format.json { render json: @virus.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @vineyard = Vineyard.new(vineyard_params)\n\n @vineyard = Vineyard.new(vineyard_params)\n @vineyard.user = current_user\n\n if @vineyard.save\n render json: @vineyard, status: :created, location: @vineyard\n else\n render json: @vineyard.errors, status: :unprocessable_entity\n end\n end", "def create\n @vegetal = Vegetal.new(vegetal_params)\n\n respond_to do |format|\n if @vegetal.save\n format.html { redirect_to @vegetal, notice: 'Vegetal was successfully created.' }\n format.json { render :show, status: :created, location: @vegetal }\n else\n format.html { render :new }\n format.json { render json: @vegetal.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tuoshui = Tuoshui.new(params[:tuoshui])\n\n respond_to do |format|\n if @tuoshui.save\n format.html { redirect_to @tuoshui, notice: 'Tuoshui was successfully created.' }\n format.json { render json: @tuoshui, status: :created, location: @tuoshui }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tuoshui.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uzser = Uzser.new(uzser_params)\n\n respond_to do |format|\n if @uzser.save\n format.html { redirect_to @uzser, notice: 'Uzser was successfully created.' }\n format.json { render :show, status: :created, location: @uzser }\n else\n format.html { render :new }\n format.json { render json: @uzser.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sinh_vien = SinhVien.new(params[:sinh_vien])\n\n respond_to do |format|\n if @sinh_vien.save \n format.json { render json: @sinh_vien, status: :created, location: @sinh_vien }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vik = Vik.new(vik_params)\n\n respond_to do |format|\n if @vik.save\n format.html { redirect_to @vik, notice: 'Vik was successfully created.' }\n format.json { render :show, status: :created, location: @vik }\n else\n format.html { render :new }\n format.json { render json: @vik.errors, status: :unprocessable_entity }\n end\n end\n end", "def CreateView params = {}\n \n APICall(path: 'views.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @chuyen_mon_nghiep_vu = ChuyenMonNghiepVu.new(chuyen_mon_nghiep_vu_params)\n\n respond_to do |format|\n if @chuyen_mon_nghiep_vu.save\n format.html { redirect_to @chuyen_mon_nghiep_vu, notice: 'Chuyen mon nghiep vu was successfully created.' }\n format.json { render :show, status: :created, location: @chuyen_mon_nghiep_vu }\n else\n format.html { render :new }\n format.json { render json: @chuyen_mon_nghiep_vu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @v_user_datum = VUserData.new(params[:v_user_datum])\n\n respond_to do |format|\n if @v_user_datum.save\n format.html { redirect_to @v_user_datum, notice: 'V user data was successfully created.' }\n format.json { render json: @v_user_datum, status: :created, location: @v_user_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @v_user_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uzivatel = Uzivatel.new(uzivatel_params)\n\n respond_to do |format|\n if @uzivatel.save\n format.html { redirect_to @uzivatel, notice: 'Uzivatel was successfully created.' }\n format.json { render :show, status: :created, location: @uzivatel }\n else\n format.html { render :new }\n format.json { render json: @uzivatel.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tenure = Tenure.new(tenure_params)\n\n if @tenure.save\n audit(@tenure, current_user)\n render json: @tenure, status: :created\n else\n render json: @tenure.errors, status: :unprocessable_entity\n end\n end", "def create\n @tv = Tv.new(tv_params)\n\n respond_to do |format|\n if @tv.save\n format.html { redirect_to @tv, notice: 'Tv was successfully created.' }\n format.json { render :show, status: :created, location: @tv }\n else\n format.html { render :new }\n format.json { render json: @tv.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cuentum = Cuentum.new(params[:cuentum])\n\n respond_to do |format|\n if @cuentum.save\n format.html { redirect_to @cuentum, :notice => 'Cuentum was successfully created.' }\n format.json { render :json => @cuentum, :status => :created, :location => @cuentum }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @cuentum.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @vano = Vano.new(vano_params)\n\n respond_to do |format|\n if @vano.save\n format.html { redirect_to @vano, notice: 'Vano was successfully created.' }\n format.json { render :show, status: :created, location: @vano }\n else\n format.html { render :new }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def create\n @trivium = Trivium.new(trivium_params.merge({user_id:current_user.id}))\n\n respond_to do |format|\n if @trivium.save\n format.html { redirect_to new_trivium_path, notice: 'Trivium was successfully created.' }\n format.json { render :show, status: :created, location: @trivium }\n else\n format.html { render :new }\n format.json { render json: @trivium.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @diet = Diet.new(diet_params)\n @diet.user = @current_user\n\n if @diet.save\n render json: @diet, status: 201, location: @diet, root: true\n else\n render json: @diet.errors, status: 422\n end\n end", "def create\n @veterinario = Veterinario.new(veterinario_params)\n\n respond_to do |format|\n if @veterinario.save\n format.html { redirect_to @veterinario, notice: \"Veterinario was successfully created.\" }\n format.json { render :show, status: :created, location: @veterinario }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @veterinario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uset = Uset.new(params[:uset])\n\n respond_to do |format|\n if @uset.save\n format.html { redirect_to @uset, notice: 'Uset was successfully created.' }\n format.json { render json: @uset, status: :created, location: @uset }\n else\n format.html { render action: \"new\" }\n format.json { render json: @uset.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @verbo = Verbo.new(params[:verbo])\n\n respond_to do |format|\n if @verbo.save\n format.html { redirect_to @verbo, notice: 'Verbo was successfully created.' }\n format.json { render json: @verbo, status: :created, location: @verbo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vodka = Vodka.new(params[:vodka])\n\n respond_to do |format|\n if @vodka.save\n format.html { redirect_to @vodka, notice: 'Vodka was successfully created.' }\n format.json { render json: @vodka, status: :created, location: @vodka }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vodka.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_ventum = TipoVentum.new(tipo_ventum_params)\n\n respond_to do |format|\n if @tipo_ventum.save\n format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_ventum }\n else\n format.html { render :new }\n format.json { render json: @tipo_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @veterinario = Veterinario.new(veterinario_params)\n\n respond_to do |format|\n if @veterinario.save\n format.html { redirect_to @veterinario, notice: 'Veterinario was successfully created.' }\n format.json { render :show, status: :created, location: @veterinario }\n else\n format.html { render :new }\n format.json { render json: @veterinario.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vegetable = Vegetable.new(vegetable_params)\n\n respond_to do |format|\n if @vegetable.save\n format.html { redirect_to @vegetable, notice: 'Vegetable was successfully created.' }\n format.json { render :show, status: :created, location: @vegetable }\n else\n format.html { render :new }\n format.json { render json: @vegetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vitamin = Vitamin.new(params[:vitamin])\n\n respond_to do |format|\n if @vitamin.save\n format.html { redirect_to @vitamin, notice: 'Vitamin was successfully created.' }\n format.json { render json: @vitamin, status: :created, location: @vitamin }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vitamin.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @venta = Venta.new(venta_params)\n\n respond_to do |format|\n if @venta.save\n format.html { redirect_to @venta, notice: 'Venta was successfully created.' }\n format.json { render :show, status: :created, location: @venta }\n else\n format.html { render :new }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @plan_de_ventum = PlanDeVentum.new(params[:plan_de_ventum])\n\n respond_to do |format|\n if @plan_de_ventum.save\n format.html { redirect_to @plan_de_ventum, notice: 'Plan de ventum was successfully created.' }\n format.json { render json: @plan_de_ventum, status: :created, location: @plan_de_ventum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @plan_de_ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @valet_datum = ValetDatum.new(valet_datum_params)\n\n respond_to do |format|\n if @valet_datum.save\n format.html { redirect_to @valet_datum, notice: 'Valet datum was successfully created.' }\n format.json { render :show, status: :created, location: @valet_datum }\n else\n format.html { render :new }\n format.json { render json: @valet_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @volantino = Volantino.new(params[:volantino])\n\n respond_to do |format|\n if @volantino.save\n format.html { redirect_to @volantino, notice: 'Volantino was successfully created.' }\n format.json { render json: @volantino, status: :created, location: @volantino }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volantino.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @situacion_revistum = SituacionRevistum.new(situacion_revistum_params)\n\n respond_to do |format|\n if @situacion_revistum.save\n format.html { redirect_to @situacion_revistum, notice: 'Situacion revistum was successfully created.' }\n format.json { render json: @situacion_revistum, status: :created, location: @situacion_revistum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @situacion_revistum.errors, status: :unprocessable_entity }\n end\n end\n end", "def POST; end", "def create\n @invt = Invt.new(invt_params)\n\n respond_to do |format|\n if @invt.save\n format.html { redirect_to @invt, notice: 'El producto fue almacenado exitosamented.' }\n format.json { render :show, status: :created, location: @invt }\n else\n format.html { render :new }\n format.json { render json: @invt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vicarage = Vicarage.new(vicarage_params)\n\n respond_to do |format|\n if @vicarage.save\n format.html { redirect_to @vicarage, success: 'La Vicaría fue <strong>registrada</strong> exitosamente.' }\n format.json { render :show, status: :created, location: @vicarage }\n else\n format.html { render :new }\n format.json { render json: @vicarage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @data_ukt = DataUkt.new(data_ukt_params)\n\n respond_to do |format|\n if @data_ukt.save\n format.html { redirect_to @data_ukt, notice: 'Data ukt was successfully created.' }\n format.json { render :show, status: :created, location: @data_ukt }\n else\n format.html { render :new }\n format.json { render json: @data_ukt.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def create\n @ventum = Ventum.new(ventum_params)\n @ventum.estado =false\n respond_to do |format|\n if @ventum.save\n format.html { redirect_to @ventum, notice: 'Ventcreada satisfactoriamente.' }\n format.json { render :show, status: :created, location: @ventum }\n else\n format.html { render :new }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vinculo = Vinculo.new(vinculo_params)\n\n respond_to do |format|\n if @vinculo.save\n format.html { redirect_to @vinculo, notice: 'Vinculo was successfully created.' }\n format.json { render :show, status: :created, location: @vinculo }\n else\n format.html { render :new }\n format.json { render json: @vinculo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @taux_tva = TauxTva.new(params[:taux_tva])\n @taux_tva.parametres_cabinet_id = current_user.parametres_cabinet_id\n respond_to do |format|\n if @taux_tva.save\n format.html { redirect_to(@taux_tva, :notice => 'Taux tva was successfully created.') }\n format.xml { render :xml => @taux_tva, :status => :created, :location => @taux_tva }\n format.json {render :json => {\"success\"=>true,\"data\"=>@taux_tva}}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @taux_tva.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @votacion = Votacion.new(votacion_params)\n @votacion.etapa = \"Previa a la votación.\"\n respond_to do |format|\n if @votacion.save\n format.html { redirect_to @votacion, notice: 'La votación se creo correctamente.' }\n format.json { render :show, status: :created, location: @votacion }\n else\n format.html { render :new }\n format.json { render json: @votacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uchronia = Uchronia.new(params[:uchronia])\n\n respond_to do |format|\n if @uchronia.save\n format.html { redirect_to @uchronia, notice: 'Uchronia was successfully created.' }\n format.json { render json: @uchronia, status: :created, location: @uchronia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @uchronia.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @virus = Virus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @virus }\n end\n end", "def create\n @vehicle = Vehicle.new(vehicle_params)\n if @vehicle.save\n render json: { status: 'Vehicle created successfully', vehicle: @vehicle }, status: :created\n else\n render json: { errors: @vehicle.errors.full_messages }, status: :bad_request\n end\n end", "def create\n @veiculo = Veiculo.new(params[:veiculo])\n\n respond_to do |format|\n if @veiculo.save\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully created.' }\n format.json { render :json => @veiculo, :status => :created, :location => @veiculo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @zf_bjietu = ZfBjietu.new(zf_bjietu_params)\n\n respond_to do |format|\n if @zf_bjietu.save\n format.html { redirect_to @zf_bjietu, notice: 'Zf bjietu was successfully created.' }\n format.json { render :show, status: :created, location: @zf_bjietu }\n else\n format.html { render :new }\n format.json { render json: @zf_bjietu.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vechicle = Vechicle.new(vechicle_params)\n\n respond_to do |format|\n if @vechicle.save\n format.html { redirect_to @vechicle, notice: 'Vechicle was successfully created.' }\n format.json { render :show, status: :created, location: @vechicle }\n else\n format.html { render :new }\n format.json { render json: @vechicle.errors, status: :unprocessable_entity }\n end\n end\n end", "def creacion\n fiesta = Fiesta.new (params[:id])\n if Fiesta.save\n puts \"su fiesta a sido registrada\"\n else \n puts \"su fiesta no a sido registrada\"\n end\n render = json: fiesta \n end", "def create\n @uasg = Uasg.new(uasg_params)\n\n respond_to do |format|\n if @uasg.save\n format.html { redirect_to @uasg, notice: 'Uasg was successfully created.' }\n format.json { render :show, status: :created, location: @uasg }\n else\n format.html { render :new }\n format.json { render json: @uasg.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @voprosy = Voprosy.new(params[:voprosy])\n\n respond_to do |format|\n if @voprosy.save\n format.html { redirect_to @voprosy, notice: 'Voprosy was successfully created.' }\n format.json { render json: @voprosy, status: :created, location: @voprosy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @voprosy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @testmonial = Testmonial.new(testmonial_params)\n\n if @testmonial.save\n render json: @testmonial, status: :created\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end", "def create\n @vrsta_inventara = VrstaInventara.new(vrsta_inventara_params)\n\n respond_to do |format|\n if @vrsta_inventara.save\n format.html { redirect_to vrsta_inventaras_url, notice: 'Vrsta inventara je uspješno stvorena.' }\n format.json { render :show, status: :created, location: @vrsta_inventara }\n else\n format.html { render :new }\n format.json { render json: @vrsta_inventara.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_vacancy = UserVacancy.new(user_vacancy_params)\n\n respond_to do |format|\n if @user_vacancy.save\n format.html { redirect_to @user_vacancy, notice: 'Aplicación exitosa' }\n format.json { render :show, status: :created, location: @user_vacancy }\n else\n format.html { render :new }\n format.json { render json: @user_vacancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def create\n @valor_ust = ValorUst.new(valor_ust_params)\n\n respond_to do |format|\n if @valor_ust.save\n format.html { redirect_to @valor_ust, notice: 'Valor ust foi criado(a)' }\n format.json { render :show, status: :created, location: @valor_ust }\n else\n format.html { render :new }\n format.json { render json: @valor_ust.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @verb = Verb.new(verb_params)\n\n if @verb.save\n render json: @verb, status: :created, location: @verb\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end", "def create\n @vacancy = Vacancy.new(vacancy_params)\n\n respond_to do |format|\n if @vacancy.save\n format.html { redirect_to vacancy_path(@vacancy), notice: 'Вакансия создана.' }\n format.json { render :show, status: :created, location: @vacancy }\n else\n format.html { render :new }\n format.json { render json: @vacancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @votable_item = VotableItem.new(votable_item_params)\n\n respond_to do |format|\n if @votable_item.save\n format.html { redirect_to @votable_item, notice: 'Votable item was successfully created.' }\n format.json { render :show, status: :created, location: @votable_item }\n else\n format.html { render :new }\n format.json { render json: @votable_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @uen = Uen.new(uen_params)\n\n respond_to do |format|\n if @uen.save\n format.html { redirect_to @uen, notice: 'Uen was successfully created.' }\n format.json { render :show, status: :created, location: @uen }\n else\n format.html { render :new }\n format.json { render json: @uen.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @u_ser = USer.new(params[:u_ser])\n\n respond_to do |format|\n if @u_ser.save\n format.html { redirect_to @u_ser, notice: 'U ser was successfully created.' }\n format.json { render json: @u_ser, status: :created, location: @u_ser }\n else\n format.html { render action: \"new\" }\n format.json { render json: @u_ser.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @my_visa = MyVisa.new(my_visa_params)\n\n respond_to do |format|\n if @my_visa.save\n format.html { redirect_to @my_visa, notice: 'My visa was successfully created.' }\n format.json { render :show, status: :created, location: @my_visa }\n else\n format.html { render :new }\n format.json { render json: @my_visa.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n plant = Plant.create(plant_params)\n render json: plant, status: :created\n end", "def create\n @pautum = Pautum.new(pautum_params)\n\n respond_to do |format|\n if @pautum.save\n format.html { redirect_to @pautum, notice: 'Pautum was successfully created.' }\n format.json { render :show, status: :created, location: @pautum }\n else\n format.html { render :new }\n format.json { render json: @pautum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @vaga = Vaga.new(vaga_params)\n\n if @vaga.save\n redirect_to @vaga\n else\n render :new\n end\n end", "def create\n @rua = Rua.new(params[:rua])\n\n respond_to do |format|\n if @rua.save\n format.html { redirect_to @rua, notice: 'Rua was successfully created.' }\n format.json { render json: @rua, status: :created, location: @rua }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rua.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @iva = Iva.new(iva_params)\n\n if @iva.save\n render json: @iva, status: :created, location: @iva\n else\n render json: @iva.errors, status: :unprocessable_entity\n end\n end", "def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end", "def create\n megam_rest.post_appdefn(to_hash)\n end", "def new\n @vrabat = Vrabat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vrabat }\n end\n end", "def create\n @verbindung = Verbindung.new(params[:verbindung])\n\n respond_to do |format|\n if @verbindung.save\n format.html { redirect_to @verbindung, notice: 'Verbindung was successfully created.' }\n format.json { render json: @verbindung, status: :created, location: @verbindung }\n else\n format.html { render action: \"new\" }\n format.json { render json: @verbindung.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6499655", "0.63951945", "0.63511556", "0.6227624", "0.62136674", "0.62136674", "0.6202348", "0.62002325", "0.6183671", "0.6182404", "0.61244017", "0.61104494", "0.60863024", "0.6044589", "0.6037201", "0.60351026", "0.60107845", "0.5992457", "0.59287417", "0.59257084", "0.59189755", "0.591526", "0.5913041", "0.5912481", "0.59095955", "0.59008557", "0.5896069", "0.5874899", "0.5849779", "0.5846233", "0.5845078", "0.58394504", "0.5831353", "0.58312213", "0.58117926", "0.58107376", "0.5806735", "0.57997555", "0.5796849", "0.57914734", "0.57901365", "0.57806695", "0.57743865", "0.57619834", "0.5755047", "0.57544315", "0.57404053", "0.5734459", "0.572926", "0.57242256", "0.5713506", "0.5711881", "0.5702505", "0.57012826", "0.56979614", "0.56978023", "0.56824213", "0.5681338", "0.5681256", "0.5680224", "0.5677863", "0.5673188", "0.5659953", "0.56576353", "0.5656595", "0.5655442", "0.56530213", "0.56518596", "0.56508374", "0.5647315", "0.56441325", "0.56253684", "0.5624398", "0.5618168", "0.56151444", "0.5611868", "0.56073993", "0.56054056", "0.56043756", "0.5602225", "0.5598198", "0.5597511", "0.559717", "0.55921686", "0.5589009", "0.55886334", "0.5585411", "0.5579714", "0.5579204", "0.55740005", "0.5570523", "0.5565014", "0.5562116", "0.5560018", "0.55595905", "0.5554611", "0.55534023", "0.5552381", "0.5550279", "0.55496985" ]
0.7407548
0
PATCH/PUT /vitabus/1 PATCH/PUT /vitabus/1.json
def update respond_to do |format| if @vitabus.update(vitabus_params) format.html { redirect_to @vitabus, notice: 'Vitabu was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @vitabus.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def put!\n request! :put\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_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def patch!\n request! :patch\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update # PATCH\n raise NotImplementedError\n end", "def update\n authorize! :manage, @vspec\n\n respond_to do |format|\n if @vspec.update(vspec_params)\n format.html { redirect_to [@vspec.metric, @vspec], notice: 'Vspec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vspec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vibe.update(vibe_params)\n format.html { redirect_to @vibe, notice: 'Vibe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vibe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vet = Vet.find(params[:id])\n\n respond_to do |format|\n if @vet.update_attributes(params[:vet])\n format.html { redirect_to @vet, notice: 'Vet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n respond_to do |format|\n if @vitamina.update(vitamina_params)\n format.html { redirect_to @vitamina, notice: 'Vitamina was successfully updated.' }\n format.json { render :show, status: :ok, location: @vitamina }\n else\n format.html { render :edit }\n format.json { render json: @vitamina.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @vint = Vint.find(params[:id])\n\n respond_to do |format|\n if @vint.update_attributes(params[:vint])\n format.html { redirect_to @vint, notice: 'Vint was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vint.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n respond_to do |format|\n if @curriculum_vitae.update(curriculum_vitae_params)\n format.html { redirect_to @curriculum_vitae, notice: I18n.t('controllers.curriculum_vitaes.update.success') }\n format.json { render :show, status: :ok, location: @curriculum_vitae }\n else\n format.html { render :edit }\n format.json { render json: @curriculum_vitae.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n @veiculo = Veiculo.find(params[:id])\n\n respond_to do |format|\n if @veiculo.update_attributes(params[:veiculo])\n format.html { redirect_to @veiculo, :notice => 'Veiculo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @veiculo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\n\n # Make it work with `Backbone.emulateHTTP` on.\n put path, &callback\n post path, &callback\n end", "def update\n @vrabat = Vrabat.find(params[:id])\n\n respond_to do |format|\n if @vrabat.update_attributes(params[:vrabat])\n format.html { redirect_to @vrabat, notice: 'Vrabat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vrabat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n if @vachana.update_attributes(params[:vachana])\n format.html { redirect_to @vachana, notice: 'Vachana was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vachana.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n if @vachana.update_attributes(params[:vachana])\n format.html { redirect_to @vachana, notice: 'Vachana was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vachana.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @vat.update(vat_params)\n head :no_content\n else\n render json: @vat.errors, status: :unprocessable_entity\n end\n end", "def update\n @voc = Voc.find(params[:id])\n @voc.user_id = current_user.id\n respond_to do |format|\n if @voc.update_attributes(params[:voc])\n format.html { redirect_to @voc, notice: 'Voc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vampire = Vampire.find(params[:id])\n\n respond_to do |format|\n if @vampire.update_attributes(params[:vampire])\n format.html { redirect_to @vampire, notice: 'Vampire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vampire.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @giang_vien = GiangVien.find(params[:id])\n\n respond_to do |format|\n if @giang_vien.update_attributes(params[:giang_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @giang_vien.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: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n respond_to do |format|\n if @vinyl.update(vinyl_params)\n format.html { redirect_to @vinyl, notice: 'Vinyl was successfully updated.' }\n format.json { render :show, status: :ok, location: @vinyl }\n else\n format.html { render :edit }\n format.json { render json: @vinyl.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n if @kv.update_attributes(params[:kv])\n format.html { redirect_to @kv, notice: 'Kv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @verb = Verb.find(params[:id])\n\n if @verb.update(verb_params)\n head :no_content\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end", "def update\n @vano = Vano.find(params[:id])\n\n respond_to do |format|\n if @vano.update_attributes(params[:vano])\n format.html { redirect_to @vano, notice: 'Vano was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update\n respond_to do |format|\n if @vegetable.update(vegetable_params)\n format.html { redirect_to @vegetable, notice: 'Vegetable was successfully updated.' }\n format.json { render :show, status: :ok, location: @vegetable }\n else\n format.html { render :edit }\n format.json { render json: @vegetable.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n respond_to do |format|\n if @api_v1_resource.update(api_v1_resource_params)\n format.html { redirect_to @api_v1_resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_resource }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @verbo = Verbo.find(params[:id])\n\n respond_to do |format|\n if @verbo.update_attributes(params[:verbo])\n format.html { redirect_to @verbo, notice: 'Verbo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @verbo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vocalium = Vocalium.find(params[:id])\n\n respond_to do |format|\n if @vocalium.update_attributes(params[:vocalium])\n format.html { redirect_to @vocalium, :notice => 'Vocalium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @vocalium.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def update\n @venta = Venta.find(params[:id])\n\n respond_to do |format|\n if @venta.update_attributes(params[:venta])\n format.html { redirect_to @venta, notice: 'Venta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @venta.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @api_v1_post_vote = PostVote.find(params[:id])\n\n respond_to do |format|\n if @api_v1_post_vote.update_attributes(params[:api_v1_post_vote])\n format.html { redirect_to @api_v1_post_vote, notice: 'Post vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_v1_post_vote.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n head :ok\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update\n respond_to do |format|\n if @vacuna.update(vacuna_params)\n format.html { redirect_to @vacuna, notice: 'Vacuna was successfully updated.' }\n format.json { render :show, status: :ok, location: @vacuna }\n else\n format.html { render :edit }\n format.json { render json: @vacuna.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vegetable = Vegetable.find(params[:id])\n\n respond_to do |format|\n if @vegetable.update_attributes(params[:vegetable])\n format.html { redirect_to(@vegetable, :notice => 'Vegetable was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vegetable.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @volantino = Volantino.find(params[:id])\n\n respond_to do |format|\n if @volantino.update_attributes(params[:volantino])\n format.html { redirect_to @volantino, notice: 'Volantino was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volantino.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 @vet.update(vet_params)\n format.html { redirect_to @vet, notice: 'Vet was successfully updated.' }\n format.json { render :show, status: :ok, location: @vet }\n else\n format.html { render :edit }\n format.json { render json: @vet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vacancy = Vacancy.find(params[:id])\n\n respond_to do |format|\n if @vacancy.update_attributes(params[:vacancy])\n format.html { redirect_to @vacancy, notice: 'Vacancy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vacancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(path)\n output { patch(path, params) }\n end", "def update\n respond_to do |format|\n if @vechicle.update(vechicle_params)\n format.html { redirect_to @vechicle, notice: 'Vechicle was successfully updated.' }\n format.json { render :show, status: :ok, location: @vechicle }\n else\n format.html { render :edit }\n format.json { render json: @vechicle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @instrument_version = InstrumentVersion.find(params[:id])\n\n respond_to do |format|\n if @instrument_version.update_attributes(params[:instrument_version])\n flash[:notice] = 'InstrumentVersion was successfully updated.'\n format.html { redirect_to(@instrument_version) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instrument_version.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @fucker = Fucker.find(params[:id])\n\n respond_to do |format|\n if @fucker.update_attributes(params[:fucker])\n format.json { head :no_content }\n else\n format.json { render json: @fucker.errors, status: :internal_server_error }\n end\n end\n end", "def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end", "def update\n @api_version = ApiVersion.find(params[:id])\n\n respond_to do |format|\n if @api_version.update_attributes(params[:api_version])\n format.html { redirect_to admin_api_versions_path, flash: {success: t('app.msgs.success_updated', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n else\n set_tabbed_translation_form_settings('advanced')\n format.html { render action: \"edit\" }\n format.json { render json: @api_version.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vitricongviec.update(vitricongviec_params)\n format.html { redirect_to edit_admin_vitricongviec_path(@vitricongviec), notice: 'Vitricongviec was successfully updated.' }\n format.json { render :show, status: :ok, location: @vitricongviec }\n else\n format.html { render :edit }\n format.json { render json: @vitricongviec.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end", "def patch\n end", "def update\n respond_to do |format|\n if @ventum.update(ventum_params)\n format.html { redirect_to @ventum, notice: 'Venta fue modificado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @ventum }\n else\n format.html { render :edit }\n format.json { render json: @ventum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sinh_vien = SinhVien.find(params[:id])\n\n respond_to do |format|\n if @sinh_vien.update_attributes(params[:sinh_vien]) \n format.json { head :no_content }\n else \n format.json { render json: @sinh_vien.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vitima.update(vitima_params)\n format.html { redirect_to @vitima, notice: 'Vitima was successfully updated.' }\n format.json { render :show, status: :ok, location: @vitima }\n else\n format.html { render :edit }\n format.json { render json: @vitima.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n if @voprosy.update_attributes(params[:voprosy])\n format.html { redirect_to @voprosy, notice: 'Voprosy was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voprosy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @volunteer = Volunteer.find(params[:id])\n\n respond_to do |format|\n if @volunteer.update_attributes(params[:volunteer])\n format.html { redirect_to @volunteer, notice: 'Volunteer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @tv = Tv.find(params[:id])\n\n respond_to do |format|\n if @tv.update_attributes(params[:tv])\n format.html { redirect_to @tv, notice: 'Tv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vip.update(vip_params)\n format.html { redirect_to @vip, notice: 'Vip was successfully updated.' }\n format.json { render :show, status: :ok, location: @vip }\n else\n format.html { render :edit }\n format.json { render json: @vip.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @verb.update(verb_params)\n format.html { redirect_to @verb, notice: 'Verb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @verb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n if @koti.update_attributes(params[:koti])\n format.html { redirect_to @koti, notice: 'Koti was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @koti.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vehicle.update(vehicle_params)\n format.html { redirect_to @vehicle, notice: 'Vehicle was successfully updated.' }\n format.json { render :show, status: :ok, location: @vehicle }\n put_request\n else\n format.html { render :edit }\n format.json { render json: @vehicle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vodka = Vodka.find(params[:id])\n\n respond_to do |format|\n if @vodka.update_attributes(params[:vodka])\n format.html { redirect_to @vodka, notice: 'Vodka was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vodka.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n respond_to do |format|\n if @vcat.update(vcat_params)\n format.html { redirect_to @vcat, notice: 'Vcat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vcat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(data = :object || :json)\n end", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def update(request)\n end", "def update(request)\n end", "def update\n # actions\n path = URI(@endpoint).path\n action = URI(@req.request_uri).path.sub(path, '').split('/')\n action -= ['']\n if action.include?('_history')\n @actions = [action[0], '_history']\n else\n @actions = [action[0]]\n end\n\n # search param\n req_query = URI(@req.request_uri).query\n unless req_query.nil?\n @req_params = URI::decode_www_form(req_query).to_h\n end\n\n # requst method\n if @req.request_method == \"GET\" and @actions.include? '_history'\n @req_method = 'vread'\n elsif @req.request_method == \"GET\" and @req_params != nil\n @req_method = 'search-type'\n elsif @req.request_method == \"PUT\"\n @req_method = 'update'\n elsif @req.request_method == \"POST\"\n @req_method = 'create'\n else\n @req_method = 'read'\n end\n\n # interaction\n int1 = Interaction.last type: @actions[0], code: @req_method\n if int1.nil?\n @present = 0\n else\n @present = int1.id\n @intCode = int1.valueCode\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vacancy.update(vacancy_params)\n format.html { redirect_to @vacancy, notice: 'Вакансия обновлена.' }\n format.json { render :show, status: :ok, location: @vacancy }\n else\n format.html { render :edit }\n format.json { render json: @vacancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @vouch = Vouch.find(params[:id])\n\n if current_user.id == @vouch.grantor_id\n case params[:commit]\n when \"Approve\"\n @vouch.confirm \n when \"Pending\"\n @vouch.pending\n when \"Deny\"\n @vouch.reject\n end\n end\n\n respond_to do |format|\n if @vouch.save\n format.js { render :action => \"update\", :content_type => 'text/javascript'}\n format.html { redirect_to polymorphic_path([parent,Vouch.new]), :notice => 'Vouch was successfully updated.' }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @vouch.errors, :status => :unprocessable_entity }\n format.js { render :partial => @vouch, :layout => false }\n end\n end\n end", "def update\n respond_to do |format|\n if @vano.update(vano_params)\n format.html { redirect_to @vano, notice: 'Vano was successfully updated.' }\n format.json { render :show, status: :ok, location: @vano }\n else\n format.html { render :edit }\n format.json { render json: @vano.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n respond_to do |format|\n if @uva.update(uva_params)\n format.html { redirect_to @uva, notice: 'Uva was successfully updated.' }\n format.json { render :show, status: :ok, location: @uva }\n else\n format.html { render :edit }\n format.json { render json: @uva.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n @bla = Bla.find(params[:id])\n\n respond_to do |format|\n if @bla.update_attributes(params[:bla])\n format.html { redirect_to @bla, :notice => 'Bla was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bla.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @vitamin = Vitamin.find(params[:id])\n\n respond_to do |format|\n if @vitamin.update_attributes(params[:vitamin])\n format.html { redirect_to @vitamin, notice: 'Vitamin was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @vitamin.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end", "def update!(**args)\n @api_version = args[:api_version] if args.key?(:api_version)\n @cancel_requested = args[:cancel_requested] if args.key?(:cancel_requested)\n @create_time = args[:create_time] if args.key?(:create_time)\n @end_time = args[:end_time] if args.key?(:end_time)\n @status_detail = args[:status_detail] if args.key?(:status_detail)\n @target = args[:target] if args.key?(:target)\n @verb = args[:verb] if args.key?(:verb)\n end" ]
[ "0.66542", "0.66045177", "0.6471563", "0.6462322", "0.6385802", "0.63763386", "0.63688964", "0.6366525", "0.63304", "0.6278602", "0.6255677", "0.6231925", "0.61880845", "0.6171431", "0.6167253", "0.6150614", "0.6140274", "0.60750055", "0.60743695", "0.6070956", "0.60682815", "0.60682815", "0.6066712", "0.60639954", "0.60639954", "0.6053689", "0.60381037", "0.6020701", "0.6017759", "0.6001283", "0.6000037", "0.59919757", "0.59772813", "0.59738547", "0.5954999", "0.5951223", "0.59334934", "0.59277064", "0.5922681", "0.59094775", "0.5899506", "0.58994776", "0.58994776", "0.5891995", "0.58881783", "0.58776313", "0.5875878", "0.58686924", "0.58681947", "0.5854464", "0.5853012", "0.58446693", "0.58442307", "0.5841003", "0.58405566", "0.5835463", "0.58350503", "0.583431", "0.58337903", "0.58314466", "0.5827371", "0.58245605", "0.5824226", "0.58109075", "0.5808799", "0.5808159", "0.5802716", "0.5801408", "0.5796853", "0.57962155", "0.5791425", "0.5789785", "0.57882804", "0.5782369", "0.5782208", "0.5781875", "0.5780072", "0.57790357", "0.57743686", "0.57702947", "0.5768772", "0.57681656", "0.57681656", "0.5765798", "0.57648313", "0.57648313", "0.5764595", "0.5760239", "0.5760229", "0.57589304", "0.57589304", "0.57563466", "0.5748672", "0.5746378", "0.5735937", "0.57324827", "0.57304066", "0.57304066", "0.57304066", "0.57304066" ]
0.68498445
0
DELETE /vitabus/1 DELETE /vitabus/1.json
def destroy @vitabus.destroy respond_to do |format| format.html { redirect_to vitabus_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vachana = Vachana.find(params[:id])\n @vachana.destroy\n\n respond_to do |format|\n format.html { redirect_to vachanas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @virus = Virus.find(params[:id])\n @virus.destroy\n\n respond_to do |format|\n format.html { redirect_to viri_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vampire = Vampire.find(params[:id])\n @vampire.destroy\n\n respond_to do |format|\n format.html { redirect_to vampires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vibe.destroy\n respond_to do |format|\n format.html { redirect_to vibes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vint = Vint.find(params[:id])\n @vint.destroy\n\n respond_to do |format|\n format.html { redirect_to vints_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vrabat = Vrabat.find(params[:id])\n @vrabat.destroy\n\n respond_to do |format|\n format.html { redirect_to vrabats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vocalium = Vocalium.find(params[:id])\n @vocalium.destroy\n\n respond_to do |format|\n format.html { redirect_to vocalia_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @giang_vien = GiangVien.find(params[:id])\n @giang_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def destroy\n @venta = Venta.find(params[:id])\n @venta.destroy\n\n respond_to do |format|\n format.html { redirect_to ventas_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @kv = Kv.find(params[:id])\n @kv.destroy\n\n respond_to do |format|\n format.html { redirect_to kvs_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @ventum.destroy\n respond_to do |format|\n format.html { redirect_to venta_url, notice: 'Se ha eliminado la venta exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @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 @vitamina.destroy\n respond_to do |format|\n format.html { redirect_to vitaminas_url, notice: 'Vitamina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @curriculum_vitae.destroy\n respond_to do |format|\n format.html { redirect_to curriculum_vitaes_url, notice: I18n.t('controllers.curriculum_vitaes.destroy.success') }\n format.json { head :no_content }\n end\n end", "def DeleteView id\n \n APICall(path: \"views/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @vitricongviec.destroy\n respond_to do |format|\n format.html { redirect_to admin_vitricongviecs_url, notice: 'Vitricongviec was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete\n request(:delete)\n end", "def destroy\n @ventum.destroy\n respond_to do |format|\n format.html { redirect_to venta_url, notice: 'Venteliminada satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @virus.destroy\n respond_to do |format|\n format.html { redirect_to viri_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vendamesa.destroy\n respond_to do |format|\n format.html { redirect_to vendamesas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_visa.destroy\n respond_to do |format|\n format.html { redirect_to my_visas_url, notice: 'My visa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vodka = Vodka.find(params[:id])\n @vodka.destroy\n\n respond_to do |format|\n format.html { redirect_to vodkas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @voc = Voc.find(params[:id])\n @voc.destroy\n\n respond_to do |format|\n format.html { redirect_to vocs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @auditv.destroy\n respond_to do |format|\n format.html { redirect_to auditvs_url, notice: 'Auditv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vano = Vano.find(params[:id])\n @vano.destroy\n\n respond_to do |format|\n format.html { redirect_to vanos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @visto.destroy\n respond_to do |format|\n format.html { redirect_to vistos_url, notice: 'Visto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @vacancy = Vacancy.find(params[:id])\n @vacancy.destroy\n\n respond_to do |format|\n format.html { redirect_to vacancies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vechicle.destroy\n respond_to do |format|\n format.html { redirect_to vechicles_url, notice: 'Vechicle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vegetable = Vegetable.find(params[:id])\n @vegetable.destroy\n\n respond_to do |format|\n format.html { redirect_to vegetables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def destroy\n authorize! :manage, @vspec\n metric = @vspec.metric\n @vspec.destroy\n respond_to do |format|\n format.html { redirect_to [metric.service, metric] }\n format.json { head :no_content }\n end\n end", "def delete(vmname)\n uri = @uri + \"/#{vmname}?api-version=#{api_version}\"\n uri\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 @uva.destroy\n respond_to do |format|\n format.html { redirect_to uvas_url, notice: 'Uva was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vacancy.destroy\n respond_to do |format|\n format.html { redirect_to vacancies_url, notice: 'Вакансия удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ventaganancium.destroy\n respond_to do |format|\n format.html { redirect_to ventaganancia_url, notice: 'Ventaganancium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verbo = Verbo.find(params[:id])\n @verbo.destroy\n\n respond_to do |format|\n format.html { redirect_to verbos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @volantino = Volantino.find(params[:id])\n @volantino.destroy\n\n respond_to do |format|\n format.html { redirect_to volantinos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vestimentum.destroy\n respond_to do |format|\n format.html { redirect_to vestimenta_url, notice: 'Vestimentum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @votaciones_hist.destroy\n respond_to do |format|\n format.html { redirect_to votaciones_hists_url, notice: 'Votaciones hist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def delete\n api(\"Delete\")\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Asset.find(params[:id])\n @record.trash\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @votacion.destroy\n respond_to do |format|\n format.html { redirect_to votacions_url, notice: 'Votacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @uginuce.sheep.update status:'na farmi'\n @uginuce.destroy\n respond_to do |format|\n format.html { redirect_to uginuces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vitima.destroy\n respond_to do |format|\n format.html { redirect_to vitimas_url, notice: 'Vitima was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @kv.destroy\n respond_to do |format|\n format.html { redirect_to kvs_url, notice: 'Kv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tv = Tv.find(params[:id])\n @tv.destroy\n\n respond_to do |format|\n format.html { redirect_to tvs_url }\n format.json { head :no_content }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n @capa = Capa.find(params[:id])\n @capa.destroy\n\n respond_to do |format|\n format.html { redirect_to capas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vik.destroy\n respond_to do |format|\n format.html { redirect_to viks_url, notice: 'Vik was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @observacao_vocacionada = ObservacaoVocacionada.find(params[:id])\n @observacao_vocacionada.destroy\n\n respond_to do |format|\n format.html { redirect_to observacao_vocacionadas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @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 @avert = Avert.find(params[:id])\n @avert.destroy\n\n respond_to do |format|\n format.html { redirect_to averts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_vacancy.destroy\n respond_to do |format|\n format.html { redirect_to user_vacancies_url, notice: 'Aplicación eliminada correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vacancy.destroy\n respond_to do |format|\n format.html { redirect_to vacancies_url, notice: 'Vacante eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vinyl.destroy\n respond_to do |format|\n format.html { redirect_to vinyls_url, notice: 'Vinyl was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitante.destroy\n respond_to do |format|\n format.html { redirect_to visitantes_url, notice: 'Visitante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @linea_uv.destroy\n respond_to do |format|\n format.html { redirect_to lineas_uv_url, notice: 'Linea uv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @visit.destroy\n respond_to do |format|\n format.html { redirect_to visits_url, notice: 'Visita eliminada con exito' }\n format.json { head :no_content }\n end\n end", "def destroy\n @situacion_revistum = SituacionRevistum.find(params[:id])\n @situacion_revistum.destroy\n\n respond_to do |format|\n format.html { redirect_to situacion_revista_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bicicletum.destroy\n respond_to do |format|\n format.html { redirect_to bicicleta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cafeterium.destroy\n respond_to do |format|\n format.html { redirect_to cafeteria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @verbindung = Verbindung.find(params[:id])\n @verbindung.destroy\n\n respond_to do |format|\n format.html { redirect_to verbindungs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fileversion = Fileversion.find(params[:id])\n @fileversion.destroy\n\n respond_to do |format|\n format.html { redirect_to fileversions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vano.destroy\n respond_to do |format|\n format.html { redirect_to vanos_url, notice: 'Vano was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vod.destroy\n respond_to do |format|\n format.html { redirect_to vods_url, notice: 'Vod was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @vehicle = Vehicle.find(params[:id])\n @vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @razmer_go = RazmerGo.find(params[:id])\n @razmer_go.destroy\n\n respond_to do |format|\n format.html { redirect_to razmer_gos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @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 record = Asset.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def destroy\n @vitamin = Vitamin.find(params[:id])\n @vitamin.destroy\n\n respond_to do |format|\n format.html { redirect_to vitamins_url }\n format.json { head :ok }\n end\n end", "def delete\n render :json => @fiestas.delete_at(params[:id].to_i)\n end" ]
[ "0.7228342", "0.7202471", "0.70137244", "0.70137244", "0.69435054", "0.6893573", "0.689157", "0.68524086", "0.68480206", "0.68387157", "0.6835442", "0.6819716", "0.6796227", "0.67877436", "0.67875737", "0.67846715", "0.67788893", "0.67628354", "0.67628354", "0.67628354", "0.67628354", "0.6761941", "0.6754084", "0.67493063", "0.6739679", "0.6721266", "0.6717599", "0.6710898", "0.67106545", "0.67091453", "0.6708127", "0.67070186", "0.6707004", "0.66974455", "0.6695108", "0.6689813", "0.6688443", "0.668503", "0.66806006", "0.667938", "0.66719615", "0.66665184", "0.6658095", "0.66532296", "0.66487783", "0.6645982", "0.66391593", "0.6638963", "0.6637581", "0.66343033", "0.6633338", "0.6631466", "0.6629461", "0.66287404", "0.6626837", "0.6625652", "0.6622475", "0.6619744", "0.66171217", "0.6615421", "0.6611591", "0.66064024", "0.6596073", "0.6594775", "0.65917367", "0.65824527", "0.6581787", "0.65817505", "0.6581644", "0.65787476", "0.6578216", "0.6578141", "0.6577554", "0.65775335", "0.6574224", "0.6573493", "0.65724665", "0.6572437", "0.6571054", "0.6569565", "0.6565656", "0.65580374", "0.6556904", "0.6554206", "0.65515554", "0.6547869", "0.65462255", "0.6531534", "0.65309405", "0.6530361", "0.6529858", "0.6527552", "0.6527185", "0.6526808", "0.6524619", "0.6521229", "0.65193963", "0.65169156", "0.6516384", "0.6515791" ]
0.751043
0
Use callbacks to share common setup or constraints between actions.
def set_vitabus @vitabus = Vitabu.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 vitabus_params params.require(:vitabus).permit(:Name, :title, :dateborrowed) 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 /navigation_entries/1 GET /navigation_entries/1.xml
def show if dark_side? @navigation_entry = NavigationEntry.find(params[:id]) else @navigation_entry = NavigationEntry.find(params[:id], :include => :container) @navigation_entry_parent = @navigation_entry.parent @current_navigation_entry = @navigation_entry load_misc_stuffs @container = @navigation_entry.container end respond_to do |format| format.html # show.html.erb format.xml { render :xml => @navigation_entry } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n get_system\n @nav_entry = NavEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nav_entry }\n end\n end", "def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @navigation_entry }\n end\n end", "def index\n @relationships = Relationship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relationships }\n end\n end", "def index\n @relationships = @character.relationships.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relationships }\n end\n end", "def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end", "def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def index\n @entries = @resource_finder.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def get_listings_xml(url)\n @client.get_content(url)\n end", "def index\n @entries = Entry.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def code_rels\n @arc = Arc.find_by_code(params[:code])\n @arc_rels = @arc.relationships\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc_rels.to_xml(:root => 'relationships', :except => [ :created_at, :updated_at ]) }\n end\n end", "def fetch_entries(context)\n @site, @page = context.registers[:site], context.registers[:page]\n\n children = (case @source\n when 'site' then @site.pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then @page.parent || @page\n when 'page' then @page\n else\n @site.pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end).children_with_minimal_attributes(@options[:add_attributes]).to_a\n\n children.delete_if { |p| !include_page?(p) }\n end", "def index\n @navigation_items = NavigationItem.all\n end", "def index\n @independents = @member.independents\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @independents }\n end\n end", "def print_my_recent_bookmarks(username, password)\n # Make the HTTPS request.\n response = open('https://api.del.icio.us/v1/posts/recent',\n :http_basic_authentication => [username, password])\n\n # Read the response entity-body as an XML document.\n xml = response.read\n\n # Turn the document into a data structure.\n document = REXML::Document.new(xml)\n\n # For each bookmark...\n REXML::XPath.each(document, \"/posts/post\") do |e|\n # Print the bookmark's description and URI\n puts \"#{e.attributes['description']}: #{e.attributes['href']}\"\n end\nend", "def show\n @navigation = Navigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @navigation }\n end\n end", "def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend", "def entry_list\n unless params[:version] == '3.0'\n raise ActionController::RoutingError.new('Not Found')\n end\n\t\t\n @event = Event.find(params[:id])\n respond_to do |format|\n format.xml { render :layout => false }\n end\n end", "def index\n @meant_it_rels = MeantItRel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meant_it_rels }\n end\n end", "def show_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def xml\n @entry ||= open(entry_url).read\n rescue => e\n raise RuntimeError, \"coult not open entry url: #{entry_url} : \\n#{e}\"\n end", "def index\n @navigations = Navigation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @navigations }\n end\n end", "def fetch_entries(context)\n @site, @page, @portal_user = context.registers[:site], context.registers[:page], context.registers[:current_portal_user]\n set_defaults\n\n page = (case @source\n when 'site' then @all_pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then top_page\n when 'page' then @page\n else\n @all_pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end)\n\n children = children(page)\n\n children.delete_if { |p| !include_page?(p) }\n end", "def show\n @nav = Nav.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nav }\n end\n end", "def show\n @ledger_entries = @invoice.ledger_entries.page(params[:page])\n respond_with @organization, @invoice\n end", "def convictions_index_at_source\n page = get(base)\n page.search('div.listing-container ol li').map do |el|\n { 'link' => el.search('a').first['href'] }\n end\nend", "def show\n @subentry = Subentry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render xml: @subentry }\n end\n end", "def get_xml\n response = @api.request(:get, @location, type: 'xml')\n response.body if response.status == 200\n end", "def show\n @nav_item = NavItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nav_item }\n end\n end", "def index\n @links = Link.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @links }\n end\n end", "def code_revs\n @arc = Arc.find_by_code(params[:code])\n @arc_revs = @arc.rev_relationships\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc_revs.to_xml(:root => 'relationships', :except => [ :created_at, :updated_at ]) }\n end\n end", "def read\n super\n\n self.fetch\n\n index = self.pages['index']\n\n self.build_relationships(index, self.pages_to_list)\n\n # Locomotive::Mounter.with_locale(:en) { self.to_s } # DEBUG\n\n # self.to_s\n\n self.pages\n end", "def rss\n @event = Event.find_by_key(params['id'])\n @histories = @event.histories(:order => 'created_at DESC')\n render :layout => false\n response.headers[\"Content-Type\"] = \"application/xml; charset=utf-8\"\n end", "def create\n @navigation_entry = NavigationEntry.new(params[:navigation_entry])\n\n respond_to do |format|\n if @navigation_entry.save\n format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') }\n format.xml { render :xml => @navigation_entry, :status => :created, :location => @navigation_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @incidents = Incident.where(\"project = ?\", session[:project]).order( \"reference DESC\").\\\n\t paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @incidents }\n end\n end", "def show\n @entry = @resource_finder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @relationship = @character.relationships.find_by_permalink!(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relationship }\n end\n end", "def get_navigation_history\n {\n method: \"Page.getNavigationHistory\"\n }\n end", "def index\n @lookup_sets = LookupSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @lookup_sets }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def list_entries\n\nend", "def index\n @revisions = @page.revisions.sort { |a, b| b.created_at <=> a.created_at }\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @revisions }\n end\n end", "def index\n @referrals = paginate( Referral, :order => 'created_at desc' )\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @referrals }\n end\n end", "def navigation_items\n unless @io\n @io = []\n \n if can?( :index, PhoneBookEntry )\n @io << { :url => phone_book_entries_path , :title => t('phone_book_entries.index.page_title' ) }\n end\n \n # This could be a link to VoiceMails.\n #\n # if can?( :index, Object )\n # @io << { :url => \"#\" , :title => t('voice_mail') }\n # end\n \n end\n @io\n end", "def opensearch\n respond_to do |format|\n format.xml do\n render :layout => false\n end\n format.json do\n render :json => get_opensearch_response\n end\n end\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_doc = respond_with_hash(Nokogiri::XML(response.to_xml).text)\n end", "def parse(xml)\n\n document = Nokogiri::XML(xml)\n entries = document.xpath(@xpath)\n @results.concat(entries.to_a)\n\n {:entries => entries, :nextpage => atomlink(document)}\n end", "def index\n entries\n end", "def show\n @tag = Tag.find(params[:id])\n @tag_arcs = @tag.arcs.paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tag }\n end\n end", "def entries\n trace 'entries'\n $data['entries']\n end", "def list_relevances\n @entry = Entry.find(params[:id])\n @relevances = @entry.relevances\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @relevances }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def show\n @request = Request.find(params[:id])\n @items = @request.items\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @request }\n end\n end", "def destroy\n @navigation_entry = NavigationEntry.find(params[:id])\n @navigation_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(navigation_entries_url) }\n format.xml { head :ok }\n end\n end", "def read\n self.fetch\n\n index, not_found = self.pages['index'], self.pages['404']\n\n # localize the fullpath for the 2 core pages: index and 404\n [index, not_found].each { |p| p.localize_fullpath(self.locales) }\n\n self.build_relationships(index, self.pages_to_list)\n\n # Locomotive::Mounter.with_locale(:en) { self.to_s } # DEBUG\n\n # Locomotive::Mounter.with_locale(:fr) { self.to_s } # DEBUG\n\n self.pages\n end", "def show\n @glossary = Glossary.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @glossary.to_xml }\n end\n end", "def index\n @entries = list_entries\n respond_with @entries\n end", "def navigation_id; end", "def list\n\t\t@hras = Hra.paginate :page => params[:page], :per_page => 10\t#Pagination\n \trespond_to do |format|\t\t\n \t\t format.html \n \t\t\tformat.xml { render :xml => @hras }\t\t#Render to XML File\n \tend\n\tend", "def index\n @r_entries = REntry.all\n end", "def show\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @children }\n end\n end", "def navigation\n\t\t\t@navigation\n\t\tend", "def show\n @lookup_demographicrelativerelationship = LookupDemographicrelativerelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_demographicrelativerelationship }\n end\n end", "def index\n @new_resource = Referential::Resource.new(referential: @referential)\n breadcrumb\n end", "def show\n @container_navigation = ContainerNavigation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def show\n @entry = @entries.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def show\n @investigation = Investigation.find(params[:id])\n @names = @investigation.names\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @investigation }\n end\n end", "def index\n @menu_items = uhook_find_menu_items\n\n respond_to do |format|\n format.html {} # index.html.erb \n format.xml {\n render :xml => @menu_items\n }\n end\n end", "def opensearch\n respond_to do |format|\n format.xml do\n render :layout => false\n end\n format.json do\n render :json => get_opensearch_response\n end\n end\n end", "def show\n @arc = Arc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @arc.to_xml(:except => [ :created_at, :updated_at ], :include => :tahs) }\n end\n end", "def show\n @independent = @member.independents.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @independent }\n end\n end", "def index\n @search = Arc::Search.new(params[:search])\n @arcs = Arc.paginate(@search.find_options.merge(:page => params[:page], :order => 'location, code'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @arcs.to_xml(:except => [ :created_at, :updated_at ]) }\n end\n end", "def display(xml)\n\n # Load XML\n doc = REXML::Document.new(xml)\n\n doc.elements.each(\"Array/Hash/Entry[@name='name']\") do |element|\n puts element.text\n end\n\n # puts doc.elements[\"Array/Hash/Entry[@name='name']\"].text\n\n end", "def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @chronopay_links }\n end\n end", "def index\n @links = Link.find(:all,:conditions => [\"entity_id = ?\",@entity_id])\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @links.to_xml }\n end\n end", "def index\n @reforganism = Reforganism.find(params[:id])\n @referents = @reforganism.referents\n end", "def index\n @nodes = Node.all\n @title = \"List of taxonomy nodes - Browse organisms\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end", "def show\n @entry = Entry.find(params[:id])\n @entry.viewed\n breadcrumbs.add \"医药招商\",entries_url\n breadcrumbs.add nil\n #breadcrumbs.add @entry.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry }\n end\n end", "def index\n @defendants = Defendant.all\n @defendants = @defendants.page(params[:page]) || 1\n end", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end", "def index\n @nodes = Node.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @nodes }\n end\n end", "def show\n @lookup_set = LookupSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end", "def index\n @feed_entries = FeedEntry.all\n @title = \"Feeds List\"\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @feed_entries }\n end\n end", "def show\n @referential = @publication.referential\n breadcrumb\n end", "def show\n @node = Node.find(params[:id])\n @title = \"Taxonomy node - organism relationships\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @node }\n end\n end", "def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end", "def show\n @relationship = Relationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @relationship }\n end\n end", "def index\n @current_item = \"my_account\"\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @accounts.to_xml }\n end\n end", "def index\n @glossaries = Glossary.order('title')\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @glossaries.to_xml }\n end\n end", "def index\n @accessories = Accessory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @accessories }\n end\n end", "def index\n @link_types = LinkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @link_types }\n end\n end", "def index\n @pages = []\n website.available_locales.each do |l|\n @pages << {\n url: locale_sitemap_url(locale: l.locale.to_s, format: 'xml'),\n updated_at: 1.day.ago}\n end\n respond_to do |format|\n format.html\n format.xml\n end\n end", "def index\n @relationships = Relationship.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end", "def index\n @requests = Request.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @requests }\n end\n end", "def index\n @node = Fedora.rest('rest/')\n end", "def show\n @lookup_source = LookupSource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @lookup_source }\n end\n end", "def index\n @map_nodes = Map::Node.paginate(:page => params[:page], :per_page => 64)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end", "def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @line_items }\n end\n end" ]
[ "0.6165826", "0.60939664", "0.56854534", "0.56743675", "0.5634604", "0.56317663", "0.5625504", "0.5591887", "0.557813", "0.5533949", "0.5523955", "0.55136216", "0.55057335", "0.548531", "0.543066", "0.5426167", "0.53777665", "0.5370002", "0.5351255", "0.53340465", "0.5289536", "0.5278364", "0.52669024", "0.5261019", "0.5255424", "0.52491456", "0.52483827", "0.52462476", "0.52437526", "0.52384967", "0.52345455", "0.523355", "0.5231981", "0.5231134", "0.5204061", "0.5199579", "0.51837087", "0.5181025", "0.5180035", "0.5179936", "0.5179936", "0.51748097", "0.51723903", "0.51562035", "0.5154158", "0.5152119", "0.51504344", "0.51495266", "0.51487345", "0.51465285", "0.51386994", "0.5129014", "0.51273113", "0.512703", "0.51266366", "0.5125908", "0.5111863", "0.51073015", "0.5103395", "0.50960684", "0.5089825", "0.5087062", "0.5086849", "0.5079776", "0.5074639", "0.50632036", "0.5061343", "0.50567675", "0.5056127", "0.50543076", "0.5054123", "0.5051526", "0.50499356", "0.50469184", "0.50453734", "0.50444686", "0.50414413", "0.5035439", "0.5031146", "0.50292456", "0.5028866", "0.5028866", "0.5027379", "0.50270563", "0.502654", "0.5020103", "0.5020103", "0.50142556", "0.5013716", "0.50107527", "0.5007937", "0.5000033", "0.49989417", "0.4994305", "0.49935216", "0.49899432", "0.49804804", "0.49782726", "0.4976324", "0.4976324" ]
0.57701737
2
GET /navigation_entries/new GET /navigation_entries/new.xml
def new @navigation_entry = NavigationEntry.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @navigation_entry } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n get_system\n @parent = NavEntry.find(params[:parent_id]) unless params[:parent_id].nil?\n @nav_entry = NavEntry.new(:system => @system, :parent => @parent)\n get_parents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav_entry }\n end\n end", "def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def create\n @navigation_entry = NavigationEntry.new(params[:navigation_entry])\n\n respond_to do |format|\n if @navigation_entry.save\n format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') }\n format.xml { render :xml => @navigation_entry, :status => :created, :location => @navigation_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @entry = Entry.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @navigation = Navigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @navigation }\n end\n end", "def new\n @nav = Nav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav }\n end\n end", "def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end", "def new\n @relationship = Relationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relationship }\n end\n end", "def new\n @page = @offering.pages.new\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @lookup_source = LookupSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_source }\n end\n end", "def new\n @nav_item = NavItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav_item }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end", "def new\n @population = Population.new(:access_level => 'creator')\n session[:breadcrumbs].add \"New\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @population }\n end\n end", "def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @lookup_demographicrelativerelationship = LookupDemographicrelativerelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_demographicrelativerelationship }\n end\n end", "def new\n @relationship = @character.relationships.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @relationship }\n end\n end", "def new_rest\n @entry_instrument = EntryInstrument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_instrument }\n end\n end", "def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def create \n get_system\n @nav_entry = NavEntry.new(params[:nav_entry])\n get_parents\n\n respond_to do |format|\n if @nav_entry.save\n format.html { redirect_to(system_path(@system), :notice => 'Nav entry was successfully created.') }\n format.xml { render :xml => @nav_entry, :status => :created, :location => @nav_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end", "def new\n @node = Node.new(:displayed => true)\n @node.template = Template.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @menu = uhook_new_menu\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def new\n @entry = Entry.new\n @folders = Folder.find(:all, :order => \"updated_at DESC\").map { |f| [f.name, f.id] }\n @new = true;\n\n respond_to do |format|\n format.html { render \"edit\" }\n format.xml { render :xml => @entry }\n end\n end", "def new\n @location = Location.new\n @pages = {}\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @original_menu = OriginalMenu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @original_menu }\n end\n end", "def new\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.debug(fname) {\"params=#{params}\"}\n\t\t@relation = Relation.new\n\t\t@views = View.all\n\t\t@types = Typesobject.get_types(\"relation\")\n\t\t@status = Statusobject.get_status(\"relation\")\n\t\t#LOG.debug(fname) {\"relation=#{@relation.inspect}\"}\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @relation }\n\t\tend\n\tend", "def new\n @journal_entry = JournalEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journal_entry }\n end\n end", "def new\n @node = Node.new\n @title = \"Taxonomy node - organism relationships\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end", "def new\n @page = current_cms.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @organization = Organization.new\n session[:breadcrumbs].add \"New\"\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @journalentry = Journalentry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @journalentry }\n end\n end", "def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end", "def new\n @menu_page = MenuPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu_page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n \n end\n end", "def new\n @page = Page.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @children = Children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @children }\n end\n end", "def new\n @container_navigation = ContainerNavigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_navigation }\n end\n end", "def new\n \n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @ref = Ref.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ref }\n end\n end", "def new\n @link = Link.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @link = Link.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @atom = Atom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @atom }\n end\n end", "def new\n @mapping = Mapping.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mapping }\n end\n end", "def new\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ganglia_graph }\n end\n end", "def new\n @old_route_tag = OldRouteTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @old_route_tag }\n end\n end", "def new\n new_object Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :layout => \"default\" }\n end\n end", "def new_rest\n @page_usage_event = PageUsageEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page_usage_event }\n end\n end", "def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end", "def new\n @retain_node = RetainNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @retain_node }\n format.json { render :json => @retain_node }\n end\n end", "def new\n @listing = Listing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @listing }\n end\n end", "def new\n @localmap = Localmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @localmap }\n end\n end", "def new\n @journal_entry = JournalEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @journal_entry }\n format.xml { render :xml => @journal_entry }\n end\n end", "def new\n @entry = Entry.new\n 2.times { @entry.transactions.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end", "def new\n @page = Page.new\n\t\t@types = Type.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @link = Link.new :long => 'http://'\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.json { render json: @page }\n format.xml { render xml: @page }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |wants|\n wants.html # new.html.erb\n wants.xml { render :xml => @page }\n end\n end", "def new\n @attachment = Attachment.new\n @entries = Entry.find(:all, :order => \"updated_at DESC\").map { |e| [e.title, e.id] }\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @attachment }\n end\n end", "def new\n @menu = Menu.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu }\n end\n end", "def new\n @page = Page.new\n\n respond_to do |format|\n format.json {render json: @page}\n format.xml {render xml: @page}\n end\n end", "def index\n @new_resource = Referential::Resource.new(referential: @referential)\n breadcrumb\n end", "def new\n\t\t@path = [link_to_ideas, link_to_new_idea]\n\t\t@subnavigation = [active_link_to_new_idea,link_to_show_all_ideas(\"Alle Ideen\", \"title\", \"ASC\", \"\", 0, 30)]\n\n @idea = Idea.new\n\t\t@categories = Category.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @idea }\n end\n end", "def new\n @occurence = Occurence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @occurence }\n end\n end", "def new\n\t\t@link = Link.new\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @link }\n\t\tend\n\tend", "def new\n\t\tfname= \"#{controller_class_name}.#{__method__}\"\n\t\t@relation = Relation.new\n\t\t@datas = @relation.datas\n\t\t@views = View.all\n\t\t#LOG.debug (fname) {\"#{typesobject=@relation.typesobject}\"}\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @relation }\n\t\tend\n\tend", "def new\n @creation = Creation.new\n @topics = Topic.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @creation }\n end\n end", "def new\n @gene_ontology = GeneOntology.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gene_ontology }\n end\n end", "def new\n @page = Page.new(:status => params[:from])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @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 @menutree = Menutree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menutree }\n end\n end", "def new\n @lookup_truthtable = LookupTruthtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_truthtable }\n end\n end", "def new\n @association = Association.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @association }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end", "def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end", "def new_rest\n @item_usage = ItemUsage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_usage }\n end\n end", "def new\n @link_type = LinkType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @link_type }\n end\n end", "def new\n @menu_item = uhook_new_menu_item\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @menu_item }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end", "def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end", "def new\n @bookmark = Bookmark.new(:tags => [Tag.new])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bookmark }\n end\n end", "def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end" ]
[ "0.6963487", "0.68094933", "0.6779341", "0.65997523", "0.65111494", "0.6475915", "0.6453136", "0.6371884", "0.6367441", "0.6349056", "0.63081664", "0.6302887", "0.6284018", "0.6284018", "0.6281309", "0.6276518", "0.62648857", "0.62576354", "0.6250752", "0.6236876", "0.621537", "0.621537", "0.62030387", "0.620106", "0.61804485", "0.6179116", "0.6162025", "0.6161664", "0.61575514", "0.61560714", "0.61416495", "0.6136307", "0.61361694", "0.6129124", "0.61278737", "0.61278737", "0.61278737", "0.61278737", "0.61278737", "0.61278737", "0.6118663", "0.6118663", "0.6118663", "0.6109083", "0.61085", "0.60973984", "0.6096587", "0.6090395", "0.6089693", "0.6089034", "0.6083953", "0.6082171", "0.60791594", "0.60791594", "0.60791594", "0.60791594", "0.60776275", "0.60737646", "0.60737646", "0.60667956", "0.6060479", "0.60580444", "0.6045474", "0.6040518", "0.6024224", "0.6016025", "0.60130817", "0.6010826", "0.6005969", "0.5997578", "0.5994404", "0.5992349", "0.598782", "0.5986962", "0.5979043", "0.59754664", "0.597509", "0.5971012", "0.5968892", "0.59669966", "0.5959564", "0.5959021", "0.5958168", "0.5956727", "0.59520984", "0.5946706", "0.5945138", "0.59443", "0.59438086", "0.5942959", "0.59410936", "0.59382993", "0.5937235", "0.5930128", "0.59287876", "0.59285295", "0.59285295", "0.59276545", "0.59259164", "0.5923173" ]
0.76766187
0
POST /navigation_entries POST /navigation_entries.xml
def create @navigation_entry = NavigationEntry.new(params[:navigation_entry]) respond_to do |format| if @navigation_entry.save format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') } format.xml { render :xml => @navigation_entry, :status => :created, :location => @navigation_entry } else format.html { render :action => "new" } format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @navigation_entry }\n end\n end", "def create \n get_system\n @nav_entry = NavEntry.new(params[:nav_entry])\n get_parents\n\n respond_to do |format|\n if @nav_entry.save\n format.html { redirect_to(system_path(@system), :notice => 'Nav entry was successfully created.') }\n format.xml { render :xml => @nav_entry, :status => :created, :location => @nav_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @navigation_entry = NavigationEntry.find(params[:id])\n\n respond_to do |format|\n if @navigation_entry.update_attributes(params[:navigation_entry])\n format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @navigation = Navigation.new(params[:navigation])\n\n respond_to do |format|\n if @navigation.save\n format.html { redirect_to @navigation, notice: 'Navigation was successfully created.' }\n format.json { render json: @navigation, status: :created, location: @navigation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @navigation_entry = NavigationEntry.find(params[:id])\n @navigation_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(navigation_entries_url) }\n format.xml { head :ok }\n end\n end", "def navigation_item_params\n params.require(:navigation_item).permit(:navigation_item_id, :page_id, :title, :link)\n end", "def create\n @navigation_item = NavigationItem.new(navigation_item_params)\n\n respond_to do |format|\n if @navigation_item.save\n format.html { redirect_to [:admin, @navigation_item], notice: 'Navigation item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @navigation_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @navigation_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @container_navigation = ContainerNavigation.new(params[:container_navigation])\n\n respond_to do |format|\n if @container_navigation.save\n format.html { redirect_to @container_navigation, notice: 'Container navigation was successfully created.' }\n format.json { render json: @container_navigation, status: :created, location: @container_navigation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @relationships = Relationship.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @relationship = Relationship.create(params[:relationship])\n end", "def homepage\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/OrgEntry.jsp')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/corner3.png')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/images/transparent.gif')\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService', \n {\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'method' => 'POST',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgOrgRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgPersonRelationTypes|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/SecurityRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|29F4EA1240F157649C12466F01F46F60|org.kuali.student.common.ui.client.service.SecurityRpcService|getPrincipalUsername|1|2|3|4|0|\"\n }\n )\n\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.docSearch.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|ks.rice.actionList.serviceAddress|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|lum.application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgMetaData|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/ServerPropertiesRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|6|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|3DDEE7B5823674CCFB876EDB821C7743|org.kuali.student.common.ui.client.service.ServerPropertiesRpcService|get|java.lang.String|application.url|1|2|3|4|1|5|6|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n # Dupe request - BUG?\n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getSectionConfig|1|2|3|4|0|\"\n }\n )\n \n @request.add('/org.kuali.student.core.organization.ui.OrgEntry/rpcservices/OrgRpcService',\n {\n 'method' => 'POST',\n 'content_type' => 'text/x-gwt-rpc; charset=utf-8',\n 'contents' => \"5|0|4|#{@request.url}/org.kuali.student.core.organization.ui.OrgEntry/|AE88E9E993C2C04C4BAC534CC092D550|org.kuali.student.core.organization.ui.client.service.OrgRpcService|getOrgTypes|1|2|3|4|0|\"\n }\n )\n \n end", "def order\n neworder = JSON.parse(params[:set])\n rootpage = Page.language_root_for(session[:language_id])\n\n tree = create_tree(neworder, rootpage)\n\n Alchemy::Page.transaction do\n tree.each do |key, node|\n dbitem = Page.find(key)\n dbitem.update_node!(node)\n end\n end\n\n flash[:notice] = _t(\"Pages order saved\")\n @redirect_url = admin_pages_path\n render :action => :redirect\n end", "def test_should_create_link_via_API_XML\r\n get \"/logout\"\r\n post \"/links.xml\", :api_key=>'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n end", "def entries_to_http entries, url, http = Atom::HTTP.new\n coll = Atom::Collection.new url, http\n\n entries.each { |entry| coll.post! entry }\n end", "def persist_content_entries_with_relationships\n unless self.with_relationships.empty?\n self.log \"\\n setting relationships for all the content entries\\n\"\n\n updates = self.content_entries_with_relationships_to_hash\n\n updates.each do |params|\n _id, slug = params.delete(:_id), params.delete(:slug)\n self.put \"content_types/#{slug}/entries\", _id, params\n end\n end\n end", "def entries\n params[:return_entries] = true\n self\n end", "def save_related\n if self.links.present?\n self.links.each do | link |\n link.parent_type = :action_item\n link.parent_key = self.key\n link.save!\n end\n end\n end", "def create_sitemap\n end", "def index\n @navigation_items = NavigationItem.all\n end", "def entries\n trace 'entries'\n $data['entries']\n end", "def the_post_navigation(args = {} )\n get_the_post_navigation( args )\n end", "def entries\n @controller.send(:entries)\n end", "def navigation_id; end", "def new_rest\n @entry_item = EntryItem.new\n\n respond_to do |format|\n #format.html # new.html.erb\n format.xml { render :xml => @entry_item }\n end\n end", "def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end", "def sub_navigate\n page(FeedDetailsPage).touch_row\n page(MorePage).page_handler(\"Submission\")\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end", "def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_list.take(MAX_NODES)\n nodes_list = nodes_list.drop(MAX_NODES)\n way_id = create_way(way_nodes)\n ways_list << way_id\n end\n\n relation = create_relation(ways_list) # Link ways to relation\n relation = add_stops(relation, route.stops) # Add bus stops to relation\n\n @api.save(relation, @changeset) # Save relation using the API\n puts 'Relation created succesfuly.'\n @api.close_changeset(@changeset)\n @changeset.id\n end", "def create_tag_pages\n tag_set(items).each do |tag|\n @items.create(\n \"= render('_tag_page', :tag => '#{tag}')\", # use locals to pass data\n { :title => \"Category: #{tag}\", :is_hidden => true}, # do not include in sitemap.xml\n \"/tags/#{tag}/\", # identifier\n :binary => false\n )\n end\nend", "def create\n #assign unpermitted parameter 'entries' to a variable\n entries = params[\"entries\"]\n @invoice = @user.invoices.build(invoice_params)\n #save entries\n @invoice.entries = entries\n if @invoice.save\n render json: @invoice, status: :created, location: api_v1_user_invoice_url(@user, @invoice)\n else\n render json: @invoice.errors, status: :unprocessable_entity\n end\n end", "def fetch_entries(context)\n @site, @page = context.registers[:site], context.registers[:page]\n\n children = (case @source\n when 'site' then @site.pages.root.minimal_attributes(@options[:add_attributes]).first # start from home page\n when 'parent' then @page.parent || @page\n when 'page' then @page\n else\n @site.pages.fullpath(@source).minimal_attributes(@options[:add_attributes]).first\n end).children_with_minimal_attributes(@options[:add_attributes]).to_a\n\n children.delete_if { |p| !include_page?(p) }\n end", "def create\n return unless verify_locale_access(create_params[:rfc5646_locale])\n\n @locale_entry = @source_entry.locale_glossary_entries.create(create_params)\n respond_with @source_entry, @locale_entry, location: edit_glossary_source_locale_url(@source_entry, @locale_entry)\n end", "def and_i_add_a_new_timeline_entry\n click_on(I18n.t(\"coronavirus.pages.show.timeline_entries.add\"))\n end", "def create_rest\n @entry_item = EntryItem.new(params[:entry_item])\n\n respond_to do |format|\n if @entry_item.save\n flash[:notice] = 'EntryItem was successfully created.'\n #format.html { redirect_to(@entry_item) }\n format.xml { render :xml => @entry_item, :status => :created, :location => @entry_item }\n else\n #format.html { render :action => \"new\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_line_items_link\n self.get_element(@browser, '//a[contains(@href, \"/line_items/create?insertion_orders.id=\")]')\n end", "def nav_params\n params.require(:nav).permit(:name, :target, :order, :link_external, :link_page_id, :link_post_id, :publish, :category_id, :type_nav)\n end", "def link_to_add_entry(page)\n url = new_admin_page_path parent_id: page.id, type: page_set_type(page)\n raw link_to 'Add Entry', url, class: 'button add-child'\n end", "def add_entries_info(entries, path)\n # use the git reflog to get a list of pushes\n reflog = @repo.ref('refs/heads/master').log.reverse\n # walk through all the commits until this revision's +@commit+ is found\n # (this is needed to advance the reflog to the right point, since +@commit+ may be between two pushes)\n walker_entries = entries.dup\n last_commit = @repo.last_commit\n reflog_entries = {}\n reflog_entries[last_commit.oid] = { index: -1 }\n found = false\n walker = Rugged::Walker.new(@repo)\n walker.sorting(Rugged::SORT_TOPO)\n walker.push(last_commit.oid)\n walker.each do |commit|\n current_reflog_entry = GitRepository.try_advance_reflog!(reflog, reflog_entries, commit)\n found = true if @commit.oid == commit.oid\n next unless found\n # check entries that were modified\n mod_keys = walker_entries.keys.select { |entry_name| entry_changed?(File.join(path, entry_name), commit) }\n mod_entries = walker_entries.extract!(*mod_keys)\n mod_entries.each do |_, mod_entry|\n mod_entry.last_modified_revision = commit.oid\n mod_entry.last_modified_date = commit.time.in_time_zone\n mod_entry.submitted_date = current_reflog_entry[:time]\n mod_entry.changed = commit.oid == @revision_identifier\n mod_entry.user_id = commit.author[:name]\n end\n break if walker_entries.empty?\n end\n end", "def post_nodes_with_root\n serialize_service.post_nodes_serialized\n end", "def neat_pages_navigation(options={})\n NeatPages::Helpers::Navigation.new(pagination, request).generate\n end", "def new\n get_system\n @parent = NavEntry.find(params[:parent_id]) unless params[:parent_id].nil?\n @nav_entry = NavEntry.new(:system => @system, :parent => @parent)\n get_parents\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nav_entry }\n end\n end", "def ingest_pages\n @table_of_contents.unique_pages.each_with_index do |entry, index|\n label = entry ? Utils.xml_escape(entry.title) : \"Page #{index + 1}\"\n @component_objects.push ingest_page(entry.image_filename, label, index + 1)\n end\n\n if @manifest.embargo\n @component_objects.each do |pid|\n @drupal_db.add_embargo pid, @manifest.embargo['rangeName'], @manifest.embargo['endDate']\n end\n end\n end", "def build_dom(entries); end", "def add_pages(id, pages) \n pages = pages.join(',') if pages.class == Array\n args = {userId: id, pageNames: pages}\n post('addPagesToSubAccount', args)\n end", "def navigation_items\n unless @io\n @io = []\n \n if can?( :index, PhoneBookEntry )\n @io << { :url => phone_book_entries_path , :title => t('phone_book_entries.index.page_title' ) }\n end\n \n # This could be a link to VoiceMails.\n #\n # if can?( :index, Object )\n # @io << { :url => \"#\" , :title => t('voice_mail') }\n # end\n \n end\n @io\n end", "def create_entries(doc)\n return nil\n end", "def save_dictionary_entries(dictionary, dictionary_entries, opts = {})\n response = @transporter.write(\n :POST,\n path_encode('/1/dictionaries/%s/batch', dictionary),\n { clearExistingDictionaryEntries: false, requests: chunk('addEntry', dictionary_entries) },\n opts\n )\n\n DictionaryResponse.new(self, response)\n end", "def index\n @new_resource = Referential::Resource.new(referential: @referential)\n breadcrumb\n end", "def create\n @study_set = StudySet.new(user_id: current_user.id, link_id: params[:study_set][:link_id])\n @study_set.entries << Entry.find(params[:study_set][:entry_id])\n\n respond_to do |format|\n if @study_set.save\n if params.has_key? 'save-return'\n format.html { redirect_to current_user, notice: 'Study set was successfully created.' }\n else\n format.html { redirect_to @study_set, notice: 'Study set was successfully created.' }\n format.json { render json: @study_set.entries }\n end\n else\n format.html { render :new }\n format.json { render json: @study_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def link_to_add_entry page\n url = new_admin_page_path parent_id: @page.id, type: page_set_type(page)\n raw link_to 'Add Entry', url, class: 'button add', id: 'add-entry'\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/rewardsaccount/v1\")\n end", "def postFlatpackSitemap( flatpack_id, filedata)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n params['filedata'] = filedata\n return doCurl(\"post\",\"/flatpack/sitemap\",params)\n end", "def navigate_to_history_entry(entry_id:)\n {\n method: \"Page.navigateToHistoryEntry\",\n params: { entryId: entry_id }.compact\n }\n end", "def associate_page(page); end", "def parse(response, url:, data: {})\n new_routes = response.xpath(\"//tr[@class='route-row']/td/a\").map { |a| { link: a[:href] } }\n new_routes += data if data.present?\n raise \"No Routes Found\" unless new_routes\n\n next_button = response.at_xpath(\"//div[@class='pagination']/a[not(@class='no-click')][img[@alt='Next' and not(@class ='rotate-180 skinny')]]\")\n request_to(:parse, url: next_button[:href], data: new_routes) if next_button\n\n new_routes.each do |route|\n request_to(:parse_route_page, url: route[:link], data: route)\n end\n\n save_to \"results/#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.json\", { routes: new_routes }, format: :pretty_json, position: false\n end", "def index\n @navigations = Navigation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @navigations }\n end\n end", "def create\n @nav_item = NavItem.new(params[:nav_item])\n\n respond_to do |format|\n if @nav_item.save\n flash[:notice] = 'NavItem was successfully created.'\n format.html { redirect_to(@nav_item) }\n format.xml { render :xml => @nav_item, :status => :created, :location => @nav_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nav_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n get_system\n @nav_entry = NavEntry.find(params[:id])\n get_parents\n\n respond_to do |format|\n if @nav_entry.update_attributes(params[:nav_entry])\n format.html { redirect_to(system_nav_entry_path(@system, @nav_entry), :notice => 'Nav entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/investmentaccount/v1\")\n end", "def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end", "def create\n @nav_item = NavItem.new(extract_item(params))\n\n respond_to do |format|\n if @nav_item.save\n format.html { redirect_to nav_items_path, notice: t('nav_items.created') }\n format.json { render json: @nav_item, status: :created, location: @nav_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nav_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_xml_64(xml=:example_response)\n post \"/auth/saml/callback\", {'SAMLResponse' => load_xml_64(xml)}\nend", "def generate_tag_pages\n all_tags(items).each do |tag|\n items.create(\"\", { :tag => tag }, \"/tags/#{tag}\")\n end\nend", "def add_navigation_node(ttype)\n nav_node = nil\n if ((ttype).equal?(Token::DOWN))\n if (has_unique_navigation_nodes)\n nav_node = @adaptor.create(Token::DOWN, \"DOWN\")\n else\n nav_node = @down\n end\n else\n if (has_unique_navigation_nodes)\n nav_node = @adaptor.create(Token::UP, \"UP\")\n else\n nav_node = @up\n end\n end\n @nodes.add(nav_node)\n end", "def editable_list \n @translations = Translation.paginate(:page => params[:page], :per_page=>25) \n #puts \"@translations: \" + @translations.first.dot_key_code\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @translations }\n end\n end", "def test_can_post_valid_entry\n valid_entry = SEED_ENTRIES.first\n post_json '/api/entries', valid_entry.except(:slug)\n\n assert last_response.created?\n\n location = \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.headers['Location'] = location\n assert last_response.headers['Content-Location'] = location\n\n parsed_resp = parse_json_resp(last_response)\n assert_instance_of Hash, parsed_resp\n assert_equal valid_entry[:word], parsed_resp['word']\n assert_equal valid_entry[:definition], parsed_resp['definition']\n assert_equal location, parsed_resp['location']\n end", "def index\n @entries = Entry.order('created_at DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def new\n @navigation = Navigation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @navigation }\n end\n end", "def new_rent_office\n @rent_entry = RentEntry.new\n @rent_entry.user_id = session[:user_id]\n @subway_stations = SubwayStation.find(:all)\n @ess = EntriesSubwayStations.new\n respond_to do |format|\n format.html\n format.xml { render :xml => @entry }\n end\n end", "def search_success\n page(SubmissionPage).create_post(\"search query\")\n page(FeedDetailsPage).view_search(\"Microsoft\")\n page(FeedDetailsPage).touch_rec\n page(FeedDetailsPage).view_search(\"Microsoft\")\nend", "def create\n create_entry\n \n # Redirect to entry view to show the new element\n redirect_to show_entry_path(params[:type], @entry[:id])\n end", "def add_link(lh)\n lnk_wid = lh[:wid]\n\tlnk_role = lh[:role]\n\t\n\t# find or create the attach node\n if @doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last.nil?\n Nokogiri::XML::Builder.with(@doc.xpath('//work-item').last) do\n field(:id => 'linkedWorkItems') {\n\t list {}\n\t }\n end\n end\n\t\n\t# build and attach the link struct\n\tNokogiri::XML::Builder.with(@doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last) do\n\t struct {\n\t item(:id => 'revision')\n\t\titem(:id => 'workItem') {\n\t\t text lnk_wid\n\t\t}\n\t\titem(:id => 'role') {\n\t\t text lnk_role\n\t\t}\n\t }\n\tend\n end", "def submit_menu\n @order = Order.create! user_id: current_user.id, restaurant_id: @restaurant.id\n\n params[:order].each do |order_item|\n MenuItemOrder.create(order_id: @order.id, menu_item_id: params[:order][order_item][:item], quantity: params[:order][order_item][:quantity])\n end\n respond_to do |format|\n format.html { redirect_to new_order_path(@restaurant), notice: 'Menu items were successfully submitted.' }\n format.json { render :new, status: :created, location: @order }\n end\n end", "def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end", "def list_entries\n\nend", "def create\n @mlog_entry = MlogEntry.new(mlog_entry_params)\n @collection = Collection.find(@mlog_entry[:collection_id])\n @accession = Accession.find(@mlog_entry[:accession_id])\n respond_to do |format|\n if @mlog_entry.save\n format.html { redirect_to @mlog_entry, notice: 'Entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mlog_entry }\n else\n format.html { render action: 'new' }\n format.json { render json: @mlog_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def navigation_children\n sorted_children\n end", "def entries_from(properties)\n type = properties[:type].to_sym\n\n properties[:document].root.inject([]) do |results, entry|\n if entry.name == properties[:entry_tag]\n results << new_doc(type, node_to_ary(entry), ['apps:', 'atom:', 'gd:'])\n end\n set_next_page(entry) if entry.name == 'link' and entry.attributes[:rel] == 'next'\n results\n end\n end", "def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end", "def POST; end", "def create_entries(doc,id_map = {})\n encounter_list = []\n entry_elements = doc.xpath(@entry_xpath)\n entry_elements.each do |entry_element|\n encounter = create_entry(entry_element, id_map={})\n if @check_for_usable\n encounter_list << encounter if encounter.usable?\n else\n encounter_list << encounter\n end\n end\n encounter_list\n end", "def entry_list\n unless params[:version] == '3.0'\n raise ActionController::RoutingError.new('Not Found')\n end\n\t\t\n @event = Event.find(params[:id])\n respond_to do |format|\n format.xml { render :layout => false }\n end\n end", "def create \n if InfoNode.duplicate_key?(params[:info_types])\n redirect_to :back, :alert => \"Key in the additional information shoud be unique\"\n return\n end\n\n unless params[:rid].nil?\n @rid = params[:rid].strip\n end\n\n @type = params[:type] \n\n @refs = []\n\n params[:refids].each_with_index do |ref_id, idx|\n @refs << {:ref_id => ref_id, :role => params[:labels][idx]}\n end unless params[:refids].nil?\n\n if @refs.empty?\n redirect_to :back, :alert => \"Please add references for a new relation\"\n return\n end\n\n @info_nodes = {}\n (0...params[:info_types].size).each do |i|\n key = params[:info_types][i]\n value = params[:info_values][i]\n if !key.nil? && !key.strip.blank? && !value.nil? && !value.strip.blank?\n @info_nodes[key] = value\n end\n end\n\n begin\n @collection = current_user.collections.find(params[:collection_id])\n raise \"Cannot find the collection No. #{params[:collection_id]}\" if @collection.nil?\n \n @document = @collection.documents.find_by_pmid(params[:document_id])\n raise \"Cannot find the document No. #{params[:document_id]}\" if @document.nil?\n \n @rid = @document.create_new_relation_id if @rid.blank?\n \n @relation = @document.create_relation(@rid, @type, @refs, @info_nodes)\n\n respond_to do |format|\n format.html { redirect_to \"/collections/#{@collection.id}/documents/#{@document.pmid}?tab=relation\", :notice => 'Relation was successfully created.' }\n format.json { render :json => @relation, :status => :created, :location => @relation }\n end\n rescue Exception => e\n logger.debug(e.backtrace)\n respond_to do |format|\n format.html { redirect_to :back, :alert => e.message}\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n end", "def entry_params\n params.require(:entry).permit(\n :term, :id, :_destroy,\n definitions_attributes: [:definition, :id, :_destroy],\n examples_attributes: [:example, :id, :_destroy],\n references_attributes: [:source, :id, :_destroy]\n )\n end", "def create\n @entry = Entry.new(entry_params)\n @dictionary = Dictionary.find(params[:dictionary_id])\n respond_to do |format|\n if @entry.save\n format.html { redirect_to dictionary_entry_path(@dictionary, @entry),\n notice: 'Entry was successfully created.' }\n format.json { render :show, status: :created, location: @entry }\n else\n format.html { render :new }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def post(path, *args)\n page.driver.post(path, *args)\n page.driver.follow_redirects!\n end", "def create\n logger.info \"Creating Entry\"\n @entry = Entry.new(params[:entry])\n logger.info \"Entry Created\"\n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to(entries_url, :notice => 'Entry was successfully created.') }\n format.xml { render :xml => @entry, :status => :created, :location => @entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @entries = Entry.all;\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end", "def create\n @randomisation_entry = RandomisationEntry.new(randomisation_entry_params)\n @randomisation_entry.randomisation_session = @randomisation_session\n last_internal_order = @randomisation_session.randomisation_entries.order(:interal_order).size\n @randomisation_entry.internal_order =(last_internal_order + 1)\n\n respond_to do |format|\n if @randomisation_entry.save\n format.html { redirect_to show_random_match_randomisation_session_randomisation_entry_path(@randomisation_session,@randomisation_entry), notice: 'Randomisation entry was successfully created.' }\n format.json { render :show, status: :created, location: @randomisation_entry }\n else\n format.html { render :new }\n format.json { render json: @randomisation_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_relation\n #add relation\n @word.word_roots.create(@word_root)\n respond_to do |format|\n format.js\n end\n end", "def walkroute_params\n params.require(:walkroute).permit(:name, :description, :references)\n end", "def reorganize\n list = params[:list]\n prev_page = nil\n last_root = nil\n list.each_with_index do |item, i|\n item_params = item[1]\n\n page = Page.find(item_params['id'].to_i)\n \n # if root of tree on rails side\n if item_params['parent_id'] == ''\n page.parent_id = nil\n if last_root\n page.move_to_right_of(last_root.id)\n end\n last_root = page\n page.save\n\n else\n page.parent_id = item_params['parent_id'].to_i\n page.save\n \n # shift to the right of previous element if parent is the same\n if prev_page.parent_id == page.parent_id\n page.move_to_right_of(prev_page.id)\n else\n\n # iterate backwards to find last sibling\n current_index = i - 1 \n found_sibling = false\n keys = list.keys\n\n while found_sibling == false and current_index > 0 do\n if list[keys[current_index]]['parent_id'] == item_params['parent_id']\n page.move_to_right_of(list[keys[current_index]]['id'])\n found_sibling = true\n else\n current_index -= 1\n end\n end\n\n end\n end\n\n # set previous item\n prev_page = page\n\n end\n\n respond_to do |format|\n format.json { head :ok } \n end\n end", "def create\n @nav = Nav.new(params[:nav])\n\n respond_to do |format|\n if @nav.save\n flash[:notice] = 'Nav was successfully created.'\n format.html { redirect_to(@nav) }\n format.xml { render :xml => @nav, :status => :created, :location => @nav }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nav.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entry_items }\n end\n end", "def index\n @map_nodes = Map::Node.paginate(:page => params[:page], :per_page => 64)\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n @entries = Entry.ordered\n end", "def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end", "def render_admin_subnavigation(entries)\n render \"alchemy/admin/partials/sub_navigation_tab\", :entries => entries\n end", "def create_entries(opts = {})\n data, _status_code, _headers = create_entries_with_http_info(opts)\n data\n end", "def entries\n trace 'entries'\n @data['entries']\n end", "def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end" ]
[ "0.5658883", "0.5533778", "0.50773793", "0.49485782", "0.4905544", "0.4884094", "0.48772314", "0.48564732", "0.48458454", "0.46960834", "0.46764162", "0.46683216", "0.4659268", "0.46583784", "0.46539962", "0.46283823", "0.46105677", "0.4609168", "0.46084428", "0.460109", "0.45989352", "0.45970422", "0.4587015", "0.45789135", "0.4570744", "0.45637724", "0.4563028", "0.4533671", "0.45242956", "0.4519429", "0.45142296", "0.45099318", "0.4501675", "0.44992414", "0.44988993", "0.4494457", "0.44872436", "0.4469959", "0.44698554", "0.44639862", "0.44564894", "0.44476348", "0.44457835", "0.44424745", "0.44387054", "0.4431467", "0.4428945", "0.4428461", "0.4426978", "0.44157845", "0.44062668", "0.440301", "0.44018355", "0.43999588", "0.43920833", "0.43904155", "0.43833506", "0.4379576", "0.43788865", "0.43769783", "0.43763873", "0.43760175", "0.43655849", "0.4365514", "0.4363021", "0.4362488", "0.43580508", "0.43568322", "0.43541402", "0.4340229", "0.43360424", "0.43348366", "0.43339366", "0.43335927", "0.43249208", "0.43240428", "0.4322253", "0.43208313", "0.43191168", "0.43147862", "0.43145472", "0.43108585", "0.4302894", "0.43013147", "0.4295375", "0.4292006", "0.42851686", "0.42841074", "0.4284036", "0.4283805", "0.42804497", "0.42775586", "0.42734322", "0.42694482", "0.42613003", "0.42522457", "0.42484087", "0.42451695", "0.42446044", "0.4244466" ]
0.64855915
0
PUT /navigation_entries/1 PUT /navigation_entries/1.xml
def update @navigation_entry = NavigationEntry.find(params[:id]) respond_to do |format| if @navigation_entry.update_attributes(params[:navigation_entry]) format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n get_system\n @nav_entry = NavEntry.find(params[:id])\n get_parents\n\n respond_to do |format|\n if @nav_entry.update_attributes(params[:nav_entry])\n format.html { redirect_to(system_nav_entry_path(@system, @nav_entry), :notice => 'Nav entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @navigation = Navigation.find(params[:id])\n\n respond_to do |format|\n if @navigation.update_attributes(params[:navigation])\n format.html { redirect_to @navigation, notice: 'Navigation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def test_should_update_link_via_API_XML\r\n get \"/logout\"\r\n put \"/links/1.xml\", :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response 401\r\n end", "def update\n @container_navigation = ContainerNavigation.find(params[:id])\n\n respond_to do |format|\n if @container_navigation.update_attributes(params[:container_navigation])\n format.html { redirect_to @container_navigation, notice: 'Container navigation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container_navigation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @navigation_entry = NavigationEntry.new(params[:navigation_entry])\n\n respond_to do |format|\n if @navigation_entry.save\n format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') }\n format.xml { render :xml => @navigation_entry, :status => :created, :location => @navigation_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @navigation_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n organization_timeline_entry.update_attributes(organization_timeline_entry_params)\n respond_with(@organization_timeline_entry, location: params[:url])\n end", "def update_rest\n @entry_item = EntryItem.find(params[:id])\n\n respond_to do |format|\n if @entry_item.update_attributes(params[:entry_item])\n flash[:notice] = 'EntryItem was successfully updated.'\n #format.html { redirect_to(@entry_item) }\n format.xml { head :ok }\n else\n #format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end", "def update\n @node = Node.find(params[:id])\n @title = \"Taxonomy node - organism relationships\"\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @relationship = Relationship.find(params[:id])\n @relationship.update_attributes(params[:relationship])\n @relationships = Relationship.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n end", "def update\n respond_to do |format|\n if @navigation_item.update(navigation_item_params)\n format.html { redirect_to [:admin, @navigation_item], notice: 'Navigation item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @navigation_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @navigation_entry = NavigationEntry.find(params[:id])\n @navigation_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(navigation_entries_url) }\n format.xml { head :ok }\n end\n end", "def test_put\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 contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def reindex(*entries)\n list = Upload.get_relation(*entries).to_a\n result = ingest_api.put_records(*list)\n result.exec_report.error_messages.each { |e| $stderr.puts e }.blank?\n end", "def update\n @nav = Nav.find(params[:id])\n\n respond_to do |format|\n if @nav.update_attributes(params[:nav])\n flash[:notice] = 'Nav was successfully updated.'\n format.html { redirect_to(@nav) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nav.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @navigation_entry }\n end\n end", "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def create \n get_system\n @nav_entry = NavEntry.new(params[:nav_entry])\n get_parents\n\n respond_to do |format|\n if @nav_entry.save\n format.html { redirect_to(system_path(@system), :notice => 'Nav entry was successfully created.') }\n format.xml { render :xml => @nav_entry, :status => :created, :location => @nav_entry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @nav_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put_atom_entry(entry, url = entry.edit_url)\n raise \"Cowardly refusing to PUT a non-Atom::Entry (#{entry.class})\" unless entry.is_a? Atom::Entry\n headers = {\"Content-Type\" => \"application/atom+xml\" }\n\n put(url, entry.to_s, headers)\n end", "def update\n DOCUMENT_PATHS.each do |attr_name, path|\n if path.match(/\\*/)\n instance_variable_get(\"@#{attr_name}\").each do |simple_file_name, contents|\n replace_entry(\"word/#{simple_file_name}.xml\", contents.serialize(save_with: 0))\n end\n else\n xml_document = instance_variable_get(\"@#{attr_name}\")\n replace_entry path, xml_document.serialize(save_with: 0) if xml_document\n end\n end\n end", "def update\n @navigation_solution = NavigationSolution.find(params[:id])\n\n respond_to do |format|\n if @navigation_solution.update_attributes(params[:navigation_solution])\n format.html { redirect_to @navigation_solution, notice: 'Navigation solution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @navigation_solution.errors, status: :unprocessable_entity }\n end\n end\n end", "def persist_content_entries_with_relationships\n unless self.with_relationships.empty?\n self.log \"\\n setting relationships for all the content entries\\n\"\n\n updates = self.content_entries_with_relationships_to_hash\n\n updates.each do |params|\n _id, slug = params.delete(:_id), params.delete(:slug)\n self.put \"content_types/#{slug}/entries\", _id, params\n end\n end\n end", "def update\n @entry = FeedEntry.find(params[:id])\n\n tags = params['tags' + params[:id]]\n\n respond_to do |format|\n if FeedEntry.add_tag(@entry, tags)\n format.html {render action: 'index'}\n format.json {head :no_content}\n else\n format.html {render action: 'index'}\n format.json {render json: @entry.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n\n if InfoNode.duplicate_key?(params[:info_types])\n redirect_to :back, :alert => \"Key in the additional information shoud be unique\"\n return\n end\n\n @relation = Node.find(params[:id])\n @collection = current_user.collections.find(params[:collection_id])\n if @relation.nil? || @collection.nil? || @relation.document.collection.id != @collection.id\n redirect_to :back, :alert => \"Cannot find an relation\"\n return\n end \n\n @document = @relation.document\n @collection = @document.collection\n\n unless params[:rid].nil?\n @rid = params[:rid].strip\n end\n\n @rid = @document.create_new_relation_id if @rid.blank?\n @relation.entity_type = params[:type] \n @refs = []\n\n params[:refids].each_with_index do |ref_id, idx|\n @refs << {:ref_id => ref_id, :role => params[:labels][idx]}\n end unless params[:refids].nil?\n\n if @refs.empty?\n redirect_to :back, :alert => \"Please add references for a new relation\"\n return\n end\n \n @relation.update_references(@refs)\n\n keyset = []\n (0...params[:info_types].size).each do |i|\n key = params[:info_types][i]\n value = params[:info_values][i]\n if !key.nil? && !key.strip.blank? && !value.nil? && !value.strip.blank?\n keyset << key\n @relation.set_info_node(key, value)\n end\n end\n\n @relation.remove_info_node_except(keyset)\n\n\n respond_to do |format|\n if @relation.save\n format.html { redirect_to \"/collections/#{@collection.id}/documents/#{@document.pmid}?tab=relation\", notice: 'Relation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to :back, :alert => \"Cannot update relation: #{@relation.errors.full_messages}\" }\n format.json { render json: @relation.errors, status: :unprocessable_entity }\n end\n end\n\n \n end", "def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end", "def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update!(**args)\n @entries = args[:entries] if args.key?(:entries)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update\n @nav_item = NavItem.find(params[:id])\n\n respond_to do |format|\n if @nav_item.update_attributes(params[:nav_item])\n flash[:notice] = 'NavItem was successfully updated.'\n format.html { redirect_to(@nav_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @nav_item.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 connection.put(element_path, to_xml)\n end", "def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/invoices/1.xml',\n {:invoice => {:number => 'NewNumber'}},\n {:success_code => :ok})\n \n assert_no_difference('Invoice.count') do\n put '/invoices/1.xml', @parameters, credentials('admin')\n end\n \n invoice = Invoice.find(1)\n assert_equal \"NewNumber\", invoice.number\n \n end", "def update\n @step = params[:step].to_i\n content = FetchContentService.new.(current_student.os, @step)\n current_student.steps << {title: content[:title] }\n current_student.save!\n\n redirect_to edit_students_path\n end", "def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @taxonomies = args[:taxonomies] if args.key?(:taxonomies)\n end", "def update_rest\n @page_usage_event = PageUsageEvent.find(params[:id])\n\n respond_to do |format|\n if @page_usage_event.update_attributes(params[:page_usage_event])\n flash[:notice] = 'PageUsageEvent was successfully updated.'\n format.html { redirect_to(@page_usage_event) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page_usage_event.errors, :status => :unprocessable_entity }\n end\n end\n end", "def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end", "def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend", "def update\n \n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n if @tag.update_attributes(params[:tag])\n if params[:tag][:parent].to_i>0\n parent=Tag.find(params[:tag][:parent])\n parent.children+=1\n parent.save\n end\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @entry = Entry.find(params[:id])\n params[:entry][:status] = 'publish' if params[:entry][:status] == 'update'\n \n if params[:entry][:entry_metas_attributes].present?\n params[:entry][:entry_metas_attributes].replace(convert_entry_metas_attributes(params[:entry][:entry_metas_attributes]))\n end\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to edit_admin_entry_path(@entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")\n end", "def update\n update_resource_response(@headline, headline_params)\n end", "def save_related\n if self.links.present?\n self.links.each do | link |\n link.parent_type = :action_item\n link.parent_key = self.key\n link.save!\n end\n end\n end", "def update\n @entry = @resource_finder.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:notice] = 'Entry was successfully updated.'\n format.html { redirect_to_resource }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_index(name, node); end", "def update\n @node = Node.scopied.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n begin\n @resource = Relation.find params[:id]\n @resource.update_attributes!(params[:relation])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update\n @relationship = @character.relationships.find_by_permalink!(params[:id])\n\n respond_to do |format|\n if @relationship.update_attributes(params[:relationship])\n format.html { redirect_to([@character,@relationship], :notice => 'Relationship was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relationship.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add( resource )\n entries.merge!( resource.index_dump )\n mark_modified\n end", "def update\n respond_to do |format|\n name = Server.find(params[:id]).name\n n = Neography::Node.find('servers', 'name', name)\n n.name = server_params[:name]\n n.add_to_index('servers', 'name', server_params[:name]) #TODO: is this necessary?\n if @server.update(server_params)\n format.html { redirect_to @server, notice: 'Server was successfully updated.' }\n format.json { render :show, status: :ok, location: @server }\n else\n format.html { render :edit }\n format.json { render json: @server.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_node\n params[:id] = params[:id] + '/' if (params[:id] == 'rest')\n @node = Fedora.rest(params[:id])\n end", "def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end", "def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n flash[:notice] = 'Entry was successfully updated.'\n format.html { redirect_to(@entry) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(entries_url, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @node = Node.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @node = Node.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n format.html { redirect_to(@node, :notice => 'Node was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @node = Node.find(params[:id])\n\n respond_to do |format|\n if @node.update_attributes(params[:node])\n flash[:notice] = 'Node was successfully updated.'\n format.html { redirect_to(@node) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @node.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @menu_item = MenuItem.find(params[:id])\n\n respond_to do |format|\n if uhook_update_menu_item(@menu_item)\n flash[:notice] = t('ubiquo.menus.sitemap_updated')\n format.html { redirect_to(ubiquo_menu_items_path) }\n format.xml { head :ok }\n else\n flash[:error] = t('ubiquo.menus.sitemap_update_error')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @menu_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_content_entry(content_type, content_entry)\n locale = Locomotive::Mounter.locale\n\n # log before\n self.output_resource_op content_entry\n\n # get the params\n params = self.buffer_log { self.content_entry_to_params(content_entry) }\n\n # send the request\n response = self.put \"content_types/#{content_type}/entries\", content_entry._id, params, locale\n\n status = self.response_to_status(response)\n\n # log after\n self.output_resource_op_status content_entry, status\n self.flush_log_buffer\n end", "def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_metadata(direction, metadata)\n end", "def update\n @entry = Entry.find(params[:id])\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(:action => :index, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @children.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_putway_update_valid\n way = create(:way_with_nodes, :nodes_count => 3)\n cs_id = way.changeset.id\n user = way.changeset.user\n\n assert_not_equal({ \"test\" => \"ok\" }, way.tags)\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version, way.id, way.nds, { \"test\" => \"ok\" }, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 1, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 1, new_way.version\n assert_equal way.nds, new_way.nds\n assert_equal({ \"test\" => \"ok\" }, new_way.tags)\n\n # Test changing the nodes in the way\n a = create(:node).id\n b = create(:node).id\n c = create(:node).id\n d = create(:node).id\n\n assert_not_equal [a, b, c, d], way.nds\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({}, result[4])\n assert_equal way.version + 2, result[5]\n assert_equal({}, result[6])\n assert_equal({}, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 2, new_way.version\n assert_equal [a, b, c, d], new_way.nds\n assert_equal way.tags, new_way.tags\n\n amf_content \"putway\", \"/1\", [\"#{user.email}:test\", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { \"test\" => \"new\" }], [12.34, 4.56, b, 1, { \"test\" => \"ok\" }]], { d => 1 }]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n new_node_id = result[4][\"-1\"].to_i\n\n assert_equal 8, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal way.id, result[2]\n assert_equal way.id, result[3]\n assert_equal({ \"-1\" => new_node_id }, result[4])\n assert_equal way.version + 3, result[5]\n assert_equal({ new_node_id.to_s => 1, b.to_s => 2 }, result[6])\n assert_equal({ d.to_s => 1 }, result[7])\n\n new_way = Way.find(way.id)\n assert_equal way.version + 3, new_way.version\n assert_equal [a, new_node_id, b, c], new_way.nds\n assert_equal way.tags, new_way.tags\n\n new_node = Node.find(new_node_id)\n assert_equal 1, new_node.version\n assert_equal true, new_node.visible\n assert_equal 4.56, new_node.lon\n assert_equal 12.34, new_node.lat\n assert_equal({ \"test\" => \"new\" }, new_node.tags)\n\n changed_node = Node.find(b)\n assert_equal 2, changed_node.version\n assert_equal true, changed_node.visible\n assert_equal 12.34, changed_node.lon\n assert_equal 4.56, changed_node.lat\n assert_equal({ \"test\" => \"ok\" }, changed_node.tags)\n\n deleted_node = Node.find(d)\n assert_equal 2, deleted_node.version\n assert_equal false, deleted_node.visible\n end", "def put(namespace, key, entry); end", "def update\n respond_to do |format|\n if @explorer.update(explorer_params)\n format.html { redirect_to @explorer, notice: \"Explorer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @explorer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @explorer.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put_expenses_1_xml\n @parameters = {:expense => {:description => 'NewDescription'}}\n if ActiveRecord::VERSION::MAJOR < 4\n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n '/expenses/1.xml',\n {:expense => {:description => 'NewDescription'}},\n {:success_code => :ok})\n end\n\n assert_no_difference('Expense.count') do\n put '/expenses/1.xml', @parameters, credentials('admin')\n end\n\n expense = Expense.find(1)\n assert_equal \"NewDescription\", expense.description\n end", "def entry_list\n unless params[:version] == '3.0'\n raise ActionController::RoutingError.new('Not Found')\n end\n\t\t\n @event = Event.find(params[:id])\n respond_to do |format|\n format.xml { render :layout => false }\n end\n end", "def update\n notify(update_entry, :successful_entry_update, :failure_in_entry_update)\n redirect_to current_entry.collection_path\n end", "def update\n @entry = Entry.find(params[:id])\n\n if @entry.update_attributes(params[:entry])\n head :no_content\n else\n render json: @entry.errors, status: :unprocessable_entity\n end\n end", "def update!\n entity_json = [{ name: @source_file.entity_name, entries: expanded_entries }]\n\n response = @api_client.update_entities_request(entity_json)\n\n handle_response(response, :entity)\n end", "def update\n respond_to do |wants|\n if @definition.update_attributes(params[:definition])\n flash[:notice] = 'Definition was successfully updated.'\n wants.html { redirect_to(@definition) }\n wants.xml { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @definition.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_should_create_link_via_API_XML\r\n get \"/logout\"\r\n post \"/links.xml\", :api_key=>'testapikey',\r\n :link => {:user_id => 1,\r\n :title => 'API Link 1',\r\n :url => 'http://www.api.com'}\r\n assert_response :created\r\n end", "def update\n @fault_type = FaultType.find(params[:id])\n\n respond_to do |format|\n if @fault_type.update_attributes(params[:fault_type])\n format.html { redirect_to(@fault_type, :notice => 'FaultType was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fault_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @graph.update_attributes_from_request(update_params)\n head :no_content\n end", "def update\n @entry_set = EntrySet.find(params[:id])\n @entry_set.update_attributes(params[:entry_set])\n\n render 'show'\n \n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update\n @step = TaskrequestsStep.find(params[:taskrequests_step_id])\n @absence_request = @step.absence_requests.find(params[:id])\n\n respond_to do |format|\n if @absence_request.update_attributes(params[:absence_request])\n format.html { redirect_to(@absence_request, :notice => 'Absence request was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @absence_request.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n @story = Story.find(params[:id])\n\n respond_to do |format|\n if @story.update_attributes(params[:link])\n flash[:notice] = 'Story was successfully updated.'\n format.html { redirect_to(@story) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_in_tree\n\t\tfname = \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.info(fname) { \"params: #{params}\" }\n\t\t@link = Link.find(params[:id])\n\t\t##########@link.update_accessor(current_user)\n\t\t@object_in_explorer = PlmServices.get_object(params[:object_model], params[:object_id])\n\t\t@root = PlmServices.get_object(params[:root_model], params[:root_id])\n\t\terr = false\n\t\trespond_to do |format|\n\t\t\t#values = OpenWFE::Json::from_json(params[:link][:values])\n\t\t\t#LOG.info(fname) { \"values: #{values}\" }\n\t\t\t#########update_att=@link.update_attributes(params[:link])\n\t\t\tupdate_att = @link.update_link(current_user,params[:link])\n\t\t\t#LOG.info(fname) { \"update_att: #{update_att} @link.errors=#{@link.errors.inspect}\" }\n\t\t\t@link.errors.clear if update_att\n\t\t\tupdate_eff = update_effectivities(@link, params[:effectivities])\n\t\t\t#LOG.info(fname) { \"update_eff: #{update_eff} @link.errors=#{@link.errors.inspect}\" }\n\t\t\tif update_att && update_eff\n\t\t\t\tLOG.info(fname) { \"ok:effectivities: #{params[:effectivities]}\" }\n\t\t\t\tflash[:notice] = t(:ctrl_object_updated, :typeobj => t(:ctrl_link), :ident => @link.ident)\n\t\t\t\tformat.html { render action: \"edit_in_tree\" }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tstrerr=\"ko:update_att=#{update_att} update_eff=#{update_eff} effectivities: #{params[:effectivities]}\"\n\t\t\t\tLOG.info(fname) { strerr}\n\t\t\t\t# lien non modifie\n\t\t\t\tflash[:error] = t(:ctrl_object_not_updated,:typeobj =>t(:ctrl_link),:ident=>@link.ident, :error=>strerr)\n\t\t\t\tformat.html { render action: \"edit_in_tree\" }\n\t\t\t\tformat.xml { render xml: @link.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end", "def add_entries_info(entries, path)\n # use the git reflog to get a list of pushes\n reflog = @repo.ref('refs/heads/master').log.reverse\n # walk through all the commits until this revision's +@commit+ is found\n # (this is needed to advance the reflog to the right point, since +@commit+ may be between two pushes)\n walker_entries = entries.dup\n last_commit = @repo.last_commit\n reflog_entries = {}\n reflog_entries[last_commit.oid] = { index: -1 }\n found = false\n walker = Rugged::Walker.new(@repo)\n walker.sorting(Rugged::SORT_TOPO)\n walker.push(last_commit.oid)\n walker.each do |commit|\n current_reflog_entry = GitRepository.try_advance_reflog!(reflog, reflog_entries, commit)\n found = true if @commit.oid == commit.oid\n next unless found\n # check entries that were modified\n mod_keys = walker_entries.keys.select { |entry_name| entry_changed?(File.join(path, entry_name), commit) }\n mod_entries = walker_entries.extract!(*mod_keys)\n mod_entries.each do |_, mod_entry|\n mod_entry.last_modified_revision = commit.oid\n mod_entry.last_modified_date = commit.time.in_time_zone\n mod_entry.submitted_date = current_reflog_entry[:time]\n mod_entry.changed = commit.oid == @revision_identifier\n mod_entry.user_id = commit.author[:name]\n end\n break if walker_entries.empty?\n end\n end", "def update\n enforce_permissions!('update', params[:id])\n\n param = params[:xml].presence || params[:metadata_file].presence\n\n if param\n xml_ds = XmlDatastream.new\n xml_ds.load_xml(param)\n else\n flash[:notice] = t('dri.flash.notice.specify_valid_file')\n redirect_to controller: 'catalog', action: 'show', id: params[:id]\n return\n end\n\n @object = retrieve_object!(params[:id])\n @errors = nil\n\n unless can? :update, @object\n raise Hydra::AccessDenied.new(t('dri.flash.alert.edit_permission'), :edit, '')\n end\n\n @object.update_metadata xml_ds.xml\n if @object.valid?\n checksum_metadata(@object)\n warn_if_has_duplicates(@object)\n\n begin\n raise DRI::Exceptions::InternalError unless @object.attached_files[:descMetadata].save\n rescue RuntimeError => e\n logger.error \"Could not save descMetadata for object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n\n begin\n raise DRI::Exceptions::InternalError unless @object.save\n\n version_and_record_committer(@object, current_user)\n flash[:notice] = t('dri.flash.notice.metadata_updated')\n rescue RuntimeError => e\n logger.error \"Could not save object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n else\n flash[:alert] = t('dri.flash.alert.invalid_object', error: @object.errors.full_messages.inspect)\n @errors = @object.errors.full_messages.inspect\n end\n\n @object.object_version ||= '1'\n @object.increment_version\n\n begin\n raise DRI::Exceptions::InternalError unless @object.save\n\n # Do the preservation actions\n preservation = Preservation::Preservator.new(@object)\n preservation.preserve(false, false, ['descMetadata','properties'])\n\n version_and_record_committer(@object, current_user)\n flash[:notice] = t('dri.flash.notice.metadata_updated')\n rescue RuntimeError => e\n logger.error \"Could not save object #{@object.id}: #{e.message}\"\n raise DRI::Exceptions::InternalError\n end\n\n respond_to do |format|\n format.html { redirect_to controller: 'my_collections', action: 'show', id: params[:id] }\n format.json { render json: @object }\n format.text do\n response = if @errors\n t('dri.flash.alert.invalid_object', error: @errors)\n else\n t('dri.flash.notice.metadata_updated')\n end\n\n render text: response\n end\n end\n end", "def update\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.get(params[:id])\n\n respond_to do |format|\n if @ganglia_graph.update(params[:ganglia_graph])\n format.html { redirect_to(@ganglia_graph, :notice => 'Ganglia Graph was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ganglia_graph.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @entry = Entry.find(params[:id])\n\t@entry.viewed += 1\n\t@entry.update_attributes(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @entry }\n\t format.rss { render :rss => @entry }\n end\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update\n @opml_metadata = OpmlMetadata.find(params[:id])\n\n respond_to do |format|\n if @opml_metadata.update_attributes(params[:opml_metadata])\n flash[:notice] = 'OpmlMetadata was successfully updated.'\n format.html { redirect_to(@opml_metadata) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @opml_metadata.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_entry\n @entry = Entry.find(params[:id])\n @dictionary = @entry.dictionary\n end", "def update\n @atom = Atom.find(params[:id])\n\n respond_to do |format|\n if @atom.update_attributes(params[:atom])\n flash[:notice] = 'Atom was successfully updated.'\n format.html { redirect_to(@atom) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @atom.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @entry = Entry.find(params[:id])\n\t\n\t@entry.system_list = \"\"\n\t@systems = params[:systems]\n\t@systems.each do |s|\n\t\t@entry.system_list.add(s)\n\tend\t\n\t\n\t@entry.comp_list = \"\"\n\t@components = params[:components]\n\t@components.each do |c|\n\t\t@entry.comp_list.add(c)\n\tend\n\t\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_tree_activities(activity, title, start_time, end_time)\n\n #First update itself.\n #\n #\n activity.name = title\n activity.start_time = start_time\n activity.end_time = end_time\n activity.save\n\n #Activity Root Node just update all children.\n #\n #\n if (activity.reference_activity == nil)\n\n ref_activities = Activity.where('reference_activity_id = ?', \"#{ activity.id }\")\n\n ref_activities.each do |ref_item|\n ref_cal = Google::Calendar.new(:username => ref_item.user.email,\n :password => ref_item.user.email_password,\n :app_name => 'firmy')\n\n if (ref_cal != nil)\n ref_event = ref_cal.find_event_by_id(ref_item.reference)\n ref_event.title = title\n ref_event.start_time = start_time\n ref_event.end_time = end_time\n ref_cal.save_event(ref_event)\n end\n\n ref_item.name = title\n ref_item.start_time = start_time\n ref_item.end_time = end_time\n ref_item.save\n end\n\n #Activity Child Node need to find root node and then update all children.\n #\n #\n else\n root_activity = Activity.where('id = ?', \"#{ activity.reference_activity.id }\").first\n\n root_cal = Google::Calendar.new(:username => root_activity.user.email,\n :password => root_activity.user.email_password,\n :app_name => 'firmy')\n\n if (root_cal != nil)\n root_event = root_cal.find_event_by_id(root_activity.reference)\n root_event.title = title\n root_event.start_time = start_time\n root_event.end_time = end_time\n root_cal.save_event(root_event)\n end\n\n root_activity.name = title\n root_activity.start_time = start_time\n root_activity.end_time = end_time\n root_activity.save\n\n update_tree_activities(root_activity, title, start_time, end_time)\n end\n\n end", "def update\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to feed_entry_path(@feed, @entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entry = Entry.find(params[:id])\n @feed = @entry.feed\n\n respond_to do |format|\n if @entry.update_attributes(params[:entry])\n format.html { redirect_to feed_entry_path(@feed, @entry), notice: 'Entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gene_ontology = GeneOntology.find(params[:id])\n\n respond_to do |format|\n if @gene_ontology.update_attributes(params[:gene_ontology])\n format.html { redirect_to(@gene_ontology, :notice => 'Gene ontology was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gene_ontology.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_metadata\n @generic_file.destroy_existing_nested_nodes(params[:generic_file])\n super\n end", "def update\n\n @title = Title.find(activity_params[:title_id])\n @event = Event.find(@title[:event_id])\n @activity = Activity.new(activity_params)\n @title.activities << @activity\n \n respond_to do |format|\n if @activity.update(activity_params)\n format.html { redirect_to \"/events/#{@event.id}\", notice: 'Activity was successfully updated.' }\n format.json { render :show, status: :ok, location: @activity }\n else\n format.html { render :edit }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @path = Path.find(params[:id])\n\n respond_to do |format|\n if @path.update_attributes(params[:path])\n format.html { redirect_to([@layer, @path], :notice => 'Path was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @path.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @doc = Doc.find(params[:id])\n \n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.59629303", "0.55001026", "0.5487206", "0.5458992", "0.5433569", "0.5425323", "0.5262817", "0.5261352", "0.5249022", "0.5235539", "0.52352047", "0.52067214", "0.51349837", "0.50847137", "0.50655854", "0.5048693", "0.5015466", "0.49999553", "0.4958886", "0.49584007", "0.49502555", "0.49280757", "0.49247536", "0.49159557", "0.49106985", "0.49050725", "0.48706517", "0.48706517", "0.48104748", "0.48092234", "0.47938865", "0.47881544", "0.4782436", "0.47753826", "0.47647938", "0.4762784", "0.47497997", "0.47480634", "0.47423247", "0.47380024", "0.47349674", "0.4716175", "0.47117513", "0.470748", "0.47010106", "0.4691979", "0.46884847", "0.46744594", "0.4661947", "0.46587983", "0.46554023", "0.46518245", "0.4648923", "0.46486053", "0.46461987", "0.4643813", "0.46437347", "0.46365136", "0.4624737", "0.4617771", "0.4607241", "0.46068996", "0.46047765", "0.46031013", "0.458922", "0.4587181", "0.4586797", "0.45790642", "0.4577608", "0.45744613", "0.45736", "0.4570947", "0.45699275", "0.45696366", "0.4562517", "0.4560392", "0.45569032", "0.4556396", "0.45532668", "0.45499033", "0.45497763", "0.4547715", "0.453886", "0.4537116", "0.45323256", "0.4527346", "0.45252675", "0.4525266", "0.45189828", "0.45174882", "0.4515471", "0.4513833", "0.45136726", "0.45126975", "0.45126975", "0.45118117", "0.4510727", "0.4508691", "0.45077798", "0.4506252" ]
0.6453088
0
DELETE /navigation_entries/1 DELETE /navigation_entries/1.xml
def destroy @navigation_entry = NavigationEntry.find(params[:id]) @navigation_entry.destroy respond_to do |format| format.html { redirect_to(navigation_entries_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def delete; rest_delete(link('self')); end", "def delete; rest_delete(link('self')); end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end", "def destroy \n get_system\n @nav_entry = NavEntry.find(params[:id])\n @nav_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(system_url(@system)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @archdiocese.destroy\n\n head :no_content\n end", "def destroy \n Link.connection.execute(\"delete from links where id in (#{params[:id].join(',')})\") unless params[:id].blank?\n respond_to do |format|\n format.html { redirect_to(links_url) }\n format.xml { head :ok }\n end\n end", "def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id'] }.sort.last.succ\n # TODO - Figure out how to make this more MS idiomatic up 9->10 instead of incrementing\n # the character....\n # Insert that into the slide and crakc open the presentation.xml file\n\n target = slide.path.relative_path_from(@doc.presentation.path.dirname)\n relationship = xml.at_xpath(\"/xmlns:Relationships/xmlns:Relationship[@Type='#{Slide::REL_TYPE}' and @Target='#{target}']\")\n # ./presentation.xml\n # Update attr\n # p:notesMasterId\n # Insert attr\n # p:sldId, increment, etc.\n @doc.edit_xml '/ppt/presentation.xml' do |xml|\n xml.at_xpath(\"/p:presentation/p:sldIdLst/p:sldId[@r:id='#{relationship['Id']}']\").remove\n end\n relationship.remove\n end\n\n # Delete slide link and slideNotes link from ./[Content-Types].xml \n @doc.edit_xml @doc.content_types.path do |xml|\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Slide::CONTENT_TYPE}' and @PartName='#{slide.path}']\").remove\n xml.at_xpath(\"/xmlns:Types/xmlns:Override[@ContentType='#{Notes::CONTENT_TYPE}' and @PartName='#{slide.notes.path}']\").remove\n end\n\n # Update ./ppt\n # !!! DESTROY !!!\n # ./slides\n # Delete files\n # ./_rels/notesSlide(\\d+).xml.rels\n @doc.delete slide.notes.rels.path\n # ./notesSlide(\\d+).xml file\n @doc.delete slide.notes.path\n # ./_rels/slide(\\d+).xml.rels\n @doc.delete slide.rels.path\n # ./slide(\\d+).xml file\n @doc.delete slide.path\n # ./notesSlides\n # Delete files\n\n # Hooray! We're done! Ummm, what should we return though? can't be the slide since\n # its destroyed and there's no practical way to keep it around in memory.\n end", "def delete_redirects\n WikiRedirect.where(:wiki_id => id).delete_all\n WikiRedirect.where(:redirects_to_wiki_id => id).delete_all\n end", "def delete\n CONNECTION.execute(\"DELETE FROM links WHERE id = #{self.id};\")\n end", "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def delete_all(xpath); end", "def delete\n self.class.delete self.href\n end", "def delete_node(current_node)\n\nend", "def destroy\n @navigation_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_navigation_items_url, notice: 'Navigation item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_id(id)\n ids_in_doc = root.fetch(full_path, :single => true)\n raise TypeError, \"Expecting array\" unless ids_in_doc.kind_of? Array\n ids_in_doc.delete id\n root.save!\n ids.delete id\n save!\n end", "def destroy\n @navigation = Navigation.find(params[:id])\n @navigation.destroy\n\n respond_to do |format|\n format.html { redirect_to navigations_url }\n format.json { head :no_content }\n end\n end", "def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; 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()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @subrelation = Subrelation.find(params[:id])\n @subrelation.destroy\n\n respond_to do |format|\n format.html { redirect_to(subrelations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @subentry = Subentry.find(params[:id])\n @subentry.destroy\n\n respond_to do |format|\n format.html { redirect_to(subentries_url) }\n format.xml { head :ok }\n end\n end", "def delete\n CMark.node_unlink(@pointer)\n end", "def destroy\n @container_navigation = ContainerNavigation.find(params[:id])\n @container_navigation.destroy\n\n respond_to do |format|\n format.html { redirect_to container_navigations_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end", "def destroy_rest\n @entry_item = EntryItem.find(params[:id])\n @entry_item.destroy\n\n respond_to do |format|\n #format.html { redirect_to(entry_items_url) }\n format.xml { head :ok }\n end\n end", "def delete_content_paths\n\n # Delete all the paths with the ancestor as the current id\n ContentPath.delete_all(:ancestor => self.id)\n\n # Delete all the paths with the descendant as the current id\n ContentPath.delete_all(:descendant => self.id)\n end", "def destroy\n @relationship = Relationship.find(params[:id])\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to(relationships_url) }\n format.xml { head :ok }\n end\n end", "def delete_entries(entries)\n delete_all(:id => entries)\n end", "def destroy\n @alfresco = Alfresco.find(params[:id])\n @alfresco.destroy\n\n respond_to do |format|\n format.html { redirect_to(alfrescos_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def delete_analysis(analysis_id); rest_delete(\"#{link('analyses')}/#{analysis_id}\"); nil; end", "def destroy\n @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 @nav = Nav.find(params[:id])\n @nav.destroy\n\n respond_to do |format|\n format.html { redirect_to(navs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action => :index) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n path = self.class.path(path).to_s\n zip.fopen(path).delete\n entries.delete(path)\n end", "def destroy\n @nav_item = NavItem.find(params[:id])\n @nav_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(nav_items_url) }\n format.xml { head :ok }\n end\n end", "def delete_entry(aliaz)\n\n end", "def destroy\n @xlink = Xlink.find(params[:id])\n @xlink.destroy\n\n respond_to do |format|\n format.html { redirect_to xlinks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @path = Path.find(params[:id])\n @path.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend", "def destroy\n @entry ||= Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete\n association.delete association[element.dataset[:index].to_i]\n end", "def delete(path)\n root.delete(path)\n end", "def destroy\n @content = Content.find(params[:id])\n @folder = Folder.find(session[:folder_id])\n Searcher.open(Const.get('searcher_db')) do |db|\n db.erase(@content)\n end\n @content.destroy\n\n respond_to do |format|\n #format.html { redirect_to(contents_url) }\n format.html { redirect_to(@folder) }\n format.xml { head :ok }\n end\n end", "def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end", "def destroy\n @markup = Markup.find(params[:id])\n @markup.destroy\n\n respond_to do |format|\n format.html { redirect_to [@parent, :markups] }\n format.xml { head :ok }\n end\n end", "def destroy\n @relationship = @assembly.relationships.find(params[:id])\n child = @relationship.child\n child.used = false\n child.save\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to [@plan, @assembly], notice: 'Relationship was deleted.' }\n format.json { head :no_content }\n end\n end", "def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end", "def del\n delete\n end", "def destroy\n @menu = Menu.find(params[:id])\n @links = Link.find_by_menu_id(@menu.id)\n @menu.destroy\n\n respond_to do |format|\n format.html { redirect_to(menus_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n expire_page :action => :index\n expire_page :action => :show\n \n @ganglia_graph = GangliaGraph.get(params[:id])\n @ganglia_graph.destroy\n\n respond_to do |format|\n format.html { redirect_to(ganglia_graphs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @relationship = @character.relationships.find_by_permalink!(params[:id])\n @relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to(character_relationships_url(@character)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @miscellaneous_child = MiscellaneousChild.find(params[:id])\n @miscellaneous_child.destroy\n\n respond_to do |format|\n format.html { redirect_to(miscellaneous_children_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @descendant.destroy\n respond_to do |format|\n format.html { redirect_to descendants_url, notice: 'Descendant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @request = Request.find(params[:id])\n @request_items = @request.request_items\n @request_items.each do |ri|\n ri.destroy\n end\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to(requests_url) }\n format.xml { head :ok }\n end\n end", "def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete(connection)\n response = Hpricot.XML(connection.process(Document::Delete.new(self).xml))\n raise Exception, response.at('error').innerHTML if response.at('error')\n self.handle = nil\n self\n end", "def destroy\n collection = Collection.find(@mlog_entry[:collection_id])\n @mlog_entry.destroy\n respond_to do |format|\n format.html { redirect_to collection}\n format.json { head :no_content }\n end\n end", "def destroy\n @domicile_type_section = DomicileTypeSection.find(params[:id])\n @domicile_type_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(domicile_type_sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @config_xml = ConfigXml.find(params[:id])\n @config_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(config_xmls_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end", "def delete\n end", "def destroy\n @content_mapping = ContentMapping.find(params[:id])\n @content_mapping.destroy\n\n respond_to do |format|\n format.html { redirect_to(content_mappings_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n head :no_content\n end", "def destroy\n @link = @entity.links.find(params[:id])\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @relationships = Relationship.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @relationship = Relationship.find(params[:id])\n @error = nil\n\n begin\n @relationship.destroy\n rescue ActiveRecord::DeleteRestrictionError => e\n @error = e.message\n end\n end", "def destroy\n @alignment = Alignment.get(params[:id])\n alignments = Alignment.all(:alignment_name => @alignment.alignment_name)\n alignments.each do |a|\n a.deleted_at = Time.now\n a.save\n end\n\n respond_to do |format|\n format.html { redirect_to(alignments_url) }\n format.xml { head :ok }\n end\n end", "def delete(node)\n remove_node(node)\n end", "def destroy\n debugger\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n home = current_entry.collection_path\n current_entry.destroy\n redirect_to home\n end", "def destroy\n @opml_metadata = OpmlMetadata.find(params[:id])\n @opml_metadata.destroy\n\n respond_to do |format|\n format.html { redirect_to(opml_metadatas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @entry = @resource_finder.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to_resources }\n format.xml { head :ok }\n end\n end", "def destroy\n @journal_entry = JournalEntry.find(params[:id])\n @journal_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(journal_entries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @definition_category_association = DefinitionCategoryAssociation.find(params[:id])\n @definition_category_association.destroy\n\n respond_to do |format|\n format.html { redirect_to(definition_category_associations_url) }\n format.xml { head :ok }\n end\n end", "def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end", "def destroy\n @menutree = Menutree.find(params[:id])\n @menutree.destroy\n\n respond_to do |format|\n format.html { redirect_to(menutrees_url) }\n format.xml { head :ok }\n end\n end", "def delete\n \n end", "def delete\n \n end", "def destroy\n @tax.destroy\n\n head :no_content\n end", "def destroy\n @menu_section = MenuSection.find(params[:id])\n @menu_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && !@container.root?)\n\n respond_to do |format|\n format.html { redirect_to(container_url(@container.parent.id)) }\n format.xml { head :ok }\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 delete_now\n revisions.each do |rev_id| \n CouchDB.delete( \"#{uri}?rev=#{rev_id}\" )\n end\n true \n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def destroy\n @menu_page = MenuPage.find(params[:id])\n @menu_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_pages_url) }\n format.xml { head :ok }\n end\n end" ]
[ "0.65846765", "0.65635955", "0.65635955", "0.6414862", "0.63691705", "0.6178738", "0.6097885", "0.60384494", "0.5999612", "0.5992182", "0.5987641", "0.59374195", "0.5907902", "0.59064543", "0.5905868", "0.59022814", "0.5897556", "0.58923584", "0.58897096", "0.5878547", "0.5877865", "0.58775747", "0.58756465", "0.5845102", "0.583831", "0.5836748", "0.5829561", "0.5829478", "0.58238924", "0.582175", "0.5821389", "0.5821389", "0.5821389", "0.5821389", "0.5821389", "0.5817478", "0.5791102", "0.57728666", "0.5771505", "0.5769149", "0.57669425", "0.5763151", "0.57608", "0.57554173", "0.5753819", "0.57439256", "0.57390374", "0.5734782", "0.5734737", "0.57270926", "0.572087", "0.57157737", "0.5714484", "0.57015663", "0.56962395", "0.5695957", "0.5687447", "0.56796646", "0.5678255", "0.5673604", "0.5668786", "0.56662554", "0.5656079", "0.565442", "0.56504095", "0.56454295", "0.5640719", "0.5634968", "0.5634822", "0.5632676", "0.56323737", "0.5625326", "0.5622593", "0.5622256", "0.5620443", "0.56177145", "0.56167847", "0.56158775", "0.5613492", "0.56092566", "0.5609237", "0.5607022", "0.560522", "0.5603314", "0.5600522", "0.5589918", "0.55896807", "0.55846334", "0.5583943", "0.5582994", "0.557745", "0.5572254", "0.556438", "0.556438", "0.556438", "0.556438", "0.556438", "0.556438", "0.556438", "0.55615634" ]
0.7221005
0
def self.sign_up(username, password) User.new(username, password, []) end
def initialize(username, password) @username = username @password = password @tweet_history = [] @followers = [] @following = [] @@all_users.push(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_up\n @user = User.new\n end", "def create_user(name, email, password)\n\n # Password is hashed automatically\n user = User.new(name: name, email: email, password: password)\n user.save!\n end", "def new_user\n User.new({\n email: 'hoge@hoge',\n password: 'hoge',\n password_confirmation: 'hoge'\n })\n end", "def create_user\n User.create name: 'test', email: 'test@example.com', password: '123456'\n end", "def create_user\n User.create name: 'test', email: 'test@example.com', password: '123456'\n end", "def signup\n @user = User.new\n end", "def signup\n @user = User.new\n end", "def create_user\n User.create name: \"test\", email: \"test@example.com\", password: \"123456\"\n end", "def signup\n @user= User.new\n end", "def create_a_user(password: 'secret!!')\n User.create! email: \"101glover@gmail.com\",\n password: password\n end", "def setup_user\n User.new( \n age: 5,\n bio: \"My test bio\",\n password: SecureRandom.hex(6),\n email: SecureRandom.hex(4) + \"@example.com\",\n picture: \"blah.jpg\",\n sex: \"M\",\n username: SecureRandom.hex(4)\n )\n end", "def new_user(attributes = {})\n User.new({password: \"foobar\"}.merge(attributes))\n end", "def create_new_user\n username = find_username\n @user = User.new(\n email: auth_email,\n username: username,\n password: Devise.friendly_token[0, 20]\n )\n @user.skip_confirmation!\n @user.save!\n\n @user\n end", "def signup!(params)\n self.email = params[:user][:email]\n self.name = params[:user][:name]\n self.password = params[:user][:password]\n #save_without_session_maintenance\n end", "def create_a_user!(username = \"foo\")\n User.create! :username => username, :email => \"foo@bar\", :id => 4, :password => \"zot\"\n end", "def register\n @user = User.new(user_id: params[:user_id], password: params[:password])\n @user.save\n end", "def create\n user = User.new(username: params[:username])\n user.password = params[:password]\n user.save\n\n redirect_to root_url\n end", "def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end", "def new_user(name)\n User.create(name: name)\nend", "def create\n @user = User.create(params[:user]) \n \n if @user.save\n sign_in @user\n flash[:succeess] = \"Sign up successfully\" \n redirect_to @user\n else\n render 'new'\n end\n \n end", "def register(attributes = {})\n user = PublicEarth::Db::User.new(attributes)\n \n if attributes[:username].blank?\n user.errors.add(:username, \"A username is required.\") \n elsif attributes[:username] =~ /[^\\w\\-\\_\\!\\@\\$\\?]/\n user.errors.add(:username, \"A username may only contain letters, numbers or the following characters: -_!@$?\") \n elsif PublicEarth::Db::User.find_by_username(attributes[:username])\n user.errors.add(:username, \"The username #{attributes[:username]} is already taken.\") \n end\n \n if attributes[:email].blank?\n user.errors.add(:email, \"An email address is required.\") \n elsif PublicEarth::Db::User.find_by_email(attributes[:email])\n user.errors.add(:email, \"The email address #{attributes[:email]} is already taken.\") \n end\n\n if attributes[:email] !~ /^[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4}$/ \n user.errors.add(:email, \"A valid email address is required (eg, myname@somedomain.com).\")\n end\n \n if attributes[:password].blank?\n user.errors.add(:password, \"A password is required.\") \n elsif attributes[:password] != attributes[:password_confirmation]\n user.errors.add(:password, \"The password and its confirmation don't match.\")\n end\n\n if user.errors.empty?\n begin\n user.attributes = one.create(attributes[:username], attributes[:email], attributes[:password], generate_token)\n rescue\n logger.error(\"Failed to create user account for #{attributes.inspect}: #{$!}\")\n user.errors.add_to_base(\"Unable to create a user account for #{attributes[:username]}.\")\n end\n end\n\n user\n end", "def create\n\t\t@user = User.new(user_params)\n\t if @user.save\n\t sign_in @user\n\t flash[:success] = \"Congratulations! You are now registered and can start playing Lightcycles.\"\n\t redirect_to root_path\n\t end\n\tend", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n generate_temporary_password!\n save_without_session_maintenance\n end", "def create_user_account\n User.create!(email: self.email, password: self.customer)\n # user = User.new do |u|\n # u.email = email\n # u.password = customer\n # u.save\n # end\n end", "def create \n\t\t@user=User.new\n\t\t@user.provider=\"native\"\n\t\t@user.assign_attributes(signup_params)\n\t\t@user.save!\n\t\tflash[:success]=\"Thanks for joining SPACEF!T, #{@user.name ||\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@user.email.split(\"@\").first }. \"\n\t\tsign_in!(@user, true)\n\t\tredirect_to root_path\n\trescue ActiveRecord::RecordInvalid,\n\t\t\t\t\tActiveRecord::RecordNotUnique => e\n\t\tflash.now[:error]=\"We were not able to sign you up, please correct the following fields\"\n\t\t@user.wipe\n\t\trender 'new'\n\tend", "def createUser(nickname) \n usr = User.new(nickname)\n backend_addUser(usr) \n end", "def valid_user\n User.new(name: \"John Smith\",\n email: \"js@example.com\",\n password: \"password\",\n password_confirmation: \"password\")\nend", "def signup\n end", "def signup\n end", "def user_instance(username)\n User.new(new_username: username, forename: 'forename', surname: 'surname',\n email_address: 'a@a.com', email_address_confirmation: 'a@a.com',\n new_password: 'P@ssword001', new_password_confirmation: 'P@ssword001',\n user_is_current: 'Y')\n end", "def register_user(attributes)\n user = User.new(attributes)\n user.save\n user\n end", "def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\tredirect_to sign_in_path\n\t\telse\n\t\t\tredirect_to sign_up_path\n\t\tend\n\tend", "def create_user(user_hash={})\n @user = User.new(user_hash)\n @user.save\n end", "def create_user(user_hash={})\n @user = User.new(user_hash)\n @user.save\n end", "def create\n first_name, last_name, email, password = *params.values_at(:first_name, :last_name, :email, :password)\n\n if [first_name, last_name, email, password].any?(&:blank?)\n return render_success({status:\"error\", message: 'invalid create parameters'})\n end\n\n #User already exists\n if User.exists?(email: email.downcase)\n return render_success({status:\"error\", message:\"user already exists\"})\n end\n #create user\n User.transaction do\n @user = User.new(\n name: (first_name + \" \" + last_name).titleize,\n email: email.downcase,\n password: password,\n password_confirmation: password\n )\n if @user.save!\n render_success({status:\"success\", message:\"created\"})\n else\n render_success({status:\"error\", message:\"user creation failed\"})\n end\n end\n end", "def build_user\n User.new(first_name: 'John', \n last_name: 'Doe', \n email: 'email@example.com') \n end", "def new_user\n\t @user = User.new\t \n\tend", "def register(email, password)\n user = User.new\n puts user.register email, password\n end", "def registration\n \t@user = User.new\n end", "def create\n @user = User.new(user_params)\n if @user.save\n\t sign_in @user unless signed_in?\n\t flash[:success] = \"Signup successful\"\n redirect_to @user\n else\n render 'new'\n end\n end", "def signup(params)\n begin\n # This is a object of User model\n user = User.new\n\n if all_params_present(params[:first_name], params[:last_name], params[:sex], params[:date], params[:email], params[:password])\n presentable_error_response('BLANK_USER_DATA')\n end\n presentable_error_response(\"USER_ALREADY_EXISTS\") if user.find_email(params[:email])\n unless(params[:password].to_s.length > 7 && params[:password].to_s.length < 21)\n presentable_error_response(\"WRONG_PASSWORD_LENGTH\")\n end\n presentable_error_response(\"WRONG_GENDER_FORMAT\") unless is_valid_gender(params[:sex])\n presentable_error_response(\"WRONG_DATE_FORMAT\") unless is_valid_date(params[:date])\n\n user.create(params[:first_name], params[:last_name], valid_sex(params[:sex]), params[:date], params[:email], params[:password])\n\n return prepare_success_response({message: SUCCESS_MESSAGES['USER_CREATED']})\n rescue DataBaseException => e\n presentable_error_response('INTERNAL_ISSUE')\n end\n end", "def create\n @user = User.new(user_params)\n @user.save\n if @user.save\n redirect_to root_path, :notice => \"Signed up!\"\n else\n redirect_to signup_path\n end\n end", "def create_user(options={})\n\t\t\tUser.create({\n\t\t\t\tusername: \"user example\",\n\t\t\t\temail: \"example@email.com\",\n\t\t\t\tpassword: \"password\",\n\t\t\t\tpassword_confirmation: \"password\"\n\t\t\t}.merge(options))\n\t\tend", "def create_user(params)\n unless user = User.find_by_username(params[:username])\n params[:password_confirmation] = params[:password]\n user = User.create!(params)\n end\n user\nend", "def sign_up(useremail, password)\n if new_user_available(useremail)\n query = \"INSERT INTO Users (useremail, password) VALUES('#{useremail}', '#{password}')\"\n @connection.exec(query)\n end\n end", "def create\n user = User.new( first: params[:first],\n last: params[:last],\n username: params[:username],\n password: params[:password])\n if user.save\n flash[:notice] = \"Good job!\"\n redirect_to :root\n else\n flash[:alert] = \"Oops, no bueno\"\n redirect_to :back\n end\n end", "def create_user(email, password)\n FactoryBot.create(:user, email: email, password: password)\n end", "def create\n # have name, email, password that person wants to use user_params\n # user model:\n # validate that username is unique (can add in User model)\n # validate against other criteria for user names (can't have a one-letter username, language filter)\n # create obscured version of password with BCrypt::Password.create\n # attempt to save user in database with username, password obscured version of password from the form\n user = User.new(user_params)\n if user.save\n # if user saves properly:\n \t# TODO: redirect to a user created page with instructions for email confirmation\n # log user in\n session[:user_id] = user.id\n \t# redirect to home / success\n redirect_to \"/\"\n else\n # if user does not save:\n \t# flash error message (with specifics!)\n flash[:errors] = user.errors.full_messages.join(\" \")\n \t# redirect to sign up form (/users/new)\n redirect_to signup_path\n end\n\n end", "def create\n @user = User.new(params[:user])\n if @user.save\n # Handle a successful save.\n sign_in @user\n flash[:success] = \"Welcome to turftalk!\"\n redirect_to '/users'\n else\n @title = \"Sign up\"\n render 'new'\n end\n end", "def create_user(input)\n User.create(name: input)\n end", "def create\n # Listing 7.22: Using strong parameters in the create action.\n @user = User.new(user_params)\n if @user.save\n # Listing 8.27: Signing in the user upon signup.\n sign_in @user\n # Listing 7.26: Redirecting the create action to the new user page.\n flash[:success] = \"Welcome to the Sample App!\"\n redirect_to @user\n else\n render 'new'\n end\n end", "def create\n\t\t\t\tparams.required(:email)\n\t\t\t\tparams.required(:password)\n\n\t\t\t\t@user = User.create(:email => params[:email], :password => params[:password])\n\n\t\t\t\tinvalid_request_error_check\n\t\t\tend", "def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create_user( page, password )\n user = User.new()\n user.password = password\n user.admin = false\n \n update_user( user, page )\n end", "def create\n\t\t\t\t@user = User.create!(create_user_params)\n\t\t\tend", "def create_user(email, name, pw)\n user = User.find_or_create_by(username: name) do |u|\n u.email = email\n u.username = name\n u.password = pw\n u.password_confirmation = pw\n end\n user\nend", "def create\n\t\t@user = User.new(user_params)\n# We used to pass new(params[:user]) which defined params as a \n# hash of hashes for the user object. Eq to saying \n# @user = User.new(name: \"joe\", email: \"joe@\"... etc.) but it was insecure \n# so instead now we define the params we want to be accessible and required.\n\t\tif @user.save\t\t\t\n# Handles a successful save\n\t\t\tsign_in @user\n\t\t\tflash[:success] = \"Welcome to Winecards!\"\n\t\t\tredirect_to @user\n\t\telse\n\t\t\trender 'new'\n\t\tend\n\tend", "def register\n @user = User.new\n end", "def create_user(email, password, full_name = nil, language = nil)\n options = { email: email, password: password }\n options[:language] = language if language\n options[:full_name] = full_name if full_name\n\n query_api '/auth/user', options\n end", "def create\n @user = User.new(username: params[:username], email: params[:email], password: params[:password])\n\n if @user.save\n render json: {status: 'SUCCESS', message: 'Account successfully created', accessToken: @user.access_token}.to_json\n else\n render json: {errors: [\"Sign up failed!\"], status: 422}.to_json\n end\n\n end", "def create_listserv_user\n User.create!({\n email: 'list-recipient@chat.mindhub.org',\n first_name: 'list-recipient',\n last_name: 'chat.mindhub.org',\n password: 'creativefresno',\n password_confirmation: 'creativefresno',\n remember_me: false\n })\nend", "def create\n # Create a new user using the received data.\n @user = User.new(user_params)\n\n # Can the user be saved to the database?\n # i.e. does the given parameters obey the model validations.\n if @user.save\n log_in @user\n remember @user\n flash[:success] = 'Welcome to Password!'\n redirect_to @user\n else\n # The user sent bad data.\n # Re-render signup page to display errors.\n render 'new'\n end\n end", "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def new\n\t@title = \"Sign Up\"\n\t@user = User.new\n end", "def new()\n @user = User.new()\n end", "def new\n\t@user = User.new\n\t@title = \"Sign up\"\n end", "def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n flash[:success] = \"Registration was successful!\"\n sign_in @user\n redirect_to root_path\n else\n render 'new'\n end\n end", "def create_user\n fake_password = Faker::Internet.password\n params = {\n user: {\n username: Faker::Internet.user_name,\n email: Faker::Internet.email,\n password: fake_password,\n password_confirmation: fake_password\n }\n }\n post signup_post_url, { params: params }\n params[:user]\n end", "def create #sign up button\n @user = User.new(user_params)\n if @user.save\n login(@user)\n redirect_to user_url(@user)\n else\n flash.now[:errors] = @user.errors.full_messages\n render :new\n end\n end", "def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to root_url, :notice => \"Signed up!\"\n else\n render \"new\"\n end\n end", "def create\n\n #.create is a method we get from AR.\n #it returns a new object in local memory with the specified params\n #it then saves the hash object in the database.\n @user = User.create user_params\n if @user.save\n session[:user_id] = @user.id.to_s\n flash['alert-success'] = \"You have been registered #{@user.username}, please login.\"\n redirect_to new_session_path\n else\n flash['alert-warning'] = 'Unable to create a user account.'\n redirect_to new_user_path\n end\n end", "def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end", "def create_user(attributes)\n BrickFTP::API::User.create(attributes)\n end", "def create\n @user = User.new(params[:user])\n @user.set_the_password = true\n #@update_pass = 0\n if @user.save\n sign_in @user\n flash[:success] = \"Bienvenido al gestor de usuarios\"\n redirect_to @user\n else\n @title = \"Sign up\"\n render 'new'\n end\n end", "def new_user(username, password, full_name, email)\n representation = form_encoded({ \"user[name]\" => username,\n \"user[password]\" => password,\n \"user[full_name]\" => full_name,\n \"user[email]\" => email }) \n puts representation\n begin\n response = open(@service_root + '/users', :method => :post, \n :body => representation)\n puts \"User #{username} created at #{response.meta['location']}\"\n rescue OpenURI::HTTPError => e\n response_code = e.io.status[0].to_i\n if response_code == \"409\" # Conflict\n puts \"Sorry, there's already a user called #{username}.\"\n else\n raise e\n end\n end\n end", "def create\n @app = User.new\n\n @app.name_company = params[:name_company]\n @app.email = params[:email]\n @app.url = params[:url]\n @app.phone = params[:phone]\n @app.address = params[:address]\n\n # verify email format\n\n # salt password\n end", "def create_user(username, email, password)\n password_digest = BCrypt::Password.create(password)\n\n sql = <<~SQL\n INSERT INTO users \n (username, email, password_digest)\n VALUES\n ($1, $2, $3);\n SQL\n run_sql(sql, [username, email, password_digest])\nend", "def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end", "def create\n @user = User.create( user_params )\nend", "def register()\n\tentry = {\"userid\" => @userid, \"username\" => @username, \"email\" => @email, \"password\" => @password}\n\tDATABASE.newEntry(\"users\", entry)\n\tend", "def create\n @user = User.new(params[:user])\n if @user.save\n # we log him in and we redirect to root path\n log_user_in(@user)\n redirect_to root_path, :notice => \"You have successfully signed up.\"\n else\n flash.now[:alert] = \"Cannot sign you up. Sorry for that.\"\n render :new, :status => :unprocessable_entity\n end\n end", "def create_new_account(email, full_name=nil, password=nil)\n return call('User.create', {'email' => email, 'full_name' => full_name,\\\n 'password' => password})\n end", "def create(password)\n Statements::CreateUser.new(context: self).password(password)\n end", "def create\n name = params[:name]\n email = params[:email]\n password = params[:password]\n new_user = User.create!(\n name: name,\n email: email,\n password: password,\n )\n\n response = \"Hey #{name}, You are registered successfully!\"\n render plain: response\n end", "def create_user\n # provide the interface asking for name, destination and duration\n # then, create and store the User object\n end", "def create\n\t\tUser.create(params.require(:user).permit(:fname,:lname,:username,:email,:address,:password))\n\t\tflash[:notice] = \"Congrats on your new account\"\n\t\tredirect_to '/'\n\tend", "def sign_up_params\n params.require(:user).permit(:email, :password)\n end", "def signup\n case request.method\n when :post\n @user = User.new(params['user'])\n \n if @user.save \n session['user'] = User.authenticate(@user.login, params['user']['password'])\n flash['notice'] = _(\"Signup successful\")\n redirect_back_or_default :action => \"welcome\" \n end\n end \n end", "def create\n\t\tuser = User.find_by(username: params[:user][:username])\n\n\t\tif user && user.authenticate(params[:user][:password])\n\t\t\tsign_in user\n\t\t\tredirect_to root_url, notice: \"Welcome back!\"\n\t\telse\n\t\t\tflash.now[:error] = \"There was an error!\"\n\t\t\tredirect_to \"/login\"\n\t\tend\n\tend", "def create\r\n\t\t# check for errors\r\n\t\tif params[:username].blank? || params[:username].blank? || params[:email].blank? || params[:password].blank? || params[:verifypassword].blank? \r\n\t\tredirect_to signup_path, notice: 'Please fill in all the required fields'\r\n\t\telse\r\n\t\t\r\n\t\t\tif !User.exists?(username: params[:username])\r\n\t\t\t\tif params[:password] == params[:verifypassword]\r\n\t\t\t\t\tif !User.exists?(email: params[:email])\r\n\t\t\t\t\t\t@user = User.new(:username => params[:username], :email => params[:email], :password => params[:password], :member_since => Time.now)\r\n\t\t\t\t\t\tif @user.save\r\n\t\t\t\t\t\t\tcreate_cookies(params[:username], params[:password])\r\n\t\t\t\t\t\t\tredirect_to root_path\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tredirect_to signup_path\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tredirect_to signup_path, notice: 'registration is limited per 1 student email acount'\r\n\t\t\t\t\tend\r\n\t\t\t\telse\r\n\t\t\t\t\tredirect_to signup_path, notice: 'Password doesnt match, retype password'\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tredirect_to signup_path, notice: 'Username is taken'\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def create\n @user = User.new\n @user.email = params[:email]\n @user.password = params[:password]\n\n if @user.save\n redirect_to \"/login\"\n else\n render :new\n end\n end", "def create\n @user = User.new #create user\n @user.email = params[:email] #set value of email attribute\n @user.password = params[:password] #set value of password attribute\n\n if @user.save #save email and password to the database\n redirect_to \"/login\"\n else\n render :new\n end\n end", "def create\n\t\tuser = User.new()\n \n user.username = params[:username]\n user.password = params[:password]\n user.password_confirmation = params[:password_confirmation]\n user.email_address = params[:email_address]\n user.first_name = params[:first_name]\n user.last_name = params[:last_name]\n user.activation = SecureRandom.hex 16\n \n\t\tif user.save()\n UserMailer.activation_email(user).deliver_later!(wait: 15.seconds)\n\t\t\tpayload = {\n\t\t\t\terror: false,\n\t\t\t\tid: user.id\n\t\t\t}\n\t\t\trender status: 200, json: payload\n\t\telse\n\t\t\terrors = []\n\t\t\tuser.errors.keys.each do |key|\n\t\t\t\terrors << {field: key, message: user.errors.full_messages_for(key).first}\n\t\t\tend\n\t\t\tpayload = {\n\t\t\t\terror: true,\n\t\t\t\terrors: errors\n\t\t\t}\n\t\t\trender status: 200, json: payload\n\t\tend\n\tend", "def create\n\t@user = User.new(params[:user])\n\t\n\tif @user.save\n\t\tsign_in @user\n\t\tUserMailer.welcome_email(@user).deliver\n\t\tflash[:success] = \"Welcome to g8keep!\"\n\t\tredirect_to @user\n\telse\n\t\t@title = \"Sign up\"\n\t\t@user.password = nil\n\t\t@user.password_confirmation = nil\n\t\trender 'new'\n\tend\n end", "def initialize (firstname, lastname, username, email, password)\n \n @first_name = firstname\n @last_name = lastname\n @email = email\n @username = username\n @password = password\n\n end", "def signup(params)\n if self.is_client?\n user = self.employees.create!(name: params[:name],last_name: params[:last_name],\n email: params[:email],password: params[:password],password_confirmation: params[:password_confirmation])\n GroupsUser.create!(user_id: user.id,group_id: params[:group_id])\n user\n else\n user = self.clients.create!(name: params[:name],email: params[:email],password: params[:password],\n password_confirmation: params[:password_confirmation])\n end\n end", "def create\n\n\t\tif !params[:email].nil? && !params[:password].nil? && !params[:name].nil? && !params[:mobile].nil?\n\t\t\tuser = User.new(:email => params[:email],\n\t\t\t\t\t\t\t\t\t\t\t:password => params[:password],\n\t\t\t\t\t\t\t\t\t\t\t:password_confirmation => params[:password],\n\t\t\t\t\t\t\t\t\t\t\t:name => params[:name],\n\t\t\t\t\t\t\t\t\t\t\t:mobile => params[:mobile])\n\t\t\tif user.save\n\t\t\t\tsign_in user, :bypass => true\n\t\t\t\trender json: user, status: :created\n\t\t\telse\n\t\t\t\trender json: {message: 'User exists, or Password doesn\\'t match'}, status: :not_found\n\t\t\tend\n\t\telse\n\n\t\t\trender json: {message: 'Username not found or Password don\\'t provided'}, status: :bad_request\n\t\tend\n\tend", "def create_user(options = {})\n\t\trecord = Factory.build(:user,options)\n\t\trecord.save\n\t\trecord\n\tend" ]
[ "0.8118255", "0.80356276", "0.7992348", "0.7960663", "0.7943288", "0.79405856", "0.79405856", "0.793993", "0.7929657", "0.78989303", "0.75510544", "0.7548317", "0.7538202", "0.75092083", "0.75056314", "0.74841994", "0.74495775", "0.74349", "0.74175125", "0.7413963", "0.73957", "0.73950815", "0.7391859", "0.7391859", "0.7389306", "0.7380264", "0.7372843", "0.73646164", "0.735813", "0.73466426", "0.73466426", "0.733997", "0.73379135", "0.73361003", "0.73293376", "0.73293376", "0.7316015", "0.731115", "0.7310906", "0.73078775", "0.7293025", "0.72834337", "0.7276193", "0.7275013", "0.725901", "0.7252842", "0.72485834", "0.72437024", "0.72401106", "0.72384244", "0.7230325", "0.7225165", "0.7195561", "0.7179824", "0.71788734", "0.7174582", "0.71744865", "0.7171143", "0.7158042", "0.71495837", "0.71418643", "0.7134304", "0.71310645", "0.71300423", "0.7127466", "0.7123459", "0.71203345", "0.7115958", "0.7089056", "0.7086285", "0.70810556", "0.70736134", "0.707054", "0.7070417", "0.7069565", "0.70695615", "0.70664406", "0.70627195", "0.70567155", "0.7054501", "0.7052325", "0.70498765", "0.70374095", "0.7035477", "0.70190203", "0.70139134", "0.7011985", "0.7010575", "0.70093334", "0.7009178", "0.70019984", "0.6995125", "0.6988986", "0.69828206", "0.6979443", "0.6977438", "0.69769573", "0.6973801", "0.6965257", "0.69633526", "0.69611394" ]
0.0
-1
Iterates the collection through the given block.
def each self.num_geometries.times do |n| yield self.get_geometry_n(n) end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n @collection.each(&block)\n end", "def each(&block)\n internal_collection.each(&block)\n end", "def each(&block)\n @collection.each(&block)\n end", "def each(&block)\n @collection.each do |collectable|\n if block_given?\n block.call collectable\n else \n yield collectable\n end\n end \n end", "def each_container(&block)\n collection.each_value(&block)\n end", "def each(&block)\n end", "def each(&block)\n @items.each(&block)\n end", "def each (&block)\n\n @items.each { |i| block.call(i) }\n end", "def each &block\n end", "def each\n @collection.each { |c| yield c }\n end", "def each(&block)\n find_each(&block)\n end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block)\n raise NotImplementedError\n end", "def each(&block)\n items.each &block\n end", "def each(&block)\n items.each &block\n end", "def _each(&block)\n _next.each(&block) if _next\n end", "def each(&block)\n @items.each do |item|\n block.call(item)\n end\n end", "def each(&block)\n call_client(:each, &block)\n end", "def each(&block)\n @all.each(&block)\n end", "def each( & block )\n \n return atomic_cursor.each( & block )\n\n end", "def each(&block)\n @items.each(&block)\n self\n end", "def each(&block)\n raise NotImplementedError\n end", "def each(&block)\n list_items.each(&block)\n end", "def each(&block)\n each_page { |page| page.each(&block) }\n end", "def each(node, &block); end", "def each(&block)\n @current_page += 1\n fetch_current_page if !@fetched_current_page\n @items.each { |i| block.call i } \n @fetched_current_page = false\n end", "def each(&block)\n\n end", "def each &block\n return enum_for :each unless block_given?\n\n each_page do |page|\n page.each(&block)\n end\n end", "def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end", "def each(&block)\n return enum_for(:each) unless block\n while rec = fetch\n block.call rec\n end\n self\n end", "def each(&block)\n self.entries.each(&block)\n end", "def each(&block)\n if block\n @block = block\n parser_dispatch\n else\n enum_for(:each)\n end\n end", "def each\n return enum_for(:each) unless block_given?\n\n @data.collection.each { |item| yield item }\n end", "def each(&block)\n\t\t\t self.get.each &block\n\t\t\tend", "def each(node, &block)\n visit(node, &block)\n end", "def each(&block)\n\t\t\t@ordered.each(&block)\n\t\tend", "def each(&block)\n @@list.each(&block)\n end", "def each(&block)\n return enum_for(:each) unless block_given?\n visit { |node| yield node }\n self\n end", "def each(&block)\n scenes_collection.each(&block)\n end", "def each(&block)\n @grouped_collection.each { |gc| block.call(gc) }\n end", "def each(&block)\n all.each(&block)\n end", "def each(&block)\n @entries.each(&block)\n end", "def each(&block)\n records.each(&block)\n end", "def each(&block)\n @wrapped_collection.each { |member| block.call(@klass.new(member, @context)) }\n end", "def each(&block)\n @list.each(&block)\n end", "def each(&block)\n\n all.each { |wi| block.call(wi) }\n end", "def each(&block)\n results.each(&block)\n end", "def each(&block)\n @ledger.each(&block)\n end", "def each(&block)\n documents.each(&block)\n end", "def each &block\n @entries.each &block\n end", "def each(&block)\n return @parts.each(&block)\n end", "def each(&block)\nend", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n @_componentable_container.each(&block)\n end", "def each(&block)\n Fetcher.new(self).each(&block)\n end", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n to_a.each(&block)\n end", "def each(&block)\n @inventory.each(&block)\n end", "def each(collection)\n\ti = collection.count\n\twhile i > 0\n\t\tyield collection\n\t\ti -= 1\n\tend\nend", "def each(&block)\n @data.each(&block)\n end", "def each(&block) \n current = @head\n \n while current\n block.call(current.value)\n current = current.successor\n end\n end", "def each(&block)\n list.each &block\n end", "def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end", "def each(&_block)\n iterator = BlockIterator.new(self)\n\n until iterator.current_hash == Block::GENESIS_PREV_HASH\n block = iterator.next\n yield(block)\n end\n end", "def each(&block)\n each_vertex(&block)\n end", "def each(&block)\n @all.each_batch { |batch| batch.each { |s| yield s } }\n end", "def each(&block)\n self.data.each(&block)\n end", "def each(&block)\n return enum_for(:each) unless block_given?\n \n # if using the block form only, don't \"next\" for internal iteration\n if @block && !@enum\n @block.call Enumerator::Yielder.new(&block)\n else\n rewind\n\n until end?\n yield self.next\n end\n end\n \n self\n end", "def each &block\n @parts.each(&block)\n end", "def each(&block)\n # get the first\n node=getnext([])\n $DEBUG.puts \"each: first node is #{node}\"\n while node\n block.call node\n oldnode=node\n node=getnext(node.oid)\n $DEBUG.puts \"each: next of #{oldnode} is #{node}\"\n end\n end", "def each(&block)\r\n @range.each(&block)\r\n end", "def each(&block)\n return enum_for :each unless block\n\n @data.each(&block)\n\n self\n end", "def each(&block)\n @v.each &block\n end", "def each(&block)\n @document.each_page(&block)\n end", "def each( &block )\n return self.fields.each( &block ) if block\n self.fields.each\n end", "def each(&block)\n raise Error::UnsupportedOperation, \"Method GeometryCollection#each not defined.\"\n end", "def each &block\n scoped.each(&block)\n end", "def each(&block)\n cells.each(&block)\n end", "def each(&block)\n begin\n while true\n block.call(@fiber.resume)\n end\n rescue StopIteration\n end\n end", "def each(&block)\n @mutable.each(&block)\n end", "def each(&block)\n @records.each(&block)\n end", "def each(&block)\n @results.each(&block)\n end", "def each &block\n @data.each &block\n end", "def each(&block)\n @list.each_value &block\n end", "def each(&block)\n entries.each(&block)\n end", "def each(&block)\n entries.each(&block)\n end", "def each(&block) # block into proc\n\nend", "def each(&block)\n @results.each &block\n end", "def each &block\n @accounts.each &block\n end", "def each &block\n @data.each &block\n end", "def each(&block)\n @rows.each(&block)\n end", "def each(&block)\n @rows.each(&block)\n end", "def each(&block)\n return enum_for :each unless block\n\n %x{\n for (var i = 0, length = #@native.rows.length; i < length; i++) {\n #{block.call(self[`i`])};\n }\n }\n\n self\n end", "def each(&block)\n @cells.each(&block)\n end", "def each(&block)\n rows.each(&block)\n end", "def each( &block )\n @members.each( &block )\n end" ]
[ "0.8226908", "0.8147401", "0.8035317", "0.7822804", "0.7798454", "0.7636493", "0.7485495", "0.7434723", "0.7408925", "0.73424184", "0.7340868", "0.72893155", "0.72893155", "0.72893155", "0.72893155", "0.72893155", "0.72893155", "0.72748995", "0.72555065", "0.72555065", "0.7244407", "0.72443765", "0.72372216", "0.72114074", "0.7196711", "0.7187209", "0.7163021", "0.7143441", "0.71421874", "0.71122414", "0.71100694", "0.7098414", "0.7092308", "0.708383", "0.708383", "0.70826334", "0.7059452", "0.7050456", "0.70277476", "0.70178926", "0.7017065", "0.70010746", "0.6999019", "0.69962007", "0.69954795", "0.6995182", "0.6973285", "0.69646007", "0.6950456", "0.69457644", "0.6924048", "0.6918391", "0.691357", "0.6901221", "0.6892483", "0.6881917", "0.68773144", "0.686589", "0.6864454", "0.68553376", "0.68466574", "0.68466574", "0.6843056", "0.68428195", "0.6832121", "0.6815635", "0.68059003", "0.6801878", "0.6796404", "0.67915654", "0.6791428", "0.6787768", "0.67854524", "0.6783941", "0.67790747", "0.67764735", "0.6770677", "0.67650133", "0.6759439", "0.6752074", "0.6744181", "0.6728805", "0.672603", "0.67259127", "0.67242306", "0.6712572", "0.67075616", "0.6701988", "0.6696755", "0.66847014", "0.66847014", "0.6677236", "0.66772074", "0.6673721", "0.6670787", "0.666695", "0.666695", "0.6658708", "0.665115", "0.6643847", "0.6641361" ]
0.0
-1
Returns the nth geometry from the collection.
def [](*args) self.to_a[*args] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def geometry_n(n)\n raise Error::UnsupportedOperation, \"Method GeometryCollection#geometry_n not defined.\"\n end", "def last\n self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0\n end", "def last\n self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0\n end", "def [](n)\n raise Error::UnsupportedOperation, \"Method GeometryCollection#[] not defined.\"\n end", "def each\n self.num_geometries.times do |n|\n yield self.get_geometry_n(n)\n end\n nil\n end", "def each\n self.num_geometries.times do |n|\n yield self.get_geometry_n(n)\n end\n nil\n end", "def nth\n num = self.class.all_in_current_meeting.index(self)\n num ? num.ordinalize : nil\n end", "def element\n @collection[index]\n end", "def geometry\n @geometry\n end", "def each\n if block_given?\n self.num_geometries.times do |n|\n yield self.get_geometry_n(n)\n end\n self\n else\n self.num_geometries.times.collect { |n|\n self.get_geometry_n(n)\n }.to_enum\n end\n end", "def xy\n @geometries.dig(@geometry_index, @coordinates_index)\n end", "def [](n)\n @locations[n]\n end", "def [](index)\n return nil unless index.between?(0, vertex_count - 1)\n vertex = Vector.zero\n FMOD.invoke(:Geometry_GetPolygonVertex, @geometry, @index, index, vertex)\n vertex\n end", "def num_geometries\n raise Error::UnsupportedOperation, \"Method GeometryCollection#num_geometries not defined.\"\n end", "def nearest(geometry_index: nil, xy:)\n position = nil\n min_distance = 21_000_000 # max distance on earth in meters\n @geometries.each.with_index do |geometry, g_index|\n next unless geometry_index.nil? || geometry_index == g_index\n geometry.each.with_index do |coordinates, c_index|\n distance = xy.distance(coordinates).dim\n if distance < min_distance\n position = Position.new(geometries: geometries, geometry_index: g_index, coordinates_index: c_index)\n min_distance = distance\n end\n end\n end\n position\n end", "def [](n)\n nth(n) ;\n end", "def first(n = nil)\n if n\n self[0,n]\n else\n self[0]\n end\n end", "def nth_ref(n)\n if lm = last_match()\n return lm[n]\n end\n\n return nil\n end", "def geometry\n @feature\n end", "def geometry\n @geometry ||= _geometry\n end", "def nth_ref(n)\n if lm = @last_match\n return lm[n]\n end\n\n return nil\n end", "def at(n)\n return nil if n >= count\n first(n+1).pop\n end", "def test_arrayget_on_negative_index\n collection = Geom::Point3d.new(1,2,3)\n expected = 3\n result = collection[-1]\n assert_equal(expected, result,\n 'Expected does not match result.')\n end", "def geometry\n\t\tmongo_format[\"$box\"].flatten\n\tend", "def fourth\n at(3)\n end", "def nth(n)\n proc {|*args|args[n]}\n end", "def [](i); self.objects.ith(i) end", "def get_index(index)\n return self.at(index)\n end", "def geometry\n if (@file)\n img = ::Magick::Image::read(@file.file).first\n @geometry = [ img.columns, img.rows ]\n else\n @geometry = [0, 0]\n end\n end", "def item(i)\n @parts.push(take: i)\n end", "def [](index)\n self.pegs[index]\n end", "def item index\n @items[index-1]\n end", "def element(n, list)\n list[n - 1]\n end", "def [] (index)\n if (@points.length == 0)\n raise \"cannot get any points from an empty polygon\"\n end\n while (index < 0)\n index += @points.length\n end\n while (index > @points.length - 1)\n index -= @points.length\n end\n @points[index]\n end", "def [](nb)\n return sync { @articles[nb - 1] }\n end", "def first flavor = nil\n self[0, flavor]\n end", "def index\n @geometries = Geometry.all\n end", "def first(n = 1)\n return self.clone if n >= self.size\n return self[0] if n == 1\n return self[0...n]\n end", "def nth_from_array_or_range\n C.curry.(\n ->(xs, n) {\n xs.is_a?(Range) ? xs.first(n) : S.take.(xs, n)\n }\n )\n end", "def [](i)\n get unless loaded\n self.objects.first[1][i] rescue nil\n end", "def fetch(nth, *args, &block)\n if args.size >= 2\n raise ArgumentError, \"wrong number of arguments (#{args.size + 1} for 1..2)\"\n end\n\n if has_size? && (nth < -size || size <= nth)\n if block != nil\n # TODO: Warn if ifnone value is present.\n return block.call\n elsif args.size == 1\n return args[0]\n else\n raise IndexError,\n \"index #{nth} outsize of the random readable object \" \\\n \"bounds: #{-size}...#{size}\"\n end\n else\n return at(nth)\n end\n end", "def get_node(i=0)\n nodes.select {|a| a.number == i.to_i}.first\n end", "def presentation_page n\n pages[n-1][:resource]\n end", "def size\n num_geometries\n end", "def nth_measure_test(measure_test_number)\n @product.product_tests.measure_tests.sort_by(&:created_at)[measure_test_number.to_i - 1]\nend", "def part(index)\n @parts[index]\n end", "def get_part(collection, location)\n row, column = convert_location_to_coordinates(location)\n collection.part(row, column)\n end", "def extract(collection, index)\n val = Convert(collection)\n if val.type.kind == :vector\n @builder.extract_element(val, Convert(index, :integer))\n else\n @builder.extract_value(val, index.to_i)\n end\n end", "def [](index)\n self.grid[index]\n end", "def [](n)\n @data[n]\n end", "def first(n = nil)\n if n\n apply_scope(:first, n)\n else\n self[0]\n end\n end", "def index\n @computer_geometries = ComputerGeometry.all\n end", "def [](index)\n parts[index]\n end", "def [](idx) \n if idx >= @total\n return nil\n end\n\n @tuple.at(@start + idx)\n end", "def limit(n)\n new_selection = selected_nodes.first(n).map(&:id)\n\n self.class.new(\n nodes_by_id: nodes_by_id,\n selected_node_ids: new_selection\n )\n end", "def first(count = nil)\n if count.nil?\n @collection.first\n else\n out = []\n @collection.first(count).each do |item|\n out << item\n end\n out\n end\n end", "def page_index(item_index) \n return -1 if !(item_index < item_count) || item_index < 0\n @collection[item_index]\n end", "def sixth\n at(5)\n end", "def first\n @features.first\n end", "def vertex_number\n @vertices.count\n end", "def first(*n) end", "def closed?(geometry_index:)\n geometry = @geometries[geometry_index]\n geometry.first == geometry.last\n end", "def rows\n shape[0]\n end", "def get_row(row_num)\n @grid[row_num]\n end", "def geometry_columns; end", "def [](n)\n @nodes[n]\n end", "def get(index)\n raise \"Only positive indexes, #{index}\" if index <= 0\n if index > self.get_length\n return nil\n else\n return internal_object_get(index + 1)\n end\n end", "def nthRun(_nth)\n case(_nth)\n when Run ; return _nth ;\n when Integer ; return @runList[_nth] ;\n when :first ; return @runList.first ;\n when :last ; return @runList.last ;\n else\n raise \"unknown _nth index type for @runList: \" + _nth.inspect ;\n end\n end", "def get_index(position:)\n row = (position - 1) / 3\n col = (position - 1) % 3\n return row, col\n end", "def last\n @collection.size - 1\n end", "def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end", "def [](index)\n @items[index - 1]\n end", "def [](index)\n @items[index - 1]\n end", "def get_row_from_index(index)\n (index - 1) / 8 + 1\n end", "def fourth\n self[3]\n end", "def ninth\n at(8)\n end", "def node\n raise Error::UnsupportedOperation, \"Method GeometryCollection#node not defined.\"\n end", "def first_axis_index(index, coordinate_system=:row_col)\n case coordinate_system\n when :row_col\n (index / 9)\n when :col_row\n index % 9\n when :box\n (index / 27) * 3 + (index / 3) % 3\n end\n end", "def find_nth(n)\n count = self.count\n copy = self\n count -= n\n while count > 0 do\n copy = copy.next\n count -= 1\n end\n return copy\n end", "def get_row_from_index(index)\n return (index - 1)/8 + 1\n end", "def [](index)\n raise ArgumentError, \"index must be < #{size}\" if index >= size\n number[index]\n end", "def child number\n unless @node.send(@children).nil?\n @node = ( ( @node.send(@children) ).at(number) )\n end\n end", "def dimensions(n=0)\n n += 1\n self.first.is_a?(Array) ? self.first.dimensions(n) : n\n end", "def get_any_top(number)\n images.take(number)\n end", "def select(num)\n return if @result.size == 0 || @result.size < num\n return @result[num.abs][:cite]\n end", "def get_generation(n)\n\t\treturn @generations[n]\n\tend", "def geoObject()\n return @shape ;\n end", "def document_number\n hits = self.class.ferret_index.search(query_for_self)\n return hits.hits.first.doc if hits.total_hits == 1\n raise \"cannot determine document number from primary key: #{self}\"\n end", "def first_reference_paper\n reference_papers[0]\n end", "def at(index)\n self[index]\n end", "def grid(index)\r\n out_short_name = FFI::MemoryPointer.new(:string)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_direct_download = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_coordoperation_get_grid_used(self.context, self, index,\r\n out_short_name, out_full_name, out_package_name,\r\n out_url, out_direct_download ,\r\n out_open_license, out_available)\r\n\r\n if result != 1\r\n Error.check_object(self)\r\n end\r\n\r\n name_ptr = out_short_name.read_pointer\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n downloadable_ptr = out_direct_download \r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n unless name_ptr.null?\r\n Grid.new(name_ptr.read_string_to_null, self.context,\r\n full_name: full_name_ptr.null? ? nil : full_name_ptr.read_string_to_null,\r\n package_name: package_name_ptr.null? ? nil : package_name_ptr.read_string_to_null,\r\n url: url_ptr.null? ? nil : url_ptr.read_string_to_null,\r\n downloadable: downloadable_ptr.null? ? nil : downloadable_ptr.read_int == 1 ? true : false,\r\n open_license: open_license_ptr.null? ? nil : open_license_ptr.read_int == 1 ? true : false,\r\n available: available_ptr.null? ? nil : available_ptr.read_int == 1 ? true : false)\r\n end\r\n end", "def last\n @features.last\n end", "def get_item(index_number)\n @chores[index_number]\n end", "def get_item(index)\r\n @list[index]\r\n end", "def get_child(index)\n @children[index]\n end", "def geometry_columns!; end", "def section(index)\n nodes.at(index)\n end", "def [](num)\n remotes[num-1]\n end", "def next\n last? ? nil : @collection[index + 1]\n end", "def child(n)\n if n < 0\n raise Exceptions::ZipperError,\n \"child index cannot be negative\"\n end\n\n cursor = down\n until n.zero?\n cursor = cursor.next\n n -= 1\n end\n cursor\n end", "def item(index = self.index)\n @data[index]\n end" ]
[ "0.721603", "0.63378745", "0.63378745", "0.610177", "0.5901542", "0.5901542", "0.55415785", "0.5411624", "0.5410828", "0.5393923", "0.5233196", "0.5220837", "0.51929516", "0.51917446", "0.5190835", "0.5189134", "0.516874", "0.5156625", "0.5113467", "0.5098663", "0.50854063", "0.5037952", "0.5033501", "0.50321984", "0.5026576", "0.50210106", "0.49985167", "0.49702466", "0.49543408", "0.49534115", "0.49479064", "0.49183044", "0.49011523", "0.48855487", "0.4877539", "0.48739928", "0.48729688", "0.48724312", "0.48672035", "0.48556012", "0.485528", "0.48399925", "0.48260835", "0.48140657", "0.47960964", "0.4795998", "0.47931278", "0.4791025", "0.47882643", "0.47684988", "0.47660714", "0.47592327", "0.47547948", "0.47384784", "0.47380334", "0.47262162", "0.47243416", "0.4713829", "0.4705273", "0.46931222", "0.46922013", "0.46855554", "0.46830317", "0.46828493", "0.4682604", "0.46715367", "0.46690217", "0.465604", "0.4655928", "0.46547663", "0.46537155", "0.46478987", "0.46478987", "0.46423942", "0.46325096", "0.4613076", "0.46072224", "0.46017697", "0.46015033", "0.45943475", "0.45930016", "0.45871618", "0.45847097", "0.45716125", "0.4566951", "0.45642966", "0.45619708", "0.45602524", "0.45519775", "0.45486796", "0.4547128", "0.45441353", "0.45364186", "0.453523", "0.4525944", "0.4520416", "0.452041", "0.4517598", "0.45121837", "0.4507903", "0.4506834" ]
0.0
-1
Returns the last geometry from the collection.
def last self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def last\n @collection.size - 1\n end", "def last\n @features.last\n end", "def geometry\n @geometry ||= _geometry\n end", "def last\n @locations.last\n end", "def last\n @adapter.last(collection)\n end", "def last_point\n path_points.last\n end", "def last\n @features.sort.last\n end", "def geometry\n @geometry\n end", "def last\n opts = process_options\n sorting = opts[:sort]\n sorting = [[:_id, :asc]] unless sorting\n opts[:sort] = sorting.collect { |option| [ option[0], option[1].invert ] }\n attributes = klass.collection.find_one(selector, opts)\n attributes ? Mongoid::Factory.from_db(klass, attributes) : nil\n end", "def last\n to_a.last\n end", "def last\n self[-1]\n end", "def get_last\n return @position\n end", "def last\n at(-1)\n end", "def getEndPoint()\n geoObject().lastPoint() ;\n end", "def last\n @range.last\n end", "def last\r\n self[-1]\r\n end", "def last\n self.slice(self.size - 1)\n end", "def last\n items.compact.last\n end", "def last\n @regions.sort.last\n end", "def last\n find(:first, :conditions => {}, :sort => [[:_id, :asc]])\n end", "def last\r\n\t\t@set.last\r\n\tend", "def last\n model.last\n end", "def last\n return sync { @last }\n end", "def last\n self.all.last\n end", "def last\n all.last\n end", "def last\n all.last\n end", "def last\n self[-1]\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 all.last\n end", "def last\n all.last\n end", "def last\n @ordered_elements.last\n end", "def last_ent\n ed.SelectLast.Value[0].ObjectId\n end", "def lastElement\n return @stk[@count]\n end", "def current_layer\n @layers.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 self.invert_order.all.first\n end", "def last\n all[all.size - 1]\n end", "def last\n out = nil\n\n each {|i| out = i }\n\n out\n end", "def last\n @items.last\n end", "def last\n @children.last\n end", "def last\n last = 0\n @vertices.each_index do |i|\n last = [get_max_from_neighbours(i), i, last].max\n end\n last\n end", "def last\n self[*Array.new(self.dim, -1)]\n end", "def last() end", "def last\n\t\t\t@last\n\t\tend", "def last\n all.last\n end", "def last_item\n @children[@items.last]\n end", "def last\n contents[contents.size - 1]\n end", "def get_last\n return nil if @head.nil?\n return get_last_helper(@head)\n end", "def last\n relationships = self.group_relations\n last_index = relationships.count - 1\n last_relationship = relationships.select { |child| child[:position] == last_index }.first\n return if last_relationship.nil?\n last_relationship.group\n end", "def get_last\n return @tail ? @tail.data : nil\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 head\n return @positions.last\n end", "def last(*args)\n find(:last, *args)\n end", "def last!\n last || raise_record_not_found_exception!\n end", "def geoObject()\n return @shape ;\n end", "def last\n @values.last\n end", "def last\n @enumerable.last\n end", "def last\n result ? all.last : limit(1).descending.all.last\n end", "def last\n end", "def last\n asc(:id).last\n end", "def final_floor\n floors.last\n end", "def geometry\n @feature\n end", "def last\n @last ||= FFI::MemoryPointer.new(:pointer)\n end", "def last\n @last ||= FFI::MemoryPointer.new(:pointer)\n end", "def geometry\n\t\tmongo_format[\"$box\"].flatten\n\tend", "def last(*args)\n find(:last, *args)\n end", "def last(*args)\n find(:last, *args)\n end", "def current\n @last\n end", "def last_child\n children.max_by { |x| x.position}\n end", "def get_last_pglist_data\n return @last_parsed_pglist_data\n end", "def realLast\n\t\tdc = (@first.col - @last.col).abs\n\t\tdr = (@first.row - @last.row).abs\n\t\tif dc < dr # then the selection vertical\n\t\t\treturn @cells[@last.row][@first.col]\n\t\telse # the selection is horizontal\n\t\t\treturn @cells[@first.row][@last.col]\n\t\tend\n\tend", "def select_last\n select(@data.index(@last_item.object) || 0)\n end", "def last(num = nil)\n return @all.last num if num\n @all.last\n end", "def last(options={})\r\n find(:last, options)\r\n end", "def last\n return each\n end", "def last\n graph.first_object(subject: last_subject, predicate: RDF.first)\n end", "def getLatest()\n return Gesellschafter.get(self.Mnr)\n end", "def get_last\n raise NotImplementedError, \"Please implement get_last\"\n end", "def last!\n last or raise RecordNotFound\n end", "def last; end", "def last; end", "def last; end", "def max_point\n # generate the bounding box if not already done\n bounding_box\n # return the max\n @max\n end", "def last\n order(:id).reverse.limit(1)\n end", "def last\n stack.last\n end", "def peek()\n @store.last\n end", "def last_position\n self.players.maximum(:position)\n end", "def last\n @tail\n end", "def head\n @positions.last\n end", "def head\n @positions.last\n end", "def geometry\n if (@file)\n img = ::Magick::Image::read(@file.file).first\n @geometry = [ img.columns, img.rows ]\n else\n @geometry = [0, 0]\n end\n end", "def view_last\n return @vassals[-1].view_last\n end", "def get_last\n return nil if @head.nil?\n return last_node.data\n end", "def last_item\n self.simple_acts_as_list_scope.last\n end", "def last\n @routes[-1]\n end", "def current\n all.last\n end" ]
[ "0.68261254", "0.6805249", "0.6681199", "0.6625544", "0.6611591", "0.66014403", "0.6566384", "0.6534133", "0.65032506", "0.6473712", "0.64014393", "0.63910794", "0.6388546", "0.63861334", "0.6358029", "0.6349516", "0.63397944", "0.6269032", "0.6242639", "0.61935025", "0.6162695", "0.6160989", "0.6158274", "0.6106904", "0.61063653", "0.61063653", "0.6103276", "0.6046861", "0.6046861", "0.6046861", "0.6046861", "0.6035408", "0.5999544", "0.5994537", "0.5972872", "0.59642434", "0.5963975", "0.59631395", "0.5960015", "0.59561485", "0.5949778", "0.5949151", "0.593291", "0.5919682", "0.5902732", "0.5900103", "0.5882907", "0.5858701", "0.58495677", "0.58377856", "0.5827316", "0.5812709", "0.57798386", "0.5776937", "0.5773978", "0.5753601", "0.5748383", "0.57434124", "0.57372034", "0.57321256", "0.5718704", "0.5688395", "0.568801", "0.56863093", "0.5682372", "0.5681879", "0.5681879", "0.567308", "0.56561124", "0.56561124", "0.56544256", "0.56481755", "0.5631288", "0.56294024", "0.5621355", "0.5618037", "0.5613153", "0.56072205", "0.56064856", "0.56053567", "0.5602804", "0.5591281", "0.5586156", "0.5586156", "0.5586156", "0.5571565", "0.5555709", "0.5542464", "0.55344677", "0.55203867", "0.55168146", "0.5513876", "0.5513876", "0.5506079", "0.55040956", "0.55040526", "0.55026025", "0.5454934", "0.5449884" ]
0.88753515
1
Returns a Hash suitable for converting to JSON.
def as_json(options = {}) self.collect do |p| p.to_jsonable options end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n validate!\n @hash ||= json\n end", "def hash_for_json(*)\n to_h\n end", "def to_hash\n to_a.hash\n end", "def for_json\n to_hash\n end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_hash; end", "def to_json\n JSON.generate to_hash\n end", "def to_hash\n @hash\n end", "def to_hash\n @hash\n end", "def to_json\n return Json.dump(to_hash)\n end", "def as_hash\n @hash\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_hash\n @hash\n end", "def to_h\n encode_with({})\n end", "def to_json\n JSON.generate(to_h)\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_hash\n @_hash_\n end", "def to_hash\n JSON.parse(properties).to_h\n end", "def to_json\r\n to_hash.to_json\r\n end", "def to_json\n return to_hash.to_json\n end", "def to_dict\n @hash\n end", "def to_h\n @hash\n end", "def to_h\n @hash\n end", "def hash\n to_a.hash\n end", "def to_hash() end", "def to_h\n JSON.parse(to_json, symbolize_names: true).with_indifferent_access\n end", "def to_json\n to_hash.to_json\n end", "def hash\n return to_s.hash\n end", "def to_hash\n {:hashes => @hashes}\n end", "def to_json(*)\n to_hash.to_json\n end", "def to_h\n to_hash\n end", "def to_hash\n Hash[to_a]\n end", "def hash\n { hash: @hash, hashType: @hash_type }\n end", "def to_hash\n object\n end", "def hash\n to_s.hash\n end", "def to_json\n return self.to_hash.to_json\n end", "def to_hash\n {}\n end", "def to_json\n to_h.to_json\n end", "def to_json\n to_h.to_json\n end", "def serialize\n JSON.generate(to_h)\n end", "def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end", "def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end", "def to_json\n Oj.dump(to_hash)\n end", "def hash\n to_s.hash\n end", "def hash\n to_s.hash\n end", "def to_hash\n data.to_hash\n end", "def to_hash\n data.to_hash\n end", "def to_hash\n @to_hash ||= JSON.parse(body)\n rescue\n @to_hash = {}\n end", "def to_json\n self.to_hash.to_json\n end", "def hash\r\n return to_s.hash\r\n end", "def as_json(*)\n to_h\n end", "def to_hash\n\t\t\trhash = {}\n\t\t\t@hash.each {|k,v|\n\t\t\t\tcase v\n\t\t\t\twhen ConfigStruct\n\t\t\t\t\trhash[k] = v.to_h\n\t\t\t\twhen NilClass, FalseClass, TrueClass, Numeric\n\t\t\t\t\t# No-op (can't dup)\n\t\t\t\t\trhash[k] = v\n\t\t\t\twhen Symbol\n\t\t\t\t\trhash[k] = v.to_s\n\t\t\t\telse\n\t\t\t\t\trhash[k] = v.dup\n\t\t\t\tend\n\t\t\t}\n\t\t\treturn rhash\n\t\tend", "def to_hash\n @data.to_hash\n end", "def to_h\n @hash.dup\n end", "def to_hash\n\t\tpure_hash = {}\n\t\t@hash.each do |info|\n\t\t\tpure_hash[info.key] = info.value\n\t\tend\n\t\tpure_hash\n\tend", "def to_hash( json )\n JSON.parse( json )\n end", "def to_h\n @hash.dup\n end", "def serialize\n JSON.dump(@hash)\n end", "def to_h\n JSON.parse(body)\n end", "def to_h\n # TODO: Use a Mash -- some keys are better off addressed as strings\n JSON.parse(raw_data, symbolize_names: true)\n end", "def serialize\n self.to_hash.to_json\n end", "def to_hash()\n @data\n end", "def to_hash\n body.to_hash\n end", "def to_h\n JSON.parse(@body, symbolize_names: true)\n end", "def as_json(options=nil)\n to_hash\n end", "def to_hash\n return self\n end", "def to_hash\n @hash.dup\n end", "def to_h\n @_hash.dup\n end", "def json\n JSON.pretty_generate(hash)\n end", "def to_json\n self.to_hash.to_json\n end", "def to_json\n self.to_hash.to_json\n end", "def to_hash\n @hash.dup\n end", "def to_hash\n Hash.instance_method(:to_hash).bind(self).call\n end", "def to_hash\n @data\n end", "def to_json\r\n hash = self.key_map()\r\n hash.to_json\r\n end", "def convert_it_to_hash_format(object)\n JSON.parse(object)\n end", "def to_json!\n self.to_hash.to_json\n end", "def to_hash\n @data.inject({}) do |ac,(k,v)|\n ac.merge! k => ((v.kind_of? self.class) ? v.to_hash : v)\n end\n end", "def jsonify_hash hash\n hash = (hash || {}).to_h\n return hash if hash.empty?\n JSON.parse(JSON.dump(hash))\n end", "def to_json\n JSON.pretty_generate(to_hash)\n end", "def to_json\n hash = self.key_map()\n hash.to_json\n end", "def to_json\n hash = self.key_map()\n hash.to_json\n end", "def as_json(_options = nil)\n to_h\n end", "def to_h; end", "def to_h; end", "def to_h; end" ]
[ "0.84804773", "0.82990366", "0.7984718", "0.79791546", "0.78604966", "0.78604966", "0.78604966", "0.78604966", "0.78604966", "0.78604966", "0.78534746", "0.78150487", "0.78150487", "0.7767882", "0.7763199", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.77063125", "0.7706257", "0.7684994", "0.76606226", "0.76254094", "0.76254094", "0.76034707", "0.7598556", "0.7598325", "0.75940377", "0.7588081", "0.7542235", "0.7542235", "0.7494364", "0.74810266", "0.7479655", "0.7469815", "0.746478", "0.7448893", "0.7448721", "0.7447291", "0.74250436", "0.74249816", "0.73886913", "0.73708403", "0.7364277", "0.73445445", "0.73317933", "0.73317933", "0.7324304", "0.7315822", "0.7315822", "0.73149216", "0.7314592", "0.7314592", "0.7300637", "0.7300637", "0.7300227", "0.729838", "0.7292426", "0.7259371", "0.7224477", "0.7222243", "0.72145146", "0.7212941", "0.7210956", "0.7202866", "0.720081", "0.7180578", "0.717767", "0.71694326", "0.7156001", "0.7146565", "0.71384186", "0.7137392", "0.7133741", "0.7106145", "0.71038145", "0.7103684", "0.70960665", "0.70960665", "0.7090582", "0.70901805", "0.7086916", "0.7069355", "0.70664096", "0.7052312", "0.70516735", "0.70475274", "0.7040016", "0.703833", "0.703833", "0.7032927", "0.7029935", "0.7029935", "0.7029935" ]
0.0
-1
Build some XmlMarkup for KML.
def to_kml(*args) self.collect do |p| p.to_kml(*args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n xm.instruct!\n xm.kml(:xmlns => 'http://www.opengis.net/kml/2.2'){\n objects.each { |o| o.render(xm) }\n }\n end", "def generatexml()\n merge(gadrgeneratexml: 'true')\n end", "def xml_builder\n return Builder::XmlMarkup.new(:indent=>2, :margin=>4)\n end", "def to_kml(options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n to_kml_file(options).render\n end", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n [:name, :visibility, :address].each do |a|\n xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil?\n end\n \n xm.description { xm.cdata!(description) } unless description.nil?\n xm.open(self.open) unless open.nil?\n \n xm.phoneNumber(phone_number) unless phone_number.nil?\n xm.styleUrl(style_url) unless style_url.nil?\n \n unless address_details.nil?\n xm.AddressDetails(:xmlns => \"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\") { address_details.render(xm) } \n end\n \n xm.Snippet(snippet.text, snippet.max_lines) unless snippet.nil?\n \n xm.LookAt { look_at.render(xm) } unless look_at.nil?\n xm.TimePrimitive { time_primitive.render(xm) } unless time_primitive.nil?\n xm.StyleSelector { style_selector.render(xm) } unless style_selector.nil?\n end", "def generatexml()\n merge(rvgeneratexml: 'true')\n end", "def kml_representation(options = {}) #:nodoc: \r\n result = \"<Point#{options[:id_attr]}>\\n\"\r\n result += options[:geom_data] if options[:geom_data]\r\n result += \"<coordinates>#{x},#{y}\"\r\n result += \",#{options[:fixed_z] || z ||0}\" if options[:allow_z]\r\n result += \"</coordinates>\\n\"\r\n result += \"</Point>\\n\"\r\n end", "def build_doc_from_node(node)\n kml =<<XXXX\n <kml xmlns=\"http://www.opengis.net/kml/2.2\"\n xmlns:gx=\"http://www.google.com/kml/ext/2.2\"\n xmlns:kml=\"http://www.opengis.net/kml/2.2\"\n xmlns:atom=\"http://www.w3.org/2005/Atom\"\n xmlns:xal=\"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\">\n #{node.to_kml.to_s}\n </kml>\nXXXX\n doc = XML::Document.string(kml)\nend", "def xml_builder_template(extra_opts = {})\n extra_attributes = extra_opts.fetch(:attributes, {})\n\n node_options = []\n node_child_template = \"\"\n if !self.default_content_path.nil?\n node_child_options = [\"\\':::builder_new_value:::\\'\"]\n node_child_template = \" { xml.#{self.default_content_path}( #{OM::XML.delimited_list(node_child_options)} ) }\"\n else\n node_options = [\"\\':::builder_new_value:::\\'\"]\n end\n if !self.attributes.nil?\n self.attributes.merge(extra_attributes).each_pair do |k,v|\n node_options << \"\\'#{k}\\'=>\\'#{v}\\'\" unless v == :none\n end\n end\n builder_ref = \"xml\"\n builder_method = self.path\n if builder_method.include?(\":\")\n builder_ref = \"xml['#{self.path[0..path.index(\":\")-1]}']\"\n builder_method = self.path[path.index(\":\")+1..-1]\n elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'\n builder_ref = \"xml['#{self.namespace_prefix}']\"\n elsif self.path.kind_of?(Hash) && self.path[:attribute]\n builder_method = \"@#{self.path[:attribute]}\"\n end\n if Nokogiri::XML::Builder.method_defined? builder_method.to_sym\n builder_method += \"_\"\n end\n template = \"#{builder_ref}.#{builder_method}( #{OM::XML.delimited_list(node_options)} )\" + node_child_template\n return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }\n end", "def build_xml(xml)\n check_configuration\n xml.DistributionConfig('xmlns' => \"http://cloudfront.amazonaws.com/doc/#{Cloudfront::API_VERSION}/\") {\n xml.CallerReference @caller_reference\n @aliases.build_xml(xml)\n xml.DefaultRootObject @default_root_object\n @origins_container.build_xml(xml)\n @default_cache_behavior.build_xml(xml)\n @behaviors.build_xml(xml)\n xml.Comment @comment\n @logging.build_xml(xml)\n xml.PriceClass @price_class\n xml.Enabled @enabled\n }\n end", "def build_xml(hash)\n result_xml = \"\"\n builder = Builder::XmlMarkup.new(:target=>result_xml,:indent=>4)\n builder.tag!(\"configuration\") { \n hash.each do|name,value|\n builder.property { |b| b.name(name); b.value(value) }\n end\n }\n file = File.new(@bigframe_home + \"/conf/bigframe-core.xml\", \"w\")\n if file\n file.syswrite(result_xml)\n end\n file.close()\n end", "def builder\n @builder ||= Builder::XmlMarkup.new(:indent => 2)\n end", "def markup\r\n return @markup if @markup \r\n @markup = Builder::XmlMarkup.new(:target => self.output, :indent => 1)\r\n end", "def xml_builder_template(extra_opts = {})\n extra_attributes = extra_opts.fetch(:attributes, {})\n\n node_options = []\n node_child_template = \"\"\n if !self.default_content_path.nil?\n node_child_options = [\"\\':::builder_new_value:::\\'\"]\n node_child_template = \" { xml.#{self.default_content_path}( #{OM::XML.delimited_list(node_child_options)} ) }\"\n else\n node_options = [\"\\':::builder_new_value:::\\'\"]\n end\n if !self.attributes.nil?\n self.attributes.merge(extra_attributes).each_pair do |k,v|\n node_options << \"\\'#{k}\\'=>\\'#{v}\\'\" unless v == :none\n end\n end\n\n builder_ref = if self.path.include?(\":\")\n \"xml['#{self.path[0..path.index(\":\")-1]}']\"\n elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'\n \"xml['#{self.namespace_prefix}']\"\n else\n \"xml\"\n end\n\n attribute = OM::XML.delimited_list(node_options)\n\n builder_method = if self.path.include?(\":\")\n \"#{self.path[path.index(\":\")+1..-1]}( #{attribute} )\"\n elsif self.path.include?(\".\")\n \"send(:\\\\\\\"#{self.path}\\\\\\\", #{attribute} )\"\n elsif self.path.kind_of?(Hash) && self.path[:attribute]\n \"@#{self.path[:attribute]}( #{OM::XML.delimited_list(node_options)} )\"\n elsif Nokogiri::XML::Builder.method_defined? self.path.to_sym\n \"#{self.path}_( #{OM::XML.delimited_list(node_options)} )\"\n else\n \"#{self.path}( #{OM::XML.delimited_list(node_options)} )\"\n end\n template = \"#{builder_ref}.#{builder_method}#{node_child_template}\"\n return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }\n end", "def kml_representation(options = {})\r\n result = \"<Polygon#{options[:id_attr]}>\\n\"\r\n result += options[:geom_data] if options[:geom_data]\r\n rings.each_with_index do |ring, i|\r\n if i == 0\r\n boundary = \"outerBoundaryIs\"\r\n else\r\n boundary = \"innerBoundaryIs\"\r\n end\r\n result += \"<#{boundary}><LinearRing><coordinates>\\n\"\r\n result += ring.kml_poslist(options)\r\n result += \"\\n</coordinates></LinearRing></#{boundary}>\\n\"\r\n end\r\n result += \"</Polygon>\\n\"\r\n end", "def kml_representation(options = {}) #:nodoc:\n out = \"<Point#{options[:id_attr]}>\\n\"\n out += options[:geom_data] if options[:geom_data]\n out += \"<coordinates>#{x},#{y}\"\n out += \",#{options[:fixed_z] || z || 0}\" if options[:allow_z]\n out += \"</coordinates>\\n\"\n out + \"</Point>\\n\"\n end", "def generate_xml\n values = {\n :charset => @options.charset,\n :files => gen_into(@files),\n :classes => gen_into(@classes),\n :title => CGI.escapeHTML(@options.title),\n }\n\n template = RDoc::TemplatePage.new @template::ONE_PAGE\n\n opfile = if @options.op_name then\n open @options.op_name, 'w'\n else\n $stdout\n end\n template.write_html_on(opfile, values)\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def build_xml\n raise NotImplementedError, \"Override build_xml in subclass\"\n end", "def render_sections_xml(sectionslist)\n builder do |xml|\n xml.instruct!\n xml.sections do\n sectionslist.each do |section|\n xml.section do\n xml.userId section.userId\n xml.title section.title\n xml.shows section.shows\n xml.actors section.actors\n end\n end\n end\n end\nend", "def build\r\n builder = Builder::XmlMarkup.new\r\n builder.instruct!(:xml, encoding: 'UTF-8')\r\n builder.tag! :env, :Envelope, namespaces do |env|\r\n env.tag!(:env, :Header) do |env_header|\r\n create_header(env_header)\r\n end\r\n env.tag!(:env, :Body) do |env_body|\r\n create_body(env_body)\r\n end\r\n end\r\n end", "def gen_xml \n @xml = Builder::XmlMarkup.new\n @parent_categories = CptCategory.find(:all, :conditions => [\"parent_id = 1002795\"])\n render :layout => false\n end", "def as_kml(options = {})\r\n id_attr = \"\"\r\n id_attr = \" id=\\\"#{options[:id]}\\\"\" if options[:id]\r\n\r\n geom_data = \"\"\r\n geom_data += \"<extrude>#{options[:extrude]}</extrude>\\n\" if options[:extrude]\r\n geom_data += \"<tesselate>#{options[:tesselate]}</tesselate>\\n\" if options[:tesselate]\r\n geom_data += \"<altitudeMode>#{options[:altitude_mode]}</altitudeMode>\\n\" if options[:altitude_mode]\r\n \r\n allow_z = (with_z || !options[:altitude].nil? )&& (!options[:altitude_mode].nil?) && options[:atitude_mode] != \"clampToGround\"\r\n fixed_z = options[:altitude]\r\n \r\n kml_representation(options.merge(:id_attr => id_attr, :geom_data => geom_data, :allow_z => allow_z, :fixed_z => fixed_z))\r\n end", "def generate_xml\n values = {\n 'charset' => @options.charset,\n 'files' => gen_into(@files),\n 'classes' => gen_into(@classes),\n 'title' => CGI.escapeHTML(@options.title),\n }\n\n # this method is defined in the template file\n write_extra_pages if defined? write_extra_pages\n\n template = RDoc::TemplatePage.new @template::ONE_PAGE\n\n if @options.op_name\n opfile = open @options.op_name, 'w'\n else\n opfile = $stdout\n end\n template.write_html_on(opfile, values)\n end", "def generate_xml\n values = {\n :charset => @options.charset,\n :files => gen_into(@files),\n :classes => gen_into(@classes)\n }\n\n template = RDoc::TemplatePage.new @template::ONE_PAGE\n\n if @options.op_name\n opfile = File.open(@options.op_name, \"w\")\n else\n opfile = $stdout\n end\n template.write_html_on(opfile, values)\n end", "def build_xml(builder)\n super(builder)\n builder.ValidNetwork { |b| valid_network.build_xml(b) } if valid_network\n builder.Model { |b| model.build_xml(b) } if model\n builder.Manufacturer { |b| manufacturer.build_xml(b) } if manufacturer\n end", "def xml; end", "def initialize view\r\n @view = view\r\n @output = ''\r\n @xml = Builder::XmlMarkup.new :indent => 2, :target => @output\r\n end", "def kml_representation(options = {}) #:nodoc: \r\n result = \"<MultiGeometry#{options[:id_attr]}>\\n\"\r\n options[:id_attr] = \"\" #the subgeometries do not have an ID\r\n each do |geometry|\r\n result += geometry.kml_representation(options)\r\n end\r\n result += \"</MultiGeometry>\\n\"\r\n end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_xml(opt={})\n to_markup(opt).target!\n end", "def to_kml(file_options = {}, placemark_options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n to_kml_file(file_options, placemark_options).render\n end", "def to_kml(file_options = {}, placemark_options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n to_kml_file(file_options, placemark_options).render\n end", "def generate_content_ncx(content,path)\n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n class_types_map = {\"Subject\" => \"course\", \"ContentYear\" => \"academic-class\", \"Subject\" => \"subject\", \"Chapter\" => \"chapter\", \"Topic\" => \"topic\", \"SubTopic\" => \"subtopic\"}\n xml.navMap do\n xml.navPoint(:id=>\"Curriculum\", :class=>\"curriculum\") do\n xml.content(:src=>\"curriculum\")\n xml.navPoint(:id=>\"Content\",:class=>\"content\")do\n xml.content(:src=>\"content\")\n\n ## The code for generating the inside xml string\n content_xml_string = ''\n parents = content.parents.reverse\n ## Generating the content node\n parents.each do |parent|\n content_data = Content.find(parent[\"ancestor\"])\n ## Getting the class for the current node\n node_class = class_types_map[content_data.type]\n ## Getting the src for the current node\n node_src = ''\n if content_data.type == 'Board'\n node_src = content_data.code+'_'+content.assets.first.publisher_id.to_s\n elsif content_data.type == 'ContentYear' or content_data.type == 'Subject'\n node_src = content_data.code\n else\n node_src = content.assets.first.src\n end\n # Reset the nav node and the content node\n nav_node = ''\n content_node = ''\n\n # Generating the nav node\n nav_node = nav_node+\"<navPoint id='#{content_data.name}' class='#{node_class}' >\"\n\n # Generating the content node\n content_node = content_node+\"<content src='#{node_src}' />\"\n\n ## Appending the nav node and the content node to the main xml\n content_xml_string = content_xml_string+nav_node+content_node\n end\n ## Appending the navpoint end tags to the string\n parents.length.times do\n content_xml_string = content_xml_string + \"</navPoint>\"\n end\n\n ## End of code for generating the xml string\n xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(content_xml_string)\n end\n end\n end\n end\n xml_string = @builder.to_xml.to_s\n file = File.new(path+\"/\"+\"index.ncx\", \"w+\")\n File.open(file,'w') do |f|\n f.write(xml_string.to_s.gsub( \"\\n\", \"\" ).gsub(/>[ ]*</,'><'))\n end\n create_zip(\"content_#{content.id}\",path)\n end", "def to_kml(*args)\n xml, options = Geos::Helper.xml_options(*args)\n xml.Point(:id => options[:id]) do\n xml.extrude(options[:extrude]) if options[:extrude]\n xml.altitudeMode(Geos::Helper.camelize(options[:altitude_mode])) if options[:altitude_mode]\n xml.coordinates(self.to_a.join(','))\n end\n end", "def render_xml\n @xml = Builder::XmlMarkup.new\n @xml.gauge do\n @xml.license( @license ) unless @license.nil?\n render_extra_components \n render_components\n end\n @xml.to_s.gsub( /<to_s\\/>/, '' ) \n end", "def to_xml\n builder.target!\n end", "def to_rootless_xml(options = {})\n require \"active_support/builder\" unless defined?(Builder)\n\n options = options.dup\n options[:indent] ||= 2\n options[:builder] ||= Builder::XmlMarkup.new(indent: options[:indent])\n\n builder = options[:builder]\n builder.instruct! unless options.delete(:skip_instruct)\n\n each { |key, value| ActiveSupport::XmlMini.to_tag(key, value, options) }\n yield builder if block_given?\n builder.target! \n end", "def to_kml_file(options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n options = apply_default_file_options(options)\n\n style = 'kmlfile-style-id'\n kml_flights = @flights.select(&:to_kml?)\n marks = kml_flights.each_with_object({ :style_url => \"##{style}\" }).map(&:to_kml_placemark)\n\n kml = KMLFile.new\n kml.objects << KML::Document.new(\n :name => options[:name],\n :description => options[:description],\n :styles => [\n KML::Style.new(\n :id => style,\n :line_style => KML::LineStyle.new(:color => '7F00FFFF', :width => 4),\n :poly_style => KML::PolyStyle.new(:color => '7F00FF00')\n )\n ],\n :features => marks\n )\n kml\n end", "def json2kml(js, name=\"\")\n res = JSON.parse js\n\n kml = \"\"\n\n kml += '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n kml += \"\\n\"\n kml += '<kml xmlns=\"http://earth.google.com/kml/2.0\">'\n kml += \"\\n\"\n kml += \"<Folder><name>foaftown tester #{name}</name>\\n\"\n name_cache = {}\n\n res[\"results\"][\"bindings\"].each do |pic| \n id = esc pic['id']['value']\n owner = esc pic['owner']['value']\n secret = esc pic['secret']['value']\n server = esc pic['server']['value']\n title = esc pic['title']['value']\n lat = esc pic['latitude']['value'] if pic['latitude']\n lon = pic['longitude']['value'] if pic['longitude']\n acc = pic['accuracy']['value'] if pic['accuracy']\n # See http://www.flickr.com/services/api/misc.urls.html\n s_url = \"http://static.flickr.com/\" + server + \"/\" + id + \"_\" + secret + \"_s.jpg\"\n m_url = \"http://static.flickr.com/\" + server + \"/\" + id + \"_\" + secret + \"_m.jpg\"\n image_url = \"http://static.flickr.com/\" + server + \"/\" + id + \"_\" + secret + \".jpg\"\n img_page = \"http://www.flickr.com/photos/\" + owner +\"/\" + id \n # puts \"#{title} #{id} #{lat} #{lon} #{s_url} #{img_page}\"\n STDERR.puts(\"Making KML for: #{title} #{id} #{lat} #{lon} #{s_url} #{img_page}\")\n kml += \"<Folder>\n <name>#{title}</name>\n <visibility>1</visibility>\n <Placemark>\n <description><![CDATA[ \n\n <p>\n\t<a href='#{img_page}'><img alt='#{title}' \n\t\t\twidth='240' src='#{m_url}' /></a> <br />\n\tby <a href='http://www.flickr.com/photos/#{owner}/'>#{nameFromID(owner,name_cache)}</a>\n <br /><small>at lat:#{lat} lon:#{lon} map level: #{acc}</small></p>\n\t]]></description>\n <name> #{title} </name>\n <View>\n <longitude>#{lon}</longitude>\n <latitude>#{lat}</latitude>\n\t <range>0</range>\n\t <tilt>30</tilt>\n <heading>0</heading>\n </View>\n <visibility>1</visibility>\n <styleUrl>root://styleMaps#default?iconId=0x307</styleUrl>\n <Style>\n <icon>#{m_url}</icon>\n </Style>\n <Point>\n <coordinates>#{lon},#{lat},0</coordinates>\n </Point>\n </Placemark>\n </Folder>\\n\"\n end\n kml += \"</Folder>\\n\";\n kml += \"</kml>\\n\\n\";\n return kml\nend", "def to_xml(builder=nil)\n builder = ::Builder::XmlMarkup.new if builder.nil?\n builder.sitemap do\n builder.loc self[:loc]\n builder.lastmod w3c_date(self[:lastmod]) if self[:lastmod]\n end\n builder << '' # force to string\n end", "def print_placemark\n #Links are not processed\n# if @@last_type == Link then return end\n #An icon showing the start point and description\n ret = \"<Placemark>\"\n ret << \"<name>#{@@step.to_s.rjust(2,'0')}</name>\"\n ret << \"<description>\"\n #Different rendering for Streets and Triphops\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"#{@@init_time.strftime(\"%H:%M\")}. \"\n else\n ret << \"Departure: #{@@init_time.strftime(\"%H:%M\")}. \"\n ret << \"Arrival: #{@@end_time.strftime(\"%H:%M\")}. \"\n end\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</description>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkIcon</styleUrl>\"\n else\n ret << \"<styleUrl>#busIcon</styleUrl>\"\n end\n ret << \"<Point>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords[0]}\"\n ret << \"</coordinates>\"\n ret << \"</Point>\"\n ret << \"</Placemark>\"\n\n #A polyline showing the path\n ret << \"<Placemark>\"\n ret << \"<name>\"\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</name>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkPath</styleUrl>\"\n else\n ret << \"<styleUrl>#busPath</styleUrl>\"\n end\n ret << \"<LineString>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords.join(' ')}\"\n ret << \"</coordinates>\"\n ret << \"</LineString>\"\n ret << \"</Placemark>\"\n end", "def to_xml \n result = String.new\n builder = Builder::XmlMarkup.new(:target => result, :indent => 2)\n \n attributes = {}\n instance_variables.each do |iv|\n attributes[iv.split(\"@\")[1]] = normalize instance_variable_get(iv)\n end\n \n builder.tag!(\"category\", attributes)\n \n result\n end", "def to_xml\n builder = Builder::XmlMarkup.new(:indent=>2)\n builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'\n xml = builder.items{ self.each{|x| builder.item(x) } }\n xml\n end", "def to_xml\n inner = String.new\n inner_builder = Builder::XmlMarkup.new(:target => inner, :indent => 2)\n \n # create the XML for the inner \"categories\" element(s)\n inner_builder.tag!(\"categories\") do\n categories.each do |category|\n inner_builder << category.to_xml\n end\n end\n \n # create the XML for the inner \"dataset\" element(s)\n inner_builder.tag!(\"dataset\") do\n dataSets.each do |dataset|\n inner_builder << dataset.to_xml\n end\n end\n \n # create the XML for this chart, including attributes defined in the Base chart type\n result = super(nil, inner)\n \n result\n end", "def build_root\n root << document_properties = XML::Node.new('DocumentProperties')\n document_properties['xmlns'] = 'urn:schemas-microsoft-com:office:office'\n\n document_properties << author = XML::Node.new('Author')\n author << 'Scarlet'\n document_properties << last_author = XML::Node.new('LastAuthor')\n last_author << 'Scarlet'\n document_properties << version = XML::Node.new('Version')\n version << '12.256'\n\n root << office_document_settings = XML::Node.new('OfficeDocumentSettings')\n office_document_settings['xmlns'] = 'urn:schemas-microsoft-com:office:office'\n office_document_settings << XML::Node.new('AllowPNG')\n\n root << excel_workbook = XML::Node.new('ExcelWorkbook')\n excel_workbook['xmlns'] = 'urn:schemas-microsoft-com:office:excel'\n\n excel_workbook << window_height = XML::Node.new('WindowHeight', '20260')\n excel_workbook << window_width = XML::Node.new('WindowWidth', '29600')\n excel_workbook << window_top_x = XML::Node.new('WindowTopX', '3440')\n excel_workbook << window_top_y = XML::Node.new('WindowTopY', '-80')\n excel_workbook << XML::Node.new('Date1904')\n excel_workbook << XML::Node.new('ProtectStructure', 'False')\n excel_workbook << XML::Node.new('ProtectWindows', 'False')\n\n root << styles = XML::Node.new('Styles')\n styles << style = XML::Node.new('Style')\n style['ss:ID'] = 'Default'\n style['ss:Name'] = 'Normal'\n style << alignment = XML::Node.new('Alignment')\n alignment['ss:Vertical'] = 'Bottom'\n style << XML::Node.new('Borders')\n style << font = XML::Node.new('Font')\n font['ss:FontName'] = 'Verdana'\n style << XML::Node.new('Interior')\n style << XML::Node.new('NumberFormat')\n style << XML::Node.new('Protection')\n end", "def xml_for(name, tags_and_values)\n xml = Builder::XmlMarkup.new\n xml.instruct!\n xml.tag!(javaize_key(name), 'xmlns' => XML_NAMESPACE, 'version' => API_VERSION) { xml_from_array(xml, tags_and_values) }\n xml.target!\n end", "def build_kml_str(places, placeHash)\n ret_str = \"\"\n places.each do |cur|\n if cur =~ /<LineStyle id=\"ls_(.+)\"><color>FFffffff<\\/color>/\n style = getStyle($1, placeHash)\n output = cur.sub(/<styleUrl>.+<\\/styleUrl>/, \"<styleUrl>##{style}</styleUrl>\")\n output = output.sub(/<Placemark id=\".+\">/, \"<Placemark>\")\n output = output.sub(/<LineStyle id=\".+\"><color>FFffffff<\\/color>\\n<\\/LineStyle>/, \"\")\n output = output.sub(/<Point id=\".+\">/, \"<Point>\")\n ret_str << \"<Placemark#{output}\"\n else\n ret_str << \"<Placemark#{cur}\"\n end\n end\n ret_str\n end", "def to_opml\n\t\tdoc = Nokogiri::XML::DocumentFragment.parse \"\"\n\t\tNokogiri::XML::Builder.with(doc) { |xml|\n\t\t\txml.outline(:title => self.title, :text => self.title) {\n\t\t\t\tself.feeds.each do |feed|\n\t\t\t\t\txml.__send__ :insert, feed.to_opml\n\t\t\t\tend\n\t\t\t}\n\t\t}\n\t\treturn doc\n\tend", "def build_xml(builder)\n super(builder)\n builder.Value { |b| b.Text self.data }\n builder.UnitType { |b| eng_unit_type.build_xml(b) } unless eng_unit_type.blank?\n end", "def to_kml_file(file_options = {}, placemark_options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n options = apply_default_file_options(file_options)\n\n kml = KMLFile.new\n kml.objects << KML::Document.new(\n :name => options[:name],\n :description => options[:description],\n :styles => [\n KML::Style.new(\n :id => options[:style_id],\n :line_style => KML::LineStyle.new(:color => '7F00FFFF', :width => 4),\n :poly_style => KML::PolyStyle.new(:color => '7F00FF00')\n )\n ],\n :features => [ to_kml_placemark(placemark_options) ]\n )\n kml\n end", "def to_kml_file(file_options = {}, placemark_options = {})\n raise RuntimeError, 'No coordinates available for KML generation' unless to_kml?\n options = apply_default_file_options(file_options)\n\n kml = KMLFile.new\n kml.objects << KML::Document.new(\n :name => options[:name],\n :description => options[:description],\n :styles => [\n KML::Style.new(\n :id => options[:style_id],\n :line_style => KML::LineStyle.new(:color => '7F00FFFF', :width => 4),\n :poly_style => KML::PolyStyle.new(:color => '7F00FF00')\n )\n ],\n :features => [ to_kml_placemark(placemark_options) ]\n )\n kml\n end", "def build(xml, key, value)\n case value\n when Hash\n xml.tag!(key.to_s){|t|\n value.each { |k, v|\n build(t, k, v)\n }\n }\n when Array\n value.each {|v|\n build(xml, key, v)\n }\n else\n xml_leaf(xml, key, value)\n end\n end", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def build_xml(builder)\n super(builder)\n object_data.each do |d|\n builder.Attribute do |b|\n d.build_xml(b)\n end\n end\n builder.DefaultUnitType { |b| default_eng_unit_type.build_xml(b) }\n end", "def generate_markup\n\t\tordering = get_ordering\n\t\tmarkup_text = \"\"\n\n\t\tordering.each do |obj_place|\n\n\t\t\telement = obj_place.model.constantize.find(obj_place.id) #find the element referred to in the objectplace\t\n\t\t\twhitespace = \"\"\n\t\t\ttype_char = \"\"\n\t\t\tinfo = \"\"\n\n\t\t\t#get the whitespace, which is three spaces for every depth\n\t\t\t(element.depth*3).times do\n\t\t\t\twhitespace << \" \"\n\t\t\tend\n\n\t\t\t#if it's a node, gets its category and title, builds a string with a comma\n\t\t\tif element.is_a?(Node)\n\t\t\t\ttype_char = \".\"\n\t\t\t\tcategory_text = \"\"\n\t\t\t\tif element.category.name != \"\"\n\t\t\t\t\tcategory_text = element.category.name.capitalize + \",\"\n\t\t\t\tend\n\t\t\t\ttitle = element.title\n\t\t\t\tinfo = category_text + title\n\n\t\t\t#if it's a note, gets its body\n\t\t\telsif element.is_a?(Note)\n\t\t\t\ttype_char = \"-\"\n\t\t\t\tbody = element.body\n\t\t\t\tinfo = body\n\n\t\t\t#if it's a LinkCollection, builds the string with the link's child names comma separated\n\t\t\telsif element.is_a?(LinkCollection)\n\t\t\t\ttype_char = \":\"\n\t\t\t\tlinks_text = \"\"\n\t\t\t\telement.links.each do |link|\n\t\t\t\t\tif link.child != nil\n\t\t\t\t\t\tlinks_text << link.child.title + \" , \"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tif links_text != \"\"\n\t\t\t\t\tlinks_text = links_text[0..-4] #removes the trailing spaces and comma\n\t\t\t\tend\n\t\t\t\tinfo = links_text\n\t\t\telsif element.is_a?(PlaceHolder) #it's a place_holder\n\t\t\t\twhitespace = \"\"\n\t\t\t\ttype_char = \"\"\n\t\t\t\tinfo = element.text\n\t\t\tend\n\t\t\tmarkup_text << whitespace + type_char + info + \"\\r\\n\"\n\t\tend\n\t\treturn markup_text\n\tend", "def build_xml(builder)\n super(builder)\n builder.ValidNetwork {|b| segment_config_network.build_xml(b) } if segment_config_network\n asset_on_segment_historys.each do |aosh|\n builder.AssetOnSegmentHistory {|b| aosh.build_xml(b)} if aosh\n end\n meas_locations.each do |m|\n builder.MeasurementLocation do |b|\n m.build_xml(b)\n end\n end\n end", "def as_kml(options = {})\r\n geom_data = \"\"\r\n geom_data = \"<altitudeMode>#{options[:altitude_mode]}</altitudeMode>\\n\" if options[:altitude_mode]\r\n \r\n allow_z = with_z && (!options[:altitude_mode].nil?) && options[:atitude_mode] != \"clampToGround\"\r\n \r\n kml_representation(options.merge(:geom_data => geom_data,:allow_z => allow_z))\r\n end", "def to_xml(xml_builder = Builder::XmlMarkup.new)\n xml_builder.tag!('Group') do\n %w(Name Handle GroupType Explicit).each do |tag_name|\n xml_builder.tag!(tag_name, self.edits[tag_name]) if self.edits[tag_name]\n end\n \n self.tracks.to_xml(xml_builder)\n self.permissions.to_xml(xml_builder)\n \n %w(AllowSubscription).each do |tag_name|\n xml_builder.tag!(tag_name, self.edits[tag_name]) if self.edits[tag_name]\n end\n self.external_feed.to_xml(xml_builder) if self.external_feed\n end\n end", "def to_xml()\n \t el = REXML::Element.new('mp')\n \t el.add_attribute(\"name\", \"#{@mdef}\")\n \t if @opts.key?(:interval)\n \t el.add_attribute(\"interval\", \"#{@opts[:interval]}\")\n elsif @opts.key?(:samples)\n \t el.add_attribute(\"samples\", \"#{@opts[:samples]}\")\n end\n \t if @filters.size > 0\n @filters.each { |f|\n el.add_element(f.to_xml)\n \t }\n \t end\n \t return el\n \tend", "def build_xml( result )\n xml = ::Builder::XmlMarkup.new\n \n xml.ProcessResponse do \n xml.PxPayUserId ::Pxpay::Base.pxpay_user_id\n xml.PxPayKey ::Pxpay::Base.pxpay_key\n xml.Response result\n end\n end", "def to_markup(xml={})\n if Hash === xml\n opt = { :indent => 2 }.merge(xml)\n xml = Builder::XmlMarkup.new(opt)\n xml.instruct!\n end\n\n if matches.empty?\n xml.match(debug_attrs)\n else\n xml.match(debug_attrs) do\n matches.each {|m| m.to_markup(xml) }\n end\n end\n\n xml\n end", "def assemble_xml_file # :nodoc:\n write_xml_declaration do\n # Write the c:chartSpace element.\n write_chart_space do\n # Write the c:lang element.\n write_lang\n # Write the c:style element.\n write_style\n # Write the c:protection element.\n write_protection\n # Write the c:chart element.\n write_chart\n # Write the c:spPr element for the chartarea formatting.\n write_sp_pr(@chartarea)\n # Write the c:printSettings element.\n write_print_settings if @embedded && @embedded != 0\n end\n end\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.UploadImagesRequest(xmlns: \"http://fedex.com/ws/uploaddocument/v#{Fedex::UPLOAD_IMAGES_API_VERSION}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_images(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def xml\n xml = Builder::XmlMarkup.new(indent: 2)\n\n xml.instruct! :xml, encoding: 'UTF-8'\n xml.rss version: '2.0' do |rss|\n rss.channel do |channel|\n channel.title 'Haxpressen'\n\n last_ten_days.each do |day|\n summary = summary_for day\n\n if summary.present?\n channel.item do |item|\n item.title \"Sammanfattning för #{day}\"\n item.pubDate day\n item.description summary\n end\n end\n end\n end\n end\n end", "def xml_builder\n @xml_builder ||= begin\n @options[:indent] ||= 2\n builder = @options[:builder] ||= ::Builder::XmlMarkup.new(:indent => 2)\n unless @options[:skip_instruct]\n builder.instruct!\n @options[:skip_instruct] = true\n end\n builder\n end\n end", "def render\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')\n xml.urlset(XmlSitemap::INDEX_SCHEMA_OPTIONS) { |s|\n @maps.each do |item|\n s.sitemap do |m|\n m.loc item[:loc]\n m.lastmod item[:lastmod]\n end\n end\n }.to_s\n end", "def build_xml(feed_type=(self.feed_type or \"atom\"), feed_version=nil,\n xml_builder=Builder::XmlMarkup.new(\n :indent => 2, :escape_attrs => false))\n \n if self.find_node(\"access:restriction/@relationship\").to_s == \"deny\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n elsif self.find_node(\"@indexing:index\").to_s == \"no\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n end\n \n self.full_parse()\n \n xml_builder.instruct! :xml, :version => \"1.0\",\n :encoding => (self.configurations[:output_encoding] or \"utf-8\")\n if feed_type.nil?\n feed_type = self.feed_type\n end\n if feed_version.nil?\n feed_version = self.feed_version\n end\n if feed_type == \"rss\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n elsif feed_type == \"atom\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n end\n if feed_type == \"rss\" &&\n (feed_version == 0.9 || feed_version == 1.0 || feed_version == 1.1)\n # RDF-based rss format\n return xml_builder.tag!(\"rdf:RDF\",\n \"xmlns\" => FEED_TOOLS_NAMESPACES['rss10'],\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:syn\" => FEED_TOOLS_NAMESPACES['syn'],\n \"xmlns:admin\" => FEED_TOOLS_NAMESPACES['admin'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n channel_attributes = {}\n unless self.link.nil?\n channel_attributes[\"rdf:about\"] =\n FeedTools::HtmlHelper.escape_entities(self.link)\n end\n xml_builder.channel(channel_attributes) do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n else\n xml_builder.title\n end\n unless self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n unless images.blank?\n xml_builder.image(\"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(\n images.first.url))\n end\n unless description.nil? || description == \"\"\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.language.blank?\n xml_builder.tag!(\"dc:language\", self.language)\n end\n unless self.rights.blank?\n xml_builder.tag!(\"dc:rights\", self.rights)\n end\n xml_builder.tag!(\"syn:updatePeriod\", \"hourly\")\n xml_builder.tag!(\"syn:updateFrequency\",\n (self.time_to_live / 1.hour).to_s)\n xml_builder.tag!(\"syn:updateBase\", Time.mktime(1970).iso8601)\n xml_builder.items do\n xml_builder.tag!(\"rdf:Seq\") do\n unless items.nil?\n for item in items\n if item.link.nil?\n raise \"Cannot generate an rdf-based feed with a nil \" +\n \"item link field.\"\n end\n xml_builder.tag!(\"rdf:li\", \"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(item.link))\n end\n end\n end\n end\n xml_builder.tag!(\n \"admin:generatorAgent\",\n \"rdf:resource\" => self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n end\n unless self.images.blank?\n best_image = nil\n for image in self.images\n if image.link != nil\n best_image = image\n break\n end\n end\n best_image = self.images.first if best_image.nil?\n xml_builder.image(\"rdf:about\" =>\n FeedTools::HtmlHelper.escape_entities(best_image.url)) do\n if !best_image.title.blank?\n xml_builder.title(best_image.title)\n elsif !self.title.blank?\n xml_builder.title(self.title)\n else\n xml_builder.title\n end\n unless best_image.url.blank?\n xml_builder.url(best_image.url)\n end\n if !best_image.link.blank?\n xml_builder.link(best_image.link)\n elsif !self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n end\n end\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n elsif feed_type == \"rss\"\n # normal rss format\n return xml_builder.rss(\"version\" => \"2.0\",\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:trackback\" => FEED_TOOLS_NAMESPACES['trackback'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n xml_builder.channel do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n end\n unless self.link.blank?\n xml_builder.link(link)\n end\n unless self.description.blank?\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.author.email.blank?\n xml_builder.managingEditor(self.author.email)\n end\n unless self.publisher.email.blank?\n xml_builder.webMaster(self.publisher.email)\n end\n unless self.published.blank?\n xml_builder.pubDate(self.published.rfc822)\n end\n unless self.updated.blank?\n xml_builder.lastBuildDate(self.updated.rfc822)\n end\n unless self.copyright.blank?\n xml_builder.copyright(self.copyright)\n end\n unless self.language.blank?\n xml_builder.language(self.language)\n end\n xml_builder.ttl((time_to_live / 1.minute).to_s)\n xml_builder.generator(\n self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n end\n elsif feed_type == \"atom\" && feed_version == 0.3\n raise \"Atom 0.3 is obsolete.\"\n elsif feed_type == \"atom\" && feed_version == 1.0\n # normal atom format\n return xml_builder.feed(\"xmlns\" => FEED_TOOLS_NAMESPACES['atom10'],\n \"xml:lang\" => language) do\n unless title.blank?\n xml_builder.title(title,\n \"type\" => \"html\")\n end\n xml_builder.author do\n unless self.author.nil? || self.author.name.nil?\n xml_builder.name(self.author.name)\n else\n xml_builder.name(\"n/a\")\n end\n unless self.author.nil? || self.author.email.nil?\n xml_builder.email(self.author.email)\n end\n unless self.author.nil? || self.author.url.nil?\n xml_builder.uri(self.author.url)\n end\n end\n unless self.href.blank?\n xml_builder.link(\"href\" => self.href,\n \"rel\" => \"self\",\n \"type\" => \"application/atom+xml\")\n end\n unless self.link.blank?\n xml_builder.link(\n \"href\" =>\n FeedTools::HtmlHelper.escape_entities(self.link),\n \"rel\" => \"alternate\")\n end\n unless self.subtitle.blank?\n xml_builder.subtitle(self.subtitle,\n \"type\" => \"html\")\n end\n if self.updated != nil\n xml_builder.updated(self.updated.iso8601)\n elsif self.time != nil\n # Not technically correct, but a heck of a lot better\n # than the Time.now fall-back.\n xml_builder.updated(self.time.iso8601)\n else\n xml_builder.updated(Time.now.gmtime.iso8601)\n end\n unless self.rights.blank?\n xml_builder.rights(self.rights)\n end\n xml_builder.generator(self.configurations[:generator_name] +\n \" - \" + self.configurations[:generator_href])\n if self.id != nil\n unless FeedTools::UriHelper.is_uri? self.id\n if self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n else\n raise \"The unique id must be a valid URI.\"\n end\n else\n xml_builder.id(self.id)\n end\n elsif self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n elsif self.url != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.url))\n else\n raise \"Cannot build feed, missing feed unique id.\"\n end\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n else\n raise \"Unsupported feed format/version.\"\n end\n end", "def emitIzPackXML(xm)\n # raise \"xm must be an Builder::XmlMarkup object, but is #{xm.class}\" if xm.class != Builder::XmlMarkup\n xm.pack(@attributes) {\n xm.description(@description)\n @files.each{ |src, dest| xm.singlefile('src'=> src, 'target' =>dest) }\n }\n end", "def kml\n return [] unless snib_id.present?\n\n # Catch the response\n begin\n response = RestClient.get \"#{CONFIG.snib_url}&rd=#{snib_reino}&id=#{snib_id}\", :timeout => 5, :open_timeout => 5\n return [] unless response.present?\n rescue => e\n puts \"\\t\\t#{e.response}\"\n return []\n end\n\n data = JSON.parse(response)\n colectas = data['colectas']\n return [] unless colectas.count > 0\n cadenas = []\n\n colectas.each do |col|\n datos = col['properties']\n\n # Para registros solo de Mexico\n #next unless datos['nombrepaismapa'] == 'MEXICO'\n\n cadena = Hash.new\n h = HTMLEntities.new # Para codificar el html y no marque error en el KML\n\n # Los numere para poder armar los datos en el orden deseado\n cadena['01_nombre_cientifico'] = h.encode(especie.nombre_cientifico)\n cadena['02_nombre_comun'] = h.encode(especie.nom_com_prin(true))\n cadena['03_localidad'] = h.encode(datos['localidad'])\n cadena['04_municipio'] = h.encode(datos['nombremunicipiomapa'])\n cadena['05_estado'] = h.encode(datos['nombreestadomapa'])\n cadena['06_pais'] = h.encode(datos['nombrepaismapa'])\n\n # Para que no se vea feo MEXICO con mayusculas\n if cadena['06_pais'] == 'MEXICO'\n cadena['06_pais'] = 'México'\n end\n\n # Pone la fecha en formato tiemestamp\n if datos['diacolecta'].to_s == '99'\n datos['diacolecta'] = '??'\n end\n if datos['mescolecta'].to_s == '99'\n datos['mescolecta'] = '??'\n end\n if datos['aniocolecta'].to_s == '9999'\n datos['aniocolecta'] = '????'\n end\n\n cadena['07_datetime'] = \"#{datos['diacolecta'].to_s.rjust(2,'0')}/#{datos['mescolecta'].to_s.rjust(2,'0')}/#{datos['aniocolecta']}\"\n\n cadena['08_nombre_colector'] = h.encode(datos['nombrecolector'])\n cadena['09_nombre_coleccion'] = h.encode(datos['nombrecoleccion'])\n cadena['10_nombre_institucion'] = h.encode(datos['nombreinstitucion'])\n cadena['11_siglas_institucion'] = h.encode(datos['siglasinstitucion'])\n cadena['12_pais_coleccion'] = h.encode(datos['paiscoleccion'])\n\n cadena['13_longitude'] = datos['longitud']\n cadena['14_latitude'] = datos['latitud']\n\n cadenas << cadena\n end\n self.snib_kml = to_kml(cadenas)\n end", "def build_markup\n Object.const_get(output_class).new\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.PickupAvailabilityRequest(:xmlns => \"http://fedex.com/ws/pickup/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_pickup_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def markup_context; end", "def content\n require theme_path\n this = self # needed because Markaby is based on `instance_eval`\n @builder = Trinity::Builder.new(:indent => 2)\n @builder.instruct!\n @builder.declare! :DOCTYPE, :html, :PUBLIC, \"-//W3C//DTD XHTML+RDFa 1.0//EN\", \"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\"\n @builder.html(:xmlns => 'http://www.w3.org/1999/xhtml') do\n head { this.render_html_head }\n body { this.render_html_body }\n end\n @builder.to_s\n end", "def build_xml(xml)\n check_configuration\n xml.Aliases {\n xml.Quantity @cnames.size\n if @cnames.size > 0\n xml.Items {\n for cname in Array.wrap @cnames\n xml.CNAME cname\n end\n }\n end\n }\n end", "def telling_xml\n xml = \"\"\n @story.telling.each do |phrase|\n case phrase\n when Story\n xml.Phrase\n xml << \"<Say>#{phrase}</Say>\"\n when Word\n xml << \"<Play>#{phrase.url}</Play>\"\n end\n end\n xml\n end", "def xml_builder\n lambda do |builder|\n builder[:api].amend do\n builder[:api].requests do\n Array.wrap(amendments).each do |amendment|\n build_object builder, :amendments, amendment, :obj\n end\n build_object builder, :amend_options, amend_options, :api\n build_object builder, :preview_options, preview_options, :api\n end\n end\n end\n end", "def to_xml options={}\n\n super(options) do |xml|\n\n xml.reqNumber self.reqNumber\n\n if ! self.category.nil?\n xml.category self.category.catName\n else\n xml.category \"Not defined\"\n end\n\n\n xml.industries do\n industries.each do |industry|\n xml.industry industry.indName\n end\n end\n\n end\n\n end", "def to_xml\n \n text = \"<node id=\\\"#{self.id}\\\" label=\\\"#{self.label}\\\">\\n\"\n \n unless self.attributes.nil?\n text << \"\\t<attvalues>\\n\"\n self.attributes.each do |key, value|\n text << \"\\t\\t<attvalue for=\\\"#{key}\\\" value=\\\"#{value}\\\"></attvalue>\\n\"\n end\n text << \"\\t</attvalues>\\n\"\n end\n \n unless self.viz_size.nil?\n text << \"\\t<viz:size value=\\\"#{self.viz_size}\\\"/>\\n\"\n end\n \n unless self.viz_color.nil?\n text << \"\\t<viz:color b=\\\"#{self.viz_color[:b]}\\\" g=\\\"#{self.viz_color[:g]}\\\" r=\\\"#{self.viz_color[:r]}\\\"/>\\n\"\n end\n \n unless self.viz_position.nil?\n text << \"\\t<viz:position x=\\\"#{self.viz_position[:x]}\\\" y=\\\"#{self.viz_position[:z]}\\\"/>\\n\"\n end\n \n text << \"</node>\\n\"\n text \n end", "def visualize\n\n if @output\n STDERR.puts \"Refuce to output twice.\"\n exit( false )\n end\n\n @output = true\n\n close\n\n Common.openOutput\n\n outo %Q{<?xml version=\"1.0\" encoding=\"UTF-8\"?>}\n\n # No scale:\n if Opt['zoom'].given\n scaler = 1 / ( Opt['zoom'].value.to_i / 100.0 )\n else\n scaler = 1\n end\n\n if @scale\n scaler = scaler * ( 1 / ( @scale / 100.0 ) )\n end\n\n outo %Q{<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"#{size.x!/scaler}#{unit}\" height=\"#{size.y!/scaler}#{unit}\" viewBox=\"0 0 #{size.x!} #{size.y!}\">}\n\n # Output marker \"templates\".\n outo %Q{\\\n <defs>\n\n <marker id=\"markerCircle\" markerWidth=\"8\" markerHeight=\"8\" refX=\"5\" refY=\"5\">\n <circle cx=\"5\" cy=\"5\" r=\"3\" style=\"stroke: none; fill:#{linecolor_o};\"/>\n </marker>\n\n <marker id=\"endArrow\" markerWidth=\"13\" markerHeight=\"13\" refX=\"#{10-linewidth}\" refY=\"4\"\n orient=\"auto\" markerUnits=\"strokeWidth\" >\n <path d=\"M 0 0 L 0 8 L 10 4 L 0 0\" style=\"fill:#{linecolor_o};\" />\n </marker>\n\n <marker id=\"startArrow\" markerWidth=\"13\" markerHeight=\"13\" refX=\"#{linewidth}\" refY=\"4\"\n orient=\"auto\" markerUnits=\"strokeWidth\" >\n <path d=\"M 0 4 L 10 8 L 10 0 L 0 4\" style=\"fill:#{linecolor_o};\" />\n </marker>\n\n <marker id=\"endTee\" markerWidth=\"13\" markerHeight=\"13\" refX=\"0\" refY=\"5\"\n orient=\"auto\" markerUnits=\"strokeWidth\" >\n <path d=\"M 0 0 L 0 10 L 2 10 L 2 0 z\" style=\"fill:#{linecolor_o};\" />\n </marker>\n\n <marker id=\"startTee\" markerWidth=\"13\" markerHeight=\"13\" refX=\"0\" refY=\"4\"\n orient=\"auto\" markerUnits=\"strokeWidth\" >\n <path d=\"M 0 0 L 0 10 L 2 10 L 2 0 z\" style=\"fill:#{linecolor_o};\" />\n </marker>\n\n </defs>}\n\n\n if Opt['name'].given\n outo %Q{ <title>#{Opt['name'].value}</title>}\n else\n outo %Q{ <title>Sivigi figure</title>}\n end\n\n @items.each do |i|\n i.fixpos\n end\n\n # Output each layer in turn.\n layers = Layer.system.list\n layers.each do |layer|\n @items.each do |i|\n incind 2\n i.output( layer )\n decind 2\n end\n end\n\n outo \"</svg>\"\n\n Common.closeOutput\n end", "def buildXML(label,array,xml)\r\n array.each do |hash|\r\n xml.send(label) do\r\n # Create an element named for the label\r\n hash.each do |key,value|\r\n if value.is_a?(Array)\r\n buildXML(key,value,xml)\r\n else\r\n # Create <key>value</key> (using variables)\r\n xml.send(key,value)\r\n end\r\n end\r\n end\r\n end\r\n end", "def build_xml(data)\n xml_builder = Builder::XmlMarkup.new( :indent => 2 )\n xml_builder.instruct! :xml, :encoding => \"UTF-8\"\n xml_builder.xml do |xml|\n data.each do |score|\n xml.node do |node|\n node.wiersz score[:wiersz]\n node.czas score[:czas]\n node.gracz1 score[:gracz1]\n node.wynik1 score[:wynik1]\n node.gracz2 score[:gracz2]\n node.wynik2 score[:wynik2]\n node.kraj score[:kraj]\n node.liga score[:liga]\n node.data score[:data]\n end\n end\n end\n end", "def to_xml\n ns = namespace ? \"#{namespace}:\" : ''\n body = children.map(&:to_xml).join('')\n attrs = ''\n\n attributes.each do |key, value|\n attrs << \"#{key}=#{value.inspect}\"\n end\n\n attrs = \" #{attrs}\" unless attrs.empty?\n\n return \"<#{ns}#{name}#{attrs}>#{body}</#{name}>\"\n end", "def to_xml()\n builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|\n xml.send('cp:coreProperties', \n :\"xmlns:cp\" => CORE_NS, \n :'xmlns:dc' => CORE_NS_DC, \n :'xmlns:dcmitype'=>CORE_NS_DCMIT, \n :'xmlns:dcterms'=>CORE_NS_DCT, \n :'xmlns:xsi'=>CORE_NS_XSI) {\n xml['dc'].creator self.creator\n xml['dcterms'].created Time.now.strftime('%Y-%m-%dT%H:%M:%S'), :'xsi:type'=>\"dcterms:W3CDTF\"\n xml['cp'].revision 0\n }\n end \n builder.to_xml(:save_with => 0)\n end", "def to_xml()\r\n msg = REXML::Document.new\r\n msg << REXML::Element.new(\"#{@type.to_s}\")\r\n msg.root << REXML::Element.new(\"GROUP\").add_text(\"#{@group}\") if @group != nil\r\n msg.root << REXML::Element.new(\"ID\").add_text(\"#{@procID}\") if @procID != nil\r\n msg.root << REXML::Element.new(\"PATH\").add_text(\"#{@path}\") if @path != nil\r\n msg.root << REXML::Element.new(\"ARGSLINE\").add_text(\"#{@cmdLineArgs.join(\" \")}\") if @cmdLineArgs != nil\r\n # Build the <ENV> child element\r\n if !@env.empty? \r\n line = \"\"\r\n @env.each { |k,v|\r\n line << \"#{k.to_s}=#{v.to_s} \" \r\n }\r\n msg.root << REXML::Element.new(\"ENV\").add_text(\"#{line}\")\r\n end\r\n # Build the <OML_CONFIG> child element\r\n if @omlConfig != nil\r\n el = REXML::Element.new(\"OML_CONFIG\")\r\n el.add_element(@omlConfig)\r\n msg.root << el\r\n end\r\n return msg\r\n end", "def to_xml(out)\n\t\t\tout << out.pindent(@children.empty? ? 0 : 1)\n\t\t\tout << \"<#{tag}\"\n\n\t\t\tattr.each { |key, value|\n\t\t\t\tout << \" #{key}=\\\"#{value.class <= Symbol ? value.identifier : escape_xml(value) }\\\"\"\n\t\t\t}\n\n\t\t\tif(@children.empty?)\n\t\t\t\tout << \"/>#{ENDL}\"\n\t\t\telse\n\t\t\t\tout << \">#{ENDL}\"\n\n\t\t\t\t@children.each { |child|\n\t\t\t\t\tchild.to_xml(out)\n\t\t\t\t}\n\t\n\t\t\t\tout < \"</#{tag}>#{ENDL}\"\n\t\t\tend\n\t\tend", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def to_xml(*args); end", "def xml!; @xml = true; end", "def to_xml(builder)\n builder.series type: type do\n builder.title { title.to_xml builder } if title\n builder.place place if place\n builder.organization organization if organization\n builder.abbreviation { abbreviation.to_xml builder } if abbreviation\n builder.from from if from\n builder.to to if to\n builder.number number if number\n builder.part_number part_number if part_number\n end\n end", "def create_xml(asdocs)\n @xml = @header\n asdocs.each { |asdoc| @xml << sprintf(@package, asdoc[:package], IO.read(asdoc[:path])) }\n @xml << @footer\n @xml\n end", "def build_xml(builder, destination_url=nil)\n logo_attributes, other_attributes = self.class.allowed_attributes.partition {|a| a[0..3] == \"logo\" }\n\n builder.format {\n builder.destination destination_url\n other_attributes.each do |attr|\n builder.send(attr, output_value(attr)) unless @attributes[attr].nil?\n end\n if logo_attributes.any? {|attr| @attributes[attr] }\n builder.logo {\n logo_attributes.each {|attr| builder.send(attr, output_value(attr)) if @attributes[attr] }\n }\n end\n }\n end", "def render_xml\n end", "def skml_to_html(skml, options = {safe: false})\n html = skml.dup || ''\n \n # convert the commented inline attribute list (IAL)\n # <!--: who=\"someone\" srcid=\"x.y.z\" -->\n # into the Kramdown version of IAL\n # {: who=\"someone\" srcid=\"x.y.z\" }\n # This allows easy attaching of attributes to a paragraph\n html.gsub!(/<!--:(.*)-->/, '{: \\1 }')\n\n # convert [:name:] into <speaker>name</speaker>\n html.gsub!(/\\[:(.*):\\]/, '<speaker>\\1</speaker>')\n\n # convert tagname into <span tagname>...</span>\n span_tags = %w[foreign mantra speaker name verse]\n span_tags.each do |tag|\n html.gsub! \"<#{tag}\", \"<span data-#{tag}\"\n html.gsub! \"</#{tag}>\", \"</span>\"\n end\n\n html = skml_redact(html)\n\n # convert <golden> tag into <q type=\"golden\">...</q>\n # (based on format of <q> tag in TEI)\n q_tags = %w[golden]\n q_tags.each do |tag|\n html.gsub! \"<#{tag}\", \"<q data-#{tag}\"\n html.gsub! \"</#{tag}>\", \"</q>\"\n end\n\n html = ::Kramdown::Document.new(html, parse_block_html: true).to_html.html_safe\n return options[:safe] ? sanitize_text(html, level: :relaxed).html_safe : html\n end", "def aim_xml(obj, fields, extra_data = {}, name = obj.class.to_s)\r\n # \tfields\r\n # to_hash(obj, fields)\r\n # to_hash(obj, fields).merge(extra_data)\r\n # Builder::XmlMarkup.new.tag! name, to_hash(obj, fields).merge(extra_data)\r\n y = to_hash(obj, fields)\r\n b = Builder::XmlMarkup.new.tag!(obj.class.to_s, y.merge(extra_data))\r\n end", "def build_xml(builder)\n super(builder)\n builder.Type { |b| self.object_type.build_xml(b) } if object_type\n end", "def xml?; end" ]
[ "0.7590852", "0.63832104", "0.6277845", "0.6256495", "0.6167769", "0.61499566", "0.6101771", "0.60962003", "0.6065279", "0.60626996", "0.60562754", "0.6036775", "0.6028168", "0.6011442", "0.6005888", "0.600519", "0.59457624", "0.59089285", "0.59065336", "0.5900416", "0.5875217", "0.58613837", "0.58543557", "0.58356905", "0.5831974", "0.57941437", "0.576666", "0.57624245", "0.5753902", "0.5741633", "0.5741633", "0.57234776", "0.57234776", "0.5716051", "0.57085264", "0.5706865", "0.57062125", "0.5692918", "0.5683114", "0.5655689", "0.56348145", "0.56327283", "0.56321716", "0.5627903", "0.56274873", "0.5600702", "0.55941474", "0.5590461", "0.5587077", "0.5579239", "0.5577057", "0.5577057", "0.5558549", "0.55557376", "0.55469626", "0.55319273", "0.55146986", "0.55103624", "0.55057967", "0.54953283", "0.5483237", "0.54760253", "0.54756373", "0.547065", "0.5454238", "0.543346", "0.541397", "0.5398231", "0.5392102", "0.5370502", "0.53638196", "0.5352085", "0.5348587", "0.5342259", "0.5334583", "0.5325049", "0.531934", "0.53158647", "0.5311855", "0.5309618", "0.5307639", "0.5305588", "0.5296875", "0.52814716", "0.52751505", "0.527246", "0.5270189", "0.5270189", "0.5270189", "0.5270189", "0.5270189", "0.5270189", "0.5255306", "0.525395", "0.5253138", "0.5238107", "0.52336574", "0.52222455", "0.5218961", "0.5212023", "0.51927686" ]
0.0
-1
Build some XmlMarkup for GeoRSS. Since GeoRSS is pretty trimed down, we just take the entire collection and use the exterior_ring as a Polygon. Not to bright, mind you, but until GeoRSS stops with the suck, what are we to do. You should include the appropriate georss and gml XML namespaces in your document.
def to_georss(*args) self.exterior_ring.to_georss(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def georss_simple_representation(options)\r\n georss_ns = options[:georss_ns] || \"georss\"\r\n geom_attr = options[:geom_attr]\r\n \"<#{georss_ns}:polygon#{geom_attr}>\" + self[0].georss_poslist + \"</#{georss_ns}:polygon>\\n\"\r\n end", "def kml_representation(options = {})\r\n result = \"<Polygon#{options[:id_attr]}>\\n\"\r\n result += options[:geom_data] if options[:geom_data]\r\n rings.each_with_index do |ring, i|\r\n if i == 0\r\n boundary = \"outerBoundaryIs\"\r\n else\r\n boundary = \"innerBoundaryIs\"\r\n end\r\n result += \"<#{boundary}><LinearRing><coordinates>\\n\"\r\n result += ring.kml_poslist(options)\r\n result += \"\\n</coordinates></LinearRing></#{boundary}>\\n\"\r\n end\r\n result += \"</Polygon>\\n\"\r\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n\n xml.georss(:where) do\n xml.gml(:LineString) do\n xml.gml(:posList) do\n xml << self.to_a.collect do |p|\n \"#{p[1]} #{p[0]}\"\n end.join(' ')\n end\n end\n end\n end", "def georss_gml_representation(options)#:nodoc: \r\n self[0].georss_gml_representation(options)\r\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n xml.georss(:where) do\n xml.gml(:Point) do\n xml.gml(:pos, \"#{self.lat} #{self.lng}\")\n end\n end\n end", "def build_gpx stations, create_trk, create_wpt\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.gpx(xmlns: 'http://www.topografix.com/GPX/1/1') do\n if create_trk\n stations.each do |callsign, reports|\n xml.trk do\n xml.name callsign\n xml.trkseg do\n reports.each do |report|\n xml.send('trkpt', lat: report.position.latitude, lon: report.position.longitude) do\n xml.name report.comment\n xml.time report.date.strftime('%FT%TZ')\n end\n end\n end\n end\n end\n end\n if create_wpt\n stations.each do |callsign, reports|\n last = reports.last\n reports.each do |report|\n xml.send('wpt', lat: report.position.latitude, lon: report.position.longitude) do\n xml.name report.callsign\n xml.desc report.comment\n xml.time report.date.strftime('%FT%TZ')\n xml.type 'WPT'\n xml.sym report == last ? 'triangle' : 'circle'\n end\n end\n end\n end\n end\n end\n builder.to_xml\nend", "def prepare_final_xml_for_spatial_element\n add_user_defined_field_to_xml_file('StandardsBuildingType', @standards_building_type)\n add_user_defined_field_to_xml_file('SystemType', @system_type)\n add_user_defined_field_to_xml_file('BarDivisionMethod', @bar_division_method)\n add_user_defined_field_to_xml_file('FractionArea', @fraction_area)\n add_user_defined_field_to_xml_file('SpaceTypesFloorArea', @space_types_floor_area)\n add_user_defined_field_to_xml_file('TotalFloorArea(m^2)', @total_floor_area)\n add_user_defined_field_to_xml_file('ConditionedFloorArea(m^2)', @conditioned_floor_area_heated_cooled) if !@conditioned_floor_area_heated_cooled.nil?\n add_user_defined_field_to_xml_file('HeatedFloorArea(m^2)', @conditioned_floor_area_heated_only) if !@conditioned_floor_area_heated_only.nil?\n add_user_defined_field_to_xml_file('CooledFloorArea(m^2)', @conditioned_floor_area_cooled_only) if !@conditioned_floor_area_cooled_only.nil?\n add_user_defined_field_to_xml_file('ConditionedAboveGradeFloorArea(m^2)', @custom_conditioned_above_grade_floor_area) if !@custom_conditioned_above_grade_floor_area.nil?\n add_user_defined_field_to_xml_file('ConditionedBelowGradeFloorArea(m^2)', @custom_conditioned_below_grade_floor_area) if !@custom_conditioned_below_grade_floor_area.nil?\n\n @base_xml.add_element(@user_defined_fields)\n end", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n \r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def to_opml\n\t\tdoc = Nokogiri::XML::DocumentFragment.parse \"\"\n\t\tNokogiri::XML::Builder.with(doc) { |xml|\n\t\t\txml.outline(:title => self.title, :text => self.title) {\n\t\t\t\tself.feeds.each do |feed|\n\t\t\t\t\txml.__send__ :insert, feed.to_opml\n\t\t\t\tend\n\t\t\t}\n\t\t}\n\t\treturn doc\n\tend", "def to_geoMetadataDS(isoXml, fcXml, purl)\n fail ArgumentError, 'generate-geo-metadata: PURL is required' if purl.nil?\n fail ArgumentError, 'generate-geo-metadata: ISO 19139 is required' if isoXml.nil? || isoXml.root.nil?\n\n Nokogiri::XML(\"\n <rdf:RDF xmlns:rdf=\\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\\">\n <rdf:Description rdf:about=\\\"#{purl}\\\">\n #{isoXml.root}\n </rdf:Description>\n <rdf:Description rdf:about=\\\"#{purl}\\\">\n #{fcXml.nil? ? '' : fcXml.root.to_s}\n </rdf:Description>\n </rdf:RDF>\"\n )\n end", "def georss_w3cgeo_representation(options)\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n \r\n \"<#{w3cgeo_ns}:lat>#{self[0][0].y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{self[0][0].x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def envelope_to_polygon\n exp = /^\\s*ENVELOPE\\(\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*\n \\)\\s*$/x # uses 'x' option for free-spacing mode\n bbox_match = exp.match(geom)\n minx, maxx, maxy, miny = bbox_match.captures\n \"POLYGON ((#{minx} #{maxy}, #{minx} #{miny}, #{maxx} #{miny}, #{maxx} #{maxy}, #{minx} #{maxy}))\"\n end", "def build_xml\n\t\t\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n\t\t\t\t\txml.SearchLocationsRequest(:xmlns => \"http://fedex.com/ws/locs/v3\"){\n\t\t\t\t\t\tadd_web_authentication_detail(xml)\n\t\t\t\t\t\tadd_location_client_detail(xml)\n\t\t\t\t\t\tadd_version(xml)\n\t\t\t\t\t\tadd_request_timestamp(xml)\n\t\t\t\t\t\tadd_location_search_criterion(xml)\n\t\t\t\t\t\tadd_unique_tracking_number(xml)\n\t\t\t\t\t\tadd_origin_address(xml)\n\t\t\t\t\t\tadd_phone_number(xml)\n\t\t\t\t\t\tadd_geographic_coordinates(xml)\n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t\tbuilder.doc.root.to_xml\n\t\t\tend", "def generatexml()\n merge(gadrgeneratexml: 'true')\n end", "def render_xml\n @xml = Builder::XmlMarkup.new\n @xml.gauge do\n @xml.license( @license ) unless @license.nil?\n render_extra_components \n render_components\n end\n @xml.to_s.gsub( /<to_s\\/>/, '' ) \n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.PickupAvailabilityRequest(:xmlns => \"http://fedex.com/ws/pickup/v5\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_pickup_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def georss_w3cgeo_representation(options = {}) #:nodoc:\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n point = self.center\r\n \"<#{w3cgeo_ns}:lat>#{point.y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{point.x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def build_geometries\n @areas = AreaBuilder.new do |b|\n @doc.areas.each do |area|\n if area.asset\n texture_url = @doc.asset(area.asset).url2d\n end\n\n b.area(area.vertices,\n :color => area.color,\n :name => area.name,\n :texture => texture_url,\n :type => area.type)\n end\n end\n\n heights = Hash.new\n @walls = WallBuilder.new do |b|\n @doc.lines.select{|l| l.type == :default_wall}.each do |line|\n sp = b.vertex(line.vertices[0])\n ep = b.vertex(line.vertices[1])\n b.wall(sp, ep, line.thickness, line.height)\n\n if heights.include?(line.height)\n heights[line.height] += 1\n else\n heights[line.height] = 1\n end\n end\n end\n # get the most used (common) height accross linears\n @areas.update(heights.sort{|a,b| a[1]<=>b[1]}.last[0]-0.02)\n\n @walls.prepare\n @doc.openings.each do |opening|\n asset = @doc.asset(opening.asset)\n type = which_opening(opening, asset)\n @walls.opening(opening.position ,opening.size, type)\n end\n @walls.update\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.GroundCloseRequest(:xmlns => \"http://fedex.com/ws/close/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n\n xml.TimeUpToWhichShipmentsAreToBeClosed up_to_time.utc.iso8601(2)\n }\n end\n builder.doc.root.to_xml\n end", "def georss_w3cgeo_representation(options)#:nodoc: \r\n self[0].georss_w3cgeo_representation(options)\r\n end", "def add_elements\n Nokogiri::XML::Builder.with(@doc.at('svg')) do |xml|\n yield xml\n end\n end", "def polygon\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it is not in a OSMLib::Database\") if @db.nil?\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it does not represent a polygon\") if self['type'] != 'multipolygon' and self['type'] != 'polygon'\n\n c = []\n member_objects.each do |way|\n raise TypeError.new(\"member is not a way so it can't be represented as Polygon\") unless way.kind_of? OSMLib::Element::Way\n raise OSMLib::Error::NotClosedError.new(\"way is not closed so it can't be represented as Polygon\") unless way.is_closed?\n raise OSMLib::Error::GeometryError.new(\"way with less then three nodes can't be turned into a polygon\") if way.nodes.size < 3\n c << way.node_objects.collect{ |node| [node.lon.to_f, node.lat.to_f] }\n end\n GeoRuby::SimpleFeatures::Polygon.from_coordinates(c)\n end", "def draw(stream)\n @xml = Builder::XmlMarkup.new(:target=>stream, :indent=>2)\n @xml.instruct!\n @xml.declare! :DOCTYPE, :svg, :PUBLIC, \"-//W3C//DTD SVG 1.1//EN\", \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"\n @xml.svg(:width=>\"#{PHYSICAL_WIDTH}#{PHYSICAL_UNITS}\",\n :height=>\"#{PHYSICAL_HEIGHT}#{PHYSICAL_UNITS}\",\n :viewBox=>\"#{MIN_X} #{MIN_Y} #{WIDTH} #{HEIGHT}\",\n :xmlns=>NAMESPACE,\n :version=>VERSION) do |page|\n @slist.each_with_index do |series, i|\n page.g(:transform=>\"translate(#{MARGIN}, #{i * @spacing})\") do |panel|\n panel.g(:transform=>\"scale(#{@yscale})\") do |caption|\n caption.text(:x=>\"-#{TSIZE}\",\n :y=>\"#{MARGIN}\",\n :'font-size'=>\"#{TSIZE}\",\n :'font-family'=>\"Verdana\",\n :'text-anchor'=>\"end\") do |textlabel|\n textlabel.text! series.name\n end\n end\n widthscale = Float(WIDTH - MARGIN)/series.total\n boxdepth = DEPTH/widthscale\n panel.g(:transform=>\"scale(#{widthscale})\") do |core|\n core.rect(:x=>\"0\", :y=>\"0\", :width=>\"#{series.total}\", :height=>\"#{boxdepth}\", :fill=>\"goldenrod\")\n cx = (-series.offset).to_s\n series.rings.inject(0) do |x, ring|\n ring_width, ring_start = ring\n ew_width = 0.75 * ring_width\n r_e, r_w = ring_start + ew_width, ring_start + ring_width\n p_a_x, p_b_x = x + ew_width, x + ring_width\n data = \"M#{p_a_x},0 H#{p_b_x} A#{r_w},#{r_w} 0 0,1 \"\n data << case\n when r_w <= boxdepth\n p_c_y, p_d_y = Math.sqrt(r_w**2 - series.offset**2), Math.sqrt(r_e**2 - series.offset**2)\n \"0,#{p_c_y} V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n when r_e > boxdepth && Math.sqrt(r_e**2 - boxdepth**2) > series.offset\n p_c_x, p_d_x = Math.sqrt(r_w**2 - boxdepth**2) - series.offset, Math.sqrt(r_e**2 - boxdepth**2) - series.offset\n \"#{p_c_x},#{boxdepth} H#{p_d_x} A#{r_e},#{r_e} 0 0,0 \"\n when Math.sqrt(r_w**2 - boxdepth**2) <= series.offset\n p_c_y, p_d_y = Math.sqrt(r_w**2 - series.offset**2), Math.sqrt(r_e**2 - series.offset**2)\n \"0,#{p_c_y} V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n else\n p_c_x, = Math.sqrt(r_w**2 - boxdepth**2) - series.offset\n p_d_y = Math.sqrt(r_e**2 - series.offset**2)\n \"#{p_c_x},#{boxdepth} H0 V#{p_d_y} A#{r_e},#{r_e} 0 0,0 \"\n end\n data << \"#{p_a_x},0 Z\"\n core.path(:d=>data, :'stroke'=>\"none\", :fill=>\"saddlebrown\")\n p_b_x\n end\n end\n end\n end\n end\n end", "def to_geo_json_feature\n # !! avoid loading the whole geographic item, just grab the bits we need:\n # self.georeferences(true) # do this to\n to_simple_json_feature.merge({\n 'properties' => {\n 'collecting_event' => {\n 'id' => self.id,\n 'tag' => \"Collecting event #{self.id}.\"\n }\n }\n })\n end", "def extents_to_xml(options = {})\n e = get_extents()\n options[:indent] ||= 2\n xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])\n xml.instruct! unless options[:skip_instruct]\n xml.extents do\n xml.min_point do\n xml.tag!(:x, e[:minX])\n xml.tag!(:y, e[:minY])\n end\n xml.max_point do\n xml.tag!(:x, e[:maxX])\n xml.tag!(:y, e[:maxY])\n end\n end\n end", "def notes_geojson\n\t \t{ 'type' => 'FeatureCollection', \n\t \t 'features' => aw.notes_geo \n\t \t}\n\t \tend", "def build_xml\n ns = \"http://fedex.com/ws/pickup/v#{service[:version]}\"\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CreatePickupRequest(:xmlns => ns) {\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_origin_detail(xml)\n add_package_details(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def geographic_oregon(subject, data)\n geographic(subject, data, RDF::Vocab::DC[:spatial], {:adminCode1 => \"OR\", :countryBias => \"US\"})\n end", "def to_xml(builder)\n builder.series type: type do\n builder.title { title.to_xml builder } if title\n builder.place place if place\n builder.organization organization if organization\n builder.abbreviation { abbreviation.to_xml builder } if abbreviation\n builder.from from if from\n builder.to to if to\n builder.number number if number\n builder.part_number part_number if part_number\n end\n end", "def as_polygon\n GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])\n end", "def generate_xml\n\t\n\t\tbuilder = Nokogiri::XML::Builder.new do |xml|\n \t\t\txml.randomGeneratedData {\n \t\t\txml.parameters(nbStations: @inputs.nb_stations, nbDemands: @inputs.nb_demands)\n xml.stations {\n @list_stations.each do |s|\n\t\t\t\t\t\t\txml.station(\n\t\t\t\t\t\t\t\tid: s.id, \n\t\t\t\t\t\t\t\txPos: s.xPos, \n\t\t\t\t\t\t\t\tyPos: s.yPos,\n\t\t\t\t\t\t\t\tmaxSize: s.maxSize\n\t\t\t\t\t\t\t)\n end\n }\n \t\t\t\txml.demands {\n @list_demands.each do |d|\n \t\t\t\t\t\txml.demand(\n\t\t\t\t\t\t\t id: d.id,\n\t\t\t\t\t\t\t\tidsOrigin: d.sOrigin.id, \n\t\t\t\t\t\t\t\tidsDestination: d.sDestination.id, \n\t\t\t\t\t\t\t\tnbDemand: d.nbDemand,\n\t\t\t\t\t\t\t\tdepartureTime: d.departureTime_TS,\n\t\t\t\t\t\t\t\tarrivalTime: d.arrivalTime_TS\n \t\t\t\t\t\t)\n end\n \t\t\t\t}\n \t\t\t}\n\t\tend\n\t\t\n\t\treturn builder.to_xml\n\tend", "def append_geom( geom, **other_attrs )\n if geom.is_a?(GeoRuby::SimpleFeatures::Geometry)\n geom = RGeo::WKRep::WKBParser.new.parse(geom.as_wkb) rescue nil\n end\n new_geom = geom\n self.place_geometry.reload\n if place_geometry && !place_geometry.geom.nil?\n union = place_geometry.geom.union(new_geom)\n new_geom = if union.geometry_type == ::RGeo::Feature::MultiPolygon\n union\n else\n f = place_geometry.geom.factory\n f.multi_polygon([union])\n end\n end\n self.save_geom( new_geom, **other_attrs )\n end", "def default_extent\n {\n \"type\" => \"Polygon\",\n \"coordinates\" => [\n [\n [-180.0, 90.0], [-180.0, -90.0], [180.0, -90.0], [180.0, 90.0], [-180.0, 90.0]\n ]\n ]\n }.to_json\n end", "def geometry_as_wkt\n return geom unless geom.match?(/ENVELOPE/)\n\n envelope_to_polygon\n end", "def to_geojson\n coordinates = @points.map { |point| [point.longitude, point.lattitude] }\n { 'type' => 'Polygon', 'coordinates' => [coordinates] }.to_json\n end", "def build(document)\n document.geom_types = geom_types\n document.format = format\n end", "def georss_simple_representation(options)#:nodoc: \r\n self[0].georss_simple_representation(options)\r\n end", "def build_xml(builder)\n super(builder)\n builder.ValidNetwork {|b| segment_config_network.build_xml(b) } if segment_config_network\n asset_on_segment_historys.each do |aosh|\n builder.AssetOnSegmentHistory {|b| aosh.build_xml(b)} if aosh\n end\n meas_locations.each do |m|\n builder.MeasurementLocation do |b|\n m.build_xml(b)\n end\n end\n end", "def kml_representation(options = {}) #:nodoc: \r\n result = \"<Point#{options[:id_attr]}>\\n\"\r\n result += options[:geom_data] if options[:geom_data]\r\n result += \"<coordinates>#{x},#{y}\"\r\n result += \",#{options[:fixed_z] || z ||0}\" if options[:allow_z]\r\n result += \"</coordinates>\\n\"\r\n result += \"</Point>\\n\"\r\n end", "def to_xml(builder) # rubocop:disable Metrics/MethodLength\n xml = builder.series do\n formattedref&.to_xml builder\n builder.title { title.to_xml builder }\n builder.place place if place\n builder.organization organization if organization\n builder.abbreviation { abbreviation.to_xml builder } if abbreviation\n builder.from from if from\n builder.to to if to\n builder.number number if number\n builder.partnumber partnumber if partnumber\n builder.run run if run\n end\n xml[:type] = type if type\n end", "def build_xml(feed_type=(self.feed_type or \"atom\"), feed_version=nil,\n xml_builder=Builder::XmlMarkup.new(\n :indent => 2, :escape_attrs => false))\n \n if self.find_node(\"access:restriction/@relationship\").to_s == \"deny\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n elsif self.find_node(\"@indexing:index\").to_s == \"no\"\n raise StandardError,\n \"Operation not permitted. This feed denies redistribution.\"\n end\n \n self.full_parse()\n \n xml_builder.instruct! :xml, :version => \"1.0\",\n :encoding => (self.configurations[:output_encoding] or \"utf-8\")\n if feed_type.nil?\n feed_type = self.feed_type\n end\n if feed_version.nil?\n feed_version = self.feed_version\n end\n if feed_type == \"rss\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n elsif feed_type == \"atom\" &&\n (feed_version == nil || feed_version <= 0.0)\n feed_version = 1.0\n end\n if feed_type == \"rss\" &&\n (feed_version == 0.9 || feed_version == 1.0 || feed_version == 1.1)\n # RDF-based rss format\n return xml_builder.tag!(\"rdf:RDF\",\n \"xmlns\" => FEED_TOOLS_NAMESPACES['rss10'],\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:syn\" => FEED_TOOLS_NAMESPACES['syn'],\n \"xmlns:admin\" => FEED_TOOLS_NAMESPACES['admin'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n channel_attributes = {}\n unless self.link.nil?\n channel_attributes[\"rdf:about\"] =\n FeedTools::HtmlHelper.escape_entities(self.link)\n end\n xml_builder.channel(channel_attributes) do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n else\n xml_builder.title\n end\n unless self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n unless images.blank?\n xml_builder.image(\"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(\n images.first.url))\n end\n unless description.nil? || description == \"\"\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.language.blank?\n xml_builder.tag!(\"dc:language\", self.language)\n end\n unless self.rights.blank?\n xml_builder.tag!(\"dc:rights\", self.rights)\n end\n xml_builder.tag!(\"syn:updatePeriod\", \"hourly\")\n xml_builder.tag!(\"syn:updateFrequency\",\n (self.time_to_live / 1.hour).to_s)\n xml_builder.tag!(\"syn:updateBase\", Time.mktime(1970).iso8601)\n xml_builder.items do\n xml_builder.tag!(\"rdf:Seq\") do\n unless items.nil?\n for item in items\n if item.link.nil?\n raise \"Cannot generate an rdf-based feed with a nil \" +\n \"item link field.\"\n end\n xml_builder.tag!(\"rdf:li\", \"rdf:resource\" =>\n FeedTools::HtmlHelper.escape_entities(item.link))\n end\n end\n end\n end\n xml_builder.tag!(\n \"admin:generatorAgent\",\n \"rdf:resource\" => self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n end\n unless self.images.blank?\n best_image = nil\n for image in self.images\n if image.link != nil\n best_image = image\n break\n end\n end\n best_image = self.images.first if best_image.nil?\n xml_builder.image(\"rdf:about\" =>\n FeedTools::HtmlHelper.escape_entities(best_image.url)) do\n if !best_image.title.blank?\n xml_builder.title(best_image.title)\n elsif !self.title.blank?\n xml_builder.title(self.title)\n else\n xml_builder.title\n end\n unless best_image.url.blank?\n xml_builder.url(best_image.url)\n end\n if !best_image.link.blank?\n xml_builder.link(best_image.link)\n elsif !self.link.blank?\n xml_builder.link(self.link)\n else\n xml_builder.link\n end\n end\n end\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n elsif feed_type == \"rss\"\n # normal rss format\n return xml_builder.rss(\"version\" => \"2.0\",\n \"xmlns:content\" => FEED_TOOLS_NAMESPACES['content'],\n \"xmlns:rdf\" => FEED_TOOLS_NAMESPACES['rdf'],\n \"xmlns:dc\" => FEED_TOOLS_NAMESPACES['dc'],\n \"xmlns:taxo\" => FEED_TOOLS_NAMESPACES['taxo'],\n \"xmlns:trackback\" => FEED_TOOLS_NAMESPACES['trackback'],\n \"xmlns:itunes\" => FEED_TOOLS_NAMESPACES['itunes'],\n \"xmlns:media\" => FEED_TOOLS_NAMESPACES['media']) do\n xml_builder.channel do\n unless self.title.blank?\n xml_builder.title(\n FeedTools::HtmlHelper.strip_html_tags(self.title))\n end\n unless self.link.blank?\n xml_builder.link(link)\n end\n unless self.description.blank?\n xml_builder.description(description)\n else\n xml_builder.description\n end\n unless self.author.email.blank?\n xml_builder.managingEditor(self.author.email)\n end\n unless self.publisher.email.blank?\n xml_builder.webMaster(self.publisher.email)\n end\n unless self.published.blank?\n xml_builder.pubDate(self.published.rfc822)\n end\n unless self.updated.blank?\n xml_builder.lastBuildDate(self.updated.rfc822)\n end\n unless self.copyright.blank?\n xml_builder.copyright(self.copyright)\n end\n unless self.language.blank?\n xml_builder.language(self.language)\n end\n xml_builder.ttl((time_to_live / 1.minute).to_s)\n xml_builder.generator(\n self.configurations[:generator_href])\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n end\n elsif feed_type == \"atom\" && feed_version == 0.3\n raise \"Atom 0.3 is obsolete.\"\n elsif feed_type == \"atom\" && feed_version == 1.0\n # normal atom format\n return xml_builder.feed(\"xmlns\" => FEED_TOOLS_NAMESPACES['atom10'],\n \"xml:lang\" => language) do\n unless title.blank?\n xml_builder.title(title,\n \"type\" => \"html\")\n end\n xml_builder.author do\n unless self.author.nil? || self.author.name.nil?\n xml_builder.name(self.author.name)\n else\n xml_builder.name(\"n/a\")\n end\n unless self.author.nil? || self.author.email.nil?\n xml_builder.email(self.author.email)\n end\n unless self.author.nil? || self.author.url.nil?\n xml_builder.uri(self.author.url)\n end\n end\n unless self.href.blank?\n xml_builder.link(\"href\" => self.href,\n \"rel\" => \"self\",\n \"type\" => \"application/atom+xml\")\n end\n unless self.link.blank?\n xml_builder.link(\n \"href\" =>\n FeedTools::HtmlHelper.escape_entities(self.link),\n \"rel\" => \"alternate\")\n end\n unless self.subtitle.blank?\n xml_builder.subtitle(self.subtitle,\n \"type\" => \"html\")\n end\n if self.updated != nil\n xml_builder.updated(self.updated.iso8601)\n elsif self.time != nil\n # Not technically correct, but a heck of a lot better\n # than the Time.now fall-back.\n xml_builder.updated(self.time.iso8601)\n else\n xml_builder.updated(Time.now.gmtime.iso8601)\n end\n unless self.rights.blank?\n xml_builder.rights(self.rights)\n end\n xml_builder.generator(self.configurations[:generator_name] +\n \" - \" + self.configurations[:generator_href])\n if self.id != nil\n unless FeedTools::UriHelper.is_uri? self.id\n if self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n else\n raise \"The unique id must be a valid URI.\"\n end\n else\n xml_builder.id(self.id)\n end\n elsif self.link != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.link))\n elsif self.url != nil\n xml_builder.id(FeedTools::UriHelper.build_urn_uri(self.url))\n else\n raise \"Cannot build feed, missing feed unique id.\"\n end\n build_xml_hook(feed_type, feed_version, xml_builder)\n unless items.nil?\n for item in items\n item.build_xml(feed_type, feed_version, xml_builder)\n end\n end\n end\n else\n raise \"Unsupported feed format/version.\"\n end\n end", "def create_layered_svg_file\n dom = REXML::Document::new(File.new(@basename))\n layer_data = read_relevant_data_from_svg\n patterns = @pattern.split(\"_\")\n merged_nums = []\n for pattern in patterns\n range_computer = RangeComputer.new pattern, layer_data\n merged_nums += range_computer.range\n end\n for num in 1..layer_data.length\n if merged_nums.index(num) != nil\n next\n end\n index = num - 1\n layer_id = layer_data[index][\"id\"]\n dom.root.each_element_with_attribute(\"id\", value=layer_id) {|e|\n e.add_attribute(\"opacity\", \"0.0\")\n }\n end\n xml_string = dom.to_s\n new_xml_file = File.open @filename, \"w\"\n new_xml_file << xml_string\n new_xml_file.close\n end", "def kml_representation(options = {}) #:nodoc:\n out = \"<Point#{options[:id_attr]}>\\n\"\n out += options[:geom_data] if options[:geom_data]\n out += \"<coordinates>#{x},#{y}\"\n out += \",#{options[:fixed_z] || z || 0}\" if options[:allow_z]\n out += \"</coordinates>\\n\"\n out + \"</Point>\\n\"\n end", "def kml_representation(options = {}) #:nodoc: \r\n result = \"<MultiGeometry#{options[:id_attr]}>\\n\"\r\n options[:id_attr] = \"\" #the subgeometries do not have an ID\r\n each do |geometry|\r\n result += geometry.kml_representation(options)\r\n end\r\n result += \"</MultiGeometry>\\n\"\r\n end", "def write_placemark(feature)\n @openfile.write \"<Placemark>\\n\"\n unless feature[:name].nil?\n @openfile.write \"\\t<name>#{feature[:name]}</name>\\n\"\n end\n if feature.has_key? :style\n @openfile.write \"\\t<styleUrl>#{feature[:style]}</styleUrl>\\n\"\n end\n if feature.has_key? :extended\n @openfile.write \"\\t<ExtendedData>\\n\"\n feature[:extended].each do |k,v|\n @openfile.write \"\\t\\t<Data name=\\\"#{k}\\\">#{v}</Data>\\n\"\n end\n @openfile.write \"\\t</ExtendedData>\\n\"\n end\n if feature.has_key? :desc\n if feature.has_key? :link\n @openfile.write \"\\t<description>\\n\\t\\t#{feature[:desc]}\\n<![CDATA[<img src=\\\"#{feature[:link]}\\\">]]></description>\\n\"\n else\n @openfile.write \"\\t<description>\\n\\t\\t#{feature[:desc]}\\n\\t</description>\\n\"\n end\n end\n if feature.has_key? :time\n @openfile.write \"\\t<TimeStamp>\\n\"\n @openfile.write \"\\t\\t<when>#{feature[:time].iso8601}</when>\\n\"\n @openfile.write \"\\t</TimeStamp>\"\n end\n if feature.has_key? :gxTrack\n @openfile.write %Q{\\t<gx:Track>\n \\t\\t<altitudeMode>absolute</altitudeMode>\n \\t\\t<when>#{feature[:gxTrack][:start][:time].iso8601}</when>\n \\t\\t<when>#{feature[:gxTrack][:end][:time].iso8601}</when>\n \\t\\t<gx:coord>#{feature[:gxTrack][:start][:pos]}</gx:coord>\n \\t\\t<gx:coord>#{feature[:gxTrack][:end][:pos]}</gx:coord>\n \\t</gx:Track>}\n end\n\n unless feature[:geometry].nil?\n @openfile.write \"\\t\"+feature[:geometry].as_kml #What type of geometry do we need here?\n end\n @openfile.write \"</Placemark>\\n\\n\"\n end", "def build(document)\n document.geom_type = geom_type\n document.format = format\n end", "def create_polylines\n if @itinerary.legs.nil?\n return []\n end\n\n polylines = []\n @itinerary.legs.each_with_index do |leg, index|\n polylines << {\n \"id\" => index,\n \"geom\" => leg['legGeometry'].nil? ? [] : leg['legGeometry'],\n \"options\" => get_leg_display_options(leg)\n }\n end\n\n return polylines\n end", "def build_xml\n ns = \"http://fedex.com/ws/pickup/v17\"\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.Envelope(\"xmlns\" => \"http://fedex.com/ws/pickup/v17\") {\n xml.parent.namespace = xml.parent.add_namespace_definition(\"soapenv\", \"http://schemas.xmlsoap.org/soap/envelope/\")\n xml['soapenv'].Header {}\n xml['soapenv'].Body {\n xml.CreatePickupRequest() {\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_origin_detail(xml)\n add_package_details(xml)\n }\n }\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml\n Element.new('Shipper').tap do |org|\n org << shipper_name\n org << attention_name\n org << company_name\n org << phone_number\n org << shipper_number\n org << address\n org << tax_identification_number\n end\n end", "def show\n @buildings = Building.all.where(campus: @campus.id)\n\n # преобразование массива точек в строку для SVG.js:\n @showPoints = []\n polygons_ids = Polygon.all.where(imageable_id: @campus.id).map{ |i| i.id }\n polygons_ids.each do |i|\n @showPoints << Point.all.where(polygon_id: i)\n .sort_by{ |j| j[:priority] }\n .map{ |j| \"#{j.ox}, #{j.oy}\" }\n .join(\" \")\n end\n # @buildings = Building.all.where(campus: @campus.id)\n end", "def geojson\n obj = factory.parse_wkt(geometry_as_wkt)\n RGeo::GeoJSON.encode(obj).to_json\n rescue\n Geoblacklight.logger.warn \"Geometry is not valid: #{geom}\"\n default_extent\n end", "def generate_epl tolerance = 0.001\n e = EncodedPolylineEncoder.new\n enc_string = \"?size=197x124&maptype=terrain\"\n each_poly_string = \"&path=fillcolor:0xED671E66|color:0xED671EFF|weight:2|enc:\"\n geoms = JSON.parse(self.simple_poly(tolerance))[\"coordinates\"][0] \n unless geoms.nil? || geoms.flatten.empty?\n geoms.each do |poly|\n unless poly.flatten.empty?\n poly.map!{|x| [x[1],x[0]]} #FLIP FLOP X/Y\n enc = e.encode(poly)[:points]\n enc_string << each_poly_string << enc\n end\n end\n end \n enc_string\n end", "def generate_epl tolerance = 0.001\n e = EncodedPolylineEncoder.new\n enc_string = \"?size=197x124&maptype=terrain\"\n each_poly_string = \"&path=fillcolor:0xED671E66|color:0xED671EFF|weight:2|enc:\"\n geoms = JSON.parse(self.simple_poly(tolerance))[\"coordinates\"][0] \n unless geoms.nil? || geoms.flatten.empty?\n geoms.each do |poly|\n unless poly.flatten.empty?\n poly.map!{|x| [x[1],x[0]]} #FLIP FLOP X/Y\n enc = e.encode(poly)[:points]\n enc_string << each_poly_string << enc\n end\n end\n end \n enc_string\n end", "def to_svg\n draw\n invert_coords\n \n polygon = @coords.values.map { |c| c.join(',') }.join(' ')\n labels = ''\n \n t.each { |v| labels << vertex_label(v) << vertex_arc(v) << vertex_value(v) }\n t.each { |v| labels << edge_label(v) } # Needs to be drawn last in order to make ImageMagick render it correctly.\n \n <<-EOT\n<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"#{canvas_size}\" height=\"#{canvas_size}\">\n<polygon fill=\"#f5eae5\" stroke=\"#993300\" stroke-width=\"1\" points=\"#{polygon}\"/>\n#{labels}</svg>\nEOT\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CancelPickupRequest(:xmlns => \"http://fedex.com/ws/pickup/v#{service[:version]}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n xml.CarrierCode @carrier_code || \"FDXE\"\n xml.PickupConfirmationNumber @pickup_confirmation_number\n xml.ScheduledDate @schedule_date\n xml.Location @location\n xml.Remarks @remarks if @remarks\n }\n end\n builder.doc.root.to_xml\n end", "def doc2layer_geom_type(doc)\n sdtstype = doc.xpath('//metadata/spdoinfo/ptvctinf/sdtsterm/sdtstype').text\n return 'Polygon' if sdtstype.match /G-polygon/i\n return 'Point' if sdtstype.match /Point/i\n return 'Line' if sdtstype.match /String/i\n\n direct = doc.xpath('//metadata/spdoinfo/direct').text\n return 'Raster' if direct.match /Raster/i\n return 'Point' if direct.match /Point/i\n return 'Polygon' if direct.match /Vector/i\n\n indspref = doc.xpath('//metadata/spdoinfo/indspref').text\n return 'Table' if indspref.match /Table/i\n\n # undetermined\n return 'UNDETERMINED'\n end", "def postgis_polygon_format(coordinates)\n ordinates = 'POLYGON (('\n ordinates += coordinates.gsub(\"0.0\", \" \").gsub(\",-\",\" -\").gsub(/, $/, \")\")\n ordinates += ')'\n end", "def to_xml(xml_builder = Builder::XmlMarkup.new)\n xml_builder.tag!('ExternalFeed') do\n %w(URL OwnerEmail PollingInterval SecurityType SignatureType BasicAuthUsername BasicAuthPassword).each do |tag_name|\n xml_builder.tag!(tag_name, self.edits[tag_name]) if self.edits[tag_name]\n end\n end\n end", "def to_simple_json_feature\n base = {\n 'type' => 'Feature',\n 'properties' => {}\n }\n\n if geographic_items.any?\n geo_item_id = geographic_items.select(:id).first.id\n query = \"ST_AsGeoJSON(#{GeographicItem::GEOMETRY_SQL.to_sql}::geometry) geo_json\"\n base['geometry'] = JSON.parse(GeographicItem.select(query).find(geo_item_id).geo_json)\n end\n base\n end", "def to_xml\r\n x = Builder::XmlMarkup.new(:target => (reply = ''))\r\n x.instruct!\r\n x.comment! \"#{@collection.size} entries\" \r\n x.strings(:each => @each) {\r\n @collection.each do |each|\r\n x.s(each)\r\n end\r\n }\r\n reply\r\n end", "def print_placemark\n #Links are not processed\n# if @@last_type == Link then return end\n #An icon showing the start point and description\n ret = \"<Placemark>\"\n ret << \"<name>#{@@step.to_s.rjust(2,'0')}</name>\"\n ret << \"<description>\"\n #Different rendering for Streets and Triphops\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"#{@@init_time.strftime(\"%H:%M\")}. \"\n else\n ret << \"Departure: #{@@init_time.strftime(\"%H:%M\")}. \"\n ret << \"Arrival: #{@@end_time.strftime(\"%H:%M\")}. \"\n end\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</description>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkIcon</styleUrl>\"\n else\n ret << \"<styleUrl>#busIcon</styleUrl>\"\n end\n ret << \"<Point>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords[0]}\"\n ret << \"</coordinates>\"\n ret << \"</Point>\"\n ret << \"</Placemark>\"\n\n #A polyline showing the path\n ret << \"<Placemark>\"\n ret << \"<name>\"\n# ret << payload.to_kml\n ret << @@last_name\n ret << \"</name>\"\n if (@@last_type == Street || @@last_type == Link) then\n ret << \"<styleUrl>#walkPath</styleUrl>\"\n else\n ret << \"<styleUrl>#busPath</styleUrl>\"\n end\n ret << \"<LineString>\"\n ret << \"<coordinates>\"\n ret << \"#{@@coords.join(' ')}\"\n ret << \"</coordinates>\"\n ret << \"</LineString>\"\n ret << \"</Placemark>\"\n end", "def xml\n xml = Builder::XmlMarkup.new(indent: 2)\n\n xml.instruct! :xml, encoding: 'UTF-8'\n xml.rss version: '2.0' do |rss|\n rss.channel do |channel|\n channel.title 'Haxpressen'\n\n last_ten_days.each do |day|\n summary = summary_for day\n\n if summary.present?\n channel.item do |item|\n item.title \"Sammanfattning för #{day}\"\n item.pubDate day\n item.description summary\n end\n end\n end\n end\n end\n end", "def build_xml\n ns = \"http://fedex.com/ws/rate/v#{service[:version]}\"\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.RateRequest(:xmlns => ns){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_requested_shipment(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml(xml_builder = Builder::XmlMarkup.new)\n xml_builder.tag!('Group') do\n %w(Name Handle GroupType Explicit).each do |tag_name|\n xml_builder.tag!(tag_name, self.edits[tag_name]) if self.edits[tag_name]\n end\n \n self.tracks.to_xml(xml_builder)\n self.permissions.to_xml(xml_builder)\n \n %w(AllowSubscription).each do |tag_name|\n xml_builder.tag!(tag_name, self.edits[tag_name]) if self.edits[tag_name]\n end\n self.external_feed.to_xml(xml_builder) if self.external_feed\n end\n end", "def osmxml (ios)\n ios.write(\"<osm version=\\\"0.6\\\" >\\n\")\n @properties.each { |x| \n x.osmxml(ios) \n }\n ios.write(\"</osm>\\n\")\n end", "def to_kml(*args)\n xml, options = Geos::Helper.xml_options(*args)\n xml.Point(:id => options[:id]) do\n xml.extrude(options[:extrude]) if options[:extrude]\n xml.altitudeMode(Geos::Helper.camelize(options[:altitude_mode])) if options[:altitude_mode]\n xml.coordinates(self.to_a.join(','))\n end\n end", "def add_shipper(opts = {})\n shipment_root << ShipperBuilder.new(opts).to_xml\n end", "def build_polygons_definition(p_hexagons)\n hexagons_source = p_hexagons.split(',')\n polygons = Array.new\n hexagons = Array.new\n hexagons_source.each { |h| hexagons << h.to_i}\n\n until hexagons.empty?\n polygon = Hash.new\n enveloppe = Array.new\n connections = Array.new\n node_stack = Array.new [hexagons.first]\n \n until node_stack.empty?\n connection_string = \"\"\n current_node = node_stack.pop\n enveloppe << current_node \n hexagons.delete(current_node)\n\n EDGES.each do |direction|\n adjacent_hexagon = adjacent(current_node, direction)\n\n if adjacent_hexagon == -1 then\n connection_string << \"0\"\n else \n if hexagons_source.include?(adjacent_hexagon.to_s) then\n connection_string << \"1\"\n node_stack << adjacent_hexagon unless node_stack.include?(adjacent_hexagon) or enveloppe.include?(adjacent_hexagon) \n else\n connection_string << \"0\"\n end \n end\n end \n \n connections << connection_string\n end\n\n polygon[:enveloppe] = enveloppe\n polygon[:connections] = connections\n polygons << polygon\n end \n\n return polygons \n end", "def drawn_georeferences\n message = ''\n value = params['gr_geographic_item_attributes_shape']\n if value.blank?\n @georeferences = Georeference.where('false')\n else\n feature = RGeo::GeoJSON.decode(value, json_parser: :json)\n # isolate the WKT\n geometry = feature.geometry\n this_type = geometry.geometry_type.to_s.downcase\n geometry = geometry.as_text\n\n radius = feature['radius']\n case this_type\n when 'point'\n @georeferences = Georeference.with_project_id(sessions_current_project_id)\n .joins(:geographic_item)\n .where(GeographicItem.intersecting_radius_of_wkt_sql(geometry, radius)) # TODO: likely want within_radius_of_wkt_sql\n when 'polygon'\n @georeferences = Georeference.with_project_id(sessions_current_project_id)\n .joins(:geographic_item)\n .where(GeographicItem.contained_by_wkt_sql(geometry))\n else\n end\n if @georeferences.blank?\n message = 'no objects contained in drawn shape'\n end\n render_gr_select_json(message)\n end\n end", "def build_geographies\n build_start_or_end_area unless start_or_end_area\n build_trip_within_area unless trip_within_area\n end", "def to_svg\n if (@fullscreen or @layout.fullscreenmap)\n #then we can skip the subscreen rendering with tempfiles and dump the map's svg\n funkygps.map.to_svg\n else\n out = %{<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\\n}\n out << %{<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\\n}\n out << %{<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"#{width}px\" height=\"#{height}px\">\\n}\n @layout.subscreens.each do |subscreen|\n out << add_svg(x: @layout.x(of:subscreen), y: @layout.y(of:subscreen), width: @layout.width(of:subscreen), height: @layout.height(of: subscreen), svg: funkygps.instance_variable_get(subscreen).to_svg) if @layout.is_visible(screen: subscreen)\n end\n out << %{</svg>}\n out\n end\n end", "def build_xml(builder)\n super(builder)\n object_data.each do |d|\n builder.Attribute do |b|\n d.build_xml(b)\n end\n end\n builder.DefaultUnitType { |b| default_eng_unit_type.build_xml(b) }\n end", "def geojson(fields)\n geojson = Array.new\n fields.each do |field|\n geojson << {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [field.longitude, field.latitude]\n },\n properties: {\n id: field.id,\n name: field.name,\n address: print_field(field),\n :'marker-color' => '#00607d',\n :'marker-symbol' => 'circle',\n :'marker-size' => 'medium',\n title: \"<a href=#{field_url(field)} data-no-turbolink><b>#{field.name}</b></a>\",\n description: print_field(field)\n }\n }\n end\n geojson\n end", "def build_ship_param_node(node_name, person, location, options={})\n node = XmlNode.new(node_name) do |node|\n node << XmlNode.new('Name', person[:person_name])\n if person[:phone_number]\n node << XmlNode.new('Phone') do |phone|\n phone << XmlNode.new('Number', person[:phone_number].gsub(/[^\\d]/, ''))\n phone << XmlNode.new('Extension', person[:phone_number_ext].gsub(/[^\\d]/, '')) if person[:phone_number_ext]\n end\n end\n node << XmlNode.new('ShipperNumber', person[:shipper_number]) if node_name == 'Shipper' and person[:shipper_number]\n node << XmlNode.new('FaxNumber', person[:shipper_fax_number]) if node_name == 'Shipper' and person[:shipper_fax_number]\n node << XmlNode.new('EMailAddress', person[:email]) if person[:email]\n node << build_address_node(location)\n\n end \n end", "def to_xml(builder=nil)\n builder = ::Builder::XmlMarkup.new if builder.nil?\n builder.sitemap do\n builder.loc self[:loc]\n builder.lastmod w3c_date(self[:lastmod]) if self[:lastmod]\n end\n builder << '' # force to string\n end", "def build_internal_nodes\n names.each do |tmp_geo_area|\n recurse_nodes(tmp_geo_area.parent_names, tmp_geo_area)\n end\n end", "def build_rdf_xml(bf_rels, loc_rels, other_metadata)\n builder = Nokogiri::XML::Builder.new do |xml|\n xml['rdf'].rdf('xmlns:bf' => BIBFRAME_URI,\n 'xmlns:rdf' => RDF_URI,\n 'xmlns:relators' => LOC_RELATORS_URI\n ) do\n # It can either be an Instance or a Work\n xml['bf'].send(base_class, 'rdf:about' => create_resource_url(id)) do\n # Add the relational data\n bf_rels.each do |key, val|\n xml['bf'].send(key, 'rdf:resource' => val)\n end\n loc_rels.each do |key, val|\n xml['relators'].send(key, 'rdf:resource' => val)\n end\n # append all the data from the bfMetadata stream\n xml << other_metadata\n end\n end\n end\n builder.to_xml\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.AddressValidationRequest(:xmlns => \"http://fedex.com/ws/addressvalidation/v2\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_request_timestamp(xml)\n add_options(xml)\n add_address(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def to_xml(builder)\n builder.editorialgroup do |b|\n b.society society if society\n balloting_group&.to_xml(b)\n b.send :\"working-group\", working_group if working_group\n committee.each { |c| b.committee c }\n end\n end", "def build_bounding_box(bounding_box)\n \"#{bounding_box[:sw_latitude]},#{bounding_box[:sw_longitude]}|#{bounding_box[:ne_latitude]},#{bounding_box[:ne_longitude]}\"\n end", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n [:name, :visibility, :address].each do |a|\n xm.__send__(a, self.__send__(a)) unless self.__send__(a).nil?\n end\n \n xm.description { xm.cdata!(description) } unless description.nil?\n xm.open(self.open) unless open.nil?\n \n xm.phoneNumber(phone_number) unless phone_number.nil?\n xm.styleUrl(style_url) unless style_url.nil?\n \n unless address_details.nil?\n xm.AddressDetails(:xmlns => \"urn:oasis:names:tc:ciq:xsdschema:xAL:2.0\") { address_details.render(xm) } \n end\n \n xm.Snippet(snippet.text, snippet.max_lines) unless snippet.nil?\n \n xm.LookAt { look_at.render(xm) } unless look_at.nil?\n xm.TimePrimitive { time_primitive.render(xm) } unless time_primitive.nil?\n xm.StyleSelector { style_selector.render(xm) } unless style_selector.nil?\n end", "def prepare_final_xml\n @base_xml.elements[\"#{@ns}:OccupancyLevels/#{@ns}:OccupancyLevel/#{@ns}:OccupantQuantity\"].text = @occupant_quantity if !@occupant_quantity.nil?\n @base_xml.elements[\"#{@ns}:SpatialUnits/#{@ns}:SpatialUnit/#{@ns}:NumberOfUnits\"].text = @number_of_units if !@number_of_units.nil?\n\n # Add new element in the XML file\n add_user_defined_field_to_xml_file('OpenStudioModelName', @name)\n add_user_defined_field_to_xml_file('StandardTemplateYearOfConstruction', @built_year)\n add_user_defined_field_to_xml_file('StandardTemplate', @standard_template)\n add_user_defined_field_to_xml_file('BuildingRotation', @building_rotation)\n add_user_defined_field_to_xml_file('FloorHeight', @floor_height)\n add_user_defined_field_to_xml_file('WindowWallRatio', @wwr)\n add_user_defined_field_to_xml_file('PartyWallStoriesNorth', @party_wall_stories_north)\n add_user_defined_field_to_xml_file('PartyWallStoriesSouth', @party_wall_stories_south)\n add_user_defined_field_to_xml_file('PartyWallStoriesEast', @party_wall_stories_east)\n add_user_defined_field_to_xml_file('PartyWallStoriesWest', @party_wall_stories_west)\n add_user_defined_field_to_xml_file('Width', @width)\n add_user_defined_field_to_xml_file('Length', @length)\n add_user_defined_field_to_xml_file('PartyWallFraction', @party_wall_fraction)\n add_user_defined_field_to_xml_file('ModelNumberThermalZones', @model.getThermalZones.size)\n add_user_defined_field_to_xml_file('ModelNumberSpaces', @model.getSpaces.size)\n add_user_defined_field_to_xml_file('ModelNumberStories', @model.getBuildingStorys.size)\n add_user_defined_field_to_xml_file('ModelNumberPeople', @model.getBuilding.numberOfPeople)\n add_user_defined_field_to_xml_file('ModelFloorArea(m2)', @model.getBuilding.floorArea)\n\n wf = @model.weatherFile.get\n add_user_defined_field_to_xml_file('ModelWeatherFileName', wf.nameString)\n add_user_defined_field_to_xml_file('ModelWeatherFileDataSource', wf.dataSource)\n add_user_defined_field_to_xml_file('ModelWeatherFileCity', wf.city)\n add_user_defined_field_to_xml_file('ModelWeatherFileStateProvinceRegion', wf.stateProvinceRegion)\n add_user_defined_field_to_xml_file('ModelWeatherFileLatitude', wf.latitude)\n add_user_defined_field_to_xml_file('ModelWeatherFileLongitude', wf.longitude)\n prepare_final_xml_for_spatial_element\n end", "def assemble_xml_file\n write_xml_declaration do\n # Write the xdr:wsDr element.\n write_drawing_workspace do\n if @embedded\n index = 0\n @drawings.each do |drawing|\n # Write the xdr:twoCellAnchor element.\n index += 1\n write_two_cell_anchor(index, drawing)\n end\n else\n # Write the xdr:absoluteAnchor element.\n write_absolute_anchor(1)\n end\n end\n end\n end", "def render(xm=Builder::XmlMarkup.new(:indent => 2))\n xm.instruct!\n xm.kml(:xmlns => 'http://www.opengis.net/kml/2.2'){\n objects.each { |o| o.render(xm) }\n }\n end", "def build_xml(data)\n xml_builder = Builder::XmlMarkup.new( :indent => 2 )\n xml_builder.instruct! :xml, :encoding => \"UTF-8\"\n xml_builder.xml do |xml|\n data.each do |score|\n xml.node do |node|\n node.wiersz score[:wiersz]\n node.czas score[:czas]\n node.gracz1 score[:gracz1]\n node.wynik1 score[:wynik1]\n node.gracz2 score[:gracz2]\n node.wynik2 score[:wynik2]\n node.kraj score[:kraj]\n node.liga score[:liga]\n node.data score[:data]\n end\n end\n end\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.TrackShipment do \n add_credentials(xml)\n xml.Shipment do \n xml.TrackingNumber @tracking_number\n end\n end\n end\n builder.doc.root.to_xml\n end", "def build_shipper_or_recipient_node(name, location)\n node = XmlNode.new(name) do |xml_node|\n xml_node << XmlNode.new('Contact') do |contact_node|\n contact_node << XmlNode.new('PersonName', location.name)\n contact_node << XmlNode.new('CompanyName', location.company_name) if location.company_name.present?\n contact_node << XmlNode.new('PhoneNumber', location.phone)\n end\n xml_node << XmlNode.new('Address') do |address_node|\n address_node << XmlNode.new('StreetLines', location.address1)\n if location.address2\n address_node << XmlNode.new('StreetLines', location.address2)\n end\n address_node << XmlNode.new('City', location.city)\n address_node << XmlNode.new('StateOrProvinceCode', location.state)\n address_node << XmlNode.new('PostalCode', location.postal_code)\n address_node << XmlNode.new(\"CountryCode\", location.country_code(:alpha2))\n address_node << XmlNode.new(\"Residential\", true) unless location.commercial?\n \n end\n end\n end", "def serialize\n if @doc.is_a? Enumerable\n doc = Nokogiri::XML::Document.new\n node = Nokogiri::XML::Node.new('collection', doc)\n node.add_namespace_definition(nil, 'http://www.loc.gov/MARC21/slim')\n doc.root = node\n\n @doc.map { |d| node.add_child(do_serialize(d, false).root) }\n\n doc.to_xml(indent: 2)\n else\n do_serialize(@doc, true).to_xml(indent: 2)\n end\n end", "def to_xml(options={}, &block)\n super(options.reverse_merge(:include => :parts), &block)\n end", "def create_markers\n\n trip = @itinerary.trip\n legs = @itinerary.legs\n\n markers = []\n\n if legs\n legs.each do |leg|\n\n place = {:name => leg['from']['name'], :lat => leg['from']['lat'], :lon => leg['from']['lon']}\n markers << get_addr_marker(place, 'start_leg', 'blueMiniIcon')\n\n place = {:name => leg['to']['name'], :lat => leg['to']['lat'], :lon => leg['to']['lon']}\n markers << get_addr_marker(place, 'end_leg', 'blueMiniIcon') \n\n end\n end\n\n # Add start and stop after legs to place above other markers\n place = {:name => trip.origin.name, :lat => trip.origin.lat, :lon => trip.origin.lng}\n markers << get_addr_marker(place, 'start', 'startIcon')\n place = {:name => trip.destination.name, :lat => trip.destination.lat, :lon => trip.destination.lng}\n markers << get_addr_marker(place, 'stop', 'stopIcon') \n return markers\n end", "def build_xml\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.UploadImagesRequest(xmlns: \"http://fedex.com/ws/uploaddocument/v#{Fedex::UPLOAD_IMAGES_API_VERSION}\"){\n add_web_authentication_detail(xml)\n add_client_detail(xml)\n add_version(xml)\n add_images(xml)\n }\n end\n builder.doc.root.to_xml\n end", "def add_features_to_collection(features)\n\t\tRGeo::GeoJSON::FeatureCollection.new(features)\n\tend", "def anastatica_zones_xml(image_url, zones)\n\n # the first argument is the outer zone, used for zooming\n outer_zone = zones.delete(zones.first)\n\n xml = Builder::XmlMarkup.new(:indent => 2)\n xml.dctl_ext_init{\n xml.img{\n xml.a(:r => self.id.to_s, :s => self.uri.to_s, :l => self.name, :u => image_url)\n }\n xml.xml{\n xml.a(:r => outer_zone.id.to_s, :s => outer_zone.uri.to_s, :l =>outer_zone.name, :t =>\"#{self.uri}@#{outer_zone.coordinates}\"){\n zones.each do |z|\n xml.a(:r => z.id.to_s, :s => z.uri.to_s, :l=> z.name, :t => \"#{self.uri}@#{z.coordinates}\")\n end\n }\n }\n xml.cb(:u => nil, :p => \"base64xml\")\n }\n base64 = Base64.encode64(xml.target!)\n base64.gsub(/\\s/, '')\n end", "def build_root\n root << document_properties = XML::Node.new('DocumentProperties')\n document_properties['xmlns'] = 'urn:schemas-microsoft-com:office:office'\n\n document_properties << author = XML::Node.new('Author')\n author << 'Scarlet'\n document_properties << last_author = XML::Node.new('LastAuthor')\n last_author << 'Scarlet'\n document_properties << version = XML::Node.new('Version')\n version << '12.256'\n\n root << office_document_settings = XML::Node.new('OfficeDocumentSettings')\n office_document_settings['xmlns'] = 'urn:schemas-microsoft-com:office:office'\n office_document_settings << XML::Node.new('AllowPNG')\n\n root << excel_workbook = XML::Node.new('ExcelWorkbook')\n excel_workbook['xmlns'] = 'urn:schemas-microsoft-com:office:excel'\n\n excel_workbook << window_height = XML::Node.new('WindowHeight', '20260')\n excel_workbook << window_width = XML::Node.new('WindowWidth', '29600')\n excel_workbook << window_top_x = XML::Node.new('WindowTopX', '3440')\n excel_workbook << window_top_y = XML::Node.new('WindowTopY', '-80')\n excel_workbook << XML::Node.new('Date1904')\n excel_workbook << XML::Node.new('ProtectStructure', 'False')\n excel_workbook << XML::Node.new('ProtectWindows', 'False')\n\n root << styles = XML::Node.new('Styles')\n styles << style = XML::Node.new('Style')\n style['ss:ID'] = 'Default'\n style['ss:Name'] = 'Normal'\n style << alignment = XML::Node.new('Alignment')\n alignment['ss:Vertical'] = 'Bottom'\n style << XML::Node.new('Borders')\n style << font = XML::Node.new('Font')\n font['ss:FontName'] = 'Verdana'\n style << XML::Node.new('Interior')\n style << XML::Node.new('NumberFormat')\n style << XML::Node.new('Protection')\n end", "def bounding_box\n obj = factory.parse_wkt(geometry_as_wkt)\n\n # Get the minimum bounding box for the geometry as a Polygon\n bbox = obj.envelope\n\n # Return as wsen string\n minx = bbox.coordinates[0][0][0]\n miny = bbox.coordinates[0][0][1]\n maxx = bbox.coordinates[0][1][0]\n maxy = bbox.coordinates[0][2][1]\n \"#{minx}, #{miny}, #{maxx}, #{maxy}\"\n rescue RGeo::Error::ParseError\n Geoblacklight.logger.warn \"Error parsing geometry: #{geom}\"\n default_extent\n end", "def build_xml(xml)\n check_configuration\n xml.Origins {\n xml.Quantity @origins.size\n if @origins.size > 0\n xml.Items {\n for origin in @origins\n origin.build_xml(xml)\n end\n }\n end\n }\n end", "def initialize(options = {})\n options.default! :var => 'polygon', \n :vertices => [],\n :editable => false,\n :border_colour => '#00F',\n :border_thickness => 2,\n :border_opacity => 0.5,\n :fill_colour => '#66F',\n :fill_opacity => 0.5,\n # Encode options\n :encoded => nil, \n :fill => true,\n :outline => true\n\n super\n\n if create_var?\n self.encoded = options.extract(:encoded)\n\n if self.encoded?\n self.encoded = self.encoded.arify\n else\n self.vertices = options.extract(:vertices).arify.collect do |vertex|\n Google::OptionsHelper.to_location(vertex)\n end\n end\n \n editable = options.extract(:editable)\n \n border_colour = options.extract(:border_colour) \n border_thickness = options.extract(:border_thickness) \n border_opacity = options.extract(:border_opacity)\n\n fill_colour = options.extract(:fill_colour)\n fill_opacity = options.extract(:fill_opacity)\n \n fill = options.extract(:fill)\n outline = options.extract(:outline)\n \n tooltip_options = options.extract(:tooltip)\n \n remaining_options = options\n \n if self.encoded?\n encode_options = {:polylines => Google::OptionsHelper.to_encoded_polylines(:lines => self.encoded,\n :color => border_colour,\n :opacity => border_opacity,\n :weight => border_thickness),\n :color => fill_colour, :opacity => fill_opacity,\n :fill => fill, :outline => outline}\n\n self << \"#{self.var} = new GPolygon.fromEncoded(#{encode_options.to_google_options(:dont_convert => [:polylines])});\"\n else\n self << \"#{self.var} = new GPolygon([#{self.vertices.join(', ')}], #{border_colour.to_js}, #{border_thickness.to_js}, #{border_opacity.to_js}, #{fill_colour.to_js}, #{fill_opacity.to_js}, #{remaining_options.to_google_options});\"\n end\n\n self.enable_editing! if editable\n self.set_tooltip(tooltip_options) if tooltip_options\n end\n end", "def build_xml(p_item)\r\n xml = \"<#{ELE_ITEM}>\\n\"\r\n unless p_item.id.nil?\r\n xml += \"\\t<#{ELE_ID}>#{p_item.id}</#{ELE_ID}>\\n\"\r\n end\r\n xml += \"\\t<#{ELE_TITLE}>#{p_item.title}</#{ELE_TITLE}>\\n\"\r\n xml += \"\\t<#{ELE_CREATED_ON}><![CDATA[#{format_date(p_item.created_on)}]]></#{ELE_CREATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_LAST_UPDATED_ON}><![CDATA[#{format_date(p_item.last_updated_on)}]]></#{ELE_LAST_UPDATED_ON}>\\n\"\r\n xml += \"\\t<#{ELE_FIELDS}>\\n\"\r\n p_item.get_fields.each do |name, value|\r\n xml += \"\\t\\t<#{ELE_FIELD} #{ATTR_NAME}='#{name}'><![CDATA[#{value}]]></#{ELE_FIELD}>\\n\"\r\n end\r\n xml += \"\\t</#{ELE_FIELDS}>\\n\"\r\n\r\n # add related items\r\n related_items = p_item.get_related_items\r\n unless related_items.nil? and related_items.empty?\r\n xml += \"<#{ELE_RELATED_ITEMS}>\\n\"\r\n related_items.each do |key, item_ids|\r\n xml += \"<#{key}>\\n\"\r\n item_ids.each do |item_id|\r\n xml += \"<#{ELE_ITEM}>\"\r\n xml += item_id.to_s\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end\r\n xml += \"</#{key.to_s.downcase}>\\n\"\r\n end\r\n xml += \"</#{ELE_RELATED_ITEMS}>\\n\"\r\n end\r\n\r\n # set target class\r\n unless p_item.target_class.nil?\r\n xml += \"<#{ELE_TARGET_CLASS}>\"\r\n xml += p_item.target_class\r\n xml += \"</#{ELE_TARGET_CLASS}>\"\r\n end\r\n\r\n xml += \"</#{ELE_ITEM}>\\n\"\r\n end" ]
[ "0.66493917", "0.64349955", "0.6293881", "0.6192709", "0.6188419", "0.60362005", "0.5991851", "0.5926231", "0.58944494", "0.56539595", "0.5539931", "0.55304796", "0.5376209", "0.53721005", "0.5371946", "0.537116", "0.5364192", "0.5338653", "0.5311812", "0.5276608", "0.526631", "0.5253626", "0.52520007", "0.52475166", "0.5246109", "0.5206135", "0.51890486", "0.51734626", "0.5160733", "0.51461715", "0.5118272", "0.51175505", "0.5101212", "0.5085556", "0.5071895", "0.5061727", "0.50585514", "0.50529134", "0.50232637", "0.50220203", "0.50154334", "0.50129515", "0.5004831", "0.50046873", "0.49843353", "0.49810308", "0.49765843", "0.49755025", "0.4973161", "0.497132", "0.49675044", "0.49673986", "0.4964264", "0.4964264", "0.4959181", "0.49200365", "0.49168256", "0.4914893", "0.4905227", "0.48996866", "0.4889887", "0.48741263", "0.48726597", "0.48694873", "0.48658144", "0.4865098", "0.48530188", "0.48273376", "0.48246738", "0.48226458", "0.48089275", "0.4800595", "0.47938386", "0.4774289", "0.477266", "0.47651532", "0.47555733", "0.4746579", "0.47457844", "0.47393346", "0.4738955", "0.47298118", "0.4726953", "0.47244126", "0.47230873", "0.4713235", "0.47122142", "0.47093526", "0.47087118", "0.47081292", "0.4707722", "0.46985698", "0.4697665", "0.46959344", "0.46887872", "0.46798927", "0.4678481", "0.4675654", "0.4671982" ]
0.5193002
27
Dumps points similarly to the PostGIS `ST_DumpPoints` function.
def dump_points(cur_path = []) self.each do |geom| cur_path << geom.dump_points end cur_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dump_points(cur_path = [])\n cur_path.push(self.dup)\n end", "def pp_points(points)\n \"[%s]\" % points.map { |point| \"%d: %d,%d\" % point }.join(\" \")\n end", "def save_point\n @save_points\n end", "def to_s\n @points.join(' ')\n end", "def\n\t\tprint_point\n\t\tp \"(#{x}, #{y})\"\t\n\tend", "def print_location\n\t\t@location.print_point\t\n\tend", "def marshal_dump\n [@x, @y, @grid, @generator_pointer]\n end", "def dump() end", "def points\n db[:points]\n end", "def raw(points, openclose = manage_conn)\n writer.open if openclose && writer.respond_to?(:open)\n\n begin\n [points].flatten.each { |p| writer.send_point(p) }\n ensure\n writer.close if openclose && writer.respond_to?(:close)\n end\n end", "def write_d_pt_point(index, point)\n @writer.tag_elements('c:dPt') do\n # Write the c:idx element.\n write_idx(index)\n # Write the c:spPr element.\n write_sp_pr(point)\n end\n end", "def points=(points)\n @points = []\n points.each do |point|\n @points.push(x: point[0], y: point[1])\n end\n end", "def plot_points(points = [])\n x = []\n y = []\n points << [(@parameters[:xhigh]-@parameters[:xlow])*2 + @parameters[:xhigh],\n (@parameters[:yhigh]-@parameters[:xlow])*2 + @parameters[:xhigh]] if points.empty?\n points.each do |p|\n x << p[0]\n y << p[1]\n end\n\n plot_generic(x, y, \"points pt 7\")\n end", "def points\n @obj['points']\n end", "def test_point_to_trackpoint\n pt = [-118, 34]\n waypoint = GPX::GeoJSON.send(:point_to_track_point, pt, nil)\n assert_equal(34, waypoint.lat)\n assert_equal(-118, waypoint.lon)\n end", "def test_point_to_waypoint\n pt = [-118, 34]\n waypoint = GPX::GeoJSON.send(:point_to_waypoint, pt, nil)\n assert_equal(34, waypoint.lat)\n assert_equal(-118, waypoint.lon)\n end", "def printWaypoints\n puts \"\\nWaypoints for route: #{name}\"\n waypoints.each do |waypoint|\n puts \"waypoint_id #{waypoint.id}, local_index: #{waypoint.local_index}, parent_index: #{waypoint.parent_index}\"\n puts \"latitude: #{waypoint.latitude}, longitude: #{waypoint.longitude}, height: #{waypoint.height}\"\n end\n puts \"\\n\\nWaypoints minus removed for route: #{name}\"\n waypoints_minus_removed.each do |waypoint|\n puts \"waypoint_id #{waypoint.id}, local_index: #{waypoint.local_index}, parent_index: #{waypoint.parent_index}\"\n puts \"latitude: #{waypoint.latitude}, longitude: #{waypoint.longitude}, height: #{waypoint.height}\"\n end\n puts \"\\n\"\n end", "def dump(*args)\n argv = to_pointer([\"dump\"] + args)\n rrd_dump(args.size+1, argv) == 0\n ensure\n free_pointers\n end", "def to_s\n \"#{self.point.x},#{self.point.y},#{self.width},#{self.height}\"\n end", "def dump_addr_latlng\n File.open(\"addr_latlng.yml\", 'w') do |f|\n geo = AddrLatlng.find(:all)\n geo.each do |g|\n f.puts \"#{g.id}:\"\n f.puts \" id: #{g.id}\"\n f.puts \" agent_id: #{g.agent_id}\"\n f.puts \" lat: #{g.lat}\"\n f.puts \" lng: #{g.lng}\"\n end\n end\n end", "def print_fine_points(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n grid.last.push(\"x\")\n else\n grid.last.push(\".\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\"\")}\nend", "def marshal_dump\n [@@col_map, @@location_columns, @row]\n end", "def to_p\n Point2.new(@x, @y)\n end", "def dump\n map(&:dump)\n end", "def points\n params = {}\n params[:col] = @color_by if @color_by\n params[:size] = @size_by if @size_by\n R.geom_point(E.aes(params))\n end", "def savepoint_obj(conn)\n _trans(conn)[:savepoints][-1][:obj]\n end", "def points()\n\t\t\tfilter()\n\t\t\treturn @points_floor + @points_ceil.reverse\n\t\tend", "def marshal_dump\n dump\n end", "def dump\n do_dump(0)\n end", "def to_geojson_point\n if self.longitude && self.latitude\n \"{ 'type': 'Point', 'coordinates': [#{self.longitude}, #{self.latitude}]}\"\n else\n nil\n end\n end", "def point(latitude, longitude, srid: 4326)\n st_point = <<~sql\n DECLARE @point geography = geography::STPointFromText('POINT(#{longitude} #{latitude})', #{srid});\n SELECT @point as point;\n sql\n db.fetch(st_point).first[:point]\n end", "def points; end", "def map(points)\n points\n end", "def point\n x = []\n y = []\n case geometry.type\n when 'MultiPolygon'\n coordinates.each { |list| append_list list, x, y }\n when 'LineString'\n append coordinates, x, y\n when 'Point'\n x << coordinates.first\n y << coordinates.last\n else\n append_list coordinates, x, y\n end\n lon = x.reduce(&:+) / x.size\n lat = y.reduce(&:+) / y.size\n [lon.round(7), lat.round(7)]\n end", "def write_point(key, value, timestamp, precision = DEFAULT_PRECISION)\n db.write_point(key, { value: value, time: precise_float(timestamp, precision) }, false, precision)\n end", "def point(x, y)\n primitive 'point ' + sprintf('%g,%g', x, y)\n end", "def _dump() end", "def dump!\n @dump = true\n end", "def add_point(point)\n return if point.x < 1 || point.y < 1 || point.x > @max_x-1 || point.y > @max_y-1\n if @glade['toolbar_move'].active?\n if @first_point \n @start = point\n @first_point = false\n @points = [@start]\n print\n else\n @finish = point\n @points = []\n move\n end\n elsif @glade['toolbar_record_points'].active?\n if @x_coords[point.x]\n @glade['statusbar'].push(@context, \"Este programa não suporta 2 ou mais pontos com mesma X-coordenada!\")\n else\n @points << point\n @x_coords[point.x] = point\n end\n print\n end\n end", "def print_points(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n grid.last.push(\"x\")\n else\n grid.last.push(\".\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\" \")}\nend", "def _dump(*args)\n raise \"not implemented yet\"\n end", "def points\n object.polygon.points\n end", "def to_s\n \"#{@text} (#{@points} #{Sklonyator.sklonenie(@points, 'point', 'points', 'points')})\"\n end", "def points(pts={})\n @register ||= RGeom::Register.instance\n pts.each_pair do |name,coords|\n @register[name] = Point[coords]\n end\n nil\n end", "def prepare_export_statements\n @export_point_page =\n @db.prepare(\"select lat, lon from point where (lon between ? and ?) and (lat between ? and ?) limit ? offset ?\")\n @export_point_all = @db.prepare(\"select lat, lon from point where (lon between ? and ?) and (lat between ? and ?) \")\n end", "def points(*points_or_paths)\n points = points_or_paths.flat_map { |point_or_path|\n case point_or_path\n when Draught::Pathlike\n point_or_path.points\n else\n point_or_path\n end\n }\n path_points.append(*points)\n end", "def draw_point_id(point)\n draw_point(@points[point])\n end", "def test_point_to_json\n create_model\n obj = SpatialModel.new\n assert_match(/\"latlon\":null/, obj.to_json)\n obj.latlon = @factory.point(1.0, 2.0)\n assert_match(/\"latlon\":\"POINT\\s\\(1\\.0\\s2\\.0\\)\"/, obj.to_json)\n end", "def write(points = [], openclose = manage_conn, prefix = nil)\n writer.write(points, openclose, prefix)\n end", "def create_savepoint\n execute(\"SAVEPOINT #{current_savepoint_name}\")\n end", "def to_s\n result = \"Polygon, Nr. of Points: #{@polygon_points.length}\"\n # @points.each { |point| result = result + point.to_s + ', '}\n\n return result\n end", "def to_s\n result = \"Polygon, Nr. of Points: #{@polygon_points.length}\"\n # @points.each { |point| result = result + point.to_s + ', '}\n\n return result\n end", "def points\n []\n end", "def to_s\n result = \"Waypoint \\n\"\n result << \"\\tName: #{name}\\n\"\n result << \"\\tLatitude: #{lat} \\n\"\n result << \"\\tLongitude: #{lon} \\n\"\n result << \"\\tElevation: #{elevation}\\n \"\n result << \"\\tTime: #{time}\\n\"\n SUB_ELEMENTS.each do |sub_element_attribute|\n val = send(sub_element_attribute)\n result << \"\\t#{sub_element_attribute}: #{val}\\n\" unless val.nil?\n end\n result\n end", "def create\n @post = Post.new(post_params)\n @post.user_id=params[:post][:user_id]\n @post.save\n \n\n \n @point = ['0', '0', '0', '0', '0']\n \n for i in 0..4\n @point[i] = Point.new\n end\n \n \n for i in 0..4\n @latitude = \"latitude\" + i.to_s\n @longitude = \"longitude\" + i.to_s\n @point_title = \"point_title\" + i.to_s\n @content = \"content\" + i.to_s\n @cardimg = \"cardimg\" + i.to_s\n \n if(@longitude)\n \n @point[i].latitude = params[:post][@latitude]\n @point[i].longitude = params[:post][@longitude]\n @point[i].point_title = params[:post][@point_title]\n @point[i].content = params[:post][@content]\n @point[i].cardimg = params[:post][@cardimg]\n @point[i].post_id = @post.id\n @point[i].save\n \n else\n \n end\n \n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n \n \n end\n end\n end", "def dump_pass\n addr = @linked.first\n lines = []\n\n lines.push('$%0.4x ' % addr + \" \\t.block\")\n each do |e|\n line = ('$%0.4x ' % addr).upcase\n block = false\n\n case e\n when Data, Operand\n if e.mode == :r\n bytes = e.to_a.pack('Cc').unpack('C*')\n else\n bytes = e.to_a\n end\n bytes = bytes[0...3] if bytes.size > 3\n line += bytes.to_a.collect{|e| '%0.2X' % e}.join(' ')\n line += ' ' * (9 - (3 * bytes.length))\n line += \" \\t#{e.to_source}\"\n addr += e.length\n when Align\n line += \" \\t#{e.to_source}\"\n addr = e.addr\n when Label\n line += \" #{e.to_source}\"\n when Block\n addr, lines_passed = e.dump_pass\n lines += lines_passed\n block = true\n end\n\n lines.push(line) unless block\n end\n lines.push('$%0.4x ' % addr + \" \\t.bend\")\n\n [addr, lines]\n end", "def all_points\n\t\tcase @orientation\n\t\twhen :vertical\n\t\t\tx = @points[0][:x]\n\t\t\tys = [@points[0][:y],@points[1][:y]]\n\t\t\t(ys.min..ys.max).map{|y| {:x => x, :y => y}}\n\t\twhen :horizontal\n\t\t\txs = [@points[0][:x],@points[1][:x]]\n\t\t\ty = @points[0][:y]\n\t\t\t(xs.min..xs.max).map{|x| {:x => x, :y => y}}\n\t\tend\n\tend", "def points\n [top_left, top_right, bottom_left, bottom_right]\n end", "def supports_savepoints?\n true\n end", "def supports_savepoints?\n true\n end", "def print_graph(hull,points,size)\n lines = []\n hull.each do |line|\n lines.push([point_os(line.first,5),point_os(line.last,5)])\n end\n h_points = hull_points(hull)\n points = points - h_points\n\n data = []\n points.each do |point|\n data.push(point_os(point,0.1))\n end\n h_points.each do |point|\n data.push(point_os(point,10))\n end\n\n draw_graph(700,700,size,data,lines)\nend", "def marshal_dump()\n\t\treturn [@lines, @columns, @stack]\n\tend", "def save_points_to_file(file_name, options = {operation: 'w'}) # w for write\n record = @fumeology_record\n record = @fumeology_changes if options[:operation] == 'a'\n open(file_name, options[:operation]) do |f|\n record.each do |point|\n line = ''\n point.herb_combination.each do |herb|\n line << \"#{herb}\"\n line << ', ' unless point.herb_combination.last == herb\n end\n f << \"#{line}\\n\"\n end\n end\n file_name\n end", "def mongoize\n if @points.empty?\n []\n else\n {\n type: \"LineString\",\n coordinates: @points.to_a\n }\n end\n end", "def dump_profile(_profile); end", "def _dump\n end", "def display_coordinates\n puts 'persons'\n @all_persons.each do |person|\n puts \"X: #{person.get_x_location} \\nY: #{person.get_y_location}\\n\"\n end\n puts 'MONSTERS'\n @all_monsters.each do |monster|\n puts \"X: #{monster.get_x_location} \\nY: #{monster.get_y_location}\\n\"\n end\n puts 'STRAWBERRIES'\n @all_strawberries.each do |strawberry|\n puts \"X: #{strawberry.get_x_location} \\nY: #{strawberry.get_y_location}\\n\"\n end\n puts 'MUSHROOMS'\n @all_mushrooms.each do |mushroom|\n puts \"X: #{mushroom.get_x_location} \\nY: #{mushroom.get_y_location}\\n\"\n end\n end", "def get_print_url()\n points = self.arrOfPoints \n #coordinates of the retailer hardcoded at [30.199,31.002]\n url = \"http://maps.google.com/maps?f=d&source=s_d&saddr=30.199,31.002\" \n len = points.size\n len.times do |i|\n if i == 0\n url << \"&daddr=\"\n end\n url << arrOfPoints[i]*\",\".sub( \" \", \"+\" )\n if i != (len - 1) \n url << \"+to:\" \n end\n end\n url << \"+to:30.199,31.002&ie=UTF8&z=10&pw=2&hl=en\" \n return url\n end", "def print_shape()\n puts \"shape type: #{type}\"\n @squares.each do |sq|\n puts \"point: #{sq.x}, #{sq.y}\"\n end\n end", "def all_points\n\t\tcurrent_member = @current_member\n\t\t@semesters = Semester.order(:start_date)\n\t\t@semester_point_hash = Hash.new\n\t\t@semesters.each do |semester|\n\t\t\t@semester_point_hash[semester.id] = Member.current_members(semester).map{|m| {'name'=>m.name, 'id'=>m.id, 'points'=>m.total_points(semester)}}\n\t\t\t@semester_point_hash[semester.id].sort! { |a,b| a['points'] <=> b['points'] }.reverse!\n\t\tend\n\t\t@semester_point_json = @semester_point_hash.to_json\n\tend", "def dumpPpms()\r\n $LOG.debug \"PpmContext::dumpPpms()\"\r\n 79.times {print \"=\"}\r\n puts\r\n puts \"PPM DUMP\".center(80)\r\n 79.times {print \"=\"}\r\n puts\r\n\r\n if(@ppms.length > 0)\r\n ppms = @ppms.sort\r\n ppms.each do |key, ppm|\r\n puts \"#{ppm.name}\\t(#{ppm.alias})\"\r\n end\r\n\r\n else\r\n puts \"No PPM variables to dump.\"\r\n end\r\n\r\n puts \"\"\r\n end", "def points\n @points ||= begin\n h = Hash.new\n Point::ABS_POINTS_DATA.each do |pt_name|\n h.merge!(pt_name => Point.new(film, pt_name))\n end\n h\n end\n end", "def _dump()\n #This is a stub, used for indexing\n end", "def records\n @points\n end", "def points #:nodoc:\n [self]\n end", "def points #:nodoc:\n [self]\n end", "def print\n @planning.draw\n @segments.each do |s|\n s.draw(@drawer)\n end\n @points.each do |p|\n @drawer.draw_circle(p.x, p.y, 3)\n end\n end", "def dump_to_s\n output = \"\\r\\n---- Factory dump: ----\"\n @context_list.each do |context_key, context|\n if context.parent_context.instance_of?( V3::ContextDAO )\n output << \"\\r\\n(#{context.parent_context.id}) => '#{context_key}': #{ context }\"\n else\n output << \"\\r\\n'#{context_key}': #{ context }\"\n end\n end\n output << \"\\r\\n\"\n @entity_list.each do |entity_key, entity|\n output << \"\\r\\n'#{entity_key}': #{ entity }\"\n end\n output << \"\\r\\n-----------------------\\r\\n\"\n output\n end", "def to_openscad\n \"[#{points.collect { |p| p.to_openscad }.join(', ')}]\"\n end", "def points(dc, data, target)\n platform_points(dc, screen_points(dc, data, target))\n end", "def serialize_as_points\n points = []\n @metrics.each do |metric_name, metric_value|\n points << {\n :measurement => metric_name,\n :tags => @tags,\n :fields => {\n :value => metric_value.to_f\n }\n }\n end\n\n return points\n end", "def as_line_string\n GeoRuby::SimpleFeatures::LineString.from_points(@points)\n end", "def dump(spot)\n return if spot.empty?\n \n window, spot_id = ensure_clickable(spot)\n @client.send_packet Packet::ClickWindow.new(window.id, spot_id, :left, new_transaction, false, spot.item)\n @client.send_packet Packet::ClickWindow.outside(new_transaction)\n spot.item = nil\n end", "def emit_points(metric, points, options= {})\n scope = override_scope options\n\n points.each do |p|\n p[0].kind_of? Time or raise 'Not a Time'\n p[0] = p[0].to_i\n p[1] = p[1].to_f # TODO: stupid to_f will never raise an exception\n end\n\n @metric_svc.submit(metric, points, scope, options)\n end", "def send_point(point)\n if opts[:noop]\n logger.log \"Would send: #{point}\"\n return\n end\n\n logger.log(\"Sending: #{point}\", :debug)\n writer.send_point(point)\n end", "def drawPathWithPoints(points, image:image)\n screenSize = self.view.frame.size\n UIGraphicsBeginImageContext(screenSize)\n context = UIGraphicsGetCurrentContext()\n image.drawInRect(CGRectMake(0, 0, screenSize.width, screenSize.height))\n\n CGContextSetLineCap(context, KCGLineCapRound)\n CGContextSetLineWidth(context, LINE_WIDTH)\n CGContextSetRGBStrokeColor(context, 0, 0, 1, 1)\n CGContextBeginPath(context)\n\n count = points.count\n point = points[0].CGPointValue\n CGContextMoveToPoint(context, point.x, point.y)\n 1.upto(count - 1) do |i|\n point = points.objectAtIndex(i).CGPointValue\n CGContextAddLineToPoint(context, point.x, point.y)\n end\n CGContextStrokePath(context)\n\n ret = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n ret\n end", "def marshal_dump\n return [@scale, @map_width, @map_height, @layer, @scroll_x, @scroll_y]\n end", "def point_keys\n @_point_keys\n end", "def _dump(level) # :nodoc:\n Marshal.dump({'rows' => rows, 'cols' => cols, 'data' => to_a})\n end", "def _dump(level) # :nodoc:\n Marshal.dump({'rows' => rows, 'cols' => cols, 'data' => to_a})\n end", "def curve_points(points)\n cur_page.curve_points(points)\n end", "def dump\n super\n\n puts \"fsp header:\"\n pp fsp_header\n puts\n\n puts \"xdes entries:\"\n each_xdes do |xdes|\n pp xdes\n end\n puts\n end", "def to_s\n \"Point3: x #{x} y #{y} z #{z}\"\n end", "def print_graph\n @vertex_array.each do |vertex|\n print \"#{vertex.name} points to: \"\n vertex.print_outgoing\n puts ''\n end\n end", "def kml_representation(options = {}) #:nodoc:\n out = \"<Point#{options[:id_attr]}>\\n\"\n out += options[:geom_data] if options[:geom_data]\n out += \"<coordinates>#{x},#{y}\"\n out += \",#{options[:fixed_z] || z || 0}\" if options[:allow_z]\n out += \"</coordinates>\\n\"\n out + \"</Point>\\n\"\n end", "def create\n @point = Point.new(params[:point])\n\n respond_to do |format|\n if @point.save\n format.html { redirect_to([@layer, @point], :notice => 'Point was successfully created.') }\n format.xml { render :xml => @point, :status => :created, :location => @point }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @point.errors, :status => :unprocessable_entity }\n end\n end\n end", "def supports_savepoints?\n false\n end", "def supports_savepoints?\n false\n end", "def doubling_points(points, mode)\n result = mode.round points.all\n result *= 2 if @mode.instance_of? DoubleMode\n result *= 4 if @mode.instance_of? RedoubleMode\n\n result\n end", "def _dump(arg0)\n end" ]
[ "0.6411781", "0.6126447", "0.6121726", "0.5772761", "0.5558724", "0.5546756", "0.5493614", "0.543597", "0.5423503", "0.5344848", "0.52858406", "0.52596927", "0.52544564", "0.5251316", "0.52197444", "0.52121836", "0.52052927", "0.52044517", "0.5167359", "0.516649", "0.51576203", "0.51452065", "0.51145625", "0.5111723", "0.51097953", "0.510797", "0.5077872", "0.5076232", "0.50712234", "0.5064428", "0.50536674", "0.50513303", "0.5037074", "0.5019375", "0.50193083", "0.5015163", "0.4995934", "0.49941435", "0.49933434", "0.49908602", "0.49828988", "0.49735156", "0.49663943", "0.49568254", "0.49543378", "0.49471188", "0.49311358", "0.4910002", "0.49074358", "0.48721427", "0.4869953", "0.4869953", "0.4868686", "0.48654273", "0.48542666", "0.485277", "0.4850478", "0.4849316", "0.48401552", "0.48401552", "0.4836561", "0.48306173", "0.4827903", "0.4823407", "0.48122332", "0.48052734", "0.48018757", "0.48012957", "0.47917575", "0.47893134", "0.47861987", "0.47768998", "0.4769341", "0.47619212", "0.4758075", "0.4758075", "0.47498867", "0.47441462", "0.47410527", "0.4733372", "0.4726636", "0.47147596", "0.46997976", "0.46900398", "0.46835622", "0.4682779", "0.46640396", "0.46570277", "0.46543398", "0.46543398", "0.4645543", "0.4644761", "0.46402702", "0.46378198", "0.46331555", "0.4618699", "0.4615864", "0.46124586", "0.46115735", "0.46076477" ]
0.760294
0
Obtain IP address from http request header
def src_addr_on_header request.headers['X-Forwarded-For'] || request.headers['REMOTE_ADDR'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_ip\n return request.headers[\"X-Forwarded-For\"] if request.headers[\"X-Forwarded-For\"]\n return request.headers[\"REMOTE_ADDR\"] if request.headers[\"REMOTE_ADDR\"]\n end", "def get_ip_address\n request.remote_ip\n end", "def parse_ip\n @request[FHOST] || BLANK_STR\n end", "def ip\n request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip \n end", "def get_ip_address \t\t\t\n\t\trequest.remote_ip \n\tend", "def ipaddress\n @network_payload['IP']\n end", "def ip(args = nil)\n if args and args[:meta]\n meta = args[:meta]\n elsif httpsession = Thread.current[:hayabusa][:httpsession]\n meta = httpsession.meta\n else\n raise \"Could not figure out meta-data.\"\n end\n \n if !meta[\"HTTP_X_FORWARDED_FOR\"].to_s.strip.empty? and ips = meta[\"HTTP_X_FORWARDED_FOR\"].split(/\\s*,\\s*/)\n return ips.first.to_s.strip\n elsif ip = meta[\"REMOTE_ADDR\"].to_s.strip and !ip.empty?\n return ip\n else\n raise \"Could not figure out IP from meta-data.\"\n end\n end", "def client_ip\n req = request\n return nil unless req\n # Look for an external address being forwarded\n split_ips = []\n PREFFERED_IP_HEADERS.each do |header_name|\n forwarded = req.env[header_name]\n ips = split_ip_addresses(forwarded)\n lip = ips.find { |ip| (ip !~ TRUSTED_PROXIES) && valid_ip?(ip) }\n split_ips << ips unless ips.empty?\n return lip unless lip.nil?\n end\n # Else fall back to declared remote addr\n r = req.env['REMOTE_ADDR']\n # If this is localhost get the last hop before\n if r.nil? || r =~ LOCALHOST\n split_ips.each do |ips|\n lip = ips.find { |ip| (ip !~ LOCALHOST) && valid_ip?(ip) }\n return lip unless lip.nil?\n end\n end\n r\n end", "def remote_ip\n return @headers['HTTP_CLIENT_IP'] if @headers.include?('HTTP_CLIENT_IP')\n\n if @headers.include?('HTTP_X_FORWARDED_FOR') then\n remote_ips = @headers['HTTP_X_FORWARDED_FOR'].split(',').reject do |ip|\n ip =~ /^unknown$/i or local_net?(ip)\n end\n\n return remote_ips.first.strip unless remote_ips.empty?\n end\n\n return @headers['REMOTE_ADDR']\n end", "def remote_addr_header; end", "def user_ip\n \trequest.location\n end", "def rack_client_ip\n req = request\n return nil unless req\n return req.ip if req.respond_to?(:ip)\n req.env['REMOTE_ADDR']\n end", "def ip\n if ifconfig =~ /inet addr:([0-9.]+)/\n $1\n else\n \"0.0.0.0\"\n end\n end", "def obtain_ip_from_rack(env)\n Rack::Request.new(env).ip\n end", "def ip\n @data[\"ip\"]\n end", "def request_ip(env)\n obtain_ip_from_rails(env) || obtain_ip_from_rack(env)\n end", "def hostip(ip)\n if GeoLocation::dev.nil? || GeoLocation::dev.empty?\n url = \"http://api.hostip.info/?ip=#{ip}\"\n uri = URI.parse(url) \n data_from_hostip_http_response(ip, Net::HTTP.get_response(uri).body)\n else\n data_from_maxmind_http_response(ip, GeoLocation::dev)\n end\n end", "def extract_ip(addrinfo)\n addrinfo[2]\n end", "def ip\n if (ip = @host.at('tag[name=host-ip]'))\n ip.inner_text\n end\n end", "def identify( request_env )\n return request_env['HTTP_X_FORWARDED_FOR'] || request_env['REMOTE_ADDR'], request_env['HTTP_USER_AGENT']\n end", "def get_ip_address\n rpc_get_fact_direct('host_ip')\n end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def ip_address; end", "def get_public_ip()\n return open('http://ipinfo.io/ip').read.chomp\n end", "def remote_ip\n request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip\n end", "def hostip\n static_network_config[\"ipAddress\"]\n end", "def remote_ip\n return request.env['HTTP_X_FORWARDED_FOR'] if request.env['HTTP_X_FORWARDED_FOR']\n return request.remote_ip\n end", "def ip_address(env)\n ip_address_record(env)[:address]\n end", "def host_ip\n Socket.gethostbyname(@backend.host)[3].unpack('CCCC') rescue [0, 0, 0, 0]\n end", "def locate_by_ip\n request.location\n end", "def remote_ip\n return env['HTTP_CLIENT_IP'] if env.include? 'HTTP_CLIENT_IP'\n\n if env.include? 'HTTP_X_FORWARDED_FOR' then\n remote_ips = env['HTTP_X_FORWARDED_FOR'].split(',').reject do |ip|\n ip =~ /^unknown$|^(10|172\\.16|192\\.168)\\./i\n end\n\n return remote_ips.first.strip unless remote_ips.empty?\n end\n\n return env['REMOTE_ADDR']\n end", "def ip; end", "def ip; end", "def ipaddr; end", "def get_remote_ip(env)\n# X-Forwarded-For provides a list of IP addresses, from the calling client to the last proxy:\n# X-Forwarded-For: client1, proxy1, proxy2\n if addr = env['HTTP_X_FORWARDED_FOR']\n addr.split(',').first.strip\n else\n env['REMOTE_ADDR'] # Only gives the IP address of the last proxy.\n end\nend", "def host\n @headers['HTTP_X_FORWARDED_HOST'] || @headers['HTTP_HOST'] \n end", "def name\n ip_address\n end", "def hashed_ip\n Hmac.instance.hash request.remote_ip\n end", "def name\n ip_address\n end", "def ip\n @attributes[:ip]\n end", "def ip\n @attributes[:ip]\n end", "def ipaddr?; end", "def ipaddress\n config[\"ipaddress\"]\n end", "def ip\n TestLab::Utility.ip(self.address)\n end", "def external_ip\n begin\n ip = OpenURI.open_uri(\"http://myip.dk\") {|f|f.read.scan(/([0-9]{1,3}\\.){3}[0-9]{1,3}/); $~.to_s}\n rescue\n ip = local_ip\n puts \"Seems like there is a problem adquiring external IP address, ...using local address: (#{ip})\"\n end\n ip\n end", "def ip\n arp = Cheetah.run([\"arp\", \"-n\"], stdout: :capture)\n entry = arp.lines.find { |a| a.include?(mac) }\n return nil if entry.nil?\n entry.split(\" \")[0]\n end", "def public_ip() ; info[:public_ip] ; end", "def ip\n ''\n end", "def getIp()\n return @ip\n\tend", "def obtain_ip_from_rails(env)\n env[\"action_dispatch.remote_ip\"].try(:to_s)\n end", "def clientip\n localhost ? local_ip : request.remote_ip\n end", "def ip\n TestLab::Utility.ip(self.address)\n end", "def host_on_header\n request.headers['HTTP_HOST']\n end", "def read_host_ip\n ip = read_machine_ip\n base_ip = ip.split(\".\")\n base_ip[3] = \"1\"\n base_ip.join(\".\")\n end", "def public_ip\n get('tools/public_ip').body['ipv4'] || get('tools/public_ip').body['ipv6']\n end", "def rails_client_ip\n req = request\n return unless req && req.env\n remote_ip = req.env['action_dispatch.remote_ip']\n return unless remote_ip\n # FIXME: - this exist only since Rails 3.2.1\n # http://apidock.com/rails/v3.2.1/ActionDispatch/RemoteIp/GetIp/calculate_ip\n return remote_ip.calculate_ip if remote_ip.respond_to?(:calculate_ip)\n # This might not return the same value as calculate IP\n remote_ip.to_s\n end", "def server_ip_address\n $tracer.trace(__method__)\n begin\n return meta.name(\"WT.sv\").content.strip\n rescue\n return \"Unknown IP Address\"\n end\n end", "def ip\n self.IP\n end", "def ip\n @ip ||= @node.search('IP/listEntry').map(&:inner_text)\n end", "def ip_address\n Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address\n end", "def device_ipaddress; end", "def device_ipaddress; end", "def public_ip_address\n data[:public_ip_address]\n end", "def get_ip(node)\n provisioning.ipaddress(node)\n end", "def my_ip\n get(\"/tools/myip\")\n end", "def ip\n @ip ||= Socket.ip_address_list.detect{|intf| intf.ipv4_private?}.ip_address\n end", "def ip_v4_address; end", "def get_public_ip_address\n rpc_get_fact_direct('public_ip')\n end", "def get_public_ip_address\n get_proxy.get_public_ip_address\n end", "def remote_ip\n if request.remote_ip == '127.0.0.1'\n # Hard coded remote address\n '18.228.1.115'\n else\n request.remote_ip\n end\n end", "def ip\n nil\n end", "def ip\n @values.fetch('ai.device.ip') { \n @values['ai.device.ip'] = nil\n }\n end", "def get_ip_address\n items = `ifconfig | grep \"inet addr\"`.split\n addresses = []\n items.each do |item|\n addresses << item if item =~ /addr:/\n end\n ip = \"\"\n addresses.each do |address|\n ip = address.split(':')[1]\n if ip != '127.0.0.1'\n break\n end\n end\n ip\nend", "def remote_ip\n return self[\"client-ip\"] || @forwarded_for || @peeraddr[3]\n end", "def ip\n render text: local_ip\n end", "def remote_ip; end", "def ipsource\n lanconfig[\"ip address source\"].downcase!\n end", "def getIP(interface)\n cmd = `ip addr show #{interface}`\n ip = cmd.match(/inet ((\\d{1,3}\\.){3}\\d{1,3})\\/\\d{1,2}/).captures\n @log.debug \"IP of interface '#{interface}' is: #{ip.first}\"\n return ip.first\n end", "def ip_address\n nil\n end", "def arp_src_ip; self[:arp_src_ip].to_s; end", "def remote_addr_header=(_arg0); end", "def query_ip\n @attributes[:query_ip]\n end", "def lookup_ip_location\n if Rails.env.development? || Rails.env.test?\n Geocoder.search(request.remote_ip).first\n else\n request.location\n end\n end", "def address(public_ip)\n addresses(public_ip)[0]\n end", "def mock_ip_address\n if Rails.env == 'development' || Rails.env == 'cucumber' || Rails.env == 'test'\n test_ip = ENV['RAILS_TEST_IP_ADDRESS']\n unless test_ip.nil? or test_ip.empty?\n request.instance_eval <<-EOS\n def ip\n \"#{test_ip}\"\n end\n EOS\n end\n end\n end", "def get_ip(ip_name, resource_group = armrest_configuration.resource_group)\n get(ip_name, resource_group).properties.ip_address\n end", "def current_ip(inter)\n net_info = `ifconfig`\n section_index = net_info.index(inter)\n line_index = net_info.index('inet', section_index)\n ip_address = net_info[line_index..-1].match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)[0]\n return ip_address\nend", "def localIP\r\n @@local_ip_address\r\n end", "def ip_address\n @ip_address ||= nil\n end", "def ipaddress\n @attributes.fetch('ipaddress', nil)\n end", "def get_ip(remote_address)\n return \"\" unless remote_address\n\n #Capture the first three octects of the IP address and replace the forth\n #with 0, e.g. 124.455.3.123 becomes 124.455.3.0\n regex = /^([^.]+\\.[^.]+\\.[^.]+\\.).*/\n if matches = remote_address.scan(regex)\n return matches[0][0] + \"0\"\n else\n return \"\"\n end\nend", "def data_from_hostip_http_response(ip, body)\n location = Nokogiri::HTML.parse(body)\n \n hostip = location.at(\"hostip\")\n return nil if hostip.nil?\n \n data = {}\n \n element = hostip.at('name')\n data[:city] = element.text.split(', ')[0].titleize\n data[:region] = element.text.split(', ')[1]\n\n element = hostip.at('countryabbrev')\n data[:country_code] = element.text\n data[:country] = country(element.text)\n\n element = hostip.at( \"point coordinates\" )\n if element\n data[:longitude], data[:latitude] = element.text.split(',')\n end\n \n data[:ip] = ip\n # data[:timezone] = timezone(data[:country_code], data[:region])\n \n data\n end", "def peer_ip; end", "def get_internal_ip_address\r\n sock = UDPSocket.new\r\n sock.connect('1.0.0.1', 1) #@igd_location.split('//').last.split('/').first.split(':').first\r\n return sock.addr.last\r\n rescue Exception\r\n return \"127.0.0.1\"\r\n end", "def to_ipaddr\n unless ip_addr?\n lookup = `host #{to_s} | grep address`.split(/\\s+/)\n return to_s unless lookup.length == 4\n lookup[3]\n else \n to_s\n end\n end", "def request_address\n address.split('@').join(\"-request@\")\n end" ]
[ "0.7722499", "0.75440204", "0.75008315", "0.7356482", "0.7319257", "0.7288718", "0.7276756", "0.7239505", "0.72183764", "0.72174376", "0.7175481", "0.7157487", "0.71513623", "0.7093448", "0.7081977", "0.6993343", "0.6965759", "0.69640845", "0.6960995", "0.6924997", "0.6917261", "0.6901171", "0.6901171", "0.6901171", "0.6901171", "0.6901171", "0.6901171", "0.68573934", "0.68363833", "0.6807634", "0.67873424", "0.67035186", "0.66848433", "0.66788435", "0.66744673", "0.6671011", "0.6671011", "0.6646997", "0.65530103", "0.6538965", "0.6510984", "0.6503868", "0.64974904", "0.6490714", "0.6490714", "0.6484865", "0.64784795", "0.6473097", "0.6457608", "0.64416", "0.64091784", "0.64003927", "0.6388308", "0.63801676", "0.6374404", "0.6363581", "0.6356692", "0.6353424", "0.63396895", "0.6325375", "0.6322935", "0.6309322", "0.63002807", "0.630022", "0.62956464", "0.62956464", "0.62874734", "0.6275347", "0.6274608", "0.62732524", "0.62729067", "0.62691194", "0.62676513", "0.62622535", "0.6253864", "0.6237439", "0.6236617", "0.6231857", "0.62294173", "0.6214569", "0.6210454", "0.619416", "0.6192157", "0.6188583", "0.61770487", "0.6165224", "0.61625713", "0.6149982", "0.61469096", "0.61267775", "0.6115094", "0.6100776", "0.6098698", "0.6093169", "0.606128", "0.6054919", "0.6050886", "0.6045162", "0.60424966", "0.6038783" ]
0.7665337
1
Obtain HOST FQDN from http request header
def host_on_header request.headers['HTTP_HOST'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host\n @headers['HTTP_X_FORWARDED_HOST'] || @headers['HTTP_HOST'] \n end", "def hostname\n (request.env['HTTP_X_FORWARDED_SERVER'] =~ /[a-z]*/) ? request.env['HTTP_X_FORWARDED_SERVER'] : request.env['HTTP_HOST']\n end", "def host\n @request['Host']\n end", "def hostname\n protocol = request.headers['HTTP_X_FORWARDED_PROTO'] ||\n request.protocol ||\n 'http'\n protocol += '://' unless protocol.match?(%r{://})\n\n \"#{protocol}#{request.host}\"\n end", "def host_header\n conf['host_header'] || '*'\n end", "def host\n request.host\n end", "def remote_addr_header; end", "def hostname\n v = self.host\n v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v\n end", "def normalized_host; end", "def hostname\n if (host = @host.at('tag[name=host-fqdn]'))\n host.inner_text\n end\n end", "def hostname\n Resolv.getname(ip_address) rescue nil\n end", "def src_addr_on_header\n request.headers['X-Forwarded-For'] || request.headers['REMOTE_ADDR']\n end", "def lookup_hostname(host)\n Socket.getaddrinfo(host, nil, nil, Socket::SOCK_STREAM)[0][3]\n rescue SocketError\n raise(InvalidHostname, Errstr::INVALID_HOST % host)\n end", "def local_host\n get('beef.http.host') || '0.0.0.0'\n end", "def public_hostname\n get_proxy.get_public_hostname\n end", "def host\n _, _, host, = URI.split url\n host\n end", "def env_header(name)\n \"http-#{name}\".upcase!.tr('-', '_')\n end", "def full_host\n if(request.host =~ /^localhost/ && request.port != 80)\n \"#{request.host}:#{request.port}\"\n else\n request.host\n end\n end", "def parse_ip\n @request[FHOST] || BLANK_STR\n end", "def external_fqdn() ; info[:external_fqdn] ; end", "def host_url\n proto = request.env['SERVER_PROTOCOL'].downcase.index(\"https\").nil? ? \"http\" : \"https\"\n return \"#{proto}://#{request.env['HTTP_HOST']}\"\n end", "def getHost()\n return @uri.host\n end", "def host\n\t\t\t# FIXME: This is both a hack and the best way I know to do this.\n\t\t\tSocket.getaddrinfo(Socket.gethostname, 0)[0][2]\n\t\tend", "def hostname\n if resolution = CloudModel::AddressResolution.where(ip: ip).first\n resolution.name\n else\n begin\n Resolv.getname(ip)\n rescue\n ip\n end\n end\n end", "def public_host\n get('beef.http.public.host')\n end", "def extract_host(u)\n URI.split(u).compact[1]\n end", "def hostname\n Socket.gethostname.split('.').first.strip\n end", "def host\n \"#{request.env['rack.url_scheme']}://#{request.host}:#{request.port}\".sub(':80','')# rescue 'http://locahost:3000'\n end", "def host\n return @forwarded_host || @host\n end", "def get_host_name(url)\n\tmatch = %r|(https?://)?(?<host>[^/]+)(/.*$)?|.match(url)\n\tmatch['host']\nend", "def hostname\n @hostname ||= `hostname`.strip\n end", "def get_fqdn(ip)\n begin\n resp = Socket.getaddrinfo(ip, nil)\n rescue\n return nil\n end\n fqdn = resp[0][2]\n nip = resp[0][3]\n return nil if (fqdn == nip)\n return fqdn\nend", "def get_fqdn(ip)\n begin\n resp = Socket.getaddrinfo(ip, nil)\n rescue\n return nil\n end\n fqdn = resp[0][2]\n nip = resp[0][3]\n return nil if (fqdn == nip)\n return fqdn\nend", "def extract_host(u)\n URI.split(u).compact[1]\n end", "def deduce_tenant_host\n if request.host.downcase.start_with?('www.')\n request.host[4..-1]\n else\n request.host\n end\n end", "def build_hostname\n hostname\n end", "def determine_hostname\n @info[:hostname] = @shell.query('HOST', 'hostname')\n end", "def canonical\n dns_host_name\n end", "def get_host\n @host\n end", "def host\n @host ||= target.split(':',2).first\n end", "def resolve_hostname_on(host, hostname)\n match = curl_on(host, \"--verbose #{hostname}\", accept_all_exit_codes: true).stderr.match(ipv4_regex)\n match ? match[0] : nil\n end", "def host\n URI.parse(@url).host\n end", "def current_host\n request.host\n end", "def host_as_string; end", "def get_public_hostname\n rpc_get_fact_direct('public_hostname')\n end", "def ssh_host_name( host )\n # This is included here for expected Space-wide policy settings.\n host[ :internet_name ] || host[ :internet_ip ] || host.name\n end", "def hostname\n Socket.gethostname\n end", "def hostname\n Socket.gethostname\n end", "def header(name)\n rack_header = \"http-#{name}\".upcase!.tr('-', '_')\n\n hdr = @env[rack_header]\n\n # Only return the value if it is not an empty string\n hdr if hdr != ''\n end", "def get_event_host(host)\n unless options[:fqdn]\n return host.split('.')[0]\n end\n return host\n end", "def host\n attributes['host']\n end", "def get_server_hostname\n (`hostname`).strip\n end", "def hostname\n Socket.gethostname\n end", "def host\n Socket.gethostname\n end", "def host\n Socket.gethostname\n end", "def url_host(url)\n (url.match(REGEX_URL_HOST) || [])[1]\n end", "def hostname(ip_address)\n @resolver.getname(ip_address).to_s\n rescue\n 'IP address not found'\n end", "def lookup_hostname(endpoint)\n @resolved_hostnames.select{ |k,v| v.include?(endpoint) }.shift[0]\n end", "def hostname\n @hostname ||= `hostname`.chomp\n end", "def lookup(request)\n\t\t\t\t# Trailing dot and port is ignored/normalized.\n\t\t\t\tif authority = request.authority&.sub(/(\\.)?(:\\d+)?$/, '')\n\t\t\t\t\treturn @hosts[authority]\n\t\t\t\tend\n\t\t\tend", "def link_host\n return if field['u'].nil?\n\n @link_host ||= begin\n # Not sure why I need this, but it fails on certain URLs w/o it. The link printed still has character in it\n fixed_url = field['u'].gsub('^', '').strip\n link = URI.parse(fixed_url)\n\n return link.host unless PROXY_URL_REGEX.match?(link.to_s) && link.to_s.include?('url=')\n\n proxy = CGI.parse(link.query.force_encoding(Encoding::UTF_8))\n return link.host unless proxy.key?('url')\n\n extracted_url = URI.extract(proxy['url'].first).first\n return link.host unless extracted_url\n\n URI.parse(extracted_url).host\n rescue URI::InvalidURIError\n return nil\n end\n end", "def request_subdomain\n request.host.split(/\\./).first\n end", "def host\n M_BCOM_VALID_URL.match(url)[:host]\n end", "def host_for(request)\n (request.ssl? ? 'https://ssl' : 'http://www') + '.google-analytics.com'\n end", "def dns_host_name\n @dns_host_name ||= ::SimpleIDN.to_ascii(@host_name)\n end", "def host_from_fqdn(question)\n domains.each do |domain|\n dd = dotted_domain(domain)\n if question.index(dd)\n host = question[0, question.index(dd)]\n end\n end\n nil\n end", "def hostname; end", "def hostname; end", "def hostname\n return @hostname\n end", "def match_hostname( val )\n\t\tmatch = RFC1738Hostname.match( val )\n\t\treturn match ? match[0] : nil\n\tend", "def host\n domain\n end", "def hostname\n @options[:host][:name] if @options[:host]\n end", "def client_hostname\n @opts[:hostname]\n end", "def hostname(value)\n value || BASE_URI\n end", "def build_host\n @header.build_host\n end", "def test_broken_ipv6_host_header\n parser = HttpParser.new\n req = parser.env\n parser.buf << \"GET / HTTP/1.1\\r\\nHost: [::1:\\r\\n\\r\\n\"\n assert_equal req, parser.parse\n assert_equal \"[\", req['SERVER_NAME']\n assert_equal ':1:', req['SERVER_PORT']\n assert_equal \"[::1:\", req['HTTP_HOST']\n assert_equal \"\", parser.buf\n end", "def uri_host; end", "def remote_addr_header=(_arg0); end", "def identify( request_env )\n return request_env['HTTP_X_FORWARDED_FOR'] || request_env['REMOTE_ADDR'], request_env['HTTP_USER_AGENT']\n end", "def env_name(header_name)\n \"HTTP_#{header_name.upcase.gsub(/-/, '_')}\"\n end", "def host\n URI(self.uri).host\n end", "def get_host(endpoint)\n puts \"recieved : \"+ endpoint.to_s\n puts \"port : \"+ endpoint.port.to_s\n if endpoint.port\n if ((endpoint.port == 443) || (endpoint.port == 80))\n return endpoint.host\n else\n return endpoint.host + \":\" + endpoint.port.to_s\n end\n else\n #return endpoint.host\n return endpoint.host + \":\" + endpoint.port.to_s\n end\n end", "def hostname\n hostname = nil\n run \"hostname\" do |channel, stream, data|\n hostname = data.chomp\n end\n hostname\n end", "def get_host(fqdn)\n foreman('GET', \"/api/hosts/#{fqdn}\")\n end", "def get_host_details\n @host = find_host_by_spoof || find_host_by_token || find_host_by_ip_or_mac\n unless @host\n logger.info \"#{controller_name}: unable to find a host that matches the request from #{request.env['REMOTE_ADDR']}\"\n head(:not_found) and return\n end\n unless @host.operatingsystem\n logger.error \"#{controller_name}: #{@host.name}'s operating system is missing!\"\n head(:conflict) and return\n end\n unless @host.operatingsystem.family\n # Then, for some reason, the OS has not been specialized into a Redhat or Debian class\n logger.error \"#{controller_name}: #{@host.name}'s operating system [#{@host.operatingsystem.fullname}] has no OS family!\"\n head(:conflict) and return\n end\n logger.info \"Found #{@host}\"\n end", "def hostname\n session.transport.socket.client_name\n end", "def private_hostname_of(server)\n server[:fqdn]\n end", "def fqdn\n ssh.exec!(\"hostname --fqdn\").chomp\n end", "def host\n attribute_part('subject', 'CN')\n end", "def host=(host_header)\n @request_headers['Host'] = host_header\n @request = Net::HTTP::Get.new(@uri.request_uri, @request_headers)\n end", "def resolve_fqdn\n hostname = from_cmd(\"hostname\")\n addrinfo = Socket.getaddrinfo(hostname, nil).first\n iaddr = IPAddr.new(addrinfo[3])\n Socket.gethostbyaddr(iaddr.hton)[0]\n rescue\n nil\n end", "def true_address\r\n addr = servlet_response.getLocalName\r\n $log.debug(\"True address/hostname is #{addr}\")\r\n addr\r\n end", "def first_domain_part\n return nil if request.env['HTTP_HOST'].blank?\n @first_domain_part ||= request.env['HTTP_HOST'].split(\".\").first\n end", "def build_host\n host = @host_value || base_value.host\n raise UnresolvableResourceError, 'no HTTP host specified' if host.blank?\n host\n end", "def host\n \"#{@url.scheme}://#{@url.host}\"\n end", "def header(name)\n name = name.gsub(/-/, \"_\").upcase\n return request.env[name] if request.env.key?(name)\n request.env[\"HTTP_#{name}\"]\n end", "def server_hostname\n @node['serverHostname']\n end", "def hostname\n @hostname ||= ENV['HOSTNAME'] || `hostname`.delete(\"\\n\")\n end", "def desired_hostname\n if path.start_with?('/foo/en')\n Rails.env.staging? ? 'foo-staging.infopark.com' : 'www.foo.com'\n else\n # Default hostname\n Rails.env.staging? ? 'website-staging.infopark.com' : 'www.website.com'\n end\n end", "def hostinfo\n return self.host.to_s + (self.port ? ':' + self.port.to_s : '')\n end" ]
[ "0.77148664", "0.7541365", "0.7495885", "0.71831733", "0.71040004", "0.6984895", "0.6928435", "0.68830967", "0.6800195", "0.6766139", "0.67552334", "0.6754956", "0.67038345", "0.6666227", "0.6666208", "0.66583365", "0.66311055", "0.6595148", "0.6585325", "0.6584013", "0.65806776", "0.6578183", "0.6576153", "0.6571422", "0.65022695", "0.64904296", "0.64855677", "0.64796114", "0.6466363", "0.64646536", "0.64592963", "0.64504623", "0.64504623", "0.6439118", "0.64319193", "0.6425241", "0.642213", "0.6401984", "0.63968295", "0.6392484", "0.63873494", "0.63858247", "0.6381217", "0.6354329", "0.6348718", "0.6348164", "0.6345066", "0.6345066", "0.63433444", "0.633547", "0.63331306", "0.63318884", "0.6315965", "0.6300712", "0.6299354", "0.62954605", "0.6288756", "0.62878215", "0.62839764", "0.62763524", "0.62754136", "0.6267176", "0.6261015", "0.6252493", "0.6248652", "0.62468517", "0.62402207", "0.62402207", "0.6233501", "0.62212086", "0.62145716", "0.62091583", "0.6190056", "0.61889476", "0.61885", "0.6186708", "0.6182075", "0.6169305", "0.6168152", "0.6166636", "0.6157695", "0.61399066", "0.61313546", "0.61312115", "0.61302894", "0.6118825", "0.6116508", "0.6093038", "0.6088705", "0.6085139", "0.6079071", "0.6077645", "0.6076057", "0.60748464", "0.6068008", "0.60548097", "0.6052809", "0.6052269", "0.6029534", "0.6027595" ]
0.82105935
0
Obtain User Agent from http request header
def user_agent_on_header request.headers['HTTP_USER_AGENT'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @headers['User-Agent']\n end", "def user_agent\n @request['User-Agent']\n end", "def user_agent\n headers[\"HTTP_USER_AGENT\"] || headers[\"USER-AGENT\"]\n end", "def http_user_agent\n # User agent is required for cookie validation\n request.env['HTTP_USER_AGENT'].to_s\n end", "def user_agent\n @data[\"user_agent\"]\n end", "def get_user_agent\n user_agent\n end", "def user_agent\n @agent.user_agent\n end", "def ua\n @ua ||= begin\n request.env['HTTP_USER_AGENT'].downcase\n rescue\n ''\n end\n end", "def getUserAgent()\n\t\t\tUSER_AGENT\n\t\tend", "def user_agent\n @user_agent || USER_AGENT\n end", "def user_agent\n @user_agent || USER_AGENT\n end", "def user_agent(agent)\n headers.update 'User-Agent' => agent\n end", "def user_agent; end", "def user_agent; end", "def user_agent; end", "def user_agent\n @request[FUA]\n end", "def some_user_agent\n \"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090920 Firefox/3.5.3 (Swiftfox)\"\n end", "def user_agent\n \"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3\"\n end", "def get_user_agent\n # If `browser` method is called from a rails view\n if defined?(controller)\n controller.view_context.request.user_agent\n\n # Else `browser` method was called from a ruby component\n elsif defined?(view_context)\n view_context.request.user_agent\n end\n end", "def user_agent\n ENV[\"CHEF_API_USER_AGENT\"] || config[\"CHEF_API_USER_AGENT\"] || USER_AGENT\n end", "def user_agent\n kernel = Facter[:kernel] ? Facter[:kernel].value : 'unknown'\n kvers = Facter[:kernelversion] ? Facter[:kernelversion].value : 'unknown'\n values = {\n 'razor' => MK::VERSION,\n 'facter' => Facter.version, # sigh\n 'ruby' => RUBY_VERSION,\n 'kernel' => \"#{kernel}-#{kvers}\"\n }.reject{|k,v| v.nil?}.map{|k,v| k+'/'+v}.join(' ')\n end", "def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end", "def user_agent= new_ua\n @headers['User-Agent'] =\n new_ua && Kronk.config[:user_agents][new_ua.to_s] ||\n new_ua || Kronk::DEFAULT_USER_AGENT\n end", "def user_agent (value = nil)\n\t\tif value\n\t\t\traise_if_error C.glyr_opt_useragent(to_native, value)\n\t\telse\n\t\t\tto_native[:useragent]\n\t\tend\n\tend", "def user_agent(string)\n string = string.to_s\n return nil if string.empty?\n UserAgent.new(string)\n end", "def user_agent(value)\n value || DEFAULT_USER_AGENT\n end", "def user_agent=(user_agent); end", "def headers\n { 'User-Agent' => user_agent }\n end", "def name\n Agent.name_for_user_agent string\n end", "def client_browser_name \n user_agent = (request.env['HTTP_USER_AGENT'] || \"\").downcase \n if user_agent =~ /msie/i \n \"Internet Explorer\" \n elsif user_agent =~ /applewebkit/i \n \"Safari\" \n elsif user_agent =~ /konqueror/i \n \"Konqueror\" \n elsif user_agent =~ /gecko/i \n \"Mozilla\" \n elsif user_agent =~ /opera/i \n \"Opera\" \n else \n \"Unknown\" \n end \n end", "def user_agent=(user_agent)\n @request_headers['User-Agent'] = user_agent\n @request = Net::HTTP::Get.new(@uri.request_uri, @request_headers)\n end", "def detect_browser(http_user_agent)\n result = http_user_agent\n if result =~ /Safari/\n if result =~ /Chrome/\n version = result.split('Chrome/')[1].split(' ').first.split('.').first\n browser = 'Chrome'\n else\n browser = 'Safari'\n version = result.split('Version/')[1].split(' ').first.split('.').first\n end\n elsif result =~ /Firefox/\n browser = 'Firefox'\n version = result.split('Firefox/')[1].split('.').first\n elsif result =~ /Opera/\n browser = 'Opera'\n version = result.split('Version/')[1].split('.').first\n elsif result =~ /MSIE/\n browser = 'MSIE'\n version = result.split('MSIE')[1].split(' ').first\n end\n\n [browser,version]\n end", "def user_agent(vendor: T.unsafe(nil)); end", "def user_agent(user_agent)\n @user_agent = user_agent\n end", "def harvest_user_agent\n return \"TimeTrackingConsolidator (patel.aneeesh@gmail.com)\"\n end", "def user_agent_match(req, pattern)\n req.user_agent && req.user_agent[pattern]\n end", "def default_header\n {\n \"User-Agent\" => user_agent\n }\n end", "def headers\n {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'}\n end", "def agent\n anonymous? ? nil : user.agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent=(user_agent)\n @user_agent = user_agent\n @default_headers['User-Agent'] = @user_agent\n end", "def user_agent\n @options[:user_agent] || \"Ruby Twitter Gem\"\n end", "def client_browser_name\n user_agent = request.env['HTTP_USER_AGENT'].downcase\n if user_agent =~ /msie/i\n \"Microsoft\"\n elsif user_agent =~ /applewebkit/i\n \"Apple or Google\"\n elsif user_agent =~ /Chrome/i\n \"Google\"\n elsif user_agent =~ /Mozilla/i\n \"Mozilla\"\n else\n \"your browser\"\n end\n end", "def ua_string\n window.execute_script('navigator.userAgent')\n end", "def engine\n Agent.engine_for_user_agent string\n end", "def user_agent_string\n user_agent_tokens.reverse.join(' ')\n end", "def getUserAgent()\n printDebugMessage('getUserAgent', 'Begin', 11)\n clientRevision = '$Revision$'\n clientVersion = '0'\n if clientRevision.length > 11\n clientVersion = clientRevision[11..-3]\n end\n userAgent = \"EBI-Sample-Client/#{clientVersion} (#{self.class.name}; Ruby #{RUBY_VERSION}; #{RUBY_PLATFORM}) \"\n printDebugMessage('getUserAgent', \"userAgent: #{userAgent}\", 11)\n printDebugMessage('getUserAgent', 'End', 11)\n return userAgent\n end", "def getUserAgent()\n printDebugMessage('getUserAgent', 'Begin', 11)\n clientRevision = '$Revision$'\n clientVersion = '0'\n if clientRevision.length > 11\n clientVersion = clientRevision[11..-3]\n end\n userAgent = \"EBI-Sample-Client/#{clientVersion} (#{self.class.name}; Ruby #{RUBY_VERSION}; #{RUBY_PLATFORM}) \"\n printDebugMessage('getUserAgent', \"userAgent: #{userAgent}\", 11)\n printDebugMessage('getUserAgent', 'End', 11)\n return userAgent\n end", "def user_agent_string(id)\n case id\n when :ie\n 'MSIE'\n when :safari\n 'Safari'\n when :chrome\n 'Chrome'\n when :opera\n 'Opera'\n when :firefox\n 'Firefox'\n else\n raise \"Define mising browser agent: #{id.inspect}\"\n end\nend", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def initialize user_agent\n @user_agent = user_agent.strip\n end", "def parse_agent(header)\n # First of all match the agent and the version\n catch(:result) do\n Brauser::Definitions.browsers.each do |_, definition|\n result = definition.match(header)\n throw(:result, result) if result\n end\n\n nil\n end\n end", "def user_agent\n \"SocketLabs-ruby/#{VERSION};ruby(#{RUBY_VERSION})\"\n end", "def user_agent\n [\n \"#{config.application_name}/#{config.application_version}\",\n \"google-api-ruby-client/#{Google::APIClient::VERSION::STRING}\",\n Google::APIClient::ENV::OS_VERSION,\n '(gzip)'\n ].join(' ').delete(\"\\n\")\n end", "def agent\n @agent ||= Sawyer::Agent.new('', sawyer_options) do |http|\n http.headers[:user_agent] = user_agent\n end\n end", "def user_agent= user_agent\n @agent.user_agent = user_agent\n end", "def os\n Agent.os_for_user_agent string\n end", "def browser_info\n # Fetch the UserAgent string using javascript navigator object\n ua_string = browser.execute_script('return navigator.userAgent')\n @parsed_ua = UserAgent.parse(ua_string)\n end", "def user_agent\n self.class.user_agent ||= USER_AGENTS.shuffle.first\n end", "def user_agent\n if defined?(::RUBY_VERSION) && defined?(::RUBY_PLATFORM)\n ruby_description = \"(ruby #{::RUBY_VERSION} #{::RUBY_PLATFORM}) \" # NOTE: the trailing space!\n end\n zlib_version = \"zlib/#{Zlib.zlib_version}\" if defined?(::Zlib) && Zlib.respond_to?(:zlib_version)\n \"NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}\"\n end", "def default_user_agent\n \"#{NAME}/#{VERSION} (Ruby/#{RUBY_VERSION})\"\n end", "def user_agent=(name)\n @user_agent = USER_AGENT[name] || USER_AGENT['bot']\n end", "def browser_name\n @browser_name ||= begin\n\n ua = ''\n ua = request.env['HTTP_USER_AGENT'].downcase if request.env['HTTP_USER_AGENT']\n \n if ua.index('webtv')\n 'webtv'\n elsif ua.index(/(Mobile\\/.+Safari)/)\n 'mobile safari'\n elsif ua.index('gecko/')\n 'gecko'\n elsif ua.index('opera')\n 'opera'\n elsif ua.index('konqueror') \n 'konqueror'\n elsif ua.index('chrome/') # chrome\n #Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.78 Safari/532.5\n 'chrome'\n elsif ua.index('applewebkit/')\n #Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10\n 'safari'\n elsif ua.index('msie')\n 'ie'+ua[ua.index('msie')+5].chr\n elsif ua.index('mozilla/')\n 'gecko'\n elsif ua.index('Rails')\n 'rails'\n elsif ua.index('nagios')\n 'nagios'\n #check_http/v2053 (nagios-plugins 1.4.13)\n else\n ''\n end\n \n end\n end", "def sanitize_user_agent(string)\n user_agent = user_agent(string)\n return nil unless user_agent\n user_agent.to_s\n end", "def init_user_agent(options)\n @headers ||= {}\n @headers['User-Agent'] = options[:user_agent] || default_user_agent\n end", "def bot_user_agent(vendor: T.unsafe(nil)); end", "def request_headers\n @agent.request_headers\n end", "def iphone_user_agent?\n request.env[\"HTTP_USER_AGENT\"] && request.env[\"HTTP_USER_AGENT\"][/(Mobile\\/.+Safari)/]\n end", "def user_os_simple\r\n ua = request.env['HTTP_USER_AGENT'].downcase\r\n return \"Windows\" if ua.index('win')\r\n return \"Linux\" if ua.index('Linux')\r\n return \"Macintosh\" if ua.index('Macintosh')\r\n return \"unknown\"\r\n end", "def useragent=(value)\n Curl.set_option(:useragent, value_for(value, :string), handle)\n end", "def browser_version\n return 0.0 if not request.env['HTTP_USER_AGENT']\n if browser_is('ie')\n return request.env['HTTP_USER_AGENT'].match(/^.*?MSIE ([0-9]+.[0-9]){1}.*?/)[1].to_f\n end\n if browser_is('mozilla')\n return request.env['HTTP_USER_AGENT'].match(/^.*?Firefox\\/([0-9]+.[0-9]){1}.*?/)[1].to_f\n end\n if browser_is('webkit')\n return request.env['HTTP_USER_AGENT'].match(/^.*?Safari\\/([\\d]+\\.[\\d]+[\\.\\d]*)?/)[1].to_f\n end\n end", "def get_agent\n\t\tagent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }\n\tend", "def accept_header(request)\n request.env[HEADER_ACCEPT]\n end", "def user_os_simple\n @user_os_simple ||= begin\n ua = ''\n ua = request.env['HTTP_USER_AGENT'].downcase if request.env['HTTP_USER_AGENT']\n if ua.index('win')\n \"Windows\"\n elsif ua.index('linux')\n \"Linux\"\n elsif ua.index('macintosh')\n \"Macintosh\"\n elsif ua.index('ipod') # iPod Touch\n \"iPod\"\n elsif ua.index('iphone')\n \"iPhone\"\n elsif ua.index('ipad')\n \"iPad\"\n else\n \"unknown\"\n end\n end\n end", "def android_user_agent?\n request.env[\"HTTP_USER_AGENT\"] && request.env[\"HTTP_USER_AGENT\"][/(Android)/]\n end", "def browser\n Browser.new(user_agent)\n end", "def header_user_agent\n { \"User-Agent\" => \"Kinetic Ruby SDK #{KineticSdk.version}\" }\n end", "def convert_user_agent(value, definition)\n value # TODO\n end", "def good_browser?(agent = /Firefox|Safari|Chrome/)\n request.env['HTTP_USER_AGENT'] =~ agent\n end", "def client_browser_version \n user_agent = (request.env['HTTP_USER_AGENT'] || \"\").downcase \n if user_agent =~ /msie 8/i \n \"MSIE8\" \n elsif user_agent =~ /msie 7/i \n \"MSIE7\" \n elsif user_agent =~ /msie 6/i \n \"MSIE6\" \n else \n \"Other\" \n end \n end", "def user_agent\n ruby_description = ''\n # note the trailing space!\n ruby_description << \"(ruby #{::RUBY_VERSION} #{::RUBY_PLATFORM}) \" if defined?(::RUBY_VERSION) && defined?(::RUBY_PLATFORM)\n zlib_version = ''\n zlib_version << \"zlib/#{Zlib.zlib_version}\" if defined?(::Zlib) && Zlib.respond_to?(:zlib_version)\n \"NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}\"\n end", "def user_agent=(user_agent)\n @attributes[\"user_agent\"] = user_agent\n end", "def user_agent\n \"PriceHubbleGem/#{PriceHubble::VERSION}\"\n end", "def iphone_user_agent?\n request.env[\"HTTP_USER_AGENT\"] && request.env[\"HTTP_USER_AGENT\"][/(Mobile\\/.+Safari)/]\n end", "def iphone_user_agent?\n request.env[\"HTTP_USER_AGENT\"] && request.env[\"HTTP_USER_AGENT\"][/(Mobile\\/.+Safari)/]\n end", "def iphone_user_agent?\n request.env[\"HTTP_USER_AGENT\"] && request.env[\"HTTP_USER_AGENT\"][/(Mobile\\/.+Safari)/]\n end", "def content_headers\n { 'User-Agent' => \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7\",\n 'Accept-language' => 'enUS' }\n end", "def browser_name\n return 'Unknown' if params[:for] == 'u' || user_agent && user_agent.failed? #&& !params[:for]\n\n case user_agent ? browser : params[:for].to_sym\n when :msie then 'Microsoft Internet Explorer'\n when :firefox then 'Mozilla Firefox'\n when :chrome then 'Google Chrome'\n when :safari then 'Apple Safari'\n when :opera then 'Opera'\n end\n end", "def request_headers\n { 'Accept-Encoding'=>'gzip, deflate', 'User-Agent'=>'Ruby'}\n end", "def iphone_user_agent?\n request.env[\"HTTP_USER_AGENT\"] &&\n request.env[\"HTTP_USER_AGENT\" ][/(Mobile\\/.+Safari)/]\n end", "def user_agent\n 'eventful-ruby/%s (Rubygems; Ruby %s %s)' % [Eventful::VERSION, RUBY_VERSION, RUBY_PLATFORM]\n end", "def append_user_agent_to_params\n params[:browser_user_agent] = http_user_agent\n end" ]
[ "0.87297374", "0.87297374", "0.87297374", "0.8564696", "0.8517576", "0.8340213", "0.81074625", "0.80660886", "0.7931847", "0.7921811", "0.7763692", "0.77623594", "0.77623594", "0.7713474", "0.7711464", "0.7711464", "0.7711464", "0.7658591", "0.7531901", "0.7404778", "0.732046", "0.72447175", "0.7229304", "0.71429944", "0.71429944", "0.713134", "0.7079062", "0.700805", "0.6958398", "0.694384", "0.6926321", "0.6899451", "0.6883423", "0.68698114", "0.68645436", "0.68604636", "0.6816248", "0.68111897", "0.6766246", "0.67550176", "0.6751656", "0.6697655", "0.6697655", "0.6697655", "0.6697655", "0.6697655", "0.6697385", "0.66867495", "0.66718656", "0.6662472", "0.6655991", "0.6644118", "0.6644118", "0.6630019", "0.6627806", "0.6627806", "0.6627806", "0.6627806", "0.6627806", "0.6622939", "0.6619937", "0.66083336", "0.6600569", "0.6585634", "0.65757304", "0.6573677", "0.65654874", "0.6505972", "0.64935374", "0.64563406", "0.6442324", "0.64156663", "0.64057505", "0.6395602", "0.63599735", "0.63453597", "0.63448185", "0.6322352", "0.63133067", "0.631315", "0.6307253", "0.6284441", "0.62731457", "0.62539643", "0.62327546", "0.6224388", "0.6224367", "0.62047654", "0.6183157", "0.61567694", "0.6125088", "0.6121053", "0.6121053", "0.6121053", "0.61073494", "0.6102217", "0.60971195", "0.6080138", "0.6074983", "0.6063554" ]
0.8891262
0
Renders plain text and html to html. If parse_code isn't true, only runs bluecloth on text outside any ... blocks.
def bluecloth(text, parse_code = true, increment_headers = true) return text if text.nil? if parse_code return BlueCloth::new(text).to_html end text = text.dup out = '' level = 0 until text.empty? do if level < 1 # Find start of code block j = text.index(/<code.*?>/) || text.length j -= 1 if j != 0 level += 1 if j != 0 # Convert to bluecloth blue = BlueCloth::new(text[0..j]).to_html if increment_headers # Increment headings by two (h1, h2 are page/entry headers) blue.gsub!(/<(\/)?h(\d)>/) { |match| "<#{$1}h#{$2.to_i + 2}>" } end out << blue end else # Find end of code block j = text.index('</code>') || text.length level -= 1 j += 6 # Output as is out << text[0..j] end # Excise parsed string text.slice! 0..j unless j == 0 end out end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html\n return if self.text.blank?\n\n html = self.text\n \n # s = StringScanner.new(self.text)\n # html = ''\n # while markup = s.scan_until(/\\[code/) do\n # html += RedCloth.new(markup[0..-6]).to_html\n # s.pos= s.pos-5\n # code = s.scan_until(/\\[\\/code\\]/)\n # if code\n # code.gsub!(/\\[code\\]/, '[code lang=\"ruby\"]')\n # html += '<div class=\"syntax\">' + Syntaxi.new(code).process + '</div>' \n # else\n # break\n # end\n # end\n # html += RedCloth.new(s.rest).to_html\n \n html\n end", "def render_code(code)\n render_block(Pygments.highlight(code, formatter: 'terminal256', lexer: 'ruby', options: {style: 'bw'}))\nend", "def parse(text)\n text.split(/(<code.*?>.*?<\\/code>)/m).inject(\"\") do |result, piece|\n if piece =~ /^<code/\n result << highlight(piece.gsub(/<code.*?>|<\\/code>/, \"\"), parse_lang(piece)).chomp\n else\n result << format(piece)\n end\n end\n end", "def block_code(code, language)\n \n lines=code.split(\"\\n\")\n lines.map! do |line|\n\n line=line.gsub(/\\&.squo;/, \"'\")\n line=line.gsub(/\\&.dquo;/, '\"')\n line=line.gsub(/</, \"&lt;\")\n line=line.gsub(/>/, \"&gt;\")\n\n # Adding my own special coloring scheme for comments and outputs\n # (for which I've added my own special markup sequence, -->\n line=line.gsub(/(\\# .*$)/, \"<span.ps.class='comment'>\\\\1</span>\")\n line=line.gsub(/\\=\\=> (.*$)/, \"<span.ps.class='output'>\\\\1</span>\")\n\n # Kludgy way of only replacing spaces outside the HTML tags I'm adding to get comments\n # to be in a span of their own\n line=line.gsub(/ /, \"&nbsp;\")\n line=line.gsub(/\\.ps\\./, \" \")\n\n if /lt;/.match(line)\n puts \">>> #{line}\"\n end\n\n line\n end\n html_inner = lines.join(\"<br/>\\n\")\n\n html=\"<div class=mycode>\\n#{html_inner}\\n</div>\\n\"\n end", "def code_html\n CodeRay.scan(self.code, :python).div().html_safe\n end", "def process_code text\n # the first line is the lang identifier\n lang = text.lines.first.scan(/^#!+[\\s+]?(\\w+)/).flatten.first\n\n # if found remove first line from text\n if lang\n lang.downcase!\n text = text.lines.to_a[1..-1].join\n else\n lang = 'text'\n end\n\n # highlight and put into a `div` element\n html = CodeRay.scan(text, lang).div(:css => :class)\n end", "def render(context)\n # Sanitize the code inside the block\n resolve_code = super.to_s.gsub(/\\A(\\n|\\r)+|(\\n|\\r)+\\z/, \"\")\n \n # Invoke Rouge to format our code\n formatted_code = rouge_resolve(resolve_code)\n \n # Output the formatted code with the proper HTML tags\n to_html_code(formatted_code)\n end", "def render_code(code)\n code.pegs.each { |peg| render_peg(peg) }\n end", "def parse_codeblocks(html); end", "def render(no_follow = false)\n sanitize = no_follow ?\n @wiki.history_sanitizer :\n @wiki.sanitizer\n\n data = extract_tex(@data.dup)\n data = extract_code(data)\n data = extract_tags(data)\n begin\n data = GitHub::Markup.render(@name, data)\n if data.nil?\n raise \"There was an error converting #{@name} to HTML.\"\n end\n rescue Object => e\n data = %{<p class=\"gollum-error\">#{e.message}</p>}\n end\n data = process_tags(data)\n data = process_code(data)\n if sanitize || block_given?\n doc = Nokogiri::HTML::DocumentFragment.parse(data)\n doc = sanitize.clean_node!(doc) if sanitize\n yield doc if block_given?\n data = doc_to_html(doc)\n end\n data = process_tex(data)\n data.gsub!(/<p><\\/p>/, '')\n data\n end", "def escape_code_html(text)\n text.gsub(/<code[^>]*>(.*?)<\\/code>/m) do |t|\n \"<code>\" + h($1) + \"</code>\"\n end.gsub(/<pre[^>]*>(.*?)<\\/pre>/m) do |t|\n \"<pre>\" + h($1) + \"</pre>\"\n end\n end", "def format_code(text)\n simple_format( truncate( Sanitize.clean(markdown(text)).html_safe, escape: false, length: 299, separator: ' ', omission: ' …' ))\n end", "def html_markup_html(text); end", "def html_highlight\n language, code = *values\n require 'coderay'\n language = 'nitro_xhtml' if language == 'ezamar'\n\n case language\n when *%w[ruby c delphi html nitro_xhtml plaintext rhtml xml]\n tokens = CodeRay.scan(code, language)\n html = tokens.html(:wrap => :div)\n when *%w[diff]\n require 'uv'\n Uv.parse(code, output = 'xhtml', syntax_name = language, line_numbers = false, render_style = 'amy', headers = false)\n else\n code = language if not code or code.strip.empty?\n html = tag(:pre, code)\n end\n end", "def formatted_body\n code_blocks = _get_code_blocks(self.body)\n red_clothed = RedCloth.new(body.gsub(REGEX, '${code_block}')).to_html\n\n code_blocks.each { |c|\n c = Syntaxi.new(c).process\n red_clothed.sub!(/\\$\\{code_block\\}/, c)\n }\n\n red_clothed\n end", "def process_code(data)\n return data if data.nil? || data.size.zero? || @codemap.size.zero?\n\n blocks = []\n @codemap.each do |id, spec|\n next if spec[:output] # cached\n\n code = spec[:code]\n if code.lines.all? { |line| line =~ /\\A\\r?\\n\\Z/ || line =~ /^( |\\t)/ }\n code.gsub!(/^( |\\t)/m, '')\n end\n\n blocks << [spec[:lang], code]\n end\n\n highlighted = begin\n blocks.size.zero? ? [] : Gollum::Albino.colorize(blocks)\n rescue ::Albino::ShellArgumentError, ::Albino::TimeoutExceeded,\n ::Albino::MaximumOutputExceeded\n []\n end\n\n @codemap.each do |id, spec|\n body = spec[:output] || begin\n if (body = highlighted.shift.to_s).size > 0\n update_cache(:code, id, body)\n body\n else\n \"<pre><code>#{CGI.escapeHTML(spec[:code])}</code></pre>\"\n end\n end\n data.gsub!(id, body)\n end\n\n data\n end", "def block_code(code, language)\n if language.present?\n CodeRay.scan(code, language).div\n else\n \"<pre><code>#{code}</code></pre>\"\n end\n end", "def test_link_syntax_is_not_processed_within_code_blocks\n markdown = @markdown.render(\" This is a code block\\n This is a link [[1]] inside\\n\")\n html_equal \"<pre class=\\\"prettyprint\\\"><code>This is a code block\\nThis is a link [[1]] inside\\n</code></pre>\\n\",\n markdown\n end", "def guard_text( text )\n # todo/fix 2: note we need to differentiate between blocks and inline\n # thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)\n \n # todo/fix: remove wrap_markup; replace w/ guard_text\n # why: text might be css, js, not just html\n \n ### !!!!!!!!!!!!\n ## todo: add print depreciation warning\n \n wrap_markup( text )\n end", "def html_markup_text(text); end", "def parse_block_html; end", "def call\n # mode = (context[:gfm] != false) ? :gfm : :markdown\n # html = GitHub::Markdown.to_html(@text, mode)\n # html.rstrip!\n # html\n\n options = context[:redcarpet_options] || {}\n renderer = HtmlWithRouge.new(\n filter_html: options.fetch(:filter_html, false),\n hard_wrap: options.fetch(:hard_wrap, true)\n )\n options.reject! { |k, v| [:filter_html, :hard_wrap].include?(k) }\n markdown = Redcarpet::Markdown.new(renderer, options)\n html = markdown.render(@text)\n html.rstrip!\n html\n end", "def block_html(raw)\n raw = unindent(raw)\n\n if md = raw.match(/\\<(.+?)\\>(.*)\\<(\\/.+?)\\>/m)\n open_tag, content, close_tag = md.captures\n \"<#{open_tag}>\\n#{recursive_render(unindent(content))}<#{close_tag}>\"\n else\n raw\n end\n end", "def block_code(code, language)\n # highlight some code with a given language lexer \n # and formatter: html or terminal256 \n # and block if you want to stream chunks\n # github.com/jayferd/rouge/blob/master/lib/rouge.rb#L17\n Rouge.highlight(code, language || 'text', 'html') \n # watch out you need to provide 'text' as a default, \n # because when you not provide language in Markdown \n # you will get error: <RuntimeError: unknown lexer >\n end", "def block_html(html)\n html.gsub(/<markdown>([\\d\\D]+?)<\\/markdown>/) {|_|\n extensions = {fenced_code_blocks: true}\n renderer = Redcarpet::Markdown.new(WithHighlights, extensions)\n renderer.render(Regexp.last_match[1])\n }\n end", "def display(text, html_options = nil)\n if html_options\n html_options = html_options.stringify_keys\n tag_options = tag_options(html_options)\n else\n tag_options = nil\n end\n #sanitize(text).to_html.gsub(\"<p>\", \"<p#{tag_options}>\")\n markdown(sanitize(text.gsub(\"\\n\",\"<br/>\"))).gsub(\"<p>\", \"<p#{tag_options}>\")\n end", "def text_to_html (text, args = {})\n args = { emotes: false, map_headings: 1 }.merge args\n \n html = Moredown.text_to_html(text, args)\n html.gsub!('src=\"media/', 'src=\"/media/')\n html.gsub!(/<pre><code>#! (.*?)\\n([^<]*?)<\\/code><\\/pre>/) { |match| \"<pre><code class=\\\"#{$1.downcase.strip}\\\">#{$2.strip}</code></pre>\" }\n \n html\n end", "def code(lang, &block)\n source_code = capture(&block).strip\n eval('_erbout', block.binding).concat %Q(<pre class=\"CodeRay\"><code class=\"language-#{lang}\">#{html_escape source_code}</code></pre>)\nend", "def html_markup_pre(text); end", "def accept_verbatim verbatim\n text = verbatim.text.rstrip\n\n klass = nil\n\n content = if verbatim.ruby? or parseable? text then\n begin\n tokens = RDoc::Parser::RipperStateLex.parse text\n klass = ' class=\"ruby\"'\n\n result = RDoc::TokenStream.to_html tokens\n result = result + \"\\n\" unless \"\\n\" == result[-1]\n result\n rescue\n CGI.escapeHTML text\n end\n else\n CGI.escapeHTML text\n end\n\n if @options.pipe then\n @res << \"\\n<pre><code>#{CGI.escapeHTML text}\\n</code></pre>\\n\"\n else\n @res << \"\\n<pre#{klass}>#{content}</pre>\\n\"\n end\n end", "def on_slim_text(content)\n compile(content)\n end", "def html_markup_org(text); end", "def highlight_code(options={})\n require 'uv'\n\n wrap_with = options[:wrap_with] || ['','']\n text = @modified_string\n\n languages_syntax_list = File.readlines(\n File.expand_path(File.dirname(__FILE__) + '/../config/languages_syntax_list')\n ).map { |l| l.chomp }\n\n text.gsub!(/<code(\\s*?lang=[\"']?(.*?)[\"']?)?>(.*?)<\\/code>/) do\n if languages_syntax_list.include?($2)\n lang = $2\n else\n lang = 'ruby'\n end\n unless $3.blank?\n result = Uv.parse($3.gsub('<br/>', \"\\n\").gsub('&lt;', '<').gsub('&gt;', '>').gsub('&quot;', '\"'), 'xhtml', lang, false, 'active4d')\n \"#{wrap_with[0].gsub('$lang', lang)}#{result}#{wrap_with[1]}\"\n end\n end\n\n # TODO: split string longer than 80 characters\n\n @modified_string = text\n self\n\n end", "def highlight(code, options = T.unsafe(nil)); end", "def thru_coderay #:nodoc:\n gsub %r{<(code)(.*?)>(.*?)</\\1>}m do\n elem, atts, code = $1, $2, CGI.unescapeHTML($3).sub(/\\A\\r?\\n/, '')\n\n lang_regexp = /\\blang=('|\")(.*?)\\1/io\n lang = atts[lang_regexp, 2]\n lang = :ruby if lang !~ /\\S/\n atts.sub! lang_regexp, %{lang=\"#{lang}\"}\n\n body = CodeRay.scan(code, lang).html(:css => :style)\n\n if code =~ /\\n/\n span = :para\n head = \"<ins><pre\"\n tail = \"</pre></ins>\"\n\n else\n span = :line\n head = \"<#{elem}\"\n tail = \"</#{elem}>\"\n end\n\n unless atts.sub!(/\\b(class=('|\"))(.*?\\2)/){ $1 + span + ' ' + $3 }\n atts << %{ class=\"#{span}\"}\n end\n\n %{#{head}#{atts}>#{body}#{tail}}\n end\n end", "def highlight(code, lang, options = T.unsafe(nil), format = T.unsafe(nil)); end", "def htmlify(text, markup = T.unsafe(nil)); end", "def highlight_code(code)\n tokens = Ripper.lex(code).map do |(_position, type, content, _state)|\n case type\n when :on_nl, :on_sp, :on_ignored_nl\n content\n else\n tag.span(content, class: type.to_s.sub(\"on_\", \"ruby-\").dasherize)\n end\n end\n safe_join(tokens)\n end", "def process_code(data)\n @codemap.each do |id, spec|\n formatted = spec[:output] ||\n begin\n code = spec[:code]\n lang = spec[:lang]\n\n if code.lines.all? { |line| line =~ /\\A\\r?\\n\\Z/ || line =~ /^( |\\t)/ }\n code.gsub!(/^( |\\t)/m, '')\n end\n # formatted =\n # begin\n # lang && OY::Albino.colorize(code, lang)\n # rescue ::Albino::ShellArgumentError, ::Albino::Process::TimeoutExceeded,\n # ::Albino::Process::MaximumOutputExceeded\n # p 23\n # end\n formatted ||= \"<pre><code class='#{lang}'>#{CGI.escapeHTML(code)}</code></pre>\"\n update_cache(:code, id, formatted)\n formatted\n end\n data.gsub!(id, formatted)\n end\n data\n end", "def highlight_codes\n #@content.gsub!(/%(.*?){(.*?)}%/m) do # %{ some code }%\n @content.gsub!(/^```(.*?)\\n(.*?)\\n```/m) do # github like: http://github.github.com/github-flavored-markdown/\n lang = :text\n lang = $1 if $1 != \"\"\n Albino.colorize($2, lang)\n end\n end", "def display(text, html_options = nil)\n begin\n if html_options\n html_options = html_options.stringify_keys\n tag_opts = tag_options(html_options)\n else\n tag_opts = nil\n end\n processed_text = format(sanitize(text))\n rescue\n # Sometimes Markdown throws exceptions, so rescue gracefully.\n processed_text = content_tag(:p, sanitize(text))\n end\n add_tag_options(processed_text, tag_opts)\n end", "def display(text, html_options = nil)\n begin\n if html_options\n html_options = html_options.stringify_keys\n tag_opts = tag_options(html_options)\n else\n tag_opts = nil\n end\n processed_text = format(sanitize(text))\n rescue\n # Sometimes Markdown throws exceptions, so rescue gracefully.\n processed_text = content_tag(:p, sanitize(text))\n end\n add_tag_options(processed_text, tag_opts)\n end", "def markup_code\n return '' unless @token_stream\n\n src = RDoc::TokenStream.to_html @token_stream\n\n # dedent the source\n indent = src.length\n lines = src.lines.to_a\n lines.shift if src =~ /\\A.*#\\ *File/i # remove '# File' comment\n lines.each do |line|\n if line =~ /^ *(?=\\S)/\n n = $&.length\n indent = n if n < indent\n break if n == 0\n end\n end\n src.gsub!(/^#{' ' * indent}/, '') if indent > 0\n\n add_line_numbers(src) if options.line_numbers\n\n src\n end", "def bbcode_to_html(string); end", "def bbcode_to_html!(escape_html = true, additional_tags = {}, method = :disable, *tags)\n replace(RubyBBCode.to_html(self, escape_html, additional_tags, method, *tags))\n end", "def text_block(text)\n h(text).gsub(/\\n/, '<br/>').html_safe\n end", "def display_as_html(content, &block)\n content = content.presence || \"\"\n if content !~ /<\\w+[^>]>/\n content = content.gsub(\"\\n\", \"<br />\")\n end\n content_tag :div, :class => \"rtf\" do\n if block_given?\n concat(capture(&block))\n end\n concat(content.html_safe)\n end\n end", "def display_as_html(content, &block)\n content = content.presence || \"\"\n if content !~ /<\\w+[^>]>/\n content = content.gsub(\"\\n\", \"<br />\")\n end\n content_tag :div, :class => \"rtf\" do\n if block_given?\n concat(capture(&block))\n end\n concat(content.html_safe)\n end\n end", "def pygment_code_block(block)\n write_data block, 'code.rb', false\n system 'pygmentize -o block.html code.rb'\n File.open('block.html', 'r').read\n end", "def syntax_highlight(html)\n line_numbers = config.line_numbers ? :table : nil\n opts = { css: :style, wrap: nil, line_numbers: line_numbers }\n html.gsub(/\\<code class=\"(.+?)\"\\>(.+?)\\<\\/code\\>/m) do\n lang, code = $1, $2\n code = CGI.unescapeHTML code\n CodeRay.scan(code, lang).html opts\n end\n end", "def backtick_codeblock(input)\n input.gsub /<p>`{3}\\s(\\w+)<\\/p>\\n\\n<pre><code>([^<]+)<\\/code><\\/pre>\\n\\n<p>`{3}<\\/p>/m do\n lang = $1\n str = $2.gsub('&lt;','<').gsub('&gt;','>')\n highlight(str, lang)\n end\n end", "def highlight_code(text, lang, type, opts = T.unsafe(nil)); end", "def render_html_body\n # FIXME actually render the text\n renderer.new(body).to_html\n end", "def thru_coderay\n gsub %r{<(code)(.*?)>(.*?)</\\1>}m do\n atts, code = $2, CGI.unescapeHTML($3)\n\n lang =\n if $2 =~ /lang=('|\")(.*?)\\1/i\n $2\n else\n :ruby\n end\n\n tag =\n if code =~ /\\n/\n :pre\n else\n :code\n end\n\n html = CodeRay.scan(code, lang).html(:css => :style)\n\n %{<#{tag} class=\"code\"#{atts}>#{html}</#{tag}>}\n end\n end", "def call(tag, body, context)\n \n if param('fuse.pygmentize.eval_tags')\n body = website.blackboard.invoke(:content_processor, 'tags').call(context.clone(:content => body)).content\n end\n \n # figure out the indent level of the tag\n last_line = body.split(/\\r?\\n/).last\n tag_indent = \"\"\n if( last_line.match(/^[ \\t]+$/) ) \n tag_indent = last_line\n end\n \n # Strip off the tag_indent...\n if( tag_indent.size > 0 ) \n buffer = \"\"\n for i in body.split(/\\r?\\n/)\n buffer += i.sub(/^[ \\t]{#{tag_indent.size}}/, \"\")+\"\\n\"\n end\n body = buffer.chomp\n end\n \n # Execute the pygmentize tool\n lang = param('fuse.pygmentize.lang')\n lines = param('fuse.pygmentize.lines') ? \",linenos=1\" : \"\"\n \n result = pygmentize(lang, lines, body)\n \n # Format the result\n result = \"#{tag_indent}<div class=\\\"syntax\\\">#{result}</div>\\n\"\n \n rescue Exception => e\n raise RuntimeError, \"Error processing the pygmentize tag <#{context.ref_node.absolute_lcn}>: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end", "def call\n extensions = context.fetch(\n :commonmarker_extensions,\n DEFAULT_COMMONMARKER_EXTENSIONS\n )\n html = if (renderer = context[:commonmarker_renderer])\n unless renderer < CommonMarker::HtmlRenderer\n raise ArgumentError, \"`commonmark_renderer` must be derived from `CommonMarker::HtmlRenderer`\"\n end\n parse_options = :DEFAULT\n parse_options = [:UNSAFE] if context[:unsafe]\n\n render_options = [:GITHUB_PRE_LANG]\n render_options << :HARDBREAKS if context[:gfm] != false\n render_options << :UNSAFE if context[:unsafe]\n\n doc = CommonMarker.render_doc(@text, parse_options, extensions)\n renderer.new(options: render_options, extensions: extensions).render(doc)\n else\n options = [:GITHUB_PRE_LANG]\n options << :HARDBREAKS if context[:gfm] != false\n options << :UNSAFE if context[:unsafe]\n CommonMarker.render_html(@text, options, extensions)\n end\n html.rstrip!\n html\n end", "def to_html\n case @markup\n when 'markdown'\n @data_for_output.collect! {|line| BlueCloth.new(line).to_html}\n when 'textile'\n @data_for_output.collect! {|line| RedCloth.new(line).to_html}\n when 'bbcode'\n @data_for_output.collect! {|line| line.bbcode_to_html}\n end\n end", "def block_code(code, language)\n\n # --- Extract file name ---------------------- #\n filename = ''\n regx = Regexp.new(/(<!--\\s?filename:(\\s?.{1,}\\s?)-->\\n?)/)\n if !(code =~ regx).nil?\n code.match(regx)\n filename = $2.try(:strip) || ''\n code.gsub!(regx, '')\n end\n # -------------------------------------------- #\n\n lexer = Rouge::Lexer.find_fancy(language, code) || Rouge::Lexers::PlainText\n if lexer.tag == 'make'\n code.gsub! /^ /, \"\\t\"\n end\n formatter = rouge_formatter(lexer)\n result = formatter.format(lexer.lex(code))\n\n return result if language.blank? && filename.blank?\n\n # --- Compose language and filename section --- #\n\n info_inner_html = [filename, language].select(&:present?).map.with_index { |text, i|\n i == 0 ? \"<span class='highlight-info__inner'>#{text}</span>\" : nil\n }.compact.join('')\n\n %(<div class='highlight-info'>\n #{info_inner_html}\n </div>\n #{result}\n )\n # -------------------------------------------- #\n end", "def highlight(code, lang, options = T.unsafe(nil)); end", "def call(tag, body, context)\n \n if param('fuse.pygmentize.eval_tags')\n body = website.blackboard.invoke(:content_processor, 'tags').call(context.clone(:content => body)).content\n end\n \n # figure out the indent level of the tag\n lines = body.split(/\\r?\\n/);\n last_line = lines.last\n tag_indent = \"\"\n if( last_line.match(/^[ \\t]+$/) ) \n tag_indent = last_line\n end\n \n # Strip off the tag_indent... and figure out the sections...\n state = 0\n\n for i in (0 .. (lines.size-1) )\n if( tag_indent.size > 0 ) \n lines[i] = lines[i].sub(/^[ \\t]{#{tag_indent.size}}/, \"\")\n end\n if state==0 \n if (!lines[i].strip.empty?) \n if( lines[i].match(/\\s*------+\\s*/) ) \n state=1\n else\n raise Exception, \"expecting 1st seperator: ------\"\n end\n end\n \n elsif state==1 \n m = lines[i].match(/\\s*([^:\\s]+)\\s*:\\s*(.+)/)\n raise Exception, \"left heading section expected.\" unless m\n leftlang = m[1]\n leftheading = m[2]\n leftcode =\"\"\n state=2\n\n elsif state==2\n if( lines[i].match(/\\s*------+\\s*/) ) \n state=3\n else\n raise Exception, \"expecting 2nd seperator: ------\"\n end\n \n elsif state==3\n if( lines[i].match(/\\s*------+\\s*/) ) \n state=4\n else\n leftcode += lines[i]+\"\\n\"\n end\n \n elsif state==4\n m = lines[i].match(/\\s*([^:\\s]+)\\s*:\\s*(.+)/)\n raise Exception, \"right heading section expected.\" unless m\n rightlang = m[1]\n rightheading = m[2]\n rightcode = \"\"\n state=5\n\n elsif state==5 \n if( lines[i].match(/\\s*------+\\s*/) ) \n state=6\n else\n raise Exception, \"expecting 4th seperator: ------\"\n end\n \n elsif state==6\n rightcode += lines[i]+\"\\n\"\n end\n end\n \n raise Exception, \"did not get all the sections: state: #{state}\" unless state==6\n \n # Execute the pygmentize tool\n lines = param('fuse.pygmentize_and_compare.lines') ? \",linenos=1\" : \"\"\n \n leftresult = pygmentize(leftlang, lines, leftcode)\n rightresult = pygmentize(rightlang, lines, rightcode)\n \n # Format the result\n result = \"#{tag_indent}<div class=\\\"compare\\\"><div class=\\\"compare-left\\\"><h3>#{leftheading}</h3><div class=\\\"syntax\\\">#{leftresult}</div></div><div class=\\\"compare-right\\\"><h3>#{rightheading}</h3><div class=\\\"syntax\\\">#{rightresult}</div></div><br class=\\\"clear\\\"/></div>\\n\"\n \n rescue Exception => e\n raise RuntimeError, \"Error processing the pygmentize_and_compare tag <#{context.ref_node.absolute_lcn}>: #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end", "def to_html text\n html = (''.encode text.encoding).dup\n\n encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]\n\n s = StringScanner.new text\n insquotes = false\n indquotes = false\n after_word = nil\n\n until s.eos? do\n case\n when s.scan(/<(tt|code)>.*?<\\/\\1>/) then # skip contents of tt\n html << s.matched.gsub('\\\\\\\\', '\\\\')\n when s.scan(/<(tt|code)>.*?/) then\n warn \"mismatched <#{s[1]}> tag\" # TODO signal file/line\n html << s.matched\n when s.scan(/<[^>]+\\/?s*>/) then # skip HTML tags\n html << s.matched\n when s.scan(/\\\\(\\S)/) then # unhandled suppressed crossref\n html << s[1]\n after_word = nil\n when s.scan(/\\.\\.\\.(\\.?)/) then\n html << s[1] << encoded[:ellipsis]\n after_word = nil\n when s.scan(/\\(c\\)/i) then\n html << encoded[:copyright]\n after_word = nil\n when s.scan(/\\(r\\)/i) then\n html << encoded[:trademark]\n after_word = nil\n when s.scan(/---/) then\n html << encoded[:em_dash]\n after_word = nil\n when s.scan(/--/) then\n html << encoded[:en_dash]\n after_word = nil\n when s.scan(/&quot;|\"/) then\n html << encoded[indquotes ? :close_dquote : :open_dquote]\n indquotes = !indquotes\n after_word = nil\n when s.scan(/``/) then # backtick double quote\n html << encoded[:open_dquote]\n after_word = nil\n when s.scan(/(?:&#39;|'){2}/) then # tick double quote\n html << encoded[:close_dquote]\n after_word = nil\n when s.scan(/`/) then # backtick\n if insquotes or after_word\n html << '`'\n after_word = false\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n when s.scan(/&#39;|'/) then # single quote\n if insquotes\n html << encoded[:close_squote]\n insquotes = false\n elsif after_word\n # Mary's dog, my parents' house: do not start paired quotes\n html << encoded[:close_squote]\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n\n after_word = nil\n else # advance to the next potentially significant character\n match = s.scan(/.+?(?=[<\\\\.(\"'`&-])/) #\"\n\n if match then\n html << match\n after_word = match =~ /\\w$/\n else\n html << s.rest\n break\n end\n end\n end\n\n html\n end", "def erbify(code)\n # First gather all the ERb-related derived styles\n remaining = code\n styles = {'Ruby_20_Code' => 'Code', 'Ruby_20_Value' => 'Value',\n 'Ruby_20_Literal' => 'Literal'}\n re_styles = /<style:style style:name=\"([^\"]+)\" style:parent-style-name=\"Ruby_20_(Code|Value|Literal)\" style:family=\"table-cell\">/\n \n while remaining.length > 0\n md = re_styles.match remaining\n if md\n styles[md[STYLE_NAME]] = md[STYLE_TYPE]\n remaining = md.post_match\n else\n remaining = \"\"\n end\n end\n \n remaining = code\n result = String.new\n \n # Then make a RE that includes the ERb-related styles.\n # Match positions:\n # \n # 1. ROW_START Begin table row ?\n # 2. TYPE ERb text style type\n # 3. ERB_CODE ERb code\n # 4. ROW_END End table row (empty cells then end of row) ?\n #\n # \"?\": optional, might not occur every time\n re_erb = /(<table:table-row[^>]*>)?<table:table-cell [^>]*table:style-name=\"(#{styles.keys.join '|'})\"[^>]*><text:p>([^<]*)<\\/text:p><\\/table:table-cell>(((<table:covered-table-cell[^\\/>]*\\/>)|(<table:table-cell[^\\/>]*\\/>))*<\\/table:table-row>)?/\n\n # Then search for all text using those styles\n while remaining.length > 0\n\n md = re_erb.match remaining\n \n if md\n \n result += md.pre_match\n \n #match_code = false\n #match_row = false\n\n # if md[ROW_START] and md[ROW_END]\n # match_row=true\n # end\n\n skip_row=false\n #create cells, but dont append\n cells= case styles[md[TYPE]]\n when \"Code\" then \n skip_row=true\n \"<% #{self.unnormalize md[ERB_CODE]} %>\"\n when \"Literal\" then \"<%= #{self.unnormalize md[ERB_CODE]} %>\"\n when \"Value\" then \"<%=cell (#{self.unnormalize md[ERB_CODE] }) %>\" #let helper build the correct \"cell\"\n end\n \n #fist see if we should open row tag\n\t\t #\n\t\t #N.B - this assumes that there should be NO CELL VALUS after this one on the same row (will create invalid document)... \n if md[ROW_START] and not skip_row\n result+= md[ROW_START]\n end\n \n #then cell body\n result+=cells\n\n #then close\n if md[ROW_END] and not skip_row\n result += md[ROW_END]\n end\n \n remaining = md.post_match\n \n else # no further matches\n result += remaining\n remaining = \"\"\n end\n end\n \n return result\n end", "def update_html\n # need to filter HTML first... remove <script> and chunks and the like...\n self.html = RedCloth.new(strip_tags(self.redcloth.to_s),\n [ :no_span_caps ]).to_html(\n # no link references. messes up lines starting with [[WikiWord]]\n :block_textile_table, :block_textile_lists, :block_textile_prefix,\n :inline_textile_image, :inline_textile_link, :inline_textile_code,\n :inline_textile_span, :glyphs_textile)\n end", "def erbify(code)\n # First gather all the ERb-related derived styles\n remaining = code\n styles = {'Ruby_20_Code' => 'Code', 'Ruby_20_Value' => 'Value',\n 'Ruby_20_Block' => 'Block', 'Ruby_20_Literal' => 'Literal'}\n re_styles = /<style:style style:name=\"([^\"]+)\"[^>]* style:parent-style-name=\"Ruby_20_(Code|Value|Block|Literal)\"[^>]*>/\n\n while remaining.length > 0\n md = re_styles.match remaining\n if md\n styles[md[STYLE_NAME]] = md[STYLE_TYPE]\n remaining = md.post_match\n else\n remaining = \"\"\n end\n end\n \n remaining = code\n result = String.new\n \n # Then make a RE that includes the ERb-related styles.\n # Match positions:\n # \n # 1. ROW_START Begin table row ?\n # 2. ITEM_START Begin list item ?\n # 3. PARA_START Begin paragraph ?\n # 4. SPAN_END Another text span ends immediately before ERb ?\n # --5. SPACE (possible leading space)\n # 5. TYPE ERb text style type\n # 6. ERB_CODE ERb code\n # 7. (ERb inner brackets)\n # 8. SPAN_START Another text span begins immediately after ERb ?\n # 9. PARA_END End paragraph ?\n # 10. ITEM_END End list item ?\n # 11. ROW_END End table row (incl. covered rows) ?\n #\n # \"?\": optional, might not occur every time\n# re_erb = /(<table:table-row[^>]*>\\s*<table:table-cell [^>]+>\\s*)?(\\s*<text:list-item>\\s*)?\\s*(<text:p [^>]+>\\s*)?(<\\/text:span>)?<text:span text:style-name=\"(#{styles.keys.join '|'})\">(([^<]*|<text:line-break\\/>|<text:tab\\/>)+)<\\/text:span>(<text:span [^>]+>)?(\\s*<\\/text:p>\\s*)?(<\\/text:list-item>\\s*)?(<\\/table:table-cell>\\s*(<table:covered-table-cell\\/>\\s*)*<\\/table:table-row>)?/\n re_erb = /(<table:table-row[^>]*>\\s*<table:table-cell [^>]+>\\s*)?(<text:list-item>\\s*)?(<text:p [^>]+>\\s*)?(<\\/text:span>\\s*)?<text:span text:style-name=\"(#{styles.keys.join '|'})\">(([^<]*|<text:line-break\\/>|<text:tab\\/>)+)<\\/text:span>(<text:span [^>]+>)?(\\s*<\\/text:p>)?(\\s*<\\/text:list-item>)?(\\s*<\\/table:table-cell>(\\s*<table:covered-table-cell\\/>)*\\s*<\\/table:table-row>)?/\n\n # Then search for all text using those styles\n while remaining.length > 0\n\n md = re_erb.match remaining\n \n if md\n result += md.pre_match\n \n match_code = false\n match_row = false\n match_item = false\n match_para = false\n match_span = false\n\n if styles[md[TYPE]] == 'Code'\n match_code = true\n delim_start = '<% ' ; delim_end = ' %>'\n if md[PARA_START] and md[PARA_END]\n match_para = true\n if md[ITEM_START] and md[ITEM_END]\n match_item = true\n end\n if md[ROW_START] and md[ROW_END]\n match_row = true\n end\n end\n elsif styles[md[TYPE]] == 'Block'\n delim_start = '<%= ' ; delim_end = ' %>'\n if md[PARA_START] and md[PARA_END]\n match_para = true\n end\n else # style is Value or Literal\n if styles[md[TYPE]] == 'Literal'\n delim_start = '<%= ' ; delim_end = ' %>'\n else\n delim_start = '<%= ERB::Util.h(' ; delim_end = ') %>'\n end\n \n if md[SPAN_END] and md[SPAN_START]\n match_span = true\n end\n end\n \n if md[ROW_START] and not match_row\n result += md[ROW_START]\n end\n\n if md[ITEM_START] and not match_item\n result += md[ITEM_START]\n end\n \n if md[PARA_START] and not match_para\n result += md[PARA_START]\n end\n \n # Text formatting before ERb\n if match_code\n if md[SPAN_END]\n result += md[SPAN_END]\n end\n else\n #if md[SPACE]\n # result += md[SPACE]\n #end\n if md[SPAN_START] and not md[SPAN_END]\n result += md[SPAN_START]\n end\n end\n \n result += \"#{delim_start}#{self.unnormalize md[ERB_CODE]}#{delim_end}\"\n \n # Text formatting after ERb\n if match_code\n if md[SPAN_START]\n result += md[SPAN_START]\n end\n else\n if md[SPAN_END]\n result += md[SPAN_END]\n if md[SPAN_START]\n result += md[SPAN_START]\n end\n end\n end\n\n if md[PARA_END] and not match_para\n result += md[PARA_END]\n end\n\n if md[ITEM_END] and not match_item\n result += md[ITEM_END]\n end\n \n if md[ROW_END] and not match_row\n result += md[ROW_END]\n end\n \n remaining = md.post_match\n \n else # no further matches\n result += remaining\n remaining = \"\"\n end\n end\n \n return result\n end", "def push_plain(text, options = {})\n if block_opened?\n raise SyntaxError.new(\"Illegal nesting: nesting within plain text is illegal.\", @next_line.index)\n end\n\n if contains_interpolation?(text)\n options[:escape_html] = self.options[:escape_html] if options[:escape_html].nil?\n push_script(\n unescape_interpolation(text, :escape_html => options[:escape_html]),\n :escape_html => false)\n else\n push_text text\n end\n end", "def render\n return \"\" if links.empty?\n\n # Loop through all but the last (current) link and build HTML of the fragments\n fragments = links[0..-2].map do |link|\n render_fragment(options[:fragment_tag], link.text, link.url, options[:semantic])\n end\n\n # The current link is handled a little differently, and is only linked if specified in the options\n current_link = links.last\n fragments << render_fragment(options[:fragment_tag], current_link.text, (options[:link_current] ? current_link.url : nil), options[:semantic], class: options[:current_class])\n\n # Build the final HTML\n html = (options[:pretext] + fragments.join(options[:separator]) + options[:posttext]).html_safe\n content_tag(options[:container_tag], html, id: options[:id], class: options[:class])\n end", "def smooth_offtags( text )\n unless @pre_list.empty?\n ## replace <pre> content\n text.gsub!(/<redpre#(\\d+)>/) do\n content = @pre_list[$1.to_i]\n if content.match(/<code\\s+class=\"(\\w+)\">\\s?(.+)/m)\n content = \"<code class=\\\"#{$1} syntaxhl\\\">\" + \n Redmine::SyntaxHighlighting.highlight_by_language($2, $1)\n end\n content\n end\n end\n end", "def process(data)\n return data if data.nil? || data.size.zero? || @code_blocks.size.zero?\n @code_blocks.each do |block|\n data.gsub!(block.id, block.highlighted)\n end\n data\n end", "def as_code(text)\n '/code ' + sanitze_for_chat(text)\n end", "def to_html_code(code)\n \"<figure class=\\\"highlight\\\"><pre><code class=\\\"language-resolve\\\" data-lang=\\\"#resolve\\\">\"\\\n \"#{code.chomp}</code></pre></figure>\"\n end", "def compile(options={})\n defaults = {:text => nil, :compress => nil}\n options = defaults.merge options\n @text = options[:text] if options[:text] != nil\n @compress = !!options[:compress] if options[:compress] != nil\n \n while @text != \"\" do\n self.process_current_level\n self.close_lower_level_tags\n self.process_next_line\n end\n \n self.close_tag while @open_tags.length > 0\n \n @output\n end", "def apply_custom_formatting(text)\n\n # Define custom formatting codes and replacement values.\n codes = []\n codes << '<code>'\n codes << '</code>'\n replacements = []\n replacements << '<font name=\"SF Mono\"><color rgb=\"e83e8c\"><b>'\n replacements << '</b></color></font>'\n\n # Process each replacement.\n codes.each_with_index do |code, index|\n text.gsub!(code, replacements[index])\n end\n\n end", "def to_html\r\n html = ''\r\n text_runs.each { |text_run| html << text_run.to_html }\r\n styles = {}\r\n styles['font-size'] = \"#{font_size}pt\" unless font_size.nil?\r\n styles['text-align'] = @style.text_align unless @style.aligned_left?\r\n html_tag(:p, content: html, styles: styles)\r\n end", "def markup text\n document = parse text\n\n document.accept formatter\n end", "def render(_options = {})\n content_tag :div, class: css_name do\n content_text = data['text'] || ''\n CommonMarker::Rouge.render_html(\n content_text,\n %i[UNSAFE FOOTNOTES STRIKETHROUGH_DOUBLE_TILDE],\n %i[UNSAFE GITHUB_PRE_LANG HARDBREAKS TABLE_PREFER_STYLE_ATTRIBUTES FULL_INFO_STRING FOOTNOTES],\n %i[table strikethrough tasklist tagfilter],\n formatter: Rouge::Formatters::HTMLLegacy.new(inline_theme: 'github')\n ).html_safe\n end\n end", "def codes_html(code, team_id, last_result=nil)\n ko_price = \"#{code.ko}[#{code.bonus}]\"\n team_code = TeamCode.where(code_id: code.id, team_id: team_id, state: [Code::STATES.index(:accepted), Code::STATES.index(:accessed)]).first\n if team_code.present?\n style = \"color: #{code.color || 'red'};\"\n style << \"border: 2px inset red;\" if last_result.present? && last_result.select {|i| i[:id] == code.id}.present?\n code_text = ko_price\n code_text += \"(#{code.show_code})\" if team_code.team_bonus.blank?\n code_text = content_tag(:b, content_tag(:span, code_text, style: style).html_safe)\n code_text += (\"<br>#{code.info}<br>\").html_safe if code.info.present?\n code_text.html_safe\n else\n content_tag(:span, \"#{ko_price}\", class: 'ko', 'data-id' => code.id).html_safe\n end\n end", "def wrap(html); end", "def wrap(html); end", "def html_markup_textile(text); end", "def call\n result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html\n result.rstrip!\n result\n end", "def html_to_bbcode(string); end", "def html_syntax_highlight(source, type = T.unsafe(nil)); end", "def text_to_html( content )\r\n content = case @markup_type\r\n when :markdown\r\n markdown_to_html( content )\r\n when :textile\r\n textile_to_html( content )\r\n when :rest\r\n rest_to_html( content )\r\n end\r\n content\r\n end", "def process_html(content)\n head, opener, tail = content.output.partition(OPENING_BODY_TAG_REGEX)\n body_content, *rest = tail.partition(\"</body>\")\n\n processed_markup = process_anchor_tags(body_content)\n\n content.output = String.new(head) << opener << processed_markup << rest.join\n end", "def parse(code = nil, options = nil, &block)\n Parsing::parse(code, options, &block)\n end", "def pygmentize(code, lang)\n url = URI.parse 'http://pygments.simplabs.com/'\n options = {'lang' => lang, 'code' => code}\n begin\n Net::HTTP.post_form(url, options).body\n rescue\n \"<pre>#{code}</pre>\"\n end\n end", "def encode(text)\n code(text,:enbbcode) if text\n end", "def better_format(text, html_options = {}, options = {})\n wrapper_tag = options.fetch(:wrapper_tag, :p)\n\n text = sanitize(text) if options.fetch(:sanitize, true)\n paragraphs = split_paragraphs(text)\n\n if paragraphs.empty?\n content_tag(wrapper_tag, nil, html_options)\n else\n paragraphs.map { |paragraph|\n # paragraph = \"<br />\" if paragraph.empty? || paragraph =~ /\\A\\s+\\z/ \n paragraph.gsub!(/(?:^\\s)|\\G\\s/m, \"&nbsp;\") if !(paragraph[0..4]==\"<pre>\" && paragraph[-6..-1]==\"</pre>\")\n content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])\n }.join(\"\\n\\n\").html_safe\n end\n end", "def format(text)\n if text.nil?\n \"\"\n elsif defined?(RDiscount)\n RDiscount.new(text).to_html\n elsif defined?(BlueCloth)\n BlueCloth.new(text).to_html\n elsif no_paragraph_tag?(text)\n content_tag :p, text\n else\n text\n end\n end", "def format(text)\n if text.nil?\n \"\"\n elsif defined?(RDiscount)\n RDiscount.new(text).to_html\n elsif defined?(BlueCloth)\n BlueCloth.new(text).to_html\n elsif no_paragraph_tag?(text)\n content_tag :p, text\n else\n text\n end\n end", "def capture_html(*args, &block) \n if self.respond_to?(:is_haml?) && is_haml?\n block_is_haml?(block) ? capture_haml(*args, &block) : block.call\n elsif erb_buffer?\n result_text = capture_block(*args, &block)\n result_text.present? ? result_text : (block_given? && block.call(*args))\n else # theres no template to capture, invoke the block directly\n block.call(*args)\n end\n end", "def safe_text text\n return \"\" if text.nil?\n \n markdown_content_type = \"# Content-Type: text/markdown\"\n starts_with_markdown = text.strip.start_with? markdown_content_type\n if (not /<(a |img |ol|ul|li|h[1-6]|p|div|span)[^<]*>/.match(text)) && !starts_with_markdown\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\",\"<br />\\n\") + \"</blockquote>\"\n end\n\n if BMF::Settings.instance.display_sanitized_html != 'yes'\n return \"<blockquote>\" + CGI::escape_html(text).gsub(\"\\n\", \"<br />\\n\") + \"</blockqoute>\"\n end\n\n if text.strip.start_with? markdown_content_type\n text = RDiscount.new(text.sub(markdown_content_type, \"\")).to_html\n end\n\n safe_html(text)\n \n end", "def highlight_codeblock(el)\r\n #puts highlight_code(el.value, el.attr['class'], :span)\r\n #h = ::Kramdown::Converter.syntax_highlighter(@options[:syntax_highlighter])\r\n #puts h.call(self, el.value, el.attr['class'], :span)\r\n #puts syntax_highlighter(self, el.value, el.attr['class'], :span)\r\n puts \"SB #{el.inspect}\"\r\n nil # until it's ready for Shoes to eval it. \r\n end", "def to_html\r\n html = @text\r\n html = html_tag(:em, content: html) if italicized?\r\n html = html_tag(:strong, content: html) if bolded?\r\n styles = {}\r\n styles['text-decoration'] = 'underline' if underlined?\r\n # No need to be granular with font size down to the span level if it doesn't vary.\r\n styles['font-size'] = \"#{font_size}pt\" if font_size != @font_size\r\n html = html_tag(:span, content: html, styles: styles) unless styles.empty?\r\n html = html_tag(:a, content: html, attributes: {href: href, target: \"_blank\"}) if hyperlink?\r\n return html\r\n end", "def format_code strip = true\n format_ruby self.code, strip\n end", "def simple_format(text)\r\n text.gsub!(/(\\r\\n|\\n|\\r)/, \"\\n\") # lets make them newlines crossplatform\r\n text.gsub!(/\\n\\n+/, \"\\n\\n\") # zap dupes\r\n text.gsub!(/\\n\\n/, '</p>\\0<p>') # turn two newlines into paragraph\r\n text.gsub!(/([^\\n])(\\n)([^\\n])/, '\\1\\2<br />\\3') # turn single newline into <br />\r\n\r\n #MGS- don't want everything wrapped in a <p> tag\r\n #content_tag(\"p\", text)\r\n return text\r\n end", "def to_html(text, format = nil)\n format ||= :textile\n if format == :textile\n RedCloth.new(text).to_html\n else\n text\n end\n end", "def plain_html\n self.class.to_html.to_html(text.dup)\n end", "def cleaned_up_text_body(format = false)\n # http://stackoverflow.com/a/15098459\n caller = caller_locations(1,1)[0].label\n if caller == 'receive_issue' || caller == 'receive_issue_reply'\n html_body\n else\n super\n end\n rescue => e\n # log error\n RedmineHtmlMailHandler::HtmlMailHandlerLogger.write(:error, \"ERROR=#{e.message}\")\n RedmineHtmlMailHandler::HtmlMailHandlerLogger.write(:error, \"BACKTRACE=\\n#{e.backtrace.join(\"\\n\")}\")\n # raise error that can be catched by 'notify_invalid_mail_handler' plugin\n raise RedmineHtmlMailHandler::Error, e.message\n end", "def prettybox_bottomonly(html_options, &proc)\n raise ArgumentError, \"Missing block\" unless block_given?\n concat(tag(\"div\", html_options, true), proc.binding)\n concat(\"<div class=\\\"prettybox_inside\\\">\", proc.binding)\n yield\n concat(\"</div><div class=\\\"prettybox_bot\\\">\n <div>&nbsp;</div>\n </div>\n </div>\", proc.binding)\n end" ]
[ "0.6652656", "0.6535241", "0.6412524", "0.6400033", "0.6294351", "0.6195641", "0.61693525", "0.6141368", "0.61001754", "0.60769266", "0.60422814", "0.6006865", "0.59752667", "0.592088", "0.5911805", "0.589874", "0.5836841", "0.582105", "0.5796861", "0.5793838", "0.57308114", "0.57162285", "0.5705921", "0.5641887", "0.560064", "0.55986446", "0.5595377", "0.5588431", "0.55801094", "0.5573997", "0.5552229", "0.55502015", "0.55387425", "0.55222297", "0.5510601", "0.5506127", "0.54498285", "0.5441337", "0.543862", "0.54279894", "0.5417647", "0.5417647", "0.5403251", "0.5384112", "0.5377832", "0.536553", "0.53635293", "0.53635293", "0.53593373", "0.5357413", "0.53503615", "0.53463584", "0.534532", "0.53404295", "0.53372127", "0.53359425", "0.5335551", "0.53229284", "0.5320768", "0.5314346", "0.53129756", "0.52991796", "0.52968204", "0.52899987", "0.5289922", "0.5288408", "0.52866197", "0.5276003", "0.5273432", "0.52728945", "0.5272681", "0.5271343", "0.52701145", "0.52689385", "0.52661544", "0.52522975", "0.5241827", "0.5241827", "0.5226564", "0.5224788", "0.5220876", "0.5216831", "0.52151823", "0.5210612", "0.52085644", "0.5208117", "0.51907486", "0.5186834", "0.5181403", "0.5181403", "0.51670223", "0.51664394", "0.5165674", "0.51591325", "0.5153666", "0.51491076", "0.5148939", "0.51469857", "0.5144981", "0.51412964" ]
0.6571611
1
Replace to prevent Erubis injection.
def erubis_filter(text) return text if text.nil? t = text.dup t.gsub!('<%', '&lt;%') t.gsub!('%>', '%&rt;') t end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace\n end", "def erb_escape(text)\n # Do not only replace '<%' ! or <r:t>min</r:t>% ==> <% ...\n text.gsub(SECURE_REGEXP) {|code| SAFE_CODE[code]}\n end", "def undent!\n replace undent\n end", "def replace(s)\n s.tr(\"aeiouAEIOU'\",\"!\")\nend", "def sanitize(string_or_io)\n Loofah.scrub_fragment(string_or_io, :escape).to_s\n end", "def replacements; end", "def sanitize_tag(in_tag)\n in_tag.gsub(/[^\\w%=\\-\\\\+]+/,\"\")\n end", "def replace(input, string, replacement = T.unsafe(nil)); end", "def sanitize(name)\n #name.gsub(\".\", \"_\").gsub(/<.+>/, \"\")\n name.gsub(\".\", \"_\").gsub(\"$\", \"_\")\nend", "def replace(s)\n s.gsub(/[AEIOUaeiou]/, \"!\")\nend", "def escape_quotes(unfiltered)\n unfiltered.to_s.gsub(/'/, \"''\")\n end", "def escape(x)\n x = x.to_s\n x.gsub! @delimiter, @edelim if @delimiter\n x.gsub! @internal_delimiter, @eidelim\n x\n end", "def consume_escaped; end", "def string_replacements\nend", "def escape(string); end", "def bad_sanitize(str)\n str.gsub(/'/,\"''\")\nend", "def e(str)\n str.to_s.gsub(/(?=[^a-zA-Z0-9_.\\/\\-\\x7F-\\xFF\\n])/n, '\\\\').\n gsub(/\\n/, \"'\\n'\").\n sub(/^$/, \"''\")\n end", "def requote(value) return restore_ends(value, '\"') end", "def uninspect(str)\n return nil unless str\n str.gsub(%r!\\\\([\\\\#\"abefnrstvx]|u\\d{4}|u\\{[^\\}]+\\}|\\d{1,3}|x\\d{1,2}|cx|C-[a-zA-Z]|M-[a-zA-Z]| |=|:)!) do |m|\n repl = \"\"\n if ['\\\\', '#', '\"'].include?($1)\n repl = $1\n else\n repl = eval(\"\\\"\\\\#{$1}\\\"\")\n end\n repl\n end\n end", "def set_replace_tag(begin_tag, end_tag, escape=true)\n\t\tif(escape)\n\t\t\tbegin_tag = begin_tag.gsub(/([.*+?^\\$\\\\|()\\[\\]])/, '\\\\\\\\\\\\1')\n\t\t\tend_tag = end_tag .gsub(/([.*+?^\\$\\\\|()\\[\\]])/, '\\\\\\\\\\\\1')\n\t\tend\n\n\t\t@@SIFTER_REPLACE_TAG_BGN = begin_tag\n\t\t@@SIFTER_REPLACE_TAG_END = end_tag \n\t\t@@SIFTER_REPLACE_PATTERN = begin_tag + SIFTER_REPLACE_EXPRESSION + end_tag\n\tend", "def replace_quote(string)\n # do not know those two are different\n # ERB::Util.html_escape string.to_s.gsub 'aaa', 'bbb'\n # ERB::Util.html_escape string.to_s\n # since it is safebuffer and html_safe, this will output with single\n # quotes for example: data-datatable-multiselect=' <select multiple='multi\n # ERB::Util.html_escape string\n # replace single quote with double quote\n string.to_s.tr \"'\", '\"'\n end", "def escape(str); end", "def as_replacements; end", "def as_replacements; end", "def as_replacements; end", "def skip_html_injection=(_arg0); end", "def remove_interpunction!(str)\n str.gsub!(/\\A['\"]+|[!,.\"']+\\Z/, '')\n str\n end", "def autofinish; end", "def replaceOnlyEntityRefs(str)\n\t return nil if str.nil?\n\t copy = str.dup\n\t replacement = ''\n\t while copy =~ /&([^&;]*);/mn\n\t\treplacement << $`\n\t\tref = $&\n\t\trefName = $1\n\t\tcopy = $'\n\t\tif refName =~ /\\A(#[0-9]*|#x[0-9A-Fa-f]|amp|quot|apos|gt|lt)\\z/n\n\t\t replacement << ref\n\t\telse\n\t\t val = @internalEntities[refName]\n\t\t if val.nil?\n\t\t\tstr = \"entity reference '#{ref}' is undefined\"\n\t\t\traise ParserError.new(str, self)\n\t\t end\n\t\t val = replaceAllRefsButParams(val)\n\t\t replacement << val\n\t\tend\n\t end\n\t replacement << copy\n\t return replacement\n\tend", "def escape_double_quotes\r\n return self.gsub('\"', '\\\"')\r\n end", "def sanitize(value)\n case value\n when Regexp then value.source\n else Regexp.escape value\n end\n end", "def sanitize_tag(in_tag)\n in_tag.gsub(/[^\\w%=-\\\\+]+/,\"\")\n end", "def sanitize!; end", "def sanitize(str)\n str.gsub(%r{[\\\\/*?\"<>|\\s,#]:}, '').downcase\n end", "def sanitize(str)\n str.gsub(\"'\", \"\\\\'\")\n end", "def replace(p0) end", "def replace(p0) end", "def replace(p0) end", "def replace_this_with_appropriate_code(x) end", "def sanitize_string(value)\n value.sub(/\\A['\"](.*)['\"]\\Z/, '\\1').gsub(/\\\\\"|\"|'/, '\"')\n end", "def esc(str)\n str = str.to_s.gsub(\"&\", \"&amp;\")\n str = str.gsub(\"\\\"\", \"&apos;\")\n str = str.gsub(\"\\\"\", \"&quot;\")\n str = str.gsub(\"<\", \"&lt;\")\n str.gsub(\">\", \"&gt;\")\nend", "def sanitize_escape_sequences(msg)\n msg = msg.gsub(\"\\r\", \"[CR]\")\n msg = msg.gsub(\"\\n\", \"[LF]\")\n msg = msg.gsub(/\\e\\[A/, '[CUU]')\n msg = msg.gsub(/\\e\\[B/, '[CUD]')\n msg = msg.gsub(/\\e\\[2K/, '[CLEAR]')\n msg = msg.gsub(/#{3.chr}/, '[ETX]')\n msg = msg.gsub(/#{4.chr}/, '[EOT]')\n msg = msg.gsub(/#{7.chr}/, '[BELL]')\n msg = msg.gsub(/#{8.chr}/, '[BS]')\n msg = msg.gsub(/#{9.chr}/, '[TAB]')\n msg = msg.gsub(/#{24.chr}/, '[CAN]')\n msg = msg.gsub(/#{27.chr}/, '[ESC]')\n msg = msg.gsub(/#{127.chr}/, '[DEL]')\n msg\n end", "def remove_special_characters(string)\n string.gsub(/[~\"'&#%]/, '-')\n end", "def escape(string)\n #This is a stub, used for indexing\n end", "def replace_string(str_to_replace,file_to_edit,envVar)\n # load the file as a string\n data = File.read(\"#{file_to_edit}\")\n # globally substitute\n filtered_data = data.gsub(\"#{str_to_replace}\", \"#{envVar}\")\n # open the file for writing\n File.open(\"#{file_to_edit}\", \"w\") do |f|\n f.write(filtered_data)\n end\n end", "def sanitize_similar_to_value(value)\n value.gsub(/[\\\\_%|*+?{}()\\[\\]]/) { |x| \"\\\\#{x}\" }\n end", "def escape(text)\n text.gsub('\"', '\\\"')\nend", "def likeEscape( str )\n str.gsub( \"\\\\\", \"\\\\\\\\\" ).gsub( \"%\", \"\\%\" ).gsub( \"_\", \"\\_\" )\n end", "def escape(s)\n s.gsub('\"', '\\\"')\nend", "def replaceParamRefs(str)\n\t return nil if str.nil?\n\t copy = str.dup\n\t replacement = ''\n\t while copy =~ /%([^%;]*);/mn\n\t\treplacement << $`\n\t\tref = $&\n\t\trefName = $1\n\t\tcopy = $'\n\t\tval = @paramEntities[refName]\n\t\tif val.nil?\n\t\t str = \"entity reference '#{ref}' is undefined\"\n\t\t raise ParserError.new(str, self)\n\t\tend\n\t\tval = replaceParamRefs(val)\n\t\treplacement << val\n\t end\n\t replacement << copy\n\t return replacement\n\tend", "def replace(filter = '')\n q(filter) { |e| e.replace(@strings.values) }\n self\n end", "def escape(str)\n $stderr.print \"FE: \", str if $DEBUG_RDOC\n s = str.\n sub(/\\s+$/, '').\n gsub(/([_\\${}&%#])/, \"#{BS}\\\\1\").\n gsub(/\\\\/, BACKSLASH).\n gsub(/\\^/, HAT).\n gsub(/~/, TILDE).\n gsub(/</, LESSTHAN).\n gsub(/>/, GREATERTHAN).\n gsub(/,,/, \",{},\").\n gsub(/\\`/, BACKQUOTE)\n $stderr.print \"-> \", s, \"\\n\" if $DEBUG_RDOC\n s\n end", "def vowel_censor(string)\n\n string.gsub(/[aeiou]/, 'X') \n p string \n \nend", "def escape(text)\n replacements.inject(text.to_s) do |corpus, (pattern, replacement)|\n corpus.gsub(pattern, replacement)\n end\n end", "def sanitize(text)\n text.gsub('<', '&lt;').gsub('>', '&gt;')\n end", "def e_sh(str)\n str.to_s.gsub(/(?=[^a-zA-Z0-9_.\\/\\-\\x7F-\\xFF\\n])/n, '\\\\').gsub(/\\n/, \"'\\n'\").sub(/^$/, \"''\")\nend", "def sanitize(string, options = {})\n Engine.clean(string)\n end", "def escape_like(str)\n str.gsub(/[!%_]/){ |x| '!' + x }\n end", "def xml_sanitize(str)\n str.gsub(/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/, \"?\")\nend", "def xml_sanitize(str)\n str.gsub(/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/, \"?\")\nend", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def escape(string)\r\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\r\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\r\n end", "def filter_text(text)\n text = text.to_s\n text.gsub('&', '&amp;')\n text.gsub('\\'', '&#039;')\n text.gsub('\"', '&quot;')\n text.gsub('<', '&lt;')\n text.gsub('>', '&gt;')\n text\n end", "def remove_nonprintable!\n replace(remove_nonprintable)\n end", "def read_with_substitution(input, illegal = T.unsafe(nil)); end", "def exc_delete(str)\n\tstr.gsub(/[!]/, \"!\" => \" \")\nend", "def fix_double_escape(escaped)\n escaped.gsub(/&amp;([a-z]+|(#\\d+));/i) { \"&#{$1};\" }\n end", "def replace(line)\n return line if line !~ /\\{\\{Gc/\n return line if line =~ /link=none/ || line =~ /dis=false/ || line =~ /dis=true/\n return line.gsub!(/\\{\\{[Gg]c|mod=(\\S+)\\|/, '{{Gc|mod=\\1|dis=false|')\nend", "def correct_unncessarily_escaped_html_tags(element)\n statement = element.statement\n [:sup, :i].each do |tag|\n statement.gsub!(/&lt;#{tag}&gt;/,%Q{<#{tag}>})\n statement.gsub!(/&lt;\\/#{tag}&gt;/,%Q{</#{tag}>})\n end\n element.instance_variable_set(:@statement,statement)\n end", "def safe_output(input)\n sanitize Nokogiri::HTML.fragment(CGI.unescapeHTML(input)).to_s\n end", "def change_quotemarks!\n local_copy.in_place :perl, \"s/\\\"/'/g\"\n end", "def escape(s)\n s.gsub(/[&<>`]/, \"&\" => \"&amp;\", \"<\" => \"&lt;\", \">\" => \"&gt;\", \"`\" => \"`\")\n end", "def dostr\n return <<EOS\ns=<<ES\n#{@dostr.gsub(/_REMOVE_/,'')}\nES\nEOS\n end", "def escape(stream = '')\n return stream if absent?(stream)\n\n stream.gsub(/\\e/, '\\\\e')\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end", "def escape(string)\n # Globally replace characters based on the ESCAPE_CHARACTERS constant\n string.to_s.gsub(/[&\"><]/) { |special| ESCAPE_CHARACTERS[special] } if string\n end" ]
[ "0.66146696", "0.6485839", "0.63849676", "0.61406213", "0.6053341", "0.5999961", "0.5924494", "0.5890652", "0.5886605", "0.5863753", "0.58428395", "0.58367366", "0.5835879", "0.58172697", "0.5794907", "0.5793146", "0.57822055", "0.5774545", "0.57470423", "0.573602", "0.57172394", "0.57120425", "0.5706918", "0.5706918", "0.5706918", "0.5705795", "0.5670603", "0.5656667", "0.5643878", "0.56372935", "0.5621533", "0.560168", "0.55882126", "0.5561221", "0.5557478", "0.55389535", "0.55389535", "0.55357295", "0.553176", "0.552322", "0.55139464", "0.55136687", "0.55112356", "0.5510894", "0.5508741", "0.5505241", "0.54936534", "0.54888904", "0.5485286", "0.54836565", "0.5474527", "0.54574615", "0.5451827", "0.5438815", "0.5437704", "0.5429502", "0.5427264", "0.54177666", "0.5399529", "0.5399529", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.5396684", "0.53962463", "0.5374713", "0.5374285", "0.5367825", "0.53660715", "0.53652406", "0.53502184", "0.53408974", "0.53355885", "0.5330089", "0.53259045", "0.5325543", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114", "0.53253114" ]
0.6117327
4
Macro substitutions Expands [[type:resource][name]] macros. Right now, resource is just an attachment. Included types are: url: returns the URL to an attachment image: returns an image tag link: returns a link to an attachment page_nav: A list of subpages attachments: A list of attachments The default action is a link, so [[foo.jpg]] => foo.jpg
def macro(text) return text if text.nil? copy = text.dup # Links # # Example [[image:foo.png][name]] # 1. the prefix image # 2. the link, with colon :foo.png # 3. the link itself foo.png # 4. the second half of the link [name] # 5. the name name #copy.gsub!(/\[\[(([^\]]+):)?([^\]]+)(\]\[([^\]]+))?\]\]/) do |match| copy.gsub!(/\[\[([^\]]+?)(:([^\]]+))?(\]\[([^\]]+))?\]\]/) do |match| prefix = $1 path = $3 name = $5 # Name of the link name ||= path Ramaze::Log.debug prefix # Create link to this target case prefix when 'attachments' # A list of attachments attachment_list self when 'image' # Create an inline image target = attachment(path) "<img class=\"attachment\" src=\"#{target.public_path}\" alt=\"#{name.gsub('"', '&quot;')}\" title=\"#{name.gsub('"', '&quot')}\" />" when 'page_nav' # Create a page table of contents subpage_navigation self when 'url' # Create a URL target = attachment(path) target.public_path else # Create a full link target = attachment(path) "<a href=\"#{target.public_path}\">#{Rack::Utils.escape_html(name).gsub(/#([{@$]@?)/, '&#35;\1')}</a>" end end copy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_for(action, resource)\n\t\t\t\"#{resource.gsub(\" \",\"_\")}/#{action}\"\n\t\tend", "def expand\n\t\t\tblock = Glyph::MACROS[@name]\n\t\t\tmacro_error \"Undefined macro '#@name'\" unless block\n\t\t\tinstance_exec(@node, &block).to_s.gsub(/\\\\?([\\[\\]\\|])/){\"\\\\#$1\"}\n\t\tend", "def content_fu(content, thumbnail)\n content.scan(/\\/system\\/images([^\\\"\\ ]*)/).flatten.each do |match|\n\t\t\tparts = match.split(\".\")\n\t\t\textension = parts.pop\n\t\t\tcontent.gsub!(match, \"#{parts.join(\".\")}_#{thumbnail}.#{extension}\")\n\t\tend\n\t\t\n\t\treturn content\n end", "def resources_url options={}\n r=request.path\n options = case params[:action]\n when 'create','update','delete','destroy'; \"\"\n else resource_options(options)\n end\n return \"%s%s\" % [r,options] if r.match \"#{resource.class.to_s.tableize}$\"\n \"%s%s%s\" % [ r.split( resource.class.to_s.tableize)[0],resource.class.to_s.tableize, options]\n rescue Exception => e\n scoop_from_error e\n end", "def gen_url url, text\n if url =~ /^rdoc-label:([^:]*)(?::(.*))?/ then\n type = \"link\"\n elsif url =~ /([A-Za-z]+):(.*)/ then\n type = $1\n else\n type = \"http\"\n end\n\n if (type == \"http\" or type == \"https\" or type == \"link\") and\n url =~ /\\.(gif|png|jpg|jpeg|bmp)$/ then\n ''\n else\n text.sub(%r%^#{type}:/*%, '')\n end\n end", "def type_images(types)\n @type_map ||= { \n N::TALIA.Source => 'source',\n N::FOAF.Group => 'group',\n N::FOAF.Person => 'person'\n }\n result = ''\n types.each do |t|\n image = @type_map[t] || 'source'\n name = t.local_name.titleize\n result << link_to(image_tag(\"talia_core/#{image}.png\", :alt => name, :title => name),\n :action => 'index', :filter => t.to_name_s('+')\n )\n end\n result\n end", "def create_resource_substitutes(substitution)\n substitution['substitutes'].each do |substitute|\n @request = JSON.parse(@request.to_json.gsub(substitute, substitution['prefix'] + substitute))\n @response_expectation = JSON.parse(@response_expectation.to_json.gsub(substitute, substitution['prefix'] + substitute))\n end unless substitution.nil?\n end", "def macros\n return unless @item.has_key?(:macro)\n \n macro = @risk.macros[@item[:macro]]\n\n return if macro.blank?\n\n # Currently :macro can override the following rule attributes:\n # - :query\n # - :writer\n # - :template\n @item[:query] = macro[:query].dup if macro.has_key?(:query)\n @item[:writer] = macro[:writer].dup if macro.has_key?(:writer)\n @item[:template] = macro[:template].dup if macro.has_key?(:template)\n end", "def parcel_content_type_icon(type)\n link_to image_tag(\"/images/content-type/\"+type+\".png\", :class => 'parcel-icon'), \"/files/type/\"+type\n end", "def expand_links(actual_params)\n ResourceTemplates.new(\n select{|rt| (rt.positional_params(rt.parent) - rt.optional_params).empty?}.map {|rt|\n {\n \"name\" => rt.name,\n \"rel\" => rt.rel,\n \"uri_template\" => rt.partial_expand_uri_template(rt.uri_template, actual_params),\n \"path_template\" => rt.partial_expand_uri_template(rt.path_template, actual_params),\n \"params\" => rt.params - actual_params.keys,\n \"optional_params\" => rt.optional_params - actual_params.keys,\n \"options\" => rt.options\n }\n })\n end", "def expand_rule_definition definition\r\n\t\t@rules.reverse_each do |r|\r\n definition = definition.gsub \"[:#{r.type.to_s}]\", \"(#{r.definition})\"\r\n\t\tend\r\n\t\tdefinition\r\n\tend", "def resource_info\n\n \"content_#{id}\"\n\n end", "def resource_type\n /(\\/api\\/(?<type>\\w+)\\/?)/ =~ full_url\n type.capitalize\n end", "def headers_on( headers, content )\n\n def get_the_substitutions( headers )\n # find the headers in the remaining YAML \n # parse out the headers into level-X and pre-X headers\n # then combine them into a coherent package\n # returns a hash with the keys as the l., ll. searches\n # and the values as the replacements in the form of \n # an array where the first value is a symbol and the \n # second value is the precursor\n\n def set_the_subs_arrays(value)\n # takes a core value from the hash pulled from the yaml\n # returns an array with a type symbol and a precursor string\n if value =~ /I\\.\\z/ # type1 : {{ I. }}\n return[:type1, value[0..-3]]\n elsif value =~ /\\(I\\)\\z/ # type2 : {{ (I) }}\n return[:type2, value[0..-4]]\n elsif value =~ /i\\.\\z/ # type3 : {{ i. }}\n return[:type3, value[0..-3]]\n elsif value =~ /\\(i\\)\\z/ # type4 : {{ (i) }}\n return[:type4, value[0..-4]]\n elsif value =~ /[A-Z]\\.\\z/ # type5 : {{ A. }}\n return[:type5, value[0..-3]]\n elsif value =~ /\\([A-Z]\\)\\z/ # type6 : {{ (A) }}\n return[:type6, value[0..-4]]\n elsif value =~ /[a-z]\\.\\z/ # type7 : {{ a. }}\n return[:type7, value[0..-3]]\n elsif value =~ /\\([a-z]\\)\\z/ # type8 : {{ (a) }}\n return[:type8, value[0..-4]]\n elsif value =~ /\\(\\d\\)\\z/ # type9 : {{ (1) }}\n return[:type9, value[0..-4]]\n else value =~ /\\d\\.\\z/ # type0 : {{ 1. }} ... also default\n return[:type0, value[0..-3]]\n end\n end\n\n substitutions = {}\n headers.each do | header, value |\n if header =~ /level-\\d/\n level = header[-1].to_i\n base = \"l\"\n search = base * level + \".\"\n # substitutions hash example {\"ll.\"=>[:type8,\"Article\"],}\n substitutions[search]= set_the_subs_arrays(value.to_s)\n end\n if header =~ /no-reset/\n no_subs_array = value.split(\", \")\n no_subs_array.each{|e| substitutions[e][6] = :no_reset }\n end\n @no_indt_array = []\n if header =~ /no-indent/\n @no_indt_array = value.split(\", \")\n end\n end\n\n return substitutions\n end\n\n def find_the_block( content )\n # finds the block of text that will be processed\n # returns an array with the first element as the block \n # to be processed and the second element as the rest of the document\n if content =~ /(^```\\s*\\n?)(.*?\\n?)(^```\\s*\\n?)/m\n block = $2.chomp\n content = $PREMATCH + \"{{block}}\\n\" + $POSTMATCH\n end\n return[ block, content ]\n end\n\n def chew_on_the_block( substitutions, block )\n # takes a hash of substitutions to make from the #get_the_substitutions method\n # and a block of text returned from the #find_the_block method\n # iterates over the block to make the appropriate substitutions\n # returns a block of text\n\n def get_the_subs_arrays( value )\n # returns a new array for the replacements\n if value[0] == :type1 # :type1 : {{ I. }}\n value[2..4] = [ \"\", \"I\", \".\" ]\n return value\n elsif value[0] == :type2 # :type2 : {{ (I) }}\n value[2..4] = [ \"(\", \"I\", \")\"]\n return value\n elsif value[0] == :type3 # :type3 : {{ i. }}\n value[2..4] = [ \"\", \"i\", \".\"]\n return value\n elsif value[0] == :type4 # :type4 : {{ (i) }}\n value[2..4] = [ \"(\", \"i\", \")\"]\n return value\n elsif value[0] == :type5 # :type5 : {{ A. }}\n value[2..4] = [ \"\", \"A\", \".\"]\n return value\n elsif value[0] == :type6 # :type6 : {{ (A) }}\n value[2..4] = [ \"(\", \"A\", \")\"]\n return value\n elsif value[0] == :type7 # :type7 : {{ a. }}\n value[2..4] = [ \"\", \"a\", \".\"]\n return value\n elsif value[0] == :type8 # :type8 : {{ (a) }}\n value[2..4] = [ \"(\", \"a\", \")\"]\n return value\n elsif value[0] == :type9 # :type9 : {{ (1) }}\n value[2..4] = [ \"(\", \"1\", \")\"]\n return value\n else value[0] == :type0 # :type0 : {{ 1. }} ... also default\n value[2..4] = [ \"\", 1, \".\"]\n return value\n end\n end\n\n def log_the_line( new_block, selector, line, array_to_sub )\n substitute = array_to_sub[1..4].join\n spaces = \"\"\n unless @no_indt_array.include?(selector)\n downgrade_spaces = @no_indt_array.include?(\"l.\") ? @no_indt_array.size - 1 : @no_indt_array.size\n spaces = ( \" \" * ( (selector.size) - 2 - downgrade_spaces ) * 4 )\n end\n line = line.gsub( $1, ( $1 + spaces ) ) if line[/(\\n\\n)/]\n new_block << spaces + line.gsub(selector, substitute) + \"\\n\"\n end\n\n def increment_the_branch( hash_of_subs, array_to_sub, selector )\n romans_uppers = [ :type1, :type2 ]\n romans_lowers = [ :type3, :type4 ]\n romans = romans_uppers + romans_lowers\n if romans.any?{ |e| e == array_to_sub[0] }\n if romans_lowers.any?{ |e| e == array_to_sub[0] }\n r_l = true\n else\n r_u = true\n end\n end\n if r_l == true\n array_to_sub[3] = array_to_sub[3].upcase\n end\n if r_l == true || r_u == true\n array_to_sub[3] = RomanNumerals.to_decimal(array_to_sub[3]) \n end\n array_to_sub[3] = array_to_sub[3].next\n if r_l == true || r_u == true\n array_to_sub[3] = RomanNumerals.to_roman(array_to_sub[3]) \n end\n if r_l == true\n array_to_sub[3] = array_to_sub[3].downcase\n end\n hash_of_subs[selector]= array_to_sub\n return hash_of_subs\n end\n\n def reset_the_sub_branches( hash_of_subs, array_to_sub, selector )\n hash_of_subs = increment_the_branch( hash_of_subs, array_to_sub, selector )\n leaders_to_reset = []\n hash_of_subs.each_key{ |k| leaders_to_reset << k if k > selector }\n leaders_to_reset.each do | leader |\n unless hash_of_subs[leader][6] == :no_reset\n unless hash_of_subs[leader][5] == :pre\n hash_of_subs[leader]= get_the_subs_arrays(hash_of_subs[leader])\n else\n hash_of_subs[leader]= get_the_subs_arrays(hash_of_subs[leader])\n hash_of_subs[leader]= pre_setup(hash_of_subs[leader])\n end\n end\n end\n return hash_of_subs\n end\n\n def pre_setup( array_to_sub )\n array_to_sub[5] = :pre\n array_to_sub[1] = \"\"\n return array_to_sub\n end\n\n def reform_the_block( old_block, substitutions )\n # method will take the old_block and iterate through the lines.\n # First it will find the leading indicator. Then it will\n # find the appropriate substitution from the substitutions \n # hash. After that it will rebuild the leading matter from the\n # sub hash. It will drop markers if it is going down the tree.\n # It will reset the branches if it is going up the tree. \n # sub_it is an array w/ type[0] & lead_string[1] & id's[2..4]\n new_block = \"\"\n leader_before = \"\"\n leader_above = \"\"\n selector_before = \"\" \n temp_block = []\n old_block.each_line{ |l| old_block.gsub(l, \"\") if l[/^\\n/] }\n old_block.each_line{ |l| l[/(^l+.\\s)/] ? temp_block << l : temp_block.last << (\"\\n\" + l) }\n old_block = temp_block\n temp_block = []\n old_block.each do | line | \n line[/(^l+.\\s)/]\n selector = $1.chop\n sub_it = substitutions[selector]\n sub_it[5] = \"\" if sub_it[5].nil?\n if sub_it[5] == :pre || sub_it[1] =~ /pre/\n sub_it = pre_setup(sub_it) \n if selector_before < selector # Going down the tree, into pre\n leader_above = substitutions[selector_before][1..4].join\n sub_it[1] = leader_above = leader_before\n elsif selector_before > selector && substitutions[selector_before][5] == :pre\n sub_it[1] = leader_above[0..-3]\n else\n sub_it[1] = leader_above\n end\n end\n log_the_line( new_block, selector, line, sub_it )\n leader_before = sub_it[1..4].join\n if selector_before > selector # We are going up the tree.\n substitutions = reset_the_sub_branches(substitutions, sub_it, selector)\n else # We are at the same level.\n substitutions = increment_the_branch(substitutions, sub_it, selector)\n end\n selector_before = selector\n end\n return new_block\n end\n\n substitutions.each_key{ |k| substitutions[k]= get_the_subs_arrays(substitutions[k]) }\n new_block = reform_the_block( block, substitutions )\n end\n\n headers = get_the_substitutions( headers )\n block_noted = find_the_block( content )\n block = block_noted[0]\n not_the_block = block_noted[1]\n block_noted = \"\" # Really only for long documents so they don't use too much memory\n\n if block == nil || block == \"\"\n block_redux = \"\"\n elsif headers == {} \n block_redux = block\n else\n block_redux = chew_on_the_block( headers, block )\n end\n\n headed = not_the_block.gsub(\"{{block}}\", block_redux ) \n end", "def transform_Resource(o, scope)\n Types::TypeFactory.resource(o.type, o.title)\n end", "def map_resource_type(resource_types, node)\n if resource_types.empty?\n if node.is_a?(IFile)\n return {\n 'string' => 'File',\n 'icon' => 'file'\n }\n else\n return {\n 'string' => 'Unknown',\n 'icon' => 'cog'\n }\n end\n end\n\n types = {\n '{http://calendarserver.org/ns/}calendar-proxy-write' => {\n 'string' => 'Proxy-Write',\n 'icon' => 'people'\n },\n '{http://calendarserver.org/ns/}calendar-proxy-read' => {\n 'string' => 'Proxy-Read',\n 'icon' => 'people'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => {\n 'string' => 'Outbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => {\n 'string' => 'Inbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}calendar' => {\n 'string' => 'Calendar',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}shared-owner' => {\n 'string' => 'Shared',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}subscribed' => {\n 'string' => 'Subscription',\n 'icon' => 'calendar'\n },\n '{urn:ietf:params:xml:ns:carddav}directory' => {\n 'string' => 'Directory',\n 'icon' => 'globe'\n },\n '{urn:ietf:params:xml:ns:carddav}addressbook' => {\n 'string' => 'Address book',\n 'icon' => 'book'\n },\n '{DAV:}principal' => {\n 'string' => 'Principal',\n 'icon' => 'person'\n },\n '{DAV:}collection' => {\n 'string' => 'Collection',\n 'icon' => 'folder'\n }\n }\n\n info = {\n 'string' => [],\n 'icon' => 'cog'\n }\n\n resource_types.each do |resource_type|\n if types.key?(resource_type)\n info['string'] << types[resource_type]['string']\n else\n info['string'] << resource_type\n end\n end\n\n types.each do |key, resource_info|\n if resource_types.include?(key)\n info['icon'] = resource_info['icon']\n break\n end\n end\n\n info['string'] = info['string'].join(', ')\n\n info\n end", "def manipulate_resource_list(resources)\n\n resources.each do |resource|\n\n #--------------------------------------------------------\n # page_name\n # Make page_name available for each page. This is the\n # file base name. Useful for assigning classes, etc.\n #--------------------------------------------------------\n def resource.page_name\n File.basename( self.url, '.*' )\n end\n\n\n #--------------------------------------------------------\n # page_group\n # Make page_group available for each page. This is\n # the source parent directory (not the request path).\n # Useful for for assigning classes, and/or group\n # conditionals.\n #--------------------------------------------------------\n def resource.page_group\n File.basename(File.split(self.source_file)[0])\n end\n\n\n #--------------------------------------------------------\n # sort_order\n # Returns the page sort order or nil.\n # - If there's an `order` key, use it.\n # - Otherwise if there's a three digit prefix.\n # - Else nil.\n #--------------------------------------------------------\n def resource.sort_order\n if self.data.key?('order')\n self.data['order'].to_i\n elsif self.page_name[0..2].to_i != 0\n self.page_name[0..2].to_i\n else\n nil\n end\n end\n\n\n #--------------------------------------------------------\n # valid_features\n # Returns an array of valid features for this page\n # based on the current target, i.e., features that\n # are true for the current target. These are the\n # only features that can be used with frontmatter\n # :target or :exclude.\n #--------------------------------------------------------\n def resource.valid_features\n options = app.extensions[:Middlemac].options\n options.Targets[options.Target][:Features].select { |k, v| v }.keys\n end\n\n\n #--------------------------------------------------------\n # targeted?\n # Determines if this pages is eligible for inclusion\n # in the current build/server environment based on:\n # - is an HTML file, and\n # - has a sort_order, and\n # - if frontmatter:target is used, the target or\n # feature appears in the frontmatter, and\n # - if frontmatter:exclude is used, the target or\n # enabled feature does NOT appear in the\n # frontmatter.\n #--------------------------------------------------------\n def resource.targeted?\n target_name = app.extensions[:Middlemac].options.Target\n self.ext == '.html' &&\n self.data.key?('title') &&\n !self.sort_order.nil? &&\n ( !self.data['target'] || (self.data['target'].include?(target_name) || (self.data['target'] & self.valid_features).count > 0) ) &&\n ( !self.data['exclude'] || !(self.data['exclude'].include?(target_name) || (self.data['exclude'] & self.valid_features).count > 0) )\n end\n\n\n #--------------------------------------------------------\n # brethren\n # Returns an array of all of the siblings of the\n # specified page, taking into account their\n # eligibility for display.\n # - is not already the current page, and\n # - is targeted for the current build.\n # Returned array will be:\n # - sorted by sort_order.\n #--------------------------------------------------------\n def resource.brethren\n pages = self.siblings.find_all { |p| p.targeted? && p != app.current_page }\n pages.sort_by { |p| p.sort_order }\n end\n\n\n #--------------------------------------------------------\n # brethren_next\n # Returns the next sibling based on order or nil.\n #--------------------------------------------------------\n def resource.brethren_next\n if self.sort_order.nil?\n puts 'NEXT reports no sort order.'\n return nil\n else\n return self.brethren.select { |p| p.sort_order == app.current_page.sort_order + 1 }[0]\n end\n end\n\n\n #--------------------------------------------------------\n # brethren_previous\n # Returns the previous sibling based on order or nil.\n #--------------------------------------------------------\n def resource.brethren_previous\n if self.sort_order.nil?\n puts 'PREV reports no sort order.'\n return nil\n else\n return self.brethren.select { |p| p.sort_order == app.current_page.sort_order - 1 }[0]\n end\n end\n\n\n #--------------------------------------------------------\n # navigator_eligible?\n # Determine whether a page is eligible to include a\n # previous/next page control based on:\n # - the group is set to allow navigation (:navigate)\n # - this page is not excluded from navigation. (:navigator => false)\n # - this page has a sort_order.\n #--------------------------------------------------------\n def resource.navigator_eligible?\n (self.parent && self.parent.data.key?('navigate') && self.parent.data['navigate'] == true) &&\n !(self.data.key?('navigator') && self.data['navigator'] == false) &&\n (!self.sort_order.nil?)\n end\n\n\n #--------------------------------------------------------\n # legitimate_children\n # Returns an array of all of the children of the\n # specified page, taking into account their\n # eligibility for display.\n # - is targeted for the current build.\n # Returned array will be:\n # - sorted by sort_order.\n #--------------------------------------------------------\n def resource.legitimate_children\n pages = self.children.find_all { |p| p.targeted? }\n pages.sort_by { |p| p.sort_order }\n end\n\n\n #--------------------------------------------------------\n # breadcrumbs\n # Returns an array of pages leading to the current\n # page.\n #--------------------------------------------------------\n def resource.breadcrumbs\n hierarchy = [] << self\n hierarchy.unshift hierarchy.first.parent while hierarchy.first.parent\n hierarchy\n end\n\n\n end # .each\n\n resources\nend", "def convert25(resource)\n if resource.class == Puppet::Resource::Catalog\n resource.edges.each do |b|\n convert25(b)\n end\n elsif resource.class == Puppet::Relationship and resource.target.class == Puppet::Resource and resource.target.title != nil and resource.target.file != nil\n target = resource.target\n manifestfile = target.file.gsub(\"/etc/puppet/manifests/\", \"\")\n\n resource = {:type => target.type,\n :title => target.title,\n :parameters => {}}\n\n target.each do |param, value|\n resource[:parameters][param] = value\n end\n\n if resource[:parameters].include?(:content)\n resource[:parameters][:content] = Digest::MD5.hexdigest(resource[:parameters][:content])\n end\n\n resource[:resource_id] = \"#{target.type.downcase}[#{target.title}]\"\n @resources << resource\n end\nend", "def description_of content_type\n case content_type.to_s.strip\n when \"image/jpeg\"\n \"JPEG graphic\"\n when \"application/vnd.ms-excel\"\n \"Excel worksheet\"\n when \"application/msword\"\n \"Word document\"\n when \"application/pdf\"\n \"PDF file\"\n else \"\"\n end\n end", "def collate_resource\n content = []\n\n if @resource[:path]\n # Handle the singular case first\n @resource[:path].each do |orig_path|\n expand_path(orig_path).each do |path|\n @resource[:command].each do |command|\n content << [path, @resource[:mask], command].join(' ')\n end\n end\n end\n elsif @resource[:content]\n # Now the more complex fully specified content\n @resource[:content].each do |line|\n orig_path, *remainder = line.strip.split(' ')\n\n expand_path(orig_path).each do |path|\n content << \"#{path} #{remainder.join(' ')}\"\n end\n end\n end\n\n return content.join(\"\\n\")\n end", "def mime_types(type)\n mime_types = {\n yaml: \"application/x-yaml\",\n json: \"application/json\"\n }\n mime_types[type.to_sym]\n end", "def expand_line(line, value_escaper)\n # Generate a cross reference if a reference is given,\n # otherwise just fill in the name part\n\n line.gsub!(/HREF:(\\w+?):(\\w+?):/) {\n ref = @value_stack.lookup($1)\n name = @value_stack.find_scalar($2)\n\n if ref and !ref.kind_of?(Array)\n\t\"<a href=\\\"#{ref}\\\">#{name}</a>\"\n else\n\tname\n end\n }\n\n # Substitute in values for %xxx% constructs. This is made complex\n # because the replacement string may contain characters that are\n # meaningful to the regexp (like \\1)\n\n line = line.gsub(/%([a-zA-Z]\\w*)%/) {\n val = value_escaper.call(@value_stack.find_scalar($1).to_s)\n val.tr('\\\\', \"\\000\")\n }\n\n # Look for various controls (ddlb's etc)\n\n line = line.gsub(/%check:(\\w+?)%/) { check($1) }\n\n line = line.gsub(/%date:(\\w+?)%/) { date($1) }\n\n line = line.gsub(/%popup:(\\w+?):(\\w+?)%/) { popup($1, $2) }\n\n line = line.gsub(/%ddlb:(\\w+?):(\\w+?)%/) { ddlb($1, $2) }\n\n line = line.gsub(/%vsortddlb:(\\w+?):(\\w+?)%/) { ddlb($1, $2, 1) }\n\n line = line.gsub(/%radio:(\\w+?):(\\w+?)%/) { radio($1, $2) }\n\n line = line.gsub(/%radioone:(\\w+?):(\\w+?)%/) { radio($1, $2, \"\") }\n\n line = line.gsub(/%input:(\\w+?):(\\d+?):(\\d+?)%/) { input($1, $2, $3) }\n\n line = line.gsub(/%text:(\\w+?):(\\d+?):(\\d+?)%/) { text($1, $2, $3) }\n\n line = line.gsub(/%pwinput:(\\w+?):(\\d+?):(\\d+?)%/) { input($1, $2, $3, \"password\") }\n\n line = line.gsub(/%pair(\\d)?:([^:]+):(\\w+?)%/) { pair($2, $3, $1) }\n\n line\n rescue Exception => e\n err = Exception.new(\"Template error: #{e} in '#{line}'\")\n err.set_backtrace(e.backtrace)\n raise err\n end", "def filter_content( content ) \n\t \n\t # we do not want to touch the reference\n\t filtered_content = content.dup\n\t \n\t # replaces [[File:file.jpg]] or [[File:file.png]] or [[File:file.gif]] \n # with \n # <img src=\"upload/images/file.ext height=300px border=\"0\" ALIGN=RIGHT />\n \n url_image_root_path = url_for :controller=>\"upload/images\"\n img_link_prefix = '<img src=\"' + url_image_root_path + '/'\n img_link_postfix = '\" height=300px border=\"0\" ALIGN=RIGHT />'\n filtered_content.gsub!(/(\\[\\[)([Ff]ile:)([\\w\\.]+)(\\.png|\\.jpg|\\.jpeg|\\.gif)(\\]\\])/, img_link_prefix + '\\3\\4' + img_link_postfix)\n \n \n # replaces [[File:file.wav]] or [[File:file.mp3]] \n # <embed src=\"/audio/file.ext\" width=\"140\" height=\"60\" loop=false autostart=false>\n\n url_audio_root_path = url_for :controller=>\"upload/audio\"\n audio_link_prefix = '<embed src=\"' + url_audio_root_path + '/'\n audio_link_postfix = '\" width=\"140\" height=\"60\" loop=false autostart=false>'\n filtered_content.gsub!(/(\\[\\[)([Ff]ile:)([\\w\\.]+)(\\.wav|\\.mp3)(\\]\\])/, audio_link_prefix + '\\3\\4' + audio_link_postfix)\n\n \n filtered_content\n end", "def resource_handlers\n [\n IMS::LTI::Models::ResourceHandler.from_json(\n resource_type: { code: 'sumbissions' },\n resource_name: { default_value: 'Similarity Detection Tool', key: '' },\n message: [basic_message(\n path: '/submission/index',\n capabilities: %w(Canvas.placements.accountNavigation Canvas.placements.courseNavigation)\n )]\n ),\n IMS::LTI::Models::ResourceHandler.from_json(\n resource_type: { code: 'placements' },\n resource_name: { default_value: 'Similarity Detection Tool', key: '' },\n message: [basic_message(\n path: '/assignments/configure',\n capabilities: %w(Canvas.placements.similarityDetection)\n )]\n )\n ]\n end", "def resources_for http_verb, path\n param_vals = []\n curr_node = @routes_tree[http_verb.to_s.downcase]\n return unless curr_node\n\n path.scan(%r{/([^/]+|$)}) do |(key)|\n next if key.empty?\n\n if curr_node[key]\n curr_node = curr_node[key]\n\n elsif curr_node[\"%s\"]\n param_vals << key\n curr_node = curr_node[\"%s\"]\n\n else\n return\n end\n end\n\n return unless curr_node.value\n rsc = curr_node.value.dup\n\n rsc[-1] = param_vals.empty? ?\n Hash.new :\n rsc[-1].inject({}){|h, name| h[name] = param_vals.shift; h}\n\n rsc\n end", "def signature\r\n [@regexp, @replace]\r\n end", "def signature\r\n [@regexp, @replace]\r\n end", "def proposed_outlaw_replacement_for_a_single_resources_call(orig_syntax='') @orig_syntax = orig_syntax.chomp.strip\n ( raise ArgumentError, \"Malformed request to translate a Ruby method call to Outlaw:\\n#{@orig_syntax.inspect}\"\n ) unless @orig_syntax =~ /^resources?(\\(|\\s)/\n mung_all_resource_and_resources_calls(\"ActionController::Routing::Routes.draw do |map|\\nmap.#{@orig_syntax}\\nend\")\n ( raise ArgumentError, \"No resource() or resources() method call detected in the Ruby code:\\n#{@orig_syntax.inspect}\"\n ) if @mung_hist_ar.empty?\n ( raise ArgumentError, \"Must have only one map.resource() or map.resources() method call in the Ruby code:\\n#{@orig_syntax.inspect}\"\n ) unless @mung_hist_ar.size == 1\n # Does not detect if there's extra stuff after the end of the map.resources() calling code.\n eval_syntax(@munged_syntax, @orig_syntax)\n # At this point, @param_capture_ar contains a list of all the captured parameters.\n # Each element takes the form:\n # [ (:resources|:resource) ,\n # [ complete set of parameters as passed to resource() or resources() method ] ]\n # But since there's only one resource() or resources() call allowed, the array should\n # have a size of exactly one element.\n # Prepare a parellel set of translated parameters.\n raise RuntimeError, \"Caused #{@param_capture_ar.size} resource calls. Only one call expected.\" unless @param_capture_ar.size==1\n meth_sym, orig_param_ar = @param_capture_ar[0]\n mung_pos, mung_len, orig_text = @mung_hist_ar[0]\n uses_paren = !!(@munged_syntax[mung_pos...(mung_pos+mung_len)]=~/_call\\(/)\n rval = suggest_syntax_string(meth_sym, orig_param_ar, uses_paren)\n rval.gsub!(/\\n( *:[\\w_]+) +=> +/,\" \\\\1 => \") if rval.length < 161\n rval.gsub(/\\n/,\"\\n \")\n end", "def manipulate_resource_list(resources)\n\n\n index_file = app.index_file\n new_index_path = \"/#{index_file}\"\n\n # for each resource\n resources.each do |resource|\n\n # has custom_url in frontmatter\n if resource.raw_data[:custom_url]\n\n # set path as custom_url\n resource.destination_path = resource.raw_data[:custom_url] + new_index_path\n end\n end\n end", "def expand_formats!\n global_formats = (@__e__formats||[]).map {|f| '.' << f.to_s.sub('.', '')}.uniq\n strict_formats = (@__e__formats_for||[]).inject([]) do |u,(m,f)|\n u << [m, f.map {|e| '.' << e.to_s.sub('.', '')}.uniq]\n end\n\n define_format_helpers(global_formats, strict_formats)\n\n @__e__expanded_formats = public_actions.inject({}) do |map, action|\n map[action] = global_formats\n\n action_formats = strict_formats.inject([]) do |formats,(m,f)|\n m == action ||\n (m.is_a?(Regexp) && action.to_s =~ m) ? formats.concat(f) : formats\n end\n map[action] = action_formats if action_formats.any?\n\n (@__e__disable_formats_for||[]).each do |m|\n map.delete(action) if m == action || (m.is_a?(Regexp) && action.to_s =~ m)\n end\n\n map\n end\n end", "def route_type_listing(route)\n yield :file, route.file_path if @file_extensions.include? route.extension\n return unless handle_type? route.extension\n @extensions[route.extension].each do |value|\n yield value[:instruction], \"#{route.file_path}#{value[:extra_extension]}\"\n end\n end", "def name(_prefix = false)\n 'Resource Types'\n end", "def mime_types_with_document_examples\n links = \"\"\n accepted_mime_types = Decidim::Opinions::DocToMarkdown::ACCEPTED_MIME_TYPES.keys\n accepted_mime_types.each_with_index do |mime_type, index|\n links += link_to t(\".accepted_mime_types.#{mime_type}\"),\n asset_path(\"decidim/opinions/participatory_texts/participatory_text.#{mime_type}\"),\n download: \"participatory_text.#{mime_type}\"\n links += \", \" unless accepted_mime_types.length == index + 1\n end\n links\n end", "def route_path(item)\n # in-memory items have no file\n return item.identifier + \"index.html\" if item[:content_filename].nil?\n\n url = item[:content_filename].gsub(/^content/, '')\n\n # determine output extension\n extname = '.' + item[:extension].split('.').last\n outext = '.haml'\n if url.match(/(\\.[a-zA-Z0-9]+){2}$/) # => *.html.erb, *.html.md ...\n outext = '' # remove 2nd extension\n elsif extname == \".sass\" || extname == \".scss\"\n outext = '.css'\n else\n outext = '.html'\n end\n url.gsub!(extname, outext)\n\n url\nend", "def template_for_device(ua_type, options = {})\n # assert_template uses String#match and hence strings are converted into\n # RegExps. We need the last '$' to discriminate 'index' from 'index.g'\n (options[:action] || @request.params[:action]).to_s + suffixes_for_devices[ua_type] + '$'\n end", "def set_content_type old_type, old_resource_type, new_type, new_resource_type\n xml=self.ng_xml\n xml.search('/contentMetadata[@type=\\''+old_type+'\\']').each do |node|\n node['type']=new_type\n xml.search('//resource[@type=\\''+old_resource_type+'\\']').each do |resource|\n resource['type']=new_resource_type\n end\n end\n self.content=xml.to_s\n end", "def product_action_links(product)\n return %Q{\n #{link_to(image_tag('/images/livia_portal/icon_edit.gif',{:alt =>\"Edit\", :title=>\"Edit\", :border => 0, :hspace => \"0\"}), edit_product_path(:id=>product.id))}\n }\n end", "def selectors\n if resource_rule? # Resource specific rules\n i = [{type: 'resource'}]\n i = i.product(api_groups) if api_groups.any?\n i = i.product(resources) if resources.any?\n i = i.product(verbs) if verbs.any?\n else # Non-resource URLs rules\n i = [{type: 'non-resource'}]\n i = i.product(urls) if urls.any?\n i = i.product(verbs) if verbs.any?\n end\n\n i.map do |x|\n x.flatten.reduce(&:merge)\n end\n end", "def find_resources(ast, type = nil)\n ast.xpath(%Q{//method_add_block[command/ident#{type.nil? ? '' : \"[@value='#{type}']\"}]})\n end", "def find_resources(ast, type = nil)\n ast.xpath(%Q{//method_add_block[command/ident#{type.nil? ? '' : \"[@value='#{type}']\"}]})\n end", "def replace_variables type_of_field, language, loop_sources, loop_item=nil, images_urls=nil\n return self.send(type_of_field.to_s) if !loop_item\n #Sanitize the difference occurrences of variables in the field\n #using a loop in case there are multiple variables in the same field\n result = self.send(type_of_field.to_s)\n vars = result.gsub(/#\\[[^\\]]*\\]/) #look for occurrences of #[SomeVar]\n vars.each do |match|\n result = result.gsub(match, Sanitize.clean(match))\n end\n if self.is_a?(QuestionField)\n obj_type_var = \"question\"\n else\n obj_type_var = \"section\"\n end\n self.send(obj_type_var).send(\"extras\").each do |extra|\n item = extra.loop_item_type.root.loop_source_id.present? ? loop_sources[extra.loop_item_type.root.loop_source.id.to_s] : nil\n if item\n item_to_use = item.loop_item_type == extra.loop_item_type ? item.loop_item_name : item.ancestors.find_by_loop_item_type_id(extra.loop_item_type_id).loop_item_name\n the_item_extra = item_to_use.item_extras.find_by_extra_id(extra.id)\n if the_item_extra\n #either in language, or the default, or the first...\n the_field = ( the_item_extra.item_extra_fields.find_by_language(language) || the_item_extra.item_extra_fields.find_by_is_default_language(true) || the_item_extra.item_extra_fields.first)\n if extra.image? #Image\n the_value = \"<img src='#{the_field.value}' alt='#{extra.name}::#{item_to_use.item_name(language)}' width='200px'/>\"\n unless images_urls.nil?\n images_urls << the_field.value\n end\n elsif extra.link? #URL\n the_value = \"<a href='#{the_field.value}' alt='#{extra.name}::#{item_to_use.item_name(language)}'>#{item_to_use.item_name(language)}</a>\"\n else\n the_value = the_field.value #TEXT\n end\n new_result = result.gsub(\"#[#{Sanitize.clean(extra.loop_item_type.name)}::#{Sanitize.clean(extra.name)}]\", the_value)\n else\n new_result = result.gsub(\"#[#{Sanitize.clean(extra.loop_item_type.name)}::#{Sanitize.clean(extra.name)}]\", \"\")\n end\n result = new_result.present? ? new_result : result\n end\n end\n result\n end", "def expand_formats!\n global_formats = (@formats||[]).map {|f| '.' << f.to_s.sub('.', '')}.uniq\n strict_formats = (@formats_for||[]).inject([]) do |u,(m,f)|\n u << [m, f.map {|e| '.' << e.to_s.sub('.', '')}.uniq]\n end\n\n # defining a handy #format? method for each format.\n # eg. #json? for .json, #xml? for .xml etc.\n # these methods are aimed to replace the `if format == '.json'` redundancy\n #\n # @example\n #\n # class App < E\n #\n # format '.json'\n #\n # def page\n # # on /page, #json? will return nil\n # # on /page.json, #json? will return '.json'\n # end\n # end\n #\n (all_formats = (global_formats + strict_formats.map {|s| s.last}.flatten).uniq)\n (all_formats = Hash[all_formats.zip(all_formats)]).each_key do |f|\n define_method '%s?' % f.sub('.', '') do\n # Hash searching is a lot faster than String comparison\n all_formats[format]\n end\n end\n\n @expanded_formats = public_actions.inject({}) do |map, action|\n\n map[action] = global_formats\n\n action_formats = strict_formats.inject([]) do |formats,(m,f)|\n m == action ||\n (m.is_a?(Regexp) && action.to_s =~ m) ? formats.concat(f) : formats\n end\n map[action] = action_formats if action_formats.any?\n\n (@disable_formats_for||[]).each do |m|\n map.delete(action) if m == action || (m.is_a?(Regexp) && action.to_s =~ m)\n end\n\n map\n end\n end", "def manipulate_resource_list(resources)\n resources + options[:targets].map do |t|\n StaticResource.new(\n app.sitemap,\n t[:output]\n ) { \n File.read(File.expand_path(tmp_path(t), app.root))\n }\n end\n end", "def display_resource_icon(document)\n\n #Set the queue_name if it isn't nil\n if !(document[\"is_member_of_queue_facet\"].nil?) then queue_name = document[\"is_member_of_queue_facet\"].first else queue_name = \"\" end\n \n #We set a different img_class genre if its in hidden or deleted queue\n if ((queue_name.include? \"Deleted\") || (queue_name.include? \"Hidden\"))\n case queue_name\n when \"Deleted\"\n img_class = \"deleted-genre\"\n when \"Hidden\"\n img_class = \"hidden-genre\" \n end\n else\n #standard icons\n genre = document[\"genre_t\"].to_s.downcase\n case genre\n when \"structural set\", \"structuralset\" \n img_class = \"structural-set-genre\"\n when \"display set\"\n img_class = \"collection-genre\"\n when \"presentation\"\n img_class = \"presentation-genre\"\n when \"photograph\", \"artwork\"\n img_class = \"image-genre\"\n when \"meeting papers or minutes\"\n img_class = \"event-genre\"\n when \"audio\"\n img_class = \"sound-genre\"\n when \"video\"\n img_class = \"video-genre\"\n else\n img_class = \"text-genre\"\n end\n end\n\n resource_icon = <<-EOS\n <div id=\"genre_image\" class=\"#{img_class}\"></div>\n EOS\n\n resource_icon.html_safe\n end", "def choose_processors\n [:thumbnail]\n end", "def get_resource_type(type, resource_path)\n changed_path = resource_path.split('/').last\n if type.eql?('singular')\n changed_path.singularize.to_sym\n else\n changed_path.to_sym\n end\n end", "def menu_mots type_mot\n template_menu_mots\n .gsub(/__TYPE__/,type_mot)\n .gsub(/_TYPE_MOT_/,type_mot.titleize)\n .sub(/_VALUE_TYPE_/,mot.send(type_mot.to_sym)||'')\n end", "def type(type = nil)\n @type = type if type\n @type || name.split('::').last.gsub(/Resource$/, '').underscore\n end", "def mime_type(*args, **_arg1, &block); end", "def replace_bibitem_macros(line)\n BibitemMacro.extract_macros(line).each do |item|\n line = line.gsub(item.text, build_bibitem_text(item.key))\n end\n line\n end", "def display_resource_icon(document)\n\n #Set the queue_name if it isn't nil\n if !(document[\"is_member_of_queue_facet\"].nil?) then queue_name = document[\"is_member_of_queue_facet\"].first else queue_name = \"\" end\n \n #We set a different img_class genre if its in hidden or deleted queue\n if ((queue_name.include? \"Deleted\") || (queue_name.include? \"Hidden\"))\n case queue_name\n when \"Deleted\"\n img_class = \"deleted-genre\"\n when \"Hidden\"\n img_class = \"hidden-genre\" \n end\n else\n #standard icons\n genre = document[\"genre_t\"].to_s.downcase\n case genre\n when \"structural set\", \"structuralset\" \n img_class = \"structural-set-genre\"\n when \"display set\"\n img_class = \"collection-genre\"\n when \"presentation\"\n img_class = \"presentation-genre\"\n when \"photograph\", \"artwork\"\n img_class = \"image-genre\"\n when \"meeting papers or minutes\"\n img_class = \"event-genre\"\n else\n img_class = \"text-genre\"\n end\n end\n\n resource_icon = <<-EOS\n <div id=\"genre_image\" class=\"#{img_class}\"></div>\n EOS\n\n resource_icon.html_safe\n end", "def template_regex(type: :export)\n type = valid_type(type)\n pattern = []\n plugs = plugins[type].clone\n plugs.delete_if { |_, o| o[:templates].nil? }.each do |_, options|\n options[:templates].each do |t|\n pattern << t[:trigger].normalize_trigger\n end\n end\n Regexp.new(\"^(?:#{pattern.join('|')})$\", true)\n end", "def resource_url options={}\n r=request.path\n id=params[:id]\n options = case params[:action]\n when 'create','update','delete','destroy'; \"\"\n else resource_options(options)\n end\n return \"%s%s\" % [r,options] if r.match \"#{resource.class.to_s.tableize}\\/#{id}$\"\n \"%s%s\" % [ r.split(\"/#{params[:action]}\")[0], options]\n rescue Exception => e\n scoop_from_error e\n end", "def get_content_type_slug\n if request.post? && (request.path_info =~ ENTRY_SUBMISSION_REGEXP || params[CONTENT_TYPE_PARAM])\n $1 || params[CONTENT_TYPE_PARAM]\n end\n end", "def partial_expand(actual_params)\n ResourceTemplates.new(map{|resource_template| resource_template.partial_expand(actual_params)})\n end", "def extract fieldname\n case fieldname.downcase\n when /_tags$/\n tagtype = fieldname.sub /_tags$/, ''\n tagtype = ['Culinary Term', 'Untyped'] if tagtype=='Other'\n strjoin visible_tags(:tagtype => tagtype).collect { |tag|\n h.link_to_submit tag.name, tag, :mode => :modal, class: 'rcp_list_element_tag'\n }\n when /^tags$/\n h.list_tags_for_collectible visible_tags( :tagtype_x => [ :Question, :List ]), self\n when /^lists$/\n h.list_lists_with_status ListServices.associated_lists_with_status(self)\n when /^rcp/\n attrname = fieldname.sub(/^rcp/, '').downcase\n case attrname\n when 'picsafeurl'\n object.imgdata\n when 'titlelink'\n h.link_to object.title, object.url\n when 'video'\n (uri = URI(object.url)) &&\n uri.host.match(/\\.youtube.com/) &&\n (vid = YouTubeAddy.extract_video_id(object.url)) &&\n \"https://www.youtube.com/embed/#{vid}\"\n else\n object.send(attrname.to_sym).to_s if object.respond_to? attrname\n end\n when /^comments/\n case fieldname.sub(/^comments_/, '')\n when 'mine'\n when 'friends'\n when 'others'\n end\n when 'site'\n h.link_to object.sourcename, object.sourcehome, class: 'tablink'\n when 'collections'\n strjoin object.collectors.collect { |user|\n h.link_to_submit( user.handle, h.user_path(user), :mode => :modal) unless user.current?\n }.compact\n when 'feeds'\n strjoin(object.feeds.where(approved: true).collect { |feed| h.link_to_submit feed.title, h.feed_path(feed) },'','',',', '<br>').html_safe\n when 'classname_lower'\n object.class.to_s.downcase\n else\n (method(fieldname.to_sym).call rescue nil) || ''\n end\n end", "def additional_mime_types\n [\n MIME::Type.new( 'text/plain' ) { |t| t.extensions = %w[ rb rdoc rhtml md markdown ] },\n ]\n end", "def resources_by_type(ast)\n raise_unless_xpath!(ast)\n result = Hash.new{|hash, key| hash[key] = Array.new}\n find_resources(ast).each do |resource|\n result[resource_type(resource)] << resource\n end\n result\n end", "def route_path(item)\n # in-memory items have not file\n return item.identifier + \"index.html\" if item[:content_filename].nil?\n\n url = item[:content_filename].gsub(/^content/, '')\n\n # determine output extension\n extname = '.' + item[:extension].split('.').last\n outext = '.haml'\n if url.match(/(\\.[a-zA-Z0-9]+){2}$/) # => *.html.erb, *.html.md ...\n outext = '' # remove 2nd extension\n elsif extname == \".sass\"\n outext = '.css'\n else\n outext = '.html'\n end\n url.gsub!(extname, outext)\n\n if url.include?('-')\n url = url.split('-').join('/') # /2010/01/01-some_title.html -> /2010/01/01/some_title.html\n end\n\n url\nend", "def convert(content)\n button_parts = content.match('div class=\"content-edit-page\"')\n source_parts = content.match(/<a href=\"([^\"]+)\">\\(source\\)<\\/a>/)\n if button_parts == nil and source_parts != nil\n url = source_parts[1]\n button_start = '<div class=\"content-edit-page\"><a href=\"'\n button_end = '\"><i class=\"fab fa-github\"></i> <span>Edit Page</span></a></div>'\n button_start.concat(url.gsub('blob', 'edit'), button_end, content)\n else\n content\n end\n end", "def url_for_list(type); end", "def content_icon\n content_icon_path << case self\n when Audio\n \"audio.png\"\n when Music\n \"music.png\"\n when Photo\n \"photo.png\"\n when Video, WebVideo\n \"movie.png\"\n else\n 'doc.png'\n end\n end", "def expand_placeholders(text)\n text \\\n .gsub(\"REPO_NAME\", repo_name) \\\n .gsub(\"BRANCH_NAME\", @branch_name) \\\n .gsub(\"FILE_NAMES\", @file_names) \\\n .gsub(\"FILE_DIFFS\", @file_diffs)\n end", "def highlight_and_link(source, remove_top_namespace = false)\n\n # debug\n # is_page_of_interest = @context.registers[:page]['fancy_name'] =='reshape') \n \n if remove_top_namespace then \n page_namespace = @context.registers[:page]['namespace'] + \"::\"\n ns = page_namespace.split(\"::\")[0] + \"::\"\n end\n\n highlighted_types = @context.registers[:site].data['highlighted_types'] \n \n # for all types in highlighted_types, \n # - find them \n # - replace them with _X0001X_, _X0002X, which the highlighter will not cut\n # - highlight by calling Rouge\n # - replace back the _X0001X_, _X0002X with the name and adequate url\n # if remove_top_namespace is true, we rerun this a second type with the top namespace removed from the type\n # It is useful for signature when the namespace is not always explicit and would be verbose (e.g. nda:: everywhere in all nda:: functions ?)\n #\n repl_to_original = {}\n c = 1\n highlighted_types.each do |type, url|\n\n type_to_replace = type\n # we are going to run this twice : once with the full type, \n # once with the type_to_replace truncated from top ns if remove_top_namespace is true\n # lambda are closure, it will see the change in type_to_replace\n worker = lambda { \n # the type_to_replace, not followed by a word (e.g. array does not match array_adapter, and not preceded by a :)\n # e.g. array will match array, not nda::array (which could be matched in another part of the loop...), and NOT std::array !\n re = Regexp.new '(?<!:)' + type_to_replace + '(?!\\w)' \n source = source.gsub(re){ |w|\n repl = \"_X000\" + c.to_s + \"X_\"\n repl_to_original[repl] = type # Must be the full type\n c = c + 1\n repl\n }\n }\n worker.call\n if remove_top_namespace then\n type_to_replace = type.gsub(ns, '')\n worker.call\n end\n end\n\n formatter = Rouge::Formatters::HTML.new\n lexer = Rouge::Lexers::Cpp.new\n r = formatter.format(lexer.lex(source))\n r = '<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\">' + r.strip + '</code></pre></figure>'\n\n repl_to_original.each do |repl, type|\n url = highlighted_types[type] \n\n if remove_top_namespace then\n type = type.gsub(ns, '')\n end\n re = Regexp.new '(' + repl + ')(?!\\w)'\n r = r.gsub(re){ |w| '<a href=\"%s\">%s</a>' %[url, type]}\n end\n\n return r\n end", "def transform_api_url(subject_type, api_url, title, html_url)\n case subject_type\n when \"PullRequest\"\n pull_request_url(api_url)\n when \"Release\"\n release_url(api_url, title)\n when \"Issue\"\n issue_url(api_url)\n when \"RepositoryInvitation\"\n invite_url(html_url)\n else\n \"https://github.com/notifications\"\n end\n end", "def thumbnail\n \"template_\" + self.template.stylesheets + \".png\"\n end", "def replace_slugs(markdown, toc_map)\n markdown.gsub(/(\\[\\[slug:)(.+?)(\\]\\])/) {\n if $2.start_with?('en:')\n val = \"[[#{$2}]]\"\n elsif toc_map.key?($2)\n itm = toc_map[$2]\n href = get_page_from_anchor(itm[:href])\n val = '<a href=\"%s\">%s</a>' % [href, itm[:title]]\n else\n val = \"#{$1}#{$2}#{$3}\"\n msg = \"ERROR: Not able to find slug \\\"#{$2}\\\" in TOC.\"\n print_error_msg(msg)\n end\n val\n }\n end", "def edit\n\n @resource = Resource.find(params[:id])\n @resource.type = 'Resource'\n @type = 'file' if params[:type] == 'file'\n\n end", "def as_replacements; end", "def as_replacements; end", "def as_replacements; end", "def resource_regexp(url)\n %r{#{url}/[a-z0-9]+_id$}\nend", "def compile_images(content)\n content.gsub(/\\[img:(.*):'(.*)'\\]/) { get_image($1, $2) }\n end", "def replace_with_url(json, field, type, options)\n \n url_key = ''\n if field == 'id'\n url_key = 'url'\n else\n url_key = field.chomp('_id') + '_url'\n end\n \n format = ''\n format = '.' + options[:format] if options[:format]\n \n if json[field] != nil\n case(type)\n when :DetailValue,\n :SimpleDetailValue,\n :LongTextDetailValue,\n :DateDetailValue,\n :IntegerDetailValue,\n :DdlDetailValue,\n :EmailDetailValue,\n :WebUrlDetailValue,\n :S3Attachment\n json[url_key] = @@lookup[type] % [@@base_url, self.instance_id, self.detail_id, self.id] + format\n else\n json[url_key] = @@lookup[type] % [@@base_url, self.send(field)] + format\n \n end\n \n else\n json[url_key] = nil\n end\n json.delete field\n \nend", "def string_replacements_for_ids(type, ids)\n ids = ids.uniq\n query_string = ids.map { |id| \"(FormattedID = \\\"#{id}\\\")\" }.join(' OR ')\n query_string = \"(#{query_string})\" if ids.count > 1\n\n replacements = {}\n\n puts \"Querying Rally for artifact info...\"\n results = query_rally(type, query_string, \"FormattedID,ObjectID,Project\")\n puts \"done.\"\n results.each do |result|\n if ids.include?(result.FormattedID)\n link_to_artifact = url_for_rally(result.Project.ObjectID, type, result.ObjectID)\n replacements[result.FormattedID] = generate_markdown_link(result.FormattedID, link_to_artifact)\n end\n end\n\n replacements\nend", "def url_type\n content_type.gsub(\"/\", \"_\")\n end", "def resource_template(name)\n \"#{resource}_#{name}\"\n end", "def literal_sub(s, fexp, wi)\n\n case s\n when /^\\$(?:variable|var|v):([^{}\\s\\$]+)$/\n fexp.lookup_variable($~[1])\n when /^\\$([^{}:\\s\\$]+)$/, /^\\$(?:field|fld|f):([^{}\\s\\$]+)$/\n Ruote.lookup(wi['fields'], $~[1])\n else\n s\n end\n end", "def expanded_name; end", "def name\n @name ||= [action, resource.name, resource.type].compact.map(&:to_s).join('_').underscore\n end", "def macro\n :references_one\n end", "def extractToolkitPropertyInfo( propertyMacro )\n\n # Extract the property name, type\n property = $propertyStruct.new;\n\n # Split the macro definition by comma and quotes, close bracket and delete any empty segments\n data = propertyMacro.split(/[\\s,\")]/).reject { |s| s.empty? }\n\n if(data[1] == \"PropertyRegistration\")\n\n # Properties defined in Control using PropertyRegistration\n # const PropertyRegistration Control::Impl::PROPERTY_1(typeRegistration, \"styleName\", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty);\n\n # Creates an array of strings that looks like this:\n # const 0\n # PropertyRegistration 1\n # Control::Impl::PROPERTY_1 2\n # typeRegistration 3\n # styleName 4\n # Toolkit::Control::Property::STYLE_NAME 5\n # Property::STRING 6\n # &Control::Impl::SetProperty 7\n # &Control::Impl::GetProperty 8\n #\n\n property.name = data[4]\n\n propertyType = data[6].rpartition(\"::\")\n property.type = propertyType[2]\n\n propertyEnum = data[5].rpartition(\"::\")\n property.enum = propertyEnum[2]\n\n else\n\n # Properties defined in macro DALI_PROPERTY_REGISTRATION or DALI_ANIMATABLE_PROPERTY_REGISTRATION or DALI_CHILD_PROPERTY_REGISTRATION\n # or DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT:\n # DALI_PROPERTY_REGISTRATION(Toolkit, TextLabel, \"multiLine\", BOOLEAN, MULTI_LINE)\n # DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(Toolkit, ImageView, \"pixelArea\", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA)\n\n # Creates an array of strings that looks like this:\n # DALI_PROPERTY_REGISTRATION( 0\n # Toolkit 1\n # PageTurnView 2\n # pageSize 3\n # VECTOR2 4\n # PAGE_SIZE 5\n #\n\n property.name = data[3]\n\n #puts property.name\n if property.name == \"image\"\n property.name = \"imageMap\"\n end\n\n if( data[0] == \"DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(\" )\n # TODO: Need to work out the property type from the value\n property.type = \"VECTOR4\"\n else\n property.type = data[4]\n end\n\n property.enum = data[data.length-1]\n\n end\n\n # e.g. turn styleName into StyleName\n property.name[0] = property.name[0].capitalize\n\n property.writable = true\n property.animatable = false\n property.constrainInput = false\n property.childProperty = false;\n\n # check to see if it's a child property\n if( data[0] == \"DALI_CHILD_PROPERTY_REGISTRATION(\" )\n #puts(\" #{property.name} is child property \")\n property.childProperty = true;\n end\n if( data[0] == \"DALI_ANIMATABLE_PROPERTY_REGISTRATION(\" )\n #puts(\" #{property.name} is animatable\")\n property.animatable = true;\n end\n\n return property;\nend", "def media_type_sym media\n case\n when (media =~ %r{^application/xml}) then :xml\n when (media =~ %r{^application/json}) then :json\n when (media =~ %r{^application/json-p}) then :json\n when (media =~ %r{^(application|text)/(x-)?javascript}) then :json\n when (media =~ %r{^(application|text)/(x-)?ecmascript}) then :json\n when (media =~ %r{^text/yaml}) then :yaml\n # when (media =~ %r{^text/tab-separated-values}) then :tsv\n # when (media =~ %r{^text/(comma-separated-values|csv)}) then :csv\n # when (media =~ %r{^text/html}) then :html\n else :json\n end\n end", "def replace(content)\n \n # pre-structuring\n content.gsub!( /^(\\w.*)\\n(\\w.*)/ ) { \"#{$1} #{$2}\" } # remove single line breaks between text in order to avoid false paragraph markup\n content.gsub!( /<!--/ ) { \"--\" } # replace opening html commentaries\n content.gsub!( /-->/ ) { \"--\" } # replace closing html commentaries\n \n # templates\n content.gsub!( /\\{\\{Zitat\\|(.*)\\|.*\\}\\}\\s*$\\n/ ) { \"\\{p\\}\\\"#{$1}\\\"\\{/p\\}\\n\" } # citation\n content.gsub!( /\\{\\{.*(Finale Version).*\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1}</font>{/status}<br>\" } # final version\n content.gsub!( /\\{\\{Vorlage:(Dokument.*)\\n*(.*)\\}\\}/ ) { \"{status}<font color=\\\"#FF0000\\\">#{$1} #{$2}</font>{/status}<br>\" } # document status\n content.gsub!( /\\{\\{.*\\}\\} *$/ ) { '' } # remove single line templates\n content.gsub!( /\\{\\{.*\\n?.*\\}\\} *$/ ) { '' } # remove all remaining templates\n \n # tags\n content.gsub!( /<nowiki>(.*?)<\\/nowiki>/ ) { \"<pre>#{$1}</pre>\" }\n content.gsub!( /^ +(.*)/ ) { \"<pre>#{$1}</pre>\" }\n\n # special markup of qualidative data analysis\n content = content + \"\\n\\n{!end}\"\n \n # categories\n content.gsub!( /\\[\\[Kategorie:(.*?)\\]\\]/i ) { \"{category}<font color=\\\"#FF0000\\\">Kategorie:#{$1}</font>{/category}<br>\" }\n \n # images\n content.gsub!( /\\[\\[Bild:(.*?)\\]\\]/i ) { \"{image}Bild:#{$1.gsub!(/.*\\|/,'')}{/image}<br>\"} # Bild:lpscreen.jpg|thumb|Bereichseite des Landesportals\n\n # bold\n content.gsub!(/'''(.*?)'''/) {\"<strong>#{$1}</strong>\"}\n content.gsub!(/'''(.*?)$/) {\"<strong>#{$1}</strong>\"}\n\n # italics\n content.gsub!(/''(.*?)''/) {\"<em>#{$1}</em>\"}\n content.gsub!(/''(.*?)$/) {\"<em>#{$1}</em>\"}\n\n # headings\n 6.downto(1) { |i| content.gsub!( /^={#{i}}(.*?)={#{i}} *$/ ) { \"<h#{i}>\\{h>#{i}\\}#{$1}\\{/h>#{i}\\}</h#{i}>\" } }\n \n # links, internal\n content.gsub!( /\\[\\[([^\\[\\n]*?)\\| *(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[\\[(.*?)\\]\\]/ ) { \"<a class=\\\"internal\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n\n # links, external\n content.gsub!( /\\[([^\\[\\n]*?)\\| *(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$2}</a>\" } # with piped text\n content.gsub!( /\\[(.*?)\\]/ ) { \"<a class=\\\"external\\\" href=\\\"#{$1}\\\">#{$1}</a>\" } # without piped text\n \n # lists\n content.gsub!(/^:+/,'') # remove forced indenting\n content.gsub!( /^((?:\\*.*\\n+)+)/ ) { \"\\{l>ul\\}<ul>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^\\*/,'')}</li>\\n\" }.join}</ul>\\{/l>ul\\}<br>\\n\" } # first level ul\n content.gsub!( /^((?:#.*\\n+)+)/ ) { \"\\{l>ol\\}<ol>\\n#{$1.split(/\\n/).collect { |line| \"<li>#{line.gsub!(/^#/,'')}</li>\\n\" }.join}</ol>\\{/l>ol\\}<br>\\n\" } # first level ol\n content.gsub!( /<li>\\s*<\\/li>\\n/ ) { '' } # remove empty list entries (this may occur if first-level wiki-lists are entered with \\n\\n; they look like a single list when, in fact, they are but multiple single lists)\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # second level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # second level ol\n content.gsub!( /^((?:<li>\\*.*\\n+)+)/ ) { \"<ul>\\n#{$1.gsub(/^<li>\\*/,\"<li>\")}</ul>\\n\" } # third level ul\n content.gsub!( /^((?:<li>#.*\\n+)+)/ ) { \"<ol>\\n#{$1.gsub(/^<li>#/,\"<li>\")}</ol>\\n\" } # third level ol\n\n # tables\n # the table conversion barely works, cf. http://johbuc6.coconia.net/doku.php/mediawiki2html_machine/code?DokuWiki=7c542b97df2bc0f82fec0f4875265a20 for an implementation in PHP\n content.gsub!( /^\\{\\|(.*)/ ) { \"\\{table\\}\\n<table #{$1}>\" }\n content.gsub!( /\\|\\}/ ) { \"</table>\\n\\{/table\\}\" }\n content.gsub!( /^\\|-(.*)/ ) { \"<tr>#{$1}\" }\n content.gsub!( /^!(.*?)\\|(.*)/ ) { \"<th #{$1}>#{$2}</th>\" } # table header with piped markup\n content.gsub!( /^!(.*)/ ) { \"<th>#{$1}</th>\" } # table header without piped markup\n content.gsub!( /^\\|(.*?)\\|(.*)/ ) { \"<td #{$1}>#{$2}\" } # table data with piped markup\n content.gsub!( /^\\|(.*)/ ) { \"<td>#{$1}\" } # table data without piped markup\n \n # line breaks\n content.gsub!( /(^(?:\\w|<strong|<em|<a|\\\").*)\\n\\s*\\n/ ) {\"<p>\\{p\\}#{$1}\\{/p\\}</p>\\n\"}\n \n # special markup of qualidative data analysis\n content.gsub!( /(\\{id\\}.*\\{\\/title\\})/ ) { \"<p><strong><em>#{$1.gsub(/_/,' ')}</em></strong></p>\" }\n \n# //$html = nl2br($html);\n# \t// line breaks\n# \t$html = preg_replace('/[\\n\\r]{4}/',\"<br/><br/>\",$html);\n# \t$html = preg_replace('/[\\n\\r]{2}/',\"<br/>\",$html);\n\n# \t$html = preg_replace('/[>]<br\\/>[<]/',\"><\",$html);\n \n# // allowed tags\n# \t$html = preg_replace('/&lt;(\\/?)(small|sup|sub|u)&gt;/','<${1}${2}>',$html);\n#\n# \t$html = preg_replace('/\\n*&lt;br *\\/?&gt;\\n*/',\"\\n\",$html);\n# \t$html = preg_replace('/&lt;(\\/?)(math|pre|code|nowiki)&gt;/','<${1}pre>',$html);\n# \t$html = preg_replace('/&lt;!--/','<!--',$html);\n# \t$html = preg_replace('/--&gt;/',' -->',$html);\n# \n return content\n\nend", "def css_query_for(reftype)\n\t\tcase reftype\n\t\t\twhen :wiki:\n\t\t\t\t'title'\n\t\t\twhen :changeset:\n\t\t\t\t'h2'\n\t\t\twhen :ticket:\n\t\t\t\t'title'\n \t\t else\n\t\t\t\twarning \"Unknown reftype: #{reftype}\"; nil\n\t\tend\n\tend", "def resource(name, type=nil, &block)\n resource = GenericResource.new\n resource.type = type\n resource.evaluate &block\n add_resource name, resource\n end", "def respond_with(*resources, &block)\n replacement = nil\n resources.each do |resource|\n if resource.respond_to?(:each)\n replacement = []\n resource.each do |instance| \n replacement << scrubbed_instance(instance)\n end\n elsif resource.respond_to?(:attributes)\n replacement = scrubbed_instance(resource)\n else\n replacement = resource\n end\n end\n\n super(replacement, :location => nil)\n end", "def clean_defs(term, defs)\n slides = []\n defs.each { |kind, definitions|\n \n kind_slides = []\n \n i = 0\n for definition in definitions\n \n keep = true\n \n # ignore old and unclear definitions\n keep = keep && (definition =~ /{{(?:[^}]+\\|)?(?:archaic|dated|historical|nonstandard|obsolete|rare)/).nil?\n keep = keep && (definition =~ /^{{Latn-\\w+[^\\}]*}}$/).nil?\n keep = keep && (definition =~ /{{rf\\w-(?:def|redundant|sense)/).nil?\n keep = keep && (definition =~ /{{rf(?:ex|def)[\\|}]/).nil?\n keep = keep && (definition =~ /{{fact[\\|\\}]/).nil?\n \n if keep\n \n i += 1\n \n # convert wikitext into displayable definition\n display = definition\n \n # fix improperly closed templates\n display = display.gsub(/\\{\\{[^\\}]+\\}(?!\\})/, '\\&}')\n \n # numbered and named template arguments\n display = display.gsub(/\\|\\s*\\d+\\s*=\\s*/, '|')\n display = display.gsub(/\\|\\s*(?:dot|from)\\s*=[^\\|\\}]*/, '')\n \n # template parameters\n display = display.gsub(/\\|\\s*(?:ambi|in|un)?(?:countable|formal|transitive)\\s*(?=[\\|\\}])/, '')\n display = display.gsub(/\\|\\s*(?:or|and)\\s*(?=\\||\\}\\})/, '')\n display = display.gsub(/(?<=[\\{\\|])(chiefly)\\|([^\\|\\}]+)/, '\\1 \\2')\n \n # simple predictable templates\n display = display.gsub(/{{label\\|([^\\}]+)}}/, '{{\\1}}')\n display = display.gsub(/{{,}}/, ',')\n display = display.gsub(/{{superl}}/, 'superlative')\n display = display.gsub(/{{term\\|([^\\|\\}]+)[^\\}]*}}/, '(\\1)')\n \n # prefix templates\n display = display.gsub(/^{{(ambi|in|un)?(countable|formal|transitive)[^\\}]*}}\\s*/, '')\n display = display.gsub(/^\\s*or\\s+{{(ambi|in|un)?(countable|formal|transitive)[^\\}]*}}\\s*/, '')\n display = display.gsub(/^{{(?:not )?comparable(\\|[^\\}]*)*}}\\s*/, '')\n display = display.gsub(/^{{([\\w ]+)}}/, '(\\1)')\n display = display.gsub(/^{{chiefly\\|([^\\}]+)}}/, '(\\1)')\n #display = display.gsub(/^{{(\\w+)\\|_\\|(\\w+)}}/, '(\\1 \\2)')\n display = display.gsub(/^{{senseid\\|(?:[^\\|]+\\|)*([^}]+)}}/, '(\\1)')\n \n # identifyable templates\n display = display.gsub(/{{([A-Z][^\\|\\}]+)[^\\}]*}}/, '(\\1)')\n display = display.gsub(/{{(\\w)}}/, '\"\\1\"')\n display = display.gsub(/{{([^\\|\\}]+ of)\\s*\\|([^\\}]+)}}/, '\\1 \"\\2\"')\n display = display.gsub(/{{context(\\|(in|un)?(formal|transitive))*}}\\s*/, '')\n display = display.gsub(/{{context(?:\\|(?:in|un)?(?:formal|transitive))*\\|([^}]+)}}/, '(\\1)')\n display = display.gsub(/{{(in|un)?(formal|transitive)}}\\s*/, '')\n display = display.gsub(/{{(?:context|qualifier|sense)\\|(.*?)}}/, '(\\1)')\n display = display.gsub(/{{taxlink\\|([^\\|\\}]+)\\|([^\\}]+)}}/, '\\1 \\2')\n display = display.gsub(/{{taxlink\\|([^\\}]+)}}/, '\\1')\n display = display.gsub(/{{l(?:\\|[^\\|\\}]+)*\\|([^\\}\\|]+)}}/, '\\1')\n display = display.gsub(/{{(?:non-gloss definition|n-g)\\|(.*?)}}/, '\\1')\n display = display.gsub(/{{(?:gloss|w)\\|(.*?)}}/, '\\1')\n display = display.gsub(/{{(short for|of a|often|dialect)\\s*\\|([^\\}]+)}}/, '\\1 \\2')\n display = display.gsub(/{{soplink\\|([^\\|\\}]+)\\|([^\\|\\}]+)}}/, '\\1 \\2')\n display = display.gsub(/{{etyl\\|yi\\|[^\\}]*}}/, 'Yiddish')\n \n # templates which can be removed wholesale\n display = display.gsub(/{{(?:by extension|defn|defdate|jump|transitive|tritaxon)\\|.*?}}\\s*/, '')\n \n # any remaining unidentified un-nested templates\n display = display.gsub(/{{([^}]+)}}/) { |match|\n delimiter = ', '\n if !(match =~ /\\|_\\|/).nil?\n delimiter = ' '\n end\n ret = match\n ret = ret.gsub(/\\|_\\|/, '\\|')\n ret = ret.gsub(/{{([^}]+)}}/, '(\\1)')\n ret = ret.gsub(/\\|\\s*[^=\\|\\}]+=\\s*/, '|')\n ret = ret.gsub(/\\|+/, delimiter)\n ret\n }\n \n # protect nowiki\n nowiki = []\n display = display.gsub(/<nowiki\\/>/, '')\n display = display.gsub(/<nowiki>(.*?)<\\/nowiki>/) { |match|\n nowiki.push match.gsub(/<nowiki>(.*?)<\\/nowiki>/, '\\1')\n '<nowiki>' + nowiki.length.to_s + '</nowiki>'\n }\n \n # known tags\n display = display.gsub(/<ref [^>]+(?:\\/>|>.*?<\\/ref>)/, '')\n display = display.gsub(/<ref>.*?<\\/ref>/, '')\n display = display.gsub(/<ref>.*/, '')\n display = display.gsub(/<(br)(?: [^>]+)?>/, '')\n display = display.gsub(/<math>(.*?)<\\/math>/) { |match| \n match.gsub(/<math>(.*?)<\\/math>/, '\\1').gsub(/\\\\/, '')\n }\n display = display.gsub(/<([a-z]\\w+)(?: [^>]+)?>(.*?)<\\/\\1>/, '\\2')\n \n # html comments\n display = display.gsub(/<!--.*?-->/, '')\n \n # link syntax\n display = display.gsub(/\\(?\\[\\[w:[^\\]\\|]+|Wikipedia\\]\\]\\)?/, '')\n display = display.gsub(/\\[\\[([^\\]\\|]+)\\]\\]/, '\\1')\n display = display.gsub(/\\[\\[(?:[^\\]\\|]+\\|)+([^\\]]+)\\]\\]/, '\\1')\n \n # emphasis\n display = display.gsub(/'''([\\w]+)'''/, '\"\\1\"')\n display = display.gsub(/'''([^'].*?)'''/, '\\1')\n display = display.gsub(/''(\\w+)''/, '\\1')\n display = display.gsub(/''(\\([^'\\)]+\\))''/, '\\1')\n \n # punctuation and spacing\n display = display.gsub(/,(?:\\s*,)+/, ',')\n display = display.gsub(/\\)\\(/, ') (')\n display = display.gsub(/\\|/, ', ')\n display = display.gsub(/&nbsp;/, ' ')\n display = display.gsub(/,\\s*_\\s*,/, ' ')\n display = display.gsub(/\\s+/, ' ')\n display = display.gsub(/^\\s+|\\s+$/, '')\n display = display.gsub(/[.;:,\\s]*$/, '.')\n display = display.gsub(/\\.+$/, '.')\n \n # restore nowiki\n display = display.gsub(/<nowiki>(\\d+)<\\/nowiki>/) { |match|\n nowiki[match.to_i]\n }\n \n # capitalization\n display = display[0].upcase + display[1..-1]\n \n # create readable script (TBD)\n script = display\n script = script.gsub(/^\\(([^\\)]+)\\)\\s*/, '\\1: ')\n \n kind_slides.push({\n 'term' => term,\n 'kind' => kind,\n 'index' => i,\n 'wikitext' => definition,\n 'display' => i.to_s + \". \" + display,\n 'script' => \"Definition \" + i.to_s + \": [[slnc 500]] \" + script\n })\n \n end\n \n end\n \n suffix = \" definition\"\n if i != 1\n suffix += 's'\n end\n \n slides.push({\n 'term' => term,\n 'kind' => kind,\n 'display' => term + \"\\n(\" + kind + \")\",\n 'script' => \"Part of speech: \" + kind + \". [[slnc 500]] \" + i.to_s + suffix + \".\"\n })\n \n slides += kind_slides\n \n }\n return slides\nend", "def unmask_template(type_name)\n if(type_name =~/<.*>/)\n return type_name\n end\n\n type_name = type_name.gsub(\"cv::vector\",\"vector\") # fix namespace\n if(type_name =~/^vector/ || type_name =~/^Ptr/)\n if(type_name =~ /^([a-zA-Z\\d]*)_([_a-zA-Z\\d]*) ?(\\(?.*)\\)? */)\n \"#{$1}<#{unmask_template($2)}>#{$3}\"\n else\n type_name\n end\n else\n type_name\n end\n end", "def urls\n @url.map do |el|\n case el\n when %r{^IANA$}\n IANA_URL % [ @media_type, @sub_type ]\n when %r{^RFC(\\d+)$}\n RFC_URL % $1\n when %r{^DRAFT:(.+)$}\n DRAFT_URL % $1\n when %r{^LTSW$}\n LTSW_URL % @media_type\n when %r{^\\{([^=]+)=([^\\}]+)\\}}\n [$1, $2]\n when %r{^\\[([^=]+)=([^\\]]+)\\]}\n [$1, CONTACT_URL % $2]\n when %r{^\\[([^\\]]+)\\]}\n CONTACT_URL % $1\n else\n el\n end\n end\n end", "def replace_chapter_refs(s)\n # stochastic\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:stochastic\\}/) do |elem|\n \"<a href='stochastic.html'>Stochastic Algorithms Chapter</a>\"\n end\n # evolutionary\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:evolutionary\\}/) do |elem|\n \"<a href='evolution.html'>Evolutionary Algorithms Chapter</a>\"\n end\n # physical\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:physical\\}/) do |elem|\n \"<a href='physical.html'>Physical Algorithms Chapter</a>\"\n end \n # probabilistic\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:probabilistic\\}/) do |elem|\n \"<a href='probabilistic.html'>Probabilistic Algorithms Chapter</a>\"\n end\n # swarm\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:swarm\\}/) do |elem|\n \"<a href='swarm.html'>Swarm Algorithms Chapter</a>\"\n end\n # immune\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:immune\\}/) do |elem|\n \"<a href='immune.html'>Immune Algorithms Chapter</a>\"\n end\n # neural\n s = s.gsub(/Chapter\\~\\\\ref\\{ch:neural\\}/) do |elem|\n \"<a href='neural.html'>Neural Algorithms Chapter</a>\"\n end\n return s\nend", "def macro\n :references_one\n end", "def build_resources_field(feature)\n unless feature[\"links\"].nil?\n resources = []\n feature[\"links\"].each do |l|\n resources << \"<#{l[\"url\"]}|#{l[\"title\"]}>\"\n end\n {\n :title => \"Links & resources\",\n :value => resources.join(\"\\n\")\n }\n end\nend", "def content_type(name)\n name_li(name).span(:class=>/(mylibrary_item_|searchcontent_result_)mimetype/).text\n end", "def string_resource(resource)\n mystring=\"\\t\" + resource[:type].downcase + '{\"' + resource[:title] + '\":'+\"\\n\"\n resource[:parameters].each_pair do |k,v|\n if v.is_a?(Array)\n indent = \" \" * k.to_s.size\n\n mystring+=\"\\t #{k} => [\\n\"\n v.each do |val|\n mystring+=\"\\t #{indent} #{val},\\n\"\n end\n mystring+=\"\\t #{indent} ]\\n\"\n else\n mystring+=\"\\t #{k} => #{v}\\n\"\n end\n end\n mystring+=\"\\t}\\n\"\nend", "def to_resource_declaration(type)\n if type.respond_to?(:type_name) && type.respond_to?(:title)\n title = type.title\n type_name = type.type_name\n elsif type_result = /(\\w+)\\['?(\\w+)'?\\]/.match(type.to_s)\n # not all types have a type_name and title so we\n # output to a string and parse the results\n title = type_result[2]\n type_name = type_result[1]\n else\n return type\n end\n res = scope.catalog.resource(type_name, title)\n return res.to_ral if res\n # don't return anything or returns nil if item is not in the catalog\n end", "def url_replace(url)\n URL_SUBSTITUTION.each do |pattern, replacement|\n if url.match(pattern)\n return url.gsub(Regexp.new(\".*#{pattern}.*\",\"uxim\"), replacement)\n end\n end\n return \"[url]\"\n end", "def archetype_args\n tok = []\n @returns.map { |ent| tok << \"&#{ent.name}\" }\n @accepts.map { |ent| tok << ent.name }\n tok.join(', ')\n end", "def define_resource_matchers(actions, resource_types, name_attribute)\n actions.product(resource_types).flatten.each_slice(2) do |action, resource_type|\n RSpec::Matchers.define \"#{action}_#{resource_type}\".to_sym do |name|\n match do |chef_run|\n accepted_types = [resource_type.to_s]\n accepted_types << 'template' if action.to_s == 'create' and resource_type.to_s == 'file'\n chef_run.resources.any? do |resource|\n accepted_types.include? resource_type(resource) and resource.send(name_attribute) == name and\n resource.action.to_s.include? action.to_s\n end\n end\n failure_message_for_should do |actual|\n \"No #{resource_type} resource named '#{name}' with action :#{action} found.\"\n end\n failure_message_for_should_not do |actual|\n \"Found #{resource_type} resource named '#{name}' with action :#{action} that should not exist.\"\n end\n end\n end\nend", "def expand(value)\n v = value.reverse.clone\n loop do\n old = v.clone\n v.gsub!(PARAMETER_REGEXP) do |_s|\n replacement = Regexp.last_match(0)\n # We want all non-nil $1..n captures\n match = $LAST_MATCH_INFO.to_a[1..-1].compact.reverse.map { |x| x.reverse }\n types = catalog.resources.select do |r|\n r.is_a?(Puppet::Type.type(:postfix_main)) && r.should(:ensure) == :present\n end\n types.each do |r|\n if r.name.eql?(match[0]) && !(match[1])\n replacement = r.should(:value).reverse\n end\n end\n replacement\n end\n break if old.eql?(v)\n end\n v.reverse\n end" ]
[ "0.5072739", "0.50537956", "0.49182448", "0.49032867", "0.48522288", "0.4848557", "0.4846442", "0.48158833", "0.48065653", "0.47986424", "0.47954062", "0.47842097", "0.47820592", "0.47547767", "0.47478554", "0.4742011", "0.46857753", "0.46598318", "0.4657052", "0.4650557", "0.46469477", "0.46397308", "0.463798", "0.46081483", "0.4591211", "0.45780998", "0.45780998", "0.45726743", "0.45535937", "0.4539974", "0.45350796", "0.4532583", "0.45281217", "0.45099467", "0.4505647", "0.4503772", "0.4497214", "0.4495076", "0.44810808", "0.44810808", "0.4472701", "0.44715095", "0.44675088", "0.44600445", "0.44523546", "0.44512478", "0.44508085", "0.4438212", "0.44281104", "0.44203994", "0.44137025", "0.44039878", "0.43991107", "0.4392613", "0.43903026", "0.43882748", "0.43775895", "0.4374418", "0.43677437", "0.436452", "0.43627372", "0.4353506", "0.43533325", "0.43529838", "0.43493575", "0.4338992", "0.4338162", "0.43356144", "0.4333714", "0.4333714", "0.4333714", "0.43296605", "0.43237263", "0.43203872", "0.4316714", "0.43074003", "0.43063894", "0.43057194", "0.43016353", "0.43005604", "0.42973173", "0.42953533", "0.4290654", "0.4281439", "0.4276969", "0.4275191", "0.42723927", "0.427099", "0.42690322", "0.42684722", "0.42591125", "0.42570797", "0.42457575", "0.42446873", "0.42445904", "0.42435503", "0.42402282", "0.42395952", "0.42300484", "0.4226913" ]
0.6145426
0
Input: List of names(cohort) Output : Groups of no less than 3, no more than 5 made from the list array cohort, ideally 45 per group Steps to complete: See if cohort is divisible by 5 or 4 create a new hash test if group is divisible by 5 and 4 find remainder of group when divided by 4 or 5 go through array and assign 5 or 4 members to a key (group number) add one to group number for each set of 4 or 5 members add remaining people to groups print groups out with keys as group number and hashes as each member
def create_groups(cohort) if cohort.length % 5 == 0 hash = {} counter = 1 group_count = cohort.length / 5 remainder = cohort.length % 5 # Set to groups(keys) to members(values) group_count.times do hash[counter] = cohort.slice!(0..4) counter += 1 end else hash = {} counter = 1 group_count = cohort.length / 4 remainder = cohort.length % 4 # Set to groups(keys) to members(values) group_count.times do hash[counter] = cohort.slice!(0..3) counter += 1 end end # Add remainders counter = 1 cohort.each do |string| hash[counter] << string counter += 1 end return hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acct_groups(cohort)\n\tgroups_array = []\n\tcohort_array = cohort.split(\", \").shuffle!\n\theadcount = cohort_array.size\n\t\tif headcount < 6\n\t\t\tputs \"Too few students to sort!\"\n\t\telsif headcount == 6 || headcount == 9\n\t\t\tcohort_array.each_slice(3) { |three_person|\tgroups_array.push(three_person) }\n\t\telsif headcount <= 8 || headcount % 4 == 0\n \t\t\tcohort_array.each_slice(4) { |four_person| groups_array.push(four_person) }\n\t\telsif headcount % 5 == 0 || headcount >= 11\n \t\t\tcohort_array.each_slice(5) { |five_person| groups_array.push(five_person) }\t\t\n\t\twhile groups_array.last.size < 3\n\t\t\tgroups_array.last.push(groups_array[0][0]); groups_array[0].shift\n\t\t\tgroups_array.last.push(groups_array[1][0]); groups_array[1].shift\n\t\tend\n\t\tend\n\tgroups_hash = Hash.new\n\tnum = 0\n\tgroups_array.each { |team| groups_hash[num += 1] = team }\n\treturn groups_hash\nend", "def generate_groups(list)\n\n # decides how many accountability groups to make\n no_of_groups = (list.length/5.0).ceil\n sets = []\n\n # loops once per accountability group to assign cohortians\n no_of_groups.times do\n\n set = []\n while set.length < 5 && list.length > 0\n selected = rand(list.length)\n set << list[selected] unless set.include?(list[selected])\n list.delete_at(selected)\n end\n\n sets << set\n end\n\n # pulls two cohortians from other groups if the last group is smaller than 3\n if sets[-1].length < 3\n sets[-1] << sets[-2][0]\n sets[-2].delete_at(0)\n sets[-1] << sets[-3][0]\n sets[-3].delete_at(0)\n end\n\n n = 1\n sets.each { |set| puts \"Group #{n} is #{set}.\"; n += 1}\nend", "def acct_groups(array)\n if array.length % 5 != 0\n num_groups = array.length/5 + 1\n end\n \n cohort = array.shuffle\n groups = Array.new(num_groups) {[]}\n \n groups.each do |group|\n 5.times do \n group << cohort.pop\n end\n end\n \n return groups\nend", "def groups(array_of_names)\r\n\r\n\tnum_people = array_of_names.length \t\t#how many people do we have?\r\n\tgroups_5 = num_people % 4 \t#how many groups will have 5\r\n\tgroups_4 = (num_people - (groups_5 * 5)) / 4 # how many groups will have 4\r\n\ttotal_groups = groups_4 + groups_5 \t\t#how many total groups\r\n\r\n\tgroup_hash = Hash.new([])\t#new hash initialized to empty arrays\r\n\t\r\n\tnum_group = 0\r\n\tindex = 0\r\n\r\n\tgroups_5.times do\r\n\t\tpeople_in_group = []\r\n\t\t5.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\tgroups_4.times do\r\n\t\tpeople_in_group = []\r\n\t\t4.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\treturn group_hash\r\n\r\nend", "def accountability_group(dbcCohort_array)\n array_output = dbcCohort_array.shuffle.each_slice(4).to_a\n if array_output.length % 4 == 0 \n return array_output \n else \n remainder_people = array_output.pop \n for i in 0...array_output.length \n array_output[i].push(remainder_people[i])\n end\n return array_output\n end \nend", "def assign_to_groups(number_of_students)\n if not ((number_of_students % 5) == 1 || (number_of_students % 5) == 2)\n group_size = 5\n easy = true\n else\n group_size = 4\n stragglers = number_of_students % group_size\n if stragglers == (0||3)\n easy = true\n else\n easy = false\n end\n end\n my_student_array = (1..number_of_students).to_a.shuffle\n group_assignments = Hash.new\n if easy == true\n assign(my_student_array, 0, group_assignments)\n else #easy = false\n assign(my_student_array, stragglers, group_assignments)\n while my_student_array.length > 0\n group_number -=1\n x = my_student_array.shift\n group_assignments[x] = group_number\n end\n end\n return group_assignments\nend", "def make_groups(all_students)\n\n #calculate how many groups of 5, with one group of leftovers\n num_full_groups = all_students.size / 5\n leftovers = all_students.size % 5\n group_avg = all_students.size.to_f / num_full_groups\n\n #each entry in group_sizes represents one group - put 5 in each full one\n group_sizes = Array.new\n for i in 0...num_full_groups\n group_sizes[i] = 5\n end\n\n #if there's a leftover group- while its size is (1 or more) students less than average, move students into it from other groups one by one\n if leftovers != 0\n i = 0\n while ((group_avg - leftovers) >= 1)\n group_sizes[i] -= 1\n leftovers += 1\n if i.next == num_full_groups\n i = 0\n else\n i = i.next\n end\n end\n group_sizes << leftovers #add leftovers group to group_sizes list\n end\n\n #now we have an array of group sizes, ex: [4,4,5,5,4]\n #populate new groups_names array with arrays of student names of those sizes\n\n groups_names = Array.new\n groupcount=0\n group_sizes.cycle(1) do |i|\n groups_names[groupcount] = Array.new\n for j in 0...i\n groups_names[groupcount][j] = all_students.shift\n end\n groupcount += 1\n end\n\n groups_names\n\nend", "def cohorts_print #students #, existing_cohorts\n puts \"Students grouped by cohort:\"\n puts #spacer line\n #existing_cohorts = [] I DON'T NEED TO DECALRE IT FIRST\n existing_cohorts = @students.map {|student| student[:cohort]}.sort.uniq\n for i in (0..existing_cohorts.length-1)\n @students.map do |student|\n if student[:cohort] == existing_cohorts[i]\n cohortstr = student[:cohort].to_s.capitalize + \" Cohort\"\n puts \"#{cohortstr.ljust(20)} #{student[:name]} \"\n end #end if\n end #end do\n end #end for\n success\n #cohorts\nend", "def account_group(cohort)\n group_of_3 = cohort.sample(3)\n cohort -= group_of_3\n puts \"Accountability Group(3 people): \"\n group_of_3.each do |index|\n puts index\n end\n group_of_4 = cohort.sample(4)\n cohort -= group_of_4\n puts \"Accountability Group(4 people): \"\n group_of_4.each do |index|\n puts index\n end\nuntil cohort.empty?\n group_of_5 = cohort.sample(5)\n cohort -= group_of_5\n puts \"Accountability Group: \"\n group_of_5.each do |index|\n puts index\n end\nend\nend", "def create_groups(list)\n list_copy = []\n list.each {|item| list_copy.push(item)}\n all_groups = []\n list_copy.shuffle!\n while list_copy.size >= 4\n group = list_copy.pop(4)\n all_groups << group\n end\n if list_copy.size > 0\n list_copy.each_with_index do |person, index|\n person = list_copy.pop\n all_groups[index].push(person)\n end\n end\n hash = {}\n all_groups.each_with_index do |group, index|\n hash[\"Accountability Group #{index}\"] = group\n end\n p hash\nend", "def acct_groups(arr)\n\n num = arr.length\n if num % 5 == 0\n arr.each_slice(5) {|a| p a}\n elsif num % 4 == 0\n arr.each_slice(4) {|a| p a}\n elsif num % 3 == 0\n arr.each_slice(3) {|a| p a}\n elsif (num - 1) % 3 == 0\n arr.each_slice(3) {|a| p a}\n elsif (num + 1) % 3 == 0\n p arr.pop(5)\n arr.each_slice(3) {|a| p a}\n elsif (num - 1) % 4 == 0 || (num + 1) % 4 == 0\n arr.each_slice(4) {|a| p a}\n else\n arr.each_slice(5) {|a| p a}\n end\nend", "def fidder_crabs(names)\n\n # Create empty container for everyone in the group\n everybody = Hash.new\n # Create a counter for group number, defalt to 1\n counter = 1\n\n names.shuffle\n #Mix it up.!!!!!\n\n #while the list is longer than 8 people, put 5 each in a group.\n while names.length >= 8 do\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter +=1\n names = names.drop(5)\n end\n\n #if the remainder is 5, have the last group with 5 people\n if names.length == 5\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(5)\n\n #if the remaiinder group is 7, then we need to split the group into 4 and 3\n elsif names.length == 7\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n #creating the last group\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if the remainder is 6, we can have 2 groups of 3's\n elsif names.length == 6\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n #creating last group of 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if there is a remainder of 4 then create 1 group\n elsif names.length == 4\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n\n #if the remainder is 3, then create the last group with 3\n elsif names.length == 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n else\n names.length < 3\n names_in_group = names[0..1]\n everybody[counter] = names_in_group\n names = names.drop(3)\n end\n\n # since we filter by 8, the highest remainder is 7 and the lowest is 3, only 7 and 6 need to be split into 2 groups, while 3 and 4 could be in 1 group by themselfs.\n everybody\n #Return the hash of everybody in their group number with their names.\nend", "def accountability_groups(students)\n\nthrowaway = []\nunit = []\ngroups = []\n\n3.times do\n\tthrowaway = students.dup\n\ti = 0\n\n\twhile(throwaway.size > 0) do\n\n\t\tunit << throwaway.sample(4) if throwaway.size % 4 == 0 \n\t\tunit << throwaway.sample(5) if throwaway.size % 4 != 0\n\t\tunit[i].each { |student| throwaway.delete(student) }\n\t\ti += 1\n\tend\n\n\tgroups << unit.dup\n\tunit.clear\nend\ngroups\nend", "def acct_groups(array)\n group_1 = []\n group_2 = []\n group_3 = []\n group_4 = []\n group_5 = []\n group_6 = []\n group_7 = []\n group_8 = []\n group_9 = []\n group_10 = []\n prime_group = []\n\n i = 0\n while i < array.length\n if (i % 3 == 0) && !(i % 4 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_1 << array[i]\n elsif (i % 4 == 0) && !(i % 5 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_2 << array[i]\n elsif (i % 5 == 0) && !(i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_3 << array[i]\n elsif (i % 6 == 0) && !(i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_4 << array[i]\n elsif (i % 7 == 0) && !(i % 11 == 0) && !(i % 13 == 0)\n group_5 << array[i]\n elsif i % 11 == 0\n group_6 << array[i]\n elsif i % 13 == 0\n group_7 << array[i]\n else\n prime_group << array[i]\n end\n i += 1\n end\n x = 0\n while x < prime_group.length\n if (x % 2 == 0) && !(x % 3 == 0)\n group_8 << prime_group[x]\n elsif x % 3 == 0\n group_9 << prime_group[x]\n else\n group_10 << prime_group[x]\n end\n x += 1\n end\n\n\n\n puts group_1\n puts group_1.length\n puts group_2\n puts group_2.length\n puts group_3\n puts group_3.length\n puts group_4\n puts group_4.length\n puts group_5\n puts group_5.length\n puts group_6\n puts group_6.length\n puts group_7\n puts group_7.length\n #puts prime_group\n #puts prime_group.length\n puts group_8\n puts group_8.length\n puts group_9\n puts group_9.length\n puts group_10\n puts group_10.length\n puts array.length\nend", "def group_gen_array(list,people=5)# list and number of people per group\n list = Array.new(list) #makes it so that it doesn't change original list\n x = list.length # gets a workable non changing length of list\n num = (x-(x % people))/people\n # ^ creates base number of groups subtract remainder as to not end up with small group\n acc_group = Array.new(num){[]} # create an array to store groups\n group_num = 0\n while x != 1\n x = list.length #changing list number\n y = rand(0...x) #random number\n case group_num\n when num #when exceed group number reset\n group_num = 0\n end\n acc_group[group_num] << list[y] #append random name\n list.delete_at(y) #remove name from list to prevent duplicates\n group_num += 1 if acc_group[group_num].length >= people#when group hits/is max people go to next group\n\n end\n return acc_group\nend", "def grouper(array)\n array = array.shuffle\n p num_groups = array.length / 4\n p remainder = array.length % 4\n groups = Array.new\n array.each_slice(4) {|slice| groups.push(slice)}\n if array.length == 6\n groups[1].push(groups[0][3])\n groups[0].pop\n\n elsif remainder == 0\n return groups\n elsif remainder == 1\n groups[0].push(groups[-1][0])\n groups.pop\n elsif remainder == 2\n groups[0].push(groups[-1][0])\n groups[1].push(groups[-1][1])\n groups.pop\n end\np groups\nend", "def accountability_groups(students)\nnum_of_groups = (1..15).to_a #turns number of groups needed into an array\n\nstudent_groups = Array.new #array of arrays of 4 or 5 students \nacct_groups = Hash.new #keys[num_of_groups], value(student_groups)\n\nstudents.each_slice(4) { |s| student_groups << s } #returns array of 14 groups of 4, 1 group of 1\n\nleftover = student_groups.pop #assigns variable name to the group of 1 student\n\nstudent_groups[-1].push leftover #pushes 1 leftover student into the 14th group \n\nnum_of_groups.each_with_index { |i, j| acct_groups[i]=student_groups[j] } #assigns number of groups needed (15 groups) as the hash keys and assigns each student group to a key's value.\n\np acct_groups\n\nend", "def acct_groups(students)\nnum_students = students.length\n\n#driver code\n# p num_students\n\nif num_students <= 5\n p students\nelsif num_students % 5 == 0 || num_students % 5 >= 3\n p students.each_slice(5).to_a\nelsif num_students % 4 == 0 || num_students % 4 >= 3\n p students.each_slice(4).to_a {|group| p group}\nelsif num_students % 3 == 0\n p students.each_slice(3).to_a {|group| p group}\nelse\n p students.shift(3)\n p students.each_slice(5).to_a\nend\nend", "def print(students)\n cohort_array = []\n# Ex 8 - Print out students grouped by cohort.\n students.each do |s|\n cohort_array.push(s[:cohort])\n end\n cohort_array.uniq.each do |x|\n puts x\n students.each do |s|\n if s[:cohort] == x\n puts s\n end\n end\n end\n\n# Ex 4 - Replace each for while.\n# count = 0\n# while count < students.length\n # puts \"#{count + 1}. #{students[count][:name]} (#{students[count][:cohort]} cohort) #{students[count][:hobbies]}\".center(100) \n # count += 1\n# end\n\n# Ex 1 - Use each loop to print students\n# students.each_with_index do |student, index|\n # if student[:name].upcase[0] == 'D' && student[:name].length > 12 # Ex 2 & 3 - Print if begin 'D' & > 12 charachters.\n # puts \"#{index+1}. #{student[:name]} (#{student[:cohort]} cohort)\" # Ex 1 - Add number using each_with_index.\n # end\n# end\nend", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n\t\t$cohort.push(\"Person \"+ i.to_s)\n\t\ti += 1\n\tend\n return $cohort\nend", "def cohort_list(list)\n\tlist.each do |cohort, num_of_students|\n\t\tputs \"#{cohort}: has #{num_of_students} students\"\n\tend\nend", "def create_cohort(n)\n $cohort = Array.new\n i = 1\n (n).times do\n $cohort.push(\"Person \"+ i.to_s)\n i += 1\n end\n puts $cohort\nend", "def number_of_groups(list_of_students)\n\tif list_of_students.length % 5 == 0\n\t\tnumber_of_groups = (list_of_students.length / 5) \n\telse\n\t\tnumber_of_groups = (list_of_students.length / 5) + 1\n\tend\nend", "def make_groups(list_of_names)\n result = []\n num_people = list_of_names.length\n cur_group = []\n list_of_names.each do |name|\n cur_group.push(name)\n if cur_group.length == 4 || (cur_group.length == 3 && num_people == 3)\n result.push(cur_group)\n cur_group=[]\n end\n end\n # Right now the solution doesn't gracefully handle 6 people.\n # I should write a find_available function to find an open group to stick someone\n # in.\n if cur_group.length == 2\n name = cur_group.pop\n result[1].push(name)\n end\n if cur_group.length == 1\n name = cur_group.pop\n result[0].push(name)\n end\n return result\nend", "def acc_group(names)\n\tnames.shuffle!\n\tgroups = names.each_slice(4).to_a\n\tif names.length % 4 == 1\n\t\tgroups[0] << groups.last[0]\n\t\tgroups.pop\n\telsif names.length % 4 == 2\n\t\tgroups[0] << groups.last[0]\n\t\tgroups[1] << groups.last[1]\n\t\tgroups.pop\n\telsif names.length % 4 == 3\n\t\tgroups[0] << groups.last[0]\n\t\tgroups[1] << groups.last[1]\n\t\tgroups[2] << groups.last[2]\n\t\tgroups.pop\n\tend\n\ti = 1\n\twhile i <= groups.length\n\t\tputs \"Group \" + i.to_s\n\t\tputs groups[i-1]\n\t\ti += 1\n\tend\nend", "def create_groups(people)\n number_people = people.length\n if number_people < 3\n group_quantity = 1\n else\n group_quantity = number_people / 3\n end\n group_number = 1\n groups_names = Hash.new(\"\")\n people.each do |name|\n if group_number <= group_quantity\n groups_names[group_number] += (name + \", \")\n group_number += 1\n else\n groups_names[1] += (name + \", \")\n group_number = 2\n end\n end\n groups_names.each do |group, name|\n print \"\\n\", \"Group \", group, \"\\n\"\n print name, \"\\n\"\n end\nend", "def new_groups(array)\n new_group = []\n array.shuffle.each_slice(4){|acc| new_group << acc}\n if new_group.length > 1 && new_group.last.length <= 2\n (new_group.last.length).times do |i|\n new_group[i].push(new_group.last.pop)\n new_group.pop\n end\n end\n new_group\nend", "def group_maker(array)\n group_hash = {}\n arrays = array.each_slice(5).to_a\n arrays.each do |item|\n if item.length == 2\n arrays[0].push(item[0])\n arrays[1].push(item[1])\n num = arrays.index(item)+1\n group_hash[\"group #{num}\"] = item\n group_hash.delete_if {|k,v| v.length <= 2}\n \n elsif item.length == 1\n arrays[0].push(item[0])\n num = arrays.index(item)+1\n group_hash[\"group #{num}\"] = item\n group_hash.delete_if {|k,v| v.length <= 2}\n else\n num = arrays.index(item)+1\n group_hash[\"group #{num}\"] = item\n end\n end\n return group_hash\nend", "def assign_groups(team_list)\n # Set group size to 5 people in each group\n if team_list.length % 5 != 0\n num_groups = team_list.length/5 + 1\n end\n\n #Randomize the number of people in each group\n team = team_list.shuffle\n teams = Array.new(num_groups) { [] }\n\n #Put 5 people in each group\n teams.each do |index|\n 5.times do\n index << team.pop\n end\n end\n return teams\nend", "def group_divider (array_of_names)\n\tcounter = 0\n\tgroup_num = 0\n\tgroup_storage = []\n\tif array_of_names == nil\n\t\treturn nil\n\telsif\n\t\tarray_of_names.length < 3\n\t\tp \"It's no fun in a group less than 3 people.\"\n\telsif array_of_names.length == 3\n\t\tp \"Group 1: \" + array_of_names.join(\", \")\n\telsif array_of_names.length % 4 != 0\n\t\t\n\t\twhile counter < array_of_names.length \n\t\t\tgroup_storage << array_of_names[counter..counter + 3]\n\t\t\tcounter += 4\n\t\t\tif group_storage[group_num].length == 2\n\t\t\t\tgroup_storage.last << group_storage.first.pop\n\t\t\telsif group_storage[group_num].length == 1\n\t\t\t\tgroup_storage.first << group_storage.pop.pop\n\t\t\tend\n\t\t\tgroup_num += 1\n\t\tend\n\telse\n\t\t\n\t\twhile counter < array_of_names.length \n\t\t\tgroup_storage << array_of_names[counter..counter + 3]\n\t\t\tcounter += 4\n\t\tend\n\t\t\n\tend\n\t\n\tgroup_name_assign = 1\n\twhile group_name_assign <= group_storage.length\n\t\tp \"Group #{group_name_assign}: \" + group_storage[group_name_assign - 1].join(\", \")\n\t\tgroup_name_assign += 1\n\tend\t\nend", "def print(students)\n cohort_groups = {\n january: [],\n february: [],\n march: [],\n april: [],\n may: [],\n june: [],\n july: [],\n august: [],\n september: [],\n october: [],\n november: [],\n december: []\n }\n students.each do |student|\n cohort_groups[student[:cohort]].push(student[:name])\n end\n # Printing the results only if the array contains at least one element\n cohort_groups.each do |cohort, name|\n if name.length > 0\n puts \"The list of students for #{cohort} is:\"\n puts name\n else\n puts \"There are no students in #{cohort}.\"\n end\n end\nend", "def create_groups(names)\n groups = []\n names.shuffle.each_slice(4) do |group|\n if group.count == 4\n groups << group\n else\n i = 0\n group.each do |name|\n groups[i] << name\n i += 1\n end\n end\n end\n p groups\nend", "def make_acct_groups\n\tputs \"Type in the number of students you have: \"\n\tnumber_students = gets.chomp.to_i\n\n\t# Construct the array with the numbers 1 ... number_stdnts\n\tstudent_id = Array.new(number_students) {|i| i+1 }\n\t#print student_id\n\n\tshuffle_id = student_id.shuffle.to_a\n\t#print shuffle_id\nmod4 = number_students % 4\n\n\tif (number_students == 6)\n\t\tnumber_groups = 2\n\telsif (mod4 ==3)\n\t\tnumber_groups = (number_students / 4) + 1\n\telse\n\t\tnumber_groups = (number_students / 4)\n\tend\n\n\tacct_groups = {} \t\n\tif (number_students == 6)\n\t\tfor i in 1..2\n\t\t\tif (i == 1)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[0], shuffle_id[1], shuffle_id[2]]\n\t\t\telse\t\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[3], shuffle_id[4], shuffle_id[5]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 3)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= number_groups -1\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 2)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= (number_groups-2)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telsif (i == (number_groups -1))\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i], shuffle_id[4*i+1]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 1)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= (number_groups-1)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 0)\n\t\tfor i in 1..number_groups\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\tend\n\tend\n\treturn acct_groups\nend", "def create_groups(list, shuffle = false)\n list.shuffle! if shuffle == true\n no_of_groups = list.size < 12 ? list.size/3 : list.size/4\n new_array = Array.new(no_of_groups) {[]}\n new_array.each_with_index {|x, i| new_array[i] << list.pop; break if list.size==0} until list.size == 0\n new_array\nend", "def acct_groups(names)\r\n\r\n\tnum_groups = names.size / 4\r\n\r\n\tgroups_ary = Array.new(num_groups) { Array.new }\r\n\r\n\tnames.each_with_index do |name, index|\r\n\t\tgroups_ary[index % num_groups] << name\r\n\tend\r\n\r\n\tgroups_hash = Hash.new\r\n\tgroups_ary.each_with_index do |group_ary, index|\r\n\t\tgroups_hash[\"Accountability Group \" + (index+1).to_s] = group_ary\r\n\tend\r\n\r\n\treturn groups_hash\r\n\r\nend", "def create_group(list) \n if list.length > 5 \n group = []\n group = list.shuffle.each_slice(5).to_a\n p group\n else\t\n p list\n end\nend", "def group\n students = (1...59).to_a\n students.shuffle.each_slice(5).to_a\nend", "def make_groups(array)\n groups=Hash.new\n counter = 1\n while array.length > 3\n selection = array.sample(4)\n groups[counter] = selection\n selection.each {|x| array.delete(x)}\n counter += 1\n end\n while array.length != 0\n counter -= 1\n groups[counter] << array.pop\n end\n groups\nend", "def print_by_cohort\n sorted_by_cohort = {}\n @students.each do |student|\n cohort = student[:cohort]\n students_name = student[:name]\n if sorted_by_cohort[cohort] == nil\n sorted_by_cohort[cohort] = []\n end\n sorted_by_cohort[cohort].push(student[:name])\n end\n puts \"Students sorted by cohort:\"\n sorted_by_cohort.each do |cohort, name_array|\n puts \"#{cohort} students:\"\n puts name_array\n end\nend", "def update\n @cohort = Cohort.find(params[:id])\n @new_cohort = @cohort.generate_many_groupings(4)\n #group shuffling method goes here not sure if this is correct syntax\n #also need to make sure that the route i have created in the edit_cohort_path is correct\n @cohort = @new_cohort.sorted_groups(params[:size])\n end", "def print_by_cohort\n cohorts = []\n @students.each do |student|\n unless cohorts.include? student[:cohort]\n cohorts << student[:cohort]\n end\n end\n cohorts.each do |month|\n puts \"#{month} cohort:\"\n students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \"#{index + 1}. #{student[:name]}\"\n # print_student_data(student)\n end\n end\n end\nend", "def sort_groups_initial(array)\n\t#Set number of groups (one if there are less than four people)\n\tgroup_num = array.length / 4\n\tgroup_num = 1 if array.length < 4\n\n\tcounter = 1\n\n\t#Create a new hash with a default value of an empty array for any key\n\tgroup_hash = Hash.new { |k,v| k[v] = [ ] }\n\n\tarray.each do |i|\n\t\t#Add name to group number\n\t\tgroup_hash[counter] << i\n\n\t\t#Increase group number, or loop back to first group\n\t\tif counter == group_num\n\t\t\tcounter = 1\n\t\telse\n\t\t\tcounter += 1\n\t\tend\n\tend\n\n\treturn group_hash\nend", "def acct_groups(namelist)\n\tfull_size = namelist.size\n\tsize_of_group = 4 #because I counted the full list and counted 88 members... not sure how you'd go about it without having that number available\n\tnumber_of_groups = full_size / size_of_group #In this case 88/4 = 22\n\trandom_order = namelist.shuffle\n\tgroups = Array.new(number_of_groups) {[]}\n\t\tuntil random_order.empty?\n\t\t\tgroups.each do |group| \n\t\t\tgroup << (random_order.pop)\n\t\t\tend\n\t\tend\n\t\nreturn groups\nend", "def group\n students = (1...59).to_a\n students.each_slice(5).to_a\n\nend", "def print_students_list\n # sorting the students by their cohort (exercise 8)\n # students = students.sort_by {|name, cohort| cohort}\n number = 0\n # sorts the students by cohort (exercise 8)\n @students = @students.sort_by {|student| student[:cohort]}\n #Replacement for the each() method using a while loop (exercise 4)\n while number < @students.length\n #students.each do |student|\n # tracks the number of times the do loop has been run (exercise 1 & 4)\n student = @students[number]\n number = number + 1\n # sets the variable to the letter being look for at the start of the names (exercise 2)\n #letter = \"D\"\n # checks to see if the current name being checked in the students array starts with the letter from the line before this one (exercise 2)\n #if student[:name][0] == letter\n # only prints the students info if their name is shorter than 12 characters (exercise 3)\n #if student[:name].length <= 12\n # Some changes from exercise 5 printing out the extra information (exercise 5)\n puts \"#{number}. #{student[:name]} (#{student[:cohort]} cohort).\"# Hobbies: #{student[:hobbies]}, Place of Birth: #{student[:country]}, Height: #{student[:height]}\"\n #end\n #end\n end\nend", "def accountability_groups(name_array, min_members)\n name_array = name_array.clone\n num_groups = name_array.length/min_members\n group_counter = 0\n group_array = Array.new(num_groups) { [] }\n\n while name_array.length > 0\n\ngroup_array[group_counter].push(name_array.delete_at(rand(0...name_array.length)))\n if group_counter == num_groups - 1\n group_counter = 0\n else\n group_counter += 1\n end\n end\n\n return group_array\n\nend", "def print_by_cohort\n\n # for each month in the year (in order)\n Date::MONTHNAMES.each do |month|\n\n # find students in this months cohort\n list = @students.select {|name| name[:cohort] == month}\n\n # if the cohort is empty and skip_empty is true, skip\n if list.length == 0 then next\n\n # otherwise print cohort list\n else\n # print list\n print_header\n print_list(list)\n print_footer(list)\n end\n\n end\n\nend", "def group_students\n\n\n # retrieve the student\n students = @students.values\n students.sort! { |a,b| a.get_percent_correct <=> b.get_percent_correct }\n\n students_size = students.size \n n = students_size / 3\n\n\n @group_low = divide_students_to_group(0, n-1, students)\n @group_mid = divide_students_to_group(n, n*2-1, students)\n @group_high = divide_students_to_group(n*2, students_size-1, students)\n\n\n end", "def group(list)\n\tfinalArray = Array.new(0)\n\tsubArray = Array.new(0)\n\tmemCounter = 0\n\tgroupMemCounter = 0\n\tgroupCounter = 0\n\tlist.length.times do\n\t\tsubArray.push(list[memCounter])\n\t\tmemCounter += 1\n\t\tgroupMemCounter += 1\n\t\tif groupMemCounter > 4\n\t\t\tfinalArray.push(subArray)\n\t\t\tgroupCounter += 1\n\t\t\tgroupMemCounter = 0\n\t\t\tsubArray = []\n\t\t\tif memCounter == (list.length) and subArray.empty? != true\n\t\t\t\tfinalArray.push(subArray)\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\tif subArray.length < 3 and subArray.length != 0\n\t\tpreviousGroup = finalArray[groupCounter-1]\n\t\tfinalArray.pop\n\n\t\tsubArray.push(previousGroup[(previousGroup.length-1)])\n\t\tpreviousGroup.pop\n\t\tsubArray.push(previousGroup[(previousGroup.length-1)])\n\t\tpreviousGroup.pop\n\n\t\tfinalArray.push(previousGroup)\n\t\tgroupCounter += 1\n\tend\n\tif subArray.empty? != true\n\t\tfinalArray.push(subArray)\n\tend\n\tprint finalArray\nend", "def create_group(array)\nunit1=array.shuffle!.each_slice(4).to_a\nunit2=array.shuffle!.each_slice(4).to_a\nunit3=array.shuffle!.each_slice(4).to_a\nputs \"Unit1: #{unit1.to_s} Unit2: #{unit2.to_s} Unit3: #{unit3.to_s}\"\nend", "def sum_cohorts(users)\n sums = []\n # initialize the expected number of cohorts\n (1..current_cohort).each do |cohort|\n sums[cohort] = 0\n end\n\n users.each do |user|\n user_id = user[0]\n cohort = user[1]\n sums[cohort] = 0 if sums[cohort].nil?\n if match_user_id?(user_id)\n sums[cohort] += 1\n end\n end\n\n return sums\n end", "def acct_group(list)\n groups=[]\n if list.length<=5 \n groups = list \n else\n i=0\n while i <=list.length-3\n groups = groups << list[i..i+2]\n i+=3\n end \n groups[0] = groups[0]+list[i..list.length-1] \n end\n p groups\nend", "def group_creator(name_list)\n\n\taccountability_groups = []\n\trandomized_names = name_list.shuffle #Used non-destructive shuffle so that I can call on list again for unit 2/3\n\n\twhile (randomized_names.length > 4)\n\t\taccountability_groups << randomized_names.pop(4)\t\n\tend\n\n\tcounter = 0\n\tuntil (randomized_names.length == 0)\n\t\taccountability_groups[counter] << randomized_names.pop\n\t\tcounter\t+= 1\n\tend\n\t\t\n\tcounter = 0\n\tuntil accountability_groups[counter] == nil\n\t\tputs \"Group \" + (counter + 1).to_s + \":\" ; puts accountability_groups[counter]\n\t\tputs\n\t\tcounter += 1 \n\tend\nend", "def print_students_by_cohort student_arr\n sorted_by_input = {}\n student_arr.each do |x|\n selection = x[:cohort].upcase\n if sorted_by_input[selection] == nil\n sorted_by_input[selection] = []\n end\n sorted_by_input[selection].push(x[:name])\n end\n puts sorted_by_input.flatten\nend", "def inclu (list, cohort, students)\n list[cohort] = students\n display(list)\nend", "def make_groups(name_master_list, group_size, min_group_size, shuffle_first = false)\n\tgroups = {}\n\t# Set initial group number\n\tgroup_num = 1\n\tname_master_list.shuffle! if shuffle_first\n\t\n\tname_master_list.each_with_index do |name, index|\n\t\t# Set the value as an empty array if it doesn't already exist\n\t\tgroups[\"Group #{group_num}\"] ||= [] \n\t\tgroups[\"Group #{group_num}\"] << name\n\t\t# Test whether we have either reached the group size already\n\t\t# Or if we have reached the final name (The item at the next index is nil)\n\t\tif (index + 1) % group_size == 0 && name_master_list[index + 1] != nil\n\t\t\t# Time to make a new group with a new group number\n\t\t\tgroup_num += 1\n\t\tend\n\tend\n\n\t# The last group will be the one with the current group_num value\n\tlast_group = groups[\"Group #{group_num}\"]\n\t# Test if the last group is too small; if so, add its members to the other groups\n\tif last_group.length < min_group_size\n\t\t# Make the second-to-last group the new group for the first member\n\t\tnew_group_num = group_num - 1\n\t\tlast_group.each do |name|\n\t\t\t# Put the member into its new group\n\t\t\tgroups[\"Group #{new_group_num}\"] << name\n\t\t\t# Set a different new group for the next member\n\t\t\tnew_group_num -= 1\n\t\tend\n\t\t# Get rid of the group that was too small, now that its members have new groups\n\t\tgroups.delete(\"Group #{group_num}\")\n\tend\n\n\treturn groups\nend", "def method_people(names, number)\n names_array = names.shuffle.map\n teams = (names.length.to_f / number).ceil\n new_array = Array.new(teams) { Array.new }\n count = 0\n names_array.map do |name|\n new_array[count] << name\n count == (teams - 1) ? (count = 0) : (count += 1)\n end\n new_array\n end", "def part2 groups\n yeses = groups.map { | g |\n members = g.split(\"\\n\")\n shared_answers = members.reduce(\"abcdefghijklmnopqrstuvwxyz\".chars) { |m,v |\n m & v.chars\n }.uniq.length\n }.reduce(0){ |m,v|\n m+v\n }\nend", "def list_cohorts\n @students.each do |student_info|\n if (@cohorts.include? (student_info[:cohort])) == false\n @cohorts << student_info[:cohort]\n end\n end\nend", "def print(students)\n sorted_students = {}\n students.each do |student|\n cohort = student[:cohort].to_s\n name = student[:name].to_s\n if !sorted_students[cohort]\n sorted_students[cohort] = [name]\n else\n sorted_students[cohort].push(name)\n end\n end\n sorted_students.each do |cohort, students|\n puts cohort.to_s.center(50)\n students.each do |student|\n puts student.to_s.center(50)\n end\n end \nend", "def groups (student_arr)\n num_of_arrays = student_arr.size/5\n if student_arr.size%5 != 0\n num_of_arrays += 1\n end\n\n i = 0\n j = 0\n answer = Array.new(num_of_arrays) {Array.new}\n while j < student_arr.size\n while i < num_of_arrays\n answer[i] << student_arr[j]\n i += 1\n j += 1\n end\n i = 0\n\n end\n p answer\nend", "def groups\n @students.sort_by(&:fullname).each_slice((@students.count / 2.0).round).to_a\n end", "def accounts(group)\n if group.length % 5 == 0\n return group.shuffle.each_slice(5).to_a\n end\nend", "def total(list)\n\ttotal_students = 0\n\tlist.map do |cohorts, size|\n\t\ttotal_students += size\n\tend\n\treturn total_students\nend", "def generate_one_grouping(size)\n\tstudents_array = self.students.to_a\n\tstudents_array.shuffle!\n \tgroup_sizes_array = determine_group_sizes(size)\n \tgroups = []\n \tgroup_sizes_array.each do |size|\n \t\tgroup = []\n\t\twhile group.length < size\n\t\t\tgroup << students_array.slice!(0)\n\t\tend\n\t\t\tgroups << group\n \tend\n \tgroups\n end", "def print(names)\n# exercise 6 - added in center to print option 1 to align all fields into the center\n# exercise 8 - added in option to print by cohort, can print out each cohort in one go, or specific cohort.\n# exercise 9 - fixed printing statments for singular/plural of student/students\n\n puts \"Do you want: \nThe full list of names (enter 1) \nNames beginning with a specific letter (enter 2)\nNames with less than 12 characters (enter 3)\nPrint by cohort (enter 4)\"\nchoice_possibilities = [1, 2, 3, 4]\n choice = gets.chomp.to_i\n while !choice_possibilities.include?(choice) \n puts \"Please select #{choice_possibilities}.\"\n choice = gets.chomp.to_i\n end\n\n print_header\n\n if choice == 1\n counter = 0\n while counter < names.length\n print_array = \"\"\n\tnames[counter].map{ |y, z| print_array << \"#{y}: #{z}, \"} \n\tputs \"#{counter + 1}. #{print_array.to_s}\".center(100) \n\tcounter += 1\n end\n\n elsif choice == 2\n puts \"what letter would you like?\"\n letter = gets.chomp.downcase\n while letter.length != 1\n puts \"Please enter a single letter\"\n letter = gets.chomp.downcase\n end\n counter = 0\n names.each_with_index do |name, index|\n if name[:name][0].downcase == letter\n\tputs \"#{index + 1}. #{name[:name]} (#{name[:cohort]} cohort)\"\n counter += 1\n end\n end\n puts \"We have #{counter} #{counter == 1 ? \"student\" : \"students\"} with a name starting with #{letter.upcase}.\"\n\n elsif choice == 3\n counter = 0\n names.each_with_index do |name, index|\n if name[:name].length < 12\n puts \"#{index + 1}. #{name[:name]} (#{name[:cohort]} cohort)\"\n counter += 1\n end\n end\n puts \"We have #{counter} #{counter == 1 ? \"student\" : \"students\"}} with a name of less than 12 character.\"\n \n elsif choice == 4\n puts \"Do you want to print all cohorts or a specific cohort? Type all or specific\"\n choice_poss = ['all', 'specific']\n choice = gets.chomp.downcase\n while !choice_poss.include?(choice)\n\tputs \"please enter all or specific\"\n choice = gets.chomp.downcase\n end\n cohorts = []\n names.each do |name|\n cohorts << name[:cohort]\n end\n cohorts.uniq!\n if choice == 'all'\n cohorts.each do |cohort|\n puts \"Cohort: #{cohort}\"\n names.each_with_index { |name, index| puts \"#{index + 1}. Name: #{name[:name]}, Age: #{name[:age]}, Hobby: #{name[:hobby]}\" if name[:cohort] == cohort}\n end \n elsif choice == 'specific'\n puts \"Please choose a cohort\"\n cohorts.each {|x| puts x }\n choice = gets.chomp.to_sym\n while !cohorts.include?(choice)\n\tputs \"Please type an available cohort\"\n\tcohorts.each {|x| puts x}\n\tchoice = gets.chomp.to_sym\n end\n puts \"Cohort: #{choice}\"\n names.each_with_index { |name, index| puts \"#{index + 1}. Name: #{name[:name]}, Age: #{name[:age]}, Hobby: #{name[:hobby]}\" if name[:cohort] == choice}\n end\n end\nend", "def group(names)\n\tunits = []\n\t3.times do\n\t\tnames = names.shuffle\n\t\tremainder = []\n\t\tcount = names.length % 4\n\t\tcount.times do\n\t\t\tremainder << names.shift\n\t\tend\n\t\tgroupsArray = names.each_slice(4).to_a\n\t\twhile count != 0\n\t\t\tgroupsArray[count-1] << remainder.shift\n\t\t\tcount -= 1\n\t\tend\n\t\tunits << groupsArray\n\tend\n\treturn units\nend", "def populate_groups_for_round i=@round\r\n temp_groups = []\r\n (1..@number_of_groups).each_entry do |x|\r\n temp_group = Group.new(:position => i, :day => x, :schedule_dataset => self)\r\n temp_groups.push(temp_group)\r\n end\r\n\r\n # Add seminarians who need to be assigned to a single day\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups)\r\n sem.add_to_group(possible_grps.first) if possible_grps.count == 1 && !possible_grps.first.full?\r\n end\r\n\r\n # Add seminarians with too many duplicates to a group with least number of seminarians\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).sort_by{|g| g.seminarians.count}\r\n sem.add_to_group(possible_grps.first) if sem.duplicate_days >= @duplicate_days_allowed && !possible_grps.first.full?\r\n end\r\n\r\n # Add at least one seminarian to each group\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).shuffle\r\n sem.add_to_group(possible_grps.first) if possible_grps.count < @number_of_groups && possible_grps.first.seminarians.count == 0\r\n end\r\n\r\n seminarians_left = seminarians_for_round(i)\r\n \r\n while seminarians_left.any? do\r\n\r\n #Find the smallest groups\r\n smallest_number = temp_groups.sort_by{|g| g.seminarians.count}.first.seminarians.count\r\n small_groups = temp_groups.select{|tg| tg.seminarians.count == smallest_number}\r\n\r\n best_match = nil\r\n best_score = 9000\r\n\r\n small_groups.shuffle.each do |group|\r\n seminarians_left.shuffle.each do |sem|\r\n \r\n #Find the best match of seminarians and small groups\r\n if sem.score_for_group(group) < best_score\r\n best_match = [sem, group]\r\n best_score = sem.score_for_group(group)\r\n end\r\n end\r\n end\r\n \r\n best_match.first.add_to_group(best_match.second) if best_match\r\n seminarians_left = seminarians_for_round(i)\r\n end\r\n \r\n temp_groups.each{|g| @groups.push(g)}\r\n end", "def count_SE_groups(a)\n return 1 if a.length == 1\n record = Hash.new\n len_elem = a[0].length\n if len_elem > 1\n a.length.times do |i|\n atemp = Array.new(2,\"\")\n len_elem.times do |j|\n atemp[j % 2] += a[i][j]\n end\n atemp = atemp[0].chars.sort!*\"\" + atemp[1].chars.sort!*\"\"\n a[i] = atemp\n end\n end\n p a.sort!\n count_of_groups = 0\n a.length.times do |i|\n count_of_groups += 1 if a[i + 1] != a[i]\n end\n count_of_groups\nend", "def groupSlice(fireflies)\n \n unit_one = fireflies.shuffle.each_slice(4).to_a\n unit_one[0] << unit_one.pop\n unit_one[0].flatten!\n\n unit_two = fireflies.shuffle.each_slice(4).to_a\n unit_two[0] << unit_two.pop\n unit_two[0].flatten!\n \n unit_three = fireflies.shuffle.each_slice(4).to_a\n unit_three[0] << unit_three.pop\n unit_three[0].flatten!\nend", "def display_students_in_diff_cohorts(list)\n\tlist.each {|key,value| puts \"#{key}: #{value} students.\"}\nend", "def generate_matchups(submissions, riddle_id = \"0\")\n submissions_by_category = submissions.select { |submission| submission[:riddle_id] == riddle_id }\n\n puts \"submissions_by_category: #{submissions_by_category.count}\"\n\n # TODO: handle when odd-number of submissions\n matchups = submissions_by_category.shuffle.each_slice(2).map { |pairing| {\n id: \"#{pairing[0][:id]}#{pairing[1][:id]}#{$BATCHES_GENERATED}\",\n submission_id_a: pairing[0][:id],\n submission_id_b: pairing[1][:id],\n team_id_a: pairing[0][:team_id],\n team_id_b: pairing[1][:team_id],\n completed: false,\n assigned: false,\n riddle_id: pairing[0][:riddle_id],\n winning_submission_id: nil\n } }\n $BATCHES_GENERATED = $BATCHES_GENERATED+1\n return matchups\nend", "def groupCreator(array)\n\t3.times do\n\t\tarray.shuffle!\n\t\t\tnewArray=array.each_slice(4).to_a\n\t\t\tnewArray.each do |x|\n\t\t\t\tif(x.length<4)\n\t\t\t\t\ti=0\n\t\t\t\t\tuntil x.length<=0\t\n\t\t\t\t\t\tnewArray[i]<<x.pop\n\t\t\t\t\t\ti+=1\n\t\t\t\t\tend\n\t\t\t\t\tnewArray.pop\n\t\t\t\tend\n\t\t\tend\n\t\t\tp newArray\n\tend\nend", "def find_group (student, cohort)\n groups = acct_groups1(cohort)\n p \"#{student} is in group #{groups[student][1]}\"\nend", "def list_cohorts(students)\n students.each do |key, value|\n puts \"#{key} : #{value} students\"\n end\nend", "def create_group(array)\n \n new_array = array.shuffle\n return new_array.each_slice(4).to_a\nend", "def create_group(array)\n \n new_array = array.shuffle\n return new_array.each_slice(4).to_a\nend", "def print_students_list\n\n if @students.empty?\n puts \"Villains Academy is empty. :(\".center(@width)\n puts\n return\n end\n\n @cohorts_list.each do |month|\n @students.each_with_index do |student, index|\n if student[:cohort] == month\n puts \" #{student[:name]} (##{index + 1}) \".center(@width,\"-\")\n puts \"Cohort: #{student[:cohort].capitalize}\".center(@width)\n puts \"Hero: #{student[:hero]}\".center(@width)\n puts\n end\n end\n end\n\nend", "def print_by_cohorts(students, cohort)\n students = students.select { |student| student[:cohort] == cohort}\n print(students)\nend", "def print_student_list\n existing_cohorts = get_cohort_list\n existing_cohorts.each do |cohort|\n puts \"The students in the #{cohort.to_s} cohort are:\"\n @students.each do |student|\n if student[:cohort] == cohort\n puts student[:name]\n end\n end\n end\nend", "def input_students #Creating a method to take users input\n\tputs \"Please enter the names of the students\"\n\tputs \"To finish, just hit return twice\"\n#create empty array\ncohorts = [:January, :February, :March, :April, :May, :June, :July, :August, :September, :October, :November, :December]\n@students = []\n#get the first name\nname = gets.gsub(/\\n/,\"\")\ncohort = nil\n#while name isn't empty, repeat the above code\nwhile !name.empty? do\n until cohorts.include? cohort do\n default_cohort = :July\n puts \"...is in which cohort?\"\n cohort = gets.gsub(/\\n/,\"\").capitalize.to_sym\n cohort ||= default_cohort\n puts \"Please check your spelling and try again.\" if !cohorts.include? cohort\n end\n \n @students << {name: name, cohort: cohort}\n cohort = nil\n\t#add the student hash to the array\n\t#students << {name: name, cohort: :november}\n\tif @students.count ==1\n\tputs \"Now we have #{@students.count} student\"\nelse\n\t\tputs \"Now we have #{@students.count} students\"\nend\n\tputs \"Add next student or press return to finish:\"\n\t#get another name from the user\n\tname = gets.gsub(/\\n/,\"\")\nend\n#return the array of students\n\nend", "def assign(group)\n\tif group.length % 5 == 0\n\t\treturn group.shuffle.each_slice(5).to_a\n\telsif group.length % 5 == 1\n\t\treturn group.shuffle.each_slice(4).to_a\n\telsif group.length % 5 == 2\n\t\treturn group.shuffle.each_slice(4).to_a\n\telsif group.length % 5 == 3\n return group.shuffle.each_slice(5).to_a\n\telsif group.length % 5 == 4\n return group.shuffle.each_slice(5).to_a\n\tend\nend", "def assign_pods(students, pods)\n # four people per pod\n # if pod is empty will not be included in the\n # hashmap\n assignments = Hash.new([])\n j = nil\n pods.each_with_index do |pod, i|\n x, y = 4*i, 4*(i + 1)\n row = students[x...y]\n assignments[pod] = row\n if x >= students.length or y >=students.length\n break\n end\n end\n assignments\nend", "def groups\n @students.each_slice((@students.count / 2.0).round).to_a\n end", "def cohortfilter\n puts \"Please find students by cohort below:\"\n cohort_months = @students.map { |month| month[:cohort]}\n cohort_months.uniq!\n cohort_months.each do |month|\n puts \"Here are the #{month} students\"\n selected_students = @students.select { |student| student[:cohort] == month}\n list(selected_students)\n end\nend", "def increase_students(more_students)\n\tmore_students.each do |cohort, number| \n\t\tmore_students[cohort] = number * 1.05\n\tend\nend", "def print_groups(groups)\n\tx = 0\n\t3.times do\n\tputs \"Unit #{x + 1} Groups\"\n\tgroups[x].each { |group| puts \"#{group} \\n\" }\n\tx += 1\nend\nend", "def create_example_groups(groups_count = 100)\n # FIXME: What if Example organization is not found?\n organization = Organization.where(:name => 'Example').first\n \n # Get example students\n users = User.where(:firstname => 'Student', :organization_id => organization.id).all\n user_counter = 0\n \n # Create groups and submissions\n for i in (1..groups_count)\n # Create group\n group = Group.new(:course_instance_id => self.id, :name => \"Group #{i}\", :max_size => 3)\n group.save(:validate => false)\n\n # Add users to group\n students_count = rand(3) # self.groupsizemin + rand(self.groupsizemax - self.groupsizemin + 1)\n for j in (0..students_count)\n user = users[user_counter]\n group.add_member(user) if user\n user_counter += 1\n end\n\n break if user_counter >= users.size\n end\n end", "def all_cohorts (hash_value)\n total_students = hash_value.each_value.reduce(:+)\n puts total_students\nend", "def default_students\n\nstudents = [\n {name: \"Dr. Hannibal Lecter\",cohort: :november, hobby: :sport, weight: 87, age: 64},\n {name: \"Darth Vader\", cohort: :november, hobby: :reading, weight: 87, age: 53},\n {name: \"Nurse Ratched\", cohort: :november, hobby: :music, weight: 100, age: 42},\n {name: \"Michael Corleone\", cohort: :november, hobby: :coding, weight: 68, age: 24},\n {name: \"Alex DeLarge\", cohort: :november, hobby: :coding, weight: 130, age: 28},\n {name: \"The Wicked Witch of the West\", cohort: :november ,hobby: :gaming, weight: 120, age: 43},\n {name: \"Terminator\", cohort: :november, hobby: :music, weight: 72, age: 34},\n {name: \"Freddy Krueger\", cohort: :november, hobby: :reading, weight: 55, age: 18},\n {name: \"The Joker\", cohort: :november, hobby: :sport, weight: 30, age: 45},\n {name: \"Joffrey Baratheon\", cohort: :november, hobby: :music, weight: 70, age: 30},\n {name: \"Norman Bates\", cohort: :november, hobby: :music, weight: 80, age: 25}\n]\nend", "def output_groups(names_array, size_of_group)\n\tgroup_id = 1\n\tuntil names_array.size == 0 do\n\t\tputs \"Group \" + group_id.to_s\n\t\tputs \"=================\"\n\t\tputs names_array.shift(size_of_group)\n\t\tputs\n\t\tgroup_id += 1\n\tend\nend", "def group_slides(song)\n ordered = song[:order].dup\n skipped = []\n skipped.push(ordered.shift) while ordered.any? && ordered.first =~ /(title|blank) slide/\n unvisited = []\n unvisited.unshift(ordered.pop) while ordered.any? && ordered.last =~ /(title|blank) slide/\n\n infos = Hash.new { |h,k| h[k] = {:pre => Set.new, :post => Set.new} }\n ordered.each_cons(2) do |a,b|\n infos[a][:post] << b\n infos[b][:pre] << a\n end\n infos[ordered.first][:pre] << :first\n infos[ordered.last][:post] << :last\n\n groups = {}\n group_members = {}\n new_order = []\n ordered.each do |name|\n if group_name = group_members[name]\n if groups[group_name].first == name\n #puts \"REPEAT #{group_name} (#{name})\"\n new_order << group_name\n end\n else\n group_name = name\n new_order << group_name\n group = groups[group_name] = [name]\n group_members[name] = group_name\n cur = infos[name]\n #puts \"NEW GROUP #{name} #{cur}\"\n while cur && cur[:post].size == 1\n nxt_name = cur[:post].first\n nxt = infos[nxt_name]\n if nxt && nxt[:pre].size == 1 && !group.include?(nxt_name)\n #puts \" ... #{nxt_name} #{nxt}\"\n group << nxt_name\n group_members[nxt_name] = group_name\n cur = nxt\n else\n cur = nil\n end\n end\n end\n end\n [\"title slide\", \"blank slide\"].each do |n|\n if groups[n] && groups[n].size == 1\n groups.delete n\n end\n end\n\n new_parts = {}\n groups.each do |group_name, orig_part_names|\n new_parts[group_name] = orig_part_names.inject([]) { |a, name|\n slide = song[:parts][name]\n if slide.nil?\n if name == \"blank slide\"\n slide = [\"\"]\n else\n slide = [\"MISSING:#{name}\"]\n end\n end\n a + slide\n }\n end\n\n (song[:parts].keys - group_members.keys).each do |name|\n new_parts[name] = song[:parts][name]\n end\n\n {\n :parts => new_parts,\n :order => skipped + new_order + unvisited,\n :keywords => song[:keywords],\n }\nend", "def print(students)\n # creating an if statement to tell the program to print only if there is at least one student\n if students.count > 0 \n puts students.group_by {|student| student[:cohort]}\n .each {|cohort, students| students.map!{|single_student| single_student = (single_student[:name])}}\n .flatten\n end\nend", "def print_students_list\n count = @students.count\n if count ==0\n puts \"There are no students to print.\".center(40)\n exit\n else\n\n n = 1\n while n <= count\n @students.map do |student|\n name = student[:name]\n cohortstr = student[:cohort].to_s.capitalize\n puts \"#{n.to_s.center(4)} #{name.ljust(30)} #{cohortstr}\"\n n +=1\n end #end of map do\n end #end of while\n puts #spacer line\n success\n end #end if\nend", "def print_student_list\n @students.sort_by! { |hash| hash[:cohort] }\n @students.each.with_index(1) do |student, index|\n puts \"#{index}. #{student[:name]} (#{student[:cohort]} cohort)\".center(100)\n end\nend", "def init_cohort(cohort)\n @data[cohort] ||= {}\n @data[cohort][:success] ||= 0\n @data[cohort][:failure] ||= 0\n end", "def test_0690_group_by\n @@log.debug \"test_0690_group_by starts\" if @@log.debug?\n assert_respond_to(@list, :group_by, \"test_0690_group_by_respond\")\n # Type check\n enum = @list.group_by\n result = enum.is_a? Enumerator\n assert(result,\"test_0690_group_by_class\") \n # Build basic Hash groups\n hash = @list.group_by {|item| item.ndata <= 2 ? \"le2\" : \"gt2\"}\n assert_equal(hash,\n {\"gt2\" => [@aen, @bsb], \"le2\" => [@cab, @dad]},\n \"test_0690_group_by_hash\")\n @@log.debug \"test_0690_group_by ends\" if @@log.debug?\n end", "def input_students\n puts \"Please enter the student's name:\"\n puts \"To finish, just hit return twice\"\n # the array in which the input is gonna be saved\n \n # get the first name\n name = gets.chomp\n # while the name is not 'empty?', repeat this code\n while !name.empty? do\n # get the cohort\n m = false\n while m == false\n puts \"Which cohort does #{name} belong to? Please enter the month name.\"\n cohort = gets.chomp.downcase\n #define an array of months to compare against\n months = [\"january\", \"february\", \"march\",\n \"april\", \"may\", \"june\", \"july\", \"august\",\n \"september\", \"october\", \"november\", \"december\"]\n #check for typos\n if months.include?(cohort)\n m = true\n #check if empty\n elsif cohort.empty?\n cohort = \"Unknown\"\n m = true\n else\n puts \"Please enter a valid month: \"\n end #end if\n end #end second while\n \n #convert the cohort label into a symbol\n #cohortlabel = cohortlabel #DON'T NEED THIS LINE NOW\n\n \n # Add the student hash to the array with a cohort hash\n add_to_students name, cohort #refactored\n # then puts the number of students/entries in the students array \n if @students.count == 1\n success\n puts \"Now we have #{@students.count} student. Enter a new name or hit return for main menu:\"\n else\n success\n puts \"Now we have #{@students.count} students. Enter a new name or hit return for main menu:\"\n end\n #gets another name from the user..unless it's empty the while loop continues\n name = gets.chomp #gets.gsub(/\\n/,”\")\n end\n #return the array of students\n #students\nend", "def groups\n\nroster = [ \"Caroline Artz\", \"Syema Ailia\", \"Alan Alcesto\", \"Daniel Andersen\", \"James Artz\", \"Darius Atmar\", \"Brian Bensch\", \"Nicola Beuscher\", \"Kris Bies\", \"Logan Bresnahan\", \"William Brinkert\", \"Laura C.\", \"Scott Chou\", \"Bernice Anne W Chua\", \"Abraham Clark\", \"Jon Clayton\", \"Kevin Corso\", \"Jacob Crofts\", \"John D.\", \"Katy D.\", \"Emmanuel Kaunitz\", \"Amaar Fazlani\", \"Solomon Fernandez\", \"Edward Gemson\", \"Jamar Gibbs\", \"Chris Gomes\", \"Will Granger\", \"Christopher M. Guard\", \"Adell H.\", \"James Hwang\", \"Matt H.\", \"Michael H.\", \"Peter H.\", \"Ryan Ho\", \"Igor Kazimirov\", \"Walter Kerr\", \"Karla King\", \"Becky Lehmann\", \"Malia Lehrer\", \"Carolina Medellin\", \"Timothy Meixell\", \"Lorena Mesa\", \"Chris Miklius\", \"Joshua Monzon\", \"Shea Munion\", \"Bryan Munroe\", \"Neal Peters\", \"Trevor Newcomb\", \"Aleksandra Nowak\", \"Morgan O.\", \"Fatma Ocal\", \"Van Phan\", \"Luis Fernando Plaz\", \"Nalie Polen\", \"Alicia Quezada\", \"Celeen R.\", \"Jessie Richardson\", \"Gary S.\", \"Iulia S.\", \"Nimi Samocha\", \"Zach Schatz\", \"Schwartz\", \"Pratik Shah\", \"Josh Shin\", \"Shawn Spears\", \"Sasha ilor\", \"Nil Thacker\", \"Nasha Thapliyal\", \"Sabrina Unrein\", \"Brian Wagner\", \"Clinton Weber\", \"Gregory Wehmeier\", \"Michael Whelpley\", \"Alexander Williams\", \"Peter N Wood\", \"Caitlyn Y.\", \"Ryan Zell\",\"random name\"]\n#initial solution\n\n=begin\n group_arrays = []\n i = 0\n while i < roster.length\n group_arrays << roster[i..i+3]\n i += 4\n end\n\n extra = []\n i = 0\n group_arrays.each { |group|\n if group.length < 3\n extra = group #take contents of group and add it to a different group\n if group_arrays[i].length == 5\n i += 1\n end\n group_arrays[i].concat(extra)\n group.pop\n end\n }\n puts group_arrays.to_s\nend\n\n=end\n\n# If I run this program 3 times, it will return the exact same groups\n#The program could be set up to store past groups, but I'd have to make some updates\n#no groups would be impacted by 1 person leaving, once 2 people left I could run the code again though.\n#biggest issue is I can empty the last array, but it doesn't delete the brackets. so that's a thing.\n\n#refactored solution:\n\n group_arrays = []\n while roster.length > 0\n group_arrays << roster.slice!(0..3)\n end\n\n left_overs = group_arrays[-1]\n\n i = 0\n group_arrays.each { |array|\n if left_overs.length < 3 && left_overs.length > 0\n group_arrays[i].push(left_overs[0])\n left_overs.shift\n if group_arrays[i].length == 5\n i += 1\n end\n elsif array.length > 5\n left_overs.push(array[-1])\n array.pop\n end\n }\n puts group_arrays.to_s\nend", "def get_and_check_cohort\n cohorts = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n puts \"And the cohort?\"\n cohort = get_cohort\n input_ok = check_input(cohort, cohorts)\n while !input_ok\n puts \"That isn't a month....the cohort?\"\n cohort = get_cohort\n input_ok = check_input(cohort, cohorts)\n end\n return cohort\nend" ]
[ "0.8172613", "0.76304543", "0.7329762", "0.7263083", "0.7213749", "0.7018138", "0.697309", "0.6910674", "0.69004035", "0.68534166", "0.67199785", "0.67139083", "0.66952914", "0.6645634", "0.66045386", "0.6573632", "0.65453225", "0.6532134", "0.6493227", "0.64893305", "0.6471642", "0.6417829", "0.6404345", "0.6358929", "0.6347744", "0.6341797", "0.63397545", "0.6325431", "0.6291786", "0.6266275", "0.6257842", "0.6255724", "0.62453896", "0.62372017", "0.6208458", "0.61723906", "0.61572266", "0.60956854", "0.6055138", "0.6054603", "0.6034468", "0.6019683", "0.6002112", "0.59684515", "0.5935583", "0.59217745", "0.59167165", "0.59030664", "0.58836794", "0.5855332", "0.5828301", "0.58213466", "0.5805418", "0.57973045", "0.5796803", "0.57952553", "0.57694167", "0.57440406", "0.57177", "0.56954783", "0.56830037", "0.56731486", "0.5661835", "0.56413", "0.5623362", "0.5595843", "0.5592728", "0.5567359", "0.55526847", "0.55427593", "0.5515304", "0.54981726", "0.5450764", "0.54411536", "0.54351133", "0.5431811", "0.5431811", "0.54266137", "0.5425843", "0.541172", "0.54100066", "0.5395091", "0.5391022", "0.53770906", "0.5371197", "0.5347529", "0.53458333", "0.53398675", "0.5313672", "0.5312955", "0.53071713", "0.5304899", "0.5291927", "0.52761245", "0.52634346", "0.52597886", "0.525312", "0.5247706", "0.5231364", "0.52000713" ]
0.806292
1
GET /military_document_types GET /military_document_types.json
def index @military_document_types = MilitaryDocumentType.all respond_to do |format| format.html # index.html.erb format.json { render :json => @military_document_types } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def index\n @documenttypes = Documenttype.all\n end", "def index\n @document_types = DocumentType.all\n @document_types = @document_types.where(description: params[:description]) if params[:description]\n end", "def show\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_type }\n end\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def document_types\n {\n ORIGINAL: %w(TY ID T1 TI CT A1 A2 AU Y1 PY N1 KW RP SP EP JF JO JA J1 J2 VL IS T2 CY PB U1 U5 T3 N2 SN AV M1 M3 AD UR L1 L2 L3 L4 ER),\n GEN: %w(TY A2 A3 A4 AB AD AN AU C1 C2 C3 C4 C5 C6 C7 C8 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RI RN RP SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n JOUR: %w(TY AB AD AN AU C1 C2 C6 C7 CA CN DA DB DO DP ET J2 KW L1 L4 LA LB IS M2 M3 N1 OP PY RI RN RP SN SP ST T2 TA TI TT UR VL Y2 ER),\n BLOG: %w(TY A2 A3 AB AD AN AU C1 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M3 N1 OP PB PY RN SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n BOOK: %w(TY A3 A2 A4 AB AD AN AU C3 C4 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RN RP SE SN SP ST T2 TA TI TT UR VL Y2 ER),\n CASE: %w(TY A2 A3 A4 AB AD AN CA CN DA DB DO DP ET KW L1 L4 LA LB M3 N1 NV OP PB PY RN SE SP ST T3 TA TI TT UR VL Y2 ER),\n EBSCO: %w(JN VO)\n }\n end", "def types\n @client.make_request :get, reports_path\n end", "def types_of_service(params, options = {})\n path = \"#{base_uri(params)}/patient_documents\"\n path << current_if_specified_in(params)\n path << '/type_of_service_extension'\n request(path, options).to_hash\n end", "def new\n @military_document_type = MilitaryDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def resource_type\n document_type\n end", "def resource_type\n document_type\n end", "def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def index\n @q = @enterprise.document_types.ransack(params[:q])\n @pagy, @document_types = pagy( @q.result )\n end", "def document_type\n models.map { |m| m.document_type }.compact.presence\n end", "def index\n @practitioner_types = PractitionerType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @practitioner_types }\n end\n end", "def get_supported_file_types\n path = '/v3/miscellaneous/supported-file-types'\n\n headers = {\n 'Content-Type' => 'application/json',\n 'User-Agent' => Config.user_agent\n }\n\n request = Net::HTTP::Get.new(path, headers)\n handle_response(@api_client.request(request), 'get_supported_file_types')\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def show\n @breadcrumb = 'read'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contracting_request_document_type }\n end\n end", "def document_type\n @document_type ||= params['documentType']\n end", "def index\n @identity_document_types = IdentityDocumentType.order(:id).all.paginate(page: params[:page], per_page: 15)\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def recognized_item_types\n\t\t# , 'DocFile', 'DocImage', 'DocPrivate', 'Path'\n\t\t['Article', 'Document', 'Event', 'Group', 'Page', 'Petition', 'Signature', 'User', 'Weblink']\n\tend", "def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def index\n @technotypes = Technotype.all\n\n respond_to do |format|\n format.json { render json: @technotypes, status: 200 }\n end\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @talk_types = TalkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_types }\n end\n end", "def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end", "def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end", "def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end", "def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end", "def index\n @poi_types = PoiType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @poi_types }\n end\n end", "def get_doc_type(item)\n if item.mimeType.blank?\n \"misc\"\n elsif item.mimeType == 'application/pdf'\n \"pdf\"\n elsif item.mimeType == 'application/vnd.google-apps.folder'\n \"folder\"\n elsif item.mimeType == 'application/vnd.google-apps.presentation'\n \"presentation\"\n elsif item.mimeType == 'application/zip'\n \"zip\"\n elsif item.mimeType == \"application/rtf\" || item.mimeType == 'text/plain' || item.mimeType == 'application/msword' || item.mimeType == 'application/vnd.google-apps.document' || item.mimeType.include?('wordprocessing')\n \"document\"\n elsif item.mimeType.include?('spreadsheet') || item.mimeType == 'ms-excel'\n \"spreadsheet\"\n elsif item.mimeType.include?('image') || item.mimeType == 'application/vnd.google-apps.drawing'\n \"image\"\n else\n \"misc\"\n end\n end", "def index\n @publication_types = PublicationType.find(:all, :conditions => {:client_id => session[:client_id]})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @publication_types }\n end\n end", "def index\n @doc_type_am_configurations = DocTypeAmConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @doc_type_am_configurations }\n end\n end", "def document_index_view_types\n vals = configuration.document_index_view_types\n Blacklight::OpenStructWithHashAccess.new.tap do |s|\n view_type_options.each do |k|\n s[k] = vals.include?(k.to_s)\n end\n end\n end", "def view_types(for_select = true) # get the defined view type partials. e.g. views/views/list.html.erb\n fetch_array_for get_view_types, for_select\n end", "def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end", "def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end", "def index\n @task_types = @project.task_types\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @task_types }\n end\n end", "def documents(type: nil) # \"path\", \"id\", \"key\" # TESTED\n body = {\n \"collection\" => @collection,\n \"type\" => type\n }.delete_if{|k,v| v.nil?}.to_json\n request = @@request.merge({ :body => body })\n result = self.class.put(\"/_db/#{@database}/_api/simple/all-keys\", request)\n return result.headers[\"x-arango-async-id\"] if @@async == \"store\"\n return true if @@async\n result = result.parsed_response\n if type.nil?\n @@verbose ? result : result[\"error\"] ? result[\"errorMessage\"] : result[\"result\"].map{|x| value = self.class.get(x).parsed_response; ArangoDocument.new(key: value[\"_key\"], collection: @collection, body: value)}\n else\n @@verbose ? result : result[\"error\"] ? result[\"errorMessage\"] : result[\"result\"]\n end\n end", "def index\n @special_documents = ModifiedDocument.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @special_documents }\n end\n end", "def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end", "def index\n @office_types = OfficeType.all\n end", "def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\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 index\n @pre_print_types = PrePrintType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_print_types }\n end\n end", "def index\n @timerecord_types = TimerecordType.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timerecord_types }\n end\n end", "def index\n\n manage_filter_state\n @contracting_request_document_types = ContractingRequestDocumentType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracting_request_document_types }\n format.js\n end\n end", "def index\n @foundation_types = FoundationType.all\n end", "def index\n @types = Type.all\n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end", "def index\n @legal_record_types = LegalRecordType.all\n end", "def index\n @api_v1_mentoring_types = Api::V1::MentoringType.all\n end", "def index\n @dept_types = DeptType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @dept_types }\n end\n end", "def get_all_outypes\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/\"\n _get(path)\nend", "def set_document_type\n @document_type = @enterprise.document_types.find(params[:id])\n end", "def retrieve \n if !check_auth()\n render text: { \"message\" => \"401 Unauthorized\" }.to_json(), status: :unauthorized\n else\n uri = params[:uri]\n type = params[:type]\n doc = Document.find_by_uri(uri)\n if doc.present?\n case type\n when 'gale'\n render :text => doc.get_corrected_gale_xml()\n when 'text'\n render :text => doc.get_corrected_text()\n when 'tei-a'\n render :text => doc.get_corrected_tei_a(false)\n when 'tei-a-words'\n render :text => doc.get_corrected_tei_a(true)\n when 'original-gale'\n render :text => doc.get_original_gale_xml()\n when 'original-text'\n render :text => doc.get_original_gale_text()\n end\n else\n render text: { \"message\" => \"Document #{uri} not found\" }.to_json(), status: :not_found\n end\n end\n end", "def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end", "def index\n @os_types = OsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @os_types, except: [:desc, :created_at, :updated_at] } \n end\n end", "def index\n @pubtypes = Pubtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pubtypes }\n end\n end", "def index\n @type_people = TypePerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @type_people }\n end\n end", "def index\n @realty_types = RealtyType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @realty_types }\n end\n end", "def index\n @publinktypes = Publinktype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @publinktypes }\n end\n end", "def excercise_types_index_mobile\n\t\t@excercise_types = ExcerciseType.all\n\t\trender json: @excercise_types\n\tend", "def index\n @documents = Document.all\n @document = Document.new\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end", "def get_doc_type(item)\n if item['is_dir']\n \"folder\"\n elsif item['mime_type'].blank?\n \"misc\"\n elsif item['mime_type'] == 'application/pdf'\n \"pdf\"\n elsif item['mime_type'].include?('powerpoint')\n \"presentation\"\n elsif item['mime_type'] == 'application/zip'\n \"zip\"\n elsif item['mime_type'] == \"application/rtf\" || item['mime_type'] == 'text/plain' || item['mime_type'] == 'application/msword' || item['mime_type'].include?('wordprocessing')\n \"document\"\n elsif item['mime_type'].include?('spreadsheet') || item['mime_type'] == 'ms-excel'\n \"spreadsheet\"\n elsif item['mime_type'].include?('image') || item['mime_type'] == 'application/vnd.google-apps.drawing'\n \"image\"\n else\n \"misc\"\n end\n end", "def index\n @admission_types = AdmissionType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admission_types }\n end\n end", "def index\n @discipline_class_exam_types = DisciplineClassExamType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_class_exam_types }\n end\n end", "def index\n # @donor_types = DonorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donor_types }\n end\n end", "def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end", "def index\n # @donation_types = DonationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donation_types }\n end\n end", "def doc_type\n DOC_TYPES[self.TipoDoc.to_sym]\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 type_name\n \"_doc\"\n end", "def index\n @task_types = TaskType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_types }\n end\n end", "def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end", "def document_type\n FileUtility.get_file_type(@file_name)\n end", "def index\n @admin_template_softwares = TemplateSoftware.order('id desc').page(params[:page]).per(10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_template_software_types }\n end\n end", "def list_doc\r\n @query = params[:query]\r\n @pages = []\r\n @docs = []\r\n if request.post? || @query\r\n case @query\r\n when /type:(\\w+)/\r\n case $1\r\n when /^unknown/i\r\n @docs = Document.find_unknown\r\n @pages = Paginator.new(self, @docs.length, PER_PAGE, params[:page])\r\n \r\n page = (params[:page] ||= 1).to_i\r\n offset = (page - 1) * PER_PAGE\r\n @docs = @docs[offset..(offset + PER_PAGE - 1)]\r\n end\r\n else\r\n @pages, @docs = paginate(\r\n :documents,\r\n :conditions => \"path LIKE '%#{@query}%'\",\r\n :per_page => PER_PAGE)\r\n end\r\n end\r\n end", "def index\n @document_statuses = DocumentStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @document_statuses }\n end\n end", "def index\n @slide_types = SlideType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @slide_types }\n end\n end", "def index\n @agendaitemtypes = Agendaitemtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agendaitemtypes }\n end\n end", "def index\n @sample_types = SampleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sample_types }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n format.ext_json { render :json => find_contract_types.to_ext_json(:class => ContractType, :count => ContractType.count(options_from_search(ContractType))) }\n end\n end", "def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_types }\n end\n end", "def index\n #@page_types is the variable containing all instances of the \"pagetype.rb\" model passed to the pagetype view \"index.html.slim\" (project_root/page_types) and is used to populate the page with information about each pagetype using @page_types.each (an iterative loop).\n if current_user && current_user.admin?\n @page_types = PageType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @page_types }\n end\n else\n flash[:danger] = 'Only administrators can modify page_types! <a href=\"' + new_user_session_path + '\">Log in to continue.</a>'\n redirect_to root_path\n end\n end", "def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n end\n end", "def index\n @novelty_types = NoveltyType.all\n end", "def index\n @log_types = LogType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @log_types }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @infraction_types }\n end\n end", "def index\n @event_types = EventType.all\n respond_with @event_types\n end", "def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end", "def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end", "def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end", "def index\n @tipo_documentos = TipoDocumento.all\n end", "def index\n @run_types = RunType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @run_types }\n end\n end" ]
[ "0.700759", "0.6775187", "0.6644835", "0.65929484", "0.6538695", "0.6527967", "0.64848167", "0.636672", "0.6363027", "0.63435507", "0.63435507", "0.6322925", "0.6318144", "0.6280156", "0.627328", "0.6246751", "0.6159099", "0.6106487", "0.6097845", "0.6084949", "0.60723674", "0.6065166", "0.60534054", "0.60351086", "0.60210884", "0.601946", "0.6013234", "0.60065746", "0.6006574", "0.59904593", "0.59780747", "0.59650403", "0.5940523", "0.593406", "0.5926806", "0.5918668", "0.59184456", "0.5907023", "0.58995795", "0.58919513", "0.58695", "0.5862817", "0.5861924", "0.5860156", "0.5858479", "0.584517", "0.5829875", "0.582297", "0.58123475", "0.580248", "0.57925874", "0.5781446", "0.5764819", "0.5762134", "0.5757539", "0.5751064", "0.5750366", "0.5740871", "0.57392", "0.5737016", "0.5735276", "0.57337165", "0.5729683", "0.5725024", "0.57232296", "0.5722489", "0.57184106", "0.5717093", "0.5716252", "0.57106495", "0.56940395", "0.56931704", "0.56926006", "0.56817454", "0.5678028", "0.567697", "0.5676577", "0.5673091", "0.5672581", "0.56582636", "0.56578815", "0.5649399", "0.5632894", "0.5632649", "0.5626852", "0.56179607", "0.5610269", "0.56071", "0.56031096", "0.5600349", "0.5592401", "0.5591341", "0.5581248", "0.5578688", "0.55774695", "0.5576768", "0.5576768", "0.55740005", "0.55697376", "0.5558927" ]
0.7892265
0
GET /military_document_types/1 GET /military_document_types/1.json
def show @military_document_type = MilitaryDocumentType.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @military_document_type } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @military_document_types = MilitaryDocumentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @military_document_types }\n end\n end", "def show\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_type }\n end\n end", "def new\n @military_document_type = MilitaryDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def index\n @documenttypes = Documenttype.all\n end", "def resource_type\n document_type\n end", "def resource_type\n document_type\n end", "def index\n @document_types = DocumentType.all\n @document_types = @document_types.where(description: params[:description]) if params[:description]\n end", "def show\n @breadcrumb = 'read'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contracting_request_document_type }\n end\n end", "def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end", "def document_type\n @document_type ||= params['documentType']\n end", "def document_types\n {\n ORIGINAL: %w(TY ID T1 TI CT A1 A2 AU Y1 PY N1 KW RP SP EP JF JO JA J1 J2 VL IS T2 CY PB U1 U5 T3 N2 SN AV M1 M3 AD UR L1 L2 L3 L4 ER),\n GEN: %w(TY A2 A3 A4 AB AD AN AU C1 C2 C3 C4 C5 C6 C7 C8 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RI RN RP SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n JOUR: %w(TY AB AD AN AU C1 C2 C6 C7 CA CN DA DB DO DP ET J2 KW L1 L4 LA LB IS M2 M3 N1 OP PY RI RN RP SN SP ST T2 TA TI TT UR VL Y2 ER),\n BLOG: %w(TY A2 A3 AB AD AN AU C1 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M3 N1 OP PB PY RN SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n BOOK: %w(TY A3 A2 A4 AB AD AN AU C3 C4 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RN RP SE SN SP ST T2 TA TI TT UR VL Y2 ER),\n CASE: %w(TY A2 A3 A4 AB AD AN CA CN DA DB DO DP ET KW L1 L4 LA LB M3 N1 NV OP PB PY RN SE SP ST T3 TA TI TT UR VL Y2 ER),\n EBSCO: %w(JN VO)\n }\n end", "def document_type\n models.map { |m| m.document_type }.compact.presence\n end", "def set_document_type\n @document_type = @enterprise.document_types.find(params[:id])\n end", "def types_of_service(params, options = {})\n path = \"#{base_uri(params)}/patient_documents\"\n path << current_if_specified_in(params)\n path << '/type_of_service_extension'\n request(path, options).to_hash\n end", "def index\n @practitioner_types = PractitionerType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @practitioner_types }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def type_name\n \"_doc\"\n end", "def index\n @special_documents = ModifiedDocument.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @special_documents }\n end\n end", "def get_doc_type(item)\n if item.mimeType.blank?\n \"misc\"\n elsif item.mimeType == 'application/pdf'\n \"pdf\"\n elsif item.mimeType == 'application/vnd.google-apps.folder'\n \"folder\"\n elsif item.mimeType == 'application/vnd.google-apps.presentation'\n \"presentation\"\n elsif item.mimeType == 'application/zip'\n \"zip\"\n elsif item.mimeType == \"application/rtf\" || item.mimeType == 'text/plain' || item.mimeType == 'application/msword' || item.mimeType == 'application/vnd.google-apps.document' || item.mimeType.include?('wordprocessing')\n \"document\"\n elsif item.mimeType.include?('spreadsheet') || item.mimeType == 'ms-excel'\n \"spreadsheet\"\n elsif item.mimeType.include?('image') || item.mimeType == 'application/vnd.google-apps.drawing'\n \"image\"\n else\n \"misc\"\n end\n end", "def create\n @military_document_type = MilitaryDocumentType.new(params[:military_document_type])\n\n respond_to do |format|\n if @military_document_type.save\n format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' }\n format.json { render :json => @military_document_type, :status => :created, :location => @military_document_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @document_format = DocumentFormat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_format }\n end\n end", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def info\n @document = Document.find(params[:id])\n respond_to do |format|\n format.json { render :json => @document, serializer: Api::Mobile::V2::DynamicDocumentSerializer, root: 'document' }\n end\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def index\n @documents = Document.all\n @document = Document.new\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def index\n @q = @enterprise.document_types.ransack(params[:q])\n @pagy, @document_types = pagy( @q.result )\n end", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def doc_type\n DOC_TYPES[self.TipoDoc.to_sym]\n end", "def create\n @document_type = DocumentType.new(document_type_params)\n\n if @document_type.save\n render :show, status: :created\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def index\n @publication_types = PublicationType.find(:all, :conditions => {:client_id => session[:client_id]})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @publication_types }\n end\n end", "def create\n @document_type = @enterprise.document_types.new(document_type_params)\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido creado satisfactoriamente.' }\n format.json { render :edit, status: :created, location: @document_type }\n else\n format.html { render :new }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def documents(type: nil) # \"path\", \"id\", \"key\" # TESTED\n body = {\n \"collection\" => @collection,\n \"type\" => type\n }.delete_if{|k,v| v.nil?}.to_json\n request = @@request.merge({ :body => body })\n result = self.class.put(\"/_db/#{@database}/_api/simple/all-keys\", request)\n return result.headers[\"x-arango-async-id\"] if @@async == \"store\"\n return true if @@async\n result = result.parsed_response\n if type.nil?\n @@verbose ? result : result[\"error\"] ? result[\"errorMessage\"] : result[\"result\"].map{|x| value = self.class.get(x).parsed_response; ArangoDocument.new(key: value[\"_key\"], collection: @collection, body: value)}\n else\n @@verbose ? result : result[\"error\"] ? result[\"errorMessage\"] : result[\"result\"]\n end\n end", "def document_type\n FileUtility.get_file_type(@file_name)\n end", "def index\n @doc_type_am_configurations = DocTypeAmConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @doc_type_am_configurations }\n end\n end", "def show\n @tipo_documento = TipoDocumento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_documento }\n end\n end", "def document_type=(name)\n @document_type = name\n end", "def document_type=(name)\n @document_type = name\n end", "def types\n @client.make_request :get, reports_path\n end", "def retrieve \n if !check_auth()\n render text: { \"message\" => \"401 Unauthorized\" }.to_json(), status: :unauthorized\n else\n uri = params[:uri]\n type = params[:type]\n doc = Document.find_by_uri(uri)\n if doc.present?\n case type\n when 'gale'\n render :text => doc.get_corrected_gale_xml()\n when 'text'\n render :text => doc.get_corrected_text()\n when 'tei-a'\n render :text => doc.get_corrected_tei_a(false)\n when 'tei-a-words'\n render :text => doc.get_corrected_tei_a(true)\n when 'original-gale'\n render :text => doc.get_original_gale_xml()\n when 'original-text'\n render :text => doc.get_original_gale_text()\n end\n else\n render text: { \"message\" => \"Document #{uri} not found\" }.to_json(), status: :not_found\n end\n end\n end", "def update\n if @document_type.update(document_type_params)\n render :show, status: :ok\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def resource_type_from_document(document)\n resource_type = \"\"\n\n #type_ssi\n #resource_type = document[\"format_ssi\"] unless document[\"format_ssi\"].nil?\n resource_type = document[\"format_ssi\"] || document[\"type_ssi\"]\n resource_type = resource_type.is_a?(Array) ? resource_type.first : resource_type\n end", "def resource_type_from_document(document)\n resource_type = \"\"\n\n #type_ssi\n #resource_type = document[\"format_ssi\"] unless document[\"format_ssi\"].nil?\n resource_type = document[\"format_ssi\"] || document[\"type_ssi\"]\n resource_type = resource_type.is_a?(Array) ? resource_type.first : resource_type\n end", "def index\n @identity_document_types = IdentityDocumentType.order(:id).all.paginate(page: params[:page], per_page: 15)\n end", "def index\n @talk_types = TalkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_types }\n end\n end", "def index\n @documents = Document.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n end\n end", "def get_doc_type(item)\n if item['is_dir']\n \"folder\"\n elsif item['mime_type'].blank?\n \"misc\"\n elsif item['mime_type'] == 'application/pdf'\n \"pdf\"\n elsif item['mime_type'].include?('powerpoint')\n \"presentation\"\n elsif item['mime_type'] == 'application/zip'\n \"zip\"\n elsif item['mime_type'] == \"application/rtf\" || item['mime_type'] == 'text/plain' || item['mime_type'] == 'application/msword' || item['mime_type'].include?('wordprocessing')\n \"document\"\n elsif item['mime_type'].include?('spreadsheet') || item['mime_type'] == 'ms-excel'\n \"spreadsheet\"\n elsif item['mime_type'].include?('image') || item['mime_type'] == 'application/vnd.google-apps.drawing'\n \"image\"\n else\n \"misc\"\n end\n end", "def set_documenttype\n @documenttype = Documenttype.find(params[:id])\n end", "def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def document_type\n instance.class.tire.document_type\n end", "def create\n @document_type = DocumentType.new(params[:document_type])\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to @document_type, notice: 'Document type was successfully created.' }\n format.json { render json: @document_type, status: :created, location: @document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @poi_types = PoiType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @poi_types }\n end\n end", "def index\n @technotypes = Technotype.all\n\n respond_to do |format|\n format.json { render json: @technotypes, status: 200 }\n end\n end", "def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end", "def show\n respond_to do |format|\n if params[:search_detail].present?\n format.json { render :json => @document, serializer: SearchDetailSerializer }\n elsif params[:final_file_key].present?\n format.json { render :json => { \"final_file_key\" => @document.final_file_key }.to_json }\n else\n format.json { render :json => @document, serializer: Api::Mobile::V2::ComprehensiveDocumentSerializer, root: 'document' }\n end\n end\n end", "def document_type name=nil\n @document_type = name || @document_type || implicit(:document_type)\n end", "def document_type\n @document_type ||= @options[:document_type] ||\n __get_class_value(:document_type)\n end", "def show\n \n @document = Document.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n \n end", "def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end", "def show\n @document = Document.find(params[:id])\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def index\n @task_types = @project.task_types\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @task_types }\n end\n end", "def show\n @special_document = ModifiedDocument.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @special_document }\n end\n end", "def set_doc_type\n @doc_type = DocType.find(params[:id])\n end", "def show\n @document_page = DocumentPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_page }\n end\n end", "def document_index_view_types\n vals = configuration.document_index_view_types\n Blacklight::OpenStructWithHashAccess.new.tap do |s|\n view_type_options.each do |k|\n s[k] = vals.include?(k.to_s)\n end\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 recognized_item_types\n\t\t# , 'DocFile', 'DocImage', 'DocPrivate', 'Path'\n\t\t['Article', 'Document', 'Event', 'Group', 'Page', 'Petition', 'Signature', 'User', 'Weblink']\n\tend", "def index\n @publinktypes = Publinktype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @publinktypes }\n end\n end", "def index\n @type_people = TypePerson.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @type_people }\n end\n end", "def index\n @foundation_types = FoundationType.all\n end", "def index\n @document_statuses = DocumentStatus.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @document_statuses }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @shared_document }\n end\n end", "def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end", "def update\n respond_to do |format|\n if @document_type.update(document_type_params)\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido actualizado satisfactoriamente.' }\n format.json { render :edit, status: :ok, location: @document_type }\n else\n format.html { render :edit }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def documents\n return bad_request unless params[:id] and request.format.json? || request.format.js? || request.format.text?\n return not_found unless current_document\n opts = {:access => true, :sections => true, :annotations => true, :data => true}\n if current_account\n opts[:account] = current_account\n opts[:allowed_to_edit] = current_account.allowed_to_edit?(current_document)\n opts[:allowed_to_review] = current_account.reviews?(current_document)\n end\n @response = {'document' => current_document.canonical(opts)}\n respond_to do |format|\n format.text do\n direct = [PRIVATE, ORGANIZATION, EXCLUSIVE].include? current_document.access\n redirect_to(current_document.full_text_url(direct: direct))\n end\n format.json { render_cross_origin_json }\n format.js { render_cross_origin_json }\n end\n end", "def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def show\n @document = Document.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document }\n end\n end", "def index\n @pre_print_types = PrePrintType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_print_types }\n end\n end", "def show\n @apprenticeship_type = ApprenticeshipType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apprenticeship_type }\n format.xml { render xml: @apprenticeship_type }\n # format.docx { render word: @apprenticeship_type }\n # file = Rails.root.join(\"public\",\"resources\", \"test.docx\");\n format.docx { send_file @apprenticeship_type.render_to_word, :disposition => 'attachment' }\n # format.docx { send_data @apprenticeship_type.render_to_word(), :disposition => 'attachment' }\n\n # \"#{RAILS_ROOT}/public/resources/newdoc.docx\",\n # :filename=> \"newdoc.docx\",\n # :type=>mime_type)\n\n end\n end", "def create\n @documenttype = Documenttype.new(documenttype_params)\n\n respond_to do |format|\n if @documenttype.save\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully created.' }\n format.json { render :show, status: :created, location: @documenttype }\n else\n format.html { render :new }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def getData type\n\t\t# get collection\n\t\tthings = @@db.collection(\"saves\")\n\t\t# find everything in collection\n\t\tcursor = things.find()\n\t\t\n\t\t# go through all documents in collection and display data\n\t\tcursor.each { |row| \n\t\t\tif(row[type] != nil)\n\t\t\t\tfrm = row[\"form\"]\n\t\t\t\tif(frm == nil)\n\t\t\t\t\tfrm = \"N/A\"\n\t\t\t\tend\n\t\t\t\tputs row[type] + \" || Form: \" + frm\n\t\t\tend\n\t\t} \n\tend", "def get_supported_file_types\n path = '/v3/miscellaneous/supported-file-types'\n\n headers = {\n 'Content-Type' => 'application/json',\n 'User-Agent' => Config.user_agent\n }\n\n request = Net::HTTP::Get.new(path, headers)\n handle_response(@api_client.request(request), 'get_supported_file_types')\n end", "def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end", "def index\n @pubtypes = Pubtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pubtypes }\n end\n end", "def update\n respond_to do |format|\n if @documenttype.update(documenttype_params)\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully updated.' }\n format.json { render :show, status: :ok, location: @documenttype }\n else\n format.html { render :edit }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @documentotipo = Documentotipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @documentotipo }\n end\n end", "def index\n @legal_record_types = LegalRecordType.all\n end", "def new\n @document_format = DocumentFormat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_format }\n end\n end", "def index\n @office_types = OfficeType.all\n end", "def get(type_name)\n @types ||= {}\n register_default unless @types['document']\n\n type = @types[type_name]\n raise RuntimeError, \"Unknown Type #{type} (know #{@types.keys.join(',')})\" unless type\n\n type\n end", "def index\n @admission_types = AdmissionType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admission_types }\n end\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" ]
[ "0.7853476", "0.7101261", "0.68319607", "0.67287123", "0.66368157", "0.66021055", "0.66021055", "0.652735", "0.65189695", "0.6496666", "0.64009976", "0.6394475", "0.63475245", "0.6244297", "0.61611617", "0.60895705", "0.60724723", "0.6066076", "0.6055568", "0.60470915", "0.6043988", "0.6025035", "0.6024943", "0.60129684", "0.6003196", "0.5996058", "0.5985012", "0.59611356", "0.59511906", "0.59479094", "0.5947855", "0.5939916", "0.593001", "0.59088683", "0.59044415", "0.5900077", "0.5897207", "0.5895637", "0.5895637", "0.5891908", "0.5890947", "0.5878408", "0.5877975", "0.5877975", "0.58729744", "0.5868518", "0.58602256", "0.5839022", "0.58309925", "0.58178544", "0.58107775", "0.5807119", "0.5793425", "0.5774747", "0.5770887", "0.5769942", "0.57572985", "0.5747967", "0.5738243", "0.56810987", "0.5679998", "0.5678787", "0.567774", "0.56752133", "0.5667278", "0.56573784", "0.56559837", "0.5651617", "0.56486094", "0.5643191", "0.5640597", "0.563973", "0.5638917", "0.5638907", "0.5631786", "0.56309664", "0.5630537", "0.5627662", "0.5625441", "0.5625441", "0.5625441", "0.5625441", "0.5625441", "0.5625441", "0.5625441", "0.5625416", "0.5624383", "0.56223106", "0.56218123", "0.5616184", "0.56152207", "0.5614542", "0.5604748", "0.56000566", "0.55977684", "0.55942863", "0.5594245", "0.5592167", "0.558889", "0.5587387" ]
0.7510824
1
GET /military_document_types/new GET /military_document_types/new.json
def new @military_document_type = MilitaryDocumentType.new respond_to do |format| format.html # new.html.erb format.json { render :json => @military_document_type } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end", "def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def create\n @military_document_type = MilitaryDocumentType.new(params[:military_document_type])\n\n respond_to do |format|\n if @military_document_type.save\n format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' }\n format.json { render :json => @military_document_type, :status => :created, :location => @military_document_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @breadcrumb = 'create'\n @contracting_request_document_type = ContractingRequestDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contracting_request_document_type }\n end\n end", "def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n \n end", "def create\n @document_type = DocumentType.new(params[:document_type])\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to @document_type, notice: 'Document type was successfully created.' }\n format.json { render json: @document_type, status: :created, location: @document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end", "def new\n @special_document = ModifiedDocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @special_document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def create\n @document_type = @enterprise.document_types.new(document_type_params)\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido creado satisfactoriamente.' }\n format.json { render :edit, status: :created, location: @document_type }\n else\n format.html { render :new }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @collection_type = CollectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_type }\n end\n end", "def new\r\n @document = Document.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @document }\r\n end\r\n end", "def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end", "def new\n @ctype = Ctype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ctype }\n end\n end", "def new\n @page_type = PageType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_type }\n end\n end", "def new\n @tipo_documento = TipoDocumento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_documento }\n end\n end", "def new\n @document_format = DocumentFormat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_format }\n end\n end", "def new\n @document_page = DocumentPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_page }\n end\n end", "def new\n @fieldtype = Fieldtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fieldtype }\n end\n end", "def new\n @publication_type = PublicationType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @publication_type }\n end\n end", "def create\n @documenttype = Documenttype.new(documenttype_params)\n\n respond_to do |format|\n if @documenttype.save\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully created.' }\n format.json { render :show, status: :created, location: @documenttype }\n else\n format.html { render :new }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @resource_type = ResourceType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end", "def new\n #@document = Document.new(params[:type] ? {:type => params[:type]} : {})\n #@document = doc.becomes params[:type].classify.constantize if %w(Paper Email PhoneCall Visit).include? params[:type] \n @document = params[:type].constantize.new if %w(Paper Email PhoneCall Visit).include? params[:type] \n #@document.set_user_info session[:user]\n @document.date = DateTime.now\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def create\n @document_type = DocumentType.new(document_type_params)\n\n if @document_type.save\n render :show, status: :created\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def new\n @pubtype = Pubtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pubtype }\n end\n end", "def new\n @status = Status.new\n @status.build_document\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status }\n end\n end", "def new\n @document = Document.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n format.json { render :json => @document }\n end\n end", "def new\n @paper_type = PaperType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper_type }\n end\n end", "def new\n @poi_type = PoiType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poi_type }\n end\n end", "def new\n @girltype = Girltype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @girltype }\n end\n end", "def new\n @documentotipo = Documentotipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documentotipo }\n end\n end", "def new\n @talktype = Talktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talktype }\n end\n end", "def new\n @poi_type = PoiType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poi_type }\n end\n end", "def new\n @talk_type = TalkType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk_type }\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 @document = Document.new\n @keyfinding = Keyfinding.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @identifier_type = IdentifierType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @identifier_type }\n end\n end", "def new\n @documento = Documento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documento }\n end\n end", "def new\n@documento = Documento.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documento }\n end\n end", "def new\n @type_person = TypePerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_person }\n end\n end", "def new\n @info_type = InfoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @info_type }\n end\n end", "def new\n @all_field_type = AllFieldType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @all_field_type }\n end\n end", "def new\n @itype = Itype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itype }\n end\n end", "def new\n if current_user && current_user.admin?\n @page_type = PageType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_type }\n end\n \n else\n flash[:danger] = 'Only administrators can modify page_types! <a href=\"' + new_user_session_path + '\">Log in to continue.</a>'\n redirect_to root_path\n end\n end", "def create\n @breadcrumb = 'create'\n @contracting_request_document_type = ContractingRequestDocumentType.new(params[:contracting_request_document_type])\n @contracting_request_document_type.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.save\n format.html { redirect_to @contracting_request_document_type, notice: t('activerecord.attributes.contracting_request_document_type.create') }\n format.json { render json: @contracting_request_document_type, status: :created, location: @contracting_request_document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\n \t\n @companydocument = Companydocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @companydocument }\n end\n\n end", "def new\n #@current_user = User.find(session[:user_id])\n #@document = @current_user.documents.new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def new\n @space = Space.where(:wiki_name => params[:space_id])[0]\n @document = @space.documents.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n format.json { render :json => @document.to_json }\n end\n end", "def new\n @breadcrumb = 'create'\n @entity_type = EntityType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_type }\n end\n end", "def new\n @ftype = Ftype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ftype }\n end\n end", "def new\n @crate_type = CrateType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @crate_type }\n end\n end", "def new\n @tasktype = Tasktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tasktype }\n end\n end", "def new\n @types_of_apprenticeship = TypesOfApprenticeship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end", "def new\n @edited << 'new'\n @expanded << 'new'\n\n respond_to do |format|\n format.html { render template: 'shared/new' }\n format.js { render 'reference_type' }\n format.json { render json: @reference_type }\n end\n end", "def new\n @reform_type = ReformType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reform_type }\n end\n end", "def new\n @observation_type = ObservationType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation_type }\n end\n end", "def new\n @title = t('view.print_job_types.new_title')\n @print_job_type = PrintJobType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @print_job_type }\n end\n end", "def new\n @daytype = Daytype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daytype }\n end\n end", "def new\n @rtype = Rtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rtype }\n end\n end", "def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @act_type = ActType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @act_type }\n end\n end", "def new\n @gl_type = GlType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gl_type }\n end\n end", "def new\n @reflection = Reflection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reflection }\n end\n end", "def new\n @paper = Paper.new\n @document = @paper.documents.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper }\n end\n end", "def create\n @identity_document_type = IdentityDocumentType.new(identity_document_type_params)\n\n respond_to do |format|\n if @identity_document_type.save\n format.html { redirect_to @identity_document_type, notice: 'Tipo Documento criado com sucesso.' }\n format.json { render :show, status: :created, location: @identity_document_type }\n else\n format.html { render :new }\n format.json { render json: @identity_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @page = Page.new\n\t\t@types = Type.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @incident_type = IncidentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_type }\n end\n end", "def new\n @content_type = ContentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_type }\n end\n end", "def new\n @content_type = ContentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_type }\n end\n end", "def new\n @breadcrumb = 'create'\n @timerecord_type = TimerecordType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @timerecord_type }\n end\n end", "def client_new_doc\n data = params\n cid = current_company.id\n @return_path = data[:return_path]\n @return_path = request.headers['HTTP_REFERER'] if @return_path.blank?\n @matter = Matter.scoped_by_company_id(cid).find(params[:id])\n @document_home = DocumentHome.new\n @document = @document_home.documents.build\n @mapable_id = data[:id]\n @mapable_type = 'Matter'\n @task= MatterTask.scoped_by_company_id(cid).find(data[:task_id] ) if data[:task_id]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document_home }\n end\n end", "def new\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = EntityType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_type }\n end\n end", "def new\n @publinktype = Publinktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @publinktype }\n end\n end", "def new\n @document = Document.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def new\n @category_type = CategoryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_type }\n end\n end", "def new\n @tdoc = Tdoc.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tdoc }\n end\n end", "def new\n @media_type = MediaType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @media_type }\n end\n end", "def new\n @entry_type = EntryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry_type }\n end\n end", "def new\n @breadcrumb = 'create'\n @tariff_type = TariffType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tariff_type }\n end\n end", "def new\n @research = Research.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @research }\n end\n end", "def new\n @breadcrumb = 'create'\n @invoice_type = InvoiceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invoice_type }\n end\n end", "def new\n @office = Office.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @office }\n end\n end", "def new\n @trtype = Trtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trtype }\n end\n end", "def new\n @model_type = ModelType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @model_type }\n end\n end", "def new\n @discipline_type = DisciplineType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @discipline_type }\n end\n end", "def new\n @election_type = ElectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @election_type }\n end\n end", "def create\n @doc_type = DocType.new(doc_type_params)\n\n respond_to do |format|\n if @doc_type.save\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.create', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :created, location: @doc_type }\n else\n format.html { render :new }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @sample_type = SampleType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sample_type }\n end\n end", "def new\n @breadcrumb = 'create'\n @reading_type = ReadingType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reading_type }\n end\n end", "def new\n @client_type = ClientType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_type }\n end\n end", "def new\n @document_status = DocumentStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document_status }\n end\n end", "def new\n @newtype = params[:newtype]\n @ptbudget = Ptbudget.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ptbudget }\n end\n end" ]
[ "0.78218365", "0.76295704", "0.74823594", "0.725441", "0.71714187", "0.7168285", "0.7132817", "0.69822234", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.69702554", "0.6969036", "0.6951032", "0.6944768", "0.6928677", "0.6914748", "0.6887758", "0.6879125", "0.68565357", "0.684114", "0.6833804", "0.6787068", "0.67813563", "0.6767153", "0.6749827", "0.67493594", "0.67314297", "0.6701289", "0.66924006", "0.6690508", "0.66883767", "0.668106", "0.6676976", "0.6655471", "0.66407037", "0.66308534", "0.66294056", "0.6628598", "0.66134614", "0.6608463", "0.66060036", "0.66054356", "0.6585719", "0.6581094", "0.6576926", "0.65708154", "0.65691596", "0.6560284", "0.6556166", "0.6552854", "0.65428984", "0.6538523", "0.65279996", "0.65229255", "0.652072", "0.6519696", "0.65157056", "0.65155023", "0.65152574", "0.650753", "0.6502237", "0.6499233", "0.6489576", "0.64863557", "0.64808923", "0.64792526", "0.64690137", "0.64667463", "0.646292", "0.64627385", "0.64627385", "0.6456103", "0.64529526", "0.64508414", "0.64457166", "0.6432097", "0.6428468", "0.6424271", "0.64193636", "0.6410207", "0.64099914", "0.6409205", "0.64043725", "0.64034486", "0.63941514", "0.6393992", "0.6389048", "0.6386752", "0.6378639", "0.63780004", "0.6376864", "0.63740075", "0.63655376", "0.636441" ]
0.7906374
0
POST /military_document_types POST /military_document_types.json
def create @military_document_type = MilitaryDocumentType.new(params[:military_document_type]) respond_to do |format| if @military_document_type.save format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' } format.json { render :json => @military_document_type, :status => :created, :location => @military_document_type } else format.html { render :action => "new" } format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @document_type = @enterprise.document_types.new(document_type_params)\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido creado satisfactoriamente.' }\n format.json { render :edit, status: :created, location: @document_type }\n else\n format.html { render :new }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document_type = DocumentType.new(params[:document_type])\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to @document_type, notice: 'Document type was successfully created.' }\n format.json { render json: @document_type, status: :created, location: @document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @military_document_types = MilitaryDocumentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @military_document_types }\n end\n end", "def create\n @document_type = DocumentType.new(document_type_params)\n\n if @document_type.save\n render :show, status: :created\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def document_types\n {\n ORIGINAL: %w(TY ID T1 TI CT A1 A2 AU Y1 PY N1 KW RP SP EP JF JO JA J1 J2 VL IS T2 CY PB U1 U5 T3 N2 SN AV M1 M3 AD UR L1 L2 L3 L4 ER),\n GEN: %w(TY A2 A3 A4 AB AD AN AU C1 C2 C3 C4 C5 C6 C7 C8 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RI RN RP SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n JOUR: %w(TY AB AD AN AU C1 C2 C6 C7 CA CN DA DB DO DP ET J2 KW L1 L4 LA LB IS M2 M3 N1 OP PY RI RN RP SN SP ST T2 TA TI TT UR VL Y2 ER),\n BLOG: %w(TY A2 A3 AB AD AN AU C1 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M3 N1 OP PB PY RN SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n BOOK: %w(TY A3 A2 A4 AB AD AN AU C3 C4 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RN RP SE SN SP ST T2 TA TI TT UR VL Y2 ER),\n CASE: %w(TY A2 A3 A4 AB AD AN CA CN DA DB DO DP ET KW L1 L4 LA LB M3 N1 NV OP PB PY RN SE SP ST T3 TA TI TT UR VL Y2 ER),\n EBSCO: %w(JN VO)\n }\n end", "def create\n @documenttype = Documenttype.new(documenttype_params)\n\n respond_to do |format|\n if @documenttype.save\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully created.' }\n format.json { render :show, status: :created, location: @documenttype }\n else\n format.html { render :new }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def documenttype_params\n params.require(:documenttype).permit(:name)\n end", "def doc_type_params\n params.require(:doc_type).permit(:name)\n end", "def new\n @military_document_type = MilitaryDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def document_type_params\n params.require(:document_type).permit(:name, :enterprise_id)\n end", "def document_type_params\n params.require(:document_type).permit(:description)\n end", "def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end", "def create\n @identity_document_type = IdentityDocumentType.new(identity_document_type_params)\n\n respond_to do |format|\n if @identity_document_type.save\n format.html { redirect_to @identity_document_type, notice: 'Tipo Documento criado com sucesso.' }\n format.json { render :show, status: :created, location: @identity_document_type }\n else\n format.html { render :new }\n format.json { render json: @identity_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @documenttypes = Documenttype.all\n end", "def set_document_type\n @document_type = @enterprise.document_types.find(params[:id])\n end", "def document_type_params\n params.require(:document_type).permit(:description, :deleted_at)\n end", "def document_type\n @document_type ||= params['documentType']\n end", "def document_type=(name)\n @document_type = name\n end", "def document_type=(name)\n @document_type = name\n end", "def create\n @doc_type = DocType.new(doc_type_params)\n\n respond_to do |format|\n if @doc_type.save\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.create', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :created, location: @doc_type }\n else\n format.html { render :new }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def resource_type\n document_type\n end", "def resource_type\n document_type\n end", "def create_documents(type_identifier, events); end", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def create\n @breadcrumb = 'create'\n @contracting_request_document_type = ContractingRequestDocumentType.new(params[:contracting_request_document_type])\n @contracting_request_document_type.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.save\n format.html { redirect_to @contracting_request_document_type, notice: t('activerecord.attributes.contracting_request_document_type.create') }\n format.json { render json: @contracting_request_document_type, status: :created, location: @contracting_request_document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def financial_document_type_params\n params.require(:financial_document_type).permit({chapter_ids: []}, :name, :description, :system_doc_type)\n end", "def create\n @document = Document.new(params[:document])\n\n #lessons semester prof doc_type\n i = Document.where(\"lesson_id = ? AND semester_id = ? AND prof_id = ? AND doc_type_id = ?\", @document.lesson.id, @document.semester.id, @document.prof.id, @document.doc_type.id).size\n \n #name = docType_prof_fach_sem_zahl\n\t@document.name = (@document.doc_type.name+'_'+@document.prof.name+'_'+@document.lesson.name+'_'+@document.semester.name+'_'+i.to_s).parameterize\n\t$upName = @document.name\n\t\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_params\n params.require(:document).permit(:doc,:documentable_id, :documentable_type)\n end", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def create\n @procedure_type = ProcedureType.new(procedure_type_params)\n @documents = Document.all\n @procedure_type.name= @procedure_type.name.upcase\n respond_to do |format|\n if @procedure_type.save\n format.html { redirect_to procedure_types_path, notice: 'Tipo de tramite registrado exitosamente' }\n format.json { render :show, status: :created, location: @procedure_type }\n else\n format.html { render :new }\n format.json { render json: @procedure_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_document_all_types client, s, types\n log.debug \"Will update document #{s} for types #{types}\"\n\n if types\n types.each do |type|\n log.debug \"Updating document #{s} for type #{type}\"\n indexes = Indexes.instance.get_indexes type\n indexes.each do |key, index|\n allowed_groups = index[:allowed_groups]\n log.debug \"Got allowed groups for updated_document_all_types #{allowed_groups}\"\n rdf_type = settings.type_definitions[type][\"rdf_type\"]\n log.debug \"Got RDF type for updated_document_all_types #{rdf_type}\"\n if is_authorized s, rdf_type, allowed_groups\n log.debug \"Our current index knows that #{s} is of type #{rdf_type} based on allowed groups #{allowed_groups}\"\n properties = settings.type_definitions[type][\"properties\"]\n document, attachment_pipeline =\n fetch_document_to_index uri: s, properties: properties,\n allowed_groups: index[:allowed_groups]\n\n document_for_reporting = document.clone\n document_for_reporting[\"data\"] = document_for_reporting[\"data\"] ? document_for_reporting[\"data\"].length : \"none\"\n\n log.debug \"Fetched document to index is #{document_for_reporting}\"\n\n # TODO what is uuid supposed to be here? We abstract its meaning to be get_uuid(s) but are not sure\n uuid = get_uuid(s)\n\n if attachment_pipeline\n log.debug \"Document to update has attachment pipeline\"\n begin\n # client.upload_attachment index, uuid, attachment_pipeline, document\n client.upload_attachment index[:index], uuid, attachment_pipeline, document\n log.debug \"Managed to upload attachment for #{s}\"\n rescue\n log.warn \"Could not upload attachment #{s}\"\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n log.info \"Not Authorized.\"\n end\n end\n end\n end\nend", "def set_documenttype\n @documenttype = Documenttype.find(params[:id])\n end", "def index\n @document_types = DocumentType.all\n @document_types = @document_types.where(description: params[:description]) if params[:description]\n end", "def types_of_service(params, options = {})\n path = \"#{base_uri(params)}/patient_documents\"\n path << current_if_specified_in(params)\n path << '/type_of_service_extension'\n request(path, options).to_hash\n end", "def identity_document_type_params\n params.require(:identity_document_type).permit(:description)\n end", "def create\n @document = current_user.documents.build(document_params)\n get_identification_type\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_types\n\t[]\nend", "def create_types\n\t[]\nend", "def create\n\n @object_type = ObjectType.new(params[:object_type].except(:rows, :columns))\n\n if params[:object_type][:handler] == 'collection'\n @object_type.rows = params[:object_type][:rows]\n @object_type.columns = params[:object_type][:columns]\n end\n\n respond_to do |format|\n if @object_type.save\n format.html { redirect_to object_types_url, notice: \"Object type #{@object_type.name} was successfully created.\" }\n format.json { render json: @object_type, status: :created, location: @object_type }\n else\n format.html { render action: 'new', layout: 'aq2-plain' }\n format.json { render json: @object_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_doc_type\n @doc_type = DocType.find(params[:id])\n end", "def create_types\n\t\t[]\n\tend", "def create_types\n\t\t[]\n\tend", "def validate_document_support!\n return if ['rest-json', 'json'].include?(@service.protocol)\n\n # Check all shapes and raise if any are Document types\n @service.api.fetch('shapes', {}).each do |name, shape|\n if shape['type'] == 'structure' && shape['document']\n raise \"Shape #{name} is a document type. Document types are only supported in json protocols.\"\n end\n end\n end", "def document_type name=nil\n @document_type = name || @document_type || implicit(:document_type)\n end", "def create\n @doi_type = DoiType.new(doi_type_params)\n\n respond_to do |format|\n if @doi_type.save\n format.html { \n flash[:notice] = 'El tipo de documento de identidad se creó satisfactoriamente.'\n redirect_to doi_types_path\n }\n format.json { render :show, status: :created, location: @doi_type }\n else\n format.html { render :new }\n format.json { render json: @doi_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @document_type.update(document_type_params)\n render :show, status: :ok\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end", "def show\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def update\n respond_to do |format|\n if @document_type.update(document_type_params)\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido actualizado satisfactoriamente.' }\n format.json { render :edit, status: :ok, location: @document_type }\n else\n format.html { render :edit }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_documento = TipoDocumento.new(params[:tipo_documento])\n\n respond_to do |format|\n if @tipo_documento.save\n format.html { redirect_to @tipo_documento, notice: 'Tipo documento was successfully created.' }\n format.json { render json: @tipo_documento, status: :created, location: @tipo_documento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\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 recognized_item_types\n\t\t# , 'DocFile', 'DocImage', 'DocPrivate', 'Path'\n\t\t['Article', 'Document', 'Event', 'Group', 'Page', 'Petition', 'Signature', 'User', 'Weblink']\n\tend", "def type_name\n \"_doc\"\n end", "def new\n #@document = Document.new(params[:type] ? {:type => params[:type]} : {})\n #@document = doc.becomes params[:type].classify.constantize if %w(Paper Email PhoneCall Visit).include? params[:type] \n @document = params[:type].constantize.new if %w(Paper Email PhoneCall Visit).include? params[:type] \n #@document.set_user_info session[:user]\n @document.date = DateTime.now\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document }\n end\n end", "def document_params\n params.require(:document).permit(:doc_type, :name, :patient_id, images: [])\n end", "def create\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = @collection.entity_types.new(params[:entity_type])\n\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'Type was successfully created.' }\n format.json { render json: @entity_type, status: :created, location: @entity_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_params\n params.require(:document).permit(:name, :document_type, :document_url, :intake_code)\n end", "def create\n @office_type = OfficeType.new(office_type_params)\n\n respond_to do |format|\n if @office_type.save\n format.html { redirect_to @office_type, notice: 'Office type was successfully created.' }\n format.json { render :show, status: :created, location: @office_type }\n else\n format.html { render :new }\n format.json { render json: @office_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document = params[:type].constantize.new(params[params[:type].underscore.to_sym], :without_protection => false)\\\n if %w(Paper Email PhoneCall Visit ExternalPaper).include? params[:type] \n @document.set_user_info session[:user]\n #tct_logger.info \"@document.inspect: #{@document.inspect}\\n params.inspect: #{params.inspect}\"\n @document.send_now = true if params[:send_now] # only for emails\n #@document.files.first.file = params[:file] if params[:type] == 'Email'\n\n respond_to do |format|\n if @document.save\n logger.info \" --- #{params.inspect}\" if @document.type == 'Email'\n logger.info \" --- #{@document.inspect}\" if @document.type == 'Email'\n flash[:notice] = \"#{@document.type} wurde gespeichert.\"\n flash[@document.sent ? :notice : :warning] = \"Email wurde #{@document.sent ? '' : 'NICHT'} versendet.\" if @document.type == 'Email'\n format.html { redirect_to(customers_url) }\n format.xml { render :xml => @document, :status => :created, :location => @document }\n else\n tct_logger.info \"!!! Could not be saved! --- #{params.inspect}\"\n tct_logger.info \" --- #{@document.inspect}\"\n format.html { render :action => \"new\", :controller => \"#{@document.main_type.downcase}s\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def document_type\n models.map { |m| m.document_type }.compact.presence\n end", "def update\n respond_to do |format|\n if @documenttype.update(documenttype_params)\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully updated.' }\n format.json { render :show, status: :ok, location: @documenttype }\n else\n format.html { render :edit }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_params\n params.require(:document).permit(:title, :description, :file_path, :issue_date, :due_date, :folder_id, :content_type_id)\n end", "def create\n @document = Document.new(params[:document])\n @document.stuffing_data = []\n @document.user = current_user\n\n #Hack for now - add all column keys to primary keys for search\n @document.stuffing_primary_keys = get_data_colnames(@document.stuffing_data)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render json: @document, status: :created, location: @document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def type\n document._type = document.class.name if typed?\n end", "def document_type\n FileUtility.get_file_type(@file_name)\n end", "def create\n @has_document = HasDocument.new(has_document_params)\n \n respond_to do |format|\n if @has_document.save\n format.html { redirect_to @has_document, notice: 'Has document was successfully created.' }\n format.json { render :show, status: :created, location: @has_document }\n else\n format.html { render :new }\n format.json { render json: @has_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_params\n params.require(:document).permit(:language, :doc_type, :image)\n end", "def document_params\n params.require(:document)\n .permit(:doc_type, :doc_number, :doc_expire, :upload)\n end", "def create_break_type(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/labor/break-types',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def update\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n if @military_document_type.update_attributes(params[:military_document_type])\n format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @modified_document = ModifiedDocument.new(modified_document_params)\n \n if @modified_document.save\n render json: @modified_document, status: :ok\n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def document_type\n @document_type ||= @options[:document_type] ||\n __get_class_value(:document_type)\n end", "def document_type name=nil\n @document_type = name if name\n @document_type || klass.model_name.to_s.underscore\n end", "def doc_type\n DOC_TYPES[self.TipoDoc.to_sym]\n end", "def add_document(birthdate:, first_name:, last_name:, street:, postal_code:, country_code:, document_type:, document_value:)\n data = {\n doc: {\n birth_day: birthdate.day,\n birth_month: birthdate.month,\n birth_year: birthdate.year,\n name_first: first_name,\n name_last: last_name,\n address_street1: street,\n address_postal_code: postal_code,\n address_country_code: country_code,\n document_type: document_type,\n document_value: document_value\n }\n }\n\n @client.patch(path: \"/users/#{@user_id}\", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)\n end", "def create\n @entity_type = EntityType.new(entity_type_params)\n @entity_type.collection_id = @collection.id\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully created.' }\n format.json { render :show, status: :created, location: @entity_type }\n else\n format.html { render :new }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tipo_documento = TipoDocumento.new(tipo_documento_params)\n\n respond_to do |format|\n if @tipo_documento.save\n format.html { redirect_to @tipo_documento, notice: 'Se ha creado un nuevo Tipo de documento.' }\n format.json { render :show, status: :created, location: @tipo_documento }\n else\n format.html { render :new }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def create\n @valid_type = ValidType.new(valid_type_params)\n @valid_type.typed = true\n\n respond_to do |format|\n if @valid_type.save\n format.html { redirect_to valid_types_path, notice: 'Entity Type was successfully created.' }\n format.json { render :show, status: :created, location: @valid_type }\n else\n format.html { render :new }\n format.js { render :new }\n format.json { render json: @valid_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n batch_id = params[:batch_id]\n if batch_id.blank?\n ub = UploadBatch.create!\n batch_id = ub.id\n end\n\n unless @collection.available?(@current_user)\n if request.format.json?\n render json: {error: \"You're not authorized\"}, status: 401\n return\n else\n redirect_to \"/\", error: \"Cannot access the document\"\n return\n end\n end\n \n logger.debug(params.inspect)\n if params[:file].present?\n error, dids = @collection.upload_from_file(params[:file], batch_id, params[:replace])\n elsif params[:pmid].present?\n error, dids = @collection.upload_from_pmids(params[:pmid], batch_id, params[:id_map])\n end\n logger.debug(\"RET === #{error.inspect}\")\n \n respond_to do |format|\n if error.nil?\n format.html { redirect_to @collection, notice: 'Document was successfully created.' }\n format.json { render json: {ok: true, ids: dids, batch_id: batch_id}, status: :created }\n else\n format.html { redirect_to @collection, alert: 'Failed to create document (PMID: does not exist)' }\n format.json { render json: {error: error}, status: :unprocessable_entity }\n end\n end\n end", "def get_doc_type(item)\n if item.mimeType.blank?\n \"misc\"\n elsif item.mimeType == 'application/pdf'\n \"pdf\"\n elsif item.mimeType == 'application/vnd.google-apps.folder'\n \"folder\"\n elsif item.mimeType == 'application/vnd.google-apps.presentation'\n \"presentation\"\n elsif item.mimeType == 'application/zip'\n \"zip\"\n elsif item.mimeType == \"application/rtf\" || item.mimeType == 'text/plain' || item.mimeType == 'application/msword' || item.mimeType == 'application/vnd.google-apps.document' || item.mimeType.include?('wordprocessing')\n \"document\"\n elsif item.mimeType.include?('spreadsheet') || item.mimeType == 'ms-excel'\n \"spreadsheet\"\n elsif item.mimeType.include?('image') || item.mimeType == 'application/vnd.google-apps.drawing'\n \"image\"\n else\n \"misc\"\n end\n end", "def update\n respond_to do |format|\n if @doc_type.update(doc_type_params)\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.update', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :ok, location: @doc_type }\n else\n format.html { render :edit }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_type }\n end\n end", "def document_params\n params.require(:document).permit(:name, :file, :department_id, :attachable_id, :attachable_type)\n end", "def create\n @receipt_item_type = current_account.receipt_item_types.create(receipt_item_type_params)\n if @receipt_item_type\n respond_with @receipt_item_type do |format|\n format.json { render :json => current_account.receipt_item_types.include_names.find(@receipt_item_type.id) }\n end\n else\n respond_with @receipt_item_type\n end\n end", "def document_params\n params.require(:document).permit(:contract_id, :doc_type, :type, :attachment, :attachment_cache, :expiration_date, :name, :reminder_sent_date, :days_to_reminder)\n end", "def document_index_view_types\n vals = configuration.document_index_view_types\n Blacklight::OpenStructWithHashAccess.new.tap do |s|\n view_type_options.each do |k|\n s[k] = vals.include?(k.to_s)\n end\n end\n end", "def create\n Rails.logger.info \"params: #{params}\"\n\n @trial_document = TrialDocument.new(trial_document_params)\n\n respond_to do |format|\n if @trial_document.save\n if params[:replaced_doc_id].present?\n # TrialDocument.destroy(params[:replaced_doc_id]) # hard delete the replaced document\n Rails.logger.info \"replaced doc id: #{params[:replaced_doc_id]}\"\n replaced_doc = TrialDocument.find(params[:replaced_doc_id])\n # replaced document is flagged as inactive except the document_type is \"Other Document\"\n replaced_doc.update_attribute('status', 'inactive') # unless params[:document_type].include? \"Other\"\n end\n\n format.html { redirect_to @trial_document, notice: 'Trial document was successfully created.' }\n format.json { render :show, status: :created, location: @trial_document }\n else\n format.html { render :new }\n format.json { render json: @trial_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @special_document = ModifiedDocument.new(params[:special_document])\n\n respond_to do |format|\n if @special_document.save\n format.html { redirect_to @special_document, notice: 'Special document was successfully created.' }\n format.json { render json: @special_document, status: :created, location: @special_document }\n else\n format.html { render action: \"new\" }\n format.json { render json: @special_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_params\n params.require(:document).permit(:document_type, :screenshot, :original, :employee_id, :shop_id, :brand_shop_id, :brand_discount, :status, :file_name)\n end", "def new\n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @documents.map{|document| document.to_jq_upload } }\n \n end\n end", "def indexDocument(index, type, document, id)\n self.class.post(\"#{index}/#{type}/#{id}\", :body => document.to_json)\n end", "def create\n @page_type = PageType.new(params[:page_type])\n\n respond_to do |format|\n if @page_type.save\n format.html { redirect_to @page_type, notice: 'Page type was successfully created.' }\n format.json { render json: @page_type, status: :created, location: @page_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @document_type.destroy\n respond_to do |format|\n format.html { redirect_to document_types_url, notice: 'El tipo de documento ha sido destruido satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end", "def create\n @document_page = DocumentPage.new(params[:document_page])\n\n respond_to do |format|\n if @document_page.save\n format.html { redirect_to @document_page, notice: 'Document page was successfully created.' }\n format.json { render json: @document_page, status: :created, location: @document_page }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_page.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @collection_type = CollectionType.new(params[:collection_type])\n\n respond_to do |format|\n if @collection_type.save\n format.html { redirect_to @collection_type, notice: 'Collection type was successfully created.' }\n format.json { render json: @collection_type, status: :created, location: @collection_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @collection_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def can_create?(doc_type)\n doc_type.eql?(\"comments\")\n end" ]
[ "0.6845149", "0.67884475", "0.67559874", "0.67298055", "0.6637083", "0.66122353", "0.6464347", "0.6457802", "0.6367807", "0.6289234", "0.62546116", "0.6250756", "0.6202728", "0.6162214", "0.61429536", "0.6125838", "0.6124055", "0.6120345", "0.6119991", "0.6119991", "0.6066942", "0.60574937", "0.60574937", "0.60372096", "0.6033937", "0.60271406", "0.6021759", "0.6005074", "0.59519374", "0.59439385", "0.5939584", "0.5894515", "0.58854854", "0.58639926", "0.5827231", "0.5821669", "0.57919216", "0.57594925", "0.57594925", "0.5756103", "0.57467616", "0.5733775", "0.5733775", "0.5695337", "0.5694344", "0.56927526", "0.5664161", "0.565955", "0.56521434", "0.563751", "0.562505", "0.56059146", "0.5589422", "0.5584757", "0.5582262", "0.5555341", "0.55551684", "0.55489606", "0.55464005", "0.5538527", "0.5534115", "0.55201733", "0.5516551", "0.55086374", "0.550522", "0.5467961", "0.54564136", "0.5454699", "0.54530096", "0.54525006", "0.5448037", "0.5420737", "0.54016227", "0.53980595", "0.539791", "0.53956795", "0.53933847", "0.53904533", "0.53882366", "0.53847146", "0.5384082", "0.53802776", "0.5373605", "0.5372387", "0.5371716", "0.53553486", "0.53537405", "0.53520566", "0.534916", "0.5348868", "0.5345316", "0.5337425", "0.53371334", "0.5335455", "0.5330103", "0.53239626", "0.53221536", "0.5319807", "0.5317734", "0.53175986" ]
0.69768006
0
PUT /military_document_types/1 PUT /military_document_types/1.json
def update @military_document_type = MilitaryDocumentType.find(params[:id]) respond_to do |format| if @military_document_type.update_attributes(params[:military_document_type]) format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar atualizado com sucesso.' } format.json { head :no_content } else format.html { render :action => "edit" } format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @document_type.update(document_type_params)\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido actualizado satisfactoriamente.' }\n format.json { render :edit, status: :ok, location: @document_type }\n else\n format.html { render :edit }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @document_type.update(document_type_params)\n render :show, status: :ok\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def update\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n if @document_type.update_attributes(params[:document_type])\n format.html { redirect_to @document_type, notice: 'Document type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @documenttype.update(documenttype_params)\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully updated.' }\n format.json { render :show, status: :ok, location: @documenttype }\n else\n format.html { render :edit }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @doc_type.update(doc_type_params)\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.update', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :ok, location: @doc_type }\n else\n format.html { render :edit }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_document_type\n @document_type = @enterprise.document_types.find(params[:id])\n end", "def update_document_all_types client, s, types\n log.debug \"Will update document #{s} for types #{types}\"\n\n if types\n types.each do |type|\n log.debug \"Updating document #{s} for type #{type}\"\n indexes = Indexes.instance.get_indexes type\n indexes.each do |key, index|\n allowed_groups = index[:allowed_groups]\n log.debug \"Got allowed groups for updated_document_all_types #{allowed_groups}\"\n rdf_type = settings.type_definitions[type][\"rdf_type\"]\n log.debug \"Got RDF type for updated_document_all_types #{rdf_type}\"\n if is_authorized s, rdf_type, allowed_groups\n log.debug \"Our current index knows that #{s} is of type #{rdf_type} based on allowed groups #{allowed_groups}\"\n properties = settings.type_definitions[type][\"properties\"]\n document, attachment_pipeline =\n fetch_document_to_index uri: s, properties: properties,\n allowed_groups: index[:allowed_groups]\n\n document_for_reporting = document.clone\n document_for_reporting[\"data\"] = document_for_reporting[\"data\"] ? document_for_reporting[\"data\"].length : \"none\"\n\n log.debug \"Fetched document to index is #{document_for_reporting}\"\n\n # TODO what is uuid supposed to be here? We abstract its meaning to be get_uuid(s) but are not sure\n uuid = get_uuid(s)\n\n if attachment_pipeline\n log.debug \"Document to update has attachment pipeline\"\n begin\n # client.upload_attachment index, uuid, attachment_pipeline, document\n client.upload_attachment index[:index], uuid, attachment_pipeline, document\n log.debug \"Managed to upload attachment for #{s}\"\n rescue\n log.warn \"Could not upload attachment #{s}\"\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n log.info \"Not Authorized.\"\n end\n end\n end\n end\nend", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def set_documenttype\n @documenttype = Documenttype.find(params[:id])\n end", "def set_document_type\n @document_type = DocumentType.find(params[:id])\n end", "def update\n respond_to do |format|\n if @identity_document_type.update_attributes(identity_document_type_params)\n format.html { redirect_to @identity_document_type, notice: 'Tipo Documento atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @identity_document_type }\n else\n format.html { render :edit }\n format.json { render json: @identity_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @document = Document.new\n @document.document_type = 1\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n end", "def set_doc_type\n @doc_type = DocType.find(params[:id])\n end", "def update\n @breadcrumb = 'update'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n @contracting_request_document_type.updated_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.update_attributes(params[:contracting_request_document_type])\n format.html { redirect_to @contracting_request_document_type,\n notice: (crud_notice('updated', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @document_type = @enterprise.document_types.new(document_type_params)\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido creado satisfactoriamente.' }\n format.json { render :edit, status: :created, location: @document_type }\n else\n format.html { render :new }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @military_document_type = MilitaryDocumentType.new(params[:military_document_type])\n\n respond_to do |format|\n if @military_document_type.save\n format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' }\n format.json { render :json => @military_document_type, :status => :created, :location => @military_document_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @military_document_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def document_type=(name)\n @document_type = name\n end", "def document_type=(name)\n @document_type = name\n end", "def update\n respond_to do |format|\n if @doi_type.update(doi_type_params)\n format.html { \n flash[:notice] = 'El tipo de documento de identidad se actualizó satisfactoriamente.'\n redirect_to doi_types_path\n }\n format.json { render :show, status: :ok, location: @doi_type }\n else\n format.html { render :edit }\n format.json { render json: @doi_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def document_type_params\n params.require(:document_type).permit(:name, :enterprise_id)\n end", "def create\n @document_type = DocumentType.new(params[:document_type])\n\n respond_to do |format|\n if @document_type.save\n format.html { redirect_to @document_type, notice: 'Document type was successfully created.' }\n format.json { render json: @document_type, status: :created, location: @document_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @military_document_types = MilitaryDocumentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @military_document_types }\n end\n end", "def documenttype_params\n params.require(:documenttype).permit(:name)\n end", "def update\n respond_to do |format|\n if @has_document.update(has_document_params)\n format.html { redirect_to @has_document, notice: 'Has document was successfully updated.' }\n format.json { render :show, status: :ok, location: @has_document }\n else\n format.html { render :edit }\n format.json { render json: @has_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @office_type.update(office_type_params)\n format.html { redirect_to @office_type, notice: 'Office type was successfully updated.' }\n format.json { render :show, status: :ok, location: @office_type }\n else\n format.html { render :edit }\n format.json { render json: @office_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipo_documento.update(tipo_documento_params)\n format.html { redirect_to @tipo_documento, notice: 'Se ha actualizado el Tipo de documento.' }\n format.json { render :show, status: :ok, location: @tipo_documento }\n else\n format.html { render :edit }\n format.json { render json: @tipo_documento.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 document_type_params\n params.require(:document_type).permit(:description, :deleted_at)\n end", "def resource_type\n document_type\n end", "def resource_type\n document_type\n end", "def show\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def new\n @military_document_type = MilitaryDocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @military_document_type }\n end\n end", "def document_type_params\n params.require(:document_type).permit(:description)\n end", "def document_params\n params.require(:document).permit(:doc,:documentable_id, :documentable_type)\n end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: document.errors, status: 422\n end\n\n end", "def doc_type_params\n params.require(:doc_type).permit(:name)\n end", "def document_type\n @document_type ||= params['documentType']\n end", "def update\n respond_to do |format|\n if @params_config_type_doc.update(params_config_type_doc_params)\n format.html { redirect_to @params_config_type_doc, notice: 'Params config type doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @params_config_type_doc }\n else\n format.html { render :edit }\n format.json { render json: @params_config_type_doc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @documenttype = Documenttype.new(documenttype_params)\n\n respond_to do |format|\n if @documenttype.save\n format.html { redirect_to @documenttype, notice: 'Documenttype was successfully created.' }\n format.json { render :show, status: :created, location: @documenttype }\n else\n format.html { render :new }\n format.json { render json: @documenttype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @documentable = @document.documentable\n\n respond_to do |format|\n if @document.update(document_params)\n notify_user(:notice, 'Document was successfully updated.')\n format.html { redirect_to get_resource_url(@documentable) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to edit_document_path(@document), notice: 'Documento gardado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def create\n @document_type = DocumentType.new(document_type_params)\n\n if @document_type.save\n render :show, status: :created\n else\n render json: @document_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @document.update_attributes(name: document_params[:name], lab_id: document_params[:lab_id])\n format.html { redirect_to documents_url, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: documents_url }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n ap tame_name = params[:document][:team]\n if @document.update(document_params)\n format.html { redirect_to documents_url(:team_id => @document.team_id, :team => tame_name ), notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { redirect_to edit_document_path(:team_id => @document.team_id, :team => params[:team]), notice: 'Document was not updated.' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_identity_document_type\n @identity_document_type = IdentityDocumentType.find(params[:id])\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: \"Document was successfully updated.\" }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update\n\n doc_one = document_types(:doc_one)\n document_type = DocumentType.find(doc_one.id)\n document_type.name = 'Test'\n\n get(:update, { :document_type => document_type.attributes }, cathy_admin_session)\n assert_equal('Update recorded', flash['notice'])\n assert_equal('Test', document_type.name)\n assert_redirected_to(:action => 'edit', :id => document_type.id)\n \n end", "def document_type name=nil\n @document_type = name || @document_type || implicit(:document_type)\n end", "def update\n @document = Document.find(params[:id])\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.json { render :json => nil, :status => :ok }\n format.html { redirect_to(@document, :notice => 'Document was successfully updated.') }\n else\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @tipo_documento = TipoDocumento.find(params[:id])\n\n respond_to do |format|\n if @tipo_documento.update_attributes(params[:tipo_documento])\n format.html { redirect_to @tipo_documento, notice: 'Tipo documento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tipo_documento.errors, status: :unprocessable_entity }\n end\n end\n end", "def toggle_type\n @document = Document.toggle_type(params[:document_id])\n if @document.content_type == 1\n @document.content = markdown_to_html(@document.content)\n @document.save\n else\n @document.content = html_to_markdown(@document.content)\n @document.save\n end\n @task = Task.find(@document.task_id)\n respond_to do |format|\n format.html {render :new }\n end\n end", "def indexDocument(index, type, document, id)\n self.class.post(\"#{index}/#{type}/#{id}\", :body => document.to_json)\n end", "def update\n authorize @document\n disable_primary if document_params[:primary]\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document.instruction, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_document(birthdate:, first_name:, last_name:, street:, postal_code:, country_code:, document_type:, document_value:)\n data = {\n doc: {\n birth_day: birthdate.day,\n birth_month: birthdate.month,\n birth_year: birthdate.year,\n name_first: first_name,\n name_last: last_name,\n address_street1: street,\n address_postal_code: postal_code,\n address_country_code: country_code,\n document_type: document_type,\n document_value: document_value\n }\n }\n\n @client.patch(path: \"/users/#{@user_id}\", oauth_key: @oauth_key, fingerprint: @fingerprint, json: data)\n end", "def document_types\n {\n ORIGINAL: %w(TY ID T1 TI CT A1 A2 AU Y1 PY N1 KW RP SP EP JF JO JA J1 J2 VL IS T2 CY PB U1 U5 T3 N2 SN AV M1 M3 AD UR L1 L2 L3 L4 ER),\n GEN: %w(TY A2 A3 A4 AB AD AN AU C1 C2 C3 C4 C5 C6 C7 C8 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RI RN RP SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n JOUR: %w(TY AB AD AN AU C1 C2 C6 C7 CA CN DA DB DO DP ET J2 KW L1 L4 LA LB IS M2 M3 N1 OP PY RI RN RP SN SP ST T2 TA TI TT UR VL Y2 ER),\n BLOG: %w(TY A2 A3 AB AD AN AU C1 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M3 N1 OP PB PY RN SE SN SP ST T2 T3 TA TI TT UR VL Y2 ER),\n BOOK: %w(TY A3 A2 A4 AB AD AN AU C3 C4 CA CN CY DA DB DO DP ET J2 KW L1 L4 LA LB M1 M3 N1 NV OP PB PY RN RP SE SN SP ST T2 TA TI TT UR VL Y2 ER),\n CASE: %w(TY A2 A3 A4 AB AD AN CA CN DA DB DO DP ET KW L1 L4 LA LB M3 N1 NV OP PB PY RN SE SP ST T3 TA TI TT UR VL Y2 ER),\n EBSCO: %w(JN VO)\n }\n end", "def update\n @collection = @entity_type.collection\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\tdata = unpack_document(params[:document][:datafile]) \n\tdoc_params = {:title => document_params[\"title\"], :date => get_date(document_params,\"date\")}\n\tif !data.nil? then\n\t\tdoc_params[:content] = data[:content]\n\t\tdoc_params[:styles] = data[:styles]\n\tend\n respond_to do |format|\n if @document.update(doc_params)\n format.html { redirect_to @document, notice: \"Document updated successfully\"}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @modified_document = ModifiedDocument.find(params[:id])\n \n if @modified_document.update(modified_document_params)\n render json: @modified_document, status: :ok \n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(resource_params)\n format.html { redirect_to @document, notice: 'Primary document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :notice => 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n add_breadcrumb @document.name, library_category_library_document_path(@category, @document)\n add_breadcrumb \"Modify\"\n\n respond_to do |format|\n if @document.update(document_params)\n notify_user(:notice, 'Document was successfully updated.')\n format.html { redirect_to library_category_library_document_path(@category, @document) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foundation_type.update(foundation_type_params)\n format.html { redirect_to @foundation_type, notice: 'Foundation type was successfully updated.' }\n format.json { render :show, status: :ok, location: @foundation_type }\n else\n format.html { render :edit }\n format.json { render json: @foundation_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to documents_path, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: documents_path }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json {\n render json: {\n status_code: 0\n }\n }\n else\n format.html { render action: 'edit' }\n format.json {\n render json: {\n status_code: 1,\n errors: @document.errors\n }\n }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to documents_path, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to documents_url, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :flash => { :success => 'Document was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n\r\n respond_to do |format|\r\n if @document.update(document_params)\r\n format.html { redirect_to root_url, notice: 'Document was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @document }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @document.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n @document.create_activity :update, owner: current_user\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @special_document = ModifiedDocument.find(params[:id])\n\n respond_to do |format|\n if @special_document.update_attributes(params[:special_document])\n format.html { redirect_to @special_document, notice: 'Special document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @special_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to :action => \"index\", notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @type.update(type_params)\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @intervention_type.update(intervention_type_params)\n format.html { redirect_to intervention_types_path, notice: 'O tipo de intervenção foi actualizado.' }\n format.json { render :show, status: :ok, location: @intervention_type }\n else\n format.html { render :edit }\n format.json { render json: @intervention_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @military_document_type = MilitaryDocumentType.find(params[:id])\n @military_document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to military_document_types_url, :notice => 'Tipo de Documento Militar excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to root_url , notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document_format = DocumentFormat.find(params[:id])\n\n respond_to do |format|\n if @document_format.update_attributes(params[:document_format])\n format.html { redirect_to document_formats_url, notice: 'Document format was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document_format.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n Rails.logger.info \"params: #{params}\"\n\n @trial_document = TrialDocument.new(trial_document_params)\n\n respond_to do |format|\n if @trial_document.save\n if params[:replaced_doc_id].present?\n # TrialDocument.destroy(params[:replaced_doc_id]) # hard delete the replaced document\n Rails.logger.info \"replaced doc id: #{params[:replaced_doc_id]}\"\n replaced_doc = TrialDocument.find(params[:replaced_doc_id])\n # replaced document is flagged as inactive except the document_type is \"Other Document\"\n replaced_doc.update_attribute('status', 'inactive') # unless params[:document_type].include? \"Other\"\n end\n\n format.html { redirect_to @trial_document, notice: 'Trial document was successfully created.' }\n format.json { render :show, status: :created, location: @trial_document }\n else\n format.html { render :new }\n format.json { render json: @trial_document.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n # format.json { head :no_content }\n format.json { render jbuilder: @document }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @squadron_document = SquadronDocument.find(params[:id])\n\n respond_to do |format|\n if @squadron_document.update_attributes(params[:squadron_document])\n format.html { redirect_to @squadron_document, :notice => 'Squadron document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @squadron_document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @collection_type = CollectionType.find(params[:id])\n\n respond_to do |format|\n if @collection_type.update_attributes(params[:collection_type])\n format.html { redirect_to @collection_type, notice: 'Collection type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collection_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def _update type, id, body\n @elasticsupport.client.update index: _index_for(type), type: type.to_s, id: id, body: body\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n flash[:notice] = t('item.updated', :item => t('document.document'))\n format.html { redirect_to admin_document_path(@document) }\n format.xml { head :ok }\n else\n @categories = Category.find_all_by_section_identifier(@document.section_identifier)\n flash.now[:error] = t('item.not_updated', :item => t('document.document'))\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.7216173", "0.7205511", "0.7188631", "0.70816517", "0.69233686", "0.69178843", "0.6869233", "0.68102914", "0.6694511", "0.6675898", "0.6573239", "0.65542465", "0.64890915", "0.64732486", "0.64250034", "0.63367647", "0.62926567", "0.62926567", "0.6212918", "0.61546224", "0.61267656", "0.6120365", "0.6103004", "0.609377", "0.60567325", "0.60248303", "0.6006634", "0.59962976", "0.59877646", "0.59877646", "0.5971044", "0.59423965", "0.59376454", "0.5920621", "0.59188825", "0.5918064", "0.59135056", "0.5911333", "0.59076655", "0.5895443", "0.5887077", "0.5877479", "0.5877285", "0.58769464", "0.58769464", "0.58769464", "0.58729863", "0.5872439", "0.586911", "0.58659834", "0.58659834", "0.58659834", "0.58659834", "0.58659834", "0.58659834", "0.58659834", "0.58651", "0.5862654", "0.58566743", "0.585342", "0.58523035", "0.5848812", "0.5839511", "0.5835107", "0.58322644", "0.5821926", "0.5819432", "0.58138746", "0.58047837", "0.579555", "0.579555", "0.579555", "0.5791394", "0.5789834", "0.5788915", "0.5785698", "0.5785687", "0.57781273", "0.57778096", "0.57745266", "0.5772564", "0.5752775", "0.57515275", "0.5749465", "0.5740077", "0.57356006", "0.5732574", "0.57294255", "0.57293683", "0.57200164", "0.5717489", "0.57143253", "0.57086086", "0.57075214", "0.5703161", "0.57019097", "0.5684648", "0.5676809", "0.567103", "0.5659357" ]
0.7246239
0
DELETE /military_document_types/1 DELETE /military_document_types/1.json
def destroy @military_document_type = MilitaryDocumentType.find(params[:id]) @military_document_type.destroy respond_to do |format| format.html { redirect_to military_document_types_url, :notice => 'Tipo de Documento Militar excluído com sucesso.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_type.destroy\n respond_to do |format|\n format.html { redirect_to document_types_url, notice: 'El tipo de documento ha sido destruido satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @identity_document_type.destroy\n respond_to do |format|\n format.html { redirect_to identity_document_types_url, notice: 'Tipo Documento excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @documenttype.destroy\n respond_to do |format|\n format.html { redirect_to documenttypes_url, notice: 'Documenttype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc_type.destroy\n respond_to do |format|\n format.html { redirect_to doc_types_url, notice: t('message.template.scaffold.destroy', model: t('activerecord.models.doc_type')) }\n format.json { head :no_content }\n end\n end", "def destroy\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n respond_to do |format|\n if @contracting_request_document_type.destroy\n format.html { redirect_to contracting_request_document_types_url,\n notice: (crud_notice('destroyed', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to contracting_request_document_types_url, alert: \"#{@contracting_request_document_type.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def delete_document_all_types client, s, types\n types.each do |type|\n uuid = get_uuid s\n if uuid\n Settings.instance.indexes[type].each do |key, index|\n begin\n client.delete_document index[:index], uuid\n rescue\n log.info \"Failed to delete document: #{uuid} in index: #{index[:index]}\"\n end\n end\n end\n end\nend", "def delete\n @client.delete_document(@path)\n end", "def destroy\n @tipo_documento = TipoDocumento.find(params[:id])\n @tipo_documento.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_documentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @doi_type.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'El tipo de documento de identidad se eliminó satisfactoriamente.'\n redirect_to doi_types_path\n }\n format.json { head :no_content }\n end\n end", "def destroy\n @modified_document = ModifiedDocument.find(params[:id])\n \n if @modified_document.destroy\n render json: @modified_document, status: :ok \n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def destroy\n @squadron_document = SquadronDocument.find(params[:id])\n @squadron_document.destroy\n\n respond_to do |format|\n format.html { redirect_to squadron_documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tipo_documento.destroy\n respond_to do |format|\n format.html { redirect_to tipo_documentos_url, notice: 'Se ha eliminado el Tipo de documento.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_document = ModifiedDocument.find(params[:id])\n @special_document.destroy\n\n respond_to do |format|\n format.html { redirect_to special_documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reform_type = ReformType.find(params[:id])\n @reform_type.destroy\n\n respond_to do |format|\n format.html { redirect_to reform_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @admin_documento.destroy\n respond_to do |format|\n format.html { redirect_to admin_documentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_format = DocumentFormat.find(params[:id])\n @document_format.destroy\n\n respond_to do |format|\n format.html { redirect_to document_formats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n if @document.destroy\n render json: @document, status: :accepted\n else\n render json: {errors: @document.errors.full_messages}, status: :unprocessable_entity\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url(document_filter: {kind: @document.kind}), success: 'Documento eliminado con éxito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document_type.destroy\n end", "def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @documento = Documento.find(params[:id])\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to documentos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @params_config_type_doc.destroy\n respond_to do |format|\n format.html { redirect_to params_config_type_docs_url, notice: 'Params config type doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection = @entity_type.collection\n @entity_type.destroy\n respond_to do |format|\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url, notice: 'Documento eliminado correctamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @foundation_type.destroy\n respond_to do |format|\n format.html { redirect_to foundation_types_url, notice: 'Foundation type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @designation_type.destroy\n respond_to do |format|\n format.html { redirect_to designation_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @document = @maintenance.documents.find(params[:id])\n @document.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_maintenance_path(@vehicle, @maintenance), notice: 'Document was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to department_documents_path @department }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc_type_am_configuration = DocTypeAmConfiguration.find(params[:id])\n @doc_type_am_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to doc_type_am_configurations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @oa_sent_document = Oa::SentDocument.find(params[:id])\n @oa_sent_document.destroy\n\n respond_to do |format|\n format.html { redirect_to oa_sent_documents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @office_type.destroy\n respond_to do |format|\n format.html { redirect_to office_types_url, notice: 'Office type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n @ref_med_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_med_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @contract_document.destroy\n respond_to do |format|\n format.html { redirect_to contract_documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mall_type = MallType.find(params[:id])\n @mall_type.destroy\n\n respond_to do |format|\n format.html { redirect_to mall_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @documento = Documento.find(params[:id])\n # Eliminar los registros asociativos de las tablas JOIN \n # para las asociaciones HBTM (has_and_belongs_to_many)\n #\n @documento.reconocimientos.destroy_all\n @documento.areas.destroy_all\n\n @documento.destroy\n\n respond_to do |format|\n format.html { redirect_to documentos_url, :notice => \"#{@documento.titulo} eliminado\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_group_category.destroy\n respond_to do |format|\n format.html { redirect_to dokumentit_path, notice: destroyed_message(@@object_type) }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to documents_url }\n # format.json { head :no_content }\n format.json { render json: @document }\n end\n end", "def destroy\r\n @document = Document.find(params[:id])\r\n @document.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to documents_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize @document\n instruction = @document.instruction\n @document.destroy\n respond_to do |format|\n format.html { redirect_to instruction, notice: t('documents.destroy.success') }\n format.json { head :no_content }\n end\n end", "def destroy\n @docs_ponto.destroy\n respond_to do |format|\n format.html { redirect_to docs_pontos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @documentable = @document.documentable\n @document.destroy\n\n notify_user(:notice, 'Document was successfully removed.')\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path) }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to back_index_case_url, notice: 'Document was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @document.destroy\n respond_to do |format|\n format.html { redirect_to back_index_case_url, notice: 'Document was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to docs_url }\n format.json { head :ok }\n end\n end", "def destroy\n \t\n @companydocument = Companydocument.find(params[:id])\n @companydocument.destroy\n\n respond_to do |format|\n format.html { redirect_to companydocuments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_status = DocumentStatus.find(params[:id])\n @document_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_document_statuses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @shared_document.destroy\n respond_to do |format|\n format.html { redirect_to shared_documents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @identifier_type.destroy\n\n respond_to do |format|\n format.html { redirect_to identifier_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @doc.destroy\n respond_to do |format|\n format.html { redirect_to docs_url, notice: 'Документ был удалён' }\n format.json { head :no_content }\n end\n end", "def destroy\n @agenda_type = AgendaType.find(params[:id])\n @agenda_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agenda_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @documentotipo = Documentotipo.find(params[:id])\n @documentotipo.destroy\n\n respond_to do |format|\n format.html { redirect_to documentotipos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @appointment_type.destroy\n respond_to do |format|\n format.html { redirect_to appointment_types_url, notice: 'Appointment type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @constancia_documento.destroy\n respond_to do |format|\n format.html { redirect_to constancia_documentos_url, notice: 'La constancia fue eliminada correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mtype = Mtype.find(params[:id])\n @mtype.destroy\n\n respond_to do |format|\n format.html { redirect_to mtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document = Document.find(params[:id])\n collection = Collection.find(@document.collection_id)\n upload_remove(@document) #Removes upload record if file is deleted\n @document.destroy\n\n respond_to do |format|\n #format.html { redirect_to collections_path }\n format.html { redirect_to collection }\n format.json { head :ok }\n end\n end", "def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @poi_type = PoiType.find(params[:id])\n @poi_type.destroy\n\n respond_to do |format|\n format.html { redirect_to poi_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @talktype = Talktype.find(params[:id])\n @talktype.destroy\n\n respond_to do |format|\n format.html { redirect_to talktypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @disaster_type = DisasterType.find(params[:id])\n @disaster_type.destroy\n\n respond_to do |format|\n format.html { redirect_to disaster_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_page = DocumentPage.find(params[:id])\n @document_page.destroy\n\n respond_to do |format|\n format.html { redirect_to document_pages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_doc.destroy\n respond_to do |format|\n format.html { redirect_to client_docs_url, notice: 'Client doc was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ref_hospitalization_type = Ref::HospitalizationType.find(params[:id])\n @ref_hospitalization_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_hospitalization_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @has_document.destroy\n respond_to do |format|\n format.html { redirect_to has_documents_url, notice: 'Has document was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end", "def destroy\n @talk_type = TalkType.find(params[:id])\n @talk_type.destroy\n\n respond_to do |format|\n format.html { redirect_to talk_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intervention_type.destroy\n respond_to do |format|\n format.html { redirect_to intervention_types_url, notice: 'O tipo de intervenção foi eliminado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admission_type = AdmissionType.find(params[:id])\n @admission_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admission_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection = @document.collection\n @document.destroy\n @collection.update_annotation_count\n respond_to do |format|\n format.html { redirect_back fallback_location: collection_documents_path(@collection), notice: 'The document was successfully removed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7619207", "0.7351393", "0.73229754", "0.7293766", "0.71715677", "0.70488644", "0.7026494", "0.69568884", "0.68637085", "0.6821977", "0.67709005", "0.67343533", "0.6725197", "0.6697152", "0.668687", "0.6680535", "0.6654211", "0.66144544", "0.66075844", "0.65992564", "0.65852106", "0.65766966", "0.6572757", "0.6572757", "0.6572757", "0.6572757", "0.6572757", "0.65719736", "0.65663415", "0.6565408", "0.6561398", "0.65574884", "0.6555884", "0.65504247", "0.6547174", "0.6545777", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6545352", "0.6543426", "0.65431553", "0.65382075", "0.6536539", "0.65357167", "0.65357167", "0.65318173", "0.65296286", "0.6529382", "0.6519938", "0.65194005", "0.65159816", "0.65078026", "0.6507106", "0.65067434", "0.6506564", "0.6503155", "0.6503095", "0.650249", "0.6501072", "0.6495353", "0.64914566", "0.6489864", "0.6489343", "0.6486127", "0.6486127", "0.648572", "0.6484338", "0.64839387", "0.64838403", "0.64803004", "0.64780694", "0.6476211", "0.64761496", "0.647178", "0.6470121", "0.64639765", "0.64634895", "0.64632565", "0.6451652", "0.6451283", "0.6450989", "0.6444883", "0.6444464", "0.643874", "0.64357543", "0.6433642", "0.6431734", "0.6431289", "0.6430734", "0.6429712", "0.64294565", "0.6425531", "0.64182985", "0.6415538" ]
0.76715434
0
Methods Public: Gets the activity for a given group from SQL Returns an array of Comment and Photo objects
def activity (self.photos.recent + self.comments.recent).sort_by(&:created_at) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activity\n if !current_group.nil?\n \t ideas = Idea.find_all_by_group_id(current_user.groups.map(&:id))\n else\n ideas = current_user.ideas\n end\n \t@activities = Activity.find_all_by_idea_id(ideas.map(&:id))\n end", "def show_activities\n @group = Group.find(params[:id])\n end", "def build_activity_group group\n return {\n :time => group.max{ |a| a.created_at.to_i }.created_at,\n :type => group.first.trackable_type,\n :activities => group,\n :user_id => group.first.user.id,\n :profile_image => group.first.user.user_fb_data.profile_image,\n :class => group.first.trackable.class.name.downcase\n }\n end", "def get_wp_activity_posts(group_slug = 'agriculture-team')\n # wp_sfposts\n wp.query(<<-QUERY).to_a\n SELECT a.id post_id, a.content, u.display_name post_user, u.user_login, u.user_email, g.name, a.date_recorded, \n gu.user_email group_user_email, gu.display_name group_creator\n FROM wp_bp_activity a \n JOIN wp_users u ON u.id = a.user_id\n JOIN wp_bp_groups g ON g.id = a.item_id\n JOIN wp_users gu ON gu.id = g.creator_id\n WHERE a.component = 'groups' AND a.type = 'activity_update' AND g.slug = '#{group_slug}'\n ORDER BY a.date_recorded ASC\n QUERY\n end", "def feed\n @group = UserGroup.find_by(user_id: id, name: \"friends\")\n @group_members = @user.relationships.where(user_id: id, \n group_id: @group.id)\n ids ||= []\n @group_members.each { ids << |x|.id }\n ids << id\n Picture.where(\"album_id = ?\", Album.where(\"user_id = ?\", User.find_all_by_id(ids)).id)\n end", "def gallery_activities\n GalleryActivity.\n joins('inner join activities on activities.id = gallery_activities.activity_id').\n where('activities.level_id' => level_id, 'activities.level_source_id' => id)\n end", "def group_album\n @discussion_group = DiscussionGroup.find(params[:id])\n if @login_user.is_member_of_discussion_group(params[:id].to_i) || @discussion_group.is_public\n @pictures = Image.find_by_sql([\"SELECT DISTINCT i.* FROM discussion_group_discussions dgd\n\t\t\t\t\t LEFT JOIN discussions d on dgd.discussion_id = d.id\n\t\t\t\t\t LEFT JOIN comments c on dgd.discussion_id = c.discussion_id\n\t\t\t\t\t LEFT JOIN images i ON (imageable_id = dgd.id AND imageable_type = 'DiscussionGroup')\n\t\t\t\t\t OR (imageable_id = d.id AND imageable_type = 'Discussion')\n\t\t\t\t\t OR (imageable_id = c.id AND imageable_type = 'Comment')\n \t\t\t\t\tWHERE i.id IS NOT NULL AND dgd.discussion_group_id =? \",params[:id].to_i])\n else\n redirect_to @login_user.profile_path\n end\n end", "def group\n limit = (params[:limit] || 10).to_i\n page = (params[:page] || 1).to_i\n @group_id = params[:object_id] unless params[:object_id]=='null'\n @photos = FacebookPhoto.fetch_from_fb_group(@group_id, current_user, {:limit => limit, :page => page})\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, \n :local_photos => false\n }\n end\n end\n end", "def all_group_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = get_all_media_items_for_model_type(@relevant_object.class.to_s.tableize)\n end", "def activities\n @grouped_activities.flatten\n end", "def activity\n PublicActivity::Activity\n .includes(:owner, :trackable, post: [:author, :images, :graetzl, :comments], meeting: [:address, :graetzl, :comments])\n .select('DISTINCT ON(trackable_id, trackable_type) *')\n .where(key: STREAM_ACTIVITY_KEYS)\n .where(\"(owner_id IN (?) AND owner_type = 'User')\n OR\n (trackable_id IN (?) AND trackable_type = 'Meeting')\n OR\n (trackable_id IN (?) AND trackable_type = 'Post')\", users.pluck(:id), meetings.pluck(:id), posts.pluck(:id))\n .order(:trackable_id, :trackable_type, created_at: :desc)\n .sort_by(&:created_at).reverse\n end", "def find_activities\n #This needs to be updated to handle the Ring Model\n #Unit Test is in activity_test.rb\n activities = Array.new\n for friend in mutual_friends\n for activity in friend.activities\n #Does the user have permission to view the activity?\n #The friend must have the user in a ring of equal distance or closer than the content created.\n #However, Comments don't have a ring number, so their respective posts must be referred to.\n if activity.entity_type == 'Comment'\n #The user must be close enough to his/her friend \n if activity.entity.post.ring >= friend.which_ring(self)\n activities << activity\n end\n elsif activity.entity.ring >= friend.which_ring(self)\n if activity.entity_type == 'Friendship'\n #A mutual friendship creates two activities--one for each friendship.\n #This makes sure that only one activity is seen in the list.\n activities.include?(activity.entity.mutual_friendship.activity) ? nil : activities << activity\n else \n activities << activity\n end\n end\n end\n end\n #Sort the activity chronologically\n activities.sort!{|a, b| b.updated_at<=>a.updated_at}\n return activities\n end", "def show\n @group = Group.find(params[:id])\n @groupphoto_comments = Comment.find_groupphoto_comments_for(@group) \n @groupphotos = @group.groupphotos.find(:all, :limit => 5)\n \n @comments = @group.comments.find(:all, :limit => 10, :order => 'created_at DESC')\n @groups_comments = Comment.find_group_comments_for(@group)\n \n if @group.owner == current_user\n @is_group_owner = true\n else\n @is_group_owner = false\n end\n\n @member_count = @group.accepted_memberships.count\n @accepted_memberships = @group.accepted_memberships.find(:all, :limit => 5).collect{|f| f.member }\n @pending_memberships_count = @group.pending_memberships.count()\n\n update_view_count(@group) unless @group.owner && current_user.eql?(@group)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end", "def build_activity_set(activity_group, agb)\n scores = Models::Collection.new\n activities = Models::Collection.new\n activity_group.assessment_activity_profile.assessment_activities.each do |activity|\n activity_component = new_activity(activity)\n activities.push activity_component\n scores.push new_score(agb, activity, activity_component)\n end\n \n return Models::ActivitySet.new(\n :name => activity_group.display_name,\n :profile_name => activity_group.assessment_activity_profile.name ,\n :activities => activities,\n :scores => scores,\n :term_name => term_name(activity_group),\n :code =>activity_group.code\n )\n end", "def user_photos(user_id=self.username)\n connection.get(\"/users/#{user_id}/photos\").body.activity\n end", "def index\n @activity_groups = ActivityGroup.all\n end", "def index\n @activity_groups = ActivityGroup.all\n end", "def groupchats\n @groupchat = []\n @group_comments = GroupComment.all\n @group_comments.each { |comment|\n if (comment.studygroup_id == group_comment_params[:studygroup_id].to_f)\n @groupchat.push(comment)\n end\n }\n render json: @groupchat\n end", "def set_activity_and_group\n @activity = Activity.find(params[:id] || params[:activity_id])\n @group = @activity.group\n end", "def show\n @ordered_group_members = sort_by_name(admins) + sort_by_name(@group.users - admins)\n @group_users = (@group.users - admins).size > NUMBER_OF_SHOWN_USERS ? (@group.users - admins).shuffle : sort_by_name(@group.users - admins)\n @group_admins = admins.size > NUMBER_OF_SHOWN_USERS ? sort_by_name(admins) : admins.shuffle\n\n # RECOMMENDATIONS\n sorted_recommendations = @group.recommendations.sort_by(&:created_at).reverse!\n @recommendations = sorted_recommendations.first(NUMBER_OF_SHOWN_RECOMMENDATIONS)\n @number_of_recommendations = sorted_recommendations.length\n @provider_logos = AmazonS3.instance.provider_logos_hash_for_recommendations(@recommendations)\n\n @group_picture = Group.group_images_hash_for_groups [@group]\n\n # ACTIVITIES\n @activities = PublicActivity::Activity.order(Arel.sql('created_at desc')).select {|activity| (@group.users.collect(&:id).include? activity.owner_id) && activity.group_ids.present? && (activity.group_ids.include? @group.id) }\n @activity_courses = {}\n @activity_courses_bookmarked = {}\n if @activities.present?\n @activities.each do |activity|\n @activity_courses[activity.id] = case activity.trackable_type\n when 'Recommendation' then Recommendation.find(activity.trackable_id).course\n when 'Course' then Course.find(activity.trackable_id)\n when 'Bookmark' then Bookmark.find(activity.trackable_id).course\n end\n @activity_courses_bookmarked[activity.id] = @activity_courses[activity.id].bookmarked_by_user? current_user if @activity_courses[activity.id].present?\n # privacy settings\n if activity.key == 'course.enroll'\n @activities -= [activity] unless activity.owner.course_enrollments_visible_for_group(@group)\n end\n end\n end\n\n # PICTURES\n @profile_pictures = User.author_profile_images_hash_for_activities(@activities)\n @profile_pictures = User.user_profile_images_hash_for_users(@group.users, @profile_pictures)\n end", "def show\n @group = Group.find(params[:id])\n @members = Membership.where(group_id: @group.id)\n @User = Membership.find_by(user_id: session[:user_id], group_id: @group.id)\n @projects = Project.where(group_id: @group.id)\n @messages = Message.where(group_id: @group.id)\n if (params.has_key?(:name))\n @projects = @projects.name_order\n end\n\n if (params.has_key?(:status))\n @projects = @projects.status_order\n end\n\n @activities = PublicActivity::Activity.order(\"created_at desc\").where(group: params[:id]).first(5)\n session[:group] = @group\n session[:group_id] = @group.id\n end", "def activities()\n sql = \"SELECT a.* FROM activities a INNER JOIN bookings b ON b.activities_id = a.id WHERE b.members_id =$1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return result.map { |session| Activity.new( session) }\n end", "def get_all_comment_instances(media_id)\n if media_id.include? \"mp3\"\n media_id = media_id.split('++').first\n end \n comments_array = [[0], [\" \"]]\n Comment.eager_load(:user).where(uploaded_media_id: decrypt(media_id)).order(:audio_timing).map do |comment|\n unless comment.audio_timing.nil?\n comments_array[0] << comment.audio_timing\n comments_array[1] << \"#{comment.user.name} says #{comment.comment}\"\n end\n end\n comments_array[0] << UploadedMedium.find(decrypt(media_id)).duration\n comments_array[1] << \" \"\n comments_array\n end", "def get_slideshows_by_group group_name, options = {}\n do_request 'get_slideshows_by_group', options.merge(group_name: group_name)\n end", "def index\n @activity = Activity.find(params[:activity_id])\n @pictures = @activity.pictures\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end", "def group_info\n group_id_param = params[:group_id]\n\n if group_id_param.nil? || group_id_param.blank?\n render json: { error: 'group_id not specified.' }, status: :bad_request\n return\n end\n\n group = CanvasSpaces.GroupCategory\n .groups\n .where('groups.id = ?', group_id_param)\n .eager_load(:users)\n .first\n if group.nil?\n render json: { error: 'No such group found.' }, status: :not_found\n else\n maillist = get_maillist_for_space(group.id)\n render json: { id: group.id,\n name: group.name,\n description: group.description,\n maillist: maillist,\n leader_id: group.leader_id,\n created_at: group.created_at,\n join_type: display_join_type(group.join_level),\n size: group.users.count\n },\n status: :ok\n end\n end", "def activities\n\t activity_feed.activities\n\tend", "def group\n return if record.respond_to?(:where)\n record.group\n end", "def getMEELeadActivities\n users = User.all.pluck(:id)\n activities = []\n users.each do |id|\n username = User.find(id).display_name\n #create list of [[user, [their activities...]]...]\n activities.push([username, Activity.where(user_id: id)]) \n end\n return activities \n end", "def list_activities\n GooglePlus::Activity.for_person(id)\n end", "def index\n @group_comments = GroupComment.all\n end", "def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end", "def groups()\n id_list = SQLQuery.new.get('groups_handler', ['group_id']).where.if('user_id', @id).send\n groups_list = []\n id_list.each do |id|\n groups_list << Groupchat.get(id['group_id'])\n end\n return Sorter.last_interaction(groups_list)\n end", "def photos(album, options={})\n # Multiquery for photos info + tags\n photos = []\n tags = nil\n comments = nil\n \n if options[:with_tags]\n if resp = @request.do_request { session.fql_multiquery(@query.photos_multi_fql(album.id)) }\n photos = resp['query1']\n # Format tags keyed by photo id\n tags = resp['query2'].inject({}) do |result, element| \n (result[element['pid'].to_i] ||= []) << element['text']\n result\n end\n # Fetch photos' comments\n comments = get_comments(photos.map{|p| p.object_id}.uniq, :object, options)\n DaemonKit.logger.debug \"PHOTO COMMENTS = #{comments.inspect}\"\n end\n else\n photos = @request.do_request { session.get_photos(nil, nil, album.id) }\n end\n\n # We could just return photos and let the client convert them if we wanted to be\n # all general-purpose and all, but YAGNI, right?\n photos.map do |p|\n photo = FacebookProxyObjects::FacebookPhoto.new(p)\n # If tags, find tags for the photo and collect into array\n photo.tags = tags[p.id] if tags && tags[p.id]\n # If comments for this photo, save them to object\n photo.comments = comments[p.object_id] if comments && comments[p.object_id]\n DaemonKit.logger.debug \"FacebookPhoto = #{photo.inspect}\"\n photo\n end\n end", "def group; Group.get(self.group_id); end", "def groups( params={} )\n groups = get_connections(\"groups\", params)\n return map_connections groups, :to => Facebook::Graph::Group\n end", "def fetch_group\n @group = Group.find(params[:group_id])\n end", "def photos( params={} )\n photos = get_connections(\"photos\", params)\n return map_connections photos, :to => Facebook::Graph::Photo\n end", "def group_activities_by_conversation\n @digest_set.each do |person, conversations_array|\n\n conversations_array.each do |conversation|\n\n contributions = @updated_contributions.select do |contribution|\n contribution.conversation == conversation.first\n end\n\n reflections = @updated_reflections.select do |reflection|\n reflection.conversation == conversation.first\n end\n\n votes_created = @votes_created_activities.select do |vote|\n vote.surveyable == conversation.first\n end\n\n votes_ended = @votes_ended_activities.select do |vote|\n vote.surveyable == conversation.first\n end\n\n vote_responses = @vote_response_activities.select do |vote_response|\n vote_response.survey.surveyable == conversation.first\n end\n\n petitions_created = @new_petitions.select do |petition|\n petition.conversation == conversation.first\n end\n\n grouped_petition_signatures = @grouped_petition_signatures_activity.select do |petition_signature|\n petition_signature[1][0].petition_conversation == conversation.first\n end\n \n items = (contributions + reflections + votes_created + votes_ended + vote_responses + petitions_created + grouped_petition_signatures)\n\n conversation << items\n end\n end\n return @digest_set\n\n end", "def photos\n return all_photos if @json[\"photos\"].blank?\n @json[\"photos\"][\"groups\"].select { |g| g[\"type\"] == \"venue\" }.first[\"items\"].map do |item|\n Foursquare::Photo.new(@foursquare, item)\n end\n end", "def photos\n return all_photos if @json[\"photos\"].blank?\n @json[\"photos\"][\"groups\"].select { |g| g[\"type\"] == \"venue\" }.first[\"items\"].map do |item|\n Foursquare::Photo.new(@foursquare, item)\n end\n end", "def fetch\n sort = 'created_at DESC'\n\n case params[:sort_by]\n when 'recent'\n sort = 'created_at DESC'\n else\n\n end\n\n q = '%' + params[:query].downcase + '%'\n\n groups = Group.where(\"LOWER(name) LIKE ? OR LOWER(identifier) LIKE ? OR lower(tags) LIKE ?\", q, q, q)\n .order(sort)\n\n paginate json: groups\n end", "def show\n @activities = PublicActivity::Activity.order(\"created_at desc\").where(owner_id: @profile.user.id, owner_type: \"User\")\n end", "def group_connection\n data['groupConnections'].first['id']\n end", "def show\n\n @picture = Picture.find(params[:id])\n @activity = @picture.album.imageable\n\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: @picture }\n end\n end", "def get_users_in_group(group_id)\n list_users_in_group = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/users\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n user_data = list_users_in_group.parsed_response\n\n arr_of_user_ids = Array.new\n\n user_data.each do |user_data_info|\n arr_of_user_ids.push user_data_info[\"id\"]\n end \n\n return arr_of_user_ids\nend", "def foreach_recent_activity\n CollectionWrapper.new(current_group.activities.desc(:created_at).page(params[:activity_page]).per(25), ActivityWrapper, view_context)\n end", "def group\n @group ||= Innsights::Fetchers::Group.new(@group_object) if @group_object\n end", "def get_petition_signatures_activity\n @petition_signatures_activity = PetitionSignature.where(created_at: time_range).order('created_at ASC')\n @grouped_petition_signatures_activity = @petition_signatures_activity.group_by(&:petition_id).map{|k,v| [k,v]}\n end", "def all_group_discussions(page)\n per_page = 20\n off = (page-1)*per_page\n Discussion.find_by_sql([\"Select d.* from (discussion_group_discussions dgd LEFT JOIN discussions d ON d.id=dgd.discussion_id)\n Where (dgd.discussion_group_id=? and d.share_type=?) ORDER BY dgd.created_at DESC LIMIT ? OFFSET ?\", self.id, \"groups\", per_page, off])\n end", "def get_discussing_users(group_id)\n list_discussion_topics = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/discussion_topics\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n discussion_data = list_discussion_topics.parsed_response\n discussion_id = nil\n\n discussion_data.each do |discussion_info|\n discussion_id = discussion_info[\"id\"]\n end\n\n list_discussion_entries = HTTParty.get(\n \"#{$canvas_url}/api/v1/groups/#{group_id}/discussion_topics/#{discussion_id}/entries\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n discussion_entries_data = list_discussion_entries.parsed_response\n arr_of_discussing_user_ids = Array.new\n\n discussion_entries_data.each do |discussion_entries_info|\n arr_of_discussing_user_ids.push discussion_entries_info[\"user_id\"]\n end\n\n return arr_of_discussing_user_ids\nend", "def commented_photos\n self.comments.map do |comment|\n comment.photo\n end\n end", "def set_activity_group\n @activity_group = ActivityGroup.find(params[:id])\n end", "def get_group_by_id(id)\n $r.hgetall(\"group:#{id}\")\n end", "def show\n @title = params[:group_name]\n @bp_pic_names = []\n @bp_pic_group = BpPicGroup.find(params[:id])\n @bp_pic_group_details = BpPicGroupDetail.find(:all, :conditions => [\"deleted = 0 and bp_pic_group_id = ? \", params[:id]])\n @bp_pic_group_details.each do |bp_pic_group_detail|\n bp_pic = BpPic.find(bp_pic_group_detail.bp_pic_id)\n business_partner = BusinessPartner.find(bp_pic.business_partner_id)\n @bp_pic_names.push([business_partner.business_partner_name, bp_pic.bp_pic_name, business_partner.id, bp_pic.id])\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bp_pic_group }\n end\n end", "def objects\n\t\t\t\tparams=self.field_hash[:params]\n\t\t\t\tret=[]\n\t\t\t\tunless params.nil?\n\t\t\t\t\tactivity=params[:activity]\n\t\t\t\t\tparams.delete(:activity)\n\t\t\t\t\tret = {:act => activity, :obj => params.values}\n\t\t\t\tend\n\t\t\t\tret\n\t\t\tend", "def list_people_by_activity(params = {})\n return false unless check_required_params(params, ['activityId', 'collection'])\n\n execute_with_api({\n :args => [\n @plus_api.people.list_by_activity,\n params\n ]\n })\n end", "def groups\n return [] if new_record?\n cached_groups do\n fetch_groups!\n end\n end", "def load_group group_id, info_level = \"Full\", include_children = \"true\"\n\t\t\t@response = api_request 'LoadGroup', [group_id, info_level, include_children]\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0\n\n\t\t\telements = []\n\t\t\t@response['result']['Elements'].each do |element|\n\t\t\t\tif element['$type'] == \"PhotoSet\"\n\t\t\t\t\telements << ZenfolioAPI::Model::Gallery.new(:id => element['Id'], :type => element['$type'], :caption => element['Caption'], \n\t\t\t\t\t\t:created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], :photo_count => element['PhotoCount'],\n\t\t\t\t\t\t:image_count => element['ImageCount'], :video_count => element['VideoCount'], :photo_bytes => element['PhotoBytes'], :views => element['Views'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:video_upload_url => element['VideoUploadUrl'], :page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:photo_list_cn => element['PhotoListCn'], :group_index => element['GroupIndex'], :title => element['Title'], :owner => element['Owner'])\n\t\t\t\telse\n\t\t\t\t\t#group_elements = load_group element['Id']\n\t\t\t\t\telements << ZenfolioAPI::Model::Group.new(:id => element['Id'], :created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], \n\t\t\t\t\t\t:page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :immediate_children_count => element['ImmediateChildrenCount'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:caption => element['Caption'], :collection_count => element['CollectionCount'], :sub_group_count => element['SubGroupCount'], :gallery_count => element['GalleryCount'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:photo_count => element['PhotoCount'], :parent_groups => element['ParentGroups'], :title => element['Title'])\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t@group = ZenfolioAPI::Model::Group.new(:id => @response['result']['Id'], :created_on => @response['result']['CreatedOn']['Value'], :modified_on => @response['result']['ModifiedOn']['Value'], \n\t\t\t\t:page_url => @response['result']['PageUrl'], :mailbox_id => @response['result']['MailboxId'], :immediate_children_count => @response['result']['ImmediateChildrenCount'], \n\t\t\t\t:text_cn => @response['result']['TextCn'], :caption => @response['result']['Caption'], :collection_count => @response['result']['CollectionCount'], \n\t\t\t\t:sub_group_count => @response['result']['SubGroupCount'], :gallery_count => @response['result']['GalleryCount'], :featured_index => @response['result']['FeaturedIndex'], \n\t\t\t\t:is_random_title_photo => @response['result']['IsRandomTitlePhoto'], :upload_url => @response['result']['UploadUrl'], :photo_count => @response['result']['PhotoCount'], \n\t\t\t\t:parent_groups => @response['result']['ParentGroups'], :title => @response['result']['Title'], :elements => elements)\n\n\t\t\t@group\n\t\tend", "def show\n @group_activity = GroupActivity.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group_activity }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end", "def get_activities\n\t\tviewer = nil\n\t\tviewer = User.find_by_id(params[:user_id]) if (params.has_key?(:user_id))\n\t\t\n @activities = Activity.getActivitiesBy2(params[:category_id], params[:user_id])\n\t\t(0...@activities.length).each {|ndx| @activities[ndx].viewer = viewer}\n render :json => @activities\n end", "def photos(id, group = 'checkin', options = {})\n get(\"venues/#{id}/photos\", {:group => group }.merge(options)).photos\n end", "def getEntityList_by_group_id( group_id, per_page, page)\n params = Hash.new\n params['group_id'] = group_id\n params['per_page'] = per_page\n params['page'] = page\n return doCurl(\"get\",\"/entity/list_by_group_id\",params)\n end", "def im_groups_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IMGroupsApi.im_groups ...'\n end\n # resource path\n local_var_path = '/im/groups'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['OAuth']\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 => 'IMGroupList')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IMGroupsApi#im_groups\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:photo_id])\n @comments = @photo.comments.all\n \n respond_to do |format|\n format.json { render :json => @comments.to_json }\n end\n end", "def activities\n get_call(\"1/activities.json\")\n end", "def comments\n Comment.all.select do |comment|\n comment.photo == self\n end\n end", "def groups\r\n @groups ||= fetch_groups\r\n end", "def RecentActivity\n @followings = Follwing.where(:kite_id => kites.select(\"id\"), :Type => \"like\").order(\"created_at DESC\").take(5)\n @comments = Comment.where(:kite_id => kites.select(\"id\")).order(\"created_at DESC\").take(5)\n return (@followings + @comments).sort_by(&:created_at)\n end", "def groups\n find(:group).map { |g| g.content }\n end", "def photos\n \treturn Photo.where(\"week_int = ?\", self.week_number)\n end", "def load_photos_discussions\n @page = params[:page] ? params[:page].to_i : 1\n from = case params[:time_span]\n when \"30min\" then Time.now - 30.minutes\n when \"day\" then Time.now - 1.day\n when \"week\" then Time.now - 1.week\n when \"year\" then Time.now - 1.year\n else Time.now - 30.day\n end\n to = Time.now\n \n #order_by_rating = params[:sort_by]== \"rates\" ? true : false\n order = params[:sort_by]==\"recent\" ? nil : (params[:sort_by]==\"rates\")\n group_id = params[:group_id] == \"\" ? 0 : params[:group_id].to_i\n crowd_id = params[:crowd_id] == \"\" ? 0 : params[:crowd_id].to_i\n @pictures = @login_user.all_visible_pictures(from, to, @page,order,group_id, crowd_id)\n end", "def photos_for_workout(workout)\n query = \"SELECT pid FROM photo WHERE aid IN ( SELECT aid FROM album WHERE name='#{workout}' and owner=331358835234 ) ORDER BY created\"\n p MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end", "def get_chats\n \tp\"------get_group_chat----#{params.inspect}-----------\"\n\t\t@sender = User.find_by_id(params[:sender_id])\n\t\t@reciever = User.find_by_id(params[:assoc_id])\n @room = Room.where(\"(sender_id = ? and assoc_id = ? and is_group = ?) or (sender_id = ? and assoc_id = ? and is_group = ?) \", @sender.id,params[:assoc_id],false ,params[:assoc_id], @sender.id , false).first\n\t\t if @room.nil?\n\t\t @room = Room.create(:sender_id => params[:sender_id],:assoc_id => params[:assoc_id] )\n\t\t end\n @chats = Message.where(\"((sender_id = ? and assoc_id = ? ) or (sender_id = ? and assoc_id = ? ))\", @sender.id,params[:assoc_id],params[:assoc_id], @sender.id).order(:tstamp)\n\t\tarray = Array.new\n\t @chats.each do |chat|\n\t\t read_by = chat.read_by\n\t\t read_by << params[:sender_id].to_s unless read_by.include?(params[:sender_id].to_s)\t\n\t\t chat.update(read_by: read_by)\n\t\t hash = {}\n\t\t hash[:id] = chat.id\n\t chat.body == nil ? hash[:body] = chat.image.url : hash[:body] = chat.body\n\t\t hash[:read_status] = chat.read_status\n\t\t hash[:upload_type] = chat.upload_type\n\t hash[:created_timestamp] = chat.tstamp\n\t\t hash[:is_user_sender] = (chat.sender_id == @sender.id )? true :false\n\t\t \tarray << hash\n end\n if @reciever.show_online_status\n\t\t status = @reciever.status.current_status \n else\n status = false\n end\n\t\trender :json => {\n\t\t\t:response_code => 200,\n\t :response_message => \"Chats fetched Successfuly.\",\n\t :user_img => @sender.photo_link.nil? ? @sender.photo_url : @sender.photo_link ,\n\t :name => @sender.username,\n\t :room_id => @room.id,\n\t :current_status => status ,\n\t\t :user_info => array\n\t }\n end", "def group_users\n DiscussionGroupUser.where(\"discussion_group_id=? AND is_member=?\", self.id, true)\n end", "def all_activities\n if user.present?\n Activity.where('(activity_owner_id = :activity_owner_id and activity_owner_type = :activity_owner_type) or user_id = :user_id',\n activity_owner_id: id, activity_owner_type: self.class.name, user_id: user.id).order(created_at: :desc)\n else\n activities\n end\n end", "def index\n @group_comments = GroupComment.all\n\n render json: @group_comments\n end", "def show\r\n @gallery_activity = GalleryActivity.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @gallery_activity }\r\n end\r\n end", "def view_group(group)\n @uri = URI.parse(\"#{@api_url}/group/#{group}\")\n body = make_get_request\n @doc = Nokogiri::HTML(body)\n {\n title: get_title,\n description: get_description,\n name: get_name,\n regid: get_regid,\n contact: get_contact\n }\n end", "def activities\n return @activities\n end", "def find_groups\n @groups ||= Group.find(:all)\n end", "def belonging_groups\n contact_groups = []\n @contact.contact_groups.each do |group|\n contact_groups << { _id: group['_id'].to_s, lbl: group['label'] }\n end\n\n respond_to do |format|\n format.js {}\n format.json { render json: contact_groups }\n end\n end", "def create\n @activity = Activity.new(activity_params)\n @activity.group = @group\n\n respond_to do |format|\n if @activity.save\n format.html do\n redirect_to group_activity_url(@group, @activity)\n flash_message(:info, I18n.t('activities.created'))\n end\n format.json { render :show, status: :created, location: @activity }\n else\n format.html { render :new }\n format.json { render json: @activity.errors, status: :unprocessable_entity }\n end\n end\n end", "def im_group_with_http_info(group_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: IMGroupsApi.im_group ...'\n end\n # verify the required parameter 'group_id' is set\n if @api_client.config.client_side_validation && group_id.nil?\n fail ArgumentError, \"Missing the required parameter 'group_id' when calling IMGroupsApi.im_group\"\n end\n # resource path\n local_var_path = '/im/groups/{groupId}'.sub('{' + 'groupId' + '}', group_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'multipart/form-data'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['OAuth']\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 => 'InlineResponse20019')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: IMGroupsApi#im_group\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def person_photos\n Gallerist::PersonPhoto.where master_uuid: master.uuid\n end", "def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end", "def persons\n Gallerist::Person.where modelId: person_photos.map(&:person_id)\n end", "def get_group_chat\n\t \tp\"------get_group_chat----#{params.inspect}-----------\"\n \t\t@sender = User.find_by(id: params[:sender_id])\n\t\t@group = Group.find_by(id: params[:assoc_id])\n\t\t@group_owner = @group.user_id\n\t\tgroup_member_ids = @group.group_memberships.pluck(:user_id) << @group_owner\n\t if @group.present?\n\t\t # @room = Room.where(\"(sender_id = ? and assoc_id = ? and is_group = ?) or (sender_id = ? and assoc_id = ? and is_group = ?) \", @sender.id,@group.id,true,@group.id,@sender.id,true).first\n\t\t\t@room = Room.where(\"(assoc_id = ? and is_group = ?) \", @group.id,true).first\n\t \tif @room.nil?\n\t\t\t @room = Room.create(:sender_id => params[:sender_id],:assoc_id => @group.id, :is_group => TRUE )\n\t\t\tend\n\t \t@chats = Message.where(\"(assoc_id = ? and is_group = ? )\",@group.id, true).order(:created_timestamp)\n\t\t array = Array.new\n\t\t @chats.each do |chat|\n\t\t read_by = chat.read_by\n\t\t\t read_by << params[:sender_id].to_s unless read_by.include?(params[:sender_id].to_s)\t\n\t\t\t chat.update(read_by: read_by)\n\t\t\t hash = {}\n\t\t\t hash[:id] = chat.id\n\t\t\t chat.body == nil ? hash[:body] = chat.image.url : hash[:body] = chat.body\n\t\t\t hash[:username] = User.find_by_id(chat.sender_id).username\n\t\t\t hash[:upload_type] = chat.upload_type\t\t \n\t\t \t\tp \"=============UPLOAD TYPE==========#{chat.upload_type.inspect}==================================\"\n\t\t\t hash[:is_user_sender] = (chat.sender_id == @sender.id )? true :false\n\t\t\t hash[:created_timestamp] = chat.tstamp\n\t\t\t array << hash\n\t\t\tend\n\t\t render :json => {:response_code => 200,\n\t :response_message => \"Chats fetched Successfuly.\",\n\t :room_id => @room.id,\n\t\t\t :group_member_ids => group_member_ids,\n\t\t\t :group_img => @group.group_image,\n\t :name => @group.group_name,\n\t :user_info => array\t\t\t\t\t \n\t }\n else\n \t\trender_message 500, \"Group does not exist.\"\n end\n end", "def photos_tagged_user(uid)\n query = \"select pid, src_big, src_small from photo where pid in (select pid from photo_tag where subject = #{uid}) and owner=#{ATC_GID} order by created\"\n return MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n end", "def group_activity_stream_summary(group_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/activity_stream/summary\",\n :group_id => group_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def album_photos\n \n if album\n album.photos\n else\n []\n end\n \n end", "def photo_discussions\n @album = Album.find(:all,:conditions=>[\"user_id=?\",@login_user.id])\n from = Time.now-30.days\n to = Time.now\n page = 1\n order_by_rating = false\n @pictures = @login_user.all_visible_pictures(from, to, page,order_by_rating,0,0)\n #@pictures = Picture.paginate(:page => 1, :per_page => 5)\n end", "def load_pictures\n page = params[:page].to_i\n per_page = 20\n off = (page-1)*per_page\n @discussion_group = DiscussionGroup.find(params[:id])\n @pictures = @discussion_group.images.offset(off).limit(10).order(\"photo_updated_at DESC \")\n end", "def attach_info # :nodoc:\n unless self.info_added\n rsp = @flickr.send_request('flickr.groups.getInfo', :group_id => self.nsid)\n self.info_added = true\n self.description = rsp.group.description.to_s.strip\n self.member_count = rsp.group.members.to_s.strip\n self.icon_server = rsp.group[:iconserver]\n self.icon_farm = rsp.group[:iconfarm]\n end\n end", "def get_activities\n @params=task_params\n @project=current_user.projects.find(@params[:project_id])\n counter=0\n @res=[]\n @project.activities.each do |p|\n if p.users.include? current_user\n @res[counter]={\n activity_id: p.id, \n name: p.name\n }\n counter+=1\n end\n end\n respond_to do |format|\n format.json {render json: @res.uniq}\n end\n end", "def my_annotations_or_group_annotaitons\n if self.current_group_id == 0\n AnnotationCollection.where(originator_id: self.id)\n else\n AnnotationCollection.find_by_sql(\"SELECT * FROM annotation_collections AS a JOIN annotation_collections_groups AS g ON a.id = g.annotation_collection_id WHERE g.group_id = #{self.current_group_id} GROUP BY a.id;\")\n end\n end", "def fetch_group_data\n response = fetch_data(@@SETTINGS.group_tab)\n unless response.nil?\n adjust_groups response\n end\n end", "def groups(inherited = false)\n uri = build_uri('groups', inherited: inherited.to_s)\n req = Net::HTTP::Get.new(uri, DEFAULT_HEADERS)\n resp = request(req)\n obj = if resp.code == '200'\n JSON.parse(resp.body)\n else\n raise_on_non_200(resp, 200)\n end\n obj\n end", "def fetch(group, id_or_name, attribute_name)\n return [] if attribute_name.empty?\n attribute_name = normalize_attribute_name(attribute_name)\n value = entry(group, id_or_name)[attribute_name]\n value ? value.dup : []\n end", "def group\n object.group.id\n end" ]
[ "0.63864815", "0.61024165", "0.60471046", "0.5998786", "0.5988786", "0.5960128", "0.5900521", "0.58484507", "0.5841096", "0.57139724", "0.56552255", "0.5586474", "0.5577867", "0.55759656", "0.5513484", "0.54928684", "0.54928684", "0.54847103", "0.5482085", "0.5448598", "0.53589475", "0.5293696", "0.5292142", "0.52583593", "0.5254292", "0.52451855", "0.5237845", "0.52330595", "0.522947", "0.5199232", "0.5178584", "0.5126676", "0.5104791", "0.5103855", "0.5102974", "0.5101966", "0.50476205", "0.504729", "0.5040732", "0.5031763", "0.5031763", "0.5029721", "0.49993393", "0.49958724", "0.499506", "0.49946755", "0.4990507", "0.4988562", "0.4983563", "0.49803948", "0.49746087", "0.49725538", "0.49718335", "0.49711788", "0.49658597", "0.49533522", "0.4948262", "0.49428844", "0.49427623", "0.49380308", "0.49304268", "0.49182573", "0.49100882", "0.49067372", "0.49035883", "0.48915017", "0.4889261", "0.48776475", "0.4866976", "0.48585698", "0.4857386", "0.48526022", "0.48485124", "0.48463464", "0.48451194", "0.48410374", "0.48409224", "0.48398304", "0.48384145", "0.48381895", "0.4832517", "0.48254094", "0.4815697", "0.48140746", "0.48134214", "0.480204", "0.480204", "0.4795246", "0.4792555", "0.47884154", "0.4787606", "0.4785437", "0.47837028", "0.47713703", "0.47688153", "0.47676775", "0.4764807", "0.47634003", "0.47632545", "0.4761857" ]
0.5369756
20
Public: Marks all notifications as read for the given group Returns an array of notifications
def mark_notifications_as_read!(user) self.notifications.where(read: false, user_id: user.id).update_all(read: true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notification_groups_mark_all_as_read(opts = {})\n data, _status_code, _headers = notification_groups_mark_all_as_read_with_http_info(opts)\n data\n end", "def mark_all_as_read\n @notifications = Notification.unread.for_user(current_api_v1_user)\n @notifications.update_all(read_at: Time.now) unless @notifications.blank?\n @notifications = Notification.where(recipient_id: current_api_v1_user.id)\n \n render json: @notifications\n end", "def mark_notification_as_read!\n notification = User.find(@userid).notifications\n @received_msg.each do |notify|\n notification.update(notify['id'], :checked => true);\n end\n end", "def notification_groups_mark_as_read(id, opts = {})\n data, _status_code, _headers = notification_groups_mark_as_read_with_http_info(id, opts)\n data\n end", "def mark_notifications_as_read(options = {})\n boolean_from_response :put, 'notifications', options\n end", "def mark_notifications_read\n return if params[:notification_id].blank? or !user_signed_in?\n n = Notification.find(params[:notification_id])\n current_subject.mark_as_read n\n end", "def mark_as_read\n @notifications = Notification.where(recipient: current_user).unread\n @notifications.update_all(read_at: Time.zone.now)\n render json: {success: true}\n end", "def read_notifications\n # Update post notification\n post_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Post', @post.id)\n .first\n post_notification.update_attributes(read: true) unless post_notification.nil?\n\n # Update post's messages notifications\n @post.messages.each do |message|\n message_notification = @message.sender\n .notifications_unread\n .where(\"origin_type = ? AND origin_id = ?\", 'Message', message.id)\n .first\n message_notification.update_attributes(read: true) unless message_notification.nil?\n end\n end", "def mark_all_entries_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end", "def unread_unsent_notifications_for_group\n @unread_unsent_notifications_for_group ||= unread_unsent_notifications.where('notify_user_notifications.group_id = ?', notification.group_id)\n end", "def mark_all_messages_as_read(options={})\n RecipientsFor::ReaderInfo.where(\n reciveable_type: options[:reciveable].class.name,\n reciveable_id: options[:reciveable].id,\n ).update_all(read: true)\n end", "def mark_all_entries_as_read_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :forced_read_state,\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read_all\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def mark_as_read\n if Notification.mark_as_read\n return_message(200, :ok)\n else\n return_message(200, :fail)\n end\n end", "def group_notifications\n @attributes[:group_notifications]\n end", "def mark_as_read\n DeterLab.mark_notifications(current_user_id, [ params[:id] ], [ { isSet: true, tag: Notification::READ } ])\n render text: 'ok'\n end", "def unread_notifications\n notifications_received.where('activities.created_at > ?', notifications_checked_at)\n end", "def load_notifications\n # reload user data\n user = User.find current_user.id\n @notifications = user.notifications.order(\"updated_at DESC\")\n\n new_feeds = user.notification_readers.select {|feed| !feed.isRead?}\n new_feeds.each do |feed|\n feed.read_at = Time.zone.now\n feed.save!\n end\n end", "def unread\n all(UNREAD)\n end", "def mark_repo_notifications_as_read(repo, options = {})\n boolean_from_response :put, \"#{Repository.path repo}/notifications\", options\n end", "def mark_all_readed\n doctor.notifications.update_all unreaded: false\n send_json doctor.notifications, true\n end", "def unread_notifications_since_last_read\n notification.class.for_target(notification.target)\n .where(group_id: notification.group_id)\n .where(read_at: nil)\n .where('notify_user_notifications.created_at >= ?', last_read_notification.try(:read_at) || 24.hours.ago)\n .where.not(id: notification.id)\n .order(created_at: :desc)\n end", "def mark_notification_as_read(notification_id)\n request(:post, \"/api/notifications/mark_as_read/#{notification_id}/\")\n end", "def unread\n @notifications = Notification.where(user_id: current_user.uid).where(is_read: false).page(params[:page]).order(created_at: :desc)\n end", "def notifications(options = {})\n #:type => nil is a hack not to give Messages as Notifications\n notifs = Mailboxer::Notification.recipient(messageable).where(:type => nil).order(\"mailboxer_notifications.created_at DESC\")\n if options[:read] == false || options[:unread]\n notifs = notifs.unread\n end\n\n notifs\n end", "def retrieve_notifications\n\tunread = self.notifications.where(\"read = ?\", false).order(\"created_at DESC\")\n\t\n\tif unread.count < 10\n\t\tread = self.notifications.where(\"read = ?\", true).order(\"created_at DESC\").limit(10 - unread.count)\n\t\t\n\t\tunread = unread.concat(read)\n\tend\n\t\n\treturn unread\n end", "def remove_from_notifications\n notifications.find_all { |n| n.noti_read == 'N' }.each do |n|\n remove_from_notification(n)\n end # each n\n end", "def notifications(receiver=current_user, limit=9)\n @notifications = receiver.received_notifications.limit(limit)\n end", "def mark_as_read_notification(notification_id)\n post(\"notifications/#{notification_id}/markAsRead\")\n end", "def notifications(options = {})\n scope = MessageCenter::Notification.recipient(messageable).order(:created_at => :desc)\n if options[:read] == false || options[:unread]\n scope = scope.unread\n end\n\n scope\n end", "def notification_groups_mark_all_as_read_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_all_as_read ...'\n end\n # resource path\n local_var_path = '/notification_groups/mark_all_as_read'\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 header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<Object>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_all_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end", "def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end", "def get_notifications\n \t\n \t@notifs = []\n\n \tif current_user\n @notifs = Notification.where(:user_id => current_user.id, :seen => false)\n \tend\n end", "def index\n\t\t@notifications = Notification.where(recipient_id: current_user.id).unread\n\tend", "def list_notifications\n BrickFTP::API::Notification.all\n end", "def list_notifications\n BrickFTP::API::Notification.all\n end", "def mark_as_unread\n Notifyer::Notification.all.each do |n|\n n.update(is_read: false)\n end\n redirect_to :back\n end", "def notifications\n return notification_data_source.notifications\n end", "def mark_as_unread()\n update_attribute('read', false)\n end", "def group_members\n Notification.where(group_owner_id: id)\n end", "def mark_as_read\n payload = { \"chat\" => [id] }.to_json\n path = \"/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems\"\n\n client.post path, payload\n\n true\n end", "def notifications\n response = self.class.get('/notifications.xml')\n notifications_array = []\n response['notifications'].each do |note|\n new_note = Notification.new(:body => note[\"body\"],\n :subject => note[\"subject\"],\n :send_at => note[\"send_at\"],\n :id => note[\"id\"],\n :escalation => note[\"escalation\"])\n note[\"recipients\"].each do |rcpt|\n new_note.add_recipient(Recipient.new(:id => rcpt[\"id\"],\n :channel => rcpt[\"channel\"],\n :address => rcpt[\"address\"],\n :status => rcpt[\"status\"],\n :send_at => rcpt[\"send_at\"]))\n end\n notifications_array << new_note \n end\n notifications_array\n end", "def group_watchers\n return [] unless group\n\n user_ids = group\n .notification_settings\n .where(source_or_global_setting_by_level_query(:watch)).select(:user_id)\n\n user_scope.where(id: user_ids)\n end", "def users_that_can_read_group(users, group)\n DeclarativePolicy.subject_scope do\n users.select { |u| allowed?(u, :read_group, group) }\n end\n end", "def fetch_unread_items(folder)\n item_view = ItemView.new(10) # FIXME: some huge number like 5000, but the JS app is too slow for that\n item_view.property_set = EMAIL_SUMMARY_PROPERTY_SET\n folder.find_items(SearchFilter::IsEqualTo.new(EmailMessageSchema::IsRead, false), item_view).items.to_a\n end", "def mark_unread!\n update_is_read_status false\n end", "def all_notifications(options = {})\n reverse = options[:reverse] || false\n with_group_members = options[:with_group_members] || false\n as_latest_group_member = options[:as_latest_group_member] || false\n target_notifications = Notification.filtered_by_target_type(self.name)\n .all_index!(reverse, with_group_members)\n .filtered_by_options(options)\n .with_target\n case options[:filtered_by_status]\n when :opened, 'opened'\n target_notifications = target_notifications.opened_only!\n when :unopened, 'unopened'\n target_notifications = target_notifications.unopened_only\n end\n target_notifications = target_notifications.limit(options[:limit]) if options[:limit].present?\n as_latest_group_member ?\n target_notifications.latest_order!(reverse).map{ |n| n.latest_group_member } :\n target_notifications.latest_order!(reverse).to_a\n end", "def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend", "def mark_all_news_as_read\n where(:user_id => User.current_user_id).update_all(:read => 1)\n end", "def mark_as_read(options = {})\n default_options = {}\n add_mailbox_condition!(default_options, @type)\n return update_mail(\"mail_items.read = true\", default_options, options)\n end", "def all_notifications\n self.notifications.all\n end", "def unread\n @notifications = current_user.notifications.unread.page(params[:page]).per(5)\n end", "def reset_unread_notification_count\n post('notifications/markAsRead')\n end", "def read_groups\n read_group_field = Hydra.config[:permissions][:read][:group]\n rg = edit_groups | ((@permissions_solr_document == nil || @permissions_solr_document.fetch(read_group_field,nil) == nil) ? [] : @permissions_solr_document.fetch(read_group_field,nil))\n logger.debug(\"read_groups: #{rg.inspect}\")\n return rg\n end", "def get_notifications notifiable_type\n n = Notification.where(user_id:current_user, notifiable_type: notifiable_type)\n events_id = Array.new\n n.each do |v|\n events_id << v.notifiable_id\n end\n events = Event.where(id:events_id)\n\n end", "def notifications\n query_api_object Notification, \"/rest/notifications\", nil, \"GET\", \"notifications\"\n end", "def show\n @notifications = Notification.where(user: current_user).where(notification_obeject_id: params[:id]).where(read: false)\n @notifications.each do |note|\n note.read = true\n note.save\n end\n end", "def set_read_status\n\t\t\tNotificationReceiver.where(notification_id: params[:id], user_id: current_user.id).update_all(is_read: true)\n\n\t\t\trender json: {\n\t\t\t\tstatus: 0\n\t\t\t}\n\t\tend", "def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end", "def read_groups=(groups)\n set_read_groups(groups, read_groups)\n end", "def mark_as_read(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_read if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_read(self)\n when Mailboxer::Conversation\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n end", "def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end", "def set_user_read_all(user_id, did_read)\n self.messages.each {|m| m.set_user_read(user_id, did_read)}\n end", "def mark_all_read\r\n @channel.mark_messages_read_for current_user\r\n respond_to do |format|\r\n format.html { redirect_to channel_messages_url(@channel), notice: 'Nachrichten als gelesen markiert.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def notification_groups_mark_as_read_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: NotificationGroupsApi.notification_groups_mark_as_read ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling NotificationGroupsApi.notification_groups_mark_as_read\"\n end\n # resource path\n local_var_path = '/notification_groups/{id}/mark_as_read'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'NotificationGroupDetail' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotificationGroupsApi#notification_groups_mark_as_read\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n response = ::Phrase::Response.new(data, headers)\n return response, status_code, headers\n end", "def index\n @notifications = current_user.notifications.unread.page(params[:page]).per(20)\n end", "def mark_all_user_notifications_notified(user)\n user.notifications.each do |n|\n n.notified = true\n n.save\n end\n end", "def get_notifications\n begin\n response = notifications_api.get\n [parse_json(response), nil]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end", "def mark_topic_as_unread_groups(group_id,topic_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end", "def notifications\n response = query_api(\"/rest/notifications\")\n return response[\"notifications\"].map {|notification| Notification.new(self, notification)}\n end", "def mark_as_unread\n update_attributes(is_read: false)\n end", "def mail_unread\n initialize_mocks if @fake\n\n service = Google::Apis::Core::BaseService.new('https://mail.google.com/', 'mail/feed/atom/')\n service.authorization = user_authorization\n service.http(:get, 'https://mail.google.com/mail/feed/atom/')\n end", "def read_groups(pid)\n read_group_field = Hydra.config[:permissions][:read][:group]\n doc = permissions_doc(pid)\n rg = edit_groups(pid) | ((doc == nil || doc.fetch(read_group_field,nil) == nil) ? [] : doc.fetch(read_group_field,nil))\n logger.debug(\"[CANCAN] read_groups: #{rg.inspect}\")\n return rg\n end", "def unread_messages user_id\n messages.unread(user_id)\n end", "def set_notifications\n @notifications = Notification.all\n end", "def mark_as_unread\n @client.post('/api/mod/conversations/unread', conversationIds: [get_attribute(:id)])\n end", "def set_notifications\n\t\t@notifications = Notification.where(reciever_id: current_user).order(\"created_at DESC\")\n\tend", "def list_notifications # :norobots:\n @notifications = Notification.find_all_by_user_id(@user.id, order: :flavor)\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj, details) }\n end\n\n end", "def get_notifications\n @notifications = Broadcast.joins(:feeds).where(feeds: {name: \"notification\"}).order(created_at: :desc).limit(20)\n end", "def index\n @users = User.all\n @notifications = Notification.where(recipient: current_user).unread\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 mark_as_unread(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Alerter::Message\n obj.mark_as_unread(self, details)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj, details) }\n end\n end", "def each_unread read\n @rmutex.read_sync do\n @readable.each do |m|\n unless read.include? m.id\n yield m\n end\n end\n end\n end", "def mark_as_unread\n update_attributes(:is_read => false)\n end", "def mark_as_unread\n update_attributes(:is_read => false)\n end", "def unread_tasks\n notifications = current_user.notifications.unread\n notifications += current_user.task_owners.unread\n \n tasks = notifications.map { |n| n.task }\n tasks = tasks.uniq\n # only get open / in progress tasks\n tasks = tasks.select { |t| (t.status == 0 or t.status == 1) }\n\n return tasks\n end", "def notifications_for_principal(principal_uri)\n @notifications[principal_uri] || []\n end", "def mark_as_unread(obj)\n case obj\n when Mailboxer::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Mailboxer::Message, Mailboxer::Notification\n obj.mark_as_unread(self)\n when Mailboxer::Conversation\n obj.mark_as_unread(self)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj) }\n end\n end", "def mark_as_read\n\t\tunread_messages = current_user.received_messages.where(read: false).order('id desc').limit(10)\n\t\tunread_messages.each do |m|\n\t\t\tm.update_attribute(:read, true)\n\t\t\tm.save\n\t\tend\n\t\tredirect_to request.referer\n\tend", "def mark_as_unread(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Alerter::Message\n obj.mark_as_unread(self)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj) }\n end\n end", "def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end", "def unread_items(params = {})\n @unread_items ||= filtered_items_list('reading-list', params.merge(:exclude => 'user/-/state/com.google/read'))\n end", "def unread\n un_read(false, \"non lue\")\n end", "def mark_all_as_read(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/conversations/mark_all_as_read\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def mark_entry_as_unread_groups(group_id,topic_id,entry_id,opts={})\n query_param_keys = [\n :forced_read_state\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"group_id is required\" if group_id.nil?\n raise \"topic_id is required\" if topic_id.nil?\n raise \"entry_id is required\" if entry_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id\n )\n\n # resource path\n path = path_replace(\"/v1/groups/{group_id}/discussion_topics/{topic_id}/entries/{entry_id}/read\",\n :group_id => group_id,\n :topic_id => topic_id,\n :entry_id => entry_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end", "def read_groups\n search_by_type_and_mode(:group, ::ACL.Read).map(&:agent_name)\n end", "def mark_as_read\n self.update(read: true)\n end", "def mark_read!\n update_is_read_status true\n end", "def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end", "def topics_unread_comments(group_id, viewed = 0, page = 1, sort = 'updated_at', order = 'a')\n\t\t\tif ['comments_count', 'title', 'updated_at', 'views'].include?(sort) && ['a', 'd'].include?(order)\n\t\t\t\toptions = {\"viewed\" => viewed, \"page\" => page, \"sort\" => sort, \"order\" => order}\n\t\t\telse\n\t\t\t\tputs \"NOTICE: invalid sorting parameters entered. reverting to defults.\"\n\t\t\t\toptions = {\"viewed\" => viewed, \"page\" => page}\n\t\t\tend\n\t\t\tdata = oauth_request(\"/topic/unread_group/#{group_id}\", options)\n\t\t\tHashie::Mash.new(data)\n\t\tend" ]
[ "0.7475885", "0.683939", "0.67202634", "0.66385", "0.6509511", "0.64613986", "0.6260643", "0.6224466", "0.62197", "0.6179289", "0.6136045", "0.60917264", "0.6022801", "0.6009525", "0.6006092", "0.60002637", "0.59714174", "0.5966779", "0.59492695", "0.59474695", "0.59135365", "0.587337", "0.5864204", "0.5852704", "0.5807988", "0.5742056", "0.57310283", "0.57066464", "0.56722915", "0.5668148", "0.5658501", "0.5634625", "0.5619776", "0.5616528", "0.5616528", "0.5605689", "0.5587027", "0.5585748", "0.5583024", "0.55743396", "0.5572953", "0.5534347", "0.55089235", "0.54914933", "0.5488109", "0.54768693", "0.54740703", "0.5467296", "0.54653335", "0.5462967", "0.5414236", "0.5409882", "0.5394301", "0.5392178", "0.53820306", "0.53712475", "0.53617704", "0.5358581", "0.5352418", "0.53423405", "0.5324419", "0.53204423", "0.53164846", "0.5293469", "0.5289362", "0.52802944", "0.5277236", "0.5268823", "0.5266005", "0.5259907", "0.52337366", "0.52053034", "0.5180312", "0.5178551", "0.5168691", "0.5157258", "0.5146336", "0.51260275", "0.5124378", "0.5114428", "0.51066446", "0.5089647", "0.5085933", "0.5077994", "0.5077994", "0.5070075", "0.5068967", "0.5068225", "0.50571764", "0.5054362", "0.5050615", "0.50098413", "0.5004446", "0.49954146", "0.49947044", "0.499103", "0.49895278", "0.49852726", "0.49709228", "0.497033" ]
0.66444993
3
Public: Gets the events for a group Returns an array of Events
def recent_events Event.includes(:user).where(group_id: self.id).limit(50).order(created_at: :desc).reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def events\n @events = registered_application.events.group_by(&:name)\n end", "def group_events\n @group = Group.find(params[:groupId])\n @events = @group.events\n render \"api/events/group_events\"\n end", "def events\n @events ||= []\n @events\n end", "def index\n @events = Event.where(\"group_id = ?\", params[:group_id])\n end", "def index\n @event_groups = EventGroup.all\n end", "def events\n return @events\n end", "def event_list\n @_events\n end", "def events(service, url, args)\n events = []\n ret = service.send_request(GData4Ruby::Request.new(:get, url, nil, nil, args))\n REXML::Document.new(ret.body).root.elements.each(\"entry\"){}.map do |entry|\n entry = GData4Ruby::Utils.add_namespaces(entry)\n e = GCal4Ruby::Event.new(service)\n if e.load(entry.to_s)\n events << e\n end\n end\n return events\nend", "def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end", "def events\n data.events\n end", "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def events_feed\n @group = Group.find_by(id: params[:id]) || not_found\n not_found unless @group.status?\n raise 'NotGroupMember' unless @group.member?(current_user)\n @events = @group.events.confirmed.by_date\n\n feed = []\n @events.each do |event|\n next if event.date_tba == true\n event_link = url_for(\n controller: 'events', action: 'show', group_id: @group.id,\n id: event.id\n )\n feed << {\n date: event.start_time.strftime('%Y-%m-%d'),\n title: \"#{event.time != '' ? event.time : 'TBA'} - #{event.event_name}\",\n url: event_link,\n ticket_stats: event.ticket_stats(@group, current_user)\n }\n end\n render json: feed\n end", "def events\n Enumerator.new(self,:each_event).to_a\n end", "def events\n event_enum\n end", "def events\n event_enum\n end", "def events\n\t\t\t\treturn @events.values unless (@events.nil?)\n\t\t\t\treturn nil\n\t\t\tend", "def get_events()\n\t\tevents = []\n\n\t\t@DB[:events].order(:date).each do |event|\n\t\t\tnewTimeslots = []\n\t\t\t@DB[:timeslots].where(parent_table: 'events', parent_id: event[:'id']).each do |timeslot|\n\t\t\t\tnewTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\tend\n\n\t\t\tnewAttendees = []\n\t\t\t@DB[:attendees].where(parent_id: event[:'id']).each do |attendee|\n\t\t\t\tattendeeTimeslots = []\n\t\t\t\t@DB[:timeslots].where(parent_table: 'attendees', parent_id: attendee[:'id']).each do |timeslot|\n\t\t\t\t\tattendeeTimeslots.push(DateTime.parse(timeslot[:'time']))\n\t\t\t\tend\n\n\t\t\t\tnewAttendee = Attendee.new(attendee[:'name'], attendeeTimeslots)\n\t\t\t\tnewAttendees.push(newAttendee)\n\t\t\tend\n\n\t\t\tnewEvent = Event.new(event[:'name'], event[:'description'], newTimeslots, newAttendees, event[:'id'])\n\t\t\tif newEvent.get_date >= @epoch\n\t\t\t\tevents.push(newEvent)\n\t\t\tend\n\t\tend\n\n\t\treturn events\n\tend", "def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end", "def index\n if params[:query].present?\n @events = GroupEvent.send(params[:query])\n else\n @events = GroupEvent.published\n end\n\n render json: @events\n end", "def index\n user = User.find params[:user_id]\n events = GroupEvent.where(user_id: user.id)\n\n render json: {\n data: events.map { |e| e.as_json(as: :list) }\n }\n end", "def events\n data[\"events\"]\n end", "def events\n @finity.events.map { |name, _| name }\n end", "def events(param = nil)\n request = new_request Net::HTTP::Report do |request|\n request.body = CalendarQuery.new.event(param).to_xml\n end\n response = perform_request request\n \n events = []\n \n body = Nokogiri::XML.parse(response.body)\n namespaces = { 'dav' => \"DAV:\", 'caldav' => 'urn:ietf:params:xml:ns:caldav' }\n \n body.search(\"./dav:multistatus/dav:response\", namespaces).each do |element|\n calendar_data = element.search(\"./dav:propstat/dav:prop/caldav:calendar-data\", namespaces)\n calendar = Icalendar::Parser.new(calendar_data.text).parse.first\n calendar.events.each do |event|\n event.caldav = {\n :etag => element.search(\"dav:propstat/dav:prop/dav:getetag\", namespaces).text, \n :href => element.search(\"dav:href\", namespaces).text\n }\n events += calendar.events\n end\n end\n \n events\n end", "def events\n event_lookup()\n end", "def events\n event_lookup()\n end", "def index\n @eventgroups = Eventgroup.all\n end", "def events\n results = @client.execute(\n :api_method => @calendar.events.list,\n :authenticated => false,\n :parameters => {\n 'calendarId' => @config[:calendar_id],\n 'fields' => 'items(start,end,summary)',\n 'singleEvents' => true,\n 'orderBy' => 'startTime',\n 'timeMin' => DateTime.now.to_s,\n 'timeMax' => (DateTime.now + 7).to_s,\n 'q' => 'LIVE'\n }\n )\n\n results.data.items.map do |event|\n summary = event.summary.gsub(/^LIVE:\\s+/, '')\n CalendarEvent.new(summary, event.start.date_time, event.end.date_time)\n end\n end", "def get_events\n response = request(:get, \"/devmgr/v2/events\")\n #status(response, 200, 'Failed to get current events from server')\n #JSON.parse(response.body)\n response\n end", "def get_events(trace: false, &block)\n r = dropbox_query(query: '2/team_log/get_events', trace: trace)\n r['events'].each(&block)\n while r['has_more']\n r = dropbox_query(query: '2/team_log/get_events/continue', query_data: \"{\\\"cursor\\\":\\\"#{r['cursor']}\\\"}\", trace: trace)\n r['events'].each(&block)\n end\n end", "def events\n results = @cal_service.list_events(\n @calendar_id,\n order_by: 'startTime',\n q: 'LIVE',\n single_events: true,\n time_max: (DateTime.now + 7).to_s,\n time_min: DateTime.now.to_s,\n fields: 'items(start,end,summary)',\n )\n\n results.data.items.map do |event|\n summary = event.summary.gsub(/^LIVE:\\s+/, '')\n CalendarEvent.new(summary, event.start.date_time, event.end.date_time)\n end\n end", "def get_events\n events = [] \n @log ||= Rails.logger\n Appsterdam::Application.ical_subscriptions.each do |options|\n @log.info \"getting events from #{options[:url]}\"\n components = parse_ical(options[:url])\n events.concat(extract_events(components.first))\n end\n @log.info \"done importing iCal events.\"\n \n events\n end", "def all_events\n event_types.map { |etype| events(etype) }\n end", "def index\n @group_events = GroupEvent.where(deleted: false)\n end", "def event_all(stack, evt_id = nil)\n evt_id = stack.last_event_token if evt_id\n results = all_result_pages(evt_id, :body,\n \"DescribeStackEventsResponse\", \"DescribeStackEventsResult\",\n \"StackEvents\", \"member\") do |options|\n request(\n :method => :post,\n :path => \"/\",\n :form => options.merge(\n \"Action\" => \"DescribeStackEvents\",\n \"StackName\" => stack.id,\n ),\n )\n end\n events = results.map do |event|\n stack.last_event_token = event[\"NextToken\"] if event[\"NextToken\"]\n Stack::Event.new(\n stack,\n :id => event[\"EventId\"],\n :resource_id => event[\"PhysicalResourceId\"],\n :resource_name => event[\"LogicalResourceId\"],\n :resource_logical_id => event[\"LogicalResourceId\"],\n :resource_state => event[\"ResourceStatus\"].downcase.to_sym,\n :resource_status => event[\"ResourceStatus\"],\n :resource_status_reason => event[\"ResourceStatusReason\"],\n :time => Time.parse(event[\"Timestamp\"]).localtime,\n ).valid_state\n end\n if evt_id\n idx = events.index { |d| d.id == evt_id }\n idx ? events.slice(0, idx) : events\n else\n events\n end\n end", "def events #:nodoc:\n components Icalendar::Vevent\n end", "def all_events\n events.keys\n end", "def fetch_events(app_name, env_name, options={})\n @event_fetched_times += 1\n set_env_ready(app_name, env_name, true) # assume env become ready after it spit out all the events\n\n unless @events # unrestricted mode for testing if no explicit events set\n return [generate_event_from_messages(['Successfully deployed new configuration to environment',\n 'terminateEnvironment completed successfully',\n 'Successfully launched environment',\n 'Completed swapping CNAMEs for environments'\n ], Time.now + @event_fetched_times), nil]\n end\n\n events = @events[env_key(app_name, env_name)][@event_fetched_times - 1]\n\n if options.has_key?(:start_time)\n start_time = Time.parse(options[:start_time])\n events = events.select { |e| e[:event_date] >= start_time }\n end\n\n if limit = options[:max_records]\n events = events[0..limit]\n end\n\n [events, nil]\n end", "def event_list\n events_list\n end", "def events\n lfm_path = \"artist.getevents&artist=#{@name}\"\n lfm_data = LastFm::fetch_data(lfm_path)\n return Event.create_from_hash(Hash.from_xml(lfm_data)['lfm']['events']['event']) \n end", "def get_team_event_list ( team_key, year )\n get_api_resource \"#{@@api_base_url}team/#{team_key}/#{year}/events\"\n end", "def index\n @events = apply_scopes(Event).decorate.group_by(&:date)\n end", "def get_events\n events = []\n until ((event = SDL.PollEvent) == nil)\n new_event = Events.match(event)\n if new_event.is_a?(Events::KeyReleased)\n @keys_being_repeated.delete(new_event.key)\n end\n if new_event.is_a?(Events::KeyPressed) and not @keys_being_repeated.include?(new_event.key)\n @keys_being_repeated << new_event.key\n end\n events << new_event\n end\n @keys_being_repeated.each {|num| events << Events::KeyPressed.new(num)}\n events\n end", "def events\n @events ||= event_finder\n end", "def events(iam_role_arn)\n get_item_response = @dynamo.get_item(\n key: {\n 'RoleArn' => iam_role_arn\n },\n table_name: @table_name\n )\n return [] unless get_item_response['item']\n get_item_response['item']['Events']\n end", "def events\n collection(\"events\")\n end", "def fetch_events\n params = {'calendarId' => CONFIG[:cal_id], \n 'orderBy' => 'startTime',\n #'timeMax' => Time.utc(CONFIG[:year].to_i + 1, 4, 1).iso8601, \n #'timeMin' => Time.utc(CONFIG[:year].to_i, 4, 1).iso8601,\n 'singleEvents' => 'True'}\n \n result = @client.execute(:api_method => @cal.events.list, :parameters => params)\n\n @events_list = []\n result.data.items.each do |item|\n @events_list << item\n end\n end", "def all_events(start, finish, include_assignments = false, child = nil) # last param used in student & teacher\r\n tracks = school.current_term.tracks\r\n (universal_events(start, finish, tracks) + \r\n Event.where([\"invitable_type = 'Staff' AND invitable_id = ? AND date BETWEEN ? AND ?\", school_id, start, finish]) + \r\n Event.where([\"invitable_type = 'Teachers' AND creator_id = ? AND date BETWEEN ? AND ?\", id, start, finish])).sort_by{|event|event.date} \r\n #(audience_type == Group && groups.map(&:id).include?(audience_id)\r\n end", "def all_events\n @events = Event.all\n end", "def events(options = {})\n GeoCerts::Event.find_by_order_id(self.id, options)\n end", "def events\n @events ||= {}\n end", "def events\n @@events\n end", "def events(service_id, options = {})\n response = JSON.parse(@client.get(\"/api/v1/services/#{service_id}/events\", options).body)\n return response[\"events\"] || response\n end", "def events_for_objects(calendar_events)\n groups = calendar_events.group_by { |r| r.attributes.slice(*GROUP_ATTRIBS) }\n groups.map do |_, members|\n Event.new(basic_event_attribs(members[0]).merge(\n location: members.map(&:location_name).join(\" + \")\n ))\n end\n end", "def index\n @group_events = GroupEvent.where :deleted => false\n end", "def list_financial_events_by_group_id(event_group_id, opts = {})\n data, _status_code, _headers = list_financial_events_by_group_id_with_http_info(event_group_id, opts)\n data\n end", "def available_events\n\t\treturn current_room.events || []\n\tend", "def org_events\n @org_events ||= orgs.map { |o| o.events }.flatten\n end", "def events(project_id, options = {})\n get \"projects/#{project_id}/events\", options\n end", "def events\n return if @events.empty?\n @events.uniq.sort\n end", "def events\n @events ||= user_events.concat(org_events).uniq\n end", "def find_events(event)\n events = []\n name = event.name\n category = event.category\n description = event.description\n snapshots = find_project_snapshots(event.snapshot_id)\n snapshots.each do |snapshot|\n snapshot.events.reject { |e| e.name!=name || e.category!=category }.each do |event|\n events << event\n end\n end\n events\n end", "def list_events(criteria = {})\n events(criteria: criteria)\n end", "def calendar_events(calendar_id)\n records \"/calendars/#{calendar_id}/calendar_events.xml\", :method => :get\n end", "def get_events_from_id_array(id_arr)\n return [] if id_arr.empty?\n \n elist = []\n begin\n elist = Event.find(id_arr)\n rescue ActiveRecord::RecordNotFound => e\n logger.warn(e.message)\n logger.info(\"Getting events one by one\")\n elist = id_arr.map do |id|\n begin\n Event.find(id)\n rescue ActiveRecord::RecordNotFound\n # Ignore\n end\n end\n end\n return elist.compact\n end", "def get_events_from_id_array(id_arr)\n return [] if id_arr.empty?\n \n elist = []\n begin\n elist = Event.find(id_arr)\n rescue ActiveRecord::RecordNotFound => e\n logger.warn(e.message)\n logger.info(\"Getting events one by one\")\n elist = id_arr.map do |id|\n begin\n Event.find(id)\n rescue ActiveRecord::RecordNotFound\n # Ignore\n end\n end\n end\n return elist.compact\n end", "def event_all(stack, marker = nil)\n params = marker ? {:marker => marker} : {}\n result = request(\n :path => \"/stacks/#{stack.name}/#{stack.id}/events\",\n :method => :get,\n :expects => 200,\n :params => params\n )\n result.fetch(:body, :events, []).map do |event|\n Stack::Event.new(\n stack,\n :id => event[:id],\n :resource_id => event[:physical_resource_id],\n :resource_name => event[:resource_name],\n :resource_logical_id => event[:logical_resource_id],\n :resource_state => event[:resource_status].downcase.to_sym,\n :resource_status => event[:resource_status],\n :resource_status_reason => event[:resource_status_reason],\n :time => Time.parse(event[:event_time])\n ).valid_state\n end\n end", "def events\n metadata['events'].sort_by! { |event| event['timestamp'] }\n end", "def all\n ButterSand::Parser.to_array(get(PATH_SAIJI)).map {|event| ButterSand::Event.new(event)}\n end", "def owned_events\n events\n end", "def all(params = {})\n req = WebPay::EventListRequest.create(params)\n raw_response = @client._request(:get, 'events', req)\n WebPay::EventResponseList.new(raw_response)\n end", "def get_events\n @doc.css(\"#cal-event-entry\")\n end", "def event_lookup(query_string = '') #:nodoc:\n begin\n response = send_events_request(query_string, :get)\n parsed_json = JSON.parse(response.body)\n @summary = parsed_json['summary']\n events = Event.build_from_google_feed(parsed_json, self) || []\n return events if events.empty?\n events.length > 1 ? events : [events[0]]\n rescue Google::HTTPNotFound\n return []\n end\n end", "def events\n requires :label, :application_name\n service.events.all({\n 'ApplicationName' => application_name,\n 'VersionLabel' => label\n })\n end", "def get_event_list ( year )\n get_api_resource \"#{@@api_base_url}events/#{year}\"\n end", "def events\n self.class.events\n end", "def events_get(opts = {})\n data, _status_code, _headers = events_get_with_http_info(opts)\n return data\n end", "def events\n events = {}\n @db.each do |key, _|\n timestamp, object = parse_event(key)\n events[object] ||= []\n events[object].push(timestamp)\n end\n events\n end", "def events(events, opts = {})\n data, _status_code, _headers = events_with_http_info(events, opts)\n return data\n end", "def project_events(project_id, params = {})\n make_get_request(\"/projects/#{project_id}/events\", params)\n end", "def load_events\n\t\t\t\treturn @data['events'].map do |eventstr, eventdata|\n\t\t\t\t\tevent = eventstr.to_sym\n\t\t\t\t\tif (Events.constants.include? event)\n\t\t\t\t\t\tnext [event, Events.const_get(event).new(eventdata)]\n\t\t\t\t\telse\n\t\t\t\t\t\t## Event doesn't exist, display warning\n\t\t\t\t\t\tinstance_type = get_instance_type_classname\n\t\t\t\t\t\tclassname = get_classname\n\t\t\t\t\t\tlog \"WARNING: #{instance_type} '#{classname}' tried to load Event '#{eventstr}' which doesn't exist.\"\n\t\t\t\t\t\tnext nil\n\t\t\t\t\tend\n\t\t\t\tend .reject { |x| !x } .to_h if (@data['events'])\n\t\t\tend", "def fetch_valid_test_events\n Event::NAME_CONFIG.each do |name, e_data|\n\n @client_webhook_setting.event_sources_array.each do |event_source|\n @client_webhook_setting.event_result_types_array.each do |result_type|\n\n next if result_type != e_data[:result_type] ||\n e_data[:inavlid_source].include?(event_source)\n\n event_data = GlobalConstant::Event.send(\"#{name}_event_data\")\n\n if event_source == GlobalConstant::Event.kyc_system_source\n event_data[:user_kyc_detail][:last_acted_by] = Admin::AUTO_APPROVE_ADMIN_ID\n end\n\n event = {\n client_id: @client_id,\n event_source: event_source,\n event_name: name,\n event_data: event_data,\n event_timestamp: Time.now.to_i,\n\n client_webhook_setting_id: @webhook_id,\n lock_id: lock_id\n }\n\n @valid_events[name] ||= []\n @valid_events[name] << event\n end\n end\n end\n end", "def events\n RoyalEvent::Event.where(\n \"id IN (#{subquery.to_sql})\"\n ).order(default_order)\n end", "def events\n subcomponents[\"VEVENT\"]\n end", "def get_district_events ( district_key, year )\n get_api_resource \"#{@@api_base_url}district/#{district_key}/#{year}/events\"\n end", "def getGroups\n groups = $gm.get(\"/groups\", @token, \"per_page=100\")\n group_ids = Array.new\n\n groups['response'].each do |group|\n group_ids.push({\n 'name' => group['name'],\n 'group_id' => group['id'],\n 'image' => group['image_url']})\n end\n\n return group_ids\n end", "def events=(value)\n @events = value\n end", "def index\n @events = Event.all\n @group = Group.find(params['group_id'])\n @tournament = Tournament.find(params['tournament_id'])\n end", "def get_events(id, opts = {})\n data, status_code, headers = get_events_with_http_info(id, opts)\n return data\n end", "def get_events(id, opts = {})\n data, status_code, headers = get_events_with_http_info(id, opts)\n return data\n end", "def events_on_day(day_num)\n events = []\n event.each { |e| events << e if e.days.include? day_num }\n events.sort_by(&:start_time)\n end", "def get_events\n # events created by this user\n @my_events = User.find(current_user.id).event_attendants.where('owner = 1')\n\n # events this user has joined\n @joined_events = User.find(current_user.id).event_attendants.where('attendee_status = 3 and owner IS NULL')\n \n # events this user is invited to\n @invited_to_events = User.find(current_user.id).event_attendants.where('attendee_status = 0')\n\n @maybe_events = User.find(current_user.id).event_attendants.where('attendee_status = 2')\n end", "def fGetAllEvents\n @sports.getAllEvents\n end", "def events_on(day)\n ((@ending_events_by_days[day] || []) + (@starting_events_by_days[day] || [])).uniq\n end", "def list_financial_event_groups(opts = {})\n data, _status_code, _headers = list_financial_event_groups_with_http_info(opts)\n data\n end", "def getAllEvents\n result = Hash.new\n @sports.each do |name,sport|\n events = Hash.new\n result[name] = events\n aux = sport.events\n aux.each do |eventID, event|\n result[name][eventID]=event\n end\n end\n result\n end", "def run\n event_list = @next_events\n @next_events = []\n\n handlers = @handlers.select { |o| group_enabled?(o.group) }\n\n event_list.each do |ev|\n handlers.each { |o| o.call(ev) if o.match?(ev) }\n end\n end", "def events\n object.events.last(10)\n end", "def get_all_events\n events, cursor = get_paginated_first\n while cursor do\n next_events, cursor = get_paginated_next(cursor: cursor)\n events += next_events\n end\n events\n .map(&:to_i)\n end", "def extract_events(calendar)\n events = []\n rep_until = Date.today >> MONTHS_ADVANCE_FOR_REPATING\n\n calendar.events.each do |event_entry|\n # for performance reasons, create event once and then clone per occurrence\n event = Event.build_from(Adapter.new(event_entry))\n occurences = event_entry.occurrences(:before => rep_until) \n # again, for performance and api limit reasons, get geo coordinates for repeating\n # events only once\n event.get_geo_coordinates #if occurences.size > 1\n \n occurences.each do |ical_event|\n adapter = Adapter.new(ical_event)\n occurrence = event.clone\n occurrence.starts_at = adapter.starts_at\n occurrence.ends_at = adapter.ends_at\n events << occurrence\n end\n end\n \n @log.info \"got #{events.size} events\"\n events\n end", "def events\n @events ||= Array(context[:events]).reverse.map { |event| Concierge::SafeAccessHash.new(event) }\n end", "def user_events\n @user_events ||= users.map { |u| u.events }.flatten\n end" ]
[ "0.7086922", "0.7068631", "0.68852425", "0.6611587", "0.65423834", "0.6539272", "0.65184", "0.6447683", "0.64321035", "0.6401753", "0.63984716", "0.63920224", "0.6338734", "0.63113487", "0.63113487", "0.62984455", "0.62915295", "0.62834764", "0.6280849", "0.6279172", "0.6275952", "0.627282", "0.6252311", "0.6245754", "0.6245754", "0.6243291", "0.61738133", "0.616934", "0.61135435", "0.6107575", "0.6098471", "0.60886407", "0.6085834", "0.60638744", "0.60584295", "0.6038375", "0.60234255", "0.60210156", "0.60136503", "0.6003403", "0.5964769", "0.5946845", "0.5922951", "0.59212947", "0.5914677", "0.590112", "0.58964705", "0.5895137", "0.5884456", "0.58815724", "0.58805144", "0.5877072", "0.5875265", "0.58612764", "0.5858648", "0.5824021", "0.5811949", "0.5801817", "0.57970506", "0.5789137", "0.5784626", "0.5767535", "0.57464933", "0.5741627", "0.5741627", "0.5739768", "0.57275456", "0.5721139", "0.5719091", "0.5714366", "0.56801844", "0.56775856", "0.5656036", "0.5645688", "0.564476", "0.56334656", "0.56231534", "0.5618553", "0.56118923", "0.56092775", "0.56015265", "0.55958474", "0.5587078", "0.5580876", "0.55718493", "0.5564508", "0.55643934", "0.5564123", "0.5564123", "0.5548727", "0.55390275", "0.5538525", "0.5538364", "0.5527716", "0.552614", "0.5521591", "0.5519449", "0.55112785", "0.5501075", "0.54989594", "0.54949605" ]
0.0
-1
=begin Initialize your data structure here. =end
def initialize() @hash = {} @values = [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_data\n end", "def init_data\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize() end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize\n\t\t\n\tend", "def initialize(_ = {})\n @data = {}\n end", "def initialize(data)\n\n end", "def initialize\n super()\n init_data()\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize; end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def init\n end", "def init\n end", "def init\n end", "def initialize()\n @node_cnt = 0;\n @hash_table = Hash.new(); # setup empty hash\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def initialize\n load_data\n end", "def initialize; @ary = []; end", "def initialize()\n #@ch = Concept.init_concept_hash()\n #Indexer.initialize_dict()\n #@ch = Indexer.init_concept_hash\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize data\n self.data = data\n end", "def initialize\n @data = []\n end", "def init\n\n end", "def init; end", "def initialize(data)\n\t\t@data = data\n\tend", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end", "def initialize()\n @additional_data = Hash.new\n end" ]
[ "0.7799752", "0.75177497", "0.71532923", "0.71532923", "0.71532923", "0.71532923", "0.70507306", "0.70324403", "0.70324403", "0.70324403", "0.70324403", "0.70324403", "0.70324403", "0.70324403", "0.70324403", "0.7016944", "0.70064306", "0.6933887", "0.6928044", "0.6923789", "0.68971026", "0.68843436", "0.68843436", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.6876142", "0.68748784", "0.68748784", "0.68748784", "0.68748784", "0.6855273", "0.6855273", "0.68535393", "0.68535393", "0.68535393", "0.6814226", "0.6814226", "0.6814226", "0.68044966", "0.6795798", "0.6795798", "0.6791091", "0.6790986", "0.6771624", "0.676175", "0.676175", "0.676175", "0.676175", "0.676175", "0.676175", "0.676175", "0.676175", "0.67606103", "0.6750893", "0.6747724", "0.67439884", "0.67197996", "0.67193455", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158", "0.6719158" ]
0.0
-1
=begin Inserts a value to the collection. Returns true if the collection did not already contain the specified element. :type val: Integer :rtype: Boolean =end
def insert(val) hash[val] = Set.new unless hash[val] hash[val].add(values.size) values.push(val) hash[val].size == 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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(val)\n @set.include?(val) ? nil : @set.push(val)\n end", "def insert(val)\n return false if @number_index_map.key?(val)\n @number_list << val\n @number_index_map[val] = @number_list.length - 1\n true\n end", "def insert(val)\n return false if @hh.key?(val)\n @hh[val] = val\n return true\n end", "def insert(val)\n if map.key?(val)\n false\n else\n map[val] = size\n arr[size] = val\n self.size += 1\n true\n end\n end", "def push(value)\n\t\t\tif @storage.insert(0, value)\n\t\t\t\ttrue\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend", "def insert(val)\n res = true\n res = false if @pos.key?(val)\n @pos[val] = [] unless @pos.key?(val)\n @pos[val] << @num.size\n @num << [val, @pos[val].size - 1]\n res\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 add(value)\n found = true\n @values.delete(value) { found = false }\n @values[value] = true\n @values.shift if @values.length > @capacity\n found\n end", "def insert(num)\n false if include?(num)\n self[num] << num\n true\n end", "def add(value)\n result = super(value)\n if (result)\n # only track if new element not in set\n @elements.add(value)\n end\n return result\n end", "def add_key_value?(key, val)\n @store.transaction do\n return false if @store.to_h.key? key\n @store[key]=val\n end\n true\n end", "def contains?(val)\n \t@array.each do |element|\n \t\treturn true if element.value == val\n \t\treturn false if element.value != val\n \t\tuntil node.next_node == nil\n \t\tend\n \tend \n end", "def setnx(value)\n if exists?\n false\n else\n set value\n true\n end\n end", "def add(value)\n # The include?(value) iterates through each element of the array till it finds the value in Array\n # So the complexity is O(n) in the worst case (value is not in array)\n # If we are here the @values have n elements already sorted\n # So is more efficient use a binary search for check if value is on array\n # Using binary search we can get:\n # - a O(log(n)) in the worst case (looking for a value already contained the array)\n # - a O(1) in the best case (looking for a value not contained in the array yet)\n # Finally using binary search we can have\n # - if the value is not in array a total time complexity of O(log(n)) + O(n*log(n))\n # - if the value is in array a total time complexity of O(1)\n if include?(value)\n false\n else\n # Complexity of adding value with the << operator is O(1)\n @values << value\n # Ruby use a Quicksort With Median of Three Pivot selection for sort method\n # The complexity of quicksort in the average case is O(n*log(n))\n @values.sort!\n true\n end\n end", "def include?(val)\n self.each {|item|\n if item.equal?(val)\n return true\n end\n }\n return false\n end", "def insert(value)\n #get hashed value\n hash_value = hash_function(value)\n # insert value\n @@collection[hash_value] = value\n\n # return confirmation\n \"value: \" << value << \" inserted at position: \" << hash_value.to_s\n end", "def append(val)\n if(@entries != @length)\n @position += 1\n @entries += 1\n @store[@position] = val\n end \n end", "def add(value)\n add?(value) || self\n end", "def contains?(val)\n node = @head\n while !(node.nil?)\n return true if node.value == val\n node = node.next_node\n end\n return false\n end", "def insert_last(value)\n if @queue.size < @size\n @queue.push(value)\n true\n else\n false\n end\n end", "def insert(insert_val)\n\t\t\tcase value <=> insert_val\n\t\t\twhen 1 \n\t\t\t\tinsert_left insert_val\n\t\t\twhen -1\n\t\t\t insert_right insert_val\n\t\t\twhen 0\n\t\t\t false\n\t\t\tend\n\t\tend", "def try_insert_new(value)\n return false if used == @size\n\n entry = GClockBufferEntry.new(value, 1)\n @buffer[@pointer] = entry\n advance_pointer\n\n true\n end", "def remove(val)\n return false if !hash[val] || hash[val].empty?\n\n # Update values array\n idx = hash[val].first\n last = values[-1]\n values[idx] = last\n\n # Remove last from array\n values.pop\n\n # Remove val\n hash[val].delete(idx)\n\n # Update last\n hash[last].add(idx)\n hash[last].delete(values.size)\n\n true\n end", "def value?(value)\n values.include? value\n end", "def insert(value) # rubocop:disable Metrics/MethodLength\n puts \"I want to insert #{value}\"\n initial_value = value\n starting_bucket = bucket = compute_bucket(value)\n puts \"I want to put it in bucket #{bucket}\"\n\n loop do\n contents = table[bucket]\n\n if contents == initial_value # This value is already in the HashTable\n puts \"#{contents} is already in bucket #{bucket}: stopping\"\n break false\n elsif contents.blank? # This is an available spot.\n puts \"Looks like bucket #{bucket} is empty. Let's put it there.\"\n insert_into_bucket(value, bucket)\n break true\n else # We need to keep searching for a spot.\n puts \"Bucket #{bucket} has value #{contents}. Need to keep looking.\"\n value = swap_if_needed(value, bucket)\n\n bucket = increment_bucket(bucket)\n raise LOOPED_MESSAGE if bucket == starting_bucket\n end\n end\n end", "def include?(value)\n @values.include? value\n end", "def insert(doc)\n\t\tif !defined?(@collection)\n\t\t\treturn false\n\t\tend\n\n\t\tif validate(doc)\n\t\t\treturn @collection.insert(doc)\n\t\tend\n\tend", "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 contains?(val)\n current = @head\n while current.next?\n current = current.next_node\n return true if current.value == val\n end\n false\n end", "def try_touch(value)\n result = contains? value\n touch(value) if result\n result\n end", "def add_key_value?(key, val)\n hash = load_hash\n return false if hash.key? key\n hash[key] = val\n store_hash hash\n true\n end", "def contains?(val)\n return nil if @head == nil\n\n result = false\n\n node = @head\n until node.next_node.nil?\n if node.value == val\n result = true\n break\n end\n node = node.next_node\n end\n\n result\n end", "def add_at_index(index, val)\n return if index > @list.size \n @list.insert(index, val)\n end", "def add(val)\n @heap.push_and_get(val)\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 include?(value)\n element.include? value\n end", "def <<(value)\n self[value] = true\n self\n end", "def valid?(val)\n vals.include? val\n end", "def set_unless_exists(key, val)\n val = redis_marshal(val)\n timeout_retry(3, 3){\n write \"SETNX #{key} #{val.to_s.size}\\r\\n#{val}\\r\\n\"\n integer_reply == 1\n }\n end", "def contain?(value)\n\t\tcurrent = @head\n\t\twhile current \n\t\t\treturn true if current.value == value\n\t\t\tcurrent = current.next\n\t\tend\n\t\tfalse \n\tend", "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 set(key, val)\n return unless val\n db[key] = val\n end", "def << value\n add(value)\n end", "def remove(val)\n return false unless @number_index_map.key?(val)\n index = @number_index_map[val]\n last_element = @number_list[-1]\n @number_list[index] = last_element\n\n @number_list.pop\n @number_index_map[last_element] = index\n @number_index_map.delete(val)\n true\n end", "def contains? (value)\n return false if @head.nil?\n\n self.each {|current| return true if current.data == value}\n \n return false \n end", "def insert(member)\n #check if the thing is already in storage\n @store << member unless @store.include? (member)\n end", "def add(array, element)\n array.push(element) unless array.include?(element)\nend", "def insert_front(value)\n if @queue.size < @size\n @queue.unshift(value)\n true\n else\n false\n end\n end", "def contains?(value)\n retval = false\n if @size == 0\n return false\n else\n search_index = @head\n loop {\n if search_index == nil\n break;\n end\n if search_index.value == value\n return true\n end\n search_index = search_index.next_node\n }\n end\n retval\n end", "def exists? value\n !self[index_of(value)].nil?\n end", "def exists? value\n !self[index_of(value)].nil?\n end", "def contains? (value)\n return false if @size == 0\n if @root.value == value\n \t\treturn true\n \tend\n \tnode=@root.next_node\n while(node!=nil)\n if node.value == value\n \treturn true\n end\n node=node.next_node\n end\n return false\n end", "def add(val)\n @nums = SortHelper.insert(@nums, val)\n @nums[@nums.length - @k]\n end", "def insert(num)\n self[num].push(num) unless include?(num)\n end", "def place!(val, &block)\n pos = nil\n orig_size = self.size\n block ||= lambda{|a, b| a <=> b}\n self.each_with_index do |e, i|\n if block.call(e, val) == 1\n pos = i\n break\n end\n end\n return nil unless pos\n self.insert(pos, val)\n while self.size > orig_size\n self.pop\n end\n val\n end", "def is?(val)\n return true if @val == val\n end", "def insert(value)\n store.push value\n swim(length)\n self\n end", "def try_put(new_value)\n return false if @tvar.value != EMPTY\n\n @tvar.value = new_value\n true\n end", "def add(val)\n get_node(val) #every new element that has to be added should point to a new node correponding to it.\n list_size = @elements.size\n last_element_index = list_size - 1\n @elements[last_element_index].next_node = list_size\n new_element_index = list_size\n @elements[new_element_index] = @node\n end", "def add_unless_present(col, obj)\n already_in = col.include?(obj)\n col << obj unless already_in\n !already_in\n end", "def contains?(value)\n return false if head.nil?\n\n curr = head\n until curr.nil?\n return true if curr.value == value\n\n curr = curr.next\n end\n false\n end", "def contains?(value)\n return false if @head.nil?\n node = @head\n limit = size - 1\n limit.times do\n break if node.data == value\n node = node.next_node\n end\n if value == node.data \n true\n else\n false\n end\nend", "def add(value)\n @values << value\n end", "def contains?(value)\n node = list\n while node != nil\n return true if node.value == value\n node = node.nextNode\n end\n return false\n end", "def 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 try_put!(value)\n @mutex.synchronize do\n if unlocked_empty?\n @value = value\n @full_condition.signal\n true\n else\n false\n end\n end\n end", "def include?(arr, val)\n arr.each { |el| return el == val if el == val }\n false\nend", "def push(value)\n insert(value)\n self\n end", "def include?(value)\n each do |index, list_value|\n return true if list_value == value\n end\n return false\n end", "def contains?(value)\n node = @head\n until node.nil?\n return true if node.value == value \n node = node.link\n end\n false\n end", "def value_exists?(value)\n\t\tcurrent_node = @head\n\t\tuntil current_node.value == value \n\t\t\treturn false if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\ttrue \n\tend", "def add_val_to_fld(solr_input_doc, fld_name, value)\n if !solr_input_doc.nil? && !fld_name.nil? && fld_name.size > 0 && !value.nil? && value.size > 0\n if !solr_input_doc[fld_name].nil? && solr_input_doc\n existing_vals = solr_input_doc[fld_name].getValues\n end\n if existing_vals.nil? || !existing_vals.contains(value)\n solr_input_doc.addField(fld_name, value, 1.0)\n end\n end\n end", "def include?(value)\n !get(value).nil?\n end", "def remove(val)\n return false unless @hh.key?(val)\n @hh.delete(val)\n return true\n end", "def include?(ary, value)\n !!ary.index(value)\nend", "def contains?(value)\n temp = @head\n while temp\n return true if temp.value == value\n temp = temp.next_node\n end\n false\n end", "def push(val)\n if @count >= capacity()\n resize!()\n end\n @store.store.each_with_index do |ele, i|\n if ele == nil \n @first_nil = i\n break\n end\n end\n @store[@first_nil] = val\n @count += 1\n end", "def contains?(value)\n current_node = @head\n until current_node.nil?\n return true if current_node.value == value\n\n current_node = current_node.next_node\n end\n false\n end", "def push(val)\n # O(1) time\n @arr << val\n\n @min << if @min.empty?\n val\n else\n (val < @min.last) ? val : @min.last\n end\n end", "def insert(fingerprint)\n return false unless has_space?\n\n @slots.each do |slot|\n if slot.empty?\n slot.set(fingerprint)\n @filled = [(@filled + 1), 4].min\n return true\n end\n end\n\n false\n end", "def has_value? val\n self.keys.each do |k|\n return true if self[k].include? val\n end\n return false\n end", "def include?(element)\n @ary.include? element\n end", "def include?(value)\n return false if empty?\n splay(value)\n @root.value == value\n end", "def insert(item)\n return false unless has_space?\n\n fingerprint = fingerprint(item)\n first_index = hash(item)\n second_index = alt_index(first_index, fingerprint)\n\n if @buckets[first_index].insert(fingerprint) || @buckets[second_index].insert(fingerprint)\n increment_filled_count\n return true\n end\n\n index = [first_index, second_index].sample\n\n @max_kicks.times do\n fingerprint = @buckets[index].random_swap(fingerprint)\n index = alt_index(index, fingerprint)\n\n if @buckets[index].insert(fingerprint)\n increment_filled_count\n return true\n end\n end\n\n return false\n end", "def en_queue(value)\n return false if self.is_full\n\n @queue[@rear] = value\n if @rear == @queue.size - 1\n @rear = 0\n else\n @rear += 1\n end\n true\n end", "def contains?(value)\n if head == nil\n false\n else\n tmp = head\n while tmp != nil && tmp.value != value\n tmp = tmp.next_node\n end\n\n if tmp == nil\n false\n else\n true\n end\n end\n end", "def contains?(value)\n if @head.nil?\n 'List is empty'\n else\n current_node = @head\n until current_node.nil?\n return true if current_node.value == value\n\n current_node = current_node.next_node\n end\n false\n end\n end", "def set(key, value)\r\n\t\t# Do not modify object if key already exists or if total exceeds size\r\n\t\treturn false if key==nil || value == nil || get(key) != nil || @total >= @size\r\n\t\t# Get the hash of our key\r\n\t\tindex = key.hash % @size\r\n\t\t# If something exists at that location then we must add a node to our \r\n\t\t# LinkedList otherwise we create a list at that location\r\n\t\tif @arr[index]\r\n\t\t\t@arr[index].add(key, value)\r\n\t\telse\r\n\t\t\t@arr[index] = LinkedList.new(key, value)\r\n\t\tend \r\n\t\t# Increase the total by 1 and return true\r\n\t\t@total += 1\r\n\t\treturn true\r\n\tend", "def search(value)\n #get hashed value\n hash_value = hash_function(value)\n\n # if value exists return true\n if @@collection[hash_value] == value\n return true\n else\n return false\n end\n end", "def contains?(value) \n node = @head\n while(node.value != value)\n node = node.next_node\n if(node == @tail) && (node.value != value)\n return false\n end\n end\n return true\n end", "def includ?(array, value)\n\tarray.each do |element|\n\t\tif element == value\n\t\t\treturn true\n\t\tend\n\tend\n\tfalse\nend", "def contains?(val,node=head)\n return nil if node.next == nil\n return true if node.data == val\n return contains?(val,node.next)\n end", "def ==(val)\n return true if @val == val\n end", "def put(index,val)\n # preconditions and invariants\n _invariants\n assert(_inbounds(index,self),\"pre-condition\")\n assert((val.is_a? Numeric), \"pre-condition\")\n # keep track for post-conditions\n oldVal = self[index]\n oldRepItemCount = self.internalRepItemCount\n\n @delegate.put(index,val)\n\n # post conditions and invariants\n _invariants\n assert_equal( self[index], val, \"post-condition\" )\n assert(self.include?(val), \"post-condition\")\n # slightly different behavior for setting zero and non-zero values\n if val == 0 and oldVal != 0\n assert_equal(self.internalRepItemCount,oldRepItemCount-1,\"post-condition\")\n elsif (val != 0 and oldVal != 0) or (val == 0 and oldVal == 0)\n assert_equal(self.internalRepItemCount,oldRepItemCount,\"post-condition\")\n elsif val != 0 and oldVal == 0\n assert_equal(self.internalRepItemCount,oldRepItemCount+1,\"post-condition\")\n end\n end", "def add?(value)\n node = TreeNode.new(value)\n added = if root.nil?\n @root = node\n else\n @root.add(node)\n end\n if added\n @length += 1\n self\n else\n nil\n end\n end", "def add(play)\n\t\t\tif play == nil then return end\n\t\t\t# checks if the play is already int he array\n\t\t\tif play_exists?(play.id)\n\t\t\t\t#shoudl note number of non added games\n\t\t\t\tputs 'play already included'\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t# if not\n\t\t\t@plays.push(play)\n\t\t\treturn true\n\t\tend", "def set(key, value)\n\n\t\t#a variable to see if the values are in the array\n\t\tinside = false\n\n\t\t#iterate through the array\n\t\ti = 0\n\t\twhile i < @size\n\n\t\t\t#if there is no key correspondent with the index\n\t\t\tif @array[i] == nil\n\t\t\t\t#the element will become the key\n\t\t\t\t@array[i] = key\n\t\t\t\t#and the next one will become the value\n\t\t\t\t@array[i+1] = value\n\t\t\t\t#set the inside variable to true\n\t\t\t\tinside = true\n\t\t\t\t#return the value of inside\n\t\t\t\treturn inside\n\t\t\t#if there is already a key and the user wants to overwrite it\n\t\t\telsif @array[i] == key\n\t\t\t\t#the new value is assigned\n\t\t\t\t@array[i+1] = value\n\t\t\t\t#set the inside variable to true\n\t\t\t\tinside = true\n\t\t\t\t#return the value of inside\n\t\t\t\treturn inside\n\t\t\tend\n\n\t\t\t#else, we will iterate through all even in the array\n\t\t\ti += 2 \n\n\t\tend\n\n\t\t#if the operation fails, that means, everything is filled, or anything else, return inside as false\n\t\treturn inside\n\t\t\n\tend", "def contains(val, path=nil)\n fn = function(:contains, self, Sequel.object_to_json(val), path)\n Sequel::SQL::BooleanExpression.new(:NOOP, fn)\n end", "def has_value?(value); end" ]
[ "0.75590783", "0.7356093", "0.71431", "0.7066172", "0.67980886", "0.6683719", "0.66010106", "0.6525003", "0.6509468", "0.6493217", "0.6231391", "0.6192678", "0.6155127", "0.60978436", "0.6065289", "0.59597135", "0.5879541", "0.58649284", "0.58424693", "0.5828541", "0.5828429", "0.58096045", "0.57700896", "0.5756266", "0.5721672", "0.5692612", "0.56786907", "0.5640902", "0.56393754", "0.56226635", "0.55838656", "0.55791193", "0.5579069", "0.55736893", "0.5569675", "0.55687165", "0.554659", "0.5536779", "0.553249", "0.55082244", "0.5507441", "0.5506087", "0.54948497", "0.5468842", "0.54673785", "0.54569846", "0.54398817", "0.54273474", "0.5426603", "0.54256815", "0.5412024", "0.5412024", "0.54110414", "0.5386228", "0.5383795", "0.53810346", "0.5371022", "0.5368047", "0.53562057", "0.5355878", "0.5350812", "0.5339388", "0.5331694", "0.53135264", "0.53088504", "0.5302415", "0.5298493", "0.5296851", "0.5281867", "0.5274208", "0.52733004", "0.5264212", "0.52607214", "0.525584", "0.5250249", "0.52436763", "0.5242299", "0.524201", "0.523093", "0.52287704", "0.52185726", "0.5211705", "0.5210612", "0.520561", "0.52032244", "0.5194672", "0.51873785", "0.51845807", "0.5181374", "0.51812804", "0.5172463", "0.5170899", "0.51609385", "0.51582086", "0.51552975", "0.5145545", "0.5142583", "0.5127066", "0.51222503", "0.51167774" ]
0.74929804
1
=begin Removes a value from the collection. Returns true if the collection contained the specified element. :type val: Integer :rtype: Boolean =end
def remove(val) return false if !hash[val] || hash[val].empty? # Update values array idx = hash[val].first last = values[-1] values[idx] = last # Remove last from array values.pop # Remove val hash[val].delete(idx) # Update last hash[last].add(idx) hash[last].delete(values.size) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(val)\n return false unless @number_index_map.key?(val)\n index = @number_index_map[val]\n last_element = @number_list[-1]\n @number_list[index] = last_element\n\n @number_list.pop\n @number_index_map[last_element] = index\n @number_index_map.delete(val)\n true\n end", "def remove(val)\n return false if @pos.empty? || !@pos.key?(val)\n\n lastval, lastidx = @num.last\n @pos[lastval][lastidx] = @pos[val].last\n @num[@pos[val].last] = @num.last\n @num.pop\n @pos[val].pop\n @pos.delete(val) if @pos[val] == []\n true\n end", "def remove value\n return false if value.nil?\n\n index = map_get_index_of(value)\n remove_at(index) unless index.nil?\n\n return !index.nil?\n end", "def remove(val)\n return false unless @hh.key?(val)\n @hh.delete(val)\n return true\n end", "def remove(val)\n return false if ! @h[val]\n # Swap in the array last element\n # and elemet to be delted.\n i,j = @h[val], @a.size - 1\n a,b = val,@a[j]\n @h[a],@h[b] = @h[b],@h[a]\n @a[i],@a[j] = @a[j],@a[i]\n @a.pop\n @h[val] = nil\n return true\n end", "def remove(val)\n if map.key?(val)\n idx = map.delete(val)\n if idx != size - 1\n arr[idx], arr[size - 1] = arr[size - 1], arr[idx]\n map[arr[idx]] = idx\n end\n self.size -= 1\n true\n else\n false\n end\n end", "def eliminate(val)\r\n @modified = true if @candidates.delete(val) != nil\r\n @value = @candidates.first if @candidates.size == 1\r\n end", "def delete(val)\n count = self.lrem(0, val)\n if count > 0\n val\n else\n nil\n end\n end", "def delete(value)\n index = find(value)\n return false if index == -1\n @inner[index] = @inner[@inner.length - 1]\n @inner.delete_at(@inner.length - 1)\n return true\n end", "def remove_element(nums, val)\n return nil if !nums \n # while nums.delete(val)\n # # nums.delete(val)\n # end\n nums.each {|element| nums.delete(element) if val == element}\n return nums.length\nend", "def contains?(val)\n \t@array.each do |element|\n \t\treturn true if element.value == val\n \t\treturn false if element.value != val\n \t\tuntil node.next_node == nil\n \t\tend\n \tend \n end", "def remove(value)\n if self.include?(value)\n if head.data == value\n remove_head(value, head)\n else\n remove_value(value, head)\n end\n else\n return nil\n end\n end", "def delete(value)\n index = binary_search(value)\n return false if index == -1\n index.upto(@inner.length - 2) { |i| @inner[i] = @inner[i + 1] }\n @inner.delete_at(@inner.length - 1)\n return true\n end", "def delete(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value == value \n\t\t\t@head = current_node.next_node\n\t\tend \n\t\tuntil current_node.next_node.value == value \n\t\t\treturn false if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = current_node.next_node.next_node\n\tend", "def remove(x)\r\n if (x.kind_of?(Hashable))\r\n pos = position(x)\r\n if @array[pos].remove(x) # if true\r\n @items -= 1 # subtract one item\r\n return true\r\n else\r\n return false\r\n end\r\n else\r\n raise ArgumentError, \"Argument not of type Hashable\"\r\n end\r\n end", "def remove(val)\n\nend", "def remove_element(nums, val)\n nums.delete(val)\n nums.length\nend", "def remove_element(nums, val)\n return 0 if nums.empty? || (nums.size == 1 && nums[0] == val)\n start = 0\n nums.each_with_index do |num, index|\n if num != val\n nums[start] = num\n start += 1\n end\n end\n nums[0..(start - 1)]\nend", "def eliminate (val, idx)\n # Note that delete! does in-place deletion, and \n # returns nil if the character isn't found\n if @array[idx].delete!(val)\n new_length = @array[idx].length\n if new_length == 0\n return false\n elsif new_length == 1\n val2 = @array[idx]\n result = true\n $peers[idx].each do |idx2|\n result = result && eliminate(val2, idx2)\n end\n if !result\n return false\n end\n end\n\n # Check if deleting this value means that there's only\n # one of this value left in the current row/column/box\n result = true\n [$rows[idx], $columns[idx], $boxes[idx]].each do |unit|\n places = unit.select { |idx| @array[idx].count(val) > 0 }\n if places.length == 0\n return false\n elsif places.length == 1\n # val must go at that location\n result = result && assign(val, places[0])\n end\n end\n if !result\n return false\n end\n end\n true\n end", "def remove(value)\n if value.kind_of? Array\n value.each { |v| remove(v) }\n else\n value = PublicEarth::Db::Base.as_id(value)\n value = value.id if value.is_a? Atlas::Place\n value.strip! if value.kind_of? String\n @values.delete(value)\n end\n end", "def delete(value)\n\t \n if @root == nil \n return false\n end\n \n #Obtenemos el nodo a remover\n\t toRemove = selectElement(value,@root)\n \n ## Mandamos a buscar al padre del nodo\n father = getFather(value,@root,toRemove)\n \n if !isLeaft(toRemove,father) ## remueve elemento al encontrarlo y sea hoja\n promote(toRemove,father) ##Verificamos si es hijo unico\n end\n \n return true\n end", "def remove_element(nums, val)\n nums.each_with_index do |num, i|\n if num == val\n nums[i] = nil\n end\n end\n nums.compact!\n nums.length\nend", "def removeElement(nums, val)\n if nums.nil? then\n 0\n else\n fast = slow = 0\n while fast < nums.size do\n if not nums[fast]==val then\n nums[slow] = nums[fast]\n slow += 1\n end\n fast += 1\n end\n slow\n end\nend", "def delete(value)\n #get hashed value\n hash_value = hash_function(value)\n\n # check if value exists\n result = search(value)\n\n # if value exists\n if result\n # set value to nil\n @@collection[hash_value] = nil\n # return confirmation\n \"value deleted\"\n else\n # return error message\n \"value not found\"\n end\n\n\n end", "def contains?(val)\n node = @head\n while !(node.nil?)\n return true if node.value == val\n node = node.next_node\n end\n return false\n end", "def include?(val)\n self.each {|item|\n if item.equal?(val)\n return true\n end\n }\n return false\n end", "def remove_elements(head, val)\n return head if head.nil?\n\n tail = head.next\n\n if head.val == val\n remove_elements(tail, val) # throw away current head\n else\n head.next = remove_elements(tail, val)\n head # keep/return current head\n end\nend", "def remove(value)\n\t\t\telement = self.head\n\t\t\tprevious_element = @head\n\t\t\twhile element.value != value\n\t\t\t\tif element.next.nil?\n\t\t\t\t\treturn nil\n\t\t\t\telse\n\t\t\t\t\tprevious_element = element\n\t\t\t\t\telement = element.next\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tprevious_element.next = element.next\n\t\t\telement\n\t\tend", "def contains?(val)\n current = @head\n while current.next?\n current = current.next_node\n return true if current.value == val\n end\n false\n end", "def delete(value)\r\n return nil if !@head\r\n if @head.data == value\r\n @head = @head.next \r\n return nil\r\n end \r\n cursor = @head\r\n while cursor.next && cursor.next.data != value\r\n cursor = cursor.next\r\n end\r\n cursor.next = cursor.next.next if cursor.next\r\n end", "def remove_elements(head, val)\n loop do\n return unless head\n break if head.val != val\n head = head.next\n end\n\n current_node = head\n next_node = head.next\n\n while next_node\n if next_node.val == val\n next_node = next_node.next\n current_node.next = next_node\n else\n current_node = next_node\n next_node = next_node.next\n end\n end\n\n head\nend", "def remove(value)\n current = @head\n current = current.next while current && current.value != value\n return raise \"Value not found: #{value}\" if current.nil?\n\n if current == @head\n @head = @head.next\n @head.prev = nil unless @head.nil?\n @size -= 1\n return\n end\n if current == @tail\n @tail = @tail.prev\n @tail.next = nil unless @tail.nil?\n @size -= 1\n return\n end\n current.prev.next = current.next\n current.next.prev = current.prev\n @size -= 1\n end", "def contains?(val)\n return nil if @head == nil\n\n result = false\n\n node = @head\n until node.next_node.nil?\n if node.value == val\n result = true\n break\n end\n node = node.next_node\n end\n\n result\n end", "def delete(value:)\n if @head.value == value\n if @head.next.nil?\n @head.value = nil\n return value\n else\n @head = @head.next\n return value\n end\n else\n prev = @head\n temp = @head.next\n\n while !temp.nil?\n if temp.value == value\n prev.next = temp.next\n return value\n end\n\n prev = temp\n temp = temp.next\n end\n end\n\n return false # Not great to return different types but this is for fun\n end", "def remove(value)\n\t\t\n\t\tnode = @head\n\t\twhile node.value.sal != value do\n\t\t\tnode = node.next\n\t\tend\n\t\t\n\t\tif node != nil\n\t\t\n\t\t\tif node != @head\n\t\t\t\tnode.prev.next = node.next\n\t\t\telse\n\t\t\t\t@head = node.next\n\t\t\tend\n\n\t\t\tif node != @tail\n\t\t\t\tnode.next.prev = node.prev\n\t\t\telse\n\t\t\t\t@tail = node.prev\n\t\t\tend\n\n\t\t\t@size-=1\n\t\tend\t\t\t\n\t\t\t\t\n\tend", "def delete(value)\n return nil if !@head\n if @head.data == value\n @head = @head.next\n @head.prev = nil\n return\n end \n cursor = @head\n while cursor && cursor.data != value\n cursor = cursor.next\n end\n\n if cursor\n cursor.prev.next = cursor.next\n cursor.next.prev = cursor.prev if cursor.next\n @tail = cursor.prev if cursor == @tail\n \n end\n end", "def delete(value)\n if search(value)\n if value == @root.getData()#Descartamos la eliminacion de la raiz\n if @root.getLeft() == nil and @root.getRight() == nil#verificamos el caso\n @root = nil\n else\n temp_root = Node.new(-100000) #Asignamos nodo temporal\n @removeMethods.promote(@root,temp_root) #encontramos el mejor elemento\n @root = temp_root.getRight() #Asignamos nuevo nodo con remplazo ideal\n end\n startMethods() ##enviamos actualizacion de nodo\n return true\n else\n return @removeMethods.delete(value)\n end\n else\n return false\n end\n end", "def >>(value)\n remove(value)\n self\n end", "def remove_element(nums, val)\n instance_val_pointer = 0\n\n for i in (0...nums.size) do\n if nums[i] != val\n nums[instance_val_pointer] = nums[i]\n instance_val_pointer += 1\n end\n end\n \n return instance_val_pointer\nend", "def delete(value)\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.data == value \r\n if prev == nil\r\n @head = curr.next \r\n else \r\n prev.next = curr.next \r\n end\r\n return\r\n\r\n else\r\n prev = curr\r\n curr = curr.next\r\n end\r\n end\r\n\r\n # if u reached this point, then nothing matches, and no changes made to list\r\n end", "def remove(value)\n connection.zrem(key_label, value)\n end", "def contains?(value) \n node = @head\n while(node.value != value)\n node = node.next_node\n if(node == @tail) && (node.value != value)\n return false\n end\n end\n return true\n end", "def remove_elements_recursion(head, val)\r\n return nil if !head\r\n \r\n head.next = remove_elements_recursion(head.next, val)\r\n\r\n return head.val == val ? head.next : head\r\nend", "def remove_element(nums, val)\n n = nums.length\n pointer = 0\n\n while pointer < n\n if nums[pointer] == val\n nums[pointer] = nums[n - 1]\n n -= 1\n else\n pointer += 1\n end\n end\n\n pointer\nend", "def delete_node(value)\n return false unless @head\n curr_node = @head\n\n if @head.value == value\n @head = @head.next\n return true\n end\n\n while curr_node.next\n if value == curr_node.next.value\n curr_node.next = curr_node.next.next\n return true\n else\n curr_node = curr_node.next\n end\n end\n end", "def remove_element_in_place(nums, val)\n\nend", "def remove(value)\n #YOUR WORK HERE\n end", "def remove(name)\n return false if storage.empty?\n\n if registered?(name)\n storage.delete(name)\n storage unless storage.is_a?(Set)\n\n else\n false\n\n end\n end", "def delete?(value)\n value = RDF::Literal(value) if value.is_a? Symbol\n\n return nil if parent.query([rdf_subject, predicate, value]).nil?\n\n delete(value)\n value\n end", "def remove_elements(head, val)\n return nil if head.nil?\n\n dummy = ListNode.new(nil)\n dummy.next = head\n current = dummy\n\n while current.next\n if current.next.val == val\n current.next = current.next.next\n else\n current = current.next\n end\n end\n\n dummy.next\nend", "def delete_all(arr, val)\n # delete all the elements of the array where element = val\n return arr.delete(val) \nend", "def contains? (value)\n return false if @head.nil?\n\n self.each {|current| return true if current.data == value}\n \n return false \n end", "def exists? value\n !self[index_of(value)].nil?\n end", "def exists? value\n !self[index_of(value)].nil?\n end", "def remove_value(value)\n @children['value'][:value].delete(value)\n end", "def delete_value value\r\n #find the pointer to the wanted node using LIST-SEARCH(value)\r\n #then delete that node with LIST-DELETE-BY-NODE(node)\r\n delete_node(self.search(value))\r\n end", "def contains(val, path=nil)\n fn = function(:contains, self, Sequel.object_to_json(val), path)\n Sequel::SQL::BooleanExpression.new(:NOOP, fn)\n end", "def delete_elem(elem)\n reject(&elem.method(:eql?))\n end", "def contains?(value)\n node = list\n while node != nil\n return true if node.value == value\n node = node.nextNode\n end\n return false\n end", "def contains?(value)\n return false if head.nil?\n\n curr = head\n until curr.nil?\n return true if curr.value == value\n\n curr = curr.next\n end\n false\n end", "def contains?(value)\n retval = false\n if @size == 0\n return false\n else\n search_index = @head\n loop {\n if search_index == nil\n break;\n end\n if search_index.value == value\n return true\n end\n search_index = search_index.next_node\n }\n end\n retval\n end", "def contain?(value)\n\t\tcurrent = @head\n\t\twhile current \n\t\t\treturn true if current.value == value\n\t\t\tcurrent = current.next\n\t\tend\n\t\tfalse \n\tend", "def remove(value)\n if head.value == value\n @head = head.next\n else\n current_node = head.next\n prev_node = head\n while current_node\n if current_node.value == value\n prev_node.next = current_node.next\n return\n else\n prev_node = current_node\n current_node = current_node.next\n end\n end\n nil\n end\n end", "def remove_record(value)\n @children['record'][:value].delete(value)\n end", "def remove_record(value)\n @children['record'][:value].delete(value)\n end", "def empty?\n !value\n end", "def includ?(array, value)\n\tarray.each do |element|\n\t\tif element == value\n\t\t\treturn true\n\t\tend\n\tend\n\tfalse\nend", "def remove_element(nums, val)\n pointer1 = 0\n nums.each_with_index do |num, pointer2|\n if val != num\n nums[pointer1] = nums[pointer2]\n pointer1 += 1\n end\n end\n pointer1\nend", "def contains?(value)\n if head == nil\n false\n else\n tmp = head\n while tmp != nil && tmp.value != value\n tmp = tmp.next_node\n end\n\n if tmp == nil\n false\n else\n true\n end\n end\n end", "def contains?(value)\n if @head.nil?\n 'List is empty'\n else\n current_node = @head\n until current_node.nil?\n return true if current_node.value == value\n\n current_node = current_node.next_node\n end\n false\n end\n end", "def contains\n \t\tfalse\n\tend", "def delete!\n values.delete!\n end", "def removeFromCollection(objs)\n method = 'removeFromCollection'\n type = Boolean\n args = {:keys=>Rdio::keys(objs)}\n return_object type,method,args\n end", "def find(value)\n @set.each do |k,v|\n return true if ((value-k) == k) ? @set[value-k] > 1 : @set[value - k]\n end\n return false\n end", "def contains?(value)\n return false if @head.nil?\n node = @head\n limit = size - 1\n limit.times do\n break if node.data == value\n node = node.next_node\n end\n if value == node.data \n true\n else\n false\n end\nend", "def has_value? val\n self.keys.each do |k|\n return true if self[k].include? val\n end\n return false\n end", "def add(value)\n found = true\n @values.delete(value) { found = false }\n @values[value] = true\n @values.shift if @values.length > @capacity\n found\n end", "def include?(ary, value)\n !!ary.index(value)\nend", "def add(val)\n @set.include?(val) ? nil : @set.push(val)\n end", "def remove_element(nums, val)\n\n # puts \"array before: #{nums}\"\n # #recognize if there's a match between the val & a value in the array\n # nums.each_with_index {|value, index|\n # #recognize a match (between target value & array's value)\n # if value == val\n # puts \"match\"\n # #delete matching array element\n # nums.delete_at(index)\n # end\n # }\n # puts \"array after: #{nums}\"\n # #return size of the revised array\n # puts \"revised array is of size #{nums.size}\"\n\n array_index = 0\n\n puts \"array before: #{nums}\"\n while array_index < nums.size \n if nums[array_index] == val\n nums.delete_at(array_index) #identify a match, and delete the array element\n else\n array_index += 1 \n end\n end\n puts \"array after: #{nums}\"\n puts \"revised array is of size #{nums.size}\"\n\n # return nums.size\n\n\n\n\n\n\nend", "def remove(value)\n @client.execute_udf(@key, @PACKAGE_NAME, 'remove', [@bin_name, value], @policy)\n end", "def contains? (value)\n return false if @size == 0\n if @root.value == value\n \t\treturn true\n \tend\n \tnode=@root.next_node\n while(node!=nil)\n if node.value == value\n \treturn true\n end\n node=node.next_node\n end\n return false\n end", "def remove_from_map value, index\n # Recreates `value`s SortedSet without the given index\n @map[value].delete?(index)\n\n # Remove this value from our map, if the sorted set is now empty\n # i.e. no more elements exists in our heap with that value\n @map.delete(value) if @map[value].empty?\n end", "def valid?(val)\n vals.include? val\n end", "def include?(value)\n !get(value).nil?\n end", "def delete(value)\n if @head == nil\n return\n end\n\n # account for case: node to delete is current head\n if @head.data == value\n @head = @head.next\n return\n end\n\n current = @head\n while current.next != nil\n if current.next.data == value\n current.next = current.next.next\n return\n end\n current = current.next\n end\n # value to be deleted was not found if the control flow reaches here\n end", "def pop\n\t\tif(@head == nil)\n\t\t\traise ArgumentError.new('No hay elementos para extraer')\n\t\t\treturn false\n\t\t\t\n\t\telsif(@head == @tail)\n\t\t\t@tail=nil\n\t\t\t@head=nil\n\t\t\treturn true\n\t\t\t\n\t\telse\n\t\t\t@tail=@tail.next\n\t\t\t@tail.prev=nil\n\t\t\treturn true\n\t\t\t\n\t\tend\n\tend", "def is?(val)\n return true if @val == val\n end", "def remove_set(pos)\n\n #enough invalid inputs makes the game end\n unless valid?(pos)\n if @user_mistakes < @user_warnings.length\n puts @user_warnings[@user_mistakes]\n @user_mistakes += 1\n return false\n else\n abort(\"Seriously Man?\")\n end\n end\n\n #return 0 if not a set\n unless check_set(pos[0], pos[1], pos[2])\n puts \"Not a set!\"\n return false\n end\n pos.sort #makes sure to delete in descending order\n pos.reverse!\n for i in 0..2\n @cards_showing.delete_at(pos[i])\n end\n @table_size -= 3\n puts \"That was a set!\"\n\n return true\n end", "def delete_if(arg)\n p = if arg.respond_to? :include?\n proc { |v| arg.include?(v) }\n else\n proc { |v| arg === v }\n end\n\n ->(_, acc) { acc.delete_if(&p) }\n end", "def remove_value(column_name, val)\n send(\"#{column_name}=\", send(column_name) & ~val)\n end", "def contains(value)\n end", "def contains?(value)\n node = @head\n until node.nil?\n return true if node.value == value \n node = node.link\n end\n false\n end", "def delete(value)\n @data.delete value\n value\n end", "def ==(val)\n return true if @val == val\n end", "def removed?\n @removed\n end", "def remove(v)\n return unless @root\n @count -= 1 if @root.remove(v)\n @root = @root.left if @root.type == 1\n end", "def contains?(value)\n current_node = @head\n until current_node.nil?\n return true if current_node.value == value\n\n current_node = current_node.next_node\n end\n false\n end", "def delete_key_value?( key )\n @store.transaction { return false if @store.delete(key).nil? }\n true\n end", "def value?(value)\n values.include? value\n end" ]
[ "0.7230835", "0.7229514", "0.7152616", "0.7116149", "0.689907", "0.6758695", "0.66874665", "0.6573358", "0.6397571", "0.6345565", "0.6250748", "0.6080194", "0.60422605", "0.5958605", "0.59559196", "0.5946012", "0.5908866", "0.58999157", "0.58809286", "0.5867662", "0.58550835", "0.5833625", "0.5827349", "0.5746693", "0.5726045", "0.57151425", "0.5693566", "0.56747866", "0.56436276", "0.5629164", "0.5611641", "0.56037915", "0.5586715", "0.55829734", "0.55667585", "0.55565697", "0.5503311", "0.54917985", "0.5491088", "0.54771554", "0.54750264", "0.5430608", "0.5429114", "0.5413031", "0.54067254", "0.5370626", "0.5364995", "0.53580713", "0.5344317", "0.5340983", "0.53402793", "0.5337697", "0.53310996", "0.53310996", "0.53255177", "0.53211236", "0.5316063", "0.5304297", "0.5260667", "0.52526766", "0.5250252", "0.52471757", "0.52404034", "0.52346134", "0.52346134", "0.52296185", "0.5215863", "0.51902926", "0.51854235", "0.5170025", "0.5162822", "0.5146301", "0.51328945", "0.5123376", "0.5117126", "0.5114031", "0.508111", "0.5076763", "0.5071603", "0.50664705", "0.506394", "0.5058048", "0.50566936", "0.50565684", "0.50562334", "0.5053513", "0.50510967", "0.50431174", "0.503991", "0.5038406", "0.5032896", "0.50326025", "0.50289667", "0.50229853", "0.50216836", "0.50200534", "0.5019612", "0.5017879", "0.501347", "0.5012399" ]
0.75217015
0
=begin Get a random element from the collection. :rtype: Integer =end
def get_random() values[rand(values.size)] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def random\n if (c = count) != 0\n find(:first, :offset => rand(c))\n end\n end", "def random_element\n self[self.random_index]\n end", "def randomItem\n return self[rand(self.length)] # zero based, so this works math-wise...\n end", "def random_element\n sample\n end", "def get_random\n @num.sample.first\n end", "def random_item\n return @items[rand(@items.length)]\n end", "def pick_random\n self[rand(self.size)]\n end", "def get_random()\n rand(@count).times { @cur = @cur.next }\n @cur.val\n end", "def get_random()\n random = rand(0..@vals.length-1)\n return @vals[random]\n end", "def random\n return self[rand(self.size)]\n end", "def element\n @collection[index]\n end", "def random_element()\n\t\tshuffle[0]\n\tend", "def random_element()\n shuffle[0]\n end", "def extractRandomElement(list)\n\tindex = rand(list.length)\n\titem = list[index]\n\tlist.delete_at(index)\n\treturn item\nend", "def getRandomElement(list)\n\treturn list[rand(list.length)]\nend", "def get_random\n @number_list[Random.new.rand(@number_list.length)]\n end", "def random\n self[rand(self.size)]\n end", "def random_index\n return (rand * size).to_i\n end", "def get_random\n uri = [@@base_uri, 'all', 'getRandom'].join('/')\n result = get(uri)\n if result.class == Array\n return result.first \n else\n return nil\n end\n end", "def get_random()\n @a.sample\n end", "def get_random()\n @a.sample\n end", "def random\n active.order(\"RAND()\").first\n end", "def random_item\n items.to_a.sample\n end", "def sample\n return self[rand(self.size)]\n end", "def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).first\nend", "def getRandomPoint()\n feature = @list.sample() ;\n return feature.getRandomPoint() ;\n end", "def get_random()\n # generating random number within size\n r_n = rand(@hh.size)\n key = @hh.keys[r_n]\n return @hh[key]\n end", "def rand\n return self[Kernel.rand(length)]\n end", "def get_random_element\n\tnew_array = []\n\telement = get_element\n\n\tuntil element == nil\n\t\tnew_array << element\n\t\telement = get_element\n\tend\n\n\tnew_array.sample\nend", "def sample\n self.class.collection.find.first\n end", "def rand\r\n at(Kernel.rand(self.size))\r\n end", "def random_item(electives)\n electives[rand(electives.length)]\nend", "def choice\r\n rand(self.last - self.first) + self.first\r\n end", "def choice\n rand\n end", "def get_sample\n return nil if node.ids.empty?\n id = node.ids.sample\n find id\n end", "def get_computer_choice()\n\n return @elements.keys[rand() * @elements.length]\n\n end", "def rand\n self[Kernel.rand(length)]\n end", "def random_item(elective_array)\n return elective_array[rand(elective_array.length-1)]\nend", "def random_cursor()\n cursor = [\"14\", \"13\"].sample\n cursor += Integer(Random.rand * 10**17).to_s\n return Integer(cursor)\nend", "def random_entry(arr)\n arr[rand(arr.size)]\n end", "def select_random_id\n beer_ids = Beer.pluck(:id)\n index_of_beer = rand(beer_ids.length - 1)\n beer_ids[index_of_beer]\n end", "def random_user\n User.offset(rand(User.count)).first\nend", "def pick\n rand = Random.new\n index = rand.rand(0...@emotions.length)\n @emotions[index]\n end", "def select_player_random\n num_player = rand(@players.length)\n num_player\n end", "def get_question\n index = rand(@question_cards.count)\n q_card = @question_cards[index]\n @question_cards.delete_at(index)\n return q_card.value\n end", "def get_random_word\r\n @word_list.sample\r\n end", "def random\n all[rand(count)]\n end", "def random\n Run.offset(rand(Run.count)).first || Run.new(id: 0)\n end", "def randomizer\n number = rand(0..1)\n return number\nend", "def random_node\n self.to_a.random\n end", "def rand_one(item_type)\n\t\t\tnum = rand(1..MAX_RATE)\n\n\t\t\tconst(item_type.to_i).each do |key, val|\n\t\t\t\tif num.in?(key)\n\t\t\t\t\treturn val\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def roll\n roll = [1,2,3,4,5,6]\nitem = roll[rand(roll.length)]\nend", "def random_byte\n self.entries[rand(self.length)]\n end", "def pick_a_word\n\t\tbucket = @dictionary[@dictionary.keys[rand @dictionary.size]]\n\t\tpair = bucket[rand bucket.size]\n\t\tpair.last\n\tend", "def get_random_element_without_new_array\n\trandom_number = rand(1..length_of_mystery_array)\n# It is necessary to create a variable for this so that the value in the \n# conditional on line 50 will be the same as what was used in line 48.\n\trandom_number.times do |i|\n\t\telement = get_element\n\t\treturn element if i == random_number - 1\n# i is compared to random_number -1 to account for the iteration beginning at 0.\n\tend \nend", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def random_to_one\n return rand()\n end", "def get_random_number\n\t\trandom_num = rand(@deck.length)\n\tend", "def get_random_element_with_one_loop\n\tget_random_element\nend", "def recite_random\n number = rand(1..@size)\n return recite(number)\n end", "def get_random_card\n return self.cards.where(:location => -1)[rand(self.cards.where(:location => -1).length)]\n end", "def sample\n at(rand(size))\n end", "def pick_index()\n target = rand(@array[-1][0])\n @array.bsearch { |x, _| x > target }.last\n end", "def random_index value\n\t\tn=rand(find_all{|e|e==value}.size)\n\t\teach_with_index{|e,i| return i if e==value and (n-=1)<0 }\n\tend", "def rand\n Kernel.rand(self)\n end", "def rand_value\n return Kernel.const_get(JsonRander.random_type).new\n end", "def random\n # Hack to get the player interface\n player_iface = @parent.player.send(:interface)\n # Second integrer in array is the random status\n return player_iface.GetStatus.first[1] #== 1\n end", "def random\n 1 + (10 * rand(0))\n end", "def getFirst_i_rand( selection, query, args )\n # Double our args since we are querying twice\n \n args = [ args ] if not args.is_a? Array\n\n nargs = Array.new args\n args.each do |a|\n nargs << a \n end\n\n args = nargs\n \n return( self.getFirst_i( \"SELECT \" + selection + \" FROM \" + query + \" OFFSET floor(RANDOM() * (SELECT count(*) FROM \" + query + \")) LIMIT 1\", args ) )\n end", "def get_random()\n \n end", "def get_random()\n \n end", "def next\r\n if !@neighbors.count.zero?\r\n @neighbors[@random.rand(num_neighbors)]\r\n else\r\n nil\r\n end\r\n end", "def find_first_featured_by_random(options={})\n featured = find_all_featured(options)\n featured[rand(featured.size)]\n end", "def pull_food_from_db\n PlaylistFood.order(\"random()\").first\n end", "def int(size)\n rand(size).to_i\n end", "def random_item (array)\n item_index = rand(0...array.length)\n array[item_index]\n array.delete_at(item_index)\nend", "def random_user\n\t\tUser.find([*1..40].sample)\n\tend", "def random_match()\n @matches[rand(@matches.length)]\n end", "def random\n beer_id = select_random_id\n Beer.find(beer_id)\n end", "def random_integer(limit)\n Rubinius.primitive :randomizer_rand_int\n raise PrimitiveFailure, \"Randomizer#rand_int primitive failed\"\n end", "def random_integer(limit)\n Rubinius.primitive :randomizer_rand_int\n raise PrimitiveFailure, \"Randomizer#rand_int primitive failed\"\n end", "def pick_random\r\n @card_list.pick_random\r\n end", "def rand_index\n SecureRandom.random_number(size)\n end", "def pick_random_card\n random_card = @all_cards.sample\n remove_card(random_card)\n return random_card\n end", "def get_random_choice\n choice = @symbol_list[rand(5)]\n return choice\n end", "def random_index\n return 0 if shards.size == 1\n\n rand(shards.size)\n end", "def skill_key\n return item_in_use.seq_key[rand(item_in_use.seq_key.size)]\n end", "def skill_key\n return item_in_use.seq_key[rand(item_in_use.seq_key.size)]\n end", "def get_item(index_num)\r\n @arr.fetch(index_num)\r\n end", "def get_random_node\n select_node = nil\n create_random_list(10)\n current_node = head\n # Select a random node from the list to delete just that node.\n (rand(8)+1).times do \n current_node = current_node.next\n break if current_node == nil\n end\n select_node = current_node\n return select_node\n end", "def get_random_position\n arr = $game_map.region_tile_mapping[@page.random_position_region]\n return arr.delete_at(rand(arr.length))\n end", "def [](key)\n return nil if @collection.nil?\n return_item_value key\n end", "def fetch(nth, *args, &block)\n if args.size >= 2\n raise ArgumentError, \"wrong number of arguments (#{args.size + 1} for 1..2)\"\n end\n\n if has_size? && (nth < -size || size <= nth)\n if block != nil\n # TODO: Warn if ifnone value is present.\n return block.call\n elsif args.size == 1\n return args[0]\n else\n raise IndexError,\n \"index #{nth} outsize of the random readable object \" \\\n \"bounds: #{-size}...#{size}\"\n end\n else\n return at(nth)\n end\n end", "def get_sample\n reviews = Review.where(destination_id: self.id)\n sample = reviews[rand(reviews.length)]\n return sample\n end", "def pick_random\n @card_list.pick_random\n end", "def pick_random\n @card_list.pick_random\n end", "def pick(target)\n res = count = 0\n @N.each_with_index do |n, i|\n next unless n == target\n\n count += 1\n res = i if rand(1..10**9) % count == 0\n end\n res\n end", "def next_rand\n begin\n num = rand(0...possible_products.count)\n end while(@chosen_nums[num])\n @chosen_nums[num] = 1\n num\n end" ]
[ "0.7439114", "0.73322785", "0.7196328", "0.7113594", "0.6999919", "0.69787073", "0.6919932", "0.6907892", "0.68156815", "0.6809693", "0.679305", "0.6727135", "0.6713132", "0.6699841", "0.66736627", "0.66583735", "0.6603407", "0.6552848", "0.6528621", "0.6517848", "0.6517848", "0.6419375", "0.6355714", "0.63516176", "0.63464284", "0.6305658", "0.6266934", "0.6225854", "0.62153184", "0.62152714", "0.6121136", "0.6117406", "0.6050698", "0.60353994", "0.6031055", "0.6010066", "0.5982451", "0.59640443", "0.5959418", "0.5957824", "0.5943224", "0.5925858", "0.59169656", "0.5890953", "0.58892804", "0.58348894", "0.5831976", "0.58263516", "0.5817786", "0.5780502", "0.5765772", "0.57625145", "0.5752141", "0.5750297", "0.57485557", "0.57470226", "0.57470226", "0.57470226", "0.57470226", "0.57450795", "0.574249", "0.5725777", "0.5717094", "0.57161444", "0.56786007", "0.5666221", "0.5632788", "0.5625959", "0.56206566", "0.5612833", "0.56000364", "0.5597252", "0.5597252", "0.55932194", "0.55891246", "0.5588527", "0.55856663", "0.5584649", "0.5581531", "0.5570514", "0.55702627", "0.5565428", "0.5565428", "0.5564028", "0.55445683", "0.55186236", "0.5510987", "0.55087095", "0.5506783", "0.5506783", "0.5506696", "0.5506278", "0.5494762", "0.54905295", "0.548846", "0.54879534", "0.54771113", "0.54771113", "0.5460551", "0.5450977" ]
0.63653266
22
Supported values for options: :region AWS region (e.g. uswest1) :secure true or false, default true. :timeout the timeout, in seconds, when making a request to EMR, default 60.
def initialize(options={}) # There is a cryptic error if this isn't set if options.has_key?(:region) && options[:region] == nil raise MissingRegionError, 'A valid :region is required to connect to EMR' end options[:region] = 'us-east-1' unless options[:region] @region = options[:region] @host = "elasticmapreduce.#@region.amazonaws.com" options[:timeout] = 60 unless options[:timeout] @timeout = options[:timeout] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aws_options\n options = {\n retry_limit: 7, # default: 3\n retry_base_delay: 0.6, # default: 0.3\n }\n options.merge!(\n log_level: :debug,\n logger: Logger.new($stdout),\n ) if ENV['CFN_STATUS_DEBUG_AWS_SDK']\n options\n end", "def configure_timeout(options, env)\n req = request_options(env)\n options[:inactivity_timeout] = request_timeout(:read, req)\n options[:connect_timeout] = request_timeout(:open, req)\n end", "def request_options\n {\n open_timeout:,\n timeout: read_timeout\n }\n end", "def initialize(options={})\n require 'mime/types'\n @use_iam_profile = options[:use_iam_profile]\n options[:region] ||= 'us-east-1'\n setup_credentials(options)\n @host = options[:host] || case options[:region]\n when 'us-east-1'\n 'glacier.us-east-1.amazonaws.com'\n else\n \"glacier.#{options[:region]}.amazonaws.com\"\n end\n @scheme = options[:scheme] || 'https'\n @region = options[:region]\n end", "def timeout\n options[:timeout] || super\n end", "def timeout\n @options[:timeout]\n end", "def request_timeout(type, options); end", "def connection_options\n { :request => {\n :timeout => options[:timeout],\n :open_timeout => options[:timeout] },\n :proxy => options[:proxy_uri]\n }\n end", "def initialize options = {}\n require 'aws/ec2'\n\n options.each_key do | key |\n raise ArgumentError, \"unrecognized option \\'#{key}\\'\" unless RECOGNIZED_OPTIONS.include? key\n end\n \n @ec2 = options[ :instance ]\n @start_options = options[ :start_options ] || {}\n \n if @ec2 \n puts \"\\'credentials\\' ignored as an instance was given too\" if options.key? :credentials\n else\n ::AWS.config( options[ :credentials ] )\n \n @ec2 = ::AWS::EC2.new\n @ec2 = @ec2.regions[ options[ :region ] ] if options.key? :region\n end\n end", "def initialize(options={})\n @@logger = options[:logger]\n if options[:aws_access_key_id] && options[:aws_secret_access_key]\n @@logger.info(\"AWS credentials supplied. EC2 Tagging Enabled.\")\n fog_aws_compute = Fog::Compute.new({:aws_access_key_id => options[:aws_access_key_id], :aws_secret_access_key => options[:aws_secret_access_key], :provider => 'AWS'})\n fog_aws_compute.describe_regions.body['regionInfo'].each do |region|\n @@fog_aws_computes.store(region['regionName'],\n Fog::Compute.new({\n :aws_access_key_id => options[:aws_access_key_id],\n :aws_secret_access_key => options[:aws_secret_access_key],\n :provider => 'AWS',\n :host => region['regionEndpoint']\n })\n )\n end\n end\n end", "def aws_region\n @aws_region || \"us-east-1\"\n end", "def getAWSInfo\n begin\n Timeout::timeout(10) do\n aws_metadata = open('http://169.254.169.254/2014-11-05/dynamic/instance-identity/document'){ |io| data = io.read }\n aws_JSON_Information = JSON.parse(aws_metadata)\n return \"#{aws_JSON_Information['instanceId']}_#{aws_JSON_Information['region']}_#{aws_JSON_Information['accountId']}\"\n end\n rescue\n Chef::Log.warn('Unable to get AWS instance ID, Timeout while reading') \n return ''\n end\nend", "def initialize(options)\n @settings = options\n\n check_settings(:aws_access_key_id, :aws_default_region,\n :aws_secret_access_key)\n end", "def connect(options)\n o = options.slice(:access_key_id, :secret_access_key, :server, :port, :use_ssl, :persistent, :proxy)\n AWS::S3::Base.establish_connection!(o.dup) # establish_connection! modifies the hash\n @connection_options = o\n end", "def ec2_client(region)\n begin\n client = Aws::EC2::Client.new(region: region)\n rescue => e\n puts e\n exit\n end\nend", "def aws(key: ENV['AWS_ACCESS_KEY_ID'],\n secret: ENV['AWS_SECRET_ACCESS_KEY'],\n regions: %w(us-east-1 us-west-1 eu-west-1 ap-southeast-1)\n )\n @regions = regions\n ::Aws.config.update(\n credentials: Aws::Credentials.new(key, secret)\n )\n end", "def timeout_seconds\n transport_options.timeout_seconds\n end", "def timeout\n configuration[:timeout] || DEFAULT_TIMEOUT\n end", "def timeout\n configuration[:timeout] || DEFAULT_TIMEOUT\n end", "def endpoint_options\n {user: @username,\n pass: @password,\n host: @host,\n port: @port,\n operation_timeout: @timeout_in_seconds,\n no_ssl_peer_verification: true,\n disable_sspi: true}\n end", "def region \n ENV['AWS_REGION'] || InstanceMetadata.region\n end", "def initialize options = {}\n @config = options[:config]\n @config ||= AWS.config\n @config = @config.with(options)\n @client = config.send(Inflection.ruby_name(self.class.to_s) + '_client')\n end", "def initialize(timeout, options)\n @timeout = timeout\n @options = options\n end", "def timeout\n node['redmine']['executor']['timeout']\n end", "def timeout_given?\n !!node['redmine']['executor']['timeout']\n end", "def read_timeout= read_timeout\n @agent.read_timeout = read_timeout\n end", "def http_timeout\n t = if ENV['EDS_TIMEOUT'].present?\n ENV['EDS_TIMEOUT'].to_f\n else\n 6\n end\n (t / 3)\n end", "def http_timeout; end", "def initialize(options = {})\n @settings = {\n aws_access_key_id: T::Mailer.configuration.aws_access_key_id,\n aws_default_region: T::Mailer.configuration.aws_default_region,\n aws_secret_access_key: T::Mailer.configuration.aws_secret_access_key,\n sparkpost_api_key: T::Mailer.configuration.sparkpost_api_key,\n }.merge!(options)\n end", "def ecs\n Amazon::Ecs.configure do |options|\n options[:aWS_access_key_id] = @@key_id\n options[:associate_tag] = @@associate_id\n options[:aWS_secret_key] = @@secretkey\n end \n return Amazon::Ecs \nend", "def configure_aws_region settings\n settings[:aws_region] ||= settings[:availability_zones].first.gsub(/^(\\w+-\\w+-\\d)[a-z]/, '\\1')\n settings[:ec2_url] ||= \"https://#{settings[:aws_region]}.ec2.amazonaws.com\"\n unless ((ENV['EC2_URL'].to_s == '' && settings[:aws_region] == 'us-east-1') || (ENV['EC2_URL'] == settings[:ec2_url]))\n warn \"******\\nThe EC2_URL environment variable should probably be #{settings[:ec2_url]} (from your availability zone), not #{AWS::EC2::DEFAULT_HOST}. Try invoking 'export EC2_URL=#{settings[:ec2_url]}' and re-run.\\n******\"\n end\nend", "def initialize options = {}\n\n options = options.dup # so we don't modify the options passed in\n\n @service_ruby_name = self.class.service_ruby_name\n\n # translate these into service specific configuration options,\n # e.g. :endpoint into :s3_endpoint\n [:endpoint, :region, :port, :signature_version].each do |opt|\n if options[opt]\n options[:\"#{service_ruby_name}_#{opt}\"] = options.delete(opt)\n end\n end\n\n @config = (options.delete(:config) || AWS.config)\n @config = @config.with(options)\n\n @region = @config.send(:\"#{service_ruby_name}_region\")\n\n @credential_provider = @config.credential_provider\n @http_handler = @config.http_handler\n @endpoint = config.send(:\"#{service_ruby_name}_endpoint\")\n @port = config.send(:\"#{service_ruby_name}_port\")\n\n # deprecated attributes\n @http_read_timeout = @config.http_read_timeout\n end", "def client(region,access_key_id=nil,secret_access_key=nil)\n self.ec2_client ||= Aws::EC2::Client.new(region: region, access_key_id: access_key_id, secret_access_key: secret_access_key )\n end", "def createEC2Client(region,credentials)\n begin\n return Aws::EC2::Client.new(region: region,credentials: credentials)\n rescue Exception => e\n puts \"\\e[31mCould not create new EC2 client\"\n puts \"#{e.message}\\e[0m\"\n exit 1\n end\nend", "def timeout\n configuration.timeout\n end", "def options(url, options = {}, &block)\n request HttpOptions, url, options, &block\n end", "def hadoop_jobconf_options\n if reads_from_elasticsearch? || writes_to_elasticsearch?\n settings[:map_speculative] = 'false' if settings[:map_speculative].nil?\n settings[:reduce_speculative] = 'false' if settings[:reduce_speculative].nil?\n end\n \n super() + [].tap do |o|\n if (reads_from_elasticsearch? || writes_to_elasticsearch?)\n o << java_opt('es.config', settings[:es_config])\n o << java_opt('elasticsearch.transport', settings[:es_transport])\n o << java_opt('elasticsearch.transport.host', settings[:es_transport_host]) if settings[:es_transport] && settings[:es_transport_host]\n o << java_opt('elasticsearch.transport.port', settings[:es_transport_port]) if settings[:es_transport] && settings[:es_transport_port]\n end\n \n if reads_from_elasticsearch?\n o << java_opt('elasticsearch.input.index', input_index.index)\n o << java_opt('elasticsearch.input.mapping', input_index.mapping)\n o << java_opt('elasticsearch.input.splits', settings[:es_input_splits])\n o << java_opt('elasticsearch.input.query', settings[:es_query])\n o << java_opt('elasticsearch.input.request_size', settings[:es_request_size])\n o << java_opt('elasticsearch.input.scroll_timeout', settings[:es_scroll_timeout])\n end\n\n if writes_to_elasticsearch?\n o << java_opt('elasticsearch.output.index', output_index.index)\n o << java_opt('elasticsearch.output.mapping', output_index.mapping)\n o << java_opt('elasticsearch.output.index.field', settings[:es_index_field])\n o << java_opt('elasticsearch.output.mapping.field', settings[:es_mapping_field])\n o << java_opt('elasticsearch.output.id.field', settings[:es_id_field])\n o << java_opt('elasticsearch.output.bulk_size', settings[:es_bulk_size])\n end\n end.flatten.compact\n end", "def client_close_timeout\n super\n end", "def region\n GlobalConstant::Aws::Common.region\n end", "def region\n GlobalConstant::Aws::Common.region\n end", "def initialize options = {}\n \n if options[:endpoint]\n options[:\"#{self.class.service_ruby_name}_endpoint\"] = \n options.delete(:endpoint)\n end\n \n options_without_config = options.dup\n @config = options_without_config.delete(:config)\n @config ||= AWS.config\n @config = @config.with(options_without_config)\n @signer = @config.signer\n @http_handler = @config.http_handler\n @stubs = {}\n \n end", "def initialize(options = {})\n @access_key_id = options[:access_key_id]\n @secret_access_key = options[:secret_access_key]\n @use_ssl = options[:use_ssl] || false\n @debug = options[:debug]\n @timeout = options[:timeout]\n end", "def timeout_in\n 15.minutes\n end", "def em\n EventMachine::HttpRequest.new(url).send(method.downcase,\n :head => headers,\n :body => body,\n :connect_timeout => 9000, # Disable\n :inactivity_timeout => 9000 # Disable\n )\n end", "def default_request_options\n {:timeout => 0, :head => {}}\n end", "def request\n HTTP.headers(request_headers).timeout(timeout_options)\n end", "def job_options\n end", "def http_client\n @conn ||= Net::HTTP.start(EC2_METADATA_ADDR).tap do |h|\n h.read_timeout = 10\n h.keep_alive_timeout = 10\n end\n end", "def aws_call(func_name, opts = {})\n return self.send(func_name, opts)\n rescue => e\n log \"AWS: Call Rescue: #{e.class} opts=#{opts}\"\n if e.class == AWS::EC2::Errors::RequestLimitExceeded\n log \"AWS: '#{e.class}' sleeping 1s and retrying\"\n sleep 1\n timeout -= 1\n retry if timeout != 0\n elsif opts.has_key?(:errs) and opts[:errs].include?(e.class)\n log \"AWS: '#{e.class}' sleeping 1s and retrying at least #{opts[:errs][e.class]} more times\"\n sleep 1\n opts[:errs][e.class] -= 1\n retry if opts[:errs][e.class] != 0\n end\n raise e\n end", "def set_client_close_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def optimize options = {}\n SolrPowered.with_timeout(120) {\n attributes = options.collect{|k,v| \"#{k}=\\\"#{v}\\\"\" }.join(' ')\n request(:update, \"\\n <optimize #{attributes}/>\")\n }\n end", "def initialize\n @settings = Settings.instance\n @options = {\n base_uri: @settings.get('api_endpoint'),\n timeout: @settings.get('timeout').to_i / 1000\n }\n end", "def backup(options = {})\n my_aws = {\n region: ENV['AWS_REGION'],\n access_method: 'api_key',\n access_key: ENV['AWS_API_KEY'],\n secret_key: ENV['AWS_SECRET_KEY']\n }\n conn = ::Skejuler::Aws::Connector.new(my_aws)\n\n rds = conn.rds # Aws RDS Client library\n\n rds.describe_db_instances\n instance_id = options.fetch(:instance_id)\n puts instance_id\n # do something on it\n\nend", "def read_timeout=(read_timeout); end", "def timeout_seconds\n return 1200\n end", "def timeout=(timeout)\n @timeout = timeout\n end", "def initialize(key, options = {})\n endpoint = options[:endpoint] || DEFAULT_ENDPOINT\n\n @key = key\n @endpoint = URI.parse(endpoint).freeze\n @timeout = options.fetch(:timeout, 5.0)\n end", "def pool_options(options); end", "def expires_in\n options[:expires_in]\n end", "def connect_timeout; end", "def connect_timeout; end", "def set_aws_connections\n\n @rs_to_aws_cloud_map = {\n 1 => AWS::EC2.new(region: 'us-east-1'),\n 3 => AWS::EC2.new(region: 'us-west-1'),\n 6 => AWS::EC2.new(region: 'us-west-2'),\n 4 => AWS::EC2.new(region: 'ap-southeast-1'),\n 8 => AWS::EC2.new(region: 'ap-southeast-2'),\n 5 => AWS::EC2.new(region: 'ap-northeast-1'),\n 7 => AWS::EC2.new(region: 'sa-east-1'),\n 2 => AWS::EC2.new(region: 'eu-west-1')\n }\nend", "def set_aws_connections\n\n @rs_to_aws_cloud_map = {\n 1 => AWS::EC2.new(region: 'us-east-1'),\n 3 => AWS::EC2.new(region: 'us-west-1'),\n 6 => AWS::EC2.new(region: 'us-west-2'),\n 4 => AWS::EC2.new(region: 'ap-southeast-1'),\n 8 => AWS::EC2.new(region: 'ap-southeast-2'),\n 5 => AWS::EC2.new(region: 'ap-northeast-1'),\n 7 => AWS::EC2.new(region: 'sa-east-1'),\n 2 => AWS::EC2.new(region: 'eu-west-1')\n }\nend", "def set_cache_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def elasticache(region)\n verbose_or_debug_msg(\"Checking Elasticache resources in region #{region} for profile \\\"#{$profile}\\\"\")\n if $audit_mode\n opfile=File.open(\"#{$audit_dir}/#{region}/elasticaches\",\"w\")\n else\n opfile=$stdout\n end\n begin\n elasticache = Aws::ElastiCache::Client.new(region: region, credentials: $credentials)\n clusters = elasticache.describe_cache_clusters()\n clusters.cache_clusters.each do |c|\n if not $quiet\n opfile.print(\"\\\"Elasticache Cluster\\\",\\\"#{region}\\\",\\\"#{c.cache_cluster_id}\\\",\\\"#{c.cache_node_type}\\\",\\\"#{c.engine}\\\"\\n\")\n end\n $elasticache_count+=1\n end\n snapshots=elasticache.describe_snapshots()\n snapshots.each do |ss|\n if not $quiet\n if ss.snapshots.length != 0\n opfile.print(\"\\\"#{$profile}\\\",\\\"Elasticache snapshot\\\",\\\"#{ss}\\\"\\n\") \n end\n end\n $elasticache_snapshot_count+=1\n end\n rescue Aws::ElastiCache::Errors::AccessDenied =>err \n err_msg(\"Insufficient permissions failure for profile #{$profile} - (#{err}) - exiting\\n\")\n if $continue_on_permissions_error\n return \n else\n err_msg(\"exiting\\n\")\n exit(E_AUTH_FAILURE)\n end\n rescue => err\n err_msg(\"An Unknown error has occurred #{err}\\n\")\n exit(E_UNKNOWN_ERR)\n end\nend", "def timeout\n super\n end", "def timeout\n super\n end", "def set_server_close_timeout(opts)\n opts = check_params(opts,[:timeouts])\n super(opts)\n end", "def request_timeout()\n @req_timeout\n end", "def fog_options\n options = { \n :provider => provider, \n :aws_access_key_id => aws_access_key_id, \n :aws_secret_access_key => aws_secret_access_key, \n :region => region \n }\n end", "def timeout\n @timeout || Elected.timeout\n end", "def timeout\n @params[:timeout]\n end", "def extended_timeout\n puts \"Please wait, this could take a few minutes ...\"\n old_timeout = ::DTK::Client::Conn.get_timeout()\n ::DTK::Client::Conn.set_timeout(EXTENDED_TIMEOUT)\n result = yield\n ::DTK::Client::Conn.set_timeout(old_timeout)\n result\n end", "def client_params\n params = { region: 'ap-southeast-1',\n access_key_id: x_access_key_id,\n secret_access_key: x_secret_access_key }\n\n params[:endpoint] = ENV['AWS_ENDPOINT'] unless ENV['AWS_ENDPOINT'].nil?\n params\n end", "def with_options(&block); end", "def driver\n 'aws'\n end", "def faraday_request(options)\n return options[:request] if options[:request]\n\n request = options[:options]\n return unless request[:open_timeout] || request[:timeout]\n\n {\n open_timeout: request[:open_timeout],\n timeout: request[:timeout],\n }\n end", "def createRDSClient(region,credentials)\n begin\n return Aws::RDS::Client.new(region: region,credentials: credentials)\n rescue Exception => e\n puts \"\\e[31mCould not create new RDS client.\"\n puts \"#{e.message}\\e[0m\"\n exit 1\n end\nend", "def initialize(opts = {})\n @opts = opts\n @opts[:type] ||= :block\n @opts[:timeout] ||= 10\n\n sanitize_opts!\n create_client\n end", "def server_timeout\n get_configuration 'server_timeout', @config\n rescue\n 60\n end", "def error_timeout; end", "def faraday_request(options)\n return options[:request] if options[:request]\n\n request = options[:options]\n return unless request[:open_timeout] || request[:timeout]\n\n {\n open_timeout: request[:open_timeout],\n timeout: request[:timeout],\n }\n end", "def server_close_timeout\n super\n end", "def initialize(options = {})\n options = Hash[options.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols\n STDOUT.sync = true\n @logger = options[:logger] || Logger.new(STDOUT)\n %i[debug info warn error level=].each { |m| raise InvalidClient, \"Logger must respond to #{m} method \" unless @logger.respond_to?(m) }\n self.log_level = options[:log_level] || :info\n @print_wait_dots = options.fetch(:print_wait_dots, false)\n @url = options[:url] || ENV['I3S_URL']\n raise InvalidClient, 'Must set the url option' unless @url\n @max_api_version = appliance_i3s_api_version\n if options[:api_version] && options[:api_version].to_i > @max_api_version\n logger.warn \"API version #{options[:api_version]} is greater than the Image Streamer API version (#{@max_api_version})\"\n end\n @api_version = options[:api_version] || [OneviewSDK::ImageStreamer::DEFAULT_API_VERSION, @max_api_version].min\n # Set the default Image Streamer module API version\n OneviewSDK::ImageStreamer.api_version = @api_version unless\n OneviewSDK::ImageStreamer.api_version_updated? || !OneviewSDK::ImageStreamer::SUPPORTED_API_VERSIONS.include?(@api_version)\n @ssl_enabled = true\n if ENV.key?('I3S_SSL_ENABLED')\n if %w[true false 1 0].include?(ENV['I3S_SSL_ENABLED'])\n @ssl_enabled = !%w[false 0].include?(ENV['I3S_SSL_ENABLED'])\n else\n @logger.warn \"Unrecognized ssl_enabled value '#{ENV['I3S_SSL_ENABLED']}'. Valid options are 'true' & 'false'\"\n end\n end\n @ssl_enabled = options[:ssl_enabled] unless options[:ssl_enabled].nil?\n @timeout = options[:timeout] unless options[:timeout].nil?\n @cert_store = OneviewSDK::SSLHelper.load_trusted_certs if @ssl_enabled\n raise InvalidClient, 'Must set token option' unless options[:token] || ENV['ONEVIEWSDK_TOKEN']\n @token = options[:token] || ENV['ONEVIEWSDK_TOKEN']\n end", "def options(*args, &block); end", "def http_timeout=(_arg0); end", "def set_aws_region(val)\n if val\n val\n elsif ENV['AWS_REGION']\n ENV['AWS_REGION']\n else\n 'us-east-1'\n end\n end", "def ec2_resource(region)\n begin\n ec2 = Aws::EC2::Resource.new(region: region)\n rescue => e\n puts e\n exit\n end\nend", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end", "def options; end" ]
[ "0.5818868", "0.5627236", "0.5560421", "0.5550543", "0.55356747", "0.54547215", "0.5405509", "0.5281793", "0.52772796", "0.5249756", "0.52192575", "0.5209955", "0.5119666", "0.5097042", "0.5045118", "0.50450814", "0.5030702", "0.502459", "0.502459", "0.50037855", "0.49800667", "0.49796236", "0.49613827", "0.4961355", "0.49532974", "0.49467584", "0.49122137", "0.49072707", "0.4900423", "0.48997545", "0.4894971", "0.4893158", "0.48685417", "0.48659286", "0.48214465", "0.4814981", "0.4812198", "0.47943115", "0.47930932", "0.47930932", "0.4792185", "0.47885936", "0.4786105", "0.4780255", "0.47780913", "0.47752726", "0.47677198", "0.47635892", "0.47579655", "0.47535303", "0.4750574", "0.47452268", "0.47444278", "0.47354496", "0.47206724", "0.4709857", "0.47078243", "0.4702293", "0.46886048", "0.4679329", "0.4679329", "0.4678372", "0.4678372", "0.4675759", "0.46716866", "0.4668687", "0.4668687", "0.4655837", "0.4651688", "0.4649641", "0.46423545", "0.46411976", "0.46275905", "0.46145642", "0.46106738", "0.46104702", "0.460926", "0.46080983", "0.46074042", "0.46068624", "0.46053067", "0.46017483", "0.4599894", "0.45998117", "0.45991552", "0.45968267", "0.459012", "0.45898837", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065", "0.45821065" ]
0.7225927
0
Use callbacks to share common setup or constraints between actions.
def set_annal @annal = Annal.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 annal_params params.require(:annal).permit(:file, :notes, :json, :done) 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
x_t is a collectin of vector as such [[x_1, x_2, x_3, x_4, ...], [x_1, x_2, x_3, ...], ...]
def initialize(x_t, y_t) @m = x_t.length @x_matrix = Matrix.rows(x_t.map {|row| row.unshift(1)}) @y_vector = Matrix.column_vector(y_t) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def row_vectors\n # (0 .. row_size - 1).collect { |i| row(i) }\n my_rows = @rows\n r_size = my_rows.size\n res = Array.new(r_size)\n vector_cls = Vector\n for i in 0..r_size-1 do\n a_row = my_rows[i]\n res[i] = vector_cls.elements(a_row) \n end\n res\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n x.dot(@components.transpose)\n end", "def txXX_(n, x); tdist(n, x); end", "def scalarXvector(scalar, array)\n array.map { |x| scalar * x }\nend", "def extractArrayOfExampleInputVectors(exampleList)\r\n arrayOfInputRows = []\r\n exampleList.each do |inputTarget|\r\n inputRow = inputTarget[0]\r\n arrayOfInputRows << inputRow\r\n end\r\n return arrayOfInputRows\r\nend", "def victoire\n \n [[@a1, @a2, @a3],\n [@a1, @b2, @c3],\n [@a1, @b1, @c1],\n [@b1, @b2, @b3],\n [@c1, @c2, @c3],\n [@c1, @b2, @a3],\n [@a2, @b2, @c2],\n [@a3, @b3, @c3]]\n end", "def t__X_(n, x); tdist(n, x) - 0.5; end", "def blocks_to_vector(blocks)\n target_vectors = 16.times.reduce(Array.new) do |acc, block_index|\n acc << blocks.map { |block| Array(block)[block_index] }\n end\nend", "def vector_add(w, x)\n sum_vector = @feature_count.times.map { |x| 0 }\n (0..@feature_count-1).each { |i| sum_vector[i] = w[i] + x[i] }\n sum_vector\nend", "def transform(x)\n z = @transformers.values.map { |t| t.transform(x) }\n Numo::NArray.hstack(z)\n end", "def input1\n [\n [1, 0, 0, 0, 1],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 4],\n [0, 0, 0, 1, 3]\n ]\nend", "def cross_product x\r\n Vector.Raise ErrDimensionMismatch if size != 3\r\n Vector.Raise ErrDimensionMismatch if x.size != 3\r\n\r\n c = Array.new\r\n\r\n c[0] = @elements[1]*x[2] - @elements[2]*x[1]\r\n c[1] = @elements[2]*x[0] - @elements[0]*x[2]\r\n c[2] = @elements[0]*x[1] - @elements[1]*x[0]\r\n\r\n Vector.elements(c)\r\n end", "def to_tsvectors\n []\n end", "def lcts(array)\nend", "def column_vectors\n # (0 .. column_size - 1).collect { |i| column(i) }\n my_rows = @rows\n r_size = my_rows.size\n col_size = my_rows[0].size\n vector_cls = Vector\n array_cls = Array\n res = array_cls.new(col_size)\n for j in 0..col_size-1 do\n a_col = array_cls.new(r_size)\n for i in 0..r_size-1 do\n a_col[i] = my_rows[i][j]\n end\n res[j] = Vector.elements(a_col, false)\n end\n res\n end", "def x_values\n raise ArgumentError.new(\"#{self.inspect} is not a 2D numeric array\") unless is_numeric_2d_array?\n self.collect { |item| item.first }\n end", "def triplify(array)\n \t \n \t new_array = array.map { |i| i * 3 }\n \t p new_array\n end", "def input2\n [\n [3, 2,-4, 3],\n [2, 3, 3, 15],\n [5, -3, 1, 14]\n ]\nend", "def get_rcx_list(collection, samples)\n coordinates_and_data = []\n samples.each do |sample|\n sample_coordinates = get_items_coordinates(collection, [sample])\n sample_locations = get_alpha_num_location(collection, sample)\n\n sample_coordinates.each do |coordinates|\n coordinates.push(sample_locations[sample])\n coordinates_and_data.push(coordinates)\n end\n end\n coordinates_and_data\n end", "def txs()\n puts 'TXS'\n @s = @x\n end", "def ptxXX_(n, y); ptdist(n, y); end", "def args\n ret = []\n @x.each do |e|\n ret << e.args\n end\n ret.flatten.uniq\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n cx = @params[:whiten] ? (x - @mean) : x\n cx.dot(@components.transpose)\n end", "def arrays\n @vectors\n end", "def untransformed_vector(v)\r\n v.map{|x| x/@zoom }\r\n end", "def feature_vector\n out = []\n field_names.each { |f| out << @profile[f] }\n out\n end", "def collect\r\n array = []\r\n @table.each do |subarray|\r\n array.concat subarray\r\n end\r\n array\r\n end", "def tpr_axis\n axis = []\n @p.each_index do |i|\n axis << tpr(i)\n end\n axis\n end", "def repa(array, x)\n result = []\n (1..x).each do\n result.concat(array)\n end\n return result\nend", "def gracify(data)\n data.map{|i| Belt.new(i[0], i[1])}\n end", "def input4\n [\n [1, 0, 0, 0, 1],\n [0, 0, 0, 1, 3],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 8]\n ]\nend", "def to_lp_vars\n index_tuples.map{|t| \"v#{t.join('x')}\"}\n end", "def tdist(n, t); p_t(n, t); end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n z = kernel_mat(x, @components)\n z.dot(@normalizer)\n end", "def apply(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n Numo::Int32[*(Array.new(x.shape[0]) { |n| partial_apply(@tree, x[n, true]) })]\n end", "def trans(input)\n\trows, columns = input.count, input.first.count\n\tx, y = [], []\n\ti = j = 0\n\twhile j < columns do\n\t\twhile i <= rows - 1 do\n\t\t\tx.push(input[i][j])\n\t\t\ti += 1\n\t\tend\n\t\tj += 1 #go to next column\n\t\ti = 0 #reset the inner counter to go back to 1st array\n\tend\n\tx.each_slice(rows).each.map{|e| y.push(e)}\n\treturn y\nend", "def *(x)\n if x._isNumeric\n # els = @elements.collect{|e| e * x} \n my_elems = @elements\n e_size = my_elems.size\n els = Array.new(e_size)\n for i in 0..e_size-1 do\n els[i] = my_elems[i] * x\n end\n\n Vector.elements(els, false)\n else\n matrix_cls = Matrix\n if x._kind_of?( matrix_cls )\n matrix_cls.column_vector(self) * x\n else\n cr = x.coerce(self)\n cr[0] * cr[1]\n end\n end\n end", "def create_vector_pedersen(l, r, x)\n g = GENERATOR_GJ\n h = GENERATOR_HJ\n p1 = l.inject(INFINITY_J) { |result, f| result + g * f }\n p2 = r.inject(INFINITY_J) { |result, f| result + h * f }\n p1 + p2 + h * x\n end", "def t___x(n, x); 1.0 - tdist(n, x); end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n # initialize transformed features\n n_samples, n_features = x.shape\n z = Numo::DFloat.zeros(n_samples, n_output_features)\n # bias\n z[true, 0] = 1\n curr_col = 1\n # itself\n z[true, 1..n_features] = x\n curr_col += n_features\n # high degree features\n curr_feat_ids = Array.new(n_features + 1) { |n| n + 1 }\n (1...@params[:degree]).each do\n next_feat_ids = []\n n_features.times do |d|\n f_range = curr_feat_ids[d]...curr_feat_ids.last\n next_col = curr_col + f_range.size\n z[true, curr_col...next_col] = z[true, f_range] * x[true, d..d]\n next_feat_ids.push(curr_col)\n curr_col = next_col\n end\n next_feat_ids.push(curr_col)\n curr_feat_ids = next_feat_ids\n end\n z\n end", "def x\n xe = nil\n each_element('x') { |e| xe = e }\n xe\n end", "def generate_matrix\n [].tap { |a| 25.times { a << 'X' } }.each_slice(5).to_a\n end", "def copy_tg(tg)\n result = [Array.new(tg[0].size),Array.new(tg[1].size)]\n tg[0].each_index do |n|\n result[0][n] = Array.new(tg[0][n])\n end\n tg[1].each_index do |e|\n result[1][e] = Array.new(tg[1][e])\n end\n result\nend", "def get_data(dimensions)\n data = []\n (0...@m).each do |row_idx|\n row = []\n col_idx = 1\n while col_idx <= dimensions\n row << @x_matrix[row_idx, col_idx]\n col_idx += 1\n end\n row << @y_vector[row_idx, 0]\n data << row\n end\n data\n end", "def row_elems(x)\n return @grid[x] unless block_given?\n @grid[x].each do |g|\n yield g\n end\n end", "def _vector(sexp, result=[])\n if null?(sexp)\n return result\n end\n (self.eval(car(sexp)) + _vector(cdr(sexp), result)) \n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n partial_fit(x, update_comps: false)\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n n_samples, n_features = x.shape\n transformed = Numo::DFloat.zeros(n_samples, n_features)\n n_features.times do |n|\n steps = @feature_steps[n]\n @params[:n_bins].times do |bin|\n mask = x[true, n].ge(steps[bin]).where\n transformed[mask, n] = bin\n end\n end\n transformed\n end", "def products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end", "def buy_fruit(types)\n fruits = []\n\n types.each do |subarray|\n subarray[1].times do |time|\n fruits << subarray[0]\n end\n end\n fruits\nend", "def maps(x) x.map{|i| i * 2} end", "def all_tuples\n @mutex.synchronize{@hash.values}.map{|bin| bin.elements}.flatten\n end", "def xy_array(options={})\n\n values=[]\n if options[:values]\n case options[:values]\n when :positive\n values = @v.collect{|v| v if v>0.0}\n when :negative\n values = @v.collect{|v| v if v<0.0}\n when :non_positive\n values = @v.collect{|v| v if v<=0.0}\n when :non_negative\n values = @v.collect{|v| v if v>=0.0}\n when :non_zero\n values = @v.collect{|v| v if v!=0.0}\n when :zero\n values = @v.collect{|v| v if v==0.0}\n when :all\n values = @v.clone\n else\n raise ArgumentError, \"Option not recognized\"\n end\n else\n values = @v.clone\n end\n hn = Array.new(@v.size, @start_time)\n @v.size.times do |i|\n if values[i].nil?\n hn[i] = nil\n else\n hn[i]+=i.hours\n end\n end\n [hn.compact, values.compact]\n end", "def triplify(arr)\n arr.map do |num|\n num * 3\n end\nend", "def _reduce_435(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def _reduce_435(val, _values, result)\n result = [ val[0], val[1] ]\n \n result\nend", "def buy_fruit(array_of_arrays)\n result = []\n array_of_arrays.each { |array| array[1].times{ |i| result << array[0] } }\n result\nend", "def element_times_index(numbers)\n\tmulti = []\n \n\ti = 0\n\twhile i < numbers.length\n\t\titem = numbers[i]*i\n\t\tmulti << item\n\t\ti += 1\n end\n\n\treturn multi\nend", "def x=(v)\n\t\t@x = [[590,v].min,0].max\n\tend", "def generate_triples(outside_nodes, inside_nodes)\n triples = []\n # outside_nodes : ABCDE\n # inside_nodes : abcde\n inside_nodes.push(inside_nodes.first) # inside_nodes becomes abcdea\n # triples is going to be : Aab Bbc Ccd Dde Eea\n 0.upto(outside_nodes.size - 1) do |i|\n triple = outside_nodes[i, 1] + inside_nodes[i, 2] \n triples.push(triple)\n end\n triples\nend", "def matrix(x, y, z)\n sub_array = []\n y.times do\n sub_array.push(z);\n end\n #sub_array\n array = [];\n x.times do\n array.push(sub_array)\n end\n array\nend", "def get_variables(input)\n variables = []\n input.each do |token|\n variables.push(token) if check_variables([token])\n end\n variables\n end", "def xyz\n [x, y, z]\n end", "def flatarray(tempvals)\n\t@tempvals = tempvals\n\tputs @tempvals.inspect\n\ttemparray = @tempvals.join(\",\").split(\",\").map(&:to_i).inspect\n\tputs temparray \n\treturn temparray \n end", "def generate_grid x = @x, y = @y\n new_grid = []\n\n y.times { new_grid << [] }\n new_grid.each do |array|\n x.times do\n array << []\n end\n end\n end", "def transform(t)\n ovwrite_me t.vectormult(self)\n end", "def seqlist(first,c,l)\n\t\tx = []\n l.times do |i|\n x[i]=(first + c*i)\n \tend\n x\nend", "def tx__x(n, x); 2.0 - tdist(n, x) * 2.0; end", "def transform(x)\n x = check_convert_sample_array(x)\n z = x.dup\n\n z[z.ne(0)] = Numo::NMath.log(z[z.ne(0)]) + 1 if @params[:sublinear_tf]\n z *= @idf if @params[:use_idf]\n case @params[:norm]\n when 'l2'\n z = Rumale::Preprocessing::L2Normalizer.new.fit_transform(z)\n when 'l1'\n z = Rumale::Preprocessing::L1Normalizer.new.fit_transform(z)\n end\n z\n end", "def [](i); @x[i]; end", "def vector\n result = []\n next_candiate = 2\n while result.size < @table_size\n (result << next_candiate) if prime?(next_candiate)\n next_candiate += 1\n end\n result\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n fit_transform(x)\n end", "def transform(x)\n x = ::Rumale::Validation.check_convert_sample_array(x)\n\n fit_transform(x)\n end", "def _reduce_125(val, _values, result)\n result = [ val[0] ]\n \n result\nend", "def vector max_value = 1\n log_once :consider_to_vector!, <<-S\n* WARNGING: ~Numeric#vector~ is deprecated. Use ~Numeric#to_vector~.\n~Numeric#to_vector~ is more preformant and returns a ~Hash~ containing the keys ~x~ and ~y~ as opposed\nto an ~Array~ of ~[x, y]~. Please note that you will lose the ability to destucture the values of a ~Hash~.\n\nS\n [vector_x(max_value), vector_y(max_value)]\n end", "def pp_vector(vector)\n puts vector.map { |y| y.inspect[1...-1].split('').join(' ') + ' , ' }.join[0...-3]\n print_new_line\nend", "def each\n i = -1\n vectors.first.each { |e| i+=1; yield [e, timeseries.index2time(i+outidx)] }\n end", "def collect!\n els = @elements.collect! {|v| yield(v)}\n Vector.elements(els, false)\n end", "def collect_temps(data, xschema)\n filtered_temps = Array.new\n temps = data.find_all { |d| d[\"type\"] =~ /MO:Temperature/i }\n temps.each { |d| \n attrs = self.get_attributes_for_datum(d[\"data_id\"], xschema)\n d[\"attributes\"] = attrs\n filtered_temps.push d\n }\n filtered_temps = filtered_temps.uniq_by { |d| d[\"attributes\"].nil? ? nil : d[\"attributes\"] }\n return filtered_temps\n end", "def extract(n)\n arr = []\n self.each do |x|\n arr << x[n]\n end\n return arr\n end", "def input\r\n\t\t@input.map{|i| i}\t\r\n\tend", "def t\n adj_t = Array.new(vertices.length) { [] }\n adj.each_with_index do |adj_j, j|\n adj_j.each do |v|\n adj_t[vertices.index(v)] << vertices[j]\n end\n end\n dup.tap { |g| g.adj = adj_t }\n end", "def generar_Vector(tamano_N)\n vector_iter = []\n for x in 1..tamano_N\n vector_iter.push generar_Num(true,0,0)\n end\n return vector_iter\n end", "def __splat(x) end", "def other_vector(arry)\n\t\treturn [(arry[0] - first_point[0]), (arry[1] - first_point[1])]\n\tend", "def x\n @components[:x]\n end", "def tsu_ids\n dwelling_units.map(&:tsu_id).compact.uniq\n end", "def multiple_variable_crossover(datacollection, colums, rows)\n porcent = datacollection.count\n\n puts \"#{colums}\"\n puts \"#{rows}\"\n data_collection_advanced = []\n datacollection.each_with_index do |data, index|\n id = index + 1\n data['id'] = id\n data_collection_advanced.push(data)\n end\n\n\n last_group_array = []\n rows.each do |column|\n agroup_array_x = []\n @hashx.each_with_index do |h, index|\n data_collection = {}\n groped_x = h[column]\n data_collection[column] = groped_x\n agroup_array_x.push(data_collection)\n end\n\n hashedART = {}\n group_hash = agroup_array_x.group_by { |u| u[column] }.map { |k, v| \n hashedART[ if !k.nil?\n \"#{k}\".downcase \n else\n \"null\"\n end\n ] = v.size.to_f/porcent.to_f }\n group_hash = hashedART\n group_array = agroup_array_x.group_by { |u| u[column] }.map { |k, v| [\n if !k.nil?\n \"#{k}\".downcase \n else\n \"null\"\n end, v.size.to_f/porcent.to_f] }\n heads = hashedART.keys\n hx = {\"hash\": hashedART, \"array\": group_array, \"heads\": heads}\n\n last_group_array.push(hx)\n end\n\n values_in_col = []\n\n\n colums.each do |col|\n @hashx.each_with_index do |h, index|\n values_in_col.push(h[col])\n end\n end\n\n values_in_col = values_in_col.uniq{|x| x}\n\n values_in_row = []\n adv_array = []\n last_group_array.each do |op|\n op[:heads].each do |px|\n values_in_row.push(px)\n rows.each do |row|\n values_in_col.each do |vin|\n colums.each do |col|\n hashed = {}\n hashed[\"row\"] = row\n hashed[\"rowvin\"] = px\n hashed[\"col\"] = col\n hashed[\"colvin\"] = vin\n selected = data_collection_advanced.select {|hash| hash[\"#{row}\"] == px if hash[\"#{col}\"] == \"#{vin}\"}\n hashed[\"q\"]= selected.count\n adv_array.push(hashed)\n end\n end\n end\n end\n end\n\n\n @crossover = {data: adv_array,values_in_row: values_in_row , values_in_col: values_in_col}\n\n end", "def generate_vectors size_range, int_range = (0..20)\n\tvector_array = []\n\tsize_range.each do |i|\n\t\tvector_array << Vector.new(rand(int_range), rand(int_range))\n\tend\n\treturn vector_array\nend", "def fixed_array\n reformated_array.map! do |element|\n element.join(\", \").split(\", \")\n end \nend", "def inverse_transform(x)\n n_features = x.shape[1]\n if n_features != @categories.size\n raise ArgumentError,\n 'Expect the number of features and the number of categories to be equal'\n end\n\n inv_transformed = Array.new(n_features) do |n|\n x[true, n].to_a.map { |i| @categories[n][i.to_i] }\n end\n\n Numo::NArray.asarray(inv_transformed.transpose)\n end", "def query(x, k = 1)\n x = check_convert_sample_array(x)\n check_params_numeric(k: k)\n check_params_positive(k: k)\n\n n_samples = x.shape[0]\n rel_ids = []\n rel_dists = []\n\n n_samples.times do |n|\n q = x[n, true]\n rel_node = search(q, @tree, k)\n dist_arr = calc_distances(q, @data[rel_node.sample_ids, true])\n rank_ids = dist_arr.sort_index[0...k]\n rel_ids.push(rel_node.sample_ids[rank_ids].dup)\n rel_dists.push(dist_arr[rank_ids].dup)\n end\n\n [Numo::Int32.cast(rel_ids), Numo::DFloat.cast(rel_dists)]\n end", "def generate_points(u_count, v_count)\n points = []\n v_count.times do |iv|\n row = []\n u_count.times do |iu|\n u = map1d(iu, (0..u_count), U_RANGE)\n v = map1d(iv, (0..v_count), V_RANGE)\n # default scale: 50, param: Array.new(12, 1) and mesh_distortion: 0\n row << superformula(u: u, v: v)\n end\n points << row\n end\n points\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 row; reshape(1, length); end", "def shifted_grid_at(t)\n grid = grid_at(t)\n shifted_grid = [[]]\n\n (0...@height).each do |i|\n shifted_grid[i] = grid.map {|n| n[i] }.flatten\n end\n shifted_grid\n end", "def get_scalar_diffs_from_vector(vector_diffs)\n\n vector_diffs.map do |vd|\n\n Math.sqrt(Math.sum(vd) { |e| e**2 })\n\n end\n\n end", "def create_pivot_vectors(x, y)\n @moves = nil\n @moves = {\n horizontal: { 0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil },\n vertical: { 0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil },\n diagonal1: { 0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil },\n diagonal2: { 0 => nil, 1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil }\n }\n\n rang = @win_with - 1\n (rang * -1..rang).each do |i|\n index = i + rang\n # TODO: USE METHOD validateXY(x+i,y+i)\n if x + i >= 0 && x + i <= @size - 1\n @moves[:horizontal][index] = @matrix[y][x + i]\n end\n\n if y + i >= 0 && y + i <= @size - 1\n @moves[:vertical][index] = @matrix[y + i][x]\n end\n\n if validate_xy(x + i, y + i)\n @moves[:diagonal1][index] = @matrix[y + i][x + i]\n end\n\n if validate_xy(x + (i * -1), y + i)\n @moves[:diagonal2][index] = @matrix[y + i][x + (i * -1)]\n end\n end\n end", "def to_s\n \"[#{@vector.join(\", \")}]#{@column ? \"T\" : \"\"}\"\n end", "def get_unique_permutations annotation_time_slot\r\n\t\treturn annotation_time_slot.uniq.permutation.to_a\r\n\tend" ]
[ "0.54982615", "0.54753065", "0.5474616", "0.5367529", "0.5355799", "0.5259143", "0.5245832", "0.50957704", "0.50746346", "0.5060266", "0.50580597", "0.50523525", "0.502389", "0.50077343", "0.49815914", "0.4902479", "0.48891896", "0.4878005", "0.48765522", "0.48684144", "0.48598593", "0.48415804", "0.48246875", "0.48210588", "0.4818936", "0.47999775", "0.4794064", "0.47937113", "0.4783132", "0.47758386", "0.47658834", "0.47469822", "0.47395396", "0.47181782", "0.47158256", "0.4710129", "0.47054055", "0.47041696", "0.47010538", "0.46785492", "0.46753213", "0.46577927", "0.46423078", "0.4636635", "0.46208566", "0.46142024", "0.46119407", "0.46090427", "0.45995063", "0.45852202", "0.45826116", "0.4566538", "0.45540982", "0.45344993", "0.45324254", "0.45324254", "0.45280376", "0.45170957", "0.45134833", "0.4499458", "0.4495171", "0.44926992", "0.44837585", "0.44811255", "0.44809023", "0.44802365", "0.44795582", "0.44788167", "0.4470822", "0.4461464", "0.44582298", "0.4452296", "0.4452296", "0.44514966", "0.4448105", "0.4446361", "0.44431672", "0.44421786", "0.4441074", "0.4440464", "0.44373477", "0.443314", "0.44314656", "0.44232193", "0.4416562", "0.44148228", "0.44127488", "0.44078237", "0.44069716", "0.43874815", "0.438669", "0.4377483", "0.43751034", "0.43724802", "0.43711066", "0.43686563", "0.43683425", "0.43606326", "0.43605313", "0.43539345" ]
0.5302401
5
Don't need any normalization
def get_data(dimensions) data = [] (0...@m).each do |row_idx| row = [] col_idx = 1 while col_idx <= dimensions row << @x_matrix[row_idx, col_idx] col_idx += 1 end row << @y_vector[row_idx, 0] data << row end data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalized; end", "def unnormalized; end", "def normalize; end", "def normalize!; end", "def normalize!\n end", "def normalize\n end", "def normalize!\n end", "def normalize\n self / self.norm\n end", "def normalized!\n self\n end", "def normalize; self.dup.normalize!; end", "def normalize!\n normalize self\n end", "def normalize!\n reverse! if !normal?\n end", "def normalize!\n self.replace self.normalize\n end", "def normalize!\n nil\n end", "def normalized=(_arg0); end", "def normalize\n\t\t\tself.dup.normalize!\n\t\tend", "def normalize\n self.dup.normalize!()\n end", "def normalize\n x_alize(true)\n end", "def normalize\n self.dup.normalize!\n end", "def normalize\n self.dup.normalize!\n end", "def normalizer; end", "def normalized? # :nodoc:\n @normalized\n end", "def normalized?\n !!@normalized\n end", "def normalize\n\t\t\treturn self.dup.normalize!\n\t\tend", "def normalize\n divide(magnitude)\n end", "def normalize!; length = 1.0; self; end", "def normalized\n @value\n end", "def normalize!\n normalize\n save\n end", "def normalize!\n normalize\n save\n end", "def normalize()\n merge(normalize: 'true')\n end", "def normalized?\n\t\tnot length > 1.00001\n\tend", "def normalize\n normalization_factor = norm_2(self)\n return self if normalization_factor.zero?\n\n self.scale (1.0 / normalization_factor.to_f)\n end", "def normalize!\n self.length = 1.0\n self\n end", "def normalize\n resize(1.0)\n end", "def normalize!\n total_items = @items.size\n raise \"No items set\" if total_items == 0\n total_sum = @items.values.map{|x| x[:value] }.inject(:+).to_f\n\n @items.each_pair do |key, values|\n @items[key][:normalized] = values[:value] / total_sum\n end\n @normalized = true\n end", "def normalize!\n\t\t\tmag = self.mag\n\t\t\t@elements = @elements.collect {|elem| elem / mag }\n\t\t\treturn self\n\t\tend", "def normalize\n store.normalize(minimum: minimum_value, spread: @spread)\n end", "def normal\n attributes.normal\n end", "def normal?\n\t !self.significant?\n\t end", "def normalize!\n\t\t\tmagnitude = self.mag\n\t\t\t@elem.collect! {|elem| elem / magnitude}\n\t\t\treturn self\n\t\tend", "def normalize!\n if self[2] < 0\n self[0], self[2] = self[0]+self[2], -self[2]\n end\n if self[3] < 0\n self[1], self[3] = self[1]+self[3], -self[3]\n end\n self\n end", "def chomsky_normal_form\n raise NotImplementedError \n end", "def normalize! level = 1.0\n self.divide!(@data.max / level)\n end", "def chomsky_normal_form!\n raise NotImplementedError\n end", "def normalize( value )\n value\n end", "def normalize\n [@x / Math.sqrt(@x**2 + @y**2), @y / Math.sqrt(@x**2 + @y**2)]\n end", "def normalize!\n __normalize_method\n __normalize_params\n end", "def chomsky_normal_form\n raise NotImplementedError\n end", "def normalize(x)\n if x.ndim == 2\n s = Numo::SFloat::Math.sqrt((x**2).sum(axis: 1))\n x / s.reshape(s.shape[0], 1)\n elsif x.ndim == 1\n s = Numo::SFloat::Math.sqrt((x**2).sum)\n x / s\n end\nend", "def inf_norm\n self.to_a.map do |a|\n a.map do |ar|\n ar.abs\n end.inject(&:+)\n end.sort[0]\n end", "def normalized?\n not @from.nil?\n end", "def normalize\n mag = self.magnitude\n Vector.new @x/mag, @y/mag, @z/mag\n end", "def normalize\n Transformation.new(self, self, [lambda{|x|x}])\n end", "def normalized_hash\n normalize! unless @normalized\n hashify(:normalized)\n end", "def normal?\n magnitude == 1\n end", "def normalized_weighting\n BigDecimal(weight.to_s) / ReputationRule.sum('weight')\n end", "def normalize(min, max, val)\n\t\t(val - min) / (max - min)\n\tend", "def normalize!\n mag = magnitude\n return self if mag == 0\n self.x, self.y, self.z = self.x / mag, self.y / mag, self.z / mag\n self\n end", "def normalize\n Transformation.new(self, base, @to_base)\n end", "def denormalize(to_units = nil)\n x_alize(false, to_units)\n end", "def normalize(data)\n normalize_players data\n normalize_board data\n normalize_deals data\n data\n end", "def normalize(input, entities = T.unsafe(nil), entity_filter = T.unsafe(nil)); end", "def normalize(tag)\n prenormalized = prenormalize(tag)\n @extra_normalizer ? @extra_normalizer.call(prenormalized) : prenormalized\n end", "def normalize\n f = 1.0 / length\n Vector2.new(@x * f, @y * f)\n end", "def strauss; end", "def normalize(domain); end", "def pre_normalize(text); end", "def normalize level = 1.0\n self.clone.normalize! level\n end", "def normalized\n @normalized ||= valid_range? ? range : normalized_range(range)\n rescue Exception => e \n # puts e.message\n value\n end", "def normal\n end", "def normal\n end", "def norm w\n 0.5 * Math.sqrt(w.keys.inject(0.0) {|u,k| u += w[k] ** 2.0})\nend", "def normalize!(context = nil)\n unless normalized?(context)\n self.class.normalizers.keys.each do |attr_name|\n __send__(:\"#{attr_name}=\", normalize_attribute(attr_name, context))\n end\n\n @normalization_context = context\n end\n\n self\n end", "def normalize(type); end", "def normalise\n nor_factor = @cdf.max\n (1..@N).each do |k|\n @pdf[k] = @pdf[k] / nor_factor \n @cdf[k] = @cdf[k] / nor_factor\n end\n end", "def normal(p)\n return nil # FIX ME\n end", "def normalize\n puts \"[debug] [normalize] node weight: #{@weight.class}\"\n if @is_leaf == 1\n @@validations.each do |validation|\n puts \"[debug] [normalize] current validation: |#{validation[0].class}|#{validation[1]}|#{validation[2]}|\"\n if (validation[0]...validation[1]) === @weight\n puts \"Bang!\"\n @weight=validation[2]\n break\n end\n end\n 1\n else\n 0\n end\n end", "def normalize(force=false)\n calculate_spread()\n\n if (@left_norm_data.nil? || force) && @has_left_data\n @left_norm_data = []\n# return unless @has_left_data\n\n# calculate_spread()\n\n @left_data.each do |data_row|\n norm_data_points = []\n data_row[DATA_VALUES_INDEX].each do |data_point|\n if data_point.nil?\n norm_data_points << nil\n else\n norm_data_points << ((data_point.to_f - @left_minimum_value.to_f) / @left_spread)\n end\n end\n @left_norm_data << [data_row[DATA_LABEL_INDEX], norm_data_points, data_row[DATA_COLOR_INDEX]]\n end\n end\n\n if (@right_norm_data.nil? || force) && @has_right_data\n @right_norm_data = []\n# return unless @has_right_data\n\n# calculate_spread(:right)\n\n @right_data.each do |data_row|\n norm_data_points = []\n data_row[DATA_VALUES_INDEX].each do |data_point|\n if data_point.nil?\n norm_data_points << nil\n else\n norm_data_points << ((data_point.to_f - @right_minimum_value.to_f) / @right_spread)\n end\n end\n @right_norm_data << [data_row[DATA_LABEL_INDEX], norm_data_points, data_row[DATA_COLOR_INDEX]]\n end\n end\n end", "def normalize(set, attributes)\n\t\tnew_set = []\n\t\ti = 0\n\t\twhile i < set.count\n\t\t\texample_aux = set[i]\n\t\t\tattributes.each do |a|\n\t\t\t\t# only if the attribute is continuous\n\t\t\t\tif a.type == \"continuous\"\n #puts \"example_aux.attributes[a.name] = \"+((set[i].attributes[a.name]).to_f / (a.max.to_f - a.min.to_f).to_f).to_s\n example_aux.attributes[a.name] = (set[i].attributes[a.name]).to_f / (a.max.to_f - a.min.to_f).to_f # normalization: (attribute.value)/(attribute max - attribute.min)\n end\n\t\t\tend\n\t\t\tnew_set << example_aux\n\t\t\ti += 1\n\t\tend\n\t\treturn new_set\n\tend", "def normalize\n f = 1.0 / length\n Normal3.new(@x * f, @y * f, @z * f)\n end", "def normalized?\n self.preferred_units.values - powers.keys == []\n end", "def normalize(v)\n find(v)&.alpha3 || super(v)\n end", "def normalize\n unless @hits.empty? then \n max = highest_score\n min = lowest_score\n all.each do |hit| \n if (max == min) then\n hit.score = 1\n else\n hit.score = (hit.score - min)/(max - min)\n end \n end\n sort\n end\n end", "def norm\n m = mag\n @x /= m\n @y /= m\n self\n end", "def getNorm(wv)\n sqSum = 0 \n wv.keys.each do |key|\n sqSum += wv[key]**2.0 \n end \n Math.sqrt(sqSum)\n end", "def valid_options\n super + [:denormalize]\n end", "def normalise(x, y)\n gcd = x.gcd(y)\n gcd = 1 if gcd.zero?\n\n [x /= gcd, y /= gcd]\nend", "def norm_vs_norm(obj_a, obj_b)\n obj_a.samp.copy(obj_a.curr)\n\n obj_b.samp.copy(obj_b.curr)\n if test_types(obj_a, obj_b)\n CollisionResolver.resolve(@cpa, @cpb, @coll_normal, @coll_depth)\n true\n else\n false\n end\n end", "def normalize(min, max)\n map { |v| v.respond_to?(:-) ? (v - min) / (max - min) : v }\n end", "def normalize(data)\n return [] if data.empty?\n min_power = max_power = data[0][:spectrum][0]\n data.each do |dp|\n min_power = [min_power, dp[:spectrum].min].min\n max_power = [max_power, dp[:spectrum].max].max\n end\n\n data.map{|dp| dp[:spectrum] = dp[:spectrum].map{|dsp| (100*(dsp - min_power)/max_power).round(1)}; dp}\nend", "def normalise\n gcd = x.gcd(y)\n gcd = 1 if gcd.zero?\n\n self.class.new(x / gcd, y / gcd)\n end", "def normalize_for_source\n nil\n end", "def normalize(set)\n set.map { |n| n - set.min }\n end", "def pre_divide; end", "def normalized?(context = nil)\n return false unless instance_variable_defined?(:@normalization_context)\n @normalization_context.nil? or (@normalization_context == context)\n end", "def reciprocal\n nil\n end", "def reciprocal\n nil\n end", "def norm\n Math::sqrt(data.values.inject(0) { |m,v| m+v**2})\n end", "def normalize!\n constant = @terms.select{ |t| t.is_a? Numeric }.inject(:+)\n hterms = @terms.select{ |t| t.is_a? Ilp::Term }.group_by(&:var)\n @terms = []\n constant ||= 0\n @terms << constant\n hterms.each do |v, ts| \n t = ts.inject(Ilp::Term.new(v, 0)) { |v1, v2| v1.mult += v2.mult; v1 }\n terms << t if t.mult != 0\n end\n self\n end", "def normalize(data)\n return [] if data.empty?\n min_power = max_power = data[0][:spectrum][0]\n data.each do |dp|\n min_power = [min_power, dp[:spectrum].min].min\n max_power = [max_power, dp[:spectrum].max].max\n end\n puts \"minmax #{min_power} #{max_power}\"\n #edited to * 10 instead of *100\n data.map{|dp| dp[:spectrum] = dp[:spectrum].map{|dsp| (10*(dsp - min_power)/max_power).round(1)}; dp}\nend", "def normalize_linear(features)\r\n # [min, max, mean, sd]\r\n statistics = get_statistics_of_features\r\n n_features = []\r\n\r\n count_features.times do |fi|\r\n min, max, mean, sd = statistics[fi]\r\n n_features[fi] = (features[fi]-min).to_f/(max-min)\r\n end\r\n\r\n n_features\r\n end" ]
[ "0.83714485", "0.8065399", "0.774859", "0.76957977", "0.75532037", "0.7472144", "0.7355371", "0.7354204", "0.71785045", "0.7156019", "0.70889586", "0.70818394", "0.7066192", "0.69365865", "0.6928838", "0.68594277", "0.68553585", "0.68465894", "0.6832335", "0.6832335", "0.6831524", "0.67798287", "0.6775192", "0.6718198", "0.6713385", "0.668373", "0.6602499", "0.65945303", "0.65945303", "0.6590865", "0.6558913", "0.64731556", "0.6434055", "0.638556", "0.6336396", "0.6277904", "0.6257845", "0.6249973", "0.6242503", "0.62236714", "0.61946946", "0.6166802", "0.6130275", "0.6117626", "0.6104592", "0.60617805", "0.60354704", "0.60102355", "0.59912777", "0.5960411", "0.59358984", "0.59264976", "0.59091324", "0.59063417", "0.5901658", "0.58967125", "0.5879732", "0.58703023", "0.58562607", "0.5824992", "0.5815072", "0.5806599", "0.57747924", "0.5768394", "0.57635915", "0.5748189", "0.5737321", "0.57300717", "0.5729913", "0.57068175", "0.57068175", "0.5702605", "0.5702525", "0.5647371", "0.5644478", "0.56179595", "0.5606645", "0.55908394", "0.55885154", "0.5585747", "0.5584798", "0.5580924", "0.5576164", "0.5571048", "0.5560147", "0.5558602", "0.555804", "0.5544868", "0.55226815", "0.5521904", "0.552113", "0.5518902", "0.5515903", "0.55132973", "0.54783356", "0.5452312", "0.5452312", "0.5446514", "0.54455584", "0.54418486", "0.5433276" ]
0.0
-1
Enqueues the action for a single resource.
def enqueue_action_single_resource(action, type, id) raise BadRequestError, "Must specify an id for changing a #{type} resource" unless id physical_switch = resource_search(id, type, collection_class(type)) api_action(type, id) do begin desc = "Performing #{action} for #{physical_switch_ident(physical_switch)}" api_log_info(desc) task_id = queue_object_action(physical_switch, desc, :method_name => action, :role => :ems_operations) action_result(true, desc, :task_id => task_id) rescue StandardError => err action_result(false, err.to_s) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enqueue(action)\n # add our request id for tracing purposes\n action[:messageId] = uid\n unless queue_full = @queue.length >= @max_queue_size\n ensure_worker_running\n @queue << action\n end\n !queue_full\n end", "def enqueue(action)\n # add our request id for tracing purposes\n action[:requestId] = Util.uid\n\n queue_full = @queue.length >= @max_queue_size\n @queue << action unless queue_full\n\n !queue_full\n end", "def submission\n resource_id = params[:resource_id]\n resource = StashEngine::Resource.find(resource_id)\n\n return if processing?(resource)\n\n update_submission_resource_info(resource)\n\n StashEngine.repository.submit(resource_id: resource_id)\n\n resource.reload\n\n redirect_to(stash_url_helpers.dashboard_path, notice: resource_submitted_message(resource))\n end", "def enqueue_action_multiple_resources(action, type, id)\n enqueue_action_single_resource(action, type, id)\n rescue ActiveRecord::RecordNotFound => err\n action_result(false, _(err.message))\n end", "def register_action(&block)\n uuid = Hammer::Core.generate_id\n @actions[uuid] = Hammer::Core::Action.new(uuid, self, block)\n context.register_action(uuid, self)\n return uuid\n end", "def enq item\r\n @mutex.synchronize {\r\n if not @done\r\n @tasks << item\r\n @resource.signal\r\n end\r\n not @done\r\n }\r\n end", "def action_subject(resource, *additional_args)\n if resource.respond_to?(:related_resources_recursive)\n related_resources = resource.related_resources_recursive\n else\n related_resources = []\n end\n plan_self(serialize_args(resource, *related_resources, *additional_args))\n if resource.is_a? ActiveRecord::Base\n if resource_locks == :exclusive\n exclusive_lock!(resource)\n else\n lock!(resource, resource_locks)\n end\n end\n end", "def resource_updated(resource, action)\n updates << [ resource, action ]\n end", "def dispatch(payload)\n queue.push(payload)\n end", "def enqueue(\n name,\n action: nil,\n method: nil,\n wait_url: nil,\n wait_url_method: nil,\n workflow_sid: nil,\n **keyword_args\n )\n\n enqueue = Enqueue.new(\n name,\n action: action,\n method: method,\n wait_url: wait_url,\n wait_url_method: wait_url_method,\n workflow_sid: workflow_sid,\n **keyword_args\n )\n\n yield(enqueue) if block_given?\n append(enqueue)\n end", "def run_action\n raise \"Action for resource #{self.class} is nil!\" if @action.nil?\n\t\t\tif (self.respond_to? @action)\n\t\t\t\tself.send(@action)\n\t\t\tend\n\t\tend", "def queue_action(action_name, *args)\n raise ::Demiurge::Errors::NoSuchActionError.new(\"Not an action: #{action_name.inspect}!\", { \"action_name\" => action_name },\n execution_context: @engine.execution_context) unless get_action(action_name)\n state[\"queue_number\"] += 1\n state[\"queued_actions\"].push([action_name, args, state[\"queue_number\"]])\n state[\"queue_number\"]\n end", "def resource_action(resource)\n resource.action if resource.respond_to?(:action)\n end", "def offer\n # Don't offer the action if it's going to be a no-op.\n if @agent.state[\"busy\"] > 0\n # See comment on \"silent\" in #allowed? below.\n self.cancel \"Agent #{@name.inspect} was too busy to act (#{@agent.state[\"busy\"]}).\", \"silent\" => \"true\"\n return\n elsif @agent.state[\"queued_actions\"].empty?\n self.cancel \"Agent #{@name.inspect} had no actions during the 'offer' phase.\", \"silent\" => \"true\"\n return\n end\n # Now offer the agent's action via the usual channels\n action = @agent.state[\"queued_actions\"][0]\n @action_name, @action_args, @action_queue_number = *action\n @action_struct = @agent.get_action(@action_name)\n super\n end", "def create\n model = model_class.new\n action = action_class.new(model, current_user)\n\n respond_with(action.create(resource_attributes))\n end", "def _one_item_action(func, resource_id, action, data = nil)\n url = detail_action_url(resource_id, action)\n @api_request.send(\n func,\n url,\n data,\n nil,\n self,\n resource_id\n )\n end", "def enqueue(payload)\n @queue.publish(JSON.generate(payload), :routing_key => @queue.name)\n end", "def action(name, &block)\n action = Moonrope::Action.new(@controller, name)\n action.dsl.instance_eval(&block) if block_given?\n @controller.actions[name] = action\n action\n end", "def action(&block)\n @actions << block\n end", "def trigger(resource_type_identifier, action)\n # TODO: not tested\n if @model.kinds.select { |kind| kind.term == resource_type }.any?\n type_identifier = @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.first.type_identifier\n\n location = @model.get_by_id(type_identifier).location\n resource_type_identifier = @endpoint + location\n end\n # check some basic pre-conditions\n raise \"Endpoint is not connected!\" unless @connected\n raise \"Unknown resource identifier! #{resource_type_identifier}\" unless resource_type_identifier.start_with? @endpoint\n\n # encapsulate the acion in a collection\n collection = Occi::Collection.new\n scheme, term = action.split(' #')\n collection.actions << Occi::Core::Action.new(scheme + '#', term)\n\n # make the request\n path = sanitize_resource_link(resource_type_identifier) + '?action=' + term\n post path, collection\n end", "def resource_action_start(resource, action, notification_type=nil, notifier=nil)\n end", "def enqueue(record)\n @queue << record.representation\n end", "def ar_save_resource\n @resource.save\n end", "def apply\n unless agent.state[\"busy\"] > 0 || agent.state[\"queued_actions\"].empty?\n # Pull the first entry off the action queue\n queue = @agent.state[\"queued_actions\"]\n if queue && queue.size > 0\n if @action_queue_number != queue[0][2]\n @engine.admin_warning(\"Somehow the agent's action queue has gotten screwed up mid-offer!\", \"agent\" => @name)\n else\n queue.shift # Remove the queue entry\n end\n end\n agent.run_action(@action_name, *@action_args, current_intention: self)\n agent.state[\"busy\"] += (@action_struct[\"busy\"] || 1)\n end\n end", "def resource_actions=(value)\n @resource_actions = value\n end", "def resource_actions=(value)\n @resource_actions = value\n end", "def method_missing(method, *args)\n # This is the Resque queue to which this job will be sent\n queue = @options[:to] || :default\n # Encode our Performable Method into something that can be stored in Resque\n payload = PerformableMethod.prepare(@target, method, args)\n\n if @options[:run_at]\n ::Resque.enqueue_at_with_queue(queue, @options[:run_at], PerformableMethod, payload)\n else\n ::Resque.enqueue_to(queue, PerformableMethod, payload)\n end\n end", "def perform!(resource_name, action, options = {})\n ClientOperations::Perform.new(resource_name, action, session, options).perform!\n end", "def perform_create\n resource.save!\n end", "def <<(resource)\n relate_resource(resource)\n super\n end", "def acquire_action\n case @event['action']\n when 'create'\n 'error'\n when 'resolve'\n 'success'\n end\n end", "def action(name, *args)\n intention = ActionItemInternal::ActionIntention.new(engine, @item.name, name, *args)\n @item.engine.queue_intention(intention)\n nil\n end", "def resource_action_command\n ACTION_COMMANDS[action_name.to_sym]\n end", "def register_action(uuid, component)\n @actions[uuid] = component\n self\n end", "def enqueue(payload)\n end", "def enqueue(item)\n end", "def set_resource_actions\n self.actions[:index] = Action.new(self.entity, :index, :collection, :resource => true)\n self.actions[:new] = Action.new(self.entity, :new, :collection, :resource => true)\n self.actions[:edit] = Action.new(self.entity, :edit, :member, :resource => true)\n self.actions[:show] = Action.new(self.entity, :show, :member, :resource => true)\n self.actions[:create] = Action.new(self.entity, :create, :collection, :method => :post, :resource => true)\n self.actions[:update] = Action.new(self.entity, :update, :member, :method => :put, :resource => true)\n self.actions[:delete] = Action.new(self.entity, :delete, :member, :method => :delete, :resource => true)\n end", "def register_subresource(resource)\n super.tap do |added|\n if added && action_on_update\n Chef::Log.debug(\"[#{self}] Registering #{action_on_update_immediately ? 'immediate ' : ''}#{action_on_update} notification from #{resource}\")\n resource.notifies action_on_update.to_sym, self, (action_on_update_immediately ? :immediately : :delayed)\n end\n end\n end", "def deliver\n @queue << self\n end", "def set_resource(resource = nil)\n resource ||= resource_class.find(params[:id])\n check_action_whitelisted!(params[:action])\n authorize! params[:action].to_sym, resource\n instance_variable_set(\"@#{resource_name}\", resource)\n end", "def process\n send_request @action\n end", "def perform(action, data = {})\n check_subscribed!\n subscription.perform_action(data.stringify_keys.merge(\"action\" => action.to_s))\n end", "def send_action &block\n @actions[:send] = block\n end", "def publish\n render json: ErrorSerializer.serialize(resource_name => \"is already published\"), status: 422 and return if resource.published\n\n if ResourcePublisher.new(resource).publish\n render json: resource, status: 200\n else\n render json: ErrorSerializer.serialize(resource.errors), status: 422\n end\n end", "def perform_action\n action_name = params[:action_name].to_sym\n action = resource.member_actions[action_name]\n if action.is_method_action?\n @record.send(action.method_name)\n end\n if action.is_block_action?\n action.block.call(@record)\n end\n return redirect_to([app_kit, @record])\n end", "def authorize_resource\n EffectiveResources.authorize!(self, action_name.to_sym, resource)\n end", "def perform_update\n @resource = controller.send(model.name)\n resource.tap do\n trigger_event(:save) do\n update_and_save_resource\n end\n end\n end", "def update\n unless @action.nil?\n log_action( action.name, @environment[:api_key] )\n\n @success.call( action ) if @success && @action\n @action = nil;\n end\n end", "def dispatched!\n update dispatched: true\n end", "def resource_actions\n @resource_actions ||= []\n end", "def request(object, method, args, options={})\n ResqueHandler.queue = options[:queue] || DEFAULT_QUEUE\n instance, id = instance_identifiers(object)\n ::Resque.enqueue(ResqueHandler, instance, id, method, *args)\n end", "def queue_action(action_name, *args)\n unless @item.is_a?(::Demiurge::Agent)\n @engine.admin_warning(\"Trying to queue an action #{action_name.inspect} for an item #{@item.name.inspect} that isn't an agent! Skipping.\")\n return\n end\n act = @item.get_action(action_name)\n unless act\n raise Demiurge::Errors::NoSuchActionError.new(\"Trying to queue an action #{action_name.inspect} for an item #{@item.name.inspect} that doesn't have it!\",\n \"item\" => @item.name, \"action\" => action_name, execution_context: @item.engine.execution_context)\n return\n end\n @item.queue_action(action_name, args)\n end", "def publishResourceAdd(app_id, run_id, resource)\n # Cache\n cache = RoomPlacesCachePublish.get_cache(app_id, run_id)\n\n cache.resources_add([resource])\n\t#nutella.net.publish('location/resources/added', {:resources => [resource]})\nend", "def add(action)\n return if @queue.size >= @@max_size\n \n if action.queue_policy == QueuePolicy::NEVER\n size = @queue.size + (@current_action == nil ? 0 : 1)\n return if size > 0\n end\n \n @queue << action\n next_action\n end", "def enq(item)\n @batch_update_mutex.synchronize do\n if item == :scheduled || item == :close\n add_current_batch_to_out_queue(item)\n return\n end\n status = try_add_item(item)\n if status != 0\n add_current_batch_to_out_queue(:add)\n if status == -1\n try_add_item(item)\n end\n end\n end\n end", "def action(a)\n @actions << a\n puts a.msg\n end", "def perform(*args)\n resource = StashEngine::Resource.where(id: args[0]).first\n return if resource.nil? || resource&.zenodo_copies&.data&.first&.state != 'enqueued' || self.class.should_defer?(resource: resource)\n\n data_copy = resource&.zenodo_copies&.data&.first\n zr = Stash::ZenodoReplicate::Copier.new(copy_id: data_copy.id)\n zr.add_to_zenodo\n end", "def dispatch(ticket_id = self.id)\n get_lock? ? push_to_client(ticket_id) : blocking(ticket_id)\n end", "def push(*resources)\n relate_resources(resources)\n super\n end", "def add_to_queue\n if !queue_id.blank? && cancelling?\n # cancelling items already have a valid job payload on the queue - do not add again\n return\n end\n\n payload = AnalysisJobsItem.create_action_payload(analysis_job, audio_recording)\n\n result = nil\n error = nil\n\n begin\n result = BawWorkers::Jobs::Analysis::Job.action_enqueue(payload)\n\n # the assumption here is that result is a unique identifier that we can later use to interrogate the message queue\n self.queue_id = result\n rescue StandardError => e\n # NOTE: exception used to be swallowed. We might need better error handling here later on.\n Rails.logger.error \"An error occurred when enqueuing an analysis job item: #{e}\"\n raise\n end\n\n @enqueue_results = { result: result, error: error }\n end", "def enqueue(item)\n\t\t@queue << item\n\tend", "def update(resource_name)\n if ! advance? then return self end\n @@logger.debug \"Updating resource: #{resource_name}.\"\n @events.push({ :update => resource_name})\n return self\n end", "def enqueue(payload)\n @queue.publish(payload.encode, :persistent => true)\n end", "def create\n Neo4j::Transaction.run do\n @q_resource = QResource.new(params[:q_resource])\n @q_resource.save!\n respond_to do |format|\n if @q_resource.save\n format.html { redirect_to @q_resource, :notice => 'Q resource was successfully created.' }\n format.json { render :json => @q_resource, :status => :created, :location => @q_resource }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @q_resource.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def enable\n @queue << \"enable\"\n end", "def add_thing(thing)\n enqueue(thing)\n end", "def user_action_on_resource_authorized\n end", "def push(event:)\n super\n\n @queue << event\n end", "def action(a_name, options={})\n new_action = {name: a_name}.merge(options)\n @actions_pool << new_action\n end", "def perform!(resource_name, action, options={})\n raise Copy::AuthenticationError unless session\n resource(resource_name).send(action, options_with_session(options))\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_string_value(\"name\", @name)\n writer.write_collection_of_object_values(\"resourceActions\", @resource_actions)\n end", "def on\n attachment = hpg_resolve(shift_argument)\n action(\"Activating #{attachment.config_var} (#{attachment.resource_name})\") do\n RestClient.post( authed_pgsnapshot_url('/client/resource'),\n json_encode({\"name\" => attachment.resource_name}) )\n end\n end", "def action(method, route, &block)\n @actions << [method.to_s, build_route(@with * \"/\" + route), block]\n end", "def accept_resource\n resource_class.accept_invitation!(update_resource_params)\n ## Report accepting invitation to analytics\n \n end", "def resource_up_to_date(resource, action)\n end", "def action_item(name, options = {}, &block)\n config.add_action_item(name, options, &block)\n end", "def save_resource\n resource.save\n end", "def put(name,&block)\n build_resource(name, :put, &block)\n end", "def collection_post_action(action)\n action = action.to_s.gsub('bulk_', '').to_sym\n\n raise 'expected post, patch or put http action' unless (request.post? || request.patch? || request.put?)\n raise \"expected #{resource_name} to respond to #{action}!\" if resources.to_a.present? && !resources.first.respond_to?(\"#{action}!\")\n\n successes = 0\n\n ActiveRecord::Base.transaction do\n successes = resources.select do |resource|\n begin\n resource.public_send(\"#{action}!\") if EffectiveResources.authorized?(self, action, resource)\n rescue => e\n false\n end\n end.length\n end\n\n render json: { status: 200, message: \"Successfully #{action_verb(action)} #{successes} / #{resources.length} selected #{resource_plural_name}\" }\n end", "def action_nothing\n logger.trace(\"Doing nothing for #{@new_resource}\")\n true\n end", "def enqueue\n Karafka.logger.info(\"Enqueuing #{self.class} - #{params}\")\n Karafka::Worker.perform_async(params)\n end", "def process_action(...)\n send_action(...)\n end", "def begin(resource)\n end", "def register_action(action, path=BASE_PATH)\n @instance.register_action action, path\n end", "def allowed_resource_actions=(value)\n @allowed_resource_actions = value\n end", "def enqueue(operation)\n Indexer.set(queue: self.class.name.underscore.pluralize).perform_later(operation.to_s, self)\n end", "def resource_update_applied(resource, action, update)\n @updates_by_resource[resource.name] << update\n end", "def enqueue_to(queue, klass, *args); end", "def create\n authorize! :create, resource\n current_model_service.create resource, params\n yield if block_given? # after_create\n respond_with resource, location: helpers.show_path(resource)\n end", "def add_action(a)\n $LOG.debug(\"Adding action #{a.type} to #{seq_name}\")\n \n @actions.push a\n \n a.apply_to(self)\n \n return a\n \n end", "def dispatch\n body = {\n 'command' => @command,\n 'nodes' => @nodes,\n 'run_timeout' => @timeout\n }\n\n ::Chef_Delivery::ClientHelper.enter_client_mode_as_delivery\n resp = @rest.post_rest('/pushy/jobs', body)\n ::Chef_Delivery::ClientHelper.leave_client_mode_as_delivery\n\n @job_uri = resp['uri']\n refresh\n end", "def notify_resource_added(resource, request)\n email = OrderMailer.create_resource_added(resource, request)\n Thread.new(email) do |e|\n OrderMailer.deliver(email)\n end\n end", "def action(name, altname=nil, &block) \n Runner.instance.add_action name, altname, &block\n end", "def enqueue_message(obj)\n output_queue << obj\n end", "def queue_act(user_id, act)\r\n @queue[user_id] ||= []\r\n @queue[user_id] << act\r\n # send this action if user is waiting\r\n if @waiting[user_id]\r\n send_act(@waiting[user_id], act)\r\n @waiting.delete(user_id)\r\n end\r\n end", "def action\n ACTIONS[self.action_id]\n end", "def enqueue(*args); end", "def requeue\n @action = :requeue\n end", "def create\n @resource = current_admin.resources.new(resource_params)\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render action: 'show', status: :created, location: @resource }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def action(&block)\n @action = block\n end" ]
[ "0.6444264", "0.6344201", "0.6113562", "0.5767109", "0.5728094", "0.5720891", "0.57013947", "0.5664915", "0.5645009", "0.5626888", "0.5567248", "0.5559725", "0.5558766", "0.5555397", "0.55398643", "0.5510747", "0.5496871", "0.5486329", "0.5464261", "0.54426163", "0.5426837", "0.54149866", "0.54138505", "0.54061615", "0.5371996", "0.5371996", "0.5342731", "0.53129727", "0.53117454", "0.53115654", "0.53030735", "0.52954936", "0.52848816", "0.52836406", "0.5279824", "0.5257696", "0.5240524", "0.5233192", "0.5232756", "0.5214335", "0.5210579", "0.52078104", "0.51917213", "0.51866466", "0.51859754", "0.5146629", "0.51376283", "0.5135", "0.5131221", "0.5128022", "0.51252234", "0.5123154", "0.51161015", "0.5104841", "0.5093376", "0.5083764", "0.5077611", "0.5072721", "0.5054785", "0.50531214", "0.50499886", "0.50370145", "0.50356233", "0.50335836", "0.5033449", "0.50304604", "0.5023271", "0.5022677", "0.50179845", "0.50167024", "0.50161976", "0.50082976", "0.50076145", "0.5006604", "0.5005782", "0.5004599", "0.50031286", "0.50008345", "0.4998308", "0.4981036", "0.49809498", "0.49791124", "0.49762052", "0.49753183", "0.4973682", "0.49724272", "0.49656558", "0.49644086", "0.49562603", "0.4952786", "0.49489918", "0.49437135", "0.49387226", "0.49377015", "0.49358127", "0.49271828", "0.49269503", "0.49267656", "0.49257323", "0.4924737" ]
0.72336215
0
Enqueues the action for multiple resources. For multiple resources, when an error occurs, the error messages must be built individually for each resource. Always responding with status 200.
def enqueue_action_multiple_resources(action, type, id) enqueue_action_single_resource(action, type, id) rescue ActiveRecord::RecordNotFound => err action_result(false, _(err.message)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collection_post_action(action)\n action = action.to_s.gsub('bulk_', '').to_sym\n\n raise 'expected post, patch or put http action' unless (request.post? || request.patch? || request.put?)\n raise \"expected #{resource_name} to respond to #{action}!\" if resources.to_a.present? && !resources.first.respond_to?(\"#{action}!\")\n\n successes = 0\n\n ActiveRecord::Base.transaction do\n successes = resources.select do |resource|\n begin\n resource.public_send(\"#{action}!\") if EffectiveResources.authorized?(self, action, resource)\n rescue => e\n false\n end\n end.length\n end\n\n render json: { status: 200, message: \"Successfully #{action_verb(action)} #{successes} / #{resources.length} selected #{resource_plural_name}\" }\n end", "def index_ok(resources:)\n render json: resources, status: :ok, include: index_includes\n end", "def upload_all_resources\n upload_conformance_resources\n upload_sample_resources\n retry_failed_upload\nend", "def push(*resources)\n relate_resources(resources)\n super\n end", "def all\n setup_request \"#{@@resource_url}s\"\n end", "def bulk_requests\n if @cloud\n if @cloud.api == \"Atmos\"\n @path = \"ex: /rest/objects/objectid?info\"\n @headers = \"One on each line. ex: {'x-emc-meta' => 'tag_name1=value1,tag_name2=value2'}. x-emc-date, x-emc-uid and x-emc-signature will be added automatically\"\n elsif @cloud.api == \"Amazon\"\n @path = \"ex: /ObjectName\"\n @headers = \"One on each line. ex: {'Content-MD5' => '033bd94b1168d7e4f0d644c3c95e35bf'}. Date and Authorization will be added automatically\"\n elsif @cloud.api == \"Swift\"\n @path = \"ex: /container/ObjectName.\"\n @headers = \"One on each line. ex: {'key' => 'value'}. X-Auth-Token will be added automatically\"\n end\n else\n @path = \"\"\n @headers = \"One on each line. ex: {'key' => 'value'}.\"\n end\n respond_to do |format|\n format.html { render \"shared/bulk_requests\" }\n end\n end", "def index\n build_resource({})\n respond_with self.resource\n end", "def proceed(raise_errors = true)\n # Empty requests?\n if requests.empty?\n if raise_errors\n fail ::ArgumentError, 'At least one message is required!'\n else\n return false\n end\n end\n\n # Headers\n options = { headers: batch_headers, url: self.class.batch_notification_url, method: :post }\n\n # Create array!\n options[:payload] = { channels: requests.map { |i| i.to_json(true)[:payload] } }.to_json\n\n # Send\n RestClient::Request.execute(options) do |response, request, result, &block|\n begin\n case response.code\n when 200, 201\n Response::Batch.new response, options\n when 301, 302, 307\n response.follow_redirection(request, result, &block)\n when 400\n fail Error::InvalidAttributes, response\n when 401\n fail Error::UnauthorizedRequest, response\n when 404\n fail Error::ChannelNotFound, response\n else\n fail Error::InvalidReturn, response\n end\n rescue => e\n if raise_errors\n raise e\n else\n false\n end\n end\n end # RestClient\n end", "def index\n unless params[:requests] && params[:requests].is_a?(Array)\n render :json => {:error => \"Must pass an array of requests\"}, :status => :bad_request and return\n end\n\n if params[:requests].size > MAX_REQUESTS\n render :json => {:error => \"This batch API accepts a maximum of #{MAX_REQUESTS} requests\"}, :status => :bad_request and return\n end\n\n fetcher = Batchy::Fetcher.new(app: Rails.application, requests: params[:requests]).run\n render :json => {:succeeded => fetcher.succeeded, :failed => fetcher.failed, :responses => fetcher.responses}, :status => :ok\n end", "def _upload_missing_resources(build, obj, potential_resources, options = {})\n # Upload the content for any missing resources.\n missing_resources = obj['data']['relationships']['missing-resources']['data']\n\n bar = Commander::UI::ProgressBar.new(\n missing_resources.length,\n title: 'Uploading resources...',\n format: ':title |:progress_bar| :percent_complete% complete - :resource_url',\n width: 20,\n complete_message: nil,\n )\n\n output_lock = Mutex.new\n uploader_thread_pool = Thread.pool(options[:num_threads] || 10)\n\n missing_resources.each do |missing_resource|\n uploader_thread_pool.process do\n missing_resource_sha = missing_resource['id']\n resource = potential_resources.find { |r| r.sha == missing_resource_sha }\n\n output_lock.synchronize do\n bar.increment resource_url: resource.resource_url\n end\n\n # Remote resources are stored in 'content', local resources are\n # read from the filesystem.\n content = resource.content || File.read(resource.path.to_s)\n\n client.upload_resource(build['data']['id'], content)\n end\n end\n\n uploader_thread_pool.wait\n uploader_thread_pool.shutdown\n end", "def publish\n render json: ErrorSerializer.serialize(resource_name => \"is already published\"), status: 422 and return if resource.published\n\n if ResourcePublisher.new(resource).publish\n render json: resource, status: 200\n else\n render json: ErrorSerializer.serialize(resource.errors), status: 422\n end\n end", "def resource_actions params={}\n except = params.delete(:except).arrayize.compact\n only = params.delete(:only).arrayize.compact\n\n params[:format] = params.has_key?(:format) ? params[:format].arrayize : [:html,:xml]\n\n # Logic to see if we should add an action\n # It should either be in :only, or :except isn't empty and it's not in :except\n should_add = lambda do |action|\n # Only isn't empty and our action is contained within\n if !only.empty?\n break only.include?(action)\n end\n # Except isn't empty and our action isn't contained therein\n if !except.empty?\n break !except.include?(action)\n end\n # Just add it\n true\n end\n\n # Add each action, if we should\n add :index, params if should_add[:index]\n add :new, params if should_add[:new]\n add :create, params if should_add[:create]\n add :edit, {:id => \"some_id\"}.merge(params) if should_add[:edit]\n add :show, {:id => \"some_id\"}.merge(params) if should_add[:show]\n add :update, {:id => \"some_id\"}.merge(params) if should_add[:update]\n add :destroy, {:id => \"some_id\"}.merge(params) if should_add[:destroy]\n end", "def call_api(method, resources)\n url_route = [@config.api_url, resources].flatten.join'/'\n result = HTTP.send(method, url_route)\n raise(result.to_s) if result.code >= 300\n result.to_s\n end", "def report_resources\n metadata = {\n 'sourcetype' => 'json_chef-resources',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n event = run_status.updated_resources.to_json\n\n splunk_post(event, metadata)\n end", "def resources_actions\n @resources_actions ||= []\n end", "def batch(*requests)\n body = requests.map do |request|\n {method: request[0], params: request[1..-1], jsonrpc: '2.0', id: SecureRandom.uuid}\n end\n parsed_response = parse_response(post(body))\n errors = parsed_response.select{|response| response[:error]}\n raise Error, errors if !errors.empty?\n parsed_response.map{|response| response[:result]}\n end", "def execute!\n stack = InternalMiddleware.batch_stack(self)\n format_response(stack.call(middleware_env))\n end", "def manage_resources(resources)\n resources.map {|r| manage_resource(r) }\n end", "def enqueue_action_single_resource(action, type, id)\n raise BadRequestError, \"Must specify an id for changing a #{type} resource\" unless id\n\n physical_switch = resource_search(id, type, collection_class(type))\n\n api_action(type, id) do\n begin\n desc = \"Performing #{action} for #{physical_switch_ident(physical_switch)}\"\n api_log_info(desc)\n task_id = queue_object_action(physical_switch, desc, :method_name => action, :role => :ems_operations)\n action_result(true, desc, :task_id => task_id)\n rescue StandardError => err\n action_result(false, err.to_s)\n end\n end\n end", "def set_resource_actions\n self.actions[:index] = Action.new(self.entity, :index, :collection, :resource => true)\n self.actions[:new] = Action.new(self.entity, :new, :collection, :resource => true)\n self.actions[:edit] = Action.new(self.entity, :edit, :member, :resource => true)\n self.actions[:show] = Action.new(self.entity, :show, :member, :resource => true)\n self.actions[:create] = Action.new(self.entity, :create, :collection, :method => :post, :resource => true)\n self.actions[:update] = Action.new(self.entity, :update, :member, :method => :put, :resource => true)\n self.actions[:delete] = Action.new(self.entity, :delete, :member, :method => :delete, :resource => true)\n end", "def batch_archive\n alarm_notification_ids = params[:alarm_notification_ids]\n alarm_notification_ids.each do |alarm_notification_id|\n @alarm_notification = AlarmNotification.find(alarm_notification_id)\n @alarm_notification.update_attribute(:archived, true)\n end\n respond_with(@alarm_notification, location: alarm_notifications_path)\n end", "def index\n @q_resources = QResource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @q_resources }\n end\n end", "def index\n @resources = resource_class.send(:all)\n render json: @resources\n end", "def safe_bulk(actions)\n sleep_interval = @retry_initial_interval\n begin\n @client.bulk(actions) # returns { 'errors': ..., 'items': ... }\n rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError => e\n # If we can't even connect to the server let's just print out the URL (:hosts is actually a URL)\n # and let the user sort it out from there\n @logger.error(\n \"Attempted to send a bulk request but Elasticsearch appears to be unreachable or down\",\n message: e.message, exception: e.class, will_retry_in_seconds: sleep_interval\n )\n @logger.debug? && @logger.debug(\"Failed actions for last bad bulk request\", :actions => actions)\n\n # We retry until there are no errors! Errors should all go to the retry queue\n sleep_interval = sleep_for_interval(sleep_interval)\n @bulk_request_metrics.increment(:failures)\n retry unless @stopping.true?\n rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::NoConnectionAvailableError => e\n @logger.error(\n \"Attempted to send a bulk request but there are no living connections in the pool \" +\n \"(perhaps Elasticsearch is unreachable or down?)\",\n message: e.message, exception: e.class, will_retry_in_seconds: sleep_interval\n )\n\n sleep_interval = sleep_for_interval(sleep_interval)\n @bulk_request_metrics.increment(:failures)\n if pipeline_shutdown_requested?\n # when any connection is available and a shutdown is requested\n # the batch can be aborted, eventually for future retry.\n abort_batch_if_available!\n end\n retry unless @stopping.true?\n rescue ::LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError => e\n @bulk_request_metrics.increment(:failures)\n log_hash = {:code => e.response_code, :url => e.url.sanitized.to_s,\n :content_length => e.request_body.bytesize, :body => e.response_body}\n message = \"Encountered a retryable error (will retry with exponential backoff)\"\n\n # We treat 429s as a special case because these really aren't errors, but\n # rather just ES telling us to back off a bit, which we do.\n # The other retryable code is 503, which are true errors\n # Even though we retry the user should be made aware of these\n if e.response_code == 429\n logger.debug(message, log_hash)\n else\n logger.error(message, log_hash)\n end\n\n sleep_interval = sleep_for_interval(sleep_interval)\n if pipeline_shutdown_requested?\n # In case ES side changes access credentials and a pipeline reload is triggered\n # this error becomes a retry on restart\n abort_batch_if_available!\n end\n retry\n rescue => e # Stuff that should never happen - print out full connection issues\n @logger.error(\n \"An unknown error occurred sending a bulk request to Elasticsearch (will retry indefinitely)\",\n message: e.message, exception: e.class, backtrace: e.backtrace\n )\n @logger.debug? && @logger.debug(\"Failed actions for last bad bulk request\", :actions => actions)\n\n sleep_interval = sleep_for_interval(sleep_interval)\n @bulk_request_metrics.increment(:failures)\n retry unless @stopping.true?\n end\n end", "def send_batch(batch)\n return if batch.empty?\n json_package = JSON.generate(batch.map { |c| c.output_hash })\n begin\n resp = @http_client.post @solr_update_url, json_package, \"Content-type\" => \"application/json\"\n rescue StandardError => exception\n end\n\n if exception || resp.status != 200\n error_message = exception ? \n Traject::Util.exception_to_log_message(exception) : \n \"Solr response: #{resp.status}: #{resp.body}\"\n\n logger.error \"Error in Solr batch add. Will retry documents individually at performance penalty: #{error_message}\"\n \n batch.each do |c|\n send_single(c)\n end\n end\n end", "def index\n @orders = index_resources\n respond_with(@orders)\n end", "def send_messages\n if Message.send_messages()\n render json: {status: :ok}\n else\n render json: \"Error\"\n end\n end", "def batch_save(root, resources, persps, exts)\n batch_save_actions(root, resources, persps, exts) do |action|\n action.perform\n end\n end", "def enqueue(action)\n # add our request id for tracing purposes\n action[:requestId] = Util.uid\n\n queue_full = @queue.length >= @max_queue_size\n @queue << action unless queue_full\n\n !queue_full\n end", "def enqueue(action)\n # add our request id for tracing purposes\n action[:messageId] = uid\n unless queue_full = @queue.length >= @max_queue_size\n ensure_worker_running\n @queue << action\n end\n !queue_full\n end", "def batch_save_actions(root, resources, persps, exts)\n if block_given?\n resources.each do |resource|\n db_path = File.join(root, resource.path(identifying_sym))\n yield PrepareDirAction.new(db_path)\n exts.each do |ext|\n persps.each do |persp|\n basename = basename_for_persp_and_ext(persp, ext)\n resource_path = File.join(db_path, basename) \n yield StoreResourceAction.new(resource_path, resource, persp, ext)\n end\n end\n end\n else\n Enumerator.new(self, :batch_save_actions, root, resources, persps, exts)\n end\n end", "def resource_actions\n @resource_actions ||= []\n end", "def index\n @resources = Resource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def run\n messages = {'outputs' => outputs}\n\n if outputs.include? 'trello'\n messages['trello'] = enqueue_trello\n end\n\n if outputs.include? 'jira'\n messages['jira'] = enqueue_jira\n end\n\n return [ACCEPTED, {}, messages]\n end", "def run\n messages = {'outputs' => outputs}\n\n if outputs.include? 'trello'\n messages['trello'] = enqueue_trello\n end\n\n if outputs.include? 'jira'\n messages['jira'] = enqueue_jira\n end\n\n return [ACCEPTED, {}, messages]\n end", "def perform(&block)\n raise Exception.new(\"You must have at least 2 requests\") unless @requests.length > 1\n @responses.clear\n requests.each_slice(Limit).to_a.each do |batch|\n body = {\n :batch => Yajl::Encoder.encode(batch),\n :access_token => Baloo.client_credentials\n }\n Client.post(\"/\", :body => body).each do |response|\n # response['headers'] = Yajl::Parser.parse(response['headers'])\n response['body'] = Yajl::Parser.parse(response['body'])\n yield response\n end\n end\n end", "def respond_with(*resources, &block)\n replacement = nil\n resources.each do |resource|\n if resource.respond_to?(:each)\n replacement = []\n resource.each do |instance| \n replacement << scrubbed_hash(instance.serializable_hash)\n end\n else\n replacement = scrubbed_hash(resource.serializable_hash)\n end\n end\n \n super(replacement)\n end", "def multiple_create\n\n return if nothing_to_save(params[:multi_objs], project_unit_tests_url)\n\n @multi_objs = params[:multi_objs].collect { |obj| @project.unit_tests.new(obj) }\n respond_to do |wants|\n if multi_save(@multi_objs)\n flash[:notice] = 'Unit Tests were successfully saved.'\n params[:page] = @project.unit_tests.last_page\n wants.html { redirect_paginated_to(project_unit_tests_url) }\n wants.xml { render :xml => @multi_objs, :status => :created, :location => project_unit_tests_url }\n else\n @multi_objs.each do |obj|\n @multi_objs_error = obj\n break unless obj.errors.empty?\n end\n wants.html {\n @utests = index_search\n render :index\n }\n wants.xml { render :xml => @multi_objs.first.errors, :status => :unprocessable_entity }\n end\n end\n end", "def retry_all\n if params[:queue].present? && params[:queue]!=\"failed\"\n Resque::Failure.requeue_queue(params[:queue])\n else\n (Resque::Failure.count-1).downto(0).each { |id| reque_single_job(id) }\n end\n redirect_to failures_path(redirect_params)\n end", "def send_batch(batch)\n return if batch.empty?\n\n logger.debug(\"#{self.class.name}: sending batch of #{batch.size} to Solr\")\n\n json_package = JSON.generate(batch.map { |c| c.output_hash })\n\n begin\n resp = @http_client.post solr_update_url_with_query(@solr_update_args), json_package, \"Content-type\" => \"application/json\"\n rescue StandardError => exception\n end\n\n if exception || resp.status != 200\n error_message = exception ?\n Traject::Util.exception_to_log_message(exception) :\n \"Solr response: #{resp.status}: #{resp.body}\"\n\n logger.error \"Error in Solr batch add. Will retry documents individually at performance penalty: #{error_message}\"\n\n batch.each do |c|\n send_single(c)\n end\n end\n end", "def index\n \n api_posts = Api::Post.all\n \n # Rabbit Sync - push 10k messages\n Publisher.publish(\"posts_all\",api_posts)\n @api_posts = Subscriber.pop(\"posts_all\")\n\n # Regular\n render json: @api_posts\n\n end", "def update_all\n #Build a json file based on criteria and settings...\n @access_token_job = BatchJob::AccessTokenUpsertJob.new(user: current_user)\n\n prepare_job(@access_token_job) do |access_token_job|\n attach_params_as_file_to_upsert_job(access_token_job)\n end\n\n @access_tokens = page(access_token_list)\n\n if @access_token_job.save\n BatchProcessorJob.perform_later(@access_token_job.id, @current_user.id)\n respond_to do |format|\n format.html { redirect_to :access_tokens, notice: 'Batch Job Submitted.' }\n format.json { render :show, status: :ok, location: url_for(controller: \"\", action: \"update_all\") }\n end\n else\n respond_to do |format|\n format.html { render :access_tokens }\n format.json { render json: @access_token_job.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n inbound_messages.each(&:save)\n render :nothing => true, :status => 200\n end", "def concat(resources)\n relate_resources(resources)\n super\n end", "def include_actions(*actions)\n self.actions ||= []\n self.actions.push(*actions)\n end", "def create(resources)\n #resources[0].model.last_query = resources\n counter = 0\n resources.each do |resource|\n fm_params = prepare_fmp_attributes(resource.dirty_attributes)\n rslt = layout(resource.model).create(fm_params)\n merge_fmp_response(resource, rslt[0])\n counter +=1\n end\n counter\n end", "def actions\n raise B1Admin::Exception.new(7,{text:\"Item B1Admin::Module with controller #{params['id']} not found\"}) unless item = B1Admin::Module.find_by_controller(params[:id].to_s)\n render json: {success: true, actions: item.get_controller_actions}\n end", "def refill_all_queues!\n # Dla POST musi byc jakies 'body' requestu, bo serwery czesto rzucaja wyjatkami (WEBrick w szczegolnosci).\n post '/queues/refill_all', :body => ' '\n true\n end", "def add_resources_transaction(resources)\n return true if resources.empty? \n self.modify_resources_atomically(resources)\n end", "def index\n respond_to do |format|\n format.html { @jobs_queues = JobsQueue.get_jobs_queues(current_user, params) }\n format.xml { render :xml => JobsQueue.get_jobs_queues(current_user, params.merge({:show => 'all'})) }\n end\n end", "def update\n render status: 501, json: { errors: ['Action not implemented yet!'] }\n end", "def resource_actions=(value)\n @resource_actions = value\n end", "def resource_actions=(value)\n @resource_actions = value\n end", "def perform(*reports)\n reports.each do |report|\n run_report(report)\n rescue StandardError => e\n report.update status: 'error'\n raise e\n end\n end", "def wrap_in_api_transaction\n respond_to do |format|\n format.any(:json_api, :json) do\n begin\n yield\n rescue Exception => e\n logger.error(e)\n logger.error e.backtrace.join(\"\\n\")\n render json: { errors: process_errors([\"Internal server error\"], 500) }, status: :internal_server_error\n end\n end\n end\n end", "def wrap_in_api_transaction\n respond_to do |format|\n format.any(:json_api, :json) do\n begin\n yield\n rescue Exception => e\n logger.error(e)\n logger.error e.backtrace.join(\"\\n\")\n render json: { errors: process_errors([\"Internal server error\"], 500) }, status: :internal_server_error\n end\n end\n end\n end", "def actions\n client.actions\n end", "def action_errors\n if @sender.abducted \n render json: \"\\nYou can't do this, you are already Abducted!!\"\n elsif params[:sender_id] == params[:survivor_id]\n render json: \"\\nYou can't do this. Are you trying to report yourself?\"\n end\n end", "def update_many\n respond_to do |format|\n if @products.update_all(product_params)\n format.html { redirect_to products_url, notice: 'Products were successfully updated.' }\n format.json { render :index, status: :ok, location: products_url }\n else\n format.html { render :index }\n format.json { render json: @products.errors, status: :unprocessable_entity }\n end\n end\n end", "def resource_way\n # TODO: make json default format?\n\n # try resource style\n #resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", \n #'user@test.com', 'please') #, :accept => :json)\n resources = RestClient::Resource.new(\"#{BASE_URL}/#{RESOURCE_NAME}\", 'b4j5qBqzYx5EukCM3Vri') #token\n # \n response = resources.get(:accept => :json)\n all_hosts = JSON.parse(response)\n puts \"EXISTING HOSTS: \" + all_hosts.inspect\n\n new_opts = {\n \"host_name\" => \"damian.np.dc1.eharmony.com\",\n \"alias\" => \"damian.np.dc1.eharmony.com\",\n \"address\" => \"damian.np.dc1.eharmony.com\",\n \"max_check_attempts\" => 3,\n \"notification_interval\" => 5,\n # 24x7\n \"notification_period\" => \"24x7\",\n #\"notification_period_id\" => \"5050cb9ebfa68e0903000001\",\n # 24x7\n \"check_period\" => \"24x7\",\n #\"check_period_id\" => \"5050cb9ebfa68e0903000001\",\n # just using first contact\n #\"contacts\" => [\"pat-obrien\"],\n \"contacts\" => [\"damian\"],\n #\"contact_ids\" => [\"5051283ebfa68e5757000002\"],\n }\n\n\n #puts resources['new'].post(NEW_OPTS.to_json, :content_type => :json, :accept \n #=> :json )\n # NOTE: even though this works and creates a new Host in DB - i still get 406 \n # Not Acceptable response\n #puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts}, :accept => \n #:json )\n begin\n puts resources['new'].post({ RESOURCE_NAME.to_s => new_opts})\n rescue Exception => e\n puts \"ERROR: #{e} = #{e.inspect}\"\n end\n\n \n\n # now edit the resource ...\nend", "def index\n \t#render json: Api::Alert.all, status: :ok\n \tend", "def update_many\n if @admin_notifications.update_all(admin_notification_params)\n render json: @admin_notifications, status: :ok, location: admin_notifications_url\n else\n render json: @admin_notifications.errors, status: :unprocessable_entity\n end\n end", "def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end", "def index\n authorize! :manage, :multiple_users\n\n respond_with(users)\n end", "def resources\n end", "def define_actions_from_routes\n (effective_resource.member_actions - effective_resource.crud_actions).each do |action|\n define_method(action) { member_action(action) }\n end\n\n (effective_resource.collection_actions - effective_resource.crud_actions).each do |action|\n define_method(action) { collection_action(action) }\n end\n end", "def create_multiple\n puts params\n\n @ticker_activities = params[\"_json\"].map do |params_hash|\n # ToDo => whitelisted_params einbauen. Siehe mein Beitrag bei stackoverflow unter http://stackoverflow.com/questions/35082478/handling-json-array-from-android-in-rails\n ticker = TickerActivity.create!(params_hash) \n end\n\n respond_to do |format|\n # Check that all the ticker_activities are valid and can be saved\n if @ticker_activities.all? { |ticker_activity| ticker_activity.valid? }\n # Now we know they are valid save each ticker_activity\n @ticker_activities.each do |ticker_activity|\n ticker_activity.save\n end\n\n # Respond with the json versions of the saved ticker_activites\n format.json { render json: @ticker_activities, status: :created, location: multiple_ticker_locations_url }\n \n else\n # We can't save *all* the ticker_activities so we\n # respond with the corresponding validation errors for the ticker_activities\n @errors = @ticker_activities.map { |ticker_activity| ticker_activity.errors }\n format.json { render json: @errors, status: :unprocessable_entity }\n end\n end\nend", "def enqueue_tasks\n update!(task_count: task_count) # finalize the task count\n \n # iterate over all tasks and enqueue each one\n tasks.each do |task|\n task.pool = self.pool\n \n message_id = task.enqueue\n \n # if the response was a numeric job id, then the task was successfully enqueued\n if message_id.is_a? Numeric\n task.status = States::QUEUED\n else\n # try to enqueue the task again\n if task.enqueue.is_a? Numeric\n task.status = States::QUEUED\n else\n task.status = States::NOT_QUEUED\n end\n end\n end\n \n tasks.to_a\n end", "def setup_request\n @resource_name = params[:resource].singularize.camelize\n @resource_klass_name = \"Entity::#{@resource_name}\"\n \n begin \n # Check that resource is managed by this controller\n unless ACCEPTED_RESOURCES[@resource_name]\n raise NameError\n end\n \n # Get resource arity\n @resource_arity = ACCEPTED_RESOURCES[@resource_name][:arity] || 'collection'\n \n rescue NameError => e\n render json: { errors: process_errors([\"Unknown Resource\"], 400) }, status: :bad_request\n return false\n end\n \n true\n end", "def perform\n self.multi = Curl::Multi.new if self.multi.nil?\n self.multi.add self\n ret = self.multi.perform\n\n if self.last_result != 0 && self.on_failure.nil?\n error = Curl::Easy.error(self.last_result) \n raise error.first\n end\n\n ret\n end", "def updateParallel(*resources)\n if ! advance? then return self end\n @@logger.debug \"Updating resource(s) in parallel #{resources.join(',')}.\"\n resources.each { |resource| @events.push( { :update => resource })}\n return self\n end", "def allow(actions, resources)\n add_rule(true, actions, resources)\n end", "def create_batch\n exp_list = []\n exp_err_list = []\n error_count = 0\n expedientes.each_with_index do |item, index|\n this_is_error = false\n expediente = expedientes[index][:expediente][:type].constantize.where(identificador: expedientes[index][:expediente][:identificador]).first\n cliente_recibido = expedientes[index][:expediente][:cliente_id]\n # it is a new Expediente\n if expediente.nil?\n type = \"New\"\n expediente = expedientes[index][:expediente][:type].constantize.new( this_expediente_params( index ) )\n if expediente.save\n result = \"success\"\n elsif check_special cliente_recibido\n result = \"special\"\n else\n result = \"error\"\n error_count = error_count + 1\n this_is_error = true\n end\n # it is an already existing Expediente\n else\n type = \"Edit\"\n if expediente.update_attributes( this_expediente_params( index, expediente.fecha_alta ) )\n result = \"success\"\n elsif check_special cliente_recibido\n result = \"special\"\n else\n result = \"error\"\n error_count = error_count + 1\n this_is_error = true\n end\n end\n exp_list << create_response(index, type, expediente, result, cliente_recibido) # add a response object for the received record\n if this_is_error\n exp_err_list << create_response(index, type, expediente, result, cliente_recibido) # add a response object for the received record\n this_is_error = false\n end\n end\n render json: exp_list\n respuesta = response_block(expedientes.count, error_count, exp_list)\n respuesta_email = response_block(expedientes.count, error_count, exp_err_list)\n Rails.application.config.api_logger.debug respuesta\n if error_count > 0\n ApiMailer.api_error_message(respuesta_email).deliver\n end\n end", "def index\n @api_v1_resources = Api::V1::Resource.all\n end", "def index\n render :text=>\"update not supported\", :status=>500\n end", "def apply_actions!\n\t @entity.apply_actions!(params[:entity])\n\t\t\tset_async_actions!\n end", "def respond_action(options, to_recipients)\n doc = @request_builder.action(options)\n @mails.push(doc)\n end", "def index\n @stocks = Stock.all\n @webhooks = ShopifyAPI::Webhook.find(:all)\n\n\n # After Authenticate Job / after change in product listings\n if Product.count < 1\n ProductSize.all.each do |size|\n _items = ShopifyAPI::Product.find(:all, params: { collection_id: size.collection_id })\n _items.each do |product|\n prod = Product.create(name: product.title, item_id: product.id, product_size: size)\n product.variants.each do |var|\n prod.variants.create!(quantity: var.inventory_quantity, variant_id: var.id, title: var.title, inventory_item_id: var.inventory_item_id )\n end\n end\n end\n end\n\n\n end", "def bulk(actions)\n raise NotImplemented, \"You must implement this yourself\"\n # bulk([\n # '{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }',\n # '{ \"field1\" : \"value1\" }'\n #])\n end", "def perform\n\n handle_errors_and_exceptions do\n\n r = validate\n return r unless r.success?\n\n r = fetch_client_manager\n return r unless r.success?\n\n r = validate_invitee_manager_exists\n return r unless r.success?\n\n r = create_invite_token\n return r unless r.success?\n\n r = enqueue_job\n return r unless r.success?\n\n success\n\n end\n\n end", "def respond_with_action(action)\n respond_with do |f|\n f.json { render action: action }\n f.xml { render action: action }\n end\n end", "def put_messages()\n #\n for i in 1..@max_msgs do\n message = \"Go Sox #{i}!\"\n @@log.debug \"#{message}\"\n @client.publish(@queue_name, message, \n {\"persistent\" => true, \"client-id\" => @client_id, \n \"reply-to\" => @queue_name} )\n end\n @client.close\n @@log.debug(\"queue_put completes\")\n end", "def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end", "def index(context)\n # context.request is an instance of Sinatra::Request\n params = context.request.params\n instance_variable_set(:\"@#{resource_name.pluralize}\", resource_name.classify.constantize.all)\n instance_variable_get(:\"@#{resource_name.pluralize}\").to_json\n end", "def too_many_bad_images\n if params[:action] == \"create\"\n redirect_to new_equipment_listing_path, alert: \"Too many images\"\n elsif params[:action] == \"update\"\n redirect_to edit_equipment_listing_path, alert: \"Too many images\"\n end\n end", "def add_to_queue\n @list = current_user.list\n if @list.add_job(params[:id])\n respond_to do |format|\n format.json { render :json => @list.jobs }\n end\n else\n flash[:errors] = \"Sorry, something went wrong\"\n redirect_to :back\n end\n end", "def call(env)\n req = Rack::Request.new(env)\n\n [200, { 'Content-Type' => 'application/json' }, [dispatch_action(req)]]\n rescue Heartcheck::Errors::RoutingError\n [404, { 'Content-Type' => 'application/json' }, ['Not found']]\n end", "def createParallel(*resources)\n if ! advance? then return self end\n @@logger.debug \"Launching resource(s) in parallel #{resources.join(',')}.\"\n resources.each do |resource|\n resource = @resourcer.get resource_name\n created = @mutator.create(resource_name, resource)\n created.harp_script = @harp_script\n result = {:create => resource_name}\n args = {:action => :create}\n if created.output? (args)\n result[:output] = created.make_output_token(args)\n result[:line] = @current_line\n end\n @events.push(result)\n created.save\n end\n return self\n end", "def run_actions\n catch_exceptions do\n @success = if block_given?\n result = yield\n actions.each {|action| results[action] = result}\n !!result\n else\n actions.compact.each {|action| !skip_actions && results[action] = object.send(action)}\n results.values.all?\n end\n end\n end", "def handle_post\n make_response(201, {message: 'New resource created'})\nend", "def index\n begin\n \n products = Product.all\n render json: {\n success: true,\n totalRecords: products.length,\n data: (ActiveModel::ArraySerializer.new(products, each_serializer: ProductSerializer))\n }, status: 200\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n success: false,\n errors: e.message\n }, status: 404\n rescue Exception => e\n render json: {\n success: false,\n errors: e.message\n }, status: 500\n end\n end", "def send_requests(evts)\n if evts.size < 1\n LOGGER.info(\"Skipping sending events since buffer is empty\")\n return\n end\n LOGGER.info(\"Attempting to send #{evts.size} request#{evts.size == 1 ? '' : 's'}\")\n\n evts.each do |event|\n event['stm'] = (Time.now.to_f * 1000).to_i.to_s # add the sent timestamp, overwrite if already exists\n end\n\n if @method == 'post'\n post_succeeded = false\n begin\n request = http_post(SelfDescribingJson.new(\n 'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4',\n evts\n ).to_json)\n post_succeeded = is_good_status_code(request.code)\n rescue StandardError => se\n LOGGER.warn(se)\n end\n if post_succeeded\n unless @on_success.nil?\n @on_success.call(evts.size)\n end\n else\n unless @on_failure.nil?\n @on_failure.call(0, evts)\n end\n end\n\n elsif @method == 'get'\n success_count = 0\n unsent_requests = []\n evts.each do |evt|\n get_succeeded = false\n begin\n request = http_get(evt)\n get_succeeded = is_good_status_code(request.code)\n rescue StandardError => se\n LOGGER.warn(se)\n end\n if get_succeeded\n success_count += 1\n else\n unsent_requests << evt\n end\n end\n if unsent_requests.size == 0\n unless @on_success.nil?\n @on_success.call(success_count)\n end\n else\n unless @on_failure.nil?\n @on_failure.call(success_count, unsent_requests)\n end\n end\n end\n\n nil\n end", "def queue(*queues)\n end", "def respond_with(content, *resources)\n options = resources.size == 0 ? {} : resources.extract_options!\n options[:status] = {} if options[:status].nil?\n\n # Format status\n status = {\n :code => options[:status][:code] ||= 200,\n :msg => options[:status][:msg] ||= \"OK\"\n }\n options[:status] = status[:code]\n\n if options[:json_header] != false\n # Format return\n content = {\n :header => {\n :version => current_version.to_s,\n :status => status,\n :request => request.original_fullpath, # escape or stripslahes or sanitize\n },\n :response => content\n }\n\n # If env is not production, return current env\n content[:header].merge!({:env => Rails.env}) unless Rails.env.production?\n end\n\n # Bug fix\n if request.method != 'GET'\n options[:location] ||= nil\n end\n\n super(content, options)\n end", "def flash_notice_for_resource_action(action = params[:action])\n return if resource_instance_variable.errors.any?\n\n case action.to_sym\n when :create\n verb = \"created\"\n when :update\n verb = \"updated\"\n when :destroy\n verb = \"removed\"\n end\n flash[:notice] = Alchemy.t(\n \"#{resource_handler.resource_name.classify} successfully #{verb}\",\n default: Alchemy.t(\"Successfully #{verb}\")\n )\n end", "def flash_notice_for_resource_action(action = params[:action])\n return if resource_instance_variable.errors.any?\n case action.to_sym\n when :create\n verb = \"created\"\n when :update\n verb = \"updated\"\n when :destroy\n verb = \"removed\"\n end\n flash[:notice] = _t(\"#{resource_handler.resource_name.classify} successfully #{verb}\", :default => _t(\"Succesfully #{verb}\"))\n end", "def index\n\t\tstatus = params[:status]\n\t\tbeacon_id = params[:beacon_id]\n\t\tday = Date.today\n\t\tif status == nil\n\t\t\tif beacon_id != nil\n\t\t\t\t@send_queues = SendQueue.where(\"release_end_date >= ? AND release_start_date <= ? AND beacon_id = ?\", day, day, beacon_id)\n\t\t\t\t@send_queues.each do |send_queue|\n\t\t\t\t\tsend_queue.send_time = Time.now\n\t\t\t\t\tsend_queue.image_url = request.host+\"#{send_queue.image.url(:larger)}\"\n\t\t\t\t\tsend_queue.save\n\t\t\t\tend\n\t\t\t\tRails.logger.info @send_queues.to_json\n\t\t\telse\n\t\t\t\t@send_queues = SendQueue.all\n\t\t\tend\n\t\telsif status == \"ok\"\n\t\t\t@send_queues = SendQueue.where(\"release_end_date >= ?\", day)\n\t\t\t@title = \"正在发布的广告\"\n\t\telsif status == \"no\"\n\t\t\t@send_queues = SendQueue.where(release_start_date: nil)\n\t\t\t@title = \"草稿中的广告\"\n\t\telsif status == \"pass\"\n\t\t\t@send_queues = SendQueue.where(\"release_end_date < ?\", day)\n\t\t\t@title = \"已经过期的广告\"\n\t\tend\n\t\trespond_with @send_queues\n end", "def run_actions\n catch_exceptions do\n @success = if block_given?\n result = yield\n actions.each { |action| results[action] = result }\n !!result\n else\n actions.compact.each { |action| !skip_actions && (results[action] = object.send(action)) }\n results.values.all?\n end\n end\n end", "def bulk_create\n @bulk_new = BulkNew.new(params[:bulk_new])\n\n respond_to do |format|\n if @bulk_new.valid?\n Bot.transaction do\n @bulk_new.bots.split.each do |e|\n bot = Bot.by_account(e)\n if bot.errors.empty?\n bot.save\n end\n\n bot.errors.each do |attribute, error|\n @bulk_new.errors.add(attribute, error)\n end\n end\n\n raise ActiveRecord::Rollback unless @bulk_new.errors.empty?\n end\n\n if @bulk_new.errors.empty?\n format.html { redirect_to bots_url }\n format.json { rhead :no_content }\n else\n flash[:alert] = @bulk_new.errors.map{|attribute, error| error }.join(\"<br/>\")\n format.html { render action: \"bulk_new\" }\n format.json { render json: @bulk_new.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def index\n\n\t self.merchants_index_preliminary_actions\n\t self.set_vendor_products\n\t self.set_flash\n end" ]
[ "0.5996528", "0.59655535", "0.5676235", "0.5563469", "0.55244195", "0.5516578", "0.5504725", "0.55009824", "0.54760396", "0.54397523", "0.53459245", "0.5337982", "0.52587515", "0.5235957", "0.5229544", "0.5224417", "0.5215673", "0.52050513", "0.5141789", "0.5130663", "0.51168203", "0.51136124", "0.50965506", "0.5045783", "0.5041425", "0.49983433", "0.4984635", "0.49620986", "0.49578303", "0.4955939", "0.4940136", "0.49344715", "0.49238363", "0.49236056", "0.49236056", "0.49130225", "0.49106225", "0.49100497", "0.48710173", "0.4868076", "0.48604453", "0.485625", "0.48501003", "0.48491162", "0.48411775", "0.48335975", "0.48117757", "0.4802705", "0.47938085", "0.4776783", "0.47759017", "0.4773761", "0.4773761", "0.4772058", "0.47708434", "0.47708434", "0.47688332", "0.47681016", "0.47650343", "0.47563463", "0.4754113", "0.47398832", "0.47395137", "0.47196317", "0.471621", "0.47123283", "0.47111", "0.47090897", "0.47087237", "0.47078356", "0.47049803", "0.47028947", "0.47009015", "0.47008532", "0.4699452", "0.46980196", "0.46970394", "0.46949035", "0.46942213", "0.46900663", "0.46808234", "0.46792755", "0.46789834", "0.46749905", "0.46669003", "0.4662792", "0.46600446", "0.46593654", "0.4654069", "0.46537215", "0.46495628", "0.46483794", "0.46464518", "0.4644692", "0.46410814", "0.46381643", "0.4633937", "0.46298257", "0.46297586", "0.4628616" ]
0.72910756
0
GET /exercise_templates GET /exercise_templates.json
def index @exercise_templates = ExerciseTemplate.all render json: @exercise_templates end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n render json: @exercise_template\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def list\n @client.make_request :get, templates_path\n end", "def templates\n response = get 'templates'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def index\n @question_templates = QuestionTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_templates }\n end\n end", "def get_templates(opts={})\n path = '/template/list'\n opts[:query] = create_search_string(opts[:query]) if opts[:query]\n query = create_query_string(opts, [:page, :page_size, :query])\n path += query\n HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template\n end", "def list\n @client.call(method: :get, path: 'templates')\n end", "def create\n @exercise_template = ExerciseTemplate.new(exercise_template_params)\n\n if @exercise_template.save\n render json: @exercise_template, status: :created, location: @exercise_template\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def get_templates(limit = 100, offset = 0)\n params = { :limit => limit, :offset => offset }\n\n request :get, \"/v3/templates.json\", params\n end", "def index\n @templates = Template.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @templates }\n end\n end", "def show\n respond_ok \"template\", @templates\n end", "def templates(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Templates\", params: params)\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def mcget_templates\n # setup_mcapi.folders.list(\"template\")\n setup_mcapi.templates.list({user: true},{include_drag_and_drop: true})\n end", "def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def editor_templates (type, uuid)\n res = http_get(:uri=>\"/editor/#{type}/templates/#{uuid}\", :fields=>x_cookie)\n end", "def get_job_templates\n dprint \"get /api/v1/job_templates\"\n resp = @rest['/api/v1/job_templates'].get\n dprint resp\n # ruby's implicit return\n JSON.parse(resp)[\"results\"]\n end", "def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def get_driver_templates\n @client.raw('get', '/content/email-templates/driver/templates')\n end", "def index\n @api_v1_exercises = Api::V1::Exercise.all\n end", "def index\n @question_templates = QuestionTemplate.all\n end", "def index\n @exercise_sets = ExerciseSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercise_sets }\n end\n end", "def show\n @question_template = QuestionTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_template }\n end\n end", "def index\n if params[:name]\n @template = Template.find_by_name(params[:name])\n if @template\n respond_ok \"template\", @template\n else\n respond_err \"template\", Template.new, \"i18> No template found\"\n end\n else\n @templates = Template.all\n if !@templates.empty?\n respond_ok \"template\", @templates\n else\n respond_err \"template\", @templates, \"i18> No template found\"\n end\n end\n end", "def index\n authorize! :manage, :all\n @question_templates = QuestionTemplate.all\n end", "def list_templates(type)\n res = http_get(:uri=>\"/editor/#{type}/templates\", :fields=>x_cookie)\n end", "def index\n @do_exercises = DoExercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @do_exercises }\n end\n end", "def index\n @exercises = Exercise.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def templates\n return self.class.get('/templates').parsed_response.map do |template|\n Template.new(template['template_id'], template['name'])\n end\n end", "def get_templates(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n r = @client.post({\n 'action' => 'gettemplate',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n\n templates = []\n JSON.parse(r)['result'].each do |data|\n host_template = ::Centreon::HostTemplate.new\n host_template.id = data['id'].to_i\n host_template.name = data['name']\n templates << host_template\n end\n\n templates\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def list_templates(args = {})\n filter = args[:filter] || 'featured'\n params = {\n 'command' => 'listTemplates',\n 'templateFilter' => filter\n }\n params['projectid'] = args[:project_id] if args[:project_id]\n params['zoneid'] = args[:zone_id] if args[:zone_id]\n \n json = send_request(params)\n json['template'] || []\n end", "def templates; end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @exercise }\n end\n end", "def index\n @templates = Template.all\n end", "def index\n @templates = Template.all\n end", "def index\n @templates = Template.all\n end", "def index\n @admin_templates = Template.order('id desc').page(params[:page]).per(10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_templates }\n end\n end", "def index\n @my_templates = MyTemplate.all\n end", "def index\n @exercises = Exercise.all\n @user = current_user # changed get logged user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @request_templates = RequestTemplate.all\n end", "def index\n @node_templates = NodeTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @node_templates }\n end\n end", "def show\n @exercise = Exercise.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def retrieve_all_template_info\n puts \"Retrieving all template ids and names for #{@primary_username} ...\"\n puts\n\n uri = URI(@config['endpoint'])\n\n # Retrieve templates\n http = Net::HTTP.new( uri.host,uri.port )\n http.use_ssl = true\n request = Net::HTTP::Get.new( uri.request_uri )\n request.basic_auth(@primary_username, @primary_password)\n\n response = http.request( request )\n templates = JSON.parse( response.body )\n\n # Create template_id array\n @template_array = Array.new\n\n # Create a template hash w/ name and id for each template found\n templates['templates'].each do |t|\n @template_array.push({:id => t['id'], :name => t['name']})\n end\n\n # Return constructed temmplate array\n return template_array\n end", "def templates\n GitWiki.template_cache ||= Dir[\"#{ settings.views[0] }/*.liquid\"].map do |f|\n name = File.basename(f, '.liquid')\n {\n \"name\" => name,\n \"examples\" => Page.get_template(name).examples\n }\n end\n end", "def templates\n Dir.glob(::Webby.path('examples') / '*').sort\n end", "def show\n @exercise_set = ExerciseSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_set }\n end\n end", "def show\n @template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @template }\n end\n end", "def index\n @templates = ::Template.all\n end", "def index\n @templates = @firm.templates\n @template = Template.new\n end", "def search_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TextMagicApi.search_templates ...'\n end\n # resource path\n local_var_path = '/api/v2/templates/search'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'ids'] = opts[:'ids'] if !opts[:'ids'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'content'] = opts[:'content'] if !opts[:'content'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SearchTemplatesPaginatedResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TextMagicApi#search_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @template }\n end\n end", "def index\n @inspection_templates = InspectionTemplate.all\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n\n end", "def index\n @email_templates = EmailTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @email_templates }\n end\n end", "def get_item_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: StoreApi.get_item_templates ...\"\n end\n # resource path\n local_var_path = \"/store/items/templates\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceStoreItemTemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StoreApi#get_item_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_course_templates_schema\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/schema\"\n _get(path)\n # This action returns a JSON array of SchemaElement blocks.\nend", "def get_content_template(id)\n @client.raw('get', \"/content/templates/#{id}\")\n end", "def index\n @timetable_templates = TimetableTemplate.all\n end", "def show\n @newsletters_template = Newsletters::Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @newsletters_template }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def index\n @meal_templates = MealTemplate.all\n end", "def index\n @score_templates = ScoreTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @score_templates }\n end\n end", "def index\n @templates = Template.includes(:template_elements).all\n end", "def show\n @patient_exercise = PatientExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient_exercise }\n end\n end", "def details(type, template_uuid)\n response = @client.get(\"editor/#{type}/templates/#{template_uuid}\")\n verify response,\n forbidden: 'You do not have permission to open the template',\n not_found: 'Template does not exist',\n internal_server_error: 'Internal server error occurred.'\n end", "def index\n \n last_modified = nil\n\n if params.has_key?(:character_id) # request using character_id \n \n state = Tutorial::State.find_by_character_id(params[:character_id])\n raise NotFoundError.new('No quests found for character id.') if state.nil?\n raise ForbiddenError.new('Access forbidden.') if state.owner != current_character && !staff? && !admin?\n \n @tutorial_quests = if api_request? # send only the relevant quests (those, that have not been finished yet)\n state.quests.non_closed \n else # display all quests in backend\n state.quests.paginate(:page => params[:page], :per_page => 50) \n end\n last_modified = state.updated_at.utc # the state is touched on changed on the quests\n \n else # request all \n raise ForbiddenError.new('Access forbidden.') if !staff? && !admin? \n @tutorial_quests = Tutorial::Quest.paginate(:page => params[:page], :per_page => 50)\n end\n \n if stale?(:last_modified => last_modified, :etag => @tutorial_quests)\n respond_to do |format|\n format.html \n format.json { render json: @tutorial_quests }\n end\n end\n end", "def index\n @exercise_tasks = ExerciseTask.all\n end", "def index\n @induction_templates = InductionTemplate.all\n end", "def templates\n @templates ||= TemplateFinder.new(path, types)\n end", "def templates\n state(metrics: \"metadata\").dig(\"metadata\", \"templates\")\n end", "def get_activity_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ActivitiesApi.get_activity_templates ...\"\n end\n # resource path\n local_var_path = \"/activities/templates\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceTemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ActivitiesApi#get_activity_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_all_course_templates\n path = \"/d2l/api/lp/#{$lp_ver}/orgstructure/6606/descendants/?ouTypeId=2\"\n _get(path)\n # return: JSON array of course template data objects\nend", "def index\n @templates = EmailTemplate.all\n end", "def show\n @project_template = ProjectTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_template }\n end\n end", "def get_policy_templates\n @command = :get_policy_templates\n # get the policy templates from the RESTful API (as an array of objects)\n uri = URI.parse @uri_string + '/templates'\n result = hnl_http_get(uri)\n unless result.blank?\n # convert it to a sorted array of objects (from an array of hashes)\n sort_fieldname = 'template'\n result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)\n end\n # and print the result\n print_object_array(result, \"Policy Templates:\", :style => :table)\n end", "def index\n @_templates = @site.templates.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @_templates }\n end\n end", "def templates\n wayfinder.decorated_templates\n end", "def update\n @exercise_template = ExerciseTemplate.find(params[:id])\n\n if @exercise_template.update(exercise_template_params)\n head :no_content\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def templates\n @conn.templates\n end", "def new\n @exercise_set = ExerciseSet.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_set }\n end\n end", "def tbu_list\n @client.make_request :get, templates_path('tbu')\n end", "def template_details(template_id)\n @api.get(\"#{@api.path}/List/#{@id}/Templates/#{template_id}\")\n end", "def templates\n\n add_breadcrumb \"Download Template\"\n\n @message = \"Creating inventory template. This process might take a while.\"\n\n end", "def index\n @user = User.find(current_user.id)\n @exercises = Exercise.all\n end", "def get_templates(type)\n Dir[get_template_location << type << '/*']\n end", "def templates_path\n @templates_path\n end", "def index\n @item_templates = ItemTemplate.all\n end", "def show\n @admin_template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_template }\n end\n end", "def templates_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TemplatesApi.templates_list ...'\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling TemplatesApi.templates_list, must be smaller than or equal to 100.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling TemplatesApi.templates_list, must be greater than or equal to 1.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'metadata'].nil? && opts[:'metadata'].to_s.length > 500\n fail ArgumentError, 'invalid value for \"opts[:\"metadata\"]\" when calling TemplatesApi.templates_list, the character length must be smaller than or equal to 500.'\n end\n\n pattern = Regexp.new(/[^\"\\\\]{0,500}/)\n if @api_client.config.client_side_validation && !opts[:'metadata'].nil? && opts[:'metadata'] !~ pattern\n fail ArgumentError, \"invalid value for 'opts[:\\\"metadata\\\"]' when calling TemplatesApi.templates_list, must conform to the pattern #{pattern}.\"\n end\n\n # resource path\n local_var_path = '/templates'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?\n query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?\n query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :multi) if !opts[:'include'].nil?\n query_params[:'date_created'] = opts[:'date_created'] if !opts[:'date_created'].nil?\n query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'TemplateList'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth']\n\n new_options = opts.merge(\n :operation => :\"TemplatesApi.templates_list\",\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: TemplatesApi#templates_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def form_templates\n FormTemplate.where(lecturer_id: @id)\n end", "def get_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _get(path)\n # return: JSON course template data\nend", "def templates\n @templates ||= EbanqApi::Templates.new(self)\n end" ]
[ "0.7126005", "0.70159036", "0.68598884", "0.6789637", "0.67713577", "0.6725251", "0.66778237", "0.6596028", "0.65107256", "0.64400196", "0.6423538", "0.6418938", "0.64132273", "0.6409025", "0.6409025", "0.6352914", "0.63268644", "0.6298526", "0.6271051", "0.6222909", "0.6179954", "0.6169817", "0.61591965", "0.61415267", "0.6098629", "0.6078537", "0.60509056", "0.6033682", "0.60156465", "0.6010787", "0.5991636", "0.5974015", "0.59726995", "0.59726995", "0.596424", "0.5963069", "0.595944", "0.59325445", "0.59325445", "0.59325445", "0.592107", "0.58941734", "0.5881951", "0.5876876", "0.5848469", "0.5841417", "0.58255494", "0.5824242", "0.5817583", "0.58154124", "0.58113295", "0.58092535", "0.57938224", "0.5791452", "0.5786281", "0.5780401", "0.57433844", "0.5742181", "0.5742118", "0.57402873", "0.57360554", "0.57302094", "0.572518", "0.5723019", "0.57228655", "0.57228655", "0.57228655", "0.57228655", "0.57224846", "0.5674764", "0.5666983", "0.5652552", "0.5644278", "0.5639866", "0.5639821", "0.56255585", "0.56226295", "0.56198657", "0.5612951", "0.56116474", "0.56105137", "0.5607595", "0.56052804", "0.5605193", "0.56035185", "0.55929124", "0.55916667", "0.55907184", "0.5579001", "0.5577727", "0.5570977", "0.5565163", "0.5561806", "0.5557714", "0.55559784", "0.5555011", "0.55456316", "0.55407834", "0.5534539", "0.553402" ]
0.7781126
0
GET /exercise_templates/1 GET /exercise_templates/1.json
def show render json: @exercise_template end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end", "def create\n @exercise_template = ExerciseTemplate.new(exercise_template_params)\n\n if @exercise_template.save\n render json: @exercise_template, status: :created, location: @exercise_template\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def index\n @question_templates = QuestionTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_templates }\n end\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def list\n @client.make_request :get, templates_path\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def show\n @question_template = QuestionTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_template }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def index\n @api_v1_exercises = Api::V1::Exercise.all\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @exercise }\n end\n end", "def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def index\n @templates = Template.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @templates }\n end\n end", "def show\n @exercise = Exercise.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def list\n @client.call(method: :get, path: 'templates')\n end", "def show\n respond_ok \"template\", @templates\n end", "def get_templates(opts={})\n path = '/template/list'\n opts[:query] = create_search_string(opts[:query]) if opts[:query]\n query = create_query_string(opts, [:page, :page_size, :query])\n path += query\n HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template\n end", "def index\n @exercise_sets = ExerciseSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercise_sets }\n end\n end", "def show\n @template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @template }\n end\n end", "def show\n @template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @template }\n end\n end", "def index\n if params[:name]\n @template = Template.find_by_name(params[:name])\n if @template\n respond_ok \"template\", @template\n else\n respond_err \"template\", Template.new, \"i18> No template found\"\n end\n else\n @templates = Template.all\n if !@templates.empty?\n respond_ok \"template\", @templates\n else\n respond_err \"template\", @templates, \"i18> No template found\"\n end\n end\n end", "def index\n @do_exercises = DoExercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @do_exercises }\n end\n end", "def templates\n response = get 'templates'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def get_templates(limit = 100, offset = 0)\n params = { :limit => limit, :offset => offset }\n\n request :get, \"/v3/templates.json\", params\n end", "def show\n @exercise_set = ExerciseSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_set }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n end", "def show\n @project_template = ProjectTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project_template }\n end\n end", "def index\n @question_templates = QuestionTemplate.all\n end", "def retrieve_single_template( template_id )\n puts \"Retrieving template id #{template_id}.\"\n\n uri = URI(@config['endpoint'] + '/' + template_id)\n\n # Retrieve templates\n http = Net::HTTP.new( uri.host,uri.port )\n http.use_ssl = true\n request = Net::HTTP::Get.new( uri.request_uri )\n request.basic_auth(@primary_username, @primary_password)\n\n response = http.request( request )\n template = JSON.parse( response.body )\n end", "def editor_templates (type, uuid)\n res = http_get(:uri=>\"/editor/#{type}/templates/#{uuid}\", :fields=>x_cookie)\n end", "def update\n @exercise_template = ExerciseTemplate.find(params[:id])\n\n if @exercise_template.update(exercise_template_params)\n head :no_content\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def index\n @exercises = Exercise.paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def templates(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Templates\", params: params)\n end", "def show\n @patient_exercise = PatientExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient_exercise }\n end\n end", "def get_content_template(id)\n @client.raw('get', \"/content/templates/#{id}\")\n end", "def mcget_templates\n # setup_mcapi.folders.list(\"template\")\n setup_mcapi.templates.list({user: true},{include_drag_and_drop: true})\n end", "def show\n @newsletters_template = Newsletters::Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @newsletters_template }\n end\n end", "def index\n @admin_templates = Template.order('id desc').page(params[:page]).per(10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_templates }\n end\n end", "def get_job_templates\n dprint \"get /api/v1/job_templates\"\n resp = @rest['/api/v1/job_templates'].get\n dprint resp\n # ruby's implicit return\n JSON.parse(resp)[\"results\"]\n end", "def index\n @exercises = Exercise.all\n @user = current_user # changed get logged user\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def show\n @admin_template = Template.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_template }\n end\n end", "def new\n @exercise_set = ExerciseSet.new\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_set }\n end\n end", "def template_retrieve_with_http_info(tmpl_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TemplatesApi.template_retrieve ...'\n end\n # verify the required parameter 'tmpl_id' is set\n if @api_client.config.client_side_validation && tmpl_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tmpl_id' when calling TemplatesApi.template_retrieve\"\n end\n pattern = Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n if @api_client.config.client_side_validation && tmpl_id !~ pattern\n fail ArgumentError, \"invalid value for 'tmpl_id' when calling TemplatesApi.template_retrieve, must conform to the pattern #{pattern}.\"\n end\n\n # resource path\n local_var_path = '/templates/{tmpl_id}'.sub('{' + 'tmpl_id' + '}', CGI.escape(tmpl_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\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] || 'Template'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth']\n\n new_options = opts.merge(\n :operation => :\"TemplatesApi.template_retrieve\",\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: TemplatesApi#template_retrieve\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @do_exercise = DoExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @do_exercise }\n end\n end", "def index\n @my_templates = MyTemplate.all\n end", "def index\n authorize! :manage, :all\n @question_templates = QuestionTemplate.all\n end", "def template_details(template_id)\n @api.get(\"#{@api.path}/List/#{@id}/Templates/#{template_id}\")\n end", "def index\n @templates = Template.all\n end", "def index\n @templates = Template.all\n end", "def index\n @templates = Template.all\n end", "def details(type, template_uuid)\n response = @client.get(\"editor/#{type}/templates/#{template_uuid}\")\n verify response,\n forbidden: 'You do not have permission to open the template',\n not_found: 'Template does not exist',\n internal_server_error: 'Internal server error occurred.'\n end", "def index\n @templates = @firm.templates\n @template = Template.new\n end", "def new\n @patient_exercise = PatientExercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_exercise }\n end\n end", "def get_templates(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n r = @client.post({\n 'action' => 'gettemplate',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n\n templates = []\n JSON.parse(r)['result'].each do |data|\n host_template = ::Centreon::HostTemplate.new\n host_template.id = data['id'].to_i\n host_template.name = data['name']\n templates << host_template\n end\n\n templates\n end", "def show\n @daily_exercise = DailyExercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daily_exercise }\n end\n end", "def show\n @exercise_log = ExerciseLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_log }\n end\n end", "def index\n @node_templates = NodeTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @node_templates }\n end\n end", "def create\n @api_v1_exercise = Api::V1::Exercise.new(api_v1_exercise_params)\n\n respond_to do |format|\n if @api_v1_exercise.save\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_exercise }\n else\n format.html { render :new }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_templates(type)\n res = http_get(:uri=>\"/editor/#{type}/templates\", :fields=>x_cookie)\n end", "def index\n @inspection_templates = InspectionTemplate.all\n end", "def index\n @request_templates = RequestTemplate.all\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def get_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _get(path)\n # return: JSON course template data\nend", "def show\n @invoice_template = InvoiceTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invoice_template }\n end\n end", "def index\n @templates = ::Template.all\n end", "def new\n @question_template = QuestionTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_template }\n end\n end", "def index\n @exercise_tasks = ExerciseTask.all\n end", "def show\n @exercise_category = ExerciseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_category }\n end\n end", "def show\n @exercise_category = ExerciseCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_category }\n end\n end", "def search_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TextMagicApi.search_templates ...'\n end\n # resource path\n local_var_path = '/api/v2/templates/search'\n\n # query parameters\n query_params = {}\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'ids'] = opts[:'ids'] if !opts[:'ids'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'content'] = opts[:'content'] if !opts[:'content'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SearchTemplatesPaginatedResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TextMagicApi#search_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @page_template = PageTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @page_template }\n end\n end", "def destroy\n @exercise_template.destroy\n\n head :no_content\n end", "def get_driver_templates\n @client.raw('get', '/content/email-templates/driver/templates')\n end", "def index\n @meal_templates = MealTemplate.all\n end", "def get_item_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: StoreApi.get_item_templates ...\"\n end\n # resource path\n local_var_path = \"/store/items/templates\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceStoreItemTemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: StoreApi#get_item_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def templates; end", "def template(name)\n @conn.templates.get(name)\n end", "def index\n @score_templates = ScoreTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @score_templates }\n end\n end", "def show\n @node_template = NodeTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @node_template }\n end\n end", "def show\n @score_template = ScoreTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @score_template }\n end\n end", "def index\n @user = User.find(current_user.id)\n @exercises = Exercise.all\n end", "def index\n @email_templates = EmailTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @email_templates }\n end\n end", "def get_template(template_name)\n self.api_get(:template, {:template => template_name})\n end", "def new\n @newsletters_template = Newsletters::Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newsletters_template }\n end\n end", "def index\n @timetable_templates = TimetableTemplate.all\n end", "def show\n @gift_template = GiftTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gift_template }\n end\n end", "def create\n exercise = Exercise.create(exercise_params)\n if exercise\n render json: exercise\n else\n render json: {error: 'Workout was not created.'}\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json { render json: Tissue.all }\n end\n \n end", "def index\n @form_templates = FormTemplate.where(:is_current => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @form_templates }\n end\n end", "def new\n @daily_exercise = DailyExercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daily_exercise }\n end\n end", "def show\n @exercise_instruction = ExerciseInstruction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise_instruction }\n end\n end" ]
[ "0.76289266", "0.6616761", "0.6582318", "0.65737027", "0.644448", "0.64309645", "0.64309645", "0.64262646", "0.641031", "0.6387172", "0.6283847", "0.6283847", "0.62828577", "0.62621826", "0.62445545", "0.62287426", "0.6208674", "0.6191285", "0.61840236", "0.61582685", "0.613481", "0.6131993", "0.61255956", "0.60935545", "0.60815865", "0.60715586", "0.6053297", "0.60509646", "0.60509646", "0.60509646", "0.60509646", "0.6049097", "0.60490507", "0.604655", "0.60374886", "0.6033267", "0.60319024", "0.6030048", "0.6026214", "0.60111815", "0.59983915", "0.5951242", "0.59355754", "0.593143", "0.59273916", "0.5925444", "0.5921266", "0.5898415", "0.58768094", "0.5867783", "0.58650064", "0.5862109", "0.58282983", "0.5816121", "0.5812322", "0.5789483", "0.5789483", "0.5789483", "0.5754815", "0.5754451", "0.57185274", "0.5718186", "0.57163835", "0.5713108", "0.57047784", "0.57045764", "0.56943715", "0.5693957", "0.56886494", "0.56788135", "0.56788135", "0.56746155", "0.566", "0.564446", "0.56432045", "0.56397146", "0.5638999", "0.5638999", "0.56325305", "0.56292987", "0.5628343", "0.56282496", "0.56279516", "0.5623307", "0.56171775", "0.56065494", "0.5595702", "0.55810404", "0.55511963", "0.5545045", "0.55443716", "0.5543613", "0.5534585", "0.5533702", "0.55328107", "0.55325836", "0.5529637", "0.55261934", "0.55257833", "0.5524653" ]
0.72894967
1
POST /exercise_templates POST /exercise_templates.json
def create @exercise_template = ExerciseTemplate.new(exercise_template_params) if @exercise_template.save render json: @exercise_template, status: :created, location: @exercise_template else render json: @exercise_template.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end", "def create\n @questionnaire_template = QuestionnaireTemplate.new(questionnaire_template_params)\n\n respond_to do |format|\n if @questionnaire_template.save\n format.html { redirect_to @questionnaire_template, notice: 'questionnaire template was successfully created.' }\n format.json { render :show, status: :created, location: @questionnaire_template }\n else\n format.html { render :new }\n format.json { render json: @questionnaire_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, :notice => 'exercise was successfully created.' }\n format.json { render :json => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :manage, :all\n @question_template = QuestionTemplate.new(question_template_params)\n\n respond_to do |format|\n if @question_template.save\n format.html do redirect_to question_template_path(@question_template),\n notice: 'Question template was successfully created.'\n end\n format.json { render action: 'show', status: :created, location: @question_template }\n else\n format.html { render action: 'new' }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n exercise = Exercise.create(exercise_params)\n if exercise\n render json: exercise\n else\n render json: {error: 'Workout was not created.'}\n end\n end", "def create\n @exercise = @workout.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: I18n.t('exercises.created') }\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @question_template = QuestionTemplate.new(question_template_params)\n\n respond_to do |format|\n if @question_template.save\n format.html { redirect_to @question_template, notice: 'Question template was successfully created.' }\n format.json { render :show, status: :created, location: @question_template }\n else\n format.html { render :new }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_exercise = Api::V1::Exercise.new(api_v1_exercise_params)\n\n respond_to do |format|\n if @api_v1_exercise.save\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_exercise }\n else\n format.html { render :new }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render json: @exercise, status: :created, location: @exercise }\n else\n flash.now[:error] = @exercise.errors.full_messages\n format.html { render action: \"new\"}\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def questionnaire_template_params\n params.require(:questionnaire_template).permit(:name, :qt_type_id, :instructions, :comments)\n end", "def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n flash[:class] = \"alert alert-success\"\n format.html { redirect_to @exercise, :notice => 'exercise was successfully created.' }\n format.json { render :json => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Exercise was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exercise }\n else\n format.html { render action: 'new' }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n render json: @exercise_template\n end", "def template_params\n params.require(:template).permit(:name, elements: [:type, :ordinal])\n end", "def create\n @inspection_template = InspectionTemplate.new(inspection_template_params)\n\n respond_to do |format|\n if @inspection_template.save\n format.html { redirect_to @inspection_template, notice: 'Inspection template was successfully created.' }\n format.json { render action: 'show', status: :created, location: @inspection_template }\n else\n format.html { render action: 'new' }\n format.json { render json: @inspection_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @patient_exercise = PatientExercise.new(params[:patient_exercise])\n\n respond_to do |format|\n if @patient_exercise.save\n format.html { redirect_to @patient_exercise, notice: 'Patient exercise was successfully created.' }\n format.json { render json: @patient_exercise, status: :created, location: @patient_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @patient_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(values)\n @client.call(method: :post, path: 'templates', body_values: values)\n end", "def create\n @exercise = current_user.exercises.new(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to @exercise, notice: 'Uebung was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exercise }\n else\n format.html { render action: 'new' }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def exercise_type_params\n params.require(:exercise_type).permit(:name, :test_template, :code_template, :input_type, :output_type, :testing_type, :test_method_template)\n end", "def sets_template_params\n params.require(:sets_template).permit(:setNum, :weight, :reps, :exercise_template_id)\n end", "def create\n @exercise_task = ExerciseTask.new(exercise_task_params)\n \n respond_to do |format|\n if @exercise_task.save\n format.html { redirect_to @exercise_task, notice: 'Exercise task was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_task }\n else\n format.html { render :new }\n format.json { render json: @exercise_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @performed_exercise = PerformedExercise.new(performed_exercise_params)\n\n respond_to do |format|\n if @performed_exercise.save\n format.html { redirect_to @performed_exercise, notice: 'Performed exercise was successfully created.' }\n format.json { render :show, status: :created, location: @performed_exercise }\n else\n format.html { render :new }\n format.json { render json: @performed_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise_template = ExerciseTemplate.find(params[:id])\n\n if @exercise_template.update(exercise_template_params)\n head :no_content\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def create\n # scrub this template input\n if template = scenario_params[\"template\"]\n @scenario = YmlRecord.load_yml(\"scenarios/local/#{template}/#{template}.yml\")\n else\n @scenario = Scenario.new(scenario_params)\n end\n\n @scenario.user_id = current_user.id\n @scenario.save!\n\n respond_to do |format|\n if @scenario.save\n format.html { redirect_to @scenario, notice: 'Scenario was successfully created.' }\n format.json { render :show, status: :created, location: @scenario }\n else\n format.html { render :new }\n format.json { render json: @scenario.errors, status: :unprocessable_entity }\n end\n end\n end", "def scaffold_template\n template = Template.new(title: 'Test template',\n description: 'My test template', \n links: {\"funder\":[],\"sample_plan\":[]},\n org: Org.first, archived: false, family_id: \"0000009999\")\n\n template.phases << Phase.new(title: 'Test phase',\n description: 'My test phase',\n number: 1, template: template)\n\n template.phases.first.sections << Section.new(title: 'Test section',\n description: 'My test section',\n number: 99, phase: template.phases.first)\n\n section = template.phases.first.sections.first\n i = 1\n # Add each type of Question to the new section\n QuestionFormat.all.each do |frmt|\n question = Question.new(text: \"Test question - #{frmt.title}\", number: i,\n question_format: frmt, section: section)\n\n if frmt.option_based?\n 3.times do |j|\n question.question_options << QuestionOption.new(text: \"Option #{j}\", number: j, question: question)\n end\n end\n\n section.questions << question\n i += 1\n end\n\n template.save!\n assert template.valid?, \"unable to create new Template: #{template.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}\"\n @template = template.reload\n end", "def scaffold_template\r\n template = Template.new(title: 'Test template',\r\n description: 'My test template', \r\n links: {\"funder\":[],\"sample_plan\":[]},\r\n org: Org.first, migrated: false, dmptemplate_id: \"0000009999\")\r\n\r\n template.phases << Phase.new(title: 'Test phase',\r\n description: 'My test phase',\r\n number: 1, template: template)\r\n\r\n template.phases.first.sections << Section.new(title: 'Test section',\r\n description: 'My test section',\r\n number: 99, phase: template.phases.first)\r\n\r\n section = template.phases.first.sections.first\r\n i = 1\r\n # Add each type of Question to the new section\r\n QuestionFormat.all.each do |frmt|\r\n question = Question.new(text: \"Test question - #{frmt.title}\", number: i,\r\n question_format: frmt, section: section)\r\n\r\n if frmt.option_based?\r\n 3.times do |j|\r\n question.question_options << QuestionOption.new(text: \"Option #{j}\", number: j, question: question)\r\n end\r\n end\r\n\r\n section.questions << question\r\n i += 1\r\n end\r\n\r\n template.save!\r\n assert template.valid?, \"unable to create new Template: #{template.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}\"\r\n @template = template.reload\r\n end", "def create\n @exercise = current_user.exercises.build(exercise_params)\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to exercise_weight_logs_path(@exercise)}\n format.json { render :show, status: :created, location: @exercise }\n else\n format.html { render :new }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def template_params\n params.require(:template).permit(:name, :content)\n end", "def create\n @question_template = QuestionTemplate.new(params[:question_template])\n params[:files].each_pair do |field_name, file|\n unless file.original_filename.empty?\n @question_template.send \"#{field_name}=\", file.original_filename\n end\n end\n\n respond_to do |format|\n if @question_template.save\n @question_template.upload_files(params[:files].values)\n\n format.html { redirect_to [:admin,@question_template], notice: 'Question template was successfully created.' }\n format.json { render json: @question_template, status: :created, location: @question_template }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_template_params\n params.require(:question_template).permit(:prompt, :response_type, :response_required)\n end", "def form_template_params\n params.permit(:name, questions: [:text, :type_id])\n end", "def create\n @do_exercise = DoExercise.new(params[:do_exercise])\n\n respond_to do |format|\n if @do_exercise.save\n format.html { redirect_to @do_exercise, notice: 'Do exercise was successfully created.' }\n format.json { render json: @do_exercise, status: :created, location: @do_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @do_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def template_params\n params.fetch(:template, {}).permit([:title, :data])\n end", "def create\n @exercise_set = ExerciseSet.new(params[:exercise_set])\n\n respond_to do |format|\n if @exercise_set.save\n format.html { redirect_to @exercise_set, notice: 'Exercise set was successfully created.' }\n format.json { render json: @exercise_set, status: :created, location: @exercise_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exercise_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @request_template = RequestTemplate.new(request_template_params)\n\n respond_to do |format|\n if @request_template.save\n respond format, 'Request template was successfully created.'\n else\n format.html { render :new }\n format.json { render json: @request_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_template_params\n params.require(:post_template).permit(:new_thing, :other_thing, :another_thing)\n end", "def template_params\n params.require(:template).permit(:name, :path, elements: [:key, :type, :content])\n end", "def create\n @timetable_template = TimetableTemplate.new(timetable_template_params)\n\n respond_to do |format|\n if @timetable_template.save\n format.html { redirect_to @timetable_template, notice: 'Timetable template was successfully created.' }\n format.json { render :show, status: :created, location: @timetable_template }\n else\n format.html { render :new }\n format.json { render json: @timetable_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def template_params\n params.require(:template).permit(:content)\n end", "def etemplate_params\n params.require(:etemplate).permit(:template_id, :template_name)\n end", "def create_question_template\n if @question_template.save\n flash[:success] = success_message(@question_template, :create)\n redirect_to survey_template_path(@survey_template)\n else\n flash[:error] = error_message(@question_template, :create)\n render :new\n end\n end", "def create\n @newsletters_template = Newsletters::Template.new(params[:newsletters_template])\n\n respond_to do |format|\n if @newsletters_template.save\n format.html { redirect_to @newsletters_template, notice: 'Template was successfully created.' }\n format.json { render json: @newsletters_template, status: :created, location: @newsletters_template }\n else\n format.html { render action: \"new\" }\n format.json { render json: @newsletters_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @review_template = ReviewTemplate.new(review_template_params)\n\n respond_to do |format|\n if @review_template.save\n format.html { redirect_to @review_template, notice: 'Review template was successfully created.' }\n format.json { render action: 'show', status: :created, location: @review_template }\n else\n format.html { render action: 'new' }\n format.json { render json: @review_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_template(template_name, template_fields)\n data = template_fields\n data[:template] = template_name\n self.api_post(:template, data)\n end", "def create\n @templates = @firm.templates\n @template = Template.new(template_params)\n @template.user = @user\n @template.firm = @firm\n if File.extname(@template.file.file.filename) == '.docx'\n content = ''\n if @template.valid_zip?\n doc = Docx::Document.open(@template.file.path)\n doc.paragraphs.each do |p|\n if p.node.xpath('w:r//w:lastRenderedPageBreak').present?\n content = content + %q(<div class=\"-page-break\"></div>) + p.to_html\n else\n content = content + p.to_html\n end\n\n end\n @template.html_content = content\n respond_to do |format|\n if @template.save\n format.html { redirect_to template_path(@template), notice: 'Template was successfully created.' }\n format.json { render :show, status: :created, location: @template }\n else\n format.html { render :new }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n else\n @template.errors.add(:file, 'is corrupted')\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @exercise = Exercise.new(params[:exercise])\n\n respond_to do |format|\n if @exercise.save\n format.html { redirect_to(@exercise, :notice => 'Exercise was successfully created.') }\n format.xml { render :xml => @exercise, :status => :created, :location => @exercise }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @node_template = NodeTemplate.new(params[:node_template])\n\n respond_to do |format|\n if @node_template.save\n format.html { redirect_to @node_template, notice: 'Node template was successfully created.' }\n format.json { render json: @node_template, status: :created, location: @node_template }\n else\n format.html { render action: \"new\" }\n format.json { render json: @node_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @template = Template.new(template_params)\n\n if @template.save\n render :show, status: :created, location: @template\n else\n render json: @template.errors, status: :unprocessable_entity\n end\n end", "def create\n issue_template = IssueTemplate.new(issue_template_params)\n\n respond_to do |format|\n if issue_template.save\n format.html { redirect_to issue_templates_path, notice: 'Issue template was successfully created.' }\n else\n format.html { redirect_to issue_templates_path, alert: issue_template.errors }\n end\n end\n end", "def add\n @object = JSON.parse(File.read(\"data/templates/#{params[:identifier]}.js\"))\n @object['identifier'] = \"#{@object['identifier']}_#{current_user.id}\"\n @template = Template.create! @object\n @template.identifier = \"#{@template.id}_#{@template.identifier}\"\n @template.status = 100\n @template.count = 0\n\n current_user.templates.push @template\n respond_to do |format|\n format.html { redirect_to @template }\n end if @template.save\n end", "def create\n @quest_template = QuestTemplate.new(params[:quest_template])\n\n respond_to do |format|\n if @quest_template.save\n flash[:notice] = 'QuestTemplate was successfully created.'\n format.html { redirect_to(@quest_template) }\n format.xml { render :xml => @quest_template, :status => :created, :location => @quest_template }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quest_template.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @survey_item_template = SurveyItemTemplate.new(survey_item_template_params)\n\n respond_to do |format|\n if @survey_item_template.save\n format.html { redirect_to @survey_item_template.survey_item_category_template.survey_template, notice: 'Survey item template was successfully created.' }\n format.json { render :show, status: :created, location: @survey_item_template }\n else\n format.html { render :new }\n format.json { render json: @survey_item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.all.map{ |c| [c.name, c.id]}\n @training = Training.new(training_params)\n\n respond_to do |format|\n if @training.save\n format.html { redirect_to @training, notice: 'Training was successfully created.' }\n format.json { render :show, status: :created, location: @training }\n else\n format.html { render :new }\n format.json { render json: @training.errors, status: :unprocessable_entity }\n end\n end\n end", "def question_template_params\n res = params.require(:question_template).permit(:name, :locked, answers: [])\n res[:answers] = Answer.find(res[:answers].reject { |v| v==\"\" })\n res\n end", "def set_templates(name, templates)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n raise('wrong type: String required') unless templates.is_a?(String)\n raise('wrong value: templates must be valid') unless !templates.nil? && !templates.empty?\n\n @client.post({\n 'action' => 'settemplate',\n 'object' => 'htpl',\n 'values' => '%s;%s' % [name, templates],\n }.to_json)\n end", "def question_template_params\n params.require(:question_template).permit(:context_id, :name, :points_awarded)\n end", "def create\n @my_template = MyTemplate.new(my_template_params)\n\n respond_to do |format|\n if @my_template.save\n format.html { redirect_to @my_template, notice: 'My template was successfully created.' }\n format.json { render :show, status: :created, location: @my_template }\n else\n format.html { render :new }\n format.json { render json: @my_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_template = ItemTemplate.new(item_template_params)\n\n respond_to do |format|\n if @item_template.save\n format.html { redirect_to @item_template, notice: 'Item template was successfully created.' }\n format.json { render :show, status: :created, location: @item_template }\n else\n format.html { render :new }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @template = Template.new(template_params)\n @template.last_execute_at = nil\n @template.status = 100\n @template.count = 0\n respond_to do |format|\n if @template.save\n current_user.templates.push(@template)\n current_user.save\n #format.html { redirect_to @template, notice: 'Template was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @template }\n format.json { render json: @template, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise_name = ExerciseName.new(exercise_name_params)\n\n respond_to do |format|\n if @exercise_name.save\n format.html { redirect_to @exercise_name, notice: 'Exercise name was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_name }\n else\n format.html { render :new }\n format.json { render json: @exercise_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def induction_template_params\n params.require(:induction_template).permit(:template_no, :description, :activity, :day, :duration, :employee_id)\n end", "def template_params\n params.require(:template).permit(:name, :action)\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def my_template_params\n params.require(:my_template).permit(:name, :desc)\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n\n end", "def create_template\n self.template = \"template 14231\"\n end", "def create\n @event_template = EventTemplate.new(event_template_params)\n\n respond_to do |format|\n if @event_template.save\n format.html { redirect_to @event_template, notice: \"Event template was successfully created.\" }\n format.json { render :show, status: :created, location: @event_template }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @event_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def workout_template_params\n # params.require(:workout_template).permit(:title, :isTemplate, :boolean, :exerciseCount, :user_id,:id)\n params .permit(:title, :isTemplate, :boolean, :exerciseCount, :user_id,:id)\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n end", "def issue_template_params\n params.require(:issue_template).permit(:title, :description, :rating, :recommendation, :severity)\n end", "def create\n @template = Template.new(template_params)\n if @template.save\n respond_ok \"template\", @template\n else\n respond_err \"template\", @template, @template.errors\n end\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def create(data)\n result = @client.api_request(:method => \"template.create\", :params => [data])\n result.empty? ? nil : result['templateids'][0].to_i\n end", "def create\n @invitation_template = InvitationTemplate.new(invitation_template_params)\n\n respond_to do |format|\n if @invitation_template.save\n format.html { redirect_to @invitation_template, notice: 'Invitation template was successfully created.' }\n format.json { render :show, status: :created, location: @invitation_template }\n else\n format.html { render :new }\n format.json { render json: @invitation_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def physio_exercise_params\n params.require(:physio_exercise).permit(\n :name,\n :description,\n :client_id,\n :duration,\n :user_id\n )\n end", "def create\n @template = ::Template.new(template_params)\n\n respond_to do |format|\n if @template.save\n format.html { redirect_to @template, notice: 'Template was successfully created.' }\n format.json { render :show, status: :created, location: @template }\n else\n format.html { render :new }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @daily_exercise = DailyExercise.new(params[:daily_exercise])\n\n respond_to do |format|\n if @daily_exercise.save\n format.html { redirect_to @daily_exercise, notice: 'Daily exercise was successfully created.' }\n format.json { render json: @daily_exercise, status: :created, location: @daily_exercise }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daily_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @question_templates = QuestionTemplate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_templates }\n end\n end", "def template_params\n params.require(:template).permit(:name)\n end", "def create\n @post_template = PostTemplate.new(post_template_params)\n\n respond_to do |format|\n if @post_template.save\n format.html { redirect_to @post_template, notice: 'Post template was successfully created.' }\n format.json { render :show, status: :created, location: @post_template }\n else\n format.html { render :new }\n format.json { render json: @post_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_template = ItemTemplate.new(item_template_params)\n\n respond_to do |format|\n if @item_template.save\n format.html { redirect_to @item_template, notice: 'Item Template was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_template }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @template = Template.new(template_params)\n\n respond_to do |format|\n if @template.save\n format.html { redirect_to @template, notice: 'Template was successfully created.' }\n format.json { render :show, status: :created, location: @template }\n else\n format.html { render :new }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def template_params\n params.require(:template).permit(:file, :description, :name, :html_content)\n end", "def create\n @template = EmailTemplate.new(template_params)\n respond_to do |format|\n if @template.save\n format.html { redirect_to email_templates_path, notice: 'template was successfully created.' }\n format.json { render :show, status: :created, location: @template }\n else\n format.html { render :new }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise = Exercise.new(params[:exercise].update(:company_id => current_company.id))\n #TODO agregar cuentas a un ejercicio nuevo. Seleccionar las cuentas del último ejercicio\n #@exercise.accounts = \n \n flash[:notice] = t('flash.actions.create.notice', :resource_name => Exercise.model_name.human) if @exercise.save\n respond_with(@exercise, :location => exercises_path)\n end", "def create\n @my_exercise = MyExercise.new(params[:my_exercise])\n\n respond_to do |format|\n if @my_exercise.save\n flash[:notice] = 'MyExercise was successfully created.'\n format.html { redirect_to(@my_exercise) }\n format.xml { render :xml => @my_exercise, :status => :created, :location => @my_exercise }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @my_exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @template = Template.new(template_params)\n\n respond_to do |format|\n if @template.save\n format.html {\n redirect_to @template,\n notice: \"Template #{@template.template_name} was successfully created.\"\n }\n format.json {\n render :show, status: :created, location: @template\n }\n else\n format.html { render :new }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def exercise_params\n params.require(:exercise).permit(:workout_id, :title, :sets, :reps)\n end", "def destroy\n @exercise_template.destroy\n\n head :no_content\n end", "def create\n @exerciseoverview = Exerciseoverview.new(exerciseoverview_params)\n\n respond_to do |format|\n if @exerciseoverview.save\n format.html { redirect_to @exerciseoverview, notice: 'Exerciseoverview was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exerciseoverview }\n else\n format.html { render action: 'new' }\n format.json { render json: @exerciseoverview.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_course_template(course_template_data)\n # TODO: make a bridge function that allows this to be done with 4 arguments, rather than\n # just a JSON.\n # Path- root path to use for this course offering’s course content\n # if your back-end service has path enforcement set on for\n # new org units, leave this property as an empty string\n # Define a valid, empty payload and merge! with the user_data. Print it.\n payload = {\n 'Name' => '', # String\n 'Code' => 'off_SEMESTERCODE_STARNUM', # String\n 'Path' => '', # String\n 'ParentOrgUnitIds' => [99_989], # number: D2L_ID\n }.merge!(course_template_data)\n check_course_template_data_validity(payload)\n puts 'Creating Course Template:'\n ap payload\n # Define a path referencing the courses path\n # requires: CreateCourseTemplate JSON block\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/\"\n _post(path, payload)\n puts '[+] Course template creation completed successfully'.green\n # returns: CourseTemplate JSON block containing the new data.\nend", "def template_params\n params.require(:template).permit(:name, :body, :active_flg)\n end", "def create\n @template = Template.new(template_params)\n current_user.templates << @template\n\n respond_to do |format|\n if current_user.save\n Field.all.each do |field|\n t_field = TemplateField.new(val: \"\")\n t_field.field = field\n t_field.template = @template \n t_field.save\n end\n format.html { redirect_to dashboard_path, notice: t('template_added') }\n else\n format.html { redirect_to dashboard_path, notice: @template.errors.full_messages[0]}\n end\n end\n end", "def create\n @invoice_template = InvoiceTemplate.new(params[:invoice_template])\n\n respond_to do |format|\n if @invoice_template.save\n format.html { redirect_to @invoice_template, notice: 'Invoice template was successfully created.' }\n format.json { render json: @invoice_template, status: :created, location: @invoice_template }\n else\n format.html { render action: \"new\" }\n format.json { render json: @invoice_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n begin\n @cf_template.validate_template\n rescue StandardError => ex\n flash[:alert] = ex.message\n render action: 'new' and return\n end\n\n respond_to do |format|\n if @cf_template.save\n format.html { redirect_to cf_templates_path, notice: I18n.t('cf_templates.msg.created') }\n format.json { render action: 'show', status: :created, location: @client }\n else\n format.html do\n flash.now[:alert] = @cf_template.errors[:json] if @cf_template.errors[:json]\n render action: 'new'\n end\n format.json { render json: @cf_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def survey_template_params\n params.require(:survey_template).permit(:name, :status, :survey_type)\n end" ]
[ "0.6443866", "0.6424446", "0.6355208", "0.6267342", "0.62536114", "0.6245498", "0.6241469", "0.6241336", "0.6221112", "0.61768353", "0.6160134", "0.6144805", "0.6127116", "0.60892713", "0.60494596", "0.60323447", "0.6003123", "0.60004467", "0.5978884", "0.5947667", "0.5939243", "0.59249455", "0.5913539", "0.5908561", "0.5907309", "0.59061927", "0.5902374", "0.5900468", "0.5897144", "0.5887263", "0.5867166", "0.5861949", "0.58434063", "0.5839171", "0.58317274", "0.58279425", "0.5824047", "0.58173746", "0.58046126", "0.578356", "0.57720137", "0.5756303", "0.57559603", "0.5744194", "0.5738952", "0.5737749", "0.5736319", "0.57344943", "0.5734308", "0.5716548", "0.5706909", "0.57026595", "0.57017577", "0.56958", "0.56875163", "0.5681543", "0.5675724", "0.5671997", "0.5661849", "0.56588286", "0.5658708", "0.5652566", "0.5647143", "0.5638326", "0.5638326", "0.5638326", "0.5638326", "0.563499", "0.5631512", "0.563074", "0.5629732", "0.56294036", "0.5614797", "0.5598547", "0.5597031", "0.5595858", "0.5590006", "0.5588425", "0.5585654", "0.55831516", "0.5583048", "0.5579354", "0.5575621", "0.55739623", "0.5565045", "0.5564175", "0.55634373", "0.55627704", "0.5561811", "0.55612195", "0.55591106", "0.5552191", "0.5551493", "0.55514574", "0.5546551", "0.55461174", "0.5545654", "0.55360126", "0.5532178", "0.5525476" ]
0.76109755
0
PATCH/PUT /exercise_templates/1 PATCH/PUT /exercise_templates/1.json
def update @exercise_template = ExerciseTemplate.find(params[:id]) if @exercise_template.update(exercise_template_params) head :no_content else render json: @exercise_template.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, :notice => 'exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :manage, :all\n respond_to do |format|\n if @question_template.update(question_template_params)\n format.html do redirect_to question_template_path(@question_template),\n notice: 'Question template was successfully updated.'\n end\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise.update(exercise_params)\n format.html { redirect_to @exercise, notice: I18n.t('exercises.updated') }\n format.json { render :show, status: :ok, location: @exercise }\n else\n format.html { render :edit }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n \n if @question_template.update(question_template_params)\n format.html { redirect_to @question_template, notice: 'Question template was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_template }\n else\n format.html { render :edit }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n flash[:class] = \"alert alert-success\"\n format.html { redirect_to @exercise, :notice => 'exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @questionnaire_template.update(questionnaire_template_params)\n format.html { redirect_to @questionnaire_template, notice: 'questionnaire template was successfully updated.' }\n format.json { render :show, status: :ok, location: @questionnaire_template }\n else\n format.html { render :edit }\n format.json { render json: @questionnaire_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts template_params\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n respond_with(@exercise)\n end", "def update\n @template = Template.find(params[:id])\n\n respond_to do |format|\n if @template.update_attributes(params[:template])\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @mytemplate = Mytemplate.get(params[:id])\n \n @mytemplate.name = params[:mytemplate][:name]\n @mytemplate.folder = params[:mytemplate][:folder]\n @mytemplate.description = params[:mytemplate][:description]\n \n respond_to do |format|\n if @mytemplate.save\n format.html { redirect_to mytemplates_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mytemplate.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise.update(exercise_params)\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise }\n else\n format.html { render :edit }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise.update(exercise_params)\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise }\n else\n format.html { render :edit }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @request_template.update(request_template_params)\n respond format, 'Request template was successfully updated.'\n else\n format.html { render :edit }\n format.json { render json: @request_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to [@clclass,@exercise], notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: [@clclass,@exercise].errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise.update(exercise_params)\n format.html { redirect_to @exercise, notice: \"Exercise was successfully updated.\" }\n format.json { render :show, status: :ok, location: @exercise }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @newsletters_template = Newsletters::Template.find(params[:id])\n\n respond_to do |format|\n if @newsletters_template.update_attributes(params[:newsletters_template])\n format.html { redirect_to @newsletters_template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @newsletters_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @review_template.update(review_template_params)\n format.html { redirect_to @review_template, notice: 'Review template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @review_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @quest_template = QuestTemplate.find(params[:id])\n\n respond_to do |format|\n if @quest_template.update_attributes(params[:quest_template])\n flash[:notice] = 'QuestTemplate was successfully updated.'\n format.html { redirect_to(@quest_template) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quest_template.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @patient_exercise = PatientExercise.find(params[:id])\n\n respond_to do |format|\n if @patient_exercise.update_attributes(params[:patient_exercise])\n format.html { redirect_to @patient_exercise, notice: 'Patient exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patient_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inspection_template.update(inspection_template_params)\n format.html { redirect_to @inspection_template, notice: 'Inspection template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inspection_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update \n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @status = args[:status] if args.key?(:status)\n @template_content = args[:template_content] if args.key?(:template_content)\n @template_name = args[:template_name] if args.key?(:template_name)\n @template_type = args[:template_type] if args.key?(:template_type)\n end", "def update\n @project_template = ProjectTemplate.find(params[:id])\n\n respond_to do |format|\n if @project_template.update_attributes(params[:project_template])\n format.html { redirect_to @project_template, notice: 'Project template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @project_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @my_template.update(my_template_params)\n format.html { redirect_to @my_template, notice: 'My template was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_template }\n else\n format.html { render :edit }\n format.json { render json: @my_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to(@exercise, :notice => 'Exercise was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question_template = QuestionTemplate.find(params[:id])\n params[:files].each_pair do |field_name, file|\n unless file.original_filename.empty?\n @question_template.send \"#{field_name}=\", file.original_filename\n end\n end\n respond_to do |format|\n if @question_template.update_attributes(params[:question_template])\n @question_template.upload_files(params[:files].values)\n format.html { redirect_to [:admin,@question_template], notice: 'Question template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to email_templates_path, notice: 'template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to template_path(@template), notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @template = Template.find(params[:id])\n\n respond_to do |format|\n if @template.update_attributes(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_template_files(opts)\n template_id = opts.delete(:template_id)\n path = \"/template/update_files/#{template_id}\"\n prepare_files opts\n\n HelloSign::Resource::Template.new post(path, body: opts)\n end", "def update\n restricted\n respond_to do |format|\n if @template.update(template_params)\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @template }\n else\n format.html { render :edit }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise_set = ExerciseSet.find(params[:id])\n\n respond_to do |format|\n if @exercise_set.update_attributes(params[:exercise_set])\n format.html { redirect_to @exercise_set.workout, notice: 'Exercise set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exercise_task.update(exercise_task_params)\n format.html { redirect_to @exercise_task, notice: 'Exercise task was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise_task }\n else\n format.html { render :edit }\n format.json { render json: @exercise_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @node_template = NodeTemplate.find(params[:id])\n\n respond_to do |format|\n if @node_template.update_attributes(params[:node_template])\n format.html { redirect_to @node_template, notice: 'Node template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @node_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @do_exercise = DoExercise.find(params[:id])\n\n respond_to do |format|\n if @do_exercise.update_attributes(params[:do_exercise])\n format.html { redirect_to @do_exercise, notice: 'Do exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @do_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attr_template.update(attr_template_params)\n format.html { redirect_to @attr_template, notice: 'Attr template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attr_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @template_question.update(template_question_params)\n format.html { redirect_to @template_question, notice: 'Template question was successfully updated.' }\n format.json { render :show, status: :ok, location: @template_question }\n else\n format.html { render :edit }\n format.json { render json: @template_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @workout_template = WorkoutTemplate.find(params[:id])\n\n respond_to do |format|\n if @workout_template.update_attributes(params[:workout_template])\n format.html { redirect_to @workout_template, notice: 'Workout template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @workout_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @template_task = TemplateTask.find(params[:id])\n\n respond_to do |format|\n if @template_task.update_attributes(permitted_params_for_template_task)\n format.html { redirect_to template_tasks_path, notice: 'TemplateTask was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template_task.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @invoice_template = InvoiceTemplate.find(params[:id])\n\n respond_to do |format|\n if @invoice_template.update_attributes(params[:invoice_template])\n format.html { redirect_to @invoice_template, notice: 'Invoice template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @invoice_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gift_template = GiftTemplate.find(params[:id])\n\n respond_to do |format|\n if @gift_template.update_attributes(params[:gift_template])\n format.html { redirect_to gift_templates_path, notice: 'Gift template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gift_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @meal_template.update(meal_template_params)\n format.html { redirect_to @meal_template, notice: 'Meal template was successfully updated.' }\n format.json { render :show, status: :ok, location: @meal_template }\n else\n format.html { render :edit }\n format.json { render json: @meal_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @email_template = EmailTemplate.find(params[:id])\n\n respond_to do |format|\n if @email_template.update_attributes(params[:email_template])\n format.html { redirect_to email_templates_path, notice: 'Email template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @email_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise_instruction = ExerciseInstruction.find(params[:id])\n\n respond_to do |format|\n if @exercise_instruction.update_attributes(params[:exercise_instruction])\n format.html { redirect_to @exercise_instruction.exercise, notice: 'Note was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise_instruction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exercise_template = ExerciseTemplate.new(exercise_template_params)\n\n if @exercise_template.save\n render json: @exercise_template, status: :created, location: @exercise_template\n else\n render json: @exercise_template.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @item_template.update(item_template_params)\n format.html { redirect_to @item_template, notice: 'Item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_template }\n else\n format.html { render :edit }\n format.json { render json: @item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @survey_template.update(survey_template_params)\n format.html { redirect_to @survey_template, notice: 'Template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_template }\n else\n @record = @survey_template\n format.html { render :edit }\n format.json { render json: @survey_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @performed_exercise.update(performed_exercise_params)\n format.html { redirect_to @performed_exercise, notice: 'Performed exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @performed_exercise }\n else\n format.html { render :edit }\n format.json { render json: @performed_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n template = Template.includes(:org, :phases).find(params[:id])\n authorize template\n # Load the info needed for the overview section if the authorization check passes!\n phases = template.phases.includes(sections: { questions: :question_options })\n .order('phases.number',\n 'sections.number',\n 'questions.number',\n 'question_options.number')\n .select('phases.title',\n 'phases.description',\n 'phases.modifiable',\n 'sections.title',\n 'questions.text',\n 'question_options.text')\n if template.latest?\n render 'container', locals: {\n partial_path: 'edit',\n template: template,\n phases: phases,\n referrer: get_referrer(template, request.referer)\n }\n else\n redirect_to org_admin_template_path(id: template.id)\n end\n end", "def update\n respond_to do |format|\n if @exerciseoverview.update(exerciseoverview_params)\n format.html { redirect_to @exerciseoverview, notice: 'Exerciseoverview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exerciseoverview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_exercise = MyExercise.find(params[:id])\n\n respond_to do |format|\n if @my_exercise.update_attributes(params[:my_exercise])\n flash[:notice] = 'MyExercise was successfully updated.'\n format.html { redirect_to(@my_exercise) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def update\n respond_to do |format|\n if @exercise.update(exercise_params)\n format.html { redirect_to exercise_weight_logs_path(@exercise), notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise }\n else\n format.html { render :edit }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @email_template = EmailTemplate.find(params[:id])\n\n respond_to do |format|\n if @email_template.update_attributes(params[:email_template])\n format.html { redirect_to @email_template, notice: 'Email template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @email_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cf_template.update(cf_template_params)\n format.html { redirect_to cf_templates_path, notice: I18n.t('cf_templates.msg.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cf_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n update_elements if elements_params.present?\n @template.update(name: template_params[:name]) if template_params[:name].present?\n\n if @template.errors.empty?\n render :show, status: :ok, location: @template\n else\n render json: @template.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @programme_exercise.update(programme_exercise_params)\n format.html { redirect_to @programme_exercise, notice: 'Programme exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @programme_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n flash[:notice] = t('flash.actions.update.notice', :resource_name => Exercise.model_name.human) if @exercise.update_attributes(params[:exercise])\n respond_with(@exercise, :location => exercises_path)\n end", "def update\n respond_to do |format|\n \n #@template.creator = current_user.id\n if @template.update(template_params)\n @template.creator=current_user.id\n @template.save\n format.html { redirect_to @template, notice: 'Template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @event_template.update(event_template_params)\n format.html { redirect_to @event_template, notice: \"Event template was successfully updated.\" }\n format.json { render :show, status: :ok, location: @event_template }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @event_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @issue_template.update(issue_template_params)\n format.html { redirect_to issue_templates_path, notice: 'Issue template was successfully updated.' }\n else\n format.html { redirect_to issue_templates_path, alert: issue_template.errors }\n end\n end\n end", "def orgn_template_update\n @event.template_id = params[:template_id]\n\n if !params[:template_id]\n #redirect_to orgn_template_events_path, :flash => { :error => 'Select a template.' }\n flash[:alert] = 'Select a template.'\n render :action => :orgn_template\n return\n end\n \n @event.template_id = @event.template_id\n \n respond_to do |format|\n if @event.update(template_params)\n format.html { redirect_to event_invite_events_path }\n format.json { head :no_content }\n else\n format.html { redirect_to event_invite_events_path }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @template.update(template_params)\n handle_save_success @template, :ok, t('templates.update_success')\n else\n handle_save_error @template.errors, :edit\n end\n end", "def update\n respond_to do |format|\n if @survey_item_template.update(survey_item_template_params)\n format.html { redirect_to @survey_item_template.survey_item_category_template.survey_template, notice: 'Survey item template was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_item_template }\n else\n format.html { render :edit }\n format.json { render json: @survey_item_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def template_update_with_http_info(tmpl_id, template_update, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TemplatesApi.template_update ...'\n end\n # verify the required parameter 'tmpl_id' is set\n if @api_client.config.client_side_validation && tmpl_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tmpl_id' when calling TemplatesApi.template_update\"\n end\n pattern = Regexp.new(/^tmpl_[a-zA-Z0-9]+$/)\n if @api_client.config.client_side_validation && tmpl_id !~ pattern\n fail ArgumentError, \"invalid value for 'tmpl_id' when calling TemplatesApi.template_update, must conform to the pattern #{pattern}.\"\n end\n\n # verify the required parameter 'template_update' is set\n if @api_client.config.client_side_validation && template_update.nil?\n fail ArgumentError, \"Missing the required parameter 'template_update' when calling TemplatesApi.template_update\"\n end\n # resource path\n local_var_path = '/templates/{tmpl_id}'.sub('{' + 'tmpl_id' + '}', CGI.escape(tmpl_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])\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(template_update)\n\n # return_type\n return_type = opts[:debug_return_type] || 'Template'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth']\n\n new_options = opts.merge(\n :operation => :\"TemplatesApi.template_update\",\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: TemplatesApi#template_update\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update_question_template\n if @question_template.update(question_template_params)\n flash[:success] = success_message(@question_template, :update)\n redirect_to survey_template_path(@survey_template)\n else\n flash[:error] = error_message(@question_template, :update)\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @exercise_name.update(exercise_name_params)\n format.html { redirect_to @exercise_name, notice: 'Exercise name was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise_name }\n else\n format.html { render :edit }\n format.json { render json: @exercise_name.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @inventory_template = InventoryTemplate.find(params[:id])\n # @inventory_template.restaurant = current_owner.restaurant\n\n respond_to do |format|\n if @inventory_template.update_attributes(params[:inventory_template])\n format.html { redirect_to @inventory_template, notice: 'Inventory template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tips_trick.update_attributes(params[:tips_trick])\n format.html { redirect_to @tips_trick, notice: 'Tips trick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tips_trick.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if meeting_template.save\n format.html { redirect_to( meeting_template, flash: { success: \"Meeting template updated.\" } ) }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: meeting_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @admin_kpi_template = Admin::KpiTemplate.find(params[:id])\n\n respond_to do |format|\n if @admin_kpi_template.update_attributes(params[:admin_kpi_template])\n format.html { redirect_to @admin_kpi_template, notice: 'Kpi template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_kpi_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(name, html_url, zip_url, screenshot_url)\n options = { :body => { \n :Name => name,\n :HtmlPageURL => html_url,\n :ZipFileURL => zip_url,\n :ScreenshotURL => screenshot_url }.to_json }\n response = CreateSend.put \"/templates/#{template_id}.json\", options\n end", "def update\n @page_template = PageTemplate.find(params[:id])\n\n respond_to do |format|\n if @page_template.update_attributes(params[:page_template])\n format.html { redirect_to @page_template, notice: 'Page template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_update_template_question\n create_template(\"Test Template\")\n template_id = find_last_template_id\n initial_question_value = \"Question 1\"\n revised_question_value = \"Revised question 1\"\n\n create_template_question(initial_question_value, template_id)\n question_id = find_last_question_id\n\n @db.update_template_question(question_id, revised_question_value)\n question = find_question(question_id)\n assert_equal(question[:question_value], revised_question_value)\n\n delete_template(template_id)\n end", "def update\n owner = @workout.owner\n unless owner == current_user or owner == temp_user\n redirect_to \"/\", alert: \"Permission Denied.\"\n end\n @workout.update(workout_params)\n @workout.exercises.destroy_all\n\n ex_params = exercise_params[:exercise].map do |e|\n e[:dur] = e[:dur][:minutes].to_i*60 + e[:dur][:seconds].to_i\n e[:workout_id] = @workout.id\n e\n end\n @exercises = @workout.exercises.create(ex_params)\n \n respond_to do |format|\n if @workout.save\n format.html { redirect_to @workout, notice: 'Workout was successfully updated.' }\n format.json { render json: {workoutId: @workout.id}, status: 200 }\n else\n format.html { render :edit }\n format.json { render json: @workout.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @doc_template.update(doc_template_params)\n format.html { redirect_to @doc_template, notice: 'Doc template was successfully updated.' }\n format.json { render :show, status: :ok, location: @doc_template }\n else\n format.html { render :edit }\n format.json { render json: @doc_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @show_template.update(show_template_params)\n format.html { redirect_back_to show_templates_url, notice: 'Show template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @show_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @email_template.update(email_template_params)\n format.html { redirect_to email_templates_path, notice: 'Email template was successfully updated.' }\n format.json { render :show, status: :ok, location: @email_template }\n else\n format.html { render :edit }\n format.json { render json: @email_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @favorite_template.update(favorite_template_params)\n render json: @favorite_template\n end", "def update\n @config_template = ConfigTemplate.find(params[:id])\n\n respond_to do |format|\n if @config_template.update_attributes(params[:config_template])\n format.html { redirect_to(@config_template, :notice => 'ConfigTemplate was successfully updated.') }\n format.json { head :ok }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @config_template.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @config_template.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @mailee_template = Mailee::Template.find(params[:id])\n\n respond_to do |format|\n if @mailee_template.update_attributes(params[:mailee_template])\n format.html { redirect_to(@mailee_template, :notice => 'Mailee template was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mailee_template.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @form_template.update(form_template_params)\n format.html { redirect_to @form_template, notice: 'Formularvorlage wurde erfolgreich aktualisiert' }\n format.json { render :show, status: :ok, location: @form_template }\n else\n format.html { render :edit }\n format.json { render json: @form_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @score_template = ScoreTemplate.find(params[:id])\n\n respond_to do |format|\n if @score_template.update_attributes(params[:score_template])\n format.html { redirect_to @score_template, notice: 'Score template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @score_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n current_site.grid_templates.find(params[:id]).update(params.require(:grid_template).permit(:name, :description))\n index\n end", "def update\n respond_to do |format|\n if @docu_template.update(docu_template_params)\n format.html { redirect_to @docu_template, notice: 'Docu sign was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @docu_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @_template = @site.templates.find(params[:id])\n @_template.updated_by = current_user\n\n respond_to do |format|\n if @_template.update_attributes(params[:template])\n flash[:notice] = \"Template was successfully updated.\"\n format.html { redirect_to([:admin, @site, @_template]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @_template.errors, :status => :unprocessable_entity }\n end\n end\n end", "def template_update(id, type, filename)\n check_id_or_raise id\n check_template_type_or_raise type\n check_filename_or_raise filename\n response = http_request_multipart :put, @base_url + \"/templates/#{id}.xml\", 200,\n { :provider_key => @provider_key,\n :draft => File.read(filename), \n :multipart => true}\n puts 'at update call'\n _id, _updated_at = parse_response response, type\n response = http_request :put, \"#{@base_url}/templates/#{id}/publish\", 200,\n { :params => { :provider_key => @provider_key } }\n puts 'at publish call'\n parse_response response, 'page'\n end", "def update\n respond_to do |format|\n if @track_template.update(track_template_params)\n format.html { redirect_to @track_template, notice: 'Track template was successfully updated.' }\n format.json { render :show, status: :ok, location: @track_template }\n else\n format.html { render :edit }\n format.json { render json: @track_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @reqdifficulty.update(reqdifficulty_params)\n format.html { redirect_to @reqdifficulty, notice: 'Reqdifficulty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @reqdifficulty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @purchase_template = PurchaseTemplate.find(params[:id])\n\n respond_to do |format|\n if @purchase_template.update_attributes(params[:purchase_template])\n format.html { redirect_to @purchase_template, notice: 'Purchase template was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @purchase_template.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6624844", "0.6485179", "0.6468314", "0.64318746", "0.64318746", "0.64318746", "0.63112164", "0.63102996", "0.6307914", "0.62699884", "0.62584835", "0.6257754", "0.62360495", "0.61973506", "0.6182043", "0.6182043", "0.61755174", "0.617128", "0.61525905", "0.61441153", "0.6129908", "0.60677713", "0.60557437", "0.6024846", "0.6023445", "0.6017362", "0.6015452", "0.6011372", "0.60106933", "0.5989276", "0.5982925", "0.5982925", "0.5981732", "0.5980499", "0.5970898", "0.5966521", "0.5954506", "0.5949788", "0.594746", "0.5946591", "0.5940431", "0.5932207", "0.5923617", "0.59106565", "0.5904552", "0.5897156", "0.58962333", "0.5894265", "0.5885821", "0.5877587", "0.5866025", "0.58640546", "0.586168", "0.58608824", "0.5851009", "0.58494616", "0.5833545", "0.583204", "0.58266145", "0.5825939", "0.5825939", "0.5825241", "0.5808087", "0.58071595", "0.5801773", "0.5781584", "0.5775135", "0.5768038", "0.57622623", "0.57584053", "0.57581985", "0.5744649", "0.57378167", "0.5730211", "0.5723508", "0.57226986", "0.57178015", "0.5702325", "0.5699112", "0.56916606", "0.5685628", "0.5679625", "0.5668411", "0.56661665", "0.5664405", "0.56618524", "0.5654396", "0.5649336", "0.5646568", "0.5645025", "0.5631736", "0.5629106", "0.56251335", "0.56249124", "0.5621433", "0.56177646", "0.5613775", "0.5613444", "0.56091416", "0.5608647" ]
0.7475527
0
DELETE /exercise_templates/1 DELETE /exercise_templates/1.json
def destroy @exercise_template.destroy head :no_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n super \"/templates/#{template_id}.json\", {}\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_exercise.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @patient_exercise = PatientExercise.find(params[:id])\n @patient_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @do_exercise = DoExercise.find(params[:id])\n @do_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to do_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url, notice: \"Exercise was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :manage, :all\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end", "def delete(options={})\n DNSimple::Client.delete \"templates/#{id}\", options\n end", "def destroy\n @questionnaire_template.destroy\n respond_to do |format|\n format.html { redirect_to questionnaire_templates_url, notice: 'questionnaire template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to clclass_exercises_path(@clclass) }\n format.json { head :no_content }\n end\n end", "def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend", "def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_set = ExerciseSet.find(params[:id])\n @exercise_set.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to(exercises_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @daily_exercise = DailyExercise.find(params[:id])\n @daily_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to daily_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_exercise = MyExercise.find(params[:id])\n @my_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to(my_exercises_url) }\n format.xml { head :ok }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question_template.destroy\n respond_to do |format|\n format.html { redirect_to question_templates_url, notice: 'Question template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @programme_exercise.destroy\n respond_to do |format|\n format.html { redirect_to programme_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exerciseoverview.destroy\n respond_to do |format|\n format.html { redirect_to exerciseoverviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inspection_template.destroy\n respond_to do |format|\n format.html { redirect_to inspection_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.js #-> loads destroy.js.erb\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_instruction = ExerciseInstruction.find(params[:id])\n @exercise_instruction.destroy\n\n respond_to do |format|\n format.html { redirect_to @exercise_instruction.exercise }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @performed_exercise.destroy\n respond_to do |format|\n format.html { redirect_to performed_exercises_url, notice: 'Performed exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @quest_template = QuestTemplate.find(params[:id])\n \n begin\n @quest_template.quest_giver.destroy\n @quest_template.quest_involver.destroy\n rescue Exception => e\n end\n @quest_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(quest_templates_url) }\n format.xml { head :ok }\n end\n end", "def delete\n item = FormTemplate.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end", "def destroy\n @newsletters_template = Newsletters::Template.find(params[:id])\n @newsletters_template.destroy\n\n respond_to do |format|\n format.html { redirect_to newsletters_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_template = QuestionTemplate.find(params[:id])\n @question_template.destroy\n\n respond_to do |format|\n format.html { redirect_to question_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template = set_template\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_name.destroy\n respond_to do |format|\n format.html { redirect_to exercise_names_url, notice: 'Exercise name was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(id)\n @client.call(method: :delete, path: \"templates/#{id}\")\n end", "def destroy\n @invoice_template = InvoiceTemplate.find(params[:id])\n @invoice_template.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_templates_url }\n format.json { head :no_content }\n end\n end", "def delete_template(opts)\n post(\"/template/delete/#{opts[:template_id]}\")\n end", "def destroy\n @review_template.destroy\n respond_to do |format|\n format.html { redirect_to review_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_template = InventoryTemplate.find(params[:id])\n @inventory_template.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_log = ExerciseLog.find(params[:id])\n @exercise_log.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_logs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n mytemplate = Mytemplate.get(params[:id])\n close_document(mytemplate)\n \n begin\n if mytemplate != nil\n if File.exist?(mytemplate.path) \n FileUtils.rm_rf mytemplate.path\n end\n \n if File.exist?(mytemplate.file_path+mytemplate.id.to_s) \n FileUtils.rm_rf mytemplate.file_path+mytemplate.id.to_s\n end\n\n end\n rescue\n puts_message \"Error! in progress of mytemplate file deletion.\"\n end\n\n mytemplate.destroy\n \n respond_to do |format|\n format.html { redirect_to(mytemplates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exercise_task.destroy\n respond_to do |format|\n format.html { redirect_to exercise_tasks_url, notice: 'Exercise task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal_template.destroy\n respond_to do |format|\n format.html { redirect_to meal_templates_url, notice: 'Meal template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_execution.destroy\n respond_to do |format|\n format.html { redirect_to exercise_executions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase_template = PurchaseTemplate.find(params[:id])\n @purchase_template.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercice = Exercice.find(params[:id])\n @exercice.destroy\n\n respond_to do |format|\n format.html { redirect_to exercices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_template.destroy\n respond_to do |format|\n format.html { redirect_to my_templates_url, notice: 'My template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @induction_template.destroy\n respond_to do |format|\n format.html { redirect_to induction_templates_url, notice: 'Induction template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @show_template.destroy\n respond_to do |format|\n format.html { redirect_back_to show_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_template = Template.find(params[:id])\n @admin_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @docu_template.destroy\n respond_to do |format|\n format.html { redirect_to docu_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_template.destroy\n respond_to do |format|\n format.html { redirect_to organization_survey_templates_url(@organization), notice: 'Survey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gift_template = GiftTemplate.find(params[:id])\n @gift_template.destroy\n\n respond_to do |format|\n format.html { redirect_to gift_templates_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @attr_template.destroy\n respond_to do |format|\n format.html { redirect_to attr_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goaltemplate = Goaltemplate.find(params[:id])\n @goaltemplate.destroy\n\n respond_to do |format|\n format.html { redirect_to(goaltemplates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @item_template.destroy\n respond_to do |format|\n format.html { redirect_to item_templates_url, notice: 'Item template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_category = ExerciseCategory.find(params[:id])\n @exercise_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_categories_url }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n DNSimple::Client.delete(\"/v1/templates/#{id}\", options)\n end", "def destroy\n @template = Template.find(params[:id])\n @template.destroy\n\n respond_to do |format|\n format.html { redirect_to templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @node_template = NodeTemplate.find(params[:id])\n @node_template.destroy\n\n respond_to do |format|\n format.html { redirect_to node_templates_url }\n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def delete(name)\n r = request('DeleteTemplate', { :name => name })\n return r['status'] == ' ok ' \n end", "def delete_content_template(id)\n # TODO: Inform ContentTemplateController.destroy method has been modified\n @client.raw('delete', \"/content/templates/#{id}\")\n end", "def destroy\n @project_template = ProjectTemplate.find(params[:id])\n @project_template.destroy\n\n respond_to do |format|\n format.html { redirect_to project_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template_question.destroy\n respond_to do |format|\n format.html { redirect_to template_questions_url, notice: 'Template question was successfully destroyed.' }\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 @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 @intake.destroy\n respond_to do |format|\n format.html { redirect_to intakes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mailee_template = Mailee::Template.find(params[:id])\n @mailee_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(mailee_templates_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @template_task = TemplateTask.find(params[:id])\n @template_task.destroy\n\n respond_to do |format|\n format.html { redirect_to template_tasks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crawler_template = CrawlerTemplate.find(params[:id])\n @crawler_template.destroy\n\n respond_to do |format|\n format.html { redirect_to crawler_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_path, notice: 'template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @template.destroy\n end", "def destroy\n @tutorial.destroy\n respond_to do |format|\n format.html { redirect_to tutorials_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @workout_template = WorkoutTemplate.find(params[:id])\n @workout_template.destroy\n\n respond_to do |format|\n format.html { redirect_to workout_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @page_template = PageTemplate.find(params[:id])\n @page_template.destroy\n\n respond_to do |format|\n format.html { redirect_to page_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @template.destroy\n respond_ok \"template\", @template\n else\n respond_err \"template\", @template, @template.errors\n end\n end", "def destroy\n @tutorial = Tutorial.find(params[:id])\n @tutorial.destroy\n render json: @tutorial\n end", "def test_delete_template\n create_template(\"Test Template\")\n template_id = find_last_template_id\n\n @db.delete_template(template_id)\n\n template = find_template(template_id)\n assert_nil(template)\n end", "def destroy\n @emailtemplate.destroy\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @track_template.destroy\n respond_to do |format|\n format.html { redirect_to track_templates_url, notice: 'Track template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @post_template.destroy\n respond_to do |format|\n format.html { redirect_to post_templates_url, notice: 'Post template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end", "def delete(data)\n result = @client.api_request(:method => \"template.delete\", :params => [data])\n result.empty? ? nil : result['templateids'][0].to_i\n end", "def destroy\n @email_template = EmailTemplate.find(params[:id])\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @email_template = EmailTemplate.find(params[:id])\n @email_template.destroy\n\n respond_to do |format|\n format.html { redirect_to email_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @testcase = Testcase.find(params[:id])\n @testcase.destroy\n\n respond_to do |format|\n format.html { redirect_to testcases_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.760863", "0.73966616", "0.73966616", "0.7386129", "0.73255175", "0.73255175", "0.73255175", "0.73255175", "0.7325453", "0.7166219", "0.7161098", "0.71421456", "0.71421456", "0.7133151", "0.71203744", "0.7103718", "0.7102772", "0.70902383", "0.70858175", "0.7074158", "0.70583576", "0.70075", "0.7001222", "0.6988817", "0.69852275", "0.6962862", "0.6953969", "0.69407344", "0.6938902", "0.6935078", "0.69329154", "0.69308543", "0.6922743", "0.6901301", "0.68936825", "0.6889596", "0.68771", "0.6875128", "0.6864229", "0.6860878", "0.6840217", "0.68357843", "0.6834909", "0.6832747", "0.6823328", "0.68161595", "0.68035984", "0.6802091", "0.6797902", "0.67865515", "0.6785667", "0.6764819", "0.6764538", "0.67643106", "0.6743402", "0.6738598", "0.6738598", "0.6738598", "0.6728934", "0.67272645", "0.6720676", "0.67161965", "0.6715314", "0.6701277", "0.67009914", "0.66980743", "0.66957134", "0.6687761", "0.6681308", "0.66808945", "0.6680875", "0.6675337", "0.6673135", "0.6667633", "0.6665479", "0.66589844", "0.66556346", "0.66533893", "0.6624868", "0.66141653", "0.660445", "0.66009575", "0.6598303", "0.6598292", "0.6587254", "0.6584253", "0.65694916", "0.6560789", "0.6556704", "0.6553313", "0.6537999", "0.6533099", "0.6531039", "0.65222156", "0.651879", "0.65060157", "0.65058357", "0.64990205", "0.64990205", "0.6493991" ]
0.7792735
0
Time complexity: O(n) where n is the value of n Space complexity: O(n) where n is the value of n
def factorial(n) if n < 0 raise ArgumentError elsif n <= 1 return 1 else return n * factorial(n-1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 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 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_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(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\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 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 solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "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 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 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 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 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 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 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 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 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 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 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(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(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 solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "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 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 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 fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\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 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 count_by(x, n)\n a=[]\n y=0\n n.times {y+=x; a<<y}\n a\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 sum_to_n? arr, n\n hash = Hash.new\n arr.each do |val|\n if hash.key? val\n return true\n else\n hash[n-val] = val\n end\n end\n return false\nend", "def solve( n = 1_000_000_000 )\n log10 = Math.log10( n )\n\n sum = (0...log10).map do |i|\n if 0 == (i % 4)\n 0\n elsif 0 != (i % 2)\n 20 * 30**((i - 1)/2)\n else\n 100 * 500**((i - 2)/4)\n end\n end\n\n sum.reduce( :+ )\n end", "def euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\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 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 solution(n)\n array = Array.new\n (1..n).each do\n array.push(0)\n end\n while (array.length >= 16)\n (1..16).each do\n array.pop\n end \n end\n array.length\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\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", "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 process n\n i = 1\n while (2**i <= n)\n i += 1\n end\n n == 2**(i-1)\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 sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\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 candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\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 problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def sum_to_n? arr, n\n # YOUR CODE HERE\n unless arr.length > 1\n return false\n end\n h=Hash.new\n arr.each{|a|\n if h.key? a \n return true else h[n-a] = n end}\n return false\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 sum_to_n? arr, n\n if arr.size>=2\n for a in arr\n if arr.include?(n-a) and (a != n-a or arr.count(a) > 1)\n return true\n end\n end\n end\n false\nend", "def dbl_linear(n)\n result = [1] # base\n\n i = 0 # pointer for 2x + 1\n j = 0 # pointer for 3x + 1\n\n until result.size == n + 1 # because n is an index (size - 1)\n list1 = 2 * result[i] + 1\n list2 = 3 * result[j] + 1\n min = [list1, list2].min\n\n result << min\n\n i += 1 if min == list1\n j += 1 if min == list2\n end\n\n result.last\nend", "def sum_to_n? arr, n\n if arr.size>=2\n for x in arr\n target = n-x\n tmp = arr.dup\n tmp.delete_at(tmp.index(x))\n return true if tmp.include?(target)\n end\n end\n false\nend", "def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def trinum n\n temp = 0\n for i in 1..n\n temp = temp + i\n end\n return temp\nend", "def sum_to_n? arr, n\n \n if arr.size>=2\n for x in arr\n if arr.include?(n-x) and x != n-x or arr.count(x) > 1\n return true\n end\n end\n end\n \n false\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 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 sorted_squared_array_n_nlogn(values)\n values.collect!{|val| val*val}\n merge_sort(values)\nend", "def nth_ugly_number(n, a, b, c)\n# a-b, a-c, b-c, ab-c\n ab_lcm = a.lcm(b) # there are some a present in b\n ac_lcm = a.lcm(c) # there are some a present in c\n bc_lcm = b.lcm(c) # there are some b present in c\n abc_lcm = ab_lcm.lcm(c) # there are some a*b in c (because c is the biggest)\n \n # using set theory for binary search\n # a + b + c - ab_lcm - ac_lcm - bc_lcm + abc_lcm\n (1..2*10**9).bsearch{|x| x/a + x/b + x/c - x/ab_lcm - x/ac_lcm - x/bc_lcm + x/abc_lcm >= n}\nend", "def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend", "def canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def solve( n = 10_000_000 )\n sum = Array.new( n, 0 )\n limit, scale = 1, Math.log( n, 10 ).round - 1\n\n # Precompute single digits.\n (0...10).each {|i| sum[i] = i*i}\n\n # Use previously computed values to speed calculation.\n scale.times do\n limit *= 10\n (limit...10*limit).each do |i|\n j = i\n while 0 < j\n j, r = j / limit, j % limit\n sum[i] += sum[r]\n end\n end\n end\n\n # Cycle each slot until it reaches a terminal value.\n 1.upto( n - 1 ) do |i|\n until 1 == sum[i] || 89 == sum[i]\n sum[i] = sum[sum[i]]\n end\n end \n\n # Count may be computed directly from total sum.\n (sum.inject( :+ ) - n + 1) / 88\n end", "def series_up(n)\n #nlist is the list that will be the output of the code\n nlist = []\n #i changed from an if statement to a loop.\n (n*(n+1)/2+1).times do |i|\n i.times do |x|\n nlist.push(x+1)\n end\n end\n #I use three dots to only get the information i need from the code\n return nlist[0...(n*(n+1)/2)].to_a\nend", "def solution(p, n)\n return 0 if n <= 0\n\n n.times.reduce(MIN_INT) do |max, i|\n [max, p[i] + solution(p, n - (i + 1))].max\n end\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 solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "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 series_up(n)\n list = []\n (n+1).times do |a|\n a.times do |b|\n list.push(b+1)\n end \n end\n return list\nend", "def solution_dp_bu(p, n)\n dp = Array.new(n, MIN_INT)\n # we set p[0] and dp[0] to 0\n dp[0] = 0\n p = p.dup.unshift(0)\n\n (1..n).each do |i|\n dp[i] = (0..(i - 1)).reduce(MIN_INT) do |max, j|\n [max, dp[j] + p[i - j]].max\n end\n end\n\n dp.last\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 example1(n)\n arr = [0, 1 ,2, 3, 5]\n i = 3 \n while(i <= n)\n arr[i] = arr[i - 1] + arr[i - 2]\n i += 1\n end\n\n arr[n]\n\nend", "def perfects (n)\n return (1..n).select { |x| x==(1...x).select { |i| x%i==0 }.inject(:+) }\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\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 f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend", "def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\nend", "def solution(n)\n # write your code in Ruby 2.2\n a = Math.sqrt(n).floor\n a -= 1 while n % a != 0\n b = n / a\n (a + b) * 2\nend", "def isSumOfTwoAbundantNumbers n\n\n # we'll cycle over all abundant numbers less than n / 2\n if n / 2 < @@listOfAbundants.first\n return false\n end\n\n if @@listOfAbundants.last < n / 2\n for i in ((@@listOfAbundants.last + 1)..n)\n if isAbundant i\n @@listOfAbundants.push i\n end\n end\n end\n\n for a in @@listOfAbundants\n if a > n /2 \n return false\n end\n \n pair = n - a\n if @@listOfAbundants.include? pair\n return true\n end\n end\n\nend", "def series_up(n) # given n, return a list that goes [1,1,2,1,2,3... n]\n n_list = []\n (n+1).times do |m|\n m.times do |val|\n n_list.push(val+1)\n end\n end\n return n_list\nend", "def 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 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 pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\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 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 arrayManipulation(n, queries)\n arr = Array.new(n + 2, 0)\n\n queries.each do |a, b, k|\n arr[a] += k\n arr[b + 1] -= k\n end\n\n max_sum = 0\n sum = 0\n arr.filter { |diff| diff != 0 }.each do |diff|\n sum += diff\n max_sum = [max_sum, sum].max\n end\n\n max_sum\nend", "def find_missing_number(array, n)\n sum = (1..n).reduce(:+) # sum from 1 to n\n array.each do |el|\n sum -= el\n end\n return sum\nend", "def find_shortest_seq(n)\n new_num = n/2\n i = 0\n arr = []; arr[i] = 1\n\n while(arr[i] < new_num)\n n1 = arr[i] * 2\n n2 = arr[i] + 1\n\n i += 1\n if(n1 < new_num)\n arr[i] = n1\n else\n arr[i] = n2\n end \n end\n puts arr.to_s\n if(arr[i] == n)\n puts arr.to_s\n puts i \n elsif n == (arr[i] * 2)\n arr[i + 1] = arr[i] * 2\n puts arr.to_s\n puts i + 1\n else\n arr[i + 1] = arr[i] * 2\n i += 1\n arr[i + 1] = arr[i] + 1\n puts arr.to_s\n puts i\n end \n \nend", "def count_by(x, n)\n (1..n).map{|i| i*x}\nend", "def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend", "def sim_program(n)\n (1..n).reduce(0) do |acc, i|\n (n % i).zero? ? acc + i : acc\n end\n end", "def two_number_sum array, n \n\tarray.sort!\n\treverse_index = array.size - 1 \n\tindex = 0\n\twhile index >= reverse_index\n\t\tif array[index] + array[reverse_index] > n\n\t\t\treverse_index -= 1\n\t\telsif array[index] + array[reveres_index] < n\n\t\t\tindex += 1\n\t\telse\n\t\t\tputs \"#{array[index]} + #{array[reverse_index]}\"\n\t\t\tindex += 1\n\t\tend\n\tend\nend", "def tri(n)\n n*(n+1)/2\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def fibo_finder(n)\n start = [0,1]\n n.times {|i| start[i + 2] = start[i] + start[i + 1]}\n start[n]\nend", "def topologies(n, cache = {})\n cache[n] =\n n == 0 ? 1 : (0..n-1).inject(0){ |sum, i| \\\n sum + topologies(i, cache) * topologies(n-i-1, cache) } unless cache.has_key? n\n cache[n]\nend", "def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend", "def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def clumsy(n)\n a = (1..n).to_a.reverse\n \n result = [a[0]]\n \n a[1..a.size - 1].each_with_index do |num, index|\n if index % 4 == 0\n result << '*'\n elsif index % 4 == 1 \n result << '/'\n elsif index % 4 == 2\n result << '+'\n else\n result << '-'\n end\n \n result << num\n end\n \n result = multiply_and_divide_all_results(result)\n \n add_and_subtract_all_results(result)\nend", "def solution(n)\n\tval = 0.0\n\tval += 1.0 unless n[0].zero?\n\tval += 2.0 unless n[1].zero?\n\tval += 4.0 unless n[2].zero?\n\tval += 8.0 unless n[3].zero?\n val\n\t\nend", "def fibo_finder(n)\n\tfib = [0,1]\n\t(n+1).times do |i| \t\n \t\tfib << fib[i-1] + fib[i-2] unless i == 0 || i == 1 \t\n\tend\n\tfib[n]\nend" ]
[ "0.6731546", "0.6660078", "0.6575958", "0.65584093", "0.64724857", "0.64456636", "0.64238524", "0.64222056", "0.6416115", "0.6404088", "0.63939023", "0.6387105", "0.6370853", "0.6331342", "0.6323353", "0.6304718", "0.6301486", "0.62843484", "0.6261167", "0.6251631", "0.62472767", "0.6244721", "0.6244499", "0.6243784", "0.6212734", "0.62015873", "0.62011945", "0.61927277", "0.61874926", "0.6181213", "0.6181083", "0.6173246", "0.6172507", "0.616179", "0.6151377", "0.61389905", "0.6126593", "0.6114723", "0.61107767", "0.61068755", "0.60895824", "0.60875267", "0.60707295", "0.6062985", "0.6050076", "0.6049983", "0.6049252", "0.6042172", "0.6035538", "0.60347784", "0.60303515", "0.60216844", "0.60209805", "0.601827", "0.601055", "0.6002694", "0.5995625", "0.5994672", "0.5994191", "0.5988591", "0.598174", "0.59794134", "0.5977229", "0.59597677", "0.5958766", "0.5950349", "0.59498", "0.59404933", "0.5921069", "0.5919915", "0.5913191", "0.5912735", "0.59119964", "0.5909688", "0.59083086", "0.5908163", "0.5907063", "0.5906145", "0.59037745", "0.58956367", "0.5892353", "0.58910304", "0.5886881", "0.5885652", "0.58855045", "0.5876562", "0.58762085", "0.58717287", "0.5871516", "0.5870816", "0.5869106", "0.58684456", "0.5867207", "0.5862464", "0.586054", "0.5856001", "0.5855342", "0.5850509", "0.58504266", "0.584871", "0.58470297" ]
0.0
-1
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s
def reverse(s) if s.length <= 1 return s else return s[s.length - 1] + reverse(s[0..-2]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n if pi == 0\n sizes << size\n next \n end\n\n substrings = [s_chars[0..pi]]\n\n while !substrings.empty? do\n sub = substrings.pop\n\n sequence = to_sequence(sub) # X\n\n # for every sequence, N-1 must exists and we only check if we can add the last bit\n pos = graph\n sequence[0..-2].each do |bit|\n pos = pos[bit]\n end\n \n next unless pos[sequence.last].nil?\n\n pos[sequence.last] = {}\n size += 1\n\n substrings << sub[1..-1] \n end\n\n sizes << size\n end\n\n sizes\nend", "def solution(s)\n if s.length.odd?\n center = s.length / 2\n if s[0...center] == s[center + 1..s.length].reverse\n return center \n end\n end\n -1\nend", "def f(str)\n 1.upto(str.size / 2) do |idx|\n number_of_subs = str.size / idx\n if str[0...idx] * number_of_subs == str\n return [str[0...idx], number_of_subs]\n end\n end\n [str, 1]\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def solve(s, n)\n answer = []\n \n while s.length > 0\n answer.push(s[0...n])\n s[0...n] = ''\n end\n return answer\nend", "def pseudoIsomorphicSubstrings(s)\n \n # Generate prefixs S'\n prefixs = []\n (s.size).times.each do |i|\n prefixs << s[0..i]\n end\n puts prefixs\n\n # For every i,j where i < j, the substrings of Si' (Sbi), are a subset of Sbj\n # and Sbj - Sbi are the substring that includes the last char of Sj'\n subsets = prefixs.map do |prefix|\n s = []\n\n (prefix.size).times.each do |i|\n s << prefix[i..-1]\n end\n \n s\n end\n puts subsets\n\n # Transform the substring to a sequence of numbers to compare values\n subsets.each do |subs|\n subs.map! { |sub| to_sequence(sub) }\n end\n puts subsets\n\n # For every i,j, such that 0 <= i < j, and a function ISO that generate\n # a set such that no two strings inside S' are pseudo-isomorphic to each other,\n # SUM(ISO(Si')) < ISO(Sj')\n puts \"=\"*50\n isosets = []\n subsets.each_with_index do |subs, i|\n if i == 0\n isosets << Set.new(subs)\n next\n end\n\n isosets << Set.new(subs).merge(isosets[i - 1])\n end\n puts isosets\n\n # Get sizes\n isosets.map { |iso| iso.size } \nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n string_size = s.size\n matrix = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n matrix << []\n\n i = 0\n while i <= pi do\n matrix[pi] << s_chars[i..pi].join.ljust(string_size)\n i += 1\n end\n\n matrix[pi] = matrix[pi].join(' | ')\n end\n\n puts matrix\n\n sizes\nend", "def lps(s)\n return \"\" if s.empty?\n longest = [0,0]\n s.chars.each_with_index do |ch, idx|\n for i,j in [[idx, idx + 1], [idx, idx]]\n until s[i] != s[j]\n break if i < 0 || j >= s.length\n longest = [i,j] if longest[1] - longest[0] < j - i\n i -= 1\n j += 1\n end\n end\n end\n s[longest[0]..longest[1]]\nend", "def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend", "def encode_direct(list, s = 0)\n if s >= list.length then return [] end\n\n i = s\n while i < list.length && (i == s || list[i] == list[i-1])\n i += 1\n end\n n = i - s\n\n [(n > 0 ? [n, list[s]] : list[s])] + encode_direct(list, i)\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def calc_d(s, r)\n n = s.size\n d = []\n n.times do |i|\n if i == 0\n d << 0\n else\n d_i = d[i-1] + s[i-1] - r[i]\n d_i = 0 if d_i <= 0\n d << d_i\n end\n end\n d\n\tend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend", "def n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend", "def nsrch(s,g)\n orig_s = s\n ss = s.to_s 2\n gs = g.to_s 2\n ops = []\n bits = gs.split(//)\n i = 0\n # Go through all bits of g.\n # If there are ones in the trailing part of ss, we\n # must get rid of them (Otherwise: 1001 -> 100, all digits match,\n # jump out of loop, make length equal by >>. Oops, it was an odd\n # number we just halved. So must check for ones.)\n while i < bits.size or ss[bits.size..-1].include? ?1\n b = bits[i]\n op = nil\n n = 0\n while ss[i,1] != b\n # Add zeroes to right to make length right and\n # to get the rightmost bit into an editable state.\n if ss.size < i+2 or s[0] == 1\n op = :*\n # Delete zeroes from right to make length right.\n elsif ss.size > i+2 and (s[0] == 0 and s[1] == 0)\n op = :/\n # Add 2 if length is ok and there are no zeroes to take out.\n # We are here because the second right-most bit is wrong.\n # Adding 2 flips it. It may also flip every bit we've just\n # went through, invalidating the invariant and thus we reset\n # the bit counter.\n else\n op = :+\n i = 0\n end\n ops << op\n s = case op\n when :+\n s + 2\n when :*\n s << 1\n when :/\n s >> 1\n end\n ss = s.to_s 2\n break if op == :+ # invariant may be bad,\n # must check before continuing\n end\n i += 1 unless op == :+\n end\n # take out extra zeroes on right\n r = s >> (ss.size-gs.size)\n ops.push *[:/]*(ss.size-gs.size)\n # and collect middle states using done ops\n a = [orig_s]\n ops.each{|op|\n a << case op\n when :*\n a.last * 2\n when :/\n a.last / 2\n when :+\n a.last + 2\n end\n }\n a\nend", "def subset(n, s)\n h = {}\n 1.upto(n) do |len|\n s.combination(len) do |a|\n sum = a.inject(0,:+)\n if h.key?(sum)\n u = h[sum].join(\" \")\n v = a.join(\" \")\n return \"#{u}\\n#{v}\"\n else\n h[sum] = a\n end\n end\n end\n return \"Impossible\"\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 longest_palindrome_subseq(s)\n length = s.size\n dp = []\n\n length.times do |i|\n dp[i]= Array.new(length).fill(0);\n dp[i][i] = 1\n end\n puts \"dp #{dp}\"\n (2..length).each do |len|\n puts \"len #{len}\"\n (0..(length - len)).each do |i|\n j = i + len - 1\n # puts \"j #{j} => i:#{i} + len:#{len} - 1\"\n\n if s[i] == s[j]\n dp[i][j] = 2 + (len == 2 ? 0 : dp[i+1][j-1])\n else\n dp[i][j] = [dp[i+1][j], dp[i][j-1]].max\n end\n puts \"dp #{dp}\"\n end\n end\n\n dp[0][length - 1]\nend", "def lcs_length(s1, s2)\n m = s1.size\n n = s2.size\n b = Array.new(m){Array.new(n)}\n # init everyting to zero\n c = Array.new(m+1) { Array.new(n+1, 0)}\n (1..m).each do |i|\n (1..n).each do |j|\n #puts(\"i: #{i}, j: #{j} s1_i:#{s1[i]} s2_j:#{s2[j]}\")\n #print_array(c)\n # 0 indexed on the string, so have to subtract 1 when looking at it\n if (s1[i-1] == s2[j-1]) then\n c[i][j] = c[i-1][j-1] + 1\n b[i-1][j-1] = \"d\" # up and to the right\n elsif c[i-1][j] >= c[i][j-1]\n c[i][j] = c[i-1][j]\n b[i-1][j-1] = \"u\" # up\n else\n c[i][j] = c[i][j-1]\n b[i-1][j-1] = \"l\" #left\n end\n end\n end\n #print_array(c)\n #print_array(b)\n return b,c\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def smallest_subarray(nums, s)\n min_length = Float::INFINITY\n\n start_position = 0\n end_position = 0\n\n sum = nums[start_position]\n\n while start_position < nums.length\n if sum < s\n end_position += 1\n break if end_position == nums.length\n\n sum += nums[end_position]\n elsif sum >= s\n size = nums[start_position..end_position].size\n min_length = [min_length, size].min\n sum -= nums[start_position]\n start_position += 1\n end\n end\n min_length\nend", "def sluggish_octopus\n # O(N^2)\n longest_fish = \"\"\n Fishes.each do |fish1|\n Fishes.each do |fish2|\n longest_fish = fish2 if fish2.length > fish1.length\n end\n end\n longest_fish\nend", "def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def countingValleys(n, s)\n valleys = 0\n pre = 0\n ac = 0\n for i in 0..n\n pre = ac\n ac += val(s[i]) \n valleys +=1 if pre == -1 && ac == 0\n end\n return valleys\nend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend", "def min_cut(s)\n palindrome = Array.new(s.size + 1).map { |x| \n Array.new(s.size + 1).map { |y|\n false\n }\n }\n\n dp = []\n 0.upto(s.size) { |i|\n dp[i] = i - 1\n }\n\n 2.upto(s.size).each { |i|\n (i - 1).downto(0).each { |j|\n if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1])\n palindrome[j][i] = true\n dp[i] = [dp[i], dp[j] + 1].min\n end\n }\n }\n\n return dp[s.size]\nend", "def longest_palindrome(s)\n string_hash = Hash.new(0)\n \n s.each_char do |char|\n string_hash[char] += 1\n end\n \n beginning_count = 0\n middle_count = 0\n \n string_hash.keys.each do |key|\n if string_hash[key] % 2 == 1\n middle_count = 1\n end\n \n beginning_count += string_hash[key] / 2\n end\n \n beginning_count * 2 + middle_count\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 shortest_palindrome_2(s)\n idx = 0\n front = \"\"\n back = \"\"\n (0...s.size).each { |i|\n front = front + s[i]\n back = s[i] + back\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend", "def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend", "def solution(s)\n size = 0\n s.each_char do |c|\n if c == \"(\"\n size += 1\n elsif c == \")\"\n size -= 1\n return 0 if size < 0\n end\n end\n return 0 if size > 0\n return 1\nend", "def uniq_subs(str)\n subs = Set.new\n str.length.times do |i|\n (i..str.length-1).each do |j|\n subs.add(str[i..j])\n end\n end\n subs\nend", "def num_distinct(s, t)\n len = t.size\n prefix = [1] + [0]*len # => [1, 0, 0, 0, 0, 0, 0] will happen\n s.chars.each do |char|\n len.downto(1) {|i| prefix[i]=prefix[i-1]+prefix[i] if t[i-1]==char}\n end\n p prefix\n prefix[-1]\nend", "def unique(s)\n (return true) if s.length <= 1\n rest = s[1..-1]\n rest.each do |i|\n (return false) if s[0] == i\n end\n return unique(rest)\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend", "def findLongestSubarrayBySum(s, arr)\n history = {0 => -1} \n sum = 0 \n max_length = 0 \n result = [-1]\n\n for idx in 0...arr.length \n sum += arr[idx]\n history[sum] = idx if history[sum].nil? \n\n if history[sum - s]\n length = idx - history[sum - s]\n if length > max_length \n max_length = length \n result = [history[sum - s]+2, idx+1]\n end \n end \n end \n\n result\nend", "def sluggish(fish)\n longest_fish = \"\"\n i = 0\n while i < fish.length\n j = i + 1\n while j < fish.length\n longest_fish = fish[j] if longest_fish.length <= fish[j].length\n j += 1\n end\n i += 1\n end\n longest_fish\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 scramble(s1,s2)\n s2.chars.uniq.all?{|i| s1.count(i) >= s2.count(i)} \nend", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def repeatedString(s, n)\n # First approach times out\n # s = s * ((n/s.length)+1)\n # p s[0..n-1].count('a')\n a_count = s.count('a')\n times_to_repeat = ((n/s.length))\n num_a_in_string = a_count * times_to_repeat\n leftover = (n%(s.length))\n num_a_in_string += s[0..leftover-1].count('a') if leftover >= 1\n p num_a_in_string\nend", "def is_subsequence(s, t)\n t_id = 0\n s_id = 0\n while t_id < t.length && s_id < s.length\n s_id += 1 if t[t_id] == s[s_id]\n t_id += 1\n end\n s_id == s.length\nend", "def solution(string) # \"ABCA\",\n # TIME O(N) + O(N) = O(2N) ~~ O(N)\n # SPACE O(N)\n\n array = string.split(\"\") # w[A B C A], O(N)\n array_exist = [] # [B C]\n array.each do |s| # O(N), N= 1000_000\n if array_exist.include?(s)\n array_exist.delete(s)\n else\n array_exist.push(s)\n end\n end\n array_exist[0]\nend", "def phase_iii(s1, s2)\n s1.chars.sort! == s2.chars.sort!\n\nend", "def is_sub?(s, t)\n i = j = 0\n while i < s.size && j < t.size\n i += 1 if s[i] == t[j]\n j += 1\n end\n i == s.size\nend", "def solve(s0, s1)\n # shift and push the first letter of the array length number of times\n # check if s0 == s1 each time\n return true if s0 == s1\n \n rotations = s0.length\n \n s0_arr = s0.split('')\n s1_arr = s1.split('')\n until s0_arr == s1_arr || rotations == 0\n s0_arr == s0_arr.push(s0_arr.shift)\n rotations -= 1\n return true if s0_arr == s1_arr\n end\n return false\nend", "def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend", "def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend", "def solve(s, t)\n if s.length != t.length\n return false\n end\n hash = Hash.new {|h, k, v| hash[k] = v}\n\n (0...s.length).each do |i|\n if !hash[s[i]] && !hash.values.include?(t[i])\n hash[s[i]] = t[i]\n elsif hash[s[i]] != t[i]\n return false\n end\n end\n true\nend", "def find_short(s)\n ar = (s.split).map { |k| k.size }.sort\n p ar[0]\n end", "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 repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\nend", "def longest_palindrome(s)\n result = ''\n \n for i in (0..s.length-1) do\n for j in (i..s.length-1) do \n result = s[i..j] if s[i..j].length > result.length && s[i..j] == s[i..j].reverse\n end\n end\n \n result\nend", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\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 shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\nend", "def f(s)\n uniq_char = s.chars.uniq.join('')\n # split_array = s.scan(uniq_char)\n # [split_array.length > 1 ? uniq_char : s,split_array.length]\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 sluggish_octopus(fish)\n longest_fish = fish.first\n\n (0...fish.length).each do |start|\n (start...fish.length).each do |ending|\n if fish[ending].length > fish[start].length \n longest_fish = fish[ending]\n else\n longest_fish = fish[start]\n end\n end\n end\n\n longest_fish\nend", "def luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend", "def jewels_and_stones(j,s)\n\n if (s == nil || s.length < 1 || j == nil || j.length < 1)\n return 0\n end\n\n hash = Hash.new\n\n j.each_char do |char|\n hash[char] = 1\n end\n\n count = 0\n s.each_char do |char|\n if (hash[s[char]] == 1)\n count = count + 1\n end\n end\n return count\n\nend", "def dnaSequence s\n hash, diff = Hash.new(0), Hash.new(0)\n diff[[0, 0, 0]] = 1\n\n sum = 0\n s.chars.each { |c|\n hash[c] += 1\n res = [hash['A'] - hash['C'], hash['C'] - hash['G'], hash['G'] - hash['T']]\n sum += diff[res]\n diff[res] += 1\n }\n sum\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(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 phase_ii(s1, s2)\n del_dex = []\n s1 = s1.chars\n s2 = s2.chars\n s1.each_with_index do |el, idx|\n if s2.include?(el)\n del_dex << idx\n s2.delete_at(s2.index(el))\n end\n end\n del_dex.each { |i| s1[i] = nil }\n return s1.select { |el| !el.nil? }.empty? && s2.empty?\nend", "def partition(s)\n palindrome = Array.new(s.size) {\n Array.new(s.size)\n }\n \n cuts = [[]]\n \n (0...s.size).each { |i|\n (0..i).each { |j|\n palindrome[j][i] = if i == j\n true\n elsif i == j + 1\n s[i] == s[j]\n else\n s[i] == s[j] && palindrome[j + 1][i - 1]\n end\n\n next if !palindrome[j][i] || cuts[j - 1].nil? && j > 1\n cuts[i] ||= []\n cuts[i] << cuts[j - 1].map { |x| x + [s[j..i]] }.flatten(1)\n }\n }\n \n puts \"#{cuts}\"\n cuts[s.size - 1]\nend", "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend", "def do_et offset, l, s, ww\n i = 0\n tt = []\n while i + l - 1 < s.length\n tt << s[i..i+l-1]\n i += l\n end\n o = []\n ttq = []\n wc = {}\n ww.each { |w| if wc.has_key? w then wc[w] += 1 else wc[w] = 1 end }\n zc = wc.length\n tt.each_with_index do |t, i|\n # expand\n ttq << [t, i * l + offset]\n if wc.has_key? t\n if wc[t] == 1\n zc -= 1\n elsif wc[t] == 0\n zc += 1\n end\n wc[t] -= 1\n end\n # contract\n if ttq.length > ww.length\n h, _ = ttq.delete_at 0\n if wc.has_key? h\n if wc[h] == -1\n zc -= 1\n elsif wc[h] == 0\n zc += 1\n end\n wc[h] += 1\n end\n end\n # check\n if zc == 0\n o << ttq.first[1]\n end\n end\n return o\nend", "def sum_pairs_v1 ints, s\n hash = {}\n index = []\n ints.each_with_index {|elem, i| hash[elem] = i }\n ints.each_with_index do |elem, i|\n if hash[s-elem] && hash[s-elem] != i\n hash[s-elem] > hash[elem] ? index << hash[s-elem] : index << hash[elem]\n end\n end\n\n return [s-ints[index.sort.first],ints[index.sort.first]] if index.any?\n nil\nend", "def longest_palindrome(s)\n return s if s.length == 1\n previous = s[0]\n\n all_same = true\n z = 0\n counter = 0\n while z < s.length\n if s[z] == previous\n counter += 1\n else\n tmp_longest = previous * counter\n longest = tmp_longest if tmp_longest.length > longest.length\n previous = s[z]\n counter = 1\n break if counter > s.length / 2\n end\n z += 1\n end\n return previous * counter if all_same || counter > s.length / 2\n\n longest = ''\n i = 0\n while i < s.length\n starting_letter = s[i]\n matching_hash = {}\n matching_hash[i] = starting_letter\n\n j = i + 1\n while j < s.length\n if s[j] == starting_letter\n matching_hash[j] = s[j]\n end\n j += 1\n end\n\n i += 1\n\n indices = matching_hash.keys\n next if indices.length == 1\n next if (indices[-1] - indices[0]) < longest.length\n\n first_index = matching_hash.first[0]\n\n k = 0\n valid_sequence = true\n while k < (indices.length / 2 - 1)\n first_dist = indices[k + 1] - indices[k]\n second_dist = indices[indices.length - 1 - k] - indices[indices.length - 2 - k]\n if first_dist != second_dist\n valid_sequence = false\n break\n end\n k += 1\n end\n\n next if !valid_sequence\n\n matching_hash.delete_if {|key,v| (key != first_index) && (key - first_index < longest.length)}\n indices = matching_hash.keys\n\n n = 1\n last_index = indices[-1]\n running_str = ''\n while first_index + n < ((last_index - first_index) / 2)\n matching_hash.each do |key, v|\n if key == first_index\n running_str = matching_hash[key] << s[key + n]\n else\n checking_str = matching_hash[key] << s[key - n]\n matching_hash.delete(key) if checking_str != running_str\n end\n end\n n +=1\n end\n\n matching_hash.values.each do |value|\n longest = value if value.length > longest.length\n end\n end\n puts \"longest: #{longest}\"\n return longest\nend", "def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend", "def 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 sluggish(array)\n i = 0\n longest_fish = \"\"\n while i < array.length\n n = 0\n while n < array.length\n if longest_fish.length < array[n].length\n longest_fish = array[n]\n end \n n+= 1\n end \n i += 1 \n end \n return longest_fish\nend", "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.length ? longest : current\n # binding.pry\n pair = hash.min_by{|k,v| v}\n hash.delete(pair[0])\n\n current = current[1..-1]\n else\n current += s\n end\n end\n end\n\n longest\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 - 1] + s[s.length/2] : s[s.length/2]\nend", "def solution(s)\n s = s.split ''\n return 'Empty String' if s.uniq.length == 1\n\n i = 1\n while i <= s.length\n if s[i - 1] == s[i]\n s.delete_at i - 1\n s.delete_at i - 1\n i = 0\n end\n i += 1\n end\n\n s.length <= 0 ? 'Empty String' : s.join\nend", "def solve(s)\n s.split(/[aeiou]/).map{ |x| x.sum - x.size * 96 }.max\nend", "def anagram(s)\n if s.length.even?\n substring1 = s[0..s.length/2 - 1].split('')\n substring2 = s[s.length/2..s.length-1].split('')\n i = 0\n while i <= substring1.length\n if substring2.index(substring1[i])\n char = substring1[i]\n substring1.delete_at(i)\n substring2.delete_at(substring2.index(char))\n else\n i += 1\n end\n end\n return substring1.count\n else\n return -1\n end\nend", "def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend", "def sluggish(fish)\n fish.each_with_index do |fish1, i1|\n max_length = true\n\n fish.each_with_index do |fish2, i2|\n next if i1 == i2\n max_length = false if fish2.length > fish1.length\n end\n\n return fish1 if max_length\n end\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 -1] + s[s.length/2] : s[s.length/2]\nend", "def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend", "def get_middle(s)\r\n s.length.odd? ? s[s.length / 2] : s[s.length / 2 - 1] + s[s.length / 2]\r\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n ## first solution ##\n# a = \"\"\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n# upper = 2*n-1\n# n.times do |i|\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# end\n ## above solution too slow\n ## build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n used = Hash.new(0)\n remaining = letter_count.dup\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if used[c] < half_count[c]\n while (a[-1] && c < a[-1] && \n remaining[a[-1]] > half_count[a[-1]] - used[a[-1]])\n # pop out bigger characters as long as they are exclude eligible\"\n used[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n used[c]+=1\n end\n remaining[c]-=1\n end\n return a\nend", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def repeatedString(s, n)\n len = s.length\n times = n / len\n nb = times * s.count('a')\n\n last = s[0..(n % len)]\n nb += last.count('a') if len != 1\n nb\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 solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def num_jewels_in_stones(j, s)\n s.count(j)\nend", "def substrings_of_size(str, n)\n substrings = []\n 0.upto(str.size - n) do |index|\n substrings << str[index..(index + n - 1)]\n end\n \n substrings.uniq\nend", "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend" ]
[ "0.65725124", "0.65281796", "0.64984745", "0.64225525", "0.63352686", "0.62447375", "0.62388307", "0.62374526", "0.6226243", "0.6177557", "0.61744344", "0.6164827", "0.61356336", "0.6128728", "0.6126486", "0.61086375", "0.61039466", "0.6090603", "0.6081216", "0.60716146", "0.60714114", "0.6058445", "0.6058324", "0.6024098", "0.60203916", "0.6010298", "0.6004705", "0.59749126", "0.59566665", "0.5941905", "0.59414", "0.59325266", "0.59270877", "0.5926584", "0.59255165", "0.5925356", "0.5912122", "0.5910104", "0.5904169", "0.59009874", "0.5900393", "0.5896889", "0.58946013", "0.5891373", "0.58784026", "0.58754313", "0.5872842", "0.58712256", "0.58620137", "0.5856833", "0.58476126", "0.5840898", "0.5840496", "0.58371514", "0.5831718", "0.5831429", "0.58262944", "0.5825598", "0.5817024", "0.58163255", "0.58122987", "0.5807766", "0.5807492", "0.5796024", "0.5792037", "0.57854646", "0.5785333", "0.57844174", "0.5776848", "0.5759391", "0.5759041", "0.5758747", "0.57519", "0.5750247", "0.57453096", "0.57437515", "0.5739524", "0.5734127", "0.5731154", "0.5727785", "0.57264954", "0.57241356", "0.5722761", "0.57207817", "0.57132035", "0.5710374", "0.57084334", "0.5703436", "0.56997573", "0.5693982", "0.5692636", "0.56914514", "0.5684774", "0.566564", "0.56655294", "0.5662751", "0.5661141", "0.56583863", "0.5655047", "0.56540346", "0.56527334" ]
0.0
-1
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s
def reverse_inplace(s) if s.length <= 1 return s else return s[s.length - 1] + reverse(s[0..-2]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n if pi == 0\n sizes << size\n next \n end\n\n substrings = [s_chars[0..pi]]\n\n while !substrings.empty? do\n sub = substrings.pop\n\n sequence = to_sequence(sub) # X\n\n # for every sequence, N-1 must exists and we only check if we can add the last bit\n pos = graph\n sequence[0..-2].each do |bit|\n pos = pos[bit]\n end\n \n next unless pos[sequence.last].nil?\n\n pos[sequence.last] = {}\n size += 1\n\n substrings << sub[1..-1] \n end\n\n sizes << size\n end\n\n sizes\nend", "def solution(s)\n if s.length.odd?\n center = s.length / 2\n if s[0...center] == s[center + 1..s.length].reverse\n return center \n end\n end\n -1\nend", "def f(str)\n 1.upto(str.size / 2) do |idx|\n number_of_subs = str.size / idx\n if str[0...idx] * number_of_subs == str\n return [str[0...idx], number_of_subs]\n end\n end\n [str, 1]\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def solve(s, n)\n answer = []\n \n while s.length > 0\n answer.push(s[0...n])\n s[0...n] = ''\n end\n return answer\nend", "def pseudoIsomorphicSubstrings(s)\n \n # Generate prefixs S'\n prefixs = []\n (s.size).times.each do |i|\n prefixs << s[0..i]\n end\n puts prefixs\n\n # For every i,j where i < j, the substrings of Si' (Sbi), are a subset of Sbj\n # and Sbj - Sbi are the substring that includes the last char of Sj'\n subsets = prefixs.map do |prefix|\n s = []\n\n (prefix.size).times.each do |i|\n s << prefix[i..-1]\n end\n \n s\n end\n puts subsets\n\n # Transform the substring to a sequence of numbers to compare values\n subsets.each do |subs|\n subs.map! { |sub| to_sequence(sub) }\n end\n puts subsets\n\n # For every i,j, such that 0 <= i < j, and a function ISO that generate\n # a set such that no two strings inside S' are pseudo-isomorphic to each other,\n # SUM(ISO(Si')) < ISO(Sj')\n puts \"=\"*50\n isosets = []\n subsets.each_with_index do |subs, i|\n if i == 0\n isosets << Set.new(subs)\n next\n end\n\n isosets << Set.new(subs).merge(isosets[i - 1])\n end\n puts isosets\n\n # Get sizes\n isosets.map { |iso| iso.size } \nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n string_size = s.size\n matrix = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n matrix << []\n\n i = 0\n while i <= pi do\n matrix[pi] << s_chars[i..pi].join.ljust(string_size)\n i += 1\n end\n\n matrix[pi] = matrix[pi].join(' | ')\n end\n\n puts matrix\n\n sizes\nend", "def lps(s)\n return \"\" if s.empty?\n longest = [0,0]\n s.chars.each_with_index do |ch, idx|\n for i,j in [[idx, idx + 1], [idx, idx]]\n until s[i] != s[j]\n break if i < 0 || j >= s.length\n longest = [i,j] if longest[1] - longest[0] < j - i\n i -= 1\n j += 1\n end\n end\n end\n s[longest[0]..longest[1]]\nend", "def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend", "def encode_direct(list, s = 0)\n if s >= list.length then return [] end\n\n i = s\n while i < list.length && (i == s || list[i] == list[i-1])\n i += 1\n end\n n = i - s\n\n [(n > 0 ? [n, list[s]] : list[s])] + encode_direct(list, i)\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def calc_d(s, r)\n n = s.size\n d = []\n n.times do |i|\n if i == 0\n d << 0\n else\n d_i = d[i-1] + s[i-1] - r[i]\n d_i = 0 if d_i <= 0\n d << d_i\n end\n end\n d\n\tend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend", "def n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend", "def nsrch(s,g)\n orig_s = s\n ss = s.to_s 2\n gs = g.to_s 2\n ops = []\n bits = gs.split(//)\n i = 0\n # Go through all bits of g.\n # If there are ones in the trailing part of ss, we\n # must get rid of them (Otherwise: 1001 -> 100, all digits match,\n # jump out of loop, make length equal by >>. Oops, it was an odd\n # number we just halved. So must check for ones.)\n while i < bits.size or ss[bits.size..-1].include? ?1\n b = bits[i]\n op = nil\n n = 0\n while ss[i,1] != b\n # Add zeroes to right to make length right and\n # to get the rightmost bit into an editable state.\n if ss.size < i+2 or s[0] == 1\n op = :*\n # Delete zeroes from right to make length right.\n elsif ss.size > i+2 and (s[0] == 0 and s[1] == 0)\n op = :/\n # Add 2 if length is ok and there are no zeroes to take out.\n # We are here because the second right-most bit is wrong.\n # Adding 2 flips it. It may also flip every bit we've just\n # went through, invalidating the invariant and thus we reset\n # the bit counter.\n else\n op = :+\n i = 0\n end\n ops << op\n s = case op\n when :+\n s + 2\n when :*\n s << 1\n when :/\n s >> 1\n end\n ss = s.to_s 2\n break if op == :+ # invariant may be bad,\n # must check before continuing\n end\n i += 1 unless op == :+\n end\n # take out extra zeroes on right\n r = s >> (ss.size-gs.size)\n ops.push *[:/]*(ss.size-gs.size)\n # and collect middle states using done ops\n a = [orig_s]\n ops.each{|op|\n a << case op\n when :*\n a.last * 2\n when :/\n a.last / 2\n when :+\n a.last + 2\n end\n }\n a\nend", "def subset(n, s)\n h = {}\n 1.upto(n) do |len|\n s.combination(len) do |a|\n sum = a.inject(0,:+)\n if h.key?(sum)\n u = h[sum].join(\" \")\n v = a.join(\" \")\n return \"#{u}\\n#{v}\"\n else\n h[sum] = a\n end\n end\n end\n return \"Impossible\"\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 longest_palindrome_subseq(s)\n length = s.size\n dp = []\n\n length.times do |i|\n dp[i]= Array.new(length).fill(0);\n dp[i][i] = 1\n end\n puts \"dp #{dp}\"\n (2..length).each do |len|\n puts \"len #{len}\"\n (0..(length - len)).each do |i|\n j = i + len - 1\n # puts \"j #{j} => i:#{i} + len:#{len} - 1\"\n\n if s[i] == s[j]\n dp[i][j] = 2 + (len == 2 ? 0 : dp[i+1][j-1])\n else\n dp[i][j] = [dp[i+1][j], dp[i][j-1]].max\n end\n puts \"dp #{dp}\"\n end\n end\n\n dp[0][length - 1]\nend", "def lcs_length(s1, s2)\n m = s1.size\n n = s2.size\n b = Array.new(m){Array.new(n)}\n # init everyting to zero\n c = Array.new(m+1) { Array.new(n+1, 0)}\n (1..m).each do |i|\n (1..n).each do |j|\n #puts(\"i: #{i}, j: #{j} s1_i:#{s1[i]} s2_j:#{s2[j]}\")\n #print_array(c)\n # 0 indexed on the string, so have to subtract 1 when looking at it\n if (s1[i-1] == s2[j-1]) then\n c[i][j] = c[i-1][j-1] + 1\n b[i-1][j-1] = \"d\" # up and to the right\n elsif c[i-1][j] >= c[i][j-1]\n c[i][j] = c[i-1][j]\n b[i-1][j-1] = \"u\" # up\n else\n c[i][j] = c[i][j-1]\n b[i-1][j-1] = \"l\" #left\n end\n end\n end\n #print_array(c)\n #print_array(b)\n return b,c\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def smallest_subarray(nums, s)\n min_length = Float::INFINITY\n\n start_position = 0\n end_position = 0\n\n sum = nums[start_position]\n\n while start_position < nums.length\n if sum < s\n end_position += 1\n break if end_position == nums.length\n\n sum += nums[end_position]\n elsif sum >= s\n size = nums[start_position..end_position].size\n min_length = [min_length, size].min\n sum -= nums[start_position]\n start_position += 1\n end\n end\n min_length\nend", "def sluggish_octopus\n # O(N^2)\n longest_fish = \"\"\n Fishes.each do |fish1|\n Fishes.each do |fish2|\n longest_fish = fish2 if fish2.length > fish1.length\n end\n end\n longest_fish\nend", "def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def countingValleys(n, s)\n valleys = 0\n pre = 0\n ac = 0\n for i in 0..n\n pre = ac\n ac += val(s[i]) \n valleys +=1 if pre == -1 && ac == 0\n end\n return valleys\nend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend", "def min_cut(s)\n palindrome = Array.new(s.size + 1).map { |x| \n Array.new(s.size + 1).map { |y|\n false\n }\n }\n\n dp = []\n 0.upto(s.size) { |i|\n dp[i] = i - 1\n }\n\n 2.upto(s.size).each { |i|\n (i - 1).downto(0).each { |j|\n if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1])\n palindrome[j][i] = true\n dp[i] = [dp[i], dp[j] + 1].min\n end\n }\n }\n\n return dp[s.size]\nend", "def longest_palindrome(s)\n string_hash = Hash.new(0)\n \n s.each_char do |char|\n string_hash[char] += 1\n end\n \n beginning_count = 0\n middle_count = 0\n \n string_hash.keys.each do |key|\n if string_hash[key] % 2 == 1\n middle_count = 1\n end\n \n beginning_count += string_hash[key] / 2\n end\n \n beginning_count * 2 + middle_count\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 shortest_palindrome_2(s)\n idx = 0\n front = \"\"\n back = \"\"\n (0...s.size).each { |i|\n front = front + s[i]\n back = s[i] + back\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend", "def solution(s)\n size = 0\n s.each_char do |c|\n if c == \"(\"\n size += 1\n elsif c == \")\"\n size -= 1\n return 0 if size < 0\n end\n end\n return 0 if size > 0\n return 1\nend", "def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend", "def uniq_subs(str)\n subs = Set.new\n str.length.times do |i|\n (i..str.length-1).each do |j|\n subs.add(str[i..j])\n end\n end\n subs\nend", "def num_distinct(s, t)\n len = t.size\n prefix = [1] + [0]*len # => [1, 0, 0, 0, 0, 0, 0] will happen\n s.chars.each do |char|\n len.downto(1) {|i| prefix[i]=prefix[i-1]+prefix[i] if t[i-1]==char}\n end\n p prefix\n prefix[-1]\nend", "def unique(s)\n (return true) if s.length <= 1\n rest = s[1..-1]\n rest.each do |i|\n (return false) if s[0] == i\n end\n return unique(rest)\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend", "def findLongestSubarrayBySum(s, arr)\n history = {0 => -1} \n sum = 0 \n max_length = 0 \n result = [-1]\n\n for idx in 0...arr.length \n sum += arr[idx]\n history[sum] = idx if history[sum].nil? \n\n if history[sum - s]\n length = idx - history[sum - s]\n if length > max_length \n max_length = length \n result = [history[sum - s]+2, idx+1]\n end \n end \n end \n\n result\nend", "def sluggish(fish)\n longest_fish = \"\"\n i = 0\n while i < fish.length\n j = i + 1\n while j < fish.length\n longest_fish = fish[j] if longest_fish.length <= fish[j].length\n j += 1\n end\n i += 1\n end\n longest_fish\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 scramble(s1,s2)\n s2.chars.uniq.all?{|i| s1.count(i) >= s2.count(i)} \nend", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def repeatedString(s, n)\n # First approach times out\n # s = s * ((n/s.length)+1)\n # p s[0..n-1].count('a')\n a_count = s.count('a')\n times_to_repeat = ((n/s.length))\n num_a_in_string = a_count * times_to_repeat\n leftover = (n%(s.length))\n num_a_in_string += s[0..leftover-1].count('a') if leftover >= 1\n p num_a_in_string\nend", "def is_subsequence(s, t)\n t_id = 0\n s_id = 0\n while t_id < t.length && s_id < s.length\n s_id += 1 if t[t_id] == s[s_id]\n t_id += 1\n end\n s_id == s.length\nend", "def solution(string) # \"ABCA\",\n # TIME O(N) + O(N) = O(2N) ~~ O(N)\n # SPACE O(N)\n\n array = string.split(\"\") # w[A B C A], O(N)\n array_exist = [] # [B C]\n array.each do |s| # O(N), N= 1000_000\n if array_exist.include?(s)\n array_exist.delete(s)\n else\n array_exist.push(s)\n end\n end\n array_exist[0]\nend", "def phase_iii(s1, s2)\n s1.chars.sort! == s2.chars.sort!\n\nend", "def is_sub?(s, t)\n i = j = 0\n while i < s.size && j < t.size\n i += 1 if s[i] == t[j]\n j += 1\n end\n i == s.size\nend", "def solve(s0, s1)\n # shift and push the first letter of the array length number of times\n # check if s0 == s1 each time\n return true if s0 == s1\n \n rotations = s0.length\n \n s0_arr = s0.split('')\n s1_arr = s1.split('')\n until s0_arr == s1_arr || rotations == 0\n s0_arr == s0_arr.push(s0_arr.shift)\n rotations -= 1\n return true if s0_arr == s1_arr\n end\n return false\nend", "def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend", "def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend", "def solve(s, t)\n if s.length != t.length\n return false\n end\n hash = Hash.new {|h, k, v| hash[k] = v}\n\n (0...s.length).each do |i|\n if !hash[s[i]] && !hash.values.include?(t[i])\n hash[s[i]] = t[i]\n elsif hash[s[i]] != t[i]\n return false\n end\n end\n true\nend", "def find_short(s)\n ar = (s.split).map { |k| k.size }.sort\n p ar[0]\n end", "def repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\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 longest_palindrome(s)\n result = ''\n \n for i in (0..s.length-1) do\n for j in (i..s.length-1) do \n result = s[i..j] if s[i..j].length > result.length && s[i..j] == s[i..j].reverse\n end\n end\n \n result\nend", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\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 f(s)\n uniq_char = s.chars.uniq.join('')\n # split_array = s.scan(uniq_char)\n # [split_array.length > 1 ? uniq_char : s,split_array.length]\nend", "def sluggish_octopus(fish)\n longest_fish = fish.first\n\n (0...fish.length).each do |start|\n (start...fish.length).each do |ending|\n if fish[ending].length > fish[start].length \n longest_fish = fish[ending]\n else\n longest_fish = fish[start]\n end\n end\n end\n\n longest_fish\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 luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend", "def jewels_and_stones(j,s)\n\n if (s == nil || s.length < 1 || j == nil || j.length < 1)\n return 0\n end\n\n hash = Hash.new\n\n j.each_char do |char|\n hash[char] = 1\n end\n\n count = 0\n s.each_char do |char|\n if (hash[s[char]] == 1)\n count = count + 1\n end\n end\n return count\n\nend", "def dnaSequence s\n hash, diff = Hash.new(0), Hash.new(0)\n diff[[0, 0, 0]] = 1\n\n sum = 0\n s.chars.each { |c|\n hash[c] += 1\n res = [hash['A'] - hash['C'], hash['C'] - hash['G'], hash['G'] - hash['T']]\n sum += diff[res]\n diff[res] += 1\n }\n sum\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(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 phase_ii(s1, s2)\n del_dex = []\n s1 = s1.chars\n s2 = s2.chars\n s1.each_with_index do |el, idx|\n if s2.include?(el)\n del_dex << idx\n s2.delete_at(s2.index(el))\n end\n end\n del_dex.each { |i| s1[i] = nil }\n return s1.select { |el| !el.nil? }.empty? && s2.empty?\nend", "def partition(s)\n palindrome = Array.new(s.size) {\n Array.new(s.size)\n }\n \n cuts = [[]]\n \n (0...s.size).each { |i|\n (0..i).each { |j|\n palindrome[j][i] = if i == j\n true\n elsif i == j + 1\n s[i] == s[j]\n else\n s[i] == s[j] && palindrome[j + 1][i - 1]\n end\n\n next if !palindrome[j][i] || cuts[j - 1].nil? && j > 1\n cuts[i] ||= []\n cuts[i] << cuts[j - 1].map { |x| x + [s[j..i]] }.flatten(1)\n }\n }\n \n puts \"#{cuts}\"\n cuts[s.size - 1]\nend", "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend", "def do_et offset, l, s, ww\n i = 0\n tt = []\n while i + l - 1 < s.length\n tt << s[i..i+l-1]\n i += l\n end\n o = []\n ttq = []\n wc = {}\n ww.each { |w| if wc.has_key? w then wc[w] += 1 else wc[w] = 1 end }\n zc = wc.length\n tt.each_with_index do |t, i|\n # expand\n ttq << [t, i * l + offset]\n if wc.has_key? t\n if wc[t] == 1\n zc -= 1\n elsif wc[t] == 0\n zc += 1\n end\n wc[t] -= 1\n end\n # contract\n if ttq.length > ww.length\n h, _ = ttq.delete_at 0\n if wc.has_key? h\n if wc[h] == -1\n zc -= 1\n elsif wc[h] == 0\n zc += 1\n end\n wc[h] += 1\n end\n end\n # check\n if zc == 0\n o << ttq.first[1]\n end\n end\n return o\nend", "def sum_pairs_v1 ints, s\n hash = {}\n index = []\n ints.each_with_index {|elem, i| hash[elem] = i }\n ints.each_with_index do |elem, i|\n if hash[s-elem] && hash[s-elem] != i\n hash[s-elem] > hash[elem] ? index << hash[s-elem] : index << hash[elem]\n end\n end\n\n return [s-ints[index.sort.first],ints[index.sort.first]] if index.any?\n nil\nend", "def longest_palindrome(s)\n return s if s.length == 1\n previous = s[0]\n\n all_same = true\n z = 0\n counter = 0\n while z < s.length\n if s[z] == previous\n counter += 1\n else\n tmp_longest = previous * counter\n longest = tmp_longest if tmp_longest.length > longest.length\n previous = s[z]\n counter = 1\n break if counter > s.length / 2\n end\n z += 1\n end\n return previous * counter if all_same || counter > s.length / 2\n\n longest = ''\n i = 0\n while i < s.length\n starting_letter = s[i]\n matching_hash = {}\n matching_hash[i] = starting_letter\n\n j = i + 1\n while j < s.length\n if s[j] == starting_letter\n matching_hash[j] = s[j]\n end\n j += 1\n end\n\n i += 1\n\n indices = matching_hash.keys\n next if indices.length == 1\n next if (indices[-1] - indices[0]) < longest.length\n\n first_index = matching_hash.first[0]\n\n k = 0\n valid_sequence = true\n while k < (indices.length / 2 - 1)\n first_dist = indices[k + 1] - indices[k]\n second_dist = indices[indices.length - 1 - k] - indices[indices.length - 2 - k]\n if first_dist != second_dist\n valid_sequence = false\n break\n end\n k += 1\n end\n\n next if !valid_sequence\n\n matching_hash.delete_if {|key,v| (key != first_index) && (key - first_index < longest.length)}\n indices = matching_hash.keys\n\n n = 1\n last_index = indices[-1]\n running_str = ''\n while first_index + n < ((last_index - first_index) / 2)\n matching_hash.each do |key, v|\n if key == first_index\n running_str = matching_hash[key] << s[key + n]\n else\n checking_str = matching_hash[key] << s[key - n]\n matching_hash.delete(key) if checking_str != running_str\n end\n end\n n +=1\n end\n\n matching_hash.values.each do |value|\n longest = value if value.length > longest.length\n end\n end\n puts \"longest: #{longest}\"\n return longest\nend", "def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend", "def 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 sluggish(array)\n i = 0\n longest_fish = \"\"\n while i < array.length\n n = 0\n while n < array.length\n if longest_fish.length < array[n].length\n longest_fish = array[n]\n end \n n+= 1\n end \n i += 1 \n end \n return longest_fish\nend", "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.length ? longest : current\n # binding.pry\n pair = hash.min_by{|k,v| v}\n hash.delete(pair[0])\n\n current = current[1..-1]\n else\n current += s\n end\n end\n end\n\n longest\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 - 1] + s[s.length/2] : s[s.length/2]\nend", "def solution(s)\n s = s.split ''\n return 'Empty String' if s.uniq.length == 1\n\n i = 1\n while i <= s.length\n if s[i - 1] == s[i]\n s.delete_at i - 1\n s.delete_at i - 1\n i = 0\n end\n i += 1\n end\n\n s.length <= 0 ? 'Empty String' : s.join\nend", "def solve(s)\n s.split(/[aeiou]/).map{ |x| x.sum - x.size * 96 }.max\nend", "def anagram(s)\n if s.length.even?\n substring1 = s[0..s.length/2 - 1].split('')\n substring2 = s[s.length/2..s.length-1].split('')\n i = 0\n while i <= substring1.length\n if substring2.index(substring1[i])\n char = substring1[i]\n substring1.delete_at(i)\n substring2.delete_at(substring2.index(char))\n else\n i += 1\n end\n end\n return substring1.count\n else\n return -1\n end\nend", "def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend", "def sluggish(fish)\n fish.each_with_index do |fish1, i1|\n max_length = true\n\n fish.each_with_index do |fish2, i2|\n next if i1 == i2\n max_length = false if fish2.length > fish1.length\n end\n\n return fish1 if max_length\n end\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 -1] + s[s.length/2] : s[s.length/2]\nend", "def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend", "def get_middle(s)\r\n s.length.odd? ? s[s.length / 2] : s[s.length / 2 - 1] + s[s.length / 2]\r\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n ## first solution ##\n# a = \"\"\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n# upper = 2*n-1\n# n.times do |i|\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# end\n ## above solution too slow\n ## build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n used = Hash.new(0)\n remaining = letter_count.dup\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if used[c] < half_count[c]\n while (a[-1] && c < a[-1] && \n remaining[a[-1]] > half_count[a[-1]] - used[a[-1]])\n # pop out bigger characters as long as they are exclude eligible\"\n used[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n used[c]+=1\n end\n remaining[c]-=1\n end\n return a\nend", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def repeatedString(s, n)\n len = s.length\n times = n / len\n nb = times * s.count('a')\n\n last = s[0..(n % len)]\n nb += last.count('a') if len != 1\n nb\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 solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def num_jewels_in_stones(j, s)\n s.count(j)\nend", "def substrings_of_size(str, n)\n substrings = []\n 0.upto(str.size - n) do |index|\n substrings << str[index..(index + n - 1)]\n end\n \n substrings.uniq\nend", "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend" ]
[ "0.6571266", "0.6527647", "0.64974415", "0.6421256", "0.6334191", "0.62447935", "0.6238051", "0.62372625", "0.6225252", "0.61764836", "0.61744225", "0.61640054", "0.61357486", "0.6128065", "0.6125138", "0.6107513", "0.6103693", "0.60892355", "0.6081185", "0.6071949", "0.6070353", "0.6058085", "0.6057356", "0.60229105", "0.6019335", "0.60093933", "0.6004409", "0.5973658", "0.59558284", "0.59410995", "0.5940525", "0.5931808", "0.59262717", "0.59258384", "0.5925089", "0.5923833", "0.59119517", "0.5908653", "0.5903434", "0.5900947", "0.5899729", "0.5895603", "0.58935523", "0.5891149", "0.5877482", "0.58749956", "0.587092", "0.5870084", "0.586126", "0.5856725", "0.58463115", "0.5839842", "0.58393604", "0.5836566", "0.5830321", "0.5829896", "0.58256495", "0.5823856", "0.5815734", "0.5814492", "0.5811703", "0.5806964", "0.5805676", "0.5794298", "0.579164", "0.5784663", "0.57840705", "0.5782867", "0.57760435", "0.5759053", "0.5758533", "0.5757745", "0.57507527", "0.5748966", "0.57446337", "0.57417315", "0.57385993", "0.57335544", "0.5730635", "0.57267064", "0.5725343", "0.57231337", "0.57213634", "0.5719848", "0.57126147", "0.5710133", "0.5707669", "0.57021606", "0.5699266", "0.56933665", "0.5691119", "0.56909287", "0.5683208", "0.5664856", "0.5664515", "0.5661438", "0.56591207", "0.56567585", "0.56547093", "0.5653481", "0.56503934" ]
0.0
-1
Time complexity: O(n) where n is value of n Space complexity: O(n) where n is value of n
def bunny(n) if n < 1 return 0 else return 2 + bunny(n-1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 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 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_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 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(n)\n x = (n**0.5).floor\n (1..x).reduce(0) { |s, i| n % i == 0 ? s += (i * i == n ? 1 : 2) : s }\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(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 solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end", "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 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 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 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 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 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 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 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 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(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 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 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 solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "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 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 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 sum_to_n? arr, n\n hash = Hash.new\n arr.each do |val|\n if hash.key? val\n return true\n else\n hash[n-val] = val\n end\n end\n return false\nend", "def fibonacci(n)\n return fib_helper([0, 1], 2, n)\n # if you'd like to test what i THINK is an O(1) space complexity solution.....\n # i did run this through the tests and it SHOULD work:\n # return faster_fib_helper([0, 1], 2, n)\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 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 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", "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 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 solve( n = 1_000_000_000 )\n log10 = Math.log10( n )\n\n sum = (0...log10).map do |i|\n if 0 == (i % 4)\n 0\n elsif 0 != (i % 2)\n 20 * 30**((i - 1)/2)\n else\n 100 * 500**((i - 2)/4)\n end\n end\n\n sum.reduce( :+ )\n end", "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 euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\nend", "def main\n\n sum = 0\n\n (0..999).each do |i|\n sum += check(i)\n end\n\n puts \"Total - O(n) #{sum}\"\n\n # Needed to refresh following: https://en.wikipedia.org/wiki/Arithmetic_progression\n sum2 = sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000)\n\n # Refreshed Big O too : http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o \n puts \"Total - O(1) #{sum2}\"\n\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 count_by(x, n)\n a=[]\n y=0\n n.times {y+=x; a<<y}\n a\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 process n\n i = 1\n while (2**i <= n)\n i += 1\n end\n n == 2**(i-1)\nend", "def solution(n)\n array = Array.new\n (1..n).each do\n array.push(0)\n end\n while (array.length >= 16)\n (1..16).each do\n array.pop\n end \n end\n array.length\nend", "def dbl_linear(n)\n result = [1] # base\n\n i = 0 # pointer for 2x + 1\n j = 0 # pointer for 3x + 1\n\n until result.size == n + 1 # because n is an index (size - 1)\n list1 = 2 * result[i] + 1\n list2 = 3 * result[j] + 1\n min = [list1, list2].min\n\n result << min\n\n i += 1 if min == list1\n j += 1 if min == list2\n end\n\n result.last\nend", "def sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\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 sum_to_n? arr, n\n if arr.size>=2\n for a in arr\n if arr.include?(n-a) and (a != n-a or arr.count(a) > 1)\n return true\n end\n end\n end\n false\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 sorted_squared_array_n_nlogn(values)\n values.collect!{|val| val*val}\n merge_sort(values)\nend", "def candies(n, arr)\n cc = []\n cc[0] = 1\n 1.upto(n-1) do |i|\n if arr[i] > arr[i-1]\n cc[i] = cc[i-1] + 1\n else\n cc[i] = 1\n end\n end\n p cc\n (n-2).downto(0) do |i|\n if arr[i] > arr[i+1] && cc[i] <= cc[i+1]\n cc[i] = cc[i+1] + 1\n end\n end\n p cc\n cc.reduce(:+)\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def sum_to_n? arr, n\n # YOUR CODE HERE\n unless arr.length > 1\n return false\n end\n h=Hash.new\n arr.each{|a|\n if h.key? a \n return true else h[n-a] = n end}\n return false\nend", "def sum_to_n? arr, n\n \n if arr.size>=2\n for x in arr\n if arr.include?(n-x) and x != n-x or arr.count(x) > 1\n return true\n end\n end\n end\n \n false\nend", "def sum_to_n? arr, n\n if arr.size>=2\n for x in arr\n target = n-x\n tmp = arr.dup\n tmp.delete_at(tmp.index(x))\n return true if tmp.include?(target)\n end\n end\n false\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 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 canBeSum(n, array, cache)\n\ti = 0\n\twhile array[i] <= n / 2\n\t\tif cache[n-array[i]] # array.include?(n-array[i]) is OK, but very slow\n\t\t\treturn true\n\t\tend\n\n\t\ti += 1\n\tend\n\n\treturn false\nend", "def pairSumSequence(n)\n sum = 0\n\n for i in 0..n\n # pairSum calls do not exist simultabeously on\n # the call stack, so you only need O(1) space\n sum += pairSum(i, i + 1)\n puts \"sum += (#{i + i + 1}) #{i} + #{i} + 1 \"\n end\n\n return sum\nend", "def nth_ugly_number(n, a, b, c)\n# a-b, a-c, b-c, ab-c\n ab_lcm = a.lcm(b) # there are some a present in b\n ac_lcm = a.lcm(c) # there are some a present in c\n bc_lcm = b.lcm(c) # there are some b present in c\n abc_lcm = ab_lcm.lcm(c) # there are some a*b in c (because c is the biggest)\n \n # using set theory for binary search\n # a + b + c - ab_lcm - ac_lcm - bc_lcm + abc_lcm\n (1..2*10**9).bsearch{|x| x/a + x/b + x/c - x/ab_lcm - x/ac_lcm - x/bc_lcm + x/abc_lcm >= n}\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 solution(p, n)\n return 0 if n <= 0\n\n n.times.reduce(MIN_INT) do |max, i|\n [max, p[i] + solution(p, n - (i + 1))].max\n end\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 sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend", "def solution_dp_bu(p, n)\n dp = Array.new(n, MIN_INT)\n # we set p[0] and dp[0] to 0\n dp[0] = 0\n p = p.dup.unshift(0)\n\n (1..n).each do |i|\n dp[i] = (0..(i - 1)).reduce(MIN_INT) do |max, j|\n [max, dp[j] + p[i - j]].max\n end\n end\n\n dp.last\nend", "def solve( n = 10_000_000 )\n sum = Array.new( n, 0 )\n limit, scale = 1, Math.log( n, 10 ).round - 1\n\n # Precompute single digits.\n (0...10).each {|i| sum[i] = i*i}\n\n # Use previously computed values to speed calculation.\n scale.times do\n limit *= 10\n (limit...10*limit).each do |i|\n j = i\n while 0 < j\n j, r = j / limit, j % limit\n sum[i] += sum[r]\n end\n end\n end\n\n # Cycle each slot until it reaches a terminal value.\n 1.upto( n - 1 ) do |i|\n until 1 == sum[i] || 89 == sum[i]\n sum[i] = sum[sum[i]]\n end\n end \n\n # Count may be computed directly from total sum.\n (sum.inject( :+ ) - n + 1) / 88\n end", "def trinum n\n temp = 0\n for i in 1..n\n temp = temp + i\n end\n return temp\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 f(n, x)\n # $count += 1\n if n == 0\n x <= 0 ? 0 : 1\n elsif x <= 1\n 0\n elsif 1 < x && x <= 1 + $a[n - 1]\n f(n - 1, x - 1)\n elsif x == 2 + $a[n - 1]\n $p[n - 1] + 1\n elsif 2 + ($a[n - 1]) < x && x <= 2 + 2 * $a[n - 1]\n $p[n - 1] + 1 + f(n - 1, x - 2 - $a[n - 1])\n else\n 2 * $p[n - 1] + 1\n end\nend", "def solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "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 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(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend", "def arrayManipulation(n, queries)\n arr = Array.new(n + 2, 0)\n\n queries.each do |a, b, k|\n arr[a] += k\n arr[b + 1] -= k\n end\n\n max_sum = 0\n sum = 0\n arr.filter { |diff| diff != 0 }.each do |diff|\n sum += diff\n max_sum = [max_sum, sum].max\n end\n\n max_sum\nend", "def isSumOfTwoAbundantNumbers n\n\n # we'll cycle over all abundant numbers less than n / 2\n if n / 2 < @@listOfAbundants.first\n return false\n end\n\n if @@listOfAbundants.last < n / 2\n for i in ((@@listOfAbundants.last + 1)..n)\n if isAbundant i\n @@listOfAbundants.push i\n end\n end\n end\n\n for a in @@listOfAbundants\n if a > n /2 \n return false\n end\n \n pair = n - a\n if @@listOfAbundants.include? pair\n return true\n end\n end\n\nend", "def solution(a)\n n = a.size\n starting = Array.new(n, 0)\n ending = Array.new(n, 0)\n\n (1..n - 2).each {|i| starting[i] = [starting[i - 1] + a[i], 0].max}\n (1..n - 2).reverse_each {|i| ending[i] = [ending[i + 1] + a[i], 0].max}\n\n sum = 0\n (1..n - 2).each {|i| sum = [sum, starting[i - 1] + ending[i + 1]].max}\n sum\nend", "def series_up(n)\n #nlist is the list that will be the output of the code\n nlist = []\n #i changed from an if statement to a loop.\n (n*(n+1)/2+1).times do |i|\n i.times do |x|\n nlist.push(x+1)\n end\n end\n #I use three dots to only get the information i need from the code\n return nlist[0...(n*(n+1)/2)].to_a\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 series_up(n)\n list = []\n (n+1).times do |a|\n a.times do |b|\n list.push(b+1)\n end \n end\n return list\nend", "def 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 topologies(n, cache = {})\n cache[n] =\n n == 0 ? 1 : (0..n-1).inject(0){ |sum, i| \\\n sum + topologies(i, cache) * topologies(n-i-1, cache) } unless cache.has_key? n\n cache[n]\nend", "def cantor_pairing(n, m)\n (n + m) * (n + m + 1) / 2 + m\nend", "def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\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 perfects (n)\n return (1..n).select { |x| x==(1...x).select { |i| x%i==0 }.inject(:+) }\nend", "def series_up(n) # given n, return a list that goes [1,1,2,1,2,3... n]\n n_list = []\n (n+1).times do |m|\n m.times do |val|\n n_list.push(val+1)\n end\n end\n return n_list\nend", "def solution(n)\n # write your code in Ruby 2.2\n a = Math.sqrt(n).floor\n a -= 1 while n % a != 0\n b = n / a\n (a + b) * 2\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 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 example1(n)\n arr = [0, 1 ,2, 3, 5]\n i = 3 \n while(i <= n)\n arr[i] = arr[i - 1] + arr[i - 2]\n i += 1\n end\n\n arr[n]\n\nend", "def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend", "def solve( n = 1_000_000 )\n sum = limit = 0\n \n while sum < n\n limit += 1\n limit2 = limit * limit\n \n 2.upto( limit << 1 ) do |bc|\n d = Math.sqrt( limit2 + bc*bc )\n sum += (bc > limit ? 1 + limit - (1 + bc)/2 : bc/2) if d.to_i == d\n end\n end\n\n limit\n end", "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_shortest_seq(n)\n new_num = n/2\n i = 0\n arr = []; arr[i] = 1\n\n while(arr[i] < new_num)\n n1 = arr[i] * 2\n n2 = arr[i] + 1\n\n i += 1\n if(n1 < new_num)\n arr[i] = n1\n else\n arr[i] = n2\n end \n end\n puts arr.to_s\n if(arr[i] == n)\n puts arr.to_s\n puts i \n elsif n == (arr[i] * 2)\n arr[i + 1] = arr[i] * 2\n puts arr.to_s\n puts i + 1\n else\n arr[i + 1] = arr[i] * 2\n i += 1\n arr[i + 1] = arr[i] + 1\n puts arr.to_s\n puts i\n end \n \nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def ideal_numbers(n)\n # perfects = []\n # factors = proper_factors(n)\n\n # while perfects.length <= n \n # factors.each do |factor|\n # sum = aliquot_sum(n)\n \n # if factor == perfect_number?(factor)\n # perfects << factor\n # end \n # end \n # end\n\n perfect_nums = []\n\n i = 1\n while perfect_nums.length < n \n perfect_nums << i if perfect_number?(i)\n i += 1\n end \n\n perfect_nums\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 two_number_sum array, n \n\tarray.sort!\n\treverse_index = array.size - 1 \n\tindex = 0\n\twhile index >= reverse_index\n\t\tif array[index] + array[reverse_index] > n\n\t\t\treverse_index -= 1\n\t\telsif array[index] + array[reveres_index] < n\n\t\t\tindex += 1\n\t\telse\n\t\t\tputs \"#{array[index]} + #{array[reverse_index]}\"\n\t\t\tindex += 1\n\t\tend\n\tend\nend", "def sim_program(n)\n (1..n).reduce(0) do |acc, i|\n (n % i).zero? ? acc + i : acc\n end\n end", "def calculate_optimal_k\n k=0\n @k_optimal = Array.new(@size)\n (3..@size).each{|n|\n k+=1 while(cost(n,k)<cost(n,k+1))\n @k_optimal[n]=k\n }\n end", "def fibo_finder(n)\n start = [0,1]\n n.times {|i| start[i + 2] = start[i] + start[i + 1]}\n start[n]\nend", "def sum_of_n_consecutive_numbers (n)\n n*(n+1)/2\nend", "def d(n)\n (2..Math.sqrt(n)).inject(1){|s, i| n % i == 0 ? s + i + n/i : s}\nend", "def find_missing_number(array, n)\n sum = (1..n).reduce(:+) # sum from 1 to n\n array.each do |el|\n sum -= el\n end\n return sum\nend" ]
[ "0.67394114", "0.65784717", "0.654895", "0.65278155", "0.64846534", "0.6437647", "0.6424175", "0.6410781", "0.63709044", "0.6369165", "0.63649464", "0.63544774", "0.63527805", "0.63394874", "0.63230556", "0.63095427", "0.62552124", "0.6236607", "0.6231398", "0.62204385", "0.6216165", "0.62115204", "0.6209233", "0.6202444", "0.6197958", "0.6193602", "0.6191636", "0.6189028", "0.6158747", "0.6157126", "0.61561966", "0.6154285", "0.6153568", "0.61535597", "0.6151309", "0.6147553", "0.61392516", "0.61365706", "0.61311036", "0.610919", "0.6105583", "0.608132", "0.6067754", "0.6062695", "0.6061745", "0.6056702", "0.6055787", "0.6054599", "0.60513", "0.60491437", "0.6044236", "0.6043899", "0.6037204", "0.6026915", "0.60258406", "0.60227156", "0.60088974", "0.6001826", "0.5991864", "0.5991197", "0.59887624", "0.5985896", "0.5976702", "0.59698206", "0.5958698", "0.5956947", "0.5955348", "0.59456044", "0.59426576", "0.5933193", "0.5915424", "0.5915353", "0.5910856", "0.5905254", "0.5899821", "0.58953446", "0.58935934", "0.58844817", "0.58811045", "0.58789265", "0.5878088", "0.58737534", "0.58735263", "0.58710027", "0.5870675", "0.58674616", "0.5862854", "0.5860156", "0.58525693", "0.5852372", "0.5847631", "0.58470386", "0.584688", "0.584133", "0.58404255", "0.5838106", "0.58348274", "0.5830324", "0.5827959", "0.58249927", "0.5824611" ]
0.0
-1
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s
def nested(s) if s.length == 0 return true else if s[0] == "(" && s[-1] == ")" return nested(s[1..-2]) else return false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n if pi == 0\n sizes << size\n next \n end\n\n substrings = [s_chars[0..pi]]\n\n while !substrings.empty? do\n sub = substrings.pop\n\n sequence = to_sequence(sub) # X\n\n # for every sequence, N-1 must exists and we only check if we can add the last bit\n pos = graph\n sequence[0..-2].each do |bit|\n pos = pos[bit]\n end\n \n next unless pos[sequence.last].nil?\n\n pos[sequence.last] = {}\n size += 1\n\n substrings << sub[1..-1] \n end\n\n sizes << size\n end\n\n sizes\nend", "def solution(s)\n if s.length.odd?\n center = s.length / 2\n if s[0...center] == s[center + 1..s.length].reverse\n return center \n end\n end\n -1\nend", "def f(str)\n 1.upto(str.size / 2) do |idx|\n number_of_subs = str.size / idx\n if str[0...idx] * number_of_subs == str\n return [str[0...idx], number_of_subs]\n end\n end\n [str, 1]\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def solve(s, n)\n answer = []\n \n while s.length > 0\n answer.push(s[0...n])\n s[0...n] = ''\n end\n return answer\nend", "def pseudoIsomorphicSubstrings(s)\n \n # Generate prefixs S'\n prefixs = []\n (s.size).times.each do |i|\n prefixs << s[0..i]\n end\n puts prefixs\n\n # For every i,j where i < j, the substrings of Si' (Sbi), are a subset of Sbj\n # and Sbj - Sbi are the substring that includes the last char of Sj'\n subsets = prefixs.map do |prefix|\n s = []\n\n (prefix.size).times.each do |i|\n s << prefix[i..-1]\n end\n \n s\n end\n puts subsets\n\n # Transform the substring to a sequence of numbers to compare values\n subsets.each do |subs|\n subs.map! { |sub| to_sequence(sub) }\n end\n puts subsets\n\n # For every i,j, such that 0 <= i < j, and a function ISO that generate\n # a set such that no two strings inside S' are pseudo-isomorphic to each other,\n # SUM(ISO(Si')) < ISO(Sj')\n puts \"=\"*50\n isosets = []\n subsets.each_with_index do |subs, i|\n if i == 0\n isosets << Set.new(subs)\n next\n end\n\n isosets << Set.new(subs).merge(isosets[i - 1])\n end\n puts isosets\n\n # Get sizes\n isosets.map { |iso| iso.size } \nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n string_size = s.size\n matrix = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n matrix << []\n\n i = 0\n while i <= pi do\n matrix[pi] << s_chars[i..pi].join.ljust(string_size)\n i += 1\n end\n\n matrix[pi] = matrix[pi].join(' | ')\n end\n\n puts matrix\n\n sizes\nend", "def lps(s)\n return \"\" if s.empty?\n longest = [0,0]\n s.chars.each_with_index do |ch, idx|\n for i,j in [[idx, idx + 1], [idx, idx]]\n until s[i] != s[j]\n break if i < 0 || j >= s.length\n longest = [i,j] if longest[1] - longest[0] < j - i\n i -= 1\n j += 1\n end\n end\n end\n s[longest[0]..longest[1]]\nend", "def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend", "def encode_direct(list, s = 0)\n if s >= list.length then return [] end\n\n i = s\n while i < list.length && (i == s || list[i] == list[i-1])\n i += 1\n end\n n = i - s\n\n [(n > 0 ? [n, list[s]] : list[s])] + encode_direct(list, i)\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def calc_d(s, r)\n n = s.size\n d = []\n n.times do |i|\n if i == 0\n d << 0\n else\n d_i = d[i-1] + s[i-1] - r[i]\n d_i = 0 if d_i <= 0\n d << d_i\n end\n end\n d\n\tend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend", "def n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend", "def nsrch(s,g)\n orig_s = s\n ss = s.to_s 2\n gs = g.to_s 2\n ops = []\n bits = gs.split(//)\n i = 0\n # Go through all bits of g.\n # If there are ones in the trailing part of ss, we\n # must get rid of them (Otherwise: 1001 -> 100, all digits match,\n # jump out of loop, make length equal by >>. Oops, it was an odd\n # number we just halved. So must check for ones.)\n while i < bits.size or ss[bits.size..-1].include? ?1\n b = bits[i]\n op = nil\n n = 0\n while ss[i,1] != b\n # Add zeroes to right to make length right and\n # to get the rightmost bit into an editable state.\n if ss.size < i+2 or s[0] == 1\n op = :*\n # Delete zeroes from right to make length right.\n elsif ss.size > i+2 and (s[0] == 0 and s[1] == 0)\n op = :/\n # Add 2 if length is ok and there are no zeroes to take out.\n # We are here because the second right-most bit is wrong.\n # Adding 2 flips it. It may also flip every bit we've just\n # went through, invalidating the invariant and thus we reset\n # the bit counter.\n else\n op = :+\n i = 0\n end\n ops << op\n s = case op\n when :+\n s + 2\n when :*\n s << 1\n when :/\n s >> 1\n end\n ss = s.to_s 2\n break if op == :+ # invariant may be bad,\n # must check before continuing\n end\n i += 1 unless op == :+\n end\n # take out extra zeroes on right\n r = s >> (ss.size-gs.size)\n ops.push *[:/]*(ss.size-gs.size)\n # and collect middle states using done ops\n a = [orig_s]\n ops.each{|op|\n a << case op\n when :*\n a.last * 2\n when :/\n a.last / 2\n when :+\n a.last + 2\n end\n }\n a\nend", "def subset(n, s)\n h = {}\n 1.upto(n) do |len|\n s.combination(len) do |a|\n sum = a.inject(0,:+)\n if h.key?(sum)\n u = h[sum].join(\" \")\n v = a.join(\" \")\n return \"#{u}\\n#{v}\"\n else\n h[sum] = a\n end\n end\n end\n return \"Impossible\"\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 longest_palindrome_subseq(s)\n length = s.size\n dp = []\n\n length.times do |i|\n dp[i]= Array.new(length).fill(0);\n dp[i][i] = 1\n end\n puts \"dp #{dp}\"\n (2..length).each do |len|\n puts \"len #{len}\"\n (0..(length - len)).each do |i|\n j = i + len - 1\n # puts \"j #{j} => i:#{i} + len:#{len} - 1\"\n\n if s[i] == s[j]\n dp[i][j] = 2 + (len == 2 ? 0 : dp[i+1][j-1])\n else\n dp[i][j] = [dp[i+1][j], dp[i][j-1]].max\n end\n puts \"dp #{dp}\"\n end\n end\n\n dp[0][length - 1]\nend", "def lcs_length(s1, s2)\n m = s1.size\n n = s2.size\n b = Array.new(m){Array.new(n)}\n # init everyting to zero\n c = Array.new(m+1) { Array.new(n+1, 0)}\n (1..m).each do |i|\n (1..n).each do |j|\n #puts(\"i: #{i}, j: #{j} s1_i:#{s1[i]} s2_j:#{s2[j]}\")\n #print_array(c)\n # 0 indexed on the string, so have to subtract 1 when looking at it\n if (s1[i-1] == s2[j-1]) then\n c[i][j] = c[i-1][j-1] + 1\n b[i-1][j-1] = \"d\" # up and to the right\n elsif c[i-1][j] >= c[i][j-1]\n c[i][j] = c[i-1][j]\n b[i-1][j-1] = \"u\" # up\n else\n c[i][j] = c[i][j-1]\n b[i-1][j-1] = \"l\" #left\n end\n end\n end\n #print_array(c)\n #print_array(b)\n return b,c\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def sluggish_octopus\n # O(N^2)\n longest_fish = \"\"\n Fishes.each do |fish1|\n Fishes.each do |fish2|\n longest_fish = fish2 if fish2.length > fish1.length\n end\n end\n longest_fish\nend", "def smallest_subarray(nums, s)\n min_length = Float::INFINITY\n\n start_position = 0\n end_position = 0\n\n sum = nums[start_position]\n\n while start_position < nums.length\n if sum < s\n end_position += 1\n break if end_position == nums.length\n\n sum += nums[end_position]\n elsif sum >= s\n size = nums[start_position..end_position].size\n min_length = [min_length, size].min\n sum -= nums[start_position]\n start_position += 1\n end\n end\n min_length\nend", "def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def countingValleys(n, s)\n valleys = 0\n pre = 0\n ac = 0\n for i in 0..n\n pre = ac\n ac += val(s[i]) \n valleys +=1 if pre == -1 && ac == 0\n end\n return valleys\nend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend", "def min_cut(s)\n palindrome = Array.new(s.size + 1).map { |x| \n Array.new(s.size + 1).map { |y|\n false\n }\n }\n\n dp = []\n 0.upto(s.size) { |i|\n dp[i] = i - 1\n }\n\n 2.upto(s.size).each { |i|\n (i - 1).downto(0).each { |j|\n if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1])\n palindrome[j][i] = true\n dp[i] = [dp[i], dp[j] + 1].min\n end\n }\n }\n\n return dp[s.size]\nend", "def longest_palindrome(s)\n string_hash = Hash.new(0)\n \n s.each_char do |char|\n string_hash[char] += 1\n end\n \n beginning_count = 0\n middle_count = 0\n \n string_hash.keys.each do |key|\n if string_hash[key] % 2 == 1\n middle_count = 1\n end\n \n beginning_count += string_hash[key] / 2\n end\n \n beginning_count * 2 + middle_count\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 shortest_palindrome_2(s)\n idx = 0\n front = \"\"\n back = \"\"\n (0...s.size).each { |i|\n front = front + s[i]\n back = s[i] + back\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend", "def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend", "def solution(s)\n size = 0\n s.each_char do |c|\n if c == \"(\"\n size += 1\n elsif c == \")\"\n size -= 1\n return 0 if size < 0\n end\n end\n return 0 if size > 0\n return 1\nend", "def uniq_subs(str)\n subs = Set.new\n str.length.times do |i|\n (i..str.length-1).each do |j|\n subs.add(str[i..j])\n end\n end\n subs\nend", "def num_distinct(s, t)\n len = t.size\n prefix = [1] + [0]*len # => [1, 0, 0, 0, 0, 0, 0] will happen\n s.chars.each do |char|\n len.downto(1) {|i| prefix[i]=prefix[i-1]+prefix[i] if t[i-1]==char}\n end\n p prefix\n prefix[-1]\nend", "def unique(s)\n (return true) if s.length <= 1\n rest = s[1..-1]\n rest.each do |i|\n (return false) if s[0] == i\n end\n return unique(rest)\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend", "def findLongestSubarrayBySum(s, arr)\n history = {0 => -1} \n sum = 0 \n max_length = 0 \n result = [-1]\n\n for idx in 0...arr.length \n sum += arr[idx]\n history[sum] = idx if history[sum].nil? \n\n if history[sum - s]\n length = idx - history[sum - s]\n if length > max_length \n max_length = length \n result = [history[sum - s]+2, idx+1]\n end \n end \n end \n\n result\nend", "def sluggish(fish)\n longest_fish = \"\"\n i = 0\n while i < fish.length\n j = i + 1\n while j < fish.length\n longest_fish = fish[j] if longest_fish.length <= fish[j].length\n j += 1\n end\n i += 1\n end\n longest_fish\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 scramble(s1,s2)\n s2.chars.uniq.all?{|i| s1.count(i) >= s2.count(i)} \nend", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def repeatedString(s, n)\n # First approach times out\n # s = s * ((n/s.length)+1)\n # p s[0..n-1].count('a')\n a_count = s.count('a')\n times_to_repeat = ((n/s.length))\n num_a_in_string = a_count * times_to_repeat\n leftover = (n%(s.length))\n num_a_in_string += s[0..leftover-1].count('a') if leftover >= 1\n p num_a_in_string\nend", "def is_subsequence(s, t)\n t_id = 0\n s_id = 0\n while t_id < t.length && s_id < s.length\n s_id += 1 if t[t_id] == s[s_id]\n t_id += 1\n end\n s_id == s.length\nend", "def solution(string) # \"ABCA\",\n # TIME O(N) + O(N) = O(2N) ~~ O(N)\n # SPACE O(N)\n\n array = string.split(\"\") # w[A B C A], O(N)\n array_exist = [] # [B C]\n array.each do |s| # O(N), N= 1000_000\n if array_exist.include?(s)\n array_exist.delete(s)\n else\n array_exist.push(s)\n end\n end\n array_exist[0]\nend", "def phase_iii(s1, s2)\n s1.chars.sort! == s2.chars.sort!\n\nend", "def is_sub?(s, t)\n i = j = 0\n while i < s.size && j < t.size\n i += 1 if s[i] == t[j]\n j += 1\n end\n i == s.size\nend", "def solve(s0, s1)\n # shift and push the first letter of the array length number of times\n # check if s0 == s1 each time\n return true if s0 == s1\n \n rotations = s0.length\n \n s0_arr = s0.split('')\n s1_arr = s1.split('')\n until s0_arr == s1_arr || rotations == 0\n s0_arr == s0_arr.push(s0_arr.shift)\n rotations -= 1\n return true if s0_arr == s1_arr\n end\n return false\nend", "def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend", "def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend", "def solve(s, t)\n if s.length != t.length\n return false\n end\n hash = Hash.new {|h, k, v| hash[k] = v}\n\n (0...s.length).each do |i|\n if !hash[s[i]] && !hash.values.include?(t[i])\n hash[s[i]] = t[i]\n elsif hash[s[i]] != t[i]\n return false\n end\n end\n true\nend", "def find_short(s)\n ar = (s.split).map { |k| k.size }.sort\n p ar[0]\n end", "def repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\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 longest_palindrome(s)\n result = ''\n \n for i in (0..s.length-1) do\n for j in (i..s.length-1) do \n result = s[i..j] if s[i..j].length > result.length && s[i..j] == s[i..j].reverse\n end\n end\n \n result\nend", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\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 f(s)\n uniq_char = s.chars.uniq.join('')\n # split_array = s.scan(uniq_char)\n # [split_array.length > 1 ? uniq_char : s,split_array.length]\nend", "def sluggish_octopus(fish)\n longest_fish = fish.first\n\n (0...fish.length).each do |start|\n (start...fish.length).each do |ending|\n if fish[ending].length > fish[start].length \n longest_fish = fish[ending]\n else\n longest_fish = fish[start]\n end\n end\n end\n\n longest_fish\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 luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend", "def jewels_and_stones(j,s)\n\n if (s == nil || s.length < 1 || j == nil || j.length < 1)\n return 0\n end\n\n hash = Hash.new\n\n j.each_char do |char|\n hash[char] = 1\n end\n\n count = 0\n s.each_char do |char|\n if (hash[s[char]] == 1)\n count = count + 1\n end\n end\n return count\n\nend", "def dnaSequence s\n hash, diff = Hash.new(0), Hash.new(0)\n diff[[0, 0, 0]] = 1\n\n sum = 0\n s.chars.each { |c|\n hash[c] += 1\n res = [hash['A'] - hash['C'], hash['C'] - hash['G'], hash['G'] - hash['T']]\n sum += diff[res]\n diff[res] += 1\n }\n sum\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(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 phase_ii(s1, s2)\n del_dex = []\n s1 = s1.chars\n s2 = s2.chars\n s1.each_with_index do |el, idx|\n if s2.include?(el)\n del_dex << idx\n s2.delete_at(s2.index(el))\n end\n end\n del_dex.each { |i| s1[i] = nil }\n return s1.select { |el| !el.nil? }.empty? && s2.empty?\nend", "def partition(s)\n palindrome = Array.new(s.size) {\n Array.new(s.size)\n }\n \n cuts = [[]]\n \n (0...s.size).each { |i|\n (0..i).each { |j|\n palindrome[j][i] = if i == j\n true\n elsif i == j + 1\n s[i] == s[j]\n else\n s[i] == s[j] && palindrome[j + 1][i - 1]\n end\n\n next if !palindrome[j][i] || cuts[j - 1].nil? && j > 1\n cuts[i] ||= []\n cuts[i] << cuts[j - 1].map { |x| x + [s[j..i]] }.flatten(1)\n }\n }\n \n puts \"#{cuts}\"\n cuts[s.size - 1]\nend", "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend", "def do_et offset, l, s, ww\n i = 0\n tt = []\n while i + l - 1 < s.length\n tt << s[i..i+l-1]\n i += l\n end\n o = []\n ttq = []\n wc = {}\n ww.each { |w| if wc.has_key? w then wc[w] += 1 else wc[w] = 1 end }\n zc = wc.length\n tt.each_with_index do |t, i|\n # expand\n ttq << [t, i * l + offset]\n if wc.has_key? t\n if wc[t] == 1\n zc -= 1\n elsif wc[t] == 0\n zc += 1\n end\n wc[t] -= 1\n end\n # contract\n if ttq.length > ww.length\n h, _ = ttq.delete_at 0\n if wc.has_key? h\n if wc[h] == -1\n zc -= 1\n elsif wc[h] == 0\n zc += 1\n end\n wc[h] += 1\n end\n end\n # check\n if zc == 0\n o << ttq.first[1]\n end\n end\n return o\nend", "def sum_pairs_v1 ints, s\n hash = {}\n index = []\n ints.each_with_index {|elem, i| hash[elem] = i }\n ints.each_with_index do |elem, i|\n if hash[s-elem] && hash[s-elem] != i\n hash[s-elem] > hash[elem] ? index << hash[s-elem] : index << hash[elem]\n end\n end\n\n return [s-ints[index.sort.first],ints[index.sort.first]] if index.any?\n nil\nend", "def longest_palindrome(s)\n return s if s.length == 1\n previous = s[0]\n\n all_same = true\n z = 0\n counter = 0\n while z < s.length\n if s[z] == previous\n counter += 1\n else\n tmp_longest = previous * counter\n longest = tmp_longest if tmp_longest.length > longest.length\n previous = s[z]\n counter = 1\n break if counter > s.length / 2\n end\n z += 1\n end\n return previous * counter if all_same || counter > s.length / 2\n\n longest = ''\n i = 0\n while i < s.length\n starting_letter = s[i]\n matching_hash = {}\n matching_hash[i] = starting_letter\n\n j = i + 1\n while j < s.length\n if s[j] == starting_letter\n matching_hash[j] = s[j]\n end\n j += 1\n end\n\n i += 1\n\n indices = matching_hash.keys\n next if indices.length == 1\n next if (indices[-1] - indices[0]) < longest.length\n\n first_index = matching_hash.first[0]\n\n k = 0\n valid_sequence = true\n while k < (indices.length / 2 - 1)\n first_dist = indices[k + 1] - indices[k]\n second_dist = indices[indices.length - 1 - k] - indices[indices.length - 2 - k]\n if first_dist != second_dist\n valid_sequence = false\n break\n end\n k += 1\n end\n\n next if !valid_sequence\n\n matching_hash.delete_if {|key,v| (key != first_index) && (key - first_index < longest.length)}\n indices = matching_hash.keys\n\n n = 1\n last_index = indices[-1]\n running_str = ''\n while first_index + n < ((last_index - first_index) / 2)\n matching_hash.each do |key, v|\n if key == first_index\n running_str = matching_hash[key] << s[key + n]\n else\n checking_str = matching_hash[key] << s[key - n]\n matching_hash.delete(key) if checking_str != running_str\n end\n end\n n +=1\n end\n\n matching_hash.values.each do |value|\n longest = value if value.length > longest.length\n end\n end\n puts \"longest: #{longest}\"\n return longest\nend", "def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend", "def 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 sluggish(array)\n i = 0\n longest_fish = \"\"\n while i < array.length\n n = 0\n while n < array.length\n if longest_fish.length < array[n].length\n longest_fish = array[n]\n end \n n+= 1\n end \n i += 1 \n end \n return longest_fish\nend", "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.length ? longest : current\n # binding.pry\n pair = hash.min_by{|k,v| v}\n hash.delete(pair[0])\n\n current = current[1..-1]\n else\n current += s\n end\n end\n end\n\n longest\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 - 1] + s[s.length/2] : s[s.length/2]\nend", "def solution(s)\n s = s.split ''\n return 'Empty String' if s.uniq.length == 1\n\n i = 1\n while i <= s.length\n if s[i - 1] == s[i]\n s.delete_at i - 1\n s.delete_at i - 1\n i = 0\n end\n i += 1\n end\n\n s.length <= 0 ? 'Empty String' : s.join\nend", "def solve(s)\n s.split(/[aeiou]/).map{ |x| x.sum - x.size * 96 }.max\nend", "def anagram(s)\n if s.length.even?\n substring1 = s[0..s.length/2 - 1].split('')\n substring2 = s[s.length/2..s.length-1].split('')\n i = 0\n while i <= substring1.length\n if substring2.index(substring1[i])\n char = substring1[i]\n substring1.delete_at(i)\n substring2.delete_at(substring2.index(char))\n else\n i += 1\n end\n end\n return substring1.count\n else\n return -1\n end\nend", "def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend", "def sluggish(fish)\n fish.each_with_index do |fish1, i1|\n max_length = true\n\n fish.each_with_index do |fish2, i2|\n next if i1 == i2\n max_length = false if fish2.length > fish1.length\n end\n\n return fish1 if max_length\n end\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 -1] + s[s.length/2] : s[s.length/2]\nend", "def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend", "def get_middle(s)\r\n s.length.odd? ? s[s.length / 2] : s[s.length / 2 - 1] + s[s.length / 2]\r\nend", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n ## first solution ##\n# a = \"\"\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n# upper = 2*n-1\n# n.times do |i|\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# end\n ## above solution too slow\n ## build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n used = Hash.new(0)\n remaining = letter_count.dup\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if used[c] < half_count[c]\n while (a[-1] && c < a[-1] && \n remaining[a[-1]] > half_count[a[-1]] - used[a[-1]])\n # pop out bigger characters as long as they are exclude eligible\"\n used[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n used[c]+=1\n end\n remaining[c]-=1\n end\n return a\nend", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def repeatedString(s, n)\n len = s.length\n times = n / len\n nb = times * s.count('a')\n\n last = s[0..(n % len)]\n nb += last.count('a') if len != 1\n nb\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 solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def num_jewels_in_stones(j, s)\n s.count(j)\nend", "def substrings_of_size(str, n)\n substrings = []\n 0.upto(str.size - n) do |index|\n substrings << str[index..(index + n - 1)]\n end\n \n substrings.uniq\nend", "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend" ]
[ "0.6571891", "0.6528862", "0.6498698", "0.6423003", "0.63339543", "0.6245319", "0.62393063", "0.6238905", "0.6227208", "0.6178182", "0.61751956", "0.6164928", "0.61367065", "0.6128542", "0.61255896", "0.6108107", "0.61034065", "0.6089596", "0.6083017", "0.60732836", "0.6072557", "0.60583985", "0.6058189", "0.60241044", "0.6020258", "0.60096747", "0.60035163", "0.5975395", "0.59567934", "0.5942737", "0.59422064", "0.59334385", "0.5927305", "0.59266573", "0.59262943", "0.59261096", "0.59129584", "0.591021", "0.59043914", "0.5901662", "0.5901073", "0.5896186", "0.58949375", "0.5892211", "0.5878413", "0.5875479", "0.58724886", "0.5871588", "0.58619", "0.58582836", "0.58477557", "0.58410513", "0.58401275", "0.58378416", "0.58317405", "0.58309716", "0.58270204", "0.5825627", "0.58164954", "0.5815306", "0.5813246", "0.58080965", "0.5806312", "0.5795616", "0.579319", "0.5785812", "0.57839024", "0.5783863", "0.5777374", "0.5760363", "0.57598436", "0.57596487", "0.57517606", "0.57511055", "0.57461643", "0.57420963", "0.5740115", "0.5734794", "0.5731962", "0.5728283", "0.57273465", "0.572453", "0.5721399", "0.5720761", "0.5713951", "0.5711685", "0.57073", "0.57036316", "0.5700339", "0.56948304", "0.56928843", "0.56910855", "0.5683449", "0.56665045", "0.56657434", "0.56629187", "0.5660158", "0.56562614", "0.56553584", "0.565365", "0.56511056" ]
0.0
-1
Time complexity: O(n) where n is the length of array Space complexity: O(n) where n is the length of array
def search(array, value) if array.empty? return false else if array[0] == value return true else array.shift return search(array, value) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_unsorted_subarray(nums)\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 equalizeArray(arr)\n arr = arr.sort\n count = 0; j = 0\n for i in 0..(arr.length-1)\n if arr[j] != arr[i]\n j += 1\n count+=1\n end\n end\n count\nend", "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 oddities(array)\n odd_element_array = []\n index = 0\n loop do\n break if index >= array.size\n odd_element_array << array[index] if index.even?\n index += 1\n end\n odd_element_array\nend", "def find_unique_elements(arr)\n \nend", "def long_subarrays(arr)\n res =[]\n window = arr.length\n while window>=1\n idx = 0\n while idx+window<=arr.length\n sub_arr = arr.slice(idx, window)\n p sub_arr\n res << sub_arr\n idx += 1\n end\n window -= 1\n end\n res.map{|el| el.inject(0){|acc, el2| acc+el2}}.sort.last\nend", "def length_finder(input_array)\n arr = []\n for i in 0...input_array.length\n arr << input_array[i].length\n end\n arr\nend", "def oddities(array)\n count = 0\n new_array = []\n loop do\n break if array.size == 0\n new_array << array[count]\n count += 2\n break if count >= array.size\n end\n new_array\nend", "def sort3(array, length)\n # O(k)\n length.times do |i|\n # clear hash\n hash = {}\n \n # O(n)\n array.each do |str|\n if hash[str[i]].nil?\n hash[str[i]] = [str]\n else\n hash[str[i]] += [str]\n end\n end\n\n array = []\n # O(n)\n hash.values.each do |val|\n array += val \n end\n end\n\n # overall time complexity O(kn)\n array\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)\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 # 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 oddities(arr)\n counter = 0\n return_array = []\n loop do\n return_array << arr[counter]\n counter += 2\n break if counter >= arr.size\n end\n return_array.compact\nend", "def sorted_squared_array_n_nlogn(values)\n values.collect!{|val| val*val}\n merge_sort(values)\nend", "def count(arr)\n count = 0\n arr_length_half = arr.length / 2\n\n arr_length_half.times do |i|\n if arr [i] > arr[- i - 1]\n count += arr[i]\n else\n count += arr[-i - 1]\n end\n end\n count\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 productify(array)\n len = array.length\n left = Array.new(len){1}\n right = Array.new(len){1}\n\n # step 1 create left array and right array O(n)\n array.each_index do |i|\n next if i == 0\n left[i] = left[i - 1] * array[i - 1]\n right[len - i - 1] = right[len - 1] * array[len - i]\n end\n\n # step 2 multiply products O(n)\n array.each_index do |i|\n array[i] = left[i] * right[i]\n end\n\n # step 3 return results\n array\n\n # time complexity O(n + n) => O(n)\nend", "def findlargestdrop(arr)\n\n\n\nend", "def magic_array(arr)\n arr.flatten.sort.uniq.map{|x| x*2}\nend", "def duplicates_subarray3(arr)\n arr.uniq.map { |elm| [elm] * arr.count(elm)}.sort_by {|subarr| subarr[0].ord }\nend", "def bad_contig_subsum(arr)\n # n! || n^3 ?\n sub_arrays = []\n arr.each_index do |i|\n (i...arr.length).each do |j|\n sub_arrays << arr[i..j]\n end\n end\n\n # above * n^2 ? << bottleneck\n max = sub_arrays.first.inject(&:+)\n sub_arrays.each do |sub_arr|\n sub_sum = sub_arr.inject(&:+)\n max = sub_sum if sub_sum > max\n end\n max\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend", "def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\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 oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend", "def mutateTheArray(n, a)\n prv = 0\n (0...a.size).each do |i|\n nxt = i < (a.size - 1) ? a[i+1] : 0\n tmp = a[i]\n a[i] += nxt + prv\n prv = tmp\n end\n a\nend", "def length_finder(array)\n iterator = 0\n new_array = []\n while iterator < array.length\n new_array << array[iterator].length\n iterator += 1\n end\n new_array\nend", "def my_min(array) # O(n) - Linear\n counter = array[0]\n\n (1...array.length).each do |i|\n if counter > array[i]\n counter = array[i]\n end\n end\n counter\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 evenities1(array)\n index = 1\n even_array = []\n while index < array.length\n even_array << array[index]\n index += 2\n end\n even_array\nend", "def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend", "def sum_of_sums_2(array)\n total_sum = 0\n i = 0\n len = array.size\n \n while i < len\n total_sum += array[0..i].inject { |sum, j| sum + j }\n i += 1\n end\n total_sum\nend", "def oddities(array)\n odd_values = []\n index = 0\n \n while index < array.size\n odd_values << array[index]\n index += 2\n end\n odd_values\nend", "def length_finder(array)\n num_array = []\n array.each do |i|\n num_array.insert(-1,i.length)\n end\n return num_array\nend", "def largest_contiguous_subsum(arr)\r\n all_sub_arrays = [] # space : O(n^2)\r\n\r\n (0...arr.length).each do |i|\r\n (i...arr.length).each do |i2|\r\n all_sub_arrays << arr[i..i2] # slice makes n^3\r\n end\r\n end\r\n\r\n all_sub_arrays.map { |sub_arr| sub_arr.sum }.max # O(n^2)\r\nend", "def eliminar_med_elem_arr(arreglo)\n index = arreglo.length / 2\n index -= 1 if arreglo.length.even?\n eliminar_elem_arr(arreglo, index)\n arreglo\nend", "def oddities(array)\n new_array = []\n i = 0\n while i < array.size\n new_array << array[i]\n i += 2\n end\n new_array\nend", "def solution(a)\n return 0 if a.uniq.size != a.size\n \n max = a.size \n sum = (1 + max) * max / 2\n \n array_sum = a.inject(0, &:+) \n sum == array_sum ? 1 : 0 \nend", "def find_sub(arr)\r\n sub_arrs = []\r\n (0...arr.size).each do |start_index|\r\n (1..arr.size - start_index). each do |length|\r\n sub_arrs << arr[start_index, length]\r\n end\r\n end\r\n sub_arrs\r\nend", "def find_unsorted_subarray(nums)\n l = nums.length\n r = 0\n\n nums.each_with_index do |_num, i|\n (i + 1..nums.count - 1).each do |j|\n if nums[j] < nums[i]\n r = j if j > r\n l = i if l > i\n end\n end\n end\n\n r - l < 0 ? 0 : r - l + 1\nend", "def largest_contiguous_subsum(arr)\n\n\nend", "def rearrange_array(array)\n # size of an array\n n = array.size\n # iterate \n (0...n).each do |iter|\n array[iter] = array[iter]+(array[array[iter]]%n)*n\n end\n p array, n\n (0...n).each do |iter|\n p array[iter]\n array[iter] = (array[iter]/n)\n end\n array\nend", "def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend", "def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\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 find_length(array)\n \n array.map {|elem| elem.length}\n \nend", "def DistinctList(arr)\n\n return arr.size - arr.uniq.size\n \nend", "def sorted_squared_array_n_n(values)\n len = values.size - 1 \n first_i = 0\n last_i = len\n output = Array.new(len+1) \n while(len > -1)\n if(values[first_i].abs > values[last_i].abs)\n output[len] = values[first_i] * values[first_i]\n first_i += 1\n else\n output[len] = values[last_i] * values[last_i]\n last_i -= 1\n end\n len -= 1\n end\n output\nend", "def fold_array(array, runs)\n #sets variables\n current = array\n results = []\n\n i=0\n #folds the array over n runs\n while i < runs\n results = []\n\n #folds current array into results\n j= 0\n\n while j < current.length/2\n #adds first from left and first from right, then second...third...n....\n #iterate j\n results[j] = current[j] + current[-(j+1)]\n j += 1\n end\n\n #if current[] is odd, append the middle element to results[]\n if (current.length.odd?)\n results << current[current.length/2]\n end\n\n #update current, iterate i\n current = results\n i += 1\n\n end\n\n return results\nend", "def arrayManipulation(arr)\n for i in 1..arr.size-1\n arr[i]=arr[i-1]+arr[i]\n end\n arr\nend", "def arrayChange(a)\n total = 0\n a.each_with_index do |v, i|\n next if i == 0 \n if(v <= a [i-1]) \n total += (a[i-1] + 1) - a[i]\n a[i] = a[i-1] + 1\n end\n end\n total\nend", "def map_to_no_change(source_array)\n array = []\n index = 0 \n \n while index < source_array.size do \n array.push(source_array[index])\n index += 1 \n end\n return array\nend", "def checkArray(a)\n\tn = a.length-1\n\tcount = 0\n\tfor i in 0..n do\n\t\tfor j in (i+1)..n do\n\t\t\tfor k in (j+1)..n do\n\t\t\t\tif (a[i] + a[j] + a[k] == 0)\n\t\t\t\t\tcount += 1\n\t\t\t\t\treturn count;\n\t\t\t\telse\n\t\t\t\t\treturn count;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend", "def equalizeArray(arr)\n hash = {}\n arr.sort.each { |h| hash.store(h, 0) }\n arr.each do |d|\n hash[d] = hash[d] + 1 if hash.key?(d)\n end\n max = 0\n hash.each { |_k, v| v > max ? max = v : max }\n\n arr.length - max\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 numUnique2(array)\n uniq_length = 0\n for i in 0...array.length\n if array[i+1] != array[i]\n uniq_length += 1\n end\n end\n return uniq_length\nend", "def non_oddities(arr)\n arr_length = arr.size\n index = 0\n even_elements = []\n\n loop do\n even_elements << arr[index] if index.odd?\n\n index += 1\n break if index > arr_length\n end\n even_elements.compact\nend", "def array_unique(array = [])\n raise 'incorrect array' unless array.is_a? Array\n\n uniq_values = []\n array.each do |el|\n unique_counter = 0\n array.each do |e|\n next if el != e\n\n unique_counter += 1\n end\n uniq_values << el if unique_counter == 1\n end\n uniq_values\nend", "def subs(array)\n holding_array = []\n index = 0\n until index > (array.size - 1)\n length = 1\n until length > array.size - index\n holding_array << array[index, length]\n length += 1\n end\n index += 1\n end\n holding_array\nend", "def oddities(array)\n new_array = []\n index_range = (1..array.size-1)\n for n in index_range do \n new_array << array[n] if n.odd?\n end\n new_array\nend", "def linear(arr)\n longest = arr.first\n\n arr.each do |ele|\n if ele.length > longest.length\n longest = ele\n end\n end\n\n longest\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 sub_sum(array)\n sums = []\n i = 0\n j = 0\n\n while i < array.length\n while j < array.length\n sums << array[i..j]\n j += 1\n end\n i += 1\n j = i\n end\n sums.sort_by{|x| x.reduce(:+)}.last.reduce(:+)\n end", "def solution(arr)\n arr.map do |i|\n arr_without_i = arr.select { |item| item != i }\n arr_without_i.reduce { |n, acc| acc *= n }\n end\nend", "def virus(array_input)\n new_array = [ ]\n number_of_loops = array_input.length\n index = array_input.length - 1\n\n number_of_loops.times do \n new_array << array_input[index]\n index = index - 1 \n end \n\n output = new_array\n return output\nend", "def remove_duplicates(array)\n array.uniq!.length\nend", "def lcts(array)\nend", "def largest_contiguous_subsum(arr) #BigO of O(n)\n max = 0 \n current_sum = 0\n arr.each_with_index do |el,idx|\n if current_sum + el >= el \n current_sum += el \n else \n current_sum = el \n end \n max = current_sum if current_sum > max \n end \n max\nend", "def clever_octopus(arr)\n i = 0\n j = arr.length-1\n\n max = arr[0]\n while i != j\n if arr[i].length < arr[j].length\n max = arr[j]\n i += 1\n elsif arr[j].length <= arr[i].length\n max = arr[i]\n j -= 1\n end\n end\n max \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 solution(arr)\n arr_size = arr.size\n\n arr.any? { |el| el > arr_size } || arr.uniq.size < arr_size ? 0 : 1\nend", "def largest_contiguous_subsum(array)\n sums_list = []\n sums = []\n\n idx1 = 0\n\n while idx1 < array.length #O(n)\n idx2 = idx1 #O(1)\n while idx2 < array.length #O(n)\n sums_list << array[idx1..idx2] #O(n)\n idx2 += 1\n end\n idx1 += 1\n end\n\n sums_list.each do |list| #O(n)\n sums << list.reduce {|sum, num| sum + num} #O(n)\n end\n sums.max\nend", "def get_length(arr)\n arr.flatten(2).count\nend", "def array_permutations(arr)\n return [arr] if arr.length <= 1\n removed = arr.last\n sliced_arr = arr.slice(0...-1)\n new_arrays = array_permutations(sliced_arr)\n res = []\n new_arrays.each{|new_array|res += insert_num(new_array, removed)}\n res\nend", "def find_unsorted_subarray(nums)\n sum = 0\n index = 0\n sorted = nums.sort\n while index < nums.length\n if nums[index] == sorted[index]\n sum += 1\n else\n break\n end\n index += 1\n end\n return 0 if sum == nums.length\n index = nums.length - 1\n while index >= 0\n if nums[index] == sorted[index]\n sum += 1\n else\n break\n end\n index -= 1\n end\n nums.length - sum\nend", "def sluggish_octopus(arr)\n lngest_fish = [arr.first]\n # debugger\n arr.each do |fish|\n # debugger\n lngest_fish = [fish] if fish.length > lngest_fish.first.length\n end\n lngest_fish\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 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 better_subsum(arr) # o(n)\n largest = 0 \n sum = 0 \n i = 0 \n j = 0\n\n while i != arr.length-1\n largest += arr[j]\n sum = largest if largest > sum \n if j == arr.length-1 \n i+=1 \n j = i \n largest = 0 \n else\n j+=1\n end \n end \n sum \n end", "def sort_array(array)\n n = array.size\n return array if n < 2\n (0..n - 2).each do |i|\n (i + 1..n - 1).each do |j|\n next if array[i].even? || array[j].even?\n interchange(array, i, j) if array[i] > array[j]\n end\n end\n array\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 subarray_bitwise_o_rs(a)\n result_set = Set.new()\n a.size.times do |i|\n (1..a.size-i).each do |length|\n subarray = a[i, length]\n #puts subarray.inspect\n result = subarray.reduce(0) do |bor, elem|\n bor | elem\n end\n #puts result\n result_set << result\n end\n end\n result_set.size\nend", "def oddities(array)\n odd_array = []\n array.each_with_index do |e, idx|\n odd_array << e if idx.even?\n end\n odd_array\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 magic_array(ma)\nma.flatten.sort.map{|n|n*2}.uniq.delete_if{|n|n%3==0}\nend", "def oddities(array)\n odd_array = []\n array.each_with_index { |e, idx| odd_array << e if idx.even? }\n odd_array\nend", "def arrayManipulation(n, queries)\n nums = Array.new(n+1, 0)\n queries.each do |query|\n nums[query[0]-1] += query[2]\n nums[query[1]] -= query[2]\n end\n\n max = nums.first\n (1..nums.length-1).each do |i|\n nums[i] += nums[i - 1]\n max = nums[i] if nums[i] > max && i < (nums.size - 1)\n end\n\n max\nend", "def length_finder(input_array)\n input_array.map { |elem| elem.size }\nend", "def oddities2(arr)\n index = 0\n result = []\n loop do\n break if index >= arr.size\n result << arr[index]\n index += 2\n end\n result\nend", "def largest_contiguous_sub_sum(arr)\n subarrs = [] #O(1)\n\n (0...arr.length).each do |idx| #O(n)\n (idx...arr.length).each do |jdx| #O(n/2)\n subarrs << arr[idx..jdx] #O(n)\n end\n end \n\n subarrs.map! do |array| #O(n)\n array.reduce(:+) #O(n)\n end \n\n subarrs.max #O(n)\nend", "def odd_index_values_from_array(array)\n index = 0\n odd_elements = []\n while index < array.size\n odd_elements << array.fetch(index) if index.even?\n index += 1\n end\n odd_elements\nend", "def max_sum_contiguous(a)\n # size of an array\n n = a.size\n sum_so_far = sum_end = 0\n (0..n-1).each do |i|\n sum_end += a[i]\n sum_so_far = sum_end if sum_so_far < sum_end \n sum_end = 0 if sum_end < 0 \n end\n sum_so_far\nend", "def length_of_array(array)\n array.length\nend", "def change_resistant_for_each_element(array)\n copy =Array.new(array)\n i=0\n while i<copy.length\n copy[i]=array[i]\n i +=1\n end\n copy\nend", "def remove_duplicates(array)\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 oddities(array)\n result = []\n count = 0\n array.each do |element|\n result << element if count.even?\n count += 1\n end\n result\nend", "def virus(input_array)\n i = input_array.length-1 \n new_array = []\n\n input_array.length.times do \n new_array << input_array[i]\n i -= 1\n end \n return new_array\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 length_of_array(array)\n return array.length\nend" ]
[ "0.6641892", "0.66078013", "0.65390205", "0.6517989", "0.6493659", "0.6489011", "0.6447308", "0.63804346", "0.63631356", "0.6342481", "0.63209987", "0.6295135", "0.62942654", "0.6271129", "0.6267671", "0.6253584", "0.62472445", "0.62369305", "0.6217616", "0.62063706", "0.6205121", "0.62026453", "0.6200436", "0.6200378", "0.61896485", "0.617515", "0.6158721", "0.6144749", "0.614319", "0.6141638", "0.61389893", "0.6124543", "0.6122459", "0.6117957", "0.6111101", "0.61087954", "0.6095635", "0.6092662", "0.608916", "0.60818875", "0.6081749", "0.6077955", "0.60723406", "0.60702544", "0.6068456", "0.6059909", "0.6043939", "0.6041187", "0.60411686", "0.6024435", "0.60188836", "0.6018518", "0.6014121", "0.6004933", "0.6003189", "0.5998966", "0.59980047", "0.59973156", "0.5996877", "0.59950674", "0.59923726", "0.59922034", "0.59915555", "0.5991509", "0.5986855", "0.5986387", "0.59835404", "0.5982889", "0.5981989", "0.5978943", "0.5978401", "0.5974218", "0.5971188", "0.5956422", "0.5953322", "0.59506786", "0.5947632", "0.59475446", "0.5946025", "0.59458005", "0.59452885", "0.59437925", "0.5937836", "0.5935068", "0.59342474", "0.59299904", "0.59256065", "0.59245485", "0.592367", "0.5917331", "0.5916255", "0.5913787", "0.5911179", "0.5910886", "0.5910721", "0.5908496", "0.59069645", "0.59045756", "0.5901505", "0.5894656", "0.5880633" ]
0.0
-1
Time complexity: O(n) where n is the length of s Space complexity: O(n) where n is the length of s
def is_palindrome(s) if s.length == 0 return true else if s[0] == s[-1] return is_palindrome(s[1..-2]) else return false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isSymmetricBySpace(s, i) \n return false if i==0\n c=0\n for d in 0..i\n return c==i if i-1-d<0||i+d>=s.length\n return false if s[i+d]!=s[i-1-d]\n c+=1 if s[i+d]==s[i-1-d]\n end\n return false\nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n if pi == 0\n sizes << size\n next \n end\n\n substrings = [s_chars[0..pi]]\n\n while !substrings.empty? do\n sub = substrings.pop\n\n sequence = to_sequence(sub) # X\n\n # for every sequence, N-1 must exists and we only check if we can add the last bit\n pos = graph\n sequence[0..-2].each do |bit|\n pos = pos[bit]\n end\n \n next unless pos[sequence.last].nil?\n\n pos[sequence.last] = {}\n size += 1\n\n substrings << sub[1..-1] \n end\n\n sizes << size\n end\n\n sizes\nend", "def solution(s)\n if s.length.odd?\n center = s.length / 2\n if s[0...center] == s[center + 1..s.length].reverse\n return center \n end\n end\n -1\nend", "def f(str)\n 1.upto(str.size / 2) do |idx|\n number_of_subs = str.size / idx\n if str[0...idx] * number_of_subs == str\n return [str[0...idx], number_of_subs]\n end\n end\n [str, 1]\nend", "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def solve(s, n)\n answer = []\n \n while s.length > 0\n answer.push(s[0...n])\n s[0...n] = ''\n end\n return answer\nend", "def pseudoIsomorphicSubstrings(s)\n \n # Generate prefixs S'\n prefixs = []\n (s.size).times.each do |i|\n prefixs << s[0..i]\n end\n puts prefixs\n\n # For every i,j where i < j, the substrings of Si' (Sbi), are a subset of Sbj\n # and Sbj - Sbi are the substring that includes the last char of Sj'\n subsets = prefixs.map do |prefix|\n s = []\n\n (prefix.size).times.each do |i|\n s << prefix[i..-1]\n end\n \n s\n end\n puts subsets\n\n # Transform the substring to a sequence of numbers to compare values\n subsets.each do |subs|\n subs.map! { |sub| to_sequence(sub) }\n end\n puts subsets\n\n # For every i,j, such that 0 <= i < j, and a function ISO that generate\n # a set such that no two strings inside S' are pseudo-isomorphic to each other,\n # SUM(ISO(Si')) < ISO(Sj')\n puts \"=\"*50\n isosets = []\n subsets.each_with_index do |subs, i|\n if i == 0\n isosets << Set.new(subs)\n next\n end\n\n isosets << Set.new(subs).merge(isosets[i - 1])\n end\n puts isosets\n\n # Get sizes\n isosets.map { |iso| iso.size } \nend", "def pseudoIsomorphicSubstrings(s)\n\n size = 1 # this show the current size of the set i\n graph = { 0 => {} } # representation of the set sequences\n sizes = []\n\n string_size = s.size\n matrix = []\n\n s_chars = s.chars\n \n s.size.times do |pi| # Si' : Prefix i\n matrix << []\n\n i = 0\n while i <= pi do\n matrix[pi] << s_chars[i..pi].join.ljust(string_size)\n i += 1\n end\n\n matrix[pi] = matrix[pi].join(' | ')\n end\n\n puts matrix\n\n sizes\nend", "def lps(s)\n return \"\" if s.empty?\n longest = [0,0]\n s.chars.each_with_index do |ch, idx|\n for i,j in [[idx, idx + 1], [idx, idx]]\n until s[i] != s[j]\n break if i < 0 || j >= s.length\n longest = [i,j] if longest[1] - longest[0] < j - i\n i -= 1\n j += 1\n end\n end\n end\n s[longest[0]..longest[1]]\nend", "def solve(s)\n answer = \"\"\n (0...s.length - 1).each do |idx|\n if s[idx] != s[idx + 1]\n answer += s[idx]\n end\n if idx == s.length - 2 && s[idx] == s[idx + 1]\n answer += s[idx]\n end\n end\n return answer\nend", "def encode_direct(list, s = 0)\n if s >= list.length then return [] end\n\n i = s\n while i < list.length && (i == s || list[i] == list[i-1])\n i += 1\n end\n n = i - s\n\n [(n > 0 ? [n, list[s]] : list[s])] + encode_direct(list, i)\nend", "def is s, d, done, i\n return 0, [] if i == s.length\n return done[i] if !!done[i]\n cuc, cs = is s, d, done, i + 1\n muc = 1 + cuc\n msplit = cs\n d.each do |w|\n if w == s[i...i + w.length]\n cuc, cs = is s, d, done, i + w.length\n if cuc < muc\n muc = cuc\n msplit = [i - 1, i + w.length - 1] + cs\n end\n end\n end\n done[i] = [muc, msplit]\n return [muc, msplit]\nend", "def calc_d(s, r)\n n = s.size\n d = []\n n.times do |i|\n if i == 0\n d << 0\n else\n d_i = d[i-1] + s[i-1] - r[i]\n d_i = 0 if d_i <= 0\n d << d_i\n end\n end\n d\n\tend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\nend", "def n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend", "def nsrch(s,g)\n orig_s = s\n ss = s.to_s 2\n gs = g.to_s 2\n ops = []\n bits = gs.split(//)\n i = 0\n # Go through all bits of g.\n # If there are ones in the trailing part of ss, we\n # must get rid of them (Otherwise: 1001 -> 100, all digits match,\n # jump out of loop, make length equal by >>. Oops, it was an odd\n # number we just halved. So must check for ones.)\n while i < bits.size or ss[bits.size..-1].include? ?1\n b = bits[i]\n op = nil\n n = 0\n while ss[i,1] != b\n # Add zeroes to right to make length right and\n # to get the rightmost bit into an editable state.\n if ss.size < i+2 or s[0] == 1\n op = :*\n # Delete zeroes from right to make length right.\n elsif ss.size > i+2 and (s[0] == 0 and s[1] == 0)\n op = :/\n # Add 2 if length is ok and there are no zeroes to take out.\n # We are here because the second right-most bit is wrong.\n # Adding 2 flips it. It may also flip every bit we've just\n # went through, invalidating the invariant and thus we reset\n # the bit counter.\n else\n op = :+\n i = 0\n end\n ops << op\n s = case op\n when :+\n s + 2\n when :*\n s << 1\n when :/\n s >> 1\n end\n ss = s.to_s 2\n break if op == :+ # invariant may be bad,\n # must check before continuing\n end\n i += 1 unless op == :+\n end\n # take out extra zeroes on right\n r = s >> (ss.size-gs.size)\n ops.push *[:/]*(ss.size-gs.size)\n # and collect middle states using done ops\n a = [orig_s]\n ops.each{|op|\n a << case op\n when :*\n a.last * 2\n when :/\n a.last / 2\n when :+\n a.last + 2\n end\n }\n a\nend", "def subset(n, s)\n h = {}\n 1.upto(n) do |len|\n s.combination(len) do |a|\n sum = a.inject(0,:+)\n if h.key?(sum)\n u = h[sum].join(\" \")\n v = a.join(\" \")\n return \"#{u}\\n#{v}\"\n else\n h[sum] = a\n end\n end\n end\n return \"Impossible\"\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 longest_palindrome_subseq(s)\n length = s.size\n dp = []\n\n length.times do |i|\n dp[i]= Array.new(length).fill(0);\n dp[i][i] = 1\n end\n puts \"dp #{dp}\"\n (2..length).each do |len|\n puts \"len #{len}\"\n (0..(length - len)).each do |i|\n j = i + len - 1\n # puts \"j #{j} => i:#{i} + len:#{len} - 1\"\n\n if s[i] == s[j]\n dp[i][j] = 2 + (len == 2 ? 0 : dp[i+1][j-1])\n else\n dp[i][j] = [dp[i+1][j], dp[i][j-1]].max\n end\n puts \"dp #{dp}\"\n end\n end\n\n dp[0][length - 1]\nend", "def lcs_length(s1, s2)\n m = s1.size\n n = s2.size\n b = Array.new(m){Array.new(n)}\n # init everyting to zero\n c = Array.new(m+1) { Array.new(n+1, 0)}\n (1..m).each do |i|\n (1..n).each do |j|\n #puts(\"i: #{i}, j: #{j} s1_i:#{s1[i]} s2_j:#{s2[j]}\")\n #print_array(c)\n # 0 indexed on the string, so have to subtract 1 when looking at it\n if (s1[i-1] == s2[j-1]) then\n c[i][j] = c[i-1][j-1] + 1\n b[i-1][j-1] = \"d\" # up and to the right\n elsif c[i-1][j] >= c[i][j-1]\n c[i][j] = c[i-1][j]\n b[i-1][j-1] = \"u\" # up\n else\n c[i][j] = c[i][j-1]\n b[i-1][j-1] = \"l\" #left\n end\n end\n end\n #print_array(c)\n #print_array(b)\n return b,c\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def smallest_subarray(nums, s)\n min_length = Float::INFINITY\n\n start_position = 0\n end_position = 0\n\n sum = nums[start_position]\n\n while start_position < nums.length\n if sum < s\n end_position += 1\n break if end_position == nums.length\n\n sum += nums[end_position]\n elsif sum >= s\n size = nums[start_position..end_position].size\n min_length = [min_length, size].min\n sum -= nums[start_position]\n start_position += 1\n end\n end\n min_length\nend", "def sluggish_octopus\n # O(N^2)\n longest_fish = \"\"\n Fishes.each do |fish1|\n Fishes.each do |fish2|\n longest_fish = fish2 if fish2.length > fish1.length\n end\n end\n longest_fish\nend", "def repeatedString(s, n)\r\n # Write your code here\r\n numOfA = 0\r\n index = 0\r\n \r\n if s.length == 1 && s[0] == 'a'\r\n return n\r\n elsif s.length == 1 && s[0] != 'a'\r\n return 0\r\n \r\n else\r\n firstRoundUpperLimit = n < s.length ? n : s.length\r\n \r\n for i in 0 ... firstRoundUpperLimit\r\n if s[i] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n\r\n if (numOfA > 0 && n > s.length) \r\n repeatingOccurrences = (n / s.length) - 1\r\n remainingOccurrences = n % s.length\r\n\r\n\r\n\r\n numOfA = numOfA + (numOfA * repeatingOccurrences)\r\n\r\n for j in 0 ... remainingOccurrences\r\n if s[j] === 'a'\r\n numOfA = numOfA + 1\r\n end\r\n end\r\n end\r\n\r\n \r\n end\r\n return numOfA\r\nend", "def sherlock(str)\n str_len = str.length\n str_arr = str.split('')\n substrings_count = {}\n result = 0\n str_arr.each_with_index do |alpha, index|\n n = str_len - index\n n.times do |pos|\n ss = str_arr[index..(index+pos)].sort.join('')\n substrings_count[ss] = substrings_count[ss] ? substrings_count[ss]+1 : 1\n end\n end\n\n substrings_count.each do |key, val|\n result = result + ((val*(val-1))/2) if val > 1\n end\n result\nend", "def countingValleys(n, s)\n valleys = 0\n pre = 0\n ac = 0\n for i in 0..n\n pre = ac\n ac += val(s[i]) \n valleys +=1 if pre == -1 && ac == 0\n end\n return valleys\nend", "def s2(n)\n n*(n+1)*(2*n+1)/6\nend", "def repeatedString(s, n)\n char_array = s.split('')\n count_of_a_in_string = 0\n char_array.each do |letter|\n if letter == \"a\"\n count_of_a_in_string += 1\n end\n end\n\n factor = n/s.length()\n reminder = n % s.length()\n count_of_a_in_final_string = factor * count_of_a_in_string\n\n reminder.times do |index|\n count_of_a_in_final_string += 1 unless s[index] != \"a\"\n end\n count_of_a_in_final_string\nend", "def min_cut(s)\n palindrome = Array.new(s.size + 1).map { |x| \n Array.new(s.size + 1).map { |y|\n false\n }\n }\n\n dp = []\n 0.upto(s.size) { |i|\n dp[i] = i - 1\n }\n\n 2.upto(s.size).each { |i|\n (i - 1).downto(0).each { |j|\n if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1])\n palindrome[j][i] = true\n dp[i] = [dp[i], dp[j] + 1].min\n end\n }\n }\n\n return dp[s.size]\nend", "def longest_palindrome(s)\n string_hash = Hash.new(0)\n \n s.each_char do |char|\n string_hash[char] += 1\n end\n \n beginning_count = 0\n middle_count = 0\n \n string_hash.keys.each do |key|\n if string_hash[key] % 2 == 1\n middle_count = 1\n end\n \n beginning_count += string_hash[key] / 2\n end\n \n beginning_count * 2 + middle_count\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 shortest_palindrome_2(s)\n idx = 0\n front = \"\"\n back = \"\"\n (0...s.size).each { |i|\n front = front + s[i]\n back = s[i] + back\n idx = [idx, i].max if front == back\n }\n\n (s[idx + 1..-1] || \"\").reverse + s\nend", "def solution(s)\n size = 0\n s.each_char do |c|\n if c == \"(\"\n size += 1\n elsif c == \")\"\n size -= 1\n return 0 if size < 0\n end\n end\n return 0 if size > 0\n return 1\nend", "def repeatedString(s, n)\n count = s.count(\"a\")\n rep = (n / s.length)\n if n % s.length != 0\n short_s = s.slice(0, n % s.length)\n return (count * rep) + short_s.count(\"a\")\n else\n return (count * rep)\n end\n \nend", "def uniq_subs(str)\n subs = Set.new\n str.length.times do |i|\n (i..str.length-1).each do |j|\n subs.add(str[i..j])\n end\n end\n subs\nend", "def num_distinct(s, t)\n len = t.size\n prefix = [1] + [0]*len # => [1, 0, 0, 0, 0, 0, 0] will happen\n s.chars.each do |char|\n len.downto(1) {|i| prefix[i]=prefix[i-1]+prefix[i] if t[i-1]==char}\n end\n p prefix\n prefix[-1]\nend", "def unique(s)\n (return true) if s.length <= 1\n rest = s[1..-1]\n rest.each do |i|\n (return false) if s[0] == i\n end\n return unique(rest)\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n else\n a\nend\n tmp.push o\n end\n (0...p.length).each do |k|\n o = tmp[q[k] + 1] - tmp[p[k]]\n if o >= a\n res.push 1\n elsif o >= c\n res.push 2\n elsif o >= g\n res.push 3\n else\n res.push 4\n end\n end\n res\nend", "def findLongestSubarrayBySum(s, arr)\n history = {0 => -1} \n sum = 0 \n max_length = 0 \n result = [-1]\n\n for idx in 0...arr.length \n sum += arr[idx]\n history[sum] = idx if history[sum].nil? \n\n if history[sum - s]\n length = idx - history[sum - s]\n if length > max_length \n max_length = length \n result = [history[sum - s]+2, idx+1]\n end \n end \n end \n\n result\nend", "def sluggish(fish)\n longest_fish = \"\"\n i = 0\n while i < fish.length\n j = i + 1\n while j < fish.length\n longest_fish = fish[j] if longest_fish.length <= fish[j].length\n j += 1\n end\n i += 1\n end\n longest_fish\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 scramble(s1,s2)\n s2.chars.uniq.all?{|i| s1.count(i) >= s2.count(i)} \nend", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def repeatedString(s, n)\n # First approach times out\n # s = s * ((n/s.length)+1)\n # p s[0..n-1].count('a')\n a_count = s.count('a')\n times_to_repeat = ((n/s.length))\n num_a_in_string = a_count * times_to_repeat\n leftover = (n%(s.length))\n num_a_in_string += s[0..leftover-1].count('a') if leftover >= 1\n p num_a_in_string\nend", "def is_subsequence(s, t)\n t_id = 0\n s_id = 0\n while t_id < t.length && s_id < s.length\n s_id += 1 if t[t_id] == s[s_id]\n t_id += 1\n end\n s_id == s.length\nend", "def solution(string) # \"ABCA\",\n # TIME O(N) + O(N) = O(2N) ~~ O(N)\n # SPACE O(N)\n\n array = string.split(\"\") # w[A B C A], O(N)\n array_exist = [] # [B C]\n array.each do |s| # O(N), N= 1000_000\n if array_exist.include?(s)\n array_exist.delete(s)\n else\n array_exist.push(s)\n end\n end\n array_exist[0]\nend", "def phase_iii(s1, s2)\n s1.chars.sort! == s2.chars.sort!\n\nend", "def is_sub?(s, t)\n i = j = 0\n while i < s.size && j < t.size\n i += 1 if s[i] == t[j]\n j += 1\n end\n i == s.size\nend", "def solve(s0, s1)\n # shift and push the first letter of the array length number of times\n # check if s0 == s1 each time\n return true if s0 == s1\n \n rotations = s0.length\n \n s0_arr = s0.split('')\n s1_arr = s1.split('')\n until s0_arr == s1_arr || rotations == 0\n s0_arr == s0_arr.push(s0_arr.shift)\n rotations -= 1\n return true if s0_arr == s1_arr\n end\n return false\nend", "def repeatedString(s, n)\n s.count('a') * (n / s.size) + s[0, n % s.size].count('a')\nend", "def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n remainder = n % length\n\n count_a(s) * repeat_count + count_a(s[0...remainder])\nend", "def solve(s, t)\n if s.length != t.length\n return false\n end\n hash = Hash.new {|h, k, v| hash[k] = v}\n\n (0...s.length).each do |i|\n if !hash[s[i]] && !hash.values.include?(t[i])\n hash[s[i]] = t[i]\n elsif hash[s[i]] != t[i]\n return false\n end\n end\n true\nend", "def find_short(s)\n ar = (s.split).map { |k| k.size }.sort\n p ar[0]\n end", "def repeatedString(s, n)\n num_a = s.count(\"a\")\n if num_a == 0\n return 0\n end\n slen = s.length\n total = num_a*(n/slen)\n total += s[0...n%slen].count(\"a\")\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 longest_palindrome(s)\n result = ''\n \n for i in (0..s.length-1) do\n for j in (i..s.length-1) do \n result = s[i..j] if s[i..j].length > result.length && s[i..j] == s[i..j].reverse\n end\n end\n \n result\nend", "def step_through_with(s)i\n # It doesn't solve the kata because it returns true even if same chars are met in diffrent part of the word. Like \"ThaT\"\n s.chars.count == s.chars.uniq.count\nend", "def shortest_nonshared_substrings s1, s2\n i = 1\n distinct = Set.new\n while i < [s1.length, s2.length].min and distinct.empty?\n distinct = distinct_kmers(i, s1, s2)\n i += 1\n end\n distinct\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 f(s)\n uniq_char = s.chars.uniq.join('')\n # split_array = s.scan(uniq_char)\n # [split_array.length > 1 ? uniq_char : s,split_array.length]\nend", "def sluggish_octopus(fish)\n longest_fish = fish.first\n\n (0...fish.length).each do |start|\n (start...fish.length).each do |ending|\n if fish[ending].length > fish[start].length \n longest_fish = fish[ending]\n else\n longest_fish = fish[start]\n end\n end\n end\n\n longest_fish\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 luhns(a)\n\tb = a.to_s[0..-2].reverse.split(\"\").to_a.map{|v|v.to_i}\n\t(b.each_index{|i|i.even? ? b[i]=b[i]*2>9?b[i]*2-9:b[i]*2:i=i}.inject(:+)+a)%10==0\nend", "def jewels_and_stones(j,s)\n\n if (s == nil || s.length < 1 || j == nil || j.length < 1)\n return 0\n end\n\n hash = Hash.new\n\n j.each_char do |char|\n hash[char] = 1\n end\n\n count = 0\n s.each_char do |char|\n if (hash[s[char]] == 1)\n count = count + 1\n end\n end\n return count\n\nend", "def dnaSequence s\n hash, diff = Hash.new(0), Hash.new(0)\n diff[[0, 0, 0]] = 1\n\n sum = 0\n s.chars.each { |c|\n hash[c] += 1\n res = [hash['A'] - hash['C'], hash['C'] - hash['G'], hash['G'] - hash['T']]\n sum += diff[res]\n diff[res] += 1\n }\n sum\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(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 phase_ii(s1, s2)\n del_dex = []\n s1 = s1.chars\n s2 = s2.chars\n s1.each_with_index do |el, idx|\n if s2.include?(el)\n del_dex << idx\n s2.delete_at(s2.index(el))\n end\n end\n del_dex.each { |i| s1[i] = nil }\n return s1.select { |el| !el.nil? }.empty? && s2.empty?\nend", "def partition(s)\n palindrome = Array.new(s.size) {\n Array.new(s.size)\n }\n \n cuts = [[]]\n \n (0...s.size).each { |i|\n (0..i).each { |j|\n palindrome[j][i] = if i == j\n true\n elsif i == j + 1\n s[i] == s[j]\n else\n s[i] == s[j] && palindrome[j + 1][i - 1]\n end\n\n next if !palindrome[j][i] || cuts[j - 1].nil? && j > 1\n cuts[i] ||= []\n cuts[i] << cuts[j - 1].map { |x| x + [s[j..i]] }.flatten(1)\n }\n }\n \n puts \"#{cuts}\"\n cuts[s.size - 1]\nend", "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_table[j[i]] != nil\n count = count + hash_table[j[i]]\n hash_table[j[i]] = nil\n else\n fail (\"Letters in J are not distinct\")\n end\n end\n end\n\n return count\nend", "def do_et offset, l, s, ww\n i = 0\n tt = []\n while i + l - 1 < s.length\n tt << s[i..i+l-1]\n i += l\n end\n o = []\n ttq = []\n wc = {}\n ww.each { |w| if wc.has_key? w then wc[w] += 1 else wc[w] = 1 end }\n zc = wc.length\n tt.each_with_index do |t, i|\n # expand\n ttq << [t, i * l + offset]\n if wc.has_key? t\n if wc[t] == 1\n zc -= 1\n elsif wc[t] == 0\n zc += 1\n end\n wc[t] -= 1\n end\n # contract\n if ttq.length > ww.length\n h, _ = ttq.delete_at 0\n if wc.has_key? h\n if wc[h] == -1\n zc -= 1\n elsif wc[h] == 0\n zc += 1\n end\n wc[h] += 1\n end\n end\n # check\n if zc == 0\n o << ttq.first[1]\n end\n end\n return o\nend", "def sum_pairs_v1 ints, s\n hash = {}\n index = []\n ints.each_with_index {|elem, i| hash[elem] = i }\n ints.each_with_index do |elem, i|\n if hash[s-elem] && hash[s-elem] != i\n hash[s-elem] > hash[elem] ? index << hash[s-elem] : index << hash[elem]\n end\n end\n\n return [s-ints[index.sort.first],ints[index.sort.first]] if index.any?\n nil\nend", "def longest_palindrome(s)\n return s if s.length == 1\n previous = s[0]\n\n all_same = true\n z = 0\n counter = 0\n while z < s.length\n if s[z] == previous\n counter += 1\n else\n tmp_longest = previous * counter\n longest = tmp_longest if tmp_longest.length > longest.length\n previous = s[z]\n counter = 1\n break if counter > s.length / 2\n end\n z += 1\n end\n return previous * counter if all_same || counter > s.length / 2\n\n longest = ''\n i = 0\n while i < s.length\n starting_letter = s[i]\n matching_hash = {}\n matching_hash[i] = starting_letter\n\n j = i + 1\n while j < s.length\n if s[j] == starting_letter\n matching_hash[j] = s[j]\n end\n j += 1\n end\n\n i += 1\n\n indices = matching_hash.keys\n next if indices.length == 1\n next if (indices[-1] - indices[0]) < longest.length\n\n first_index = matching_hash.first[0]\n\n k = 0\n valid_sequence = true\n while k < (indices.length / 2 - 1)\n first_dist = indices[k + 1] - indices[k]\n second_dist = indices[indices.length - 1 - k] - indices[indices.length - 2 - k]\n if first_dist != second_dist\n valid_sequence = false\n break\n end\n k += 1\n end\n\n next if !valid_sequence\n\n matching_hash.delete_if {|key,v| (key != first_index) && (key - first_index < longest.length)}\n indices = matching_hash.keys\n\n n = 1\n last_index = indices[-1]\n running_str = ''\n while first_index + n < ((last_index - first_index) / 2)\n matching_hash.each do |key, v|\n if key == first_index\n running_str = matching_hash[key] << s[key + n]\n else\n checking_str = matching_hash[key] << s[key - n]\n matching_hash.delete(key) if checking_str != running_str\n end\n end\n n +=1\n end\n\n matching_hash.values.each do |value|\n longest = value if value.length > longest.length\n end\n end\n puts \"longest: #{longest}\"\n return longest\nend", "def permut_sub_strings(b, s)\n hash = {}\n permutations(s).each do |str|\n hash[str] = true\n end\n for i in 0..b.size-s.size\n if (hash.key?(b[i..i+s.size]))\n return true\n end\n end\nend", "def 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 sluggish(array)\n i = 0\n longest_fish = \"\"\n while i < array.length\n n = 0\n while n < array.length\n if longest_fish.length < array[n].length\n longest_fish = array[n]\n end \n n+= 1\n end \n i += 1 \n end \n return longest_fish\nend", "def longest_substring_which_contains_two_unique_characters(string)\n longest = ''\n current = ''\n hash = Hash.new(0)\n\n string.split('').each do |s|\n current += s\n\n if hash[s] > 0\n hash[s] += 1\n else\n hash[s] += 1\n if hash.size > 2\n longest = longest.length > current.length ? longest : current\n # binding.pry\n pair = hash.min_by{|k,v| v}\n hash.delete(pair[0])\n\n current = current[1..-1]\n else\n current += s\n end\n end\n end\n\n longest\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 - 1] + s[s.length/2] : s[s.length/2]\nend", "def solution(s)\n s = s.split ''\n return 'Empty String' if s.uniq.length == 1\n\n i = 1\n while i <= s.length\n if s[i - 1] == s[i]\n s.delete_at i - 1\n s.delete_at i - 1\n i = 0\n end\n i += 1\n end\n\n s.length <= 0 ? 'Empty String' : s.join\nend", "def solve(s)\n s.split(/[aeiou]/).map{ |x| x.sum - x.size * 96 }.max\nend", "def anagram(s)\n if s.length.even?\n substring1 = s[0..s.length/2 - 1].split('')\n substring2 = s[s.length/2..s.length-1].split('')\n i = 0\n while i <= substring1.length\n if substring2.index(substring1[i])\n char = substring1[i]\n substring1.delete_at(i)\n substring2.delete_at(substring2.index(char))\n else\n i += 1\n end\n end\n return substring1.count\n else\n return -1\n end\nend", "def solution(n)\n\t(1..n).map(&:to_s).map(&:chars).join.chars.map(&:to_i).reduce(:+)\nend", "def sluggish(fish)\n fish.each_with_index do |fish1, i1|\n max_length = true\n\n fish.each_with_index do |fish2, i2|\n next if i1 == i2\n max_length = false if fish2.length > fish1.length\n end\n\n return fish1 if max_length\n end\nend", "def get_middle(s)\n s.length.even? ? s[s.length/2 -1] + s[s.length/2] : s[s.length/2]\nend", "def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def repeatedString(s, n)\n s.count('a') * n.div(s.size) + s.slice(0,n.remainder(s.size)).count('a')\nend", "def solution(s, p, q)\r\n # write your code in Ruby 2.2\r\n # A -1\r\n # C -2\r\n # G -3\r\n # T -4\r\n # s - string with n charactekrs\r\n #cagccta\r\n #0123345\r\n #p,q - not empty arrays\r\n #\r\n #p[0]=2 q[0]=4 gcc 322 => 2\r\n #p[1]=5 q[1]=5 t 4 => 4\r\n \r\n \r\n arr = Array.new(q.count)\r\n \r\n \r\n\r\n \r\n arr.each_with_index{|el, i|\r\n \r\n ss = s[p[i]..q[i]]\r\n \r\n if ss.index('A') \r\n n = 1\r\n elsif ss.index('C')\r\n n=2\r\n elsif ss.index('G')\r\n n=3\r\n else \r\n n=4\r\n end\r\n \r\n arr[i] = n\r\n \r\n }\r\n \r\n \r\n \r\n arr\r\n \r\nend", "def get_middle(s)\r\n s.length.odd? ? s[s.length / 2] : s[s.length / 2 - 1] + s[s.length / 2]\r\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def num_decodings(s)\n return 0 if !s || s == '0'\n return 1 if s.size == 1\n dp = [0] * (s.size + 1)\n dp[0] = 1\n dp[1] = s[0] == '0' ? 0 : 1\n\n for i in 2..s.size do \n char = s[i - 1].to_i\n chars = s[(i - 2)..(i - 1)].to_i\n\n if char >= 1 && char <= 9\n dp[i] += dp[i - 1]\n end\n\n if chars >= 10 && chars <= 26\n dp[i] += dp[i - 2]\n end\n end\n\n dp.last\nend", "def fourth_anagram?(str1, str2)\n hash1 = Hash.new(0)#O(1)\n beginning_time = Time.now\n str1.each_char {|char| hash1[char]+=1}#O(n)\n str2.each_char {|char| hash1[char]-=1}#O(n)\n hash1.all? {|_, v| v.zero?}#O(n)\n \"Time complexity of first_anagram: #{(Time.now - beginning_time)}\"\nend", "def reverseShuffleMerge(s)\n # handle incorrect test case\n return \"eaid\" if s==\"aeiouuoiea\"\n ###\n ## first solution ##\n# a = \"\"\n# n = s.length/2\n# dar = s.chars.sort\n# car = []\n# 0.upto(n-1) do |i|\n# car << dar[i*2] \n# end\n# upper = 2*n-1\n# n.times do |i|\n# found = nil\n# here = nil\n# lower = n-1-i\n# car.each_with_index do |x, k|\n# ix = s[lower..upper].rindex(x) # look for \"a\" from right\n# next unless ix\n# ix+= lower\n# temp = car.dup\n# s[0..ix].each_char{|e| if j = temp.index(e) then temp.delete_at(j) end}\n# if temp.empty? # s[0..ix] contains all of car \n# found = x\n# here = k\n# upper = ix-1\n# break\n# end\n# end\n# if found\n# a << found\n# car.delete_at(here)\n# end\n# end\n ## above solution too slow\n ## build a letter count hash instead\n letter_count = Hash.new(0)\n s.each_char do |c|\n letter_count[c]+=1\n end\n half_count = letter_count.transform_values { |v| v/2 }\n used = Hash.new(0)\n remaining = letter_count.dup\n a = \"\"\n s.reverse.each_char do |c|\n # should I include or exclude c ?\n if used[c] < half_count[c]\n while (a[-1] && c < a[-1] && \n remaining[a[-1]] > half_count[a[-1]] - used[a[-1]])\n # pop out bigger characters as long as they are exclude eligible\"\n used[a[-1]]-=1\n a.slice!(-1)\n end\n a << c\n used[c]+=1\n end\n remaining[c]-=1\n end\n return a\nend", "def solve(str)\n idx = 0\n count = 0\n\n substr_1 = ''\n substr_2 = ''\n\n loop do\n substr_1 = str[0..idx]\n substr_2 = str[(idx + 1)..-1]\n\n substr_1.to_i.odd? ? count += 1 : nil \n substr_2.to_i.odd? ? count += 1 : nil \n \n idx += 1\n break if idx >= str.length\n end\n count\nend", "def repeatedString(s, n)\n len = s.length\n times = n / len\n nb = times * s.count('a')\n\n last = s[0..(n % len)]\n nb += last.count('a') if len != 1\n nb\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 solve( n = 100_000_000 )\n # Assuming the largest valid sum of squares is S = a^2 + (a - 1)^2 < n,\n # first find a and set aside space to cache that many running sums.\n len = (1 + Math.sqrt( 2*n )) / 2\n sos = Array.new( len )\n\n seen = []\n sos[0] = 1\n\n (1...len).each do |i|\n # Precompute the ∑ i^2 for all i <= a. \n ds = i*i + 2*i + 1\n sos[i] = sos[i - 1] + ds\n\n seen << sos[i] if sos[i].palindrome?\n\n # Most of the sum of square values will exceed n, so subtract lower sums\n # to check shorter runs.\n (i - 2).downto( 0 ) do |j|\n diff = sos[i] - sos[j]\n break unless diff < n\n\n # Update our total if the shorter run a[j] + a[j + 1] + ... + a[i] is\n # a palindrome.\n seen << diff if diff.palindrome?\n end\n end\n\n seen.uniq.reduce( :+ )\n end", "def num_jewels_in_stones(j, s)\n s.count(j)\nend", "def substrings_of_size(str, n)\n substrings = []\n 0.upto(str.size - n) do |index|\n substrings << str[index..(index + n - 1)]\n end\n \n substrings.uniq\nend", "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend" ]
[ "0.6571266", "0.6527647", "0.64974415", "0.6421256", "0.6334191", "0.62447935", "0.6238051", "0.62372625", "0.6225252", "0.61764836", "0.61744225", "0.61640054", "0.61357486", "0.6128065", "0.6125138", "0.6107513", "0.6103693", "0.60892355", "0.6081185", "0.6071949", "0.6070353", "0.6058085", "0.6057356", "0.60229105", "0.6019335", "0.60093933", "0.6004409", "0.5973658", "0.59558284", "0.59410995", "0.5940525", "0.5931808", "0.59262717", "0.59258384", "0.5925089", "0.5923833", "0.59119517", "0.5908653", "0.5903434", "0.5900947", "0.5899729", "0.5895603", "0.58935523", "0.5891149", "0.5877482", "0.58749956", "0.587092", "0.5870084", "0.586126", "0.5856725", "0.58463115", "0.5839842", "0.58393604", "0.5836566", "0.5830321", "0.5829896", "0.58256495", "0.5823856", "0.5815734", "0.5814492", "0.5811703", "0.5806964", "0.5805676", "0.5794298", "0.579164", "0.5784663", "0.57840705", "0.5782867", "0.57760435", "0.5759053", "0.5758533", "0.5757745", "0.57507527", "0.5748966", "0.57446337", "0.57417315", "0.57385993", "0.57335544", "0.5730635", "0.57267064", "0.5725343", "0.57231337", "0.57213634", "0.5719848", "0.57126147", "0.5710133", "0.5707669", "0.57021606", "0.5699266", "0.56933665", "0.5691119", "0.56909287", "0.5683208", "0.5664856", "0.5664515", "0.5661438", "0.56591207", "0.56567585", "0.56547093", "0.5653481", "0.56503934" ]
0.0
-1
Time complexity: O(n) where n is the length of the smaller integer Space complexity: O(n) where n is the length of the smaller integer
def digit_match(n, m, match = 0) if n.digits.count == 1 || m.digits.count == 1 if n % 10 == m % 10 return match +=1 else return match end else if n % 10 == m % 10 match += 1 end n = n / 10 m = m / 10 return digit_match(n, m, match) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend", "def next_smaller(n)\n result = n.digits.permutation.select { |p| p.join.to_i < n && p.first != 0 }\n result.empty? ? -1 : result.last.join.to_i\nend", "def make_smaller(num)\n #declare variable for adding number\n small_num = 0\n \n # convert the number to a string so it can be used like an array\n num = num.to_s\n # find out how many digits on in the number so the for loop knows how many time to go though\n digits = num.length - 1\n\n # add each number to each other\n #for i in 0..digits do\n # small_num += num[i].to_i\n\n #end\n num.each do |digit|\n small_num += digit.to_i\n end\n\n #make sure number is only one digits\n if small_num.to_s.length > 1 then small_num = make_smaller small_num end\n \n small_num\nend", "def smaller_num(n1, n2)\n\tif n1.length > n2.length\n\t\tn2\n\telsif n2.length > n1.length\n\t\tn1\n\telse\n\t\tn1.to_i > n2.to_i ? n2 : n1 \n\tend\nend", "def my_min_2(nums) # O(n)\n smallest = 0\n nums.each do |num|\n smallest = num if num < smallest\n end\n smallest\nend", "def my_min_v2(arr) # O(n)\n num = arr[0]\n arr.each { |int| num = int if int < num }\n num\nend", "def min_permutation n\n n.to_s.chars.sort.join.to_i\nend", "def find_smallest(array, length)\n smallest_int = array[0]\n length.times do |i|\n if array[i] < smallest_int\n smallest_int = array[i]\n end\n end\n return smallest_int\nend", "def solution(n)\n n.to_s(2).reverse.to_i.to_s.split('1').map(&:length).max || 0\nend", "def smallest_integer(list_of_nums)\n length = list_of_nums.length\n if length == 0\n return nil\n elsif length == 1\n return list_of_nums[0]\n else\n a = 0\n b = 1\n while b < length\n if list_of_nums[a] < list_of_nums[b]\n output = list_of_nums[a]\n b += 1\n else\n output = list_of_nums[b]\n a = b\n b += 1\n end\n end\n return output\n end\nend", "def min_subsequence(nums)\n sorted = nums.sort\n left = sorted.inject(:+)\n right = 0\n i = 0\n while i < nums.length\n left -= sorted[i]\n right += sorted[i]\n\n if left < right\n return sorted.drop(i-a1).sort.reverse\n end\n i += 1\n end\n return []\nend", "def seqlength(n)\n seen = []\n m = 1\n\n 1.upto(n) do |i|\n rem = m % n\n return i if seen.include?(rem)\n seen.<< rem\n m = 10 * rem\n end\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(array) # O(n) - Linear\n counter = array[0]\n\n (1...array.length).each do |i|\n if counter > array[i]\n counter = array[i]\n end\n end\n counter\nend", "def find_shortest_seq(n)\n new_num = n/2\n i = 0\n arr = []; arr[i] = 1\n\n while(arr[i] < new_num)\n n1 = arr[i] * 2\n n2 = arr[i] + 1\n\n i += 1\n if(n1 < new_num)\n arr[i] = n1\n else\n arr[i] = n2\n end \n end\n puts arr.to_s\n if(arr[i] == n)\n puts arr.to_s\n puts i \n elsif n == (arr[i] * 2)\n arr[i + 1] = arr[i] * 2\n puts arr.to_s\n puts i + 1\n else\n arr[i + 1] = arr[i] * 2\n i += 1\n arr[i + 1] = arr[i] + 1\n puts arr.to_s\n puts i\n end \n \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 smallest_subarray(nums, s)\n min_length = Float::INFINITY\n\n start_position = 0\n end_position = 0\n\n sum = nums[start_position]\n\n while start_position < nums.length\n if sum < s\n end_position += 1\n break if end_position == nums.length\n\n sum += nums[end_position]\n elsif sum >= s\n size = nums[start_position..end_position].size\n min_length = [min_length, size].min\n sum -= nums[start_position]\n start_position += 1\n end\n end\n min_length\nend", "def short_long_short(a, b)\n [a + b + a, b + a + b].sort_by(&:size)[0]\nend", "def my_min(arr)\n l = arr.length - 1 # constant\n # min = 0 # is this more efficient than swapping? \n (0...l).each do |i| # n times1\n if arr[i] < arr[i+1] # 1\n arr[i], arr[i+1] = arr[i+1], arr[i] # 1\n end\n end\n\n arr.last # 1\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 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 solution(digits)\n result = 0\n digits.size.times do |n|\n new_number = digits[n...(n + 5)].to_i\n result = new_number if new_number > result\n end\n result\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(n)\n array = Array.new\n (1..n).each do\n array.push(0)\n end\n while (array.length >= 16)\n (1..16).each do\n array.pop\n end \n end\n array.length\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 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)\n ((1..a.length).to_a - a).empty? ? 1 : 0\nend", "def smallest_integer(list_of_nums)\r\n # Your code goes here!\r\n a = list_of_nums.length\r\n \r\n \tloop do \r\n \t\tswapped = false\r\n \t\t\r\n \t\t(a-1).times do |i|\r\n \t\t\tif list_of_nums[i] > list_of_nums[i+1]\r\n \t\t\t\tlist_of_nums[i], list_of_nums[i+1] = list_of_nums[i+1], list_of_nums[i]\r\n \t\t\t\tswapped = true \r\n \t\t\tend\r\n \t\tend\r\n\r\n \t\tbreak if not swapped\r\n \tend\r\n \tsmallest = list_of_nums[0]\r\n \tsmallest\r\n\r\n\r\nend", "def min_palindrome(a)\n return 0 if a.nil? || a.empty?\n n = a.size - 1 \n flag = 0\n count = 0\n i = 0 \n while(i <= n)\n if (a[i] == a[n])\n i += 1\n n -= 1\n flag += 1 \n else\n count += 1 + flag\n n = a.size - 1 if flag > 0\n i += 1\n flag = 0 \n end\n end\n return count\nend", "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend", "def find_smallest(array, length)\n smallest_number = array[0]\n length.times do |i|\n if smallest_number > array[i]\n smallest_number = array[i]\n end\n end\n return smallest_number\nend", "def missing_integer(a)\n a.sort!\n a.select!{|i| i > 0}\n\n return 1 if a.length == 0 || a[0] > 1\n\n\n (0..(a.length - 2)).each do |i|\n return (a[i] + 1) if a[i+1] - a[i] > 1\n end\n return a[-1] + 1\nend", "def next_bigger(n)\n return -1 if n / 10 == 0 || same_digits?(n) || biggest?(n)\n digits_array = n.to_s.chars.map(&:to_i)\n n_length = digits_array.length\n i = 1\n until i == n_length\n if digits_array[n_length - i] > digits_array[n_length - 1 - i]\n # find next bigger num from the right\n b = digits_array[(n_length - i)..-1].sort.find { |x| x > digits_array[n_length - 1 - i] }\n digits_array.insert(n_length - 1 - i, b)\n # sort everything on the right and delete inserted num\n sorted = digits_array[(n_length - i)..-1].sort!\n sorted.delete_at(sorted.index(b))\n digits_array[(n_length - i)..-1] = sorted\n return digits_array.join.to_i\n end\n i += 1\n end\nend", "def smallest_integer(list_of_nums)\n\tif list_of_nums.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_nums[0]\n\tj = 1\n\twhile j <= list_of_nums.length - 1 do\n\t\tif i > list_of_nums[j]\n\t\t\ti = list_of_nums[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend", "def solution(n)\n # write your code in Ruby 2.2\n a = n.to_s(2)\n arr = []\n if a[-1] == '1'\n arr = a.split('1')\n else\n arr = a.split('1')\n arr.pop\n end\n if arr.max.nil?\n 0\n else\n arr.max.length\n end\nend", "def find_min_value(array)\n min_element = 10000000\n array.length.times { |index|\n if min_element > array[index]\n min_element = array[index]\n end\n }\n return min_element# Add your solution here\nend", "def find_smallest(array, length)\n smallest_number = array[0]\n length.times do |index|\n if array[index] < smallest_number\n smallest_number = array[index]\n end\n end\n return smallest_number\nend", "def min_partitions(n)\n n.chars.max.to_i\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 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 even_the_bit_lengths(*numbers)\n longest_length = numbers.max {|a, b| a.length <=> b.length}.length\n numbers.map! do |number|\n while number.length != longest_length\n number.unshift(0)\n end\n number\n end\n numbers\nend", "def solution(n)\n n.to_s.split(//).inject(1) { |a,d| a + d.to_i }\nend", "def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend", "def min_sub_array_len(s, nums)\n # debugger\n nums.length.times do |window_size|\n (nums.length - window_size + 1).times do |window_start|\n window_arr = nums.slice(window_start,window_size + 1)\n return window_arr if window_arr.reduce(:+) == s\n end\n end\nend", "def twice_as_big(num)\n num + num\nend", "def smallest_n_digit_number(n)\n 10 ** (n-1)\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 uniq_integer(input_array)\n unique = 0\n input_array.each do |num|\n unique = unique ^ num\n end\n\n unique\nend", "def solution(a)\n ((1..a.size + 1).to_a - a).first\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 n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend", "def smallest_integer(list_of_nums)\n\n small_int = list_of_nums[0]\n list_of_nums.each do |small|\n if small < small_int\n small_int = small\n end\n end\n return small_int\nend", "def longest_increasing_subseq(arr)\n n = arr.size\n lis = Array.new(n, 1)\n\n (0 ... n).each do |i|\n (0 ... i).each do |j|\n if arr[i] > arr[j] && lis[j] + 1 > lis[i]\n lis[i] = lis[j] + 1\n end\n end\n end\n\n max_len = 0\n\n (1 ... n).each do |k|\n max_len = lis[k] if max_len < lis[k]\n end\n\n max_len\nend", "def my_min_2(list) # n\n min_value = list.first\n i = 0\n while i < list.length\n min_value = list[i] if list[i] < min_value\n i += 1\n end\n min_value\nend", "def length n\n Math.log10(n).floor \nend", "def smallest_integer(list_of_nums)\n while list_of_nums.length > 1\n list_of_nums[0] > list_of_nums[1] ? list_of_nums.delete_at(0) : list_of_nums.delete_at(1)\n end\n smallest_num = list_of_nums[0]\nend", "def find_duplicate_space(nums)\n floor = 0\n ceiling = nums.length - 1\n\n while floor < ceiling\n possible_distinct_count_first_half = 0\n possible_distinct_count_second_half = 0\n count_first_half = 0\n count_second_half = 0\n\n middle_i = floor + (ceiling - floor)\n\n (floor..middle_i-1).each do |i|\n possible_distinct_count_first_half += 1\n\n count_first_half += 1 if nums[i] >= nums[floor] && nums[i] <= nums[middle_i-1]\n end\n\n (middle_i..ceiling).each do |i|\n possible_distinct_count_second_half += 1\n count_second_half += 1 if nums[i] <= nums[ceiling] && nums[i] >= nums[middle_i]\n end\n\n if count_first_half > possible_distinct_count_first_half\n ceiling = middle_i\n elsif count_second_half < possible_distinct_count_second_half\n floor = middle_i\n end\n end\n\n return nums[floor]\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(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(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 smallest(n)\n\tdivisible = false\n\tstart = 1\n\n\tuntil divisible == true\n\t\t(1...n).each do |i|\n\t\t\tif start % i != 0\n\t\t\t\tdivisible = false\n\t\t\telse\n\t\t\t\tdivisible = true\n\t\t\tend \n\t\t\tif divisible == false\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tstart += 1\n\tend\n\tp start - 1\nend", "def solution(n)\n (1..n).to_a.join.chars.map(&:to_i).sum\nend", "def smallest_common_multiple(n)\n\n\treturn 0\nend", "def twice(int)\n int = int.to_s\n half_int = int[0, int.length/2]\n return int.to_i if half_int + half_int == int\n return int.to_i * 2 if half_int + half_int != int\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 reduce_2n1(a, n)\n b = a >> n\n a = a & ((1 << n) - 1)\n r = a - b\n if r < 0\n return r + (1 << n) + 1\n end\n return r\nend", "def sturges\n len = array.length\n return 1.0 if len == 0\n\n # return (long)(ceil(Math.log2(n)) + 1);\n return Math.log2(len).ceil + 1\n end", "def smallest_integer(list_of_nums)\n # Your code goes here!\n\tsmall = list_of_nums[0]\n\tlist_of_nums.each do |x|\n\t\tsmall = x if x < small\n\tend\n\treturn small\nend", "def max_sub(a)\na[(0...(n=a.size)).inject([]){|r,i|(i...n).inject(r){|r,j|r<<(i..j)}}.sort_by{|r|a[r].inject{|i,j|i+j}}[-1]]\nend", "def missing_int(a)\n a.sort!\n return 1 if a.length == 0 || a[0] != 1\n n_plus_one = a.length + 1\n return n_plus_one if a[-1] != n_plus_one\n\n len = a.length - 2\n missing_val = nil\n (0..len).each do |i|\n if (a[i + 1] - a[i]) > 1\n missing_val = a[i] + 1\n break\n end\n end\n return missing_val || n_plus_one\nend", "def LongestIncreasingSequence(arr)\n size = arr.size\n \n while size > 1\n sub_seq = arr.combination(size).to_a\n sub_seq.each do |seq|\n inc_seq = true\n seq.each_cons(2) { |num1, num2| break inc_seq = false unless num2 > num1 }\n return seq.size if inc_seq\n end \n size -= 1\n end\n 1\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 longestIncreasingSubseq(nums)\n\tres = []\n\tnums.each { |x| \n\t\tindex = (0...res.size).bsearch { |i| \n\t\t\tres[i] >= x\n\t\t}\n\t\tres[index||res.size] = x\n\t}\n\tres.size\nend", "def find_short(s)\n # s.split.map(&:size).min\n s.split\n .map(&:size)\n .min\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 find_unsorted_subarray2(nums)\n sort_nums = nums.sort\n\n left = nums.length\n right = 0\n\n sort_nums.each_with_index do |num, index|\n if num != nums[index]\n left = [index, left].min\n right = [index, right].max\n end\n end\n\n right >= left ? right - left + 1 : 0\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 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(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 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", "def trinum n\n temp = 0\n for i in 1..n\n temp = temp + i\n end\n return temp\nend", "def euler_golf(size)\n a = [1]\n euler_golf(size - 1).slice(1, size - 1).each { |el| a.push(a.last + el) } unless size == 1\n a.push(a.last * 2)\nend", "def smallest_integer(list_of_nums)\n small = list_of_nums[0]\n list_of_nums.each do |num|\n if num < small\n small = num\n end\n end\nsmall\nend", "def solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "def min_cut(s)\n palindrome = Array.new(s.size + 1).map { |x| \n Array.new(s.size + 1).map { |y|\n false\n }\n }\n\n dp = []\n 0.upto(s.size) { |i|\n dp[i] = i - 1\n }\n\n 2.upto(s.size).each { |i|\n (i - 1).downto(0).each { |j|\n if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1])\n palindrome[j][i] = true\n dp[i] = [dp[i], dp[j] + 1].min\n end\n }\n }\n\n return dp[s.size]\nend", "def space_edition(input_array)\n lowest_range = 1\n highest_range = input_array.length - 1\n \n while (lowest_range < highest_range)\n \n mid = (lowest_range + highest_range) /2\n \n first_half_lowest_range = lowest_range\n first_half_highest_range = mid\n \n second_half_lowest_range = mid + 1\n second_half_highest_range = highest_range\n \n number_of_elements_in_first_half = 0\n input_array.each do |number|\n if number >= first_half_lowest_range && number <= first_half_highest_range \n number_of_elements_in_first_half += 1\n end\n \n number_of_unique_possibilities_in_first_half = first_half_highest_range - first_half_lowest_range + 1\n \n if number_of_elements_in_first_half > number_of_unique_possibilities_in_first_half\n lowest_range, highest_range = first_half_lowest_range, first_half_highest_range\n else\n lowest_range, highest_range = second_half_lowest_range, second_half_highest_range\n end\n end\n \n end\n\n return lowest_range\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 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 find_unsorted_subarray(nums)\n l = 0\n r = nums.length - 1\n min = 10_001\n max = -10_001\n st = 0\n nd = -1\n\n while r >= 0\n nums[l] >= max ? max = nums[l] : nd = l\n nums[r] <= min ? min = nums[r] : st = r\n\n l += 1\n r -= 1\n end\n\n nd - st + 1\nend", "def integer_break(n)\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 sum_two_small_numbers(numbers)\n numbers.sort.first(2).inject(:+)\nend", "def smallest(number_of_digits)\n ('1' * number_of_digits).to_i\nend", "def lucas_numbers(n)\n comparison = [2,1]\n if n > 1\n (n - 1).times do\n new = comparison.inject(:+)\n comparison = [comparison.last, new]\n end\n return comparison.last\n elsif n < 0\n n.abs.times do\n new = comparison.pop - comparison.first\n comparison.unshift(new)\n end\n return comparison.first\n else\n return comparison[n]\n end\nend", "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 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 subarray(arr,num)\n\t#sort the array, use pointers\n\tj = 0\n\ti = 0\n\tsum = 0\n\twhile j < arr.length\n\t\tif sum < num\n\t\t\t#moving up the array if sum is less than number\n\t\t\tsum += arr[j]\n\t\t\tj += 1\n\t\telse\n\t\t\tminLen = [9000, j-i].min\n\t\t\tif i == (j-1)\n\t\t\t\treturn 1\n\t\t\tend\n\t\t\tsum -= arr[i]\n\t\t\ti += 1\n\t\tend\n\t\tputs sum, \"first\"\n\t\tputs minLen, \"minfirst\"\n\t\tputs i,\"i\", j, \"j\"\n\tend\n\t\n\twhile sum >= num\n\t\tminLen = [9000, j-i].min\n\t\ti += 1\n\t\tsum -= arr[i]\n\t\tputs sum, \"second\"\n\t\tputs minLen, \"minsecond\"\n\t\tputs i,\"i\", j, \"j\"\n\tend\n\tif minLen == 9000\n\t\tputs 0\n\telse\n\t\tputs minLen\n\tend\n\nend", "def smallest_integerv2(list_of_nums)\n # Your code goes here!\n\treturn list_of_nums.min\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(digits)\n digits.chars.each_cons(5).max_by(&:itself).join.to_i\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" ]
[ "0.694552", "0.6893638", "0.66248393", "0.6528624", "0.6471821", "0.6471151", "0.6393683", "0.63389885", "0.6309311", "0.6306566", "0.6285366", "0.62834203", "0.625928", "0.6252865", "0.6251095", "0.6234594", "0.62342674", "0.620438", "0.6180211", "0.61737156", "0.61720467", "0.61605704", "0.6110285", "0.6096001", "0.60939115", "0.60813737", "0.6057027", "0.6045039", "0.6033896", "0.60140365", "0.59859854", "0.59805006", "0.59697473", "0.59666026", "0.5966039", "0.5962419", "0.5960311", "0.5959397", "0.59586954", "0.5954839", "0.59534216", "0.59452707", "0.5936317", "0.59346354", "0.59304273", "0.5919709", "0.5908851", "0.58958465", "0.58854616", "0.5871687", "0.5868381", "0.5864883", "0.5862808", "0.5862758", "0.58596843", "0.58571446", "0.58541214", "0.5851768", "0.5850909", "0.5849603", "0.58486724", "0.58448374", "0.5844561", "0.58417666", "0.58405113", "0.5839199", "0.5837152", "0.58316153", "0.5821666", "0.58212376", "0.58207375", "0.58150613", "0.58072543", "0.5805003", "0.57975316", "0.57954556", "0.5795214", "0.57920307", "0.5791177", "0.57884526", "0.5771524", "0.57711315", "0.5766119", "0.57644", "0.5760169", "0.5759444", "0.57590795", "0.5755297", "0.57527125", "0.5751575", "0.57515585", "0.57441753", "0.57422596", "0.5741963", "0.57397527", "0.5733813", "0.57289666", "0.572564", "0.57243955", "0.57243055", "0.5718983" ]
0.0
-1
From Rack from Camping
def escape( s ) s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) do '%'+$1.unpack('H2'*$1.size).join('%').upcase end.tr(' ', '+') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rack_builder; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def rack_input ; @env['rack.input'] ; end", "def weber; end", "def req\n \n end", "def raw_response; end", "def http; end", "def call(request); end", "def process(request); end", "def preflight; end", "def perform(request, response); end", "def net_http_res; end", "def set_request; end", "def respond(); end", "def middleware; end", "def send_request; end", "def receive(request); end", "def rackup(app); return @@rack.call(app); end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def request_method; end", "def send_request(req); end", "def request=(_arg0); end", "def request=(_arg0); end", "def request=(_arg0); end", "def request_data; end", "def middlewares_stack; end", "def private; end", "def apply_request(request_env); end", "def rack_standard(env)\n [200, {\"Content-Type\" => \"text/plain\"}, [\"Hey from a standard rack app\"]]\n # Just another way to do the above, can get more request info, ...\n # @req = Rack::Request.new(env)\n # @res = Rack::Response.new\n # @res.write(\"Hey from a standard rack app\")\n # @res.finish\n end", "def request_uri; end", "def initialize\n# We create the array called @rack\n @rack = []\n end", "def request(*args); end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def response; end", "def rack_standard(env)\n @req = Rack::Request.new(env)\n # puts \"here in standard rack handler\"\n @res = Rack::Response.new\n @res.write(\"Hey from a standard rack app\")\n @res.finish\n end", "def call(env)\n request = Request.new(env) \n snip, part, format = request_uri_parts(request)\n if snip\n params = request.params.merge(:snip => snip, :part => part, \n :format => format, :method => request.request_method.downcase)\n [200, {\"Content-Type\" => \"text/html\"}, [Vanilla.present(params)]]\n else\n four_oh_four = Vanilla.present(:snip => 'system', :part => 'four_oh_four', :format => 'html')\n [404, {\"Content-Type\" => \"text/html\"}, [four_oh_four]]\n end\n end", "def middlewares; end", "def before_dispatch(env); end", "def middlewares=(_arg0); end", "def call(env)\n\trequest = Rack::Request.new(env)\n\tresponse = Rack::Response.new\n\tprocess(request, response)\n\t[response.status, response.headers, response.body]\n end", "def rack_hijack_io ; @env['rack.hijack_io'] ; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def headers; end", "def sitemaps; end", "def request\n raise 'need to be implemented'\n end", "def handler; end", "def handler; end", "def response_body=(_arg0); end", "def rack(&prc)\n @@rack = prc if not prc.nil?\n return @@rack\n end", "def request; return @request end", "def body_io; end", "def body_io; end", "def middleware(&block); end", "def pre_connect(request); end", "def rackup(path); end", "def transport; end", "def transport; end", "def transport; end", "def request(*args, &block); end", "def on_pre_request( request ); end", "def app_middleware; end", "def server; end", "def server; end", "def server; end", "def server; end", "def server; end", "def server; end", "def server; end", "def server; end" ]
[ "0.7031487", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.6606145", "0.65996605", "0.649244", "0.6301462", "0.6239088", "0.61803716", "0.61601365", "0.61429065", "0.61401135", "0.6114718", "0.6107081", "0.61038256", "0.6095986", "0.607486", "0.6067612", "0.6056706", "0.6009132", "0.59995055", "0.59995055", "0.59995055", "0.59995055", "0.599846", "0.5951603", "0.5941781", "0.5941781", "0.5941781", "0.5911301", "0.59072673", "0.58800006", "0.58513415", "0.58031213", "0.5802019", "0.57851887", "0.5737593", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5736403", "0.5728898", "0.5706012", "0.57002187", "0.5689793", "0.5683908", "0.5669984", "0.56526226", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.564412", "0.56307286", "0.5627822", "0.5621423", "0.5621423", "0.5611943", "0.5608473", "0.5602455", "0.56003225", "0.56003225", "0.55935913", "0.55880773", "0.55875075", "0.5577426", "0.5577426", "0.5577426", "0.5572559", "0.5571954", "0.5564804", "0.5561118", "0.5561118", "0.5561118", "0.5561118", "0.5561118", "0.5561118", "0.5561118", "0.5561118" ]
0.0
-1
Don't know how to properly test this feature, ask for dans help, should also be refactored into it's own rest model
def send_flow flow = Flowdock::Flow.new(api_token: ENV['LP_FLOW'], source: "LaunchPairs", from: { name: current_user.first_name, address: current_user.email }) flow.push_to_chat(:content => params[:flow][:question], :external_user_name => current_user.first_name) flash[:success] = "Your question was sent! Check the flow for any answers" redirect_to dashboard_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rest_endpoint; end", "def from_api?; false end", "def define_restful_api(model)\n get \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.all }\n end\n\n get \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors do\n result = model.find_by_id(params[:id])\n halt 404 if result.nil?\n json result\n end\n end\n\n post \"/#{model.resource}\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.create(@json_payload) }\n end\n\n patch \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { json model.update(params[:id], @json_payload) }\n end\n\n delete \"/#{model.resource}/:id\" do\n sleep settings.fake_latency if settings.fake_latency > 0\n catch_errors { model.delete(params[:id]) }\n end\n\n private\n def catch_errors()\n begin\n yield\n rescue Exception => e\n logger.fatal(\"Exception: #{e}\")\n status 500\n json({'error' => e})\n end\n end\nend", "def jsonapi_received_relationships\n\t\t\t\t\t# Relationship definitions for current model\n\t\t\t\t\trels = jsonapi_relationships\n\n\t\t\t\t\t# Consider only current relationship for relationship actions\n\t\t\t\t\t# (params[:relationship] contains the relationship name)\n\t\t\t\t\tif params[:relationship] \n\n\t\t\t\t\t\trels.select! do |rel|\n\t\t\t\t\t\t\trel[:name].to_sym == params[:relationship].to_sym\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\t# If no relationship is received, then return the definition only\n\t\t\t\t\t\tif request.method == \"GET\"\n\t\t\t\t\t\t\treturn rels.collect do |rel|\n\t\t\t\t\t\t\t\t{definition: rel}\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\n\n\t\t\t\t\trels.collect do |relationship|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\treceived_params = nil\n\n\t\t\t\t\t\t\t# Relationship action\n\t\t\t\t\t\t\tif params[:relationship]\n\t\t\t\t\t\t\t\treceived_params = params.permit({\n\t\t\t\t\t\t\t\t\tdata: [\n\t\t\t\t\t\t\t\t\t\t:type, :id\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t# Object action\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treceived_params = params.require( \n\t\t\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t\t\t:relationships\n\t\t\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t\t\trelationship[:name]\n\t\t\t\t\t\t\t\t).permit({\n\t\t\t\t\t\t\t\t\tdata: [\n\t\t\t\t\t\t\t\t\t\t:type, :id\n\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t# => {\"data\"=>{\"type\"=>\"users\", \"id\"=>1}} # sample value for a to-one association\n\t\t\t\t\t\t\t# => {\"data\"=>[{\"type\"=>\"properties\", \"id\"=>1}, {\"type\"=>\"properties\", \"id\"=>2}]} # sample value for a to-many association\n\n\t\t\t\t\t\t\t# is received data conformant to the database schema? \n\t\t\t\t\t\t\tconformant = true\n\t\t\t\t\t\t\tloop do\n\t\t\t\t\t\t\t\t# to-many\n\t\t\t\t\t\t\t\tif received_params[:data].kind_of? Array\n\t\t\t\t\t\t\t\t\tif relationship[:type] != :to_many\n\t\t\t\t\t\t\t\t\t\tconformant = false\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\treceived_params[:data].each do |item|\n\t\t\t\t\t\t\t\t\t\tnext if item[:type].to_sym == relationship[:receiver][:type]\n\t\t\t\t\t\t\t\t\t\tconformant = false\n\t\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# to-one\n\t\t\t\t\t\t\t\tif relationship[:type] != :to_one\n\t\t\t\t\t\t\t\t\tconformant = false\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tconformant = false unless received_params[:data][:type].to_sym == relationship[:receiver][:type]\n\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tnext unless conformant\n\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdefinition: relationship,\n\t\t\t\t\t\t\t\tparams: received_params\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\trescue ActionController::ParameterMissing => e\n\n\t\t\t\t\t\t\t# nil assignment to to-one relationship?\n\t\t\t\t\t\t\tif relationship[:type] == :to_one\n\t\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\t\tif params[:relationship] # relationship action\n\t\t\t\t\t\t\t\t\t\treceived_params = params.permit(\n\t\t\t\t\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\treceived_params = params.require( \n\t\t\t\t\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t\t\t\t\t:relationships\n\t\t\t\t\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t\t\t\t\trelationship[:name]\n\t\t\t\t\t\t\t\t\t\t).permit(\n\t\t\t\t\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\t# received nil?\n\t\t\t\t\t\t\t\t\tnext if received_params[:data] # TODO: should return error to client?\n\n\t\t\t\t\t\t\t\t\tnext {\n\t\t\t\t\t\t\t\t\t\tdefinition: relationship,\n\t\t\t\t\t\t\t\t\t\tparams: received_params\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trescue ActionController::ParameterMissing => e\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tnil\n\t\t\t\t\t\tend\n\t\t\t\t\tend.compact\n\t\t\t\tend", "def serializer; end", "def parent_api; end", "def parent_api; end", "def api; end", "def api; 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 validate_rest_call\n \n # Parse the incoming JSON\n if params[:relation]\n begin\n params[:relation] = JSON.parse(params[:relation])\n params[:relation] = substitute_ids(params[:relation])\n check_id_conflict(params[:relation], params[:id])\n valid_relation?(params[:relation], params)\n rescue MadbException => e\n render :json => report_errors(nil,e)[0], :status => e.code and return false\n rescue Exception => e\n render :json => report_errors(nil,e)[0], :status => 400 and return false\n end\n end\n \n \n if params[:action] == 'index'\n # if the access URL is:\n # GET /relations\n render :json => report_errors(nil, 'GET /relatiosn is not allowed, use GET /entities/:entity_id/relations instead')[0],\n :status => 400 and return false if !params[:entity_id]\n \n end\n \n \n if params[:action] == 'create' or params[:action] == 'update' \n render :json => report_errors(nil, 'Provide the relation resource to be created/updated')[0],\n :status => 400 and return false if !params[:relation]\n \n# # If its a nested call like /entities/relations or /databases/entities/relations\n# # and parent or child parameter is provided, then the entity id that is part of the url\n# # would be used as relation\n# if params[:child] and params[:entity_id] and params[:action] == 'create'\n# params[:relation][:parent_id] = params[:entity_id]\n# params[:relation][:child_id] = params[:child]\n# \n# elsif params[:parent] and params[:entity_id] and params[:action] == 'create'\n# params[:relation][:child_id] = params[:entity_id]\n# params[:relation][:parent_id] = params[:parent]\n# end\n\n end\n \n if params[:action] == 'destroy'\n render :json => report_errors(nil, 'Provide lock_version for update/delete operations')[0],\n :status => 400 and return false if !params[:lock_version]\n end\n \n end", "def test_additional_model_properties1()\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_parameters1(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 api_only; end", "def api_only; end", "def api_only; end", "def rest_end_point; end", "def apis; end", "def get()\n \n end", "def get_field_deserializers()\n return {\n \"bodyContains\" => lambda {|n| @body_contains = n.get_collection_of_primitive_values(String) },\n \"bodyOrSubjectContains\" => lambda {|n| @body_or_subject_contains = n.get_collection_of_primitive_values(String) },\n \"categories\" => lambda {|n| @categories = n.get_collection_of_primitive_values(String) },\n \"fromAddresses\" => lambda {|n| @from_addresses = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"hasAttachments\" => lambda {|n| @has_attachments = n.get_boolean_value() },\n \"headerContains\" => lambda {|n| @header_contains = n.get_collection_of_primitive_values(String) },\n \"importance\" => lambda {|n| @importance = n.get_enum_value(MicrosoftGraph::Models::Importance) },\n \"isApprovalRequest\" => lambda {|n| @is_approval_request = n.get_boolean_value() },\n \"isAutomaticForward\" => lambda {|n| @is_automatic_forward = n.get_boolean_value() },\n \"isAutomaticReply\" => lambda {|n| @is_automatic_reply = n.get_boolean_value() },\n \"isEncrypted\" => lambda {|n| @is_encrypted = n.get_boolean_value() },\n \"isMeetingRequest\" => lambda {|n| @is_meeting_request = n.get_boolean_value() },\n \"isMeetingResponse\" => lambda {|n| @is_meeting_response = n.get_boolean_value() },\n \"isNonDeliveryReport\" => lambda {|n| @is_non_delivery_report = n.get_boolean_value() },\n \"isPermissionControlled\" => lambda {|n| @is_permission_controlled = n.get_boolean_value() },\n \"isReadReceipt\" => lambda {|n| @is_read_receipt = n.get_boolean_value() },\n \"isSigned\" => lambda {|n| @is_signed = n.get_boolean_value() },\n \"isVoicemail\" => lambda {|n| @is_voicemail = n.get_boolean_value() },\n \"messageActionFlag\" => lambda {|n| @message_action_flag = n.get_enum_value(MicrosoftGraph::Models::MessageActionFlag) },\n \"notSentToMe\" => lambda {|n| @not_sent_to_me = n.get_boolean_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"recipientContains\" => lambda {|n| @recipient_contains = n.get_collection_of_primitive_values(String) },\n \"senderContains\" => lambda {|n| @sender_contains = n.get_collection_of_primitive_values(String) },\n \"sensitivity\" => lambda {|n| @sensitivity = n.get_enum_value(MicrosoftGraph::Models::Sensitivity) },\n \"sentCcMe\" => lambda {|n| @sent_cc_me = n.get_boolean_value() },\n \"sentOnlyToMe\" => lambda {|n| @sent_only_to_me = n.get_boolean_value() },\n \"sentToAddresses\" => lambda {|n| @sent_to_addresses = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"sentToMe\" => lambda {|n| @sent_to_me = n.get_boolean_value() },\n \"sentToOrCcMe\" => lambda {|n| @sent_to_or_cc_me = n.get_boolean_value() },\n \"subjectContains\" => lambda {|n| @subject_contains = n.get_collection_of_primitive_values(String) },\n \"withinSizeRange\" => lambda {|n| @within_size_range = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SizeRange.create_from_discriminator_value(pn) }) },\n }\n end", "def serializer\n ArticleSerializer\n end", "def serializer\n ArticleSerializer\n end", "def jsonapi_deserialize(document)\n\n # Optional fields, if present, convert to snake/symbol\n # data - (if present, flatten it accordingly to jsonapi spec)\n # include\n # fields\n # filter\n # sort\n # page\n # platform\n\n # Duplicate document and convert to JSON\n # if document.is_a?(ActionController::Parameters)\n # primary_data = document.dup.as_json\n if document.respond_to?(:permit!)\n # Handle Rails params...\n primary_data = document.dup.require(:data).permit!.as_json\n elsif document.is_a?(Hash)\n primary_data = document.as_json.deep_dup\n else\n return {}\n end\n\n # This is the hash that is going to be returned\n parsed = {}\n parsed['include'] = primary_data['include'] if primary_data['include']\n parsed['fields'] = primary_data['fields'] if primary_data['fields']\n parsed['filter'] = primary_data['filter'] if primary_data['filter']\n parsed['sort'] = primary_data['sort'] if primary_data['sort']\n parsed['page'] = primary_data['page'] if primary_data['page']\n parsed['platform'] = primary_data['platform'] if primary_data['platform']\n\n # Convert primary_data to snake_case\n _primary_data = primary_data.deep_transform_keys(&:underscore)\n\n if _primary_data['data']\n relationships = _primary_data['data']['relationships'] || {}\n parsed['id'] = _primary_data['id'] if _primary_data['id']\n\n # Map _primary_data['data']['attributes'] to parsed hash\n if _primary_data['data']['attributes'].respond_to? :each\n _primary_data['data']['attributes'].each do |key, val|\n parsed[key] = val\n end\n end\n\n relationships.map do |assoc_name, assoc_data|\n assoc_data = (assoc_data || {})['data'] || {}\n rel_name = jsonapi_inflector.singularize(assoc_name)\n\n if assoc_data.is_a?(Array)\n parsed[\"#{rel_name}_ids\"] = assoc_data.map { |ri| ri['id'] }.compact\n next\n end\n\n parsed[\"#{rel_name}_id\"] = assoc_data['id']\n if (options['polymorphic'] || []).include?(assoc_name)\n rel_type = jsonapi_inflector.classify(assoc_data['type'].to_s)\n parsed[\"#{rel_name}_type\"] = rel_type\n end\n end\n end\n\n # Convert to symbols before returning to client\n parsed.deep_transform_keys!(&:to_sym)\n end", "def consume_rest; end", "def test_send_model()\n # Parameters for the API call\n model = Employee.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"Shahid Khaliq\",\"age\":5147483645,\"address\":\"H # 531, S # 20\",\"u'\\\n 'id\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9'\\\n '571247Z\",\"salary\":20000,\"department\":\"Software Development\",\"joiningDay'\\\n '\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"boss\":{\"perso'\\\n 'nType\":\"Boss\",\"name\":\"Zeeshan Ejaz\",\"age\":5147483645,\"address\":\"H # 531'\\\n ', S # 20\",\"uid\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-1'\\\n '3T14:01:54.9571247Z\",\"salary\":20000,\"department\":\"Software Development\"'\\\n ',\"joiningDay\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"d'\\\n 'ependents\":[{\"name\":\"Future Wife\",\"age\":5147483649,\"address\":\"H # 531, '\\\n 'S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T'\\\n '14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age\":5147483648,\"address\":\"H '\\\n '# 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994'\\\n '-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 06 Nov 1994 08:49:37 GMT\",\"'\\\n 'promotedAt\":1484719381},\"dependents\":[{\"name\":\"Future Wife\",\"age\":51474'\\\n '83649,\"address\":\"H # 531, S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13'\\\n '\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age'\\\n '\":5147483648,\"address\":\"H # 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"199'\\\n '4-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 0'\\\n '6 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_model(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_send_model()\n # Parameters for the API call\n model = Employee.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"Shahid Khaliq\",\"age\":5147483645,\"address\":\"H # 531, S # 20\",\"u'\\\n 'id\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9'\\\n '571247Z\",\"salary\":20000,\"department\":\"Software Development\",\"joiningDay'\\\n '\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"boss\":{\"perso'\\\n 'nType\":\"Boss\",\"name\":\"Zeeshan Ejaz\",\"age\":5147483645,\"address\":\"H # 531'\\\n ', S # 20\",\"uid\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-1'\\\n '3T14:01:54.9571247Z\",\"salary\":20000,\"department\":\"Software Development\"'\\\n ',\"joiningDay\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"d'\\\n 'ependents\":[{\"name\":\"Future Wife\",\"age\":5147483649,\"address\":\"H # 531, '\\\n 'S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T'\\\n '14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age\":5147483648,\"address\":\"H '\\\n '# 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994'\\\n '-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 06 Nov 1994 08:49:37 GMT\",\"'\\\n 'promotedAt\":1484719381},\"dependents\":[{\"name\":\"Future Wife\",\"age\":51474'\\\n '83649,\"address\":\"H # 531, S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13'\\\n '\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age'\\\n '\":5147483648,\"address\":\"H # 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"199'\\\n '4-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 0'\\\n '6 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.send_model(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 get_field_deserializers()\n return super.merge({\n \"content\" => lambda {|n| @content = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"nextExpectedRanges\" => lambda {|n| @next_expected_ranges = n.get_collection_of_primitive_values(String) },\n })\n end", "def get; end", "def stockInformation\n ActiveModel::SerializableResource.new(object.stock, each_serializer: StockSerializer)\nend", "def req\n \n end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def to_api\n {\n id: self.id,\n name: self.name\n }\n end", "def index\n build_resource({})\n respond_with self.resource\n end", "def rest_token_endpoint; end", "def get_field_deserializers()\n return super.merge({\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"resourceName\" => lambda {|n| @resource_name = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_type = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"resource\" => lambda {|n| @resource = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Entity.create_from_discriminator_value(pn) }) },\n \"resourceReference\" => lambda {|n| @resource_reference = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResourceReference.create_from_discriminator_value(pn) }) },\n \"resourceVisualization\" => lambda {|n| @resource_visualization = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResourceVisualization.create_from_discriminator_value(pn) }) },\n \"weight\" => lambda {|n| @weight = n.get_object_value(lambda {|pn| Double.create_from_discriminator_value(pn) }) },\n })\n end", "def resource; end", "def rest_endpoint=(_arg0); end", "def retrieve\n end", "def singular_resource\n super.decorate\n end", "def jsonapi_received_attributes\n\t\t\t\t\tbegin\n\t\t\t\t\t\tparams.require(\n\t\t\t\t\t\t\t:data\n\t\t\t\t\t\t).require(\n\t\t\t\t\t\t\t:attributes\n\t\t\t\t\t\t).permit(\n\t\t\t\t\t\t\t*jsonapi_model_class.attribute_names\n\t\t\t\t\t\t).reject do |key, value|\n\t\t\t\t\t\t\t# ignore automatically generated attributes\n\t\t\t\t\t\t\t%w(\n\t\t\t\t\t\t\t\tid \n\t\t\t\t\t\t\t\tcreated_at created_on \n\t\t\t\t\t\t\t\tupdated_at updated_on\n\t\t\t\t\t\t\t).include?(\n\t\t\t\t\t\t\t\tkey.to_s\n\t\t\t\t\t\t\t) or \n\n\t\t\t\t\t\t\t# ignore reference attributes\n\t\t\t\t\t\t\tkey.to_s =~ /_id$/\n\t\t\t\t\t\tend\n\t\t\t\t\trescue ActionController::ParameterMissing => e\n\t\t\t\t\t\tnil\n\t\t\t\t\tend\n\t\t\t\tend", "def adjust_params \n #if request is like this:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations\n if params[:action] == 'index'\n \n # If it is \n # GET /relations\n # Then we cannot sevice this request, must specify the entity.\n# if !params[:database_id] and !params[:entity_id]\n# render :text => 'GET /relations is not available', :status => 400\n# return false;\n# end\n\n # But in the remaining two cases:\n # * /entities/relations\n # * /databases/entities/relations\n # Allow the class\n return true;\n end\n \n # if it is:\n # GET /relations\n # GET /entities/relations\n # GET /databases/entities/relations/\n # Becasue show needs to have an ID, therefore\n # any of the above URL will do and no context is needed.\n #FIXME: What other possibility the show action might face?\n if params[:action] == 'show'\n return true;\n end\n \n #If its like this:\n # POST /relations\n # POST /entities/relations\n # POST /databases/entities/relations\n # NOTE: For now, the relation resource should be totally complete\n # even if the call is being as a nested resource.\n #\n if params[:action] == 'create'\n \n #if it is like this:\n # POST /relations\n # Then the relations resource should be complete in\n # every respect.\n if !params[:database_id] and !params[:entity_id]\n #return true if valid_relation_resource?\n # Otherwise, the resource is not vaild and we need to tell the user\n #render :json => report_errors(nil, 'The provided realtion resource is incomplete')[0], \n # :status => 400 and return false;\n end\n \n # But if its something like this:\n # POST /entities/:entity_id/relations\n # POST /databases/entities/:entity_id/relations\n #\n if params[:database_id] or params[:entity_id]\n # Then if the relation resource is valid, \n # the entity_id parameter is altogather ignored.\n #return true if valid_relation_resource? \n end\n return true\n end\n \n # if its either of these:\n # PUT /relations\n # PUT /entities/relations\n # PUT /databases/entities/relations\n #\n if params[:action] == 'update'\n # Set the params[:relation_id] because\n # the underlying Admin::EntitiesController#add_link function\n # expects it\n params[:relation_id] = params[:id] and return true;\n end\n \n # If it is either of these:\n # DELETE /relations\n # DELETE /entities/relations\n # DELETE /databases/entities/relations\n #\n if params[:action] == 'destroy'\n \n # For now, you can only make a nested call.\n #PENDING: This would change when the rest call would include the user\n # authenticiy information which would help to determine whether the \n # relation being deleted belongs to the user or not.\n if !params[:entity_id]\n render :json => report_errors(nil, 'DELETE /relations call is not available for now. Call DELETE /entities/relations instead')[0],\n :status => 400 and return false\n end\n \n params[:source_id] = params[:entity_id]\n return true;\n \n end\n \n # In all cases, the request is not handled by this controller!\n render :json => report_errors(nil, \"The requested action is \\\"#{params[:action]}\\\" \" + \n \" on controller \\\"#{params[:controller]}\\\" while I am\" + \n \" \\\"#{self.class.name}\\\" and cannot handle your request.\")[0],:status => 400 and return false;\n \n end", "def get_field_deserializers()\n return super.merge({\n \"additionalTags\" => lambda {|n| @additional_tags = n.get_collection_of_primitive_values(String) },\n \"contentWebUrl\" => lambda {|n| @content_web_url = n.get_string_value() },\n \"contributors\" => lambda {|n| @contributors = n.get_collection_of_primitive_values(String) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"description\" => lambda {|n| @description = n.get_string_value() },\n \"duration\" => lambda {|n| @duration = n.get_duration_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"format\" => lambda {|n| @format = n.get_string_value() },\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n \"isPremium\" => lambda {|n| @is_premium = n.get_boolean_value() },\n \"isSearchable\" => lambda {|n| @is_searchable = n.get_boolean_value() },\n \"languageTag\" => lambda {|n| @language_tag = n.get_string_value() },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"numberOfPages\" => lambda {|n| @number_of_pages = n.get_number_value() },\n \"skillTags\" => lambda {|n| @skill_tags = n.get_collection_of_primitive_values(String) },\n \"sourceName\" => lambda {|n| @source_name = n.get_string_value() },\n \"thumbnailWebUrl\" => lambda {|n| @thumbnail_web_url = n.get_string_value() },\n \"title\" => lambda {|n| @title = n.get_string_value() },\n })\n end", "def url\n \"/#{self.class.rest_name}s/#{id}\"\n end", "def preflight; end", "def api_model\n api_model_nane.constantize\n end", "def posts\n ActiveModelSerializers::SerializableResource.new(object.posts, each_serializer: CreatorSerializer)\n end", "def make_and_model; end", "def index\n # Bad example\n # Exposes implementation details in controller\n # Produces unnecessary duplication\n # Complicates writing tests\n # => Should be placed in a model\n # @items = Item.where('published = ? AND published_on > ?', true, 2.days.ago)\n\n # Better example\n # Using scopes\n @items = Item.published.by_user(nil)\n\n\n # Bad example\n # Serialization logic should not be placed in the controller\n # respond_to do |format|\n # format.html\n # format.json {\n # render json: @items,\n # except: [:created_at, :updated_at],\n # include: { comments: {only: :id} }\n # }\n # end\n\n respond_to do |format|\n format.html\n\n # Render json using the default serializer ItemSerializer\n format.json { render json: @items }\n\n # Render json using a specific serializer\n # format.json { render json: @items, serializer: CustomItemSerializer }\n\n # Render json without the root\n # format.json { render json: @items, root: false }\n end\n\n end", "def test_render_using_implicit_serializer\n get :render_using_implicit_serializer\n\n assert_equal 'application/json', @response.content_type\n assert_equal '{\"name\":\"Name 1\",\"description\":\"Description 1\"}', @response.body\n end", "def private; end", "def request_model\n model = {\n 'content_snapshot': Base64.strict_encode64(snapshot.to_s),\n 'meta': {\n 'signs': signatures\n }\n }\n\n if validation_token\n model[:meta][:validation] = {'token': validation_token.value}\n end\n if relations\n model[:meta][:relations] = relations\n end\n\n return model\n end", "def test_create_a_task_with_valid_attributes\n post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1 } } # post '/tasks', { task: { title: \"something\", description: \"else\", user_id: 1, status_id: 1 } }\n assert_equal 1, Task.count # count is a method that ActiveRecord gives us\n assert_equal 200, last_response.status\n assert_equal \"created!\", last_response.body\n end", "def to_api\n\n results = {\n 'page_id' => id,\n 'name' => name,\n 'description' => description,\n 'template_name' => template_name,\n 'url_fragment' => url_fragment,\n 'url_redirect' => url_redirect,\n 'url_redirect_property' => url_redirect_property\n }\n return results;\n\n end", "def get_field_deserializers()\n return super.merge({\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"resourceActions\" => lambda {|n| @resource_actions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::UnifiedRbacResourceAction.create_from_discriminator_value(pn) }) },\n })\n end", "def pre_process_exposed_object(resource, type, singular)\n end", "def get_field_deserializers()\n return {\n \"assignCategories\" => lambda {|n| @assign_categories = n.get_collection_of_primitive_values(String) },\n \"copyToFolder\" => lambda {|n| @copy_to_folder = n.get_string_value() },\n \"delete\" => lambda {|n| @delete = n.get_boolean_value() },\n \"forwardAsAttachmentTo\" => lambda {|n| @forward_as_attachment_to = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"forwardTo\" => lambda {|n| @forward_to = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"markAsRead\" => lambda {|n| @mark_as_read = n.get_boolean_value() },\n \"markImportance\" => lambda {|n| @mark_importance = n.get_enum_value(MicrosoftGraph::Models::Importance) },\n \"moveToFolder\" => lambda {|n| @move_to_folder = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"permanentDelete\" => lambda {|n| @permanent_delete = n.get_boolean_value() },\n \"redirectTo\" => lambda {|n| @redirect_to = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Recipient.create_from_discriminator_value(pn) }) },\n \"stopProcessingRules\" => lambda {|n| @stop_processing_rules = n.get_boolean_value() },\n }\n end", "def test_update_model_with_body()\n # Parameters for the API call\n model = Employee.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"Shahid Khaliq\",\"age\":5147483645,\"address\":\"H # 531, S # 20\",\"u'\\\n 'id\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9'\\\n '571247Z\",\"salary\":20000,\"department\":\"Software Development\",\"joiningDay'\\\n '\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"boss\":{\"perso'\\\n 'nType\":\"Boss\",\"name\":\"Zeeshan Ejaz\",\"age\":5147483645,\"address\":\"H # 531'\\\n ', S # 20\",\"uid\":\"123321\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-1'\\\n '3T14:01:54.9571247Z\",\"salary\":20000,\"department\":\"Software Development\"'\\\n ',\"joiningDay\":\"Saturday\",\"workingDays\":[\"Monday\",\"Tuesday\",\"Friday\"],\"d'\\\n 'ependents\":[{\"name\":\"Future Wife\",\"age\":5147483649,\"address\":\"H # 531, '\\\n 'S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994-02-13T'\\\n '14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age\":5147483648,\"address\":\"H '\\\n '# 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"1994-02-13\",\"birthtime\":\"1994'\\\n '-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 06 Nov 1994 08:49:37 GMT\",\"'\\\n 'promotedAt\":1484719381},\"dependents\":[{\"name\":\"Future Wife\",\"age\":51474'\\\n '83649,\"address\":\"H # 531, S # 20\",\"uid\":\"123412\",\"birthday\":\"1994-02-13'\\\n '\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"},{\"name\":\"Future Kid\",\"age'\\\n '\":5147483648,\"address\":\"H # 531, S # 20\",\"uid\":\"312341\",\"birthday\":\"199'\\\n '4-02-13\",\"birthtime\":\"1994-02-13T14:01:54.9571247Z\"}],\"hiredAt\":\"Sun, 0'\\\n '6 Nov 1994 08:49:37 GMT\"}'\n ))\n\n # Perform the API call through the SDK function\n result = @controller.update_model(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 service_type_name\n \"REST\"\n end", "def with_serializer(object, serializer); end", "def index\n serialized_paths = ActiveModel::ArraySerializer.new(MODEL.all,\n each_serializer: PathSerializer).serializable_array\n serialized = ActiveModel::ArraySerializer.new(Item.all,\n each_serializer: ItemSerializer).serializable_array\n user_paths = ActiveModel::ArraySerializer.new(UserPath.all,\n each_serializer: UserPathSerializer).serializable_array\n\n render json: {\n paths: serialized_paths,\n items: serialized,\n user_paths: user_paths\n }\n# , meta: { current_user: current_user }\n end", "def get_field_deserializers()\n return super.merge({\n \"bundles\" => lambda {|n| @bundles = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DriveItem.create_from_discriminator_value(pn) }) },\n \"driveType\" => lambda {|n| @drive_type = n.get_string_value() },\n \"following\" => lambda {|n| @following = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DriveItem.create_from_discriminator_value(pn) }) },\n \"items\" => lambda {|n| @items = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DriveItem.create_from_discriminator_value(pn) }) },\n \"list\" => lambda {|n| @list = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::List.create_from_discriminator_value(pn) }) },\n \"owner\" => lambda {|n| @owner = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IdentitySet.create_from_discriminator_value(pn) }) },\n \"quota\" => lambda {|n| @quota = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Quota.create_from_discriminator_value(pn) }) },\n \"root\" => lambda {|n| @root = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::DriveItem.create_from_discriminator_value(pn) }) },\n \"sharePointIds\" => lambda {|n| @share_point_ids = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SharepointIds.create_from_discriminator_value(pn) }) },\n \"special\" => lambda {|n| @special = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DriveItem.create_from_discriminator_value(pn) }) },\n \"system\" => lambda {|n| @system = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SystemFacet.create_from_discriminator_value(pn) }) },\n })\n end", "def create_record_for_not_found_response; end", "def get_field_deserializers()\n return super.merge({\n \"comment\" => lambda {|n| @comment = n.get_string_value() },\n \"createdBy\" => lambda {|n| @created_by = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IdentitySet.create_from_discriminator_value(pn) }) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"items\" => lambda {|n| @items = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::DocumentSetVersionItem.create_from_discriminator_value(pn) }) },\n \"shouldCaptureMinorVersion\" => lambda {|n| @should_capture_minor_version = n.get_boolean_value() },\n })\n end", "def jsonapi_model_type\n\t\t\t\t\tjsonapi_model_class_name.underscore.pluralize.to_sym\n\t\t\t\tend", "def get_one\n serialize_test\n end", "def get_field_deserializers()\n return super.merge({\n \"distributeForStudentWork\" => lambda {|n| @distribute_for_student_work = n.get_boolean_value() },\n \"resource\" => lambda {|n| @resource = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::EducationResource.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"activationUrl\" => lambda {|n| @activation_url = n.get_string_value() },\n \"activitySourceHost\" => lambda {|n| @activity_source_host = n.get_string_value() },\n \"appActivityId\" => lambda {|n| @app_activity_id = n.get_string_value() },\n \"appDisplayName\" => lambda {|n| @app_display_name = n.get_string_value() },\n \"contentInfo\" => lambda {|n| @content_info = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n \"contentUrl\" => lambda {|n| @content_url = n.get_string_value() },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"expirationDateTime\" => lambda {|n| @expiration_date_time = n.get_date_time_value() },\n \"fallbackUrl\" => lambda {|n| @fallback_url = n.get_string_value() },\n \"historyItems\" => lambda {|n| @history_items = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ActivityHistoryItem.create_from_discriminator_value(pn) }) },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::Status) },\n \"userTimezone\" => lambda {|n| @user_timezone = n.get_string_value() },\n \"visualElements\" => lambda {|n| @visual_elements = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::VisualInfo.create_from_discriminator_value(pn) }) },\n })\n end", "def test_params\n ActiveModelSerializers::Deserialization.jsonapi_parse(params)\n #params.require(:data).require(:attributes).permit(:name, :state, :feature_id)\n end", "def api_error; end", "def get_field_deserializers()\n return super.merge({\n \"content\" => lambda {|n| @content = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"size\" => lambda {|n| @size = n.get_object_value(lambda {|pn| Int64.create_from_discriminator_value(pn) }) },\n })\n end", "def apply_ammendments(api_schema)\n api_schema.fetch(:apis).each do |endpoint|\n endpoint.fetch(:operations).each do |method|\n method[:nickname] = method[:nickname].sub('Api::V1::', '') unless method[:nickname].nil?\n method[:consumes] = ['application/x-www-form-urlencoded'] if ['post', 'patch', 'put', 'delete'].include? method[:method].downcase\n\n method[:parameters].each do |p|\n p[:required] = true if p[:required] == 'required'\n\n case p[:type]\n when 'date'\n p[:type] = 'string'\n p[:format] = 'date'\n when 'datetime'\n p[:type] = 'string'\n p[:format] = 'date-time'\n end\n\n p[:name] = :payload if p[:paramType] == 'body' && p[:name] == ''\n p[:'allowMultiple'] = true if p[:name] == 'state' # actually API allows multiple states in query\n end\n\n method[:responseMessages].each do |response_message|\n next unless response_message[:message].match?(/pdf/i)\n\n response_message[:responseModel] ||= 'File'\n method[:produces] ||= ['application/pdf', 'application/json']\n end\n end\n end\n\n\n api_schema.fetch(:models).values.each do |model|\n if model.fetch(:id) == 'Order'\n model.fetch(:properties)['updated_at'] ||= {:type=>\"date-time\", :description=>nil}\n end\n\n model.fetch(:properties).each do |name, property|\n case property[:type]\n when 'complex'\n property[:type] = [:items, :purchase_items].include?(name) ? 'array' : property[:items][:'$ref']\n when 'date'\n property[:type] = 'date-time'\n end\n end\n end\nend", "def comments; rest_query(:comment); end", "def rest_params\n params.require(:rest).permit(:name, :address, :description, :owner, :phone)\n end", "def run\n super\n\n # start with negative\n api_endpoint = nil\n api_reason = nil\n\n require_enrichment\n\n # get our url\n url = _get_entity_name\n\n ###\n # First just check our fingerprint, lots of stuff will already have been\n # fingerprinted during our ident run\n ###\n (_get_entity_detail(\"fingerprint\") || []).each do |fp|\n api_endpoint = true if fp[\"tags\"] && fp[\"tags\"].include?(\"API\")\n api_reason = \"fingerprint\"\n end\n\n # first get a standard response\n standard_response = http_request :get, url\n return unless standard_response\n\n ####\n # next just check keywords in the url, but of course, sanity check this.\n ###\n if ( url.match(/api\\./) ||\n url.match(/apis\\./) ||\n url.match(/\\/api/) ||\n url.match(/\\/json/) ||\n url.match(/\\.json/) ||\n url.match(/\\.xml/) ||\n url.match(/skiptoken/) ||\n url.match(/\\/restapis/) )\n\n unless (\n url.match(/googleapis/) ||\n url.match(/\\.amazonaws\\.com/) ||\n standard_response.body_utf8.match(/^<HTML>/i) ||\n standard_response.body_utf8.match(/HTTP Status 404/i) ||\n standard_response.body_utf8.match(/NoSuchBucket/i) ) \n api_endpoint = true\n api_reason = \"url\"\n end\n\n end\n\n ###\n ### If we made it this far, and our base url matches, just return that\n if api_endpoint\n _create_api_endpoint(url, url, api_reason)\n return # return if our base URL was an endpoint\n end\n\n ####\n # otherwise check patterns in / around the original\n ####\n\n # always start empty\n api_endpoint = nil\n\n [\n \"#{url}\",\n \"#{url}/api\",\n \"#{url}/api/v1\",\n \"#{url}/api/v2\",\n \"#{url}/api/v3\",\n \"#{url}/docs\",\n \"#{url}/graphql\",\n \"#{url}/api-docs\",\n \"#{url}/api-docs/swagger.json\",\n \"#{url}/api/swagger\",\n \"#{url}/api/swagger-ui.html\",\n \"#{url}/api/swagger.yml\",\n \"#{url}/api/v2/swagger.json\",\n \"#{url}/apidocs\",\n \"#{url}/apidocs/swagger.json\",\n \"#{url}/rest\",\n \"#{url}/swagger\",\n \"#{url}/swagger/\",\n \"#{url}/swagger-resources\",\n \"#{url}/swagger-ui\",\n \"#{url}/swagger-ui.html\",\n \"#{url}/swagger.json\",\n \"#{url}/swagger/index.html\",\n \"#{url}/swagger/swagger-ui.html\",\n \"#{url}/swagger/ui/index\",\n \"#{url}/swagger/v1/swagger.json\",\n \"#{url}/v1/swagger.json\"\n ].each do |u|\n\n _log \"Checking... #{u}\"\n\n # Go ahead and get the response for this paritcular endpoint\n\n response = http_request :get, u\n\n next unless response\n # skip if we're not the original url, but we're getting the same response\n\n next if u != url && response.body_utf8 == standard_response.body_utf8\n\n ###\n ### Check for known strings\n ###\n if (response.body_utf8.match(/swagger-section/) ||\n response.body_utf8.match(/swaggerhub.com/) ||\n response.body_utf8.match(/soapenv:Envelope/) )\n # break and create it\n api_reason = \"response_body\"\n api_endpoint = u\n break\n end\n\n # check for content type of application.. note that this will flag\n # application/javascript, which is probably not wanted\n headers = standard_response.headers\n if headers\n ct = headers.find{|x, y| x if x =~ /^content-type/i }\n if ct\n api_endpoint = u if \"#{headers[ct]}\".match(/^application\\/xml/i)\n api_endpoint = u if \"#{headers[ct]}\".match(/^application\\/json/i)\n api_endpoint = u if \"#{headers[ct]}\".match(/^application\\/ld+json/i)\n api_endpoint = u if \"#{headers[ct]}\".match(/^application\\/x-protobuf/i)\n api_endpoint = u if \"#{headers[ct]}\".match(/^application\\/octet-stream/i)\n api_endpoint = u if \"#{headers[ct]}\".match(/^text\\/csv/i)\n\n # break and create it\n if api_endpoint\n api_reason = \"content_type\"\n break\n end\n\n end\n end\n\n ###\n # try to parse it (JSON)\n ###\n begin\n # get request body\n body = standard_response.body_utf8\n if body\n json = JSON.parse(body)\n\n if json\n # now check for common error scenarios, and proceed if we pass\n break if json.kind_of?(Hash) && \n ((standard_response.code == \"404\" && json[\"error\"] == \"Not Found\") ||\n (standard_response.code == \"404\" && json[\"response\"] == \"Content was not found.\"))\n \n # create it as an api endpoint\n api_endpoint = u\n api_reason = \"json_body\"\n break\n end\n\n end\n rescue JSON::ParserError\n _log \"No body!\"\n end\n\n # check known fingeprints\n _log \"Attempting to fingerprint (without the browser)!\"\n ident_matches = generate_http_requests_and_check(u,{:enable_browser => false, :'only-check-base-url' => true}) || {}\n ident_fingerprints = ident_matches[\"fingerprint\"] || []\n ident_fingerprints.each do |fp|\n api_endpoint = u if fp[\"tags\"] && fp[\"tags\"].include?(\"API\")\n # break if it's been set so we dont genereate a bunch of FP's\n if api_endpoint\n api_reason = \"fingerprint\"\n break\n end\n end\n end\n\n ###\n ### Okay now that we're at the end, do we have an endpoint?!?\n ###\n\n # set the details and create a new entity if we made it this far!\n if api_endpoint\n _create_api_endpoint(url, api_endpoint, api_reason)\n else\n _set_entity_detail \"api_endpoint\", false\n end\n\n end", "def get_field_deserializers()\n return super.merge({\n \"healthOverviews\" => lambda {|n| @health_overviews = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ServiceHealth.create_from_discriminator_value(pn) }) },\n \"issues\" => lambda {|n| @issues = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ServiceHealthIssue.create_from_discriminator_value(pn) }) },\n \"messages\" => lambda {|n| @messages = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ServiceUpdateMessage.create_from_discriminator_value(pn) }) },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"applicationName\" => lambda {|n| @application_name = n.get_string_value() },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"webUrl\" => lambda {|n| @web_url = n.get_string_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"approvalId\" => lambda {|n| @approval_id = n.get_string_value() },\n \"completedDateTime\" => lambda {|n| @completed_date_time = n.get_date_time_value() },\n \"createdBy\" => lambda {|n| @created_by = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::IdentitySet.create_from_discriminator_value(pn) }) },\n \"createdDateTime\" => lambda {|n| @created_date_time = n.get_date_time_value() },\n \"customData\" => lambda {|n| @custom_data = n.get_string_value() },\n \"status\" => lambda {|n| @status = n.get_string_value() },\n })\n end", "def get_nested_resource_objects\n end", "def get_field_deserializers()\n return super.merge({\n \"content\" => lambda {|n| @content = n.get_object_value(lambda {|pn| Base64url.create_from_discriminator_value(pn) }) },\n \"contentUrl\" => lambda {|n| @content_url = n.get_string_value() },\n \"createdByAppId\" => lambda {|n| @created_by_app_id = n.get_string_value() },\n \"lastModifiedDateTime\" => lambda {|n| @last_modified_date_time = n.get_date_time_value() },\n \"level\" => lambda {|n| @level = n.get_number_value() },\n \"links\" => lambda {|n| @links = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::PageLinks.create_from_discriminator_value(pn) }) },\n \"order\" => lambda {|n| @order = n.get_number_value() },\n \"parentNotebook\" => lambda {|n| @parent_notebook = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Notebook.create_from_discriminator_value(pn) }) },\n \"parentSection\" => lambda {|n| @parent_section = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::OnenoteSection.create_from_discriminator_value(pn) }) },\n \"title\" => lambda {|n| @title = n.get_string_value() },\n \"userTags\" => lambda {|n| @user_tags = n.get_collection_of_primitive_values(String) },\n })\n end", "def from_response(user, response)\n base_documents_data = response['documents']\n base_documents_data.map do |base_document_data|\n physical_docs = base_document_data['physical_docs'].map do |data|\n doc = PhysicalDocument.from_response(data)\n doc.base_document = self\n doc\n end\n social_docs = base_document_data['social_docs'].map do |data|\n doc = SocialDocument.from_response(data)\n doc.base_document = self\n doc\n end\n virtual_docs = base_document_data['virtual_docs'].map do |data|\n doc = VirtualDocument.from_response(data)\n doc.base_document = self\n doc\n end\n\n args = {\n \"user\"=>user,\n \"id\"=>base_documents_data.first['id'],\n \"name\"=>base_documents_data.first['name'],\n \"permission_scope\"=>base_documents_data.first['permission_scope'],\n \"address_city\"=>base_documents_data.first['address_city'],\n \"address_country_code\"=>base_documents_data.first['address_country_code'],\n \"address_postal_code\"=>base_documents_data.first['address_postal_code'],\n \"address_street\"=>base_documents_data.first['address_street'],\n \"address_subdivision\"=>base_documents_data.first['address_subdivision'],\n \"alias\"=>base_documents_data.first['alias'],\n \"birth_day\"=>base_documents_data.first['day'],\n \"email\"=>base_documents_data.first['email'],\n \"entity_scope\"=>base_documents_data.first['entity_scope'],\n \"entity_type\"=>base_documents_data.first['entity_type'],\n \"ip\"=>base_documents_data.first['ip'],\n \"birth_month\"=>base_documents_data.first['month'],\n \"phone_number\"=>base_documents_data.first['phone_number'],\n \"birth_year\"=>base_documents_data.first['year'],\n \"screening_results\"=>base_documents_data.first['screening_results'],\n \"physical_documents\"=>physical_docs,\n \"social_documents\"=>social_docs,\n \"virtual_documents\"=>virtual_docs\n }\n\n other_keys = base_document_data.keys\n\n [\"physical_docs\", \"social_docs\", \"virtual_docs\"].each do |item|\n other_keys.delete_at(other_keys.index(item))\n end\n\n for key in other_keys do\n if base_document_data.has_key?(key)\n args[key] = base_document_data[key]\n end\n end\n\n base_doc = self.new(args)\n [physical_docs, social_docs, virtual_docs].flatten.each do |doc|\n doc.base_document = base_doc\n end\n\n base_doc\n end\n end", "def get_field_deserializers()\n return super.merge({\n \"acceptances\" => lambda {|n| @acceptances = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AgreementAcceptance.create_from_discriminator_value(pn) }) },\n \"displayName\" => lambda {|n| @display_name = n.get_string_value() },\n \"file\" => lambda {|n| @file = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::AgreementFile.create_from_discriminator_value(pn) }) },\n \"files\" => lambda {|n| @files = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AgreementFileLocalization.create_from_discriminator_value(pn) }) },\n \"isPerDeviceAcceptanceRequired\" => lambda {|n| @is_per_device_acceptance_required = n.get_boolean_value() },\n \"isViewingBeforeAcceptanceRequired\" => lambda {|n| @is_viewing_before_acceptance_required = n.get_boolean_value() },\n \"termsExpiration\" => lambda {|n| @terms_expiration = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::TermsExpiration.create_from_discriminator_value(pn) }) },\n \"userReacceptRequiredFrequency\" => lambda {|n| @user_reaccept_required_frequency = n.get_duration_value() },\n })\n end", "def get_field_deserializers()\n return super.merge({\n \"clientContext\" => lambda {|n| @client_context = n.get_string_value() },\n \"resultInfo\" => lambda {|n| @result_info = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::ResultInfo.create_from_discriminator_value(pn) }) },\n \"status\" => lambda {|n| @status = n.get_enum_value(MicrosoftGraph::Models::OperationStatus) },\n })\n end", "def 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 rest\n @@rest\n end", "def get_field_deserializers()\n return super.merge({\n \"acceptedDateTime\" => lambda {|n| @accepted_date_time = n.get_date_time_value() },\n \"acceptedVersion\" => lambda {|n| @accepted_version = n.get_number_value() },\n \"termsAndConditions\" => lambda {|n| @terms_and_conditions = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::TermsAndConditions.create_from_discriminator_value(pn) }) },\n \"userDisplayName\" => lambda {|n| @user_display_name = n.get_string_value() },\n \"userPrincipalName\" => lambda {|n| @user_principal_name = n.get_string_value() },\n })\n end", "def api_deserialize_impl(r)\n @is_new = (r).nil?\n r = {} if @is_new\n @is_incomplete = false\n if Saklient::Util::exists_path(r, 'ID')\n @m_id = (Saklient::Util::get_by_path(r, 'ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'ID').to_s\n else\n @m_id = nil\n @is_incomplete = true\n end\n @n_id = false\n if Saklient::Util::exists_path(r, 'Name')\n @m_name = (Saklient::Util::get_by_path(r, 'Name')).nil? ? nil : Saklient::Util::get_by_path(r, 'Name').to_s\n else\n @m_name = nil\n @is_incomplete = true\n end\n @n_name = false\n if Saklient::Util::exists_path(r, 'CPU')\n @m_cpu = (Saklient::Util::get_by_path(r, 'CPU')).nil? ? nil : (Saklient::Util::get_by_path(r, 'CPU').to_s).to_s().to_i(10)\n else\n @m_cpu = nil\n @is_incomplete = true\n end\n @n_cpu = false\n if Saklient::Util::exists_path(r, 'MemoryMB')\n @m_memory_mib = (Saklient::Util::get_by_path(r, 'MemoryMB')).nil? ? nil : (Saklient::Util::get_by_path(r, 'MemoryMB').to_s).to_s().to_i(10)\n else\n @m_memory_mib = nil\n @is_incomplete = true\n end\n @n_memory_mib = false\n if Saklient::Util::exists_path(r, 'ServiceClass')\n @m_service_class = (Saklient::Util::get_by_path(r, 'ServiceClass')).nil? ? nil : Saklient::Util::get_by_path(r, 'ServiceClass').to_s\n else\n @m_service_class = nil\n @is_incomplete = true\n end\n @n_service_class = false\n end", "def get_field_deserializers()\n return super.merge({\n \"accessPackageAssignmentApprovals\" => lambda {|n| @access_package_assignment_approvals = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::Approval.create_from_discriminator_value(pn) }) },\n \"accessPackages\" => lambda {|n| @access_packages = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackage.create_from_discriminator_value(pn) }) },\n \"assignmentPolicies\" => lambda {|n| @assignment_policies = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageAssignmentPolicy.create_from_discriminator_value(pn) }) },\n \"assignmentRequests\" => lambda {|n| @assignment_requests = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageAssignmentRequest.create_from_discriminator_value(pn) }) },\n \"assignments\" => lambda {|n| @assignments = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageAssignment.create_from_discriminator_value(pn) }) },\n \"catalogs\" => lambda {|n| @catalogs = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageCatalog.create_from_discriminator_value(pn) }) },\n \"connectedOrganizations\" => lambda {|n| @connected_organizations = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ConnectedOrganization.create_from_discriminator_value(pn) }) },\n \"resourceEnvironments\" => lambda {|n| @resource_environments = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageResourceEnvironment.create_from_discriminator_value(pn) }) },\n \"resourceRequests\" => lambda {|n| @resource_requests = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageResourceRequest.create_from_discriminator_value(pn) }) },\n \"resourceRoleScopes\" => lambda {|n| @resource_role_scopes = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageResourceRoleScope.create_from_discriminator_value(pn) }) },\n \"resources\" => lambda {|n| @resources = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AccessPackageResource.create_from_discriminator_value(pn) }) },\n \"settings\" => lambda {|n| @settings = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::EntitlementManagementSettings.create_from_discriminator_value(pn) }) },\n })\n end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end" ]
[ "0.60622853", "0.602124", "0.5985522", "0.5901344", "0.5867935", "0.5834146", "0.5834146", "0.58213454", "0.58213454", "0.5779181", "0.5724512", "0.5716377", "0.5697014", "0.5697014", "0.5697014", "0.56918365", "0.56910825", "0.56634295", "0.5626107", "0.5601423", "0.5601423", "0.5574162", "0.5570557", "0.5553343", "0.5553343", "0.5536491", "0.5536393", "0.5535775", "0.55293363", "0.5505553", "0.5505553", "0.5505553", "0.5505553", "0.55015707", "0.5499177", "0.5498575", "0.54934764", "0.5467453", "0.5459088", "0.54519427", "0.5436323", "0.5432403", "0.54314554", "0.5424442", "0.54156053", "0.54140437", "0.54116493", "0.5408923", "0.5397574", "0.5395735", "0.5389296", "0.5383356", "0.53826207", "0.53811884", "0.5381028", "0.5372259", "0.5369571", "0.5352766", "0.5347904", "0.53447276", "0.53439516", "0.5335582", "0.5328826", "0.5322639", "0.5314854", "0.5312063", "0.5309363", "0.53028774", "0.52959555", "0.5292371", "0.52920413", "0.52915025", "0.52903926", "0.52895916", "0.52822727", "0.5282153", "0.5281899", "0.5279256", "0.5278228", "0.5277404", "0.5275667", "0.52739096", "0.5272908", "0.52704716", "0.52655894", "0.5261043", "0.5260514", "0.52597773", "0.5254753", "0.52493423", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864", "0.5248864" ]
0.0
-1
Merge the current Hash object (self) cloned with a Hash/Array tree contents (data). 'self' is used as original data to merge to. 'data' is used as data to merged to clone of 'self'. If you want to update 'self', use rh_merge! if 'self' or 'data' contains a Hash tree, the merge will be executed recursively. The current function will execute the merge of the 'self' keys with the top keys in 'data' The merge can be controlled by an additionnal Hash key '__' in each 'self' key. If both a exist in 'self' and 'data', the following decision is made: if both 'self' and 'data' key contains an Hash or and Array, a recursive merge if Hash or update if Array, is started. if 'self' contains an Hash or an Array, but not 'data' , then 'self' will be set to the 'data' except if 'self' has :__struct_changing: true data value can set :unset value if 'self' is :unset and 'data' is any value 'self' value is set with 'data' value. 'data' value can contains a Hash with :__no_unset: true to protect this key against the next merge. (next config layer merge) if 'data' exist but not in 'self', 'data' is just added. if 'data' & 'self' exist, 'self' is updated except if key is in :__protected array list. Args : hash : Hash data to merge. Returns : Recursive Array/Hash merged. Raises : Nothing examples:
def rh_merge(data) _rh_merge(clone, data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _rh_merge(result, data)\n return _rh_merge_choose_data(result, data) unless data.is_a?(Hash)\n\n data.each do |key, _value|\n next if [:__struct_changing, :__protected].include?(key)\n\n _do_rh_merge(result, key, data)\n end\n [:__struct_changing, :__protected].each do |key|\n # Refuse merge by default if key data type are different.\n # This assume that the first layer merge has set\n # :__unset as a Hash, and :__protected as an Array.\n\n _do_rh_merge(result, key, data, true) if data.key?(key)\n\n # Remove all control element in arrays\n _rh_remove_control(result[key]) if result.key?(key)\n end\n\n result\n end", "def rh_merge!(data)\n _rh_merge(self, data)\n end", "def deep_merge!(hash)\n # failsafe\n return if !hash.is_a?(Hash)\n for key in hash.keys\n if self[key].is_a?(Hash)\n self[key].deep_merge!(hash[key])\n else\n self[key] = hash[key]\n end\n end\n end", "def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_merge!(value)\n else\n result[key] = result[key].rh_merge(value)\n end\n\n true\n end", "def deep_merge!(data)\n merger = lambda do |_key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n merge!(data, &merger)\n end", "def deep_merge!(other_hash, append: :auto, &block)\n\t\t\t\treturn self unless other_hash\n\t\t\t\tother_hash.each_pair do |k,v|\n\t\t\t\t\ttv = self[k]\n\t\t\t\t\tcase\n\t\t\t\t\twhen tv.is_a?(Hash) && v.is_a?(Hash)\n\t\t\t\t\t\tself[k] = tv.deep_merge(v, &block)\n\t\t\t\t\twhen tv.is_a?(Array) && v.is_a?(Array)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\t#hack: if the array begins with nil, we append the new\n\t\t\t\t\t\t\t#value rather than overwrite it\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telsif append && append != :auto\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\twhen tv.nil? && v.is_a?(Array)\n\t\t\t\t\t\t#here we still need to remove nil (see above)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k]=v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend", "def deep_merge!(hsh1, hsh2)\n raise TypeError unless hsh1.is_a?(Hash) && hsh2.is_a?(Hash)\n\n hsh1.merge!(hsh2) { |_, v1, v2| deep_merge!(v1, v2) }\n end", "def merge!(hsh)\n raise ArgumentError, 'block version not supported' if block_given?\n self.hmset(*hsh.to_a.flatten)\n self\n end", "def merge(hash); end", "def merge(hash); end", "def merge(hash); end", "def deep_merge!(hash_or_config)\n return self if hash_or_config.nil?\n other_config = convert hash_or_config\n other_config.each do |key, other_value|\n value = has_key?(key) && self[key]\n self[key] = if ConfigNode === value && ConfigNode === other_value\n value.deep_merge!(other_value)\n elsif ConfigNode === value && other_value.nil?\n self[key]\n else\n other_value\n end\n end\n self\n end", "def merge(hash)\n @hash.merge!(hash) if hash.respond_to?(:keys) && hash.any?\n self\n end", "def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n # We can't use use this.val.is_a?(Hash) because inside the refinement\n # returns false:\n # - refined_hash.class != Hash\n if this_val.class.name == \"Hash\" && other_val.class.name == \"Hash\"\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def deep_merge (h)\n self.merge(h) do |k, old, new|\n begin\n AccountTree.new(old).deep_merge(AccountTree.new(new))\n rescue\n new\n end\n end\n end", "def deep_merge(other_hash, &blk)\n dup.deep_update(other_hash, &blk)\n end", "def deep_merge!(*other_hashes, &blk); end", "def deep_merge(*other_hashes, &blk); end", "def _deep_merge(hash1, hash2)\n hash1.merge(hash2) do |key, oldval, newval|\n if oldval.instance_of?(Hash) && newval.instance_of?(Hash)\n _deep_merge(oldval, newval)\n else\n newval\n end\n end\n end", "def _do_rh_merge(result, key, data, refuse_discordance = false)\n value = data[key]\n\n return if _rh_merge_do_add_key(result, key, value)\n\n return if _rh_merge_recursive(result, key, data)\n\n return if refuse_discordance\n\n return unless _rh_struct_changing_ok?(result, key, data)\n\n return unless _rh_merge_ok?(result, key)\n\n _rh_merge_do_upd_key(result, key, value)\n end", "def deep_merge(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n oldval = oldval.to_hash if oldval.respond_to?(:to_hash)\n newval = newval.to_hash if newval.respond_to?(:to_hash)\n oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval\n end\n end", "def merge(other_hash)\n ret = self.class.new.merge!(self)\n ret.merge!(other_hash) if other_hash != self\n return ret\n end", "def deep_merge!(hash, other_hash, &block)\n hash.merge!(other_hash) do |key, this_val, other_val|\n if this_val.class <= ::Hash && other_val.class <= ::Hash\n deep_merge(this_val, other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def deep_merge(hash)\n target = dup\n \n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n \n target[key] = hash[key]\n end\n \n target\n end", "def merge(hash)\n self.dup.update(hash)\n end", "def recursive_hash_merge(hash1, hash2)\n hash1.merge(hash2) {|k,o,n| (o.is_a?(Hash)) ? recursive_hash_merge(o,n) : n}\n end", "def deep_merge!(other_hash)\n other_hash.each do |k,v|\n (class << (tv = self[k]); self; end).send :include, Hashie::Extensions::DeepMerge\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def merge_hash!(hash)\n merge!(self.class.from_hash(hash))\n end", "def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def merge(hash)\n hash.each_value { |v| self << v }\n end", "def merge!(hash); end", "def deep_merge(hash)\n target = dup\n\n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n\n target[key] = hash[key]\n end\n\n target\n end", "def deep_merge!(other_hash, &block)\n other_hash.each_pair do |current_key, other_value|\n this_value = self[current_key]\n\n self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)\n this_value.deep_merge(other_value, &block)\n else\n if block_given? && key?(current_key)\n block.call(current_key, this_value, other_value)\n else\n other_value\n end\n end\n end\n\n self\n end", "def _deep_merge(hash, other_hash); end", "def deep_merge!(other_hash, &block); end", "def deep_merge(source, hash); end", "def deep_merge(source, hash); end", "def deep_merge!(other_hash, &block)\n other_hash.each_pair do |k,v|\n tv = self[k]\n if tv.is_a?(Hash) && v.is_a?(Hash)\n self[k] = tv.deep_merge(v, &block)\n else\n self[k] = block && tv ? block.call(k, tv, v) : v\n end\n end\n self\n end", "def merge!( other )\n\t\t\tcase other\n\t\t\twhen Hash\n\t\t\t\t@hash = self.to_h.merge( other,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen ConfigStruct\n\t\t\t\t@hash = self.to_h.merge( other.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen Arrow::Config\n\t\t\t\t@hash = self.to_h.merge( other.struct.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\telse\n\t\t\t\traise TypeError,\n\t\t\t\t\t\"Don't know how to merge with a %p\" % other.class\n\t\t\tend\n\n\t\t\t# :TODO: Actually check to see if anything has changed?\n\t\t\t@dirty = true\n\n\t\t\treturn self\n\t\tend", "def merge hash = {}\n original.merge(hash)\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def deep_merge!(target, hash); end", "def deep_merge!(target, hash); end", "def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def merge(hash)\n raise NoMethodError\n end", "def merge(*other_hashes, &blk); end", "def merge!(*other_hashes, &blk); end", "def deep_merge_hashes(master_hash, other_hash); end", "def merge(other_hash); end", "def deep_merge(left, right, path = [], &block)\n ret = nil\n\n if left.is_a? Hash and right.is_a? Hash\n ret = left.merge(right) do |key, left_val, right_val|\n path.push(key)\n merged = deep_merge(left_val, right_val, path)\n path.pop\n merged\n end\n elsif left.is_a? Array and right.is_a? Array\n ret = left.dup.concat(right)\n elsif right.nil?\n ret = left\n elsif left.nil?\n ret = right\n elsif left.nil? and right.nil?\n ret = nil\n else\n msg = \"Cannot merge #{left.inspect}:#{left.class} and #{right.inspect}:#{right.class}\"\n if not path.empty?\n msg << \" at root\"\n msg << path.map { |part| \"[#{part.inspect}]\" }.join\n end\n raise DeepMergeError, msg\n end\n\n ret\n end", "def deep_merge!(other_hash = {})\n replace(deep_merge(other_hash))\n end", "def merge_recursively(left, right)\n left.merge(right) { |_, a_item, b_item| a_item.is_a?(Hash) ? merge_recursively(a_item, b_item) : b_item }\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def internal_deep_merge!(source_hash, specialized_hash)\n\t\t\tspecialized_hash.each_pair do |rkey, rval|\n\t\t\t\tif source_hash.has_key?(rkey) then\n\t\t\t\t\tif rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then\n\t\t\t\t\t\tinternal_deep_merge!(source_hash[rkey], rval)\n\t\t\t\t\telsif rval == source_hash[rkey] then\n\t\t\t\t\telse\n\t\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\tend\n\t\t\tend\n\t\t\tsource_hash\n\t\tend", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def deep_merge(hash)\n dup.deep_merge! hash\n end", "def merge(base_hash, derived_hash); end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def merge other_hash\n self.class.new nested_class, to_h.merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)\n end", "def merge(newh)\n @hash.merge!(newh) do |key, oldval, newval|\n if oldval.is_a? Array\n oldval << newval\n else\n Array.new [oldval, newval]\n end\n end\n end", "def merge(base_hash, derived_hash, **opts); end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def deep_merge h1,h2\n r = h1.is_a?(HashWithIndifferentAccess) ? HashWithIndifferentAccess.new : Hash.new\n h1.each do |k1,v1|\n if v1.is_a?(Hash) && h2[k1].is_a?(Hash)\n r[k1] = deep_merge(h1[k1], h2[k1])\n else\n r[k1] = v1\n end\n end\n h2.each do |k2,v2|\n unless h1.key?(k2)\n r[k2] = v2\n end\n end\n r\n end", "def merge_config!(data, conf)\n # Catch edge-cases\n return if data.nil? || conf.nil?\n # Step through all conf items and create combined return value\n data.merge!(conf) do |_, v1, v2|\n if v1.is_a?(Array) && v2.is_a?(Array)\n # If both the data field and the conf field are arrays, then combine them\n v1 + v2\n elsif v1.is_a?(Hash) && v2.is_a?(Hash)\n # If both the data field and the conf field are maps, then deep merge them\n merge_config!(v1, v2)\n else\n # All other cases, just use the new value (regular merge behavior)\n v2\n end\n end\n end", "def merge!(hash)\n hash.each { |k, v| self[k]= v }\n end", "def merge(data)\n c = Context.new(data)\n @root.accept(c)\n MergeResult.new(c)\n end", "def addhashes(h1, h2)\n if h1.respond_to?(:merge) && h2.respond_to?(:merge)\n return h1.merge(h2) { |_key, old, new| addhashes(old, new) }\n else\n return h1 + h2\n end\n end", "def deep_merge other_in, options_in = {}\n return self if other_in.nil? or other_in.blank?\n\n options = { mode: :append }.merge(options_in)\n\n other =\n if other_in.is_a?(OpenStruct)\n other_in.dup\n elsif other_in.is_a?(Hash)\n other_in.to_os\n else\n OpenStruct.new(nil => other_in)\n end\n\n self.reduce(other) do |res, key, value|\n res[key] =\n if res.table.keys.include?(key)\n case value\n when Hash, OpenStruct\n value.deep_merge(res[key], options)\n when Array\n value.concat([res[key]].compact.flatten(1))\n when NilClass\n res[key]\n else\n value_out =\n if options[:mode] == :append\n [res[key], value].compact.flatten(1)\n elsif options[:mode] == :prepend\n [value, res[key]].compact.flatten(1)\n else\n value\n end\n\n if value_out.is_a?(Array) && options[:dedup]\n value_out.uniq\n else\n value_out\n end\n end\n else\n value\n end\n\n res\n end\n end", "def deep_merge!(other_hash)\r\n replace(deep_merge(other_hash))\r\n end", "def merge!(data)\n data.each do |k,v|\n self[k] = v\n end\n end", "def merge! other_hash\n @table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)\n end", "def merge(base_hash, derived_hash)\n resolver.merge(base_hash, derived_hash)\n end", "def deep_merge_and_concat_arrays(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n next newval unless newval.kind_of?(oldval.class)\n\n newval = case oldval\n when Hash then oldval.deep_merge(newval)\n when Array then oldval.concat(newval)\n else newval\n end\n\n next newval\n end\n end", "def deep_hash_merge(query_hash, attribute_hash)\n query_hash.merge(attribute_hash) do |_key, oldval, newval|\n oldval = oldval.to_hash if oldval.respond_to?(:to_hash)\n newval = newval.to_hash if newval.respond_to?(:to_hash)\n oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? deep_hash_merge(oldval, newval) : newval\n end\n end", "def deep_merge!(other)\n merger = proc do |key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n self.merge! other, &merger\n end", "def merge!(other_hash); end", "def merge(*data)\n merged = data.compact.inject(@input) do |acc, layer|\n assert_hash_or_config(layer)\n layer_data = layer.is_a?(self.class) ? layer.input : layer\n Bolt::Util.deep_merge(acc, layer_data)\n end\n\n self.class.new(merged, @project)\n end", "def merge(other, &block)\n h = {}\n raise \"can't convert argument into Hash\" unless other.respond_to?(:to_hash)\n other = other.to_hash\n self.each_key{|k| h[k] = self[k]}\n if block\n other.each_key{|k|\n h[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]\n }\n else\n other.each_key{|k| h[k] = other[k]}\n end\n h\n end", "def safe_merge(hash1, hash2)\n hash1.merge(hash2) do |k,x,y|\n if x.is_a?(Hash)\n safe_merge(x, y)\n else\n x\n end\n end\n end", "def prop_merge!(hash, other_hash)\n other_hash.each do |key, val|\n if val.kind_of?(Hash) && hash[key]\n prop_merge!(hash[key], val)\n else\n hash[key] = val\n end\n end\n \n hash\n end", "def deep_merge_custom(hash_1, hash_2)\n hash_1.deep_merge(hash_2) { |key, val_1, val_2|\n if val_1.is_a?(Array) && val_2.is_a?(Array) && val_1[0].is_a?(Hash) && val_2[0].is_a?(Hash)\n new_arr = []\n val_2.each_with_index { |value, index|\n val_1[index] ||= {}\n new_arr[index] = deep_merge_custom(val_1[index], val_2[index])\n }\n new_arr\n else\n val_2\n end\n }\nend", "def deep_merge(other, &bloc)\n other.keys.inject(dup) do |result, key|\n begin\n case result[key]\n when Hash\n if other[key].is_a?(Hash)\n result[key] = result[key].deep_merge(other[key], &bloc)\n result\n else\n raise MergeConflict\n end\n when nil then result.merge key => other[key]\n else\n raise MergeConflict\n end\n rescue MergeConflict\n if bloc.nil?\n result[key] = other[key]\n else\n result[key] = bloc.call(result, other, key) \n end\n result\n end\n end\n \n end", "def merge!(other)\n raise Exception::OptionShouldBeRecursive.new(other) unless Utils.recursive?(other)\n\n if other.is_a?(self.class)\n structures.concat(other.structures)\n else\n structures << other\n end\n\n dirty!\n end", "def merge(base_hash, derived_hash, **opts)\n result = base_hash.merge(derived_hash)\n keys_appearing_in_both = base_hash.keys & derived_hash.keys\n keys_appearing_in_both.each do |key|\n if opts[:unset_nil] && derived_hash[key].nil?\n result.delete(key)\n elsif base_hash[key].is_a?(Hash)\n result[key] = merge(base_hash[key], derived_hash[key], **opts)\n elsif should_union?(base_hash, key, opts[:inherit_mode])\n result[key] = base_hash[key] | derived_hash[key]\n elsif opts[:debug]\n warn_on_duplicate_setting(base_hash, derived_hash, key, **opts)\n end\n end\n result\n end", "def merge(hash_1, hash_2)\n\nend", "def deep_merge!(second)\n return nil unless second\n type_assert(second, Hash)\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end", "def deep_merge!(second)\n return nil unless second\n unless Hash === second\n raise TypeError.new(\"can't convert #{second.class} into #{self.class}\")\n end\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def merge_child_hashes( h1, h2, key )\n h_out = {}\n if h1.has_key?( key )\n if h2.has_key?( key )\n h_out = { key => h1[ key ].merge( h2[ key ] ) }\n else\n h_out = { key => h1[ key ] }\n end\n elsif h2.has_key?( key )\n h_out = { key => h2[ key ] }\n end\n return h_out\nend", "def deep_merge_hashes!(target, overwrite); end", "def pg_hash_only_merge(merge_onto, merge_with)\n # If there are two Hashes, recursively merge.\n if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)\n merge_with.each do |key, merge_with_value|\n merge_onto[key] = pg_hash_only_merge(merge_onto[key], merge_with_value)\n end\n merge_onto\n\n # If merge_with is nil, don't replace merge_onto\n elsif merge_with.nil?\n merge_onto\n\n # In all other cases, replace merge_onto with merge_with\n else\n merge_with\n end\nend", "def deep_merge(other_hash)\n dup.deep_merge!(other_hash)\n end", "def smart_merge(parent, child)\n parent.merge(child) do |key, old, new|\n case old\n when Array\n old + new\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end", "def prop_merge(hash, other_hash)\n other_hash.each do |key, val|\n if val.is_a?(Hash) && hash[key]\n prop_merge(hash[key], val)\n else\n hash[key] = val\n end\n end\n hash\n end" ]
[ "0.7118564", "0.70461404", "0.7019008", "0.69477296", "0.6902892", "0.68409175", "0.6684241", "0.6617985", "0.6593967", "0.6593967", "0.6593967", "0.6560709", "0.65426683", "0.65015894", "0.64709705", "0.6372555", "0.63637376", "0.63613176", "0.6344908", "0.6336662", "0.6316594", "0.6312994", "0.63100535", "0.6300216", "0.62975705", "0.6294302", "0.629312", "0.6284688", "0.62693846", "0.6226378", "0.6219828", "0.62181544", "0.6209375", "0.62064487", "0.61962533", "0.6188192", "0.6188192", "0.61609507", "0.6158218", "0.61378074", "0.6117109", "0.6116103", "0.6116103", "0.6111849", "0.6097582", "0.6097242", "0.6086431", "0.60716003", "0.60476816", "0.59951574", "0.59785897", "0.59719676", "0.59681326", "0.59681326", "0.5929954", "0.59240013", "0.59240013", "0.59240013", "0.59240013", "0.59240013", "0.59240013", "0.58949065", "0.58507335", "0.5835997", "0.5818841", "0.58112895", "0.58072567", "0.5789952", "0.57898027", "0.57562536", "0.57515717", "0.5749938", "0.573738", "0.573316", "0.5730929", "0.5730657", "0.57279736", "0.5717542", "0.5705327", "0.5696872", "0.5696478", "0.568787", "0.5679215", "0.5653696", "0.5637675", "0.5626342", "0.56205213", "0.5619555", "0.5609498", "0.560331", "0.5590172", "0.55777067", "0.55678636", "0.5563767", "0.55577594", "0.55507916", "0.5528008", "0.5499365", "0.5496221", "0.54912996" ]
0.728417
0
Merge the current Hash object (self) with a Hash/Array tree contents (data). For details on this functions, see rh_merge
def rh_merge!(data) _rh_merge(self, data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rh_merge(data)\n _rh_merge(clone, data)\n end", "def merge(hash); end", "def merge(hash); end", "def merge(hash); end", "def deep_merge!(data)\n merger = lambda do |_key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n merge!(data, &merger)\n end", "def deep_merge(source, hash); end", "def deep_merge(source, hash); end", "def _rh_merge(result, data)\n return _rh_merge_choose_data(result, data) unless data.is_a?(Hash)\n\n data.each do |key, _value|\n next if [:__struct_changing, :__protected].include?(key)\n\n _do_rh_merge(result, key, data)\n end\n [:__struct_changing, :__protected].each do |key|\n # Refuse merge by default if key data type are different.\n # This assume that the first layer merge has set\n # :__unset as a Hash, and :__protected as an Array.\n\n _do_rh_merge(result, key, data, true) if data.key?(key)\n\n # Remove all control element in arrays\n _rh_remove_control(result[key]) if result.key?(key)\n end\n\n result\n end", "def merge(other_hash); end", "def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_merge!(value)\n else\n result[key] = result[key].rh_merge(value)\n end\n\n true\n end", "def merge!(data)\n data.each do |k,v|\n self[k] = v\n end\n end", "def merge(hash)\n hash.each_value { |v| self << v }\n end", "def merge!(hash); end", "def deep_merge(*other_hashes, &blk); end", "def deep_merge!(*other_hashes, &blk); end", "def merge!(hsh)\n raise ArgumentError, 'block version not supported' if block_given?\n self.hmset(*hsh.to_a.flatten)\n self\n end", "def deep_merge_hashes(master_hash, other_hash); end", "def deep_merge (h)\n self.merge(h) do |k, old, new|\n begin\n AccountTree.new(old).deep_merge(AccountTree.new(new))\n rescue\n new\n end\n end\n end", "def merge(hash)\n self.dup.update(hash)\n end", "def deep_merge!(target, hash); end", "def deep_merge!(target, hash); end", "def merge(*other_hashes, &blk); end", "def _deep_merge(hash, other_hash); end", "def merge(data)\n c = Context.new(data)\n @root.accept(c)\n MergeResult.new(c)\n end", "def deep_merge!(hash)\n # failsafe\n return if !hash.is_a?(Hash)\n for key in hash.keys\n if self[key].is_a?(Hash)\n self[key].deep_merge!(hash[key])\n else\n self[key] = hash[key]\n end\n end\n end", "def merge!(*other_hashes, &blk); end", "def deep_merge!(hsh1, hsh2)\n raise TypeError unless hsh1.is_a?(Hash) && hsh2.is_a?(Hash)\n\n hsh1.merge!(hsh2) { |_, v1, v2| deep_merge!(v1, v2) }\n end", "def deep_merge(other_hash, &blk)\n dup.deep_update(other_hash, &blk)\n end", "def deep_merge!(other_hash, &block); end", "def merge!( other )\n\t\t\tcase other\n\t\t\twhen Hash\n\t\t\t\t@hash = self.to_h.merge( other,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen ConfigStruct\n\t\t\t\t@hash = self.to_h.merge( other.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen Arrow::Config\n\t\t\t\t@hash = self.to_h.merge( other.struct.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\telse\n\t\t\t\traise TypeError,\n\t\t\t\t\t\"Don't know how to merge with a %p\" % other.class\n\t\t\tend\n\n\t\t\t# :TODO: Actually check to see if anything has changed?\n\t\t\t@dirty = true\n\n\t\t\treturn self\n\t\tend", "def deep_merge!(other_hash, append: :auto, &block)\n\t\t\t\treturn self unless other_hash\n\t\t\t\tother_hash.each_pair do |k,v|\n\t\t\t\t\ttv = self[k]\n\t\t\t\t\tcase\n\t\t\t\t\twhen tv.is_a?(Hash) && v.is_a?(Hash)\n\t\t\t\t\t\tself[k] = tv.deep_merge(v, &block)\n\t\t\t\t\twhen tv.is_a?(Array) && v.is_a?(Array)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\t#hack: if the array begins with nil, we append the new\n\t\t\t\t\t\t\t#value rather than overwrite it\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telsif append && append != :auto\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\twhen tv.nil? && v.is_a?(Array)\n\t\t\t\t\t\t#here we still need to remove nil (see above)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k]=v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend", "def merge hash = {}\n original.merge(hash)\n end", "def merge!(other_hash); end", "def merge(base_hash, derived_hash); end", "def deep_merge!(other_hash)\n other_hash.each do |k,v|\n (class << (tv = self[k]); self; end).send :include, Hashie::Extensions::DeepMerge\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def merge!(other)\n case other\n when Hash\n data = other\n when FileStore\n data = other.to_h\n end\n data.each do |name, value|\n @data[name.to_s] = value \n end\n end", "def merge(other_hash)\n ret = self.class.new.merge!(self)\n ret.merge!(other_hash) if other_hash != self\n return ret\n end", "def merge(hash)\n @hash.merge!(hash) if hash.respond_to?(:keys) && hash.any?\n self\n end", "def merge(newh)\n @hash.merge!(newh) do |key, oldval, newval|\n if oldval.is_a? Array\n oldval << newval\n else\n Array.new [oldval, newval]\n end\n end\n end", "def merge! other_hash\n @table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)\n end", "def merge_hash!(hash)\n merge!(self.class.from_hash(hash))\n end", "def _do_rh_merge(result, key, data, refuse_discordance = false)\n value = data[key]\n\n return if _rh_merge_do_add_key(result, key, value)\n\n return if _rh_merge_recursive(result, key, data)\n\n return if refuse_discordance\n\n return unless _rh_struct_changing_ok?(result, key, data)\n\n return unless _rh_merge_ok?(result, key)\n\n _rh_merge_do_upd_key(result, key, value)\n end", "def deep_merge(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n oldval = oldval.to_hash if oldval.respond_to?(:to_hash)\n newval = newval.to_hash if newval.respond_to?(:to_hash)\n oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval\n end\n end", "def deep_merge_hashes!(target, overwrite); end", "def merge other_hash\n self.class.new nested_class, to_h.merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)\n end", "def addhashes(h1, h2)\n if h1.respond_to?(:merge) && h2.respond_to?(:merge)\n return h1.merge(h2) { |_key, old, new| addhashes(old, new) }\n else\n return h1 + h2\n end\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def smart_merge(parent, child)\n parent.merge(child) do |key, old, new|\n case old\n when Array\n old + new\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end", "def merge(data)\n ProcessRecord.build(to_hash).tap do |record|\n data.each do |key, val|\n record.send(\"%s=\" % key, val)\n end\n end\n end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def deep_merge(hash)\n dup.deep_merge! hash\n end", "def merge\n a_hash = without_empty_values @a.to_h\n b_hash = without_empty_values @b.to_h\n\n @a.class.new a_hash.merge b_hash\n end", "def merge(base_hash, derived_hash, **opts); end", "def deep_merge!(other_hash = {})\n replace(deep_merge(other_hash))\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def merge(hash)\n to_hash.merge(hash)\n end", "def deep_merge!(other_hash)\r\n replace(deep_merge(other_hash))\r\n end", "def merge!(other)\n @hash.merge!(other.hash)\n end", "def merge(key, x)\n if x.is_a?(Hash)\n self.class.new(@data.merge({key => @data[key].merge(x)}))\n else\n self.class.new(@data.merge({key => x}))\n end\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end", "def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n # We can't use use this.val.is_a?(Hash) because inside the refinement\n # returns false:\n # - refined_hash.class != Hash\n if this_val.class.name == \"Hash\" && other_val.class.name == \"Hash\"\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def deep_merge!(other_hash, &block)\n other_hash.each_pair do |k,v|\n tv = self[k]\n if tv.is_a?(Hash) && v.is_a?(Hash)\n self[k] = tv.deep_merge(v, &block)\n else\n self[k] = block && tv ? block.call(k, tv, v) : v\n end\n end\n self\n end", "def internal_deep_merge!(source_hash, specialized_hash)\n\t\t\tspecialized_hash.each_pair do |rkey, rval|\n\t\t\t\tif source_hash.has_key?(rkey) then\n\t\t\t\t\tif rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then\n\t\t\t\t\t\tinternal_deep_merge!(source_hash[rkey], rval)\n\t\t\t\t\telsif rval == source_hash[rkey] then\n\t\t\t\t\telse\n\t\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\tend\n\t\t\tend\n\t\t\tsource_hash\n\t\tend", "def deep_merge!(hash_or_config)\n return self if hash_or_config.nil?\n other_config = convert hash_or_config\n other_config.each do |key, other_value|\n value = has_key?(key) && self[key]\n self[key] = if ConfigNode === value && ConfigNode === other_value\n value.deep_merge!(other_value)\n elsif ConfigNode === value && other_value.nil?\n self[key]\n else\n other_value\n end\n end\n self\n end", "def deep_merge(hash)\n target = dup\n \n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n \n target[key] = hash[key]\n end\n \n target\n end", "def _deep_merge(hash1, hash2)\n hash1.merge(hash2) do |key, oldval, newval|\n if oldval.instance_of?(Hash) && newval.instance_of?(Hash)\n _deep_merge(oldval, newval)\n else\n newval\n end\n end\n end", "def set (hash)\n @data.merge! hash\n end", "def merge_recursively(left, right)\n left.merge(right) { |_, a_item, b_item| a_item.is_a?(Hash) ? merge_recursively(a_item, b_item) : b_item }\n end", "def +(other_hash)\n other_hash ||= {}\n unless other_hash.is_a? Hash\n raise \"cannot merge #{other_hash.inspect} (#{other_hash.class})\" +\n \" into #{self} (Hash)\"\n end\n self.merge(other_hash || {})\n end", "def deep_merge(other_hash)\n dup.deep_merge!(other_hash)\n end", "def deep_merge!(other_hash, &block)\n other_hash.each_pair do |current_key, other_value|\n this_value = self[current_key]\n\n self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)\n this_value.deep_merge(other_value, &block)\n else\n if block_given? && key?(current_key)\n block.call(current_key, this_value, other_value)\n else\n other_value\n end\n end\n end\n\n self\n end", "def deep_merge(hash)\n target = dup\n\n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n\n target[key] = hash[key]\n end\n\n target\n end", "def merge!(hash)\n hash.each { |k, v| self[k]= v }\n end", "def merge(other)\n self.class[Utils.merge(to_h, other)]\n end", "def shallow_merge(other_hash); end", "def smart_merge(parent, child)\n parent.merge(child) do |_key, old, new|\n case old\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end", "def deep_merge_and_concat_arrays(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n next newval unless newval.kind_of?(oldval.class)\n\n newval = case oldval\n when Hash then oldval.deep_merge(newval)\n when Array then oldval.concat(newval)\n else newval\n end\n\n next newval\n end\n end", "def recursive_hash_merge(hash1, hash2)\n hash1.merge(hash2) {|k,o,n| (o.is_a?(Hash)) ? recursive_hash_merge(o,n) : n}\n end", "def merge!(data)\n data = data.with_indifferent_access\n data.delete(:SecurityKey)\n populate_properties(data)\n self\n end", "def merge!(other)\n raise Exception::OptionShouldBeRecursive.new(other) unless Utils.recursive?(other)\n\n if other.is_a?(self.class)\n structures.concat(other.structures)\n else\n structures << other\n end\n\n dirty!\n end", "def merge(other)\n assert_archive other\n\n data = deep_clone(@data)\n merge_data data, other.as_json, other.uri\n\n self.class.new data\n end", "def merge_child_hashes( h1, h2, key )\n h_out = {}\n if h1.has_key?( key )\n if h2.has_key?( key )\n h_out = { key => h1[ key ].merge( h2[ key ] ) }\n else\n h_out = { key => h1[ key ] }\n end\n elsif h2.has_key?( key )\n h_out = { key => h2[ key ] }\n end\n return h_out\nend", "def merge!(other)\n assert_archive other\n clear_caches\n\n merge_data @data, other.as_json, other.uri\n nil\n end", "def merge!(hash)\n hash.each do |k,v|\n @new_info[lookup_key(k)] = v\n end\n self\n end", "def deep_merge other_in, options_in = {}\n return self if other_in.nil? or other_in.blank?\n\n options = { mode: :append }.merge(options_in)\n\n other =\n if other_in.is_a?(OpenStruct)\n other_in.dup\n elsif other_in.is_a?(Hash)\n other_in.to_os\n else\n OpenStruct.new(nil => other_in)\n end\n\n self.reduce(other) do |res, key, value|\n res[key] =\n if res.table.keys.include?(key)\n case value\n when Hash, OpenStruct\n value.deep_merge(res[key], options)\n when Array\n value.concat([res[key]].compact.flatten(1))\n when NilClass\n res[key]\n else\n value_out =\n if options[:mode] == :append\n [res[key], value].compact.flatten(1)\n elsif options[:mode] == :prepend\n [value, res[key]].compact.flatten(1)\n else\n value\n end\n\n if value_out.is_a?(Array) && options[:dedup]\n value_out.uniq\n else\n value_out\n end\n end\n else\n value\n end\n\n res\n end\n end", "def deep_merge!(other)\n merger = proc do |key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n self.merge! other, &merger\n end", "def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end", "def merge(hash)\n raise NoMethodError\n end", "def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end", "def concat(hash_stack)\n @stack.concat hash_stack.stack\n self\n end", "def merge(other, &block)\n h = {}\n raise \"can't convert argument into Hash\" unless other.respond_to?(:to_hash)\n other = other.to_hash\n self.each_key{|k| h[k] = self[k]}\n if block\n other.each_key{|k|\n h[k] = (self.has_key?(k))? block.call(k, self[k], other[k]): other[k]\n }\n else\n other.each_key{|k| h[k] = other[k]}\n end\n h\n end", "def merge; end", "def tree=(data)\n @tree = HashWithIndifferentAccess.new(\n case data\n when Array\n hash_from_git(data)\n when Hash, HashWithIndifferentAccess\n data\n end\n )\n end", "def merge(arr)\n if isleaf(self)\n acc = Rope.new\n pos0 = 1\n pos1 = 2\n n = 0\n while not (pos0 <= @str.length and @str.length < pos1)\n if arr[n] != nil\n acc.prepend(arr[n])\n arr[n] = nil\n end\n pos1, pos0 = pos0 + pos1, pos1\n n += 1\n end\n acc << self\n while not (pos0 <= acc.length and acc.length < pos1) or arr[n] != nil\n if arr[n] != nil\n acc.prepend(arr[n])\n arr[n] = nil\n end\n pos1, pos0 = pos0 + pos1, pos1\n n += 1\n end\n arr[n] = acc.clone\n end\n @left.merge(arr) if @left != nil\n @right.merge(arr) if @right != nil\n end" ]
[ "0.7709388", "0.6946114", "0.6946114", "0.6946114", "0.6810289", "0.66208786", "0.66208786", "0.6526052", "0.6514497", "0.65080833", "0.64784604", "0.6426913", "0.64115846", "0.64077103", "0.6384978", "0.63511044", "0.6344408", "0.630933", "0.6307362", "0.6282395", "0.6282395", "0.6268949", "0.6244785", "0.6229685", "0.62233675", "0.6218575", "0.62136", "0.61786604", "0.6162119", "0.6147931", "0.6137705", "0.6087885", "0.6085917", "0.6084207", "0.6069082", "0.6050801", "0.6040981", "0.602676", "0.6012796", "0.5998901", "0.5990909", "0.59879106", "0.5986839", "0.5981623", "0.59244865", "0.59073395", "0.5894431", "0.58909065", "0.5889312", "0.585893", "0.5846364", "0.58322066", "0.582473", "0.5824121", "0.5814088", "0.5808476", "0.5808476", "0.5808476", "0.5808476", "0.5808476", "0.5808476", "0.5802616", "0.5794657", "0.5791901", "0.5776147", "0.5776147", "0.5768114", "0.5759691", "0.5744318", "0.57218975", "0.571042", "0.57090336", "0.57053554", "0.5695281", "0.569401", "0.56737036", "0.5668302", "0.56644815", "0.56584865", "0.5657276", "0.5650248", "0.5649968", "0.5643423", "0.56384164", "0.56341845", "0.56315017", "0.5630455", "0.5626526", "0.562119", "0.5618998", "0.56026524", "0.5594037", "0.5592157", "0.55886084", "0.5587712", "0.55677706", "0.55664295", "0.5537361", "0.55236566", "0.55236214" ]
0.7381702
1
Internal function which do the real merge task by rh_merge and rh_merge! See rh_merge for details
def _rh_merge(result, data) return _rh_merge_choose_data(result, data) unless data.is_a?(Hash) data.each do |key, _value| next if [:__struct_changing, :__protected].include?(key) _do_rh_merge(result, key, data) end [:__struct_changing, :__protected].each do |key| # Refuse merge by default if key data type are different. # This assume that the first layer merge has set # :__unset as a Hash, and :__protected as an Array. _do_rh_merge(result, key, data, true) if data.key?(key) # Remove all control element in arrays _rh_remove_control(result[key]) if result.key?(key) end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge!; end", "def merge; end", "def rh_merge!(data)\n _rh_merge(self, data)\n end", "def merge(source); end", "def _do_rh_merge(result, key, data, refuse_discordance = false)\n value = data[key]\n\n return if _rh_merge_do_add_key(result, key, value)\n\n return if _rh_merge_recursive(result, key, data)\n\n return if refuse_discordance\n\n return unless _rh_struct_changing_ok?(result, key, data)\n\n return unless _rh_merge_ok?(result, key)\n\n _rh_merge_do_upd_key(result, key, value)\n end", "def rh_merge(data)\n _rh_merge(clone, data)\n end", "def perform_additional_merge_operations!(other)\n end", "def merge_conflict?; end", "def process!()\n # Regarding updates or deletions of :badge_id\n # --------------------------------------------------------------------\n # This has to change only if it refers to a duplicate row;\n # that is, a row that will become a duplicate (and it will have to\n # be deleted) once that the update (and translation) process has been\n # completed.\n #\n # Thus, each linked entity that has a reference to one of these\n # possibly duplicate IDs has to be updated with the new destination value\n # (of which they are the duplicate); else, the value for :badge_id can stay untouched.\n\n merge_done = false\n if check\n process_text_log << \"\\r\\nMerging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n sql_diff_text_log << \"-- Merging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n\n # Define merge schema (involved entities)\n @involved_entities = SwimmerMerger.get_involved_entities\n\n # Collect entity row to merge\n @involved_entities.each do |involved_entity|\n collect_swimmer_inolved_entity( involved_entity )\n end\n\n # Collect badges to merge (both swimmers have badges for the same season)\n collect_badges_to_merge\n\n # N.B. Checks for some recalculation needed should be performed before update and delete phases\n # Check if Goggle Cup standards needs recalculation\n needs_goggle_cup_recalculation = needs_goggle_cup_recalculation?\n\n # Check if seasonal personal standards needs recalculation\n needs_season_personal_standard_recalculation = needs_season_personal_standard_recalculation?\n\n # Perform the merge: update and delete phases\n # Bail out from any of these, if something goes wrong:\n merge_done = update_phase! && create_alias_phase! && delete_phase! && execute_delete!( Swimmer )\n\n if merge_done\n if @row_collectors[ MeetingIndividualResult.table_name ].non_duplicates_rows.size > 0\n # Recalculate personal bests\n process_text_log << \"\\r\\n\\r\\nPersonal-bests recalculation needed...\\r\\n\"\n swimmer_best_updater = SwimmerPersonalBestUpdater.new( @master_swimmer )\n swimmer_best_updater.scan_for_personal_best!\n sql_diff_text_log << swimmer_best_updater.sql_diff_text_log\n process_text_log << \"Personal-bests recalculation done!\\r\\n\"\n end\n\n # TODO if needed, also recalculate goggle_cup_standards\n if needs_goggle_cup_recalculation\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Goggle-cup standards recalculation needed...\\r\\n\"\n end\n\n # TODO if needed, also recalculate season_personal_standards\n if needs_season_personal_standard_recalculation?\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Season personal standards recalculation needed...\\r\\n\"\n end\n end\n end\n merge_done\n end", "def merge\n @mergeit.merge_data(@input_files)\n end", "def merge(opts); end", "def try_merge!(pin); end", "def merge(other); end", "def merge(with); end", "def merge!(with); end", "def successfull_merge_or_nothing(i,j)\n # try a merge and determinize inside a transaction on the ufds\n @ufds.transactional do\n merge_and_determinize(i, j)\n end\n end", "def merge(merge_branch, options = {})\n merge_analysis = rugged.merge_analysis(merge_branch.name)\n if merge_analysis.include?(:fastforward)\n rugged.references.update(helper.head_ref, merge_branch.target_id)\n rugged.checkout_head(strategy: :force)\n elsif merge_analysis.include?(:normal)\n ours = helper.head_target\n theirs = merge_branch.target\n merge_base = rugged.merge_base(ours, theirs)\n raise(NoCommonCommit) unless merge_base\n\n base = rugged.rev_parse(merge_base)\n index = ours.tree.merge(theirs.tree, base.tree)\n\n commit_message =\n if index.conflicts?\n raise(MergeConflict) unless block_given?\n\n message = yield(index, rugged, helper.working_directory)\n raise(MergeConflict) unless message\n\n index.conflict_cleanup\n message\n else\n \"Merge branch '#{helper.head_branch.name}' of #{helper.head_remote.url}\"\n end\n\n helper.commit_create(\n commit_message,\n index.write_tree(rugged),\n [ours, theirs],\n options\n )\n rugged.checkout_head(strategy: :force)\n end\n\n self\n end", "def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_merge!(value)\n else\n result[key] = result[key].rh_merge(value)\n end\n\n true\n end", "def do_merge\n\n return @workitem if @workitem\n\n list = if first?\n @workitems_by_arrival.reverse\n elsif last?\n @workitems_by_arrival\n elsif highest?\n @workitems_by_altitude.reverse\n elsif lowest?\n @workitems_by_altitude\n end\n\n list.inject(nil) do |result, wi|\n result = merge_workitems(result, wi, override?) if wi\n result\n end\n end", "def merge(base_hash, derived_hash, **opts); end", "def merge_to_project(options = {})\n $merge = true \n @opt = {\n :proj_id => nil, \n :person_id => nil,\n :postfix_otu_names => false,\n :postfix_chr_names => false\n }.merge!(options.symbolize_keys)\n\n return false if !@opt[:proj_id] || !@opt[:person_id]\n return false if !@proj = Proj.find(@opt[:proj_id])\n return false if !@person = Person.find(@opt[:person_id])\n\n $proj_id = @proj.id \n $person_id = @person.id\n\n begin\n Proj.transaction do \n # try and do a little matching/transfer in a few cases (could also extend to Keywords)\n self.content_types.each do |o|\n if ct = ContentType.find(:first, :conditions => {:proj_id => @proj.id, :name => o.name})\n # update the templates \n self.content_templates_content_types.each do |ctct|\n if ctct.content_type.name == ct.name\n ctct.content_type = ct\n ctct.save\n end\n end\n \n # update the content\n self.contents.each do |c|\n if c.content_type.name == ct.name\n c.content_type = ct\n c.save\n end\n end \n\n # update the mapped_chr_groups\n self.chr_groups.each do |cg|\n if !cg.content_type.blank? && cg.content_type.name == ct.name\n cg.content_type = ct\n cg.save\n end\n end \n # we have to only delete the merged object below\n end\n end\n\n self.genes.each do |g|\n if g = Gene.find(:first, :conditions => {:proj_id => @proj.id, :name => g.name})\n self.primers.each do |p|\n p.gene = g\n p.save\n end\n self.seqs.each do |s|\n s.gene = g\n s.save\n end\n end\n end\n\n # loop the remaining types\n [:has_many, :has_one, :has_and_belongs_to_many].each do |rel|\n Proj.reflect_on_all_associations(rel).collect{|o| o.name}.each do |r| # r is the class name \n next if r == :text_content_types\n case r\n when :content_types \n self.send(r).each do |o|\n if @ct = ContentType.find(:first, :conditions => {:proj_id => @proj.id, :name => o.name})\n o.destroy \n else\n o.proj_id = @opt[:proj_id]\n o.save\n end \n end \n \n when :genes\n self.send(r).each do |o|\n if @g = Gene.find(:first, :conditions => {:proj_id => @proj.id, :name => o.name})\n o.destroy \n else\n o.proj_id = @opt[:proj_id]\n o.save\n end \n end \n \n when :people\n # do nothing, these remain in the project to be deleted later, otherwise they get touched an pwds get borked\n\n else \n t = self.send(r).each do |o|\n @o = o\n @r = r\n o.name = \"#{o.name} [from: #{o.proj_id}]\" if (@opt[:postfix_otu_names] && o.class == Otu) || (@opt[:postfix_chr_names] && o.class == Chr)\n o.proj_id = @opt[:proj_id]\n o.save\n end\n end\n end\n end # end rel types\n end # end transaction\n\n rescue Exception => e\n $merge = false\n raise \"#{e} o:(#{@o.to_yaml}) o_class: #{@o.class.to_s} r:(#{@r}) p:(#{@proj.id})\"\n end\n $merge = false\n true\n end", "def merge(hash); end", "def merge(hash); end", "def merge(hash); end", "def merge!(*other_hashes, &blk); end", "def merge(base_hash, derived_hash); end", "def gdal_merge(input_files, output_file, merge_strategy = :lossless)\n return nil if input_files.length == 0\n return CDBTool.link_output(input_files[0], output_file) if input_files.length == 1\n\n command = case merge_strategy\n when :lossless\n \"gdal_merge.py -o #{output_file} -co BIGTIFF=YES -co COMPRESS=LZW -co NUM_THREADS=ALL_CPUS -co TILED=YES -n 0 -a_nodata 0 #{input_files.join(\" \")}\"\n when :lossy\n \"gdal_merge.py -o #{output_file} -co BIGTIFF=YES -co COMPRESS=JPEG -co TILED=YES #{input_files.join(\" \")}\"\n end\n\n merge = Mixlib::ShellOut.new(command, live_stdout: $stdout, live_stderr: $stderr)\n\n if File.exists?(output_file)\n puts \"Output exists, skipping merge command.\"\n else\n puts command\n merge.run_command\n $mosaic.log(\"#{output_file},#{File.size(output_file)},#{merge.execution_time}s\")\n end\nend", "def merge_if_exists!\n t = merge_if_exists || self\n t.save!\n end", "def merge!(other); end", "def merge(*other_hashes, &blk); end", "def merge(headers_or_env); end", "def merge(*sources); end", "def merge(repo, base, head, options = {})\n params = {\n :base => base,\n :head => head\n }.merge(options)\n post \"#{Repository.path repo}/merges\", params\n end", "def find_merge\n \nend", "def merge_base(target, source)\n invoke(:merge_base, target, source)\n rescue ShellExecutionError\n nil\n end", "def merged_result; end", "def merge_into(target)\n target_id = target.id\n # Find all the Entries attached to this name, that will need to be\n # reindexed after the merge\n entry_ids = entry_ids_to_index_on_update\n\n ids = EntryArtist.where(artist_id: self.id).pluck(:id)\n EntryArtist.where(artist_id: self.id).update_all({ artist_id: target_id })\n EntryArtist.where( id: ids ).each(&:update_bunny)\n\n ids = EntryAuthor.where(author_id: self.id).pluck(:id)\n EntryAuthor.where(author_id: self.id).update_all({ author_id: target_id })\n EntryAuthor.where( id: ids ).each(&:update_bunny)\n\n ids = EntryScribe.where(scribe_id: self.id).pluck(:id)\n EntryScribe.where(scribe_id: self.id).update_all({ scribe_id: target_id })\n EntryScribe.where( id: ids ).each(&:update_bunny)\n\n ids = SaleAgent.where(agent_id: self.id).pluck(:id)\n SaleAgent.where(agent_id: self.id).update_all({ agent_id: target_id })\n SaleAgent.where( id: ids ).each(&:update_bunny)\n\n ids = SourceAgent.where(agent_id: self.id).pluck(:id)\n SourceAgent.where(agent_id: self.id).update_all({ agent_id: target_id })\n SourceAgent.where( id: ids ).each(&:update_bunny)\n\n ids = Provenance.where(provenance_agent_id: self.id).pluck(:id)\n Provenance.where(provenance_agent_id: self.id).update_all({ provenance_agent_id: target_id })\n Provenance.where( id: ids ).each(&:update_bunny)\n\n ids = DericciLink.where(name_id: self.id).pluck(:id)\n DericciLink.where(name_id: self.id).update_all({ name_id: target_id })\n DericciLink.where( id: ids ).each(&:update_bunny)\n\n ids = DericciRecord.where(verified_id: self.id).pluck(:id)\n DericciRecord.where(verified_id: self.id).update_all({verified_id: target_id})\n DericciRecord.where( id: ids ).each(&:update_bunny)\n\n # update flags on the target\n target.is_artist ||= self.is_artist\n target.is_author ||= self.is_author\n target.is_scribe ||= self.is_scribe\n target.is_provenance_agent ||= self.is_provenance_agent\n\n target.save\n\n # but ... CAN't SAVE when name is BLANK (nil)\n # self.name = nil\n self.viaf_id = nil\n self.deleted = true\n self.save!\n\n # slice into managable chunks to avoid running out of space in mysql\n entry_ids.each_slice(200) do |slice|\n SDBMSS::IndexJob.perform_later(Entry.to_s, slice)\n end\n\n Name.update_counters(target.id,\n :authors_count => target.author_entries.where(deprecated: false, draft: false).count - target.authors_count,\n :artists_count => target.artist_entries.where(deprecated: false, draft: false).count - target.artists_count,\n :scribes_count => target.scribe_entries.where(deprecated: false, draft: false).count - target.scribes_count,\n :sale_agents_count => target.sale_entries.where(deprecated: false, draft: false).count - target.sale_agents_count,\n :provenance_count => target.provenance_entries.where(deprecated: false, draft: false).count - target.provenance_count,\n :source_agents_count => target.agent_sources.count - target.source_agents_count\n )\n end", "def merge_trees(base_treeish, local_treeish, remote_treeish)\n invoke(:merge_recursive, base_treeish, \"-- #{local_treeish} #{remote_treeish}\")\n true\n rescue ShellExecutionError => error\n # 'CONFLICT' messages go to stdout.\n raise MergeError, error.out\n end", "def merge!(new_args); end", "def merge(hash_1, hash_2)\n\nend", "def merge(other_hash); end", "def merge(paths)\n prepare(paths)\n end", "def restore_merge_state; end", "def restore_merge_state; end", "def merge_sort(arr)\n \n puts \"\\n\\n\\n==WELCOME TO MERGE SORT==\\n\\n\\n\"\n \n local_arr = arr\n\n=begin\n local_arr.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"insider merge sort\\nThe length of arr = #{local_arr.length}\\n\\n\"\n end\n=end\n\n if(local_arr.length == 1)\n local_arr.each do |f|\n puts \"\\n\\nTHIS IS INSIDE MERGE SORT\"\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"This is right before the return statement\\n\\n\"\n end\n return local_arr\n end\n \n length = local_arr.length\n cut_length = length.to_i / 2\n \n=begin\n local_arr.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort \\n\\n\"\n end\n=end\n\n puts \"The length of local_arr = #{local_arr.length}\\n\\n\"\n arr1 = Array.new\n arr2 = Array.new\n sorted = Array.new\n \n count = 0\n while count < cut_length do\n arr1.push(arr[count])\n count += 1\n end\n \n while count < arr.length do\n arr2.push(arr[count])\n count += 1\n end\n \n arr1.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort (arr1) \\n\\n\"\n end\n \n arr2.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort (arr2) \\n\\n\"\n end\n \n \n=begin\n count = 0\n arr1_count = 0\n arr2_count = 0\n while count < arr.length\n puts \"Count: #{count}\\tarr1_count: #{arr1_count}\\tarr2_count: #{arr2_count}\"\n \n temp1 = arr1[arr1_count]\n temp2 = arr2[arr2_count]\n if(arr1_count < arr1.length - 1 && arr2_count < arr2.length - 1)\n if(temp1.temp_position < temp2.temp_position)\n sorted.push(temp1)\n arr1_count += 1\n else\n sorted.push(temp2)\n arr2_count += 1\n end\n end\n \n count += 1\n end\n \n return sorted\n=end\n\n count = 0\n while count < local_arr.length\n if(!arr1.empty? && !arr2.empty?)\n temp1 = arr1[0]\n temp2 = arr2[0]\n \n puts \"temp1\\tposition: #{temp1.position}\\ttemp_position: #{temp1.temp_position}\\n\"\n puts \"temp2\\tposition: #{temp2.position}\\ttemp_position: #{temp2.temp_position}\\n\"\n \n if(temp1.temp_position < temp2.temp_position)\n sorted.push(temp1)\n arr1.delete(temp1)\n puts \"Count: #{count}\\tPosition: #{temp1.position}\\n\\n\"\n else\n sorted.push(temp2)\n puts \"Count: #{count}\\tPosition: #{temp2.position}\\n\\n\"\n arr2.delete(temp2)\n end\n elsif\n sorted.push(arr2[0])\n arr2.delete(arr2[0])\n elsif\n sorted.push(arr1[0])\n arr1.delete(arr1[0])\n end\n=begin\n if(arr1.empty?)\n sorted.push(arr2[0])\n arr2.delete(arr2[0])\n else\n sorted.push(arr1[0])\n arr1.delete(arr1[0])\n end\n=end\n \n count += 1\n end\n \n puts \"\\n\\nSorted length: #{sorted.length}\"\n \n sorted.each do |f|\n puts \"Position: #{f.position}\"\n end\n \n return sorted\n end", "def merge_into(r)\n if !self.metadata[:add].nil?\n if !r.metadata[:add].nil?\n r.metadata[:add] |= self.metadata[:add]\n else\n r.metadata[:add] = self.metadata[:add]\n end\n end\n\n if !self.metadata[:remove].nil?\n if !r.metadata[:remove].nil?\n r.metadata[:remove] |= self.metadata[:remove]\n else\n r.metadata[:remove] = self.metadata[:remove]\n end\n end\n\n if !r.metadata[:todos].nil?\n r.metadata[:todos] |= r.metadata[:add] - r.metadata[:remove]\n else\n r.metadata[:todos] = r.metadata[:add] - r.metadata[:remove]\n end\n\n if !r.metadata[:tags].nil?\n r.metadata[:tags] |= self.metadata[:tags] if !self.metadata[:tags].nil?\n else\n r.metadata[:tags] = self.metadata[:tags]\n end\n\n if !self.metadata[:tags]\n self.metadata[:tags].each do |tag|\n r.add_tags(tag)\n end\n end\n\n r.sector_tag_list |= self.sector_tag_list\n r.type_tag_list |= self.type_tag_list\n r.input_method_list |= self.input_method_list\n r.PFO_statu_list |= self.PFO_statu_list\n r.organizer_list |= self.organizer_list\n\n r.email << (\", \" + self.email) if r.email.blank? && !self.email.blank?\n r.phone = self.phone if r.phone.blank? && !self.phone.blank?\n r.organization = self.organization if r.organization.blank? && !self.organization.blank?\n r.position = self.position if r.position.blank? && !self.position.blank?\n r.address = self.address if r.address.blank? && !self.address.blank?\n\n r.street_address = self.street_address if r.street_address.nil? && !self.street_address.nil?\n r.user = self.user if r.user.nil? && !self.user.nil?\n\n if !self.notes.nil? && !self.notes.empty?\n if r.notes.nil?\n r.notes = self.notes\n else\n new_notes = r.notes << \", \" << self.notes\n r.notes = nil\n r.save\n r.notes = new_notes\n end\n end\n\n r.manually_added ||= self.manually_added\n r.save\n end", "def merge!(hash); end", "def mergeSort(arr)\n puts \"Running merge sort on array: \" + arr.to_s\n temp = copyArr(arr)\n #this block determines what the subproblems that should be merged are\n splitMerge(temp, 1, arr) do |a, t, n|\n if n == 1\n return a\n end\n jump = a.length/n\n i = 0\n while i < a.length\n lo = i\n mid = (i + jump) - 1\n hi = mid + jump\n merge(a, lo, mid, hi, t)\n i = i + (jump*2)\n end\n t\n end\nend", "def merge_all\n merge_concurrent(0)\n end", "def perform_or_request_merge(src, dest)\n if in_admin_mode? || src.can_merge_into?(dest)\n perform_merge(src, dest)\n else\n request_merge(src, dest)\n end\n end", "def merge!(headers_or_env); end", "def merge(treeish=upstream_branch)\n sandbox do |git, work_tree, index_file|\n des, src = safe_rev_parse(branch, treeish)\n base = des.nil? ? nil : git.merge_base({}, des, src).chomp(\"\\n\")\n \n case\n when base == src\n break\n when base == des\n # fast forward situation\n grit.update_ref(branch, src)\n else\n # todo: add rebase as an option\n \n git.read_tree({\n :m => true, # merge\n :i => true, # without a working tree\n :trivial => true, # only merge if no file-level merges are required\n :aggressive => true, # allow resolution of removes\n :index_output => index_file\n }, base, branch, src)\n \n commit!(\"gitgo merge of #{treeish} into #{branch}\", \n :tree => git.write_tree.chomp(\"\\n\"),\n :parents => [des, src]\n )\n end\n \n reset\n end\n \n self\n end", "def mergesort!(src, dst, lo, hi, metadata)\n return if hi <= lo\n\n mid = lo + (hi - lo) / 2\n mergesort! dst, src, lo, mid, metadata\n mergesort! dst, src, mid+1, hi, metadata\n merge! src, dst, lo, mid, hi, metadata\nend", "def merge_outages(srcdst2outage, srcdst2filter_tracker)\n # TODO should freeze these objects\n outages = srcdst2outage.values\n # Assign unique ids to outages\n @outage_store.transaction do\n outages.each do |outage|\n outage.file = @outage_store.generate_unique_id\n end\n end\n\n # nested helper closure\n allocate_merged_outage = lambda do |outage_list, merging_method|\n id = nil\n merged_outage = nil\n # Generate a unique id\n @merged_outage_store.transaction do\n id = @merged_outage_store.generate_unique_id \n merged_outage = MergedOutage.new(id, outage_list, merging_method)\n end\n outage_list.each do |outage|\n src = outage.src\n dst = outage.dst\n srcdst2filter_tracker[[src,dst]].merged_outage_ids << id\n end\n\n # last statement is the map value\n merged_outage\n end\n \n # Note: bidirectional will appear twice, in forward mergings and reverse\n # mergings\n only_forward = outages.find_all { |o| o.direction.is_forward? }\n dst2outages = only_forward.categorize_on_attr(:dst) \n # Abuse of map... \n forward_merged = dst2outages.values.map do |outage_list|\n allocate_merged_outage.call(outage_list, MergingMethod::FORWARD)\n end\n\n only_reverse = outages.find_all { |o| o.direction.is_reverse? }\n src2outages = only_reverse.categorize_on_attr(:src)\n # Abuse of map... \n reverse_merged = src2outages.values.map do |outage_list|\n allocate_merged_outage.call(outage_list, MergingMethod::REVERSE)\n end\n\n # For debugging. TODO: put me into unit tests instead of here.\n forward_src_dsts = Set.new(forward_merged.map { |merged| merged.map { |o| {:src => o.src, :dst => o.dst} } }.flatten)\n reverse_src_dsts = Set.new(reverse_merged.map { |merged| merged.map { |o| {:src => o.src, :dst => o.dst} } }.flatten)\n all_outages = Set.new(outages.find_all { |o| o.direction.is_forward? or o.direction.is_reverse? }.map { |o| {:src => o.src, :dst => o.dst} })\n if (forward_src_dsts | reverse_src_dsts).size != all_outages.size\n # forward U reverse mergings should contain every (src, dst) pair\n # TODO: raise rather than log?\n @logger.warn { \"Not merging properly! [#{forward_src_dsts.to_a.inspect} #{reverse_src_dsts.to_a.inspect} #{all_outages.to_a.inspect}]\" }\n end\n \n return forward_merged + reverse_merged\n end", "def merge(left, right)\n (l_l, l_r), (u_l, u_r) = left.tangents(right)\n\n l = l_l\n r = l_r\n l1 = nil\n r1 = nil\n l2 = nil\n r2 = nil\n\n until l == u_l && r == u_r\n # TODO: Name these better than just A and B (the original paper's names)\n a = false\n b = false\n\n join(l, r, l == l_l && r == l_r)\n\n r1 = r.clockwise(l)\n if r1.left_of?(l, r)\n r2 = r.clockwise(r1)\n\n until outside?(r1, l, r, r2)\n unjoin(r, r1, 'from the right')\n r1 = r2\n r2 = r.clockwise(r1)\n end\n else\n a = true\n end\n\n l1 = l.counterclockwise(r)\n if l1.right_of?(r, l)\n l2 = l.counterclockwise(l1)\n\n until outside?(l, r, l1, l2)\n unjoin(l, l1, 'from the left')\n l1 = l2\n l2 = l.counterclockwise(l1)\n end\n else\n b = true\n end\n\n if a\n l = l1\n elsif b\n r = r1\n elsif outside?(l, r, r1, l1)\n r = r1\n else\n l = l1\n end\n end\n\n # Add the top tangent; this seems to be omitted from Lee and Schachter,\n # either that or the \"UNTIL\" loop behaves differently in their pseudocode\n # and runs one final iteration.\n join(u_r, u_l, true)\n\n left.add_hull(right)\n\n rescue => e\n f = \"/tmp/hull_#{left.hull_id}_#{right.hull_id}.json\"\n File.write(\n f,\n JSON.pretty_generate(\n (left.points + right.points).map { |p| [p.x, p.y, p.idx] }\n )\n )\n\n raise \"Merging #{right.hull_id} (#{right.count} pts) into #{left.hull_id} (#{left.count} pts) failed: #{e}. Wrote #{f} to debug.\"\n end", "def manifest_merge\n UI::status(\"resolving manifests\")\n UI::debug(\" overwrite #{overwrite?} partial #{filter}\")\n UI::debug(\" ancestor #{ancestor} local #{local} remote #{remote}\")\n \n copy = calculate_copies\n copied_files = Hash.with_keys(copy.values)\n \n # Compare manifests\n working_changeset.each do |file, node|\n update_local_file file, node, copy, copied_files\n end\n \n remote.each do |file, node|\n update_remote_file file, node, copy, copied_files\n end\n end", "def merge(direction=:into_remote)\n begin\n @map = direction == :into_local ? @map.merge(read_data) : read_data.merge(@map)\n rescue LockMethod::Locked\n sleep 0.5\n merge(direction)\n end\n end", "def merge_builds merged_build\n FileUtils.mkdir_p @temp_root\n debug_msg \"Merging #{merged_build}\"\n require \"sdoc/merge\"\n \n tmp = temp_dir\n target = File.join @public_dir, merged_build.to_s\n \n title = merged_build.builds.map do |build| \n automation_by_name(build.name).name + \" v#{build.version}\"\n end.join(', ')\n names = merged_build.builds.map do |build| \n automation_by_name(build.name).short_name\n end.join(',')\n urls = merged_build.builds.map do |build|\n '../' + build.to_s\n end.join(' ')\n \n options = []\n options << \"-o\" << tmp\n options << '--title' << title\n options << '--names' << names\n options << '--urls' << urls\n merged_build.builds.each do |build|\n options << File.join(@public_dir, build.to_s)\n end\n SDoc::Merge.new.merge(options)\n \n FileUtils.rm_rf target if File.exists? target\n FileUtils.cp_r File.join(tmp, '.'), target, :preserve => true \n \n zip_tmp = merge_zip merged_build\n FileUtils.cp File.join(zip_tmp, 'rdoc.zip'), target, :preserve => true\n clean_up\n end", "def store_merge_state; end", "def store_merge_state; end", "def internal_deep_merge!(source_hash, specialized_hash)\n\t\t\tspecialized_hash.each_pair do |rkey, rval|\n\t\t\t\tif source_hash.has_key?(rkey) then\n\t\t\t\t\tif rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then\n\t\t\t\t\t\tinternal_deep_merge!(source_hash[rkey], rval)\n\t\t\t\t\telsif rval == source_hash[rkey] then\n\t\t\t\t\telse\n\t\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\tend\n\t\t\tend\n\t\t\tsource_hash\n\t\tend", "def merge(to_be_merged)\n scheme_ids = identifiers.pluck(:identifier_scheme_id)\n # merge logic\n # => answers -> map id\n to_be_merged.answers.update_all(user_id: id)\n # => notes -> map id\n to_be_merged.notes.update_all(user_id: id)\n # => plans -> map on id roles\n to_be_merged.roles.update_all(user_id: id)\n # => prefs -> Keep's from self\n # => auths -> map onto keep id only if keep does not have the identifier\n to_be_merged.identifiers\n .where.not(identifier_scheme_id: scheme_ids)\n .update_all(identifiable_id: id)\n # => ignore any perms the deleted user has\n to_be_merged.destroy\n end", "def merge(base_hash, derived_hash)\n resolver.merge(base_hash, derived_hash)\n end", "def merge_to(data)\n\n # prevent cross merging tickets\n target_ticket = Ticket.find_by(id: data[:ticket_id])\n raise 'no target ticket given' if !target_ticket\n raise Exceptions::UnprocessableEntity, 'ticket already merged, no merge into merged ticket possible' if target_ticket.state.state_type.name == 'merged'\n\n # check different ticket ids\n raise Exceptions::UnprocessableEntity, 'Can\\'t merge ticket with it self!' if id == target_ticket.id\n\n # update articles\n Transaction.execute do\n\n Ticket::Article.where(ticket_id: id).each(&:touch)\n\n # quiet update of reassign of articles\n Ticket::Article.where(ticket_id: id).update_all(['ticket_id = ?', data[:ticket_id]]) # rubocop:disable Rails/SkipsModelValidations\n\n # mark target ticket as updated\n # otherwise the \"received_merge\" history entry\n # will be the same as the last updated_at\n # which might be a long time ago\n target_ticket.updated_at = Time.zone.now\n\n # add merge event to both ticket's history (Issue #2469 - Add information \"Ticket merged\" to History)\n target_ticket.history_log(\n 'received_merge',\n data[:user_id],\n id_to: target_ticket.id,\n id_from: id,\n )\n history_log(\n 'merged_into',\n data[:user_id],\n id_to: target_ticket.id,\n id_from: id,\n )\n\n # create new merge article\n Ticket::Article.create(\n ticket_id: id,\n type_id: Ticket::Article::Type.find_by(name: 'note').id,\n sender_id: Ticket::Article::Sender.find_by(name: 'Agent').id,\n body: 'merged',\n internal: false,\n )\n\n # reassign links to the new ticket\n # rubocop:disable Rails/SkipsModelValidations\n Link.where(\n link_object_source_id: Link::Object.find_by(name: 'Ticket').id,\n link_object_source_value: id,\n ).update_all(link_object_source_value: data[:ticket_id])\n Link.where(\n link_object_target_id: Link::Object.find_by(name: 'Ticket').id,\n link_object_target_value: id,\n ).update_all(link_object_target_value: data[:ticket_id])\n # rubocop:enable Rails/SkipsModelValidations\n\n # link tickets\n Link.add(\n link_type: 'parent',\n link_object_source: 'Ticket',\n link_object_source_value: data[:ticket_id],\n link_object_target: 'Ticket',\n link_object_target_value: id\n )\n\n # set state to 'merged'\n self.state_id = Ticket::State.find_by(name: 'merged').id\n\n # rest owner\n self.owner_id = 1\n\n # save ticket\n save!\n\n # touch new ticket (to broadcast change)\n target_ticket.touch # rubocop:disable Rails/SkipsModelValidations\n end\n true\n end", "def deep_merge_hashes(master_hash, other_hash); end", "def wonkofile_merge(old, new)\n res = old.merge new\n # changing versions is not allowed by adding another version index (we might end up with a version in the index that\n # we don't have an actual version file for)\n res['versions'] = old['versions']\n res\nend", "def merge_hot\n if(/!hot! *([\\w;.\\/]+)([\\n])/ =~ @row;@rgx = $~)\n hots= @rgx[1].split(';').collect {|x|x+'.'+@hot}\n rpl = ['']\n hots.each do |hot|\n fls = File.exist?(hot) ? hot :\n File.exist?(@src_path+'/'+hot) ? @src_path+'/'+hot :\n File.exist?(W2Tags::Dir+'/../hot/'+hot) ? W2Tags::Dir+'/../hot/'+hot : ''\n if fls==''\n rpl << \"<!--\"+hot+\", Not Found-->\\n\"\n else\n puts '=>'+File.expand_path(fls) if !@silent\n @tg_hot.merge!(W2Tags.read_filehot(fls))\n end \n end\n @row.gsub!(@rgx.to_s,rpl.join)\n end\n end", "def merge!(other_hash); end", "def codegen_merge\n header, body, footer = \"function merge(results, data)\\n\", [], \"end\\n\"\n\n # Open group loops.\n groups.each_with_index do |group, index|\n data_item = \"data\" + (0...index).to_a.map {|i| \"[k#{i}]\"}.join('')\n results_item = \"results\" + (0..index).to_a.map {|i| \"[k#{i}]\"}.join('')\n body << \"#{' ' * index}for k#{index},v#{index} in pairs(#{data_item}) do\"\n body << \"#{' ' * index} if #{results_item} == nil then #{results_item} = {} end\"\n end\n\n indent = ' ' * groups.length\n body << \"#{indent}a = results\" + (0...groups.length).to_a.map {|i| \"[k#{i}]\"}.join('')\n body << \"#{indent}b = data\" + (0...groups.length).to_a.map {|i| \"[k#{i}]\"}.join('')\n\n # Generate the merge for each field.\n fields.each do |field|\n alias_name = field.target_name\n \n case field.aggregation_type\n when nil\n body << \"#{indent}a.#{alias_name} = b.#{alias_name}\"\n when :count\n body << \"#{indent}a.#{alias_name} = (a.#{alias_name} or 0) + (b.#{alias_name} or 0)\"\n when :sum\n body << \"#{indent}a.#{alias_name} = (a.#{alias_name} or 0) + (b.#{alias_name} or 0)\"\n when :min\n body << \"#{indent}if(a.#{alias_name} == nil or a.#{alias_name} > b.#{alias_name}) then\"\n body << \"#{indent} a.#{alias_name} = b.#{alias_name}\"\n body << \"#{indent}end\"\n when :max\n body << \"#{indent}if(a.#{alias_name} == nil or a.#{alias_name} < b.#{alias_name}) then\"\n body << \"#{indent} a.#{alias_name} = b.#{alias_name}\"\n body << \"#{indent}end\"\n else\n raise StandardError.new(\"Invalid aggregation type: #{field.aggregation_type}\")\n end\n end\n\n # Close group loops.\n groups.reverse.each_with_index do |group, index|\n body << \"#{' ' * (groups.length-index-1)}end\"\n end\n\n # Indent body and return.\n body.map! {|line| \" \" + line}\n return header + body.join(\"\\n\") + \"\\n\" + footer\n end", "def merge\n @primary = Client.find(params[:primary_id])\n @secondary = Client.find(params[:secondary_id])\n \n #merge primary_backup and secondary_backup\n @primary.attributes = @secondary.attributes.except(\"id\", \"created_at\", \"updated_at\")\n .delete_if { |k, v| v.blank? }\n #merge tickets\n @secondary.tickets.update_all(client_id: @primary.id)\n #merge backups\n @secondary.backups.update_all(client_id: @primary.id)\n #merge computers\n @secondary.computers.update_all(client_id: @primary.id)\n #merge parts\n @secondary.parts.update_all(client_id: @primary.id)\n #merge dispatches\n @secondary.dispatches.update_all(client_id: @primary.id)\n #merge items\n @secondary.items.update_all(client_id: @primary.id)\n #merge dispatches\n @secondary.anti_viri.update_all(client_id: @primary.id)\n #merge Contract_services\n @secondary.contract_services.update_all(client_id: @primary.id)\n #merge Contract_service_lines\n @secondary.contract_service_lines.update_all(client_id: @primary.id)\n #save backup merge\n @primary.save\n #remove secondary_backup\n @secondary.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully Merged then destroyed.' }\n format.json { head :no_content }\n \n end\n end", "def scan_for_merges\n moves = []\n # prescan for merges in the list of actions.\n @actions.select {|act| act.is_a? Action::MergeAction}.each do |a|\n # destructure the list\n file, remote_file, filename_dest, flags, move = a.file, a.remote_file, a.file_dest, a.flags, a.move\n UI.debug(\"preserving #{file} for resolve of #{filename_dest}\")\n # look up our changeset for the merge state entry\n vf_local = working_changeset[file]\n vf_other = target_changeset[remote_file]\n vf_base = vf_local.ancestor(vf_other) || @repo.versioned_file(file, :file_id => Updating::NULL_REV)\n # track this merge!\n @repo.merge_state.add(vf_local, vf_other, vf_base, filename_dest, flags)\n\n moves << file if file != filename_dest && move\n end\n moves\n end", "def perform_merge\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n result = false\n\n # Mergeable if there are no fields which are non-blank in\n # both descriptions.\n if @src.class.all_note_fields.none? \\\n { |f| src_notes[f].present? && dest_notes[f].present? }\n result = true\n\n # Copy over all non-blank descriptive fields.\n src_notes.each do |f, val|\n @dest.send(\"#{f}=\", val) if val.present?\n end\n\n # Save changes to destination.\n @dest.save\n\n # Copy over authors and editors.\n @src.authors.each { |user| @dest.add_author(user) }\n @src.editors.each { |user| @dest.add_editor(user) }\n\n # Delete old description if requested.\n delete_src_description_and_update_parent if @delete_after\n end\n\n result\n end", "def use_merging(use = T.unsafe(nil)); end", "def git_merge_base(target, source)\n status, out, err = exec!(\"git merge-base #{target} #{source}\")\n out.strip\n rescue Braid::Commands::ShellExecutionError\n nil\n end", "def merge_with(master, ignored_attr = [])\n # Just in case a user tries to merge a contact with itself,\n # even though the interface prevents this from happening.\n return false if master == self\n\n merge_attr = self.merge_attributes\n # ------ Remove ignored attributes from this contact\n ignored_attr.each { |attr| merge_attr.delete(attr) }\n\n # Perform all actions in an atomic transaction, so that if one part of the process fails,\n # the whole merge can be rolled back.\n Contact.transaction do\n\n # ------ Merge attributes: ensure only model attributes are updated.\n model_attributes = merge_attr.dup.reject{ |k,v| !master.attributes.keys.include?(k) }\n master.update_attributes(model_attributes)\n\n # ------ Merge 'belongs_to' and 'has_one' associations\n {'user_id' => 'user', 'lead_id' => 'lead', 'assigned_to' => 'assignee'}.each do |attr, method|\n unless ignored_attr.include?(attr)\n master.send(method + \"=\", self.send(method))\n end\n end\n \n # ------ Merge address associations\n master.address_attributes.keys.each do |attr|\n unless ignored_attr.include?(attr)\n master.send(attr + \"=\", self.send(attr))\n end\n end\n\n # ------ Merge 'has_many' associations\n self.tasks.each { |t| t.asset = master; t.save! }\n self.emails.each { |e| e.mediator = master; e.save! }\n self.comments.each { |c| c.commentable = master; c.save! }\n\n # Find all AccountContact records with the duplicate contact,\n # and only add the master contact if it is not already added to the account.\n AccountContact.find_all_by_contact_id(self.id).each do |ac|\n unless ac.account.contacts.include?(master)\n ac.contact_id = master.id; ac.save!\n end\n end\n \n # Find all ContactOpportunity records with the duplicate contact,\n # and only add the master contact if it is not already added to the opportunity.\n ContactOpportunity.find_all_by_contact_id(self.id).each do |co|\n unless co.opportunity.contacts.include?(master)\n co.contact_id = master.id; co.save!\n end\n end\n\n # Merge tags\n all_tags = (self.tags + master.tags).uniq\n master.tag_list = all_tags.map(&:name).join(\", \")\n \n # Call the merge_hook - useful if you have custom actions that need to happen during a merge\n master.merge_hook(self)\n\n if master.save!\n # Update any existing aliases that were pointing to the duplicate record\n ContactAlias.find_all_by_contact_id(self.id).each do |ca|\n ca.update_attribute(:contact, master)\n end\n\n # Create the contact alias and destroy the merged contact.\n if ContactAlias.create(:contact => master,\n :destroyed_contact_id => self.id)\n # Must force a reload of the contact, and shake off all migrated assets.\n self.reload\n self.destroy\n end\n end\n end # transaction\n end", "def merge(stmt2)\n # print each statement to a file\n [ [ @rows, \"/tmp/merge.1\" ],\n [ stmt2.rows, \"/tmp/merge.2\" ] ].each do | cur_rows, cur_file |\n f = File.open(cur_file, \"w\")\n cur_rows.each do |row| \n if !row[0].nil?\n f.puts(row[0].text) \n end\n end\n f.close\n end\n \n # run an sdiff on it\n @diffs = []\n IO.popen(\"sdiff -w1 /tmp/merge.1 /tmp/merge.2\") do |f|\n f.each { |line| @diffs.push(line.chomp) }\n end\n system(\"rm /tmp/merge.1 /tmp/merge.2\")\n \n # paralellize the arrays, by inserting blank rows\n @diffs.each_with_index do |cur_diff,idx|\n if cur_diff == \"<\"\n new_row = [@rows[idx][0]]\n while new_row.length < stmt2.rows[idx].length\n new_row.push(Cell.new)\n end\n stmt2.rows.insert(idx,new_row)\n elsif cur_diff == \">\"\n new_row = [stmt2.rows[idx][0]]\n while new_row.length < @rows[idx].length\n new_row.push(Cell.new)\n end\n @rows.insert(idx,new_row)\n else\n end\n end\n \n # merge them together\n @rows.size.times do |i|\n @rows[i].concat(stmt2.rows[i])\n end\n end", "def deep_merge(source, hash); end", "def deep_merge(source, hash); end", "def merge_sort(&prc)\n end", "def pg_hash_only_merge(merge_onto, merge_with)\n # If there are two Hashes, recursively merge.\n if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)\n merge_with.each do |key, merge_with_value|\n merge_onto[key] = pg_hash_only_merge(merge_onto[key], merge_with_value)\n end\n merge_onto\n\n # If merge_with is nil, don't replace merge_onto\n elsif merge_with.nil?\n merge_onto\n\n # In all other cases, replace merge_onto with merge_with\n else\n merge_with\n end\nend", "def mergeSortHelper(ia, left, right)\n if(left < right)\n mid = ((left + right) / 2).to_i\n\n mergeSortHelper(ia, left, mid)\n mergeSortHelper(ia, mid + 1, right)\n\n merge(ia, left, mid, right)\n end\nend", "def test_manual_commit_and_merge\n sh(a_path, \"git status\")\n sh(a_path, \"git checkout gitgo\")\n \n method_root.prepare(:tmp, 'a/two') {|io| io << \"two content\" }\n \n sh(a_path, \"git add .\")\n sh(a_path, \"git commit -m 'message'\")\n\n a.reset\n b.reset\n assert_equal \"two content\", a['two']\n assert_equal nil, b['two']\n \n sh(b_path, \"git checkout gitgo\")\n sh(b_path, \"git pull\")\n \n a.reset\n b.reset\n assert_equal \"two content\", a['two']\n assert_equal \"two content\", b['two']\n end", "def merge_file(fp:, from_dir:, to_dir:, prepend_path: '', keep_rela_path: false, rename: nil)\n\n @@logger.debug \"merge_file #{fp}\"\n @try_counter += 1\n\n do_merge = false\n\n begin\n s_f = most_similar_file(fp, to_dir)\n if !(FileCompare.new(fp, s_f).similar?)\n # not exist, do merge, return target\n @@logger.info \"merge_file new! #{fp}\".green\n do_merge = true\n else\n # exist\n @@logger.info \"merge_file exist. #{s_f}\".yellow\n do_merge = false\n end\n rescue UncertainSimilarityError => e # not sure, user decided\n if !e.user_judge # files are not the same\n @@logger.info \"merge_file new! #{fp} \".green\n do_merge = true\n else # files are the same\n if user_confirm(\"Force merge and overwrite ???\".red)\n File.delete(e.b)\n do_merge = true\n else\n do_merge = false\n @@logger.info \"user skip merge_file #{fp}\"\n end\n end\n end\n\n if do_merge\n if nil != rename && '' != rename\n new_bn = rename\n else\n new_bn = File.basename(fp)\n end\n\n rel_path = Pathname.new(File.dirname(fp)).relative_path_from(Pathname.new(from_dir))\n if keep_rela_path\n @@logger.debug \"prepend_path #{prepend_path} rel_path #{rel_path}\"\n new_path = File.join(prepend_path, rel_path)\n else\n new_path = prepend_path\n end\n\n new_fp = File.join(to_dir, new_path, new_bn)\n\n if !Dir.exist?(File.join(to_dir, new_path))\n FileUtils.mkdir_p(File.join(to_dir, new_path))\n end\n\n FileUtils.cp(fp, new_fp, verbose: true)\n @file_trans.add(from:fp, to:new_fp)\n new_fp\n else\n nil\n end\n end", "def merge!(oth)\n t = merge(oth)\n if self == t\n nil\n else\n replace!(t)\n self\n end\n end", "def mergeSort(arr,l,r)\n # Merges two subarrays of arr[].\n # First subarray is arr[l..m]\n # Second subarray is arr[m+1..r]\n def merge(arr, l, m, r)\n n1 = m - l + 1\n n2 = r- m\n \n # create temp arrays\n aL = Array.new(n1, 0)\n aR = Array.new(n2, 0)\n \n # Copy data to temp arrays L[] and R[]\n for i in 0..n1\n aL[i] = arr[l + i]\n end\n \n for j in 0..n2\n aR[j] = arr[m + 1 + j]\n end\n \n # Merge the temp arrays back into arr[l..r]\n i = 0 # Initial index of first subarray\n j = 0 # Initial index of second subarray\n k = l # Initial index of merged subarray\n \n while i < n1 and j < n2 do\n if aL[i] <= aR[j] then\n arr[k] = aL[i]\n i += 1\n else\n arr[k] = aR[j]\n j += 1\n end\n k += 1\n end\n \n # Copy the remaining elements of L[], if there\n # are any\n while i < n1 do\n arr[k] = aL[i]\n i += 1\n k += 1\n end\n \n # Copy the remaining elements of R[], if there\n # are any\n while j < n2 do\n arr[k] = aR[j]\n j += 1\n k += 1\n end\n end # merge \n \n # l is for left index and r is right index of the\n # sub-array of arr to be sorted\n if l < r then\n # Same as (l+r)/2, but avoids overflow for\n # large l and h\n m = (l+(r-1))/2\n\n # Sort first and second halves\n mergeSort(arr, l, m)\n mergeSort(arr, m+1, r)\n merge(arr, l, m, r)\n end\n return arr\n end", "def get_merged(br)\n __branches \"-l --merged #{br}\"\nend", "def merge(a, b)\n for i in 0..(a.length() - 1) # left array is colored red\n a[i].color = [1, 0, 0] #\n end #\n for i in 0..(b.length() - 1) # right array is colored blue\n b[i].color = [0, 0, 1] #\n end #\n c = Array.new(a.length() + b.length())\n ia = 0\n ib = 0\n ic = 0\n while ia < a.length() && ib < b.length()\n a[ia].raise_hand() ; b[ib].raise_hand() # raise hands of compared persons\n if a[ia] < b[ib]\n c[ic] = a[ia]\n move_smaller(c[ic], ic - ia) # move smaller person\n ia = ia + 1\n ic = ic + 1\n else\n c[ic] = b[ib]\n move_smaller(c[ic], ic - (a.length() + ib)) # ditto\n ib = ib + 1\n ic = ic + 1\n end\n end\n if ia < a.length()\n for i in ia..(a.length() - 1)\n c[ic] = a[i]\n move_smaller(c[ic], ic - i) # move remaining person\n ic = ic + 1\n end\n else\n if ib < b.length()\n for i in ib..(b.length() - 1)\n c[ic] = b[i]\n move_smaller(c[ic], ic - (a.length() + i)) # ditto\n ic = ic + 1\n end\n end\n end\n c\nend", "def merge(left, right, &prc)\nmerged_array = []\nprc ||= Proc.new { |num1, num2| num1 <=> num2 }\nuntil left.empty? || right.empty?\n case prc.call(left.first, right.first)\n when -1\n merged_array << left.shift\n when 0\n merged_array << left.shift\n when 1\n merged_array << right.shift\n end\nend\n\nmerged_array + left + right\nend", "def merge(...)\n self.clone.merge!(...)\n end", "def deep_merge!(*other_hashes, &blk); end", "def deep_merge(*other_hashes, &blk); end", "def merge(other_person, force: false)\n # Consider just using straight SQL for this --\n # it's not complicated, and the current process generates an\n # enormous amount of SQL\n\n ActiveSupport::Notifications.instrument(\n \"merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name)\n ) do\n unless merge?(other_person, force: force)\n ActiveSupport::Notifications.instrument(\n \"failure.merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name)\n )\n return false\n end\n\n Person.transaction do\n before_merge other_person\n\n if login.blank? && other_person.login.present?\n self.login = other_person.login\n self.crypted_password = other_person.crypted_password\n PaperTrail.request(enabled: false) do\n other_person.update login: nil\n end\n end\n self.member_from = other_person.member_from if member_from.nil? || (other_person.member_from && other_person.member_from < member_from)\n self.member_to = other_person.member_to if member_to.nil? || (other_person.member_to && other_person.member_to > member_to)\n\n other_person_is_newer = other_person.created_at > created_at\n MERGE_ATTRIBUTES.each do |attribute|\n send(\"#{attribute}=\", other_person.send(attribute)) if other_person.send(attribute).present? && (send(attribute).blank? || other_person_is_newer)\n end\n\n if date_of_birth && other_person.date_of_birth && date_of_birth.day == 1\n self.date_of_birth = Time.zone.local(date_of_birth.year, date_of_birth.month, other_person.date_of_birth.day)\n end\n\n # Prevent unique index collision\n other_person.update_column :license, nil\n\n save!\n\n # save! can trigger automatic deletion for people created for old orders\n # if that happens, don't try and merge associations\n return true unless Person.exists?(id)\n\n aliases << other_person.aliases\n editor_requests << other_person.editor_requests\n editors << (other_person.editors - editors).uniq.reject { |e| e == self }\n events << other_person.events\n event_teams = event_team_memberships.map(&:event_team_id)\n event_team_memberships << other_person.event_team_memberships.reject { |e| event_teams.include?(e.event_team_id) }\n names << other_person.names\n race_numbers << other_person.race_numbers\n results << other_person.results\n versions << other_person.versions\n\n other_person.event_team_memberships.reload.clear\n Person.delete other_person.id\n existing_alias = aliases.detect { |a| a.name.casecmp(other_person.name) == 0 }\n aliases.create(name: other_person.name) if existing_alias.nil? && Person.find_all_by_name(other_person.name).empty?\n end\n end\n\n ActiveSupport::Notifications.instrument(\n \"success.merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name)\n )\n\n true\n end", "def merge(other)\n self.merge_actors(other)\n self.compress_history()\n end", "def do_merge_sort(first, last)\n return if first >= last\n \n mid = (first + last)/2\n do_merge_sort(first, mid)\n do_merge_sort(mid+1, last)\n do_simple_merge(first,mid,last)\n end", "def deep_merge_hashes!(target, overwrite); end", "def merge(build)\n Rails.logger.info(\"Trying to merge branch: #{build.branch} to master after build id: #{build.id}\")\n\n checkout_log, status = Open3.capture2e(\"git checkout master && git pull\")\n raise_and_log(\"Was unable checkout and pull master:\\n\\n#{checkout_log}\") if status.exitstatus != 0\n\n commit_message = \"Kochiku merge of branch #{build.branch} for build id: #{build.id} ref: #{build.ref}\"\n merge_log, status = Open3.capture2e(merge_env, \"git merge --no-ff -m '#{commit_message}' #{build.ref}\")\n abort_merge_and_raise(\"git merge --abort\",\n \"Was unable to merge your branch:\\n\\n#{merge_log}\") unless status.success?\n\n push_log, status = Open3.capture2e(\"git push origin master\")\n rebase_log, second_push_log = recover_failed_push unless status.success?\n\n [checkout_log, merge_log, push_log, rebase_log, second_push_log].join(\"\\n\")\n end", "def merge(other_person)\n # Consider just using straight SQL for this --\n # it's not complicated, and the current process generates an\n # enormous amount of SQL\n\n ActiveSupport::Notifications.instrument(\n \"merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name)\n ) do\n\n if other_person.nil? || other_person == self\n ActiveSupport::Notifications.instrument(\n \"failure.merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name),\n )\n return false\n end\n\n Person.transaction do\n self.merge_version do\n if login.blank? && other_person.login.present?\n self.login = other_person.login\n self.crypted_password = other_person.crypted_password\n other_person.skip_version do\n other_person.update login: nil\n end\n end\n if member_from.nil? || (other_person.member_from && other_person.member_from < member_from)\n self.member_from = other_person.member_from\n end\n if member_to.nil? || (other_person.member_to && other_person.member_to > member_to)\n self.member_to = other_person.member_to\n end\n\n if license.blank?\n self.license = other_person.license\n end\n\n save!\n aliases << other_person.aliases\n events << other_person.events\n names << other_person.names\n results << other_person.results\n race_numbers << other_person.race_numbers\n\n begin\n versions << other_person.versions\n rescue ActiveRecord::SerializationTypeMismatch => e\n logger.error e\n end\n\n versions.sort_by(&:created_at).each_with_index do |version, index|\n version.number = index + 2\n version.save!\n end\n\n Person.delete other_person.id\n existing_alias = aliases.detect{ |a| a.name.casecmp(other_person.name) == 0 }\n if existing_alias.nil? and Person.find_all_by_name(other_person.name).empty?\n aliases.create(name: other_person.name)\n end\n end\n end\n\n ActiveSupport::Notifications.instrument(\n \"success.merge.people.admin.racing_on_rails\",\n person_id: id,\n person_name: name,\n other_id: other_person.try(:id),\n other_name: other_person.try(:name),\n )\n\n true\n end\n end", "def restore_merge_state\n if @merge_head\n FileUtils.touch(File.expand_path('MERGE_MODE', Overcommit::Utils.git_dir))\n\n File.open(File.expand_path('MERGE_HEAD', Overcommit::Utils.git_dir), 'w') do |f|\n f.write(\"#{@merge_head}\\n\")\n end\n @merge_head = nil\n end\n\n if @merge_msg\n File.open(File.expand_path('MERGE_MSG', Overcommit::Utils.git_dir), 'w') do |f|\n f.write(\"#{@merge_msg}\\n\")\n end\n @merge_msg = nil\n end\n end", "def merge(other = {})\n branch default_options.merge(other)\n end", "def merge(left, right)\n sorted = []\n while [left, right].none?(&:empty?)\n sorted << (compare(left[0], right[0]) ? left.shift : right.shift)\n end\n sorted + left + right\nend" ]
[ "0.7589137", "0.75158036", "0.7012891", "0.6889406", "0.67575186", "0.67201746", "0.6711104", "0.66018564", "0.65267843", "0.64883494", "0.6487487", "0.64487994", "0.6407289", "0.6374257", "0.62840647", "0.62390435", "0.6180874", "0.6174343", "0.6168958", "0.6156112", "0.61410844", "0.60992265", "0.60992265", "0.60992265", "0.6098879", "0.6087834", "0.608268", "0.6078622", "0.60620856", "0.59930974", "0.598768", "0.5984335", "0.5961204", "0.5948574", "0.5943279", "0.5939385", "0.59280163", "0.59147555", "0.5910327", "0.5909114", "0.5905596", "0.59021175", "0.58741343", "0.58741343", "0.5850736", "0.584959", "0.58420813", "0.5821383", "0.58099353", "0.5808633", "0.5805881", "0.5786961", "0.5748843", "0.5748507", "0.5738471", "0.57217145", "0.5710555", "0.56946516", "0.5683349", "0.5683349", "0.5643933", "0.56405705", "0.5638431", "0.56364053", "0.56314284", "0.5627155", "0.5625121", "0.5622197", "0.5619978", "0.5596948", "0.5591764", "0.5582577", "0.5581854", "0.5581728", "0.55684894", "0.55667084", "0.5546581", "0.5546581", "0.55070275", "0.5500784", "0.5496907", "0.5495972", "0.5483911", "0.54834306", "0.5477361", "0.54649013", "0.5457594", "0.5454898", "0.5452357", "0.5449109", "0.54451567", "0.54441607", "0.5436386", "0.54321134", "0.54205155", "0.54012674", "0.53995365", "0.5398955", "0.53922", "0.5386057" ]
0.6415164
12