query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
GET /badges/1 GET /badges/1.json | def show
@badge = Badge.find_by_key(params[:id])
respond_to do |format|
format.html
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def badges\n get(\"user/#{user_id}/badges.json\")\n end",
"def badges(id)\n get(\"users/#{id}/badges\")\n end",
"def full_badges\n client.user_badges(id)\n end",
"def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end",
"def badge\n if badge_id\n Merit::Badge.find(badge_id)\n else\n Merit::Badge.find_by_name_and_level(badge_name, level)\n end\n end",
"def badges(options={})\n self.class.parse_badges(request(singular(user_id) + \"/badges\", options))\n end",
"def badges(options={})\n get('/user_badge', options)\n end",
"def badge\n if @badge.nil?\n badges = Badge.by_name(badge_name)\n badges = badges.by_level(level) unless level.nil?\n @badge = badges.first\n end\n @badge\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end",
"def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end",
"def show\n @badge = Badge.find(params[:id])\n @users = @badge.users\n respond_with @badge\n end",
"def user_badges user_id=\"self\"\n response = get(\"/users/#{user_id}/badges\")[\"response\"]\n if response[\"sets\"] and response[\"sets\"][\"groups\"]\n response[\"sets\"][\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}\n end\n\n if response[\"badges\"]\n response[\"badges\"].each_key do |badge_id|\n response[\"badges\"][badge_id] = badge(badge_id)\n end\n end\n response\n end",
"def badges_for_user(username)\n response = get \"v1/market/user-badges:#{username}.json\"\n response[:'user-badges']\n end",
"def badges_url\n view_context.badges_url\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def show\n @badge = Badge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def show\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @badge }\n end\n \n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid flag #{params[:id]}\"\n redirect_to root_path, notic: 'Invalid page'\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def get_project_vulnerabilities_badge1_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge1 ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling BadgeApi.get_project_vulnerabilities_badge1\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{uuid}'.sub('{' + 'uuid' + '}', CGI.escape(uuid.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(['image/svg+xml'])\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] || 'ProjectMetrics' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgeApi#get_project_vulnerabilities_badge1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def parse_badges(result)\n parse_type(result, \"badge\")\n end",
"def index\n @user_badges = UserBadge.where(active: true).where(user_id: params[:user_id])\n end",
"def get_project_vulnerabilities_badge1(uuid, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge1_with_http_info(uuid, opts)\n data\n end",
"def [](level)\n raise ArgumentError unless valid?(level)\n\n @badges ||= {}\n @badges[level] ||= new(level)\n end",
"def fetch_badge_from_params\n badge = nil\n\n params.permit(:badge_name)\n if params[:badge_name].nil?\n params.require(:badge_id)\n badge = Badge.find_by(id: params[:badge_id], enabled: true)\n else\n badge = Badge.find_by(name: params[:badge_name], enabled: true)\n end\n raise Discourse::NotFound if badge.blank?\n\n badge\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }\n format.json { render :json => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n check_authorization\n #@badges = Badge.find(:all, :conditions => [\"organization_id = ? and segment_id = ?\", @organization.id, @segment.id ] )\n @badges = Badge.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end",
"def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def showbadge\n authorize! :read, Operator\n @operator = Operator.find_by_badge(params[:badge])\n if @operator\n render json: @operator, except: :badge\n else\n render json: {error: ['Cannot find user']}, status: :unprocessable_entity\n end\n end",
"def index\n @my_badges = current_account.my_badges \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_my_badges }\n end\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge }\n else\n format.html { render :edit }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def badges\n end",
"def index\n if current_user.admin?\n @badges = Badge.all\n else\n @badges = Badge.finished\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n session[:admin] = true\n @badges = Badge.order('approved_at desc,id')\n @fri_count = Badge.select { |b| b.friday? }.size\n @sat_count = Badge.select { |b| b.saturday? }.size\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @badges }\n end\n end",
"def new_badges\n achievements.map(&:new_badges).flatten\n end",
"def get_badge\n swimmer.badges.for_season(@season).first if swimmer.badges.for_season(@season).exists?\n end",
"def add_badge(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"] = true\n badges[\"#{badge_id}\"][\"earn_date\"] = Date.current\n self.update(badges: badges.to_json)\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end",
"def update_badges(badge)\n @badges = {}\n badge.split(',').each do |_badge|\n type, value = _badge.split '/'\n @badges[type] = value.to_i\n end\n end",
"def get_project_vulnerabilities_badge_with_http_info(name, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge ...'\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{name}/{version}'.sub('{' + 'name' + '}', CGI.escape(name.to_s)).sub('{' + 'version' + '}', CGI.escape(version.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(['image/svg+xml'])\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] || 'ProjectMetrics' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgeApi#get_project_vulnerabilities_badge\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def set_admin_badge\n @badge = Badge.find(params[:id])\n end",
"def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end",
"def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @badges }\n end\n end",
"def for_badge(badge); end",
"def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end",
"def show\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gauge }\n end\n end",
"def parse_badges(badges)\n badges.map { |badge| create_new_badge(badge) } if badges\n end",
"def update\n @badge = Badge.find(params[:id])\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n flash[:notice] = 'Badge was successfully updated.'\n format.html { redirect_to organization_segment_badge_url(@organization,@segment, @badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @badge_projects = BadgeProject.all\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end",
"def badges\n achievements.reduce({}) do |badges, achievement|\n badges.merge(achievement.name => achievement.badges)\n end\n end",
"def badge; end",
"def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end",
"def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated badge: #{@badge.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @badge = Badge.find(params[:id])\n if not @badge.finished? and not current_user.admin?\n redirect_to home_url\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def badges\n Merit::Badge.find { |b| b.custom_fields[:skill_level] == self.name_key.to_sym }\n end",
"def get_badge(subject, status, color = 'blue', options = {})\n st = status.gsub(/-/, '--').gsub(/_/, '__')\n res = \"https://img.shields.io/badge/#{subject}-#{st}-#{color}.svg\"\n res += \"?style=#{options[:style]}\" if options[:style]\n res\n end",
"def craft_badge(badge_page_url)\n appid = badge_page_url.split('/').last\n uid = badge_page_url.split('/')[4]\n # TODO, figure out what the series and border_color parameters mean.\n # for now set them to the observed values of 1,0\n sessionid = URI.decode(@c.cookie_manager.cookies.select{|i| i.match?(URI(\"https://steamcommunity.com\")) && i.name == \"sessionid\"}.first.value)\n body = {\n appid: appid,\n series: 1,\n border_color: 0,\n sessionid: sessionid\n }\n res = @c.post(\"http://steamcommunity.com/id/#{uid}/ajaxcraftbadge/\", body, {Referer: badge_page_url, Origin: \"http://steamcommunity.com\"}) rescue nil\n res && res.code == 200\n end",
"def set_badge\n @badge = Badge.friendly.find(params[:id])\n authorize @badge\n end",
"def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end",
"def badge(*args)\n badge_label(:badge, *args)\n end",
"def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end",
"def update\n get_my_badge\n respond_to do |format|\n if @my_badge.update_attributes(params[:my_badge])\n flash[:notice] = 'Your badge was successfully updated.'\n format.html { redirect_to user_my_badge_url(@my_badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end",
"def show\n authorize @badge\n @staff = User.where(role: 'staff', school: current_user.school)\n @awarded_badge = AwardedBadge.where(user: current_user, badge: @badge).first\n end",
"def find_badge(name)\n badge_name = name.delete(\" \").downcase #delete whitespace\n return name unless badges.has_key?(badge_name)\n badges[badge_name] \n end",
"def index\n @honey_badgers = HoneyBadger.all\n respond_to do |format|\n format.html\n format.json { render json: @honey_badgers }\n end\n end",
"def show\n @account = current_account\n @my_badges = current_account.my_badges\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @my_badge }\n end\n end",
"def get_project_vulnerabilities_badge(name, version, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge_with_http_info(name, version, opts)\n data\n end",
"def badges_version_list_with_http_info(owner, repo, package_format, package_name, package_version, package_identifiers, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: BadgesApi.badges_version_list ...\"\n end\n # verify the required parameter 'owner' is set\n if @api_client.config.client_side_validation && owner.nil?\n fail ArgumentError, \"Missing the required parameter 'owner' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'repo' is set\n if @api_client.config.client_side_validation && repo.nil?\n fail ArgumentError, \"Missing the required parameter 'repo' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_format' is set\n if @api_client.config.client_side_validation && package_format.nil?\n fail ArgumentError, \"Missing the required parameter 'package_format' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_name' is set\n if @api_client.config.client_side_validation && package_name.nil?\n fail ArgumentError, \"Missing the required parameter 'package_name' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_version' is set\n if @api_client.config.client_side_validation && package_version.nil?\n fail ArgumentError, \"Missing the required parameter 'package_version' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_identifiers' is set\n if @api_client.config.client_side_validation && package_identifiers.nil?\n fail ArgumentError, \"Missing the required parameter 'package_identifiers' when calling BadgesApi.badges_version_list\"\n end\n # resource path\n local_var_path = \"/badges/version/{owner}/{repo}/{package_format}/{package_name}/{package_version}/{package_identifiers}/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s).sub('{' + 'package_format' + '}', package_format.to_s).sub('{' + 'package_name' + '}', package_name.to_s).sub('{' + 'package_version' + '}', package_version.to_s).sub('{' + 'package_identifiers' + '}', package_identifiers.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'badge_token'] = opts[:'badge_token'] if !opts[:'badge_token'].nil?\n query_params[:'cacheSeconds'] = opts[:'cache_seconds'] if !opts[:'cache_seconds'].nil?\n query_params[:'color'] = opts[:'color'] if !opts[:'color'].nil?\n query_params[:'label'] = opts[:'label'] if !opts[:'label'].nil?\n query_params[:'labelColor'] = opts[:'label_color'] if !opts[:'label_color'].nil?\n query_params[:'logoColor'] = opts[:'logo_color'] if !opts[:'logo_color'].nil?\n query_params[:'logoWidth'] = opts[:'logo_width'] if !opts[:'logo_width'].nil?\n query_params[:'render'] = opts[:'render'] if !opts[:'render'].nil?\n query_params[:'shields'] = opts[:'shields'] if !opts[:'shields'].nil?\n query_params[:'show_latest'] = opts[:'show_latest'] if !opts[:'show_latest'].nil?\n query_params[:'style'] = opts[:'style'] if !opts[:'style'].nil?\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['apikey']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgesApi#badges_version_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def add_badge!( badge, update_badge = true )\n unless @badges.include?( badge )\n @badges << badge\n badge.add_user!( self, false) if update_badge\n end\n return @badges\n end",
"def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badges_count\n badges.count\n end",
"def show\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gage }\n end\n end",
"def has_badge?(badge)\n case badge\n when Badge\n badges.find_by_id(badge.id)\n when Fixnum\n badges.find_by_id(badge)\n when String\n badges.find_by_name(badge)\n end\n end",
"def show\n @green = Green.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @green }\n end\n end",
"def new\n @gauge = Gauge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gauge }\n end\n end",
"def badge_url\n raise NotImplementedError\n end",
"def badge_image\n badge_type.image_url + year.to_s + \".png\"\n end",
"def crear_achievement badge, id_app\n description = badge[\"description\"].encode(\"UTF-8\")\n \n body = {\n name:badge[\"name\"],\n imageUrl:badge[\"imageUrl\"],\n unique: true,\n criteriaUrl: badge[\"criteriaUrl\"],\n earnerDescription: description,\n consumerDescription: description ,\n criteria: badge[\"criteria\"],\n type: 'Badge'\n }\n status 201\n \n response = signed_post_request @@API_ROOT+\"/issuers/#{id_app}/badges\", body\n\n end",
"def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to(admin_badges_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted badge: #{@badge.name}\")\n end",
"def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend",
"def create\n @user_badge = UserBadge.new(user_badge_params)\n @user_badge.active = true\n @user_badge.user_id = @user.id\n\n respond_to do |format|\n if @user_badge.save\n format.html { redirect_to team_user_path(@team, @user), notice: 'User badge was successfully created.' }\n format.json { render :show, status: :created, location: @user_badge }\n else\n format.html { render :new }\n format.json { render json: @user_badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_user\n id = params[:slug] || params[:id]\n @user = User.find(id)\n @badges = @user.badges.group_by(&:level)\n end",
"def index\n @bulletins = Bulletin.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bulletins }\n end\n end",
"def show\n @gist = Gist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gist }\n end\n end",
"def achievement_badge_path(achievement = nil)\n image_path(achievement&.badge&.medium&.url || 'achievement_blank.png')\n end",
"def index\n @badge_categories = BadgeCategory.all\n end",
"def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end",
"def show\n @gastracker = Gastracker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gastracker }\n end\n end",
"def set_user_badge\n @user_badge = UserBadge.find(params[:user_badge_id])\n end",
"def new\n @meritbadge = Meritbadge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @meritbadge }\n end\n end"
] | [
"0.82816005",
"0.7840446",
"0.7380956",
"0.7360627",
"0.7244829",
"0.71667504",
"0.7026382",
"0.6960049",
"0.6957535",
"0.6946959",
"0.6925517",
"0.68794656",
"0.6792295",
"0.66721576",
"0.6649838",
"0.6576033",
"0.6542274",
"0.6541617",
"0.6541617",
"0.6541617",
"0.6520932",
"0.64992493",
"0.64456975",
"0.64445317",
"0.64355505",
"0.63744426",
"0.63265306",
"0.62988704",
"0.6292403",
"0.62876076",
"0.6277409",
"0.62699914",
"0.6262015",
"0.6240285",
"0.6215581",
"0.6171743",
"0.6155408",
"0.61146235",
"0.6111611",
"0.61112446",
"0.61044294",
"0.6031487",
"0.6026476",
"0.6023703",
"0.5963545",
"0.5954217",
"0.59215856",
"0.59089017",
"0.5908058",
"0.58885604",
"0.5857089",
"0.58547914",
"0.58441985",
"0.5819448",
"0.57878846",
"0.57877624",
"0.57623464",
"0.5750281",
"0.57371885",
"0.5733273",
"0.57322097",
"0.572648",
"0.57246065",
"0.5718194",
"0.5717329",
"0.57121",
"0.57016766",
"0.5693021",
"0.5672123",
"0.5671637",
"0.5668391",
"0.5645848",
"0.5645149",
"0.56334484",
"0.562786",
"0.56062984",
"0.56006026",
"0.5583798",
"0.55781376",
"0.5557395",
"0.5544177",
"0.5542894",
"0.5539044",
"0.5519711",
"0.5509259",
"0.5496594",
"0.54822046",
"0.5465785",
"0.54651254",
"0.5462421",
"0.54542667",
"0.5448157",
"0.5408755",
"0.5405553",
"0.54020107",
"0.54016805",
"0.53697664",
"0.53665346",
"0.53462356",
"0.53449005"
] | 0.6895976 | 11 |
GET /badges/new GET /badges/new.json | def new
@badge = Badge.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @badge }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }\n format.json { render :json => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_new_badge(badge)\n Badge.new(badge)\n end",
"def new\n @green = Green.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @green }\n end\n end",
"def new\n @gist = Gist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gist }\n end\n end",
"def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def new\n @gauge = Gauge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gauge }\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @gig_request = GigRequest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig_request }\n end\n end",
"def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end",
"def new\n @pledge = Pledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pledge }\n end\n end",
"def new\n @meritbadge = Meritbadge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @meritbadge }\n end\n end",
"def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @good }\n end\n end",
"def new\n @grade = Grade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grade }\n end\n end",
"def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @bounty = Bounty.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bounty }\n end\n end",
"def new\n @hoge = Hoge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hoge }\n end\n end",
"def new\n @gitem = Gitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitem }\n end\n end",
"def new\n @gage = Gage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gage }\n end\n end",
"def new\n @tagging = Tagging.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagging }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @normal_issue = NormalIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @normal_issue }\n end\n end",
"def new\n @hit = Hit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hit }\n end\n end",
"def new\n @issue = Issue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def badges\n get(\"user/#{user_id}/badges.json\")\n end",
"def new\n @stalking = Stalking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stalking }\n end\n end",
"def new\n @lodge = Lodge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lodge }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @notice = @person.notices.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notice }\n end\n end",
"def new\n @needed_good = NeededGood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @needed_good }\n end\n end",
"def new\n @have = Have.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @have }\n end\n end",
"def new\n @bulletin = Bulletin.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bulletin }\n end\n end",
"def new\n @level_goal = LevelGoal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_goal }\n end\n end",
"def new\n @popularty = Popularty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @popularty }\n end\n end",
"def new\n @fridge = Fridge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fridge }\n end\n end",
"def create\n respond_to do |format|\n if @badge.save\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully created.') }\n format.xml { render xml: @badge, status: :created, location: @badge }\n website.add_log(user: current_user, action: \"Created badge: #{@badge.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @damage = Damage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @damage }\n end\n end",
"def new\n @contribution = Contribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contribution }\n end\n end",
"def new\n @grade = Grade.new\n\n respond_to do |format|\n format.html { render :layout => false }\n format.json { render json: @grade }\n end\n end",
"def new\n @glass = Glass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glass }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end",
"def new\n @baggage = Baggage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @baggage }\n end\n end",
"def new\n @messege = Messege.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messege }\n end\n end",
"def new\n if params[:product_id]\n @badge.product = Product.find(params[:product_id])\n end\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @badge }\n end\n end",
"def new\n @pushup = Pushup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pushup }\n end\n end",
"def new\n @garbage = Garbage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @garbage }\n end\n end",
"def new\n @laugh = Laugh.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @laugh }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @health_level }\n end\n end",
"def new\n get_status\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @enhancement = Enhancement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enhancement }\n end\n end",
"def new\n @grm = Grm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @grm }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end",
"def new\n @zombie = Zombie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zombie }\n end\n end",
"def new\n @threshold = Threshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @threshold }\n end\n end",
"def new\n @patch = Patch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patch }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announce }\n end\n end",
"def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end",
"def new\n @bundle = Bundle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bundle }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def new\n @goal = Goal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goal }\n end\n end",
"def new\n @encounter = Encounter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @encounter }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interest }\n end\n end",
"def new\n @belief = Belief.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @belief }\n end\n end",
"def new\n @status = Status.new\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 @push_notification = PushNotification.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @push_notification }\n end\n end",
"def new\n @compromise = Compromise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @compromise }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end",
"def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end",
"def new\n @prob = Prob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prob }\n end\n end",
"def new\n @gastracker = Gastracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gastracker }\n end\n end",
"def new\n @objective = Objective.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @objective }\n end\n end",
"def new\n @ninja = Ninja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ninja }\n end\n end",
"def new\n get_projects\n\n\n @breadcrumb = 'create'\n @billable_item = BillableItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billable_item }\n end\n end",
"def new\n @Love = Love.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @Love }\n end\n end",
"def new\n @bob = Bob.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bob }\n end\n end",
"def new\n @gopy = Gopy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gopy }\n end\n end",
"def new\n @gnode = Gnode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gnode }\n end\n end",
"def new\n @gid2name = Gid2name.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gid2name }\n end\n end",
"def new\n @tag = Tag.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @interest = Interest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interest }\n end\n end",
"def new\n @gl = Gl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gl }\n end\n end",
"def new\n @base_issue = BaseIssue.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @base_issue }\n end\n end",
"def new\n @lost_pet = LostPet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost_pet }\n end\n end",
"def 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 @lbl_colour = LblColour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lbl_colour }\n end\n end",
"def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announcement }\n end\n end",
"def new\n @githuber = Githuber.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @githuber }\n end\n end",
"def new\n @gold_price = GoldPrice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gold_price }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def create\n @meritbadge = Meritbadge.new(params[:meritbadge])\n\n respond_to do |format|\n if @meritbadge.save\n format.html { redirect_to(@meritbadge, :notice => 'Meritbadge was successfully created.') }\n format.xml { render :xml => @meritbadge, :status => :created, :location => @meritbadge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meritbadge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n #@gethotel = Gethotel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gethotel }\n end\n end"
] | [
"0.81727326",
"0.76246285",
"0.7512228",
"0.7369779",
"0.70479316",
"0.6955548",
"0.6943522",
"0.69004935",
"0.68820465",
"0.6828595",
"0.6789535",
"0.6776546",
"0.6776546",
"0.6743277",
"0.6743267",
"0.67414254",
"0.6724051",
"0.66959083",
"0.6686734",
"0.66722065",
"0.66702324",
"0.66555744",
"0.66513383",
"0.66453433",
"0.6644062",
"0.663724",
"0.6615093",
"0.66105884",
"0.6604284",
"0.65691626",
"0.656176",
"0.6557698",
"0.6556369",
"0.6553781",
"0.65479004",
"0.6545513",
"0.65448827",
"0.6539798",
"0.6537074",
"0.6522188",
"0.652065",
"0.65004724",
"0.6496507",
"0.6488351",
"0.64879787",
"0.6478507",
"0.647485",
"0.6471025",
"0.6465989",
"0.6458221",
"0.64571893",
"0.6456988",
"0.6450702",
"0.6449032",
"0.64481676",
"0.64477926",
"0.64370406",
"0.64300215",
"0.6428932",
"0.64188266",
"0.6418384",
"0.6409239",
"0.6402025",
"0.6399512",
"0.63927114",
"0.63927114",
"0.63927114",
"0.6385099",
"0.6383892",
"0.637906",
"0.6378559",
"0.6375161",
"0.6374141",
"0.63729274",
"0.6372163",
"0.63664734",
"0.63649684",
"0.6364744",
"0.636114",
"0.6354676",
"0.63499737",
"0.63489354",
"0.6346814",
"0.6345479",
"0.6343535",
"0.63407964",
"0.6337055",
"0.63261443",
"0.63230664",
"0.63219535",
"0.6321031",
"0.63185906",
"0.63185084",
"0.6315905",
"0.6314864",
"0.6311727",
"0.63115144",
"0.63086957",
"0.6298184",
"0.6294537"
] | 0.8216712 | 0 |
POST /badges POST /badges.json | def create
@badge = Badge.new(params[:badge])
respond_to do |format|
if @badge.save
format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }
format.json { render :json => @badge, :status => :created, :location => @badge }
else
format.html { render :action => "new" }
format.json { render :json => @badge.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def badges\n get(\"user/#{user_id}/badges.json\")\n end",
"def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end",
"def create\n @user_badge = UserBadge.new(user_badge_params)\n @user_badge.active = true\n @user_badge.user_id = @user.id\n\n respond_to do |format|\n if @user_badge.save\n format.html { redirect_to team_user_path(@team, @user), notice: 'User badge was successfully created.' }\n format.json { render :show, status: :created, location: @user_badge }\n else\n format.html { render :new }\n format.json { render json: @user_badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_badge(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"] = true\n badges[\"#{badge_id}\"][\"earn_date\"] = Date.current\n self.update(badges: badges.to_json)\n end",
"def badge_params\n params.require(:badge).permit(:name, :description)\n end",
"def parse_badges(badges)\n badges.map { |badge| create_new_badge(badge) } if badges\n end",
"def create_new_badge(badge)\n Badge.new(badge)\n end",
"def crear_achievement badge, id_app\n description = badge[\"description\"].encode(\"UTF-8\")\n \n body = {\n name:badge[\"name\"],\n imageUrl:badge[\"imageUrl\"],\n unique: true,\n criteriaUrl: badge[\"criteriaUrl\"],\n earnerDescription: description,\n consumerDescription: description ,\n criteria: badge[\"criteria\"],\n type: 'Badge'\n }\n status 201\n \n response = signed_post_request @@API_ROOT+\"/issuers/#{id_app}/badges\", body\n\n end",
"def create\n respond_to do |format|\n if @badge.save\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully created.') }\n format.xml { render xml: @badge, status: :created, location: @badge }\n website.add_log(user: current_user, action: \"Created badge: #{@badge.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n # current_user.add_badge(1)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Postagem criada com sucesso.' }\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 badges(options={})\n self.class.parse_badges(request(singular(user_id) + \"/badges\", options))\n end",
"def badge_params\n params.require(:badge).permit(:name, :slug, :description, :earned_by, :position,\n :avatar, :retained_avatar, :remove_avatar, :avatar_url\n )\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge }\n else\n format.html { render :edit }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @meritbadge = Meritbadge.new(params[:meritbadge])\n\n respond_to do |format|\n if @meritbadge.save\n format.html { redirect_to(@meritbadge, :notice => 'Meritbadge was successfully created.') }\n format.xml { render :xml => @meritbadge, :status => :created, :location => @meritbadge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meritbadge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def badge_params\n params.require(:badge).permit(:startdate, :enddate, :number, :member_id, :user_id)\n end",
"def badge_params\n params.require(:badge).permit(:course, :website, :date, :purpose)\n end",
"def badges(id)\n get(\"users/#{id}/badges\")\n end",
"def update_badges(badge)\n @badges = {}\n badge.split(',').each do |_badge|\n type, value = _badge.split '/'\n @badges[type] = value.to_i\n end\n end",
"def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badge_params\n params.require(:badge).permit(:user_id , :message, :sound)\n end",
"def badge_params\n params.require(:badge).permit(:title, :image, :rule, :rule_parameter)\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def badge_params\n params[:user].permit(:name, :badge, :admin_id)\n end",
"def users_badge_params\n params.require(:users_badge).permit(:user_id, :badge_id)\n end",
"def create\n @badge_category = BadgeCategory.new(badge_category_params)\n\n respond_to do |format|\n if @badge_category.save\n format.html { redirect_to @badge_category, notice: 'Badge category was successfully created.' }\n format.json { render :show, status: :created, location: @badge_category }\n else\n format.html { render :new }\n format.json { render json: @badge_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gauge = Gauge.new(params[:gauge])\n\n respond_to do |format|\n if @gauge.save\n format.html { redirect_to @gauge, notice: 'Gauge was successfully created.' }\n format.json { render json: @gauge, status: :created, location: @gauge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gauge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def create\n @badge_project = BadgeProject.new(badge_project_params)\n\n respond_to do |format|\n if @badge_project.save\n format.html { redirect_to @badge_project, notice: 'Badge project was successfully created.' }\n format.json { render :show, status: :created, location: @badge_project }\n else\n format.html { render :new }\n format.json { render json: @badge_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badges(options={})\n get('/user_badge', options)\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end",
"def user_badges user_id=\"self\"\n response = get(\"/users/#{user_id}/badges\")[\"response\"]\n if response[\"sets\"] and response[\"sets\"][\"groups\"]\n response[\"sets\"][\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}\n end\n\n if response[\"badges\"]\n response[\"badges\"].each_key do |badge_id|\n response[\"badges\"][badge_id] = badge(badge_id)\n end\n end\n response\n end",
"def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end",
"def craft_badge(badge_page_url)\n appid = badge_page_url.split('/').last\n uid = badge_page_url.split('/')[4]\n # TODO, figure out what the series and border_color parameters mean.\n # for now set them to the observed values of 1,0\n sessionid = URI.decode(@c.cookie_manager.cookies.select{|i| i.match?(URI(\"https://steamcommunity.com\")) && i.name == \"sessionid\"}.first.value)\n body = {\n appid: appid,\n series: 1,\n border_color: 0,\n sessionid: sessionid\n }\n res = @c.post(\"http://steamcommunity.com/id/#{uid}/ajaxcraftbadge/\", body, {Referer: badge_page_url, Origin: \"http://steamcommunity.com\"}) rescue nil\n res && res.code == 200\n end",
"def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend",
"def badge_params\n params.require(:badge).permit(:employee_id, :first_name, :last_name, :title, :department, :dn, :update_thumbnail)\n end",
"def user_badge_params\n params.require(:user_badge).permit(:user_id, :badge, :name, :src, :description, :active, :issued_by_id)\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def save_badges(user_id, badge_defs)\n badge_defs.each do |bdef|\n Badge.new do |badge|\n badge.user_id = user_id\n badge.badge_def_id = bdef.id\n badge.save\n end\n end\n end",
"def for_badge(badge); end",
"def full_badges\n client.user_badges(id)\n end",
"def validate_badge(data, badge)\n if data[\"client_id\"] == badge.client_id && data[\"badge_id\"] == badge.id && data[\"name\"] == badge.name &&\n data[\"description\"] == badge.description && data[\"image\"] == badge.badge_image.image.url(:thumb) &&\n data[\"feats\"].length == badge.feats.length\n if data[\"feats\"].length == 0\n return true\n end\n if data[\"feats\"].length > 0 && validate_feat(data[\"feats\"][0] == badge.feats[0])\n return true\n end\n end\n return false\n end",
"def link\n token = params[:token].split(\" \\\" \")\n qrcode = params[:qrcode]\n\n #insertion des information dans la base de données badge\n badge = Badge.new(\n customer_id: Customer.find_by_authentication_token(token).authentication_token,\n activate: true,\n qrcode: qrcode\n )\n\n # on enregistre\n if badge.save\n render json: {\n status: 200,\n message: \"Liaision etablie\"\n }\n else\n render json: {\n status: 404,\n message: badge.errors.full_messages\n }\n end\n end",
"def update\n get_my_badge\n respond_to do |format|\n if @my_badge.update_attributes(params[:my_badge])\n flash[:notice] = 'Your badge was successfully updated.'\n format.html { redirect_to user_my_badge_url(@my_badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def award_badge(participant_id, badge_name)\n badge_id = Badge.get_id_from_name(badge_name: badge_name)\n AwardedBadge.where(participant_id: participant_id, badge_id: badge_id, approval_status: 0).first_or_create\n end",
"def create\n @honey_badger = HoneyBadger.new(honey_badger_params)\n\n respond_to do |format|\n if @honey_badger.save\n format.html { redirect_to @honey_badger, notice: 'Honey badger was successfully created.' }\n format.json { render :show, status: :created, location: @honey_badger }\n else\n format.html { render :new }\n format.json { render json: @honey_badger.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @badge = Badge.find(params[:id])\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n flash[:notice] = 'Badge was successfully updated.'\n format.html { redirect_to organization_segment_badge_url(@organization,@segment, @badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def badges\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated badge: #{@badge.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_badge\n @badge = Badge.friendly.find(params[:id])\n authorize @badge\n end",
"def create\n megam_rest.post_billedhistories(to_hash)\n end",
"def create\n @lounge = Lounge.new(lounge_params)\n\n respond_to do |format|\n if @lounge.save\n format.html { redirect_to @lounge, notice: 'Lounge was successfully created.' }\n format.json { render :show, status: :created, location: @lounge }\n else\n format.html { render :new }\n format.json { render json: @lounge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parse_badges(result)\n parse_type(result, \"badge\")\n end",
"def award_badges!(new_badges)\n return true if new_badges.empty?\n if !new_badges.first.is_a?(Badge)\n new_badges = Badge.find(:all, :conditions => [\"ref IN (?)\", new_badges])\n end\n self.badges += (new_badges - self.badges)\n end",
"def bridges_create(params = {})\n post \"bridges\", params\n end",
"def badges_url\n view_context.badges_url\n end",
"def create\n @grade = Grade.new(grade_params)\n\n if @grade.save\n render json: @grade, status: :created, location: @grade\n else\n render json: @grade.errors, status: :unprocessable_entity\n end\n end",
"def post_new_gist content \n\t\t\t\turl = GITHUB_API_GIST_LINK \n\t\t\t\tresponse = https_open_for ({url: url, mthd:\"post\", content: content})\n \t\t\t\tJSON.parse response.body\n\t\t\tend",
"def create\n @grumble = Grumble.new(grumble_params)\n\n respond_to do |format|\n if @grumble.save\n format.html { redirect_to @grumble, notice: 'Grumble was successfully created.' }\n format.json { render :show, status: :created, location: @grumble }\n else\n format.html { render :new }\n format.json { render json: @grumble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @gauge = Gauge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gauge }\n end\n end",
"def create\n gig = Gig.new()\n respond_to do |format|\n if update_gig(gig)\n format.html { render json: gig, status: :created, location: gig }\n format.json { render json: gig, status: :created, location: gig }\n else\n format.html { render action: \"new\" }\n format.json { render json: gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_badges\n achievements.map(&:new_badges).flatten\n end",
"def create\n @badge = Badge.find(params[:badge_id])\n @presence = @badge.presences.build(params[:presence])\n if @presence.value == nil\n \[email protected] = 1\n end\n\n respond_to do |format|\n if @presence.save\n# format.html { redirect_to @presence, notice: 'Presence was successfully created.' }\n format.html { render json: @presence, status: :created, location: @presence }\n format.json { render json: @presence, status: :created, location: @presence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @presence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_badge!( badge, update_badge = true )\n unless @badges.include?( badge )\n @badges << badge\n badge.add_user!( self, false) if update_badge\n end\n return @badges\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end",
"def create\n @garply = Garply.new(garply_params)\n\n respond_to do |format|\n if @garply.save\n format.html { redirect_to @garply, notice: 'Garply was successfully created.' }\n format.json { render :show, status: :created, location: @garply }\n else\n format.html { render :new }\n format.json { render json: @garply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @garrage = Garrage.new(garrage_params)\n @garrage.user_id = current_user.id\n\n respond_to do |format|\n if @garrage.save\n format.html { redirect_to garrage_stuffs_path(@garrage), notice: 'Garrage was successfully created.' }\n format.json { render :show, status: :created, location: @garrage }\n else\n format.html { render :new }\n format.json { render json: @garrage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badge_assertion_params\n params.require(:badge_assertion).permit(:badge_id, :user_id)\n end",
"def create\n @gauge_graph = GaugeGraph.new(gauge_graph_params)\n\n respond_to do |format|\n if @gauge_graph.save\n format.html { redirect_to edit_gauge_graph_path(@gauge_graph), notice: 'Gauge graph was successfully created.' }\n format.json { render :edit, status: :created, location: @gauge_graph }\n else\n format.html { render :new }\n format.json { render json: @gauge_graph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pushbullet = Pushbullet.new(pushbullet_params)\n\n respond_to do |format|\n if @pushbullet.save\n format.html { redirect_to @pushbullet, notice: 'Pushbullet was successfully created.' }\n format.json { render :show, status: :created, location: @pushbullet }\n else\n format.html { render :new }\n format.json { render json: @pushbullet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gage = Gage.new(params[:gage])\n\n respond_to do |format|\n if @gage.save\n format.html { redirect_to @gage, notice: 'Gage was successfully created.' }\n format.json { render json: @gage, status: :created, location: @gage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badge\n if badge_id\n Merit::Badge.find(badge_id)\n else\n Merit::Badge.find_by_name_and_level(badge_name, level)\n end\n end",
"def create\n @hoge = Hoge.new(params[:hoge])\n\n respond_to do |format|\n if @hoge.save\n format.html { redirect_to @hoge, notice: 'Hoge was successfully created.' }\n format.json { render json: @hoge, status: :created, location: @hoge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badge; end",
"def create\n @order = Order.new\n collect_access_code\n @my_badge.account = current_account \n respond_to do |format|\n if @my_badge.save\n session[:unsaved_badge] = nil\n flash[:notice] = \"Your badge was successfully created.\"\n #format.html { redirect_to user_my_badge_url(@my_badge) }\n format.html { redirect_to user_my_badge_share_url(@my_badge) }\n format.xml { render :xml => @my_badge, :status => :created, :location => @my_badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def fetch_badge_from_params\n badge = nil\n\n params.permit(:badge_name)\n if params[:badge_name].nil?\n params.require(:badge_id)\n badge = Badge.find_by(id: params[:badge_id], enabled: true)\n else\n badge = Badge.find_by(name: params[:badge_name], enabled: true)\n end\n raise Discourse::NotFound if badge.blank?\n\n badge\n end",
"def get_project_vulnerabilities_badge1_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge1 ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling BadgeApi.get_project_vulnerabilities_badge1\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{uuid}'.sub('{' + 'uuid' + '}', CGI.escape(uuid.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(['image/svg+xml'])\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] || 'ProjectMetrics' \n\n # auth_names\n auth_names = opts[:auth_names] || []\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgeApi#get_project_vulnerabilities_badge1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def badges_for_user(username)\n response = get \"v1/market/user-badges:#{username}.json\"\n response[:'user-badges']\n end",
"def create\n @baggage = Baggage.new(params[:baggage])\n\n respond_to do |format|\n if @baggage.save\n format.html { redirect_to @baggage, notice: 'Baggage was successfully created.' }\n format.json { render json: @baggage, status: :created, location: @baggage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @baggage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to(admin_badges_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted badge: #{@badge.name}\")\n end",
"def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end",
"def set_admin_badge\n @badge = Badge.find(params[:id])\n end",
"def update_assignment_badges\n @assigned_badges = @assignment_form.assignment.badges\n @badges = Badge.all\n end",
"def set_badge(device_token, badge)\n client.post('/set_badge', device_token: device_token, badge: badge)\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end",
"def [](level)\n raise ArgumentError unless valid?(level)\n\n @badges ||= {}\n @badges[level] ||= new(level)\n end",
"def apply_badges\n if rule_applies?\n grant_badge if new_or_multiple?\n else\n remove_badge if @rule.temporary\n end\n end",
"def create\n @pledge = Pledge.new(params[:pledge])\n\n respond_to do |format|\n if @pledge.save\n format.html { redirect_to @pledge, notice: 'Pledge was successfully created.' }\n format.json { render json: @pledge, status: :created, location: @pledge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pledge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @messege = Messege.new(params[:messege])\n\n respond_to do |format|\n if @messege.save\n format.html { redirect_to @messege, notice: 'Messege was successfully created.' }\n format.json { render json: @messege, status: :created, location: @messege }\n else\n format.html { render action: \"new\" }\n format.json { render json: @messege.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bounty = Bounty.new(bounty_params)\n\n respond_to do |format|\n if @bounty.save\n format.html { redirect_to @bounty, notice: 'Bounty was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bounty }\n else\n format.html { render action: 'new' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end",
"def create\n @achievement = Achievement.new(achievement_params)\n\n respond_to do |format|\n if @achievement.save\n format.html { redirect_to @achievement, notice: 'Achievement was successfully created.' }\n format.json { render json: @achievement, status: :created, location: @achievement }\n else\n format.html { render \"new\" }\n format.json { render json: @achievement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @bounty = Bounty.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @bounty }\n end\n end"
] | [
"0.7457712",
"0.6846014",
"0.6806162",
"0.67646587",
"0.6714363",
"0.6706622",
"0.66743445",
"0.6616647",
"0.64745873",
"0.63554764",
"0.63486",
"0.6334261",
"0.6324032",
"0.62979513",
"0.62812895",
"0.6273197",
"0.62320244",
"0.6105499",
"0.6099493",
"0.609918",
"0.6073953",
"0.6056592",
"0.6039441",
"0.6038695",
"0.6030489",
"0.60238034",
"0.60158676",
"0.60158676",
"0.60158676",
"0.6007275",
"0.5987764",
"0.5973079",
"0.5922562",
"0.59217244",
"0.5895819",
"0.5892521",
"0.5862047",
"0.5840229",
"0.5826655",
"0.5775069",
"0.5772278",
"0.5769849",
"0.5753103",
"0.5710879",
"0.56987464",
"0.5652924",
"0.56130695",
"0.5611533",
"0.5607414",
"0.56066024",
"0.55929625",
"0.5587791",
"0.55831724",
"0.55794215",
"0.5573709",
"0.5573524",
"0.5536188",
"0.55261683",
"0.55089504",
"0.5507599",
"0.5490559",
"0.5488608",
"0.54676247",
"0.5461147",
"0.54431814",
"0.5423832",
"0.5417638",
"0.5416104",
"0.54089695",
"0.5407002",
"0.5386249",
"0.5376979",
"0.5375497",
"0.5373616",
"0.53680575",
"0.53520644",
"0.5346978",
"0.5334848",
"0.5334195",
"0.5328317",
"0.5325203",
"0.531923",
"0.53091574",
"0.53081495",
"0.5302438",
"0.5299894",
"0.52995205",
"0.529923",
"0.52963006",
"0.5294389",
"0.52697176",
"0.52628756",
"0.52613777",
"0.5239795",
"0.523409",
"0.5231985",
"0.5228974",
"0.5218371",
"0.52176267",
"0.5202977"
] | 0.7510865 | 0 |
PUT /badges/1 PUT /badges/1.json | def update
@badge = Badge.find_by_key(params['id'])
@badge.approved_at = Time.now unless session[:admin]
respond_to do |format|
if @badge.update_attributes(params[:badge])
format.html { redirect_to @badge, :notice => 'Badge was successfully updated.' }
else
format.html { render :action => "edit" }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge }\n else\n format.html { render :edit }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @badge = Badge.find(params[:id])\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n flash[:notice] = 'Badge was successfully updated.'\n format.html { redirect_to organization_segment_badge_url(@organization,@segment, @badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n get_my_badge\n respond_to do |format|\n if @my_badge.update_attributes(params[:my_badge])\n flash[:notice] = 'Your badge was successfully updated.'\n format.html { redirect_to user_my_badge_url(@my_badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated badge: #{@badge.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def set_badge\n @badge = Badge.find(params[:id])\n end",
"def update\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n if @gauge.update_attributes(params[:gauge])\n format.html { redirect_to @gauge, notice: 'Gauge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gauge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_badge(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"] = true\n badges[\"#{badge_id}\"][\"earn_date\"] = Date.current\n self.update(badges: badges.to_json)\n end",
"def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meritbadge = Meritbadge.find(params[:id])\n\n respond_to do |format|\n if @meritbadge.update_attributes(params[:meritbadge])\n format.html { redirect_to(@meritbadge, :notice => 'Meritbadge was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meritbadge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }\n format.json { render :json => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @badge_project.update(badge_project_params)\n format.html { redirect_to @badge_project, notice: 'Badge project was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge_project }\n else\n format.html { render :edit }\n format.json { render json: @badge_project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_badges(badge)\n @badges = {}\n badge.split(',').each do |_badge|\n type, value = _badge.split '/'\n @badges[type] = value.to_i\n end\n end",
"def set_badge\n @badge = Badge.friendly.find(params[:id])\n authorize @badge\n end",
"def update\n respond_to do |format|\n if @badge_category.update(badge_category_params)\n format.html { redirect_to @badge_category, notice: 'Badge category was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge_category }\n else\n format.html { render :edit }\n format.json { render json: @badge_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_admin_badge\n @badge = Badge.find(params[:id])\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end",
"def update!(**args)\n @badge_specialization = args[:badge_specialization] if args.key?(:badge_specialization)\n @badge_specialization_state = args[:badge_specialization_state] if args.key?(:badge_specialization_state)\n end",
"def badge_params\n params.require(:badge).permit(:name, :description)\n end",
"def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end",
"def put(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.put(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def badge_params\n params.require(:badge).permit(:name, :slug, :description, :earned_by, :position,\n :avatar, :retained_avatar, :remove_avatar, :avatar_url\n )\n end",
"def update\n goal = Goal.find params[:id]\n if goal.update(goal_params)\n render json: goal, status: 200\n else\n render json: goal.errors.full_messages, status: 422\n end\n end",
"def update\n @shot = Shot.find(params[:id])\n\n if @shot.update(shot_params)\n head :no_content\n else\n render json: @shot.errors, status: :unprocessable_entity\n end\n end",
"def update\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n if update_gig(@gig)\n format.html { redirect_to @gig, notice: 'Gig was successfully updated.' }\n format.json { render json: @gig, status: :ok, location: @gig }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @grade = Grade.find(params[:id])\n\n if @grade.update(grade_params)\n head :no_content\n else\n render json: @grade.errors, status: :unprocessable_entity\n end\n end",
"def update\n @hit = Hit.find(params[:id])\n\n respond_to do |format|\n if @hit.update_attributes(params[:hit])\n format.html { redirect_to @hit, notice: 'Hit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hoge = Hoge.find(params[:id])\n\n respond_to do |format|\n if @hoge.update_attributes(params[:hoge])\n format.html { redirect_to @hoge, notice: 'Hoge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @green = Green.find(params[:id])\n\n respond_to do |format|\n if @green.update_attributes(params[:green])\n format.html { redirect_to scaffold_green_url(@green), notice: 'Green was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @green.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @achievement.update(achievement_params)\n format.html { redirect_to @achievement, notice: 'Achievement was successfully updated.' }\n format.json { render :show, status: :ok, location: @achievement }\n else\n format.html { render :edit }\n format.json { render json: @achievement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @achievement.update_attributes(achievement_params)\n format.html { redirect_to @achievement, notice: 'Achievement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render \"edit\" }\n format.json { render json: @achievement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end",
"def update\n @good = Good.find(params[:id])\n\n respond_to do |format|\n if @good.update_attributes(params[:good])\n format.html { redirect_to :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @good.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def badges\n get(\"user/#{user_id}/badges.json\")\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end",
"def update_assignment_badges\n @assigned_badges = @assignment_form.assignment.badges\n @badges = Badge.all\n end",
"def set_user_badge\n @user_badge = UserBadge.find(params[:user_badge_id])\n end",
"def update\n @gist = Gist.find(params[:id])\n\n respond_to do |format|\n if @gist.update_attributes(params[:gist])\n format.html { redirect_to @gist, notice: 'Gist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n if @gage.update_attributes(params[:gage])\n format.html { redirect_to @gage, notice: 'Gage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_badge = UserBadge.new(user_badge_params)\n @user_badge.active = true\n @user_badge.user_id = @user.id\n\n respond_to do |format|\n if @user_badge.save\n format.html { redirect_to team_user_path(@team, @user), notice: 'User badge was successfully created.' }\n format.json { render :show, status: :created, location: @user_badge }\n else\n format.html { render :new }\n format.json { render json: @user_badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @profile ||= Profile.find(params[:profile_id])\n @achievement.update(achievement_params)\n end",
"def update\n @gastracker = Gastracker.find(params[:id])\n\n respond_to do |format|\n if @gastracker.update_attributes(params[:gastracker])\n format.html { redirect_to @gastracker, notice: 'Gastracker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gastracker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @gig_request = GigRequest.find(params[:id])\n\n respond_to do |format|\n if @gig_request.update_attributes(params[:gig_request])\n format.html { redirect_to @gig_request, notice: 'Gig request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gig_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @issue.votes = 0\n if @issue.update(issue_params)\n format.html { redirect_to @issue, notice: 'Issue was successfully updated.' }\n format.json { render :show, status: :ok, location: @issue }\n else\n format.html { render :edit }\n format.json { render json: @issue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @health.update(health_params)\n format.html { redirect_to @health, notice: 'Health was successfully updated.' }\n format.json { render :show, status: :ok, location: @health }\n else\n format.html { render :edit }\n format.json { render json: @health.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n tag = Tag.find_by_id(params[:id])\n if tag.update(params.permit(:name))\n render json: tag, status: :ok\n else\n respond_with tag.errors, status: :unprocessable_entity\n end\n end",
"def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @shot = Shot.find(params[:id])\n @shot.update_attributes(shot_params)\n respond_with @shot\n end",
"def update\n @damage = Damage.find(params[:id])\n\n respond_to do |format|\n if @damage.update_attributes(params[:damage])\n format.html { redirect_to @damage, notice: 'Damage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @damage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @gist.update(gist_params)\n format.html { redirect_to @gist, notice: 'Gist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @gist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fridge = Fridge.find(params[:id])\n\n respond_to do |format|\n if @fridge.update_attributes(params[:fridge])\n format.html { redirect_to @fridge, notice: 'Fridge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fridge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @habbit.update(habbit_params)\n format.html { redirect_to @habbit, notice: 'Habbit was successfully updated.' }\n format.json { render :show, status: :ok, location: @habbit }\n else\n format.html { render :edit }\n format.json { render json: @habbit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @gig.update(gig_params)\n format.html { redirect_to @gig, notice: \"Gig was successfully updated.\" }\n format.json { render :show, status: :ok, location: @gig }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @gig.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def update\n @house = House.find(params[:id])\n\n respond_to do |format|\n if @house.update_attributes(params[:house])\n format.html { redirect_to @house, notice: 'Gig was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @house.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 respond_to do |format|\n if @git_hub_issue.update(git_hub_issue_params)\n format.html { redirect_to @git_hub_issue, notice: 'Git hub issue was successfully updated.' }\n format.json { render :show, status: :ok, location: @git_hub_issue }\n else\n format.html { render :edit }\n format.json { render json: @git_hub_issue.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @compromise = Compromise.find(params[:id])\n\n if @compromise.update(compromise_params)\n Notification.delete_all([\"compromise_id = ?\", @compromise.id])\n create_for_each_notification_type(@compromise)\n head :no_content\n else\n render json: @compromise.errors, status: :unprocessable_entity\n end\n end",
"def award_badges!(new_badges)\n return true if new_badges.empty?\n if !new_badges.first.is_a?(Badge)\n new_badges = Badge.find(:all, :conditions => [\"ref IN (?)\", new_badges])\n end\n self.badges += (new_badges - self.badges)\n end",
"def update\n respond_to do |format|\n if @grumble.update(grumble_params)\n format.html { redirect_to @grumble, notice: 'Grumble was successfully updated.' }\n format.json { render :show, status: :ok, location: @grumble }\n else\n format.html { render :edit }\n format.json { render json: @grumble.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badge_params\n params[:user].permit(:name, :badge, :admin_id)\n end",
"def badge_params\n params.require(:badge).permit(:user_id , :message, :sound)\n end",
"def update\n respond_to do |format|\n if @hit.update(hit_params)\n format.html { redirect_to @hit, notice: 'Batida atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @hit }\n else\n format.html { render :edit }\n format.json { render json: @hit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def badges(id)\n get(\"users/#{id}/badges\")\n end",
"def update\n respond_to do |format|\n if @great.update(great_params)\n format.html { redirect_to @great, notice: 'Great was successfully updated.' }\n format.json { render :show, status: :ok, location: @great }\n else\n format.html { render :edit }\n format.json { render json: @great.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @damage.update(damage_params)\n format.html { redirect_to @damage, notice: \"Damage was successfully updated.\" }\n format.json { render :show, status: :ok, location: @damage }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @damage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @baggage = Baggage.find(params[:id])\n\n respond_to do |format|\n if @baggage.update_attributes(params[:baggage])\n format.html { redirect_to @baggage, notice: 'Baggage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @baggage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bundle = Bundle.find(params[:id])\n\n respond_to do |format|\n if @bundle.update_attributes(params[:bundle])\n format.html { redirect_to @bundle, notice: 'Bundle was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bundle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @garply.update(garply_params)\n format.html { redirect_to @garply, notice: 'Garply was successfully updated.' }\n format.json { render :show, status: :ok, location: @garply }\n else\n format.html { render :edit }\n format.json { render json: @garply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end",
"def users_badge_params\n params.require(:users_badge).permit(:user_id, :badge_id)\n end",
"def update\n respond_to do |format|\n if @pushbullet.update(pushbullet_params)\n format.html { redirect_to @pushbullet, notice: 'Pushbullet was successfully updated.' }\n format.json { render :show, status: :ok, location: @pushbullet }\n else\n format.html { render :edit }\n format.json { render json: @pushbullet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @honey_badger.update(honey_badger_params)\n format.html { redirect_to @honey_badger, notice: 'Honey badger was successfully updated.' }\n format.json { render :show, status: :ok, location: @honey_badger }\n else\n format.html { render :edit }\n format.json { render json: @honey_badger.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @dice = Dice.find(params[:id])\n\n if @dice.update(dice_params)\n head :no_content\n else\n render json: @dice.errors, status: :unprocessable_entity\n end\n end",
"def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end",
"def for_badge(badge); end",
"def update\n @health.user_id = current_user\n @user = current_user\n @profile = current_user.profile\n respond_to do |format|\n if @health.update(health_params)\n format.html { redirect_to \"/dashboard\", notice: 'Health was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @health.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/tags/#{gid}\", body: data, options: options)).first)\n end",
"def set_badge(device_token, badge)\n client.post('/set_badge', device_token: device_token, badge: badge)\n end",
"def update\n @bucket = current_user.buckets.find(params[:id])\n respond_to do |format|\n if @bucket.update_attributes(params[:bucket])\n flash[:notice] = 'Bucket was successfully updated.'\n format.html { redirect_to(@bucket) }\n format.xml { head :ok }\n format.iphone { redirect_to(@bucket) }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bucket.errors, :status => :unprocessable_entity }\n format.iphone { render :action => \"edit\", :layout => false}\n end\n end\n end",
"def update\n @grocery = Grocery.find(params[:id])\n\n if @grocery.update(grocery_params)\n head :no_content\n else\n render json: @grocery.errors, status: :unprocessable_entity\n end\n end",
"def update\n @objective = Objective.find(params[:id])\n\n respond_to do |format|\n if @objective.update_attributes(params[:objective])\n format.html { redirect_to @objective, notice: 'Objective was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @objective.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @good.update(good_params)\n format.html { redirect_to @good, notice: 'Good was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @good.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @made_in_g.update(made_in_g_params)\n format.html { redirect_to @made_in_g, notice: 'Made in g was successfully updated.' }\n format.json { render :show, status: :ok, location: @made_in_g }\n else\n format.html { render :edit }\n format.json { render json: @made_in_g.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @health_status.update(health_status_params)\n format.html { redirect_to @health_status, notice: 'Health status was successfully updated.' }\n format.json { render :show, status: :ok, location: @health_status }\n else\n format.html { render :edit }\n format.json { render json: @health_status.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7433612",
"0.7292388",
"0.7160003",
"0.67772365",
"0.6748671",
"0.65781724",
"0.6536563",
"0.6536563",
"0.6536563",
"0.64023155",
"0.62654424",
"0.62097263",
"0.61501694",
"0.6138595",
"0.6097217",
"0.60823286",
"0.6052821",
"0.60479176",
"0.5934693",
"0.5902172",
"0.5857143",
"0.58463556",
"0.5805806",
"0.5773537",
"0.57586575",
"0.57430893",
"0.5706801",
"0.5691514",
"0.5688365",
"0.56690526",
"0.5646395",
"0.56450474",
"0.56410754",
"0.5640932",
"0.5634735",
"0.56346846",
"0.5633278",
"0.5625892",
"0.562305",
"0.56089646",
"0.56073177",
"0.56020707",
"0.5600994",
"0.55854625",
"0.55810416",
"0.5575392",
"0.55480695",
"0.5532844",
"0.5528322",
"0.55245334",
"0.55185163",
"0.5515227",
"0.5514304",
"0.54920965",
"0.54871917",
"0.54793614",
"0.5469964",
"0.54644895",
"0.5457315",
"0.5454256",
"0.54495144",
"0.54494804",
"0.5446594",
"0.5438614",
"0.54216194",
"0.54206705",
"0.54134744",
"0.5412642",
"0.5410858",
"0.540389",
"0.5401986",
"0.54008305",
"0.5400796",
"0.53975874",
"0.53833675",
"0.53829193",
"0.5380529",
"0.53788316",
"0.5377557",
"0.5371804",
"0.53689003",
"0.5362164",
"0.5355989",
"0.5354332",
"0.5353757",
"0.5351288",
"0.5345332",
"0.53399646",
"0.5334739",
"0.5332111",
"0.5330572",
"0.53238666",
"0.532324",
"0.5322971",
"0.53222376",
"0.531636",
"0.531263",
"0.53124064",
"0.5309551",
"0.5305584"
] | 0.63369906 | 10 |
Increase the default delay by five seconds since some kernelmode payloads may not run immediately. | def wfs_delay
super + 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delay\n @delay ||= 600\n end",
"def default_delay\n 0.seconds\n end",
"def delay\n sleep(2)\n end",
"def default_delay\n @@default_delay ||= 0\n end",
"def set_delay(delay)\n @delay = delay\n end",
"def default_delay=(v)\n @@default_delay = v\n end",
"def delay_1() sleep(3) end",
"def delay; end",
"def delay; end",
"def delay; end",
"def delay(seconds); end",
"def delay(seconds); end",
"def delay_time\n end",
"def wfs_delay\r\n\t\t10\r\n\tend",
"def sleep_for\n @sleep_for ||= 5\n end",
"def delay\n @delay || initial_delay\n end",
"def delay_time=(seconds)\n end",
"def delay(value)\n model.delay = value\n end",
"def delay(value)\n model.delay = value\n end",
"def delay\n @delay || initial_delay\n end",
"def delay\n puts \"Delaying ...\"\n sleep 1\n end",
"def wfs_delay\n\t\t30\n\tend",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def sleep(dur=0) end",
"def delay(seconds)\n sleep(seconds)\n end",
"def wfs_delay\n 2\n end",
"def delay(time)\n @context.backend.delay(time)\n end",
"def sleep_time\n\t\t\t# TODO: Hard-coded for now. See doc/app_manager.rdoc for some\n\t\t\t# thoughts on this.\n\t\t\t1\n\t\tend",
"def delay=(value)\n return false unless @enabled\n update(:type => self.type, :delay => value)\n end",
"def delay_ms(ms)\n @delay_ms = ms\n end",
"def operation_delay\n begin\n if $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY > 0 &&\n $ITEST2_OPERATION_DELAY && $ITEST2_OPERATION_DELAY < 30000 then # max 30 seconds\n sleep($ITEST2_OPERATION_DELAY / 1000)\n end\n\n while $ITEST2_PAUSE\n debug(\"Paused, waiting ...\")\n sleep 1\n end\n rescue => e\n puts \"Error on delaying: #{e}\"\n # ignore\n end\n end",
"def pre_sleep; end",
"def sleep_time\n 60\n end",
"def delay_request\n\t\tif config[:strategy][:type] == \"linear\"\n\t\t\tdelay = Random.rand( config[:strategy][:delaymin] .. config[:strategy][:delaymax]).to_f\n\t\t\t\n\t\t\tdebug.print(3, \"Delaying\", delay, \" before adding another request in queue\", File.basename(__FILE__), __LINE__)\n\t\t\t\n\t\t\tsleep(delay)\n\t\tend\n\tend",
"def persistent_delay\n get_config_value(:persistent_delay, 5)\n end",
"def idle_delay(arg = nil)\n set_or_return(:idle_delay, arg, kind_of: Integer)\n end",
"def idle_time_before_sleep_in_seconds=(value)\n @idle_time_before_sleep_in_seconds = value\n end",
"def delay! seconds\n @delay_received << seconds\n end",
"def sleep\n sleep_after(0)\n end",
"def delay\n sleep(rand / 100)\n end",
"def delay_time\n return (self.aggressive == false ? 0 : (15 - self.aggressive) * 3)\n end",
"def enter_debug_mode_delay!\n if dut.respond_to?('enter_debug_mode_delay!'.to_sym)\n cc 'Using DUT-defined #enter_debug_mode_delay! for core to enter debug mode'\n dut.enter_debug_mode_delay!\n else\n cc \"Delaying #{enter_debug_mode_delay_cycles} cycles for core to enter debug mode\"\n tester.cycle(repeat: enter_debug_mode_delay_cycles)\n end\n end",
"def snooze(t)\n sleep(t)\n end",
"def redisplay_delay\r\n 20\r\n end",
"def sleep_value\n 20\n end",
"def increment_delay!\n @delay = [delay * multiplier, max_delay].min\n end",
"def io_sleep\n # sleep 2.5/1000.0\n end",
"def page_delay(seconds = ENV['MIN_PAGE_DELAY'].to_i)\n sleep(seconds) if ENV['DO_PAGE_DELAY'] == \"true\"\n end",
"def delay(mode)\n if mode == @mode\n d = @deadline - Time.now\n d = 0 if d < 0 # No negative delays\n @deadline += @delay\n block_given? ? yield(d) : d\n end\n end",
"def increment_delay!\n @delay = [delay * multiplier, max_delay].min\n end",
"def simulate_latency\n sleep 0.5\n end",
"def set_SleepTimeEnabled(value)\n set_input(\"SleepTimeEnabled\", value)\n end",
"def follow_on_delay\n default_delay\n end",
"def enable!\n `tc qdisc add dev lo root netem delay #{delay}ms`\n end",
"def sleep_if_set\n config[:sleep].to_i.times do\n print '.'\n sleep 1\n end\n end",
"def delay\n \"%3d days %2d hours %2d minutes %2d seconds\" % distance_of_time_as_array( timestamp_device, timestamp_server)\n end",
"def delay\n self['Delay'].to_i || 0\n end",
"def delay=(sec)\n raise ArgumentError, 'Delay sec can not be a negative number.' if sec.to_f < 0\n @delay = sec.to_f\n end",
"def sleep(n)\n Kernel.sleep(n)\n end",
"def click_delay(seconds = 0)\n sleep(ENV['MIN_CLICK_DELAY'].to_i + seconds) if ENV['DO_CLICK_DELAY'] == \"true\"\n end",
"def minretrydelay=(retry_delay)\r\n\t\t\t`#{BITS::BITSADMIN} /setminretrydelay {#{@id}} #{retry_delay}`\r\n\t\tend",
"def page_delay\n if $TESTWISE_PAGE_DELAY && $TESTWISE_PAGE_DELAY.to_i > 0 && $TESTWISE_PAGE_DELAY.to_i < 100\n sleep $TESTWISE_PAGE_DELAY.to_i\n end \n end",
"def sleep_if_set\n sleep_sec = config[:sleep].to_i\n if sleep_sec > 0\n info(\"Sleep #{config[:sleep]} seconds...\")\n sleep sleep_sec\n end\n end",
"def event_wait_delay seconds\n ScriptActionHandler::HandlerResult::waitDelay seconds\n end",
"def maybe_fake_delay!\n if (auth_db_delay = env.params['auth_db_delay'].to_f) > 0\n enqueue_acceptor(:sleepy){|acc| EM.add_timer(auth_db_delay){ acc.succeed } }\n end\n end",
"def delay_me\n\t\tsleep(10.0) # sleep for 10 seconds between queries\n\tend",
"def lock_timeout_retry_delay=(_arg0); end",
"def sub_delay _value, _abs=0\n send_cmd(\"sub_delay #{_value} #{_abs}\")\n end",
"def idle_timeout=(timeout); end",
"def default_timeout\n 900\n end",
"def default_timeout\n 3\n end",
"def set_StartSleepTime(value)\n set_input(\"StartSleepTime\", value)\n end",
"def wfs_delay\n (datastore['WfsDelay'] || 0).to_i\n end",
"def sim delay\n request delay #tools and food\n produce delay\n transport delay\n consume delay\n end",
"def sleep_time\n 1.0/(rand(10) + 1)\n end",
"def simulate_latency\n sleep(rand(2)) if Rails.env == 'development'\n end",
"def default_timeout\n @default_timeout ||= 20000\n end",
"def retry_delay\n 30\n end",
"def delay=(d)\n raise ArgumentError, 'delay must be greater than or equal to 0' if Integer(d) < 0\n\n @images.each { |f| f.delay = Integer(d) }\n end",
"def lock_on_sleep= value\n put_settings(get_settings.tap {|s| s[:lock_on_sleep] = value ? 1 : 0})\n end",
"def sleep_test\n sleep(10)\n \"slept for 10 sec!\"\n end",
"def msleep( msec )\n NSThread.sleepForTimeInterval(msec / 1000.0)\n end",
"def _delay\n class << self; self; end.module_eval { yield }\n end",
"def set_queue_delay\n new_delay = params[:delay].to_f\n if new_delay == 0\n head :bad_request\n else\n Rails.application.config.queue_delay = new_delay\n render :get_queue_delay\n end\n end",
"def delay(x=1) \n current_time = Time.now.to_i\n while Time.now.to_i - current_time < x \n\tend\nend",
"def watch_delay\n @conn.watch(Web.keys[:delay]) do\n yield if block_given?\n end\n end",
"def implicit_wait=(seconds); end",
"def delay\n if @delay_den != 0\n @delay_num/@delay_den\n else\n @delay_num/100\n end\n end",
"def throttle\n 5\n end",
"def default_timeout\n 60\n end",
"def delay(time, &b)\n time = time.to_a.sample unless time.is_a? Integer\n EM.add_timer(time, &b)\n end",
"def initial_dealing_time\r\n\tdelay_time_of_card(@players.count - 2, 1)\r\n end",
"def idle_timeout=(idle_timeout); end",
"def delay_sanitize\n \tself.delay ||= 0\n end",
"def idle_time_before_sleep_in_seconds\n return @idle_time_before_sleep_in_seconds\n end",
"def delay(input, val=nil)\n raise ArgumentError unless (0..31) === input\n input = input.to_i\n reg = input / DELAYS_PER_REG\n shift = (input % DELAYS_PER_REG) * BITS_PER_DELAY\n regval = send(\"delay_#{reg}\")\n if val\n regval &= ~( DELAY_MASK << shift)\n regval |= ((DELAY_MASK & val) << shift)\n send(\"delay_#{reg}=\", regval)\n self\n else\n (regval >> shift) & DELAY_MASK\n end\n end",
"def default_timeout\n @default_timeout ||= 30\n end",
"def sleeper\n\t\tsleep(0.4)\n\tend",
"def set_idle_threshold!(time)\n time = time.to_i\n\n if time != 0 && time < 10\n raise ArgumentError, \"time must be >= 10 minutes\"\n end\n\n if time % 5 != 0\n raise ArgumentError, \"time must be in 5 minute increments\"\n end\n\n !!self.send!(\"+XT:3013,#{time}\")\n end"
] | [
"0.738869",
"0.70848966",
"0.6960668",
"0.692924",
"0.6891885",
"0.6881094",
"0.68787515",
"0.6872018",
"0.6872018",
"0.6872018",
"0.684173",
"0.684173",
"0.68239194",
"0.67521393",
"0.67432237",
"0.6718678",
"0.6693301",
"0.6691764",
"0.6691764",
"0.66433674",
"0.6562137",
"0.6507548",
"0.6503203",
"0.6503203",
"0.64884245",
"0.64531624",
"0.64160883",
"0.6390994",
"0.6388477",
"0.63822037",
"0.6378499",
"0.628914",
"0.6172375",
"0.61678725",
"0.61329794",
"0.61303586",
"0.6105947",
"0.60810494",
"0.6067634",
"0.60354227",
"0.60310286",
"0.6022271",
"0.60051095",
"0.6002392",
"0.59879124",
"0.5983131",
"0.5967657",
"0.5963526",
"0.5962466",
"0.59539634",
"0.59156966",
"0.5915327",
"0.5897239",
"0.58712035",
"0.58504665",
"0.5847649",
"0.5844238",
"0.583784",
"0.58012736",
"0.57918465",
"0.5785119",
"0.5772105",
"0.57648957",
"0.57282615",
"0.5720884",
"0.57103086",
"0.5699055",
"0.5697717",
"0.5682564",
"0.56762993",
"0.56627965",
"0.5656716",
"0.56252396",
"0.56092894",
"0.55803794",
"0.5577687",
"0.5571615",
"0.55710006",
"0.55687845",
"0.5562339",
"0.5560503",
"0.55581784",
"0.55581254",
"0.55506396",
"0.5543958",
"0.5538377",
"0.5527131",
"0.55209535",
"0.5520951",
"0.551758",
"0.55170447",
"0.5515948",
"0.5476039",
"0.54743254",
"0.5452732",
"0.5435817",
"0.5429993",
"0.5429086",
"0.5412789",
"0.54121655"
] | 0.6942297 | 3 |
GET /circles GET /circles.json | def index
search_word = SearchForm.new(circle_params)
if search_word.valid?
@circles = Circle.search(search_word.serializable_hash)
puts "circle is #{@circles}"
@circles
else
render json: search_word.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @circle = current_user.circle\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @circle }\n end\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def index\n @circles = Circle.all\n end",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @circle }\n end\n end",
"def list_people_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.people.list_by_circle,\n params\n ]\n })\n end",
"def index\n\n min_tolerance = 0.1\n max_tolerance = 2 # ~200km\n tolerance = min_tolerance\n \n if params[:tag]\n # search by tags\n @circles = Circle.tagged_with(params[:tag]).paginate(:page => params[:circle_page], :per_page => 100)\n\n else\n # search by location\n client_ip = request.remote_ip\n @c = GeoIP.new('data/GeoLiteCity.dat').city(client_ip) #iau orasul\n if @c != nil\n # daca am gasit localitatea dupa IP\n # caut cercuri in orase tot mai indepartate, pana gasesc vreun cerc sau pana depasesc o limita de distanta\n while true do\n @city_id = City.find(:all, :select => 'id', :conditions => [\"abs(latitude - ?) < ? AND abs(longitude - ?) < ?\", @c.latitude, tolerance, @c.longitude, tolerance] )\n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n\n if @circles.count > 0 || tolerance > max_tolerance\n break\n end\n\n tolerance = tolerance * 2\n end\n else\n # altfel, ii dau orasului id=0, adica nu am gasit orasului\n @city_id = 0 \n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n @location_unknown = true\n end\n end\n\n if (@location_unknown.nil? || !@location_unknown) && @circles.count == 0 \n # known location, but no results\n @no_circles = true\n end\n\n @hide_invite_button = true\n refresh_notifications\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def show\n\n # render action: \"preview\" and return\n @circle = Circle.find(params[:id], :include => [:gossips])\n\n @circle.gossips.each do |g|\n g.last_comments = Comment.where(\"gossip_id = ?\", g.id).order(\"created_at desc\").limit(COMMENTS_PER_GOSSIP).reverse\n end\n\n @og_type = \"thegossip:circle\"\n @og_title = \"a circle\"\n @og_url = File.join(SITE_URL, \"circles/#{@circle.id}\")\n @og_description = \"#{@circle.name} \\n #{@circle.description}\"\n\n @post_created_circle = params[:post_created]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def list_activities_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.activities.list_by_circle,\n params\n ]\n })\n end",
"def mycircles\n #iau cercurile userului\n @circles = current_user.circles\n \n #redundant, dar trebuie\n @circles.each do |circle|\n circle.joined = current_user.already_joined?(circle.id)\n end\n\n @hide_invite_button = true\n \n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @circles, :include => :city }\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def new\n @circle = Circle.new\n @circle.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @circle }\n end\n end",
"def index\n @jam_circles = @user.jam_circles\n #@jam_circle = JamCircle.new\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def index # returns all bikes within a certain radius\n ## TODO: use coordinates later, when more campuses and bikes.\n # # defaults radius to half mile, and coordinate to requesting ip address\n # radius = params[:radius] ? params[:radius] : 0.5\n # coordinates = params[:coordinates] ? params[:coordinates] : request.location\n # puts coordinates\n # @bikes = Coordinate.near(coordinates, radius).joins(:bikes)\n @bikes = Bike.available\n render json: @bikes\n end",
"def create\n @circle = Circle.new(params[:circle])\n @circle.user = current_user\n \n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, :notice => 'Circle was successfully created.' }\n format.json { render :json => @circle, :status => :created, :location => @circle }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @circulars = Circular.all\n end",
"def sub_circles\n Circle.where(super_circle_id: id)\n end",
"def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def create\n @user = User.find(current_user)\n @circle = current_user.circles.build(params[:circle])\n\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render json: @circle, status: :created, location: @circle }\n format.js { \n @circles = @user.circles\n flash[:notice] = \"Successfully created post\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @circle.destroy\n respond_to do |format|\n format.html { redirect_to circles_url, notice: 'Circle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @care_circles = current_user.care_circles\n number_of_care_circles = @care_circles.length\n if (number_of_care_circles > 0)\n \t# no point in wasting time selecting care circle if there is only one\n\t\t\tredirect_to @care_circles.first if number_of_care_circles == 1\n\t\telse\n\t\t\tredirect_to new_care_circle_path\n end\n\tend",
"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\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def update\n respond_to do |format|\n if @circle.update(circle_params)\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { render :show, status: :ok, location: @circle }\n else\n format.html { render :edit }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def circle_info(radius)\n {:area => Math::PI * (radius * radius),\n :perimeter => Math::PI * (2 * radius),\n :sphere_volume => ((4/3)* Math::PI * (radius ** 3)),\n :sphere_surface_area => (4* (Math::PI * (radius * radius)))}\nend",
"def find_root(circles=nil, roles=nil)\n circles ||= self.get :circles\n roles ||= self.get :roles\n Glassfrog::Graph.root(circles, roles)\n end",
"def index\n \tif params[:category] == \"METRO\"\n \trender :json => Interest.stops.to_json\n elsif params[:category] == \"Photos\"\n render :json => Interest.panoramio\n \telsif params[:category]\n \t\tcategory_id = Category.find_by_name(params[:category]).id\n \t\trender :json => Interest.find_all_by_category_id(category_id).to_json(:methods => :category_name)\n \telse\n \t\trender :json => Interest.all\n \tend\n\n end",
"def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end",
"def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n redirect_to circles_path\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def create\n @circle = Circle.new(post_params)\n\n if @circle.save\n render :show, status: :created, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \n end\n end",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def create_circles(num)\n circle_image = circle_image()\n circles = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_circle(1.0, 10,10, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(SCREEN_WIDTH), rand(40) - 50)\n shape = CP::Shape::Circle.new(body, 10, CP::Vec2.new(0, 0))\n shape.e = 0.4\n shape.u = 0.4\n circles << AObject.new(circle_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return circles\n end",
"def call\n create_circle(display_name: \"Friends\",\n content: friends_content)\n\n create_circle(display_name: \"Family\",\n content: family_content)\n\n create_circle(display_name: \"Acquaintances\",\n content: acquaintances_content)\n\n create_circle(display_name: \"Following\",\n content: following_content)\n end",
"def circle_zone(lat, lon, count, options = {})\n url = 'http://api.openweathermap.org/data/2.5/find'\n new(options.merge(lat: lat, lon: lon, cnt: count)).retrieve url\n end",
"def index\n @cycles = Cycle.where(group_id: params[:group_id])\n\n render json: @cycles\n end",
"def points_on_circle(center, normal, radius, numseg)\r\n # Get the x and y axes\r\n axes = Geom::Vector3d.new(normal).axes\r\n center = Geom::Point3d.new(center)\r\n xaxis = axes[0]\r\n yaxis = axes[1]\r\n \r\n xaxis.length = radius\r\n yaxis.length = radius\r\n\r\n # compute the points\r\n da = (Math::PI * 2) / numseg\r\n pts = []\r\n for i in 0...numseg do\r\n angle = i * da\r\n cosa = Math.cos(angle)\r\n sina = Math.sin(angle)\r\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\r\n pts.push(center + vec)\r\n end\r\n \r\n # close the circle\r\n pts.push(pts[0].clone)\r\n\r\n pts\r\nend",
"def points_for_circle(x, y, r)\n cur_page.points_for_circle(x, y, r)\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def circle_nodes(width=@width, height=@height, nodeset=@nodes)\n center = Vector[width/2, height/2]\n radius = [width,height].min/2\n nodeset.each_with_index{|(key, node), i| nodeset[key].location = Vector[\n center[0] + (radius * Math.sin(Math::PI/4+2*Math::PI*i/nodeset.length)), \n center[1] - (radius * Math.cos(Math::PI/4+2*Math::PI*i/nodeset.length))] if !nodeset[key].static}\n end",
"def index\n authenticate_request!\n @cars = Car.all\n\n render json: @cars\n end",
"def circle(option={})\n set RGhost::Circle.new(options)\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, :notice => 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def index\n @profiles = Profile.all\n respond_to do |format|\n format.html\n format.json do\n @profiles = Profile.near(\n [\n current_user.profile.latitude,\n current_user.profile.longitude\n ], params[:radius]\n ).distinct\n @profiles = @profiles.where.not(id: current_user.profile.id)\n @profiles = @profiles.min_age(params[:min_age]) if params[:min_age].present?\n @profiles = @profiles.max_age(params[:max_age]) if params[:max_age].present?\n @profiles = @profiles.by_gender(params[:gender]) if params[:gender].present?\n @profiles = @profiles.by_activity(params[:activity])\n\n render json: @profiles.map{|profile| profile.attributes.merge(image: profile.image.url(:medium))}\n end\n end\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def draw_circle_shape(circle)\n body = circle.body\n c = body.p + circle.center.rotate(body.rot)\n self.draw_circle(c.x,c.y,circle.radius,body.a)\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end",
"def circle(radius)\n pixels = []\n \n @width.times do |x|\n row = Array.new(@height, nil)\n \n @height.times do |y|\n pixel = 0\n @density.times do |i|\n xx = (x + i.to_f/@density) - @x_offset\n yy = f_halfcircle(xx, radius)\n yt = yy + @y_offset\n yb = -yy + @y_offset\n\n if (yt >= y && yt < y + 1) || (yb >= y && yb < y + 1)\n pixel = 1\n end\n end\n row[y] = pixel\n end\n pixels << row\n end\n \n PNM.create(pixels.transpose.reverse!, {:type => :pbm})\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 index\n @clan_matches = ClanMatch.all\n\n render json: @clan_matches\n end",
"def show\n @recents = @circle.recents\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sp_points_on_circle(center, normal, radius, numseg, rotAngle)\n # Get the x and y axes\n axes = Geom::Vector3d.new(normal).axes\n center = Geom::Point3d.new(center)\n xaxis = axes[0]\n yaxis = axes[1]\n xaxis.length = radius\n yaxis.length = radius\n rotAngle = 0.0 unless rotAngle.is_a?(Numeric)\n # Compute the points\n da = (Math::PI*2) / numseg\n pts = []\n for i in 0...numseg do\n angle = rotAngle + (i * da)\n cosa = Math.cos(angle)\n sina = Math.sin(angle)\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\n pts.push(center + vec)\n end\n # Close the circle\n pts.push(pts[0].clone)\n pts\n end",
"def index\n @civilizations = Civilization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @civilizations }\n end\n end",
"def initialize(radius)\n @radius = radius\n @@no_of_circles += 1\n @id = @@no_of_circles\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def create\n @circle = Circle.new(circle_params)\n current_user.add_role(:owner, @circle)\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render :show, status: :created, location: @circle }\n else\n format.html { render :new }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_document_circle_annotations(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_circle_annotations_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_circle_annotations_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def index\n @lab_methods = LabMethod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lab_methods }\n end\n end",
"def get_page_circle_annotations(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_page_circle_annotations_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_page_circle_annotations_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end",
"def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end",
"def index\n @stars = Star.all\n render :json => @stars\n end",
"def index\n @loves = Love.all\n render json: @loves\n end",
"def index\n @pricings = Pricing.all\n\n render json: @pricings\n end",
"def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def index \n @calculation = Calculation.all # retrieve all calculations from calculations table \n json_response(@calculation) # respond with the array of calculations\n end",
"def get_document_circle_annotations_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_document_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/annotations/circle\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'CircleAnnotationsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def get_page_circle_annotations_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_page_circle_annotations\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/annotations/circle\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'CircleAnnotationsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @competence_center = CompetenceCenter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competence_center }\n end\n end",
"def index\n @cities = City.all\n\n render json: @cities\n end",
"def init_circles_html_data(with_sc_roles = true)\n circles_data_hash = circle_to_hash\n html_data = [\n {\n tag: 'div',\n class: 'circle-0'\n },\n {\n tag: 'a',\n path: 'circle_path',\n path_target: self\n },\n {\n tag: 'div',\n class: 'circle-title-container'\n },\n {\n tag: 'h2',\n class: 'circle-title',\n inner_text: title.to_s\n },\n { tag: '/h2' },\n { tag: '/div' },\n { tag: '/a' }\n ]\n\n # subcircles (with or without roles)\n # TODO: create all these methods\n if with_sc_roles\n html_data << Circle.create_sub_circles_html_data({ data: circle_to_hash })\n else\n html_data << Circle.create_sub_circles_html_data({ data: circle_to_hash, without_roles: true })\n end\n\n # roles\n # TODO: create this method\n html_data << Circle.create_roles_html_data(roles)\n html_data << { tag: '/div' }\n html_data.flatten\n html_data\n end",
"def index\n @pic_spaces = PicSpace.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pic_spaces }\n end\n end",
"def all_circles\n (circles + Circle.globals).uniq\n end",
"def get\n CircleCi.request(conf, '/projects').get\n end",
"def index\n @drawables = Drawable.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drawables }\n end\n end",
"def index\n # @places = Place.get_nearby_places(params[:lat], params[:lon]).paginate(:page => get_page)\n @places = Kaminari.paginate_array(Place.get_close_places(params[:lat], params[:lon], params[:radius])).page(get_page)\n render :json => \n { \n :places => @places.as_json(:lean_list => true),\n :page_info => \n { \n :page => get_page,\n :per_page => Place.per_page,\n :total_entries => @places.total_count \n }\n }\n end",
"def update\n if @circle.update(post_params)\n render :show, status: :ok, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \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 create\n @jam_circle = JamCircle.new(jam_circle_params)\n @jam_circle.user_id = @user.id\n @jam_circle.users << @user\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.save\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :created, location: @jam_circle }\n else\n format.html { render :new }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n render json: Picture.all\n end",
"def index\n @pictures = Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pictures }\n end\n end",
"def index\r\n markers = Marker.all\r\n render json: markers\r\n end",
"def index\n @user_figures = UserFigure.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_figures }\n end\n end",
"def index\n @clubs = Club.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clubs }\n end\n end",
"def index\n @cars = Car.all\n\n render json: @cars\n end"
] | [
"0.7484646",
"0.73138803",
"0.7197082",
"0.7190375",
"0.7155239",
"0.6725961",
"0.63376987",
"0.63168573",
"0.63034815",
"0.63034815",
"0.62562346",
"0.62343293",
"0.6225809",
"0.6105686",
"0.60478145",
"0.60374385",
"0.60374385",
"0.6002041",
"0.59485286",
"0.593329",
"0.59129953",
"0.5888825",
"0.58735156",
"0.582285",
"0.582285",
"0.5774085",
"0.57491195",
"0.5642367",
"0.559888",
"0.5597439",
"0.55733526",
"0.55601156",
"0.55569386",
"0.5540581",
"0.5528359",
"0.55161995",
"0.55138713",
"0.55123717",
"0.550743",
"0.55063355",
"0.54920864",
"0.54699236",
"0.5462332",
"0.54467",
"0.54422337",
"0.5440274",
"0.54342973",
"0.540827",
"0.5407459",
"0.5404481",
"0.53938085",
"0.5381901",
"0.53754807",
"0.53711957",
"0.53547966",
"0.53499275",
"0.53379804",
"0.53295827",
"0.5327919",
"0.5326355",
"0.53256553",
"0.53248864",
"0.53239197",
"0.5316762",
"0.5316762",
"0.5309114",
"0.53040487",
"0.5303729",
"0.52994806",
"0.52975875",
"0.5296913",
"0.5292712",
"0.5291238",
"0.52897894",
"0.5281942",
"0.5275324",
"0.52692217",
"0.5268389",
"0.5266382",
"0.52642524",
"0.5263492",
"0.5260304",
"0.525691",
"0.5256804",
"0.52359456",
"0.5230059",
"0.5229726",
"0.52263236",
"0.52244514",
"0.5223063",
"0.52172214",
"0.52138066",
"0.52097476",
"0.52095455",
"0.52061737",
"0.52051955",
"0.5204537",
"0.520231",
"0.52015775",
"0.5200067"
] | 0.6273125 | 10 |
GET /circles/1 GET /circles/1.json | def show
@genres = @circle.genres
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @circle }\n end\n end",
"def index\n @circle = current_user.circle\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @circle }\n end\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @circles = Circle.all\n end",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def new\n @circle = Circle.new\n @circle.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @circle }\n end\n end",
"def show\n\n # render action: \"preview\" and return\n @circle = Circle.find(params[:id], :include => [:gossips])\n\n @circle.gossips.each do |g|\n g.last_comments = Comment.where(\"gossip_id = ?\", g.id).order(\"created_at desc\").limit(COMMENTS_PER_GOSSIP).reverse\n end\n\n @og_type = \"thegossip:circle\"\n @og_title = \"a circle\"\n @og_url = File.join(SITE_URL, \"circles/#{@circle.id}\")\n @og_description = \"#{@circle.name} \\n #{@circle.description}\"\n\n @post_created_circle = params[:post_created]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def list_people_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.people.list_by_circle,\n params\n ]\n })\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def index\n search_word = SearchForm.new(circle_params)\n if search_word.valid?\n @circles = Circle.search(search_word.serializable_hash)\n puts \"circle is #{@circles}\"\n @circles\n else\n render json: search_word.errors, status: :unprocessable_entity \n end\n \n end",
"def create\n @circle = Circle.new(params[:circle])\n @circle.user = current_user\n \n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, :notice => 'Circle was successfully created.' }\n format.json { render :json => @circle, :status => :created, :location => @circle }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @jam_circles = @user.jam_circles\n #@jam_circle = JamCircle.new\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def index\n\n min_tolerance = 0.1\n max_tolerance = 2 # ~200km\n tolerance = min_tolerance\n \n if params[:tag]\n # search by tags\n @circles = Circle.tagged_with(params[:tag]).paginate(:page => params[:circle_page], :per_page => 100)\n\n else\n # search by location\n client_ip = request.remote_ip\n @c = GeoIP.new('data/GeoLiteCity.dat').city(client_ip) #iau orasul\n if @c != nil\n # daca am gasit localitatea dupa IP\n # caut cercuri in orase tot mai indepartate, pana gasesc vreun cerc sau pana depasesc o limita de distanta\n while true do\n @city_id = City.find(:all, :select => 'id', :conditions => [\"abs(latitude - ?) < ? AND abs(longitude - ?) < ?\", @c.latitude, tolerance, @c.longitude, tolerance] )\n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n\n if @circles.count > 0 || tolerance > max_tolerance\n break\n end\n\n tolerance = tolerance * 2\n end\n else\n # altfel, ii dau orasului id=0, adica nu am gasit orasului\n @city_id = 0 \n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n @location_unknown = true\n end\n end\n\n if (@location_unknown.nil? || !@location_unknown) && @circles.count == 0 \n # known location, but no results\n @no_circles = true\n end\n\n @hide_invite_button = true\n refresh_notifications\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def mycircles\n #iau cercurile userului\n @circles = current_user.circles\n \n #redundant, dar trebuie\n @circles.each do |circle|\n circle.joined = current_user.already_joined?(circle.id)\n end\n\n @hide_invite_button = true\n \n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @circles, :include => :city }\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def sub_circles\n Circle.where(super_circle_id: id)\n end",
"def update\n respond_to do |format|\n if @circle.update(circle_params)\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { render :show, status: :ok, location: @circle }\n else\n format.html { render :edit }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @circle.destroy\n respond_to do |format|\n format.html { redirect_to circles_url, notice: 'Circle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def list_activities_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.activities.list_by_circle,\n params\n ]\n })\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, :notice => 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @circulars = Circular.all\n end",
"def index # returns all bikes within a certain radius\n ## TODO: use coordinates later, when more campuses and bikes.\n # # defaults radius to half mile, and coordinate to requesting ip address\n # radius = params[:radius] ? params[:radius] : 0.5\n # coordinates = params[:coordinates] ? params[:coordinates] : request.location\n # puts coordinates\n # @bikes = Coordinate.near(coordinates, radius).joins(:bikes)\n @bikes = Bike.available\n render json: @bikes\n end",
"def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n redirect_to circles_path\n end",
"def create\n @user = User.find(current_user)\n @circle = current_user.circles.build(params[:circle])\n\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render json: @circle, status: :created, location: @circle }\n format.js { \n @circles = @user.circles\n flash[:notice] = \"Successfully created post\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @cn_curves = CnCurve.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cn_curves }\n end\n end",
"def index\n url = \"https://data.cityofchicago.org/resource/x2n5-8w5q.json\"\n options = { :body => {:status => text}, :basic_auth => @auth }\n @response = HTTParty.get(url, options)\n\n @crime = Hash.new\n\n #@crime['block'] = @response[0]['block']\n @crime = @response\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gittos }\n end\n end",
"def create\n @circle = Circle.new(post_params)\n\n if @circle.save\n render :show, status: :created, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \n end\n end",
"def index\n @care_circles = current_user.care_circles\n number_of_care_circles = @care_circles.length\n if (number_of_care_circles > 0)\n \t# no point in wasting time selecting care circle if there is only one\n\t\t\tredirect_to @care_circles.first if number_of_care_circles == 1\n\t\telse\n\t\t\tredirect_to new_care_circle_path\n end\n\tend",
"def show\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climate }\n end\n end",
"def current_circle(host_id = self.current_host_id)\n if host_id and (rel = relationships.find_by_user_id(host_id))\n rel.circle\n else\n circles.first\n end\n end",
"def show\n @competence_center = CompetenceCenter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competence_center }\n end\n end",
"def show\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @slab }\n end\n end",
"def show\n @recents = @circle.recents\n end",
"def index\n @clubs = Club.all\n render json: @clubs\n end",
"def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def circle(option={})\n set RGhost::Circle.new(options)\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\t\t@clubs = Club.all\n\t\trender json: @clubs\n\tend",
"def index\n \tif params[:category] == \"METRO\"\n \trender :json => Interest.stops.to_json\n elsif params[:category] == \"Photos\"\n render :json => Interest.panoramio\n \telsif params[:category]\n \t\tcategory_id = Category.find_by_name(params[:category]).id\n \t\trender :json => Interest.find_all_by_category_id(category_id).to_json(:methods => :category_name)\n \telse\n \t\trender :json => Interest.all\n \tend\n\n end",
"def circle_info(radius)\n {:area => Math::PI * (radius * radius),\n :perimeter => Math::PI * (2 * radius),\n :sphere_volume => ((4/3)* Math::PI * (radius ** 3)),\n :sphere_surface_area => (4* (Math::PI * (radius * radius)))}\nend",
"def update\n if @circle.update(post_params)\n render :show, status: :ok, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \n end\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
"def initialize(radius)\n @radius = radius\n @@no_of_circles += 1\n @id = @@no_of_circles\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 circle_zone(lat, lon, count, options = {})\n url = 'http://api.openweathermap.org/data/2.5/find'\n new(options.merge(lat: lat, lon: lon, cnt: count)).retrieve url\n end",
"def index\n require 'rest-client'\n response = RestClient::Request.execute(method: :get, url: 'localhost:3001/colores',\n headers: {page: params[:page], items: 9})\n if response.code == 200\n body = JSON.parse(response.body)\n @colors = body[\"data\"]\n @page = body[\"page\"]\n end\n end",
"def index\n @cycles = Cycle.where(group_id: params[:group_id])\n\n render json: @cycles\n end",
"def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @socio }\n end\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @photos = JSON.parse(response.body)\t\t \n\tend\n end",
"def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def show\n @club = Club.find(params[:id])\n\n render json: @club\n end",
"def get_page_circle_annotations_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_page_circle_annotations\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/annotations/circle\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'CircleAnnotationsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_circles(num)\n circle_image = circle_image()\n circles = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_circle(1.0, 10,10, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(SCREEN_WIDTH), rand(40) - 50)\n shape = CP::Shape::Circle.new(body, 10, CP::Vec2.new(0, 0))\n shape.e = 0.4\n shape.u = 0.4\n circles << AObject.new(circle_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return circles\n end",
"def get\n CircleCi.request(conf, '/projects').get\n end",
"def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend",
"def destroy\n @jam_circle.destroy\n respond_to do |format|\n format.html { redirect_to jam_circles_url }\n format.json { head :no_content }\n end\n end",
"def show\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sphere }\n end\n end",
"def show\n @curve = Curve.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @curve }\n end\n end",
"def create\n @circle = Circle.new(circle_params)\n current_user.add_role(:owner, @circle)\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render :show, status: :created, location: @circle }\n else\n format.html { render :new }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end",
"def show\n respond_to do |format|\n format.html { render :show }\n format.json { render json: Oj.dump(@curriculum) }\n end\n end",
"def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end",
"def index\n @stars = Star.all\n render :json => @stars\n end",
"def get_document_circle_annotations_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_document_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/annotations/circle\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'CircleAnnotationsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @socio = Socio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @socio }\n end\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def call\n create_circle(display_name: \"Friends\",\n content: friends_content)\n\n create_circle(display_name: \"Family\",\n content: family_content)\n\n create_circle(display_name: \"Acquaintances\",\n content: acquaintances_content)\n\n create_circle(display_name: \"Following\",\n content: following_content)\n end",
"def show\n @fraction = Fraction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fraction }\n end\n end",
"def cards\n @celebrity = Celebrity.find(params[:id])\n @cards = @celebrity.cards\n render json: @cards\n end",
"def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end",
"def index\n @lab_methods = LabMethod.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lab_methods }\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def show\n @graphic = Graphic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @graphic }\n end\n end",
"def show\n @graphic = Graphic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @graphic }\n end\n end",
"def show\n @crime = Crime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crime }\n end\n end",
"def index\n @clan_matches = ClanMatch.all\n\n render json: @clan_matches\n end",
"def index\n @civilizations = Civilization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @civilizations }\n end\n end",
"def show\n @grocery = Grocery.find(params[:id])\n\n render json: @grocery\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cn_curve }\n end\n end",
"def index\n render json: Picture.all\n end",
"def create\n @circle = Circle.new(params[:circle].except(:city_name, :city_lat, :city_long))\n @circle.users << current_user\n\n city = City.where(name: params[:circle][:city_name]).first_or_initialize\n if not city.persisted? \n city.latitude = params[:circle][:city_lat]\n city.longitude = params[:circle][:city_long]\n city.save\n end\n\n @circle.user_id = current_user.id\n @circle.city = city #pun orasul la cerc\n @circle.people_count = 1 # adaug omu care o creat cercul in numaratoare\n\n respond_to do |format|\n if @circle.save\n @post_created_circle = false\n City.update_counters(city.id, circle_count: 1) # cresc numarul de cercuri la oras\n User.update_counters(current_user.id, circle_count: 1) # cresc numarul de cercuri la persoana\n format.html { redirect_to circle_path(@circle, post_created: \"true\") }\n format.json { render json: @circle, status: :created, location: @circle }\n else\n \n format.html { render action: \"new\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def index\n @labs = Lab.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @labs }\n end\n end",
"def index\n @cars = Car.all\n\n render json: @cars\n end",
"def draw_circle_shape(circle)\n body = circle.body\n c = body.p + circle.center.rotate(body.rot)\n self.draw_circle(c.x,c.y,circle.radius,body.a)\n end",
"def index\n @cars = Car.all\n render json: @cars\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def show\n @call_center = CallCenter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @call_center }\n end\n end",
"def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end",
"def get(url, params = {})\n params['circle-token'] = configuration.circleci_token\n Faraday.get(url + '?' + params.map { |key, value| \"#{key}=#{value}\" }.join('&'))\n end"
] | [
"0.7646373",
"0.7601681",
"0.7542692",
"0.7041239",
"0.6995559",
"0.6820596",
"0.6820596",
"0.65825766",
"0.6460563",
"0.6421201",
"0.63588256",
"0.6315388",
"0.6315388",
"0.6289307",
"0.6289307",
"0.6170639",
"0.61608595",
"0.6133126",
"0.6112254",
"0.6094382",
"0.6061157",
"0.59100235",
"0.5909629",
"0.5893263",
"0.58775896",
"0.584398",
"0.5825781",
"0.58248925",
"0.5824817",
"0.57994515",
"0.57994515",
"0.57843655",
"0.57751423",
"0.5770596",
"0.57520306",
"0.5654486",
"0.56435627",
"0.56372035",
"0.56272596",
"0.55980664",
"0.5585502",
"0.55832535",
"0.5578379",
"0.5578044",
"0.5539894",
"0.55156136",
"0.5498132",
"0.54869556",
"0.5475109",
"0.54727674",
"0.5471934",
"0.54718274",
"0.5454847",
"0.54529655",
"0.54478824",
"0.5437364",
"0.543015",
"0.5411539",
"0.5405607",
"0.54009694",
"0.5400763",
"0.53953296",
"0.539531",
"0.53924495",
"0.5387358",
"0.538716",
"0.5364052",
"0.5362865",
"0.53509486",
"0.53487384",
"0.5348159",
"0.5343701",
"0.53406674",
"0.5337652",
"0.53323495",
"0.53304",
"0.53196746",
"0.5308002",
"0.53042203",
"0.53035325",
"0.5301597",
"0.52986634",
"0.5293767",
"0.5287456",
"0.5287456",
"0.52815664",
"0.5276526",
"0.52701503",
"0.5268832",
"0.52671474",
"0.5267022",
"0.5263537",
"0.52614856",
"0.52614856",
"0.52608746",
"0.5255076",
"0.5254767",
"0.525082",
"0.5249925",
"0.52491045",
"0.52474886"
] | 0.0 | -1 |
POST /circles POST /circles.json | def create
@circle = Circle.new(post_params)
if @circle.save
render :show, status: :created, location: @circle
else
render json: @circle.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @circle = Circle.new(params[:circle])\n @circle.user = current_user\n \n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, :notice => 'Circle was successfully created.' }\n format.json { render :json => @circle, :status => :created, :location => @circle }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user)\n @circle = current_user.circles.build(params[:circle])\n\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render json: @circle, status: :created, location: @circle }\n format.js { \n @circles = @user.circles\n flash[:notice] = \"Successfully created post\" }\n else\n format.html { render action: \"new\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @circle = Circle.new(params[:circle].except(:city_name, :city_lat, :city_long))\n @circle.users << current_user\n\n city = City.where(name: params[:circle][:city_name]).first_or_initialize\n if not city.persisted? \n city.latitude = params[:circle][:city_lat]\n city.longitude = params[:circle][:city_long]\n city.save\n end\n\n @circle.user_id = current_user.id\n @circle.city = city #pun orasul la cerc\n @circle.people_count = 1 # adaug omu care o creat cercul in numaratoare\n\n respond_to do |format|\n if @circle.save\n @post_created_circle = false\n City.update_counters(city.id, circle_count: 1) # cresc numarul de cercuri la oras\n User.update_counters(current_user.id, circle_count: 1) # cresc numarul de cercuri la persoana\n format.html { redirect_to circle_path(@circle, post_created: \"true\") }\n format.json { render json: @circle, status: :created, location: @circle }\n else\n \n format.html { render action: \"new\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jam_circle = JamCircle.new(jam_circle_params)\n @jam_circle.user_id = @user.id\n @jam_circle.users << @user\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.save\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :created, location: @jam_circle }\n else\n format.html { render :new }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @circle = Circle.new(circle_params)\n current_user.add_role(:owner, @circle)\n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, notice: 'Circle was successfully created.' }\n format.json { render :show, status: :created, location: @circle }\n else\n format.html { render :new }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def circle_params\n params.require(:circle).permit(:name)\n end",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def new\n @circle = Circle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @circle }\n end\n end",
"def create\n @measurement = Measurement.new( measurement_params )\n\n # TODO \n unless @measurement.save\n render status: 500, json: @measurement.errors.full_messages\n end\n \n data = {\n circles: @measurement.circles.to_json \n }\n render status: :ok, json: @measurement if @measurement.valid?\n \n end",
"def circle_params\n params.require(:circle).permit(:display_name, :content)\n end",
"def create\n @circular = Circular.new(circular_params)\n\n respond_to do |format|\n if @circular.save\n format.html { redirect_to @circular, notice: 'Circular was successfully created.' }\n format.json { render :show, status: :created, location: @circular }\n else\n format.html { render :new }\n format.json { render json: @circular.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @circle = Circle.new\n @circle.user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @circle }\n end\n end",
"def index\n @circle = current_user.circle\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @circle }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def index\n search_word = SearchForm.new(circle_params)\n if search_word.valid?\n @circles = Circle.search(search_word.serializable_hash)\n puts \"circle is #{@circles}\"\n @circles\n else\n render json: search_word.errors, status: :unprocessable_entity \n end\n \n end",
"def update\n if @circle.update(post_params)\n render :show, status: :ok, location: @circle \n else\n render json: @circle.errors, status: :unprocessable_entity \n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def index\n @circles = Circle.all\n end",
"def destroy\n @circle.destroy\n respond_to do |format|\n format.html { redirect_to circles_url, notice: 'Circle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @circle.update(circle_params)\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { render :show, status: :ok, location: @circle }\n else\n format.html { render :edit }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def perform\n @person.circles.create!(display_name: 'Friends',\n content: 'Your real friends, the ones you feel comfortable sharing private details with.')\n\n @person.circles.create!(display_name: 'Family',\n content: 'Your close and extended family, with as many or as few in-laws as you want.')\n\n @person.circles.create!(display_name: 'Acquaintances',\n content: \"A good place to stick people you've met but aren't particularly close to.\")\n\n @person.circles.create!(display_name: 'Following',\n content: \"People you don't know personally, but whose posts you find interesting.\")\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end",
"def add_circle(center, normal, radius, numsegs = 24)\n end",
"def circle_params\n params.require(:circle).permit(:user_id, :name, :description, :picture, setting_attributes: [ :show_members, :invite_only ] )\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, :notice => 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def circle_user_params\n params.require(:circle_user).permit(:circle_id, :user_id)\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n redirect_to circles_path\n end",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def create\n # byebug\n @circular = Circular.new(circular_params)\n @circulars = Circular.all\n if @circular.save\n @circular = Circular.new\n end\n flash[:notice] = 'Circular saved Successfully.' \n redirect_to new_circular_path\n \n end",
"def create_circles(num)\n circle_image = circle_image()\n circles = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_circle(1.0, 10,10, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(SCREEN_WIDTH), rand(40) - 50)\n shape = CP::Shape::Circle.new(body, 10, CP::Vec2.new(0, 0))\n shape.e = 0.4\n shape.u = 0.4\n circles << AObject.new(circle_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return circles\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @circle }\n end\n end",
"def jam_circle_params\n params.require(:jam_circle).permit( :user_id, :title, :description, :open, :public )\n end",
"def create\n @unit = Unit.new(unit_params)\n respond_to do |format|\n if @unit.save\n Unit.transaction do\n auth = Signet::Rails::Factory.create_from_env :google, request.env\n client = Google::APIClient.new\n client.authorization = auth\n plusDomain = client.discovered_api('plusDomains')\n @result = client.execute(:api_method => plusDomain.circles.insert,\n :parameters => {'userId' => 'me'},\n :body =>MultiJson.dump('displayName' => @unit.name),\n :headers => {'Content-Type' => 'application/json'}\n )\n @unit.update_column(:circle_id, @result.data.id)\n end\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def draw_circle_shape(circle)\n body = circle.body\n c = body.p + circle.center.rotate(body.rot)\n self.draw_circle(c.x,c.y,circle.radius,body.a)\n end",
"def list_people_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.people.list_by_circle,\n params\n ]\n })\n end",
"def initialize(radius)\n @radius = radius\n @@no_of_circles += 1\n @id = @@no_of_circles\n end",
"def mycircles\n #iau cercurile userului\n @circles = current_user.circles\n \n #redundant, dar trebuie\n @circles.each do |circle|\n circle.joined = current_user.already_joined?(circle.id)\n end\n\n @hide_invite_button = true\n \n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @circles, :include => :city }\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def update\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.update(jam_circle_params)\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :ok, location: @jam_circle }\n else\n format.html { render :edit }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def points_on_circle(center, normal, radius, numseg)\r\n # Get the x and y axes\r\n axes = Geom::Vector3d.new(normal).axes\r\n center = Geom::Point3d.new(center)\r\n xaxis = axes[0]\r\n yaxis = axes[1]\r\n \r\n xaxis.length = radius\r\n yaxis.length = radius\r\n\r\n # compute the points\r\n da = (Math::PI * 2) / numseg\r\n pts = []\r\n for i in 0...numseg do\r\n angle = i * da\r\n cosa = Math.cos(angle)\r\n sina = Math.sin(angle)\r\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\r\n pts.push(center + vec)\r\n end\r\n \r\n # close the circle\r\n pts.push(pts[0].clone)\r\n\r\n pts\r\nend",
"def index\n @jam_circles = @user.jam_circles\n #@jam_circle = JamCircle.new\n end",
"def assign_tenants_to_circle(args = {}) \n body_put(\"/tenantcircles.json/tenants/#{args[:circleId]}\", args[:array_of_ids])\nend",
"def care_circle_params\n #params[:care_circle]\n #params.require(:care_circle).permit(relationship_attributes: [:relationship_type])\n params.require(:care_circle).permit(relationship_attributes: [:relationship_type])\n end",
"def call\n create_circle(display_name: \"Friends\",\n content: friends_content)\n\n create_circle(display_name: \"Family\",\n content: family_content)\n\n create_circle(display_name: \"Acquaintances\",\n content: acquaintances_content)\n\n create_circle(display_name: \"Following\",\n content: following_content)\n end",
"def destroy\n @jam_circle.destroy\n respond_to do |format|\n format.html { redirect_to jam_circles_url }\n format.json { head :no_content }\n end\n end",
"def circle(option={})\n set RGhost::Circle.new(options)\n end",
"def circle_params\n params.permit({genre: []}, :fee, :order, :min, :max, :frequency, :days, :location, :freeword)\n end",
"def show\n\n # render action: \"preview\" and return\n @circle = Circle.find(params[:id], :include => [:gossips])\n\n @circle.gossips.each do |g|\n g.last_comments = Comment.where(\"gossip_id = ?\", g.id).order(\"created_at desc\").limit(COMMENTS_PER_GOSSIP).reverse\n end\n\n @og_type = \"thegossip:circle\"\n @og_title = \"a circle\"\n @og_url = File.join(SITE_URL, \"circles/#{@circle.id}\")\n @og_description = \"#{@circle.name} \\n #{@circle.description}\"\n\n @post_created_circle = params[:post_created]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def index\n\n min_tolerance = 0.1\n max_tolerance = 2 # ~200km\n tolerance = min_tolerance\n \n if params[:tag]\n # search by tags\n @circles = Circle.tagged_with(params[:tag]).paginate(:page => params[:circle_page], :per_page => 100)\n\n else\n # search by location\n client_ip = request.remote_ip\n @c = GeoIP.new('data/GeoLiteCity.dat').city(client_ip) #iau orasul\n if @c != nil\n # daca am gasit localitatea dupa IP\n # caut cercuri in orase tot mai indepartate, pana gasesc vreun cerc sau pana depasesc o limita de distanta\n while true do\n @city_id = City.find(:all, :select => 'id', :conditions => [\"abs(latitude - ?) < ? AND abs(longitude - ?) < ?\", @c.latitude, tolerance, @c.longitude, tolerance] )\n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n\n if @circles.count > 0 || tolerance > max_tolerance\n break\n end\n\n tolerance = tolerance * 2\n end\n else\n # altfel, ii dau orasului id=0, adica nu am gasit orasului\n @city_id = 0 \n @circles = Circle.where(:city_id => @city_id).paginate(:page => params[:circle_page], :per_page => 100)\n @location_unknown = true\n end\n end\n\n if (@location_unknown.nil? || !@location_unknown) && @circles.count == 0 \n # known location, but no results\n @no_circles = true\n end\n\n @hide_invite_button = true\n refresh_notifications\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {\n 'html' => render_to_string( partial: \"circle_header\", :as => :circle, :collection => @circles, formats: [:html])\n }, status: :created, location: @gossip }\n end\n end",
"def api_params\n params.permit(:address, :latitude, :longitude, :radius, groups:[])\n end",
"def circle(radius)\n pixels = []\n \n @width.times do |x|\n row = Array.new(@height, nil)\n \n @height.times do |y|\n pixel = 0\n @density.times do |i|\n xx = (x + i.to_f/@density) - @x_offset\n yy = f_halfcircle(xx, radius)\n yt = yy + @y_offset\n yb = -yy + @y_offset\n\n if (yt >= y && yt < y + 1) || (yb >= y && yb < y + 1)\n pixel = 1\n end\n end\n row[y] = pixel\n end\n pixels << row\n end\n \n PNM.create(pixels.transpose.reverse!, {:type => :pbm})\n end",
"def create\n @order = @circle.orders.new(order_params)\n @order.circleName = @circle.name\n @order.requestUserName = @user.name\n respond_to do |format|\n if @order.save\n # filter users by circle id and loop through each use and send them an email\n UserMailer.order_placed_email(@user).deliver\n format.html { redirect_to @circle, notice: 'Order was successfully created.' }\n # format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_page_circle_annotations_with_http_info(name, page_number, annotations, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.post_page_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.post_page_circle_annotations\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.post_page_circle_annotations\"\n end\n # verify the required parameter 'annotations' is set\n if @api_client.config.client_side_validation && annotations.nil?\n fail ArgumentError, \"Missing the required parameter 'annotations' when calling PdfApi.post_page_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/annotations/circle\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n post_body = @api_client.object_to_http_body(annotations)\n auth_names = ['JWT']\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 => 'AsposeResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#post_page_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def destroy\n @care_circle.destroy\n respond_to do |format|\n format.html { redirect_to care_circles_url }\n format.json { head :no_content }\n end\n end",
"def _generate_circle\n total_weight = 0\n \n @nodes.each do |node|\n total_weight += @weights[node.to_s] || 1\n end\n\n @nodes.each do |node|\n weight = @weights[node.to_s] || 1\n factor = ((40 * @nodes.length * weight) / total_weight.to_f).floor.to_i\n\n factor.times do |j|\n b_key = self._hash_digest(\"#{node}-#{j}\")\n\n 3.times do |i|\n key = self._hash_val(b_key) { |x| x+(i*4) }\n @ring[key] = node\n @_sorted_keys.push(key)\n end\n end\n end\n\n @_sorted_keys.sort!\n end",
"def sp_points_on_circle(center, normal, radius, numseg, rotAngle)\n # Get the x and y axes\n axes = Geom::Vector3d.new(normal).axes\n center = Geom::Point3d.new(center)\n xaxis = axes[0]\n yaxis = axes[1]\n xaxis.length = radius\n yaxis.length = radius\n rotAngle = 0.0 unless rotAngle.is_a?(Numeric)\n # Compute the points\n da = (Math::PI*2) / numseg\n pts = []\n for i in 0...numseg do\n angle = rotAngle + (i * da)\n cosa = Math.cos(angle)\n sina = Math.sin(angle)\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\n pts.push(center + vec)\n end\n # Close the circle\n pts.push(pts[0].clone)\n pts\n end",
"def create\n @care_circle = current_user.care_circles.new(care_circle_params)\n relationship = @care_circle.relationships.build\n relationship.user = current_user\n # TODO: figure out why I can't do this with strong parameters (Unpermitted parameters: relationship)\n relationship.relationship_type_id = params[:care_circle][:relationship][:relationship_type]\n\n respond_to do |format|\n if @care_circle.save\n format.html { redirect_to @care_circle, notice: 'Care circle was successfully created.' }\n format.json { render action: 'show', status: :created, location: @care_circle }\n else\n format.html { render action: 'new' }\n format.json { render json: @care_circle.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 to_circle(x, width, height)\n gv = GraphViz.new(:G, :type => :digraph )\n gv.graph[ concentrate: true]\n gv.edge[arrowhead: :none, fontcolor: :grey]\n topics = x.select {|i| i.level <= 5}\n assign_node_positions(topics,200)\n topics.each do |topic|\n position = quote(topic.x,topic.y)\n level = topic.level\n gv.add_nodes(topic.index, { height: height(level), fontcolor: fontcolor(level), fontsize: fontsize(level) , label: topic.label, shape: shape(level), style: style(level), color: color(level), pos: position })\n gv.add_edges(topic.parent_index, topic.index) if topic.level > 0\n end\n gv.output(svg: \"roadmap.svg\", use: \"neato\", no_layout: 1, scale: 72 )\nend",
"def create\n @slab = Slab.new(params[:slab])\n\n respond_to do |format|\n if @slab.save\n format.html { redirect_to @slab, :notice => 'Slab was successfully created.' }\n format.json { render :json => @slab, :status => :created, :location => @slab }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def circle_nodes(width=@width, height=@height, nodeset=@nodes)\n center = Vector[width/2, height/2]\n radius = [width,height].min/2\n nodeset.each_with_index{|(key, node), i| nodeset[key].location = Vector[\n center[0] + (radius * Math.sin(Math::PI/4+2*Math::PI*i/nodeset.length)), \n center[1] - (radius * Math.cos(Math::PI/4+2*Math::PI*i/nodeset.length))] if !nodeset[key].static}\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def create\n @circulation = Circulation.new(params[:circulation])\n\n respond_to do |format|\n if @circulation.save\n format.html { redirect_to @circulation, notice: 'Circulation was successfully created.' }\n format.json { render json: @circulation, status: :created, location: @circulation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @circulation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_activities_by_circle(params = {})\n return false unless check_required_params(params, ['circleId'])\n\n execute_with_api({\n :args => [\n @plus_api.activities.list_by_circle,\n params\n ]\n })\n end",
"def create\n @competence_center = CompetenceCenter.new(params[:competence_center])\n\n respond_to do |format|\n if @competence_center.save\n format.html { redirect_to @competence_center, notice: 'Competence center was successfully created.' }\n format.json { render json: @competence_center, status: :created, location: @competence_center }\n else\n format.html { render action: \"new\" }\n format.json { render json: @competence_center.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build\n CircleCi.request(conf, base_path).post\n end",
"def do_draw(circle, points, canvas)\r\n draw = Magick::Draw.new\r\n\r\n draw.fill('light gray')\r\n draw.ellipse(scale(circle.center.x), \r\n scale(circle.center.y), \r\n circle.radius * @height/2, \r\n circle.radius * @height/2, \r\n 0, 360)\r\n\r\n draw.fill('red')\r\n draw.fill_opacity('65%')\r\n for pt in points\r\n draw.ellipse(scale(pt.x), \r\n scale(pt.y), \r\n @small_circle_radii, @small_circle_radii, 0, 360)\r\n end\r\n draw.draw(canvas)\r\n end",
"def closer_add\n unless @user && @kroog\n flash[:warning] = \"Error: The specified circle does not exist\".t\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id]) and return\n end\n\n unless current_actor.is_a_follower_of?(@user)\n flash[:warning] = \"No request sent: you can not send requests to the not followed users\".t\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id]) and return\n end\n\n unless @kroog.can_request_invite?\n flash[:warning] = \"No request sent: you can not send request to this circle\".t\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id]) and return\n end\n\n if current_actor.is_self_or_owner?(@user)\n flash[:warning] = \"No request sent: you are already as close as you can get\".t\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id]) and return\n end\n\n unless current_actor.invites_i_requested.rejected.requests_to(@user).select { |x| x.circle_id == params[:circle].to_i }.size < 3\n flash[:warning] = \"No request sent: stop bugging this user!\".t\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id]) and return\n end\n\n InviteRequest.request_invite(current_actor, @user, params[:circle].to_i)\n PublicQuestionHelper::set_question_artist_id(@user, self)\n\n flash[:success] = \"Your request was successfully sent\".t\n redirect_to :controller => 'kroogi', :action => 'join_circles', :id => @user\n end",
"def create\n @corge = Corge.new(corge_params)\n\n respond_to do |format|\n if @corge.save\n format.html { redirect_to @corge, notice: 'Corge was successfully created.' }\n format.json { render :show, status: :created, location: @corge }\n else\n format.html { render :new }\n format.json { render json: @corge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_is_polygon_with_circle\n m = Sketchup.active_model\n ents = m.entities\n\n # Create a circle\n center = [0, 0, 0]\n normal = [0, 0, 1]\n radius = 20\n ents.add_circle center, normal, radius\n\n # Check circle edges\n m.entities.each do |e|\n if e.is_a? Sketchup::Edge and e.curve.respond_to? 'is_polygon?'\n assert_equal(false, e.curve.is_polygon?,\n 'Curve of circle edge should not be polygon.')\n end\n end\n end",
"def post_page_circle_annotations(name, page_number, annotations, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = post_page_circle_annotations_with_http_info(name, page_number, annotations, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = post_page_circle_annotations_with_http_info(name, page_number, annotations, opts)\n else\n raise\n end\n return data\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def create\n @centrale = Centrale.new(centrale_params)\n\n respond_to do |format|\n if @centrale.save\n format.html { redirect_to @centrale, notice: 'Centrale was successfully created.' }\n format.json { render :show, status: :created, location: @centrale }\n else\n format.html { render :new }\n format.json { render json: @centrale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def draw_force_circle(context, center, radius)\n rectangle = CGRectMake(center.x - radius, center.y - radius, radius*2, radius*2)\n CGContextSetStrokeColorWithColor(context,UIColor.redColor.CGColor)\n CGContextSetLineWidth(context, 5)\n CGContextAddEllipseInRect(context, rectangle)\n CGContextStrokePath(context)\n end",
"def create\n @society_recuritment = SocietyRecuritment.new(society_recuritment_params)\n\n respond_to do |format|\n if @society_recuritment.save\n format.html { redirect_to @society_recuritment, notice: 'Society recuritment was successfully created.' }\n format.json { render :show, status: :created, location: @society_recuritment }\n else\n format.html { render :new }\n format.json { render json: @society_recuritment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def nine_point_circle\n # Circle.new(*self.medial.vertices)\n end",
"def create\n @popcorn = Popcorn.new(popcorn_params)\n\n respond_to do |format|\n if @popcorn.save\n format.html { redirect_to @popcorn, notice: 'Popcorn was successfully created.' }\n format.json { render :show, status: :created, location: @popcorn }\n else\n format.html { render :new }\n format.json { render json: @popcorn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_circle(options)\n circle = OptionsHelper.to_circle(options)\n self.add_overlay circle\n\n circle\n end",
"def circle_vs_circle(a, b)\n return unless a[CircleShape] && b[CircleShape]\n\n nx, ny = [b[Position].x + b[CircleShape].x - a[Position].x - a[CircleShape].x,\n b[Position].y + b[CircleShape].x - a[Position].y - a[CircleShape].y]\n\n r = a[CircleShape].r + b[CircleShape].r\n r2 = r * r\n\n return if nx * nx + ny * ny > r2\n\n d = Math.sqrt(nx * nx + ny * ny)\n\n if d != 0\n contact = Stomp::Math.vadd(Stomp::Math.to_v(a[Position]),\n Stomp::Math.vmul([nx, ny], a[CircleShape].r))\n [nx / d, ny / d, r - d, [contact]]\n else\n [1, 0, a[CircleShape].r, [Stomp::Math.to_v(a[Position])]]\n end\n end",
"def create\n @tree = Tree.new(params[:tree])\n @tree.synclatlon\n respond_to do |format|\n if @tree.save\n format.html { redirect_to @tree, notice: 'Tree was successfully created.' }\n format.json { render json: @tree, status: :created, location: @tree }\n else\n format.html { render 'new' }\n format.json { render json: @tree.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @complexity = Complexity.new(params[:complexity])\n\n respond_to do |format|\n if @complexity.save\n format.html { redirect_to @complexity, notice: 'Complexity was successfully created.' }\n format.json { render json: @complexity, status: :created, location: @complexity }\n else\n format.html { render action: \"new\" }\n format.json { render json: @complexity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n points = params[:solution][:points_earned]\n unless current_user.posse.current_solution?\n solution = current_user.posse.solutions.create(solution_params)\n current_user.posse.add_points(points.to_i)\n end\n render json: solution\n end",
"def set_jam_circle\n @jam_circle = JamCircle.find(params[:id])\n @clip = Clip.new\n end",
"def test_circle_circle(a, b, response)\n # Check if the distance between the centers of the two\n # circles is greater than their combined radius.\n difference_v = T_VECTORS.pop.set(b.position) - a.position\n total_radius = a.r + b.r\n total_radius_sq = total_radius * total_radius\n distance_sq = difference_v.lengthsq\n # If the distance is bigger than the combined radius, they don't intersect.\n if distance_sq > total_radius_sq\n T_VECTORS.push(difference_v)\n return false\n end\n # They intersect. If we're calculating a response, calculate the overlap.\n if response\n dist = Math.sqrt(distance_sq)\n response.a = a\n response.b = b\n response.overlap = total_radius - dist\n response.overlap_n = difference_v.normalize\n response.overlap_v = difference_v * response.overlap\n response.a_in_b = a.r <= b.r && dist <= b.r - a.r\n response.b_in_a = b.r <= a.r && dist <= a.r - b.r\n end\n T_VECTORS.push(difference_v)\n return true\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 circle_info(radius)\n {:area => Math::PI * (radius * radius),\n :perimeter => Math::PI * (2 * radius),\n :sphere_volume => ((4/3)* Math::PI * (radius ** 3)),\n :sphere_surface_area => (4* (Math::PI * (radius * radius)))}\nend",
"def get_page_circle_annotations_with_http_info(name, page_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_page_circle_annotations ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_page_circle_annotations\"\n end\n # verify the required parameter 'page_number' is set\n if @api_client.config.client_side_validation && page_number.nil?\n fail ArgumentError, \"Missing the required parameter 'page_number' when calling PdfApi.get_page_circle_annotations\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/pages/{pageNumber}/annotations/circle\".sub('{' + 'name' + '}', name.to_s).sub('{' + 'pageNumber' + '}', page_number.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'CircleAnnotationsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_page_circle_annotations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def points_for_circle(x, y, r)\n cur_page.points_for_circle(x, y, r)\n end",
"def circle(*args)\n Circle.new(self, *args)\n end",
"def create\n @criterion = Criterion.new(params[:criterion])\n\n if @criterion.save\n render json: @criterion, status: :created, location: @criterion\n else\n render json: @criterion.errors, status: :unprocessable_entity\n end\n end",
"def create\n @club = Club.new(params[:club])\n\n if @club.save\n render json: @club, status: :created, location: @club\n else\n render json: @club.errors, status: :unprocessable_entity\n end\n end",
"def update_circle(circle)\n circle.update(part_of_bingo: true)\n end",
"def create\n @sphere = Sphere.new(params[:sphere])\n\n respond_to do |format|\n if @sphere.save\n format.html { redirect_to @sphere, notice: 'Sphere a été crée avec succès.' }\n format.json { render json: @sphere, status: :created, location: @sphere }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @point_of_contact.save\n render json: @point_of_contact, status: :created, location: @point_of_contact\n else\n render json: @point_of_contact.errors, status: :unprocessable_entity\n end\n end"
] | [
"0.7368445",
"0.7193256",
"0.68230915",
"0.65687287",
"0.65500444",
"0.64309543",
"0.6428214",
"0.6428214",
"0.6351642",
"0.62205863",
"0.6118326",
"0.610242",
"0.6060388",
"0.5932615",
"0.5932615",
"0.5931351",
"0.5915893",
"0.590707",
"0.588749",
"0.5874788",
"0.5854617",
"0.58288014",
"0.58112174",
"0.58112174",
"0.5775654",
"0.57584476",
"0.5723309",
"0.5699417",
"0.5668362",
"0.56404686",
"0.56207865",
"0.561087",
"0.55934787",
"0.55912477",
"0.55800855",
"0.5562842",
"0.5562842",
"0.5553387",
"0.5528177",
"0.55022556",
"0.5471593",
"0.5458771",
"0.5425973",
"0.54246986",
"0.5406695",
"0.53950083",
"0.5341211",
"0.52897644",
"0.52715987",
"0.5267202",
"0.5259412",
"0.5244537",
"0.52211154",
"0.5219977",
"0.5208377",
"0.51911163",
"0.51630116",
"0.51562244",
"0.51516587",
"0.51368153",
"0.5113952",
"0.5111558",
"0.5056126",
"0.50537187",
"0.50532424",
"0.5052044",
"0.50438154",
"0.5041288",
"0.50225616",
"0.50128645",
"0.500722",
"0.49775502",
"0.49735433",
"0.49725962",
"0.49695218",
"0.49581483",
"0.4947777",
"0.49301735",
"0.4910133",
"0.48790118",
"0.48767966",
"0.4859622",
"0.48509547",
"0.48487324",
"0.48454544",
"0.48448715",
"0.48445717",
"0.4841817",
"0.48375192",
"0.48205602",
"0.4817481",
"0.4813285",
"0.48107353",
"0.47990927",
"0.47946927",
"0.47899976",
"0.47663403",
"0.4762727",
"0.47539568",
"0.47525638"
] | 0.7293516 | 1 |
PATCH/PUT /circles/1 PATCH/PUT /circles/1.json | def update
if @circle.update(post_params)
render :show, status: :ok, location: @circle
else
render json: @circle.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, :notice => 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n if @circle.update_attributes(params[:circle])\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @circle.update(circle_params)\n format.html { redirect_to @circle, notice: 'Circle was successfully updated.' }\n format.json { render :show, status: :ok, location: @circle }\n else\n format.html { render :edit }\n format.json { render json: @circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @care_circle.update(care_circle_params)\n format.html { redirect_to @care_circle, notice: 'Care circle was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @care_circle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @circular.update(circular_params)\n format.html { redirect_to @circular, notice: 'Circular was successfully updated.' }\n format.json { render :show, status: :ok, location: @circular }\n else\n format.html { render :edit }\n format.json { render json: @circular.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.update(jam_circle_params)\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :ok, location: @jam_circle }\n else\n format.html { render :edit }\n format.json { render json: @jam_circle.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!(**args)\n @circle_id = args[:circle_id] if args.key?(:circle_id)\n @circle_set = args[:circle_set] if args.key?(:circle_set)\n @display_name = args[:display_name] if args.key?(:display_name)\n end",
"def update!(**args)\n @circle_id = args[:circle_id] if args.key?(:circle_id)\n @metadata = args[:metadata] if args.key?(:metadata)\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update!(**args)\n @circle = args[:circle] if args.key?(:circle)\n @contact_group = args[:contact_group] if args.key?(:contact_group)\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def update_circle(circle)\n circle.update(part_of_bingo: true)\n end",
"def update!(**args)\n @circle = args[:circle] if args.key?(:circle)\n @rectangle = args[:rectangle] if args.key?(:rectangle)\n end",
"def set_circle\n @circle = Circle.find(params[:id])\n end",
"def set_circle\n @circle = Circle.find(params[:id])\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\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch(path, data, params = {}, request_options = {})\n request(:patch, path, data, params)\n end",
"def update!(**args)\n @circle_id = args[:circle_id] if args.key?(:circle_id)\n @owner_gaia_id = args[:owner_gaia_id] if args.key?(:owner_gaia_id)\n @required_consistency_timestamp_usec = args[:required_consistency_timestamp_usec] if args.key?(:required_consistency_timestamp_usec)\n end",
"def update!(**args)\n @circle_id = args[:circle_id] if args.key?(:circle_id)\n @owner_gaia_id = args[:owner_gaia_id] if args.key?(:owner_gaia_id)\n @required_consistency_timestamp_usec = args[:required_consistency_timestamp_usec] if args.key?(:required_consistency_timestamp_usec)\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def put!\n request! :put\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n @circular.update(circular_params)\n @circulars = Circular.all\n @circular = Circular.new\n redirect_to new_circular_path\n flash[:notice] = 'Circular Updated Successfully' \n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update!(**args)\n @circle_id = args[:circle_id] if args.key?(:circle_id)\n @contact_group_id = args[:contact_group_id] if args.key?(:contact_group_id)\n @metadata = args[:metadata] if args.key?(:metadata)\n @system_contact_group_id = args[:system_contact_group_id] if args.key?(:system_contact_group_id)\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\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!(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\n end",
"def update!(**args)\n @bezier_params = args[:bezier_params] if args.key?(:bezier_params)\n @circle_params = args[:circle_params] if args.key?(:circle_params)\n @type = args[:type] if args.key?(:type)\n end",
"def circle_params\n params.require(:circle).permit(:name)\n end",
"def patch(operation, path, value = nil)\n ensure_client && ensure_uri\n body = {\n 'op' => operation,\n 'path' => path,\n 'value' => value\n }\n response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)\n @client.response_handler(response)\n end",
"def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end",
"def patch(url, options = {}, &block)\n request HttpPatch, url, options, &block\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 render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def assign_tenants_to_circle(args = {}) \n body_put(\"/tenantcircles.json/tenants/#{args[:circleId]}\", args[:array_of_ids])\nend",
"def put(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.put(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def update\n\n @laboratory = Laboratory.find(params[:id])\n\n if @laboratory.update!(laboratory_params)\n render json: @laboratory\n else \n render json: @laboratory.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, **args); end",
"def update\n @slab = Slab.find(params[:id])\n\n respond_to do |format|\n if @slab.update_attributes(params[:slab])\n format.html { redirect_to @slab, :notice => 'Slab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @slab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end",
"def patch(path, opts = {}, &block)\n request(:patch, path, opts, &block)\n end",
"def patch(url, data, headers = {})\n request(:patch, url, headers, :data => data)\n end",
"def modify(name: nil, avatar: nil, channel_id: nil)\n RestClient.patch(@url, { name: name, avatar: avatarise(avatar), channel_id: channel_id }.compact.to_json, content_type: :json)\n end",
"def create\n @circle = Circle.new(params[:circle])\n @circle.user = current_user\n \n respond_to do |format|\n if @circle.save\n format.html { redirect_to @circle, :notice => 'Circle was successfully created.' }\n format.json { render :json => @circle, :status => :created, :location => @circle }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @circle.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def update\n 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_radios_for_array(args = {}) \n put(\"/radios.json/#{args[:arrayId]}\", args)\nend",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def patch(path, data, options = {})\n uri = build_uri(path, options)\n\n request = Net::HTTP::Patch.new(uri.request_uri)\n set_authorisation_header(request)\n request.set_form_data(data)\n\n response = https_client(uri).request(request)\n end",
"def update\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n if @sphere.update_attributes(params[:sphere])\n format.html { redirect_to @sphere, notice: 'Sphere a été édité avec succès.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n require 'rest-client'\n response = RestClient.put('localhost:3001/colores/'[email protected]_s, color_params.as_json, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'})\n if response.code == 200\n @color = JSON.parse(response.body)\n\n format.html { redirect_to @color, notice: \"Color was successfully updated.\" }\n format.json { render :show, status: :ok, location: @color }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put options\n rest_request({ method: :put }.merge(options))\n end",
"def put options\n rest_request({ method: :put }.merge(options))\n end",
"def update!(**args)\n @radius = args[:radius] if args.key?(:radius)\n end",
"def update\n respond_to do |format|\n if @order.update(order_params)\n format.html { redirect_to @circle, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @circle }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n put :update\n end",
"def show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circle }\n end\n end",
"def patch(uri, options = T.unsafe(nil)); end",
"def update(path)\n output { patch(path, params) }\n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update\n respond_to do |format|\n if @contract.update(update_params)\n format.html { redirect_to_leaf_notice(UPDATE_SUCCESS) }\n format.json { render :show, status: :ok, location: @contract }\n else\n unprocessable_response(format)\n end\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def 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 show\n @circle = Circle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @circle }\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 recipe.update(recipe_params)\n render json: recipe\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(operation, path, value)\n response = @client.rest_patch(@data['uri'], 'body' => [{ op: operation, path: path, value: value }])\n @client.response_handler(response)\n end",
"def update\n respond_to do |format|\n if @sick.update(sick_params)\n format.html { redirect_to @sick, notice: 'Sick was successfully updated.' }\n format.json { render :show, status: :ok, location: @sick }\n else\n format.html { render :edit }\n format.json { render json: @sick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end",
"def update\n @pictures = Picture.all.order(created_at: :desc)\n @picture.update(picture_params)\n render json: @pictures\n # head :no_content\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def circle_params\n params.require(:circle).permit(:display_name, :content)\n end",
"def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end",
"def update\n @contact.update(contact_params)\n if @contact.valid?\n render json: @contact\n end\n end",
"def update\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n if @circulation.update_attributes(params[:circulation])\n format.html { redirect_to @circulation, notice: 'Circulation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circulation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @circle.destroy\n respond_to do |format|\n format.html { redirect_to circles_url, notice: 'Circle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @cocoon_example.update(cocoon_example_params)\n format.html { redirect_to @cocoon_example, notice: 'Cocoon example was successfully updated.' }\n format.json { render :show, status: :ok, location: @cocoon_example }\n else\n format.html { render :edit }\n format.json { render json: @cocoon_example.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def update\n respond_to do |format|\n if @sphere.update(sphere_params)\n format.html { redirect_to @sphere, notice: 'Sphere was successfully updated.' }\n format.json { render :show, status: :ok, location: @sphere }\n else\n format.html { render :edit }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solidarity.update(solidarity_params)\n format.html { redirect_to @solidarity, notice: 'Solidarity was successfully updated.' }\n format.json { render :show, status: :ok, location: @solidarity }\n else\n format.html { render :edit }\n format.json { render json: @solidarity.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.75676835",
"0.7538444",
"0.7538444",
"0.7405154",
"0.7237855",
"0.64841455",
"0.6473821",
"0.61811185",
"0.61735976",
"0.6159464",
"0.60976195",
"0.60976195",
"0.60677433",
"0.6050749",
"0.6037844",
"0.5989796",
"0.5967441",
"0.5935556",
"0.5923504",
"0.58812666",
"0.58812666",
"0.5869984",
"0.5869984",
"0.5793114",
"0.57920146",
"0.5766167",
"0.5766167",
"0.5757923",
"0.57407653",
"0.5712165",
"0.5708092",
"0.57077086",
"0.568198",
"0.56580234",
"0.5654835",
"0.56462085",
"0.56462085",
"0.5621597",
"0.5613124",
"0.5570578",
"0.556931",
"0.55619067",
"0.5555405",
"0.5541326",
"0.5535137",
"0.5522852",
"0.55207354",
"0.55182695",
"0.5515592",
"0.5510727",
"0.5500104",
"0.54996085",
"0.549726",
"0.5495756",
"0.5490416",
"0.54497296",
"0.54497296",
"0.5443762",
"0.5441304",
"0.54353",
"0.5422981",
"0.54222614",
"0.54215765",
"0.5413707",
"0.54104257",
"0.5410121",
"0.54060906",
"0.5398548",
"0.5398548",
"0.5392333",
"0.5386046",
"0.5382327",
"0.5373974",
"0.5366033",
"0.53621846",
"0.53577167",
"0.5349376",
"0.5346354",
"0.5346249",
"0.5342253",
"0.5341307",
"0.53387403",
"0.5335789",
"0.5335785",
"0.53338766",
"0.5328746",
"0.5328586",
"0.53144896",
"0.5313737",
"0.52948475",
"0.52897686",
"0.5287354",
"0.52776515",
"0.5272913",
"0.52706075",
"0.52705586",
"0.5267853",
"0.526407",
"0.5255777",
"0.5250709"
] | 0.659366 | 5 |
DELETE /circles/1 DELETE /circles/1.json | def destroy
@circle.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n\n respond_to do |format|\n format.html { redirect_to circles_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 @circle.destroy\n respond_to do |format|\n format.html { redirect_to circles_url, notice: 'Circle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circle = Circle.find(params[:id])\n @circle.destroy\n redirect_to circles_path\n end",
"def destroy\n @jam_circle.destroy\n respond_to do |format|\n format.html { redirect_to jam_circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @care_circle.destroy\n respond_to do |format|\n format.html { redirect_to care_circles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circular.destroy\n respond_to do |format|\n format.html { redirect_to circulars_url, notice: 'Circular was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @club_path = ClubPath.find(params[:id])\n @club_path.destroy\n\n respond_to do |format|\n format.html { redirect_to club_paths_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @curso.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\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 @clonet = Clonet.find(params[:id])\n @clonet.destroy\n\n respond_to do |format|\n format.html { redirect_to clonets_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def delete\n api(\"Delete\")\n end",
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\n format.json { head :no_content }\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy\n @dot.destroy\n respond_to do |format|\n format.html { redirect_to dots_url, notice: 'Dot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @climate = Climate.find(params[:id])\n @climate.destroy\n\n respond_to do |format|\n format.html { redirect_to climates_url }\n format.json { head :no_content }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete\n api_client.delete(url)\n end",
"def destroy\n \n respond_to do |format|\n RestClient.delete 'localhost:3001/colores/'[email protected]_s, {:Authorization => 'admin irizREhyoG6Ejwr4AcjsQME9'}\n format.html { redirect_to colors_url, notice: \"Color was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @datacenter.destroy\n\n respond_to do |format|\n format.html { redirect_to datacenters_url }\n format.json { head :ok }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def destroy\n @cn_curve.destroy\n respond_to do |format|\n format.html { redirect_to cn_curves_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @consensu = Consensu.find(params[:id])\n @consensu.destroy\n\n respond_to do |format|\n format.html { redirect_to consensus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sphere = Sphere.find(params[:id])\n @sphere.destroy\n\n respond_to do |format|\n format.html { redirect_to spheres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @complexity = Complexity.find(params[:id])\n @complexity.destroy\n\n respond_to do |format|\n format.html { redirect_to complexities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @circulation = Circulation.find(params[:id])\n @circulation.destroy\n\n respond_to do |format|\n format.html { redirect_to circulations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cog.destroy\n respond_to do |format|\n format.html { redirect_to cogs_url, notice: 'Cog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_networking.destroy\n\n render json: @social_networking, status: :ok\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @graphium_city.destroy\n respond_to do |format|\n format.html { redirect_to graphium_cities_url, notice: 'City was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nodo.destroy\n respond_to do |format|\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @green = Green.find(params[:id])\n @green.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_greens_url }\n format.json { head :ok }\n end\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def destroy\n @rayon = Rayon.find(params[:id])\n @rayon.destroy\n\n respond_to do |format|\n format.html { redirect_to rayons_url }\n format.json { head :no_content }\n end\n end",
"def soccer_delete\n base_delete(params, \"Soccer\")\n end",
"def delete(path, params={}, options={})\n request(:delete, api_path(path), params, options)\n end",
"def destroy\n @colaboration = Colaboration.find(params[:id])\n @colaboration.destroy\n\n respond_to do |format|\n format.html { redirect_to colaborations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @socio_rg.destroy\n respond_to do |format|\n format.html { redirect_to socio_rgs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chronicle = Chronicle.find(params[:id])\n @chronicle.destroy\n\n respond_to do |format|\n format.html { redirect_to library_path }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n @socio = Socio.find(params[:id])\n @socio.destroy\n\n respond_to do |format|\n format.html { redirect_to socios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @socio = Socio.find(params[:id])\n @socio.destroy\n\n respond_to do |format|\n format.html { redirect_to socios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, 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",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cord.destroy\n respond_to do |format|\n format.html { redirect_to cords_url, notice: t('cords.destroy.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @bracket_golfer.destroy\n respond_to do |format|\n format.html { redirect_to bracket_golfers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @operations_center = OperationsCenter.find(params[:id])\n @operations_center.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_centers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @socio.destroy\n respond_to do |format|\n format.html { redirect_to socios_url }\n format.json { head :no_content }\n end\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 destroy\n @curve = Curve.find(params[:id])\n @curve.destroy\n\n respond_to do |format|\n format.html { redirect_to curves_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @cloud.delete\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def delete(path, params = {}, request_options = {})\n request(:delete, path, params)\n end",
"def destroy\n @dotsmember = Dotsmember.find(params[:id])\n @dotsmember.destroy\n\n respond_to do |format|\n format.html { redirect_to dotsmembers_url }\n format.json { head :no_content }\n end\n end",
"def delete(url)\n do_request(\"delete\", url)\n end",
"def destroy\n id = @api_v1_canvas.id\n @api_v1_canvas.destroy\n respond_to do |format|\n format.html do\n redirect_to api_v1_canvases_url, notice: 'Canvas was successfully destroyed.'\n end\n\n format.json do\n msg = { id: id }\n broadcast(\"deleted\", msg)\n head :no_content\n end\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @curso.destroy\n respond_to do |format|\n format.html { redirect_to cursos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spatial_coverages = SpatialCoverages.find(params[:id])\n @spatial_coverages.destroy\n\n respond_to do |format|\n format.html { redirect_to spatial_coverage_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @svgpost = Svgpost.find(params[:id])\n @svgpost.destroy\n\n respond_to do |format|\n format.html { redirect_to svgposts_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end"
] | [
"0.7906571",
"0.7906571",
"0.7596188",
"0.7595404",
"0.7483723",
"0.7348654",
"0.7110125",
"0.6873949",
"0.6805337",
"0.6778534",
"0.66757864",
"0.6646662",
"0.6629113",
"0.65654445",
"0.65654445",
"0.65654445",
"0.65654445",
"0.6547623",
"0.6458799",
"0.6457974",
"0.64198214",
"0.64170855",
"0.64117074",
"0.6400983",
"0.6391034",
"0.6388416",
"0.6371595",
"0.63696253",
"0.6363747",
"0.6340566",
"0.63178414",
"0.6311813",
"0.6308114",
"0.63066137",
"0.6306443",
"0.6303649",
"0.6295025",
"0.6287172",
"0.6281917",
"0.6278891",
"0.6278816",
"0.6278036",
"0.6276288",
"0.62628424",
"0.62352324",
"0.62321633",
"0.6229677",
"0.6226255",
"0.62189555",
"0.62165576",
"0.6216206",
"0.6216206",
"0.6214842",
"0.6214488",
"0.6213343",
"0.6211719",
"0.621085",
"0.6206989",
"0.62065226",
"0.6202863",
"0.6201997",
"0.6201486",
"0.6199418",
"0.61986834",
"0.61986834",
"0.6198259",
"0.6197529",
"0.6197529",
"0.61855733",
"0.61855733",
"0.61855733",
"0.61855733",
"0.61855733",
"0.61855733",
"0.61855733",
"0.61808074",
"0.6179005",
"0.61750585",
"0.6173965",
"0.61708975",
"0.6166656",
"0.61663735",
"0.6158754",
"0.6158754",
"0.6158754",
"0.6158167",
"0.61577713",
"0.61459374",
"0.6145592",
"0.61451846",
"0.6142725",
"0.61403114",
"0.61391616",
"0.6135076",
"0.6131419",
"0.61270815",
"0.6123564",
"0.61231107",
"0.6120772",
"0.61194444"
] | 0.7237059 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_circle
@circle = Circle.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def call\n setup_context\n super\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0.53307265",
"0.5312121",
"0.5298173",
"0.5296388",
"0.52952695",
"0.5258086",
"0.52430934",
"0.5237911",
"0.5237911",
"0.5237911",
"0.5237911",
"0.5237911",
"0.52335346",
"0.5232943",
"0.5226392",
"0.52221715",
"0.5217978",
"0.52136153",
"0.52076435",
"0.52067244",
"0.5175402",
"0.5174649",
"0.5173085",
"0.5165201",
"0.5162052",
"0.5157932",
"0.5152905",
"0.5152353",
"0.5150909",
"0.514719",
"0.5138596",
"0.51333916",
"0.51139015",
"0.5113431",
"0.5113431",
"0.5109581",
"0.51066816",
"0.5091428",
"0.5089407",
"0.5082971",
"0.50822043",
"0.50668514",
"0.5055155",
"0.50525695",
"0.50499475",
"0.50499475",
"0.5034445",
"0.50249445",
"0.5022226",
"0.50167644",
"0.5014211",
"0.4999924",
"0.49996212",
"0.49978727",
"0.4989682",
"0.4989682",
"0.49851838",
"0.49817684",
"0.4979687",
"0.49787104",
"0.49688423",
"0.49664098",
"0.49564412",
"0.49561828",
"0.49547398",
"0.4953481",
"0.4952925",
"0.4946049",
"0.494379",
"0.49319315",
"0.49313048",
"0.49269778",
"0.49263066",
"0.49257493",
"0.4924526",
"0.49212465",
"0.49173486",
"0.4915802",
"0.49151486",
"0.49150333",
"0.49147308"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def circle_params
params.permit({genre: []}, :fee, :order, :min, :max, :frequency, :days, :location, :freeword)
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 |
Part 1 Below code takes an array of integers as an argument and returns the sum of its elements. | def sum(in_array)
# YOUR CODE HERE
sumr=0
if in_array.length == 0
sumr=0
elsif
#Enumerable
sumr= in_array.reduce(:+)
end
return sumr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_array(int_array)\n int_array.reduce(:+)\nend",
"def sum_array(array)\n sum = 0\n array.each do |x|\n sum += x\n end\n return sum\nend",
"def sum_array(array)\n sum = 0\n\n array.each do |number|\n sum += number\n end\n\n return sum\nend",
"def sum_array(array)\n\tarray.inject { |sum, n| sum + n }\nend",
"def sum(array_of_integers)\n # TODO\nend",
"def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each{ |num| sum += num }\n sum\nend",
"def sum_array(array)\n\tarray.inject do |sum, n| sum + n\n\tend\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum(array)\n array.map(&:to_i).reduce(0, :+)\nend",
"def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend",
"def sum_array(array)\n return array.sum\n\n # sum_total_of_array = 0\n # for number in array\n # sum_total_of_array += number\n # end\n # return sum_total_of_array\nend",
"def sum(array)\n array.reduce(0) {|sum, num| sum += num}\nend",
"def array_sum(arr)\n\tsum = 0\n\n\t# an for each loop\n\tfor i in arr\n\t\tsum += i\n\tend\n\t\n\treturn sum\n\t\nend",
"def sum_array(array)\n array.sum\nend",
"def it_arr_sum(array)\r\n sum = 0\r\n array.each {|ele| sum += ele}\r\n return sum\r\nend",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def array_sum(arr)\n arr.reduce(:+)\nend",
"def sum_array(array)\n the_sum_of_array = array.sum\n the_sum_of_array\nend",
"def array_sum(arr)\n return arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0) {|sum, el| sum + el}\nend",
"def sum_array(array)\n sum = 0\n array.each do |element|\n sum += element\n end\n sum\nend",
"def sum_array(array)\n array.sum\nend",
"def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n arr.reduce(0, :+)\nend",
"def array_sum(arr)\n\n sum = 0\n arr.each {|n| sum += n}\n\n sum\nend",
"def sum_array(array)\n array.reduce(:+)\nend",
"def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend",
"def sum_array(array)\n total = 0\n array.each do |num|\n total += num\n end\n total\nend",
"def sum(array)\n array.inject(0){|sum, n| sum + n}\n end",
"def simpleArraySum(ar)\n return ar.map(&:to_i).sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |i|\n sum+=i\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |value|\n sum += value\n end\n sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum+=num\n end\n sum\nend",
"def array_sum(array)\r\n array.inject(0, :+)\r\nend",
"def sum(array)\n\tarray.reduce(:+)\nend",
"def sum_array(numbers)\n return numbers.sum()\nend",
"def sum(array)\n sum = 0\n array.each do |a|\n sum += a\n end\n return sum\nend",
"def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend",
"def sum(array)\n\treturn array.reduce(:+)\nend",
"def sum(array)\n sum = 0\n array.each { |n| sum += n } \n sum\nend",
"def sum_array(array)\n array.inject { |sum,n| sum + n }\nend",
"def sum_of_sums(array)\n sum = 0\n sum_array = array.map { |x| sum += x }\n sum_array.inject(:+)\nend",
"def sum(array)\n\tanswer = 0\n\tif array.length > 0 then\n\t\tarray.each {|x| answer += x}\n\telse\n\t\treturn 0\n\tend\n\treturn answer\nend",
"def array_sum(arr)\n arr.reduce(:+)\n\nend",
"def sum_array(integers)\n integers.sum\nend",
"def sum_array(array)\n array.inject { |sum, n| sum += n}\nend",
"def sum(array)\n array.reduce(0, :+)\n=begin\n res =0\n array.each { |a| res += a }\n res.to_i\n=end\nend",
"def sum (array)\n y=array.inject(:+).to_i\nend",
"def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend",
"def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend",
"def simple_array_sum arr\n arr.reduce(:+)\n end",
"def sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum_of_sums(array)\n total = 0\n\n 1.upto(array.size) do |num|\n total += array.slice(0, num).reduce(:+)\n end\n total\nend",
"def sum_array(array)\n array.inject { |sum, x| sum + x }\nend",
"def sum (arr)\n\treturn arr.inject(0, :+)\nend",
"def sum(array)\n return array.inject(0, &:+)\nend",
"def sum_array(array)\n #array.inject(0){|sum,x| sum + x }\n array.inject(0){|sum,x| sum + x }\nend",
"def sum(array)\n array.sum\nend",
"def get_sum(array)\n return array.inject (0) { |sum, n| sum + n }\nend",
"def sum(array)\n return 0 if array.empty?\n return array.first if array.length == 1\n\n array.inject(:+)\nend",
"def sum_array (arr)\n result = 0\n arr.each do |value|\n result +=value\n end\n result\nend",
"def sum(array)\n array.reduce(0) {|base, ele|\n base+=ele\n }\n end",
"def total(array)\n sum = 0\n array.each { |i| sum += i }\n return sum\nend",
"def sum_array(array)\n array.inject {|sum, n| sum + n }\nend",
"def my_sum(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n sum\nend",
"def sum_array(array)\n array.inject {|sum, n| sum + n}\nend",
"def sum(array)\n s = 0\n\tarray.each {|x| s+= x}\n\ts\nend",
"def array_sum(arr)\n if arr.length == 0\n return 0\n end\n arr.reduce(:+)\nend",
"def sum_array(array)\n array.inject do |sum, n|\n sum + n\n end\nend",
"def sum(theArray)\n\ttotal = 0\n\ttheArray.each do |i|\n\t\ttotal = total + i\n\tend\n\treturn total\nend",
"def total (array)\n\tarray.inject { |sum, n| sum + n }\nend",
"def sum_of_sums(array)\r\nend",
"def total(array)\n sum = 0\n array.each do |n|\n sum += n\n end\n sum\nend",
"def sum_array(any_array)\n any_array.inject(:+)\n end",
"def total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\n return sum\nend",
"def sum_of array\n# add the numbers of the array, these are three different ways I found\n array.inject{ |sum, value| sum += value}\n # or\n # array.map(&:to_i).reduce(0, :+)\n # or\n # array.sum\nend",
"def sum arr\n rtn = 0\n arr.each { |n| rtn += n }\n return rtn\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def total(array)\n sum = 0\n array.each do |num|\n sum += num\n end\n return sum\nend",
"def sum(in_array)\n return 0 if in_array.length == 0\n return in_array.reduce(:+)\nend",
"def total(array)\n sum = 0\n array.each {|x| sum += x}\n return sum\nend",
"def sum(array)\n array.inject(0, :+)\nend",
"def simpleArraySum(ar)\n ar.sum\nend",
"def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n arr.reduce(:+)\nend",
"def total(array)\n\tarray.inject { |sum, x| sum + x }\nend",
"def sum_of_arr(arr)\n arr.inject(:+)\nend",
"def total(array)\n\tsum = 0\n\tarray.each {|number| sum += number}\n\tsum\nend",
"def total(array)\n\tsum = 0\n\tarray.each do |i|\n\t\tsum += i\n\tend\n\treturn sum\nend",
"def array_sum(arr)\n return 0 if arr.empty?\n\n arr.reduce(&:+)\nend",
"def total(array)\n sum = 0\n array.each do |number|\n sum = sum += number\n end\n sum\nend",
"def sumArray(array)\n sum = 0\n array.each do\n |n|\n sum += n.to_i\n end\n puts \"Somme : #{sum}\"\nend",
"def sum(array)\n y = 0\n array.each do |x|\n y += x\n end\n y\nend",
"def sum(array)\n return 0 if array.empty?\n array.inject(:+)\nend",
"def total(array)\n\treturn array.inject { |sum, x| sum + x }\nend",
"def total_of_array(array)\n array.reduce(:+)\nend",
"def total (array)\n\tsum=0\n\tarray.each do |n| sum += n\n\tend\n\treturn sum\nend"
] | [
"0.86859727",
"0.85542965",
"0.85490406",
"0.85471165",
"0.85007906",
"0.84865177",
"0.8482826",
"0.8471103",
"0.8458727",
"0.84479445",
"0.8447448",
"0.844739",
"0.84460264",
"0.8445915",
"0.8445287",
"0.8444723",
"0.84398735",
"0.84398735",
"0.84395623",
"0.84348696",
"0.84315324",
"0.84236306",
"0.84225595",
"0.84213763",
"0.8421327",
"0.8421327",
"0.8421327",
"0.8410024",
"0.8405709",
"0.83996564",
"0.8392979",
"0.8389519",
"0.83825046",
"0.83821154",
"0.8379707",
"0.83781195",
"0.8368665",
"0.8368383",
"0.8366037",
"0.83598936",
"0.83597654",
"0.83587956",
"0.8342306",
"0.83294237",
"0.83289003",
"0.8323315",
"0.8311425",
"0.8307281",
"0.82968473",
"0.829476",
"0.8285853",
"0.82837886",
"0.82760406",
"0.82745385",
"0.8274477",
"0.827365",
"0.826362",
"0.82537955",
"0.8241186",
"0.8238759",
"0.8229821",
"0.8229752",
"0.82237166",
"0.8207196",
"0.81919485",
"0.8185237",
"0.8183464",
"0.8177984",
"0.8173494",
"0.81607914",
"0.8150912",
"0.8148181",
"0.8145712",
"0.8139321",
"0.8136902",
"0.81351197",
"0.8127972",
"0.81216323",
"0.8115095",
"0.8106031",
"0.81035566",
"0.81019807",
"0.80994457",
"0.80923444",
"0.80922365",
"0.8084178",
"0.8083012",
"0.8081792",
"0.8081792",
"0.8081436",
"0.80793667",
"0.80774206",
"0.8076059",
"0.8071121",
"0.8069871",
"0.8065391",
"0.80639845",
"0.8062123",
"0.8058",
"0.80525863",
"0.8051856"
] | 0.0 | -1 |
Below code takes an array of integers as an argument and returns the sum of its two largest elements. | def max_2_sum(int_array)
# YOUR CODE HERE
heyr=0
if int_array.length == 0
heyr=0
return heyr
elsif int_array.length == 1
heyr=int_array[0]
return heyr
end
int_array.sort!.reverse!
heyr= int_array[0] + int_array[1]
return heyr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_two_largest_numbers(arr)\n arr.max(2).reduce(:+)\nend",
"def max_2_sum(array)\n sum(array.sort.last(2))\nend",
"def max_2_sum(array)\n sum array.sort.last(2)\nend",
"def max_2_sum(int_array)\n sum(int_array.sort {|a,b| b <=> a}[0,2])\nend",
"def max_2_sum array\n return 0 if array.empty?\n return array.first if array.length == 1\n sum_of_two_largest_values = array.sort[-2] + array.sort[-1]\nend",
"def max_2_sum arr\n # arr.max(2).sum()\n return arr.sort.reverse[0,2].sum() # 내림차순 sort하고 2개 합\nend",
"def max_2_sum(array)\n array.max(2).sum\nend",
"def max_2_sum(array)\n\n raise 'array includes non integers' unless \n (array.empty? || array.length == 1 || array.all? { |x| x.integer?})\n\n case array.length\n when 0\n return 0\n when 1\n return array[0]\n else\n array_sorted = array.sort\n return array_sorted[array.length-2] + array_sorted[array.length-1]\n end\nend",
"def max_2_sum array\n # return 0 if array.empty?\n # return array[0] if array.length == 1\n # array.sort![-1] + array[-2]\n array.length > 0 ? array.sort.pop(2).inject(:+) : 0\nend",
"def max_2_sum arr\n sum(arr.sort.last(2))\nend",
"def max_2_sum(array)\n array_size = array.size\n case array_size\n when 0\n 0\n when 1\n array[0]\n else\n array.sort!.last(2).inject(:+)\n\n end\nend",
"def max_2_sum arr\n sum(arr.sort.last(2)) \nend",
"def max_2_sum(int_array)\n return 0 if int_array.size == 0\n return int_array[0] if int_array.size == 1\n\n int_array.sort!\n return (int_array[int_array.length - 2] + int_array[int_array.length - 1])\nend",
"def max_2_sum arr\n sorted_array = arr.sort { |a, b| b <=> a }\n sorted_array.slice(0, 2).reduce(0) { |memo, x| memo + x }\nend",
"def max_2_sum(int_array)\n return 0 if int_array.length == 0\n return int_array[0] if int_array.length == 1\n int_array.sort!.reverse!\n return int_array[0] + int_array[1] \nend",
"def max_2_sum(array)\n # YOUR CODE HERE\n return 0 if array.empty?\n\treturn array[0] if array.length == 1\n\tar = array.sort\n\tar[-1] + ar[-2]\nend",
"def max_2_sum arr\n return 0 if arr.empty?\n return arr.first if arr.size == 1\n arr.sort.pop(2).inject(:+)\nend",
"def max_2_sum arr\n #If the array is empty return 0\n if arr.length == 0 then\n\treturn 0\n end\n #If the array has only one element return that element\n if arr.length == 1 then \n return arr[0]\n end\n #Sorts the array in increasing order to return the sum of the last two elements.\n return arr.sort.last(2).sum\nend",
"def max_2_sum(*n)\n\tn.sort[-1] + n.sort[-2] #sort sorts array items from small - large, [] gets the location of an item in an array\nend",
"def largest_sum_arr_n2(arr)\n list = []\n i = 0\n while i < arr.length\n j = i\n while j < arr.length\n list.push arr[i..j]\n j += 1\n end\n i += 1\n end\n\n result = nil\n max = nil\n list.each do |a|\n current_sum = a.inject(:+)\n if max.nil? || current_sum > max\n result = a\n max = current_sum\n end\n end\n result\nend",
"def max_2_sum arr\n # YOUR CODE HERE\n sortedarr = arr.sort.reverse\n total = sortedarr.take(2).sum\n \n return total\nend",
"def max_2_sum arr\n if arr.count > 1 \n arr_ord = arr.sort \n return arr_ord[-1] + arr_ord[-2]\n elsif arr.count == 1\n return arr[0]\n else\n return 0\n end\nend",
"def max_2_sum arr\n return 0 if arr.empty?\n return arr[0] if arr.length == 1\n sorted = arr.sort.reverse\n sorted[0] + sorted[1]\nend",
"def max_2_sum arr\n arr = arr.max(2).sum \nend",
"def max_2_sum arr\n result = 0\n unless arr.empty?\n if arr.size == 1\n result = arr[0]\n else \n arr = arr.sort{|x,y| y<=>x}\n result = arr[0]+arr[1]\n end\n end\n return result\nend",
"def max_2_sum arr\n sum = 0\n if arr.length == 0\n return 0\n end\n if arr.length == 1\n return arr[0]\n end\n sorted_arr = arr.sort\n maxa = sorted_arr.pop\n maxb = sorted_arr.pop\n sum = maxa+ maxb\n return sum\nend",
"def max_2_sum(arr)\n arr.max(2).reduce(0,:+)\nend",
"def max_2_sum arr\n # arr.empty? ? 0 : arr.sort.last(2).inject(:+)\n arr.sort.last(2).inject(0, :+)\nend",
"def max_2_sum arr\n arr.max(2).reduce(0, :+)\nend",
"def max_2_sum arr\n arr.max(2).reduce(0, :+)\nend",
"def max_2_sum arr\n # YOUR CODE HERE\n if arr.empty?\n return 0 \n end\n if arr.length == 1\n return arr[0] \n end\n a = arr.sort\n a[-2] + a[-1]\nend",
"def max_2_sum arr\n size = arr.length\n case size\n when 0\n return 0\n when 1\n return arr[0]\n else\n return arr.sort!.last(2).inject(0){|s, r| s+r}#sorts arr in Asc. order and saves, takes the last 2, black accumulator on those last 2 e's returned\n end\nend",
"def max_2_sum(a)\n a.length > 0 ? a.sort.pop(2).inject(:+) : 0\nend",
"def max_2_sum(ar)\n return 0 if ar.empty?\n return ar[0] if ar.length == 1\n sar = ar.sort {|x,y| y <=> x }\n return sar[0] + sar[1]\nend",
"def array_2_sum(array)\r\n array.max(2).inject(0, :+) # Sum for max 2 elements.\r\nend",
"def max_2_sum arr\n larSum = 0\n if arr.length == 0\n larSum = 0\n elsif arr.length == 1\n larSum = arr[0]\n else\n newArr = arr.sort\n larSum = newArr[newArr.length-1]+newArr[newArr.length-2]\n end\n return larSum\nend",
"def max_2_sum(array)\n if array.empty?\n 0\n elsif array.count ==1\n array[0]\n else\n array.sort! {|a,b| b <=> a}\n array[0] + array[1]\n end\nend",
"def sum_of_two_largest_numbers(arr)\n sum = 0\n\n sum += arr.max\n arr.delete(arr.max)\n\n sum += arr.max\n\n return sum\nend",
"def max_2_sum (arr)\n \n s=0\n if (arr.length == 1)\n return arr[0]\n end\n \n if (arr.length == 0)\n return 0\n end\n \n if (!arr.empty?)\n arr=arr.sort{ |x,y| y <=> x }\n end\n \n s= arr[0] + arr[1]\n \n return s\nend",
"def max_2_sum arr\n if arr.empty?\n return 0\n elsif arr.size==1\n return arr[arr.size-1]\n else\n arr=arr.sort\n return arr[arr.size-1]+arr[arr.size-2]\n end\nend",
"def max_2_sum arr\n if arr.length == 0\n return 0\n elsif arr.length==1\n return arr[0]\n else arr.sort!\n return arr[-1]+arr[-2]\n end\nend",
"def max_2_sum arr\n if arr.empty? \n \tsum = 0\n elsif arr.count == 1\n \tsum = arr[0]\n else\n arr = arr.sort.reverse\n sum = arr[0] + arr[1]\n end\n return sum\nend",
"def solve(array)\n largest_sum = 0\n\n array.each_with_index do |element, index|\n current_largest_sum = 0\n if element > 0\n current_largest_sum += element\n\n array[index..(-1)].each do |el|\n current_largest_sum += el if el > element\n end\n current_largest_sum -= element\n largest_sum = current_largest_sum if current_largest_sum > largest_sum\n end\n end\n largest_sum\nend",
"def max_2_sum arr\n s = 0\n\n return s if arr.empty?\n return arr[0] if arr.length==1\n \n arr.sort!\n arr[-1] + arr[-2] \nend",
"def max_2_sum( arr )\n\n if arr.nil? or arr.empty?\n 0\n elsif arr.length == 1\n arr.first\n else\n max = arr.sort[-2..-1]\n max.first + max.last\n end\n\nend",
"def max_2_sum(array)\n res= array.max.to_i\n (array.delete(array.max))\n res+=array.max.to_i\nend",
"def max_2_sum arr\n \n if arr.empty?\n 0\n else\n arr.max(2).reduce(:+)\n end\n \nend",
"def max_2_sum arr\n if arr.length == 0\n return 0\n elsif arr.length ==1\n return arr[0]\n else\n arr.sort!\n return arr[arr.length-1] + arr[arr.length-2]\n end\nend",
"def largest_sum_pair(array)\nend",
"def max_2_sum arr\n if arr.empty?\n 0\n else\n arr.max(2).reduce(:+)\n end\nend",
"def largest_cont_sum(array)\n return nil if array.empty?\n \n max_sum = 0\n current_max_sum = 0\n\n array.each do |number|\n current_max_sum = [current_max_sum + number, number].max\n max_sum = [current_max_sum, max_sum].max\n end\n\n max_sum\nend",
"def better_largest_sub_sum(array)\n largest_sum = 0\n current_sum = 0\n array.each_with_index do |el, idx|\n current_sum += el\n current_sum = 0 if current_sum < 0\n largest_sum = current_sum if current_sum > largest_sum\n end\n largest_sum\nend",
"def max_2_sum(numbers=[])\n\tif numbers.length == 0\n\t\treturn 0\n\telsif numbers.length == 1\n\t\treturn numbers[0]\n\telse\n\t\tmax = numbers.sort.reverse[0]\n\t\tmax2 = numbers.sort.reverse.drop(1)[0]\n\t\treturn max + max2\n\tend\nend",
"def biggest_number(array_of_integers)\n # TODO\nend",
"def max_2_sum(ints)\n return 0 if ints.empty?\n return ints.first if ints.size == 1\n ints.sort.reverse[0,2].inject(0, :+)\nend",
"def max_2_sum(arr)\n return 0 if arr.empty?\n return arr[0] if arr.size == 1\n\n first_max = arr.max\n arr.delete_at arr.index first_max\n\n second_max = arr.max\n\n\n first_max + second_max\nend",
"def find_largest_nums(arr)\n\tlargest = []\n\tarr.each { |x| largest << x.sort[-1] }\n\treturn largest\nend",
"def optimized_largest_subsum(arr)\n max = arr.first\n sum = arr.first \n arr.shift\n arr.each do |el|\n sum += el\n if el > max && el > sum \n max = el \n sum = el \n elsif sum > max\n max = sum\n end \n end \n max\nend",
"def sub_array_sum(nums)\n greatest_sum = nums.first\n current_sum = 0\n nums.each do |num|\n current_sum += num\n greatest_sum = current_sum if current_sum > greatest_sum\n current_sum = 0 if current_sum < 0\n end\n greatest_sum\nend",
"def max_sub_array(arr)\n current_sum = arr[0]\n max_sum = current_sum\n\n arr[1..-1].each do |num|\n current_sum = [num, current_sum + num].max\n max_sum = [max_sum, current_sum].max\n end\n\n return max_sum\nend",
"def sub_max(array)\n so_far = array[0]\n max_point = array[0] # [0] -2 and [1] 1 sum -1, number 1\n\n array.each do |number|\n # to find the max between the two values:\n max_point = max((number + max_point), number)\n so_far = max(max_point, so_far)\n end\n\n return so_far\nend",
"def find_sum(array)\n max = 0\n temp_array = array.clone\n (1...array.length).each do |i|\n (0...i).each do |j|\n if (array[i] > array[j] && temp_array[i] < temp_array[j] + array[i])\n temp_array[i] = temp_array[j] + array[i]\n end\n end\n end\n (0...array.length).each do |k|\n max = temp_array[k] if temp_array[k] > max\n end\n return max\nend",
"def max_2_sum arr\n arr.empty? ? 0 : arr.max(2).reduce(:+) \nend",
"def sum_two_highest_positive_integers(numbers)\n sorted = numbers.sort!\n sorted[-1] + sorted[-2]\nend",
"def largest_subsum_p2(arr)\n max_sum = 0\n arr.each do |el|\n temp = max_sum + el\n temp = 0 if temp < 0\n max_sum = temp if temp > max_sum\n end\n\n if max_sum == 0\n # all the nums are negative\n max_sum = arr[0]\n arr.each do |el|\n max_sum = el if el > max_sum\n end\n end\n\n max_sum\nend",
"def solve(nums)\n sorted = nums.sort\n largest = 0\n (0...sorted.length - 1).each do |i|\n if (sorted[i+1] - sorted[i]) > largest\n largest = (sorted[i+1] - sorted[i])\n end\n end\n return largest\n\nend",
"def max_2_sum arr\n return 0 if arr.empty?\n return arr[0] if arr.length==1\n \n i=1\n \n arr.each do |c| \n if i== 1\n @a=c\n elsif i==2\n if c> @a\n @b=@a\n @a=c \n else\n @b=c\n end\n elsif c>@a and c>@b\n @b=@a\n @a=c \n elsif c>@b\n @b=c\n end\n i+=1\n end\n return @a+@b\nend",
"def cusmax(array)\r\n return array.sort.max\r\nend",
"def two_largest_integers_sum(input)\n largest = input[0]\n second_to_largest = input[0]\n\n input.each do |num|\n if largest < num\n second_to_largest = largest\n largest = num \n end\n end\n\n return largest + second_to_largest\nend",
"def max_sub_array(array)\n max_sum = current_val = array[0]\n array.each_with_index do |num, i|\n if (i > 0)\n sum = current_val + num\n if (sum > num)\n current_val = sum\n else\n current_val = num\n end\n if current_val > max_sum\n max_sum = current_val\n end\n end\n end\n max_sum\nend",
"def largest(array)\nend",
"def max_sub_array(nums)\n current_sum = nil\n max_sum = nil\n \n nums.each do |n|\n if current_sum.nil?\n current_sum = n\n elsif current_sum + n < n\n current_sum = n\n else\n current_sum = current_sum + n\n end\n max_sum = current_sum if max_sum.nil? || current_sum > max_sum\n end\n max_sum\nend",
"def miniMaxSum(arr)\n arr.sort!\n low_sum = arr[0..3].inject(0, :+)\n high_sum = arr[1..4].inject(0, :+)\n print \"#{low_sum} #{high_sum}\"\nend",
"def max(array)\n\tn = 0\n\tarray.each do |x|\n\t\tif x > n\n\t\t\t n = x\n\t\tend\n\tend\n\t puts n\nend",
"def largest_sum_better(arr)\n largest_sum = arr.first\n current = arr.first\n\n (1...arr.length).each do |idx|\n if current < 0\n current = 0\n end\n\n current += arr[idx]\n \n if current > largest_sum\n largest_sum = current\n end\n end\n\n largest_sum\nend",
"def miniMaxSum(arr)\n arr.sort!\n sum = 0\n arr.each {|item| sum+=item}\n puts \"#{sum-arr[-1]} #{sum-arr[0]}\"\nend",
"def largest_sub_sum_linear(arr)\n largest = arr.first\n current = arr.first\n\n return arr.max if arr.all? { |num| num < 0 }\n i = 1\n\n while i < arr.length\n current = 0 if current < 0\n current += arr[i]\n largest = current if current > largest\n i+=1\n end\n\n largest\n end",
"def better_largest_cont_sum(array)\n largest = 0\n current = 0\n\n array.each do |n|\n current += n\n largest = current if current > largest\n current = 0 if current < 0\n end\n\n largest\nend",
"def largest_pair(pairs_array)\n # 1. iterate through each pair in array\n # 2. add the pair of numbers together\n # 3. store sum\n # 4. if sum is greater than stored sum, save index of those numbers\n #\n\n largest = pairs_arr.first\n\n pairs_arr.each_index do |idx|\n if largest[0] + largest[1] < pairs_arr[idx][0] + pairs_arr[idx][1]\n # reset the largest variable; we've found out otherwise!\n largest = pairs_arr[idx]\n end\n end\n\n largest\n\n\nend",
"def max_2_sum(ints)\n\treturn 0 if ints.empty?\n\treturn ints[0] if ints.length == 1\n\tints.sort!.reverse!\n\treturn ints[0] + ints[1]\nend",
"def max_sub_array(nums)\n max_sum = nums[0]\n\n for i in (0...nums.length) do\n sum_so_far = 0\n for j in (i...nums.length) do\n sum_so_far += nums[j]\n max_sum = [sum_so_far, max_sum].max\n end\n end\n\n return max_sum\nend",
"def max_sub_array(numbers)\n max = numbers[0]\n\n (1...numbers.size).each do |idx|\n current_sum = numbers[idx] + numbers[idx - 1]\n numbers[idx] = current_sum if current_sum > numbers[idx]\n max = numbers[idx] if numbers[idx] > max\n end\n\n max\nend",
"def largest_integer(array)\n large = array[0]\n array.each do |n|\n if n > large\n large = n\n end\n end\n large\nend",
"def max_sub_array3(nums)\n max_sum = nums[0]\n\n (1...nums.size).each do |i|\n # nums[i] 记录到该位置时,可能获得的最大和\n # 如果前面的一个是正的,那么就加上\n # 如果前面的是付的,那么就保留当前值\n nums[i] += nums[i - 1] if nums[i - 1] > 0\n max_sum = [nums[i], max_sum].max\n end\n p nums\n p nums.max\n max_sum\nend",
"def max_sub_array(nums)\n\tmax = count = nums.shift\n\n\tnums.each do |num|\n\t\tcount = num > count + num ? num : count + num\n\t\tmax = count if count > max\n\tend\n\n\tmax\nend",
"def lcss_2(arr)\n largest_num = arr.max\n max_sum = 0\n current_sum = 0\n\n arr.each do |num|\n current_sum += num\n\n if current_sum < 0\n current_sum = 0\n elsif max_sum < current_sum\n max_sum = current_sum\n end\n end\n\n return largest_num if max_sum == 0\n max_sum\nend",
"def largest_contiguous_subsum2(array)\r\n largest = array[0]\r\n current_sum = array[0]\r\n\r\n (1...array.length).each do |i|\r\n current_sum = 0 if current_sum < 0\r\n num = array[i]\r\n current_sum += num\r\n if current_sum > largest\r\n largest = current_sum\r\n end\r\n end\r\n\r\n largest\r\nend",
"def max_subarray_v2(numbers)\n max = numbers[0].to_i\n max_current = numbers[0].to_i\n\n for i in 1..numbers.length\n max_current = [numbers[i].to_i, max_current + numbers[i].to_i].max\n max = [max, max_current].max\n end\n\n max\n end",
"def find_max_value(array)\n sorted_array = array.sort\n sorted_array.last\nend",
"def solution2(a)\n\n total_max, current_max = a[0], 0\n\n a.each do |int|\n current_max = [current_max + int, int].max\n total_max = [total_max, current_max].max\n end\n\n return max\n\nend",
"def find_max_value(array)\n array.sort!\n return array[-1]\nend",
"def max_sub_array(nums)\n return 0 if nums.nil? \n return nil if nums.empty?\n \n max_so_far = nums[0]\n max_for_sub_array = 0\n\n nums.each do |num|\n max_for_sub_array = max_for_sub_array + num\n if num > max_for_sub_array\n max_for_sub_array = num\n end\n if max_for_sub_array > max_so_far\n max_so_far = max_for_sub_array\n end\n end\n return max_so_far\n\nend",
"def opt_max_sum(arr)\n result = -1000\n (0...arr.length).each do |start|\n sum = 0\n (1..arr.length).each do |size|\n if start + size > arr.length\n break\n end\n sum += arr[start + size - 1]\n if sum > result\n result = sum\n end\n end\n end\n return result\nend",
"def miniMaxSum(arr)\n arr = arr.sort\n a = arr[1..-1].reduce(:+)\n b = arr[0..-2].reduce(:+)\n print b\n print \" \"\n print a\nend",
"def phase_2_largest_contiguous_sum(arr)\n\n return [[]] if arr.empty?\n subs = arr.take(arr.count-1).phase_2_largest_contiguous_sum\n subs.concat(subs.map {|sub| sub + [last]})\n\n largest_sum = subs.first.sum \n\n subs.each do |sub|\n current_sum = sub.sum \n if current_sum > largest_sum\n largest_sum = current_sum\n end\n end\n\n largest_sum\n\nend",
"def maximum_sub_array2(arr)\n current = []\n max_sum = cur_sum = 0\n max = (0...arr.size).inject([]) do |max, i|\n current << arr[i]\n cur_sum += arr[i]\n if cur_sum > max_sum\n max << i\n max_sum = cur_sum\n end\n max\n end\n arr[max[0]..max[-1]]\nend",
"def find_largest_nums(arr)\n\ta = 0\n\tfinal_arr = []\n\twhile a < arr.length\n\t\tfinal_arr << arr[a].max\n\t\ta += 1\n\tend\n\treturn final_arr\nend",
"def max_sub_array(nums)\n return 0 if nums == nil\n return nil if nums.empty?\n \n max_by_here = nums[0]\n max_so_far = nums[0]\n \n nums.each_with_index do |num, index|\n unless index == 0\n if max_so_far < 0\n if num > max_so_far\n max_so_far = num\n end\n else\n max_by_here += num\n \n if max_by_here < 0\n max_by_here = 0\n elsif max_by_here > max_so_far\n max_so_far = max_by_here\n end\n end\n end\n end\n \n return max_so_far\nend",
"def find_max\n\tarr = [100,10,-1000,59,03,453,2345,365,-45,266,-345]\n\tarr_new = arr.sort.pop\n\tprint \"this is the higest number in the array #{arr_new}\"\nend",
"def max(arr)\n greatest = array[0]\n arr.each do |num|\n if num > greatest\n greatest = num\n end\n end\n greatest\nend"
] | [
"0.8579375",
"0.85732424",
"0.85603315",
"0.8454468",
"0.84254694",
"0.83595246",
"0.8342365",
"0.8296276",
"0.825158",
"0.82363594",
"0.8219529",
"0.8212155",
"0.8199183",
"0.818208",
"0.81219846",
"0.8103977",
"0.80883586",
"0.8058619",
"0.8050383",
"0.80021906",
"0.79997945",
"0.79947144",
"0.7985027",
"0.7981918",
"0.7980072",
"0.797753",
"0.795129",
"0.7902444",
"0.7881922",
"0.7881922",
"0.78625417",
"0.7857719",
"0.785538",
"0.785427",
"0.7844417",
"0.77948993",
"0.77854574",
"0.7784257",
"0.77776486",
"0.77677864",
"0.77662045",
"0.77622724",
"0.7719515",
"0.771929",
"0.76828724",
"0.7676588",
"0.76304895",
"0.7620069",
"0.76180214",
"0.75964504",
"0.75935465",
"0.7567693",
"0.7545151",
"0.7538127",
"0.752239",
"0.75209445",
"0.75043195",
"0.7465152",
"0.74545276",
"0.7452428",
"0.74276376",
"0.74107766",
"0.74067426",
"0.74061906",
"0.7405469",
"0.7384616",
"0.73736244",
"0.7368892",
"0.7368733",
"0.7366155",
"0.7361041",
"0.7356094",
"0.73414683",
"0.7336603",
"0.73347276",
"0.7334168",
"0.73252064",
"0.7319278",
"0.731852",
"0.7317614",
"0.7314303",
"0.73102766",
"0.72706264",
"0.725452",
"0.72445875",
"0.72402555",
"0.7230895",
"0.7218973",
"0.72116625",
"0.71942216",
"0.71822083",
"0.71665734",
"0.71661866",
"0.71612656",
"0.71552116",
"0.71372366",
"0.7120238",
"0.71148",
"0.7110851",
"0.7100092"
] | 0.7865954 | 30 |
Belwo code takes an array of integers and an additional integer, n, as arguments and returns true if any two elements in the array of integers sum to n. | def sum_to_n?(int_array,n)
# YOUR CODE HERE
return false if int_array.length == 0
int_array.each_with_index{ |val, index|
return true if int_array.find_index(n - val) && int_array.find_index(n - val ) != index
}
return false # default return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to_n?(array, n)\n return false if array.empty? || array.length == 1\n\n array.combination(2).any? { |x, y| x + y == n }\nend",
"def array_sum_to_n?(array, n)\r\n array.combination(2).any?{ |x, y| x + y == n } # For any combination of two elements their sum must be equal to n.\r\nend",
"def sum_to_n?(array,n)\n\n raise 'parameters include non integers' unless \n (array.empty? || array.length == 1 || n.integer? || array.all? { |x| x.integer?})\n\n array.length.times do \n y = array.shift\n if array.any? { |x| x + y == n } \n return true\n end\n end\n return false\nend",
"def sum_to_n?(array,n)\n if array.empty? || array.count == 1\n false\nend\n if array.combination(2).detect {|a,b| a+b ==n}\n true\n end\nend",
"def sum_to_n?(array, n)\n return false if array.length < 2\n\n for i in 0..array.length - 2\n for j in i+1..array.length - 1\n return true if array[i] + array[j] == n\n end\n end\n\n return false\nend",
"def sum_to_n? arr, n\n !!arr.uniq.combination(2).detect { |x, y| x + y == n }\nend",
"def sum_to_n?( arr, n )\n return false if arr.nil? or arr.empty? or arr.length == 1\n arr.each do |first|\n arr.each do |second|\n return true if (first + second == n) and first != second\n end\n end\n false\nend",
"def sum_to_n?(array, n)\n array.product(array).any? {|couple| sum(couple) == n}\nend",
"def sum_to_n? arr, n\n if arr.nil? || arr.empty? || arr.size == 1\n return false\n else \n arr.each {|x| arr.each {|y| return true if x + y == n && x != y}}\n end\n return false\nend",
"def sum_to_n? arr, n\n arr = arr.combination(2).to_a\n arr.any? {|a| a.sum == n} ? true : false\nend",
"def sum_to_n?(array, n)\n\n array_size = array.size\n\n i = 0\n\n while i < array_size do\n argument = array.slice!(0)\n array.each{|x| return true if x + argument == n}\n i += 1\n end\n return false\nend",
"def sum_to_n?(int_array, n)\n return false unless int_array.respond_to?(:combination)\n \n int_array.uniq.combination(2).detect {|arr| sum(arr) == n }\nend",
"def sum_to_n?(array, n)\n if array.empty? and n==0 or (array.size==1 and array[0] == n)\n return true\nend\na=array.combination(2).to_a\na.map! { |row| row.reduce(:+) }\na.each { |e|\n if e==n\n return true\n end }\n false\n end",
"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\nreturn false if arr.empty? || arr.length==1\n\nfor i in 0...arr.length\n for j in 0...arr.length\n if i != j\n return true if arr[i] + arr[j] == n\n end\n end\nend\n\nreturn false\n\nend",
"def sum_to_n? arr, n\n arr = [0] if (arr.nil? || arr.empty?)\n arr.combination(2).any? { |a,b| (a+b) == n }\nend",
"def sum_to_n? arr, n\n return false if arr.empty?\n combinations_found = arr.combination(2).to_a.select { |o| o.inject(:+) == n }\n combinations_found.size > 0\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 sum_to_n?(arr, n)\n return false if arr.empty?\n\n combinations = arr.combination(2).to_a # for [1, 2, 3] return [[1, 2], [1, 3], [2, 3]]\n sums = combinations.map { |combination| combination.reduce(0, :+) }\n\n sums.include? n\nend",
"def sum_to_n?(arr, n)\n return false if arr.empty? or arr.length == 1\n # returns true at first pair that sum to n\n return true if arr.combination(2).find { |x, y| x + y == n }\n # returns true at first pair that sum to n\n return false\nend",
"def sum_to_n?(ints, n)\n\t# ints.each{|first|\n\t# \tints.each{|second|\n\t# \t\treturn true if first + second == n\n\t# \t}\n\t# }\n\t# return false\n\tif ints.empty?\n\t\tints[0,1] = 0,0\n\t\t# return n == 0 ? true : false\n\tend\n\n\tcombinations = ints.combination(2).to_a\n\tcombinations.each{|c|\n\t\treturn true if c[0] + c[1] == n\n\t}\n\treturn false\nend",
"def sum_to_n?(ints, n)\n return n == 0 if ints.size == 0\n (0...ints.size).each_with_index do |i|\n (i+1...ints.size).each do |j|\n return true if (ints[i]+ints[j]==n)\n end\n end\n return false\nend",
"def sum_to_n? arr, n\n return false if arr.empty? or arr.length == 1\n for i in 0...arr.length - 1\n for j in i + 1...arr.length\n if arr[i] + arr[j] == n\n return true\n end\n end\n end\n return false\nend",
"def sum_to_n?(int_array, n)\n return true if int_array.length == 0 && n == 0\n int_array.each_with_index{ |val, index| \n return true if int_array.find_index(n - val) && int_array.find_index(n - val ) != index\n }\n return false # default return false\nend",
"def sum_to_n? arr, n\n return false if arr.empty?#empty to 0\n i=0\n while i < arr.length do#goes throgh all elements\n e = arr.shift#returns the 1st element to e and removes it from array\n arr.each{ |x| return true if x + e == n }#add e and all the remaining elements to see if they add up to n\n i += 1\n end\n false\nend",
"def sum_to_n? arr, n\n arr.each_with_index { |first, i1|\n arr.each_with_index { |sec, i2|\n return true if first + sec == n && i1 != i2\n }\n }\n return false\nend",
"def sum_to_n? arr, n\n match = arr.combination(2).find { |x, y| x + y == n }\n if match\n return true\n else\n return false\n end\nend",
"def sum_to_n? arr, n\n\n if arr.empty? \n sum = false\n elsif arr.count == 1\n \tsum = false\n else\n x = arr.combination(2).each { |s| (s[0] + s[1]) }\n if x.include? n\n sum = true\n else\n sum = false\n end\n end\n\nend",
"def sum_to_n?(arr, n)\n for x in arr\n if arr.include?(n - x)\n return true\n end\n end\n return n==0 && arr.empty?\nend",
"def sum_to_n? (arr, n)\n \n count=false\n \n if !(arr.empty? || arr.length == 1)\n count=!! arr.uniq.combination(2).detect{|a,b| a + b == n} \n end\n \n return count\nend",
"def sum_eq_n?(arr, n)\n if arr == [] && n == 0\n return true\n end\n for i in 0..arr.length-2\n for j in i+1..arr.length-1\n if arr[i] + arr[j] == n\n return true\n end\n end\n end\n return false\nend",
"def sum_to_n?(ar, n)\n return false if ar.empty? or ar.count == 1\n ar.uniq.permutation(2).any? { |a| a.first+a.last == n }\nend",
"def sum_to_n? arr, n\n # Creates an array of every possible pair in arr and finds pair that sums n\n if arr.combination(2).find{|a,b| a + b == n}\n return true\n else\n return false\n end\nend",
"def sum_to_n? arr, n\n result = false\n sum = 0\n if arr.size>1\n arr.each {|num| result = true if num == n}\n end\n \n return result\nend",
"def sum_to_n? arr, n\n #arr.product(arr).any? {|c| sum(c) == n && c[0] != c[1] } ----1.3\n arr = arr.sort\n low = 0\n high = arr.length - 1\n while low < high\n if arr[low] + arr[high] == n\n return true\n end\n arr[low] + arr[high] < n ? low += 1 : high -= 1 \n end\n return false\nend",
"def sum_to_n? arr, n\n # YOUR CODE HERE\n pairs = arr.combination(2).to_a\n \n for p in pairs\n if p.sum == n \n return true\n end\n end\n \n return false\nend",
"def sum_to_n? arr, n\n len = arr.length\n\n #Returns false when the length of the array is 0.\n if len == 0 then\n return false\n end\n #Iterates through the array to find the first index\n i = 0\n while i < len-1 do\n #Iterate through the rest of the elements of the array\n j = i+1\n while j <= len-1 do\n if arr[i]+arr[j] == n then\n return true\n end\n j+=1\n end\n i+=1\n end\n return false\nend",
"def can_be_summed_by_two_abunds?(n, arr)\n i = 0\n while i < arr.length-1\n j = i+1\n while j < arr.length\n if arr[i] + arr[j] == n\n return true\n end\n j+=1\n end\n i+=1\n end\n return false\nend",
"def sum_to_n?(a, n)\n result = false\n\n while a.length > 1\n e1 = a.slice!(0)\n a.each {|e2| e2 + e1 == n ? result = true : break }\n end\n\n result\nend",
"def sum_to_n?(numbers, n)\n\tif numbers.length == 0\n\t\tif n == 0\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\telse\n\t\treturn numbers.permutation(2).any?{|pair| pair.inject(:+) == n}\n\tend\nend",
"def sum_to_n? (int_array, n)\r\n found = false\r\n secondAddendCandidates = []\r\n int_array.each do |num|\r\n # Check if we found the 2nd addend \r\n if secondAddendCandidates.include? num\r\n found = true\r\n break\r\n else\r\n # Key = candidate for the 2nd addend in the sum\r\n secondAddendCandidates << n-num\r\n end\r\n end\r\n\r\n found\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 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_to_n?(array, n)\n # YOUR CODE HERE\n return false if array.empty? or array.length == 1\n\n\th = Hash.new\n\tarray.each{|x| \n\t\tif h.key? x\n\t\t\treturn true\n\t\telse\n\t\t\th[n - x] = n\t\n\t\tend\n\t}\n\treturn false\nend",
"def bad_two_sum?(arr, target_sum)\n arr.size.times do |start|\n (start + 1...arr.size).each do |stop|\n return true if arr[start] + arr[stop] == target_sum\n end\n end\n false\nend",
"def okay_two_sum?(array, target)\n array.sort!\n (1...array.length).each do |idx|\n return true if array[idx-1] + array[idx] == target\n end\n false\nend",
"def bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i + 1..arr.length - 1).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend",
"def bad_two_sum?(arr, target)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n return false\nend",
"def two_sum?(arr, target_sum)\n (0...arr.length).each do |i|\n (0...arr.length).each do |j|\n next if i == j\n return true if arr[i] + arr[j] == target_sum\n end\n end\n\n false\nend",
"def okay_two_sum?(arr, target) # => [0,1,5,7] \n sorted = qs(arr)\n\n (0...sorted.length-1).each do |i|\n return true if sorted[i] + sorted[i + 1] == target\n end\n\n false\nend",
"def bad_two_sum?(arr, target)\n (0...arr.length).each do |idx1|\n return true if arr[idx1] == target\n (idx1+1...arr.length).each do |idx2|\n return true if (arr[idx1] + arr[idx2]) == target\n end\n end\n false\nend",
"def okay_two_sum?(arr, target)\n # arr.sort.bsearch(target)\n # arr.combination(2).any? { |el,el2| return true if el + el2 == target }\n\n sorted = arr.sort\n (0...sorted.lentgh-1).each do |i|\n if arr[i] + arr[i+1] == target \n return true \n end \n end \nend",
"def bad_two_sum?(arr, target)\n (0...(arr.length - 1)).each do |idx1|\n ((idx1 + 1)...arr.length).each do |idx2|\n return true if arr[idx1] + arr[idx2] == target\n end\n end\n false\nend",
"def is_sum_of_any_two(target, numbers)\n for index1 in 0...numbers.length - 1\n for index2 in index1 + 1...numbers.length\n if (numbers[index1] + numbers[index2]) == target\n return true\n end\n end\n end\n false\nend",
"def exactly?(arr, n, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == n\nend",
"def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |o_el, o_idx|\n arr.each_with_index do |i_el, i_idx|\n next if o_idx == i_idx\n return true if o_el + i_el == target_sum\n end\n end\n false\nend",
"def sum_to_n (arr, n) \n\n if arr.length == 1 or arr.empty?\n \tfalse\n\n else\n \tarr.each do |el|\n \t\tnumber = el\n \t\tfor i in el...arr.length do\n \t\t\tif arr[i] + number == n\n \t\t\t\tputs \"in the loop\"\n \t\t\telse\n \t\t\t\tputs \"else\"\n \t\t\tend\n \t\tend\n \tend\n\n end\n\nend",
"def okay_two_sum?(arr, target_sum)\n\narr.sort!\n\nreturn false if arr[-1] < target_sum\n\ni = 0\ni += 1 until arr[i] > target_sum\n\nresult = []\nnew_arr = arr[0...i]\n(0...new_arr.length - 1).each do |i|\n (i+1...new_arr.length).each do |j|\n result << new_arr[i] + new_arr[j]\n end\n end\n result.include?(target_sum)\n\nend",
"def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend",
"def bad_two_sum?(arr, target_sum)\n arr.length.times do |i|\n (arr.length - i - 1).times do |j|\n return true if arr[i] + arr[j + i + 1] == target_sum\n end\n end\n false\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 exactly?(arr, n , &prc)\n count = 0\n arr.each do |ele|\n count += 1 if prc.call(ele)\n end\n return true if n == count\n false\nend",
"def okay_two_sum?(arr, target_sum)\n sorted_arr = arr.sort\n (0...sorted_arr.length).each do |i|\n next if i+1 == sorted_arr.length\n return true if sorted_arr[i] + sorted_arr[i+1] == target_sum\n end\n\n return false\nend",
"def okay_two_sum?(arr, target)\n \n\nend",
"def at_least?(arr, n, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count >= n\nend",
"def okay_two_sum?(arr, target_sum)\n sorted_arr = quick_sort(arr)\n (0...sorted_arr.length - 1).each do |i|\n return true if sorted_arr[i] + sorted_arr[i + 1] == target_sum\n end\n false\nend",
"def okay_two_sum?(arr, target_sum)\n array = arr.sort #n log n\n i1 = 0\n i2 = array.length-1\n while i1 < i2\n case array[i1] + array[i2] <=> target_sum\n when 0\n return true\n when -1\n i1 += 1\n when 1\n i2 -= 1\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum)\r\n arr.each_with_index do |ele1, i1|\r\n arr.each_with_index do |ele2, i2|\r\n return true if i2 != i1 && (ele1 + ele2 == target_sum)\r\n end\r\n end\r\n\r\n false\r\nend",
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1,idx1|\n i = idx1 + 1\n while i < arr.length\n return true if num1 + arr[i] == target\n i+=1\n end\n end\n false\nend",
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum) \n arr.each_with_index do |num, idx|\n arr.each_with_index do |num2, idx2|\n next if idx2 == idx\n return true if num2 + num == target_sum\n end\n end\n false\nend",
"def sum_checker(array)\n# Check if the array contains at least 2 elements\n if array.length < 2\n false\n else\n# Iterate over the array to check if the array has a -num (num and -num add up to zero)\n array.each do |num|\n return true if array.include?(-num)\n end\n end\n false\nend",
"def okay_two_sum?(arr, target)\n arr.sort!\n pairs = arr.combination(2)\n pairs.any? { |pair| pair.sum == target }\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 bad_two_sum?(arr, target_sum)\n arr.each_with_index do |ele1, idx1|\n arr.each_with_index do |ele2,idx2|\n if idx2 > idx1 && arr[idx1] + arr[idx2] == target_sum\n return true\n end\n end\n end\n false\nend",
"def okay_two_sum?(arr, target)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend",
"def at_least?(arr, n, &prc)\n count = 0\n arr.each do |ele|\n count += 1 if prc.call(ele) \n end\n return true if count >= n\n false\nend",
"def bad_two_sum?(arr, target)\n sums = []\n arr.each_index do |i|\n (i+1...arr.length).each do |j|\n sums << arr[i] + arr[j]\n end\n end\n sums.include?(target)\nend",
"def bad_two_sum?(array, target)\n array.each.with_index do |el1, idx1|\n array.each.with_index do |el2, idx2|\n if el1 + el2 == target && idx2 > idx1\n return true \n end\n end\n end\n false \nend",
"def sum_to_n? arr, n\n if arr.length == 1\n return false\n end\n \n #sort arr and find head and tail indices\n sorted_arr = arr.sort\n head = 0\n tail = sorted_arr.length-1\n \n #iterating through arr to find the sum that equals n\n while head < tail\n current_sum = sorted_arr[head] + sorted_arr[tail]\n if current_sum == n\n return true\n elsif current_sum < n\n head = head + 1\n else\n tail = tail - 1\n end\n end\n return false\nend",
"def two_sum_to_zero?(array)\nend",
"def two_sum(array, target)\n arr_a = array.pop()\n var = false \n array.each { |x| \n return true if arr_a + x == target\n }\n return false \nend",
"def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend",
"def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |num1, i|\n arr[i..-1].each do |num2|\n next if num1 == num2\n\n return true if (num1 + num2) == target_sum\n end\n end\n\n false\nend",
"def nums(target, *array)\n\tarray.each_with_index do |a, x|\n\t\tarray.each_with_index do |b, y|\n\t\t\tif x > y\n\t\t\t\tif a + b == target\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn false\nend",
"def okay_two_sum?(arr, target_sum)\n arr.sort!\n i, j = 0, arr.length - 1\n\n until i == j\n this_sum = arr[i] + arr[j]\n return true if this_sum == target_sum\n this_sum < target_sum ? i += 1 : j -= 1\n end\n\n false\nend",
"def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n (0...sorted.length).each do |i|\n (i + 1...sorted.length).each do |j|\n return true if sorted[i] + sorted[j] == target_sum\n break if sorted[i] + sorted[j] > target_sum\n end\n end\n false\nend",
"def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend",
"def okay_two_sum?(arr, target)\n i = 0\n j = arr.length - 1\n\n while i < j\n if arr[i] + arr[j] == target\n return true\n elsif arr[i] + arr[j] < target\n i += 1\n else\n j -= 1\n end \n end\n false\nend",
"def okay_two_sum?(array,target_sum)\n array_sorted = array.sort\n i = 0\n j = array.length - 1\n\n until i == j\n sum = array_sorted[i] + array_sorted[j]\n return true if sum == target_sum\n if sum < target_sum\n i += 1\n elsif sum > target_sum\n j -= 1\n end\n end\n false\nend",
"def two_sum?(array, target_sum)\n array_hash = {}\n array.each do |el|\n array_hash[el] = true\n end\n\n array.each_with_index do |el|\n next if target_sum - el == el\n return true if array_hash[target_sum - el]\n end\n false\nend",
"def sum_to_n?(array, num)\n return false if array.length < 2\n hash = Hash.new\n array.each do |val|\n if hash.key? val\n return true\n else \n hash[num-val] = val\n end\n end\n return false\nend",
"def two_sum(arr)\n \n found = false\n arr.each do |e|\n found = true if arr.any?{|x| e+x == 0}\n end\n found\n \nend",
"def okay_two_sum?(arr, target)\n arr.sort!\n\n arr.select! { |el| el < target }\n\n arr.each { |el| arr.include?(target - el) ? (return true) : next }\n false\nend",
"def arr_sum(arr, target)\n 0.upto(arr.size - 2) do |idx1|\n 1.upto(arr.size - 1) do |idx2|\n return true if arr[idx1] + arr[idx2] == target && idx2 > idx1\n end\n end\n false\nend",
"def bad_sum?(arr, target)\n\n (0...arr.length).each do |idx|\n (idx + 1...arr.length).each do |jdx|\n return true if arr[idx] + arr[jdx] == target\n end\n end\n false\nend",
"def a_sum?(num, game_array)\n\tarray_of_sums = []\n\tarray_of_sums << game_array[0]\n\n\tgame_array.each_index do |i|\n\t\tgame_array.each_index do |j|\n\t\t\tunless i == j\n\t\t\t\tarray_of_sums << game_array[i] + game_array[j]\n\t\t\tend\n\t\tend\n\tend\n\tif ([num] & array_of_sums).length > 0\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def okay_two_sum?(arr, target_sum)\n i = 0 \n j = arr.length - 1 \n arr = arr.sort \n\n while i < j \n if arr[i] + arr[j] == target_sum \n return true \n elsif arr[i] + arr[j] > target_sum\n j -= 1 \n else \n i += 1 \n end\n end\n false \nend"
] | [
"0.8592546",
"0.85841346",
"0.8521152",
"0.8400378",
"0.83924204",
"0.8335459",
"0.8320183",
"0.8266337",
"0.8250457",
"0.8237341",
"0.8197147",
"0.81915534",
"0.81590706",
"0.8119986",
"0.81177366",
"0.8112718",
"0.8087066",
"0.80859077",
"0.8079516",
"0.80459446",
"0.80435205",
"0.80133694",
"0.8003765",
"0.79988337",
"0.79966635",
"0.7994505",
"0.7986769",
"0.797316",
"0.7972905",
"0.7963298",
"0.7957802",
"0.79557097",
"0.7926206",
"0.79253167",
"0.79069746",
"0.7867457",
"0.7830638",
"0.7818821",
"0.7787393",
"0.77727115",
"0.77428764",
"0.7681817",
"0.76508665",
"0.753459",
"0.74103034",
"0.73913187",
"0.73735064",
"0.73690385",
"0.7357708",
"0.7355381",
"0.73161644",
"0.72944856",
"0.7293664",
"0.7290524",
"0.7278271",
"0.7277603",
"0.72753924",
"0.72645944",
"0.7253736",
"0.7250509",
"0.7207519",
"0.7178243",
"0.7165796",
"0.7165017",
"0.7162009",
"0.715872",
"0.71471965",
"0.7125777",
"0.71217954",
"0.7117899",
"0.71128625",
"0.7109733",
"0.7108163",
"0.7104033",
"0.7103074",
"0.7097845",
"0.7073552",
"0.7065234",
"0.70572275",
"0.70426923",
"0.7031752",
"0.7028262",
"0.70180637",
"0.7013917",
"0.70067966",
"0.70057875",
"0.6996791",
"0.6992813",
"0.6992043",
"0.6990377",
"0.69838476",
"0.69832253",
"0.697379",
"0.69715905",
"0.6965776",
"0.69645256",
"0.6960888",
"0.6959476",
"0.69557476",
"0.6955562"
] | 0.7873853 | 35 |
Part 2 Below code takes a string representing a name and returns the string "Hello, " concatenated with the name. | def hello(name)
# YOUR CODE HERE
"Hello, #{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hello(name)\n \"Hello, \".concat(name)\nend",
"def hello(name)\n\ts = \"Hello, \" + name\n\treturn s\nend",
"def hello(name)\n \n str = \"Hello, #{name}\"\n return str \n \nend",
"def hello(name)\n str1 = name\n str2 = \"Hello, \"\n str2.concat(str1)\nend",
"def name(name)\n return \"Hello, #{name}!\"\nend",
"def greeting(name)\n name = name.strip\n puts \"`Hello #{name}. It's nice to meet you.`\"\nend",
"def hello(name)\n # YOUR CODE HERE\n response = \"Hello, \".concat(name)\n \n return response\nend",
"def greeting(name)\n if name[-1] == '!'\n name.chop!\n return \"HELLO #{name.upcase}. WHY ARE WE SCREAMING?\"\n else\n return \"Hello #{name}.\"\n end\nend",
"def say_hello(name)\r\n\tputs \"Hello #{name}!\"\r\n\t#don't need #{name.to_s}!\" because it knows it needs to convert it to a string\r\nend",
"def hello(name)\n\tif name == \"John\"\n\t\t\"Hello #{name}!\"\n\telsif name == \"Kevin\"\n\t\t\"Hey there #{name}!\"\n\telse\n\t\t\"I don't know you!\"\n\tend\nend",
"def hello(name)\n\t\"Hello, \" + name\nend",
"def say_hello\n return \"hello I am #{@name}\"\n end",
"def say_hello\n \"Hello #{@name}\"\n end",
"def say_hello(name)\n \"Hello, #{name}.\"\n end",
"def say_name\n \"My name is #{@name}\"\n end",
"def hello1(name)\n 'Hello ' + name \nend",
"def greet(name)\n \"Hello #{name.capitalize}!\"\nend",
"def greet(name)\n \"Hello #{name.capitalize}!\"\nend",
"def hello1(name)\n 'Hello ' + name\nend",
"def hello1(name)\n 'Hello ' + name\nend",
"def hello2 name2\n 'good day ' + name2\nend",
"def hello(name) \n\t\"hello #{name}\"\nend",
"def sayHello(name)\n result = \"Hello, \" + name + \"!\"\n return result\nend",
"def hello1 (name)\n 'Hello ' + name\nend",
"def hello(name) #\n \"Hello, #{name}!\" #\nend",
"def sayGoodnightTo(name)\n result = \"Goodnight, #{name}!\"\nend",
"def say_hello(name)\n \"Hi #{name}!\"\nend",
"def say_hello(name,city,state)\n new_name = name.map {|x| x.capitalize}.join(' ')\n \"Hello, #{new_name}! Welcome to #{city.capitalize}, #{state.capitalize}!\"\nend",
"def hello(name)\n return \"Hello, \" + name.to_s\nend",
"def hello(name)\n return \"Hello, \" + name.to_s\nend",
"def hello1(name)\n 'halo ' + name\nend",
"def shout_name\n puts \"What is your name?\"\n name = gets.chomp\n\n message = \"Hello #{name}\"\n\n if name[-1] == '!'\n puts \"#{message} Why are we screaming?\".upcase\n else\n puts message + \".\"\n end\nend",
"def hello(name)\n return 'Hello, ' + name\nend",
"def say_hi(name)\n result = \"Hey Hi, #{name}\"\n return result\nend",
"def say_hello(name)\n return \"Hi, #{name}. Have a good day.\"\nend",
"def greeter(name)\n return \"hello \" + name + \" its nice to see you.\"\nend",
"def hello(name)\n # YOUR CODE HERE\n output_string = \"Hello, \"+name\n return output_string\nend",
"def greet(name)\n\t\"Hello, #{name}!\"\nend",
"def say_hi(name)\n return \"Bonjour #{name.capitalize}.\"\n # string\nend",
"def say_goodnight(name)\n result = \"Good night, \" + name.capitalize\n return result\nend",
"def hello(name)\n hello = \"Hello, \" + name;\n return hello\nend",
"def say_goodnight(name)\r\n \"Dobranoc #{ name.capitalize }\"\r\nend",
"def sayHello(name)\n result = \"Hello \" + name + \"!\"\n # Using the \", the sequence #{expression} is replaced by the value of expression.\n result = \"Hello #{name}!\"\n return result\n#since the value returned by a ruby method is the value of the last expression evaluated, we can get rid of the return statement altogether.\n \"Hello #{name}!\"\nend",
"def hello2 name2\n 'Hello ' + name2\nend",
"def hello2 name2\n 'Hello ' + name2\nend",
"def say_hello(name)\n var = \"Hello, \" + name\n return var\nend",
"def hello2 (name2)\n 'Hello ' + name2\nend",
"def yell_greeting(string)\n name = string\n name = name.downcase\n greeting = \"WASSAP, #{name}!\"\nend",
"def say_hello(name)\n return \"Hello, \" + name\nend",
"def greetings(name)\n puts \"Hello #{name.capitalize}\"\nend",
"def greet(name)\n greeting = \"Hello #{bob}!\"\n return greeting\nend",
"def say_hello(name)\n \"Hello, \" + name\nend",
"def sayGoodnight(name)\n result = \"Goodnight, #{name}\" \n # return result\nend",
"def goodbye(name)\n\tstr = \"Bye \" + name + \".\"\n return str\nend",
"def helloPerson(name)\n puts \"hello #{name.capitalize}!\"\nend",
"def hello (name)\n return \"Hello, \" + name\nend",
"def say_hello name1=\"Oscar\", name2=\"Shane\"\n \"hello, #{name1} and #{name2}\"\nend",
"def say_hello_personal(name)\n\tputs \"Hello \" + name\nend",
"def say_hello(name=\"Ruby Programmer\")\n puts \"Hello #{name}!\"\nend",
"def introduce_yourself\n \"Hi, my name is #{name} and I am the boss. YAY!\"\n end",
"def get_name\n return \"#{name}\"\n end",
"def greet(name)\n result = \"Good night #{name}\"\n return result\nend",
"def say_name\n puts \"#{name}\"\n end",
"def string_concat(name_1, name_2)\n puts \"I went to the concert with \" +name_1 + \" and \" + name_2 + \".\"\nend",
"def say_hello name1=\"oscar\", name2=\"shane\"\n\t\"hello, #{name1} and #{name2}\"\nend",
"def print_name(name)\n puts \"Hello #{name}.\"\nend",
"def say_hello(name, city, state)\n 'Hello, ' + name.join(' ') + \"#{name.length != 0 ? '! Welcome' : 'Welcome'}\" + ' to ' + city + ', ' + state + '!'\nend",
"def hello(name)\n return \"Hello, \"+name\nend",
"def say_hello(name, city, state)\n return 'Hello,' + name.join(' ') + '! Welcome to ' + city + ', ' + state + '!'\nend",
"def say_name\n p \"#{name}\"\n end",
"def greetings(name, info)\n full_name = name.join(' ')\n puts \"Hello, #{full_name}! Nice to have a #{info[:title]} #{info[:occupation]} around.\"\nend",
"def hello name\n \"Hello, \" + name\nend",
"def hello name\n \"Hello, \" + name\nend",
"def hello name\n \"Hello, \" + name\nend",
"def hello name\n \"Hello, \" + name\nend",
"def say_hello\n \"Quack! I'm a duck called #{ @name }\"\n end",
"def hello(name)\n \"Hello #{name}\"\nend",
"def hello2 name2 \r\n 'Hello ' + name2 \r\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, #{name}\"\nend",
"def hello(name)\n \"Hello, \" << name\nend",
"def say_hello_3 name1=\"Bill\", name2=\"Ted\"\n \"hello, #{name1} and #{name2}\"\nend",
"def name\n \"Lord Admiral #{@name}\"\n end",
"def say_hello name\n \"Hello, #{name}!\"\nend",
"def name(namei)\n return \"hola \" + namei + \" Welcome\"#namei->name input\nend",
"def name_str\n if name?\n ' '+name\n else\n ''\n end\n end",
"def say_hello name\n return \"Hello, #{name}!\"\nend",
"def greeting(name)\n \"Hello #{name.capitalize}!\"\nend",
"def say_hello(name, city, state)\n \"Hello, %s! Welcome to %s, %s!\" % [name.join(\" \"), city, state]\nend",
"def greeting(name)\n \"Hello \" + name.capitalize + \"!\"\nend",
"def say_hello(name)\n puts \"Hello, #{name}!\"\n end",
"def greeter (name)\n return \"Hello #{name}\"\n end"
] | [
"0.7989296",
"0.79874384",
"0.78154844",
"0.7744972",
"0.76759094",
"0.75783575",
"0.7567679",
"0.7525287",
"0.7521374",
"0.7491182",
"0.74480134",
"0.7436089",
"0.7417998",
"0.7399628",
"0.7386105",
"0.73432976",
"0.73335195",
"0.73335195",
"0.73268956",
"0.73268956",
"0.73242813",
"0.73241156",
"0.73238206",
"0.731216",
"0.7298483",
"0.7293413",
"0.72624457",
"0.72594744",
"0.72566533",
"0.72566533",
"0.7256297",
"0.7246138",
"0.72381306",
"0.72211516",
"0.720489",
"0.7198044",
"0.71966916",
"0.7193176",
"0.7187996",
"0.7168073",
"0.7168031",
"0.7167356",
"0.7163547",
"0.7154636",
"0.71528643",
"0.71505785",
"0.7146839",
"0.71316344",
"0.7130905",
"0.7122862",
"0.7117026",
"0.7108903",
"0.7106586",
"0.71055156",
"0.7101951",
"0.70904225",
"0.7083841",
"0.7082614",
"0.70718294",
"0.70580846",
"0.70548475",
"0.7053211",
"0.70523995",
"0.7045839",
"0.704273",
"0.7037608",
"0.70326024",
"0.702384",
"0.70172644",
"0.70162773",
"0.7015661",
"0.7015376",
"0.7015376",
"0.7015376",
"0.7015376",
"0.700358",
"0.7000927",
"0.70008665",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.69977194",
"0.6993892",
"0.6989777",
"0.6984981",
"0.6977851",
"0.6975098",
"0.69743824",
"0.6968635",
"0.6966154",
"0.69573885",
"0.6950714",
"0.69488",
"0.6941432"
] | 0.0 | -1 |
Below code takes a string and returns true if it starts with a consonant and false otherwise. | def starts_with_consonant?(s)
# YOUR CODE HERE
!!(s[0] =~ /[qzyxwvtsrbcdfghjklmnp]+/i)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def starts_with_consonant? s\n return false if s == ''\n return false if !s[0].match(/^[[:alpha:]]$/)\n s[0] =~ /[AaEeIiOoUu]/ ? false : true\nend",
"def starts_with_consonant? s\n return false if s.empty?\n s.downcase!\n if s[0].match(/\\A[bcdfghjklmnpqrstvwxyz]/)\n return true\n else\n false\n end\nend",
"def starts_with_consonant? s\n !!(s[0] =~ /[bcdfghjklmnpqrstvwxyz]+/i)\nend",
"def starts_with_consonant? s\n !!(s[0] =~ /[bcdfghjklmnprstvwxyz]+/i)\nend",
"def starts_with_consonant? s\n !!(s[0] =~ /[bcdfghjklmnprstvwxyz]+/i)\nend",
"def starts_with_consonant? s\n return false if s.empty?\n consonant = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'\n consonant.each_char{|c|\n return true if s.start_with?(c)\n }\n false\nend",
"def starts_with_consonant? s\n return false if s.empty?\n consonant = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'\n consonant.each_char{|c|\n return true if s.start_with?(c)\n }\n false\nend",
"def starts_with_consonant?(s)\n return false if s.empty?\n %Q{b c d f g h j k l m q r s t v w x y z}.include? s[0].downcase\nend",
"def starts_with_consonant?(s)\r\n !!(s[0] =~ /[bcdfghjklmnprstvwxyz]+/i)\r\nend",
"def starts_with_consonant? s\n # If empty, return false\n if s.size == 0\n return false\n end\n # Check if first character matches a consonant\n if s[0].match(/[[a-zA-Z]&&[^aeiouAEIOU]]/)\n return true\n else\n return false\n end\nend",
"def starts_with_consonant? s\n (s[0] =~ /[bcdfghjklmnprstvwxyz]+/i) != nil\nend",
"def starts_with_consonant?(s)\n s.downcase!\n if (s =~ /\\A[b-df-hj-np-tv-z]/) == 0 \n return true\n else\n return false\n end\nend",
"def starts_with_consonant? s\n cond1 = /[[:alpha:]]/ =~ s\n cond2 = /[^aeiouAEIOU]/ =~ s\n if cond1 != 0 \n return false\n else\n if cond2 == 0\n return true\n else\n return false\n end\n end\n return false\nend",
"def starts_with_consonant? str\n\treturn (str =~ /\\A(?=[^aeiou])(?=[a-z])/i) == 0 ? true : false\nend",
"def starts_with_consonant? s\n return false if s.empty?\n return true if s[0] =~ /[^\\Waeiou]/i\n return false\nend",
"def starts_with_consonant?(s)\n\tif s.downcase =~ /\\A(?=[^aeiou])(?=[a-z])/i\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend",
"def starts_with_consonant? s\n # YOUR CODE HERE\n if s.start_with?(/[b-df-hj-np-tv-z]/i) \n return true\n end\n \n return false\nend",
"def starts_with_consonant?(s)\n\n return false if s.empty?\n s.downcase!\n s[0].match(/\\b([bcdfghjklmnprstvwxyz])+/) ? true : false\n\nend",
"def starts_with_consonant? s\n first = s[0,1].downcase\n vowels = ['a', 'e', 'i', 'o', 'u']\n \n if vowels.include?(first)\n return false\n end\n if first =~ /[[:alpha:]]/\n return true\n end\nend",
"def starts_with_consonant?(s)\n first_symbol = s[0]\n return false if first_symbol.nil?\n\n if %w(a e i o u A E I O U).include? first_symbol\n false # vowels\n elsif ('a'..'z').include? first_symbol.downcase\n true #consolants\n else\n false #nonletters\n end\nend",
"def starts_with_consonant?(s)\n !!(s =~ /^[A-Z&&[^AEIOU]]/i)\nend",
"def starts_with_consonant? s\n #Uses regular expression to check if the string starts with a consonant\n if /\\A(?=[^aeiou])(?=[a-z])/i.match(s)!=nil then\n return true\n end\n return false\nend",
"def starts_with_consonant?(s)\n s.match(/^[b-z&&[^eiou]]/i) != nil\nend",
"def starts_with_consonant?(s)\n !!(s =~ /\\A[^aeiou\\W].*/i)\nend",
"def starts_with_consonant? s\n s !~ /^[AEIOU]/i && s =~ /^\\w/i\nend",
"def starts_with_consonant? s\n !!(s[0] =~ /[^aeiou\\W]/i)\nend",
"def starts_with_consonant?(s)\n return /(?=^[^aiueo_\\d])(?=\\w)/i.match(s) ? true : false \nend",
"def starts_with_consonant? (s)\n start = false\n if ((s =~ /\\A(?=[^aeiou])(?=[a-z])/i) == 0)\n start = true\n end\n return start\nend",
"def starts_with_consonant?(s)\n if s.empty?\n return false\n elsif ( /[a-z]/ =~ s[0].downcase && /[^aeiou]/ =~ s[0].downcase)\n return true\n elsif ( /[A-Z]/ =~ s[0].upcase && /[^AEIOU]/ =~ s[0].upcase)\n return true\n else\n return false\n end\nend",
"def starts_with_consonant?(s)\n consonant = /^[^aeiou\\d\\W_]/i\n return true if consonant.match(s)\nend",
"def starts_with_consonant? s\n if s.empty?\n return false\n else\n stopwords = 'AEIOUaeiou0123456789$*~&!@#$%^()-=+/\\?,.'\n stopwords.each_char{|c|\n return false if s.start_with?(c)\n }\n end\n true\nend",
"def starts_with_consonant? s\n s =~ /\\A(?=[^aeiou])(?=[a-z])/i\nend",
"def starts_with_consonant?(s)\n # YOUR CODE HERE\n /^[b-df-hj-np-tv-z]/i.match(s) != nil\nend",
"def starts_with_consonant? s\n\n s[0] =~ /[^aeiou\\W]/i\n \nend",
"def starts_with_consonant?(s)\n (/(?=[a-z]+)(?=^([^aeiou]))/i =~ s) == 0\nend",
"def starts_with_consonant? s\n s_lower=s.downcase\n if /^[a-z&&[^aeiou]]/.match(s_lower) \n return true\n else \n return false\n end\nend",
"def starts_with_consonant?(s)\n # if s.empty?\n \n \n # psj :: !! it's easier to evaluate an array of vowels using #includes? than understand your regular expression\n # vh: agreed but was not passing test on special characters ex. /&%$# \n # this expression works too (s =~ /^(?=[^aeiou])(?=a-z)/i )==0\n # you had it something like this: , so we can add\n # BP : What I noticed on this is that the original way it was written,\n # any tests with numbers or special characters were returning true. ..and emptys and ints threw errors.\n # the other option could be to just test the consonants instead of vowels.. but that isn't very elegent \n vowels = %w(a e i o u)\n consonant =(\"a\"..\"z\").find_all { |letter| !vowels.include? letter}\n #consonant = (\"a\"..\"z\").collect { |letter| !vowels.include? letter}\n if s.is_a?(String) && !s.empty?\n return consonant.include? s[0].downcase\n\n else\n return false\n end\n \n \nend",
"def starts_with_consonant? s\n s =~ /^[^aeiou\\W]/i\nend",
"def starts_with_consonant?(s)\n regex = /^[AEIOU]/i\n regex2 = /^[BCDFGHJKLMNPQRSTVWXYZ]/i\n (s =~ regex2) != nil\n # regex2 = /^[BCDFGHJKLMNPQRSTVWXYZ]/i\n # if regex2.match(s) == nil\n # \tfalse\n # else true\n # end\nend",
"def starts_with_consonant? s\n /^[a-zA-Z&&[^aeiouAEIOU]]/.match s\nend",
"def starts_with_consonant? s\n # if /^[^aeiou\\W]/i.match(s) == nil then false else true end\n /^[^aeiou\\W]/i.match(s)==nil ? false : true\n # !%w(a e i o u).include? s[0].downcase unless s.empty? or /^\\W/.match(s)\n \nend",
"def starts_with_consonant? s\n if /^[^aeiouAEIOU\\W]/.match(s) == nil\n return false\n else\n return true\n end\nend",
"def consonants # :nodoc:\n /^(y|[bcdfghjklmnprstvwxz]+|qu)/\n end",
"def isConsonant letter\n\tvowels = ['a', 'e', 'i', 'o', 'u']\n\treturn !(vowels.include?(letter))\nend",
"def consonant?\n self != 'ㅇ' && kor.chosung?(self)\n end",
"def double_consonants(string)\n doubled_string = ''\n string.chars.each do |char|\n doubled_string << char\n doubled_string << char if consonant?(char.downcase)\n end\n\n doubled_string\nend",
"def starts_with(string, character)\n return string[0] == character\nend",
"def next_consonant(char)\n char = char.downcase\n compare = \"bcdfghjklmnpqrstvwxyz\"\n\n # not a consonant, i.e., no instance of the variable\n if compare.count(char) == 0\n # puts \"Not a consonant\"\n return nil\n end\n\n consonant_index = compare.index(char)\n\n if consonant_index == compare.length - 1 # end edge case\n return 'b'\n else\n return compare[consonant_index + 1]\n end\nend",
"def start_codon?(codon)\n @start.include?(codon.downcase)\n end",
"def double_consonants(string)\n consonants = %(bcdfghjklmnpqrstvwxyz)\n string.chars.map{ |char| consonants.include?(char.downcase)? char * 2 : char}.join\nend",
"def str_start_with (orig_string, little_string)\n return !orig_string.match(/\\A#{Regexp.escape(little_string)}/).nil?\nend",
"def double_consonants(string)\n result = ''\n string.chars.each do |char|\n result += char\n result += char if char =~ /[a-z]/i && char =~ /[^aeiou]/i\n end\n result\nend",
"def starts_with?(s)\n index(s) == 0\n end",
"def Starts_whit(string1,character)\n return string1[0] == character\nend",
"def double_consonants(string)\n result_string = ''\n string.each_char do |letter|\n (letter =~ /[b-df-hj-np-tv-z]/i) == 0 ? result_string << letter << letter : result_string << letter\n end\n result_string\nend",
"def double_consonants(string)\n result_string = ''\n string.each_char do |char|\n if char =~ /[a-z&&[^aeiou]]/i\n result_string << char << char\n else\n result_string << char\n end\n end\n result_string\nend",
"def begins_with?(s)\n index(s) == 0\n end",
"def count_consonants(str)\n str.chars.map do |letter|\n if consonant? letter\n letter = 1\n else\n letter = 0\n end\n end.reduce(0, :+)\nend",
"def double_consonants(string)\n doubled_string = ''\n string.each_char do |char|\n char.match(/[a-z&&[^aeiou]]/i) ? doubled_string << char << char : doubled_string << char\n end\n doubled_string\nend",
"def double_consonants(str)\n str.split(//).map { |chr| chr.match?(/[^aeiou\\d\\W]/i) ? chr + chr : chr }.join\nend",
"def double_consonants(str)\n str.gsub(/([a-z&&[^aeiou]])/i,'\\1\\1')\nend",
"def custom_start_with?(string, substring)\n array_of_strings = string.split(\" \")\n array_of_strings.first == substring ? true : false\nend",
"def starts_with_a_vowel?(word)\n word.scan(/\\b[aeiou]/i) == true\nend",
"def double_consonants(str)\n new_str = ''\n str.each_char do |char|\n if char =~ /[-!aeiou0-9' ']/i\n new_str << char\n else\n new_str << char.concat(char)\n end\n end\n new_str\nend",
"def double_consonants(string)\n new_string = ''\n string.each_char do |char|\n if char =~ /[a-z]/i && char =~ /[^aeiou]/i\n new_string << char << char\n else\n new_string << char\n end\n end\n new_string\nend",
"def double_consonants(string)\n string.gsub(/([b-df-hj-np-tv-z])/i, '\\1\\1')\nend",
"def double_consonants(str)\n str.gsub(/([bcdfghjklmnpqrstvwxyz])/i, '\\1\\1')\nend",
"def double_consonants(string)\n output = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n if char.match(/[[a-z]&&[^aeiou]]/i)\n output << char * 2\n else\n output << char \n end\n end\n output\nend",
"def starts_with_vowel?(str)\n @str= str.capitalize\n (@str[0] == 'A' or @str[0] == 'E' or @str[0] == 'I' or @str[0] == 'O' or @str[0] == 'U') ? true : false\nend",
"def double_consonants(string)\n double_con_string = []\n string.chars.each do |char|\n if char.match?(/[aeiouAEIOU]/)\n double_con_string << char\n elsif char.match?(/[a-zA-Z]/)\n double_con_string << char << char\n else\n double_con_string << char\n end\n end\n double_con_string.join\nend",
"def double_consonants(str)\nnew_str = \"\"\n\nstr.each_char do |char|\n\tif /[aeiou\\W\\d\\s]/ =~ char \n\t\tnew_str << char\n\telse\n\t\tnew_str << char << char\n\tend\nend\nnew_str\nend",
"def starts_with_a_vowel?(word)\n word.match(/\\b[AEIOUaeiou][a-z]*\\b/)? (true) : (false)\nend",
"def double_consonants(str)\n results = \"\"\n str.each_char do |char| \n if char.downcase =~ /[a-z&&[^aeiou]]/\n results << char * 2 \n else\n results << char\n end\n end\n results\nend",
"def custom_start(string, substring)\n string_char = string.chars\n sub_char = substring.chars\n bool = true\n sub_char.each_with_index do |element, index|\n if element == string_char[index]\n bool = true\n else\n bool = false\n break\n end\n end\n\n p bool\nend",
"def starts_with_a_vowel?(word)\n word.match(/^[aeiouAEIOU]/) ? true : false\nend",
"def double_consonants(string)\n doubled_chars = string.chars.map do |char|\n if char =~ /[A-Za-z]/ && !VOWELS.include?(char)\n char + char\n else\n char\n end\n end\n doubled_chars.join\nend",
"def starts_with_a_vowel?(word)\n word.match(/^[aeiouAEIOU]/) ? true : false\nend",
"def next_consonant(string)\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\t#set index of string \n\tindex = 0\n\t#set index of vowels\n\ti = 0\n\t#create an empty string\n\tconverted_string = \"\"\n\t#for each index of the string, checks if equal to corresponding consonant and if so goes to the next consonant by adding one to the index\n\twhile index < string.length\n\t\t#start with if string has \"z\", converts to \"b\"\n\t\tif string[index] == consonants[20]\n\t\t\tconverted_string += \"b\"\n\t\t#if the string has any consonant besides \"z\"\n\t\telsif string[index] == consonants[i]\n\t\t\tconverted_string += consonants[i+1]\n\t\t#if string has vowels doesnt change character\n\t\telse \n\t\t\tconverted_string += string[index]\n\t\tend\n\t\t#go to next index in string\n\t\tindex += 1\n\t\t#reset vowel index to zero\n\t\ti += 1\n\tend\n\tconverted_string\nend",
"def starts_with_a_vowel?(word)\n word.match(/^[aeiouAEIOU]\\w+/) ? true : false #beginning of string is a lower or upper vowel with at least one or many word characters\nend",
"def double_consonants(string)\n results = []\n\n string.chars.each do |char|\n if char =~ /[\"AEIOUaeiou\"]/ || \n char =~ /\\W/ ||\n char =~ /\\d/\n results << char\n else\n results << char << char\n end\n end\n\n results.join\nend",
"def conj?\n words.any? { |wor| wor.pos == 'CONJ' }\n end",
"def consonant(letter)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\talphabet2 = alphabet.chars.rotate.join('')\n\teach_id = alphabet.index(letter.downcase)\n\tnext_consonant = alphabet2[each_id]\nend",
"def consonant(letter)\n\talphabet = \"bcdfghjklmnpqrstvwxyz\"\n\talphabet2 = alphabet.chars.rotate.join('')\n\teach_id = alphabet.index(letter.downcase)\n\tnext_consonant = alphabet2[each_id]\nend",
"def consonant(letter)\n alphabet = \"bcdfghjklmnpqrstvwxyz\"\n alphabet2 = alphabet.chars.rotate.join('')\n each_id = alphabet.index(letter.downcase)\n next_consonant = alphabet2[each_id]\n end",
"def first_word_capitalized_and_ends_with_punctuation?(text)\n text.match(/^[A-Z].+[.!?]$/) ? true : false\nend",
"def double_consonants(string)\n string.chars.map { |chr| chr.match(/[bcdfghj-np-tvwxyz]/i) ? chr * 2 : chr }.join\nend",
"def count_consonants\n text.scan(/[bcdfghjklmnpqrstvwxyz]/).length\n end",
"def is_special?\n # Only consonants\n return true if self =~ /^[bcdfghjklmnpqrstvwxz]+$/i\n\n # Not a word\n return false if self =~ /[^\\s]\\s[^\\s]/;\n return false if self.length < 3;\n # Alphanumeric\n return true if self =~ /[0-9]/ && self =~ /[a-z]/i\n # All Caps\n return true if self =~ /[A-Z]{2,}/;\n # Caps Mix\n return true if self =~ /[a-z][A-Z]/;\n # All consonants\n return true if self =~ /^[a-z]$/i && self !~ /[aeiou]/i\n # Dashed word\n return true if self =~ /(^\\w-|-\\w$)/\n # To many consonants (very heuristic)\n if self =~ /([^aeiouy]{3,})/i && !CONSONANTS.include?($1.downcase)\n return true\n end\n\n return false\n end",
"def double_consonants(str)\n result = \"\"\n str.chars.each do |ch|\n result << if ch.downcase.match?(/[a-z&&[^aeiou]]/)\n ch * 2\n else\n ch\n end\n end\n result\nend",
"def ABCheck(str)\n\n return \"true\" if str=~(/a...b/) or str=~(/b...a/)\n return \"false\"\n \nend",
"def starts_with_a_vowel?(word)\nword.match? (/\\b[aeiou]/i)\n end",
"def SimpleSymbols(str)\n things = str.split(\"\")\n\n things.each_with_index do |unit, idx|\n if unit =~ /[a-z]/\n return false if things[idx - 1] != \"+\" || things[idx + 1] != \"+\"\n end\n end\n\n true\nend",
"def is_string_contains_another_string?(char_string, char_set)\n (char_string.sub(char_set, '**').index('**') ? true : false) if(valid_strings?(char_string, char_set))\nend",
"def double_consonants(string)\n string.chars.inject('') do |str, char|\n char.downcase.count(\"a-z\", \"^aeiou\") > 0 ? str + char * 2 : str + char\n end\nend",
"def next_consonant(letter)\n\tconsonants = \"bcdfghjklmnpqrstvwxyz\"\n\tif letter == \"z\"\n\t\tnext_consonant = \"b\"\n\telse\n\tnext_consonant = consonants[consonants.index(letter) + 1]\nend\nend",
"def ion(input)\n\t(/^[a-zA-Z]{1}([a-zA-Z]{2})*(ion)$/ =~ input)? \"true\" : \"false\"\nend",
"def first_word_capitalized_and_ends_with_punctuation?(text)\n if text.match(/^[A-Z].*\\W$/)\n return true\n else false\n end\nend",
"def is_lowercase(string)\n lowercase = ('a'..'z').to_a\n lowercase.include? string\nend",
"def get_next_consonant (consonant)\n\treturn 'b' if consonant == 'z'\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.chars\n\tconsonants[consonants.index(consonant) + 1]\nend",
"def get_next_consonant (consonant)\n\treturn 'b' if consonant == 'z'\n\tconsonants = 'bcdfghjklmnpqrstvwxyz'.chars\n\tconsonants[ consonants.index(consonant) + 1 ]\nend"
] | [
"0.8950055",
"0.89398736",
"0.89318657",
"0.8914293",
"0.8914293",
"0.8906625",
"0.8906625",
"0.8899526",
"0.88632745",
"0.882058",
"0.879161",
"0.87850225",
"0.87237024",
"0.87055355",
"0.86931926",
"0.8682036",
"0.8658485",
"0.8651877",
"0.8643868",
"0.8622101",
"0.8617414",
"0.86149794",
"0.8609437",
"0.8598086",
"0.8557274",
"0.8548313",
"0.8536426",
"0.8513214",
"0.85008734",
"0.84962845",
"0.8427071",
"0.8392831",
"0.8370578",
"0.8358813",
"0.8353539",
"0.83203244",
"0.831695",
"0.83148426",
"0.8291077",
"0.82687503",
"0.8086688",
"0.80466926",
"0.72891235",
"0.7257139",
"0.7134178",
"0.6812943",
"0.67701644",
"0.66462696",
"0.65948653",
"0.65740865",
"0.65673125",
"0.6542546",
"0.6533652",
"0.6516273",
"0.6490109",
"0.6474743",
"0.64734864",
"0.6464223",
"0.6456712",
"0.6439988",
"0.6427393",
"0.6384817",
"0.63838536",
"0.63771987",
"0.63648564",
"0.6311379",
"0.6302861",
"0.6299028",
"0.6226248",
"0.62125164",
"0.62034374",
"0.619094",
"0.61849374",
"0.6176524",
"0.6172213",
"0.6169932",
"0.6168387",
"0.6161752",
"0.6147933",
"0.6147177",
"0.61468583",
"0.6141953",
"0.6141953",
"0.6136069",
"0.6125683",
"0.6113546",
"0.61043674",
"0.60959697",
"0.608744",
"0.60651207",
"0.6055181",
"0.6054621",
"0.60489506",
"0.6047517",
"0.6035517",
"0.60350984",
"0.6030855",
"0.6003671",
"0.5987013",
"0.5985391"
] | 0.8744369 | 12 |
Below code takes a string and returns true if the string represents a binary number that is a multiple of 4. | def binary_multiple_of_4?(s)
# YOUR CODE HERE
if s =~ /^[0-1]+$/
return s.to_i(2) % 4 == 0
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_multiple_of_4? str\n\treturn (str =~ /\\b[01]+\\b/) != 0 ? false : str.to_i(2) % 4 == 0 ? true : false\nend",
"def binary_multiple_of_4? s\n return false if s =~ /[^0-1]/\n return false if s == ''\n s.to_i(2) % 4 == 0 ? true : false\nend",
"def binary_multiple_of_4?(str)\n if str!=''\n str.each_char { |e|\n if e!=0.to_s and e!=1.to_s\n return false\n end }\n str=Integer('0b'+str)\n str%4==0\n else\n false\n end\nend",
"def binary_multiple_of_4?(s) \n \n # tests for a string, tests that is is a binary, tests for multiple of 4,\n # returns a boolean\n \n\n test = s.is_a?(String) && s.match(/^[0-1]+$/)!= nil && s.to_i(2) % 4 == 0\n \nend",
"def binary_multiple_of_4?(s)\n return false if s =~ /[^01]/ || s.length == 0\n s.to_i(2) % 4 == 0\nend",
"def binary_multiple_of_4?(s)\n return false unless s =~ /^[01]+$/\n i = s.to_i(base=2)\n i % 4 == 0\nend",
"def binary_multiple_of_4? s\n return false if /[^01]/ =~ s or s == \"\"\n s.to_i(2) % 4 == 0\nend",
"def binary_multiple_of_4?(s)\n # check that string only contains 0 and 1s\n return false if !((s =~ /^[01]+$/) == 0)\n # convert to number\n num = s.to_i(2)\n # check if mod 4 returns 0\n return num % 4 == 0\nend",
"def binary_multiple_of_4?(s)\n\n return false if s == \"\"\n for i in 0..s.size-1\n return false unless s[i] == \"0\" || s[i] == \"1\"\n end\n s.to_i(2) % 4 == 0\nend",
"def binary_multiple_of_4?(s)\n return false if s.empty?\n\n not_valid_symbol_position = s =~ /[^0,1]/\n return false unless not_valid_symbol_position.nil?\n\n\n number = s.to_i(2)\n (number % 4 == 0) ? true : false\nend",
"def binary_multiple_of_4? s\n # Check that string is a binary number\n if s.size == 0 || s.match(/[a-zA-Z]/)\n return false\n end\n \n # Convert the string to a decimal number\n binary = []\n n = 0\n # Put the reversed string into an array\n s.reverse.each_char{|c| binary.push(c)}\n # For each character, if it is a '1' then add the corresponding power of 2\n binary.each_with_index{|b,i| n += 2**(i) if b == '1'}\n \n # Check if the number is a multiple of 4\n if n % 4 == 0\n return true\n else\n return false\n end\nend",
"def binary_multiple_of_4?(s)\n /^[01]+$/.match(s) && s.to_i(2) % 4 == 0 ? true : false\nend",
"def binary_multiple_of_4?\n return false unless s =~ /^[01]+$/\n s.to_i(2) % 4 == 0 \nend",
"def binary_multiple_of_4? s\n\n if s =~ /^[01]/ && s.to_i(2) % 4 == 0\n return true\n else\n return false\n end\n \nend",
"def binary_multiple_of_4? s\n # YOUR CODE HERE\n if s !~ /[^01]/ and s != \"\"\n num = s.to_i(2)\n if num % 4 == 0\n return true\n else\n return false\n end\n end\n \n return false\nend",
"def binary_multiple_of_4? s\n if s =~ /[^01]/ or s.empty?\n return false\n end\n chars = s.split('')\n chars = chars.reverse\n binary_num = 0\n chars.each_with_index do |c, ndx|\n binary_num += (c.to_i * (2**ndx))\n end\n \n if (binary_num % 4) == 0\n return true\n else\n return false\n end\nend",
"def binary_multiple_of_4? s\n if s =~ /^[0-1]+$/\n return s.to_i(2) % 4 == 0 unless s == \"0\"\n end\n false\nend",
"def binary_multiple_of_4? s\n value = /^[01]+$/.match s\n return false if value.nil?\n s.to_i(2)%4==0\nend",
"def binary_multiple_of_4? (s)\n isIt = false\n if((s.to_i(2).is_a? Integer) && (s[0] == '0' || s[0] == '1'))\n if(s.to_i(2) % 4 == 0)\n isIt = true\n end\n end\n return isIt\nend",
"def binary_multiple_of_4? s\n return false if s == \"\"#error if i didn't check for \"\"\n for i in 0..s.size-1 #cycle and check if it's binary\n return false unless s[i] == \"0\" || s[i] == \"1\"#1s and 0s only\n end\n s.to_i(2) % 4 == 0\nend",
"def binary_multiple_of_4?(s)\n return false unless s =~ /^[01]+$/ and s.to_i!=0\n s.to_i(2)%4==0\nend",
"def binary_multiple_of_4?(s) \n return false if s.to_i(2) == 0\n (s.to_i(2)) % 4 == 0 \nend",
"def binary_multiple_of_4? s\n return true if s==\"0\"\n num_decimal = s.to_i(2)\n if num_decimal != 0 and num_decimal%4 == 0\n return true\n else\n return false\n end\nend",
"def binary_multiple_of_4? s\n return false if s.empty? or s =~ /[^01]/\n return true if s.to_i % 100 == 0\n return false\nend",
"def binary_multiple_of_4? s\n if s.empty? || s.count('0-9')!=(s.size)\n return false\n else\n return true if s.end_with?('00') || s=='0'\n end\n false\nend",
"def binary_multiple_of_4? s\n if s =~ /^[0-1]+$/\n return s.to_i(2) % 4 == 0 unless s == 0\n end\n false\nend",
"def binary_multiple_of_4? s\n decimal = s.to_i(10)\n if (decimal == 0)\n return decimal.to_s(2).eql?(s)\n else\n return decimal % 4 == 0\n end\nend",
"def binary_multiple_of_4? s\n if not s.empty? and (s.end_with?('00') or s=='0') and s.count('0-9')==(s.size)\n return true\n end\n false\nend",
"def binary_multiple_of_4?(str)\n str =~ /^[01]*1[01]*00$/\nend",
"def binary_multiple_of_4? s\n if s == \"0\"\n return true\n end\n if /^[01]*(00)$/.match(s)\n return true\n else\n return false\n end\nend",
"def binary_multiple_of_4? s\n if not s.empty? and s.count('0-9')==(s.size) and (s.end_with?('00') or s=='0')\n return true\n end\n false\nend",
"def binary_multiple_of_4?(s)\n return /(^[10]*(00)$)|\\b0/.match(s) ? true: false\nend",
"def binary_multiple_of_4?(s)\n # YOUR CODE HERE\n return true if s == \"0\"\n\t/^[10]*00$/.match(s) != nil\nend",
"def binary_multiple_of_4? (s)\r\n\t#s.to_i(2) % 4 == 0\r\n\ts == \"0\" || s.class.to_s =='String' && s.length > 2 && s =~ /^[01]*00$/\r\n\t\r\nend",
"def binary_multiple_of_4? s\n if /^[10]*00$/.match(s) or /^[10]*0$/.match(s) \n return true\n else \n return false\n end\nend",
"def binary_multiple_of_4?(s)\n if s.empty?\n return false\n elsif (s) == \"0\"\n return true\n elsif (/^[01]*(00)$/ =~ s)\n return true\n else \n return false\n end\nend",
"def binary_multiple_of_4? s\n #If the string is 0 return true\n if s.length == 1 && s == '0'\n return true\n end\n #Uses regular expression to make sure that the string is made of 0 or 1 and ends with 00. As every multiple of 4 ends with 00.\n if /\\A[01]*00\\z/.match(s)!=nil then\n return true\n end\nreturn false\nend",
"def binary_multiple_of_4?(s)\n (/^[10]*00$/ =~ s) != nil\nend",
"def binary_multiple_of_4?(s)\n\tregex3 = /(00)$/\n\tregex4 = /[2-9A-Za-z_]/\n\t# if regex3.match(s) == nil && s != \"0\" || regex4.match(s) != nil\n\t# \tfalse\n\t# else true\n\tif regex4.match(s) != nil\n\t\tfalse\n\telsif regex3.match(s) == nil && s != \"0\"\n\t\tfalse\n\telse true\n\n\tend\n\t# (s =~ regex3) != nil\nend",
"def binary_multiple_of_4? s\n s =~ /^([01]*0)?0$/\nend",
"def binary_multiple_of_4? s\n return true if s == \"0\" \n /^[10]*00$/.match(s) != nil\n \nend",
"def binary_multiple_of_4? s\n s =~ /(^0|^[10]*00)$/ \nend",
"def is_power_of_four(num)\n s = num.to_s(2)\n zero_count = s[1..s.size - 1].count('0')\n if s[0] == '1' && zero_count == s.size - 1 && zero_count % 2 == 0\n return true\n end\n return false\nend",
"def power_of_four? n\n ((n&(n-1))== 0) && (n&0x55555555) != 0\nend",
"def is_power_of_four(num)\n return false if num < 1\n return true if num == 1\n 0 == Math.log2(num)%2\nend",
"def divisibleByFour(num)\n num % 4 == 0 ? true : false\nend",
"def is_binary?(s)\n\t\n\ts.split(\"\").each do |char|\n\t\tif char != '0' && char != '1'\n\t\t\treturn false\n\t\tend\n\tend\n\ttrue\t\t \nend",
"def dble_num?(num)\n str = num.to_s\n str.size.even? && (str[0...str.size/2] == str[str.size/2...str.size])\nend",
"def power_of_4(number)\np number\n i = 0\np number.class\n if number.class == Integer || Fixnum && number != 0 && number.class != String && number >= 1\n while 4**i <= number\n if 4**i == number\n x = true\n else x = false\n end\n i = i + 1\n end\n p x\n else p false\n end\n\n\n\n # best practice\n def power_of_4(n)\n n.is_a?(Integer) && n>0 ? Math.log(n, 4) % 1 == 0 : false\nend",
"def ipv4_address?(n)\n arr = n.split('.')\n if arr.count != 4 ||\n !('1'..'255').include?(arr[0])\n return false\n end\n\n arr.each do |num|\n return false if !('1'..'255').include?(num)\n end\n true\nend",
"def luck_check (str)\n raise ArgumentError if str.match?(/\\D/) || str.empty?\n middle = str.size / 2\n first_half, second_half = str.split(/(\\d{#{middle}})\\d?(\\d{#{middle}})/).last(2)\n first_half.to_i.digits.sum == second_half.to_i.digits.sum\nend",
"def ABcheck(str)\ncounter = 0 \nstr.each_char.do |x|\nif( x == 'a' && counter + 4 < str.length str.chars.to_a[counter + 4] =='b'\nreturn true\nend",
"def hk_phone_number?(str)\n # setup a dictionary where indices correspond to a number for O(1) lookup\n numbers = {\n '0' => true,\n '1' => true,\n '2' => true,\n '3' => true,\n '4' => true,\n '5' => true,\n '6' => true,\n '7' => true,\n '8' => true,\n '9' => true\n }\n if str.length == 9\n i = 0\n while i < str.length\n if i == 4 && str[i] != ' '\n return false\n elsif i != 4 && !numbers[str[i]]\n return false\n end\n i += 1\n end\n else\n return false\n end\n true\nend",
"def ABCheck(str)\n\n counter = 0\n str.each_char do |x|\n if(x == 'a' && counter + 4 < str.length && str.chars.to_a[counter + 4] == 'b')\n return true\n end\n counter += 1\n end\n return false \n \nend",
"def match(n)\n str = n.to_s\n return false unless str[0] == 1.to_s\n return false unless str[2] == 2.to_s\n return false unless str[4] == 3.to_s\n return false unless str[6] == 4.to_s\n return false unless str[8] == 5.to_s\n return false unless str[10] == 6.to_s\n return false unless str[12] == 7.to_s\n return false unless str[14] == 8.to_s\n return false unless str[16] == 9.to_s\n return true\nend",
"def validLengthFour? usersMove\n return false unless /^[a-h][81]=[RNBQ]/ =~ usersMove\n return true\n end",
"def eightchar?(string)\n if string.length <= 8\n return false\n else\n return true\n end\nend",
"def four_of_a_kind?\n n_of_a_kind? 4\n end",
"def valid(n)\n ns = n.to_s\n begin\n return ns[0..0] + ns[2..2] + ns[4..4] + ns[6..6] + ns[8..8] + ns[10..10] + ns[12..12] + ns[14..14] + ns[16..16] + ns[18..18] == \"1234567890\"\n rescue\n return false\n end\nend",
"def featured?(num)\n chars = num.to_s.split(//)\n num.odd? && (num % 7).zero? && chars.size == chars.uniq.size\nend",
"def solve(s)\n s.each_char do |char|\n if !\"0123456789.\".include?(char)\n return false\n end\n end\n arr = s.split(\".\")\n if arr.length != 4\n return false\n end\n arr.each do |el|\n if !(el.to_i.is_a? Integer) || el.to_i > 255 || (\"a\"..\"z\").include?(el)\n return false\n end\n if el.length > 1 && el[1..-1].include?(\"0\")\n return false\n end\n end\n true\n\nend",
"def is_section_number? string\n /^[A-Za-z0-9]{4}$/.match string #if the string is of this particular format\n end",
"def parity_check_bf(str)\n ans = 0\n for c in str.split(\"\")\n ans += 1 if c == '1'\n end\n ans % 2\nend",
"def valid_cc_number?\n #remove non-digits and read from right to left\n number = self.cc_four_digits.to_s.gsub(/\\D/, '').reverse\n\n sum, i = 0, 0\n\n number.each_char do |ch|\n n = ch.to_i\n\n # Step 1\n n *= 2 if i.odd?\n\n # Step 2\n n = 1 + (n - 10) if n >= 10\n\n sum += n\n i += 1\n end\n\n if (sum % 10).zero? # Step 3\n return true\n else\n errors.add(:cc_four_digits, 'Sorry, an invalid cardNumber Entered')\n return false\n end\n\n end",
"def is_binary_base?(num)\n binarify(num).count('1') == 1\nend",
"def magic_number?(n)\n n.to_s.split('').each.map {|ch| ch.to_i}.reduce(:+) == 7 \nend",
"def four_of_a_kind?\n repeat_counts.include? 4\n end",
"def abCheck(str)\n\treturn false if(str.include?('a') == false || str.include?('b') == false || str.rindex('b') < str.rindex('a'))\n\treturn str.rindex('b') - str.rindex('a') == 4\n\t\nend",
"def is_valid_PIN(pin)\n# check if the pin is equal to the converted pin\n pin == \"#{pin.to_i}\"\n # if pin && (pin.length == 4 || pin.length ==6)\n # return true\n # end\n # false\nend",
"def valid_ip?(str)\n nums = str.split(\".\").map(&:to_i)\n return false if nums.size != 4\n nums.all? { |num| num >= 0 && num <= 255 }\nend",
"def ipv4?(string)\n !!string.match(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/)\nend",
"def number_is_valid_2?(number)\n str = number.to_s\n str.scan(/(\\d)\\1+/).length - str.scan(/(\\d)\\1\\1+/).length > 0\nend",
"def valid_ip?(str)\n str_arr = str.split(\".\");\n return false if str_arr.length != 4\n\n str_arr.each do |el|\n return false unless el.match(/^\\d{0,3}$/) && el.to_i >= 0 && el.to_i <= 255\n end\n return true \nend",
"def string_to_binary(str)\n if str.('a'..'m').include?\n return \"0\"\n else\n return \"1\"\n end\nend",
"def meets_qualifications?(num_string)\n num_string[1, 3].to_i % 2 == 0 &&\n num_string[2, 3].to_i % 3 == 0 &&\n num_string[3, 3].to_i % 5 == 0 &&\n num_string[4, 3].to_i % 7 == 0 &&\n num_string[5, 3].to_i % 11 == 0 &&\n num_string[6, 3].to_i % 13 == 0 &&\n num_string[7, 3].to_i % 17 == 0\nend",
"def is_hexword(s)\n s.match(/^[0-9a-fA-F]{8}$/) != nil\nend",
"def hack?(n)\n binary_n = n.to_s(2).to_i\n palindrome? binary_n and sum_digits(binary_n).odd?\nend",
"def is_valid_number?(string_of_digits, input_string)\n\n # input_string is a string, can be 1 or multiple characters\n # Go from the beginning of input_string to the end\n\n input_string.each do |char|\n digit_valid = is_valid_digit?(string_of_digits, char)\n return false if !digit_valid\n end\n\n true\nend",
"def armstrong? num\n n = num.length\n num.chars.inject(0) { |sum,d| sum + (d.to_i ** n) } == num.to_i\nend",
"def balancer(str)\n str.count('(') == str.count(')')\nend",
"def check_string(s)\r\n\t\treturn s.length == @m*@n\r\n\tend",
"def can_win_nim(n)\n if n % 4 == 0\n false\n else\n true\n end\nend",
"def verN(num)\n\t\tret = true\n\t\t\n\t\tif num == nil\n\t\t\treturn false\n\t\tend\n\t\tif num.strip.size == 0\n\t\t\treturn false\n\t\tend\n\t\t\n\t\ttam = num.strip.size\n\t\ttam = tam -1 \n\t\t\n\t\tfor ct in (0..tam)\n\t\t\tif num[ct..ct] != \"0\" and num[ct..ct] != \"1\" and num[ct..ct] != \"2\" and num[ct..ct] != \"3\" and num[ct..ct] != \"4\" and num[ct..ct] != \"5\" and num[ct..ct] != \"6\" and num[ct..ct] != \"7\" and num[ct..ct] != \"8\" and num[ct..ct] != \"9\"\n\t\t\t\tret = false\n\t\t\t\tbreak\n\t\t\tend\t\n\t\tend\n\t\t\n\t\treturn ret\n\tend",
"def ABCheck(str)\n\n i = 0\n while i < str.length\n puts str[i]\n while str[i] == 'a' && str[i + 4] == 'b' || str[i] == 'b' && str[i +4] == 'a'\n \tputs str[i]\n \treturn 'true'\n end\n i += 1\n end\n return 'false'\nend",
"def valid?(str)\r\n if str =~ /^([^2]*(13|31)|[^4]*(17|71)|[^6]*(39|93)|[^8]*(79|97)|\r\n [^5]*(46|64|28|82|19|91|37|73)).*\\z/x\r\n false\r\n else\r\n true\r\n end\r\n end",
"def ABCheck(str)\n\n new_str = str.split(\"\")\n index = 0 \n value = false\n \n while index < new_str.length\n if new_str[index] == 'a' and new_str[index+4] == 'b'\n value = true\n end\n index += 1\n end\n \n \n # code goes here\n return value \n \nend",
"def is_four_of_a_kind( hand )\n\tkind = check_kind( 4, hand )\n\treturn 0 != kind.length ? kind : 0\nend",
"def balancer(string)\n string.count('(') == string.count(')')\nend",
"def IPv4ToBits(ipv4)\n if !Check4(ipv4)\n Builtins.y2error(\"Not a valid IPv4: %1\", ipv4)\n return nil\n end\n\n ret = \"\"\n Builtins.foreach(Builtins.splitstring(ipv4, \".\")) do |ipv4_part|\n ipv4_part_i = Builtins.tointeger(ipv4_part)\n Builtins.foreach(@bit_weight_row) do |try_i|\n if Ops.greater_than(Ops.divide(ipv4_part_i, try_i), 0)\n ipv4_part_i = Ops.modulo(ipv4_part_i, try_i)\n ret = Ops.add(ret, \"1\")\n else\n ret = Ops.add(ret, \"0\")\n end\n end\n end\n\n ret\n end",
"def balanced?(str)\n #str.count(')') == str.count('(')\n array = str.chars\n\n count = 0\n array.each do |char|\n count += 1 if char == '('\n count -= 1 if char == ')'\n end\n return false if count < 0\n end",
"def balanced?(str)\n count = 0\n str.chars.each do |c|\n count += 1 if c == '('\n count -= 1 if c == ')'\n return false if count == -1\n end\n count == 0\nend",
"def valid_pkcs7?(str)\n last = str[-1]\n\n if last.ord > 0 && last.ord <= 16\n padding_string = last * last.ord\n\n str[-16..-1] =~ /#{padding_string}$/\n else\n false\n end\n end",
"def number_is_valid_1?(number)\n number.to_s =~ /(\\d)\\1/\nend",
"def valid_looking_string?(str)\n str =~ /\\d/\n end",
"def triplet_true?(str)\n hash = Hash.new { |h, k| h[k] = 0 }\n str.chars { |char| hash[char] += 1 }\n hash.any? { |k, v| v > 2 }\nend",
"def featured?(num)\n chars = num.to_s.chars\n num % 7 == 0 && num.odd? && chars.none? { |char| chars.count(char) > 1 }\nend",
"def CheckNetwork4(network)\n generic_check = CheckNetworkShared(network)\n if generic_check != nil\n return generic_check \n\n # 192.168.0.1, 0.8.55.999\n elsif Check4(network)\n return true \n\n # 192.168.0.0/20, 0.8.55/158\n elsif Builtins.regexpmatch(\n network,\n Ops.add(Ops.add(\"^[\", @ValidChars4), \"]+/[0-9]+$\")\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check4(Ops.get(net_parts, 0, \"\")) &&\n Netmask.CheckPrefix4(Ops.get(net_parts, 1, \"\")) \n\n # 192.168.0.0/255.255.255.0, 0.8.55/10.258.12\n elsif Builtins.regexpmatch(\n network,\n Ops.add(\n Ops.add(Ops.add(Ops.add(\"^[\", @ValidChars4), \"]+/[\"), @ValidChars4),\n \"]+$\"\n )\n )\n net_parts = Builtins.splitstring(network, \"/\")\n return Check4(Ops.get(net_parts, 0, \"\")) &&\n Netmask.Check4(Ops.get(net_parts, 1, \"\"))\n end\n\n false\n end",
"def balanced?(str)\n open_count, close_count = [0, 0]\n str.chars.each do |char|\n open_count += 1 if char == '('\n close_count += 1 if char == ')'\n break if close_count > open_count\n end\n open_count == close_count ? true: false \nend",
"def valid_ip?(string)\n decimal_counter = 0\n range_counter = 0\n\n strArray = string.split('')\n strArray.each do |char|\n if char == '.'\n decimal_counter += 1\n end\n end\n\n numArray = string.split('.')\n numArray.each do |int|\n int = int.to_i\n if int >= 0 && int <= 255\n range_counter += 1\n else\n return\n end\n end\n\n if decimal_counter == 3 && range_counter == 4\n p \"true\"\n return true\n else\n p \"false\"\n return false\n end\nend",
"def valid_ip?(str)\n ip_ary = str.split('.')\n ip_ary.size == 4 && ip_ary.all?{|x| x.match(/^\\d{1,3}$/) && (0..255).include?(x.to_i)}\nend"
] | [
"0.91391087",
"0.90644675",
"0.90362066",
"0.8990401",
"0.8975801",
"0.8928835",
"0.8916422",
"0.88924944",
"0.888888",
"0.88709724",
"0.88660556",
"0.88583463",
"0.88283455",
"0.8823368",
"0.88209933",
"0.8793129",
"0.87742674",
"0.8743983",
"0.87246525",
"0.8681561",
"0.8681341",
"0.8660496",
"0.85927296",
"0.8584672",
"0.8570701",
"0.8553365",
"0.8536533",
"0.8500713",
"0.849738",
"0.847512",
"0.8464237",
"0.8347549",
"0.83221376",
"0.83094823",
"0.82931685",
"0.82711333",
"0.8233861",
"0.819809",
"0.81169367",
"0.80951583",
"0.80293036",
"0.7760016",
"0.7649948",
"0.65689224",
"0.6552089",
"0.64367324",
"0.64318544",
"0.6418147",
"0.63032216",
"0.62329704",
"0.61222965",
"0.6119663",
"0.6057709",
"0.6018939",
"0.60157365",
"0.59827363",
"0.5970123",
"0.5966153",
"0.59527624",
"0.5949021",
"0.5941974",
"0.58810556",
"0.5875963",
"0.5855394",
"0.58520705",
"0.5840832",
"0.5781006",
"0.5779387",
"0.5779241",
"0.5768001",
"0.5765968",
"0.5757958",
"0.57575864",
"0.57368356",
"0.5719089",
"0.5702478",
"0.5701269",
"0.56920755",
"0.56915367",
"0.5685775",
"0.5684562",
"0.5676999",
"0.56681234",
"0.5665709",
"0.5657007",
"0.56522256",
"0.56303304",
"0.5612568",
"0.5609061",
"0.56001526",
"0.55849373",
"0.5584535",
"0.55832016",
"0.55781084",
"0.5571257",
"0.5567073",
"0.55578053",
"0.55465174",
"0.5538487",
"0.5537003"
] | 0.87391615 | 18 |
also change the method key?, include?, member? | def has_key?(key)
local?(key) || ([email protected]? && @parent.key?(key))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key(method)\n @_key = method\n end",
"def key=(key); end",
"def include?(key); end",
"def include?(key); end",
"def key=(_); end",
"def key=(_); end",
"def rekey_as_needed; end",
"def pfadd(key, member); end",
"def [](key)\n Extension.mixin_to(self,key,super)\n end",
"def proxy_across_keytypes(method, key)\n key_registry.send(method, key) || key_registry.send(method, build_key(key))\n end",
"def include_key?(key)\n\t\t\ttrue\n\t\tend",
"def exchange_keys; end",
"def exchange_keys; end",
"def inc(key)\n \n end",
"def assoc(key)\n super(convert_key(key))\n end",
"def key_method method\n @key_method = method\n validates_presence_of method\n validates_length_of method, minimum: 1\n define_method(:key) { prepare_key(self.send method) }\n end",
"def key_attr_reader(key)\n define_method key do\n self[key]\n end\n end",
"def key=(_arg0); end",
"def key=(_arg0); end",
"def key=(_arg0); end",
"def set_key_statement\n super\n end",
"def updateKey; @key = getKey; self end",
"def include?(key)\n\t\t\t\tsuper || @l2.include?(key)\n\t\t\tend",
"def sadd?(key, *members); end",
"def sadd?(key, *members); end",
"def change_include_possible(include,user)\n\t\t\n \tend",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def key; end",
"def include(*mods)\n clear_setter_methods_cache\n super\n end",
"def include(*mods)\n clear_setter_methods_cache\n super\n end",
"def method_missing(mid, *args)\n if mid.to_s =~ /(.+)\\?$/\n return $1 == self.key.to_s\n else\n super\n end\n end",
"def [](key)\n super(key) or super(alternate_key(key))\n end",
"def keys\n\t\tsuper + self.class.keys\n\tend",
"def key\n raise NotImplementedError, \"You must implement #{self.class}##{__method__}\"\n end",
"def zmscore(key, *members); end",
"def zmscore(key, *members); end",
"def [](key)\n super(key.to_sym)\n end",
"def add_method(key)\n self.class.send(:define_method, key) do\n @hash[key]\n end\n end",
"def get(key)\n \n end",
"def [](key); super(key.to_s); end",
"def method_missing( method, *args, &block )\n key = @key.dup << method.to_s\n Undefined.warn key\n return Undefined.new(key)\n end",
"def needs_rekey?; end",
"def see(method_key)\n return unless Apipie.active_dsl?\n raise \"'See' method called twice.\" if Apipie.last_dsl_data[:see]\n Apipie.last_dsl_data[:see] = method_key\n end",
"def respond_to_missing?(method, include_all)\n super || key?(method) || hash_respond_to?(method)\n end",
"def sadd(key, *members); end",
"def key=(value); end",
"def key_coercions=(_arg0); end",
"def sismember(key, member); end",
"def sismember(key, member); end",
"def smembers(key); end",
"def smembers(key); end",
"def if_needs_rekey?; end",
"def handle_key(key); end",
"def extra_keys(options, recall = T.unsafe(nil)); end",
"def method_missing_with_attr_encrypted(method, *args, &block)\n if match = /^(find|scoped)_(all_by|by)_([_a-zA-Z]\\w*)$/.match(method.to_s)\n attribute_names = match.captures.last.split('_and_')\n attribute_names.each_with_index do |attribute, index|\n encrypted_name = \"encrypted_#{attribute}\"\n if method_defined? encrypted_name.to_sym\n args[index] = ::SymmetricEncryption.encrypt(args[index])\n attribute_names[index] = encrypted_name\n end\n end\n method = \"#{match.captures[0]}_#{match.captures[1]}_#{attribute_names.join('_and_')}\".to_sym\n end\n method_missing_without_attr_encrypted(method, *args, &block)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def include?(key = nil)\n key ||= Stash.caller_name\n @store.include? key.to_sym\n end",
"def method_missing(m, *args, &block)\n method_name = m.to_s.gsub(/=$/, '')\n if self.class.schema.keys.include?(method_name)\n m.to_s.match(/=$/) ? @hash[method_name] = args[0] : @hash[method_name]\n else\n super\n end\n end",
"def include=(_arg0); end",
"def [](key)\n super(key.to_sym)\n end",
"def [](key)\n super(key.to_sym)\n end",
"def my_hash_modification_method!(source, thing_to_modify)\n\tsource.each {|k, v| source[k] = v + thing_to_modify}\nend",
"def method_missing(name, *args)\n super unless args.empty? && !block_given?\n @set.include?(name)\n end",
"def [](key)\n super(convert_key(key))\n end",
"def method_missing ( method, *args )\n # Handle all valid *_index/*_key calls:\n return _addIndexes( method, *args ) if VALID_INDEX_HINTS.include? method \n super\n end",
"def key_reader *keys\n keys.each do |method|\n key = method.to_s\n define_method method do\n self[key]\n end\n end\n end",
"def key_writer *keys\n keys.each do |method|\n key = method.to_s\n define_method \"#{method}=\" do |value|\n self[key] = value\n end\n end\n end",
"def safe_key(method, *args)\n \"CachableModel[#{klass.name}].#{method}(#{args.join(',')})\".gsub(/\\s/, \"-\")[0, 220]\n end",
"def decorators(key); end",
"def decorators(key); end",
"def get key; call key; end",
"def method=(_); end",
"def _wrapper_key; end",
"def [](key)\n super(convert_key(key))\n end",
"def underbang_reader(key); end",
"def method_missing(method_name, *args, &block)\n if attrs.keys.include? method_name.to_s\n attrs[method_name.to_s]\n else\n super(method_name)\n end\nend",
"def related_fields(method)\n \n end",
"def _key(*args); args.hash; end",
"def def_set_accessor(key)\n key = key.to_sym\n raise ArgumentError.new('Invalid entry type: %s' % key) if respond_to?(key)\n metaclass.class_eval do\n define_method(key) {|*val| val.size > 0 ? (self[key] ||= Set.new).merge(val) : self[key] }\n define_method(\"#{key}!\") {|*val| val.size > 0 ? (cache[key] ||= Set.new).merge(val) : cache[key] }\n end\n end",
"def include?(key)\n has_key?(key)\n end",
"def key?(key)\n super(convert_key(key))\n end",
"def method_missing(method)\n\t\t\t@crisis[method.to_s] if @crisis and @crisis.class.eql?(Hash) and @crisis.key?(method.to_s)\n\t\tend"
] | [
"0.66888416",
"0.6590128",
"0.6431418",
"0.6431418",
"0.6410342",
"0.6410342",
"0.6348724",
"0.6241407",
"0.61003023",
"0.60467255",
"0.60247505",
"0.60032475",
"0.60032475",
"0.5917361",
"0.5880308",
"0.58585143",
"0.58408993",
"0.5834375",
"0.5834375",
"0.5834375",
"0.58235145",
"0.5822057",
"0.58172727",
"0.5803691",
"0.5803691",
"0.5793423",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.5776834",
"0.57767737",
"0.57767737",
"0.57552814",
"0.5746091",
"0.5738499",
"0.57177365",
"0.5715478",
"0.5715478",
"0.57152075",
"0.5712732",
"0.5707142",
"0.57049865",
"0.56974006",
"0.5692741",
"0.5685862",
"0.5685059",
"0.56598645",
"0.56559515",
"0.5648104",
"0.5643454",
"0.5643454",
"0.56404656",
"0.56404656",
"0.5632466",
"0.5631324",
"0.56026304",
"0.5589419",
"0.55842775",
"0.55842775",
"0.55795807",
"0.5574439",
"0.5570389",
"0.5566159",
"0.5566159",
"0.5553227",
"0.553952",
"0.5539429",
"0.5538411",
"0.55313975",
"0.5523133",
"0.55109787",
"0.5504077",
"0.5504077",
"0.55033714",
"0.549784",
"0.54965746",
"0.5492106",
"0.5490918",
"0.5485414",
"0.5477286",
"0.5472948",
"0.5465007",
"0.54595",
"0.5438705",
"0.5418712"
] | 0.0 | -1 |
GET /cordinators GET /cordinators.json | def index
@cordinators = Cordinator.all.order('name ASC').page(params[:page]).per(3)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cords = Cord.all\n @cords = Cord.user_cords(current_user)\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @commanders = Commander.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commanders }\n end\n end",
"def index\n clients = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients\"\n ).body\n end\n styled_header(\"OAuth Clients\")\n styled_array(clients.map { |client|\n [client[\"name\"], client[\"id\"], client[\"redirect_uri\"]]\n })\n end",
"def index\n @cultivators = Cultivator.all\n end",
"def index\n get_clientes\n end",
"def index\n @admin_collaborators = Admin::Collaborator.all\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @admin_collaborators }\n end\n end",
"def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end",
"def index\n render json: Client.all\n end",
"def index\n @authorized_clients = AuthorizedClient.all\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def index\r\n user = authenticate\r\n if user\r\n clients = Client.where('clientof = ?', user.id)\r\n render json: {clients: clients, message: 'Success', status: :ok}\r\n else\r\n render json: {message: 'Invalid token', status: :unauthorized}\r\n end\r\n end",
"def index\n @colaborators = Colaborator.all\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @recitators = Recitator.all\n end",
"def getdoctors\n #verify user in slug is logged in\n token_passed = params[:token] unless params[:token].nil?\n patient = Patient.find_by_slug!(params[:patient_id])\n if my_encrypt(patient.remember_token) != token_passed\n redirect_to signin_path\n else\n allows_cors\n clinic = Clinic.find_by_name(params[:clinic])\n doctors = Doctor.in_clinic(clinic)\n docnames = []\n doctors.each { |d| docnames << d.full_name }\n render json: {doctors: docnames}\n end\n end",
"def index\n authorize! :admin, Coordenador\n \n @coordenadores = Coordenador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenadores }\n end\n end",
"def index\n colorizers = Colorizer.all\n\n render json: colorizers\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n @cordinates = Cordinate.all\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def index\n @clients = Client.page(params[:page] || 1).per(10)\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def moderators\n\n @cloud = fetch_cloud()\n @users = @cloud.moderators\n render :index, status: 200\n\n end",
"def index\n if current_user.role == 'customer_admin'\n render json: current_user.customer and return\n else\n authorize! :read_all, Customer\n customers = Customer.order('name asc')\n render json: customers and return\n end\n end",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def show\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_collaborator }\n end\n end",
"def index\n @donators = Donator.all\n end",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def index\n #authorize! :index, @login, :message => 'Not authorized as an administrator.'\n #É preciso ir buscar a clinica do gestor atual para carregar a informação\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @clinic = manager.clinic\n\n @managers = Manager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @managers }\n end\n end",
"def listar()\n @client.get(Route.new([ROTA_DID]))\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def index\n @collaborators = Collaborator.all\n end",
"def index\n @collaborators = Collaborator.all\n end",
"def index\n @canisters = Canister.all.to_a\n render(json: @canisters.map do |canister|\n setup_canister_properties canister\n canister.properties\n end)\n end",
"def index\n @directorios = Directorio.all\n end",
"def index\n @directorios = Directorio.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end",
"def index\n @auttors = Auttor.all\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @commands = Command.all\n render :json => @commands\n end",
"def index\n @microroles = Microrole.includes(:verb_coding_frame_microroles).readonly(false).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @microroles }\n end\n end",
"def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mirrors }\n end\n end",
"def index\n @chargers = Charger.all\n render json: @chargers\n end",
"def list(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics/#{@topic_id}/percolators\", body, options\n\n return response\n end",
"def clients\n clis = []\n url = prefix + \"listc\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n clis << User.new(u[\"id\"], @authid, @subdomain, u)\n end\n return clis\n else #failed\n return users\n end\n end",
"def index\n @administradors = Administrador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @administradors }\n end\n end",
"def index\n @users = User.not_deleted.where(:client_id => nil).order(:role_id, :name).page(params[:page]).per(15)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def index\n @carrers = Carrer.all\n end",
"def index\n @advances = user_capabilities(Advance).current_advances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advances }\n end\n end",
"def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end",
"def index\n #byebug\n #CHECK AUTHORIZATION HERE NOT JUST JUST AUTHENTICATION\n \n render json: {farmers: Farmer.all, customers: CustomerUser.all} #User.all #CustomerUser.all #{users: User.all, customers: Customer_User.all}\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def index\n @clients = current_user.is_admin ? Client.all : current_user.clients\n end",
"def index\n @clinic_doctors = ClinicDoctor.includes(:clinic, :doctor).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clinic_doctors }\n end\n end",
"def index\n render jsonapi: authorized_collection, each_serializer: Connection::Serializer\n end",
"def index\n @citizenship_classes = @grantee.citizenship_classes.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @citizenship_classes }\n end\n end",
"def index\n @normas = Norma.all\n render json: @normas\n end",
"def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n @electors = Elector.all\n\n render json: @electors\n end",
"def index\n @clients = current_user.account.clients.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page => params[:page])\n\n @account = current_user.account\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n head 404\n # @api_v1_followers = Api::V1::Follower.all\n\n # render json: @api_v1_followers\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def index\n @clan_matches = ClanMatch.all\n\n render json: @clan_matches\n end",
"def index\n render json: current_org.users\n end",
"def index\n @relatorios = Relatorio.all.page(params[:page]).per(15)\n end",
"def index\n @players = Player.all\n auth!\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @players }\n end\n end",
"def index\n @wrestlers = Wrestler.all\n end",
"def index\n authorize! :manage, @users\n\n @users = @users.includes(:character).ordered\n\n respond_to do |format|\n format.html { @users = @users.page(params[:page]).per(50) }\n format.json { }\n end\n end",
"def index\n @waiters = @course.waiters.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @waiters }\n end\n end",
"def index\n @creators = Creator.all\n end",
"def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end",
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def clients_index\n @clients = User.clients\n end",
"def me\n render status: 200, json: current_user.db_user.as_json(only: [:id, :email], include: { discord_identity: { }, roles: { include: { nested_roles: { include: { role_nested: { } } } } } }, methods: [:main_character])\n end",
"def index\n @contenders = Contender.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contenders }\n end\n end",
"def index\n @distributions = current_user.distributions\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distributions }\n end\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @authers = Auther.all\n end",
"def index\n @authers = Auther.all\n end",
"def index\n champions = Champion.all\n render json: champions\n end",
"def index\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @neuropsychologists = Neuropsychologist.all(:conditions => \"clinic_id = #{manager.clinic.id}\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neuropsychologists }\n end\n end",
"def index\n @turns = Turn.all\n\t\trespond_with @turns\n end"
] | [
"0.6471373",
"0.6235497",
"0.60187787",
"0.5987753",
"0.5859183",
"0.5853303",
"0.58433515",
"0.5839788",
"0.57999206",
"0.5787826",
"0.57639337",
"0.5750131",
"0.5735624",
"0.5713239",
"0.56854445",
"0.5667751",
"0.56671786",
"0.5663496",
"0.5654859",
"0.5637093",
"0.56341636",
"0.5623451",
"0.5619996",
"0.5619737",
"0.56125695",
"0.56093913",
"0.55900115",
"0.5585699",
"0.5570509",
"0.5567747",
"0.55571383",
"0.5550952",
"0.5546261",
"0.5543743",
"0.5543506",
"0.55380535",
"0.55380535",
"0.5537508",
"0.5526168",
"0.5526168",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55168974",
"0.55083704",
"0.54993045",
"0.54947245",
"0.54943055",
"0.549181",
"0.5487112",
"0.54789805",
"0.5474708",
"0.54714125",
"0.54592997",
"0.54580957",
"0.545487",
"0.5445577",
"0.5444313",
"0.5439714",
"0.54380876",
"0.543026",
"0.54280996",
"0.5424301",
"0.54193777",
"0.5419296",
"0.5418049",
"0.5416548",
"0.5410867",
"0.5408357",
"0.54034907",
"0.54023117",
"0.53955215",
"0.53895277",
"0.5386081",
"0.53833055",
"0.53826493",
"0.5379417",
"0.5374863",
"0.53723335",
"0.5370906",
"0.5366647",
"0.5366219",
"0.53647",
"0.5363888",
"0.5360648",
"0.5355592",
"0.5351835",
"0.53493494",
"0.5348934",
"0.5348519",
"0.534044",
"0.53386194",
"0.53386194",
"0.53377277",
"0.533204",
"0.5331358"
] | 0.66650933 | 0 |
GET /cordinators/1 GET /cordinators/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @cordinators = Cordinator.all.order('name ASC').page(params[:page]).per(3)\n end",
"def index\n @cords = Cord.all\n @cords = Cord.user_cords(current_user)\n end",
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def show\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collaborator }\n end\n end",
"def index\n @commanders = Commander.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commanders }\n end\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n get_clientes\n end",
"def show\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_collaborator }\n end\n end",
"def index\n render json: Client.all\n end",
"def show\n @commander = Commander.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @commander }\n end\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def show\n @conductor = Conductor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conductor }\n end\n end",
"def show\n @conductor = Conductor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conductor }\n end\n end",
"def index\n @colaborators = Colaborator.all\n end",
"def index\n clients = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients\"\n ).body\n end\n styled_header(\"OAuth Clients\")\n styled_array(clients.map { |client|\n [client[\"name\"], client[\"id\"], client[\"redirect_uri\"]]\n })\n end",
"def index\n @clients = Client.page(params[:page] || 1).per(10)\n end",
"def index\r\n user = authenticate\r\n if user\r\n clients = Client.where('clientof = ?', user.id)\r\n render json: {clients: clients, message: 'Success', status: :ok}\r\n else\r\n render json: {message: 'Invalid token', status: :unauthorized}\r\n end\r\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def show\n @crust = Crust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @crust }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end",
"def index\n @recitators = Recitator.all\n end",
"def show\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lector }\n end\n end",
"def index\n @admin_collaborators = Admin::Collaborator.all\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @admin_collaborators }\n end\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @clues = Clue.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clues }\n end\n end",
"def index\n @authorized_clients = AuthorizedClient.all\n end",
"def index\n @conns = current_user.conns\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @conns }\n end\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @clients = Client.all\n end",
"def index\n @cultivators = Cultivator.all\n end",
"def show\n @cerc = Cerc.find(params[:id])\n\n render json: @cerc\n end",
"def index\n @mirrors = Mirror.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mirrors }\n end\n end",
"def show\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clonet }\n end\n end",
"def index\n @denuncia = Denuncium.all\n\n render json: @denuncia\n end",
"def index\n #authorize! :index, @login, :message => 'Not authorized as an administrator.'\n #É preciso ir buscar a clinica do gestor atual para carregar a informação\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @clinic = manager.clinic\n\n @managers = Manager.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @managers }\n end\n end",
"def index\n @clients = Client.all\n end",
"def getdoctors\n #verify user in slug is logged in\n token_passed = params[:token] unless params[:token].nil?\n patient = Patient.find_by_slug!(params[:patient_id])\n if my_encrypt(patient.remember_token) != token_passed\n redirect_to signin_path\n else\n allows_cors\n clinic = Clinic.find_by_name(params[:clinic])\n doctors = Doctor.in_clinic(clinic)\n docnames = []\n doctors.each { |d| docnames << d.full_name }\n render json: {doctors: docnames}\n end\n end",
"def index\n @chargers = Charger.all\n render json: @chargers\n end",
"def show\n @client = clients.find(params[:id])\n end",
"def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end",
"def index\n #since trainers is conncected to gym\n #find the gym where the id of gym is equal to the trainer\n #SO THIS WILL TARGET SPECEFIC PEOPLE WHOS GYM.ID IS EQUAL TO TRAINER gym_id\n @gym=Gym.find(params[:gym_id])\n @trainers=Trainer.where(gym_id: @gym.id)\n render json: @trainers, include: :clients, status: :ok\n end",
"def index\n authorize! :admin, Coordenador\n \n @coordenadores = Coordenador.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @coordenadores }\n end\n end",
"def show\n @doctor_cliente = DoctorCliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @doctor_cliente }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def index\n @donators = Donator.all\n end",
"def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end",
"def index\n @cordinates = Cordinate.all\n end",
"def index\n @commands = Command.all\n render :json => @commands\n end",
"def index\n head 404\n # @api_v1_followers = Api::V1::Follower.all\n\n # render json: @api_v1_followers\n end",
"def index\n @microroles = Microrole.includes(:verb_coding_frame_microroles).readonly(false).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @microroles }\n end\n end",
"def index\n @consents = Consent.all\n render json: @consents\n end",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def show\n @client = Client.find(params[:id])\n authorize! :read, @client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end",
"def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @circulation }\n end\n end",
"def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end",
"def show\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:show [ID]\")\n\n client = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if options[:shell]\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end",
"def show\n @coordinador = Coordinador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coordinador }\n end\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def me\n render status: 200, json: current_user.db_user.as_json(only: [:id, :email], include: { discord_identity: { }, roles: { include: { nested_roles: { include: { role_nested: { } } } } } }, methods: [:main_character])\n end",
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n Rails.logger.info('👻 Disraptor: Showing available routes.')\n\n routes = Disraptor::Route.find_all()\n\n render json: { 'disraptor/routes': routes }\n end",
"def index\n @ordens = Orden.all\n render json: @ordens\n end",
"def index\n @directorios = Directorio.all\n end",
"def index\n @directorios = Directorio.all\n end",
"def index\n render json: current_org.users\n end",
"def index\n colorizers = Colorizer.all\n\n render json: colorizers\n end",
"def moderators\n\n @cloud = fetch_cloud()\n @users = @cloud.moderators\n render :index, status: 200\n\n end",
"def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end",
"def index\n @collaborators = Collaborator.all\n end",
"def index\n @collaborators = Collaborator.all\n end",
"def recent\n if current_user.is_admin?\n @clients = Client.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @clients }\n end\n end",
"def index\n @cages = current_user.cages\n\n respond_to do |format|\n format.json { render json: @cages }\n end\n end",
"def index\n @challenges = Challenge.user(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @challenges }\n end\n end",
"def set_cordinator\n @cordinator = Cordinator.find(params[:id])\n end",
"def index\n render jsonapi: authorized_collection, each_serializer: Connection::Serializer\n end",
"def listar()\n @client.get(Route.new([ROTA_DID]))\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def show\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climate }\n end\n end",
"def show\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leader }\n end\n end",
"def index\n manager = Manager.first(:conditions => \"login_id = #{current_login.id}\")\n @neuropsychologists = Neuropsychologist.all(:conditions => \"clinic_id = #{manager.clinic.id}\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @neuropsychologists }\n end\n end",
"def index\n @contestants = Contestant.all\n\n if @contestants.count > 2\n first_id = @contestants.first.id\n last_id = @contestants.last.id\n winner = rand(first_id..last_id)\n @winner = Contestant.find(winner)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contestants }\n end\n end",
"def show\n @contacter = Contacter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contacter }\n end\n end",
"def index\n @clan_matches = ClanMatch.all\n\n render json: @clan_matches\n end",
"def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end",
"def index\n if current_user.role == 'customer_admin'\n render json: current_user.customer and return\n else\n authorize! :read_all, Customer\n customers = Customer.order('name asc')\n render json: customers and return\n end\n end",
"def clients_index\n @clients = User.clients\n end",
"def show\n render json: @client\n end",
"def set_cord\n @cord = Cord.find(params[:id])\n end",
"def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientships }\n end\n end",
"def index\n @distributions = current_user.distributions\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @distributions }\n end\n end",
"def clients\r\n ClientsController.instance\r\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @creations = Creation.where(user_id: params[:user_id])\n\n render json: @creations\n end",
"def show\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end"
] | [
"0.6468164",
"0.6338109",
"0.6239724",
"0.5967036",
"0.5955771",
"0.5939155",
"0.5887246",
"0.5843991",
"0.5815789",
"0.57620484",
"0.5746067",
"0.5701565",
"0.5701565",
"0.56876874",
"0.568302",
"0.5659988",
"0.5654441",
"0.56499875",
"0.5635845",
"0.56357145",
"0.5604299",
"0.5600476",
"0.5592434",
"0.5580804",
"0.5555869",
"0.55517066",
"0.5542948",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5541551",
"0.5540377",
"0.55378664",
"0.5527711",
"0.5522521",
"0.5516474",
"0.5515991",
"0.5512501",
"0.55101156",
"0.5503837",
"0.550016",
"0.5496305",
"0.54936504",
"0.54896307",
"0.548245",
"0.5477692",
"0.5467356",
"0.54640216",
"0.5458853",
"0.5446983",
"0.5445457",
"0.5444431",
"0.544334",
"0.5442299",
"0.54404694",
"0.5437295",
"0.54357177",
"0.5435131",
"0.54265857",
"0.5424303",
"0.5423645",
"0.5421808",
"0.54201716",
"0.5407193",
"0.5403521",
"0.5397163",
"0.5397163",
"0.53845274",
"0.53826475",
"0.53822094",
"0.5381299",
"0.5380866",
"0.5380866",
"0.5378687",
"0.53757805",
"0.5371134",
"0.53666306",
"0.5365866",
"0.5362034",
"0.5357431",
"0.5355859",
"0.5353154",
"0.53470397",
"0.534546",
"0.5344622",
"0.5343056",
"0.5342629",
"0.53422797",
"0.533899",
"0.53383803",
"0.53341866",
"0.5325479",
"0.53211904",
"0.5312863",
"0.5312292",
"0.5312262",
"0.5302468"
] | 0.0 | -1 |
POST /cordinators POST /cordinators.json | def create
@cordinator = Cordinator.new(cordinator_params)
respond_to do |format|
if @cordinator.save
format.html { redirect_to @cordinator, notice: 'El cordinador se ha creado correctamente' }
format.json { render :show, status: :created, location: @cordinator }
else
format.html { render :new }
format.json { render json: @cordinator.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # @cord = Cord.new(cord_params)\n @cord = @racquet.cords.new(cord_params)\n @cord.user = current_user\n respond_to do |format|\n if @cord.save\n format.html { redirect_to @cord, notice: t('cords.create.success') }\n format.json { render :show, status: :created, location: @cord }\n else\n format.html { render :new }\n format.json { render json: @cord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(percolator, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:percolator] = percolator\n\n response = @client.post \"/api/topics/#{@topic_id}/percolators\", body, options\n\n return response\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def create\n @aucrecord = Aucrecord.new(aucrecord_params)\n\n respond_to do |format|\n if @aucrecord.save\n format.html { redirect_to @aucrecord, notice: 'Aucrecord was successfully created.' }\n format.json { render action: 'show', status: :created, location: @aucrecord }\n else\n format.html { render action: 'new' }\n format.json { render json: @aucrecord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorio = Relatorio.new(relatorio_params)\n\n respond_to do |format|\n if @relatorio.save\n format.html { redirect_to @relatorio, notice: 'Relatorio was successfully created.' }\n format.json { render :show, status: :created, location: @relatorio }\n else\n format.html { render :new }\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def medieval_composers\n response = RestClient.get 'https://api.openopus.org/composer/list/epoch/Medieval.json'\n json = JSON.parse response\n puts json\n\n if !json.nil?\n json[\"composers\"].map do |composer|\n Composer.create(name: \"#{composer[\"complete_name\"]}\", birth: \"#{composer[\"birth\"]}\", death: \"#{composer[\"death\"]}\", portrait: \"#{composer[\"portrait\"]}\", period_id: 1)\n end\n else\n puts \"Error seeding composers\"\n end\nend",
"def create\n @colaborator = Colaborator.new(colaborator_params)\n\n respond_to do |format|\n if @colaborator.save\n format.html { redirect_to @colaborator, notice: 'Colaborator was successfully created.' }\n format.json { render :show, status: :created, location: @colaborator }\n else\n format.html { render :new }\n format.json { render json: @colaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @doctor = Doctor.new(params[:doctor])\n\n if @doctor.save\n render json: @doctor, status: :created, location: @doctor\n else\n render json: @doctor.errors, status: :unprocessable_entity\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n client= Client.new\n client.cedula= params[:cedula]\n client.sector= params[:sector]\n client.nombre= params[:nombre]\n client.telefono= params[:telefono]\n client.pagina= params[:pagina]\n client.direccion= params[:direccion]\n if client.save\n render(json: client, status: 201 , location: client)\n else \n render(json: client.errors, status: 422)\n end\n end",
"def create\n\n client = Cliente.new\n\n client.nombre = params[:nombre]\n client.cedula = params[:cedula]\n client.pagina = params[:pagina]\n\n client.dirrecion = params[:dirrecion]\n client.telefono = params[:telefono]\n \n client.sector = params[:sector]\n \n\n if client.save\n \n\n render(json: client,status: 201 ,location: client)\n else\n\n render(json: client.errors,status: 422 )\n\n end\n end",
"def create\n @delegado = Delegado.new(delegado_params)\n\n respond_to do |format|\n if @delegado.save\n format.html { redirect_to @delegado, notice: 'Delegado was successfully created.' }\n format.json { render :show, status: :created, location: @delegado }\n else\n format.html { render :new }\n format.json { render json: @delegado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @directorio = Directorio.new(directorio_params)\n\n respond_to do |format|\n if @directorio.save\n format.html { redirect_to @directorio, notice: 'Directorio was successfully created.' }\n format.json { render :show, status: :created, location: @directorio }\n else\n format.html { render :new }\n format.json { render json: @directorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @collaborator = Collaborator.new(params[:collaborator])\n\n respond_to do |format|\n if @collaborator.save\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully created.' }\n format.json { render json: @collaborator, status: :created, location: @collaborator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dna = Dna.new(dna_params)\n\n if @dna.save\n render json: @dna, status: :created, location: @dna\n else\n render json: @dna.errors, status: :unprocessable_entity\n end\n end",
"def create\n if @mission.torched_by? current_user\n return respond_to do |format|\n format.html { redirect_to mission_path(@mission) }\n format.json { head :no_content }\n end\n end\n @mission.torches.create torcher: current_user\n respond_to do |format|\n # TODO: notification and activity\n format.html { redirect_to mission_path(@mission), notice: t('missions.torch_awarded_successfully') }\n format.json { render json: { count: @mission.torches.count } }\n end\n end",
"def create\n @torneo = Torneo.new(params[:torneo])\n\n respond_to do |format|\n if @torneo.save\n format.html { redirect_to @torneo, notice: 'Torneo was successfully created.' }\n format.json { render json: @torneo, status: :created, location: @torneo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @torneo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cordinate = Cordinate.new(cordinate_params)\n\n respond_to do |format|\n if @cordinate.save\n format.html { redirect_to @cordinate, notice: 'Cordinate was successfully created.' }\n format.json { render :show, status: :created, location: @cordinate }\n else\n format.html { render :new }\n format.json { render json: @cordinate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @commander = Commander.new(params[:commander])\n\n respond_to do |format|\n if @commander.save\n format.html { redirect_to @commander, notice: 'Commander was successfully created.' }\n format.json { render json: @commander, status: :created, location: @commander }\n else\n format.html { render action: \"new\" }\n format.json { render json: @commander.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_collaborator = Admin::Collaborator.new(params[:admin_collaborator])\n\n respond_to do |format|\n if @admin_collaborator.save\n format.html { redirect_to @admin_collaborator, notice: 'Collaborator was successfully created.' }\n format.json { render json: @admin_collaborator, status: :created, location: @admin_collaborator }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @delegation = Delegation.new(params[:delegation])\n\n respond_to do |format|\n if @delegation.save\n format.html { redirect_to @delegation, :notice => 'Delegation was successfully created.' }\n format.json { render :json => @delegation, :status => :created, :location => @delegation }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @delegation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cerc = Cerc.new(params[:cerc])\n\n if @cerc.save\n render json: @cerc, status: :created, location: @cerc\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def create_tobacco_cessation(options={})\n options = {\n access_token: options[:access_token],\n tobacco_cessation: {\n cigarettes_allowed: options[:cigarettes_allowed],\n cigarettes_smoked: options[:cigarettes_smoked],\n cravings: options[:cravings],\n last_smoked: options[:last_smoked],\n timestamp: options[:timestamp],\n source: options[:source]\n }\n }\n\n response = post(\"/#{Validic.api_version}/tobacco_cessation.json\", options)\n response if response\n end",
"def create\n p'*'*800\n p params\n\n @trainer = Trainer.new(trainer_params)\n\n p @trainer\n\n if @trainer.save\n render json: @trainer, status: :created, location: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @recolector = Recolector.new(recolector_params)\n\n respond_to do |format|\n if @recolector.save\n format.html { redirect_to @recolector, notice: 'Recolector was successfully created.' }\n format.json { render :show, status: :created, location: @recolector }\n else\n format.html { render :new }\n format.json { render json: @recolector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorio_colaborador = RelatorioColaborador.new(relatorio_colaborador_params)\n\n respond_to do |format|\n if @relatorio_colaborador.save\n format.html { redirect_to @relatorio_colaborador, notice: 'Relatorio colaborador was successfully created.' }\n format.json { render :show, status: :created, location: @relatorio_colaborador }\n else\n format.html { render :new }\n format.json { render json: @relatorio_colaborador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add(params)\n headers = {\n 'Cookie' => @context[:koha_rest_api_cookie],\n 'Content-Type' => 'application/json'\n }\n\n http = Net::HTTP.new(\"xkoha\", 8081)\n uri = URI(intranet(:koha_rest_api) + \"patrons\")\n res = http.post(uri, params.to_json, headers)\n expect(res.code).to eq(\"201\"), \"got unexpected #{res.code} when adding patron.\\nResponse body: #{res.body}\"\n res.body\n end",
"def create\n @donator = Donator.new(donator_params)\n\n respond_to do |format|\n if @donator.save\n format.html { redirect_to @donator, notice: \"Donator was successfully created.\" }\n format.json { render :show, status: :created, location: @donator }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @donator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lector = Lector.new(params[:lector])\n\n respond_to do |format|\n if @lector.save\n format.html { redirect_to @lector, notice: 'El nuevo lector se ha guardado correctamente.' }\n format.json { render json: @lector, status: :created, location: @lector }\n else\n format.html { render action: \"new\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @orador = Orador.new(params[:orador])\n\n respond_to do |format|\n if @orador.save\n format.html { redirect_to @orador, notice: 'Orador was successfully created.' }\n format.json { render json: @orador, status: :created, location: @orador }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @conductor = Conductor.new(params[:conductor])\n\n respond_to do |format|\n if @conductor.save\n format.html { redirect_to @conductor, notice: 'Conductor was successfully created.' }\n format.json { render json: @conductor, status: :created, location: @conductor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @conductor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cargo = Cargo.new(cargo_params)\n if @cargo.save\n render json: @cargo\n else\n render json: @cargo.errors, status: :unprocessable_entity\n end\n end",
"def test_create\n assert(nybg.curators.include?(rolf))\n curator_count = nybg.curators.count\n\n login(\"rolf\")\n post(:create, params: { id: nybg.id, add_curator: mary.login })\n assert_equal(curator_count + 1, nybg.reload.curators.count)\n assert_redirected_to(herbarium_path(nybg))\n end",
"def create\n @cultivator = Cultivator.new(cultivator_params)\n\n respond_to do |format|\n if @cultivator.save\n format.html { redirect_to @cultivator, notice: 'Cultivator was successfully created.' }\n format.json { render :show, status: :created, location: @cultivator }\n else\n format.html { render :new }\n format.json { render json: @cultivator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n from_interface = Interface.find(patchcord_params['from_node'])\n to_interface = Interface.find(patchcord_params['to_node'])\n @patchcord = Patchcord.new(from_node: from_interface,\n to_node: to_interface,\n length: patchcord_params['length'])\n\n respond_to do |format|\n if @patchcord.save\n format.html { redirect_to @patchcord, notice: 'Patchcord was successfully created.' }\n format.json { render :show, status: :created, location: @patchcord }\n else\n format.html { redirect_to new_patchcord_url, alert: @patchcord.errors }\n format.json { render json: @patchcord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @doctor_cliente = DoctorCliente.new(params[:doctor_cliente])\n\n respond_to do |format|\n if @doctor_cliente.save\n format.html { redirect_to @doctor_cliente, notice: 'Doctor cliente was successfully created.' }\n format.json { render json: @doctor_cliente, status: :created, location: @doctor_cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @doctor_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @responder = Responder.new(params[:responder])\n\n respond_to do |format|\n if @responder.save\n format.html { redirect_to @responder, :notice => 'Responder was successfully created.' }\n format.json { render :json => @responder, :status => :created, :location => @responder }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @responder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n @relatorio_pedagogico = RelatorioPedagogico.new(relatorio_pedagogico_params)\n\n respond_to do |format|\n if @relatorio_pedagogico.save\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico criado com sucesso!' }\n format.json { render :show, status: :created, location: @relatorio_pedagogico }\n else\n format.html { render :new }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # authorize preorder_conversition\n member = Member.where(id: params[:preorder_conversition][:member_id]).first\n @preorder_conversition = @site.preorder_conversitions.new(permitted_attributes(PreorderConversition).merge(user_id: current_user.id, member_name: member.name, member_phone: member.mobile_phone))\n if @preorder_conversition.save\n render json: {status: 'ok', url: agent_preorder_conversitions_path}\n else\n render json: {status: 'error', message:@preorder_conversition.errors.full_messages.join(',')}\n end\n end",
"def create\n @collaborator = Collaborator.new(collaborator_params)\n\n respond_to do |format|\n if @collaborator.save\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully created.' }\n format.json { render :show, status: :created, location: @collaborator }\n else\n format.html { render :new }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @collaborator = Collaborator.new(collaborator_params)\n\n respond_to do |format|\n if @collaborator.save\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully created.' }\n format.json { render :show, status: :created, location: @collaborator }\n else\n format.html { render :new }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n Rentlinx.client.post(self)\n end",
"def create\n @ordenanza = Ordenanza.new(ordenanza_params)\n\n respond_to do |format|\n if @ordenanza.save\n format.html { redirect_to @ordenanza, notice: 'Ordenanza was successfully created.' }\n format.json { render :show, status: :created, location: @ordenanza }\n else\n format.html { render :new }\n format.json { render json: @ordenanza.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @conductor = Conductor.new(conductor_params)\n\n if @conductor.save\n render :show, status: :created, location: @conductor\n else\n render json: @conductor.errors, status: :unprocessable_entity\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @director = Director.new(params[:director])\n\n respond_to do |format|\n if @director.save\n format.html { redirect_to @director, notice: 'Director was successfully created.' }\n format.json { render json: @director, status: :created, location: @director }\n else\n format.html { render action: \"new\" }\n format.json { render json: @director.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ordr = Ordr.new(ordr_params)\n @ordr.user_id = current_user.id\n @ordr.joined = 0\n @ordr.status = \"Waiting\"\n respond_to do |format|\n if @ordr.save\n uids = params[:ordr][:uids].split(',')\n oid = @ordr.id\n uids.each do |uid|\n if !uid.empty?\n noti = Notification.new\n noti.user_id = current_user.id\n noti.reciever_id = uid\n noti.ordr_id = oid\n noti.read = 0\n noti.joined = 0\n noti.seen = 0\n noti.save\n end\n end\n format.html { redirect_to @ordr, notice: 'Ordr was successfully created.' }\n format.json { render :show, status: :created, location: @ordr }\n else\n format.html { render :new }\n format.json { render json: @ordr.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @coordinador = Coordinador.new(params[:coordinador])\n\n respond_to do |format|\n if @coordinador.save\n format.html { redirect_to @coordinador, notice: 'Coordinador was successfully created.' }\n format.json { render json: @coordinador, status: :created, location: @coordinador }\n else\n format.html { render action: \"new\" }\n format.json { render json: @coordinador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params.permit(:pseudo_administrateur, :email_administrateur, :motDePasse_administrateur)\n ajout = AdministrateurService.instance.creerNouveauAdmin(params[:pseudo_administrateur], params[:email_administrateur], params[:motDePasse_administrateur])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def create\n @contacter = Contacter.new(params[:contacter])\n\n respond_to do |format|\n if @contacter.save\n format.html { redirect_to @contacter, notice: 'Contacter was successfully created.' }\n format.json { render json: @contacter, status: :created, location: @contacter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contacter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :admin, Coordenador\n \n @coordenador = Coordenador.new(params[:coordenador])\n\n respond_to do |format|\n if @coordenador.save\n format.html { redirect_to @coordenador, notice: 'Coordenador was successfully created.' }\n format.json { render json: @coordenador, status: :created, location: @coordenador }\n else\n format.html { render action: \"new\" }\n format.json { render json: @coordenador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @telefononegocio = Telefononegocio.new(params[:telefononegocio])\n\n respond_to do |format|\n if @telefononegocio.save\n format.html { redirect_to @telefononegocio, notice: 'Telefononegocio was successfully created.' }\n format.json { render json: @telefononegocio, status: :created, location: @telefononegocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @telefononegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @relatorio = Relatorio.new(relatorio_params)\r\n\r\n respond_to do |format|\r\n if @relatorio.save\r\n format.html { redirect_to @relatorio, notice: 'Relatório criado com sucesso.' }\r\n format.json { render :show, status: :created, location: @relatorio }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def method_missing(method, *args, &block)\n data = { method: method, parameters: args }\n request.post(path: nodes_path, data: data, auth_token: auth_token)\n end",
"def create\n @clonet = Clonet.new(params[:clonet])\n\n respond_to do |format|\n if @clonet.save\n format.html { redirect_to @clonet, notice: 'Clonet was successfully created.' }\n format.json { render json: @clonet, status: :created, location: @clonet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fornecedor_custo = FornecedorCusto.new(params[:fornecedor_custo])\n\n respond_to do |format|\n if @fornecedor_custo.save\n format.html { redirect_to @fornecedor_custo, notice: 'Fornecedor custo was successfully created.' }\n format.json { render json: @fornecedor_custo, status: :created, location: @fornecedor_custo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fornecedor_custo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cordinator_params\n params.require(:cordinator).permit(:name, :address, :phone)\n end",
"def create\n @colaborattor = Colaborattor.new(colaborattor_params)\n\n respond_to do |format|\n if @colaborattor.save\n format.html { redirect_to colaborattors_path, notice: I18n.t('messages.created_with', item: @colaborattor.colaborattorname) }\n format.json { render :show, status: :created, location: @colaborattor }\n else\n format.html { render :new }\n format.json { render json: @colaborattor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recitator = Recitator.new(recitator_params)\n\n respond_to do |format|\n if @recitator.save\n format.html { redirect_to @recitator, notice: 'Recitator was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recitator }\n else\n format.html { render action: 'new' }\n format.json { render json: @recitator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n response = Codeclimate::Api.client.post(@path)\n response.code == \"200\"\n end",
"def create\n # @doctor = Doctor.new(doctor_params)\n @centers = Center.all.order('name ASC')\n @doctor = current_user.doctors.build(doctor_params)\n\n respond_to do |format|\n if @doctor.save\n # format.html { redirect_to @doctor, notice: 'Doctor was successfully created.' }\n format.html { redirect_to doctors_path, notice: 'Doctor registrado exitosamente.'}\n format.json { render :show, status: :created, location: @doctor }\n else\n format.html { render :new }\n format.json { render json: @doctor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @actuator = Actuator.new(params[:actuator].each_value(&:strip!))\n @actuator.command = Command.new\n\n #if @actuator.save\n # @actuator.data_uri = actuator_commands_path(@atuator)\n # @actuator.configuration_uri = actuator_path(@actuator)\n #end \n\n respond_to do |format|\n if @actuator.save\n format.html { redirect_to(@actuator, :notice => 'Actuator was successfully created.') }\n format.xml { render :xml => @actuator, :status => :created, :location => @actuator }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @actuator.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # @route = Route.new(params[:route])\n \n waypoints = params[:waypoints]\n creator = params[:creator]\n updated_at = params[:updated_at]\n name = params[:name]\n\n @route = Route.new(waypoints: waypoints, creator: creator, updated_at: updated_at, name: name)\n \n @route.save\n\n render json: @route\n\n # @vote_creator = VoteCreator.new(vote_params)\n # @vote = @vote_creator.vote\n # if @vote_creator.save\n # render json: @vote, status: :created, location: @vote\n # else\n # render json: @vote.errors, status: :unprocessable_entity\n # end\n end",
"def create\n @delegacione = Delegacione.new(params[:delegacione])\n\n\n respond_to do |format|\n if @delegacione.save\n newAuditoria = Auditoria.new\n newAuditoria.tabla = params[:controller]\n newAuditoria.action = params[:action]\n newAuditoria.usuario = User.all.first.id\n newAuditoria.clave = @delegacione.id\n newAuditoria.save\n format.html { redirect_to @delegacione, notice: 'Delegacione was successfully created.' }\n format.json { render json: @delegacione, status: :created, location: @delegacione }\n else\n format.html { render action: \"new\" }\n format.json { render json: @delegacione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @trnodo = Trnodo.new(params[:trnodo])\n\n respond_to do |format|\n if @trnodo.save\n format.html { redirect_to @trnodo, notice: 'Trnodo was successfully created.' }\n format.json { render json: @trnodo, status: :created, location: @trnodo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @trnodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @candidato = Candidato.new(params[:candidato])\n\n respond_to do |format|\n if @candidato.save\n format.html { redirect_to @candidato, notice: 'Candidato was successfully created.' }\n format.json { render json: @candidato, status: :created, location: @candidato }\n else\n format.html { render action: \"new\" }\n format.json { render json: @candidato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @motorista = Motorista.new(motorista_params)\n\n respond_to do |format|\n if @motorista.save\n format.html { redirect_to @motorista, notice: 'Motorista was successfully created.' }\n format.json { render :show, status: :created, location: @motorista }\n else\n format.html { render :new }\n format.json { render json: @motorista.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @calendar = Calendar.new(params[:calendar])\n @calendar.update_attribute :user_id, current_user.id\n\n params[:doors].each_value do |door|\n @calendar.doors.build(door)\n end\n\n respond_to do |format|\n if @calendar.save\n format.html { redirect_to @calendar, notice: 'Calendar was successfully created.' }\n format.json { render json: @calendar, status: :created, location: @calendar }\n else\n format.html { render action: \"new\" }\n format.json { render json: @calendar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #debugger\n @resto = Restaurant.find(params[:relationship][:restaurant_id])\n current_user.follow!(@resto)\n #debugger\n #respond_with @resto\n redirect_to @resto\n end",
"def create\n @anexo_relatorio_colaborador = AnexoRelatorioColaborador.new(anexo_relatorio_colaborador_params)\n\n respond_to do |format|\n if @anexo_relatorio_colaborador.save\n format.html { redirect_to @anexo_relatorio_colaborador, notice: 'Anexo relatorio colaborador was successfully created.' }\n format.json { render :show, status: :created, location: @anexo_relatorio_colaborador }\n else\n format.html { render :new }\n format.json { render json: @anexo_relatorio_colaborador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torneo = Torneo.new(torneo_params)\n\n respond_to do |format|\n if @torneo.save\n format.html { redirect_to @torneo, notice: 'Torneo fue creado exitosamente.' }\n format.json { render :show, status: :created, location: @torneo }\n else\n format.html { render :new }\n format.json { render json: @torneo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n seleccionarMenu(:rondas)\n @ronda = current_usuario.rondas.build(params[:ronda])\n\n respond_to do |format|\n if @ronda.save\n format.html { redirect_to @ronda, notice: 'Ronda creada satisfactoriamente.' }\n format.json { render json: @ronda, status: :created, location: @ronda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ronda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dino = Dino.new(dino_params)\n\n if @dino.save\n render json: @dino, status: :created, location: @dino\n else\n render json: @dino.errors, status: :unprocessable_entity\n end\n end",
"def create\n @demonstrator = Demonstrator.new(demonstrator_params)\n\n respond_to do |format|\n if @demonstrator.save\n format.html { redirect_to @demonstrator, notice: 'Demonstrator was successfully created.' }\n format.json { render :show, status: :created, location: @demonstrator }\n else\n format.html { render :new }\n format.json { render json: @demonstrator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @therapist = Therapist.new(therapist_params.merge({code: create_code}))\n if @therapist.save\n render :json => {\n id: @therapist.id,\n email: @therapist.email,\n firstName: @therapist.first_name,\n lastName: @therapist.last_name,\n prefix: @therapist.prefix,\n profession: @therapist.profession,\n code: @therapist.code,\n token: get_token(@therapist)\n }\n else\n render json: @therapist.errors, status: :unprocessable_entity\n # render json: @therapist.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(*['custids','acctids','itemids'])\n\t\t\n\t\t# ok, this join stuff is bogus - it encodes properly, but the other side only sees the last element and loses the array type - it's just string\n\t\t# this way, i 'split' it at the other side to recover my array\n\t\t# it should work without the join/split crap, but it doesn't\n\t\trequest.set_form_data({:custids => ( params['custids'] || []).join(','), :acctids => ( params['acctids'] || []).join(','), :itemids => ( params['itemids'] || []).join(','), :amount => params['amount'], :type => params['type']})\n\t\t\n\t\tputs request.body\n\t\t\n\t\tresponse = http.request(request)\n\t\tputs response.body\n\n respond_to do |format|\n format.html { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n format.json { render :text => response.code == :ok ? \"\" : response.body, status: response.code }\n end\n end",
"def create\n @auttor = Auttor.new(auttor_params)\n\n respond_to do |format|\n if @auttor.save\n format.html { redirect_to @auttor, notice: 'Auttor was successfully created.' }\n format.json { render :show, status: :created, location: @auttor }\n else\n format.html { render :new }\n format.json { render json: @auttor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n cartoon_ad = CartoonAd.create(cartoon_ad_params)\n render json: cartoon_ad\n end",
"def create_new_customer \n ForestOperations.link_parent_child_nodes_return_parent(\n ForestOperations.create_node(\n line_content[:sent_or_accepted_by],\n :accepted),\n ForestOperations.create_node(\n line_content[:recived_by]\n ) \n )\n end",
"def create\n @creator_accession_relationship = CreatorAccessionRelationship.new(params[:creator_accession_relationship])\n\n respond_to do |format|\n if @creator_accession_relationship.save\n format.html { redirect_to @creator_accession_relationship, notice: 'Creator accession relationship was successfully created.' }\n format.json { render json: @creator_accession_relationship, status: :created, location: @creator_accession_relationship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @creator_accession_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @orden = Orden.new(params[:orden])\n\n respond_to do |format|\n if @orden.save\n format.html { redirect_to @orden, notice: 'Orden was successfully created.' }\n format.json { render json: @orden, status: :created, location: @orden }\n else\n format.html { render action: \"new\" }\n format.json { render json: @orden.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def create\n @responder = Responder.new(responder_params)\n\n respond_to do |format|\n if @responder.save\n format.html { redirect_to @responder, notice: 'Responder was successfully created.' }\n format.json { render :show, status: :created, location: @responder }\n else\n format.html { render :new }\n format.json { render json: @responder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @custo = Custo.new(params[:custo])\n\n respond_to do |format|\n if @custo.save\n format.html { redirect_to @custo, notice: 'Custo was successfully created.' }\n format.json { render json: @custo, status: :created, location: @custo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @custo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n expose Challenge.create(@oauth_token, params[:data])\n end",
"def create\n # byebug\n @survey_creator = SurveyCreator.create(survey_creator_params)\n if @survey_creator.valid?\n wristband = encode_token({ survey_creator_id: @survey_creator.id })\n render json: { survey_creator: SurveyCreatorSerializer.new(@survey_creator), token: wristband }\n else\n render json: { error: 'Invalid username or password' }\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_ordem\n @cliente = Cliente.new(params[:cliente])\n\n respond_to do |format|\n if @cliente.save\n\t@ordem = Ordem.new(:cliente_id => @cliente.id, :user_id => current_user.id)\n\tif @ordem.save\n\t\tformat.html { redirect_to @ordem, notice: 'O cliente foi adicionado com sucesso.' }\n\t\tformat.json { render json: @cliente, status: :created, location: @cliente }\n\telse\n\t\tformat.html { render action: \"index\" }\n \tformat.json { render json: @cliente.errors, status: :unprocessable_entity }\n\tend\n else\n format.html { render action: \"new_for_order\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(data) # rubocop:disable Rails/Delegate\n client.create(data)\n end",
"def create\n @delegation = Delegation.new(delegation_params)\n\n respond_to do |format|\n if @delegation.save\n format.html { redirect_to @delegation, notice: 'Delegation was successfully created.' }\n format.json { render :show, status: :created, location: @delegation }\n else\n format.html { render :new }\n format.json { render json: @delegation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @canon = Canon.new(params[:canon])\n\n respond_to do |format|\n if @canon.save\n format.html { redirect_to @canon, notice: 'Canon was successfully created.' }\n format.json { render json: @canon, status: :created, location: @canon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @canon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n discounts = []\n (1..params[:discount_number].to_i).each do |i|\n @discount = Discount.new(params[:discount])\n @discount.generate_token params[:discount_six_length].to_i\n @discount.save\n discounts << @discount\n end\n respond_to do |format|\n format.html { redirect_to discounts_url, notice: I18n.t(:discount_created, n: params[:discount][:name], c: params[:discount_number] ) }\n format.json { render json: discounts, status: :created, location: discounts }\n end\n end",
"def create\n @fornecedor = Fornecedor.new(fornecedor_params)\n\n respond_to do |format|\n if @fornecedor.save\n format.html { redirect_to @fornecedor, notice: 'Fornecedor was successfully created.' }\n format.json { render :show, status: :created, location: @fornecedor }\n else\n format.html { render :new }\n format.json { render json: @fornecedor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @delegation = Delegation.new(delegation_params)\n\n respond_to do |format|\n if @delegation.save\n format.html { redirect_to @delegation, notice: \"Delegation was successfully created.\" }\n format.json { render :show, status: :created, location: @delegation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @delegation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n require 'securerandom'\n #candidato_params += [\"key\" => SecureRandom.urlsafe_base64(10)]\n @candidato = Candidato.new(candidato_params)\n respond_to do |format|\n if @candidato.save\n format.html { redirect_to @candidato, notice: 'Candidato was successfully created.' }\n format.json { render :show, status: :created, location: @candidato }\n #ApplicationMailer.sendMail(@candidato.email.to_s, \"https://casd-adautobraz.c9users.io/\".concat(@candidato.key.to_s))\n else\n format.html { render :new }\n format.json { render json: @candidato.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n passenger = Passenger.new(:name => params[:name], :contact_number => params[:contact_number], :nationality => params[:nationality], :meal_pref => params[:meal_pref])\n passenger.save\n render :json => passenger\n end",
"def create\n @cliente = Cliente.new(cliente_params)\n\n respond_to do |format|\n if @cliente.save\n #--ADICIONADO\n if params[:cliente][:perfil_ids]\n \t\t params[:cliente][:perfil_ids].each do |ss|\n \t\t\t @cliente.perfilclientes.create(:cliente_id => @cliente.id, :perfil_id => ss)\n \t\t end\n end\n #--ADICIONADO\n format.html { redirect_to clientes_url, notice: 'Cliente criado com sucesso.' }\n format.json { render action: 'show', status: :created, location: @cliente }\n else\n format.html { render action: 'new' }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torso = Torso.new(params[:torso])\n\n respond_to do |format|\n if @torso.save\n format.html { redirect_to @torso, notice: 'Torso was successfully created.' }\n format.json { render json: @torso, status: :created, location: @torso }\n else\n format.html { render action: \"new\" }\n format.json { render json: @torso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @educator = Educator.new(educator_params)\n\n respond_to do |format|\n if @educator.save\n format.html { redirect_to @educator, notice: 'Educator was successfully created.' }\n format.json { render :show, status: :created, location: @educator }\n else\n format.html { render :new }\n format.json { render json: @educator.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.60080016",
"0.5506219",
"0.54745144",
"0.5445114",
"0.54281193",
"0.5355071",
"0.5354252",
"0.5341191",
"0.5331485",
"0.53251165",
"0.53107536",
"0.53016144",
"0.52887005",
"0.5285094",
"0.52657056",
"0.5245813",
"0.52454466",
"0.5236012",
"0.5230248",
"0.5229306",
"0.5202732",
"0.5178209",
"0.51771545",
"0.517364",
"0.5173112",
"0.51653427",
"0.515941",
"0.5147423",
"0.51443785",
"0.5142948",
"0.51376146",
"0.51375216",
"0.5134894",
"0.51325536",
"0.51221466",
"0.5118518",
"0.5113754",
"0.5108821",
"0.5105113",
"0.5094194",
"0.5094194",
"0.50801516",
"0.50771797",
"0.50754094",
"0.5054883",
"0.5043086",
"0.5042575",
"0.5034956",
"0.503135",
"0.5027891",
"0.5026671",
"0.50255567",
"0.501572",
"0.5014484",
"0.50062966",
"0.5002463",
"0.4998971",
"0.4998554",
"0.49907947",
"0.49791658",
"0.49740773",
"0.4973981",
"0.49684325",
"0.49655715",
"0.49625587",
"0.49620554",
"0.49555022",
"0.4951888",
"0.49465847",
"0.49438784",
"0.49403206",
"0.49376458",
"0.49359718",
"0.4933824",
"0.49335703",
"0.49334547",
"0.49308297",
"0.49303734",
"0.49210787",
"0.49207383",
"0.49180636",
"0.49112153",
"0.49111682",
"0.49093646",
"0.49093238",
"0.4894418",
"0.48850623",
"0.48824298",
"0.4879654",
"0.48737368",
"0.48731875",
"0.4872088",
"0.48658338",
"0.4865438",
"0.4861957",
"0.4850519",
"0.4850259",
"0.48489523",
"0.48479354",
"0.48467425"
] | 0.56536317 | 1 |
PATCH/PUT /cordinators/1 PATCH/PUT /cordinators/1.json | def update
respond_to do |format|
if @cordinator.update(cordinator_params)
format.html { redirect_to @cordinator, notice: 'El cordinador se ha actualizado correctamente' }
format.json { render :show, status: :ok, location: @cordinator }
else
format.html { render :edit }
format.json { render json: @cordinator.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def patch!\n request! :patch\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @collaborator = Collaborator.find(params[:id])\n\n respond_to do |format|\n if @collaborator.update_attributes(params[:collaborator])\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cord.update(cord_params)\n format.html { redirect_to @cord, notice: t('cords.update.success') }\n format.json { render :show, status: :ok, location: @cord }\n else\n format.html { render :edit }\n format.json { render json: @cord.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n\n respond_to do |format|\n if @admin_collaborator.update_attributes(params[:admin_collaborator])\n format.html { redirect_to @admin_collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_collaborator.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 authorize! :update, Client\n load_client\n build_client\n save_client or render :edit\n end",
"def update\n respond_to do |format|\n if @colaborator.update(colaborator_params)\n format.html { redirect_to @colaborator, notice: 'Colaborator was successfully updated.' }\n format.json { render :show, status: :ok, location: @colaborator }\n else\n format.html { render :edit }\n format.json { render json: @colaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @conductor = Conductor.find(params[:id])\n\n respond_to do |format|\n if @conductor.update_attributes(params[:conductor])\n format.html { redirect_to @conductor, notice: 'Conductor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conductor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client.update(client_params)\n render json: @client\n end",
"def update\n @clonet = Clonet.find(params[:id])\n\n respond_to do |format|\n if @clonet.update_attributes(params[:clonet])\n format.html { redirect_to @clonet, notice: 'Clonet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clonet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n put :update\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 @crust = Crust.find(params[:id])\n\n respond_to do |format|\n if @crust.update_attributes(params[:crust])\n format.html { redirect_to @crust, notice: 'Crust was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @crust.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n end",
"def update\n # this action is not provided for partyroles\n end",
"def update\n \n\n @client.redirect_urls << client_params[:add_redirect_url] if client_params[:add_redirect_url]\n \n @client.app_ids << BSON::ObjectId.new.to_s if client_params[:add_app_id]\n \n \n @client.versioned_update({\"redirect_urls\" => 1, \"app_ids\" => 1})\n\n if @client.op_success?\n render \"show\"\n else\n render \"edit\"\n end\n \n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @collaborator.update(collaborator_params)\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { render :show, status: :ok, location: @collaborator }\n else\n format.html { render :edit }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collaborator.update(collaborator_params)\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { render :show, status: :ok, location: @collaborator }\n else\n format.html { render :edit }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collaborator.update(collaborator_params)\n format.html { redirect_to @collaborator, notice: 'Collaborator was successfully updated.' }\n format.json { render :show, status: :ok, location: @collaborator }\n else\n format.html { render :edit }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end",
"def update\n # binding.pry;''\n @occasion.administrators << User.find(params[:adminstrator]) if params[:adminstrator]\n respond_to do |format|\n if @occasion.update(occasion_params)\n format.html { redirect_to @occasion, notice: 'Occasion was successfully updated.' }\n format.json { render :show, status: :ok, location: @occasion }\n else\n format.html { render :edit }\n format.json { render json: @occasion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'El cliente se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @collaborator.update(collaborator_params)\n format.html { redirect_to :back, notice: \"Le Collaborateur #{@collaborator.name} a été modifié avec succès.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :admin, Coordenador\n \n @coordenador = Coordenador.find(params[:id])\n\n respond_to do |format|\n if @coordenador.update_attributes(params[:coordenador])\n format.html { redirect_to @coordenador, notice: 'Coordenador was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coordenador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lector = Lector.find(params[:id])\n\n respond_to do |format|\n if @lector.update_attributes(params[:lector])\n format.html { redirect_to @lector, notice: 'Las modificaciones al Lector se han guardado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lector.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to_update({thing: @author})\n end",
"def update\n @commander = Commander.find(params[:id])\n\n respond_to do |format|\n if @commander.update_attributes(params[:commander])\n format.html { redirect_to @commander, notice: 'Commander was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @commander.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @cordinate.update(cordinate_params)\n format.html { redirect_to @cordinate, notice: 'Cordinate was successfully updated.' }\n format.json { render :show, status: :ok, location: @cordinate }\n else\n format.html { render :edit }\n format.json { render json: @cordinate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @aucrecord.update(aucrecord_params)\n format.html { redirect_to @aucrecord, notice: 'Aucrecord was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @aucrecord.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 id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:update [ID] [options]\")\n\n if options.empty?\n raise(Heroku::Command::CommandFailed, \"Missing options\")\n end\n\n validate!(options[:url]) if options[:url]\n shell = options.delete(:shell)\n options[:redirect_uri] = options.delete(:url)\n\n client = request do\n api.request(\n :body => encode_json(options),\n :expects => 200,\n :headers => headers,\n :method => :patch,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if shell\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Updated client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end",
"def update(percolator, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:percolator] = percolator\n\n response = @client.put \"/api/topics/#{@topic_id}/percolators/#{@id}\", body, options\n\n return response\n end",
"def update\n #@patron = Patron.find(params[:id])\n\n respond_to do |format|\n if @patron.update_attributes(params[:patron])\n flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.patron'))\n format.html { redirect_to patron_url(@patron) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render :action => \"edit\" }\n format.json { render :json => @patron.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @contacter = Contacter.find(params[:id])\n\n respond_to do |format|\n if @contacter.update_attributes(params[:contacter])\n format.html { redirect_to @contacter, notice: 'Contacter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contacter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n head :unauthorized\n end",
"def update\n respond_with []\n end",
"def update\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:username] = current_user.username\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @client.update_attributes(client_params)\r\n format.html { redirect_to @client, notice: 'Client 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: @client.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @coordinador = Coordinador.find(params[:id])\n\n respond_to do |format|\n if @coordinador.update_attributes(params[:coordinador])\n format.html { redirect_to @coordinador, notice: 'Coordinador was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @coordinador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_client\n\t\tif(request.method == \"OPTIONS\")\n\t\t\trespond({status: 0})\n\t\telsif request.method == \"POST\"\n\t\t\trespond(update_user_client(params))\n\t\tend\n\tend",
"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 patch\n Rentlinx.client.patch(self)\n end",
"def update\n @client = Client.find(params[:id])\n authorize! :update, @client\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.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 @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def update(options = {})\n @client.put(self.link(:edit), self.to_json, options)\n end",
"def update\n @doctor_cliente = DoctorCliente.find(params[:id])\n\n respond_to do |format|\n if @doctor_cliente.update_attributes(params[:doctor_cliente])\n format.html { redirect_to @doctor_cliente, notice: 'Doctor cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @doctor_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, **args); end",
"def update\n respond_to do |format|\n if @leadership.update(leadership_params)\n format.html { redirect_to @leadership, notice: 'Leadership was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leadership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @responder = Responder.find(params[:id])\n\n respond_to do |format|\n if @responder.update_attributes(params[:responder])\n format.html { redirect_to @responder, :notice => 'Responder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @responder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n expose Challenge.update(@oauth_token, params[:challenge_id].strip,\n params[:data])\n end",
"def update\n respond_to do |format|\n succeess_redirect_path = URI(request.referer).path.gsub 'edit', ''\n if @client.update(client_params)\n format.html { redirect_to succeess_redirect_path, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { redirect_to URI(request.referer).path }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Klijent je uspjesno izmjenjen.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @colaborattor.update(colaborattor_params)\n format.html { redirect_to colaborattors_path, notice: I18n.t('messages.updated_with', item: @colaborattor.colaborattorname) }\n format.json { render :show, status: :ok, location: @colaborattor }\n else\n format.html { render :edit }\n format.json { render json: @colaborattor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end",
"def update\n respond_to do |format|\n if @reqcargo.update(reqcargo_params)\n format.html { redirect_to @reqcargo, notice: 'Reqcargo was successfully updated.' }\n format.json { render :show, status: :ok, location: @reqcargo }\n else\n format.html { render :edit }\n format.json { render json: @reqcargo.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 head 404\n # @api_v1_follower = Api::V1::Follower.find(params[:id])\n\n # if @api_v1_follower.update(api_v1_follower_params)\n # head :no_content\n # else\n # render json: @api_v1_follower.errors, status: :unprocessable_entity\n # end\n end",
"def update\n respond_to do |format|\n if @relatorio.update(relatorio_params)\n format.html { redirect_to @relatorio, notice: 'Relatorio was successfully updated.' }\n format.json { render :show, status: :ok, location: @relatorio }\n else\n format.html { render :edit }\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_client\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n respond_to do |format|\n if params[:client][:permalink].present?\n @client.update_attributes(:slug => params[:client][:permalink])\n end\n if @client.update_attributes(params[:client])\n format.html { redirect_to edit_admin_path(@client), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to new_admin_session_path and return\n end \n end",
"def update\nlogger.debug \"update discipline: \"[email protected]\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end",
"def update\n @cerc = Cerc.find(params[:id])\n\n if @cerc.update_attributes(params[:cerc])\n head :no_content\n else\n render json: @cerc.errors, status: :unprocessable_entity\n end\n end",
"def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # NOTE: API V1 dropped support for updating client keys via update (aka PUT),\n # but this code never supported key updating in the first place. Since\n # it was never implemented, we will simply ignore that functionality\n # as it is being deprecated.\n # Delete this comment after V0 support is dropped.\n payload = { name: name }\n payload[:validator] = validator unless validator.nil?\n\n # DEPRECATION\n # This field is ignored in API V1, but left for backwards-compat,\n # can remove after API V0 is no longer supported.\n payload[:admin] = admin unless admin.nil?\n\n begin\n new_client = chef_rest_v1.put(\"clients/#{name}\", payload)\n rescue Net::HTTPClientException => e\n # rescue API V0 if 406 and the server supports V0\n supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS)\n raise e unless supported_versions && supported_versions.include?(0)\n\n new_client = chef_rest_v0.put(\"clients/#{name}\", payload)\n end\n\n Chef::ApiClientV1.from_hash(new_client)\n end",
"def update\n respond_to do |format|\n if @command.update(command_params)\n format.json { render :json => @command }\n else\n format.json { render json: @command.errors, status: 401 }\n end\n end\n end",
"def set_patchcord\n @patchcord = Patchcord.find(params[:id])\n end",
"def update\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @leader = Leader.find(params[:id])\n\n respond_to do |format|\n if @leader.update_attributes(params[:leader])\n format.html { redirect_to @leader, notice: 'Leader was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @leader.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crate.update(crate_params)\n format.html { redirect_to tenant_crates_path(@tenant), notice: 'Crate was successfully updated.' }\n format.json { render :show, status: :ok, location: @crate }\n else\n format.html { render :edit }\n format.json { render json: @crate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clinic = Clinic.find(params[:id])\n authorize! :update, @clinic\n #raise params.inspect\n #admin_id = params[:clinic].delete(:administrator_id)\n \n @clinic = Clinic.find(params[:id])\n #@clinic.administrator_id = admin_id\n\n respond_to do |format|\n if @clinic.update_attributes(params[:clinic])\n format.html { redirect_to @clinic, notice: 'Clinica editada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clinic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trein_consul_comercial.update(trein_consul_comercial_params)\n format.html { redirect_to @trein_consul_comercial, notice: 'Trein consul comercial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trein_consul_comercial.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @remixer.update(remixer_params)\n format.html { redirect_to @remixer, notice: 'Remixer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @remixer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @originator\n respond_to do |format|\n if @originator.update(originator_params)\n format.html { redirect_to @originator, success: I18n.t('notices.updated', entity: Originator.model_name.human, title: @originator.name) }\n format.json { render :show, status: :ok, location: @originator }\n else\n format.html { render :edit }\n format.json { render json: @originator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cultivator.update(cultivator_params)\n format.html { redirect_to @cultivator, notice: 'Cultivator was successfully updated.' }\n format.json { render :show, status: :ok, location: @cultivator }\n else\n format.html { render :edit }\n format.json { render json: @cultivator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @relatorio_colaborador.update(relatorio_colaborador_params)\n format.html { redirect_to @relatorio_colaborador, notice: 'Relatorio colaborador was successfully updated.' }\n format.json { render :show, status: :ok, location: @relatorio_colaborador }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_colaborador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n @clients = get_clients\n #format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n #format.html { render action: \"index\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n if @climate.update_attributes(params[:climate])\n format.html { redirect_to climates_path, notice: 'Climate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @climate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @couch.update(couch_params)\n format.html { redirect_to @couch, notice: 'Couche was successfully updated.' }\n format.json { render :show, status: :ok, location: @couch }\n else\n format.html { render :edit }\n format.json { render json: @couch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n if @circulation.update_attributes(params[:circulation])\n format.html { redirect_to @circulation, notice: 'Circulation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @circulation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recitator.update(recitator_params)\n format.html { redirect_to @recitator, notice: 'Recitator was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @recitator.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => \"Client was successfully updated. #{undo_link}\") }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to edit_cliente_path(@cliente), notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.61959916",
"0.61746824",
"0.6141433",
"0.61092645",
"0.60911775",
"0.6066104",
"0.60299885",
"0.5993334",
"0.5988145",
"0.59813017",
"0.59496444",
"0.59359086",
"0.59230864",
"0.59155315",
"0.59032506",
"0.58857113",
"0.5864647",
"0.57712567",
"0.57603264",
"0.5755869",
"0.5753953",
"0.5753691",
"0.5749513",
"0.5747333",
"0.5747333",
"0.5747333",
"0.57324106",
"0.572309",
"0.5706846",
"0.570234",
"0.5699827",
"0.5690474",
"0.56879085",
"0.566347",
"0.5662099",
"0.5642424",
"0.56409514",
"0.5639479",
"0.5634528",
"0.5623203",
"0.56147134",
"0.56117994",
"0.560988",
"0.5608683",
"0.5608683",
"0.56010216",
"0.56000245",
"0.55828714",
"0.5581541",
"0.5577876",
"0.5575571",
"0.55753225",
"0.5573177",
"0.5567517",
"0.5565874",
"0.556569",
"0.55622727",
"0.55559486",
"0.5554949",
"0.55545896",
"0.5552506",
"0.5550812",
"0.5549399",
"0.5548029",
"0.55452245",
"0.55452245",
"0.5543364",
"0.5541985",
"0.55380213",
"0.5535969",
"0.5533802",
"0.55328655",
"0.55326104",
"0.5525711",
"0.552541",
"0.5522387",
"0.5520295",
"0.5520295",
"0.55177635",
"0.55163157",
"0.5515382",
"0.5515312",
"0.55116105",
"0.55095226",
"0.55087626",
"0.5506809",
"0.5505136",
"0.5504227",
"0.55027723",
"0.5501261",
"0.5499454",
"0.5495729",
"0.5495366",
"0.5492958",
"0.5488668",
"0.5486484",
"0.54771346",
"0.54750675",
"0.5474516",
"0.54677147"
] | 0.59656715 | 10 |
DELETE /cordinators/1 DELETE /cordinators/1.json | def destroy
@cordinator.destroy
respond_to do |format|
format.html { redirect_to cordinators_url, notice: 'El cordinador se ha eliminado correctamente' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @cord.destroy\n respond_to do |format|\n format.html { redirect_to cords_url, notice: t('cords.destroy.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n [email protected]\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete!\n Recliner.delete(uri)\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end",
"def destroy\n @client.delete( name )\n end",
"def destroy\n @client.delete(@name)\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 url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conductor = Conductor.find(params[:id])\n @conductor.destroy\n\n respond_to do |format|\n format.html { redirect_to conductors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @crust = Crust.find(params[:id])\n @crust.destroy\n\n respond_to do |format|\n format.html { redirect_to crusts_url }\n format.json { head :no_content }\n end\n end",
"def delete!\n request! :delete\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\r\n @client = Client.find(params[:id])\r\n @client.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to clients_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Данные по клиенту удалены.' }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @commander = Commander.find(params[:id])\n @commander.destroy\n\n respond_to do |format|\n format.html { redirect_to commanders_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @client = Client.find(params[:id])\n authorize! :update, @client\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n \n if @client.deleted_at.blank?\n @client.destroy\n else\n @client.revive\n end\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :ok }\n end\n end",
"def destroy\n @contacter = Contacter.find(params[:id])\n @contacter.destroy\n\n respond_to do |format|\n format.html { redirect_to contacters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n clients_delete(@entity)\n @entity.destroy\n respond_to do |format|\n format.html { redirect_to clients_path }\n format.json { render json: {success: true} }\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete\n api(\"Delete\")\n end",
"def destroy\n user = User.find(params[:id])\n senator = Senator.find(params[:senator_id])\n user.senators.delete(senator)\n render json: user.senators\n end",
"def destroy\n @recitator.destroy\n respond_to do |format|\n format.html { redirect_to recitators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client a été supprimer.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doctor_cliente = DoctorCliente.find(params[:id])\n @doctor_cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to doctor_clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'El Cliente fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to collaborators_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def destroy\n @patchcord.destroy\n respond_to do |format|\n format.html { redirect_to patchcords_url, notice: 'Patchcord was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @colaborator.destroy\n respond_to do |format|\n format.html { redirect_to colaborators_url, notice: 'Colaborator was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cordinate.destroy\n respond_to do |format|\n format.html { redirect_to cordinates_url, notice: 'Cordinate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n Accessor.find(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to accessors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cervejarium = Cervejarium.find(params[:id])\n @cervejarium.destroy\n\n respond_to do |format|\n format.html { redirect_to cervejaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @otg_client.destroy\n respond_to do |format|\n format.html { redirect_to otg_clients_url, notice: 'Otg client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n @admin_collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_collaborators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente excluído com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recolector.destroy\n respond_to do |format|\n format.html { redirect_to recolectors_url, notice: 'Recolector was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @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 @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n \n respond_to do |format|\n format.html { redirect_to clients_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_accessory.destroy\n respond_to do |format|\n format.html { redirect_to client_accessories_url, notice: 'Client accessory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Users.delete(params[\"id\"])\n end",
"def destroy\n authorize @client\n @client.destroy\n respond_to do |format|\n format.html { redirect_back_or_default clients_url, t('Record has been deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatorio.destroy\n respond_to do |format|\n format.html { redirect_to relatorios_url, notice: 'Relatorio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @directorio.destroy\n respond_to do |format|\n format.html { redirect_to directorios_url, notice: 'Directorio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chaine = Chaine.find(params[:id])\n @chaine.destroy\n\n respond_to do |format|\n format.html { redirect_to chaines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientepedido = Clientepedido.find(params[:id])\n @clientepedido.destroy\n\n respond_to do |format|\n format.html { redirect_to clientepedidos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to canvases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @couch.destroy\n respond_to do |format|\n format.html { redirect_to couches_url, notice: 'Couche was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @authorized_client.destroy\n respond_to do |format|\n format.html {redirect_to authorized_clients_url, notice: 'Authorized client was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\n end",
"def destroy\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to admins_url }\n format.json { head :no_content }\n end\n else\n redirect_to new_admin_session_path and return\n end \n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @coordinador = Coordinador.find(params[:id])\n @coordinador.destroy\n\n respond_to do |format|\n format.html { redirect_to coordinadors_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7258742",
"0.7114767",
"0.693792",
"0.6838794",
"0.6816151",
"0.68074024",
"0.67969173",
"0.6780562",
"0.6769751",
"0.673742",
"0.67337257",
"0.6727356",
"0.6705943",
"0.6698743",
"0.6698743",
"0.6691693",
"0.66801524",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6667553",
"0.6663135",
"0.66604143",
"0.66604143",
"0.6644447",
"0.664242",
"0.6630156",
"0.66255635",
"0.6622551",
"0.6615644",
"0.66138756",
"0.6605336",
"0.6605284",
"0.6602466",
"0.6602466",
"0.6602466",
"0.6602466",
"0.66020435",
"0.659988",
"0.6594088",
"0.6587218",
"0.6580902",
"0.6570817",
"0.65676165",
"0.6554706",
"0.6550168",
"0.6546555",
"0.6544952",
"0.653744",
"0.6533244",
"0.65292144",
"0.65257597",
"0.65143293",
"0.65143293",
"0.65120715",
"0.6510851",
"0.6505266",
"0.6498907",
"0.6498722",
"0.64986897",
"0.64930975",
"0.64918226",
"0.64915276",
"0.6482203",
"0.6478876",
"0.6476253",
"0.6472353",
"0.6470346",
"0.6466968",
"0.6465355",
"0.6464894",
"0.6464447",
"0.6457365",
"0.6455914",
"0.6451778",
"0.64497167",
"0.64497167",
"0.64497167",
"0.644571",
"0.6444671",
"0.64405775",
"0.64366686",
"0.64344394",
"0.6432448",
"0.6430707",
"0.64291155",
"0.6423699",
"0.6419849",
"0.6419773",
"0.64190334",
"0.64147294",
"0.64119273",
"0.64088744",
"0.64067155",
"0.64065874"
] | 0.70559186 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_cordinator
@cordinator = Cordinator.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 cordinator_params
params.require(:cordinator).permit(:name, :address, :phone)
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 |
Never trust parameters from the scary internet, only allow the white list through. | def requests_cloning_params
params.require(:requests_cloning).permit(:name, :company, :mail, :phone, :shipping_address, :group_leader,
:payment_method, :sample_name, :sample_volume, :pcr_product_size,
:req_type, :sequencing_type, :inv_name, :inv_rfc, :inv_address, :inv_city,
:inv_municipality, :inv_state_id, :inv_mail)
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 social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\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 filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n 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 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 backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\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 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.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62909746",
"0.62904227",
"0.62837297",
"0.6240993",
"0.6239739",
"0.6217764",
"0.6214983",
"0.62112504",
"0.6194765",
"0.6178",
"0.61755055",
"0.61729854",
"0.61636627",
"0.6153461",
"0.6151674",
"0.61478525",
"0.6122671",
"0.61188513",
"0.61075556",
"0.6105721",
"0.6092412",
"0.6081011",
"0.6071054",
"0.6064436",
"0.6022111",
"0.6018135",
"0.60151577",
"0.60108894",
"0.60070235",
"0.60070235",
"0.6000806",
"0.6000464",
"0.5998811",
"0.59926987",
"0.5992257",
"0.5991173",
"0.5980311",
"0.59660876",
"0.59596545",
"0.5959415",
"0.59589994",
"0.5957478",
"0.5953214",
"0.5952233",
"0.5944033",
"0.59396756",
"0.59396756",
"0.59386414",
"0.59345603",
"0.5931261",
"0.5926345",
"0.5925795",
"0.59174526",
"0.59108645",
"0.5909469",
"0.5908263",
"0.59053195",
"0.58980685",
"0.5897738",
"0.589657",
"0.5895971",
"0.58942044",
"0.5892847",
"0.588742",
"0.58834344",
"0.5880024",
"0.58739793",
"0.5868253",
"0.5867907",
"0.58670515",
"0.58668053",
"0.5865756",
"0.5863549",
"0.5863236",
"0.5862728",
"0.5861283",
"0.58591247",
"0.5855159",
"0.5854291",
"0.58512247",
"0.58498096"
] | 0.0 | -1 |
GET /forum/topics GET /forum/topics.json | def index
@forum_topics = Forum::Topic.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forum_get_topics(args={})\n JSON.parse(HelpSpot.api_request('forums.getTopics', 'GET', {:xForumId => args[:forum_id]}.merge(args)))['topic'] rescue []\n end",
"def show\n\t\t@forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.order(\"created_at DESC\")\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend",
"def GetTopicsByForum id,params = {}\n\n params = params.merge(path: \"forums/#{id}/topics.json\")\n APICall(params)\n\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def topics\n client = Comments.discourse\n @topics = client.latest_topics\n respond_to do |fmt|\n fmt.js { }\n end\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def list(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics\", body, options\n\n return response\n end",
"def show\n @forum = Forum.find(params[:id])\n\t\t@topics = Topic.find_all_by_forum_id(@forum.id)\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum }\n end\n end",
"def topics\n\t\t\t# Magically make arrays from string Wooooo!\n\t\t\tuid = params[\"uid\"].split(\",\")\n\t\t\ttid = params[\"tid\"].split(\",\")\n\n\t\t\t#request post from usrs AND specific topics ahhhhhhh!\n\t\t\tposts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )\n\t\t\t \t\t\t\t\t\t\t\t\t.order(created_at: :desc)\n\t\t\t \t.limit(params[\"total\"])\n\t\t\t\t\t\t\t\t\t\t\t\t.offset(params[\"start\"])\n\n\t\t\t# that cleaned that up\n\t\t\trender_json_dump(serialize_data(posts, PostSerializer))\n\t\t\t#K shows over\n\t\tend",
"def index\n respond_with current_user.topics.all.to_json(:include => [:posts, :owner])\n end",
"def show\n @topic = Topic.find(params[:id])\n @forum = Forum.find(@topic.forum_id)\n @posts = Post.where(:topic_id => @topic.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.getCommunityTopic(params)\n respond_with(@topics)\n end",
"def get_topics\n @topics = Topic.all\n end",
"def get_topics\n @topics = Topic.all\n end",
"def index\n @topics = current_user.topics\n end",
"def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end",
"def index\n @api_v1_topics = Api::V1::Topic.all\n end",
"def forum_get(args)\n JSON.parse(HelpSpot.api_request('forums.get', 'GET', :xForumId => args[:forum_id])) rescue []\n end",
"def GetForum id\n\n APICall(path: \"forums/#{id}.json\")\n\n end",
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def topics(path = nil)\n # NOTE: root url\n platform.topics_at url_for(path: path.to_s)\n end",
"def get(*topics)\n # FIXME: implement this\n end",
"def topics\n optional! :order, type: String, default: \"recent\", values: %w[recent likes replies]\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @topics = @user.topics.fields_for_list\n @topics =\n if params[:order] == \"likes\"\n @topics.high_likes\n elsif params[:order] == \"replies\"\n @topics.high_replies\n else\n @topics.recent\n end\n @topics = @topics.includes(:user).offset(params[:offset]).limit(params[:limit])\n end",
"def forum_get_topic_posts(args={})\n JSON.parse(HelpSpot.api_request('forums.getPosts', 'GET', :xTopicId => args[:topic_id]))['post'] rescue []\n end",
"def show\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.accessible_by(current_ability).page params[:page]\n @feed_link = forum_topic_url(@forum, @topic, :format => :atom)\n\n if current_user\n @topic.mark_as_read! :for => current_user\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n format.atom { render :layout => false }\n end\n end",
"def show\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @forum = TogForum::Forum.find(params[:id])\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_social.profile.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id]\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def list\n @topic = get_topic(params)\n @topic_list = get_topic_list(@topic)\n respond_to do |format|\n format.html\n format.xml { render xml: @topic_list.to_xml }\n format.json { render json: @topic_list.to_json }\n end\n end",
"def GetTopic id\n\n APICall(path: \"topics/#{id}.json\")\n\n end",
"def index\n @community_topics = CommunityTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @community_topics }\n end\n end",
"def show\n @topics_user = TopicsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topics_user }\n end\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def show\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to forum_topic_posts_url(@forum, @topic) }\n format.json { render json: @post }\n end\n end",
"def new\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.order('created_at DESC').limit(5)\n\n @message.title = @topic.title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end",
"def index\n @admin_topics = Topic.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admin_topics }\n end\n end",
"def new\n @forum_id = params[:forum_id];\n @forum = Forum.find(@forum_id) if (params[:forum_id])\n @topic = Topic.new\n @user_id = current_user.id;\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n load_topic\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def all\n data = service.list_topics.body[\"topics\"] || []\n load(data)\n end",
"def show\n @topic = Topic.find(params[:id])\n @messages = @topic.messages.order(\"created_at DESC\")\n @message = Message.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n\t\t@forums = Forum.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @forums }\n\t\tend\n\tend",
"def index\n @topics = Topic.all\n end",
"def topics\n topics = [\"News\", \"A.I.\", \"V.R.\", \"RMIT\", \"Game\", \"Rails\", \"Go\", \"Web\", \"M.L\", \"Joke\", \"React\", \"Vue\", \"Node\", \"iOS\", \"AWS\"]\n end",
"def forums_list\n JSON.parse(HelpSpot.api_request('forums.list'))['forum'] rescue []\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n\t\t@page = params[:page].to_i\n @forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.paginate :page => @page, :order => 'replied_at DESC', :per_page => 10\n respond_to do |format|\n format.html do\n\t\t\t\t(session[:forums] ||= {})[@forum.id] = Time.now\n (session[:forum_page] ||= Hash.new(1))[@forum.id] = params[:page].to_i if params[:page]\n\t\t\tend\n format.js do\n render :update do |page|\n page.replace_html 'topics', :partial => \"topics/list\"\n end\n end\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n render 'api/v1/topics/show'\n end",
"def get_topics_values\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n end\n end\n render json: list\n end",
"def index\n @category = Category.find(params[:id])\n @topic = @category.topics.all\n end",
"def topics\n _topics\n end",
"def index\n @user_topics = UserTopic.all\n end",
"def show\n render :json => Topic.find(params[:id]) \n end",
"def index\n @topics = @pool.topics.order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @forum = Forum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum }\n end\n end",
"def get_topic(org_unit_id, topic_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _get(query_string)\nend",
"def show\n @forum = TogForum::Forum.find_by_id(params[:id]) || TogForum::Forum.top_level\n \n @order = params[:order] || 'tog_forum_topics.title' #'tog_forum_topics.current_rating'\n\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_forum.topics.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id],\n :order => @order + \" \" + @asc\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def topics_for_course\n redirect_guest\n @course = Course.find(params[:id])\n @topics = @course.topics\n end",
"def get_most_recently_visited_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/recent\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def all\n data = service.list_topics.to_h[:topics] || []\n load(data)\n end",
"def index\n @data_topics = DataTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_topics }\n end\n end",
"def topics(usernames)\n get(\"/1/users/topics.json\", :users => [usernames].flatten).users\n end",
"def index\n @topics = Topic.all\n @topics_json = turn_topics_to_timeline_json(@topics)\n respond_to do |format|\n format.html\n format.json { render :json => @topics_json } #debug use\n end\n\n end",
"def find(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics/:id\", body, options\n\n return response\n end",
"def show\n @topic = Topic.find(params[:id])\n @posts = Post.getTopicPosts(params)\n respond_with(@topic)\n end",
"def new\n @company_forum = CompanyForum.find(params[:company_forum_id])\n @company_forum_topic = CompanyForumTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company_forum_topic }\n end\n end",
"def index\n @topics = @ip.topics\n end",
"def index\n\n\t\t@topics = Topic.all\n\n\t\treturn @topics\n\n\tend",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@topic, referenced, users)\n\tend",
"def topics\n @topics ||= [cloudenvoy_options_hash[:topic], cloudenvoy_options_hash[:topics]].flatten.compact.map do |t|\n t.is_a?(String) ? { name: t } : t\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum_topic }\n end\n end",
"def show\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subtopic }\n end\n end",
"def new\n @topic = current_user.topics.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def show\n @admin_topic = Admin::Topic.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @admin_topic }\n end\n end",
"def index\n @content_pack = ContentPack.find(params[:content_pack_id])\n @topics = @content_pack.topics\n end",
"def show\n @forum = Forum.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum }\n end\n @posts = @forum.posts.paginate(page: params[:page], per_page: 20)\n end",
"def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @class_topics = ClassTopic.all\n end",
"def index\n opts = {\n parent_ids: @site.id,\n status: params[:status],\n headline_level: params[:head],\n rcmd_level: params[:rcmd]\n }.delete_if {|k,v|v.blank?}\n opts[:parent_id] = params[:channel_id] unless params[:channel_id].blank?\n opts[:title] = /.*#{params[:key]}.*/ unless params[:key].blank?\n @topics = Topic.includes(:channel).where(opts).order(id: :desc).page(params[:page])\n end",
"def index\n @topics = Admin::Topic.order(date: :desc).paginate(page: params[:page], per_page: 20)\n end",
"def show\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community_topic }\n end\n end",
"def show\n @forum = @group.forum\n if @forum\n @topics = @forum.topics.paginate :order => \"created_at DESC\", :page => params[:page]\n else\n @topics = [].paginate\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @topic = Topic.new forum_id: params[:forum_id]\n @topic.messages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @topics }\n end\n end",
"def index\n @topics = Topic.published\n end",
"def topics(repo, options = {})\n opts = ensure_api_media_type(:topics, options)\n paginate \"#{Repository.path repo}/topics\", opts\n end",
"def index\n respond_to do |format|\n format.html { redirect_to forum_path(params[:forum_id]) }\n format.xml do\n @topics = Topic.find_all_by_forum_id(params[:forum_id], :order => 'sticky desc, replied_at desc', :limit => 25)\n render :xml => @topics.to_xml\n end\n end\n end",
"def list_topics\n req_hash = generate_request('ListTopics')\n request_info(req_hash, SnsListTopicsParser.new(:logger => @logger))\n rescue\n on_exception\n end",
"def index\n topic_breadcrums({})\n @topics = Topic.all\n end"
] | [
"0.80589384",
"0.79791427",
"0.79392666",
"0.7635081",
"0.7461913",
"0.73416793",
"0.72031635",
"0.71412176",
"0.7139532",
"0.7101658",
"0.7086375",
"0.70813334",
"0.70747966",
"0.70747966",
"0.70747966",
"0.7047645",
"0.70448375",
"0.70448375",
"0.7020688",
"0.6995761",
"0.69835436",
"0.69030476",
"0.69010264",
"0.6893134",
"0.6880831",
"0.6876044",
"0.6864447",
"0.6846859",
"0.68197125",
"0.68061733",
"0.6766471",
"0.676447",
"0.6745435",
"0.668516",
"0.6674402",
"0.6673413",
"0.6673413",
"0.6673413",
"0.6665134",
"0.6663946",
"0.66497856",
"0.6646985",
"0.66398084",
"0.6616224",
"0.6615201",
"0.66134",
"0.66073096",
"0.6604095",
"0.65896785",
"0.65883803",
"0.6587636",
"0.6587636",
"0.6587636",
"0.6587636",
"0.6580435",
"0.6564407",
"0.65555125",
"0.6542879",
"0.6537303",
"0.65360147",
"0.65359753",
"0.65256023",
"0.65241975",
"0.65042746",
"0.6468312",
"0.6460808",
"0.64570683",
"0.64529765",
"0.6438346",
"0.6436636",
"0.64311266",
"0.6430815",
"0.64248455",
"0.6408586",
"0.6407868",
"0.6402871",
"0.6401219",
"0.6388923",
"0.6385676",
"0.6375851",
"0.63536495",
"0.6349034",
"0.6347402",
"0.6345185",
"0.6342232",
"0.63350725",
"0.6334899",
"0.6331267",
"0.63274425",
"0.6322835",
"0.63188386",
"0.6315109",
"0.6312689",
"0.6310834",
"0.63029945",
"0.6300381",
"0.62889844",
"0.62871784",
"0.62859845",
"0.6285658"
] | 0.73567235 | 5 |
GET /forum/topics/1 GET /forum/topics/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\t\t@forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.order(\"created_at DESC\")\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend",
"def GetTopicsByForum id,params = {}\n\n params = params.merge(path: \"forums/#{id}/topics.json\")\n APICall(params)\n\n end",
"def forum_get_topics(args={})\n JSON.parse(HelpSpot.api_request('forums.getTopics', 'GET', {:xForumId => args[:forum_id]}.merge(args)))['topic'] rescue []\n end",
"def GetForum id\n\n APICall(path: \"forums/#{id}.json\")\n\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def index\n @forum_topics = Forum::Topic.all\n end",
"def show\n @topic = Topic.find(params[:id])\n @forum = Forum.find(@topic.forum_id)\n @posts = Post.where(:topic_id => @topic.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @forum = Forum.find(params[:id])\n\t\t@topics = Topic.find_all_by_forum_id(@forum.id)\n\t\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum }\n end\n end",
"def topics\n client = Comments.discourse\n @topics = client.latest_topics\n respond_to do |fmt|\n fmt.js { }\n end\n end",
"def GetTopic id\n\n APICall(path: \"topics/#{id}.json\")\n\n end",
"def forum_get(args)\n JSON.parse(HelpSpot.api_request('forums.get', 'GET', :xForumId => args[:forum_id])) rescue []\n end",
"def new\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.order('created_at DESC').limit(5)\n\n @message.title = @topic.title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @forum_id = params[:forum_id];\n @forum = Forum.find(@forum_id) if (params[:forum_id])\n @topic = Topic.new\n @user_id = current_user.id;\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def get_topics\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: u.id, name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: u.id, name: u.name]}\n end\n end\n render json: list\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def index\n @topics = Topic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.accessible_by(current_ability).page params[:page]\n @feed_link = forum_topic_url(@forum, @topic, :format => :atom)\n\n if current_user\n @topic.mark_as_read! :for => current_user\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n format.atom { render :layout => false }\n end\n end",
"def index\n @api_v1_topics = Api::V1::Topic.all\n end",
"def index\n @topics = @category.topics.preload(:category)\n render 'api/v1/topics/index'\n end",
"def index\n respond_with current_user.topics.all.to_json(:include => [:posts, :owner])\n end",
"def show\n @forum = Forum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum }\n end\n end",
"def index\n @topics = Topic.getCommunityTopic(params)\n respond_with(@topics)\n end",
"def show\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @forum = TogForum::Forum.find(params[:id])\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_social.profile.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id]\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to forum_topic_posts_url(@forum, @topic) }\n format.json { render json: @post }\n end\n end",
"def show\n @topics_user = TopicsUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topics_user }\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n @messages = @topic.messages.order(\"created_at DESC\")\n @message = Message.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @topics = current_user.topics\n end",
"def show\n @topic = Topic.find(params[:id])\n render 'api/v1/topics/show'\n end",
"def get_forum id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get FORUMS, id )\n\t\t\t\tend",
"def show\n load_topic\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n render :json => Topic.find(params[:id]) \n end",
"def topics\n\t\t\t# Magically make arrays from string Wooooo!\n\t\t\tuid = params[\"uid\"].split(\",\")\n\t\t\ttid = params[\"tid\"].split(\",\")\n\n\t\t\t#request post from usrs AND specific topics ahhhhhhh!\n\t\t\tposts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )\n\t\t\t \t\t\t\t\t\t\t\t\t.order(created_at: :desc)\n\t\t\t \t.limit(params[\"total\"])\n\t\t\t\t\t\t\t\t\t\t\t\t.offset(params[\"start\"])\n\n\t\t\t# that cleaned that up\n\t\t\trender_json_dump(serialize_data(posts, PostSerializer))\n\t\t\t#K shows over\n\t\tend",
"def new\n @company_forum = CompanyForum.find(params[:company_forum_id])\n @company_forum_topic = CompanyForumTopic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company_forum_topic }\n end\n end",
"def forum_get_topic_posts(args={})\n JSON.parse(HelpSpot.api_request('forums.getPosts', 'GET', :xTopicId => args[:topic_id]))['post'] rescue []\n end",
"def get_topic(org_unit_id, topic_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _get(query_string)\nend",
"def show\n\t\t@page = params[:page].to_i\n @forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.paginate :page => @page, :order => 'replied_at DESC', :per_page => 10\n respond_to do |format|\n format.html do\n\t\t\t\t(session[:forums] ||= {})[@forum.id] = Time.now\n (session[:forum_page] ||= Hash.new(1))[@forum.id] = params[:page].to_i if params[:page]\n\t\t\tend\n format.js do\n render :update do |page|\n page.replace_html 'topics', :partial => \"topics/list\"\n end\n end\n end\n end",
"def get(*topics)\n # FIXME: implement this\n end",
"def new\n @topic = Topic.new forum_id: params[:forum_id]\n @topic.messages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @community_topics = CommunityTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @community_topics }\n end\n end",
"def get_topics\n @topics = Topic.all\n end",
"def get_topics\n @topics = Topic.all\n end",
"def show\n @admin_topic = Admin::Topic.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @admin_topic }\n end\n end",
"def show\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @community_topic }\n end\n end",
"def show\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subtopic }\n end\n end",
"def new\n @topic = current_user.topics.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @topics = @pool.topics.order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @forum = TogForum::Forum.find_by_id(params[:id]) || TogForum::Forum.top_level\n \n @order = params[:order] || 'tog_forum_topics.title' #'tog_forum_topics.current_rating'\n\n @page = params[:page] || '1'\n @asc = (params[:asc] and params[:asc] == \"desc\") ? \"asc\" : 'desc'\n\n @topics = TogForum::Topic.paginate :per_page => Tog::Config[\"plugins.tog_forum.topics.list.page.size\"],\n :page => @page,\n :conditions => ['tog_forum_topics.forum_id = ?', @forum.id],\n :order => @order + \" \" + @asc\n \n respond_to do |format|\n format.js { render :partial => \"/forums/partials/topics_paginated\" }\n format.html\n format.rss { render :rss => @forum }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @forum_topic }\n end\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def index\n @topics = Topic.all\n end",
"def show\n @forum = Forum.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum }\n end\n @posts = @forum.posts.paginate(page: params[:page], per_page: 20)\n end",
"def new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def list(options = {})\n body = options.has_key?(:query) ? options[:query] : {}\n\n response = @client.get \"/api/topics\", body, options\n\n return response\n end",
"def show\n @topic = Topic.find(params[:id])\n @page_title = \"Topic Show: #{@topic.topic_name}\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n \n end\n end",
"def index\n @admin_topics = Topic.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admin_topics }\n end\n end",
"def get_topic\n Topic.find(params[:id])\n end",
"def get_bookmarked_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/bookmarks\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def index\n @topics = Topic.all\n end",
"def show\n @forum_category = ForumCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forum_category }\n end\n end",
"def index\n @topics = Topic.where('timeint >= :timeint', :timeint => Topic.current_timeint(Time.now))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @topics }\n end\n end",
"def show\n @wforum = Wforum.find_by_permalink(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wforum }\n end\n end",
"def get_topic\n Topic.find(params[:id])\n end",
"def topics\n optional! :order, type: String, default: \"recent\", values: %w[recent likes replies]\n optional! :offset, type: Integer, default: 0\n optional! :limit, type: Integer, default: 20, values: 1..150\n\n @topics = @user.topics.fields_for_list\n @topics =\n if params[:order] == \"likes\"\n @topics.high_likes\n elsif params[:order] == \"replies\"\n @topics.high_replies\n else\n @topics.recent\n end\n @topics = @topics.includes(:user).offset(params[:offset]).limit(params[:limit])\n end",
"def index\n @category = Category.find(params[:id])\n @topic = @category.topics.all\n end",
"def find_forum_topic\n @forum_topic = @node.content\n end",
"def index\n\t\t@forums = Forum.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @forums }\n\t\tend\n\tend",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forum }\n end\n end",
"def topics(path = nil)\n # NOTE: root url\n platform.topics_at url_for(path: path.to_s)\n end",
"def show\n @forum = @group.forum\n if @forum\n @topics = @forum.topics.paginate :order => \"created_at DESC\", :page => params[:page]\n else\n @topics = [].paginate\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def list\n @topic = get_topic(params)\n @topic_list = get_topic_list(@topic)\n respond_to do |format|\n format.html\n format.xml { render xml: @topic_list.to_xml }\n format.json { render json: @topic_list.to_json }\n end\n end",
"def create\n respond_to do |format|\n if @forum.topics.create!(params[:topic])\n format.html { redirect_to forum_path(@forum), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n @topic.updater_id = current_user.id\n message = @topic.messages.first\n message.user_id = current_user.id\n message.forum_id = params[:topic][:forum_id]\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @topic = Topic.find(params[:id])\n @posts = Post.getTopicPosts(params)\n respond_with(@topic)\n end",
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def show\n @topic = Topic.find(params[:id]) \n @[email protected](params[:page]).per(post_per_page)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic }\n end\n end",
"def topic\n begin\n @topic = @owner.topics.find(params[:id])\n rescue render_return\n end\n end",
"def show\n @chapter = Chapter.find(params[:id])\n @topics = @chapter.topics.page(params[:page])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chapter }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def show\n @topic2 = Topic2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @topic2 }\n end\n end",
"def get_most_recently_visited_topics(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/recent\"\n _get(query_string)\n # Returns: a JSON array of Topic ToC entries.\nend",
"def get_topic id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get TOPICS, id )\n\t\t\t\tend",
"def new\n @topic = Topic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def index\n @data_topics = DataTopic.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_topics }\n end\n end",
"def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end",
"def index\n @user_topics = UserTopic.all\n end",
"def index\n @topics = Topic.all\n @topics_json = turn_topics_to_timeline_json(@topics)\n respond_to do |format|\n format.html\n format.json { render :json => @topics_json } #debug use\n end\n\n end",
"def index\n @content_pack = ContentPack.find(params[:content_pack_id])\n @topics = @content_pack.topics\n end",
"def new\n @topics_user = TopicsUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topics_user }\n end\n end",
"def get_topics_values\n @chapter = Chapter.find(params[:id]) unless params[:id].blank?\n if current_user.is?(\"EA\") or current_user.is?(\"IA\")\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n topic_ids = ContentUserLayout.get_unlocked_topics(@chapter,current_user)\n if !topic_ids.nil?\n list = @chapter.topics.where(:id=>topic_ids).map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n else\n list = @chapter.topics.map {|u| Hash[value: (u.id.to_s+'|'+get_params(u.params.to_s)), name: u.name]}\n end\n end\n render json: list\n end"
] | [
"0.80613303",
"0.7809695",
"0.76935434",
"0.74766177",
"0.74642545",
"0.7445874",
"0.72653353",
"0.7255433",
"0.7225459",
"0.72048295",
"0.71258485",
"0.71119815",
"0.70608765",
"0.70500576",
"0.7041242",
"0.7029406",
"0.7029406",
"0.7029406",
"0.7015976",
"0.69895816",
"0.696884",
"0.6934332",
"0.6915669",
"0.6911205",
"0.68883514",
"0.6864897",
"0.6864897",
"0.6864897",
"0.6864897",
"0.68647105",
"0.6858859",
"0.6836903",
"0.6829878",
"0.6828064",
"0.682364",
"0.6818738",
"0.6778085",
"0.6776987",
"0.6737797",
"0.6735361",
"0.67095685",
"0.6692842",
"0.6691804",
"0.66904145",
"0.6676566",
"0.66659385",
"0.66489965",
"0.66489965",
"0.6639047",
"0.66289365",
"0.66262573",
"0.6615923",
"0.6611019",
"0.6599863",
"0.6587788",
"0.6585405",
"0.6585405",
"0.6585405",
"0.65801454",
"0.65611243",
"0.65579385",
"0.65545917",
"0.6537005",
"0.65248096",
"0.6521294",
"0.6506247",
"0.65011984",
"0.6496689",
"0.6492774",
"0.6481628",
"0.64804345",
"0.6476947",
"0.6465334",
"0.645578",
"0.64527",
"0.6451948",
"0.64479786",
"0.6447889",
"0.6443837",
"0.6441908",
"0.64207774",
"0.64196914",
"0.6402927",
"0.64028543",
"0.6402348",
"0.6389345",
"0.6389345",
"0.6389345",
"0.6389345",
"0.6389345",
"0.6389179",
"0.6387168",
"0.6386939",
"0.63867384",
"0.6386327",
"0.63806343",
"0.6375656",
"0.6373749",
"0.63546866",
"0.6337136",
"0.63353693"
] | 0.0 | -1 |
POST /forum/topics POST /forum/topics.json | def create
@forum_topic = Forum::Topic.new(forum_topic_params)
respond_to do |format|
if @forum_topic.save
format.html { redirect_to @forum_topic, notice: 'Topic was successfully created.' }
format.json { render action: 'show', status: :created, location: @forum_topic }
else
format.html { render action: 'new' }
format.json { render json: @forum_topic.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n respond_to do |format|\n if @forum.topics.create!(params[:topic])\n format.html { redirect_to forum_path(@forum), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def CreateForum params = {}\n \n APICall(path: 'forums.json',method: 'POST',payload: params.to_json)\n \n end",
"def post_topic(forum_id, title, body, options = { })\n self.post(\"/topics.json\",\n options.merge(\n :body => { :topic => {\n :forum_id => forum_id, :title => title, :body => body\n } }.to_json\n )\n )['topic']\n end",
"def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n @topic.updater_id = current_user.id\n message = @topic.messages.first\n message.user_id = current_user.id\n message.forum_id = params[:topic][:forum_id]\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def CreateTopic params = {}\n \n APICall(path: 'topics.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(topic_params)\n @post = @topic.posts.build(post_params)\n @topic.user = current_user\n @post.user = current_user\n @topic.forum = @forum\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @forum, notice: 'Topic was successfully created.' }\n format.mobile { redirect_to @forum, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.mobile { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = @forum.topics.new(params[:topic])\n @topic.user = current_user\n p = @topic.posts.first\n p.user = current_user\n p.topic = @topic\n p.save!\n \n respond_to do |format|\n if @topic.save\n format.html { render :action => \"show\", :notice => \"Topic successfully created\" }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create_forum payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post FORUMS, payload )\n\t\t\t\tend",
"def create\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_topic!\n fora.post_new_topic\n end",
"def new\n @topic = Topic.new forum_id: params[:forum_id]\n @topic.messages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def create\n @topic_form_url = forum_category_forum_topics_path(@category, @forum)\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = current_user.topics.build(topic_params)\n @topic.user_id = current_user.id\n @topic.forum_id = @forum.id\n \n if @topic.save\n redirect_to forum_topic_path(@forum, @topic)\n else\n render 'new'\n end\n end",
"def create\n @forum = Forum.find(params[:forum_id])\n\n @topic.forum = @forum\n @topic.user = current_user\n @topic.moderation = true if current_user.role <= Role.get_id(:guest)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [@forum, @topic], notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.create(topic_params)\n current_user.topics.push(@topic)\n \n respond_with @topic\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def new\n @topic = current_user.topics.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def create\n @topic = current_user.topics.build()\n @topic.title = params[:title]\n @topic.user_id = current_user.id\n @topic.user_email = current_user.email\n\n respond_to do |format|\n if @topic.save!\n format.html { redirect_to topics_url, :notice => 'topic was successfully created.' }\n format.json { render :json => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n\t\t@post = Post.new(params[:posts])\n\t\[email protected] = current_user\n\t\[email protected] = @forum\n\t\[email protected] = current_user\n\t\[email protected] = @topic\n\t\t\n respond_to do |format|\n if @topic.save\n\t\t\t\[email protected]\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to([@forum, @topic]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def create\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.build(params[:topic])\n @topic.last_post_at = DateTime.now\n @topic.user = current_user\n @topic.last_poster = current_user\n @topic.posts.first.user = current_user\n\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n redirect_to forum_url(@topic.forum_id)\n else\n render :action => \"new\"\n end\n end",
"def create\n @topic = @category.topics.new(topic_params)\n authorize @topic\n\n if @topic.save\n render 'api/v1/topics/show', status: :created\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end",
"def create\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.new(params[:post].merge(:author => current_user))\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [@forum, @topic, @post], notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @company_forum = CompanyForum.find_by_id(params[:company_forum_id])\n @company_forum_topic = @company_forum.company_forum_topics.build(company_forum_topic_params)\n\n respond_to do |format|\n if @company_forum_topic.save\n format.html { redirect_to company_forum_company_forum_topic_path(@company_forum, @company_forum_topic), notice: 'Company forum topic was successfully created.' }\n format.json { render json: @company_forum_topic, status: :created, location: @company_forum_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @company_forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_topic payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post TOPICS, payload )\n\t\t\t\tend",
"def create\n #@topic = Topic.new(topic_params)\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def GetTopicsByForum id,params = {}\n\n params = params.merge(path: \"forums/#{id}/topics.json\")\n APICall(params)\n\n end",
"def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @forum = current_user.forums.new(params[:forum])\n\n respond_to do |format|\n if @forum.save\n format.html { redirect_to @forum, notice: 'Forum was successfully created.' }\n format.json { render json: @forum, status: :created, location: @forum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n @messages = @topic.messages.order('created_at DESC').limit(5)\n\n @message.title = @topic.title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def new\n @topic = @forum.topics.new\n @topic.posts.build(:user => current_user)\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create(topic, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:topic] = topic\n\n response = @client.post \"/api/topics\", body, options\n\n return response\n end",
"def create\n topic = Topic.find(sub_topic_params[:topic_id])\n @sub_topic = topic.sub_topics.build(sub_topic_params)\n\n respond_to do |format|\n if @sub_topic.save\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully created.' }\n format.json { render :show, status: :created, location: @sub_topic }\n else\n format.html { render :new }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_path, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.friendly.find(params[:topic_id])\n @post = @topic.posts.new(post_params)\n @post.user_id = current_user.id\n @post.topic_id = @topic.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to topic_posts_path(@topic), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n topic_breadcrums({\"display_text\": \"Create Topic\"})\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_url, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_topic(forum, subject, message)\n self.validate_topic_input(forum, subject, message)\n self.auth.login_with_raises\n uri = self.get_new_topic_uri(forum, subject, message)\n page = self.get_new_topic_page(uri)\n form = self.get_new_topic_form(page)\n self.set_subject_and_message(form, subject, message)\n page = self.post_new_topic(form)\n page = self.validate_new_topic_result(page)\n topic = self.get_topic_from_result(page)\n\n self.config.add_subject(forum, topic, subject)\n\n { :forum => forum,\n :topic => topic,\n :subject => subject,\n :message => message,\n :result => true }\n end",
"def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n\n @message.topic = @topic\n @message.user = current_user\n\n @messages = @topic.messages.order('created_at DESC').limit(5)\n\n respond_to do |format|\n if @message.save\n\n # Notify users who want to be\n @message.notify_users_topic_update!(current_user)\n\n format.html { redirect_to forum_topic_path(@forum, @topic, :anchor => \"msg_id_#{@message.id}\"), notice: 'Message was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.build\n @topic.posts.build\n end",
"def create\n @admin_topic = Topic.new(params[:topic])\n \n respond_to do |format|\n if @admin_topic.save\n format.html { redirect_to :action => 'index', :notice => 'Topic was successfully created.' }\n format.json { render :json => @admin_topic, :status => :created, :location => @admin_topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @admin_topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [:admin, @topic], notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n if @topic.save\n forum = Forum.find(@topic.forum_id)\n redirect_to forum;\n else\n render action: \"new\" \n end\n\n end",
"def can_create_forem_topics? forum\n true\n end",
"def topic_params\n params.require(:topic).permit(:title, :forum_id, :user_id)\n end",
"def create\n @topic = current_user.communities.find(params[:community_id]).topics.new(create_params)\n Topic.checkParams(params, current_user) && @topic.save\n respond_with(@topic)\n end",
"def create\n @subtopic = Subtopic.new(params[:subtopic])\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render json: @subtopic, status: :created, location: @subtopic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n requires! :title\n requires! :body\n requires! :node_id\n\n raise AccessDenied.new(\"The current user does not have permission to create Topic.\") unless can?(:create, Topic)\n\n @topic = current_user.topics.new(title: params[:title], body: params[:body])\n @topic.node_id = params[:node_id]\n @topic.save!\n\n render \"show\"\n end",
"def test_should_create_post_via_API_JSON\r\n get \"/logout\"\r\n post \"/forum_posts.json\", :api_key=>'testapikey',\r\n :forum_post => {:title=>'API Test Post',\r\n :body=>'Test Post desc',\r\n :user_id=>1}\r\n assert_response :created\r\n topic = JSON.parse(response.body)\r\n assert topic['title'] == 'API Test Post', 'Incorrect topic title'\r\n assert topic['user_id'] == 1, 'Incorrect user id'\r\n assert topic['body'] == 'Test Post desc', 'Incorrect topic description' \r\n end",
"def create\n @api_v1_topic = Api::V1::Topic.new(api_v1_topic_params)\n\n respond_to do |format|\n if @api_v1_topic.save\n format.html { redirect_to @api_v1_topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_topic }\n else\n format.html { render :new }\n format.json { render json: @api_v1_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n parameters = topic_params\n parameters[:user_id] = current_user.id\n @topic = Topic.new(parameters)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def topic_new_params\n params.require(:forum_topic).permit(:title, :locked, :pinned, posts_attributes: [:content])\n end",
"def new\n @forum_id = params[:forum_id];\n @forum = Forum.find(@forum_id) if (params[:forum_id])\n @topic = Topic.new\n @user_id = current_user.id;\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def create\n \n client = Mastodon::REST::Client.new(base_url: ENV[\"MASTODON_URL\"], bearer_token: ENV[\"ACCESS_TOKEN\"])\n \n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n response = client.create_status(\"新しいトピック:#{@topic.title} が作成されました!\")\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def forum_get_topics(args={})\n JSON.parse(HelpSpot.api_request('forums.getTopics', 'GET', {:xForumId => args[:forum_id]}.merge(args)))['topic'] rescue []\n end",
"def create\n topic = Topic.find(params[:topic_id])\n @post = topic.posts.build(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [topic, @post], notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = current_user.topics.new(topic_params)\n @topic.subscriber = @user\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [@user, @topic], notice: '成功新增' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_topic(forum, subject, message)\n @topic.new_topic(forum, subject, message)\n end",
"def create\n @topic = @board.topics.new\n\n @topic.content = Boards::DiscussionTopic.new(params[:boards_discussion_topic])\n respond_to do |format|\n if @topic.content.save\n flash[:notice] = 'Nieuwe discussie was succesvol gestart'\n @topic.user = current_user\n @topic.category = \"topic\"\n @topic.save\n \n format.html { redirect_to(board_discussion_topic_path(@board, @topic.content)) }\n format.xml { render :xml => @topic, :status => :created, :location => board_discussion_topic_path(@board, @topic.content) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.content.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @subtopic = Subtopic.new(subtopic_params)\n\n respond_to do |format|\n if @subtopic.save\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully created.' }\n format.json { render :show, status: :created, location: @subtopic }\n else\n format.html { render :new }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@title = \"Nowe spotkanie\"\n @meeting = Meeting.new(params[:meeting])\n\t\tunless params[:meeting][:topics].nil?\n\t\t\t@temp = Topic.find(params[:meeting][:topics])\n\t\t\[email protected] = @temp\n\t\tend\n respond_to do |format|\n if @meeting.save\n format.html { redirect_to @meeting, notice: 'Meeting was successfully created.' }\n format.json { render json: @meeting, status: :created, location: @meeting }\n else\n\t\t\t\t@alltopics = Topic.where(:meeting_id => nil)\n format.html { render action: \"new\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def topic\n @topic = Topic.new\n @a = @topic.posts.build\n @discussion_categories = DiscussionCategory.all_active\n end",
"def create\n @user_topic = UserTopic.new(user_topic_params)\n\n respond_to do |format|\n if @user_topic.save\n format.html { redirect_to @user_topic, notice: 'User topic was successfully created.' }\n format.json { render :show, status: :created, location: @user_topic }\n else\n format.html { render :new }\n format.json { render json: @user_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topic }\n end\n end",
"def topics\n\t\t\t# Magically make arrays from string Wooooo!\n\t\t\tuid = params[\"uid\"].split(\",\")\n\t\t\ttid = params[\"tid\"].split(\",\")\n\n\t\t\t#request post from usrs AND specific topics ahhhhhhh!\n\t\t\tposts = Post.where('user_id IN (?) OR topic_id IN (?) OR raw LIKE (?)', uid, tid, '%@everyone%' )\n\t\t\t \t\t\t\t\t\t\t\t\t.order(created_at: :desc)\n\t\t\t \t.limit(params[\"total\"])\n\t\t\t\t\t\t\t\t\t\t\t\t.offset(params[\"start\"])\n\n\t\t\t# that cleaned that up\n\t\t\trender_json_dump(serialize_data(posts, PostSerializer))\n\t\t\t#K shows over\n\t\tend",
"def topic_params\n params.require(:topic).permit(:title, :content, :clicks, :status)\n end",
"def new\n @topic = current_user.topics.build()\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @topic }\n end\n end",
"def create\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.create(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors, status: :unprocessable_entity\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end",
"def topic_params\n params.require(:topic).permit(:title, :body)\n end",
"def create\n @forum = Forum.new(forum_params)\n respond_to do |format|\n if @forum.save\n format.html { redirect_to @forum, notice: t('.success') }\n format.json { render :show, status: :created, location: @forum }\n else\n format.html { render :new }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n\t\t@forum = Forum.find(params[:id])\n\t\t@topics = @forum.topics.order(\"created_at DESC\")\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @forum }\n\t\tend\n\tend",
"def create_post topic_id, payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post POSTS, payload, topic_id, nil, \"create_post\" )\n\t\t\t\tend",
"def create\n @article_topic = ArticleTopic.new(article_topic_params)\n\n respond_to do |format|\n if @article_topic.save\n format.html { redirect_to @article_topic, notice: 'Article topic was successfully created.' }\n format.json { render :show, status: :created, location: @article_topic }\n else\n format.html { render :new }\n format.json { render json: @article_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def forum_topic_params\n params.require(:forum_topic).permit(:category_id, :title)\n end",
"def create\n @list = current_user.topics.create list_params\n end",
"def create\n @topic = Topic.new\n @topic.topic_name = params[:topic][:topic_name].titleize\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@forum = Forum.new(params[:forum])\n\n\t\trespond_to do |format|\n\t\t\tif @forum.save\n\t\t\t\tformat.html { redirect_to admin_forums_path, notice: 'Το forum δημιουργήθηκε με επιτυχία' }\n\t\t\t\tformat.json { render json: @forum, status: :created, location: @forum }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @forum.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n topic = Topic.new(topic_params)\n if topic.save\n response_data = {\n status: 'success',\n txt: ['質問を投稿しました!'],\n }\n else\n response_data = {\n status: 'error',\n txt: topic.errors.full_messages,\n }\n end\n render json: response_data\n end",
"def new\n\t@topic = Topic.new\n\[email protected]\n\[email protected] \n\trespond_to do |format|\n\t format.html # new.html.erb\n\t format.json { render json: @topic }\n\tend\n end",
"def create\n @topic = Topic.find(params[:topic_id])\n @topic_answer = @topic.topic_answers.build(topic_answer_params)\n\n respond_to do |format|\n if @topic_answer.save\n format.html { redirect_to @topic, notice: 'Topic answer was successfully created.' }\n format.json { render :show, status: :created, location: @topic_answer }\n else\n @topic_answers = @topic.get_answers(params[:page])\n format.html { render \"topics/show\" }\n format.json { render json: @topic_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topics_user = TopicsUser.new(:topic_id=>params[:topic_id], :user_id=>params[:user_id])\n respond_to do |format|\n if @topics_user.save\n format.html { redirect_to find_topics_url, notice: 'Topic successfully added.' }\n format.json { render json: @topics_user, status: :created, location: @topics_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topics_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @community_topic = CommunityTopic.new(params[:community_topic])\n\n respond_to do |format|\n if @community_topic.save\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully created.' }\n format.json { render json: [@community, @community_topic], status: :created, location: @community_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n @topic = Topic.find(post_params[:topic_id])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @topic, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to @topic}\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = current_user.topics.build(params[:topic])\n @encounter = Encounter.find(session[:encounter_key])\n\n\n respond_to do |format|\n if @topic.save\n session[:topic_key] = @topic.id\n format.html { redirect_to encounter_path(@encounter), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @forum_forum = Forum::Forum.new(forum_forum_params)\n\n respond_to do |format|\n if @forum_forum.save\n format.html { redirect_to @forum_forum, notice: 'Forum was successfully created.' }\n format.json { render :show, status: :created, location: @forum_forum }\n else\n format.html { render :new }\n format.json { render json: @forum_forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @forum_thread = ForumThread.new(forum_thread_params)\n\n respond_to do |format|\n if @forum_thread.save\n format.html { redirect_to @forum_thread, notice: 'Forum thread was successfully created.' }\n format.json { render :show, status: :created, location: @forum_thread }\n else\n format.html { render :new }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @forum_topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_url }\n format.json { head :no_content }\n end\n end",
"def create\n @forum_thread = Forum::Thread.new(forum_thread_params)\n\n respond_to do |format|\n if @forum_thread.save\n format.html { redirect_to @forum_thread, notice: 'Thread was successfully created.' }\n format.json { render :show, status: :created, location: @forum_thread }\n else\n format.html { render :new }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def all_topics\n topics = Feed.find(params[:feed_id]).topics\n render :json => topics\n end",
"def create\n ##@forum = Forum.new(forum_params)\n @forum = current_user.forums.new(forum_params)\n respond_to do |format|\n if @forum.save\n format.html { redirect_to forum_path(@forum), notice: 'Foro creado exitosamente.' }\n format.json { render :show, status: :created, location: @forum }\n else\n format.html { render :new }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(body)\n server = XMLRPC::Client.new2('http://www.juggernautguild.com/interface/board/')\n\n response = server.call('postTopic', {\n :api_module => 'ipb',\n :api_key => Juggernaut[:ipb_api_key],\n :member_field => 'id',\n :member_key => 4095, # Attendance\n :forum_id => 10,\n :topic_title => self.to_s,\n :post_content => body\n })\n end",
"def create\n @data_topic = DataTopic.new(params[:data_topic])\n\n respond_to do |format|\n if @data_topic.save\n format.html { redirect_to @data_topic, notice: 'Data topic was successfully created.' }\n format.json { render json: @data_topic, status: :created, location: @data_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @forum_thread = current_user.forum_threads.new forum_thread_params\n @forum_thread.user_id = current_user.id\n\n respond_to do |format|\n if @forum_thread.save\n format.html { redirect_to @forum_thread, notice: I18n.t('forum_threads.new.create_success') }\n format.json { render :show, status: :created, location: @forum_thread }\n else\n format.html { render :new }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7544425",
"0.73355794",
"0.72056794",
"0.7142488",
"0.70683473",
"0.69810206",
"0.6958741",
"0.6956227",
"0.6907363",
"0.68847775",
"0.6875981",
"0.68741125",
"0.6870669",
"0.6831642",
"0.6827633",
"0.68154293",
"0.6778422",
"0.6762545",
"0.67495096",
"0.6734686",
"0.6723402",
"0.67055607",
"0.6697848",
"0.66967803",
"0.667798",
"0.66334885",
"0.66164243",
"0.65989256",
"0.65856856",
"0.658377",
"0.658377",
"0.6555069",
"0.6548678",
"0.65429395",
"0.65426594",
"0.6541502",
"0.6525272",
"0.6522284",
"0.6500831",
"0.64992726",
"0.6489681",
"0.64856493",
"0.64775246",
"0.6476644",
"0.6476626",
"0.64651275",
"0.6465015",
"0.6460637",
"0.64461654",
"0.64362067",
"0.64342034",
"0.6412593",
"0.6406696",
"0.6402486",
"0.64000064",
"0.6383972",
"0.6380415",
"0.6377817",
"0.6371938",
"0.63686204",
"0.6364957",
"0.63583547",
"0.6354663",
"0.6350884",
"0.63470584",
"0.6326274",
"0.6321927",
"0.63118887",
"0.628979",
"0.62861174",
"0.6284258",
"0.62723255",
"0.62723184",
"0.62552875",
"0.6253566",
"0.62454873",
"0.6238566",
"0.62365496",
"0.6234716",
"0.6232846",
"0.62292945",
"0.6228124",
"0.6225157",
"0.62187773",
"0.62158084",
"0.62154734",
"0.6206241",
"0.62023395",
"0.6199579",
"0.61967796",
"0.6196338",
"0.61952305",
"0.6191265",
"0.61846614",
"0.6181578",
"0.61746484",
"0.6174243",
"0.6164625",
"0.6164625",
"0.6159942"
] | 0.70196164 | 5 |
PATCH/PUT /forum/topics/1 PATCH/PUT /forum/topics/1.json | def update
respond_to do |format|
if @forum_topic.update(forum_topic_params)
format.html { redirect_to @forum_topic, notice: 'Topic was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @forum_topic.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @topic = Topic.find(params[:id])\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to forum_topic_path(@forum,@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @forum = Forum.find(params[:forum_id])\n\n params[:user_id] = current_user.id\n params[:forum_id] = @forum.id\n params[:moderation] = true if current_user.role <= Role.get_id(:guest)\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to [@forum, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic.update_attributes!(topic_params)\n json_response(@topic)\n end",
"def update\n params[:topic].delete :messages_attributes\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to forum_path(:id => @forum), notice: 'Topic was successfully updated.' }\n format.mobile { redirect_to forum_path(:id => @forum), notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.mobile { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n topic = Topic.find(params[:id])\n if topic.update(params_topic)\n render json: topic, status: 200\n else\n render json: topic.errors, status: 422\n end\n\n end",
"def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n\n params[:topic_id] = @topic.id\n\n respond_to do |format|\n if @message.update_attributes(params[:message])\n format.html { redirect_to forum_topic_path(@forum, @topic, :anchor => \"msg_id_#{@message.id}\"), notice: 'Message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_topic.update(api_v1_topic_params)\n format.html { redirect_to @api_v1_topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_topic }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n\n respond_to do |format|\n if @company_forum_topic.update_attributes(company_forum_topic_params)\n format.html { redirect_to @company_forum_topic, notice: 'Company forum topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @company_forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTopic id,params = {}\n \n APICall(path: \"topics/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_with @topic.update(topic_params)\n end",
"def update\n topic = Topic.find(params[:id])\n if topic.update_attributes(topic_params)\n render :json => {:ok => true}, :head => :no_content\n else\n render :json => {:ok => false, :message => topic.errors}, :status => :unprocessable_entity\n end\n end",
"def update\n topic_breadcrums({\"display_text\": \"Update Topic\"})\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to topics_url, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n # @topic = current_user.topics.find(topic_params)\n @topic = current_user.topics.find(params[:id])\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to [@forum, @topic, @post], notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update!(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@forum) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n authorize @topic\n\n if @topic.update(topic_params)\n render 'api/v1/topics/show', status: :success\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to topics_path, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @featured_topic.update(featured_topic_params)\n else\n format.json { render json: @featured_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @topic.topic_type.nil?\n @topic.topic_type = :yesno\n end\n \n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to \"/#{@topic.permalink}\", success: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params) \n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to [:admin, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to forums_path, notice: t('.success') }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n if @topic.update_attributes(params[:topic])\n forum = Forum.find(@topic.forum_id);\n redirect_to forum\n else\n render action: \"edit\" \n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to [@pool, @topic], notice: 'Topic was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n topic_params = params[:project_topic] || params[:topic]\n title = params[:project_topic] ? 'Project Topic' : 'Topic'\n params[:project_topic] ? load_project_topic : load_topic\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to redirect_path, notice: \"#{title} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render 'form' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = \"Topic was successfully updated.\"\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @subtopic = Subtopic.find(params[:id])\n\n respond_to do |format|\n if @subtopic.update_attributes(params[:subtopic])\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(topic, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:topic] = topic\n\n response = @client.put \"/api/topics/:id\", body, options\n\n return response\n end",
"def update\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.find(params[:id])\n topic.update(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end",
"def update\r\n respond_to do |format|\r\n if @forum.update(forum_params)\r\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @forum }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @forum.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: \"Forum was successfully updated.\" }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum_forum.update(forum_forum_params)\n format.html { redirect_to @forum_forum, notice: 'Forum was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum_forum }\n else\n format.html { render :edit }\n format.json { render json: @forum_forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n row = @topic.id+1\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n @ws[row,2] = @topic.topic\n @ws[row,3] = @topic.subject.subject\n @ws[row,4] = @topic.seab_sub_topic.topic\n @ws[row,5] = @topic.description\n @ws.save()\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @admin_topic = Admin::Topic.find(params[:id])\n \n respond_to do |format|\n if @admin_topic.update_attributes(params[:admin_topic])\n format.html { redirect_to @admin_topic, :notice => 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @admin_topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to group_topic_path(:id => @topic.id), notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @article_topic.update(article_topic_params)\n format.html { redirect_to @article_topic, notice: 'Article topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @article_topic }\n else\n format.html { render :edit }\n format.json { render json: @article_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_topic(org_unit_id, topic_id, content_topic) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n payload = {\n 'Title' => \"\",\n 'ShortTitle' => \"\",\n 'Type' => 0,\n 'TopicType' => 0,\n 'StartDate' => nil,\n 'EndDate' => nil,\n 'DueDate' => nil,\n 'IsHidden' => nil,\n 'IsLocked' => false,\n 'OpenAsExternalResource' => nil, # Added with LE v1.6 API\n 'Description' => nil,\n 'MajorUpdate' => nil, # Added with LE v1.12 API\n 'MajorUpdateText' => \"\", # Added with LE v1.12 API\n 'ResetCompletionTracking' => nil # Added with LE v1.12 API\n }.merge!(content_topic)\n check_content_topic_validity(content_topic)\n _put(query_string, payload)\nend",
"def update\n @community_topic = CommunityTopic.find(params[:id])\n\n respond_to do |format|\n if @community_topic.update_attributes(params[:community_topic])\n format.html { redirect_to [@community, @community_topic], notice: 'Community topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @community_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if @topic.update_attributes(topic_params)\n flash[:success] = \"Topic updated\"\n redirect_to forum_topic_path(@forum, @topic)\n else\n render 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n format.html { redirect_to [@user, @topic], notice: '成功更新' }\n format.json { render :show, status: :ok, location: @topic }\n else\n format.html { render :edit }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @discussion_topic = Boards::Topics::DiscussionTopic.find(params[:id])\n\n respond_to do |format|\n if @discussion_topic.update_attributes(params[:discussion_topic])\n flash[:notice] = 'Boards::Topics::DiscussionTopic was successfully updated.'\n format.html { redirect_to(@discussion_topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @discussion_topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sub_topic.update(sub_topic_params)\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @sub_topic }\n else\n format.html { render :edit }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @seab_topic.update(seab_topic_params)\n format.html { redirect_to @seab_topic, notice: 'Seab topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @seab_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @faq = Faq.find(params[:id])\n\n respond_to do |format|\n if @faq.update_attributes(params[:faq])\n format.html { redirect_to @faq, notice: 'FAQ atualizada com sucesso.' }\n format.json { head :no_content }\n else\n @subjects = Subject.all\n format.html { render action: \"edit\" }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n expire_front \n\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:success] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @data_topic = DataTopic.find(params[:id])\n\n respond_to do |format|\n if @data_topic.update_attributes(params[:data_topic])\n format.html { redirect_to @data_topic, notice: 'Data topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n flash[:notice] = 'Topic was successfully updated.'\n format.html { redirect_to(@topic) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@forum = Forum.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @forum.update_attributes(params[:forum])\n\t\t\t\tformat.html { redirect_to @forum, notice: 'Το forum άλλαξε με επιτυχία' }\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: @forum.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @forum_thread.update(forum_thread_params)\n format.html { redirect_to @forum_thread, notice: 'Forum thread was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum_thread }\n else\n format.html { render :edit }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topics_user = TopicsUser.find(params[:id])\n\n respond_to do |format|\n if @topics_user.update_attributes(params[:topics_user])\n format.html { redirect_to @topics_user, notice: 'Topics user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topics_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_topic.update(user_topic_params)\n format.html { redirect_to @user_topic, notice: 'User topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_topic }\n else\n format.html { render :edit }\n format.json { render json: @user_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @document_topic_sub_topic.update(document_topic_sub_topic_params)\n format.html { redirect_to @document_topic_sub_topic, notice: 'Document topic sub topic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document_topic_sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subtopic.update(subtopic_params)\n format.html { redirect_to @subtopic, notice: 'Subtopic was successfully updated.' }\n format.json { render :show, status: :ok, location: @subtopic }\n else\n format.html { render :edit }\n format.json { render json: @subtopic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n\n respond_to do |format|\n if @topic.update_attributes(topic_params)\n format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic.update(topic_params)\n @content_pack = @topic.content_pack\n @topics = @content_pack.topics\n end\n format.js\n end\n end",
"def update\n news_topic_params[:context].gsub!(\"\\n\", '</br>')\n news_topic_params[:short_context].gsub!(\"\\n\", '</br>')\n\n respond_to do |format|\n if @news_topic.update(news_topic_params)\n format.html { redirect_to news_topics_path, :notice => 'News topic was successfully updated.' }\n format.json { render :show, :status => :ok, :location => @news_topic }\n else\n format.html { render :edit }\n format.json { render :json => @news_topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question_topic = QuestionTopic.find(params[:id])\n\n respond_to do |format|\n if @question_topic.update_attributes(params[:question_topic])\n format.html { redirect_to(@question_topic, :notice => 'Question topic was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_topic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum_thread.update(forum_thread_params)\n format.html { redirect_to @forum_thread, notice: I18n.t('forum_threads.edit.update_success') }\n format.json { render :show, status: :ok, location: @forum_thread }\n else\n format.html { render :edit }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meeting = Meeting.find(params[:id])\n\t\t@title = \"Edycja spotkania\"\n @oldtopics = Topic.where(:meeting_id => @meeting.id)\n @oldtopics.each do |topic|\n topic.update_attributes({:meeting_id => nil})\n end\n\t\tunless params[:meeting][:topics].nil?\n\t\t\t@temp = Topic.find(params[:meeting][:topics])\n\t\t\[email protected] = @temp\n\t\tend\n respond_to do |format|\n if @meeting.update_attributes(params[:meeting])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { head :ok }\n else\n @unusedtopics = Topic.where(:meeting_id => nil)\n @thistopics = Topic.where(:meeting_id => @meeting.id)\n @alltopics = @thistopics + @unusedtopics\n format.html { render action: \"edit\" }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Foro actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @forum }\n else\n format.html { render :edit }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topic = Topic.find(params[:id])\n p = @topic.posts\n if(p.user.nil?)\n p.user = current_user\n p.topic = @topic\n p.save!\n end\n \n respond_to do |format|\n if @topic.update_attributes(params[:topic])\n format.html { redirect_to(:action => \"show\", :notice => 'Topic was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n if current_user and current_user.admin == 'manager'\n @forum = Forum.find(params[:id])\n else\n if (current_user and current_user.admin == 'customer') or (current_user and current_user.admin == 'worker')\n @forum = current_user.forums.find(params[:id])\n end\n end\n respond_to do |format|\n if @forum.update_attributes(params[:forum])\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @forum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum_thread.update(forum_thread_params)\n format.html { redirect_to @forum_thread, notice: 'Thread was successfully updated.' }\n format.json { render :show, status: :ok, location: @forum_thread }\n else\n format.html { render :edit }\n format.json { render json: @forum_thread.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic03.update(topic03_params)\n format.html { redirect_to @topic03, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic03 }\n else\n format.html { render :edit }\n format.json { render json: @topic03.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @forum = Forum.find(params[:id])\n\n respond_to do |format|\n if @forum.update_attributes(params[:forum])\n format.html { redirect_to(@forum, :notice => 'Forum was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @forum.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forum_message.update(forum_message_params)\n format.html { redirect_to @forum_thread, notice: 'Forum message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forum_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @topickey = Topickey.find(params[:id])\n\n respond_to do |format|\n if @topickey.update_attributes(params[:topickey])\n format.html { redirect_to @topickey, notice: 'Topickey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topickey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @topic02.update(topic02_params)\n format.html { redirect_to @topic02, notice: 'Topic was successfully updated.' }\n format.json { render :show, status: :ok, location: @topic02 }\n else\n format.html { render :edit }\n format.json { render json: @topic02.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @forumm.update(forumm_params)\n format.html { redirect_to @forumm, notice: 'Forumm was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @forumm.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7393139",
"0.7090509",
"0.7087829",
"0.7048357",
"0.6968193",
"0.68985105",
"0.6887631",
"0.6876073",
"0.68731165",
"0.6817543",
"0.6807804",
"0.6806315",
"0.6772678",
"0.6745174",
"0.6718342",
"0.6717167",
"0.6713969",
"0.67085344",
"0.670782",
"0.670782",
"0.670782",
"0.670782",
"0.670782",
"0.67069256",
"0.6643329",
"0.6617238",
"0.66123104",
"0.6588011",
"0.65419775",
"0.6532135",
"0.6532135",
"0.6532135",
"0.6532135",
"0.65214384",
"0.6519552",
"0.65113336",
"0.65073",
"0.6501014",
"0.6501014",
"0.6501014",
"0.6499611",
"0.64804846",
"0.6480053",
"0.64768845",
"0.64668965",
"0.64468366",
"0.64468366",
"0.6442495",
"0.6432808",
"0.6431248",
"0.64282817",
"0.64020205",
"0.63992584",
"0.63930124",
"0.638996",
"0.63875395",
"0.6372294",
"0.63697606",
"0.636744",
"0.6364079",
"0.63479984",
"0.63479173",
"0.63362706",
"0.63313556",
"0.6326537",
"0.63143575",
"0.6311538",
"0.6309096",
"0.6282338",
"0.6281296",
"0.62775844",
"0.6264939",
"0.6254695",
"0.6245789",
"0.6245789",
"0.6245789",
"0.6245789",
"0.6245789",
"0.6245692",
"0.624561",
"0.62427235",
"0.6233972",
"0.6231153",
"0.6227875",
"0.6215583",
"0.6215182",
"0.62091464",
"0.6201141",
"0.6192433",
"0.6187969",
"0.6179607",
"0.6168038",
"0.6166617",
"0.6160166",
"0.61507463",
"0.61388856",
"0.6125819",
"0.6103271",
"0.6101373",
"0.6085212"
] | 0.7075809 | 3 |
DELETE /forum/topics/1 DELETE /forum/topics/1.json | def destroy
@forum_topic.destroy
respond_to do |format|
format.html { redirect_to forum_topics_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteForum id\n \n APICall(path: \"forums/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @forum = Forum.find(params[:forum_id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_url(@forum) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n forum = @topic.forum\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_url(forum) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_url(@forum) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company_forum_topic = CompanyForumTopic.find(params[:id])\n @company_forum_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to company_forum_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_url(:id=>@forum) }\n format.mobile { redirect_to forum_url(:id=>@forum) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to forum_topics_path, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to forum_topic_path(params[:forum_id], params[:topic_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum = Forum.find(params[:forum_id])\n @topic = @forum.topics.find(params[:topic_id])\n @post = @topic.posts.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_topic_posts_url(@forum, @topic) }\n format.json { head :ok }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def DeleteTopic id\n \n APICall(path: \"topics/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to @forum, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forumm.destroy\n respond_to do |format|\n format.html { redirect_to forumms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_topics_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Topic.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to topics_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_v1_topic.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum_message.destroy\n respond_to do |format|\n format.html { redirect_to forum_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n\t\t@forum = @topic.forum\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(@forum) }\n end\n end",
"def destroy\n @forum_thread.destroy\n respond_to do |format|\n format.html { redirect_to forum_threads_url, notice: I18n.t('forum_threads.edit.delete_success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n load_topic.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to pool_topics_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @forum_forum.destroy\n respond_to do |format|\n format.html { redirect_to forum_forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seab_topic.destroy\n respond_to do |format|\n format.html { redirect_to seab_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n \t@topic = Topic.find(params[:id])\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n @discussion_topic = Boards::Topics::DiscussionTopic.find(params[:id])\n @discussion_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(boards/topics_discussion_topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Foro eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy!\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subtopic = Subtopic.find(params[:id])\n @subtopic.destroy\n\n respond_to do |format|\n format.html { redirect_to subtopics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news_topic.destroy\n respond_to do |format|\n format.html { redirect_to news_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: \"Forum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t@topic = Topic.find(params[:id])\n\[email protected]_all\n\[email protected]_all\n\[email protected]\n\n\trespond_to do |format|\n\t format.html { redirect_to topics_url }\n\t format.json { head :no_content }\n\tend\n end",
"def destroy\n @community_topic = CommunityTopic.find(params[:id])\n @community_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to community_topics_url }\n format.json { head :no_content }\n end\n end",
"def delete_forum id\n\t\t\t\t\tFreshdesk::Api::Client.delete_status_wrapper do\n\t\t\t\t\t\t( @connection.delete FORUMS, id ).code\n\t\t\t\t\tend\n\t\t\t\tend",
"def destroy\n # don't really destroy\n @topic = Topic.find(params[:topic_id])\n @forum = Forum.find(params[:forum_id])\n\n # mark as deleted with default reason\n @message.deleted = true\n @message.deletion_reason = \"Message deleted\"\n @message.deletion_by = current_user.id\n\n @message.save\n\n respond_to do |format|\n format.html { redirect_to forum_topic_path(@forum, @topic) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @forum.destroy\r\n respond_to do |format|\r\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n forum = Forum.find(@topic.forum_id);\n @topic.destroy\n redirect_to forum \n end",
"def destroy\n if @topic.destroy\n render json: {success: true}\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end",
"def delete(options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n\n response = @client.delete \"/api/topics/:id\", body, options\n\n return response\n end",
"def destroy\n @forum_thread.destroy\n respond_to do |format|\n format.html { redirect_to forum_threads_url, notice: 'Forum thread was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topics_user = TopicsUser.find(params[:id])\n @topics_user.destroy\n\n respond_to do |format|\n format.html { redirect_to my_topics_url, notice: 'Remove topic succeed!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum = Forum.find(params[:id])\n @forum.destroy\n\n respond_to do |format|\n format.html { redirect_to(forums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @wforum = Wforum.find_by_permalink(params[:id])\n @wforum.destroy\n\n respond_to do |format|\n format.html { redirect_to wforums_url }\n format.json { head :no_content }\n end\n end",
"def delete_topic(org_unit_id, topic_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/topics/#{topic_id}\"\n _delete(query_string)\nend",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to xmt_press_topics_url(site_id: @site.id, channel_id: @channel.id), notice: '文章删除成功.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum_thread.destroy\n respond_to do |format|\n format.html { redirect_to forum_threads_url, notice: 'Thread was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article_topic.destroy\n respond_to do |format|\n format.html { redirect_to article_topics_url, notice: 'Article topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(topics_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_topics_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @forum_category.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_categories_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n authorize @topic\n @topic.destroy\n\n head :no_content\n end",
"def destroy\n @data_topic = DataTopic.find(params[:id])\n @data_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to data_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum_category = ForumCategory.find(params[:id])\n @forum_category.destroy\n\n respond_to do |format|\n format.html { redirect_to forums_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @category = @topic.category\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to @category }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with @topic.destroy \n end",
"def destroy\n @featured_topic.destroy\n head :ok\n end",
"def destroy\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to [@user, Topic], notice: '成功刪除' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_topic = Admin::Topic.find(params[:id])\n @admin_topic.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lda_post_topic = LdaPostTopic.find(params[:id])\n @lda_post_topic.destroy\n\n respond_to do |format|\n format.html { redirect_to lda_post_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = @topic.posts.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_topic_url(@forum, @topic)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @forum = TogForum::Forum.find(params[:id])\n\n if @forum.destroy\n flash[:notice] = \"The forum was successfully deleted.\"\n else\n flash[:error] = \"An error occurred: #{@forum.errors.full_messages}\"\n end\n \n respond_to do |format|\n format.html { redirect_to(forums_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @topic = Topic.find(params[:id])\n #logger.info \"=========================#{@topic}\"\n @group_id = @topic.group_id || 1\n #logger.info \"===========================#{@group_id}\"\n @topic.destroy\n\n respond_to do |format|\n format.html { redirect_to group_topics_path(@group_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum_post = ForumPost.find(params[:id])\n @forum_post.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Destruir moderaciones\n Moderator.all.each do |mod|\n mod.destroy if mod.forum_id == @forum.id\n end\n\n # Destruir subscripciones\n Subscription.all.each do |sub|\n sub.destroy if sub.forum_id == @forum.id\n end\n\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url, notice: 'Forum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subtopic.destroy\n respond_to do |format|\n format.html { redirect_to subtopics_url, notice: 'Subtopic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub_topic.destroy\n respond_to do |format|\n format.html { redirect_to sub_topics_url, notice: 'Sub topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @document_topic_sub_topic.destroy\n respond_to do |format|\n format.html { redirect_to document_topic_sub_topics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mdl_forum_discussion.destroy\n respond_to do |format|\n format.html { redirect_to mdl_forum_discussions_url, notice: 'Mdl forum discussion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_to do |format|\n if @topic.destroy\n format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n unless @user.level >= 8 or @topic.creator == @user.id.to_s\n redirect_to \"/\" and return\n end\n @topic.destroy\n respond_to do |format|\n format.html { redirect_to \"/list\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topic.destroy\n redirect_to root_url\n end"
] | [
"0.79541385",
"0.7953616",
"0.7926266",
"0.7818605",
"0.7737781",
"0.7694223",
"0.7600998",
"0.75670964",
"0.7549272",
"0.7543759",
"0.7537674",
"0.7520923",
"0.751746",
"0.751746",
"0.751746",
"0.751746",
"0.751746",
"0.75159913",
"0.75077087",
"0.74912995",
"0.74714893",
"0.74712414",
"0.74712414",
"0.74712414",
"0.74712414",
"0.74712414",
"0.74712414",
"0.7470925",
"0.74693316",
"0.74509263",
"0.7435057",
"0.7416775",
"0.73738456",
"0.7347198",
"0.7344855",
"0.733174",
"0.732201",
"0.7319963",
"0.7315892",
"0.7313421",
"0.7312447",
"0.7311167",
"0.7307251",
"0.73038226",
"0.7303405",
"0.72999555",
"0.7296778",
"0.72706604",
"0.7270399",
"0.72478724",
"0.72478724",
"0.7247362",
"0.7235669",
"0.7235669",
"0.7235669",
"0.7235669",
"0.7235669",
"0.7235669",
"0.7235669",
"0.7233775",
"0.7226017",
"0.72205365",
"0.7217657",
"0.721292",
"0.72072095",
"0.7205541",
"0.7191017",
"0.7190396",
"0.71690816",
"0.7154361",
"0.71540487",
"0.71540487",
"0.71540487",
"0.71540487",
"0.71540487",
"0.71540487",
"0.71540487",
"0.7142719",
"0.7139723",
"0.7129687",
"0.71296585",
"0.71169275",
"0.71136105",
"0.71057576",
"0.7102853",
"0.71027637",
"0.70922035",
"0.70905435",
"0.70889586",
"0.70816165",
"0.707733",
"0.7074126",
"0.7072651",
"0.7065425",
"0.706339",
"0.7053833",
"0.70473135",
"0.7031833",
"0.70272356",
"0.7025357"
] | 0.8012485 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_forum_topic
@forum_topic = Forum::Topic.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 forum_topic_params
params.require(:forum_topic).permit(:category_id, :title)
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 |
Use callbacks to share common setup or constraints between actions. | def set_sensor
if current_user
@sensor = current_user.sensors.find(params[:id])
else
# Determine if this user has set this sensor as public
public_sensor = Sensor.find(params[:id]).public
@sensor = Sensor.find(params[:id]) if public_sensor
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def call\n setup_context\n super\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0.53307265",
"0.5312121",
"0.5298173",
"0.5296388",
"0.52952695",
"0.5258086",
"0.52430934",
"0.5237911",
"0.5237911",
"0.5237911",
"0.5237911",
"0.5237911",
"0.52335346",
"0.5232943",
"0.5226392",
"0.52221715",
"0.5217978",
"0.52136153",
"0.52076435",
"0.52067244",
"0.5175402",
"0.5174649",
"0.5173085",
"0.5165201",
"0.5162052",
"0.5157932",
"0.5152905",
"0.5152353",
"0.5150909",
"0.514719",
"0.5138596",
"0.51333916",
"0.51139015",
"0.5113431",
"0.5113431",
"0.5109581",
"0.51066816",
"0.5091428",
"0.5089407",
"0.5082971",
"0.50822043",
"0.50668514",
"0.5055155",
"0.50525695",
"0.50499475",
"0.50499475",
"0.5034445",
"0.50249445",
"0.5022226",
"0.50167644",
"0.5014211",
"0.4999924",
"0.49996212",
"0.49978727",
"0.4989682",
"0.4989682",
"0.49851838",
"0.49817684",
"0.4979687",
"0.49787104",
"0.49688423",
"0.49664098",
"0.49564412",
"0.49561828",
"0.49547398",
"0.4953481",
"0.4952925",
"0.4946049",
"0.494379",
"0.49319315",
"0.49313048",
"0.49269778",
"0.49263066",
"0.49257493",
"0.4924526",
"0.49212465",
"0.49173486",
"0.4915802",
"0.49151486",
"0.49150333",
"0.49147308"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def sensor_params
params[:sensor][:unit] = params[:sensor][:unit].to_i
params[:sensor][:kind] = params[:sensor][:kind].to_i
params[:sensor][:type_of_graph] = params[:sensor][:type_of_graph].to_i
params[:sensor][:notification] = params[:sensor][:notification].to_i
params[:sensor][:notification_value] = params[:sensor][:notification_value].to_i
if params[:sensor][:public] == "on"
params[:sensor][:public] = true
else
params[:sensor][:public] = false
end
params.require(:sensor).permit(:name, :unit, :kind, :type_of_graph, :public, :notification, :notification_value)
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 |
dynamic programming bottom up | def is_match(s, p)
dp = Array.new(s.length+1) { Array.new(p.length+1, false) }
m, n = s.length, p.length
dp[m][n] = true
m.downto(0) do |i|
(n-1).downto(0) do |j|
first = i < m && (s[i] == p[j] || p[j] == '.')
if p[j+1] == '*'
dp[i][j] = dp[i][j+2] || (first && dp[i+1][j])
else
dp[i][j] = first && dp[i+1][j+1]
end
end
end
dp[0][0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_solution\n\n end",
"def build_subsolutions\n @success_probability = Array.new(@size)\n @success_probability[@size-1] = 1.0/@size\n (@size-1).downto(1).each { |k|\n @success_probability[k-1] = 1.0/@size + @success_probability[k]*(k-1)/k\n }\n end",
"def solve\n dp = H.times.map { [nil] * W }\n dp[0][0] = 1 << 60\n dp[1][0] = A[0][0] + A[1][0] + C\n dp[0][1] = A[0][0] + A[0][1] + C\n\n (1...W).each do |x|\n dp[0][x] = [A[0][x - 1] + C + A[0][x],\n dp[0][x - 1] + C + A[0][x] - A[0][x - 1]].min\n end\n (1...H).each do |y|\n dp[y][0] = [A[y - 1][0] + C + A[y][0],\n dp[y - 1][0] + C + A[y][0] - A[y - 1][0]].min\n end\n (1...H).each do |y|\n (1...W).each do |x|\n now = A[y][x]\n dp[y][x] = [\n A[y - 1][x] + C + now,\n A[y][x - 1] + C + now,\n dp[y - 1][x] + C + now - A[y - 1][x],\n dp[y][x - 1] + C + now - A[y][x - 1]\n ].min\n end\n end\n\n dp.flatten.min\nend",
"def alg; end",
"def minimize; end",
"def solve\n # Generate uniques\n spaces = student_ids.product(bag_ids)\n\n visited_nodes = 0\n student_ids.each do |sid|\n bid = solver.choose(*bag_choices_for_student(sid))\n visited_nodes +=1\n partial_plan[sid] = bid\n solver.assert assigned_bags_are_unique(partial_plan)\n solver.assert assigned_bags_without_student_repeats(partial_plan)\n end\n\n puts \"Visited: #{visited_nodes} nodes\"\n partial_plan.to_a\n end",
"def solve\n @time = Time.new\n for j in 0..@generations\n new_generation = Array.new\n @selection.init(@population)\n \n for i in 0..(@population_size/2)-1\n children = @reproduction.reproduce(@selection.select,@selection.select,@mutation)\n \n son = children[0]\n daughter = children[1]\n \n if son.fitness > @best_fitness\n @best_fitness = son.fitness\n @best_configuration = son.configuration.conf\n end\n \n if daughter.fitness > @best_fitness\n @best_fitness = daughter.fitness\n @best_configuration = daughter.configuration.conf\n end\n \n new_generation.push(son)\n new_generation.push(daughter)\n \n end\n \n @population = new_generation\n \n end\n @time = Time.new - @time\n end",
"def solve\n @time = Time.new\n while true\n if @stack.pop == 0\n else\n while (not @stack.empty?) && (@stack.peek == 1)\n @stack.pop\n end\n if not @stack.empty?\n @stack.pop\n else\n b = Time.new\n @time = b - @time\n return\n end\n \n end\n \n @current_configuration[@stack.size] = 1\n @stack.push(1)\n while @stack.size < @dimension\n @current_configuration[@stack.size] = 0\n @stack.push(0)\n end\n \n conf = Configuration.new(@current_configuration, @problem)\n curr_fitness = conf.fitness\n if curr_fitness > @best_fitness\n @best_fitness = curr_fitness\n for i in 0..@current_configuration.size - 1\n @best_configuration[i] = @current_configuration[i]\n end\n \n end\n \n end\n \n \n end",
"def solve\n a = Time.new\n for i in 0..@itemsSize - 1\n @table[0][i] = 0\n end\n \n for i in 1..@itemsSize - 1\n price = @problem.prices[i-1]\n weight = @problem.weights[i-1]\n for w in 1..@weights - 1\n if weight <= w\n if (price + @table[w - weight][i - 1]) > @table[w][i -1]\n @table [w][i]= price + @table[w - weight][i - 1]\n else\n @table[w][i] = @table[w][i - 1]\n end\n else\n @table[w][i] = @table[w][i - 1]\n end\n end\n end\n \n \n prev_item = 0\n for i in 1..@itemsSize - 1\n curr_item = @table[@weights - 1][i]\n if prev_item < curr_item\n @best_configuration.push(1)\n else\n @best_configuration.push(0)\n end\n prev_item = curr_item\n end\n \n @best_fitness = @table[@weights - 1][@itemsSize - 1]\n \n b = Time.new\n @time = b-a\n end",
"def solve\n loop { break if !shift }\n return @solutions\n end",
"def DP_solve(a)\n max, head, tail = 0, 0, 0\n cur_head = 0\n sum = [ [0, a[0]].max ] # base case\n (1...a.size).each do |j|\n sum[j] = [0, sum[j-1] + a[j]].max # bottom-up\n cur_head = j if sum[j-1] == 0 and sum[j] > 0\n if sum[j] > max\n head = cur_head\n tail = j\n max = sum[j]\n end\n end\n return max, head, tail\nend",
"def solve\n s = Hash[(1...1000).map { |i| [i, i * i] }]\n (1...1000).each do |c|\n (1...c).each do |b|\n (1..b).each do |a|\n return a * b * c if (a + b + c) == 1000 && (s[a] + s[b]) == s[c]\n end\n end\n end\nend",
"def solve\n end",
"def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end",
"def solve\n\t\tres = solveRec()\n\t\treturn res if res == [-1]\n\t\twhile ((nextIter = solveRec()) != [])\n\t\t\tres += nextIter\n\t\tend\n\n\t\treturn res;\n\tend",
"def min_ops(n)\n\n # Step 1:\n # Create a table containing the minimum operations\n # needed to reach n given our permitted operators.\n all_parents = Array.new\n all_min_ops = [0] + [nil] * n\n\n (1..n+1).each do |k|\n curr_parent = k - 1\n curr_min_ops = all_min_ops[curr_parent] + 1\n [2, 3].each do |i|\n if k % i == 0\n parent = k / i\n num_ops = all_min_ops[parent] + 1\n if num_ops < curr_min_ops\n curr_parent, curr_min_ops = parent, num_ops\n end\n end\n end\n all_parents[k], all_min_ops[k] = curr_parent, curr_min_ops\n end\n\n # Step 2: Trace back to find the optimal choices\n # made in the previous step.\n numbers = Array.new\n k = n\n while k > 0\n numbers << k\n k = all_parents[k]\n end\n puts numbers.size - 1\n numbers.reverse\nend",
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def solve_problem\n max = 4000000\n f_curr = 8\n f_prev = 2\n p_curr = 1\n sum = f_prev \n while f_curr <= max\n sum += f_curr\n temp = f_curr\n f_curr = 3*f_curr + 4*f_prev + 2*p_curr\n p_curr = 2*f_prev + p_curr\n f_prev = temp\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 solved(ans)\n\n end",
"def minimize\n\t\tdfa = DFA.new\n\t\tif @alphabet.empty?\n\t\t\treturn self\n\t\tend\n\t\taccept = @final.keys\n\t\treject = @state.keys - accept\n\t\t#print \"Accept { \" + accept.join(\", \").to_s + \" }\\n\"\n\t\t#print \"Reject { \" + reject.join(\", \").to_s + \" }\\n\"\n\t\tcounter = @@nextID\n\t\ta = counter\n\t\tif(!reject.empty?)\n\t\t\tcounter+=1\n\t\tend\n\t\tb = counter\n\t\tsymbol = nil\n\t\tdestination = nil\n\t\t\n\t\tif(!reject.empty?)\n\t\t\tdfa.state_rep[a] = reject\n\t\t\tdfa.state_rep[b] = accept\n\t\telse\n\t\t\tdfa.state_rep[a] = accept\n\t\tend\n\t\t\t\n\t\tstack = Array.new\n\t\tstack.push a\n\t\tstack.push b\n\t\tpartitions = Array.new\n\t\t#dfa.prettyPrint\n\t\twhile(partitions != stack)\n\t\t\tpartitions = stack\n\t\t\tstack = Array.new\n\t\t\t#puts \"Part: \" + partitions.to_s + \"stak: \" + stack.to_s\n\t\t\t#print \"R = {\" + partitions.join(\", \").to_s + \"}\\n\"\n\t\t\tpartitions.flatten.each{ |p|\n\t\t\t\t#print \"Split partition: { \" + dfa.state_rep[p].join(\", \").to_s + \" }\\n\"\n\t\t\t\tdfa.state_rep[p], temp = split(dfa.state_rep[p], dfa.state_rep)\n\t\t\t\t#print p.to_s + \" now contains: { \" + dfa.state_rep[p].join(\", \").to_s + \" }\\n\"\n\t\t\t\t#print \"Temp: { \" + temp.join(\", \").to_s + \" }\\n\"\n\t\t\t\tif(!temp.empty?)\n\t\t\t\t\tcounter+=1\n\t\t\t\t\tc = counter\n\t\t\t\t\tstack.push p\n\t\t\t\t\tstack.push c\n\t\t\t\t\t#print c.to_s + \" now contains { \" + temp.join(\", \").to_s + \" }\\n\"\n\t\t\t\t\t#dfa.prettyPrint\n\t\t\t\t\tdfa.state_rep[c] = temp\n\t\t\t\tend\n\t\t\t\tdfa.state_rep.keys.each { |state|\n\t\t\t\t\tdfa.clear_trans(state)\n\t\t\t\t\tdfa.state_rep[state].each { |stuffs|\n\t\t\t\t\[email protected]{ |c|\n\t\t\t\t\t\tdest = get_transition(stuffs, c)\n\t\t\t\t\t\tif dest != nil\n\t\t\t\t\t\t\tparks = dfa.state_rep.keys.dup\n\t\t\t\t\t\t\tparks.each{ |place|\n\t\t\t\t\t\t\t\tif dfa.state_rep[place].include?(dest)\n\t\t\t\t\t\t\t\t\t#puts \"adding (\" + state.to_s + \" \" + c.to_s + \" \" + place.to_s + \"\\n\" \n\t\t\t\t\t\t\t\t\tdfa.add_transition(state, place, c)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t#end\n\t\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#print dfa.state.to_s + \"\\n\"\n\t\t\t\t#puts \"-------------------------------\"\n\t\t\t}\n\t\t\t#puts \"Part: \" + partitions.to_s + \"stak: \" + stack.to_s\n\t\tend\n\t\tdfa.state.keys.each{ |parts|\n\t\t\tresult = 0\n\t\t\tis_start = 0\n\t\t\t#puts parts\n\t\t\tdfa.state_rep[parts].each { |state|\n\t\t\t\tif(is_final?(state))\n\t\t\t\t\tresult = 1\n\t\t\t\tend\n\t\t\t\tif(state == @start)\n\t\t\t\t\tis_start = 1\n\t\t\t\tend\n\t\t\t\t}\n\t\t\tif result == 1\n\t\t\t\tdfa.set_final(parts)\n\t\t\tend\n\t\t\tif(is_start == 1)\n\t\t\t\tdfa.set_start(parts)\n\t\t\tend\n\t\t}\n\t\tdfa\n end",
"def dynamicArray(n, queries)\n solver = Solver.new(n, queries)\n solver.execute\nend",
"def greedy1_fill!(remaining_partitions)\n remaining_partitions.each do |src_partition|\n # Test each site ...\n src_partition.sites.each do |site|\n\n simulation_result_below_bound = {}\n simulation_result_above_bound = {}\n # ... in each bin ...\n self.each_with_index do |bin, bin_index|\n target_partition = bin.list[src_partition.name]\n if target_partition.nil?\n # Creating a new partition is more costly than the worst case\n operations = @operations_worst_case + 1\n else\n # Simulate insertion of site into existing partition of current bin\n operations = target_partition.incr_add_sites!([site], simulate = true)\n end\n # Check if bin.size is smaller than lower_bound. Save simulation_result accordingly to prefer addition below lower_bound.\n if bin.update_size!.size < @operations_lower_bound\n simulation_result_below_bound.merge!({operations => bin_index})\n else\n simulation_result_above_bound.merge!({operations => bin_index})\n end\n\n end\n\n # Insert at lowest operation cost\n best = if simulation_result_below_bound.empty?\n simulation_result_above_bound.min_by { |operations, bin_index| operations }\n else\n simulation_result_below_bound.min_by { |operations, bin_index| operations }\n end\n target_partition = @list[best[1]].list[src_partition.name]\n if target_partition.nil?\n @list[best[1]].add!([Partition.new(src_partition.name, [site], src_partition.tree)])\n else\n target_partition.incr_add_sites!([site])\n end\n\n end\n end\n end",
"def problem_106a\n combin = lambda { |m,h| m.factorial / (h.factorial * (m - h).factorial) }\n max = 20\n\n sum = Array.new(max+1,-1)\n 1.upto(max) do |n|\n 0.upto(n/2) do |k|\n sum[n] += combin.call(n,2*k) * combin.call(2*k - 1, k + 1)\n end\n puts \"#{n} #{sum[n]}\"\n end\n sum[12]\nend",
"def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend",
"def dpll\n\t\t#need to count degree, best_guess, assignments and such heuristic stuff somewhere... makes sense to do it here\n\t\t#should make a version without heuristics aswell\n##############################################3\n#\t\tputs \"the kb : \" + @kb.to_s\n\n\t\[email protected] do |sente|\n##########################################################333\n#\t\t\tputs \" the sentences: \" + sente.to_s\n\n\t\t\tif(sente.size==1)\n\t\t\t\tindex=sente[0]\n\t\t\t\tif(index > 0)\n\t\t\t\t\t@id_array[index-1].pos_increment\n\t\t\t\t\t@id_array[index-1].puret=true\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tindex*=-1\n\t\t\t\t\t@id_array[index-1].neg_increment\n\t\t\t\t\t@id_array[index-1].puref = true\n\t\t\t\tend\t\n\t\t\telse\t\n\t\t\t\tsente.each do |atome|\n#############################################################\n#\t\t\t\t\tputs \"the individual atoms: \" + atome.to_s\n\t\t\t\t\tif(atome > 0)\n\t\t\t\t\t\tindex = atome-1\n\t\t\t\t\t\t@id_array[index].pos_increment\n\t\t\t\t\telse\n\t\t\t\t\t\tindex = -1*atome-1\n\t\t\t\t\t\t@id_array[index].neg_increment\n\t\t\t\t\tend\t\t\t\n\t\t\t\tend\n\t\t\tend\t\n\t\tend\n\t\t@id_array.each do |var|\n\t\t\tif(!var.assignment_intialize)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\t\n\t\t#intialization stuff\n\t\t##########heuristic sort!\n\t\tvar_list = @id_array\n\t\tvar_list.sort!\n\t\t\n\t\tdepth=0\n\t\tassignment = Array.new\n\t\tsatisfiable = false\n\t\tstack = []\n\t\n\t\t#make parallel array assignment\n\t\tid_array.map { assignment << 0}\n\t\t\n\n\t\t#insert root\n\t\t(var_list[depth].assignments).map do |child|\n\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\tend\n\t\t\n\t\t#start depth-first search\n\t\twhile(stack.size()>0)\n\t\n\t\t\ttemp = stack.pop\n\t\t\n\t\t\t#comparing depth to make sure assignment variables reassigned if popping up the tree\n\t\t\twhile(depth>temp.depth)\n\t\t\t\tassignment[depth] = 0\n\t\t\t\tdepth -=1\n\t\t\tend\t\n\t\t\t#add it to the assignment evaluation list (depth doubles as index through var_list)\n\t\t\tassignment[var_list[temp.depth].id - 1] = temp.value\n\t\t\n\t\t\t#Evaluate the assignment list\n\t\t\tif(satisfiable_assignment?(assignment)==1)\n##########################################################################333\n\t\t\t\tputs \"the kb is: \" + @kb.to_s \n\t\t\t\tputs \"the assignment that evaluates to true: \"\n\t\t\t\tputs assignment.to_s\n#############################################################################\n\t\t\t\t\n\t\t\t\treturn true\n\t\t\tend\n\t\n\t\t\t#add children\n\t\t\tdepth+=1\t\n\t\n\t\t\t#if not bottumed out, add more children based on values from the var\n\t\t\tif(depth<var_list.size())\n\t\t\t\t(var_list[depth].assignments).map do |child|\n\t\t\t\t\tstack.push(Assign_Stack_Object.new(child,depth))\n\t\t\t\tend\t \n\t\t\telse\n\t\t#reset to bottom value\n\t\t\t\tdepth =var_list.size-1\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def solution \n row_search \n columns_search \n diagonal_search\n end",
"def test_DP_20\n path=\"/home/miro/NetBeansProjects/Knapsack/test/\"\n\n p=Solver.new\n\n p.read_problem(path+\"input3\")\n\n assert_equal(1995, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input4\")\n\n assert_equal(2168, p.dynamic)\n\n p=Solver.new\n p.read_problem(path+\"input5\")\n\n assert_equal(2623, p.dynamic)\n\n\n\n end",
"def solve(ingredients, part_two: false)\n score = 0\n max = 0\n\n (0..100).each do |i|\n (0..100 - i).each do |j|\n (0..100 - i - j).each do |k|\n l = 100 - i - j - k\n capacity = calculate_total(ingredients, \"capacity\", i, j, k, l)\n durability = calculate_total(ingredients, \"durability\", i, j, k, l)\n flavor = calculate_total(ingredients, \"flavor\", i, j, k, l)\n texture = calculate_total(ingredients, \"texture\", i, j, k, l)\n calories = calculate_total(ingredients, \"calories\", i, j, k, l)\n\n next if part_two && calories != 500\n next if capacity <= 0 || durability <= 0 || flavor <= 0 || texture <= 0\n\n score = capacity * durability * flavor * texture\n max = score if score > max\n end\n end\n end\n max\nend",
"def condition(i, j)\n # first solved the two equations for just i and j\n 500_000 - 1000*i - 1000*j + i*j == 0\nend",
"def minimize\n# create a new one, or modify the current one in place,\n# and return it\nfa = FiniteAutomaton.new\nkeys = @state.keys.sort\np0, p1 = [], []\nkeys.each{|k|\nif is_final?(k)\np0 = p0.push(k)\nelsif\np1 = p1.push(k)\nend\n}\nnewfa = {}\nrstate = []\nif p0 != nil then rstate.push(p0) end\nif p1 != nil then rstate.push(p1) end\npstate = []\nwhile pstate != rstate\npstate = []\nrstate.each{|r| pstate.push(r)}\nrstate = []\npstate.each{|p|\np = p.sort\nresult = split(p, pstate)\np0 = result[0]\np1 = result[1]\nresult.each{|r|\nif r != []\nr = r.sort\nrstate = rstate.push(r)\nend\n}\n}\nend\nstart = []\nfinal = []\nrstate.each{|r| newfa[r] = fa.new_state}\nlist = newfa.keys\nlist.each{|l|\nl.each{|k|\nif k == @start\nstart.push(l)\nend\nif is_final?(k)\nfinal.push(l)\nend\n}\n}\nif start != []\nstart.each{|s| if newfa[s] then fa.set_start(newfa[s]) end}\nend\nif final != []\nfinal.each{|f| fa.set_final(newfa[f], true)}\nend\nrstate.each{|r0|\nr0.each{|r1|\[email protected]{|a|\nif get_transition(r1, a) != nil\nrstate.each{|r|\nif r.include?(get_transition(r1, a)[0])\nif !(fa.get_transition(newfa[r0], a))\nfa.add_transition(newfa[r0], newfa[r], a)\nif fa.get_alpha.include?(a) == false\nfa.get_alpha.push(a)\nend\nend\nend\n}\nend\n}\n}\n}\nfa\nend",
"def maximize; end",
"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 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(a=nil, b=nil)\n program = @program.dup\n pointer = 0\n opcode = 0\n program[1] = a if a\n program[2] = b if b\n\n while (opcode != @STOP && pointer < program.length) do \n puts \"pointer: #{pointer}\" if @DEBUG\n opcode = program[pointer]\n a = 0\n b = 0\n c = 0\n\n # Check Immeidate Mode\n if(opcode.to_s.length > 2)\n opcode = opcode.to_s\n # need to parse that fancy code\n instruction = opcode[-2..-1].to_i\n puts \"instruction: #{instruction}\\nopcode: #{opcode}\" if @DEBUG\n \n if (opcode.length == 3)\n puts \"length: 3\" if @DEBUG\n c = opcode[0].to_i\n elsif (opcode.length == 4)\n puts \"length: 4\" if @DEBUG\n b = opcode[0].to_i\n c = opcode[1].to_i\n elsif (opcode.length == 5)\n puts \"length: 5\" if @DEBUG\n a = opcode[0].to_i\n b = opcode[1].to_i\n c = opcode[2].to_i\n end\n else\n puts \"opcode only: #{opcode}\" if @DEBUG\n instruction = opcode.to_i\n end\n\n if(instruction == @STOP)\n puts \"STOP\"\n break\n end\n\n puts \"a: #{a}\\nb: #{b}\\nc: #{c}\\n\" if @DEBUG\n \n if(instruction == @ADD || instruction == @MULTIPLY)\n position_a = program[pointer + 1].to_i\n position_a = program[position_a].to_i if c == 0\n\n position_b = program[pointer + 2].to_i\n position_b = program[position_b].to_i if b == 0\n\n position_c = program[pointer + 3].to_i #if a == 0\n #position_c = program[pointer + 3].to_i if a == 1\n \n if(instruction == @ADD)\n program[position_c] = position_a + position_b\n elsif(instruction == @MULTIPLY)\n program[position_c] = position_a * position_b\n end\n pointer += 4\n puts \"incrementing pointer by 4\" if @DEBUG\n end\n\n if(instruction == @READ)\n if (c == 0)\n puts \"\\nSTATUS: #{program[program[pointer + 1].to_i]}\\n\"\n else\n puts \"\\nSTATUS: #{program[pointer + 1]}\\n\"\n end\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n if(instruction == @STORE)\n print \"input: \"\n number = gets.strip\n target = program[pointer + 1].to_i\n program[target] = number.to_i\n pointer += 2\n puts \"incrementing pointer by 2\" if @DEBUG\n end\n\n # only two params\n if(instruction == @JUMP_IF_TRUE)\n puts \"Jump if true\" if @DEBUG\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n unless program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # only two params\n if(instruction == @JUMP_IF_FALSE)\n puts \"Jump if false\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n \n if @DEBUG\n puts \"first: #{first}\\nsecond: #{second}\"\n puts \"first_value: #{program[first]}\\nsecond_value: #{program[second]}\"\n end\n\n if program[first].to_i == 0\n pointer = program[second].to_i\n puts \"assigning pointer to #{pointer}\" if @DEBUG\n else\n pointer += 3\n puts \"incrementing pointer by 3\" if @DEBUG\n end\n end\n\n # four parameters\n if(instruction == @LESS)\n puts \"Less\" if @DEBUG\n\n first = pointer + 1\n first = program[first].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n if(program[first].to_i < program[second].to_i)\n program[third] = 1\n else\n program[third] = 0\n end\n\n pointer += 4\n end\n\n if(instruction == @EQUALS)\n puts \"Equals\" if @DEBUG\n\n first = pointer + 1\n first = program[pointer + 1].to_i if c == 0\n\n second = pointer + 2\n second = program[second].to_i if b == 0\n\n third = pointer + 3\n third = program[third].to_i if a == 0\n\n puts \"first: #{program[first]}, second: #{program[second]}\" if @DEBUG\n\n if(program[first].to_i == program[second].to_i)\n puts \"Setting #{third} to 1\" if @DEBUG\n program[third] = 1\n else\n puts \"Setting #{third} to 0\" if @DEBUG\n program[third] = 0\n end\n\n pointer += 4\n end\n gets if @DEBUG\n end\n return program[0]\n end",
"def calculate_subsolutions\n @subsolutions = Array.new(@items.size+1) { Array.new(@max_weight+1) }\n @subsolutions[0].map!{|value| 0}\n ([email protected]).each { |i|\n (0..@max_weight).each { |j|\n # case 1. Item i excluded, no additional weight added to knapsack\n value1 = @subsolutions[i-1][j]\n # case 2. Item i is included, requires adding item's weight to knapsack\n value2 = (@items[i-1].weight<=j) ? (@items[i-1].value + @subsolutions[i-1][j-@items[i-1].weight]) : -1\n # a total value stored in a knapsack, when i items and j max_knapsack_weight\n @subsolutions[i][j] = (value1>value2) ? value1 : value2\n }\n }\n @max_value = @subsolutions[@items.size][@max_weight]\n end",
"def slow_solution(a)\n m = 0\n a.size.times do |i|\n a[i] = a[i].abs\n m = [a[i], m].max\n end\n maxsum = a.sum # sum of absolute val of all nums in array\n # maxsum = a.map(&:abs).sum <- Ruby shortcut\n\n # If dp = 1 at an index, it means some combo of elements in a add up to that index\n dp = [0] * (maxsum + 1)\n dp[0] = 1\n\n a.size.times do |j|\n maxsum.downto(0).each do |possible_sum|\n puts \"a[j]: #{a[j]}, possible sum: #{possible_sum}\"\n if (dp[possible_sum] == 1) and (possible_sum + a[j] <= maxsum)\n\n # if possible_sum + new element a[j] is possible sum, dp = 1!\n dp[possible_sum + a[j]] = 1\n puts \"Mark #{possible_sum + a[j]} as possible sum in dp\"\n end\n end\n puts \"row: #{j}, a[j]: #{a[j]}, dp: #{dp}\"\n puts\n end\n\n min_q_minus_p = maxsum\n\n # Divide array a into 2 parts, where P = sum of part 1 and Q = sum of part 2,\n # P + Q = maxsum, and P <= maxsum / 2 <= Q.\n # We want largest possible P to get smallest possible Q-P.\n\n # loop from 0 to maxsum / 2, covering every possible P, Q division\n (maxsum / 2 + 1).times do |possible_half_sum|\n # puts \"possible_half_sum: #{possible_half_sum}\"\n if dp[possible_half_sum] == 1 # means P or Q = possible_half_sum\n q_minus_p = maxsum - 2 * possible_half_sum\n # puts \"Q - P: #{q_minus_p}\"\n min_q_minus_p = [min_q_minus_p, q_minus_p].min\n # puts \"min Q - P: #{min_q_minus_p}\"\n end\n end\n\n min_q_minus_p\nend",
"def compute(array)\n\n index = 0\n while index < array.length\n code = array[index]\n instruction = code % 100\n case instruction\n when 1\n add(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 2\n multiply(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 3\n # Input\n consume_input(code, array, array[index + 1])\n index += 2\n when 4\n # Output\n write_to_output(code, array, array[index + 1])\n index += 2\n when 5\n bool, new_index = jump_if_true(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 6\n bool, new_index = jump_if_false(code, array, array[index + 1], array[index + 2])\n\n index = bool ? new_index : index + 3\n when 7\n less_than(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 8\n equals(code, array, array[index + 1], array[index + 2], array[index + 3])\n index += 4\n when 9\n add_to_relative_base(code, array, array[index + 1])\n index += 2\n when 99\n break\n else\n break\n end\n end\nend",
"def simulatedAnnealing(is,cS,cC,bSolution,bCost,temp,final_temp,alpha)\n #membuat array untuk menampung setiap solusi\n solusiTemp = {}\n solusiBestSolution = {}\n solusiBestCost= {}\n j=1 #insisialisasi\n while temp > final_temp do\n\n for i in 1..100\n #memunculkan bilangan random untuk perbandingan sekarang dengan yang baru\n x11 = fungsiRandom()\n x22 = fungsiRandom()\n nS = [x11,x22] #state baru\n nC = cost(nS) #perhitungan fungsi dari state baru\n end\n if nC < cC then #membandingkan costBaru dengan costSekarang\n cS = nS\n cC = nC\n if cC < bCost then #jika costBaru lebih kecil dari costSekarang maka bandingkan dengan bestCost\n bSolution = cS\n bCost = cC\n end\n else #jika tidak maka diliat nilai probab\n #ilitasnya lalu bandignkan dengan nilai random(0,1)\n if (prob(nC,cC,temp) > fungsiRandom01()) then\n cS = nS\n cC = nC\n end\n #menampung solusi\n solusiTemp[j] = temp\n solusiBestSolution[j] = bSolution\n solusiBestCost[j] = bCost\n end\n j = j+1\n temp = temp * alpha #Menghitung penentu iterasi temperatur\n end\n xx = solusiTemp[solusiTemp.length]\n y = bSolution\n z = bCost\n #mengembalikan nilai solusi\n return solusiTemp,solusiBestSolution,solusiBestCost,xx,y,z\n\nend",
"def solve!\n end",
"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 n_queens_problem_sum_variant(n)\n n_queens_problem_rec(0, Array.new(n, -1))\nend",
"def resolve\n\t\treturn 1 if @n == 0\n\t\trow = [1,1]\n\t\t2.upto(@n) do\n\t\t\tcurrent = [1]\t\t\t\n\t\t\t1.upto(row.size-1) do |i|\n\t\t\t\tcurrent << row[i-1] + row[i]\n\t\t\tend\n\t\t\tcurrent << 1\n\t\t\trow = current\n\t\tend\n\t\trow.inject(0) {|sum, n| sum + n*n}\n\tend",
"def solution(a)\n # [1, -INFINITY, -INFINITY, -INFINITY, -INFINITY, -INFINITY]\n # [1,-1, 1, 10, 0, -1] row = 1. start_val = 1\n # [1,-1, 1, 10, 0, -1] row = 2. start_val = -1\n # [1,-1, 1, 10, 0, -1] row = 3. start_val = 1\n # [1,-1, 1, 10, 9, 8] row = 4. start_val = 10\n # [1,-1, 1, 10, 9, 8] row = 5. start_val = 9\n\n dp = [a[0]] + [MININT] * (a.size - 1)\n (1..a.size - 1).each do |row|\n start_index = row - 1\n start_val = dp[start_index]\n\n # we may only move forward up to 6 spots\n end_col = [a.size - 1, start_index + 6].min\n puts \"start_val: #{start_val}. Inner loop start_col: #{row} / end_col: #{end_col}\"\n\n (row..end_col).each do |col|\n puts \"row: #{row}, col: #{col}\"\n dp[col] = [dp[col], start_val + a[col]].max\n end\n p dp\n puts\n end\n\n \"Answer: #{dp.last}\"\nend",
"def find_solution(arr)\n arr.each_with_index do |e, i|\n rest = arr[0..i - 1] + arr[i + 1..-1]\n prod = rest.reduce(:*)\n arr[i] = prod\n end\n\n arr\nend",
"def qytt\n # procure the numbers\n arrNumbers = [ arrNumbersOfProcGivenMinMax( method(:intGetTriangleInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetSquareInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetPentagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHexagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHeptagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetOctagonalInt), 1000, 10000) ]\n arrNumbers.map! do |arr|\n deletable = []\n arr.each do |num|\n if ( num / 10 % 10 == 0 )\n deletable << num\n end\n end\n arr -= deletable\n end\n\n # get the hash numbers which we will jump to and from\n hashNumbers = Array.new(6){ HashChained.new }\n (0..5).each do |i|\n arrNumbers[i].each do |num|\n hashNumbers[i][num/100] = num % 100\n end\n end\n\n threads = []\n # we're guaranteed only one solution\n superResult = 0\n\n # iterate through the octagonal numbers\n arrNumbers.last.each do | firstNum |\n checker = firstNum % 100\n hashNumbers[0..4].permutation.each do |perm|\n t = Thread.new do\n result = qyttRecursion( checker, perm )\n if result[0] > 0 && result[1] == firstNum / 100\n superResult = result[0] + firstNum\n end\n end\n threads << t\n end\n end\n\n threads.each do |t|\n t.join\n end\n superResult\n\nend",
"def sor(n, a, b, x0, w, error, n_max)\n n = n - 1\n\n x = Array.new(n + 1)\n for k in (0..n_max)\n sumatoria = (1..n).inject(0) { |sum, j| sum + a[0][j] * x0[j] }\n x[0] = (1 - w) * x0[0] + w * (b[0] - sumatoria).fdiv(a[0][0])\n\n (1..n - 1).each do |i|\n sumatoria_1 = (0..i - 1).inject(0) { |sum, j| sum + a[i][j] * x[j] }\n sumatoria_2 = (i + 1..n).inject(0) { |sum, j| sum + a[i][j] * x0[j] }\n x[i] = (1 - w) * x0[i] + w * (b[i] - sumatoria_1 - sumatoria_2).fdiv(a[i][i])\n end\n\n sumatoria = (0..n - 1).inject(0) { |sum, j| sum + a[n][j] * x[j] }\n x[n] = (1 - w) * x0[n] + w * (b[n] - sumatoria).fdiv(a[n][n])\n\n resta = x.map.with_index { |xi, i| xi - x0[i] }\n modulo = Math::sqrt(resta.inject(0) { |sum, i| sum + i ** 2 })\n if modulo < error\n puts \"Una solucion aproximada es X = #{x}.\"\n return x\n end\n\n x0.replace(x)\n end\n\n puts \"Se alcanzo el numero maximo de iteraciones n_max pero no la tolerancia.\"\nend",
"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 has_solution(n)\n# Store input in variable N\n$N = n\n\n#Declare and initialize variables to find the maximum number of times 6, 9 and 20 divide into N\n$A_1 = $N/$x\n$A_2 = $N/$y\n$A_3 = $N/$z\n\n#Declare and initialize arrays to store potential combinations, where A is number of 6 packs, B number of 9 packs and C number of 20 packs\n@A = (0..$A_1).to_a\n@B = (0..$A_2).to_a\n@C = (0..$A_3).to_a\n\n#Declare function to calculate different combinations of A, B and C\ndef test(i,j,k)\nreturn @A[i]*$x + @B[j]*$y + @C[k]*$z\nend\n\n#Loop to exhaustively test combinations of A, B and C, with values ranging between 1 and the maximum number of times 6, 9 and 20 divide into N\nfor i in (0..$A_1)\n for j in (0..$A_2)\n for k in (0..$A_3)\n #Use declared function test to check each combination of i,j and k, and if it is equal to N, print out values of i, j and k\n if test(i,j,k) == $N\n return true\n end\n end\n end\nend\n\nend",
"def solution\n throw 'No Solution yet' unless @cs\n lambda do |x|\n res = 0;\n @cs.each.with_index do |c,i|\n res += c*phi(i,x)\n end\n res\n end\n end",
"def solve_biro_recursion\n\t\ttime do\n\t\t\tans = self.biro_recursion(@size, @size)\n\t\t\tputs \"The number of routes through a #{@size}x#{@size} grid is #{ans}.\"\n\t\tend\n\tend",
"def solve\n n = 33\n while true\n begin\n n += 2\n end while n.prime?\n\n s, ds = 2, 6\n while s < n && !(n - s).prime?\n s += ds\n ds += 4\n end\n\n break if s >= n\n end\n \n n\n end",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def primordial; end",
"def calculate_subsolutions_space_efficient\n @subsolutions_1 = Array.new(@max_weight+1, 0)\n @subsolutions_2 = Array.new(@max_weight+1)\n\n ([email protected]).each { |i|\n puts i\n (0..@max_weight).each { |j|\n # case 1. Item i excluded, no additional weight added to knapsack\n value1 = @subsolutions_1[j]\n # case 2. Item i is included, requires adding item's weight to knapsack\n value2 = (@items[i-1].weight<=j) ? (@items[i-1].value + @subsolutions_1[j-@items[i-1].weight]) : -1\n # a total value stored in a knapsack, when i items and j max_knapsack_weight\n @subsolutions_2[j] = (value1>value2) ? value1 : value2\n }\n # move newly found subsolutions to subsolutions1\n (0..@subsolutions_2.size-1).each {|i| @subsolutions_1[i] = @subsolutions_2[i] }\n }\n @max_value = @subsolutions_2[@max_weight]\n end",
"def solver (seed_char, blanks_words_sizes, matrix)\n\t# Set numerical target\n\ttarget = magic_num(seed_char)\t\n\t# Find magic number sum buckets\n\tskynet(target, blanks_words_sizes, blanks_words_sizes.length - 1, 0, [])\n\t# Alphabetical sort input matrix\n\tsorted_seed_char = seed_char.chars.sort.join\t\n\n\t# Find unique sets from skynet solutions\n\t$answer[:trace].each do |arrOarr|\n\t\tarrOarr.sort!\n\tend \n\n\t$answer[:trace].uniq!\t\n\t\n\t# Finds match for complete set of words from skynet solutions\n\t$answer[:trace].each do |answer_arr_el|\t\t\t\t\n\t\tunordered_match(sorted_seed_char, matrix, answer_arr_el, answer_arr_el.length - 1, \"\", [])\n\t\t# Can be ignored\n\t\t$ops += $seed[answer_arr_el[0][0]][:num_groups][answer_arr_el[0][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length *\n\t\t\t$seed[answer_arr_el[1][0]][:num_groups][answer_arr_el[1][1]].length\t\t\n\tend\n\t\n\treturn $answer[:words]\nend",
"def compare_solutions(count = 5, n_min = 1, n_max = 300)\n arr = generate(count, n_min, n_max)\n if solve(arr) != solve_opt(arr)\n puts \"\\nFAILED\"\n puts 'data: ' + arr.to_s\n puts 'solution: ' + solve(arr).to_s\n puts 'optimized solution: ' + solve_opt(arr).to_s\n end\nend",
"def solution\n\n return self if solved?\n\n while [hidden_singles, naked_singles].any?\n end\n\n return self if solved?\n\n\n # Brute force\n i = each_empty_cell.sort_by { |cell, n| legal_values(n).size }.first.try :last\n\n legal_values(i).map do |value|\n fill(i, value).solution\n end.compact.select { |n| n.solved? }.first\n end",
"def solution(size=5)\n ([1] + (3..size).select(&:odd?).map do |x|\n 4*x**2 - 6*x + 6\n end).reduce(:+)\nend",
"def solve\n max = nil\n\n # Start with the longest possible and work down. \n 9.downto( 1 ) do |i|\n max = Array.new( i ) {|j| 1 + j}.permutation.to_a.map! {|j| j.join.to_i}.select {|j| j.prime? }.max\n break if max\n end\n \n max\n end",
"def test_ce_deBoer_2\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n # Cost matrix\n n = 5\n c = NArray[[0,1,3,5,6],\n [1,0,3,6,5],\n [3,3,0,2,2],\n [5,6,2,0,2],\n [6,5,2,2,0]]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.pr[true,0] = NArray[0.0,1.0] # put vertex 0 in subset 1\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n smooth = 0.4\n\n max_cut_score = proc do |sample|\n weight = 0\n for i in 0...n\n for j in 0...n\n weight += c[j,i] if sample[i] < sample[j]\n end\n end\n -weight # to be minimized\n end\n best_cut = NArray[1,1,0,0,0]\n assert_equal(-15, max_cut_score.call(NArray[1,0,0,0,0]))\n assert_equal(-28, max_cut_score.call(best_cut))\n\n mp.to_score_sample(&max_cut_score)\n\n mp.to_update do |pr_iter|\n smooth*pr_iter + (1 - smooth)*mp.pr\n end\n\n mp.for_stop_decision do\n #p mp.pr\n mp.num_iters >= mp.max_iters\n end\n\n mp.solve\n\n if best_cut != mp.most_likely_solution\n warn \"expected #{best_cut}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end",
"def solution4(input)\n end",
"def optimize(ary, total)\n return [] if ary.empty?\n table = []\n (ary.size+1).times { |i| table[i] = [] }\n (0..total).each { |zerg| table[0][zerg] = 0 }\n (1..ary.size).each do |base|\n table[base][0] = 0\n (1..total).each do |zerg|\n if ary[base-1].zerg <= zerg && (ary[base-1].minerals + table[base-1][zerg - ary[base-1].zerg] > table[base-1][zerg])\n table[base][zerg] = ary[base-1].minerals + table[base-1][zerg - ary[base-1][1]]\n else\n table[base][zerg] = table[base-1][zerg]\n end\n end\n end\n result = []\n i, k = ary.size, total\n while i > 0 && k > 0\n if table[i][k] != table[i-1][k]\n result << ary[i-1]\n k -= ary[i-1].zerg\n end\n i -= 1\n end\n result\nend",
"def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end",
"def special_pythag_trip(target_sum)\n\ta = 1\n\tb = 1\n\tfor a in (1..target_sum) do\n\t\tfor b in (1..target_sum) do\n\t\t\t#puts \"a : #{a}\"\n\t\t\t#puts \"b : #{b}\"\n\t\t\tsum_of_squares = a*a + b*b\n\t\t\tc = Math.sqrt(sum_of_squares).to_i\n\t\t\t\n\t\t\tif c*c == sum_of_squares\n\t\t\t\ttriple = [a,b,c] \n\t\t\t\tsum = triple.inject(0) {|sum,num| sum + num}\n\t\t\t\t\n\t\t\t\treturn triple[0]*triple[1]*triple[2] if sum == target_sum\n\t\t\tend\n\t\t\t\n\t\tend\n\t\n\tend\nend",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend",
"def solve_prims\n linked, unlinked = [nodes.first], nodes[1..-1].dup\n end",
"def solve_for_d_optimized\n hash = {}\n for a in (1..5)\n for b in (1..5)\n result = (a**2) + (b**2)\n if hash[result].nil?\n hash[result] = [\"(#{a}, #{b})\"]\n else\n hash[result] << \"(#{a}, #{b})\"\n end\n end\n end\n\n hash.each do |key, array|\n if array.length > 1\n puts \"This is the result (#{array})\"\n end\n end\nend",
"def arrayManipulation(n, queries)\r\n arr = Array.new(n, 0)\r\n\r\n queries.each do |query|\r\n left = query[0] - 1\r\n right = query[1] - 1\r\n summand = query[2]\r\n\r\n arr[(left..right)] = arr[(left..right)].map { |a| a + summand }\r\n end\r\n\r\n arr.max\r\nend",
"def knapsack_dp(w, w_arr, v_arr, n)\n return 0 if w == 0 || n == 0\n cache = {}\n\n (0..n).each do |nn|\n cache[nn] = {}\n (0..w).each do |ww|\n cache[nn][ww] = if ww == 0 || nn == 0\n 0\n elsif w_arr[nn - 1] > ww\n cache[nn - 1][ww]\n else\n [v_arr[nn - 1] + cache[nn - 1][ww - w_arr[nn - 1]], cache[nn - 1][ww]].max\n end\n end\n end\n cache[n][w]\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n #trangular\r\n # a[0] = 10\r\n # a[2] = 5\r\n # a[4] = 8\r\n # 10 + 5 > 8\r\n # 5 + 8 > 10\r\n #8 + 10 > 5\r\n \r\n \r\n l=a.count\r\n \r\n i=0\r\n while(i<l) do\r\n j=i+1\r\n while(j<l) do\r\n k=j+1\r\n \r\n \r\n while(k<l) do\r\n if((a[i] + a[j] > a[k]) && (a[j] +a[k] > a[i]) && (a[k] + a[i] >a[j]))\r\n return 1\r\n end\r\n k+=1 \r\n end \r\n \r\n j+=1 \r\n end\r\n i+=1\r\n end\r\n \r\n return 0\r\n \r\nend",
"def problem(a=100,b=100)\n (2..a).inject(0) {|s1,i| s1 += (2..b).inject(0) {|s2,j| @terms.add?(i**j) ? s2 += 1 : s2}}\n end",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def getWays(n, c)\n # Write your code here\n w = n\n m = c.length\n dp = Array.new(m+1){Array.new(w+1)}\n 0.upto(m) do |i|\n dp[i][0] = 1\n end\n 0.upto(w) do |j|\n dp[0][j] = 0\n end\n 1.upto(m) do |i|\n 1.upto(w) do |j|\n x = j-c[i-1] >= 0 ? dp[i][j-c[i-1]] : 0\n y = j >= 1 ? dp[i-1][j] : 0\n dp[i][j] = x+y\n end\n end\n p dp\n dp[m][w]\nend",
"def solve!\n mapping = [4, 7, 9]\n @matrix[0..2].each { |row| mapping.each { |idx| raise 'invalid equations system' unless (1 - row.fetch(idx)).zero_eps? }}\n\n first = @matrix.fetch(0)\n second = @matrix.fetch(1)\n third = @matrix.fetch(2)\n\n @matrix[1..2].each { |row| row.subtract!(first) }\n second.normalize_term!(2)\n third.normalize_term!(2).subtract!(second) unless third.fetch(2).zero_eps?\n third.normalize_term!(3)\n second.normalize_term!(3).subtract!(third).normalize_term!(2) unless second.fetch(3).zero_eps?\n\n mapping = [4, 1, 0]\n {1 => 7, 2 => 9}.each do |ri, ci|\n row = @matrix.fetch(ri)\n mapping.zip(sum_square(row.fetch(1), row.fetch(0))).each do |idx, val|\n first[idx] += val\n end\n first[ci] -= 1.0\n end\n\n first.normalize_term!(2).subtract!(second) unless first.fetch(2).zero_eps?\n first.normalize_term!(3).subtract!(third) unless first.fetch(3).zero_eps?\n first.normalize_term!(4)\n\n coefs = mapping.map { |idx| first.fetch(idx) }\n mapping = Set.new(mapping)\n first.each_with_index { |val, idx| raise 'calculating error' unless mapping.include?(idx) || val.zero_eps? }\n delta = coefs[1] ** 2 - 4 * coefs[0] * coefs[2]\n raise 'negative or zero discriminant' if delta <= 0 || delta.zero_eps?\n delta = Math.sqrt(delta)\n\n root_x = ->(delta_sqrt) { (delta_sqrt - coefs[1]) / (2 * coefs[0]) }\n root_yz = ->(x, row) { -(row.fetch(0) + x * row.fetch(1)) }\n @roots = [delta, -delta].map do |x|\n x = root_x.call(x)\n [x, root_yz.call(x, second), root_yz.call(x, third)]\n end\n end",
"def solution(arr)\n dp = Array.new(arr.max+2, 0)\n arr.each { |a| dp[a] += 1 }\n\n for i in 2...dp.size do\n dp[i] = [dp[i-2] + i*dp[i], dp[i-1]].max\n end\n dp.last\nend",
"def calculate_solution\n Solve.it!(\n GraphBuilder.graph_from_cache(@cache, @options),\n resolver.constraints\n )\n end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def A(w, v, i,j)\n if i == 0 || j == 0\n \t0\n\telsif w[i-1] > j\n A(w, v, i-1, j)\n else\n \t[A(w,v, i-1, j), v[i-1] + A(w,v, i-1, j - w[i-1])].max\n end\nend",
"def solve jug_sizes, starting_state, has_drain, has_source\n if !block_given? \n raise \"Solve must be called with a block that checks a state (array of jug fill states) if it is a winning state.\"\n end\n\n if jug_sizes.length != starting_state.length \n raise \"The jug sizes array and starting state array must have the same length (i.e. for each jug there must be a size and fill state)\"\n end\n\n seen_states=[starting_state].to_set\n states_to_process = [[[], starting_state]]\n\n while states_to_process.length > 0\n state_to_process = states_to_process.delete_at(0)\n puts \"Processing state #{state_to_process[1]}...\"\n if yield(state_to_process[1]) \n puts \" problem solved.\"\n return state_to_process[0] \n end\n\n state=state_to_process[1]\n steps=state_to_process[0]\n\n for from in 0..jug_sizes.length-1\n for to in 0..jug_sizes.length-1\n next if from==to\n next if state[from]==0\n next if state[to]==jug_sizes[to]\n\n new_state=state[0..-1]\n if state[from] + state[to] > jug_sizes[to]\n new_state[to] = jug_sizes[to]\n poured_amount = jug_sizes[to] - state[to]\n new_state[from] = state[from] - poured_amount\n else\n new_state[to] = state[from] + state[to]\n new_state[from] = 0\n end\n\n puts \" after pouring from #{from} to #{to} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n seen_states.add(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{from} -> #{to}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=0 \n puts \" after draining from #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"#{target} -> DRAIN\"\n states_to_process << [new_steps, new_state]\n end\n end\n end\n\n if has_drain \n for target in 0..jug_sizes.length-1\n new_state=state[0..-1]\n new_state[target]=jug_sizes[target]\n puts \" after filling #{target} reached #{new_state}.\"\n if !seen_states.include?(new_state)\n new_steps = steps[0..-1]\n new_steps << \"SOURCE -> #{target}\"\n states_to_process << [new_steps, new_state]\n end\n end\n end \n end\n\n raise \"No solution found.\"\nend",
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes 0!=1 class Quiz\n # find even values\n def solution1(input)\n # Final solution\n input.flatten.select do |value|\n value.even?\n end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.select do |value|\n # value.even?\n # end\n # end.flatten\n end\n\n # find value sum\n def solution2(input)\n # Final Solution\n input.flatten.inject(:+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.flatten.inject do |sum, value|\n # sum += value\n # end\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.inject do |sum, value|\n # sum += value\n # end\n # end.inject do |sum, value|\n # sum += value\n # end\n end\n\n # find max value\n def solution3(input)\n # Final solution\n input.flatten.max\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.max\n # end.max\n end\n\n # sum the array lengths\n def solution4(input)\n # Final solution\n input.map(&:length).inject(0, :+)\n\n # Second solution:\n # Works correctly\n # Doesn't use shortcut version of inject\n #\n # input.map(&:length).inject{|sum, value| sum += value}\n\n # First solution:\n # Works correctly\n # Unoptimized\n #\n # input.map do |ary|\n # ary.length\n # end.inject {|sum, value| sum += value}\n end\n\n # transform to factorials\n # Factorial is defined as the product of all the whole numbers from 1 to n\n # Examples:\n # 4! = 4*3*2*1\n # 1! = 1\n # 0! = 1\n def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iterates and keeps the running total\n\n # Final solution\n # Uses shorthand version of inject\n # Remove the useless multiple by 1\n # Note the use of the starting value of 1 for inject\n # which makes this work properly for all values (including 0, 1)\n input.map do |ary|\n ary.map do |value|\n (2..value).inject(1, :*)\n end\n end\n\n # First solution\n # Mostly optimized\n # Does 1 more multiplication than needed (mult by 1)\n #\n # input.map do |ary|\n # ary.map do |value|\n # (1..value).inject(1) do |factorial, value|\n # factorial *= value\n # end\n # end\n # end\n end\nend",
"def ukp3(ukpi, ret_table = true)\n n = ukpi[:n]\n c = ukpi[:c]\n items = ukpi[:items].clone\n\n # step one\n g = Array.new(c+1, 0)\n d = Array.new(c+1, n-1)\n sort_items_by_profitability!(items)\n\n gy_col = nil\n dy_col = nil\n if ret_table then\n gy_col = Array.new(c+1) { [] }\n dy_col = Array.new(c+1) { [] }\n end\n\n ys = y_star(items, true)\n min_necessary_steps = ys < c+1 ? ys : c+1\n # step two to six\n min_necessary_steps.times do | y |\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n items.each_with_index do | item, j |\n if y - item[:w] >= 0 && j <= d[y - item[:w]] then\n v = g[y - item[:w]] + item[:p]\n if v > g[y] then\n g[y] = v\n d[y] = j\n if ret_table then\n gy_col[y] << g[y]\n dy_col[y] << d[y]\n end\n end\n end\n end\n end\n\n if min_necessary_steps != c+1 then\n extra_capacity = c - ys\n c1, a1 = items[0][:p], items[0][:w]\n qt_best_item_used = Rational(extra_capacity, a1).ceil\n space_used_by_best_item = qt_best_item_used*a1\n profit_generated_by_best_item = qt_best_item_used*c1\n g[c] = g[c-space_used_by_best_item] + profit_generated_by_best_item\n end\n\n table = \"y\\tg(y)\\t\\td(y)\\n\"\n if ret_table then\n (c+1).times do | y |\n table << \"#{y}\\t#{gy_col[y].join(' ')}\\t\\t#{dy_col[y].join(' ')}\\n\"\n end\n end\n \n if ret_table then\n table\n else\n g\n end\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 solve\n return [] if @current_state.achieved?(@objective)\n return nil if @remaining_rounds <= 0\n\n possible_transformations = @transformations.select { |transformation| @current_state.can_apply?(transformation) }\n\n sorted_transformations = possible_transformations.sort_by do |transformation|\n future_state = @current_state.dup.apply(transformation)\n future_state.distance_of(@objective)\n end\n return nil if sorted_transformations.empty?\n\n sorted_transformations.lazy.map do |transformation|\n elapsed_rounds = @opts[:max_rounds] - @remaining_rounds - 1\n future_state = apply(transformation, elapsed_rounds)\n return nil unless future_state # apply can returns nil in case of error\n\n world = World.new(@transformations, @objective, @remaining_rounds - 1, future_state, @opts)\n res = world.solve\n [transformation] + res if res\n end.select(&:itself).first\n end",
"def solution(x, y, d)\r\n # write your code in Ruby 2.2\r\n i=1\r\n loop do\r\n s=x+i*d\r\n \r\n break if(s>=y)\r\n \r\n i+=1\r\n end \r\n i\r\nend",
"def floyd_warshall_variation()\n edges = %w( 0,1 1,2 2,3 1,3 )\n num = edges.join.gsub(\",\",\"\").split(\"\").uniq.size\n\n a = Array.new(num) { Array.new(num) { Array.new(num) } }\n \n # initialize\n num.times do |k|\n num.times do |i|\n num.times do |j|\n a[i][j][k] = Float::INFINITY\n a[i][j][k] = 0 if i == j\n a[i][j][k] = 1 if edges.include? \"#{i},#{j}\"\n end\n end\n end\n\n # run\n (1..num-1).each do |k|\n num.times do |i|\n num.times do |j|\n a[i][j][k] = [\n a[i][j][k-1] +\n a[i][k][k-1] * a[k][j][k-1]\n ].min\n end\n end\n end\n\n # print\n num.times do |i|\n num.times do |j|\n puts \"#{i},#{j}: #{a[i][j][num-1]}\"\n end\n end\n\nend",
"def solution(a, b)\n a.size > b.size ? b+a+b : a+b+a\nend",
"def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend",
"def math(b1,b2,goal)\r\n\r\n\t# link to math:\r\n\t# http://www.math.tamu.edu/~dallen/hollywood/diehard/diehard.htm\r\n\t# mp = nq = k\r\n\t# (x)(b1) + (y)(b2) = goal\r\n\r\n\tx = 0\r\n\ty = 0\r\n\tcurrent_total = 0\r\n\r\n\t#determine x and y mathematically\r\n\twhile (current_total != goal) do\r\n\r\n\t\tif current_total < goal\r\n\t\t\tx += 1\r\n\t\telsif current_total > goal\r\n\t\t\ty -= 1\r\n\t\tend\r\n\r\n\t\tcurrent_total = x*b1.size + y*b2.size\r\n\t\tputs \"X: #{x}, Y: #{y}, CT: #{current_total}\"\r\n\r\n\tend\r\n\r\nend",
"def fitness\n -(0..5).map{|t| \n $pors_store = 0 # reset store\n t_val = t\n values = {:rec=>proc{$pors_store},:T=>proc{ cv=t_val; t_val=0; cv} } # using T destroys T\n (eval_genes(values) - N*t).abs \n }.sum - 0.1*size # find a tree that multiplies T by 3\n end",
"def problem_78\n n = 1\n p_cache = [1]\n\n generate = lambda do |k|\n ret = 0\n sign = 0\n Integer.generalized_pentagonals do |gp|\n if k < gp\n false # Need to exit ruby1.8, can't break...\n else\n if sign >= 0\n ret += p_cache[k-gp]\n else\n ret -= p_cache[k-gp]\n end\n sign += (sign == 1) ? -3 : 1 # 4 states + + - -\n end\n end\n p_cache[k] = ret % 100_000_000\n ret\n end\n\n p = 1\n loop do\n r = generate.call(p)\n# puts \"#{p} #{generate.call(p)}\"\n break if r % 1_000_000 == 0\n p += 1\n end\n p\nend",
"def squareRaySolver(dim)\n sum = 0\n until dim < 1\n sum += squareHelper(dim)\n dim = dim - 2\n end\n sum\nend",
"def compute_ruby\n check_frequencies\n #\n # INITIALIZATION\n #\n @r = 0\n sdzero = 0\n @sdr = 0\n @itype = 0\n @ifault = 0\n delta = 0\n \n\n # GOTO (4, 1, 2 , 92), kdelta\n #\n # delta IS 0.0, 0.5 OR -0.5 ACCORDING TO WHICH CELL IS 0.0\n #\n\n if(@kdelta==2)\n # 1\n delta=0.5\n @r=-1 if (@a==0 and @d==0)\n elsif(@kdelta==3)\n # 2\n delta=-0.5\n @r=1 if (@b==0 and @c==0)\n end\n # 4\n if @r!=0\n @itype=3\n end\n\n #\n # STORE FREQUENCIES IN AA, BB, CC AND DD\n #\n @aa = @a + delta\n @bb = @b - delta\n @cc = @c - delta\n @dd = @d + delta\n @tot = @aa+@bb+@cc+@dd\n #\n # CHECK IF CORRELATION IS NEGATIVE, 0.0, POSITIVE\n # IF (AA * DD - BB * CC) 7, 5, 6\n\n corr_dir=@aa * @dd - @bb * @cc\n if(corr_dir < 0)\n # 7\n @probaa = @bb.quo(@tot)\n @probac = (@bb + @dd).quo(@tot)\n @ksign = 2\n # -> 8\n else\n if (corr_dir==0)\n # 5\n @itype=4\n end\n # 6\n #\n # COMPUTE PROBABILITIES OF QUADRANT AND OF MARGINALS\n # PROBAA AND PROBAC CHOSEN SO THAT CORRELATION IS POSITIVE.\n # KSIGN INDICATES WHETHER QUADRANTS HAVE BEEN SWITCHED\n #\n\n @probaa = @aa.quo(@tot)\n @probac = (@aa+@cc).quo(@tot)\n @ksign=1\n end\n # 8\n\n @probab = (@aa+@bb).quo(@tot)\n\n #\n # COMPUTE NORMAL DEVIATES FOR THE MARGINAL FREQUENCIES\n # SINCE NO MARGINAL CAN BE 0.0, IE IS NOT CHECKED\n #\n @zac = Distribution::Normal.p_value(@probac.to_f)\n @zab = Distribution::Normal.p_value(@probab.to_f)\n @ss = Math::exp(-0.5 * (@zac ** 2 + @zab ** 2)).quo(TWOPI)\n #\n # WHEN R IS 0.0, 1.0 OR -1.0, TRANSFER TO COMPUTE SDZERO\n #\n if (@r != 0 or @itype > 0)\n compute_sdzero\n return true\n end\n #\n # WHEN MARGINALS ARE EQUAL, COSINE EVALUATION IS USED\n #\n if (@a == @b and @b == @c)\n calculate_cosine\n return true\n end\n #\n # INITIAL ESTIMATE OF CORRELATION IS YULES Y\n #\n @rr = ((Math::sqrt(@aa * @dd) - Math::sqrt(@bb * @cc)) ** 2) / (@aa * @dd - @bb * @cc).abs\n @iter = 0\n begin\n #\n # IF RR EXCEEDS RCUT, GAUSSIAN QUADRATURE IS USED\n #\n #10\n if @rr>RCUT\n gaussian_quadrature\n return true\n end\n #\n # TETRACHORIC SERIES IS COMPUTED\n #\n # INITIALIZATION\n #\n va=1.0\n [email protected]_f\n wa=1.0\n [email protected]_f\n term = 1.0\n iterm = 0.0\n @sum = @probab * @probac\n deriv = 0.0\n sr = @ss\n #15\n begin\n if(sr.abs<=CONST)\n #\n # RESCALE TERMS TO AVOID OVERFLOWS AND UNDERFLOWS\n #\n sr = sr / CONST\n va = va * CHALF\n vb = vb * CHALF\n wa = wa * CHALF\n wb = wb * CHALF\n end\n #\n # FORM SUM AND DERIVATIVE OF SERIES\n #\n # 20\n dr = sr * va * wa\n sr = sr * @rr / term\n cof = sr * va * wa\n #\n # ITERM COUNTS NO. OF CONSECUTIVE TERMS < CONV\n #\n iterm+= 1\n iterm=0 if (cof.abs > CONV)\n @sum = @sum + cof\n deriv += dr\n vaa = va\n waa = wa\n va = vb\n wa = wb\n vb = @zac * va - term * vaa\n wb = @zab * wa - term * waa\n term += 1\n end while (iterm < 2 or term < 6)\n #\n # CHECK IF ITERATION CONVERGED\n #\n if((@sum-@probaa).abs <= CITER)\n @itype=term\n calculate_sdr\n return true\n end\n #\n # CALCULATE NEXT ESTIMATE OF CORRELATION\n #\n #25\n @iter += 1\n #\n # IF TOO MANY ITERATlONS, RUN IS TERMINATED\n #\n delta = (@sum - @probaa) / deriv\n @rrprev = @rr\n @rr = @rr - delta\n @rr += 0.5 * delta if(@iter == 1)\n @rr= RLIMIT if (@rr > RLIMIT)\n @rr =0 if (@rr < 0.0)\n end while @iter < NITER\n raise \"Too many iteration\"\n # GOTO 10\n end"
] | [
"0.6271544",
"0.61861247",
"0.61526287",
"0.6137266",
"0.60934085",
"0.6063052",
"0.6055467",
"0.60319865",
"0.60048896",
"0.5980103",
"0.5975958",
"0.59746754",
"0.5965973",
"0.5965729",
"0.5914004",
"0.5860188",
"0.5858055",
"0.5839102",
"0.5814709",
"0.5807538",
"0.5798958",
"0.57611287",
"0.5745465",
"0.5724741",
"0.57225156",
"0.57170343",
"0.5716529",
"0.5714552",
"0.5698536",
"0.5694664",
"0.5693309",
"0.5678957",
"0.5674569",
"0.5667524",
"0.5666344",
"0.56539005",
"0.56519794",
"0.5646228",
"0.5643477",
"0.5642516",
"0.5629163",
"0.56257075",
"0.562198",
"0.56199676",
"0.561432",
"0.560648",
"0.5604734",
"0.55918056",
"0.5585407",
"0.5576227",
"0.55632216",
"0.5562349",
"0.5561447",
"0.55550796",
"0.55537874",
"0.55413383",
"0.5515985",
"0.5514859",
"0.5512961",
"0.55107534",
"0.5501616",
"0.5500933",
"0.54922074",
"0.54809207",
"0.5477926",
"0.54775935",
"0.54742193",
"0.5472591",
"0.54704136",
"0.546952",
"0.5468432",
"0.54645336",
"0.54633474",
"0.54587144",
"0.54587144",
"0.54587144",
"0.54587144",
"0.54587144",
"0.545741",
"0.54552364",
"0.54427034",
"0.54382426",
"0.5425792",
"0.5425792",
"0.5425792",
"0.5425792",
"0.54249245",
"0.5422188",
"0.54184574",
"0.5403427",
"0.53933465",
"0.5392916",
"0.5388532",
"0.5384643",
"0.5375717",
"0.5373554",
"0.5368202",
"0.53499043",
"0.53453207",
"0.5343527",
"0.53400654"
] | 0.0 | -1 |
Renders holding page if it exists, if member is NOT logged in, and the root request path is used. /loggedout should render the homepage, but not the holding page | def render_holding_page_if_exists
if view_exists?(HOLDING_VIEW) && !@logged_in_member && request.path == '/'
render(:template => HOLDING_VIEW, :layout => false) and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if current_user\n render_home_page\n else\n render_welcome_page\n end\n end",
"def signed_user_unnecessary_pages\n if signed_in?\n redirect_to(root_path)\n end\n end",
"def verify_logged_in\n redirect_to root_path unless logged_in?\n end",
"def profile\n if(current_user)\n render 'layouts/loggedin'\n else\n render \"layouts/guest\"\n end\n end",
"def not_authenticated\n redirect_to root_landing_url\n end",
"def redirect_if_not_logged_in\n\t\tredirect_to '/' if !logged_in?\n\tend",
"def require_login\n if !is_logged_in\n return render_404\n end\n end",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:notice] = \"You must be logged in to view the page you tried to view.\"\n redirect '/'\n end\n end",
"def index\n redirect_to(:action => 'login') unless logged_in? \n end",
"def require_logged_in\n redirect_to root_path unless logged_in?\n end",
"def must_be_logged_in\n redirect_to root_path unless logged_in?\n end",
"def require_logged_out\n\t\t\tif session[:user] != nil\n\t\t\t\tredirect_to(:controller => \"users\", :action => \"home\")\n\n\t\t\tend\n\n\n\t\tend",
"def require_logout\n if session && !session[:user_id].blank?\n flash[:error] = \"The page you're trying to access is only available to logged out users.\"\n redirect_to dashboard_path and return\n end\n end",
"def require_logged_out\n return unless logged_in?\n\n redirect_to profile_path\n end",
"def redirect_unless_logged_in\n unless current_member\n session[:redirect] = request.original_url\n flash.alert = \"You must be logged in to view page\"\n redirect_to root_path and return false\n end\n end",
"def user_logged\n \tif !current_user\n \t\treturn redirect_to '/'\n \tend\n end",
"def home\n if current_user\n redirect_to '/dashboard'\n else\n render 'home'\n end\n end",
"def loged?\n @user = current_user\n if not @user\n redirect_to welcome_index_path\n end\n end",
"def index\n\t\tif SITE_LOCKED && !logged_in?\n\t\t\trender \"site_lock\"\n\t\tend\n\tend",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:errors] = \"You must be logged in to view the page \"\n redirect '/'\n end\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? or User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? or User.count > 0\n end",
"def logged_in_user\n unless logged_in?\n redirect_to root_url\n end\n end",
"def require_logged_out\n access_denied(\"You can't do that while logged in.\") if logged_in?\n end",
"def home\n if !view_context.signed_in?\n redirect_to '/'\n end\n end",
"def index\n redirect_to disabled_path\n # unless logged_in?\n # redirect_to tour_path\n # else\n # @current_item = \"my_hsa\"\n # end\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def index\n redirect_to(:action => 'signup') unless logged_in? || User.count > 0\n end",
"def block_unauthenticated_user!\n unless current_user\n return render_unauthorized\n end\n end",
"def landing\n redirect_to dashboard_path if current_user\n end",
"def logged_in?\n redirect_to(root_path, notice: 'Unauthorized access!') unless current_user\n end",
"def landing_page\n if current_user\n redirect_to actions_path(current_user[:id])\n end\n end",
"def show\n render layout: \"sin_menu\" unless user_signed_in? \n end",
"def redirect_home_if_not_logged_in\n unless logged_in?\n session[:error] = \"You must be signed in to do that.\"\n redirect \"/\"\n end\nend",
"def index\n redirect_to(:action => 'login') #unless logged_in? || User.count > 0\n end",
"def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end",
"def index\n if session[:user_id] != nil \n redirect_to '/home'\n end\n end",
"def not_log_redirect\n\t\t\tif !logged_in?\n\t\t\t\tflash[:no_log_signup] = \"Please Sign Up or Log In - Error Code: #{response.status}\"\n\t\t\t\tredirect '/'\n\t\t\tend\n\t\tend",
"def index\n # Handle bookmarked or otherwise incorrect GETs to the login action\n if request.method == :get\n redirect_to login_path\n else\n redirect_to member_home_path\n end\n end",
"def logged_in_dog\n unless logged_in?\n redirect_to '/'\n end\n end",
"def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end",
"def restrict_access\n render :\"/home/http_404\" unless @profile && @profile.user == current_user\n end",
"def authorized\n if logged_in?\n return View(\"sessions/page_requires_login\"); \n end\n return View(\"Index\")\n end",
"def home\n if logged_in?\n redirect_to user_path(current_user) # Redirect to user show page if logged in\n else\n render layout: 'welcome' # Render home view with welcome layout\n end\n end",
"def check_logged_in?\n if !logged_in?\n redirect_to root_path\n end\n end",
"def not_authenticated\n redirect_to root_path\n end",
"def require_no_user\n if current_user\n store_location\n flash[:notice] = \"You must be logged out to access this page.\"\n redirect_to root_url\n return false\n end\n end",
"def home_check\n if logged_in? && @current_user.admin?\n puts @current_user\n redirect_to account_url(@current_user.id)\n return\n elsif logged_in?\n redirect_to cases_path\n else\n redirect_to page_path(\"home\")\n return\n end\n end",
"def user\n if !user_signed_in? \n redirect_to '/404.html'\n end\n end",
"def index\n # If someone is signed in on the browser\n if signed_in?\n # Take the user to their profile page\n redirect_to \"/#{@current_user.name}\"\n # Abort execution\n return\n end\n \n # Don't use an application layout.\n render layout: false\n end",
"def no_access\n flash[:message] = \"You do not have access to that page.\"\n redirect '/'\n end",
"def landing\n render text: '<h3>You logged in!</h3>', layout: true\n end",
"def Usuario_noLogueado\n redirect_to(root_url) unless logged_in?\n end",
"def loggedin(id)\n if id.empty?\n redirect to (\"/\")\n end\nend",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend",
"def require_no_user\n if current_user\n store_location\n flash[:notice] = \"You must be logged out to access this page\"\n redirect_to root_url\n return false\n end\n end",
"def access_denied\n if ( user_signed_in? )\n render :file => File.join( RAILS_ROOT, 'public', '404.html' ),\n :status => :not_found\n else\n authenticate_user!\n end\n end",
"def authorized\n redirect_to '/welcome' unless logged_in?\n end",
"def require_logout\n return unless current_user\n\n flash[:alert] = 'You must be logged out to access this section'\n redirect_to root_url # halts request cycle\n end",
"def user_not_authenticated?\n if !logged_in?\n redirect_to root_path\n return true\n end\n return false\n end",
"def is_logged_in\n redirect_to login_path unless logged_in?\n end",
"def show\n redirect_to(default_url) unless logged_in? || User.count > 0\n @user = current_user\n end",
"def require_login\n if request.fullpath == \"/about\"\n #Let everybody (even not logged in users) see the about page\n else\n unless current_user\n redirect_to root_url\n end\n end\n end",
"def enforce_logged_in\n bounce unless current_user\n end",
"def require_logout\n redirect_to user_path(current_user) if logged_in?\n end",
"def redirect_if_not_logged_in\n if !logged_in?\n flash[:message] = \"You must login to view this page\"\n # flash[:errors] = \"You must be logged in to view the page you tried to view.\"\n redirect '/'\n end\n end",
"def maintenance\n if current_user.present?\n redirect_to root_path\n else\n render layout: 'basic'\n end\n end",
"def maintenance\n if current_user.present?\n redirect_to root_path\n else\n render layout: 'basic'\n end\n end",
"def logged_in_user\n unless current_user \n redirect_to root_path\n end\n end",
"def user_takeout\n\n check_for_signed_in_user_and_issues\n\n @personal_roll_export = :true\n\n unless @user_signed_in\n @custom_error = \"Sorry, you must be signed in to export your data.\"\n else\n @display_export_form = :true\n end\n\n render '/home/landing'\n end",
"def check_logged_in_home\n if current_user != nil\n redirect_to user_path(current_user)\n end\n end",
"def home_page\n if current_user.guest?\n user_signup_url\n elsif current_user.administrator?\n admin_films_path\n elsif current_user.judge?\n judging_categories_path\n else\n obejct_url current_user\n end\n end",
"def forum_signed_in\n if user_signed_in?\n render 'layouts/forums_shared/logged_in'\n else\n render 'layouts/forums_shared/not_logged'\n end\n end",
"def require_no_user\n if current_user\n store_location\n flash[:notice] = \"You must be logged out to access this page\"\n redirect_to \"\"\n return false\n end\n end",
"def view\n if !logged_in?\n\n redirect_to \"/\"\n flash[:notice] = \"You must be logged in to view your module reviews.\"\n end\n end",
"def check_current_user_owns\n head :not_found unless @user == current_user\n end",
"def index\n session[:current_user_id] = ''\n render 'layouts/application'\n\n end",
"def verify_signed_out_user\n head :no_content if all_signed_out?\n end",
"def already_logged_in\n\t\t\t#current user is not nil\n\t\t\tif !current_user.nil?\n\t\t\t\tredirect_to root_url\n\t\t\tend\n\t\tend",
"def if_not_logged_in\n !view_context.user_signed_in?\n end",
"def redirect_if_not_logged_in\n redirect_to login_path unless logged_in?\n end",
"def check_if_current_user_page\n redirect_to('/') and return unless (current_user.id == User.from_param(params[:id])) || current_user.is_admin?\n end",
"def require_no_user\n if current_user\n logger.warn \"Accessing login page when already logged in\"\n store_location\n flash[:notice] = \"You must NOT be logged in to access this page\"\n redirect_to root_url\n return false\n end\n end",
"def logged_in_or_invited_layout\n logged_in? ? \"logged_in\" : \"front\"\n end",
"def verified_user\n redirect_to '/' unless logged_in?\n end",
"def logged_user_only\n unless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in!\"\n\t redirect_to login_url\n\t end\n end",
"def show\n unless @user\n render 'not_found_page'\n end\n end",
"def no_log_show\n if !session[:user_id]\n flash[:notice] = \"Please log in or sign up!\"\n redirect_to root_path\n end\n end",
"def require_no_user\n logger.debug \"ApplicationController::require_no_user\"\n if current_user\n store_location\n flash[:notice] = \"You must be logged out to access this page\"\n redirect_to userhome_url #account_url\n return false\n end\n true\n end",
"def redirect_if_logged_in\n redirect_to root_path if logged_in?\n end",
"def only_for_anonymous\n redirect_to root_path if session[:username]\n end",
"def check_login\n head :forbidden unless self.current_user\n end",
"def isAuth\n # Redirect the browser to the homepage, unless the user is logged in\n redirect_to root_path unless signed_in?\n # Execute the 'locked' method unless the user does not have a lock associated with their account\n locked unless current_user.lock == nil\n end",
"def non_logged_user\n respond_to do |format|\n format.html { redirect_to login_path}\n flash[:info] = \"Por favor, faça o login.\"\n end if ! logged_in?\n end",
"def restrict_access\n render :\"/home/http_404\" unless @pet && @pet.user == current_user\n end",
"def logged_in_member\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def require_login\n # If we are logged in or the action we are requesting is excluded from login requirement\n if logged_in? or action_and_format_excluded?\n if logged_in? and current_user.units.empty?\n flash[:warning] = \"You are not permitted to any units!\"\n render :file => \"#{Rails.root}/public/generic_error.html\", :layout => false\n end\n else\n flash[:warning] = \"You must be logged in to view that page\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end"
] | [
"0.64634496",
"0.6334306",
"0.6315294",
"0.6296778",
"0.62539876",
"0.6199986",
"0.6176579",
"0.61680365",
"0.6154387",
"0.61512864",
"0.6147536",
"0.61446613",
"0.6105697",
"0.60962707",
"0.60889",
"0.60882086",
"0.608639",
"0.60824186",
"0.6082179",
"0.6053566",
"0.60375595",
"0.60375595",
"0.60342914",
"0.6027349",
"0.60134375",
"0.6009917",
"0.600853",
"0.600853",
"0.600853",
"0.60068554",
"0.6004314",
"0.59971786",
"0.59635603",
"0.5953537",
"0.593731",
"0.5933785",
"0.5926627",
"0.5926627",
"0.5920326",
"0.5905206",
"0.58995056",
"0.5891984",
"0.58912337",
"0.5888288",
"0.58835953",
"0.5865207",
"0.5864335",
"0.5862843",
"0.5855603",
"0.58501744",
"0.58479637",
"0.5847406",
"0.58360803",
"0.58298224",
"0.5828213",
"0.5821107",
"0.5817331",
"0.5815784",
"0.58154947",
"0.58133256",
"0.5811719",
"0.5799271",
"0.57964474",
"0.5794521",
"0.57871026",
"0.5780794",
"0.57776636",
"0.5777493",
"0.5777493",
"0.57650906",
"0.5758352",
"0.5755857",
"0.57508045",
"0.57450426",
"0.57440823",
"0.57422525",
"0.57371217",
"0.57269627",
"0.57262963",
"0.57226557",
"0.5720316",
"0.571821",
"0.57172257",
"0.57153445",
"0.5708817",
"0.5706083",
"0.5697538",
"0.56966877",
"0.56911945",
"0.56892675",
"0.56880367",
"0.56852037",
"0.5677443",
"0.5674534",
"0.56742203",
"0.56725186",
"0.5672081",
"0.5670683",
"0.5669304",
"0.56690085"
] | 0.8022832 | 0 |
G:T, R:E, F:S, J:W, H:U, V:I, L:Y, Z:M} | def block_word?(word)
down = word.downcase
indexArray = []
letter1 = ["b", "x", "d", "c", "n", "g", "r", "f", "j", "h", "v", "l", "z"]
letter2 = ["o", "k", "q", "p", "a", "t", "e", "s", "w", "u", "i", "y", "m"]
letter1.each_with_index do |element, index|
if down.include?(element)
indexArray[index] = 1
else
indexArray[index] = 0
end
end
letter2.each_with_index do |element, index|
if down.include?(element)
indexArray[index] += 1
end
end
!indexArray.any? {|x| x > 1}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getgm() end",
"def human_representation(options = {}, g = { x: x, y: y })\n g.map do |k, v|\n deg = v.to_i.abs\n min = (60 * (v.abs - deg)).to_i\n labs = (v * 1_000_000).abs / 1_000_000\n sec = ((((labs - labs.to_i) * 60) -\n ((labs - labs.to_i) * 60).to_i) * 100_000) * 60 / 100_000\n str = options[:full] ? '%.i°%.2i′%05.2f″' : '%.i°%.2i′%02.0f″'\n if options[:coord]\n out = format(str, deg, min, sec)\n # Add cardinal\n out + (k == :x ? v > 0 ? 'N' : 'S' : v > 0 ? 'E' : 'W')\n else\n format(str, v.to_i, min, sec)\n end\n end\n end",
"def values\n{\n :A => 1, :B => 3, :C => 3, :D => 2,\n :E => 1, :F => 4, :G => 2, :H => 4,\n :I => 1, :J => 8, :K => 5, :L => 1,\n :M => 3, :N => 1, :O => 1, :P => 3,\n :Q => 10, :R => 1, :S => 1, :T => 1,\n :U => 1, :V => 4, :W => 4, :X => 8,\n :Y => 4, :Z => 10\n}\nend",
"def romeo_and_juliet; end",
"def genclase\n \"M\"\n end",
"def spritestack_coordinates\n return 25, 125\n end",
"def to_latlng(easting, northing, type = :gb)\n\n \t if type == :ie\n @OSGB_F0 = 1.000035\n @N0 = 250000.0\n @E0 = 200000.0\n @phi0 = deg_to_rad(53.5)\n @lambda0 = deg_to_rad(-8.0)\n @a = 6377340.189\n @b = 6356034.447\n else\n @OSGB_F0 = 0.9996012717\n @N0 = -100000.0\n @E0 = 400000.0\n @phi0 = deg_to_rad(49.0)\n @lambda0 = deg_to_rad(-2.0)\n @a = 6377563.396\n @b = 6356256.909\n end\n\n @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)\n @phi = 0.0\n @lambda = 0.0\n @E = easting\n @N = northing\n @n = (@a - @b) / (@a + @b)\n @M = 0.0\n @phiPrime = ((@N - @N0) / (@a * @OSGB_F0)) + @phi0\n\n \t begin\n\n \t @M =\n \t (@b * @OSGB_F0)\\\n \t * (((1 + @n + ((5.0 / 4.0) * @n * @n) + ((5.0 / 4.0) * @n * @n * @n))\\\n \t * (@phiPrime - @phi0))\\\n \t - (((3 * @n) + (3 * @n * @n) + ((21.0 / 8.0) * @n * @n * @n))\\\n \t * Math.sin(@phiPrime - @phi0)\\\n \t * Math.cos(@phiPrime + @phi0))\\\n \t + ((((15.0 / 8.0) * @n * @n) + ((15.0 / 8.0) * @n * @n * @n))\\\n \t * Math.sin(2.0 * (@phiPrime - @phi0))\\\n \t * Math.cos(2.0 * (@phiPrime + @phi0)))\\\n \t - (((35.0 / 24.0) * @n * @n * @n)\\\n \t * Math.sin(3.0 * (@phiPrime - @phi0))\\\n \t * Math.cos(3.0 * (@phiPrime + @phi0))))\n\n \t @phiPrime += (@N - @N0 - @M) / (@a * @OSGB_F0)\n\n \t end while ((@N - @N0 - @M) >= 0.001)\n\n \t @v = @a * @OSGB_F0 * ((1.0 - @eSquared * sin_pow_2(@phiPrime)) ** -0.5)\n \t @rho =\n \t @a\\\n \t * @OSGB_F0\\\n \t * (1.0 - @eSquared)\\\n \t * ((1.0 - @eSquared * sin_pow_2(@phiPrime)) ** -1.5)\n \t @etaSquared = (@v / @rho) - 1.0\n \t @VII = Math.tan(@phiPrime) / (2 * @rho * @v)\n \t @VIII =\n \t (Math.tan(@phiPrime) / (24.0 * @rho * (@v ** 3.0)))\\\n \t * (5.0\\\n \t + (3.0 * tan_pow_2(@phiPrime))\\\n \t + @etaSquared\\\n \t - (9.0 * tan_pow_2(@phiPrime) * @etaSquared))\n \t @IX =\n \t (Math.tan(@phiPrime) / (720.0 * @rho * (@v ** 5.0)))\\\n \t * (61.0\\\n \t + (90.0 * tan_pow_2(@phiPrime))\\\n \t + (45.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime)))\n \t @X = sec(@phiPrime) / @v\n \t @XI =\n \t (sec(@phiPrime) / (6.0 * @v * @v * @v))\\\n \t * ((@v / @rho) + (2 * tan_pow_2(@phiPrime)))\n \t @XII =\n \t (sec(@phiPrime) / (120.0 * (@v ** 5.0)))\\\n \t * (5.0\\\n \t + (28.0 * tan_pow_2(@phiPrime))\\\n \t + (24.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime)))\n \t @XIIA =\n \t (sec(@phiPrime) / (5040.0 * (@v ** 7.0)))\\\n \t * (61.0\\\n \t + (662.0 * tan_pow_2(@phiPrime))\\\n \t + (1320.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime))\\\n \t + (720.0\\\n \t * tan_pow_2(@phiPrime)\\\n \t * tan_pow_2(@phiPrime)\\\n \t * tan_pow_2(@phiPrime)))\n \t @phi =\n \t @phiPrime\\\n \t - (@VII * ((@E - @E0) ** 2.0))\\\n \t + (@VIII * ((@E - @E0) ** 4.0))\\\n \t - (@IX * ((@E - @E0) ** 6.0))\n \t @lambda =\n \t @lambda0\\\n \t + (@X * (@E - @E0))\\\n \t - (@XI * ((@E - @E0) ** 3.0))\\\n \t + (@XII * ((@E - @E0) ** 5.0))\\\n \t - (@XIIA * ((@E - @E0) ** 7.0))\n\n \t { :latitude => rad_to_deg(@phi), :longitude => rad_to_deg(@lambda) }\n\n \t end",
"def mapping\n {\n \"ch\" => 4,\n \"co\" => 3,\n \"gen\" => 0,\n \"char\" => 4,\n \"copy\" => 3,\n \"art\" => 1,\n \"meta\" => 5,\n \"general\" => 0,\n \"character\" => 4,\n \"copyright\" => 3,\n \"artist\" => 1,\n }\n end",
"def zrotation\n end",
"def screen_z\n return screen_y\n end",
"def screen_z\n return screen_y\n end",
"def magnitude_word\n MAGNITUDE[magnitude]\n end",
"def guage(n) \n r = (255 * n) / 100\n g = (255 * (100 - n)) / 100 \n b = 0\n return { :r => r, :g => g, :b => b }\nend",
"def values\n {\n 'a' => 1, 'e' => 1, 'i' => 1, 'o' => 1,\n 'u' => 1, 'l' => 1, 'n' => 1, 'r' => 1,\n 's' => 1, 't' => 1, 'd' => 2, 'g' => 2,\n 'b' => 3, 'c' => 3, 'm' => 3, 'p' => 3,\n 'f' => 4, 'h' => 4, 'v' => 4, 'w' => 4,\n 'y' => 4, 'k' => 5, 'j' => 8, 'x' => 8,\n 'q' => 10, 'z' => 10\n }\nend",
"def king_richard_iii; end",
"def gremlins\n {\n space: \"\\u2420\",\n tab: \"\\u21B9\",\n carriage_return: \"\\u23CE\",\n line_feed: \"\\u240A\",\n\n control_c: \"\\u2404\",\n control_d: \"\\u2403\",\n control_r: \"\\u2412\",\n\n escape: \"\\u238B\",\n\n backspace: \"\\u2408\",\n delete: \"\\u232B\",\n\n up: \"\\u2191\",\n down: \"\\u2193\",\n left: \"\\u2190\",\n right: \"\\u2192\"\n }\n end",
"def transformations; end",
"def directions\n { 'N' => %w[W E],\n 'E' => %w[N S],\n 'S' => %w[E W],\n 'W' => %w[S N] }\n end",
"def formation; end",
"def character\n {0 => :s, 1 => :p, 2 => :d, 3 => :f}[quantum_number]\n end",
"def movements\n @movements ||= {\n \"s\" => -> (x, y, z) { [x, y - 1, z + 1] },\n \"n\" => -> (x, y, z) { [x, y + 1, z - 1] },\n \"ne\" => -> (x, y, z) { [x + 1, y, z - 1] },\n \"se\" => -> (x, y, z) { [x + 1, y - 1, z] },\n \"nw\" => -> (x, y, z) { [x - 1, y + 1, z] },\n \"sw\" => -> (x, y, z) { [x - 1, y, z + 1] },\n }\n end",
"def wind_direction_map\n wind_directions = [\"NNE\", \"NE\", \"ENE\", \"E\", \"ESE\", \"SE\", \"SSE\", \"S\", \"SSW\", \"SW\", \"WSW\", \"W\", \"WNW\", \"NW\", \"NNW\", \"N\"];\n magic_map = {}\n wind_directions.each_with_index { |x, index| \n magic_map[x] = (index+1) * 22.5\n }\n magic_map\n end",
"def google_tile(tx, ty, zoom)\n [tx, (2**zoom - 1) - ty]\n end",
"def face_as_unit_vector\n case @face\n when :N\n return [0,1]\n when :S\n return [0,-1]\n when :E\n return [1,0]\n when :W\n return [-1,0]\n end\n end",
"def mitch_hedberg; end",
"def create_gr(entities)\n\tif($gr_side == \"SW1\")\n\t\tr = Geom::Transformation.rotation [0, 0, 0], [0,0,1], 360.degrees\n\t\tt = Geom::Transformation.new [$gr_offset,0,$gr_height]\n\t\tbuild_gr(entities,r,t)\n\tend\n\tif($gr_side == \"SW2\")\n\t\tr = Geom::Transformation.rotation [0, 0, 0], [0,0,1], 180.degrees\n\t\tt = Geom::Transformation.new [$length-$gr_offset,$width,$gr_height]\n\t\tbuild_gr(entities,r,t)\n\tend\n\tif($gr_side == \"EW1\")\n\t\tr = Geom::Transformation.rotation [0, 0, 0], [0,0,1], 270.degrees\n\t\tt = Geom::Transformation.new [0,$width-$gr_offset,$gr_height]\n\t\tbuild_gr(entities,r,t)\n\tend\n\tif($gr_side == \"EW2\")\n\t\tr = Geom::Transformation.rotation [0, 0, 0], [0,0,1], 90.degrees\n\t\tt = Geom::Transformation.new [$length,$gr_offset,$gr_height]\n\t\tbuild_gr(entities,r,t)\n\tend\n\t\nend",
"def z; self[Z]; end",
"def z; self[Z]; end",
"def z; self[Z]; end",
"def g3\n [0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11,\n 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21,\n 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,\n 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41,\n 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1,\n 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1,\n 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1,\n 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81,\n 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,\n 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba,\n 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea,\n 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda,\n 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a,\n 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a,\n 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a,\n 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a][self]\n end",
"def r\n return (x**2.0 + y**2.0 + z**2.0)**0.5\n end",
"def to_WGS84\n\n\t if @type == :ie\n\t @a = 6377340.189\n\t @b = 6356034.447\n else\n @a = 6377563.396\n @b = 6356256.909\n end\n\n @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)\n\n @phi = deg_to_rad(@latitude)\n @lambda = deg_to_rad(@longitude)\n @v = @a / (Math.sqrt(1 - @eSquared * sin_pow_2(@phi)))\n @H = 0\n @x = (@v + @H) * Math.cos(@phi) * Math.cos(@lambda)\n @y = (@v + @H) * Math.cos(@phi) * Math.sin(@lambda)\n @z = ((1 - @eSquared) * @v + @H) * Math.sin(@phi)\n\n @tx = 446.448\n @ty = -124.157\n @tz = 542.060\n\n @s = -0.0000204894\n @rx = deg_to_rad( 0.00004172222)\n @ry = deg_to_rad( 0.00006861111)\n @rz = deg_to_rad( 0.00023391666)\n\n @xB = @tx + (@x * (1 + @s)) + (-@rx * @y) + (@ry * @z)\n @yB = @ty + (@rz * @x) + (@y * (1 + @s)) + (-@rx * @z)\n @zB = @tz + (-@ry * @x) + (@rx * @y) + (@z * (1 + @s))\n\n @a = 6378137.000\n @b = 6356752.3141\n @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)\n\n @lambdaB = rad_to_deg(Math.atan(@yB / @xB))\n @p = Math.sqrt((@xB * @xB) + (@yB * @yB))\n @phiN = Math.atan(@zB / (@p * (1 - @eSquared)))\n\n (1..10).each do |i|\n @v = @a / (Math.sqrt(1 - @eSquared * sin_pow_2(@phiN)))\n @phiN1 = Math.atan((@zB + (@eSquared * @v * Math.sin(@phiN))) / @p)\n @phiN = @phiN1\n end\n\n @phiB = rad_to_deg(@phiN)\n\n { :latitude => @phiB, :longitude => @lambdaB }\n\n end",
"def geo; end",
"def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, &rendering_code); end",
"def s; @side.to_s[0,1]; end",
"def w; self[W]; end",
"def move_diffs\n\t\tif is_king?\n\t\t\tVECTORS\n\t\telsif color == :black\n\t\t\tVECTORS[0..1]\n\t\telse\n\t\t\tVECTORS[2..3]\n\t\tend\n\tend",
"def rg2ekn(rg, a, z)\n momentn = rg * z / a\n Math.sqrt(MP * MP + momentn * momentn) - MP\n end",
"def to_Earth() \r\n Celes.nut06a(@ajd, 0)[ 1 ] + Celes.obl06(@ajd, 0) \r\n end",
"def point_values\n {\n \"A\"=>1, \"B\"=>3, \"C\"=>3, \"D\"=>2,\n \"E\"=>1, \"F\"=>4, \"G\"=>2, \"H\"=>4,\n \"I\"=>1, \"J\"=>8, \"K\"=>5, \"L\"=>1,\n \"M\"=>3, \"N\"=>1, \"O\"=>1, \"P\"=>3,\n \"Q\"=>10, \"R\"=>1, \"S\"=>1, \"T\"=>1,\n \"U\"=>1, \"V\"=>4, \"W\"=>4, \"X\"=>8,\n \"Y\"=>4, \"Z\"=>10\n }\n end",
"def point_values\n {\n \"A\"=>1, \"B\"=>3, \"C\"=>3, \"D\"=>2,\n \"E\"=>1, \"F\"=>4, \"G\"=>2, \"H\"=>4,\n \"I\"=>1, \"J\"=>8, \"K\"=>5, \"L\"=>1,\n \"M\"=>3, \"N\"=>1, \"O\"=>1, \"P\"=>3,\n \"Q\"=>10, \"R\"=>1, \"S\"=>1, \"T\"=>1,\n \"U\"=>1, \"V\"=>4, \"W\"=>4, \"X\"=>8,\n \"Y\"=>4, \"Z\"=>10\n }\n end",
"def range(unknown)\n\t\tif(vars[:yo] == 0 && vars[:yf] == 0) then\n\t\t\t#xf - xo = ((vo**2)*(Math.sin(2*theta)))/9.8\n\t\t\tcase unknown\n\t\t\twhen :xf\n\t\t\t\t(((vars[:vo]**2) * (Math.sin(2 * (vars[:theta] / (180/Math::PI))))) / -vars[:ay]) + vars[:xo]\n\t\t\twhen :xo\n\t\t\t\tvars[:xf] - (((vars[:vo]**2) * (Math.sin(2 * (vars[:theta] / (180/Math::PI))))) / -vars[:ay])\n\t\t\twhen :vo\n\t\t\t\t(((vars[:xf] - vars[:xo]) * -vars[:ay]))/Math.sin(2 * (vars[:theta] / (180/Math::PI)))**(1/2.0)\n\t\t\twhen :theta\n\t\t\t\t(Math.asin((((vars[:xf] - vars[:xo]) * -vars[:ay])) / vars[:vo]**2) / 2) * (180/Math::PI)\n\t\t\tend\n\t\tend\n\tend",
"def valores\n {\n 'a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1,\n 'l' => 1, 'n' => 1, 'r' => 1, 's' => 1, 't' => 1,\n 'd' => 2, 'g' => 2,\n 'b' => 3, 'c' => 3, 'm' => 3, 'p' => 3,\n 'f' => 4, 'h' => 4, 'v' => 4, 'w' => 4, 'y' => 4,\n 'k' => 5,\n 'j' => 8, 'x' => 8,\n 'q' => 10 , 'z' => 10\n }\n end",
"def grasa\n\t\t1.2*imc+0.23*@edad-10.8*@sexo-5.4\n\tend",
"def three_sizes\n \"#{object.bust}-#{object.waist}-#{object.hip}\"\n end",
"def get_hotcloud_info_from_moji(mojihour)\n useful={\"date\"=>\"2017-12-31\", \"hour\"=>\"11\",\"lightCondition\"=>\"晴\",\"rainCondition\"=>\"无\", \"humidity\"=>\"15\",\"temprature\"=>\"3\", \"wind_speed\"=>\"9\"}\n mojihour.each do |k,v|\n case k\n when \"date\"\n useful[\"date\"]=v\n when \"hour\"\n case v\n when \"0\"\n\t\t\t useful[\"hour\"]=\"00\"\n when \"1\"\n\t\t\t useful[\"hour\"]=\"01\"\n when \"2\"\n\t\t\t useful[\"hour\"]=\"02\"\n when \"3\"\n\t\t\t useful[\"hour\"]=\"03\"\n when \"4\"\n\t\t\t useful[\"hour\"]=\"04\"\n when \"5\"\n\t\t\t useful[\"hour\"]=\"05\"\n when \"6\"\n\t\t\t useful[\"hour\"]=\"06\"\n when \"7\"\n\t\t\t useful[\"hour\"]=\"07\"\n when \"8\"\n\t\t\t useful[\"hour\"]=\"08\"\n when \"9\"\n\t\t\t useful[\"hour\"]=\"09\"\n else\n\t\t\t useful[\"hour\"]=v\n end\n\t\t\twhen \"humidity\"\n useful[\"humidity\"]=v\n when \"temp\"\n useful[\"temprature\"]=v\n when \"condition\"\n case v\n when \"晴\"\n useful[\"lightCondition\"]=\"晴\"\n useful[\"rainCondition\"]=\"无\"\n when \"多云\"\n useful[\"lightCondition\"]=\"多云\"\n useful[\"rainCondition\"]=\"无\"\n when \"少云\"\n useful[\"lightCondition\"]=\"多云\"\n useful[\"rainCondition\"]=\"无\"\n when \"雾\"\n useful[\"lightCondition\"]=\"多云\"\n useful[\"rainCondition\"]=v\n when \"阴\"\n useful[\"lightCondition\"]=\"阴天\"\n useful[\"rainCondition\"]=\"无\"\n else\n useful[\"lightCondition\"]=\"阴天\"\n useful[\"rainCondition\"]=\"阴天\"\n end\n when \"windSpeed\"\n v=v.to_i\n case v\n when 0 .. 11\n useful[\"wind_speed\"]=\"<3\"\n when 12 ..19\n useful[\"wind_speed\"]=\"3\"\n when 20 .. 28\n useful[\"wind_speed\"]=\"4\"\n when 29 .. 38\n useful[\"wind_speed\"]=\"5\"\n when 39 .. 49\n useful[\"wind_speed\"]=\"6\"\n else\n useful[\"wind_speed\"]=\"8\"\n end\n end\n end\n useful\n end",
"def alpha_mapping\n {# 1st line\n Q: '__{ KeyCode::Q, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n W: \"__{ KeyCode::KEY_5, #{shift_opt}, KeyCode::MINUS, #{shift_opt}, #{left} }__\", # []\n E: \"__{ KeyCode::KEY_5, KeyCode::MINUS, #{left} }__\", # ()\n R: \"__{ KeyCode::KEY_5, #{opt}, KeyCode::MINUS, #{opt}, #{left} }__\", # {}\n T: \"__{ KeyCode::BACKQUOTE, KeyCode::BACKQUOTE, #{shift}, #{left} }__\", # <>\n Y: \"__{ KeyCode::KEY_1, #{shift} }__\", # 1\n U: \"__{ KeyCode::CURSOR_LEFT, #{cmd} }__\", # left\n I: '__{ KeyCode::CURSOR_UP }__', # up\n O: \"__{ KeyCode::CURSOR_RIGHT, #{cmd} }__\", # right\n P: nil,\n\n # 2nd line\n A: '__{ KeyCode::A, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n S: '__{ KeyCode::S, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n D: '__{ KeyCode::D, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n F: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # \"\",\n G: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # '',\n H: '__{ KeyCode::RawValue::0x97 }__', # nil, # 0, # ----- # todo: <- NC #'__{ KeyCode::M }__',\n J: '__{ KeyCode::CURSOR_LEFT }__', # LEFT\n K: '__{ KeyCode::CURSOR_DOWN }__', # DOWN\n L: '__{ KeyCode::CURSOR_RIGHT }__', # RIGHT\n QUOTE: '__{ KeyCode::RawValue::0x98 }__', # todo: -> NC\n\n # 3rd line\n Z: '__{ KeyCode::Z, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n X: '__{ KeyCode::X, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n C: '__{ KeyCode::C, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n V: '__{ KeyCode::V, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n B: '__{ KeyCode::B, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n N: '__{ KeyCode::N, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n M: \"__{ KeyCode::CURSOR_LEFT, #{opt} }__\", # <- word\n COMMA: '__{ KeyCode::RawValue::0x96 }__', # down something\n DOT: \"__{ KeyCode::CURSOR_RIGHT, #{opt} }__\", # -> word\n # BACKQUOTE: 'BACKSLASH', Z: 'COMMA',\n\n KEY_2: \"__{ KeyCode::L, #{shift_opt}, KeyCode::L, #{shift_opt}, #{left} }__\", # ||\n KEY_3: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # '', # -----\n KEY_4: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # \"\", # -----\n KEY_5: \"__{ KeyCode::BACKSLASH, KeyCode::BACKSLASH, #{left} }__\", # ``,\n KEY_7: nil,\n KEY_8: '__{ KeyCode::RawValue::0x95 }__',\n KEY_9: nil\n }.with_indifferent_access\n end",
"def groups\n z.standardize.map do |val|\n if val.positive?\n 'H'\n else\n 'L'\n end\n end\n end",
"def material; end",
"def material; end",
"def as_ewkt(allow_srid=true,allow_z=true,allow_m=true)\r\n if allow_srid\r\n ewkt=\"SRID=#{@srid};\"\r\n else\r\n ewkt=\"\"\r\n end\r\n ewkt << text_geometry_type \r\n ewkt << \"M\" if @with_m and allow_m and (!@with_z or !allow_z) #to distinguish the M from the Z when there is actually no Z... \r\n ewkt << \"(\" << text_representation(allow_z,allow_m) << \")\" \r\n end",
"def sTemperatur()\n @len = @seq.length\n # Falls die Länge ungleich 0 ist\n # rechnen wir was nötig ist\n if @len\n # Falls die Länge der Zeichenkette kleiner oder gleich 14 ist \n # rechnen wir das ein bisschen anders\n if(@len <= 14)\n\treturn 4.0 * (occ(@seq, 'G') + occ(@seq, 'C')) + 2 * (occ(@seq, 'A') + occ(@seq, 'T'))\n # Falls die Länget des DNAs relativ gross ist \n # dann rechnen wir das auch anders\n else \n\treturn 64.9 + 41.0 * (occ(@seq, 'G') + occ(@seq, 'C') - 16.4) / @len\n end\n end \n return NIL\n end",
"def interpolation_patterns; end",
"def z\n return @z\n end",
"def stderrs; end",
"def matz; end",
"def reverse_mapping\n {\n 0 => \"general\",\n 4 => \"character\",\n 3 => \"copyright\",\n 1 => \"artist\",\n 5 => \"meta\",\n }\n end",
"def available_gravities\n {\n size: [\"grow\", \"shrink\", \"closest_fit\"],\n x: [\"left\", \"center\", \"right\"],\n y: [\"top\", \"center\", \"bottom\"],\n }\n end",
"def initialize string_args, value #this @value is a hash where the keys are monster, player, item, and maptype\r\n case string_args #will store the value of whatever is in that room at that moment\r\n when 'n' #will be in this order {monster: [], player: [], item: [], maptype: xxxx}\r\n self.north value #will start with default values\r\n when 's'\r\n self.south value\r\n when 'w'\r\n self.west value\r\n when 'e'\r\n self.east value\r\n when 'ne'\r\n self.northeast value\r\n when 'nw'\r\n self.northwest value\r\n when 'sw'\r\n self.southwest value\r\n when 'se'\r\n self.southeast value\r\n end\r\n end",
"def ordinal_azimuth; end",
"def hash\n [camera_type, field_of_view_angle, zoom, x_rotation, y_rotation, z_rotation].hash\n end",
"def to_gigahertz(**options) = convert_to('gigahertz', **options)",
"def direction; end",
"def direction; end",
"def shout\n\t\tputs @x.to_s+\" \"[email protected]_s+\" \"[email protected](@orientation.to_i)+\"\t\"[email protected]_s\n\tend",
"def specific_keys\n %w(\n animate\n size\n background\n transparent\n enhanced\n rounded\n butt\n linewidth\n dashlength\n tiny\n small\n medium\n large\n giant\n font\n fontscale\n crop\n )\n end",
"def create_representation(pieces_position_list)\n arr = (0..6).to_a.map { |x| [] }\n positions = ('A'..'G').to_a.each_with_index.reduce({}) { |x, i| x.merge(Hash[*i]) }\n pieces_position_list.reduce(arr) do |x, m|\n (pos, color) = m.split(\"_\")\n arr[positions[pos]] << color\n arr\n end\nend",
"def translate( *args ) \n ## From Martin Rinehart 'Edges to Rubies' chapter 15\n ## May be called with a transformation and a vector, \n ## or with a transformation and r, g, b values.\n\n trans = args[0]\n if args.length == 2\n vec = args[1]\n r = vec[0]; g = vec[1]; b = vec[2] \n else\n r = args[1]; g = args[2]; b = args[3] \n end\n arr = trans.to_a()\n arr[12] += r; arr[13] += g; arr[14] += b \n return Geom::Transformation.new( arr )\n \n\tend",
"def quarter_wind_azimuth; end",
"def megahertz? = unit == 'megahertz'",
"def name_text_coordinates\n return 8, 5, 98, 16\n end",
"def tongue_twister; end",
"def look(spaces)\n \t#Here we have an array\n vision = {}\n\n spaces.each_with_index { |space, index|\n #instance variable\n distance = index.succ\n entity = OBJECTS.select { |type|\n space.send \"#{type.to_s}?\".to_sym\n }.first\n raise \"woah\" unless entity\n vision[:nearest] = entity unless vision[:nearest]\n if vision[entity]\n vision[entity] << distance\n else\n vision[entity] = [distance]\n end\n\n nearest_entity_key = \"nearest_#{entity.to_s}\".to_sym\n vision[nearest_entity_key] = distance unless vision[nearest_entity_key]\n \n #This adds the items that he sees to the array\n if vision[:view]\n vision[:view] << entity\n else\n vision[:view] = [entity]\n end\n }\n\n vision\n end",
"def basics()\n x = {\n 'wt' => 'standard',\n 'rows' => 10,\n 'start' => 0,\n 'fl' => '*,score',\n 'hl' => 'true',\n 'hl.maxAnalyzedChars' => 2147483647,\n 'hl.fragsize' => 0\n }\n\n return x\n end",
"def display_maze_with_ascii(grid)\n \nend",
"def second_pass_endings\n {\n feminine: %w[a e opsis lepis],\n masculine: %w[er es ops os us],\n neuter: %w[on um]\n }\n end",
"def constellation; end",
"def modeler_description\n return 'Not sure how I will handle arguments. Maybe lump together all spaces on same sotry that have the same multilier value. This will have variable number of arguments basd on the model pased in. Alternative is to either only allo w one group to be chosen at at time, or allow a comlex string that describes everything. Also need to see how to define shirting. There is an offset but it may be above and below and may not be equal. In Some cases a mid floor is halfway betwen floors which makes just copying the base surfaces as shading multiple times probemeatic, since there is overlap. It coudl be nice to stretch one surface over many stories. If I check for vertial adn orthogonal surface that may work fine. '\n end",
"def panoramic_pairs(landmarks)\n\nend",
"def create_spaces\n ((@tiles, @tile_map),\n (@up_vtexs, @up_vtex_map),\n (@down_vtexs, @down_vtex_map),\n (@asc_edges, @asc_edge_map),\n (@desc_edges, @desc_edge_map),\n (@vert_edges, @vert_edge_map)) =\n [[Tile, nil, 1..5, [3,4,5,4,3], [1..3, 1..4, 1..5, 2..5, 3..5]],\n [Vtex, :up, 1..6, [3,4,5,6,5,4], [1..3, 1..4, 1..5, 1..6, 2..6, 3..6]],\n [Vtex, :down, 0..5, [4,5,6,5,4,3], [0..3, 0..4, 0..5, 1..5, 2..5, 3..5]],\n [Edge, :asc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 2..6, 3..6, 4..6]],\n [Edge, :desc, 1..6, [3,4,5,5,4,3], [1..3, 1..4, 1..5, 1..5, 2..5, 3..5]],\n [Edge, :vert, 1..5, [4,5,6,5,4], [1..4, 1..5, 1..6, 2..6, 3..6]]\n ].map {|cls, align, row_interval, row_counts, col_intervals|\n rows = row_counts.zip(row_interval.to_a).map {|c, r| [r]*c}.flatten\n cols = col_intervals.map {|ival| ival.to_a}.flatten\n count = rows.length\n list = (0...count).to_a.map {|i| cls.new}\n list.each {|obj| obj.alignment = align} unless align.nil?\n list.zip(rows, cols).each {|obj, row, col| obj.row, obj.col = row, col}\n map = Hash[list.map {|obj| [[obj.row, obj.col], obj]}]\n [list, map]\n }\n\n @vtexs = @up_vtexs + @down_vtexs\n @edges = @asc_edges + @desc_edges + @vert_edges\n @all_spaces = @tiles + @vtexs + @edges\n\n @vtex_map = Hash[@vtexs.map {|v| [v.coords, v]}]\n @edge_map = Hash[@edges.map {|e| [e.coords, e]}]\n\n @all_spaces.zip((0...(@all_spaces.length)).to_a).each do |obj, id|\n obj.id = id\n end\n end",
"def z\n end",
"def vin; end",
"def game_parameters\n\t\t\"(#{$dimensions[:x]}, #{$dimensions[:y]}) #{$wall_max}, #{$cooldown[:hunter]}, #{$cooldown[:prey]}\"\n\tend",
"def quad_faces\r\n @faces_to_quads.keys\r\n end",
"def modeler_description\n return \"Make an array of the spaces that meet the criteria. Locate the sensor x and y values by averaging the min and max X and Y values from floor surfaces in the space. If a space already has a daylighting control, do not add a new one and leave the original in place. Warn the user if the space isn't assigned to a thermal zone, or if the space doesn't have any translucent surfaces. Note that the cost is added to the space not the sensor. If the sensor is removed at a later date, the cost will remain.\"\n end",
"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 west \n \"west\" \n end",
"def cardinal_azimuth; end",
"def modeler_description\n return \"Each window in the building is assigned a thermochromic window construction and a shading control. The shading control is set to increase the window tint to meet the daylighting setpoint in the zone. If the zone already has daylighting controls, the setpoints from those controls are used. If the zone does not have controls, new controls are added at the center of the zone with a setpoint of 500 lux. These controls are only used for changing the window tint; they are not used to control the interior lighting.\"\n end",
"def guct\n end",
"def place_private piece, orientation, c\n return nil unless fits?(piece, orientation, c)\n case orientation\n when :vertical_up\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face][c.row + 1][c.left] = piece.id if piece.size > 1\n @a[c.face][c.row + 2][c.left] = piece.id if piece.size == 3\n\n string_end = C.new(c.face, c.row + piece.size - 1, c.left)\n\n when :vertical_down\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face][c.row - 1][c.left] = piece.id if piece.size > 1\n @a[c.face][c.row - 2][c.left] = piece.id if piece.size == 3\n\n string_end = C.new(c.face, c.row - piece.size + 1, c.left)\n\n when :sideways_right\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face][c.row][c.left + 1] = piece.id if piece.size > 1\n @a[c.face][c.row][c.left + 2] = piece.id if piece.size == 3\n\n string_end = C.new(c.face, c.row, c.left + piece.size - 1)\n\n when :sideways_left\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face][c.row][c.left - 1] = piece.id if piece.size > 1\n @a[c.face][c.row][c.left - 2] = piece.id if piece.size == 3\n\n string_end = C.new(c.face, c.row, c.left - piece.size + 1)\n\n when :long_far\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face + 1][c.row][c.left] = piece.id if piece.size > 1\n @a[c.face + 2][c.row][c.left] = piece.id if piece.size == 3\n\n string_end = C.new(c.face + piece.size - 1, c.row, c.left)\n\n when :long_near\n @a[c.face][c.row][c.left] = piece.id\n @a[c.face - 1][c.row][c.left] = piece.id if piece.size > 1\n @a[c.face - 2][c.row][c.left] = piece.id if piece.size == 3\n\n string_end = C.new(c.face - piece.size + 1, c.row, c.left)\n end\n\n return true, string_end\n end",
"def _locations_ordered_for_text_dump\n locations = Hash[(1..23).to_a.map {|row| [row, {}]}]\n @tiles.each {|t| locations [t.row * 4 ] [t.col * 4 - t.row * 2 + 5] = t}\n @up_vtexs.each {|v| locations [v.row * 4 - 3] [v.col * 4 - v.row * 2 + 5] = v}\n @down_vtexs.each {|v| locations [v.row * 4 + 3] [v.col * 4 - v.row * 2 + 5] = v}\n @asc_edges.each {|e| locations [e.row * 4 - 2] [e.col * 4 - e.row * 2 + 4] = e}\n @desc_edges.each {|e| locations [e.row * 4 - 2] [e.col * 4 - e.row * 2 + 6] = e}\n @vert_edges.each {|e| locations [e.row * 4 ] [e.col * 4 - e.row * 2 + 3] = e}\n return locations\n end",
"def to_color(letter)\n case letter\n when \"r\"\n return :red\n when \"g\"\n return :green\n when \"b\"\n return :blue\n when \"c\"\n return :cyan\n when \"m\"\n return :magenta\n when \"y\"\n return :yellow\n else\n return letter\n end\nend",
"def get_zigzag_points(loop)\r\n bb = loop.face.bounds\r\n ht = bb.max.y - bb.min.y - @bit_diameter - 0.001\r\n wd = bb.max.x - bb.min.x - @bit_diameter - 0.001\r\n# puts \"ht #{ht.to_mm} wd #{wd.to_mm}\"\r\n if ((wd < @bit_diameter) || (ht < @bit_diameter)) \r\n# puts \"exiting nil\"\r\n return nil\r\n end\r\n if PhlatScript.pocketDirection?\r\n return get_zigzag_points_x(loop) # zigs along Y - suites phlatprinter\r\n else\r\n return get_zigzag_points_y(loop) # zigs along x - suites gantries\r\n end\r\n end",
"def units_hash\n {\n \"_hrs\" => \"hours\",\n \"_hours\"=>\"hours\",\n \"_min\"=>\"minutes\",\n \"_minutes\"=>\"minutes\",\n \"_ppm\"=>\"ppm\",\n \"_ppb\"=>\"ppb\",\n \"_mgm3\"=>\"mg/m3\",\n \"_f\"=>\"°f\",\n \"_c\"=>\"°c\",\n \"_rh\"=>\"% rh\",\n \"_utf\"=>\"\"\n }\n end",
"def tuc(arg)\n h = Hash.[](\".\"=>\"་\", \"/\"=>\"།\", \";\"=>\"༔\", \"\"=>\"\",\n \"ka\"=>\"ཀ\", \"kha\"=>\"ཁ\", \"ga\"=>\"ག\", \"nga\"=>\"ང\",\n \"ca\"=>\"ཅ\", \"cha\"=>\"ཆ\", \"ja\"=>\"ཇ\", \"nya\"=>\"ཉ\",\n \"ta\"=>\"ཏ\", \"tha\"=>\"ཐ\", \"da\"=>\"ད\", \"na\"=>\"ན\",\n \"pa\"=>\"པ\", \"pha\"=>\"ཕ\", \"ba\"=>\"བ\", \"ma\"=>\"མ\",\n \"tsa\"=>\"ཙ\", \"tsha\"=>\"ཚ\", \"dza\"=>\"ཛ\", \"wa\"=>\"ཝ\",\n \"zha\"=>\"ཞ\", \"za\"=>\"ཟ\", \"'a\"=>\"འ\", \"ya\"=>\"ཡ\",\n \"ra\"=>\"ར\", \"la\"=>\"ལ\", \"sha\"=>\"ཤ\", \"sa\"=>\"ས\",\n \"ha\"=>\"ཧ\", \"a\"=>\"ཨ\",\n # numbers !!! better include number_generator\n \"0\"=>\"༠\", \"1\"=>\"༡\", \"2\"=>\"༢\", \"3\"=>\"༣\",\n \"4\"=>\"༤\", \"5\"=>\"༥\", \"6\"=>\"༦\", \"7\"=>\"༧\",\n \"8\"=>\"༨\", \"9\"=>\"༩\",\n # vowel signs\n \".e\"=>\"ེ\", \".i\"=>\"ི\", \".o\"=>\"ོ\", \".u\"=>\"ུ\",\n # double vowel signs\n \"E\" => \"ཻ\", \"O\" => \"ཽ\",\n # subscribed characters\n \"x_ka\"=>\"ྐ\", \"x_kha\"=>\"ྑ\", \"x_ga\"=>\"ྒ\", \"x_nga\"=>\"ྔ\",\n \"x_ca\"=>\"ྕ\", \"x_cha\"=>\"ྖ\", \"x_ja\"=>\"ྗ\", \"x_nya\"=>\"ྙ\",\n \"x_ta\"=>\"ྟ\", \"x_tha\"=>\"ྐ\", \"x_da\"=>\"ྡ\", \"x_na\"=>\"ྣ\",\n \"x_pa\"=>\"ྤ\", \"x_pha\"=>\"ྥ\", \"x_ba\"=>\"ྦ\", \"x_ma\"=>\"ྨ\",\n \"x_tsa\"=>\"ྩ\", \"x_tsha\"=>\"ྪ\", \"x_dza\"=>\"ྫ\", \"x_wa\"=>\"ྭ\",\n \"x_zha\"=>\"ྮ\", \"x_za\"=>\"ྯ\", \"x_'a\"=>\"ཱ\", \"x_ya\"=>\"ྱ\",\n \"x_ra\"=>\"ྲ\", \"x_la\"=>\"ླ\", \"x_sha\"=>\"ྴ\", \"x_sa\"=>\"ྶ\",\n \"x_ha\"=>\"ྷ\", \"x_a\"=>\"ྸ\",\n # superscribed character\n \"ra_x\"=>\"ར\",\n # revered letters\n \"Ta\"=>\"ཊ\", \"Tha\" => \"ཋ\", \"Da\" => \"ཌ\", \"Na\" => \"ཎ\",\n \"Sha\" => \"ཥ\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end",
"def dir(direction)\n if direction == \"f\"\n return \"left\"\n elsif direction == \"g\"\n return \"center\"\n elsif direction == \"h\"\n return \"right\"\n elsif direction == \"c\"\n return \"away\"\n else\n return \"invalid\"\n end\n end",
"def z\n end",
"def grid; @parameters['GRiD']; end",
"def map\n\n end",
"def screen_z\n # Return after calculating z-coordinate by order of members in party\n if self.index != nil\n return 4 - self.index\n else\n return 0\n end\n end"
] | [
"0.5961361",
"0.5650462",
"0.564609",
"0.5439773",
"0.5438751",
"0.53969264",
"0.5392047",
"0.5287255",
"0.52759415",
"0.526136",
"0.526136",
"0.52569556",
"0.5253616",
"0.52456146",
"0.51385486",
"0.5133525",
"0.5129573",
"0.5119237",
"0.5099938",
"0.50962394",
"0.50892293",
"0.508815",
"0.50807774",
"0.50596815",
"0.50527555",
"0.50453496",
"0.50339985",
"0.50339985",
"0.50339985",
"0.5030369",
"0.5017481",
"0.5010699",
"0.50040865",
"0.50015026",
"0.5001413",
"0.50013524",
"0.49997696",
"0.49805006",
"0.49730667",
"0.4955408",
"0.4955408",
"0.4950865",
"0.4947559",
"0.49403965",
"0.49268138",
"0.49232867",
"0.49218613",
"0.49134013",
"0.49084684",
"0.49084684",
"0.4907345",
"0.4906702",
"0.48972076",
"0.4891977",
"0.48915255",
"0.48905328",
"0.48879516",
"0.48864648",
"0.4883625",
"0.4881369",
"0.48762164",
"0.487375",
"0.4864282",
"0.4864282",
"0.4859916",
"0.48555014",
"0.48527214",
"0.48507044",
"0.48454654",
"0.4835025",
"0.48323345",
"0.48288614",
"0.4820533",
"0.48185438",
"0.48126543",
"0.48120055",
"0.4808485",
"0.48028842",
"0.47994018",
"0.47991574",
"0.47973186",
"0.4793737",
"0.47914943",
"0.47898608",
"0.47852495",
"0.47806752",
"0.47724256",
"0.47716475",
"0.47671106",
"0.4765183",
"0.4762855",
"0.47558305",
"0.47541824",
"0.4751569",
"0.4750394",
"0.47473997",
"0.47460595",
"0.47442883",
"0.47394332",
"0.47350973",
"0.4734675"
] | 0.0 | -1 |
GET /ad/1 GET /ad/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad }\n end\n end",
"def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end",
"def index\n @ads = Ad.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end",
"def show\n @ad_tag = AdTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_tag }\n end\n end",
"def show\n @home_indices_ad = Home::Indices::Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_indices_ad }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n end",
"def show\n @ad = Ad.find(params[:id])\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ad }\n format.json \n end\n end",
"def show\n @ad_post = AdPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_post }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html \n end\n end",
"def show\n @ad_type = AdType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_type }\n end\n end",
"def show\n @advertisement = Advertisement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advertisement }\n end\n end",
"def show\n @advert = Advert.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advert }\n end\n end",
"def show\n render json: @advert\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render json: { advertisements: @advertisements } }\n end\n end",
"def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ads }\n format.json { render :json => @ads }\n end\n end",
"def new\n @ad = Ad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ad }\n end\n end",
"def new\n @ad = Ad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ad }\n end\n end",
"def show\n @advert = Advert.find(params[:id])\n @vcounter = ViewsCounter.counter('Advert', params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advert }\n end\n end",
"def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end",
"def index\n respond_with Ad.all \n end",
"def index\n @ads = Ad.all \n end",
"def index\n @ads = @org.ads\n end",
"def index\n @ads = Ad.all\n end",
"def index\n @ads = Ad.all\n end",
"def index\n @ads = Ad.all\n end",
"def index\n @ads = Ad.all\n end",
"def index\n @ads = Ad.all\n end",
"def call\n response = call_ads_api\n ads = response[\"ads\"]\n ads_hash = index_ads_remote(ads)\n {success: true, data: ads_hash}\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ad }\n end\n end",
"def show\n @acd = Acd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @acd }\n end\n end",
"def show\n @aadt = Aadt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aadt }\n end\n end",
"def show\n @ad_contact = AdContact.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_contact }\n end\n end",
"def show\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @adv }\n end\n end",
"def show\n @advertisment = Advertisment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advertisment }\n end\n end",
"def show\n\t\t@ad = Ad.includes({:ad_group => :campaign}, :ad_type).where(\"campaigns.account_id = ?\", @auth_user.account_id).find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @ad }\n\t\tend\n\tend",
"def show\n @google_adwords_account = GoogleAdwordsAccount.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @google_adwords_account }\n end\n end",
"def show\n @ad_unit = AdUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_unit }\n end\n end",
"def index\n @advertisements = Advertisement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advertisements }\n end\n end",
"def index\n @advertisements = Advertisement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advertisements }\n end\n end",
"def show\n render json: @banner\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @ad.to_xml }\n end\n end",
"def show\n @sales_ad = SalesAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sales_ad }\n end\n end",
"def show\n @audience = Audience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @audience }\n end\n end",
"def show\n @purchasing_ad = PurchasingAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @purchasing_ad }\n end\n end",
"def index\n @ads = Ad.find_all_by_account_id(session[:account_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ads }\n end\n end",
"def index\n @advertises = Advertise.all\n render 'index', formats: 'json', handlers: 'jbuilder'\n end",
"def index\n @adjs = Adj.all\n end",
"def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ads }\n end\n end",
"def show\n @obj = {\n id: @cargapp_ad.id,\n name: @cargapp_ad.name,\n price: @cargapp_ad.price,\n description: @cargapp_ad.description,\n body: @cargapp_ad.body,\n image: @cargapp_ad.image.attached? ? url_for(@cargapp_ad.image) : nil,\n url: @cargapp_ad.url,\n media: @cargapp_ad.media.attached? ? url_for(@cargapp_ad.media) : nil,\n have_discoun: @cargapp_ad.have_discoun,\n is_percentage: @cargapp_ad.is_percentage,\n discoun: @cargapp_ad.discoun,\n active: cargapp_ad.active,\n user_id: @cargapp_ad.user_id,\n created_at: @cargapp_ad.created_at,\n updated_at: @cargapp_ad.updated_at\n } \n render json: @obj\n end",
"def set_ad\n @ad = @org.ads.find(params[:id])\n end",
"def show\n @wadl = Wadl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @wadl }\n end\n end",
"def show\n render json: Alien.find(params[\"id\"])\n end",
"def show\n render json: @admitting\n end",
"def show\n if params[:archive_id]\n @some_kind_of_ad = Ad.find_by(archive_id: params[:archive_id]) \n elsif params[:ad_id]\n @some_kind_of_ad = FbpacAd.find_by(id: params[:ad_id])\n end\n\n raise ActiveRecord::RecordNotFound if @some_kind_of_ad.nil?\n\n ad_text = @some_kind_of_ad.ad_text\n\n respond_to do |format|\n format.html {\n redirect_to \"https://dashboard.qz.ai/ad/#{ad_text.text_hash}\"\n }\n format.json { render json: {\n ad_text: ad_text\n } }\n end\n end",
"def show\n @creative = Creative.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @creative }\n end\n end",
"def show\n @assay = Assay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assay }\n end\n end",
"def show\n render json: @adopter\n end",
"def show\n @create_classified_ad = CreateClassifiedAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @create_classified_ad }\n end\n end",
"def index\n @admittings = Admitting.all\n render json: @admittings\n end",
"def show\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def show\n redirect_to edit_banner_url(params[:id])\n\n #@banner = Banner.find(params[:id])\n #\n #respond_to do |format|\n # format.html # show.html.erb\n # format.json { render :json => @banner }\n #end\n end",
"def get_ads(params, headers={})\n url = \"#{@fqdn}#{SERVICE_URL}\"\n\n if params\n args = \"?\"\n params.each do |key, value|\n if value && !value.empty?\n args << \"&\" unless args.end_with? \"?\"\n args << \"#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}\"\n end\n end\n url << args\n end\n\n self.get(url, headers)\n end",
"def index\n @advertises = current_user.advertises.page(params[:page])\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def new\n @advertise = Advertise.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertise }\n end\n end",
"def index\n @ads = Ad.find(:all)\n\n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @ads.to_xml }\n end\n end",
"def new\n @advert = Advert.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advert }\n end\n end",
"def new\n @home_indices_ad = Home::Indices::Ad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @home_indices_ad }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ad }\n end\n end",
"def index\n @cargapp_ads = CargappAd.all\n\n @result = []\n @cargapp_ads.each do |cargapp_ad|\n @obj = {\n id: cargapp_ad.id,\n name: cargapp_ad.name,\n price: cargapp_ad.price,\n description: cargapp_ad.description,\n body: cargapp_ad.body,\n image: cargapp_ad.image.attached? ? url_for(cargapp_ad.image) : nil,\n url: cargapp_ad.url,\n media: cargapp_ad.media.attached? ? url_for(cargapp_ad.media) : nil,\n have_discoun: cargapp_ad.have_discoun,\n is_percentage: cargapp_ad.is_percentage,\n discoun: cargapp_ad.discoun,\n active: cargapp_ad.active,\n user_id: cargapp_ad.user_id,\n created_at: cargapp_ad.created_at,\n updated_at: cargapp_ad.updated_at\n }\n @result << @obj\n end\n render json: @result\n end",
"def index\n @sales_ads = SalesAd.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sales_ads }\n end\n end",
"def set_ad\n@ad = Ad.find(params[:id])\nend",
"def new\n @advertisement = Advertisement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertisement }\n end\n end",
"def new\n @advertisement = Advertisement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertisement }\n end\n end",
"def new\n @advertisement = Advertisement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertisement }\n end\n end",
"def show\n @ass = Ass.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ass }\n end\n end",
"def index\n @advertisements = Advertisement.where(merchant_id: params[:merchant_id])\n\n render json: @advertisements\n end",
"def set_ad\n @ad = Ad.find(params[:id])\n end",
"def new\n\n \n @advert = Advert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advert }\n \n end\n end",
"def new\n @ad_tag = AdTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ad_tag }\n end\n end",
"def show\n @dataload_ga = DataloadGa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataload_ga }\n end\n end",
"def index\n @advertisements = Advertisement.where(user: current_user).order(updated_at: :desc).with_attached_images\n\n respond_to do |format|\n format.html\n format.json { render json: { advertisements: @advertisements } }\n end\n end",
"def show\n @advertisement = Advertisement.where(id: params[:id]).last\n end",
"def set_ad\n\t@ad = Ad.find(params[:id])\n end",
"def show\n #@banner = Banner.find(params[:id])\n @banner = Banner.find_by_id(params[:pidm])\n\n @title = 'Banner Details'\n @description = 'Detailed Banner Data'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @banner }\n end\n end",
"def index\n # missing verification if user owns ad:\n @ad = Ad.find(params[:ad_id])\n @ad_id = params[:ad_id]\n @ad_images = AdImage.for_ad_id( params[:ad_id] ).all\n respond_to do |format|\n format.html {\n render :index\n }\n format.json {\n render :json => @ad_images.collect { |p| p.to_dropzone_gallery }.to_json\n }\n end\n end",
"def create\n @ad = Ad.new(ad_params)\n\n if @ad.save\n render :show, status: :created, location: @ad\n else\n render json: @ad.errors, status: :unprocessable_entity\n end\n end",
"def index\n @ads = Ad.all.ultimos\n end",
"def adcreatives(options = {})\n\t\t\tself.id = self.id + \"/adcreatives\"\n\t\t\tread options\n\t\tend",
"def show\n @drip = Drip.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drip }\n end\n end",
"def show\n # @deal = Deal.find(params[:id], :include => [:retailer, :advertiser, {:retailer => :account}] )\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @deal }\n end\n end",
"def show\n @getadvice = Getadvice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @getadvice }\n end\n end",
"def show\n @admin_agency = Admin::Agency.where(:id => params[:id]).includes(:pages)[0]\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def index\n@magazine = Magazine.find_by_id(params[:magazine_id])\n@ads = @magazine.ads\nend",
"def show\n @award = Award.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @award }\n end\n end",
"def show\n @advertise = Advertise.find(params[:id])\n authorize! :show, @advertise, :message => 'Acceso denegado.'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advertise }\n end\n end",
"def show\n @adversaire = Adversaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @adversaire }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n #The next line are a security to validate that the object being shown is owned by the current session holder.\n if !validate_account_id(@ad.account_id).call().nil? then return end\n @campaign_name = Campaign.find(@ad.campaign_id).name\n @zone_name = Zone.find(@ad.zone_id).name\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ad }\n end\n end",
"def new\n # @advertisement = Advertisement.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertisement }\n end\n end"
] | [
"0.7653487",
"0.7653487",
"0.7653487",
"0.7245162",
"0.7229485",
"0.7094977",
"0.7065143",
"0.70625454",
"0.70625454",
"0.70081294",
"0.6920105",
"0.6905401",
"0.68924284",
"0.6842743",
"0.6810194",
"0.680532",
"0.6676285",
"0.66659755",
"0.66574806",
"0.66574806",
"0.6642968",
"0.66268957",
"0.6605303",
"0.6592371",
"0.65904945",
"0.6583179",
"0.6583179",
"0.6583179",
"0.6583179",
"0.6583179",
"0.6515783",
"0.6496268",
"0.6486845",
"0.6481334",
"0.64636034",
"0.6460541",
"0.6435699",
"0.6431249",
"0.64232916",
"0.6408561",
"0.6338872",
"0.6338872",
"0.6316808",
"0.6310542",
"0.63083166",
"0.6295217",
"0.6259021",
"0.6250412",
"0.6246508",
"0.62456006",
"0.62214684",
"0.62114686",
"0.62069356",
"0.6203837",
"0.6197399",
"0.6194878",
"0.6184282",
"0.617461",
"0.61705726",
"0.616532",
"0.61639833",
"0.6160093",
"0.6132848",
"0.6125322",
"0.6114461",
"0.6108696",
"0.60956913",
"0.6091556",
"0.6071487",
"0.60675085",
"0.6065083",
"0.60442215",
"0.6040554",
"0.6037855",
"0.603497",
"0.603497",
"0.603497",
"0.60333216",
"0.60301864",
"0.6025866",
"0.60235953",
"0.60229325",
"0.6013167",
"0.60030985",
"0.60021293",
"0.59971076",
"0.59923095",
"0.5985383",
"0.59624755",
"0.59621567",
"0.5942162",
"0.5931964",
"0.59300685",
"0.59195936",
"0.59176546",
"0.59142077",
"0.59105045",
"0.5909373",
"0.59091014",
"0.5902094",
"0.5886446"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_ad
@ad = Ad.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 |
Currently there is no way of knowing when error output has finished, so now we capture errors from start of receiving first line is 1 second ago or we started capturing error output is 4 seconds ago. Hope this will be enough. | def capture_error_output
puts "Capturing error output..."
@stderr.flush
error_catching_thread = Thread.new {
@out = ""
thread = Thread.start do
@stderr.each_line do |line|
@out << line
end
end
}
@stderr.sync = false
line = ""
while c = @stdout.read(1)
line += c
if line =~ /\(fcsh\)/
puts "Done...."
return @out
end
next if c != "/n"
puts "(out) " + line.inspect if $DEBUG
if line =~ /Nothing has changed/
puts "Nothing has changed" if $DEBUG
return @out
end
if line =~ /Files changed:/
puts "Filed changed:" if $DEBUG
return @out
end
if line =~ /Error: (.*)/
raise CompileError.new(line)
end
if line =~ /.+\.swf/
puts "" if $DEBUG
return @out
end
line = ""
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture_error\n begin\n yield\n @error = all_output unless last_exit_status == 0\n rescue => @error\n end\n end",
"def recoverable_error e, msg = \"Error\", bt = []\n puts \"#{msg} at time #{clock}\"\n puts \"From \" + bt[0..2].join(\"\\n \") unless bt.empty\n puts \" ...\" if bt.length > 3\n shell.run\n end",
"def start_listen_errors\n return nil unless @io_err\n\n @thr_err = Thread.new do\n begin\n @io_err.each_line do |str|\n $stderr.print str if @debug\n end\n rescue => e\n @listen_err_err = e\n end\n end\n end",
"def stderr_received(data); end",
"def capture_request_response_cycle_error_info\n capture_request_response_cycle_end_info(capture_error: true)\n end",
"def capture_stderr\n previous_stdout, $stdout = $stdout, StringIO.new\n yield\n $stdout.string\nensure\n $stdout = previous_stdout\nend",
"def each_successful_run\n each_log_line do |(timestamp, rest)|\n if host=parse_last_run(rest)\n yield [timestamp, host]\n end\n end\n end",
"def handle_error(cmd, stderr)\n summary = \"\\rError running \\`#{cmd}\\`\"\n details = readable_curr_time << \"\\n\\n\"\n details << \"**************************************************************\\n\"\n details << \"#{summary}\\n\"\n details << \"**************************************************************\\n\"\n details << stderr << \"\\n\\n\"\n File.open(@err_path, 'a') { |file| file.write(details) }\n summary\nend",
"def error_threshold_timeout; end",
"def handle_error(stdout)\n while (line = stdout.gets)\n puts line\n end\n end",
"def handle_stderr(stream)\n @err_array = []\n # synchronize access to @err_array\n @semaphore = Mutex.new\n Thread.new do\n until (line = stream.gets).nil?\n line.strip!\n @semaphore.synchronize { @err_array << line if line.size > 3 }\n end\n end\n end",
"def error_timeout; end",
"def process_error(exp)\n return exp.shift\n end",
"def count_errors(exec_obj)\n num_errors = 0\n re = Regexp.new '^ERROR.*'\n exec_obj.stdout.split(\"\\n\").each do |line|\n $log.debug line\n\n next unless line.match(re)\n\n $log.debug \"Matching error output: #{line}\"\n\n num_errors += 1\n end\n num_errors\n end",
"def check_for_errors\n return unless @chunks.any? { |chunk| chunk.first[0] == :error }\n errors = @chunks.find_all { |chunk| chunk[0] == :error }\n $stderr.puts \"WARNING: found the following errors: #{errors.map(&last).inspect}\"\n end",
"def last_stderr\n @last_stdout.string if @last_stdout\n end",
"def strip_wait_message(error_message)\n error_message.split(\"\\n\\n\", 2).last\n end",
"def retrieve_last_match_from_stderr(re, nth = 0)\n return unless $stderr.stat.file?\n $stderr.flush\n f = $stderr.dup\n matched = nil\n begin\n f.seek(0)\n f.each do |line|\n m = line.slice(re, nth)\n matched = m if m\n end\n ensure\n f.close\n end\n matched = matched.to_s.strip\n matched.empty? ? nil : matched\n end",
"def error_chunks(text) \n text.split(/^$/).select(){ |block| block =~ /^(\\d+)\\t([^\\t]+)\\t([^\\t]+)\\t(.+)$/ }\nend",
"def record_error_with_less_nodes\n @supervisor.increment_error_count\n\n dashes = '-' * 90\n\n @error = %{#{exception.message}\\n#{exception.backtrace.join(\"\\n\")}\n#{dashes}\\nQUEUE ELEMENT:\\n#{@element.inspect}\n#{dashes}\\nRAW PAYLOAD:\\n#{@response.inspect}\n#{dashes}\\nRAW BODY:\\n#{@response_body.inspect}\n#{dashes}\\nPARSED PAYLOAD:\\n#{@entity.inspect}}\n\n log(\"#{'=' * 90}\\nERROR processing data!#{@error}\")\nend",
"def consume_stderr(text)\n @@log.warn {\"Unexpected line on stderr: '#{text}'. Verify that scripts are not broken.\"}\n end",
"def terminal_parse_failure(r0, terminal)\n stop_index = r0.stop_index\n return nil if @terminal_parse_failures and @terminal_parse_failures[0]>stop_index\n @terminal_parse_failures = [stop_index] if @terminal_parse_failures.nil? or\n @terminal_parse_failures[0]<stop_index\n @terminal_parse_failures << terminal\n nil\n end",
"def replay_at_error (error_source_event)\n\n get_workqueue.push(\n get_expression_pool,\n :do_apply_reply,\n error_source_event[3], # message (:apply for example)\n error_source_event[2], # fei or exp\n error_source_event[4]) # workitem\n\n # 0 is :error and 1 is the date and time of the error\n\n linfo do\n fei = extract_fei(error_source_event[2])\n \"replay_at_error() #{error_source_event[3]} #{fei}\"\n end\n end",
"def replay_at_last_error (wfid)\n\n events = load_events(get_path(wfid))\n\n error_event = events.reverse.find do |evt|\n evt[0] == :error\n end\n\n replay_at_error(error_event)\n end",
"def last_err\n api(\"LastErr\")\n end",
"def trace_errors\n getErrors.each { |e|\n puts \"(#{e.object || ''}): #{e.error}\"\n }\n end",
"def print_error\n parts = @curr_blk.text.split('|')\n out = \"Line #{@curr_line}:\"\n\n case @curr_blk.validity\n when 1\n out += \" Could not parse line '#{@curr_blk.text}.\"\n when 2\n out += \" Invalid block number #{@curr_blk.number}, should be #{@curr_line}.\"\n when 3\n out += \" Could not parse transactions list '#{@curr_blk.text.split('|')[2]}'.\"\n when 4\n out += \" Invalid block, address #{@curr_wallet.address} has #{@curr_wallet.balance} billcoins!\"\n when 5\n out += \" Could not parse timestamp '#{@curr_blk.text.split('|')[3]}'.\"\n when 6\n out += \" Previous timestamp #{@p_s}.#{@p_ns} >= new timestamp #{@curr_blk.seconds}.#{@curr_blk.nseconds}.\"\n when 7\n h_string = @curr_blk.text.chomp('|' + parts[4])\n out += \" String '#{h_string}' hash set to #{parts[4]}, should be #{@curr_hash}.\"\n when 8\n out += \"Previous hash was #{parts[1]}, should be #{@p_h}.\"\n when 9\n out += \" Previous hash was #{parts[1]}, should be 4 characters or less.\" if parts[1].length > 4\n out += \" Block hash was #{parts[4]}, should be 4 characters or less.\" if parts[4].length > 4\n end\n\n puts out\n\n @curr_blk.validity\n end",
"def process_unknown_output(line)\n @@log.warn {\"Unexpected output line on stdout: '#{line}'. Verify that the scripts are not broken.\"}\n end",
"def capture_stdout\n #binding.pry\n stdin, stdout, stderr = Open3.popen3(\"ruby #{@file_path}\")\n error = stderr.readlines \n if error == []\n puts \"PIKABU SEES NO ERRORS IN YOUR SCRIPT\" \n puts \" O> \"\n puts \" |\"\n puts \" OOOO\"\n puts \" ^ ^\"\n puts \" O> \"\n puts \" |\"\n puts \" OOOO\"\n puts \" ^ ^\"\n else\n #binding.pry\n puts \"PIKABU SEES ALL THE ERRORS\"\n if /\\d\\d\\d/=~ error.first\n num = (/\\d\\d\\d/=~ error.first)\n @line_num = error.first[num..num+2].to_i\n elsif /\\d\\d/ =~ error.first\n num = (/\\d\\d/=~ error.first)\n @line_num = error.first[num..num+1].to_i\n\n elsif /\\d/=~ error.first\n num = (/\\d/=~ error.first)\n @line_num = error.first[num].to_i\n else \n puts \"oops what's going on\"\n end\n #ADD SOPHISTICATED EMOJIS\n end\n puts \"PIKABU SEES YOUR ERROR ON LINE #{@line_num}\"\n peek \n end",
"def error_line(logs)\n logs.select { |line| line.downcase =~ /.*error.*/ }\nend",
"def on_error(error)\n STDOUT << \"on_error\" << \"\\n\"\n \" error \" << error << \"\\n\"\n STDOUT.flush\n end",
"def last_stdout\n strip_duration(@last_stdout)\n end",
"def re_stderr\n @logdev.re_stderr\n self\n end",
"def on_stream_error(message)\n puts \"error: #{message}\\n\"\n end",
"def timeout_safe # :block\n error_n = 0\n begin\n $stderr.puts(\" try get same page again...\") if error_n > 0\n yield\n rescue Errno::EBADF, Timeout::Error\n error_n += 1\n error_name = $!.class.to_s\n if error_n >= 3\n $stderr.puts \"#{error_name} ERROR #3\"\n raise $!\n end\n sleep_for = error_n * 5\n $stderr.puts \"#{error_name} ERROR ##{error_n}, sleep #{sleep_for} seconds before next attempt\"\n sleep sleep_for\n retry\n end\nend",
"def error_time\n @@state[@server] && @@state[@server][:time]\n end",
"def report error_event\n async_start\n\n synchronize do\n @queue.push error_event\n @queue_resource.broadcast\n\n retries = 0\n while @max_queue_size && @queue.size > @max_queue_size\n retries += 1\n @queue_resource.wait 1\n\n # Drop early queue entries when have waited long enough.\n @queue.pop while @queue.size > @max_queue_size && retries > 3\n end\n end\n end",
"def get_errors\n return nil unless has_errors?\n return filter_low_priority_errors(@stderr)\n end",
"def do_error_command(name, file) \n output, result = compile_file(name)\n errors = parse_output(output)\n saved = []\n ln = 1 # first line is already parsed, start loop at 2\n file.each do |line| \n ln = ln + 1\n match = line.match(/(\\/\\/+).*ERROR(.*)/)\n unless !match.nil? && match[1].length == 2 \n\t\t\tunless errors[ln].nil?\n\t\t\t\terrors[ln].each do |err|\n\t\t\t\t\tsaved << [err, \"\"]\n\t\t\t\tend\n\t\t\tend\n next\n end\n\n regex = \"#{name}:#{ln}:.+:.*#{match[2].strip}\"\n regelse = \"#{name}:#{ln}:.+:.*\"\n\n\t\tif errors[ln].nil? \n\t\t\tsaved << [\"\", regex]\n\t\t\tnext\n\t\tend\n\n errors[ln].each do |err|\n omatch = output.match(regex)\n unless omatch.nil? \n next\n\t\t\tend\n\t\t\tsaved << [err, regex]\n end\n\tend\n\n if saved.length > 0 \n puts \"----------------------------------------------------------------------\"\n puts \"BUG: %s unmatched errors \" % name\n puts \"----------------------------------------------------------------------\"\n saved.each do |error|\n puts \"#{error[0]} -- #{error[1]}\"\n end\n puts \"----------------------------------------------------------------------\"\n exit 1\n end\nend",
"def error_message_and_leave(e)\n # consider a loading bar or spinner here\n\n sleep 1\n puts \"\\nOk so in technical terms, this is the issue :\\n\\n\"\n\n error_msg = e.to_s.chars\n\n error_msg.each do |i|\n print Rainbow(i).red\n sleep 0.05\n end\n\n puts \"\\n\\n\"\n\n final_message = 'So...... Anyways....... Please restart program and try creating a new profile '.chars\n final_message.each_with_index do |character, index|\n sleep 0.8 if (index == 8) || (index == 23) || (index == final_message.length - 1)\n sleep 0.04\n print Rainbow(character).yellow\n end\n\n exit #exit the program if issues with reading file \n\n end",
"def detect_failure\n time = Time.now\n server = server_structs.detect do |server|\n server.next_retry > time\n end\n inspect_server(server) if server\n end",
"def fr_error input\n if @calling_command.nil? then\n $stderr.puts input\n else\n @calling_command.stderr = \"#{calling_command.stderr}#{input}\\n\"\n @calling_command.save\n end\n end",
"def capture\n stats = Quickie::Runner.class_variable_get(:@@stats)\n trace = Quickie::Runner.class_variable_get(:@@trace)\n\n standard, $stdout = $stdout, StringIO.new\n yield\n $stdout.string\nensure\n if $stdout.string == '.'\n stats[:success] -= 1\n else\n stats[:failure] -= 1\n trace.pop\n end\n $stdout = standard\nend",
"def parse_failure_message(output)\n output_message = \"\"\n output.each { |message| output_message += message.text + \"\\n\"}\n return output_message.rstrip # strip off trailing end line character.\n end",
"def error(process_variable)\n e = process_variable - @set_point\n now = Time.now\n if @last_time\n dt = now - @last_time\n dt = Float::MIN if dt == 0\n else\n dt = 1.0\n end\n @last_time = now\n [e, dt]\n end",
"def capture_stderr(&block)\n old = $stderr\n $stderr = fake = StringIO.new\n yield\n fake.string\n ensure\n $stderr = old\n end",
"def show_exit_error\n @end_time = Time.now\n puts TTY::Box.error(\n \"Flow : #{self.class.name}\\n\" \\\n \"Start : #{@start_time}\\n\" \\\n \"End : #{@end_time}\\n\" \\\n \"Time : #{@end_time - @start_time} sec\",\n width: TTY::Screen.width, padding: 1\n )\n end",
"def error(rc)\n return rc[0].strip if rc[2].success?\n\n puts \"ERROR: #{rc[1]}\"\n\n exit(-1)\nend",
"def add_terminal_error(error, counter)\n if counter\n @terminal_error = I18n.t(\"bulk_import.error.stopped\", row: counter, msg: error)\n else\n @terminal_error = I18n.t(\"bulk_import.error.initialize\", msg: error)\n end\n end_row\n end",
"def receive_line line\n send_through_dataflow(line)\n rescue => e\n error = Wukong::Error.new(e)\n # EM.stop\n \n # We'd like to *raise* `error` here and have it be handled by\n # Wukong::Runner.run but we are fighting with EventMachine.run\n # which executes in the middle.\n #\n # It seems no matter what we do, EventMachine.run will swallow\n # any Exception raised here (including SystemExit) and exit\n # the Ruby process with a return code of 0.\n #\n # Instead we just log the message that *would* have gotten\n # logged by Wukong::Runner.run and leave it to EventMachine to\n # exit very unnaturally.\n log.error(error.message)\n end",
"def event_exception(error_str)\n unless error_str.to_s.include?('Connection reset by peer') or\n error_str.to_s.include?('Connection timed out')\n event_log \"Exception: #{error_str}\"\n end\nend",
"def get_redshift_error\n sql = <<-RE.squish\n SELECT filename, line_number, colname, type, raw_field_value, raw_line, err_reason\n FROM STL_LOAD_ERRORS\n WHERE filename like '%#{import_file}%'\n ORDER BY starttime desc\n LIMIT 1\n RE\n result = ::RailsRedshiftReplicator.connection.exec(sql).entries\n error = result.first.map{ |k, v| [k, v.strip].join('=>') }.join(\";\")\n replication.update_attribute :last_error, error\n end",
"def check_unconsumed\n return if chunks.empty?\n $stderr.puts \"WARNING: line not consumed: #{@chunks}; (line: '#{@line}')\"\n end",
"def error_threshold; end",
"def last_error\n @error.respond_to?(:message) ? @error.message : @error\n end",
"def error(message)\n Kernel.puts \" !\"\n message.split(\"\\n\").each do |line|\n Kernel.puts \" ! #{line.strip}\"\n end\n Kernel.puts \" !\"\n exit 1\nend",
"def error\n @last_error && @last_error.error\n end",
"def previous_error\n error = command(:getpreverror => 1)\n error[\"err\"] ? error : nil\n end",
"def on_error(error)\n @result << \"error: #{error}\"\n end",
"def error(delayed_job, exception)\n STDERR.putc 'E'\n STDERR.flush\n end",
"def errored\n @errored ||= count('errored')\n end",
"def validate_error(error, request_id=nil)\n error_pattern_string = %r(Error occurred for outgoing request \\(requestId='(?<error_id>[-a-zA-Z0-9]+)', \\d+.\\d* ms\\))\n expect(error[0]).to match(error_pattern_string)\n error[0] =~ error_pattern_string # match to capture id\n error_id = $1\n expect(error_id).to eq(request_id) unless request_id.nil?\nend",
"def capture_io\n err = nil\n out = capture_out do\n err = capture_err do\n yield\n end\n end\n\n [out, err]\nend",
"def stderr(command, data)\n # called when the process writes to STDERR\n end",
"def capture_with_status(*args)\n _print_command(*args)\n args.last.delete :errexit if args.last.is_a? Hash\n args.last.delete :xtrace if args.last.is_a? Hash\n stdout, status = Open3.capture2(*args)\n return stdout.chomp, status\nend",
"def format_compile_error(file_name, file_path, reason,\n line, cursor); EMPTY; end",
"def reader_thread_proc\n begin\n File::Tail::Logfile.tail(@path, :backward => 10) do |line|\n begin\n parse_logline(line)\n rescue Exception => e\n puts \"Malformed log line [#{line}]: #{e}\"\n end\n end\n rescue Exception => e \n puts \"LogReader is dead: #{e}\"\n end\n end",
"def manage_errors event, client\n\n puts \"Error Counter #{ @@error_counter }\"\n \n @@error_counter += 1\n\n if @@error_counter > 5\n client.chat_postMessage(channel: event.channel, text: \"This is really fishy now. Why are you doing this? :unamused: Please be nice or type `help` to find my commands.\", as_user: true)\n elsif @@error_counter > 2 and @@error_counter <= 4\n client.chat_postMessage(channel: event.channel, text: \"Hmmm, you seem to be different today :thinking_face:. Hope all is well. Anyways, type `help` to find my commands.\", as_user: true) \n else\n client.chat_postMessage(channel: event.channel, text: \"I didn't get that but that's alright. If you're stuck, type `help` to find my commands.\", as_user: true)\n end\n end",
"def handle_errors(output)\n if $? != 0\n puts output\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n puts \"~ FATAL: Command failed with status #{$?}\"\n exit 1\n end\nend",
"def report_error(error, out: $output)\n out.puts\n out.puts \"Error: #{error}.\"\nend",
"def report_error(error, out: $output)\n out.puts\n out.puts \"Error: #{error}.\"\nend",
"def report_error(error, out: $output)\n out.puts\n out.puts \"Error: #{error}.\"\nend",
"def process_output command\n @warnings = [] # Keep global so we can show the warnings with the swf\n errors = []\n\n stdin, stdout, stderr = Open3.popen3(command)\n\n while msg = stderr.gets do\n message = /(.+)\\(([0-9]+)\\): col: ([0-9]+) (Error|Warning): (.*)/.match(msg)\n\n if message then\n array = case message[4]\n when \"Warning\" then @warnings\n when \"Error\" then errors\n end\n\n array.push(message)\n end\n\n 4.times {stderr.gets}\n end\n\n unless errors.empty? then\n puts html_head(:window_title => \"ActionScript 3 — Errors\", :page_title => \"Errors for #{@document_class}\")\n puts \"#{@command}\\n\\n<br />\"\n print_message_list errors\n html_footer\n TextMate.exit_show_html\n\n false # Code shouldn't get here\n else\n true\n end\nend",
"def replay_at_error (error)\n\n get_error_journal.replay_at_error(error)\n end",
"def command_output_each_line(command, options)\n Open3::popen3(command, options) do |_, stdout, stderr, wait_thread|\n loop do\n check_output_with_timeout(stdout)\n\n begin\n yield stdout.readline\n rescue EOFError\n break\n end\n end\n status = wait_thread.value.exitstatus\n if status > 0\n message = \"Bot <#{command}> exited with status #{status}: #{stderr.read}\"\n raise RuntimeError.new(message)\n end\n end\nend",
"def terminal_parse_failure(expected_string)\n return nil if index < max_terminal_failure_index\n if index > max_terminal_failure_index\n @max_terminal_failure_index = index\n @terminal_failures = []\n end\n terminal_failures << TerminalParseFailure.new(index, expected_string)\n return nil\n end",
"def error job, exception\n if tracetop = exception.backtrace&.first\n # Extract the file and line # from the stack top\n tracetop = \" at<br>\" + tracetop.match(/(.*:[\\d]*)/).to_s.if_present || tracetop\n tracetop.sub! Rails.root.to_s+'/', ''\n end\n errors.add :base, exception.to_s+tracetop\n self.status = :bad if processing? # ...thus allowing others to set the status\n end",
"def on_subshell_error(&block)\n @subshell_error_block = block\n end",
"def send_error\n send_text funny_responses.sample\n end",
"def util_capture\r\n require 'stringio'\r\n orig_stdout = $stdout.dup\r\n orig_stderr = $stderr.dup\r\n captured_stdout = StringIO.new\r\n captured_stderr = StringIO.new\r\n $stdout = captured_stdout\r\n $stderr = captured_stderr\r\n yield\r\n captured_stdout.rewind\r\n captured_stderr.rewind\r\n return captured_stdout.string, captured_stderr.string\r\n ensure\r\n $stdout = orig_stdout\r\n $stderr = orig_stderr\r\n end",
"def trythreetimes\n tries = 0\n begin\n yield\n rescue Exception => e \n tries += 1\n logger \"Error: #{e.message}\"\n if tries < 3\n logger \"Waiting 5 seconds and trying again...\"\n sleep(5)\n retry\n end\n logger \"Giving up and ending program!\"\n abort\n end\nend",
"def dump_failures(*args)\n lock_output do\n super\n end\n @output.flush\n end",
"def get_last_error()\n return @last_error\n end",
"def write_error_info\n end",
"def reset_last_error\n @last_error = nil\n @last_error_code = nil\n end",
"def execute_error(send, line)\n # Send the exit command if that hasn't already happened\n if not @exit_sent\n send.call([{:exit => {:successful => false}}])\n @exit_sent = true\n end\n\n # Output the error line\n return error_line(line)\n end",
"def streams_after(out_,err_)\n $stdout = out_\n $stderr = err_\nend",
"def capture_output\n begin\n require 'stringio'\n $o_stdout, $o_stderr = $stdout, $stderr\n $stdout, $stderr = StringIO.new, StringIO.new\n yield\n {:stdout => $stdout.string, :stderr => $stderr.string}\n ensure\n $stdout, $stderr = $o_stdout, $o_stderr\n end\nend",
"def err(input)\n puts \"[#{Time.now.strftime(\"%T\").purple} \" + \"ERROR\".red + \"] \" + \"#{input.red}\"\n end",
"def on_error reason\n puts reason\n close\n end",
"def stderr\n run unless ran?\n\n @stderr\n end",
"def run_failed; end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def error_thread_crash error, error_location; end",
"def err *args, **kwds, &input_block\n capture(*args, **kwds, &input_block).err\n end",
"def check_and_log_running_timeout\n if benchmark_active? && !events.last.failed?\n events.create_with_name!(:failed_on_running, 'Running timeout elapsed.')\n end\n end",
"def get_ssh_stderr( index = 1 )\n index.is_a?(Fixnum) and index > 0 ? self.ssh_stderr[-index] : self.ssh_stderr[index]\n end"
] | [
"0.6697931",
"0.62562585",
"0.6221313",
"0.6126352",
"0.6086054",
"0.58403146",
"0.5776747",
"0.5739993",
"0.5723699",
"0.5719512",
"0.5719336",
"0.57189155",
"0.57005",
"0.56867373",
"0.56538385",
"0.5606686",
"0.5600694",
"0.5589313",
"0.5583187",
"0.55641943",
"0.5559698",
"0.5558781",
"0.5549039",
"0.5525181",
"0.5520611",
"0.5517187",
"0.55137867",
"0.5498991",
"0.5496759",
"0.54832065",
"0.54824734",
"0.54768026",
"0.5454421",
"0.543259",
"0.54313236",
"0.54176533",
"0.5414226",
"0.5412568",
"0.5397769",
"0.5379926",
"0.5357607",
"0.5349461",
"0.5344123",
"0.53043133",
"0.52926975",
"0.52870065",
"0.52845967",
"0.527279",
"0.5265828",
"0.5262161",
"0.52549314",
"0.5254487",
"0.5228268",
"0.5220701",
"0.52115065",
"0.52085453",
"0.52030635",
"0.5182662",
"0.51751673",
"0.5146206",
"0.5140893",
"0.51382476",
"0.513644",
"0.51294404",
"0.5121892",
"0.510794",
"0.51070666",
"0.50968915",
"0.5093576",
"0.5092115",
"0.5092115",
"0.5092115",
"0.50773084",
"0.5076108",
"0.5074571",
"0.50652474",
"0.50648737",
"0.5061993",
"0.5059825",
"0.505781",
"0.5051758",
"0.5051428",
"0.5047189",
"0.5044343",
"0.5035739",
"0.5026399",
"0.5025472",
"0.50253963",
"0.50228626",
"0.50227505",
"0.5022318",
"0.50122327",
"0.50030863",
"0.50030863",
"0.50030863",
"0.50030863",
"0.50016075",
"0.4997317",
"0.499512",
"0.4993339"
] | 0.70106184 | 0 |
Wait on stdout for pattern | def wait_for_on_stdout(pattern)
out = ''
# read everything in out and stop when pattern is matched
{} while !((out << @stdout.read(1)) =~ pattern)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for(pattern)\n $_api_exec_state = :wait_for\n if pattern.is_a?(Array)\n pattern = Regexp.new(pattern.join('|'))\n end\n\n (0..1000000).each do\n line = API::sync_read\n if line and line.match(pattern)\n $_api_exec_state = :none\n return\n end\n sleep 0.01\n end\nend",
"def wait_for_output(which, regexp, opts = {})\n _get_log(which).wait_for_output(regexp, opts)\n end",
"def wait_until( desc, freq = 1.0 )\n $stdout.write( \"Waiting for \" + desc )\n until (ret = yield) do\n $stdout.write '.'\n sleep freq\n end\n ret\n ensure\n puts\n end",
"def waitForReplySearch(pattern)\r\n while true\r\n servermsg = $oculussock.gets.strip\r\n puts servermsg\r\n if servermsg =~ pattern then break end\r\n\tend\r\n return servermsg\r\nend",
"def check_match(pattern)\n match = nil\n @thread = Thread.current\n while match.nil?\n @out_mutex.synchronize do\n match = pattern.match(@buffer)\n if match.nil?\n raise Timeout::Error if @pid.zero?\n @out_mutex.sleep\n end\n end\n end\n match\n ensure\n @thread = nil\n end",
"def wait_for(id, pattern)\n response = [ ]\n loop do\n begin\n x = @responses[id].pop\n print @responses[:error].pop\n rescue\n sleep(2)\n end\n unless x.nil?\n if x[:head] =~ pattern\n response << x\n x.each { |key, value| puts \"#{key}=#{value}\" }\n break\n elsif x[:head] =~ /ProtocolError/\n response << x\n x.each { |key, value| puts \"#{key}=#{value}\" }\n break\n else\n response << x\n x.each { |key, value| puts \"#{key}=#{value}\" }\n end\n else\n sleep(1)\n end\n end\n response\n end",
"def wait_for_text(pattern, options={})\n builder = JavascriptExpressionBuilder.new\n\t\t builder.find_text(pattern, options).append(\"text_match == true;\")\n wait_for_condition builder.script, options[:timeout_in_seconds]\n end",
"def scan_until(pattern)\n do_scan pattern, true, true, false\n end",
"def wait(timeout: nil)\n\t\t\t\tif timeout\n\t\t\t\t\tread_ready, _, _ = IO.select([@output], [], [], timeout)\n\t\t\t\t\t\n\t\t\t\t\treturn false unless read_ready and read_ready.any?\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@signalled or @output.read(1)\n\t\t\t\t\n\t\t\t\t# Just in case that this was split across multiple processes.\n\t\t\t\t@signalled = true\n\t\t\tend",
"def scan_until(pattern); end",
"def wait_for_server_to_match(re, idx = nil, log: false)\n sleep 0.05 until @server.is_a?(IO)\n retry_cntr = 0\n line = nil\n begin\n @server.wait_readable 1\n if log\n puts \"Waiting for '#{re.inspect}'\"\n begin\n line = @server&.gets\n puts line if !line&.strip.empty?\n end until line&.match?(re)\n else\n true until (line = @server.gets || '').match?(re)\n end\n rescue Errno::EBADF, Errno::ECONNREFUSED, Errno::ECONNRESET, IOError => e\n retry_cntr += 1\n raise e if retry_cntr > 10\n sleep 0.1\n retry\n end\n idx ? line[re, idx] : line\n end",
"def wait_for_cmd_or_ack(cmd_or_ack)\n log \"Waiting for #{cmd_or_ack}\"\n loop do\n last_line = last_chat_line\n return get_info(last_line, cmd_or_ack) if last_line.include?(cmd_or_ack)\n sleep 1\n end\n end",
"def wait_until_done\n return if !running?\n send_eof\n\n # TODO: handle case where command doesn't exit.\n start = Time.now\n @standard_output.read_until_eof(timeout)\n @standard_error.read_until_eof(timeout - (Time.now - start))\n pid, @status = Process::waitpid2(@pid)\n @pid = nil\n end",
"def stdout_received(data); end",
"def wait_for(pattern)\n ProtonBot::EventLock.new(self, pattern)\n self\n end",
"def check_until(pattern)\n _scan(pattern, false, true)\n end",
"def run_and_watch_prompt(cmd, regex_to_watch)\n run cmd, :pty => true do |ch, stream, data|\n watch_prompt(ch, stream, data, regex_to_watch)\n end\nend",
"def scan_until(pattern)\n _scan(pattern, true, true)\n end",
"def wait_for_pending_sends\n send_pending\n while output.length > 0\n result = IO.select(nil, [self]) or next\n next unless result[1].any?\n\n send_pending\n end\n end",
"def wait(str='Press ENTER to continue.')\n puts\n self.warning(str)\n STDIN.gets\n end",
"def stdout_should_include(*patterns)\n patterns.each do |pattern|\n re = Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern))\n @stdout.should_receive(:puts).with(re).at_least(:once)\n end\nend",
"def wait_until(msg = nil)\n if block_given?\n msg_thread, work_thread = nil, nil\n \n # prints incremental '...' message while waiting for the given block to finish successfully\n if msg\n print \"#{msg.to_s}...\"\n msg_thread = Thread.new do\n loop do\n print \".\"\n $stdout.flush\n sleep 1\n end\n end\n end\n \n # repeatedly yields to the given block until it returns true\n work_thread = Thread.new do\n result = false\n until result\n result = yield\n sleep 1\n end\n end\n \n work_thread.join if work_thread\n msg_thread.kill if msg_thread\n \n print \"\\n\" if msg\n end\n end",
"def waiting actual\n interval = 0.5\n i = 0\n while true\n if actual == yield\n return 'true!!'\n end\n i += interval\n puts '.'\n sleep i\n end\n 'false!!'\nend",
"def monitor_for(options = {})\n # Loop and wait till event is detected.\n lcnt = 0\n scount = 0\n while true\n while line = @rchan.gets\n if yield(line, lcnt)\n return true\n end\n lcnt += 1\n end\n sleep 1\n if fptimer = options[:filepos]\n scount += 1\n if scount >= fptimer\n send \"get\"\n scount = 0\n end\n end\n end\n false\n end",
"def wait_for_log_matches(regexp, expected_matches, timeout=120, args={})\n matches = vespa.logserver.log_matches(regexp, args)\n endtime = Time.now.to_i + timeout.to_i\n while (Time.now.to_i < endtime) && (matches < expected_matches)\n sleep 1\n matches = vespa.logserver.log_matches(regexp, args)\n end\n\n assert_equal(expected_matches, matches, \"Expected #{regexp} to produce #{expected_matches} matches in the vespa log, but produced #{matches} matches\")\n return matches\n end",
"def wait\n execute_tmux_with('list-panes -F #{pane_pid}' + \" -t #{name}\", true)\n pid = last_stdout.strip\n return if pid.empty?\n\n loop do\n exec_wait_check_cmd(pid)\n children = last_stdout\n break if children.empty?\n end\n end",
"def stdout_should_receive(*messages)\n messages.each do |message|\n @stdout.should_receive(:puts).with(message).once.ordered\n end\nend",
"def waitfor(options) # :yield: recvdata\n time_out = @options[\"Timeout\"]\n waittime = @options[\"Waittime\"]\n fail_eof = @options[\"FailEOF\"]\n\n if options.kind_of?(Hash)\n prompt = if options.has_key?(\"Match\")\n options[\"Match\"]\n elsif options.has_key?(\"Prompt\")\n options[\"Prompt\"]\n elsif options.has_key?(\"String\")\n Regexp.new( Regexp.quote(options[\"String\"]) )\n end\n time_out = options[\"Timeout\"] if options.has_key?(\"Timeout\")\n waittime = options[\"Waittime\"] if options.has_key?(\"Waittime\")\n fail_eof = options[\"FailEOF\"] if options.has_key?(\"FailEOF\")\n else\n prompt = options\n end\n\n if time_out == false\n time_out = nil\n end\n\n line = ''\n buf = ''\n rest = ''\n sock = @ssh.transport.socket\n\n times_out1 = 10 # timeout 1s\n until prompt === line and @buf == \"\" and (@eof or (not sock.closed? and not IO::select([sock], nil, nil, waittime || 60)))\n break if (times_out1 -= 1) <= 0\n\n times_out2 = 10 # timeout 1s\n while @buf == \"\" and !@eof\n break if (times_out2 -= 1) <= 0\n \n # timeout is covered by net-ssh\n begin\n @channel.connection.process(0.1)\n rescue IOError\n @eof = true\n end\n end\n if @buf != \"\"\n c = @buf; @buf = \"\"\n @dumplog.log_dump('<', c) if @options.has_key?(\"Dump_log\")\n buf = rest + c\n rest = ''\n unless @options[\"Binmode\"]\n if pt = buf.rindex(/\\r\\z/no)\n buf = buf[0 ... pt]\n rest = buf[pt .. -1]\n end\n buf.gsub!(/#{EOL}/no, \"\\n\")\n end\n @log.print(buf) if @options.has_key?(\"Output_log\")\n line += buf\n yield buf if block_given?\n elsif @eof # End of file reached\n break if prompt === line\n raise EOFError if fail_eof\n if line == ''\n line = nil\n yield nil if block_given?\n end\n break\n end\n end\n line\n end",
"def wait(seq)\n nseq = nil\n while not nseq\n nseq,data = read_data(seq)\n select\n end\n end",
"def wait_until(msg, timeout_at, sleep_time = 10, options = {})\n logger = options.fetch(:logger, nil)\n\n done = block_given? ? yield : false\n\n while Time.now.to_i < timeout_at && !done do\n done = block_given? ? yield : false\n\n unless done\n logger ? logger.info(msg) : puts(msg)\n sleep(sleep_time)\n end\n end\n\n done\n end",
"def print_results_forever(wait_between_print=5)\r\n while(1) do\r\n print_results\r\n sleep wait_between_print\r\n end\r\n end",
"def waitForR(rpipe)\n rpipe.puts %{cat(\"\\\\n\")}\n rpipe.gets\n end",
"def wait_for_atleast_log_matches(regexp, expected_matches, timeout=120, args={})\n matches = vespa.logserver.log_matches(regexp, args)\n endtime = Time.now.to_i + timeout.to_i\n while (Time.now.to_i < endtime) && (matches < expected_matches)\n sleep 1\n matches = vespa.logserver.log_matches(regexp, args)\n end\n\n assert(matches >= expected_matches, \"Expected #{regexp} to produce at least #{expected_matches} matches in the vespa log, but produced #{matches} matches\")\n return matches\n end",
"def analysis_succeeded(stdout)\n while (line = stdout.gets)\n puts line\n end\n end",
"def awaiter(args = {})\n args[:smcup] && tput_smcup\n thr = if args[:msg]\n Thread.new do\n (1..4).cycle.each do |i|\n print \"\\r\"\n print \"#{FMT.cur_dt} \" if args[:time]\n print \"#{args[:msg].red}\\b#{SPIN[i % 4].red}\"\n sleep 1\n end\n end\n end\n yield\n ensure\n thr && thr.kill\n puts if args[:newline]\n end",
"def wait\n loop do sleep 1 end\n end",
"def command_output_each_line(command, options)\n Open3::popen3(command, options) do |_, stdout, stderr, wait_thread|\n loop do\n check_output_with_timeout(stdout)\n\n begin\n yield stdout.readline\n rescue EOFError\n break\n end\n end\n status = wait_thread.value.exitstatus\n if status > 0\n message = \"Bot <#{command}> exited with status #{status}: #{stderr.read}\"\n raise RuntimeError.new(message)\n end\n end\nend",
"def wait(*msg, &block)\n log(:info, *msg, &block)\n end",
"def consume_pattern(pattern)\n m = @stream.match pattern\n return if m.nil?\n\n debug \"Consuming n=#{m.end(0)} chars after matching #{m[0]} from #{@stream}...\", :verbose\n consume m.end(0)\n m[0]\n end",
"def wait; end",
"def wait; end",
"def wait; end",
"def read_until(pattern)\n\t\t\t\tindex = @read_buffer.index(pattern)\n\t\t\t\t\n\t\t\t\tuntil index\n\t\t\t\t\toffset = @read_buffer.size\n\n\t\t\t\t\tfill_read_buffer\n\t\t\t\t\t\n\t\t\t\t\treturn if @eof\n\n\t\t\t\t\tindex = @read_buffer.index(pattern, offset)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tmatched = @read_buffer.slice!(0, index)\n\t\t\t\t@read_buffer.slice!(0, pattern.bytesize)\n\t\t\t\t\n\t\t\t\treturn matched\n\t\t\tend",
"def wait_for_no_text(pattern, options={})\n builder = JavascriptExpressionBuilder.new\n\t\t builder.find_text(pattern, options).append(\"text_match == false;\")\n wait_for_condition builder.script, options[:timeout_in_seconds]\n end",
"def watch_prompt(ch, stream, data, regex_to_watch)\n\n # the regex can be an array or a single regex -> we force it to always be an array with [*xx]\n if [*regex_to_watch].find { |regex| data =~ regex}\n # prompt, and then send the response to the remote process\n ch.send_data(Capistrano::CLI.password_prompt(data) + \"\\n\")\n else\n # use the default handler for all other text\n Capistrano::Configuration.default_io_proc.call(ch, stream, data)\n end\nend",
"def wait_until(cycle)\n until yield\n\t sleep(cycle)\n\tend\n end",
"def wait_for_message\n listen_for_messages\n loop { publish_message(@current_user, gets.strip) }\n end",
"def scan_next(pattern)\n return unless @s.scan_until(pattern)\n @s.matched\n end",
"def wait_for_message\n loop do\n message = gets.strip\n publish_message(@current_user, message)\n end\n end",
"def wait_for_server_to_include(str, log: false)\n sleep 0.05 until @server.is_a?(IO)\n retry_cntr = 0\n begin\n @server.wait_readable 1\n if log\n puts \"Waiting for '#{str}'\"\n begin\n line = @server&.gets\n puts line if !line&.strip.empty?\n end until line&.include?(str)\n else\n true until (@server.gets || '').include?(str)\n end\n rescue Errno::EBADF, Errno::ECONNREFUSED, Errno::ECONNRESET, IOError => e\n retry_cntr += 1\n raise e if retry_cntr > 10\n sleep 0.1\n retry\n end\n true\n end",
"def wait!\n wait\n raise @error if timeout?\n @messages\n end",
"def wait_while\n while yield\n\twait\n end\n end",
"def wait_while\n while yield\n wait\n end\n end",
"def sync_wait\n if IO.select([sync_read], nil, nil, 20).nil?\n # timeout reading from the sync pipe.\n send_side_channel_error(\"Error syncing processes in run lock test (timeout)\")\n exit!(1)\n else\n sync_read.getc\n end\n end",
"def capture_output(&block)\n stdout = STDOUT.clone\n\n read_io, write_io = IO.pipe\n read_io.sync = true\n\n output = \"\"\n reader = Thread.new do\n begin\n loop do\n output << read_io.readpartial(1024)\n end\n rescue EOFError\n end\n end\n\n STDOUT.reopen(write_io)\n block.call\nensure\n STDOUT.reopen(stdout)\n write_io.close\n reader.join\n\n return output\nend",
"def admiral_sleep(sec)\n IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return\n SELF_PIPE[0].kgio_tryread(11)\n end",
"def wait(term=nil)\n\t\tbuffer = []\n\t\tlog_incr \"Waiting for response\"\n\t\t\n\t\twhile true do\n\t\t\tbuf = read(term)\n\t\t\tbuffer.push(buf)\n\t\t\t\n\t\t\t# some errors contain useful error codes,\n\t\t\t# so raise a proper error with a description\n\t\t\tif m = buf.match(/^\\+(CM[ES]) ERROR: (\\d+)$/)\n\t\t\t\tlog_then_decr \"!! Raising Gsm::Error #{$1} #{$2}\"\n\t\t\t\traise Error.new(*m.captures)\n\t\t\tend\n\t\t\n\t\t\t# some errors are not so useful :|\n\t\t\tif buf == \"ERROR\"\n\t\t\t\tlog_then_decr \"!! Raising Gsm::Error\"\n\t\t\t\traise Error\n\t\t\tend\n\t\t\n\t\t\t# most commands return OK upon success, except\n\t\t\t# for those which prompt for more data (CMGS)\n\t\t\tif (buf==\"OK\") or (buf==\">\")\n\t\t\t\tlog_decr \"=#{buffer.inspect}\"\n\t\t\t\treturn buffer\n\t\t\tend\n\t\t\n\t\t\t# some commands DO NOT respond with OK,\n\t\t\t# even when they're successful, so check\n\t\t\t# for those exceptions manually\n\t\t\tif m = buf.match(/^\\+CPIN: (.+)$/)\n\t\t\t\tlog_decr \"=#{buffer.inspect}\"\n\t\t\t\treturn buffer\n\t\t\tend\n\t\tend\n\tend",
"def wait_while\n while yield\n wait\n end\n end",
"def after_resolution\n output.puts\n end",
"def wait\n Kernel.sleep self.interval until check_files\n end",
"def wait_done\n sleep 0.01 until done?\n end",
"def require_stdout_count(count, max_sleep=10)\n @stdout_handler.require_read_count count, max_sleep\n end",
"def wait(arg0)\n end",
"def wait_while(cycle)\n while yield\n sleep(cycle)\n end\n end",
"def wait\n @t.each{|t| t.join}\n end",
"def spawn_and_wait(instance)\n instance.register\n\n 20.times do\n instance.send(:connection_open?) ? break : sleep(0.1)\n end\n\n # Extra time to make sure the output can attach\n sleep 1\n end",
"def sudo_and_watch_prompt(cmd, regex_to_watch)\n sudo cmd, :pty => true do |ch, stream, data|\n watch_prompt(ch, stream, data, regex_to_watch)\n end\nend",
"def sync( timeout = TIMEOUT, &proc)\n while true do\n line = timed_readline(timeout)\n Puppet.debug \"#{line}\"\n break if line =~ SUCCESS_SYNC_STRING\n fail 'command in deamon failed.' if line =~ FAILED_SYNC_STRING\n proc.call(line) if proc\n end\n end",
"def brute_wait(delay)\n sleep(delay)\n end",
"def text_when_done(num, cmd, cntcs) #third argument may be unecessary. not familiar with ruby scope\n\n\tcontacts = cntcs #probably...maybe uneccesary?\n\tsent = false\n\n\trun = `#{cmd}` #really dangerous! I need to find a better way!\n\n\twhile(!sent)\n\t\tsleep 60\n\t\tif (`ps cax | pgrep -i #{cmd}`.nil?)\n\t\t\tip = `dig +short myip.opendns.com @resolver1.opendns.com`.strip()\n\t\t\thost = `hostname`.strip()\n\t\t\tdate = `date +\"%d-%m-%Y %H:%M %Z\"`.strip()\n\t\t\tuser = `echo $USER`.strip()\n\t\t\tphone_index = contacts['phone_numbers'].values.index(num)\n\t\t\tphone = contacts['phone_numbers'].values[contacts[phone_index]]\n\t\t\treceiver = contacts['phone_numbers'].key(phone) \n\t\t\tmessage = \"Hey #{receiver}, the process #{cmd} has finished running on #{host} at #{date}.\\nThis process was run by #{user} from IP address #{ip}.\"\n\n\t\t\t#commence sending message\n\t\t\tsend_req = `curl -X POST http://textbelt.com/text -d number=#{num} -d \"message=#{message}`\n \t\tbody = JSON.parse(send_req.body)\n \t\tbody['success'.freeze]\n\t\tend\n\tend\nend",
"def wait\n while source\n saved_source = source\n saved_source.wait\n break if saved_source.equal?(source)\n end\n end",
"def printRed(tempoDormir,n,proximoSinal,mutexAtual,cv)\n mutexAtual.synchronize do\n n.times do\n # cv.signal\n sleep(tempoDormir)\n \n print(\"Vermelho !!! dormi por #{tempoDormir} segundos....\\n\")\n # cv.wait(mutexAtual)\n cv.signal\n cv.wait(mutexAtual)\n \n \n \n end\n end\n \nend",
"def cmd_list pattern = '.'\n puts \"Following mnemo's #{pattern && \"matching regexp /#{pattern}/\"} are present\"\n puts\n references_by_pattern(pattern).each do |reference|\n puts (\" \" * 4) + reference\n end\n\n puts\n puts \"Done ..\"\n end",
"def master_sleep(sec)\n IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return\n SELF_PIPE[0].kgio_tryread(11)\n end",
"def wait\n true\n end",
"def new_reader\n Thread.new do\n while line = @pipe.gets\n # The output strings must not contain \"\\n\".\n line.chomp!\n case line\n when BEGIN_MARKER\n @inside_output = true\n $stderr.puts 'Found the begin marker.' if $DEBUG\n when END_MARKER\n @inside_output = false\n $stderr.puts 'Found the end marker.' if $DEBUG\n else\n if @inside_output\n @queue_mutex.synchronize { @queue << line }\n $stderr.puts \"<#{line}> added to the queue.\" if $DEBUG\n end\n end\n end\n end # thread\n end",
"def capture_output\n dummy_stdio{ yield }\n end",
"def before_enter(token = nil)\n wait_length = 0.1\n Rex::ThreadSafe.select(nil, nil, nil, wait_length)\n if token.nil?\n rstream.flush\n return nil\n end\n\n absolute_timeout = 5\n buf = ''\n begin\n ::Timeout.timeout(absolute_timeout) do\n rstream.sync\n loop do\n if (tmp = shell_read(-1, 1))\n buf << do_encoding_terminal(tmp)\n break if buf.match(token)\n else\n # sleep 1\n Rex::ThreadSafe.select(nil, nil, nil, 0.1)\n end\n end\n end\n rescue\n end\n rstream.flush\n buf\n end",
"def execute\n @output.start\n while(@producer.has_next?)\n json_object = @producer.next\n if @matcher.match?(json_object)\n @output.output(json_object)\n end\n end\n @output.done\n end",
"def wait_until\n until yield\n\twait\n end\n end",
"def run_with_timeout(command, target_output, timeout = SOLVER_TIMEOUT, tick = 0.5)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n print '.'\n\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(BUFFER_SIZE)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n output = 'SHIT'\n break\n end\n\n break if target_output =~ output\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\nend",
"def verify_channel\n while ! self.channel\n raise EOFError if ! self.thread.alive?\n ::IO.select(nil, nil, nil, 0.10)\n end\n end",
"def wait\n\tend",
"def wait_until\n until yield\n wait\n end\n end",
"def enter_at_mode\n while gets.size > 0; end # discard remain data\n Machine.delay(1000) # wait 1 second\n loop {\n self.write '+'; Machine.delay(1)\n self.write '+'; Machine.delay(1)\n self.write '+'\n Machine.delay(1000) # wait 1 second\n rsp = self.gets\n return rsp if rsp == \"OK\\r\"\n }\n end",
"def wait_readable(io)\n wait io do |monitor|\n monitor.wait_readable\n end\n end",
"def waiting; end",
"def waiting; end",
"def log_action(initial_text, final_text=\"Done.\", &block)\n $stdout.sync = true\n print initial_text, \"...\"\n yield\n puts final_text\nend",
"def master_sleep(sec)\n IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return\n SELF_PIPE[0].kgio_tryread(11)\n end",
"def send_cmd(cmd, conn)\n out = conn.cmd('String' => cmd, 'Match' => /(SUCCESS:.*\\n|ERROR:.*\\n|END.*\\n)/)\n out.lines\nend",
"def read_wait(timeout: nil)\n !!IO.select([io], [], [], timeout)\n end",
"def with_filter(command)\n io = IO.popen(command, 'r+')\n yield io.method(:puts)\n\n io.close_write\n io.readlines.map(&:chomp)\nend",
"def wait_for_title(exit)\n waited = 0\n [0.25, 0.5, 1, 2, 4, 8, 16].each do |delay|\n if page_title =~ /-/\n title = page_title.gsub(/[-].+/, '').strip\n unless title.empty?\n puts \"Waited for page title for #{waited} seconds.\"\n return title\n end\n end\n sleep(delay)\n waited += delay\n end\n fail(\"Waited for page title for #{waited} seconds. Page title not found.\") if exit\n end",
"def while_saying(narrative)\n if block_given?\n fork { say(narrative) }\n yield\n Process.wait\n else\n say(narrative)\n end\n end",
"def wait_until\n until yield\n wait\n end\n end",
"def wait_until_not_full; end",
"def wait\n sleep 0.0001\n end",
"def show_wait_cursor(result, spinningCursor)\n chars = %w[| / - \\\\]\n fps = 10\n seconds = 99999999\n delay = 1.0/fps\n killed = []\n (seconds*fps).round.times { |i|\n if !spinningCursor.nil?\n @mutex.synchronize do\n print chars[i % chars.length]\n end\n end\n\n sleep delay\n\n @mutex.synchronize do\n if !spinningCursor.nil?\n print \"\\b\"\n end\n if !@isRunning\n break\n end\n end\n if i > 0 && i % 100 == 0\n out = `ps -ef | grep ruby`\n @mutex.synchronize do\n @logs.each do |k, v|\n if !out.include? k and !killed.include? k\n puts '####################################'\n puts '#'\n puts \"# #{k} Ended\"\n puts \"# For details see : #{v.path}\"\n puts '#'\n puts '####################################'\n result[KILLED] << v.path\n killed << k\n end\n end\n end\n end\n }\nend",
"def wait_for_io_eof(timeout)\n start = Time.now\n Timeout.timeout(timeout) do\n sleep(0.1) until @process.eof?\n end\n FFMPEG.logger.debug \"IO#eof? #{@process.eof?}\"\n Time.now - start\n end"
] | [
"0.7417049",
"0.7047585",
"0.6606024",
"0.6486684",
"0.6402355",
"0.63500684",
"0.6254041",
"0.6245654",
"0.61042506",
"0.6070601",
"0.6046916",
"0.601509",
"0.5966015",
"0.5950698",
"0.58704716",
"0.58571386",
"0.5849312",
"0.581083",
"0.58056253",
"0.57866293",
"0.57653826",
"0.57442415",
"0.57312244",
"0.5702014",
"0.5688137",
"0.56867146",
"0.5637962",
"0.5628227",
"0.5628166",
"0.56109333",
"0.55955034",
"0.55806166",
"0.5575972",
"0.5547923",
"0.55364275",
"0.55022913",
"0.5500907",
"0.5491301",
"0.548806",
"0.54688674",
"0.54688674",
"0.54688674",
"0.5453929",
"0.54324245",
"0.5403899",
"0.53834146",
"0.5363584",
"0.53584385",
"0.5331262",
"0.53138447",
"0.5292321",
"0.5283811",
"0.52834105",
"0.5281591",
"0.5281333",
"0.5275095",
"0.5271668",
"0.5227933",
"0.52267736",
"0.5219933",
"0.52168626",
"0.5211534",
"0.5209402",
"0.52049774",
"0.51909757",
"0.51904243",
"0.51872665",
"0.51839995",
"0.51699156",
"0.5159788",
"0.5158733",
"0.51512265",
"0.514281",
"0.5141802",
"0.51368415",
"0.5133593",
"0.5132411",
"0.5130232",
"0.51283324",
"0.51194566",
"0.51138675",
"0.51097786",
"0.5101901",
"0.5097065",
"0.50855976",
"0.5078818",
"0.5077341",
"0.5077341",
"0.50630623",
"0.50554836",
"0.5054599",
"0.50529295",
"0.50516105",
"0.5047828",
"0.50464255",
"0.5043917",
"0.5042444",
"0.5040452",
"0.50395393",
"0.50381607"
] | 0.8712005 | 0 |
This is horrid, should be moved to something like map.resolve_room(name, relative_to = nil) | def find_room(room_name)
if room_name[0..0] == '.'
@map[room_name[1..-1]]
else
p = @path.dup
p.pop
p += room_name.split('.')
r = @map[p.join('.')]
r || @map[room_name]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_room_lookup_table(parsed_rooms)\n room_lookup = {} \n parsed_rooms.each do |room|\n room_lookup[room[1]] = room.first\n end \n room_lookup\nend",
"def find_room(room_or_identifier)\n case room_or_identifier\n when Room\n room_or_identifier\n else\n Room.fuzzy_find(room_or_identifier)\n end\n end",
"def lookup_room(room)\n @dictionary[room]\n end",
"def buildwalk(dir, supplied=nil)\n if supplied\n if supplied.is_a?(Room)\n found = {:room=>supplied}\n else\n view \"Linking failed. Target was not a room.\" + ENDL\n return nil\n end\n else\n m = Automap.new(in_room, [(-1..1),(-1..1)], {:full_traverse=>true})\n found = m.find(Automap.offset([0,0], dir))\n end\n\n if !found\n new_room = Room.dig_rooms(in_room.vnum, Vnum.gen_vnum, dir)\n new_room.sector = in_room.sector # same sector as old room\n new_room.namespace = in_room.namespace\n new_room.assign_tag Tag.gen_generic_tag(new_room), in_room.namespace\n return new_room\n else\n Room.dig_rooms(in_room.vnum, found[:room].vnum, dir)\n return found[:room]\n end\n end",
"def find_room_by_name(name)\n rooms.detect {|room| room.name == name }\n end",
"def find_room uri\n payload = { \"uri\" => uri }.to_json\n data = self.post \"#{api_prefix}/rooms\", payload\n\n Room.new(self, data)\n end",
"def location_of(item)\r\n return @pack if @pack.has?(item)\r\n @rooms.each { |id, r|\r\n return r if r.has?(item)\r\n }\r\n return nil\r\n end",
"def try_resolve(router)\n ret = @macs.find{|e| e[:router]==router || e[:macs].index(router)}\n return ret[:router] if ret #found something?\n router #nope\n end",
"def find_room_by_name(room_name)\n @rooms.collect { |room| room if room[:name] == room_name }.reject { |room| room.nil? }.first\n end",
"def get_room\n @key = @a_keys.shift\n find_room(@key)\n end",
"def resolve\n raise NotImplementedError, \"#resolve must be reimplemented in objects meant to be used in the coordination primitives\"\n end",
"def get_room(code, param)\n\t\tcase code\n\t\twhen :ev_id\n\t\t\teach_room { |room| return room if room.has_event?(param) }\n\t\tend\n\tend",
"def find_room_in_dungeon(reference)\n\t\troom = @rooms.detect{|room| room.reference == reference}\n\t\troom = find_room_in_maze(reference) if room == nil\n\t\troom\n\tend",
"def room(location = nil)\n return @@current_room if location.nil?\n Item.allRooms.each do |r|\n return r if r.item_id == location\n end\n# @room[@room_id]\n end",
"def find_room(row_rmrecnbr)\n Room.find_by(rmrecnbr: row_rmrecnbr) || nil\n end",
"def find_room_in_maze(reference)\n\t\[email protected]{|room| room.reference == reference}\n\tend",
"def room; end",
"def find_room_in_dungeon(reference)\n\t\trooms.detect { |room| room.reference == reference }\n\tend",
"def resolve(pattern, parents)\n keymap_result = keymap[pattern]\n\n case keymap_result\n when Incomplete # try to find a full or longer match in parents\n resolve_incomplete(pattern, parents, keymap_result)\n when Impossible # anything better than that.\n resolve_impossible(pattern, parents, keymap_result)\n else\n # full match from us, so get the action out.\n return keymap_result\n end\n end",
"def resolve_to_url\n #special case for the null root omrl\n if @omrl == ''\n return \"/entities/1\"\n end\n\n if flow?\n# #confirm that we can find the a link that actually declares the flow\n# return nil if !Link.find_declaring_entity(to_s)\n return \"/entities/#{@flow_id}\"\n end\n\n l = Link.find_naming_link(entity_name,parent_context)\n# raise \"could not find naming link for name: #{the_name} in context: #{the_context}\" if !l\n if l\n if l.is_a?(Array)\n l[0].omrl\n else\n l.omrl\n end\n else\n nil\n end\n end",
"def resolve nm,params=nil\n return nil if nm.nil?\n root = @root\n root = @rel_root unless (params && params[:absolute])\n if params.nil?\n File.join(root,'originals',File.basename(nm))\n elsif params[:width]\n File.join(root,'w',params[:width].to_s,File.basename(nm))\n elsif params[:height]\n File.join(root,'h',params[:height].to_s,File.basename(nm))\n else\n File.join(root,'originals',File.basename(nm))\n end\n end",
"def resolve(route, line, column)\n return nil unless column # firefox doesn't support column numbers\n return nil unless map.filename == route || begin\n uri = URI.parse(route) rescue nil\n if uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS)\n uri.path == map.filename\n else\n false\n end\n end\n mapping = map.bsearch(GemSourceMap::Offset.new(line, column))\n return nil unless mapping\n {\n 'file' => mapping.source,\n 'line' => mapping.original.line,\n 'column' => mapping.original.column\n }\n end",
"def to_partial_path\n 'room'\n end",
"def spawn(player_room)\n # get all possible paths and create a hash indexed by size\n paths_to_player = self.rooms.inject({}) do |hsh, room|\n path = self.class.grue_path(room, player_room, self.edges)\n hsh[path.size] = path\n hsh\n end\n\n # get the longest of the shortest paths\n # (this is as far away as we can get)\n longest_path = paths_to_player[paths_to_player.keys.max]\n\n # get the first element of the first edge\n self.current_room = longest_path.first.first\n end",
"def resolve(route, line, column)\n if (mapping = map.resolve(route, line, column))\n {\n 'file' => mapping.source_file,\n 'line' => mapping.source_line,\n 'symbol' => mapping.symbol\n }\n else\n nil\n end\n end",
"def find_room_in_direction(direction)\n\t\tfind_room_in_dungeon(@player.location).connections[direction]\n\tend",
"def find_room_in_direction(direction)\n\t\tfind_room_in_dungeon(@player.location).connections[direction]\n\tend",
"def resolve_reference; end",
"def set_room(room_name)\n @room = find_room_by_name(room_name)\n end",
"def find_by_id(rid)\n return nil unless rooms.keys.include?(rid)\n rooms[rid]\n end",
"def room\n end",
"def test_room_paths()\n \t# the parameter is the (name, description) in initialize in class Room\n \t# to create new room of center/north/south\n center = Room.new(\"Center\", \"Test room in the center.\")\n north = Room.new(\"North\", \"Test room in the north.\")\n south = Room.new(\"South\", \"Test room in the south.\")\n\n # to add path of center room\n center.add_paths({:north => north, :south => south})\n\n # check if center.go(:north) really goes to north\n assert_equal(center.go(:north), north)\n # check if center.go(:south) really goes to south\n assert_equal(center.go(:south), south)\n end",
"def absolute nm,params=nil\n n = nil\n pa = if params then params.clone else {} end\n pa[:absolute] = true\n n = resolve nm,pa\n return n\n end",
"def spawn_lookup(name)\n name = name.to_s\n require \"earth_tools/lookup/#{name}\"\n klass = name.split(\"_\").map{ |i| i[0...1].upcase + i[1..-1] }.join\n EarthTools::Lookup.const_get(klass).new\n end",
"def room\n Room.all.find { |room| room.id == room_id }\n end",
"def resolve_name(name)\n name = resolve_name_without_remap(name)\n for k, v in @remappings\n if name.end_with?(k)\n if Resolver.global_name?(v)\n name = v\n else\n if name == k\n name = v\n else\n n = \"#{name[0..name.length-k.length-1]}/#{v}\"\n name = Resolver.canonicalize_name(n)\n end\n end\n break\n end\n end\n resolve_name_without_remap(name)\n end",
"def set_room\n @room = Room.get_room(params[:id], params[:branch_id]).first\n end",
"def find_room(room_number)\n return rooms.find { |room| room.room_number == room_number }\n end",
"def resolve(identifier, required:true)\n return nil if identifier.blank? && !required\n #todo: be smart about existance of 'internal_name', for now assume not called unless exists\n result = by_uuid(identifier) || find_by_internal_name(identifier)\n raise \"#{self.name} not found for identifier: #{identifier}\" if required && !result\n result\n end",
"def get_room\n return self if parent.tag == :root\n parent.get_room\n end",
"def join_room uri\n has_room = rooms.detect { |room| room.uri == uri }\n\n return has_room if has_room\n\n @rooms = nil # clear rooms cache\n self.class.find_room(uri).join\n end",
"def find(qry, opts = {})\n find_by_alias(qry, opts[:room]) || find_by_id(qry)\n end",
"def resolve\n end",
"def resolve( name )\n name = name.name if name.is_a?(Name)\n \n if @pattern_defs.member?(name) then\n return @pattern_defs[name]\n elsif @rule_defs.member?(name) then\n return @rule_defs[name]\n elsif @group_defs.member?(name) then\n return @group_defs[name]\n end\n \n return nil\n end",
"def find_by_alias(alas, room = nil)\n return contacts.values.find{|c| c.alias == alas } if room.nil?\n contacts.values.find { |c| c.alias == alas ? c.room && (c.room.id == room) : false }.tap{|c| puts c.nil? ? \"nil\" : \"*** returning #{c.id} : #{c.room}\"}\n end",
"def get_room_stuff(pos)\r\n my_port = 8083\r\n room_map_message = \"/maps/#{$roomnumber}/#{pos}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{room_map_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n if my_json[\"east\"]\r\n return my_json[\"east\"]\r\n \r\n elsif my_json[\"west\"]\r\n return my_json[\"west\"]\r\n\r\n elsif my_json[\"north\"]\r\n return my_json[\"north\"]\r\n\r\n elsif my_json[\"contents\"]\r\n return my_json[\"contents\"]\r\n\r\n elsif my_json[\"south\"]\r\n return my_json[\"south\"]\r\n\r\n elsif my_json[\"down\"]\r\n return my_json[\"down\"]\r\n\r\n elsif my_json[\"up\"]\r\n return my_json[\"up\"] \r\n end\r\nend",
"def resolver; end",
"def resolve(name)\n #FIXME: how to handle namespace\n @symtab[name] || (parent ? parent.resolve(name) : nil)\n end",
"def resolve\n abstract\n end",
"def get_new_room (user_input, current_room)\n\t\tnew_location = current_room.location\n\t\tcase user_input\n\t\twhen \"N\"\t \n\t\t\t new_location[:y] +=1\n\t\twhen \"E\"\n\t\t\tnew_location[:x] +=1\n\t\twhen \"S\"\n\t\t\tnew_location[:y] -=1\n\t\twhen \"W\"\n\t\t\tnew_location[:x] -=1\n\t\tend\n\t\tnew_room = @rooms.select do |name, room|\n\t\t\troom.location == new_location\n\t\tend\n\t\treturn new_room.to_a[0][1]\n\tend",
"def resolve_mapping(name) # :nodoc:\n if is_a_moo_number?(name) && prod_targets\n # If an exact match\n if prod_targets[name.upcase]\n prod_targets[name.upcase]\n # If a wildcard match\n elsif prod_targets[\"*#{moo_number_minus_revision(name)}\"]\n prod_targets[\"*#{moo_number_minus_revision(name)}\"]\n # Else just return the given name\n else\n name\n end\n else\n name\n end\n end",
"def map_teamnames\n home = self.bookmaker.teamnames.find_or_create_by_name(self.home_name)\n away = self.bookmaker.teamnames.find_or_create_by_name(self.away_name)\n\n self.home_id = home.id unless home.nil?\n self.away_id = away.id unless away.nil?\n end",
"def room_has_name()\n return @room1.name\n end",
"def route_from(oth)\n # you can modify `rel', but can not `oth'.\n begin\n oth, rel = route_from0(oth)\n rescue\n raise $!.class, $!.message\n end\n if oth == rel\n return rel\n end\n\n rel.set_path(route_from_path(oth.path, self.path))\n if rel.path == './' && self.query\n # \"./?foo\" -> \"?foo\"\n rel.set_path('')\n end\n\n return rel\n end",
"def resolve(candidate)\n return candidate if candidate.blank? || (candidate =~ /^\\w*:/)\n begin\n URI.join(@site.home, candidate).to_s\n rescue\n candidate\n end\n end",
"def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n if f[:bld_id] and not df.building_find(f[:bld_id])\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = [r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i] }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end",
"def checkroom(r)\n case r.status\n when :plan\n # moot\n when :dig\n # designation cancelled: damp stone etc\n r.dig\n when :dug, :finished\n # cavein / tree\n r.dig\n # tantrumed furniture\n r.layout.each { |f|\n next if f[:ignore]\n t = df.map_tile_at(r.x1+f[:x].to_i, r.y1+f[:y].to_i, r.z1+f[:z].to_i)\n if (f[:bld_id] and not df.building_find(f[:bld_id]))\n df.add_announcement(\"AI: fix furniture #{f[:item]} in #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = t }\n f.delete :bld_id\n @tasks << [:furnish, r, f]\n end\n if f[:construction]\n try_furnish_construction(r, f, t)\n end\n }\n # tantrumed building\n if r.misc[:bld_id] and not r.dfbuilding\n df.add_announcement(\"AI: rebuild #{r.type} #{r.subtype}\", 7, false) { |ann| ann.pos = r }\n r.misc.delete :bld_id\n construct_room(r)\n end\n end\n end",
"def find_chat_room\n if params[:room_uuid].present?\n ChatRoom.find_by(uuid: params[:room_uuid])\n elsif params[:is_group_chat] == FALSE_STR\n find_one_to_one_chat_room\n end\n end",
"def resolve(query, am_manager, authorizer)\n debug \"MappingSubmodule: query: #{query}\"\n\n if query[:resources] != nil\n query[:resources].each do |res|\n raise UnknownTypeException unless res[:type]\n resolve_valid_from(res)\n resolve_valid_until(res)\n\n if res[:exclusive].nil? && query[:resources].first[:exclusive] #if exclusive is nil and at least one exclusive is given.\n resolve_exclusive(res, query[:resources], am_manager, authorizer)\n elsif res[:exclusive].nil?\n resolve_exclusive(res, am_manager, authorizer)\n end\n\n if res[:domain].nil? && query[:resources].first[:domain] #if domain is nil and at least one domain is given.\n resolve_domain(res, query[:resources], am_manager, authorizer)\n elsif res[:domain].nil?\n resolve_domain(res, am_manager, authorizer)\n end\n\n resolve_resource(res, query[:resources], am_manager, authorizer)\n res[:valid_from] = res[:valid_from].to_s\n res[:valid_until] = res[:valid_until].to_s\n end\n end\n debug \"Map resolve response: #{query}\"\n query\n end",
"def start\n rooms = get_rooms \n lookup_table = get_room_lookup_table(rooms)\n EventMachine::run do\n rooms.each do |room_id|\n room_manager(room_id, lookup_table)\n end\n end\nend",
"def resolution(*args); end",
"def resolve(pattern)\n super(pattern, parents)\n end",
"def get_lookup(name)\n @lookups = {} unless defined?(@lookups)\n @lookups[name] = spawn_lookup(name) unless @lookups.include?(name)\n @lookups[name]\n end",
"def [](id)\n return @rooms[id] if id.start_with? '!'\n\n if id.start_with? '#'\n res = @rooms.find { |_, r| r.canonical_alias == id }\n return res.last if res.respond_to? :last\n end\n\n res = @rooms.find { |_, r| r.name == id }\n res.last if res.respond_to? :last\n end",
"def get_room(id)\n @rooms[id]\n end",
"def find_adjacent_rooms(from)\r\n return from.return_adjacent_rooms\r\n end",
"def update_rooms\n Room.find_or_create_by(name: @moving_item.room)\n end",
"def roster(target)\n room_roster target.id\n end",
"def find_by_alias(alas)\n rooms.values.find{|r| r.alias == alas }\n end",
"def lookup_by_team (team_name)\n game_hash.map { |home_or_away, team_info|\n if team_name === team_info[:team_name] \n team_info[:location] = home_or_away;\n return team_info;\n end\n }\nend",
"def locate_pins(location); end",
"def resolve(curie_or_uri)\n ns, short_name = split_curie curie_or_uri\n\n if ns && (namespaces.has_key? ns)\n namespaces[ns].expand(rel: short_name).to_s\n else\n curie_or_uri\n end\n end",
"def reverse_get mapping\n (@map.rassoc(mapping) || (raise \"#{mapping} is not a mapping of a registered id\"))[0]\n end",
"def set_room\n @room = Room.find(params[:room_id])\n end",
"def set_room\n @room = Room.find(params[:room_id])\n end",
"def set_room\n @room = Room.find(params[:id]) rescue nil\n return res_with_error(\"Room not found\", :not_found) unless @room\n end",
"def partial_resolve(namespace, name, type = T.unsafe(nil)); end",
"def room_with(hazard)\n for r in 0...20\n checkRoom= room(r)\n if checkRoom.has?(hazard)\n return checkRoom\n end\n end\n end",
"def roomName(hash={})\n\t\t$roomtitle = $_SERVERSTRING_.gsub(/<[^>]+>/o,'')\n\t\tif $roomtitle.include?(',')\n\t\t\t$roomarea = $roomtitle.split(',').first\n\t\tend\n\tend",
"def get_some_room_stuff(roomnumberone,pos)\r\n my_port = 8083\r\n room_map_message = \"/maps/#{roomnumberone}/#{pos}\"\r\n url = URI.parse(\"http://localhost:#{my_port}#{room_map_message}\")\r\n req = Net::HTTP::Get.new(url.to_s)\r\n res = Net::HTTP.start(url.host, url.port){|http|\r\n http.request(req)\r\n }\r\n my_json = JSON.parse(res.body) \r\n if my_json[\"east\"]\r\n return my_json[\"east\"]\r\n \r\n elsif my_json[\"west\"]\r\n return my_json[\"west\"]\r\n\r\n elsif my_json[\"north\"]\r\n return my_json[\"north\"]\r\n\r\n elsif my_json[\"contents\"]\r\n return my_json[\"contents\"]\r\n\r\n elsif my_json[\"south\"]\r\n return my_json[\"south\"]\r\n\r\n elsif my_json[\"down\"]\r\n return my_json[\"down\"]\r\n\r\n elsif my_json[\"up\"]\r\n return my_json[\"up\"] \r\n end\r\nend",
"def build_data_objects_from_place_info_data(existing_object_lookup, new_place_info)\n if(!existing_object_lookup[new_place_info[:atlas_id]]) # The place does not exist\n existing_object_lookup[new_place_info[:atlas_id]] = build_destination_data_object(new_place_info)\n else\n existing_object_lookup[new_place_info[:atlas_id]] = update_destination_data_object(existing_object_lookup[new_place_info[:atlas_id]],new_place_info)\n end\n\n if(!existing_object_lookup[new_place_info[:parent_atlas_id]]) # The parent place does not exist\n existing_object_lookup[new_place_info[:parent_atlas_id]] = build_parent_destination_data_object(new_place_info)\n end\n \n existing_object_lookup = add_child_node_to_parent(existing_object_lookup,new_place_info[:parent_atlas_id],new_place_info[:atlas_id])\n return existing_object_lookup\n end",
"def go_room(command)\n if @current_room.has_exit?(command) \n # current room has this exit \n exit_room = @current_room.get_exit(command) # return string of room name\n # Search for instance of this room\n # update current room\n @game_rooms.each do |room|\n if room.is_room?(exit_room)\n @current_room = room # update current room\n end\n end\n puts \"\\nYou have entered the #{@current_room.print_name}!\\n\"\n else \n puts \"That is not a direction you can travel.\\n\"\n end\n end",
"def find(name); end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def set_room\n @room = Room.find(params[:id])\n end",
"def get_room \\\n name,\n options: nil,\n &block\n request = {\n name: name\n }.delete_if { |_, v| v.nil? }\n request = Google::Gax.to_proto request, Google::Showcase::V1alpha3::GetRoomRequest\n @get_room.call(request, options, &block)\n end",
"def get_room(params)\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}\"), :query_params => params)\n return unless res.successful?\n Room::Detail.new(res.data)\n end",
"def move(direction)\n if not @location.exits.include? direction\n return nil\n end\n destination = @location.exits[direction]\n if not @rooms.include? destination \n raise \"%s was not a known room name.\" % destination\n end\n @location = @rooms[destination]\n return @location\n end",
"def resolve(parser)\n end",
"def room?\n type == :room_id || type == :room_alias\n end",
"def room?\n type == :room_id || type == :room_alias\n end",
"def search_rooms\n end",
"def is_room?(room_string)\n return true if @name == room_string\n end",
"def resolve(parents, query, namespace)\n if polymorphic?\n resolve_polymorphic(parents, query)\n else\n resolve_basic(parents, query, namespace)\n end\n end"
] | [
"0.65332305",
"0.6158236",
"0.60059655",
"0.5988852",
"0.5506339",
"0.5477326",
"0.54548943",
"0.5454551",
"0.54327685",
"0.5415896",
"0.53470814",
"0.5337693",
"0.5325693",
"0.5290417",
"0.52707285",
"0.52569366",
"0.5214262",
"0.52050155",
"0.51989424",
"0.5194192",
"0.5159841",
"0.51547796",
"0.51525664",
"0.5150412",
"0.5144065",
"0.5131847",
"0.5131847",
"0.51275563",
"0.5103474",
"0.5090047",
"0.50823426",
"0.50814486",
"0.50675285",
"0.506724",
"0.50671077",
"0.50583947",
"0.50362945",
"0.50213265",
"0.4995628",
"0.49889767",
"0.49748066",
"0.49679628",
"0.49505994",
"0.49415103",
"0.493952",
"0.49330658",
"0.49239463",
"0.49170798",
"0.49143666",
"0.4898348",
"0.48911905",
"0.4886669",
"0.48718232",
"0.48617476",
"0.48578337",
"0.48485985",
"0.48467132",
"0.48460087",
"0.48449525",
"0.4842706",
"0.48370025",
"0.48293164",
"0.4826935",
"0.48201898",
"0.48100373",
"0.48079768",
"0.4793331",
"0.4776127",
"0.47732303",
"0.47728857",
"0.47694558",
"0.47687012",
"0.4762268",
"0.47598395",
"0.47598395",
"0.47576532",
"0.47559714",
"0.47545716",
"0.47516054",
"0.47485602",
"0.47360986",
"0.473501",
"0.47341526",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47338217",
"0.47200504",
"0.47086325",
"0.4703898",
"0.47035003",
"0.46931222",
"0.46931222",
"0.4692548",
"0.46870297",
"0.4686187"
] | 0.6862318 | 0 |
a simple versio of above code | def multiply(x, y)
return x * y if x.is_a?(Numeric) && y.is_a?(Numeric)
fail ArgumentError, 'Arguments must be a number'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def suivre; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def terpene; end",
"def verdi; end",
"def anchored; end",
"def same; end",
"def probers=(_arg0); end",
"def formation; end",
"def bs; end",
"def berlioz; end",
"def first; end",
"def first; end",
"def stderrs; end",
"def offences_by=(_arg0); end",
"def weber; end",
"def r; end",
"def r; end",
"def wrapper; end",
"def ibu; end",
"def whiny=(_arg0); end",
"def flag; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def select; end",
"def select; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def call; end",
"def standalone=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def ext=(_arg0); end",
"def custom; end",
"def custom; end",
"def operations; end",
"def operations; end",
"def villian; end",
"def from; end",
"def from; end",
"def from; end",
"def from; end",
"def who_we_are\r\n end",
"def intensifier; end",
"def trd; end",
"def result=(_); end",
"def ismn; end",
"def spice; end",
"def malts; end",
"def operation; end",
"def isolated; end",
"def isolated; end",
"def sld; end",
"def refutal()\n end",
"def rassoc(p0) end",
"def op; end",
"def call() end",
"def offences_by; end",
"def overload; end",
"def next() end",
"def next() end",
"def getc() end",
"def getc() end",
"def getc() end",
"def PO114=(arg)",
"def alt; end",
"def gounod; end",
"def tiny; end",
"def schumann; end",
"def isolated=(_arg0); end",
"def isolated=(_arg0); end",
"def return_value=(_arg0); end",
"def first() end",
"def start=(_arg0); end",
"def explicit; end",
"def zuruecksetzen()\n end",
"def returns; end",
"def calls; end",
"def calls; end",
"def sb(t, s, c)\n\n end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def result; end",
"def lsi; end",
"def active=(_arg0); end",
"def active=(_arg0); end"
] | [
"0.6328854",
"0.61629325",
"0.60624635",
"0.60624635",
"0.60624635",
"0.60624635",
"0.5967665",
"0.59564024",
"0.5887669",
"0.57578367",
"0.57401544",
"0.5660327",
"0.5645947",
"0.5640901",
"0.5633973",
"0.5625773",
"0.5602865",
"0.5602865",
"0.55473095",
"0.55178684",
"0.5507931",
"0.5507335",
"0.5507335",
"0.54861486",
"0.5479185",
"0.5438448",
"0.5429567",
"0.5422177",
"0.5422177",
"0.541033",
"0.541033",
"0.54070425",
"0.54070425",
"0.54070425",
"0.54070425",
"0.54070425",
"0.54070425",
"0.54070425",
"0.54070425",
"0.5406933",
"0.5394184",
"0.5394184",
"0.5394184",
"0.5392478",
"0.5392478",
"0.53914",
"0.53914",
"0.53566974",
"0.53564787",
"0.53564787",
"0.53564787",
"0.53564787",
"0.53562874",
"0.5322609",
"0.53191286",
"0.53154296",
"0.5308102",
"0.529484",
"0.52934945",
"0.52904177",
"0.5284725",
"0.5284725",
"0.5283654",
"0.52824783",
"0.52698535",
"0.52698165",
"0.5266732",
"0.52662385",
"0.52635443",
"0.5262148",
"0.5262148",
"0.5259911",
"0.5259911",
"0.5259911",
"0.52461684",
"0.52367115",
"0.5233339",
"0.52137125",
"0.52132165",
"0.52120185",
"0.52120185",
"0.52112925",
"0.520548",
"0.51978207",
"0.51831234",
"0.5172514",
"0.517108",
"0.51701355",
"0.51701355",
"0.5169232",
"0.516486",
"0.516486",
"0.516486",
"0.516486",
"0.516486",
"0.516486",
"0.516486",
"0.516486",
"0.51610994",
"0.5158819",
"0.5158819"
] | 0.0 | -1 |
Custom label methods def property_label_method if self.property_category.nil? self.property_name else self.property_category.category_name + ": " + self.property_name end end | def property_label_method
self.property_category ? self.property_category.category_name + ": " + self.property_name : self.property_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_label\n \"#{self.name}\"\n end",
"def custom_label\n \"#{self.name}\"\n end",
"def property_label_text(property)\n case property.to_sym\n when :image_default then t(:image_url)\n when :web_default then t(:website_url)\n when :web_blog then t(:blog_url)\n else t(property.to_sym)\n end\n end",
"def label\n self.category.nil? ? nil : self.category.label\n end",
"def generate_label_for_attribute?; end",
"def property_name\n property.display_name\n end",
"def label\n if respond_to?(\"#{@attribute}_label\".to_sym)\n send(\"#{@attribute}_label\".to_sym)\n else\n @attribute.to_s.titleize\n end\n end",
"def label\r\n @label ? @label : \"#{super}_#{strategy_name}\"\r\n end",
"def label\n end",
"def label\n @label ||= self.new.class.to_s.underscore.gsub('/', '.')\n end",
"def to_label\n \"#{name}\"\n end",
"def label_text\n method.to_s.gsub('-', ' ')\n end",
"def link_section_label_method\n if self.id\n \"#{self.link_root_cat.try(:name)}/#{self.link_top_cat.try(:name)}/#{self.link_sub_cat.try(:name)}\"\n end\n end",
"def link_section_label_method\n if self.id\n \"#{self.link_root_cat.name}/#{self.link_top_cat.name}/#{self.link_sub_cat.name}\"\n end\n end",
"def name\n label\n end",
"def custom_label_method\n \"#{self.email}\"\n end",
"def method_missing(method_name, *args)\n if m = method_name.to_s.match(/\\A(\\w+)_(label|Label)\\Z/)\n customer_label(m[1], :titleize => m[2] == \"Label\")\n elsif respond_to?(method_name)\n try(method_name.to_s, *args)\n else\n super(method_name, *args)\n end\n end",
"def label\n return @label\n end",
"def label\n full_title\n end",
"def name_for_label\n self.class.translated_label_for(self.name, self.element.name)\n end",
"def _label\n field = self.content_type.label_field\n value = self.dynamic_getter(field.name)\n\n if field.type == :belongs_to\n value.try(:_label)\n else\n value\n end\n end",
"def description_label\n raise NotImplementedError\n end",
"def category_label\n Categories::LABELS[category]\n end",
"def label\n attribute :label\n end",
"def custom_label_method\n \"#{self.email}\"\n end",
"def label; end",
"def label; end",
"def to_label\n \"#{label}\"\n end",
"def label\n self['label']\n end",
"def label_translation; end",
"def label_name\n \n \"#{nombre_etiqueta}\"\n \n end",
"def label\n \"#{@name} (#{@id})\"\n end",
"def name label\n label(label)\n end",
"def label\n return @label\n end",
"def label\r\n\t\t''\r\n\tend",
"def label\n @label || \"unknown\"\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def label\n attributes.fetch(:label)\n end",
"def labels\n super.map{ |i| i.to_s.upcase } unless super.nil?\n end",
"def label\n \"\"\n end",
"def label\n nome\n end",
"def customer_label(label_name, options = {})\n if plural_match = label_name.to_s.match(/(\\w+)s\\Z/)\n pluralize = true\n label_name = plural_match[1]\n end\n method_name = \"#{label_name.to_s}_label\"\n return_label = self.try(method_name) if self.respond_to?(method_name)\n return_label = DEFAULT_LABEL[label_name.to_sym] if return_label.blank?\n format_customer_label(return_label, :titleize => options[:titleize], :pluralize => pluralize)\n end",
"def property_name\n property.identifing_name\n end",
"def category_name \n\tself.category.name \n end",
"def label\n read_attr :label\n end",
"def name\n @property_name\n end",
"def name\n @custom_name || @attribute.to_s.humanize\n end",
"def label\n label = \"#{number}: #{name}\"\n end",
"def to_label\n to_s\n end",
"def property_summary(object_name, method_name, options={})\n object = if object_name.is_a?(String) || object_name.is_a?(Symbol)\n instance_variable_get(\"@#{object_name}\")\n else\n object_name\n end\n result = object.send(\"#{method_name}\")\n unless result.blank?\n markdown(result)\n else\n '---'\n end\n end",
"def sub_name\n primary_property ? \"#{primary_property.description}\" : ''\n end",
"def to_label\n manufacturer.to_s + \" - \" + title\n end",
"def label(attribute_name, *args); end",
"def label\n code.to_s.capitalize\n end",
"def to_label\n \"#{person.nil? ? '' : person.name}\"\n end",
"def show_sex_label_method\n self.sex\n end",
"def method_missing(meth, *args, &block)\n label = meth.to_s.gsub('_', ' ')\n label = label.singularize if is_plural = (label == label.pluralize)\n if label = (labels.find { |candidate| candidate.downcase == label }) || label.capitalize\n return is_plural ? results_for(label) : result_for(label)\n end\n super\n end",
"def document_show_field_label(document, field)\n lookup_display_name(document, field) || super\n end",
"def human_name_for(instance, method)\n I18n.t(\"activerecord.attributes.#{instance}.#{method}\", :default => method.to_s.humanize)\n end",
"def show_sex_label_method\n sex\n end",
"def generated_label\n name = \"\"\n\n if @generated_name_classes.last\n clazz, reflection = @generated_name_classes.last[:clazz], @generated_name_classes.last[:reflection]\n if reflection.collection?\n name << clazz.model_name.human(count: 2)\n else\n name << clazz.model_name.human\n end\n end\n\n name << \" \" unless name.empty?\n name << @current_clazz.human_attribute_name(@attribute).to_s.downcase\n\n return name\n end",
"def label_for(object_name, method, options = {})\n ActionView::Helpers::InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_label_tag(options)\n end",
"def label(method, options_or_text=nil, options=nil)\n if options_or_text.is_a?(Hash)\n return \"\" if options_or_text[:label] == false\n options = options_or_text\n text = options.delete(:label)\n else\n text = options_or_text\n options ||= {}\n end\n text = localized_string(method, text, :label) || humanized_attribute_name(method)\n text += required_or_optional_string(options.delete(:required))\n\n # special case for boolean (checkbox) labels, which have a nested input\n text = (options.delete(:label_prefix_for_nested_input) || \"\") + text\n\n input_name = options.delete(:input_name) || method\n super(input_name, text, options)\n end",
"def category_name \n self.category ? self.category.name : nil\n end",
"def label(method, text = nil, options = {}, &block) #:nodoc:\n\n options, text = text, nil if text.is_a?(Hash)\n text ||= method.to_s.humanize\n\n options.stringify_keys!\n klasses = (options.delete(['class']) || \"\").split(\" \")\n klasses << 'field_with_errors' if errors_on_attribute?(method)\n options['class'] = klasses.join(\" \") unless klasses.compact.empty?\n\n text = \"#{text} <abbr title='Required'>*</abbr>\".html_safe if attribute_required?(method) || required_by_option?(options.delete('required')) \n super(method, text, options, &block)\n\n end",
"def category_name\n !self.category.nil? ? self.category.name : \"\"\n end",
"def to_s\n label\n end",
"def label_for_category(category)\n CATEGORY_LABELS.fetch(category, \"~#{category}\")\n end",
"def property_name\n property.name if property\n end",
"def show_status_label_method\n \"#{self.status}\"\n end",
"def label_for_field(method, options = {})\n return '' if options[:no_label]\n label_text = options.delete(:label) || l((\"field_\"+method.to_s.gsub(/\\_id$/, \"\")).to_sym)\n label_text += @options[:read_only] ? \":\" : options[:required] ? @template.content_tag(\"span\", \" *\", :class => \"required\"): \"\"\n @template.content_tag(\"div\",\n @template.content_tag(\"label\", label_text, \n :class => (object_has_errors?(method) ? \"error\" : nil), \n :for => \"#{@object_name}_#{method}\"), \n :class => \"label\")\n end",
"def emit_label\n return '' if @options[:no_label]\n title = @anno[:title] || @options[:label] || @anno[:name].to_s.humanize\n %{<label for=\"#{control_id}\">#{title}</label>}\n end",
"def sub_name\n primary_property ? \"#{primary_property.description}\" : ''\n end",
"def label_from_options\n res = super\n res = res.call if res.is_a? Proc\n res\n end",
"def label_name(product)\n return product.label_override unless product.label_override.nil?\n Google::StringUtils.underscore(product.name)\n .split('_')\n .map { |x| x[0] }\n .join\n .concat('_label')\n end",
"def label\r\n\t\t\tname.match(/\\?$/) ? name : name + \":\"\r\n\t\tend",
"def label(item = nil)\n (item || self).name.presence\n end",
"def get_autocomplete_label\n label = ActionController::Base.helpers.strip_tags(self.title.strip)\n label += \" (\" + self.collection_identifier + \")\" if (self.collection_identifier && self.collection_identifier.length > 0)\n label += \" [COLLECTION]\" if (self.is_collection)\n label += \" [RESOURCE]\" if (self.is_resource)\n label += \" [EXHIBITION]\" if (self.is_exhibition)\n label += \" [STUDY SET]\" if (self.is_crcset)\n\n label\n end",
"def get_flexi_label\n labels = [_flexi_metadata[:label_singular],\n _flexi_metadata[:label_plural]].compact\n\n if labels.empty?\n _f_name = _friendly_name(self.name)\n [_f_name.singularize, _f_name.pluralize]\n else\n labels\n end\n end",
"def label_callback\n klass.fact_model.dimension_label_callbacks[@label]\n end",
"def type_label\n @type.underscore.humanize.titleize\n end",
"def type_label\n @type.underscore.humanize.titleize\n end",
"def labels(labels)\n super.transform_keys { |key| \"#{label_base}/#{key}\" }\n end",
"def title\n if label.blank? then name else label end\n end",
"def category_name\n category.name if category\n end",
"def category_name\n object.category.name rescue \"\"\n end",
"def labels; end",
"def label_for(method, opts_or_val)\n if opts_or_val.is_a?(String)\n return @template.label @object_name, method, opts_or_val\n elsif opts_or_val.is_a?(Hash)\n val = opts_or_val[:val]\n opts_or_val.delete :val\n return @template.label @object_name, method, val, opts_or_val\n end\n end",
"def descriptive_label\n @attributes[:descriptive_label]\n end",
"def to_label()\n \"[#{person.initials rescue '??' }] #{name.capitalize}\"\n end",
"def full_label\n ''\n end",
"def name\n description_category\n end",
"def translation_for(field)\n object.class.human_attribute_name(field)\n end",
"def label\r\n\t\tname.match(/\\?$/) ? name : name + \":\"\r\n\tend",
"def label\n @given_label || I18n.t(\"bureaucrat.#{form_name}.#{name}.label\", default: name.to_s.humanize)\n end",
"def property(name); end"
] | [
"0.75380534",
"0.7479646",
"0.71289426",
"0.70067066",
"0.6887744",
"0.6871248",
"0.6810501",
"0.67141193",
"0.6654435",
"0.65932643",
"0.6588898",
"0.6527019",
"0.64864457",
"0.6482465",
"0.6436876",
"0.642014",
"0.64193153",
"0.6410453",
"0.6404373",
"0.6390871",
"0.6384548",
"0.6377747",
"0.6375479",
"0.6352507",
"0.63524115",
"0.63344026",
"0.63344026",
"0.63310194",
"0.6296349",
"0.6279339",
"0.62769383",
"0.62635046",
"0.6248328",
"0.6235662",
"0.6234778",
"0.6228067",
"0.6218601",
"0.6218601",
"0.6218601",
"0.6218601",
"0.6218601",
"0.6218601",
"0.6209604",
"0.6204754",
"0.62031364",
"0.6191046",
"0.6171775",
"0.6171072",
"0.6159161",
"0.61576176",
"0.61494464",
"0.61251473",
"0.60959333",
"0.60883623",
"0.60871303",
"0.6073205",
"0.60432076",
"0.6042249",
"0.60389096",
"0.6032603",
"0.6003797",
"0.59964824",
"0.5995575",
"0.59842056",
"0.5980195",
"0.59791434",
"0.5959061",
"0.5955986",
"0.59281343",
"0.5913268",
"0.5899893",
"0.58987796",
"0.5898037",
"0.5887423",
"0.5884614",
"0.58752775",
"0.5867623",
"0.58623344",
"0.58604574",
"0.5856884",
"0.58463407",
"0.5844099",
"0.5842302",
"0.5839468",
"0.58353007",
"0.58353007",
"0.58341044",
"0.58302593",
"0.58246464",
"0.5822883",
"0.58225054",
"0.5821157",
"0.5818646",
"0.5811916",
"0.58099514",
"0.58065987",
"0.58063114",
"0.579757",
"0.57849956",
"0.57793796"
] | 0.9473136 | 0 |
In my own words: Create a method that takes a string argument. It returns a new string, that contains the original string value. Except all the consecutive duplicate characters are collapsed into a single character. input: a string object output: is a new string object steps: => make a copy of the string with dup => examine each character of the string => store the current character inside of a variable outside of the each method => => if the current character is equal to the last character, remove it => after we have iterated through all the characters, return the new string. | def remove_consec_dup(string)
new_string_array = string.dup.chars
current_character = []
new_string_array.each do |char|
if current_character.last == char
next
else current_character << char
end
end
current_character.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_adjacent_duplicates(input)\n result = \"\"\n last = \"\"\n input.chars.each do |letter|\n if letter != last\n result += letter\n last = letter\n end\n end\n return result\nend",
"def no_dupes(string)\n string_arr = string.split('')\n if string_arr.length <= 1\n return string\n else\n current_char = string_arr[0] # set current char\n end\n\n string_arr.each_index do |index|\n # edge cases when passed an array of 0 or 1 length\n if index == (string_arr.length - 1) # edge case at the end of the array\n break\n end\n next_char = string_arr[index] # set next_char\n # check if the chars are duplicated\n if current_char == next_char\n string_arr.delete_at(index+1)\n else current_char = next_char\n end\n end\n # return the pruned array, transformed into a string\n return string_arr.join.to_s\nend",
"def crunch(string)\n no_duplicates = ''\n string.chars.each do |letter|\n no_duplicates << letter unless no_duplicates[-1] == letter\n end\n no_duplicates\nend",
"def same_char_collapse(str)\n while adjacent_same_char?(str)\n str.chars.each_index do |i|\n if str[i] == str[i + 1]\n str[i..i + 1] = ''\n break\n end\n end\n end\n\n return str\nend",
"def crunch(str)\n single_str = ''\n\n str.each_char do |character|\n single_str << character unless character == single_str[-1]\n end\n single_str\nend",
"def removeDuplicate( str)\n\ths = []\n\tout = \"\"\n\tfor ch in str do\n\t\tif (hs.include?(ch) == false)\n\t\t\tout += ch\n\t\t\ths.push(ch)\n\t\tend\n\tend\n\treturn out\nend",
"def same_char_collapse(str)\n i = 0\n while i < str.length\n if i == 0\n new_str = \"\"\n end\n\n if i != str.length-1\n if str[i] == str[i+1]\n new_str += str[i+2..-1]\n str = new_str\n i = 0\n else\n new_str += str[i]\n i += 1\n end\n else\n new_str += str[i]\n i += 1\n end\n\n end\n return str\nend",
"def remove_duplicates(string)\n counter = string.size - 1\n array = string.chars\n new_array = []\n\n until counter < 0\n\n new_array.unshift(array[0]) if counter == 0\n\n if array[counter] == array[counter - 1]\n counter -= 1\n next\n else\n new_array.unshift(array[counter])\n end\n\n counter -= 1\n end\n\n new_array.join\nend",
"def same_char_collapse(str)\n str = str.split('')\n i = 0\n\n while i < str.length\n j = i + 1\n if str[i] == str[j]\n str.delete_at(j)\n str.delete_at(i)\n i = 0\n next\n end\n i += 1\n\n end\n return str.join()\nend",
"def crunch(str)\n last_character = ''\n collapsed = str.chars.each_with_object([]) do |character, arr|\n unless character == last_character\n arr.push(character)\n last_character = character\n end\n end\n collapsed.join\nend",
"def remove_adjacent_duplicates(input)\n # Your code goes here\n # Split string into array of individual characters\n input_arr = input.chars\n index = 0\n # Solution 1: Iterate over array of characters, deleting |x| then adding it to the index in whichever position it was found\n input_arr.each do |char|\n if input_arr.count(char) > 1\n input_arr.delete_at(index)\n end\n index += 1\n end\n # Solution 2: Iterate over array of characters, comparing the index of |x| to that x-1 and x+1 and if either match deleting itself by index\n input_arr.each do |char|\n # Compare char to character at (index - 1) if true, remove that index > maybe use a while loop to catch multiple identical characters\n if index > 0\n while char == input_arr[(index - 1)]\n input_arr.delete_at(index - 1)\n end\n end\n while char == input_arr[(index + 1)]\n input_arr.delete_at(index + 1)\n end\n index += 1\n end\n return input_arr.join\nend",
"def remove_adjacent_duplicates1(input)\n input = input.chars\n i = 1\n input.length.times do\n if input[i] == input[i-1]\n input.delete_at(i)\n else\n i += 1\n end\n end\n return input.join\nend",
"def crunch(str)\n new_string = ''\n counter = 0\n while counter <= str.length - 1\n new_string << str[counter] unless str[counter] == str[counter + 1]\n counter += 1\n end\n new_string\nend",
"def same_char_collapse(str)\n word = \"\"\n str.each_char.with_index do |char, i|\n if (char == word[-1])\n word = word[0...-1]\n else\n word += char \n end\n end\n\n return word\nend",
"def remove_adjacent_duplicates(input)\n # Your code goes here\n input = input.chars\n i = 0\n last = \"\"\n result = \"\"\n while i < input.length\n if input[i] != last\n result += input[i]\n last = input[i] \n # input.delete_at(i + 1)\n # puts input\n\n end\n i += 1\n end\n return result\nend",
"def custom_squeeze(string)\n # characters = []\n # p characters = sentence.chars\n characters = string.chars\n eos = characters.length - 1\n return_string = \"\"\n # p return_string << characters[2]\n\n characters.each_with_index do |char, index|\n unless char == characters [index + 1] then return_string << characters[index]\n # puts \"char = #{char}\"\n # puts \"index = #{index}\"\n # puts \"characters from index = #{characters [index + 1]}\"\n # puts \"eos = #{eos}\"\n # puts \"return_string = #{return_string << characters[index]}\"\n # puts\n # else\n # puts \"Found repeating char #{char} at index #{index + 1}! \\n Removing repeating character!\"\n # puts\n end\n end\n return return_string\nend",
"def remove_dups(str)\n found = Hash.new(false)\n str.each_char { |chr| found[chr] = true }\n found.select { |_, v| v }.keys.join\nend",
"def crunch(string)\n str_result = ''\n string.chars.each do |char|\n str_result << char unless char == str_result[-1]\n end\n str_result\nend",
"def squeeze(string)\n new_string = []\n string.chars.each_with_index do |char, index|\n unless string[index] == string[index+1]\n new_string << char\n end\n end\n new_string.join()\nend",
"def crunch(string)\n non_consecutive = ''\n\n string.chars.each do |char|\n non_consecutive << char if char != non_consecutive[-1]\n end\n\n non_consecutive\nend",
"def same_char_collapse(str)\r\n reducible = true\r\n\r\n while reducible\r\n chars = str.split(\"\")\r\n reducible = false\r\n\r\n chars.each.with_index do |char, i|\r\n if chars[i] == chars[i + 1]\r\n chars[i] = \"\"\r\n chars[i + 1] = \"\"\r\n reducible = true\r\n end\r\n end\r\n\r\n str = chars.join(\"\")\r\n end\r\n\r\n return str\r\nend",
"def solve(s)\n new_str = ''\n s.each_char do |char|\n if new_str[-1] != char\n new_str += char\n end\n end\n return new_str\nend",
"def crunch(str)\n new_str = ''\n prev = ''\n str.chars.each do |c|\n next if prev == c\n new_str << c\n prev = c\n end\n new_str\nend",
"def same_char_collapse(str)\n complete = true\n while complete\n complete = false\n arr = str.split(\"\")\n arr.each.with_index do |char, i|\n if arr[i] == arr[i+1]\n arr[i] = \"\"\n arr[i+1] = \"\"\n complete = true\n break\n end\n end\n str = arr.join(\"\")\n end\n str\nend",
"def same_char_collapse(str)\n reducible = true\n\n while reducible\n chars = str.split(\"\")\n reducible = false\n\n chars.each.with_index do |char, i|\n if chars[i] == chars[i + 1]\n chars[i] = \"\"\n chars[i + 1] = \"\"\n reducible = true\n end\n end\n\n str = chars.join(\"\")\n end\n\n return str\nend",
"def same_char_collapse(str)\n reducible = true\n\n while reducible\n chars = str.split(\"\")\n reducible = false\n\n chars.each.with_index do |char, i|\n if chars[i] == chars[i + 1]\n chars[i] = \"\"\n chars[i + 1] = \"\"\n reducible = true\n end\n end\n\n str = chars.join(\"\")\n end\n\n return str\nend",
"def crunch(string)\n clean_string = ''\n string.each_char do |letter|\n clean_string << letter unless letter == clean_string[-1]\n end\n clean_string\nend",
"def remove_repeated(string)\n last_letter = \"\"\n fixed_string_array = []\n string.split(\"\").each do |letter|\n if letter == last_letter\n fixed_string_array.pop\n else\n fixed_string_array.push(letter)\n end\n last_letter = letter\n end\n fixed_string_array.join(\"\")\nend",
"def non_repeating_character(str)\n str.each_char do |char|\n return char if str.count(char) == 1\n end\nend",
"def crunch(str)\n current_char = nil\n new_str = ''\n str.each_char do |char| \n if current_char != char\n new_str << char \n current_char = char\n end\n end\n new_str\nend",
"def same_char_collapse(str)\n collapsible = true\n\n while collapsible\n collapsible = false\n\n chars = str.split(\"\")\n chars.each.with_index do |char, i|\n if chars[i] == chars[i + 1]\n chars[i] = \"\"\n chars[i + 1] = \"\"\n collapsible = true\n break\n end\n end\n str = chars.join(\"\")\n end\n \n return str\nend",
"def remove_duplicates(str)\n uniques = \"\"\n\n str.each_with_index do |ltr, i|\n uniques << ltr unless str[0..i - 1].include?(ltr)\n end\n\n uniques\nend",
"def crunch(double_string)\n current_character = ''\n new_string = ''\n double_string.each_char do |character|\n if character != current_character\n new_string += character\n current_character = character\n end\n end\n new_string\nend",
"def crunch(string)\n last_char_used = []\n new_string = ''\n string.each_char do |char|\n new_string << char if char != last_char_used.last\n last_char_used << char\n end\n new_string\nend",
"def crunch(string)\n new_array = [ ]\n\n original_string_arr = string.chars\n\n original_string_arr.each_with_index do |char, index|\n if char != original_string_arr[index + 1]\n new_array << char\n end\n end\n\n new_array.join\nend",
"def crunch(string)\n new_string = ''\n string.each_char { |char| new_string += char if new_string[-1] != char}\n new_string\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 same_char_collapse(str)\n collases =true\n while collases\n chars = str.split(\"\")\n collases = false\n chars.each.with_index do |char, i|\n if chars[i] == chars[i + 1]\n chars[i] = \"\"\n chars[i + 1] = \"\"\n collases = true\n break\n end\n end\n str = chars.join(\"\")\n end\n str\nend",
"def crunch(string)\n prev_char = ''\n new_string = ''\n \n string.chars.each do |char|\n if char == prev_char\n next\n else\n new_string << char\n prev_char = char\n end\n end\n \n new_string\nend",
"def remove_duplicates(string)\n letters = string.split('')\n\n unique_letters = []\n\n letters.each do |letter|\n unless unique_letters.include?(letter)\n unique_letters.push(letter)\n end\n end\n unique_letters.join\nend",
"def crunch(str)\n counter = 0\n result = ''\n while counter < str.length\n result << str[counter] unless str[counter] == result[-1]\n counter += 1\n end\n result\nend",
"def remove_duplicates(str)\n check = 0b0\n remove = []\n str.each_char.with_index do |c, index|\n one = 0b1\n if (check ^ one << (c.ord - 97)) < check\n remove << index\n else\n check = check ^ one << (c.ord - 97)\n end\n end\n remove.sort!\n number_deleted = 0\n remove.each do |r|\n str.slice!(r-number_deleted)\n number_deleted += 1\n end if remove\n return str\nend",
"def unique_chars_with_extra_space?(str)\n hash = {}\n for i in 0..str.size-1\n if hash.key?(str[i])\n puts \"dup => #{str[i]}\"\n return false\n end\n hash[str[i]] = true\n end\n true\nend",
"def duplicate_encode(str)\n new_str = ''\n\n str.downcase.each_char do |character|\n if str.downcase.count(character) > 1\n new_str << ')'\n else\n new_str << '('\n end\n end\n new_str\nend",
"def crunch(string)\n counter = 0\n new_string = string[0]\n return new_string if string.length <= 1\n return string if string == ''\n loop do\n counter += 1\n new_string << string[counter] if string[counter - 1] != string[counter]\n\n break if counter == (string.length - 1)\n end\n new_string\nend",
"def crunch(string)\n array = string.chars\n no_repeats = []\n no_repeats.push(array[0])\n for i in 0..(array.size - 1)\n no_repeats.push(array[i+1]) if array[i] != array[i+1]\n end\n\n no_repeats.join\nend",
"def crunch(string)\n index = 0\n str_text = ''\n while index <= string.length - 1\n str_text << string[index] unless string[index] == string[index + 1]\n index += 1\n end\n str_text\nend",
"def same_char_collapse(str)\n collapsable = true\n while collapsable\n collapsable = false\n chars = str.split(\"\")\n chars.each.with_index do |char, i|\n if chars[i] == chars[i+1]\n chars[i] = \"\"\n chars[i+1] = \"\"\n collapsable = true\n break\n end\n end\n # print chars.join(\"\")\n str = chars.join(\"\")\n end\n return str\nend",
"def same_char_collapse(str)\r\n newStr = str\r\n newStr = collapsed(newStr)\r\n if !newStr[1]\r\n return newStr[0]\r\n else\r\n same_char_collapse(newStr)\r\n end\r\nend",
"def crunch(string)\n final = ''\n string.chars.each { |chr| final << chr unless final[-1] == chr }\n final\nend",
"def crunch(string)\n output = []\n string.chars.each { output << char unless output.last == char }\n output.join\nend",
"def crunch(string)\n crunched = []\n chars = string.split('') \n chars.each_with_index do |c,i|\n if i == 0\n crunched << c\n elsif chars[i-1] != c\n crunched << c\n end\n end\n crunched.join\nend",
"def crunch(str)\n i = 0\n crunch_text = ''\n while i <= str.length\n crunch_text << str[i] unless str[i] == str[i + 1]\n i += 1\n end\n crunch_text\nend",
"def compress_str(str)\n curr = str[0]\n new_str = \"\"\n len = 1\n (1..(str.length - 1)).each do |i|\n if str[i] == str[i - 1]\n len += 1\n else\n new_str += compressed(str[i - 1], len)\n len = 1\n end\n end\n new_str += compressed(str[-1], len)\nend",
"def unique_chars(str) \n # split the string into an array\n # order the array\n # iterate through the array\n # if next iteration is same as previous point, then there are duplicates\n\n array_str = str.downcase.split(\"\").sort()\n last_char = nil\n\n array_str.each do |let|\n if (let == last_char)\n raise ArgumentError, \"string is not unique!\"\n else\n last_char = let\n end\n end\n\n puts \"String has all unique characters!\"\nend",
"def compress_str(str)\n new_str = \"\"\n\n i = 0\n while i < str.length\n char = str[i]\n count = 0\n while char == str[i]\n count += 1\n i += 1\n end\n\n if count > 1\n new_str += count.to_s + char\n else\n new_str += char\n end\n end\n\n new_str\nend",
"def compress(string)\n return string if string.length < 2\n compressed = \"\"\n\n i = 0\n while i < string.length\n\n counter = 1 # counter counts the number of repeated characters string[i]\n until string[i] != string[i+counter]\n counter += 1 # increments it as long as the current and next characters are identical\n end\n\n # we append to 'compressed' the current character + the counts of its repetition\n compressed << string[i] + counter.to_s\n i += counter # the looping goes to the next non repeated character\n end\n\n compressed\nend",
"def crunch(str)\n crunched_string = ''\n str.each_char do |chr|\n crunched_string << chr unless crunched_string[-1] == chr\n end\n crunched_string\nend",
"def compress_str(str)\n newstr = \"\"\n lastc = \"\"\n str.each_char.with_index do |c, i|\n next if lastc == c\n lastc = c\n newstr += count_reps(str[i..-1])\n newstr += lastc\n end\n newstr\nend",
"def crunch(str)\n str.chars.map.with_index { |char, idx| char == str.chars[idx + 1] ? 'delete' : char }.select { |l| l unless l == 'delete' }.join\nend",
"def non_repeating(str)\n str.chars.find { |char| str.count(char) == 1 }\nend",
"def crunch(string)\n string == '' ? new_str = '' : new_str = string[0]\n string.each_char do |char|\n char == new_str[-1] ? next : new_str = new_str + char\n end\n new_str\nend",
"def NonrepeatingCharacter(str)\n str.chars.each_with_index do |char,idx|\n after = idx + 1\n return char unless str.chars[after..str.length - 1].include?(char)\n end\nend",
"def crunch(string)\n string.gsub(/(.)\\1+/, '\\1')\nend",
"def compress_str(string)\n\n result = \"\" #[a]\n i = 0\n \n while i < string.length\n counter = 1\n while string[i] == string[i + 1]\n counter += 1\n i += 1\n end\n \n result += counter.to_s if counter > 1\n result += string[i]\n i += 1\n end\n result\nend",
"def encode_repeating(my_string)\n # return if nil or empty\n return if (my_string == nil || my_string.length == 0)\n\n entering_index = 0 # this is where characters will get replaced\n examining_index = 0 # this is where the current character is getting examined and counted\n length = my_string.length\n while examining_index < length # all n characters will be examined\n temp = my_string[examining_index] # current character\n count = 1 # current character count\n while my_string[examining_index+1] == temp && examining_index < length\n examining_index += 1 # increment index\n count += 1 # increment current character count\n end\n # update at entering_index on seeing the subsequent character changing\n if count > 2 # enter the current character followed by it's count\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n my_string[entering_index] = count.to_s\n entering_index += 1\n elsif count == 2 # enter the current character twice\n count.times do\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n else # count == 1, enter the current character once\n my_string[entering_index] = my_string[examining_index]\n entering_index += 1\n end\n examining_index += 1 # move to next character\n end\n\n # delete trailing characters in the string.\n count = length - entering_index\n count.times do # worst case: delete n-2 number of characters\n my_string.slice! entering_index # trim the string\n end\n return\nend",
"def compress(string)\n compressed_string = []\n count_consecutive = 0\n\n ##\n # Here is a simple counter: count_consecutiv will add 1 each time\n # next string letter is the same. If next array element is not the the same\n # will write letter and counter after the letter. Once it happened will set\n # counter back to 0.\n #\n for i in 0..string.length - 1\n count_consecutive +=1\n\n if string.chars[i] != string.chars[i+1]\n if count_consecutive == 1\n compressed_string << string.chars[i].to_s\n count_consecutive = 0\n else\n compressed_string << string.chars[i].to_s + count_consecutive.to_s\n count_consecutive = 0\n end\n end\n end\n compressed_string.join\nend",
"def non_repeating3(str)\n set = Set.new\n str.each_char do |char|\n return char unless set.add?(char)\n end\nend",
"def unique(str)\n return str if str.nil?\n set = Set.new\n str.chars.each {|c| set << c}\n set.to_a.sort.reverse.join\nend",
"def crunch(string)\n string_arr = string.chars\n return_arr = []\n string_arr.select do |current_char|\n next if return_arr[-1] == current_char\n return_arr << current_char\n end\n return_arr.join\nend",
"def compress_str(str)\n\n new = []\n count = 1\n\n (0..str.length-1).each do |i|\n if str[i] == str[i+1]\n count += 1\n elsif str[i] != str[i+1]\n if count > 1\n new << count.to_s + str[i]\n count = 1\n else \n new << str[i]\n end\n end\n end\n new.join(\"\")\nend",
"def compress_str(str)\n\n new = \"\"\n count = 1\n\n (0..str.length-1).each do |i|\n if str[i] == str[i+1]\n count += 1\n elsif str[i] != str[i+1]\n if count > 1\n new += count.to_s + str[i]\n count = 1\n else \n new += str[i]\n end\n end\n end\n new\nend",
"def non_unique_letters(string)\n character=string.chars.uniq\n character.delete(\" \")\n character.select {|char| string.count(char)>1}\nend",
"def first_non_repeat_char(string)\n raise ArgumentError, 'Parameter must be a string' unless string.is_a? String\n\n char_array = string.upcase.chars\n unique = char_array.select { |char| char_array.count(char) == 1 }\n unique.first\nend",
"def nonrptchar(string)\n strcpy = string.reverse.chars\n while strcpy != nil do \n y = strcpy.pop\n if strcpy.include? y\n strcpy.delete(y)\n else\n return y\n end\n end\nend",
"def remove_char(string, character)\n i = 0\n while i < string.length\n if character == string[i]\n string[i] = \"\"\n i -= 1\n end\n i += 1\n end\n return string\nend",
"def encode_repeating(my_string)\r\n i = 0\r\n j = 0\r\n letter = my_string[i]\r\n while i < my_string.length\r\n j += 1 while my_string[j + 1] == letter\r\n if j - i >= 2\r\n my_string[(i + 1)..j] = (j - i + 1).to_s\r\n end\r\n additional = 0\r\n additional = 1 if j > i\r\n i += 1 + additional\r\n j = i\r\n letter = my_string[i]\r\n end\r\n return my_string\r\nend",
"def compress_str(str)\n \n # Checks each char for the number of duplicates, keeps only chars that\n # are repeated more than once.\n dups = str.chars.group_by{|e| e}.keep_if{|_, e| e.length > 0}\n\n\n # Map the chars from a hash into a new string, key value is the number\n # of times that the char is repeated, value is the char itself. Join the\n # chars back into a string at the end and return it.\n new_str = dups.map{|k, v| v.length.to_s + k}.join(\"\")\n\nend",
"def custom_squeeze(string)\n final=\"\"\n characters_array= string.split(\"\")\n characters_array.each_with_index do |char, index|\n unless index >= 0 && characters_array[index - 1] == char\n final += char\n end\n end\n p final\nend",
"def permutations_with_dups(str)\n permutations(str).uniq\nend",
"def compress_str(str)\n new_char = str.split(\"\") \n answer = \"\" \n count = 1\n i = 0\n while i < new_char.length \n if new_char[i] == new_char[i+1] \n count += 1\n elsif new_char[i] != new_char[i +1] && new_char[i] != new_char[i - 1]\n answer += new_char[i]\n else\n answer += count.to_s + new_char[i] \n count = 1\n end\n i += 1\n end\n answer\nend",
"def remove(string,char)\n if char.length>1\n return \"char can't be longer than one character!\"\n end\n\n i = 0\n output=\"\"\n while i<= string.length-1\n if string[i] != char\n output += string[i]\n end\n i+=1\n end\n return output\nend",
"def string_compress(string)\n original=string\n i=0\n while(i<string.length)\n j=i\n while (string[i]==string[j])\n j+=1\n end\n string[i..j-1]=\"#{string[i]}#{(j-i)}\"\n i+=2\n end\n return original if string.length>original.length \n return string\n \nend",
"def encode_repeating(my_string)\n return nil if my_string.nil?\n return my_string if my_string.length <= 1\n\n i = 0\n j = 0\n k = 0\n while j <= i && i < my_string.length\n k = i\n if my_string[i] != my_string[i + 1]\n my_string[j] = my_string[i]\n\n else\n counter = 1\n while my_string[i] == my_string[i + 1]\n i += 1\n counter += 1\n end\n\n if counter == 2\n my_string[j] = my_string[k]\n my_string[j + 1] = my_string[k]\n else\n my_string[j] = my_string[k]\n my_string[j + 1] = counter.to_s\n end\n j += 1\n end\n j += 1\n i += 1\n end\n\n my_string[j...my_string.length] = \"\"\n return my_string\nend",
"def compress_str(str)\n new_str = ''\n count = 1\n (0..str.length - 1).each do |i|\n if str[i + 1] == str[i]\n count += 1\n else\n new_str << count.to_s if count > 1\n new_str << str[i]\n count = 1\n end\n end\n new_str\nend",
"def compress_string(string)\n str = ''\n start = 0\n (0..string.length).each do |i|\n next if string[start] == string[i]\n\n str << string[start] << (i - start).to_s\n start = i\n end\nend",
"def compress_str(str)\n res = \"\"\n curChar = str[0]\n curCharCount = 1\n (1...str.length).each do |i|\n if str[i] != curChar \n res += add_to_result(curChar, curCharCount)\n curChar, curCharCount = str[i], 1 \n \n else \n curCharCount += 1\n end \n end \n res += add_to_result(curChar, curCharCount)\n res \nend",
"def compress_str(str)\n compressed_str = \"\"\n c = 0\n (0...str.length).each do |i|\n c += 1\n if str[i] == str[i+1]\n next\n end\n compressed_str += c.to_s if c > 1 \n compressed_str += str[i]\n c = 0\n end\n compressed_str\nend",
"def remove(string, char)\n output = \"\"\n i = 0\n while i < string.length\n if string[i] == char\n i += 1\n end\n if i < string.length\n output += string[i]\n end\n i += 1\n end\n return output\nend",
"def unique_in_order(string)\n string.each_char.with_index.reduce([]) do |arr, (el, i)|\n if el == string.chars[i+1]\n arr\n else\n arr << el\n end\n end\nend",
"def non_repeat(a_word)\n chars_array = a_word.chars\n char = \"\"\n i = 0\n while i < chars_array.length\n j = i + 1\n while j < chars_array.length\n if chars_array[i] == chars_array[j]\n puts chars_array[i]\n puts chars_array[j]\n break\n else #if not equal\n #check if end of j loop when it equals length of array\n if j == chars_array.length - 1\n char = chars_array[i]\n return char\n end\n end\n j += 1\n end\n i+= 1\n end\n return char\nend",
"def first_non_repeating_letter(string)\n letter_group = letters.split('').group_by{ |x| x.downcase }\n uniqs = letter_group.reject{ |letter, arr| arr.count > 1 }.keys\n for x in 0..uniqs.length\n\n end\n\n\n\n # letters = string.split('')\n # letter_group = letters.group_by{ |x| x.downcase }\n # p letter_group\n # uniqs = letter_group.reject{ |letter, arr| arr.count > 1 }.keys\n # p uniqs\n # '' + uniqs[0].to_s\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 same_letter(arr)\n new_str = arr.shift\n\n loop do\n if arr[0] == new_str[-1]\n new_str << arr.shift\n else\n break\n end\n end\n new_str\nend",
"def unique_prefix(string)\n hash = Hash.new(false)\n uniq = ''\n\n string.each_char do |e|\n if hash[e]\n return uniq\n end\n\n hash[e] = true\n uniq << e\n end\nend",
"def unique_chars(str)\n str.each_char.with_index do |letter, index|\n next_idx = index + 1\n substring = str[next_idx..-1]\n \n substring.each_char.with_index do |sub_letter|\n return false if letter == sub_letter\n end\n # p \"#{letter}: #{index}\"\n end\n\n return true\nend",
"def non_unique_letters(string)\n string.chars.reduce([]) do |array,letter|\n if string.count(letter) > 1 && array.include?(letter) == false && letter != \" \"\n array << letter\n else\n array\n end\n end\nend",
"def non_unique_letters(string)\n\n result = [] # empty accumulator\n\n string.split(\"\").uniq.each do |uni| # finding character present in the string\n each_char = 0\n\n string.split(\"\").each do |ltr| # iterating array of string\n each_char += 1 if ltr == uni\n end\n result << uni if each_char > 1\n end\n\n result\nend",
"def first_not_repeating_character(str)\n count = Hash.new(0)\n\n str.each_char do |ch|\n count[ch] += 1\n end\n\n str.each_char do |ch|\n return ch if count[ch] == 1\n end\n\n \"_\"\nend",
"def remove_char(string, character)\n i = 0\n output = \"\"\n while i < string.length\n if string[i] != character\n output << string[i]\n end\n i += 1\n end\n return output\nend"
] | [
"0.80858",
"0.7859303",
"0.7795108",
"0.7722764",
"0.7551813",
"0.7535296",
"0.7511013",
"0.7506296",
"0.74835664",
"0.7459274",
"0.74411875",
"0.73930335",
"0.73283374",
"0.7305244",
"0.73006004",
"0.723436",
"0.7223878",
"0.7211926",
"0.7194081",
"0.71889544",
"0.71437615",
"0.7143148",
"0.7140184",
"0.7138237",
"0.7127273",
"0.7127273",
"0.71051824",
"0.70987135",
"0.70891255",
"0.7087105",
"0.7078836",
"0.70724386",
"0.70578295",
"0.7048351",
"0.70374495",
"0.7026511",
"0.70233774",
"0.70028496",
"0.6995649",
"0.69682825",
"0.6951769",
"0.69103575",
"0.6909305",
"0.68960714",
"0.6895526",
"0.6888874",
"0.68734604",
"0.6859194",
"0.68358505",
"0.6810241",
"0.679317",
"0.6773645",
"0.6767634",
"0.6727379",
"0.67225194",
"0.6717373",
"0.6715195",
"0.6695851",
"0.66834164",
"0.66675985",
"0.6654427",
"0.6641263",
"0.6637699",
"0.66355765",
"0.6634716",
"0.6621357",
"0.6619021",
"0.6614899",
"0.66082376",
"0.66011626",
"0.6599407",
"0.6581442",
"0.65704966",
"0.6551011",
"0.6544575",
"0.654416",
"0.6531558",
"0.6527381",
"0.6514576",
"0.6496204",
"0.64929307",
"0.64833844",
"0.6478299",
"0.6468217",
"0.6463351",
"0.64609873",
"0.64569294",
"0.64467216",
"0.64293146",
"0.64284074",
"0.6396006",
"0.63954145",
"0.63805693",
"0.6376935",
"0.63679445",
"0.63496625",
"0.63361764",
"0.63326323",
"0.6330395",
"0.63300735"
] | 0.8259019 | 0 |
logs out the current user. | def signout
session.delete(:user_id)
@current_user = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n if !current_user.nil?\n forget(current_user)\n\n session.delete(:user_id)\n session.delete(:user_type)\n @current_user = nil\n end\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n reset_session\n @current_user = nil\n end",
"def log_out\n\t\tforget(current_user) #call user.forget\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user= nil\n\tend",
"def log_out\n session.delete(:user_credentials)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n\t \tsession.delete(:user_id)\n\t \t@current_user =nil\n\t end",
"def log_out\n forget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n flash[:danger] = 'Logoff realizado!'\n end",
"def log_out\r\n forget(current_user)\r\n session.delete(:user_id)\r\n @current_user = nil\r\n end",
"def log_out\n forget(current_user)\n reset_session\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil \n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget current_user\n session.delete :user_id\n @current_user = nil\n end",
"def user_log_out\n forget_user(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:user_id)\n session.delete(:user_type_string)\n @current_user = nil\n end",
"def log_out\n forget(current_user)\n session.delete(:username)\n @current_user = nil\n end",
"def user_log_out\n user_forget(current_user)\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n\n end",
"def log_out \n session.clear\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n session.delete(:type)\n @current_user = nil\n end",
"def log_out\n \tsession.delete(:user_id)\n \t@current_user = nil\n end",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\t\t# Setting @current_user to nil would only matter if @current_user were created before the destroy action (which it isn’t) and if we didn’t issue an immediate redirect (which we do). This is an unlikely combination of events, and with the application as presently constructed it isn’t necessary, but because it’s security-related I include it for completeness\n\tend",
"def log_out\n forget current_user\n reset_session\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n forget(@current_user)\n @current_user=nil\n end",
"def log_out\n session.delete(:uid)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id) #remove the user id from the browser cache\n @current_user = nil\n end",
"def log_out\n\t\tsession.delete(:id)\n\t\t@current_user = nil\n\t\tadmin_session(false)\n\tend",
"def log_out\n forget(current_user)\n # Logging out involves undoing the effects of the log_in method.\n session.delete(:user_id) # Delete the user id stored in the session.\n @current_user = nil # Clear the cached current user.\n end",
"def log_out\n session.delete(:username)\n session.delete(:token)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user=nil\n end",
"def log_out\n session.delete(:user_id)\n session.delete(:user_name)\n session.delete(:user_email)\n @current_user = nil\n end",
"def log_out\n session.clear\n cookies.clear\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n session.delete(:user_type)\n session.delete(:user_email)\n @current_user = nil\n end",
"def log_out\n session.delete(:email)\n @current_user = nil\n end"
] | [
"0.8546083",
"0.85344946",
"0.85344946",
"0.85344946",
"0.85344946",
"0.85344946",
"0.852604",
"0.8525856",
"0.8525856",
"0.8525856",
"0.8525856",
"0.8483694",
"0.8480767",
"0.8480241",
"0.84791666",
"0.84397125",
"0.84262",
"0.84262",
"0.84262",
"0.84262",
"0.84262",
"0.840906",
"0.8395663",
"0.83900654",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83897823",
"0.83779484",
"0.8359269",
"0.8354137",
"0.8353999",
"0.8352419",
"0.83521277",
"0.8337425",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.8337352",
"0.83241457",
"0.83240616",
"0.8323427",
"0.83229387",
"0.8300157",
"0.8292327",
"0.8287105",
"0.82825655",
"0.8278581",
"0.82731533",
"0.8267438",
"0.8262622",
"0.82416993",
"0.8223547",
"0.8178138",
"0.8157592",
"0.8128198",
"0.8119386",
"0.81088024",
"0.81072795",
"0.80858713",
"0.8085379"
] | 0.0 | -1 |
Generates asymmetric key pair that is comprised of both public and private keys by specified type. | def generate_keys(keys_type: @default_key_type, key_material: nil)
key_material = Validation.check_filled_array_argument!(key_material) if key_material
begin
native_type = KeyPairType.convert_to_native(keys_type)
native_key_pair = nil
native_key_pair = if key_material
Core::VirgilKeyPair.generate_from_key_material(
native_type,
key_material
)
else
Core::VirgilKeyPair.generate(native_type)
end
key_pair_id = compute_public_key_hash(native_key_pair.public_key)
private_key = VirgilPrivateKey.new(
key_pair_id,
wrap_bytes(
Core::VirgilKeyPair.private_key_to_der(native_key_pair.private_key)
)
)
public_key = VirgilPublicKey.new(
key_pair_id,
wrap_bytes(
Core::VirgilKeyPair.public_key_to_der(native_key_pair.public_key)
)
)
return KeyPair.new(private_key, public_key)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asymmetric_key(name, ssl_class, privkey_abi_type, pubkey_abi_type,\n hooks = {})\n object_wrapper \"private_#{name}\", Tem::Keys::Asymmetric,\n [privkey_abi_type, nil],\n :read => hooks[:read_private] || hooks[:read] ||\n lambda { |k| Tem::Keys::Asymmetric.new k },\n :to => hooks[:to_private] || hooks[:to] ||\n lambda { |k| k.ssl_key },\n :new => hooks[:new_private] || hooks[:new] ||\n lambda { |k| ssl_class.new }\n object_wrapper \"public_#{name}\", Tem::Keys::Asymmetric,\n [pubkey_abi_type, nil],\n :read => hooks[:read_public] || hooks[:read] ||\n lambda { |k| Tem::Keys::Asymmetric.new k }, \n :to => hooks[:to_public] || hooks[:to] ||\n lambda { |k| k.ssl_key },\n :new => hooks[:new_private] || hooks[:new] ||\n lambda { |k| ssl_class.new }\n end",
"def generate_key_pair\n\tg = 2\n\tp = generate_safe_prime(g)\n\td = rand(p)\n\te2 = ModMath.pow(g, d, p)\n\n\tpublic_key = [p, g, e2]\n\tprivate_key = [p, g, d]\n\n\treturn public_key, private_key\nend",
"def generate_keypair\n key = OpenSSL::PKey::RSA.new 2048\n load_keypair(key.to_pem, key.public_key.to_pem)\n return [@private_key, @public_key]\n end",
"def build_key(public_key, private_key)\n group = OpenSSL::PKey::EC::Group.new('prime256v1')\n key = OpenSSL::PKey::EC.new(group)\n\n public_bn = OpenSSL::BN.new(public_key, 16)\n private_bn = OpenSSL::BN.new(private_key, 16)\n public_key = OpenSSL::PKey::EC::Point.new(group, public_bn)\n\n key.tap do\n key.public_key = public_key\n key.private_key = private_bn\n end\n end",
"def make_keypair\n\t gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')\n\t key_id = gpg.gen_key({\n\t\t :key_type => 'RSA',\n\t\t :key_length => 4096,\n\t\t :subkey_type => 'RSA',\n\t\t :subkey_length => 4096,\n\t\t :name => @dname,\n\t\t :comment => nil,\n\t\t #:email => '',\n\t\t #:passphrase => '',\n\t\t})\n\tend",
"def generate_ssh_key_ruby(type=\"RSA\", bits = 2048, comment = \"OpenShift-Key\")\n key = RHC::Vendor::SSHKey.generate(:type => type,\n :bits => bits,\n :comment => comment)\n ssh_dir = RHC::Config.ssh_dir\n priv_key = RHC::Config.ssh_priv_key_file_path\n pub_key = RHC::Config.ssh_pub_key_file_path\n\n if File.exists?(priv_key)\n say \"SSH key already exists: #{priv_key}. Reusing...\"\n return nil\n else\n unless File.exists?(ssh_dir)\n FileUtils.mkdir_p(ssh_dir)\n File.chmod(0700, ssh_dir)\n end\n File.open(priv_key, 'w') {|f| f.write(key.private_key)}\n File.chmod(0600, priv_key)\n File.open(pub_key, 'w') {|f| f.write(key.ssh_public_key)}\n\n ssh_add\n end\n pub_key\n end",
"def generate_key!\n unless priv_key\n tmp = OpenSSL::PKey.generate_key(self)\n set_key(tmp.pub_key, tmp.priv_key)\n end\n self\n end",
"def generate_key # :nodoc:\n p, g = get_parameters\n\n asn1 = OpenSSL::ASN1::Sequence(\n [\n OpenSSL::ASN1::Integer(p),\n OpenSSL::ASN1::Integer(g)\n ]\n )\n\n dh_params = OpenSSL::PKey::DH.new(asn1.to_der)\n # XXX No private key size check! In theory the latter call should work but fails on OpenSSL 3.0 as\n # dh_paramgen_subprime_len is now reserved for DHX algorithm\n # key = OpenSSL::PKey.generate_key(dh_params, \"dh_paramgen_subprime_len\" => data[:need_bytes]/8)\n if OpenSSL::PKey.respond_to?(:generate_key)\n OpenSSL::PKey.generate_key(dh_params)\n else\n dh_params.generate_key!\n dh_params\n end\n end",
"def generate_keys\n one = 1.to_bn\n # Gera os 2 numeros primos aleatorios\n p = OpenSSL::BN.generate_prime(512, safe=true)\n q = OpenSSL::BN.generate_prime(512, safe=true)\n # gera n\n n = p * q\n # Computa a função totiente phi(n) = (p -1) (q -1)\n phi_n = (p - one) * (q - one)\n # pega o valor de e (pega um primo aleatorio menor que que phi n e testa se é co-primo com phi(n))\n e = OpenSSL::BN.generate_prime(256, safe=true)\n while(phi_n.gcd(e) > one) do\n e = e + one\n end\n # calcula d, o inverso multiplicativo de e\n d = e.to_bn.mod_inverse(phi_n)\n pub_key = [n, e]\n pvt_key = [n, d]\n return [pub_key, pvt_key]\n end",
"def key type\n make_key get_class(type)\n end",
"def create_public_private_rsa_key_pair_strings\r\n private_key = OpenSSL::PKey::RSA.new(2048)\r\n public_key = private_key.public_key\r\n private_public_key_strings_pair = {\r\n 'private_key_string' => private_key,\r\n 'public_key_string' => public_key\r\n }\r\n puts 'The randomly generated 2048-bit RSA private key string is:'\r\n puts private_public_key_strings_pair['private_key_string']\r\n puts 'The corresponding 2048-bit public key string is:'\r\n puts private_public_key_strings_pair['public_key_string']\r\n puts 'Keep a record of these key strings. You will not be able to properly ' \\\r\n 'encrypt and decrypt the contents of objects without these keys.'\r\n return private_public_key_strings_pair\r\nend",
"def generate_key_pair(compressed: true)\n private_key = 1 + SecureRandom.random_number(GROUP.order - 1)\n public_key = GROUP.generator.to_jacobian * private_key\n privkey = ECDSA::Format::IntegerOctetString.encode(private_key, 32)\n pubkey = public_key.to_affine.to_hex(compressed)\n [privkey.bth, pubkey]\n end",
"def generate_keys\n key = OpenSSL::PKey::RSA.new 2048\n self.pubkey = key.public_key.to_s\n self.privkey = key.to_s\n self.save\n end",
"def create\n @public_key = PublicKey.new\n\n new_key_pair = KeyDistributorHelper::generate_key_pair\n @public_key.key = new_key_pair.public_key\n\n # Get a non-matching public_key for the lulz!\n rand_public_key = begin PublicKey.offset(rand(PublicKey.count)).first.key rescue nil end\n\n # Put em together\n new_private_key = new_key_pair.private_key\n @key_pair = KeyDistributorHelper::KeyPair.new new_private_key, rand_public_key\n \n respond_to do |format|\n if @public_key.save\n format.html { render }\n format.json { render json: key_pair, status: :created }\n else\n format.html { render :new }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def openssl_generate_key(*args,&block)\n keypair = OpenSSL::PKey::RSA.new CaHelper.ca_config['key_size']\n end",
"def make_keypair\n\t gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')\n\t key_id = gpg.gen_key({\n\t\t :key_type => 'DSA',\n\t\t :key_length => 1024,\n\t\t :subkey_type => 'ELG-E',\n\t\t :subkey_length => 1024,\n\t\t :name => @dname,\n\t\t :comment => nil,\n\t\t #:email => '',\n\t\t #:passphrase => '',\n\t\t})\n\tend",
"def generate_new_keys(\n name:,\n email: \"\",\n comment: \"\",\n creation_date: Time.now,\n key_validity_seconds: 1.year\n )\n\n generated =\n Rnp.new.generate_key(\n default_key_params(\n name: name,\n email: email,\n comment: comment,\n creation_date: creation_date,\n key_validity_seconds: key_validity_seconds,\n ),\n )\n\n %i[primary sub].map do |key_type|\n raw = generated[key_type]\n creation_hash = creation_params(\n raw: raw, activation_date: creation_date, metadata: raw.json,\n )\n\n RK::Key::PGP.create(creation_hash)\n end\n end",
"def generate_keypair(rsa_bits = DEFAULT_RSA_BITS, digest = DEFAULT_DIGEST)\n cn = \"Akero #{Akero::VERSION}\"\n rsa = OpenSSL::PKey::RSA.new(rsa_bits)\n\n cert = OpenSSL::X509::Certificate.new\n cert.version = 3\n cert.serial = rand(2**42)\n name = OpenSSL::X509::Name.parse(\"/CN=#{cn}\")\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n # valid until 2038-01-19 04:14:06 +0100\n cert.not_after = Time.at(2_147_483_646)\n cert.public_key = rsa.public_key\n\n ef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n ef.issuer_certificate = cert\n cert.extensions = [\n ef.create_extension('basicConstraints', 'CA:FALSE'),\n ef.create_extension('subjectKeyIdentifier', 'hash')\n ]\n aki = ef.create_extension('authorityKeyIdentifier',\n 'keyid:always,issuer:always')\n cert.add_extension(aki)\n cert.sign(rsa, digest.new)\n [rsa, cert]\n end",
"def key_type\n v = version\n case v\n when Bitcoin.chain_params.bip49_pubkey_p2wpkh_p2sh_version\n Bitcoin::Key::TYPES[:p2wpkh_p2sh]\n when Bitcoin.chain_params.bip84_pubkey_p2wpkh_version\n Bitcoin::Key::TYPES[:p2wpkh]\n when Bitcoin.chain_params.extended_pubkey_version\n Bitcoin::Key::TYPES[:compressed]\n end\n end",
"def generate_keypair(*args)\n options[:keypair] = \"#{parent && parent.is_a?(PoolParty::Pool::Pool) ? parent.name : \"poolparty\"}_#{name}\" unless has_keypair?\n end",
"def generate_rsa_keys(p, q)\r\n # Find \"n\", the product of two primes\r\n n = p * q\r\n # Calculate Euler's Totient For The Two Primes\r\n eulers_totient = (p - 1) * (q - 1)\r\n # Find Public Key \"e\" such that 1 < e < totient, e is coprime to totient\r\n key_public = 2\r\n loop do\r\n break if (key_public.gcd(eulers_totient) == 1)\r\n key_public += 1\r\n end\r\n # Find Private Key \"d\" such that e * d * mod(totient) = 1\r\n key_private = 1\r\n loop do\r\n key_private += 1\r\n break if ((key_public * key_private) % eulers_totient == 1)\r\n end\r\n # Public Key = (e,n), Private Key = (d,n)\r\n return [key_public, key_private, n]\r\nend",
"def read_key(type, key=nil, passphrase=nil)\n return key if key.nil?\n\n raise \"Could not find key #{key}\" unless File.exist?(key)\n\n if type == :public\n return OpenSSL::PKey::RSA.new(File.read(key))\n elsif type == :private\n return OpenSSL::PKey::RSA.new(File.read(key), passphrase)\n else\n raise \"Can only load :public or :private keys\"\n end\n end",
"def create(name, write_private)\n new_key = OpenSSL::PKey::RSA.generate(1024)\n new_public = new_key.public_key.to_pem\n new_private = new_key.to_pem\n File.open(File.join(@keystore, \"#{name}.pub\"), 'w') { |f| f.puts new_public }\n File.open(File.join(@keystore, \"#{name}.key\"), 'w') { |f| f.puts new_key } if write_private\n new_key\n end",
"def key_type\n v = version\n case v\n when Bitcoin.chain_params.bip49_privkey_p2wpkh_p2sh_version\n Bitcoin::Key::TYPES[:p2wpkh_p2sh]\n when Bitcoin.chain_params.bip84_privkey_p2wpkh_version\n Bitcoin::Key::TYPES[:p2wpkh]\n when Bitcoin.chain_params.extended_privkey_version\n Bitcoin::Key::TYPES[:compressed]\n end\n end",
"def choose_key_type\n if !config[:use_secret_key]\n 'pub'\n else\n 'sec'\n end\n end",
"def create_key\n @type = params[:type].to_sym\n\n target = Pathname.new(\"~/.ssh/id_rsa\").expand_path\n\n if !target.file?\n o, s = Open3.capture2e(\"ssh-keygen\", \"-t\", \"rsa\", \"-b\", \"4096\", \"-N\", \"\", \"-f\", \"#{ENV['HOME']}/.ssh/id_rsa\")\n success = s.success?\n else\n o = \"SSH key already exists\"\n success = false\n end\n\n respond_to do |format|\n if success\n format.html { redirect_to products_url(type: @type), notice: 'SSH key was successfully created.' }\n format.json { head :no_content }\n else\n format.html { redirect_to products_url(type: @type), alert: \"SSH key failed to be created: #{o}\" }\n format.json { render json: o, status: :internal_server_error }\n end\n end\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def generate\n Puppet.info \"Creating a new SSL key for #{name}\"\n @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)\n end",
"def generate_pem\n OpenSSL::PKey::RSA.generate(2048)\nend",
"def generate_key_pair(compressed: true)\n with_context do |context|\n ret, tries, max = 0, 0, 20\n while ret != 1\n raise 'secp256k1_ec_seckey_verify in generate_key_pair failed.' if tries >= max\n tries += 1\n priv_key = FFI::MemoryPointer.new(:uchar, 32).put_bytes(0, SecureRandom.random_bytes(32))\n ret = secp256k1_ec_seckey_verify(context, priv_key)\n end\n private_key = priv_key.read_string(32).bth\n [private_key, generate_pubkey_in_context(context, private_key, compressed: compressed)]\n end\n end",
"def private_key\n OpenSSL::PKey::RSA.new(_keypair)\n end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def private_key\n # jruby-openssl OpenSSL::PKey::EC support isn't complete\n # https://github.com/jruby/jruby-openssl/issues/189\n jruby_not_implemented(\"OpenSSL::PKey::EC is not fully implemented\") if type == \"ecdsa\"\n\n key_object.to_pem\n end",
"def gen_key\n # get 2 random primes\n p, q = Prime.each.take_while {|x| x <= KEY_SPACE}.sample(2)\n # special easy case of Euler's totient function\n phi = (p-1)*(q-1)\n # calculate modulus, public key, and private key\n n = p*q\n e = get_public(phi)\n d = get_private(phi, e)\n # print results\n puts \"modulus: #{n}\"\n puts \"public key: #{e}\"\n puts \"private key: #{d}\"\n puts \"(internal information)\"\n puts \"phi: #{phi}\"\n puts \"p,q: #{p},#{q}\"\nend",
"def gen_pub_key(tn)\n begin\n pub = rand(3..tn)\n # end until Prime.fermat_prime?(pub) && pub.gcd(tn) == 1\n end until pub % 2 != 0 && pub.gcd(tn) == 1\n pub\n end",
"def new_checkout_key(type)\n CircleCi.request(@conf, \"/project/#{username}/#{project}/checkout-key\").post(type: type)\n end",
"def new_checkout_key(type)\n CircleCi.request(conf, \"#{base_path}/checkout-key\").post(type: type)\n end",
"def generate_key; end",
"def generate_access_key\n access_keys.generate_new\n end",
"def gen_ec_priv_key(curve)\n raise TypeError, \"curve must be a string\" unless curve.is_a?(String)\n raise ArgumentError, \"Specified curve is not available on this system\" unless %w{prime256v1 secp384r1 secp521r1}.include?(curve)\n\n ::OpenSSL::PKey::EC.new(curve).generate_key\n end",
"def get_credit_key(type, name)\n generate_store_key(\"#{type}-c:#{name}\")\n end",
"def ssh_public_key_conversion\n methods = SSH_CONVERSION[type]\n methods.inject([typestr.length].pack(\"N\") + typestr) do |pubkeystr, m|\n # Given public_key_object.class == OpenSSL::BN, public_key_object.to_s(0)\n # returns an MPI formatted string (length prefixed bytes). This is not\n # supported by JRuby, so we still have to deal with length and data separately.\n val = public_key_object.send(m)\n\n case type\n when \"dsa\",\"rsa\" then data = self.class.ssh_public_key_data_dsarsa(val)\n when \"ecdsa\" then data = self.class.ssh_public_key_data_ecdsa(val)\n else\n raise \"Unknown key type: #{type}\"\n end\n\n pubkeystr + [data.length].pack(\"N\") + data\n end\n end",
"def keypair(n=keypair_name)\n cloud_provider.keypair(n)\n end",
"def regenerate_private_key! length = private_key_length\n self[:kopal_encoded_private_key] =\n Base64::encode64(OpenSSL::PKey::RSA.new(length).to_pem)\n end",
"def createkey(hostname, pupmodule, pubfolder, prvfolder)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n key = SelfSignedCertificate.new(hostname)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n |io| io.write key.pub end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write key.crt end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write key.priv end\n 'OK'\nend",
"def priv_key\n key = master_ext_key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true)\n\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(key) { |key, p| key.derive(p) }\n end",
"def make_key(type, name)\n \"%#{type}%#{name}\"\n end",
"def symmetric_key(name, cipher_class, cipher_name, key_abi_type, hooks = {})\n object_wrapper name, Tem::Keys::Symmetric, [key_abi_type, :key],\n :read => lambda { |k| Tem::Keys::Symmetric.new k },\n :to => lambda { |k| k.ssl_key },\n :new => lambda { |klass|\n k = cipher_class.new cipher_name\n \n unless k.respond_to? :key\n # Some ciphers don't give back the key that they receive.\n # We need to synthesize that.\n class <<k\n def key=(new_key)\n super\n @_key = new_key\n end\n def key\n @_key\n end\n end\n end\n k\n }\n end",
"def create(pvt)\n key = Bitcoin::Key.new\n key.priv = pvt\n key.addr\n end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def gen_key(info = {})\n stdin, stdout, stderr = exec3(:gen_key) do |stdin, stdout, stderr|\n stdin.puts \"Key-Type: #{info[:key_type]}\" if info[:key_type]\n stdin.puts \"Key-Length: #{info[:key_length]}\" if info[:key_length]\n stdin.puts \"Subkey-Type: #{info[:subkey_type]}\" if info[:subkey_type]\n stdin.puts \"Subkey-Length: #{info[:subkey_length]}\" if info[:subkey_length]\n stdin.puts \"Name-Real: #{info[:name]}\" if info[:name]\n stdin.puts \"Name-Comment: #{info[:comment]}\" if info[:comment]\n stdin.puts \"Name-Email: #{info[:email]}\" if info[:email]\n stdin.puts \"Expire-Date: #{info[:expire_date]}\" if info[:expire_date]\n stdin.puts \"Passphrase: #{info[:passphrase]}\" if info[:passphrase]\n stdin.puts \"%commit\"\n end\n stderr.each_line do |line|\n if (line = line.chomp) =~ /^gpg: key ([0-9A-F]+) marked as ultimately trusted/\n return $1.to_i(16) # the key ID\n end\n end\n return nil\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n @log.info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def private_key; end",
"def private_key; end",
"def public_key\n encode64(curve.public_key.to_bn.to_s(2))\n end",
"def gen_ssh_key(sshkey, passphrase)\n if !File.exists?(sshkey + \".pub\") then\n if(passphrase) then\n key = SSHKey.generate(:type => \"RSA\", :bits => 2048, :passphrase => prompt_password())\n \n # Write the private key to the file system\n File.open(sshkey, \"w\") { |f| f.write(key.encrypted_private_key) }\n else\n key = SSHKey.generate(:type => \"RSA\", :bits => 2048)\n \n # Write the private key to the file system\n File.open(sshkey, \"w\") { |f| f.write(key.private_key) }\n end\n\n # Write the public key to the file system\n File.open(sshkey + \".pub\", \"w\") { |f| f.write(key.ssh_public_key) }\n end\n end",
"def public_key\n DH.new(to_der)\n end",
"def builder_keypair\n if File.exists?(\"#{cluster_data_dir}/builder_key\")\n OpenSSL::PKey::RSA.new(File.read(\"#{cluster_data_dir}/builder_key\"))\n else\n OpenSSL::PKey::RSA.generate(2048)\n end\n end",
"def private_key\n @private_key ||= case private_key_type\n when 'p12'\n OpenSSL::PKCS12.new(private_key_string, private_key_password).key\n else\n OpenSSL::PKey::RSA.new(private_key_string, private_key_password)\n end if private_key_string\n end",
"def generate_key(compressed: true)\n privkey, pubkey = generate_key_pair(compressed: compressed)\n Tapyrus::Key.new(priv_key: privkey, pubkey: pubkey, compressed: compressed)\n end",
"def createkey(hostname, pupmodule, pubfolder, prvfolder, subject, ca_key_file,\nca_crt_file, passphrase)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n ca_key = OpenSSL::PKey::RSA.new File.read(ca_key_file), passphrase\n ca_cert = OpenSSL::X509::Certificate.new File.read ca_crt_file\n c=SignedCertificate.new(ca_key, ca_cert, subject)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n #|io| io.write c.key.public_key.to_pem end\n #open \"#{pubfolder}/#{pupmodule}/#{hostname}.csr.pem\", 'w' do\n #|io| io.write c.csr.to_pem end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write c.cert.to_pem end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write c.key.to_pem end\n 'OK'\nend",
"def initialize(private_key, options = {})\n @passphrase = options[:passphrase]\n @comment = options[:comment] || \"\"\n self.directives = options[:directives] || []\n\n begin\n @key_object = OpenSSL::PKey::RSA.new(private_key, passphrase)\n @type = \"rsa\"\n @typestr = \"ssh-rsa\"\n rescue OpenSSL::PKey::RSAError\n @type = nil\n end\n\n return if @type\n\n begin\n @key_object = OpenSSL::PKey::DSA.new(private_key, passphrase)\n @type = \"dsa\"\n @typestr = \"ssh-dss\"\n rescue OpenSSL::PKey::DSAError\n @type = nil\n end\n\n return if @type\n\n @key_object = OpenSSL::PKey::EC.new(private_key, passphrase)\n @type = \"ecdsa\"\n bits = ECDSA_CURVES.invert[@key_object.group.curve_name]\n @typestr = \"ecdsa-sha2-nistp#{bits}\"\n end",
"def private_key_get\n return @priv_key unless @priv_key.nil?\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n case resource[:auth_type].downcase\n when 'dsa'\n OpenSSL::PKey::DSA.new(file, resource[:key_password])\n when 'rsa'\n OpenSSL::PKey::RSA.new(file, resource[:key_password])\n when 'ec'\n OpenSSL::PKey::EC.new(file, resource[:key_password])\n else\n raise Puppet::Error, \"Unknown authentication type '#{resource[:auth_type]}'\"\n end\n else\n false\n end\n end",
"def set_keypair\n # The generated keypair is stored in PEM encoding.\n self._keypair ||= OpenSSL::PKey::RSA.new(2048).to_pem\n self.jwk_kid = public_jwk.kid\n end",
"def set_keypair\n # The generated keypair is stored in PEM encoding.\n self._keypair ||= OpenSSL::PKey::RSA.new(2048).to_pem\n self.jwk_kid = public_jwk.kid\n end",
"def create_keys_files(config_data,external_private_key_path,internal_private_key_path,internal_public_key_path)\n if !File.exist?(external_private_key_path) and !File.exist?(internal_private_key_path)\n File.open(external_private_key_path, \"w\") do |f|\n config_data['keys']['external_private_key'].each { |element| f.puts(element) }\n end\n File.chmod(0600,external_private_key_path)\n File.open(internal_private_key_path, \"w\") do |f|\n config_data['keys']['internal_private_key'].each { |element| f.puts(element) }\n end\n File.chmod(0600,internal_private_key_path)\n end\n if !File.exist?(internal_public_key_path)\n shell_cmd = \"ssh-keygen -y -f #{internal_private_key_path}\"\n generated_key = %x[ #{shell_cmd} ]\n File.open(internal_public_key_path, \"w\") do |f|\n f.puts(generated_key)\n end\n end\nend",
"def compute_key(pub_bn)\n peer = dup\n peer.set_key(pub_bn, nil)\n derive(peer)\n end",
"def compute_key(pub_bn)\n peer = dup\n peer.set_key(pub_bn, nil)\n derive(peer)\n end",
"def one_time_public_key\n token = generate_token('get_encription_public_key', @public_key)\n response = commit(:pci_encryption_key, token: token)\n response.params['encryption_key']\n end",
"def urlsafe_base64_asymmetric_encrypt(data, public_key)\n # Load key\n pkey = OpenSSL::PKey::RSA.new(public_key, nil)\n raise 'Invalid public key.' unless pkey.public?\n\n # Encrypt data\n encrypted_data = pkey.public_encrypt(data)\n # Encode encrypted data with custom Encoder\n custom_base64_urlsafe_encode(encrypted_data)\n end",
"def make_key t\n (sig_key(t) + sum_key(t))[0..MAX_KEY_SIZE].sub(/\\0+\\z/, \"\")\n end",
"def create_keypair\n return false unless keypair\n unless ::File.exists?( new_keypair_path )\n FileUtils.mkdir_p ::File.dirname( new_keypair_path )\n Kernel.system \"ec2-add-keypair #{keypair} > #{new_keypair_path} && chmod 600 #{new_keypair_path}\"\n end\n end",
"def masa_pki\n masakey.public_key.to_der\n end",
"def pubkey\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(payment_base) { |key, p| key.derive(p) }\n end",
"def key_generator; end",
"def key_generator; end",
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def private_key\n encode64(curve.private_key.to_s(2))\n end",
"def generate_keys(from_wallet_name, master_key)\n ks = { 'master' => master_key }\n %w(recovery money social memo).each do |role|\n private_key = Xgt::Ruby::Auth.generate_wif(from_wallet_name, master_key, 'recovery')\n public_key = Xgt::Ruby::Auth.wif_to_public_key(private_key, @address_prefix)\n ks[\"#{role}_private\"] = private_key\n ks[\"#{role}_public\"] = public_key\n end\n ks['wallet_name'] = Xgt::Ruby::Auth.generate_wallet_name(ks['recovery_public'])\n ks\nend",
"def encrypted_private_key\n return private_key unless passphrase\n key_object.to_pem(OpenSSL::Cipher.new(\"AES-128-CBC\"), passphrase)\n end",
"def gen_rsa_priv_key(key_length)\n raise ArgumentError, \"Key length must be a power of 2 greater than or equal to 1024\" unless key_length_valid?(key_length)\n\n ::OpenSSL::PKey::RSA.new(key_length)\n end",
"def gen_rsa_priv_key(key_length)\n raise ArgumentError, \"Key length must be a power of 2 greater than or equal to 1024\" unless key_length_valid?(key_length)\n\n ::OpenSSL::PKey::RSA.new(key_length)\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def key_type(type)\n # Specify valid types of key.\n valid_types = [:major, :minor]\n if valid_types.include?(type)\n # If the type is valid we must also check for consistency with the tonic note.\n if type == :minor && (@metadata[:key_note] == :cb || @metadata[:key_note] == :gb || @metadata[:key_note] == :db)\n # Cb, Gb, Db minors are NOT valid.\n raise \"Key note #{ @metadata[:key_note] } not valid for a #{ type } key.\"\n elsif type == :major && (@metadata[:key_note] == :gs || @metadata[:key_note] == :ds || @metadata[:key_note] == :as)\n # Gs, Ds, As majors are NOT valid.\n raise \"Key note #{ @metadata[:key_note] } not valid for a #{ type } key.\"\n else\n # Key is valid if no key note is specified, or it does not fall into one of the above cases.\n @metadata[:key_type] = type\n end\n else\n raise \"The type of key: #{ type } is not supported.\"\n end\n return self\n end",
"def key_types; end",
"def key_types; end",
"def generate_key( username, password, contract)\n response_xml = self.call( :generate_key, message: {\n arg0: username,\n arg1: password,\n arg2: contract\n })\n response = IssueCentre::Response.parse( response_xml,\n {contract_id: contract})\n end",
"def create_key\n self.key = Digest::MD5.hexdigest(self.official_id.to_s + self.sent_to_email)\n end",
"def key_algorithm\n if @req.public_key.kind_of? OpenSSL::PKey::RSA then\n 'RSA'\n elsif @req.public_key.kind_of? OpenSSL::PKey::DSA then\n 'DSA'\n end\n end",
"def create_inception_key_pair\n say \"Creating ssh key pair for Inception VM...\"\n create_key_pair_store_in_settings(\"inception\")\n end",
"def createEc2SSHKey\n\t\t\treturn [@keypairname, @ssh_private_key, @ssh_public_key] if [email protected]?\n\t\t keyname=\"deploy-#{MU.mu_id}\"\n\t\t\tkeypair = MU.ec2(MU.myRegion).create_key_pair(key_name: keyname)\n\t\t\t@keypairname = keyname\n\t\t @ssh_private_key = keypair.key_material\n\t\t\tMU.log \"SSH Key Pair '#{keyname}' fingerprint is #{keypair.key_fingerprint}\"\n\t\t\n\t\t if !File.directory?(\"#{@myhome}/.ssh\") then\n\t\t\t\tMU.log \"Creating #{@myhome}/.ssh\", MU::DEBUG\n\t\t Dir.mkdir(\"#{@myhome}/.ssh\", 0700)\n\t\t end\n\t\t\n\t\t # Plop this private key into our local SSH key stash\n\t\t\tMU.log \"Depositing key '#{keyname}' into #{@myhome}/.ssh/#{keyname}\", MU::DEBUG\n\t\t ssh_keyfile = File.new(\"#{@myhome}/.ssh/#{keyname}\", File::CREAT|File::TRUNC|File::RDWR, 0600)\n\t\t ssh_keyfile.puts @ssh_private_key\n\t\t ssh_keyfile.close\n\n\t\t\t# Drag out the public key half of this\n\t\t\t@ssh_public_key = %x{/usr/bin/ssh-keygen -y -f #{@myhome}/.ssh/#{keyname}}\n\t\t\t@ssh_public_key.chomp!\n\n\t\t\t# Replicate this key in all regions\n\t\t\tMU::Config.listRegions.each { |region|\n\t\t\t\tnext if region == MU.myRegion\n\t\t\t\tMU.log \"Replicating #{keyname} to #{region}\", MU::DEBUG, details: @ssh_public_key\n\t\t\t\tMU.ec2(region).import_key_pair(\n\t\t\t\t\tkey_name: @keypairname,\n\t\t\t\t\tpublic_key_material: @ssh_public_key\n\t\t\t\t)\n\t\t\t}\n\n# XXX This library code would be nicer... except it can't do PKCS8.\n#\t\t\tfoo = OpenSSL::PKey::RSA.new(@ssh_private_key)\n#\t\t\tbar = foo.public_key\n\n\t\t\tsleep 3\n\t\t return [keyname, keypair.key_material, @ssh_public_key]\n\t\tend",
"def make_keys!\n root_dir = SAFE_KEYS_DIR\n object_id = self.id\n pass = self.password \n raise Safe::KeygenError if object_id.nil? || pass.nil?\n dir_class = root_dir + \"/#{self.class.to_s.tableize}/\"\n dir = dir_class + \"#{object_id}/\"\n if File.exists?(root_dir) && File.directory?(root_dir)\n Dir.mkdir(dir_class) unless File.exists?(dir_class)\n Dir.mkdir(dir) unless File.exists?(dir)\n gen_keypair(dir, pass)\n else\n Dir.mkdir(root_dir)\n Dir.mkdir(dir_class)\n Dir.mkdir(dir)\n gen_keypair(dir, pass)\n end \n end"
] | [
"0.729749",
"0.66765815",
"0.66422683",
"0.63273656",
"0.625815",
"0.6220553",
"0.61587065",
"0.61463636",
"0.61270756",
"0.61120385",
"0.6096021",
"0.6094618",
"0.6069927",
"0.60410285",
"0.6017853",
"0.5986215",
"0.5859098",
"0.5844397",
"0.5822082",
"0.5821618",
"0.579483",
"0.5755308",
"0.5752925",
"0.5737605",
"0.5722458",
"0.5703384",
"0.56838995",
"0.56671524",
"0.56640667",
"0.565502",
"0.5637201",
"0.5627376",
"0.56212074",
"0.55935794",
"0.5564095",
"0.5558415",
"0.5554055",
"0.55234176",
"0.55197024",
"0.55083495",
"0.55047",
"0.5479898",
"0.54681265",
"0.54662764",
"0.54412043",
"0.54278225",
"0.5423103",
"0.5399468",
"0.5387912",
"0.5377465",
"0.53456366",
"0.53456366",
"0.53456366",
"0.53456366",
"0.53456366",
"0.53431475",
"0.53384256",
"0.53294456",
"0.5308875",
"0.5308875",
"0.5307046",
"0.52969927",
"0.5290659",
"0.5282155",
"0.5273643",
"0.52711874",
"0.5266155",
"0.5265051",
"0.524986",
"0.5245835",
"0.5245835",
"0.5237836",
"0.52345365",
"0.52345365",
"0.5227562",
"0.52112216",
"0.5202389",
"0.52022594",
"0.5200681",
"0.5196382",
"0.51838446",
"0.51838446",
"0.51831156",
"0.51831156",
"0.51831156",
"0.5168711",
"0.51655066",
"0.51644814",
"0.5161957",
"0.5161957",
"0.5130102",
"0.5125398",
"0.51244134",
"0.51244134",
"0.5123583",
"0.512184",
"0.5119001",
"0.5102527",
"0.5086504",
"0.5078203"
] | 0.7097795 | 1 |
Imports the Private key from material representation. | def import_private_key(key_bytes, password = nil)
key_bytes = Validation.check_filled_array_argument!(key_bytes)
begin
decrypted_private_key = if !password
Core::VirgilKeyPair.private_key_to_der(key_bytes)
else
Core::VirgilKeyPair.decrypt_private_key(
key_bytes,
Bytes.from_string(password)
)
end
public_key_bytes = Core::VirgilKeyPair.extract_public_key(
decrypted_private_key, []
)
key_pair_id = compute_public_key_hash(public_key_bytes)
private_key_bytes = Core::VirgilKeyPair.private_key_to_der(
decrypted_private_key
)
return VirgilPrivateKey.new(key_pair_id, wrap_bytes(private_key_bytes))
rescue => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def priv_key\n key = master_ext_key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true)\n\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(key) { |key, p| key.derive(p) }\n end",
"def private_key\n @private_key ||= load_key(@private_key_file)\n end",
"def private_key\n @private_key.to_der\n end",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n @n, @e= publickey\n @privatekey=privatekey\n #puts $n, $e, $privatekey\n end",
"def private_key_get\n return @priv_key unless @priv_key.nil?\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n case resource[:auth_type].downcase\n when 'dsa'\n OpenSSL::PKey::DSA.new(file, resource[:key_password])\n when 'rsa'\n OpenSSL::PKey::RSA.new(file, resource[:key_password])\n when 'ec'\n OpenSSL::PKey::EC.new(file, resource[:key_password])\n else\n raise Puppet::Error, \"Unknown authentication type '#{resource[:auth_type]}'\"\n end\n else\n false\n end\n end",
"def private_key\n @priv\n end",
"def load_private_key_password\n Puppet::FileSystem.read(Puppet[:passfile], :encoding => Encoding::BINARY)\n rescue Errno::ENOENT\n nil\n end",
"def private_key\n @private_key ||= case private_key_type\n when 'p12'\n OpenSSL::PKCS12.new(private_key_string, private_key_password).key\n else\n OpenSSL::PKey::RSA.new(private_key_string, private_key_password)\n end if private_key_string\n end",
"def importprivkey(bitcoinprivkey, label = nil, rescan = true)\n @api.request 'importprivkey', bitcoinprivkey, label, rescan\n end",
"def export_private_key(private_key, password = nil)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n unless password\n return Core::VirgilKeyPair.private_key_to_der(\n private_key.raw_key\n )\n end\n password_bytes = Bytes.from_string(password)\n private_key_bytes = Core::VirgilKeyPair.encrypt_private_key(\n private_key.raw_key,\n password_bytes\n )\n wrap_bytes(\n Core::VirgilKeyPair.private_key_to_der(\n private_key_bytes,\n password_bytes\n )\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def load_keypair(private_key, public_key)\n @private_key = private_key\n @public_key = public_key\n @private_rsa = OpenSSL::PKey::RSA.new @private_key\n @public_rsa = OpenSSL::PKey::RSA.new @public_key\n end",
"def load_private_key(path, password: nil)\n file_name = File.expand_path path\n if !File.exists?(file_name)\n file_name += \".private.unikey\"\n raise NotFoundException.new(path) unless File.exists?(file_name)\n end\n open(file_name, 'rb') { |f| Universa::PrivateKey.from_packed(f.read, password: password) }\n end",
"def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end",
"def private_key=(private_key); end",
"def load_private_key\n @private_rsa = nil\n \n if private_key_file && File.file?(private_key_file)\n @private_key = File.read(private_key_file)\n end\n end",
"def private_key\n read_attribute(:private_key) || reset_private_key\n end",
"def private_key!\n if self[:kopal_encoded_private_key].blank?\n regenerate_private_key!\n end\n OpenSSL::PKey::RSA.new Base64::decode64(self[:kopal_encoded_private_key])\n end",
"def get_private_key\n return @private_key\n end",
"def load_private_key(filename, passphrase = T.unsafe(nil), ask_passphrase = T.unsafe(nil), prompt = T.unsafe(nil)); end",
"def private_key\n return @priv_key unless @priv_key.nil?\n\n # Verify that the given directory exists\n unless File.directory?(resource[:priv_key_dir])\n raise ArgumentError, \"Directory not found for: #{resource[:priv_key_dir]}\"\n end\n\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n OpenSSL::PKey.read(file, resource[:priv_key_password])\n else\n false\n end\n end",
"def private_key\n # jruby-openssl OpenSSL::PKey::EC support isn't complete\n # https://github.com/jruby/jruby-openssl/issues/189\n jruby_not_implemented(\"OpenSSL::PKey::EC is not fully implemented\") if type == \"ecdsa\"\n\n key_object.to_pem\n end",
"def private_key_pem\n @private_key.to_pem\n end",
"def load_public_key(filename); end",
"def private_key\n encode64(curve.private_key.to_s(2))\n end",
"def private_key; end",
"def private_key; end",
"def encrypted_private_key\n return private_key unless passphrase\n key_object.to_pem(OpenSSL::Cipher.new(\"AES-128-CBC\"), passphrase)\n end",
"def require_key\n fail 'No private key loaded' unless @private_key\n end",
"def private_key\n OpenSSL::PKey::RSA.new(_keypair)\n end",
"def import_key(identifier, key)\n file = Tempfile.open(\"backup-gpg_import\", Config.tmp_path)\n file.write(key.gsub(%r{^[[:blank:]]+}, \"\"))\n file.close\n ret = run \"#{utility(:gpg)} #{base_options} \" \\\n \"--keyid-format 0xlong --import '#{file.path}' 2>&1\"\n file.delete\n\n keyid = ret.match(%r{ 0x(\\w{16})}).to_a[1]\n raise \"GPG Returned:\\n#{ret.gsub(%r{^\\s*}, \" \")}\" unless keyid\n\n keyid\n rescue => err\n Logger.warn Error.wrap(\n err, \"Public key import failed for '#{identifier}'\"\n )\n nil\n end",
"def private_key\n\t '-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3D37CD3A313CADA2 7c1TAxzv6Gn2OmZzVNtEnU9lqrEwRL65huGc9ewQQ7senY3rkBgIqBzqVarAfS0I 6OMimI57q7XywAiFn7CZ+L7fbXdNuvmGx5JDNRwylgGWR+hPi9JMKEAP1yjdJPRS 608pDXIliz5bO0GdvufQxQ91MPjE4Bs5AT8TIE3bzuFllBYJD/mLpkK4bOjLHswI 7W7afVctpYaRAwzb64Z+gUQZL0BIcQzG2wYvFU3vAs5sCtEy9o7riY/bBi78EEH6 go01DkgYLt8M7ApTwblJNJR0G/8bwy3oDgdieM42sFLzftxwjeBhIiF1ExH+KuYA ftAcROOfr8rduvNNc6jJcx2lyze+4joPjHDBXZr27bg3o3SwOQCIXUHe0DHG0PHn TbZkL2btHH36mTMq0j6P9R4t1wLhJ8Pq2LjLDwLhXw3Tb8aIX1tpShxyy9Yv8F84 Q6dfBLe4yqmvW1Db2nGmZ++gPua2OGWuNXwjivt2XrZ0fGAGri5j9bsqyvDsHwUS aRs8PaG97rgmyRGHYUoicBdgeFZhBHSLlU5F6RNUTOgK9QAHP4+bdKbMQxvhveh8 +v9o7Xa7BlqEvUYXIfBwEbHZoJx4t90XSndSS3chlfoEb6vcxOBmplUZlWs55aSL U7dW1MaE48Afav6TtM2VsN9RzwU8QSplpm7z9C9xkYVBMN6UcKIbnHH1yXdhTGEG uaEvPrtSh+BroAx1OmMjkmb0s1PjgDqLEtaYifP1OXgSS3uTqPBcpgUZDnuYQZmW Ihv7SvGdyWVQUgpv5LukyZPhXdlsCQ+8TlEYn4MOl87uxqo3KCVzVdmhAx2PWS/q wLcyOq0wJuvgAAtmI4/EnXVaP5P6WQ7rixfxdDfR1nI5TnDQkgs2xquyb0cms0J+ hXkIGvQOMAzq2Js3Ad7qyiklDASR20zZt6JPKTgZpLq682Fx+LJCCryAqjye2nAI 0w5SHEd80J/lAUEYo/HrNDBWS0JzD4lfERwUxgXxvynFI1ak38h0YP9RR2ka0pMI DJ8G6/w3Ir1qgLM/E+bTvp1YE683J/j1+vdYC/eoAbki2wgJAitYFdexLpw/qMvj xonY4iyhVkgzQb0GObesjPhr0CQ1gRC8p/A68Pk4cXejKTO95gUnD682Mu6lgYXQ e3rEnNVUruiPEzMKbkPLIsaWfUKfGRb0okQmuISXEfjyLfjkUgD6bxes+9KuHdvj pZze3dOgB1W6ZGsbrQ8ooXAOewYbhDcEqVsPOItVBoZ14CmCSd1X8RiW1dnfZBLa 5W8L7HaVLgiKUWlu2N6BE3etMK/fzhLh1K8WT6PxqzqVfJZZ9TYwVSYbcJuej0Hf ioHwYgqO22aZrp+ciJplCyOooFOKVVW45iLPtSHX64aE6FKbdPEPcndIOl0J9ah0 Hwicaw0ADP4STb83NysAZdHO2UVNEERkp2P4XmgeeH3gYHhPv3xCbbDejrrRJjeq VRer8i6HxiuJ/SxNKvbiwztF/44nWJ+9m2FoNqumTITdQAx7VU3681uEsO9ZbsJU Lbt0zwxna4X6WEtjdy5ExqLlU+wnzWgG+I11vgXSarye2oTuGPK8wjBkfEqdRTxs -----END RSA PRIVATE KEY----- '\n\tend",
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def load_data_private_key(data, passphrase = T.unsafe(nil), ask_passphrase = T.unsafe(nil), filename = T.unsafe(nil), prompt = T.unsafe(nil)); end",
"def private_decrypt(ciphertext)\n @private_key.private_decrypt(ciphertext)\n end",
"def private_key\n @key\n end",
"def extract_private_key(options)\n extract_key(\n options[:private_key] || options[:key_pair] || ENV['PRIVATE_KEY'],\n options[:private_key_password] || ENV['PRIVATE_KEY_PASSWORD']\n )\n end",
"def get_host_private_key(host)\n private_key = host.puppet['hostprivkey']\n # puppet may not have laid down the private_key yet, so check to make sure\n # the file exists\n host.execute(\"test -f #{private_key}\")\n host.execute(\"cat #{private_key}\", :silent => true)\n end",
"def auth_key_from_pem\n public_key = private_key.public_key\n Base64.strict_encode64(public_key.to_der)\n end",
"def private_rsa\n if password\n options = {:password => password}\n options[:algorithm] = algorithm if algorithm\n \n private_key = @private_key.decrypt(:symmetric, options)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def load_private_key(filename, passphrase = nil, ask_passphrase = true, prompt = Prompt.default)\n data = File.read(File.expand_path(filename))\n load_data_private_key(data, passphrase, ask_passphrase, filename, prompt)\n end",
"def load(enc_hs, key = nil)\n enc_attr = EncryptedMash.json_create(enc_hs)\n decrypted = enc_attr.decrypt(key || local_key)\n decrypted['content'] # TODO: check this Hash\n end",
"def initialize(private_key, opts = { public_key: nil, passphrase: nil })\n if private_key.is_a? OpenSSL::PKey::RSA\n @private_key = private_key\n elsif !private_key.to_s.eql?('')\n @private_key = OpenSSL::PKey::RSA.new(\n if File.exists?(File.expand_path(private_key))\n File.read(File.expand_path(private_key))\n else\n private_key\n end,\n opts[:passphrase]\n )\n unless @private_key.private?\n raise(\n Cryptic::InvalidKey,\n \"Public key '#{private_key}' provided as a private key.\"\n )\n end\n end\n\n if public_key.is_a? OpenSSL::PKey::RSA\n @public_key = public_key\n else\n @public_key = OpenSSL::PKey::RSA.new(\n if opts[:public_key] && File.exists?(File.expand_path(opts[:public_key].to_s))\n File.read(File.expand_path(opts[:public_key].to_s))\n elsif opts[:public_key]\n opts[:public_key]\n else\n @private_key or raise(Cryptic::KeyNotFound)\n end,\n opts[:passphrase]\n ).public_key\n end\n rescue OpenSSL::PKey::RSAError => e\n if e.message.eql? 'Neither PUB key nor PRIV key:: not enough data'\n if @private_key.nil?\n raise Cryptic::InvalidKey, \"Invalid private key: #{private_key}\"\n elsif @public_key.nil?\n raise Cryptic::InvalidKey, \"Invalid public key: #{public_key}\"\n end\n elsif e.message.eql? 'Neither PUB key nor PRIV key:: nested asn1 error'\n raise Cryptic::IncorrectPassphrase, \"Unable to open private key:\n '#{private_key}'. was the passphrase valid?\"\n else\n raise e\n end\n end",
"def read_key(type, key=nil, passphrase=nil)\n return key if key.nil?\n\n raise \"Could not find key #{key}\" unless File.exist?(key)\n\n if type == :public\n return OpenSSL::PKey::RSA.new(File.read(key))\n elsif type == :private\n return OpenSSL::PKey::RSA.new(File.read(key), passphrase)\n else\n raise \"Can only load :public or :private keys\"\n end\n end",
"def export_public_key\n public_key = context.crypto.extract_public_key(private_key)\n VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))\n end",
"def key_passphrase=(pw)\n raise PrivateKeyDecrypted, 'private_key already given' if @private_key\n\n @private_key = OpenSSL::PKey::RSA.new(@raw_private_key, pw)\n\n @raw_private_key = nil\n nil\n end",
"def import_public_key key_name, pubkey, fprint=nil\n params = { \n 'KeyName' => key_name,\n 'PublicKey' => pubkey\n }\n params.merge!( 'Fingerprint' => fprint ) unless fprint.nil?\n\n response = @client.action \"ImportPublicKey\", params\n\n Response::Credential.new response.body[\"ImportPublicKeyResponse\"]['return']\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def key_pem; end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def decode_openssh_private_key(raw)\n total_read = 0\n\n magic = raw.byteslice(total_read, OPENSSH_PRIVATE_KEY_MAGIC.bytesize)\n unless magic == OPENSSH_PRIVATE_KEY_MAGIC\n raise DecodeError, \"bad OpenSSH private key\"\n end\n total_read += OPENSSH_PRIVATE_KEY_MAGIC.bytesize\n\n data, read = decode_fields(raw, OPENSSH_PRIVATE_KEY_FIELDS, total_read)\n total_read += read\n\n # TODO: add support for encrypted private keys\n unless data[:ciphername] == \"none\" && data[:kdfname] == \"none\"\n raise DecryptError, \"cannot decode encrypted private keys\"\n end\n\n data[:public_keys], read = decode_n_strings(raw, total_read, data[:nkeys])\n total_read += read\n\n privs, read = decode_string(raw, total_read)\n total_read += read\n\n privs_read = 0\n\n data[:checkint1], read = decode_uint32(privs, privs_read)\n privs_read += read\n\n data[:checkint2], read = decode_uint32(privs, privs_read)\n privs_read += read\n\n unless data[:checkint1] == data[:checkint2]\n raise DecryptError, \"bad private key checksum\"\n end\n\n data[:private_keys] = data[:nkeys].times.map do\n algo, read = decode_string(privs, privs_read)\n privs_read += read\n\n unless fields = KEY_FIELDS_BY_PRIVATE_KEY_ALGO[algo]\n raise AlgorithmError, \"unknown algorithm: #{algo.inspect}\"\n end\n\n priv_data, read = decode_fields(privs, fields, privs_read)\n privs_read += read\n\n comment, read = decode_string(privs, privs_read)\n privs_read += read\n\n priv_data.merge(algo: algo, comment: comment)\n end\n\n # padding at end is bytes 1, 2, 3, 4, etc...\n data[:padding] = privs.byteslice(privs_read..-1)\n unless data[:padding].bytes.each_with_index.all? { |b, i| b == (i + 1) % 255 }\n raise DecodeError, \"bad padding: #{data[:padding].inspect}\"\n end\n\n [data, total_read]\n end",
"def initialize(pvt_key_string)\n @pvt_key_string = pvt_key_string\n @pvt_key = PrivateKey.new pvt_key_string\n log 'pvt key', @pvt_key\n @address = @pvt_key.address_str\n log 'address', @address\n end",
"def key(keygap)\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key = Keygap.new.merge(key, keygap)\n @log.debug(\"The private key of @#{@login} reassembled: #{key.to_s.length} chars\")\n key\n end",
"def recover_private_key(buffer, params, signature, k)\n q = params[1]\n r, s = signature\n ((s * k - SHA1.hexdigest(buffer).to_i(16)) * invmod(r, q)) % q\nend",
"def private_key=(k)\n return self.authentication.private_key = k\n end",
"def private_key=(k)\n return self.authentication.private_key = k\n end",
"def generate_keypair\n key = OpenSSL::PKey::RSA.new 2048\n load_keypair(key.to_pem, key.public_key.to_pem)\n return [@private_key, @public_key]\n end",
"def decrypt(string)\n require_key\n\n @private_key.private_decrypt(Base64.decode64(string))\n end",
"def private_rsa\n if @key\n private_key = @private_key.decrypt(:symmetric, :key => @key, :algorithm => @algorithm)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def from_wif\n addr = Dash::WIF.new(string: self)\n addr ? addr.private_key : nil\n end",
"def imported_password_hash\n @attributes[:imported_password_hash]\n end",
"def load_data_public_key(data, filename = T.unsafe(nil)); end",
"def privkey(add_compressed_suffix=false)\n compressed_suffix = add_compressed_suffix && compressed ? \"01\" : \"\"\n [key.private_key.to_s(16) + compressed_suffix].pack('H*')\n end",
"def private_key\n return self.authentication.private_key\n end",
"def private_key\n return self.authentication.private_key\n end",
"def extract_public_key(private_key)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n public_key_bytes = Core::VirgilKeyPair.extract_public_key(\n private_key.raw_key,\n []\n )\n VirgilPublicKey.new(\n private_key.id,\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key_bytes)\n )\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def decrypt(data)\n raise NoPrivateKeyError, \"Private key file: #{@private_key_file}\" unless private?\n \n decrypted_data = Base64.decode64(data)\n private_rsa.private_decrypt(decrypted_data)\n end",
"def ssh_private_key(name)\n get(driver_url + API_BASE + \"nodes/#{name}/attribs/#{KEY_ATTRIB}\")\n end",
"def public_key\n require_key\n\n @private_key.public_key.to_pem\n end",
"def load_key(key_file)\n OpenSSL::PKey::RSA.new(File.read(key_file), @password)\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def extract_key(key, password = nil)\n return nil unless key\n\n case key\n when Proc then extract_key_from_proc(key, password)\n when Symbol then extract_key_from_method(key, password)\n when ::OpenSSL::PKey::RSA then key\n else\n key = retrieve_key_string_from_stream(key)\n return ::OpenSSL::PKey::RSA.new(key) if password.nil?\n ::OpenSSL::PKey::RSA.new(key, password.to_s)\n end\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n @log.info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def privatize(txt)\n private_properties unless defined?(@private_props)\n @private_props.each{|v| txt.gsub!(v,\"-private-\") }\n txt.gsub!(decrypt_string_with_prefix(SS_integration_password_enc), \"-private-\") if defined?(SS_integration_password)\n txt\n end",
"def import(api_params)\n #api_params[:privatekey] = api_params[:ssh_private_key].read\n #api_params[:publickey] = api_params[:ssh_public_key].read\n api_params[:publickey] = api_params[:ssh_public_key]\n api_params[:privatekey] = api_params[:ssh_private_key]\n api_request(SSHKEYS, CREATE, api_params)\n end",
"def generate_key!\n unless priv_key\n tmp = OpenSSL::PKey.generate_key(self)\n set_key(tmp.pub_key, tmp.priv_key)\n end\n self\n end",
"def public_key\n @public_key.to_der\n end",
"def decrypt()\n \t@private_key = AES.decrypt(self.encrypted_private_key, ENV[\"DECRYPTION_KEY\"])\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def public_key\n @priv.public_key\n end",
"def build_key(public_key, private_key)\n group = OpenSSL::PKey::EC::Group.new('prime256v1')\n key = OpenSSL::PKey::EC.new(group)\n\n public_bn = OpenSSL::BN.new(public_key, 16)\n private_bn = OpenSSL::BN.new(private_key, 16)\n public_key = OpenSSL::PKey::EC::Point.new(group, public_bn)\n\n key.tap do\n key.public_key = public_key\n key.private_key = private_bn\n end\n end",
"def initialize(json: nil, path: nil)\n if json\n load_privatekeyjson(json)\n elsif path\n load_privatekeyfile(path)\n end\n end",
"def load(serialized)\n if serialized && serialized.class == String\n begin\n Date.parse(serialized.decrypt(:symmetric, :password => Rails.application.secrets.secret_key_base))\n rescue\n nil\n end\n else\n nil\n end\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def import_public_key(key_bytes)\n key_bytes = Validation.check_filled_array_argument!(key_bytes)\n\n begin\n key_pair_id = compute_public_key_hash(key_bytes)\n public_key_bytes = Core::VirgilKeyPair.public_key_to_der(key_bytes)\n VirgilPublicKey.new(key_pair_id, wrap_bytes(public_key_bytes))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def load_data_private_key(data, passphrase = nil, ask_passphrase = true, filename = \"\", prompt = Prompt.default)\n key_type = classify_key(data, filename)\n\n encrypted_key = nil\n tries = 0\n\n prompter = nil\n result =\n begin\n key_type.read(data, passphrase || 'invalid')\n rescue *key_type.error_classes => e\n encrypted_key = !!key_type.encrypted_key?(data, e) if encrypted_key.nil?\n if encrypted_key && ask_passphrase\n tries += 1\n if tries <= 3\n prompter ||= prompt.start(type: 'private_key', filename: filename, sha: Digest::SHA256.digest(data))\n passphrase = prompter.ask(\"Enter passphrase for #{filename}:\", false)\n retry\n else\n raise\n end\n else\n raise\n end\n end\n prompter.success if prompter\n result\n end",
"def load_key_string(key_string)\n Rnp.new.tap do |rnp|\n rnp.load_keys(\n format: \"GPG\",\n input: Rnp::Input.from_string(key_string),\n public_keys: true,\n secret_keys: true,\n )\n end\n end",
"def load(key_store_file, password)\n\n end",
"def decode!(passphrase)\n JSON(decrypt(passphrase)).each do |k,v|\n self.send(\"#{k}=\", v)\n end\n end",
"def load_pubkey\n #filter line data\n load_raw_line([:key_data,:key_type,:note]) \n \n # sanitize old raw line\n self.raw_line = self.gen_raw_line\n end",
"def get_initial_password_v2(instance_id, private_key)\n link = generate_request('GetPasswordData',\n 'InstanceId' => instance_id )\n response = request_info(link, QEc2GetPasswordDataParser.new(:logger => @logger))\n if response[:password_data].blank?\n raise AwsError.new(\"Initial password is not yet created for #{instance_id}\")\n else\n OpenSSL::PKey::RSA.new(private_key).private_decrypt(Base64.decode64(response[:password_data]))\n end\n rescue Exception\n on_exception\n end",
"def create(pvt)\n key = Bitcoin::Key.new\n key.priv = pvt\n key.addr\n end",
"def decrypt_message ciphertext\n key_pair.decrypt ciphertext\n end",
"def public_decrypt(ciphertext)\n @public_key.public_decrypt(ciphertext)\n end",
"def load_key(dump)\n dump.fetch(:key_attribute)\n end",
"def regen_key\n @user = current_user\n @user.regen_private_key\n send_data @user.private_key, :type => \"application/pem-keys\", :disposition => \"attachment\", :filename => \"#{@user.username}.pem\"\n end"
] | [
"0.6410091",
"0.628885",
"0.62853765",
"0.61700916",
"0.6164279",
"0.6070474",
"0.6064182",
"0.59653336",
"0.59652615",
"0.59352744",
"0.59266746",
"0.5918565",
"0.5909634",
"0.5906501",
"0.59021956",
"0.58240163",
"0.58090043",
"0.5782825",
"0.5745873",
"0.57402426",
"0.5655587",
"0.5653435",
"0.5643702",
"0.56398994",
"0.5634339",
"0.5634339",
"0.5628973",
"0.56090647",
"0.56018186",
"0.5600435",
"0.55605245",
"0.54981977",
"0.54921526",
"0.54495615",
"0.5434584",
"0.53868306",
"0.537839",
"0.5366756",
"0.5352007",
"0.53506845",
"0.53499347",
"0.53451735",
"0.53415614",
"0.53400415",
"0.53284556",
"0.531565",
"0.53126323",
"0.53126323",
"0.52989125",
"0.5296591",
"0.52943367",
"0.52943367",
"0.5291846",
"0.527725",
"0.52661115",
"0.5263107",
"0.52415484",
"0.52415484",
"0.5180226",
"0.51652044",
"0.5135604",
"0.51295257",
"0.5125898",
"0.5123556",
"0.5115858",
"0.51053196",
"0.51053196",
"0.5094647",
"0.50897634",
"0.50834453",
"0.507465",
"0.50729364",
"0.50632286",
"0.5055156",
"0.5049788",
"0.5049462",
"0.5035394",
"0.50335616",
"0.50267327",
"0.50213104",
"0.50163805",
"0.50163805",
"0.5007221",
"0.49849793",
"0.4984366",
"0.49805647",
"0.497923",
"0.49776483",
"0.4975733",
"0.4967937",
"0.4967168",
"0.49670094",
"0.4966179",
"0.49613273",
"0.496042",
"0.49564037",
"0.49408236",
"0.49327096",
"0.492683",
"0.49220413"
] | 0.67856556 | 0 |
Imports the Public key from material representation. | def import_public_key(key_bytes)
key_bytes = Validation.check_filled_array_argument!(key_bytes)
begin
key_pair_id = compute_public_key_hash(key_bytes)
public_key_bytes = Core::VirgilKeyPair.public_key_to_der(key_bytes)
VirgilPublicKey.new(key_pair_id, wrap_bytes(public_key_bytes))
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_public_key key_name, pubkey, fprint=nil\n params = { \n 'KeyName' => key_name,\n 'PublicKey' => pubkey\n }\n params.merge!( 'Fingerprint' => fprint ) unless fprint.nil?\n\n response = @client.action \"ImportPublicKey\", params\n\n Response::Credential.new response.body[\"ImportPublicKeyResponse\"]['return']\n end",
"def load_public_key(filename); end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def load_public_key\n @public_rsa = nil\n \n if public_key_file && File.file?(public_key_file)\n @public_key = File.read(public_key_file)\n end\n end",
"def load_public_key(filename)\n data = File.read(File.expand_path(filename))\n load_data_public_key(data, filename)\n end",
"def public_key(format: :z85)\n case format\n when :z85\n ffi_delegate.public_txt.force_encoding(Encoding::ASCII)\n when :binary\n ffi_delegate.public_key.read_string(32)\n else\n raise ArgumentError, format('invalid format: %p', format)\n end\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def export_public_key\n public_key = context.crypto.extract_public_key(private_key)\n VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))\n end",
"def public_key\n @public_key ||= load_key(@public_key_file)\n end",
"def import_key(identifier, key)\n file = Tempfile.open(\"backup-gpg_import\", Config.tmp_path)\n file.write(key.gsub(%r{^[[:blank:]]+}, \"\"))\n file.close\n ret = run \"#{utility(:gpg)} #{base_options} \" \\\n \"--keyid-format 0xlong --import '#{file.path}' 2>&1\"\n file.delete\n\n keyid = ret.match(%r{ 0x(\\w{16})}).to_a[1]\n raise \"GPG Returned:\\n#{ret.gsub(%r{^\\s*}, \" \")}\" unless keyid\n\n keyid\n rescue => err\n Logger.warn Error.wrap(\n err, \"Public key import failed for '#{identifier}'\"\n )\n nil\n end",
"def public_key\n public_key_object.to_pem\n end",
"def public_key_data\n @public_key\n end",
"def load_data_public_key(data, filename = T.unsafe(nil)); end",
"def public_key\n require_key\n\n @private_key.public_key.to_pem\n end",
"def public_key\n as_public_key(rpc(:account_key, _access: :key))\n end",
"def load_data_public_key(data, filename = \"\")\n fields = data.split(/ /)\n\n blob = nil\n begin\n blob = fields.shift\n end while !blob.nil? && !/^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp\\d+)(-cert-v01@openssh\\.com)?$/.match(blob)\n blob = fields.shift\n\n raise Net::SSH::Exception, \"public key at #{filename} is not valid\" if blob.nil?\n\n blob = blob.unpack(\"m*\").first\n reader = Net::SSH::Buffer.new(blob)\n reader.read_key or raise OpenSSL::PKey::PKeyError, \"not a public key #{filename.inspect}\"\n end",
"def public_key\n @public_key.to_der\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def export_public_key(public_key)\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n\n begin\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key.raw_key)\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def public_key\n @priv.public_key\n end",
"def public_key\n @data_public_key ||= load_public_key\n end",
"def public_key\n # Base64 encode without line feeds\n Base64.strict_encode64(public_key_raw)\n end",
"def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end",
"def public_key\n @pub\n end",
"def public_key_params\n params[:public_key]\n end",
"def public_key_params\n params[:public_key]\n end",
"def get_public_key(pub_key_url, reload = false)\n unless pub_key_url.start_with?(PUB_KEY_URL_PREFIX) ||\n pub_key_url.start_with?(PUB_KEY_URL_PREFIX_S)\n fail \"Invalid public key URL: #{pub_key_url}\"\n end\n\n if reload || @pub_key.nil?\n @pub_key = open(pub_key_url) { |f| f.read }\n end\n\n @pub_key\nend",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n @n, @e= publickey\n @privatekey=privatekey\n #puts $n, $e, $privatekey\n end",
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def load_pubkey\n #filter line data\n load_raw_line([:key_data,:key_type,:note]) \n \n # sanitize old raw line\n self.raw_line = self.gen_raw_line\n end",
"def get_public_key\n return @public_key\n end",
"def decode_string_public_key(raw, offset=0, algo=nil)\n key_raw, str_read = decode_string(raw, offset)\n key, cert_read = decode_public_key(key_raw, 0, algo)\n\n if cert_read != key_raw.bytesize\n raise DecodeError, \"unexpected trailing data\"\n end\n\n [key, str_read]\n end",
"def import(api_params)\n #api_params[:privatekey] = api_params[:ssh_private_key].read\n #api_params[:publickey] = api_params[:ssh_public_key].read\n api_params[:publickey] = api_params[:ssh_public_key]\n api_params[:privatekey] = api_params[:ssh_private_key]\n api_request(SSHKEYS, CREATE, api_params)\n end",
"def set_public_key\n @public_key = PublicKey.first || PublicKey.create(body: 'public key body', algorithm: PublicKey::ALGORITHMS.first)\n end",
"def parse_public_keys\n # Convert keys to compressed_hex format for bitcoin-ruby\n @public_keys_hex = @cosigners_nodes.map { |index, key| key.public_key.to_hex }\n end",
"def load_keypair(private_key, public_key)\n @private_key = private_key\n @public_key = public_key\n @private_rsa = OpenSSL::PKey::RSA.new @private_key\n @public_rsa = OpenSSL::PKey::RSA.new @public_key\n end",
"def auth_key_from_pem\n public_key = private_key.public_key\n Base64.strict_encode64(public_key.to_der)\n end",
"def create\n cnt = GpgKeys.import_keys(params)\n flash[:notice] = t(:msg_gpg_keys_imported, pub: cnt[0], priv: cnt[1])\n redirect_to gpgkeys_path\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def decode_public_key(raw, offset=0, algo=nil)\n total_read = 0\n\n if algo.nil?\n algo, read = decode_string(raw, offset + total_read)\n total_read += read\n end\n\n unless fields = KEY_FIELDS_BY_PUBLIC_KEY_ALGO[algo]\n raise AlgorithmError, \"unknown algorithm: #{algo.inspect}\"\n end\n\n data, read = decode_fields(raw, fields, offset + total_read)\n total_read += read\n\n data[:algo] = algo\n\n [data, total_read]\n end",
"def public_key(arg = nil)\n set_or_return(\n :public_key,\n arg,\n kind_of: String\n )\n end",
"def public_key=(_); end",
"def public_key=(_); end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def extract_public_key(options)\n extract_key(options[:public_key] || options[:key_pair] || ENV['PUBLIC_KEY'])\n end",
"def public_key\n @cert.public_key\n end",
"def import_key_string(key_string, activation_date: Time.now)\n rnp = load_key_string(key_string)\n all_keys(rnp).map do |raw|\n metadata = raw.json\n creation_hash = creation_params(\n raw: raw, activation_date: activation_date, metadata: metadata,\n )\n create(creation_hash)\n end\n end",
"def one_time_public_key\n token = generate_token('get_encription_public_key', @public_key)\n response = commit(:pci_encryption_key, token: token)\n response.params['encryption_key']\n end",
"def public_key\n DH.new(to_der)\n end",
"def masa_pki\n masakey.public_key.to_der\n end",
"def public_key\n @cert.public_key\n end",
"def create\n @public_key = PublicKey.new\n\n new_key_pair = KeyDistributorHelper::generate_key_pair\n @public_key.key = new_key_pair.public_key\n\n # Get a non-matching public_key for the lulz!\n rand_public_key = begin PublicKey.offset(rand(PublicKey.count)).first.key rescue nil end\n\n # Put em together\n new_private_key = new_key_pair.private_key\n @key_pair = KeyDistributorHelper::KeyPair.new new_private_key, rand_public_key\n \n respond_to do |format|\n if @public_key.save\n format.html { render }\n format.json { render json: key_pair, status: :created }\n else\n format.html { render :new }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def public_key_file=(file)\n @public_key_file = file and load_public_key\n end",
"def recover_public_key(message)\n ctx = Secp256k1::Context.new\n recovery_id = Chains.to_recovery_id(@v, @chain_id)\n\n recoverable_signature = ctx.recoverable_signature_from_compact(@signature, recovery_id)\n public_key_bin = recoverable_signature.recover_public_key(message.hash).uncompressed\n public_key_to_address(public_key_bin)\n end",
"def public_key_params\n params.require(:public_key).permit(:body, :algorithm)\n end",
"def public_key\n encode64(curve.public_key.to_bn.to_s(2))\n end",
"def pubkey\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(payment_base) { |key, p| key.derive(p) }\n end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def public_key_file=(file)\n @public_key_file = file and load_public_key\n end",
"def ext_pubkey\n k = ExtPubkey.new\n k.depth = depth\n k.number = number\n k.parent_fingerprint = parent_fingerprint\n k.chain_code = chain_code\n k.pubkey = key.pubkey\n k.ver = priv_ver_to_pub_ver\n k\n end",
"def recover_public_key(message)\n ctx = Secp256k1::Context.new\n recovery_id = Chains.to_recovery_id(@v, @chain_id)\n\n recoverable_signature = ctx.recoverable_signature_from_compact(@signature, recovery_id)\n public_key_bin = recoverable_signature.recover_public_key(message.hash).uncompressed\n public_key_to_address(public_key_bin)\n end",
"def set_public_key(obj, priv)\n case priv\n when OpenSSL::PKey::EC\n obj.public_key = priv\n when OpenSSL::PKey::RSA\n obj.public_key = priv.public_key\n else\n raise ArgumentError, 'priv must be EC or RSA'\n end\n end",
"def to_bytes\n @public_key\n end",
"def create\n @public_key = PublicKey.new(public_key_params)\n\n respond_to do |format|\n if @public_key.save\n format.html { redirect_to @public_key, notice: 'Public key was successfully created.' }\n format.json { render :show, status: :created, location: @public_key }\n else\n format.html { render :new }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def encrypt_key(key, public_key)\n encrypted_key = public_key.public_encrypt(key)\n encode encrypted_key\n end",
"def public_key_for_push_header\n trim_encode64(curve.public_key.to_bn.to_s(2))\n end",
"def public_key\n encode_tz(:edpk, 32)\n end",
"def ecdh_public_key_bytes; end",
"def load_key_string(key_string)\n Rnp.new.tap do |rnp|\n rnp.load_keys(\n format: \"GPG\",\n input: Rnp::Input.from_string(key_string),\n public_keys: true,\n secret_keys: true,\n )\n end\n end",
"def extract_public_key(private_key)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n public_key_bytes = Core::VirgilKeyPair.extract_public_key(\n private_key.raw_key,\n []\n )\n VirgilPublicKey.new(\n private_key.id,\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key_bytes)\n )\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def public_encrypt(plaintext)\n @public_key.public_encrypt(plaintext)\n end",
"def ext_pubkey\n k = ExtPubkey.new\n k.depth = depth\n k.number = number\n k.parent_fingerprint = parent_fingerprint\n k.chain_code = chain_code\n k.pubkey = key.pubkey\n k\n end",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def initialize(data, public_key = nil, encoding = :none, opts = {})\n @encoding = encoding\n\n if !public_key && !opts[:public_key_file]\n # If no public key was provided the data should already be encrypted\n @data = data\n elsif File.exists?(opts[:public_key_file].to_s)\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n elsif public_key\n public_key = OpenSSL::PKey::RSA.new(public_key)\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n end\n end",
"def importprivkey(bitcoinprivkey, label = nil, rescan = true)\n @api.request 'importprivkey', bitcoinprivkey, label, rescan\n end",
"def set_ssl_public_key_in_session\n if encryption_required?\n key = OpenSSL::PKey::RSA.new(session[:key] || 1024)\n @public_modulus = key.public_key.n.to_s(16)\n @public_exponent = key.public_key.e.to_s(16)\n session[:key] = key.to_pem\n end\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def get_public_key\n # Obtain public key\n pem_cert = Env.instance['RSA_PUBLIC_KEY_PATH']\n begin\n public_key = File.read(pem_cert)\n return public_key\n rescue => err \n $stderr.puts \"ERROR: missing RSA_PUBLIC_KEY_PATH in env.yml'\"\n end\n nil\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end"
] | [
"0.71169686",
"0.69393384",
"0.65846115",
"0.65846115",
"0.6482507",
"0.6423467",
"0.6289779",
"0.6258966",
"0.6258966",
"0.6255277",
"0.6232235",
"0.6186848",
"0.61603004",
"0.6153982",
"0.6153051",
"0.6130288",
"0.6117486",
"0.61031467",
"0.6101312",
"0.60989517",
"0.6053993",
"0.6047044",
"0.60317564",
"0.60144806",
"0.60126716",
"0.5976747",
"0.5920354",
"0.59198624",
"0.59198624",
"0.5839376",
"0.5813252",
"0.5794666",
"0.5794666",
"0.5794666",
"0.57827455",
"0.57516366",
"0.5717767",
"0.5712467",
"0.5707724",
"0.57034063",
"0.5695152",
"0.56574696",
"0.56327105",
"0.56305736",
"0.55932015",
"0.55913895",
"0.5590768",
"0.5590768",
"0.5571383",
"0.5571383",
"0.5566586",
"0.55461496",
"0.5532459",
"0.5508544",
"0.5495353",
"0.54945266",
"0.5476843",
"0.5473326",
"0.547155",
"0.54527074",
"0.54402024",
"0.5439448",
"0.5435804",
"0.54316336",
"0.54249513",
"0.5421291",
"0.5408196",
"0.5404631",
"0.5387573",
"0.5383725",
"0.5381688",
"0.5363923",
"0.5361337",
"0.5361198",
"0.5356655",
"0.535124",
"0.5317164",
"0.5317164",
"0.5312827",
"0.53042096",
"0.52903605",
"0.5288088",
"0.52735656",
"0.52495736",
"0.52482086",
"0.52482086",
"0.523555",
"0.52284664",
"0.52284664",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061",
"0.5207061"
] | 0.67922914 | 2 |
Exports the Private key into material representation. | def export_private_key(private_key, password = nil)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
unless password
return Core::VirgilKeyPair.private_key_to_der(
private_key.raw_key
)
end
password_bytes = Bytes.from_string(password)
private_key_bytes = Core::VirgilKeyPair.encrypt_private_key(
private_key.raw_key,
password_bytes
)
wrap_bytes(
Core::VirgilKeyPair.private_key_to_der(
private_key_bytes,
password_bytes
)
)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_public_key\n public_key = context.crypto.extract_public_key(private_key)\n VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))\n end",
"def private_key\n @private_key.to_der\n end",
"def output_key(key)\n STDOUT.write \"# Private key (d, n): #{'%X' % key.d} #{'%X' % key.n}\\n\"\n STDOUT.write \"key #{'%X' % key.e} #{'%X' % key.n}\\n\"\nend",
"def private_key\n encode64(curve.private_key.to_s(2))\n end",
"def private_key\n @priv\n end",
"def export_der!\n export(pem: false)\n end",
"def priv_key\n key = master_ext_key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true)\n\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(key) { |key, p| key.derive(p) }\n end",
"def write_new_key\n File.open(full_key_path, 'w') do |f|\n f.write OpenSSL::PKey::RSA.generate(1024).export()\n end\n end",
"def private_key=(private_key); end",
"def private_key; end",
"def private_key; end",
"def private_key\n @key\n end",
"def regen_key\n @user = current_user\n @user.regen_private_key\n send_data @user.private_key, :type => \"application/pem-keys\", :disposition => \"attachment\", :filename => \"#{@user.username}.pem\"\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def private_key_pem\n @private_key.to_pem\n end",
"def export(key_id = nil)\n OpenPGP::Message.parse(exec([:export, *[key_id].flatten]).read)\n end",
"def generate\n key = Bitcoin::Key.generate.priv\n @log.info(\"Bitcoin private key generated: #{key[0..8]}...\")\n key\n end",
"def keyfile(key)\n keyfile = Tempfile.new(\"ec2_private.key\")\n key_material = \"\"\n key.split(\"\\n\").each { |line| key_material+=\"#{line.strip}\\n\" if line.strip.size>0 }\n keyfile.write(key_material) && keyfile.close\n puts \"[*] Using #{keyfile.path} as private key\"\n keyfile.path\n end",
"def private_key\n # jruby-openssl OpenSSL::PKey::EC support isn't complete\n # https://github.com/jruby/jruby-openssl/issues/189\n jruby_not_implemented(\"OpenSSL::PKey::EC is not fully implemented\") if type == \"ecdsa\"\n\n key_object.to_pem\n end",
"def export_public_key(public_key)\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n\n begin\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key.raw_key)\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def get_private_key\n return @private_key\n end",
"def encrypted_private_key\n return private_key unless passphrase\n key_object.to_pem(OpenSSL::Cipher.new(\"AES-128-CBC\"), passphrase)\n end",
"def private_key\n read_attribute(:private_key) || reset_private_key\n end",
"def export_der(password:,\n cipher: nil,\n pbkdf: nil,\n iterations: Botan::DEFAULT_KDF_ITERATIONS,\n rng: Botan::RNG.new)\n export_encrypted(password: password,\n pem: true,\n cipher: cipher,\n pbkdf: pbkdf,\n iterations: iterations,\n rng: rng)\n end",
"def private_key\n @private_key ||= load_key(@private_key_file)\n end",
"def generate_key!\n unless priv_key\n tmp = OpenSSL::PKey.generate_key(self)\n set_key(tmp.pub_key, tmp.priv_key)\n end\n self\n end",
"def public_key\n @public_key.to_der\n end",
"def export_to_pem(key, password)\n pem_file = key.gsub('.key', '.pem')\n\n if File.exist?(pem_file)\n return pem_file\n else\n command = \"openssl pkcs8 -inform DER -in someKey.key -passin pass:somePassword -out key.pem\"\n\n pem_file = key.gsub('.key', '.pem')\n\n command.gsub! 'someKey.key', key\n command.gsub! 'somePassword', password\n command.gsub! 'key.pem', pem_file\n\n result = system( command )\n return pem_file\n end\n\n\n end",
"def key_for_export(key)\n clean_key = key_without_numbers(key)\n unnumbered_key = mapping[clean_key] ? mapping[clean_key]['from'].first : clean_key\n # Bring the number back if there is one\n \"#{unnumbered_key}#{key.sub(clean_key, '')}\"\n end",
"def key_for_export(key)\n clean_key = key_without_numbers(key)\n unnumbered_key = mapping[clean_key] ? mapping[clean_key]['from'].first : clean_key\n # Bring the number back if there is one\n \"#{unnumbered_key}#{key.sub(clean_key, '')}\"\n end",
"def export_pem!\n export(pem: true)\n end",
"def private_key\n OpenSSL::PKey::RSA.new(_keypair)\n end",
"def test_generate_pkey_dsa_to_text\n assert_match(\n /Private-Key: \\(512 bit\\)/,\n OpenSSL::PKey::DSA.new(512).to_text\n )\n end",
"def private_key\n @private_key ||= case private_key_type\n when 'p12'\n OpenSSL::PKCS12.new(private_key_string, private_key_password).key\n else\n OpenSSL::PKey::RSA.new(private_key_string, private_key_password)\n end if private_key_string\n end",
"def key\n @agent.private_key\n end",
"def write_key!\n dir = Tinc.config['key_dir']\n File.open(\"#{dir}/#{node.mac}\", 'w') do |f|\n f.write(self.cert_data) \n end\n end",
"def key= key\n @agent.private_key = key\n end",
"def export\n to_h.stringify_keys\n end",
"def regenerate_key\n self.private_key = true\n self.save\n end",
"def create(name, write_private)\n new_key = OpenSSL::PKey::RSA.generate(1024)\n new_public = new_key.public_key.to_pem\n new_private = new_key.to_pem\n File.open(File.join(@keystore, \"#{name}.pub\"), 'w') { |f| f.puts new_public }\n File.open(File.join(@keystore, \"#{name}.key\"), 'w') { |f| f.puts new_key } if write_private\n new_key\n end",
"def key\n ECDSA.build_key(public_key, private_key)\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def private_key_get\n return @priv_key unless @priv_key.nil?\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n case resource[:auth_type].downcase\n when 'dsa'\n OpenSSL::PKey::DSA.new(file, resource[:key_password])\n when 'rsa'\n OpenSSL::PKey::RSA.new(file, resource[:key_password])\n when 'ec'\n OpenSSL::PKey::EC.new(file, resource[:key_password])\n else\n raise Puppet::Error, \"Unknown authentication type '#{resource[:auth_type]}'\"\n end\n else\n false\n end\n end",
"def private_key!\n if self[:kopal_encoded_private_key].blank?\n regenerate_private_key!\n end\n OpenSSL::PKey::RSA.new Base64::decode64(self[:kopal_encoded_private_key])\n end",
"def private_key\n\t '-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3D37CD3A313CADA2 7c1TAxzv6Gn2OmZzVNtEnU9lqrEwRL65huGc9ewQQ7senY3rkBgIqBzqVarAfS0I 6OMimI57q7XywAiFn7CZ+L7fbXdNuvmGx5JDNRwylgGWR+hPi9JMKEAP1yjdJPRS 608pDXIliz5bO0GdvufQxQ91MPjE4Bs5AT8TIE3bzuFllBYJD/mLpkK4bOjLHswI 7W7afVctpYaRAwzb64Z+gUQZL0BIcQzG2wYvFU3vAs5sCtEy9o7riY/bBi78EEH6 go01DkgYLt8M7ApTwblJNJR0G/8bwy3oDgdieM42sFLzftxwjeBhIiF1ExH+KuYA ftAcROOfr8rduvNNc6jJcx2lyze+4joPjHDBXZr27bg3o3SwOQCIXUHe0DHG0PHn TbZkL2btHH36mTMq0j6P9R4t1wLhJ8Pq2LjLDwLhXw3Tb8aIX1tpShxyy9Yv8F84 Q6dfBLe4yqmvW1Db2nGmZ++gPua2OGWuNXwjivt2XrZ0fGAGri5j9bsqyvDsHwUS aRs8PaG97rgmyRGHYUoicBdgeFZhBHSLlU5F6RNUTOgK9QAHP4+bdKbMQxvhveh8 +v9o7Xa7BlqEvUYXIfBwEbHZoJx4t90XSndSS3chlfoEb6vcxOBmplUZlWs55aSL U7dW1MaE48Afav6TtM2VsN9RzwU8QSplpm7z9C9xkYVBMN6UcKIbnHH1yXdhTGEG uaEvPrtSh+BroAx1OmMjkmb0s1PjgDqLEtaYifP1OXgSS3uTqPBcpgUZDnuYQZmW Ihv7SvGdyWVQUgpv5LukyZPhXdlsCQ+8TlEYn4MOl87uxqo3KCVzVdmhAx2PWS/q wLcyOq0wJuvgAAtmI4/EnXVaP5P6WQ7rixfxdDfR1nI5TnDQkgs2xquyb0cms0J+ hXkIGvQOMAzq2Js3Ad7qyiklDASR20zZt6JPKTgZpLq682Fx+LJCCryAqjye2nAI 0w5SHEd80J/lAUEYo/HrNDBWS0JzD4lfERwUxgXxvynFI1ak38h0YP9RR2ka0pMI DJ8G6/w3Ir1qgLM/E+bTvp1YE683J/j1+vdYC/eoAbki2wgJAitYFdexLpw/qMvj xonY4iyhVkgzQb0GObesjPhr0CQ1gRC8p/A68Pk4cXejKTO95gUnD682Mu6lgYXQ e3rEnNVUruiPEzMKbkPLIsaWfUKfGRb0okQmuISXEfjyLfjkUgD6bxes+9KuHdvj pZze3dOgB1W6ZGsbrQ8ooXAOewYbhDcEqVsPOItVBoZ14CmCSd1X8RiW1dnfZBLa 5W8L7HaVLgiKUWlu2N6BE3etMK/fzhLh1K8WT6PxqzqVfJZZ9TYwVSYbcJuej0Hf ioHwYgqO22aZrp+ciJplCyOooFOKVVW45iLPtSHX64aE6FKbdPEPcndIOl0J9ah0 Hwicaw0ADP4STb83NysAZdHO2UVNEERkp2P4XmgeeH3gYHhPv3xCbbDejrrRJjeq VRer8i6HxiuJ/SxNKvbiwztF/44nWJ+9m2FoNqumTITdQAx7VU3681uEsO9ZbsJU Lbt0zwxna4X6WEtjdy5ExqLlU+wnzWgG+I11vgXSarye2oTuGPK8wjBkfEqdRTxs -----END RSA PRIVATE KEY----- '\n\tend",
"def add_key(key)\n if File.exist?(key)\n data = File.open(key).read\n key_import = GPGME::Key.import(data, armor: true)\n key = GPGME::Key.get(key_import.imports[0].fpr).uids[0].email\n else\n data = GPGME::Key.export(key, armor: true).read\n end\n\n raise I18n.t('error.export_key') if data.to_s.empty?\n\n @keys[key] = data\n @passwords.each_key { |id| set_password(id, get_password(id)) }\n @otp_keys.each_key { |id| set_otp_key(id, get_otp_key(id)) }\n end",
"def generate_keys\n key = OpenSSL::PKey::RSA.new 2048\n self.pubkey = key.public_key.to_s\n self.privkey = key.to_s\n self.save\n end",
"def key_file\n write_file(\"request-#{domain}.key\", key.to_pem)\n end",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n @n, @e= publickey\n @privatekey=privatekey\n #puts $n, $e, $privatekey\n end",
"def key_pem; end",
"def to_xml private_key\n # Generate magic envelope\n magic_envelope = XML::Document.new\n\n magic_envelope.root = XML::Node.new 'env'\n\n me_ns = XML::Namespace.new(magic_envelope.root,\n 'me', 'http://salmon-protocol.org/ns/magic-env')\n\n magic_envelope.root.namespaces.namespace = me_ns\n\n # Armored Data <me:data>\n data = @activity.to_atom\n @plaintext = data\n data_armored = Base64::urlsafe_encode64(data)\n elem = XML::Node.new 'data', data_armored, me_ns\n elem.attributes['type'] = 'application/atom+xml'\n data_type_armored = 'YXBwbGljYXRpb24vYXRvbSt4bWw='\n magic_envelope.root << elem\n\n # Encoding <me:encoding>\n magic_envelope.root << XML::Node.new('encoding', 'base64url', me_ns)\n encoding_armored = 'YmFzZTY0dXJs'\n\n # Signing Algorithm <me:alg>\n magic_envelope.root << XML::Node.new('alg', 'RSA-SHA256', me_ns)\n algorithm_armored = 'UlNBLVNIQTI1Ng=='\n\n # Signature <me:sig>\n plaintext =\n \"#{data_armored}.#{data_type_armored}.#{encoding_armored}.#{algorithm_armored}\"\n\n # Assign @signature to the signature generated from the plaintext\n @signature = Nelumba::Crypto.emsa_sign(plaintext, private_key)\n\n signature_armored = Base64::urlsafe_encode64(@signature)\n magic_envelope.root << XML::Node.new('sig', signature_armored, me_ns)\n\n magic_envelope.to_s :indent => true, :encoding => XML::Encoding::UTF_8\n end",
"def private_key_string(privatekey)\n private_key_names=[\"primesinverses\",\"d_set\", \"primes\"]\n private_key_string=\"privatekey=[\"\n for i in 0..privatekey.length-1\n private_key_string << private_key_names[i]+\"=[\"\n for x in 0..privatekey[i].length-1\n private_key_string << privatekey[i][x].to_s+\",\"\n end\n private_key_string << \"],\\n\"\n end\n private_key_string << \"]\"\n private_key_string\n end",
"def public_key\n require_key\n\n @private_key.public_key.to_pem\n end",
"def regenerate_private_key! length = private_key_length\n self[:kopal_encoded_private_key] =\n Base64::encode64(OpenSSL::PKey::RSA.new(length).to_pem)\n end",
"def public_key\n @priv.public_key\n end",
"def private_key\n return @priv_key unless @priv_key.nil?\n\n # Verify that the given directory exists\n unless File.directory?(resource[:priv_key_dir])\n raise ArgumentError, \"Directory not found for: #{resource[:priv_key_dir]}\"\n end\n\n priv_key_path = File.join(resource[:priv_key_dir], resource[:priv_key_name])\n @priv_key = if Pathname.new(priv_key_path).exist?\n file = File.read(priv_key_path)\n OpenSSL::PKey.read(file, resource[:priv_key_password])\n else\n false\n end\n end",
"def private_key\n return self.authentication.private_key\n end",
"def private_key\n return self.authentication.private_key\n end",
"def build_key(public_key, private_key)\n group = OpenSSL::PKey::EC::Group.new('prime256v1')\n key = OpenSSL::PKey::EC.new(group)\n\n public_bn = OpenSSL::BN.new(public_key, 16)\n private_bn = OpenSSL::BN.new(private_key, 16)\n public_key = OpenSSL::PKey::EC::Point.new(group, public_bn)\n\n key.tap do\n key.public_key = public_key\n key.private_key = private_bn\n end\n end",
"def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end",
"def private_key=(k)\n return self.authentication.private_key = k\n end",
"def private_key=(k)\n return self.authentication.private_key = k\n end",
"def reset_private_key\n self.private_key = ActiveSupport::SecureRandom.hex(32)\n end",
"def export_pem(password:,\n cipher: nil,\n pbkdf: nil,\n iterations: Botan::DEFAULT_KDF_ITERATIONS,\n rng: Botan::RNG.new)\n export_encrypted(password: password,\n pem: true,\n cipher: cipher,\n pbkdf: pbkdf,\n iterations: iterations,\n rng: rng)\n end",
"def privkey(add_compressed_suffix=false)\n compressed_suffix = add_compressed_suffix && compressed ? \"01\" : \"\"\n [key.private_key.to_s(16) + compressed_suffix].pack('H*')\n end",
"def grant_with_private_key\n id = params[:id]\n participants = if id\n [AssignmentParticipant.find(id)]\n else\n AssignmentParticipant.where(user_id: session[:user].id)\n end\n private_key = params[:private_key]\n\n begin\n participants.each do |participant|\n participant.assign_copyright(private_key)\n end\n redirect_to action: 'view'\n rescue StandardError\n flash[:notice] = 'The private key you inputted was invalid.'\n if id\n redirect_to action: 'grant', id: participants[0].id\n else\n redirect_to action: 'grant'\n end\n end\n end",
"def ssh_private=(key_content)\n @ssh_private_file = temp_file_manager.path('key')\n IO.write(@ssh_private_file, key_content)\n end",
"def write_pkcs12(filename_or_io,password,friendly_name='r509 pkcs12')\n if @key.nil?\n raise R509::R509Error, \"Writing a PKCS12 requires both key and cert\"\n end\n pkcs12 = OpenSSL::PKCS12.create(password,friendly_name,@key.key,@cert)\n write_data(filename_or_io, pkcs12.to_der)\n end",
"def generate_keypair\n key = OpenSSL::PKey::RSA.new 2048\n load_keypair(key.to_pem, key.public_key.to_pem)\n return [@private_key, @public_key]\n end",
"def recover_private_key(buffer, params, signature, k)\n q = params[1]\n r, s = signature\n ((s * k - SHA1.hexdigest(buffer).to_i(16)) * invmod(r, q)) % q\nend",
"def to_pem\n @spki.to_pem\n end",
"def export(data = nil, depth = 0)\n pre_export\n data = Exporter.export(data || {}, self, depth)\n data.merge!(serialization_export_header).stringify_keys\n end",
"def masa_pki\n masakey.public_key.to_der\n end",
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def key(keygap)\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key = Keygap.new.merge(key, keygap)\n @log.debug(\"The private key of @#{@login} reassembled: #{key.to_s.length} chars\")\n key\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def key_material\n data.key_material\n end",
"def to_payload\n Bitcoin.chain_params.extended_privkey_version.htb << [depth].pack('C') <<\n parent_fingerprint.htb << [number].pack('N') << chain_code << [0x00].pack('C') << key.priv_key.htb\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def public_jwk_export\n public_jwk.export.merge(\n alg: ALGORITHM,\n use: 'sig'\n )\n end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def key=(key)\n PrivateKey.enforce_valid_key_type!(key)\n\n @key = key\n end",
"def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end",
"def ssh_private_key(name)\n get(driver_url + API_BASE + \"nodes/#{name}/attribs/#{KEY_ATTRIB}\")\n end",
"def public_key\n DH.new(to_der)\n end",
"def write_pkcs12(filename_or_io, password, friendly_name = 'r509 pkcs12')\n if @key.nil?\n raise R509::R509Error, \"Writing a PKCS12 requires both key and cert\"\n end\n pkcs12 = OpenSSL::PKCS12.create(password, friendly_name, @key.key, @cert)\n write_data(filename_or_io, pkcs12.to_der)\n end",
"def export(key)\n @@exported[key] = @vars[key]\n end",
"def to_show_login\n\t\t# Password strategy\t\t\n\t\tkey = OpenSSL::PKey::RSA.new(1024)\n\t\t@public_modulus = key.public_key.n.to_s(16)\n\t\t@public_exponent = key.public_key.e.to_s(16)\n\t\tsession[:key] = key.to_pem\n\tend",
"def to_bytes; @key; end",
"def to_bytes; @key; end",
"def user_to_private_keys(home, private_keys)\n private_keys.map do |filename, data|\n {\n 'fn' => \"#{home}/.ssh/#{filename}\",\n 'content' => data\n }\n end\nend",
"def dump(key)\n send_command([:dump, key])\n end",
"def client_cert_save(cert, priv_key)\n Puppet.debug('saving cert')\n key = OpenSSL::PKey.read(priv_key)\n x509_cert = OpenSSL::X509::Certificate.new(cert)\n name = resource[:cert_name]\n # PKCS12 private keys must be at least 4 characaters\n if resource[:priv_key_password] && resource[:priv_key_password].size >= 4\n password = resource[:priv_key_password]\n else\n # PKCS12 private keys require a password, so generate a random 16 character one\n Puppet.debug(\"vault_cert[#{resource[:cert_name]}] was either not given a private key password or it was less than 4 characters, automatically generating a private key password for you\")\n require 'securerandom'\n password = SecureRandom.alphanumeric(16)\n end\n pkcs12 = OpenSSL::PKCS12.create(password, name, key, x509_cert)\n pkcs12_der = pkcs12.to_der\n\n Puppet.debug(\"cert data: #{cert}\")\n\n file = Tempfile.new(resource[:cert_name])\n begin\n file.binmode\n file.write(pkcs12_der)\n # have to close file before Import-PfxCertificate can open it\n file.close\n\n cmd = <<-EOF\n $password = ConvertTo-SecureString -String '#{password}' -Force -AsPlainText\n Import-PfxCertificate -FilePath '#{file.path}' -CertStoreLocation '#{resource[:cert_dir]}' -Password $password\n EOF\n res = ps(cmd)\n Puppet.debug(\"Imported cert exitcode: #{res[:exitcode]} \")\n Puppet.debug(\"Imported cert stdout: #{res[:stdout]} \")\n Puppet.debug(\"Imported cert stderr: #{res[:stderr]} \")\n ensure\n file.close\n file.unlink\n end\n end",
"def import_private_key(key_bytes, password = nil)\n key_bytes = Validation.check_filled_array_argument!(key_bytes)\n\n begin\n decrypted_private_key = if !password\n Core::VirgilKeyPair.private_key_to_der(key_bytes)\n else\n Core::VirgilKeyPair.decrypt_private_key(\n key_bytes,\n Bytes.from_string(password)\n )\n end\n\n public_key_bytes = Core::VirgilKeyPair.extract_public_key(\n decrypted_private_key, []\n )\n key_pair_id = compute_public_key_hash(public_key_bytes)\n private_key_bytes = Core::VirgilKeyPair.private_key_to_der(\n decrypted_private_key\n )\n return VirgilPrivateKey.new(key_pair_id, wrap_bytes(private_key_bytes))\n rescue => error\n raise VirgilCryptoException, error.message\n end\n\n end",
"def to_s\n StringIO.open do |buffer|\n buffer.write(destination.to_s)\n buffer.write(private_key.to_s)\n buffer.write(signing_key.to_s)\n buffer.string\n end\n end",
"def key_passphrase=(pw)\n raise PrivateKeyDecrypted, 'private_key already given' if @private_key\n\n @private_key = OpenSSL::PKey::RSA.new(@raw_private_key, pw)\n\n @raw_private_key = nil\n nil\n end",
"def public_key_data\n @public_key\n end",
"def key_fingerprint\n data.key_fingerprint\n end",
"def gen_key\n # get 2 random primes\n p, q = Prime.each.take_while {|x| x <= KEY_SPACE}.sample(2)\n # special easy case of Euler's totient function\n phi = (p-1)*(q-1)\n # calculate modulus, public key, and private key\n n = p*q\n e = get_public(phi)\n d = get_private(phi, e)\n # print results\n puts \"modulus: #{n}\"\n puts \"public key: #{e}\"\n puts \"private key: #{d}\"\n puts \"(internal information)\"\n puts \"phi: #{phi}\"\n puts \"p,q: #{p},#{q}\"\nend",
"def create_public_private_rsa_key_pair_strings\r\n private_key = OpenSSL::PKey::RSA.new(2048)\r\n public_key = private_key.public_key\r\n private_public_key_strings_pair = {\r\n 'private_key_string' => private_key,\r\n 'public_key_string' => public_key\r\n }\r\n puts 'The randomly generated 2048-bit RSA private key string is:'\r\n puts private_public_key_strings_pair['private_key_string']\r\n puts 'The corresponding 2048-bit public key string is:'\r\n puts private_public_key_strings_pair['public_key_string']\r\n puts 'Keep a record of these key strings. You will not be able to properly ' \\\r\n 'encrypt and decrypt the contents of objects without these keys.'\r\n return private_public_key_strings_pair\r\nend"
] | [
"0.6920574",
"0.67797095",
"0.6773375",
"0.649842",
"0.6434023",
"0.63304627",
"0.63133013",
"0.62821907",
"0.6170287",
"0.6142262",
"0.6142262",
"0.6125581",
"0.61235327",
"0.60936517",
"0.6080612",
"0.60539454",
"0.60521984",
"0.5998864",
"0.5927688",
"0.58925164",
"0.5851994",
"0.58271134",
"0.58091474",
"0.5756377",
"0.5730421",
"0.5716907",
"0.56827617",
"0.5681823",
"0.5679255",
"0.5679255",
"0.5659792",
"0.5641352",
"0.5636886",
"0.56349444",
"0.5630709",
"0.56217164",
"0.56073385",
"0.5604051",
"0.55916077",
"0.55866426",
"0.5584093",
"0.5551427",
"0.55378944",
"0.55324084",
"0.5513077",
"0.5503619",
"0.54875636",
"0.54843605",
"0.5466681",
"0.54576457",
"0.5451782",
"0.5436296",
"0.5416701",
"0.54142815",
"0.5413271",
"0.5410652",
"0.54066545",
"0.54066545",
"0.53765523",
"0.536584",
"0.53641623",
"0.53641623",
"0.5360441",
"0.53567064",
"0.5341419",
"0.53352106",
"0.5331181",
"0.5329995",
"0.5320837",
"0.53047234",
"0.5302528",
"0.5295319",
"0.529117",
"0.52876157",
"0.5260667",
"0.52451473",
"0.5233388",
"0.5230054",
"0.5223927",
"0.5221478",
"0.522107",
"0.52203834",
"0.5219561",
"0.52193415",
"0.5212396",
"0.5203733",
"0.51887083",
"0.51866466",
"0.5185496",
"0.5185496",
"0.5169066",
"0.5168217",
"0.51581675",
"0.51479536",
"0.5147305",
"0.51448745",
"0.5143931",
"0.51391",
"0.5119612",
"0.51181865"
] | 0.73202413 | 0 |
Exports the Public key into material representation. | def export_public_key(public_key)
public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)
begin
wrap_bytes(
Core::VirgilKeyPair.public_key_to_der(public_key.raw_key)
)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export_public_key\n public_key = context.crypto.extract_public_key(private_key)\n VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))\n end",
"def public_key\n @public_key.to_der\n end",
"def public_key_data\n @public_key\n end",
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end",
"def write_new_key\n File.open(full_key_path, 'w') do |f|\n f.write OpenSSL::PKey::RSA.generate(1024).export()\n end\n end",
"def public_key\n require_key\n\n @private_key.public_key.to_pem\n end",
"def public_key\n @priv.public_key\n end",
"def public_key\n public_key_object.to_pem\n end",
"def public_jwk_export\n public_jwk.export.merge(\n alg: ALGORITHM,\n use: 'sig'\n )\n end",
"def export(key_id = nil)\n OpenPGP::Message.parse(exec([:export, *[key_id].flatten]).read)\n end",
"def to_bytes\n @public_key\n end",
"def public_key\n # Base64 encode without line feeds\n Base64.strict_encode64(public_key_raw)\n end",
"def public_key\n @pub\n end",
"def public_key\n encode64(curve.public_key.to_bn.to_s(2))\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n as_public_key(rpc(:account_key, _access: :key))\n end",
"def output_key(key)\n STDOUT.write \"# Private key (d, n): #{'%X' % key.d} #{'%X' % key.n}\\n\"\n STDOUT.write \"key #{'%X' % key.e} #{'%X' % key.n}\\n\"\nend",
"def get_public_key\n return @public_key\n end",
"def key_for_export(key)\n clean_key = key_without_numbers(key)\n unnumbered_key = mapping[clean_key] ? mapping[clean_key]['from'].first : clean_key\n # Bring the number back if there is one\n \"#{unnumbered_key}#{key.sub(clean_key, '')}\"\n end",
"def key_for_export(key)\n clean_key = key_without_numbers(key)\n unnumbered_key = mapping[clean_key] ? mapping[clean_key]['from'].first : clean_key\n # Bring the number back if there is one\n \"#{unnumbered_key}#{key.sub(clean_key, '')}\"\n end",
"def create\n @public_key = PublicKey.new\n\n new_key_pair = KeyDistributorHelper::generate_key_pair\n @public_key.key = new_key_pair.public_key\n\n # Get a non-matching public_key for the lulz!\n rand_public_key = begin PublicKey.offset(rand(PublicKey.count)).first.key rescue nil end\n\n # Put em together\n new_private_key = new_key_pair.private_key\n @key_pair = KeyDistributorHelper::KeyPair.new new_private_key, rand_public_key\n \n respond_to do |format|\n if @public_key.save\n format.html { render }\n format.json { render json: key_pair, status: :created }\n else\n format.html { render :new }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def export\n to_h.stringify_keys\n end",
"def key\n ECDSA.build_key(public_key, private_key)\n end",
"def masa_pki\n masakey.public_key.to_der\n end",
"def public_key(format: :z85)\n case format\n when :z85\n ffi_delegate.public_txt.force_encoding(Encoding::ASCII)\n when :binary\n ffi_delegate.public_key.read_string(32)\n else\n raise ArgumentError, format('invalid format: %p', format)\n end\n end",
"def encrypt_key(key, public_key)\n encrypted_key = public_key.public_encrypt(key)\n encode encrypted_key\n end",
"def public_key=(_); end",
"def public_key=(_); end",
"def create\n @public_key.user = current_user\n respond_to do |format|\n if @public_key.save\n # PublicKey.regenerate_authorized_keys\n GitWit.add_authorized_key(current_user.username, @public_key.raw_content)\n\n format.html { redirect_to @public_key, notice: 'Public key was successfully created.' }\n format.json { render json: @public_key, status: :created, location: @public_key }\n else\n format.html { render action: \"new\" }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def public_key\n @public_key ||= load_key(@public_key_file)\n end",
"def export_der!\n export(pem: false)\n end",
"def import_public_key key_name, pubkey, fprint=nil\n params = { \n 'KeyName' => key_name,\n 'PublicKey' => pubkey\n }\n params.merge!( 'Fingerprint' => fprint ) unless fprint.nil?\n\n response = @client.action \"ImportPublicKey\", params\n\n Response::Credential.new response.body[\"ImportPublicKeyResponse\"]['return']\n end",
"def public_key\n return @public_key if File.exist?(@agent_file) && File.exist?(@key_file)\n # create the agent and key if at least one file does not exist (anymore)\n create_agent_key_combo\n @public_key\n end",
"def public_key\n @cert.public_key\n end",
"def generate_keys\n key = OpenSSL::PKey::RSA.new 2048\n self.pubkey = key.public_key.to_s\n self.privkey = key.to_s\n self.save\n end",
"def create\n @public_key = PublicKey.new(public_key_params)\n\n respond_to do |format|\n if @public_key.save\n format.html { redirect_to @public_key, notice: 'Public key was successfully created.' }\n format.json { render :show, status: :created, location: @public_key }\n else\n format.html { render :new }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def export_home(k, v) export(k, homify(v)) end",
"def public_key\n @data_public_key ||= load_public_key\n end",
"def public_key\n @cert.public_key\n end",
"def public_key\n DH.new(to_der)\n end",
"def public_key\n encode_tz(:edpk, 32)\n end",
"def public_key_params\n params[:public_key]\n end",
"def public_key_params\n params[:public_key]\n end",
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def ssh_public=(key_content)\n @ssh_public_file = temp_file_manager.path('key.pub')\n IO.write(@ssh_public_file, key_content)\n end",
"def export(data = nil, depth = 0)\n pre_export\n data = Exporter.export(data || {}, self, depth)\n data.merge!(serialization_export_header).stringify_keys\n end",
"def accept(host, key)\n @public_keys[host] = key\n File.open(@public_keys_file, 'w') do |f|\n YAML::dump(@public_keys, f)\n end \n end",
"def one_time_public_key\n token = generate_token('get_encription_public_key', @public_key)\n response = commit(:pci_encryption_key, token: token)\n response.params['encryption_key']\n end",
"def add_key(key)\n if File.exist?(key)\n data = File.open(key).read\n key_import = GPGME::Key.import(data, armor: true)\n key = GPGME::Key.get(key_import.imports[0].fpr).uids[0].email\n else\n data = GPGME::Key.export(key, armor: true).read\n end\n\n raise I18n.t('error.export_key') if data.to_s.empty?\n\n @keys[key] = data\n @passwords.each_key { |id| set_password(id, get_password(id)) }\n @otp_keys.each_key { |id| set_otp_key(id, get_otp_key(id)) }\n end",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def public_key_for_push_header\n trim_encode64(curve.public_key.to_bn.to_s(2))\n end",
"def private_key\n @private_key.to_der\n end",
"def pubkey\n end",
"def export_private_key(private_key, password = nil)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n unless password\n return Core::VirgilKeyPair.private_key_to_der(\n private_key.raw_key\n )\n end\n password_bytes = Bytes.from_string(password)\n private_key_bytes = Core::VirgilKeyPair.encrypt_private_key(\n private_key.raw_key,\n password_bytes\n )\n wrap_bytes(\n Core::VirgilKeyPair.private_key_to_der(\n private_key_bytes,\n password_bytes\n )\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def public_key\n return self.authentication.public_key\n end",
"def public_key\n return self.authentication.public_key\n end",
"def saveTempKey\n File.open(\"tempOut.txt\", 'w') {|f| f.write($publicKey) }\nend",
"def to_bytes; @key; end",
"def to_bytes; @key; end",
"def public_key(arg = nil)\n set_or_return(\n :public_key,\n arg,\n kind_of: String\n )\n end",
"def load_public_key(filename); end",
"def public_key_to_address(public_key_bin)\n Secp256k1::Util.bin_to_hex(keccak256(public_key_bin[1..-1])[-20..-1])\nend",
"def write_key!\n dir = Tinc.config['key_dir']\n File.open(\"#{dir}/#{node.mac}\", 'w') do |f|\n f.write(self.cert_data) \n end\n end",
"def public_key_to_address(public_key_bin)\n Secp256k1::Util.bin_to_hex(keccak256(public_key_bin[1..-1])[-20..-1])\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def regen_key\n @user = current_user\n @user.regen_private_key\n send_data @user.private_key, :type => \"application/pem-keys\", :disposition => \"attachment\", :filename => \"#{@user.username}.pem\"\n end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def key_material\n data.key_material\n end",
"def public_key_fingerprint\n Cryptosphere.kdf(public_key).unpack('H*').first.scan(/.{4}/).join(\":\")\n end",
"def export!\n render_manifest_output_and_keys\n render_zip\n end",
"def key_fingerprint\n data.key_fingerprint\n end",
"def export(key)\n @@exported[key] = @vars[key]\n end",
"def private_key; end",
"def private_key; end",
"def ecdh_public_key_bytes; end",
"def ext_pubkey\n k = ExtPubkey.new\n k.depth = depth\n k.number = number\n k.parent_fingerprint = parent_fingerprint\n k.chain_code = chain_code\n k.pubkey = key.pubkey\n k.ver = priv_ver_to_pub_ver\n k\n end",
"def to_rsa_pkey\n FrontEndBuilds::Utils::SSHPubKeyConvert\n .convert(pubkey)\n end",
"def key_file\n write_file(\"request-#{domain}.key\", key.to_pem)\n end",
"def transcend_public_key\n connection = Faraday.new() do |conn|\n conn.request :authorization, 'Bearer', $TRANSCEND_API_KEY\n conn.method :get\n end\n response = connection.get($PUBLIC_KEY_URL)\n OpenSSL::PKey.read(response.body)\nend",
"def update\n respond_to do |format|\n if @public_key.update(public_key_params)\n format.html { redirect_to @public_key, notice: 'Public key was successfully updated.' }\n format.json { render :show, status: :ok, location: @public_key }\n else\n format.html { render :edit }\n format.json { render json: @public_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def to_jwk\n KeySet.new(key.public_key).to_jwk\n end",
"def ext_pubkey\n k = ExtPubkey.new\n k.depth = depth\n k.number = number\n k.parent_fingerprint = parent_fingerprint\n k.chain_code = chain_code\n k.pubkey = key.pubkey\n k\n end",
"def export_pem!\n export(pem: true)\n end",
"def write(key)\n encrypted_key = key_encrypting_key.encrypt(key)\n puts \"\\n\\n********************************************************************************\"\n puts \"Set the environment variable as follows:\"\n puts \" export #{key_env_var}=\\\"#{encoder.encode(encrypted_key)}\\\"\"\n puts \"********************************************************************************\"\n end",
"def createkey(hostname, pupmodule, pubfolder, prvfolder)\n return 'Already there' if\n File.exist?(\"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\")\n key = SelfSignedCertificate.new(hostname)\n FileUtils.mkdir_p \"#{pubfolder}/#{pupmodule}/\"\n FileUtils.mkdir_p \"#{prvfolder}/#{hostname}/#{pupmodule}/\"\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.pub.pem\", 'w' do\n |io| io.write key.pub end\n open \"#{pubfolder}/#{pupmodule}/#{hostname}.cert.pem\", 'w' do\n |io| io.write key.crt end\n open \"#{prvfolder}/#{hostname}/#{pupmodule}/#{hostname}.priv.pem\", 'w' do\n |io| io.write key.priv end\n 'OK'\nend",
"def export\n\n end",
"def create(name, write_private)\n new_key = OpenSSL::PKey::RSA.generate(1024)\n new_public = new_key.public_key.to_pem\n new_private = new_key.to_pem\n File.open(File.join(@keystore, \"#{name}.pub\"), 'w') { |f| f.puts new_public }\n File.open(File.join(@keystore, \"#{name}.key\"), 'w') { |f| f.puts new_key } if write_private\n new_key\n end",
"def export\n\n end",
"def build_key(public_key, private_key)\n group = OpenSSL::PKey::EC::Group.new('prime256v1')\n key = OpenSSL::PKey::EC.new(group)\n\n public_bn = OpenSSL::BN.new(public_key, 16)\n private_bn = OpenSSL::BN.new(private_key, 16)\n public_key = OpenSSL::PKey::EC::Point.new(group, public_bn)\n\n key.tap do\n key.public_key = public_key\n key.private_key = private_bn\n end\n end",
"def generate_key_pair(compressed: true)\n private_key = 1 + SecureRandom.random_number(GROUP.order - 1)\n public_key = GROUP.generator.to_jacobian * private_key\n privkey = ECDSA::Format::IntegerOctetString.encode(private_key, 32)\n pubkey = public_key.to_affine.to_hex(compressed)\n [privkey.bth, pubkey]\n end",
"def save_public_key(pub_key_file_data, dev_id) \n pub_key_save_path = File.join(@@gitolite_keydir_path, \"#{dev_id}.pub\")\n if !File.exists?(pub_key_save_path)\n File.open(pub_key_save_path, \"wb\") { |f| f.write pub_key_file_data}\n else\n LOGGER.debug \"Public key file already exists at #{pub_key_save_path}; this will not be overwritten\"\n end\n return pub_key_save_path\n end"
] | [
"0.7781859",
"0.66773355",
"0.6368939",
"0.6321901",
"0.6321901",
"0.6321901",
"0.63197047",
"0.6272041",
"0.6263479",
"0.62478334",
"0.6205551",
"0.62020594",
"0.61686707",
"0.6161021",
"0.6156813",
"0.61464834",
"0.61463153",
"0.61401",
"0.61248195",
"0.61248195",
"0.60571754",
"0.6007899",
"0.5995302",
"0.5991974",
"0.5991974",
"0.5983744",
"0.59503454",
"0.5947092",
"0.593933",
"0.58874804",
"0.58870554",
"0.5851888",
"0.5851888",
"0.5850075",
"0.5825321",
"0.5793604",
"0.5793604",
"0.578129",
"0.57785136",
"0.5768924",
"0.5752705",
"0.57393306",
"0.57361823",
"0.5722441",
"0.57220125",
"0.57114655",
"0.5710581",
"0.57041633",
"0.56761104",
"0.5668291",
"0.5668291",
"0.56487596",
"0.5647115",
"0.5636056",
"0.5627724",
"0.5601789",
"0.5595155",
"0.55938554",
"0.5590504",
"0.5584474",
"0.5569307",
"0.55533147",
"0.5523891",
"0.5523891",
"0.5513082",
"0.5511471",
"0.5511471",
"0.55090743",
"0.5504433",
"0.54986566",
"0.5493732",
"0.5483666",
"0.5480792",
"0.54782295",
"0.5455006",
"0.5455006",
"0.5453787",
"0.54307365",
"0.5426413",
"0.54187536",
"0.54115605",
"0.54022133",
"0.54022133",
"0.5400098",
"0.54000777",
"0.53948957",
"0.53940487",
"0.5391682",
"0.53907645",
"0.5382369",
"0.5353099",
"0.5348764",
"0.5343483",
"0.5328123",
"0.53216034",
"0.53132975",
"0.5294995",
"0.5279672",
"0.5277719",
"0.52753276"
] | 0.7246649 | 1 |
Extracts the Public key from Private key. | def extract_public_key(private_key)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
public_key_bytes = Core::VirgilKeyPair.extract_public_key(
private_key.raw_key,
[]
)
VirgilPublicKey.new(
private_key.id,
wrap_bytes(
Core::VirgilKeyPair.public_key_to_der(public_key_bytes)
)
)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_public_key(private_key)\n PointG1.from_private_key(private_key)\n end",
"def extract_public_key(options)\n extract_key(options[:public_key] || options[:key_pair] || ENV['PUBLIC_KEY'])\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n require_key\n\n @private_key.public_key.to_pem\n end",
"def public_key\n @priv.public_key\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def public_key\n public_key_object.to_pem\n end",
"def get_public_key\n return @public_key\n end",
"def export_public_key\n public_key = context.crypto.extract_public_key(private_key)\n VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))\n end",
"def public_key\n @public_key.to_der\n end",
"def public_key_data\n @public_key\n end",
"def public_key\n Akero.replate(@cert.to_s, Akero::PLATE_CERT)\n end",
"def public_key\n @pub\n end",
"def public_key\n as_public_key(rpc(:account_key, _access: :key))\n end",
"def private_key\n @priv\n end",
"def public_key\n @public_key ||= load_key(@public_key_file)\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def gen_rsa_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::RSA.new key_content, priv_key_password\n key.public_key.to_pem\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def get_public_key(pub_key_url, reload = false)\n unless pub_key_url.start_with?(PUB_KEY_URL_PREFIX) ||\n pub_key_url.start_with?(PUB_KEY_URL_PREFIX_S)\n fail \"Invalid public key URL: #{pub_key_url}\"\n end\n\n if reload || @pub_key.nil?\n @pub_key = open(pub_key_url) { |f| f.read }\n end\n\n @pub_key\nend",
"def get_private_key\n return @private_key\n end",
"def public_key_params\n params[:public_key]\n end",
"def public_key_params\n params[:public_key]\n end",
"def private_key\n OpenSSL::PKey::RSA.new(_keypair)\n end",
"def load_public_key\n @public_rsa = nil\n \n if public_key_file && File.file?(public_key_file)\n @public_key = File.read(public_key_file)\n end\n end",
"def load_public_key(filename); end",
"def keyload(key_file_path=\"rsa_private_key.rb\")\n #require key_file_path\n require_relative key_file_path\n @n, @e= publickey\n @privatekey=privatekey\n #puts $n, $e, $privatekey\n end",
"def decode_string_public_key(raw, offset=0, algo=nil)\n key_raw, str_read = decode_string(raw, offset)\n key, cert_read = decode_public_key(key_raw, 0, algo)\n\n if cert_read != key_raw.bytesize\n raise DecodeError, \"unexpected trailing data\"\n end\n\n [key, str_read]\n end",
"def private_key\n @private_key.to_der\n end",
"def load_keypair(private_key, public_key)\n @private_key = private_key\n @public_key = public_key\n @private_rsa = OpenSSL::PKey::RSA.new @private_key\n @public_rsa = OpenSSL::PKey::RSA.new @public_key\n end",
"def load_data_public_key(data, filename = \"\")\n fields = data.split(/ /)\n\n blob = nil\n begin\n blob = fields.shift\n end while !blob.nil? && !/^(ssh-(rsa|dss|ed25519)|ecdsa-sha2-nistp\\d+)(-cert-v01@openssh\\.com)?$/.match(blob)\n blob = fields.shift\n\n raise Net::SSH::Exception, \"public key at #{filename} is not valid\" if blob.nil?\n\n blob = blob.unpack(\"m*\").first\n reader = Net::SSH::Buffer.new(blob)\n reader.read_key or raise OpenSSL::PKey::PKeyError, \"not a public key #{filename.inspect}\"\n end",
"def pubkey\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(payment_base) { |key, p| key.derive(p) }\n end",
"def public_key\n # Base64 encode without line feeds\n Base64.strict_encode64(public_key_raw)\n end",
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def priv_key\n key = master_ext_key.derive(PURPOSE_TYPE, true).derive(Tapyrus.chain_params.bip44_coin_type, true)\n\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(key) { |key, p| key.derive(p) }\n end",
"def extract_key(key, password = nil)\n return nil unless key\n\n case key\n when Proc then extract_key_from_proc(key, password)\n when Symbol then extract_key_from_method(key, password)\n when ::OpenSSL::PKey::RSA then key\n else\n key = retrieve_key_string_from_stream(key)\n return ::OpenSSL::PKey::RSA.new(key) if password.nil?\n ::OpenSSL::PKey::RSA.new(key, password.to_s)\n end\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def public_key_string\n [@public_key.to_s].pack(\"m*\").gsub(\"\\n\", \"\")\n end",
"def public_key\n @data_public_key ||= load_public_key\n end",
"def public_key\n DH.new(to_der)\n end",
"def one_time_public_key\n token = generate_token('get_encription_public_key', @public_key)\n response = commit(:pci_encryption_key, token: token)\n response.params['encryption_key']\n end",
"def gen_ec_pub_key(priv_key, priv_key_password = nil)\n # if the file exists try to read the content\n # if not assume we were passed the key and set the string to the content\n key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key\n key = ::OpenSSL::PKey::EC.new key_content, priv_key_password\n\n # Get curve type (prime256v1...)\n group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)\n # Get Generator point & public point (priv * generator)\n generator = group.generator\n pub_point = generator.mul(key.private_key)\n key.public_key = pub_point\n\n # Public Key in pem\n public_key = ::OpenSSL::PKey::EC.new\n public_key.group = group\n public_key.public_key = pub_point\n public_key.to_pem\n end",
"def get_public_key\n # Obtain public key\n pem_cert = Env.instance['RSA_PUBLIC_KEY_PATH']\n begin\n public_key = File.read(pem_cert)\n return public_key\n rescue => err \n $stderr.puts \"ERROR: missing RSA_PUBLIC_KEY_PATH in env.yml'\"\n end\n nil\n end",
"def private_key\n\t '-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3D37CD3A313CADA2 7c1TAxzv6Gn2OmZzVNtEnU9lqrEwRL65huGc9ewQQ7senY3rkBgIqBzqVarAfS0I 6OMimI57q7XywAiFn7CZ+L7fbXdNuvmGx5JDNRwylgGWR+hPi9JMKEAP1yjdJPRS 608pDXIliz5bO0GdvufQxQ91MPjE4Bs5AT8TIE3bzuFllBYJD/mLpkK4bOjLHswI 7W7afVctpYaRAwzb64Z+gUQZL0BIcQzG2wYvFU3vAs5sCtEy9o7riY/bBi78EEH6 go01DkgYLt8M7ApTwblJNJR0G/8bwy3oDgdieM42sFLzftxwjeBhIiF1ExH+KuYA ftAcROOfr8rduvNNc6jJcx2lyze+4joPjHDBXZr27bg3o3SwOQCIXUHe0DHG0PHn TbZkL2btHH36mTMq0j6P9R4t1wLhJ8Pq2LjLDwLhXw3Tb8aIX1tpShxyy9Yv8F84 Q6dfBLe4yqmvW1Db2nGmZ++gPua2OGWuNXwjivt2XrZ0fGAGri5j9bsqyvDsHwUS aRs8PaG97rgmyRGHYUoicBdgeFZhBHSLlU5F6RNUTOgK9QAHP4+bdKbMQxvhveh8 +v9o7Xa7BlqEvUYXIfBwEbHZoJx4t90XSndSS3chlfoEb6vcxOBmplUZlWs55aSL U7dW1MaE48Afav6TtM2VsN9RzwU8QSplpm7z9C9xkYVBMN6UcKIbnHH1yXdhTGEG uaEvPrtSh+BroAx1OmMjkmb0s1PjgDqLEtaYifP1OXgSS3uTqPBcpgUZDnuYQZmW Ihv7SvGdyWVQUgpv5LukyZPhXdlsCQ+8TlEYn4MOl87uxqo3KCVzVdmhAx2PWS/q wLcyOq0wJuvgAAtmI4/EnXVaP5P6WQ7rixfxdDfR1nI5TnDQkgs2xquyb0cms0J+ hXkIGvQOMAzq2Js3Ad7qyiklDASR20zZt6JPKTgZpLq682Fx+LJCCryAqjye2nAI 0w5SHEd80J/lAUEYo/HrNDBWS0JzD4lfERwUxgXxvynFI1ak38h0YP9RR2ka0pMI DJ8G6/w3Ir1qgLM/E+bTvp1YE683J/j1+vdYC/eoAbki2wgJAitYFdexLpw/qMvj xonY4iyhVkgzQb0GObesjPhr0CQ1gRC8p/A68Pk4cXejKTO95gUnD682Mu6lgYXQ e3rEnNVUruiPEzMKbkPLIsaWfUKfGRb0okQmuISXEfjyLfjkUgD6bxes+9KuHdvj pZze3dOgB1W6ZGsbrQ8ooXAOewYbhDcEqVsPOItVBoZ14CmCSd1X8RiW1dnfZBLa 5W8L7HaVLgiKUWlu2N6BE3etMK/fzhLh1K8WT6PxqzqVfJZZ9TYwVSYbcJuej0Hf ioHwYgqO22aZrp+ciJplCyOooFOKVVW45iLPtSHX64aE6FKbdPEPcndIOl0J9ah0 Hwicaw0ADP4STb83NysAZdHO2UVNEERkp2P4XmgeeH3gYHhPv3xCbbDejrrRJjeq VRer8i6HxiuJ/SxNKvbiwztF/44nWJ+9m2FoNqumTITdQAx7VU3681uEsO9ZbsJU Lbt0zwxna4X6WEtjdy5ExqLlU+wnzWgG+I11vgXSarye2oTuGPK8wjBkfEqdRTxs -----END RSA PRIVATE KEY----- '\n\tend",
"def private_key; end",
"def private_key; end",
"def create_public_private_rsa_key_pair_strings\r\n private_key = OpenSSL::PKey::RSA.new(2048)\r\n public_key = private_key.public_key\r\n private_public_key_strings_pair = {\r\n 'private_key_string' => private_key,\r\n 'public_key_string' => public_key\r\n }\r\n puts 'The randomly generated 2048-bit RSA private key string is:'\r\n puts private_public_key_strings_pair['private_key_string']\r\n puts 'The corresponding 2048-bit public key string is:'\r\n puts private_public_key_strings_pair['public_key_string']\r\n puts 'Keep a record of these key strings. You will not be able to properly ' \\\r\n 'encrypt and decrypt the contents of objects without these keys.'\r\n return private_public_key_strings_pair\r\nend",
"def generate_keypair\n key = OpenSSL::PKey::RSA.new 2048\n load_keypair(key.to_pem, key.public_key.to_pem)\n return [@private_key, @public_key]\n end",
"def to_rsa_pkey\n FrontEndBuilds::Utils::SSHPubKeyConvert\n .convert(pubkey)\n end",
"def public_key\n @cert.public_key\n end",
"def public_decrypt(ciphertext)\n @public_key.public_decrypt(ciphertext)\n end",
"def private_rsa\n if @key\n private_key = @private_key.decrypt(:symmetric, :key => @key, :algorithm => @algorithm)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def public_key\n encode64(curve.public_key.to_bn.to_s(2))\n end",
"def extract_private_key(options)\n extract_key(\n options[:private_key] || options[:key_pair] || ENV['PRIVATE_KEY'],\n options[:private_key_password] || ENV['PRIVATE_KEY_PASSWORD']\n )\n end",
"def decode_public_key(raw, offset=0, algo=nil)\n total_read = 0\n\n if algo.nil?\n algo, read = decode_string(raw, offset + total_read)\n total_read += read\n end\n\n unless fields = KEY_FIELDS_BY_PUBLIC_KEY_ALGO[algo]\n raise AlgorithmError, \"unknown algorithm: #{algo.inspect}\"\n end\n\n data, read = decode_fields(raw, fields, offset + total_read)\n total_read += read\n\n data[:algo] = algo\n\n [data, total_read]\n end",
"def public_key_to_address(public_key_bin)\n Secp256k1::Util.bin_to_hex(keccak256(public_key_bin[1..-1])[-20..-1])\nend",
"def private_key\n @private_key ||= load_key(@private_key_file)\n end",
"def public_key\n return self.authentication.public_key\n end",
"def public_key\n return self.authentication.public_key\n end",
"def auth_key_from_pem\n public_key = private_key.public_key\n Base64.strict_encode64(public_key.to_der)\n end",
"def transcend_public_key\n connection = Faraday.new() do |conn|\n conn.request :authorization, 'Bearer', $TRANSCEND_API_KEY\n conn.method :get\n end\n response = connection.get($PUBLIC_KEY_URL)\n OpenSSL::PKey.read(response.body)\nend",
"def public_key\n return @children['public-key'][:value]\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def privkey(add_compressed_suffix=false)\n compressed_suffix = add_compressed_suffix && compressed ? \"01\" : \"\"\n [key.private_key.to_s(16) + compressed_suffix].pack('H*')\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def public_key\n @cert.public_key\n end",
"def private_key!\n if self[:kopal_encoded_private_key].blank?\n regenerate_private_key!\n end\n OpenSSL::PKey::RSA.new Base64::decode64(self[:kopal_encoded_private_key])\n end",
"def private_key\n # jruby-openssl OpenSSL::PKey::EC support isn't complete\n # https://github.com/jruby/jruby-openssl/issues/189\n jruby_not_implemented(\"OpenSSL::PKey::EC is not fully implemented\") if type == \"ecdsa\"\n\n key_object.to_pem\n end",
"def publickey hashid, &block\n em_get( \"/clients/#{uuid}/#{hashid}/publickey\" ) { |response| block.call( response ) }\n end",
"def load_public_key(filename)\n data = File.read(File.expand_path(filename))\n load_data_public_key(data, filename)\n end",
"def private_key\n encode64(curve.private_key.to_s(2))\n end",
"def private_key\n @key\n end",
"def public_key(format: :z85)\n case format\n when :z85\n ffi_delegate.public_txt.force_encoding(Encoding::ASCII)\n when :binary\n ffi_delegate.public_key.read_string(32)\n else\n raise ArgumentError, format('invalid format: %p', format)\n end\n end",
"def build_key(public_key, private_key)\n group = OpenSSL::PKey::EC::Group.new('prime256v1')\n key = OpenSSL::PKey::EC.new(group)\n\n public_bn = OpenSSL::BN.new(public_key, 16)\n private_bn = OpenSSL::BN.new(private_key, 16)\n public_key = OpenSSL::PKey::EC::Point.new(group, public_bn)\n\n key.tap do\n key.public_key = public_key\n key.private_key = private_bn\n end\n end",
"def public_key_to_address(public_key_bin)\n Secp256k1::Util.bin_to_hex(keccak256(public_key_bin[1..-1])[-20..-1])\n end",
"def ecdh_public_key_bytes; end",
"def parse_public_keys\n # Convert keys to compressed_hex format for bitcoin-ruby\n @public_keys_hex = @cosigners_nodes.map { |index, key| key.public_key.to_hex }\n end",
"def public_key_for_push_header\n trim_encode64(curve.public_key.to_bn.to_s(2))\n end",
"def get_host_private_key(host)\n private_key = host.puppet['hostprivkey']\n # puppet may not have laid down the private_key yet, so check to make sure\n # the file exists\n host.execute(\"test -f #{private_key}\")\n host.execute(\"cat #{private_key}\", :silent => true)\n end",
"def export_public_key(public_key)\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n\n begin\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key.raw_key)\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def priv_ver_to_pub_ver\n case version\n when Bitcoin.chain_params.bip49_privkey_p2wpkh_p2sh_version\n Bitcoin.chain_params.bip49_pubkey_p2wpkh_p2sh_version\n when Bitcoin.chain_params.bip84_privkey_p2wpkh_version\n Bitcoin.chain_params.bip84_pubkey_p2wpkh_version\n else\n Bitcoin.chain_params.extended_pubkey_version\n end\n end",
"def to_bytes\n @public_key\n end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def public_key=(k)\n return self.authentication.public_key = k\n end",
"def masa_pki\n masakey.public_key.to_der\n end",
"def private_key_pem\n @private_key.to_pem\n end",
"def public_key\n encode_tz(:edpk, 32)\n end",
"def initialize(private_key, opts = { public_key: nil, passphrase: nil })\n if private_key.is_a? OpenSSL::PKey::RSA\n @private_key = private_key\n elsif !private_key.to_s.eql?('')\n @private_key = OpenSSL::PKey::RSA.new(\n if File.exists?(File.expand_path(private_key))\n File.read(File.expand_path(private_key))\n else\n private_key\n end,\n opts[:passphrase]\n )\n unless @private_key.private?\n raise(\n Cryptic::InvalidKey,\n \"Public key '#{private_key}' provided as a private key.\"\n )\n end\n end\n\n if public_key.is_a? OpenSSL::PKey::RSA\n @public_key = public_key\n else\n @public_key = OpenSSL::PKey::RSA.new(\n if opts[:public_key] && File.exists?(File.expand_path(opts[:public_key].to_s))\n File.read(File.expand_path(opts[:public_key].to_s))\n elsif opts[:public_key]\n opts[:public_key]\n else\n @private_key or raise(Cryptic::KeyNotFound)\n end,\n opts[:passphrase]\n ).public_key\n end\n rescue OpenSSL::PKey::RSAError => e\n if e.message.eql? 'Neither PUB key nor PRIV key:: not enough data'\n if @private_key.nil?\n raise Cryptic::InvalidKey, \"Invalid private key: #{private_key}\"\n elsif @public_key.nil?\n raise Cryptic::InvalidKey, \"Invalid public key: #{public_key}\"\n end\n elsif e.message.eql? 'Neither PUB key nor PRIV key:: nested asn1 error'\n raise Cryptic::IncorrectPassphrase, \"Unable to open private key:\n '#{private_key}'. was the passphrase valid?\"\n else\n raise e\n end\n end",
"def public_key=(_); end",
"def public_key=(_); end",
"def rsa_key(key_as_string)\n OpenSSL::PKey::RSA.new key_as_string\n end",
"def public_key(arg = nil)\n set_or_return(\n :public_key,\n arg,\n kind_of: String\n )\n end",
"def private_rsa\n if password\n options = {:password => password}\n options[:algorithm] = algorithm if algorithm\n \n private_key = @private_key.decrypt(:symmetric, options)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def generate_rsa_keys(p, q)\r\n # Find \"n\", the product of two primes\r\n n = p * q\r\n # Calculate Euler's Totient For The Two Primes\r\n eulers_totient = (p - 1) * (q - 1)\r\n # Find Public Key \"e\" such that 1 < e < totient, e is coprime to totient\r\n key_public = 2\r\n loop do\r\n break if (key_public.gcd(eulers_totient) == 1)\r\n key_public += 1\r\n end\r\n # Find Private Key \"d\" such that e * d * mod(totient) = 1\r\n key_private = 1\r\n loop do\r\n key_private += 1\r\n break if ((key_public * key_private) % eulers_totient == 1)\r\n end\r\n # Public Key = (e,n), Private Key = (d,n)\r\n return [key_public, key_private, n]\r\nend",
"def public_key_fingerprint\n Cryptosphere.kdf(public_key).unpack('H*').first.scan(/.{4}/).join(\":\")\n end"
] | [
"0.78158396",
"0.7225965",
"0.72168237",
"0.72168237",
"0.69963855",
"0.69673043",
"0.6884596",
"0.6699677",
"0.6683896",
"0.66786957",
"0.66164",
"0.65782636",
"0.6566694",
"0.6541878",
"0.6507677",
"0.65064543",
"0.64971787",
"0.64472294",
"0.64472294",
"0.6425457",
"0.6398824",
"0.6393028",
"0.6389497",
"0.6389497",
"0.6378611",
"0.6342159",
"0.6319705",
"0.62847376",
"0.6249822",
"0.6240661",
"0.62388307",
"0.6218145",
"0.62128675",
"0.6188956",
"0.6173896",
"0.6173896",
"0.6173896",
"0.6172453",
"0.616558",
"0.61547816",
"0.61547816",
"0.61418784",
"0.6133773",
"0.6123487",
"0.61036474",
"0.60960096",
"0.60624605",
"0.6058776",
"0.6043525",
"0.6043525",
"0.6030873",
"0.6024461",
"0.60221153",
"0.60201806",
"0.6003171",
"0.6001609",
"0.6000203",
"0.6000016",
"0.597697",
"0.59657794",
"0.59603167",
"0.5959158",
"0.5959158",
"0.59525466",
"0.59430647",
"0.5939087",
"0.59315354",
"0.5929178",
"0.5929096",
"0.5929096",
"0.5919402",
"0.5915019",
"0.59054327",
"0.58938307",
"0.5886462",
"0.5881646",
"0.58778286",
"0.5851702",
"0.584966",
"0.584894",
"0.583367",
"0.5823916",
"0.58219224",
"0.5785638",
"0.5758863",
"0.57581854",
"0.57538956",
"0.5743107",
"0.5743107",
"0.5733192",
"0.5729119",
"0.57101995",
"0.5698324",
"0.56938785",
"0.56938785",
"0.5685677",
"0.5680369",
"0.5676735",
"0.56705344",
"0.5651464"
] | 0.7918782 | 0 |
Encrypts the specified data using the specified recipients Public keys. | def encrypt(bytes, *public_keys)
bytes = Validation.check_filled_array_argument!(bytes)
begin
encrypt_for_recipients(bytes, Core::VirgilCipher.new, public_keys)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(data)\n raise NoPublicKeyError, \"Public key file: #{@public_key_file}\" unless public?\n \n encrypted_data = public_rsa.public_encrypt(data)\n Base64.encode64(encrypted_data)\n end",
"def encrypt(data)\n\t\t# The limit of the encryption scheme is 235 bytes, so if the string is longer than that we need to limit it\n\t\tif data.length > 234\n\t\t\tdata = data[0..234] + \"\\n\"\n\t\tend\n\n\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/attacker.pub'\n\t\treturn key.public_key.public_encrypt(data)\n\tend",
"def public_encrypt(data)\n Base64.encode64(@key.public_encrypt(data))\n end",
"def encrypt(data, expires_at: nil, expires_in: nil, purpose: nil)\n return nil unless data\n\n service.encrypt_and_sign(\n data,\n expires_at: expires_at,\n expires_in: expires_in,\n purpose: purpose\n )\n end",
"def encrypt( data )\n rsa = OpenSSL::PKey::RSA.new( File.read( @public_pem ) )\n\n # encrypt with 256 bit AES with CBC\n aes = OpenSSL::Cipher::Cipher.new( 'aes-256-cbc' )\n aes.encrypt\n\n # use random key and IV\n aes.key = key = aes.random_key\n aes.iv = iv = aes.random_iv\n\n # this will hold all primitives and ciphertext\n primitives = {}\n\n primitives['ciphertext'] = aes.update( data )\n primitives['ciphertext'] << aes.final\n\n primitives['key'] = rsa.public_encrypt( key )\n primitives['iv'] = rsa.public_encrypt( iv )\n\n # serialize everything and base64 encode it\n Base64.encode64( primitives.to_yaml )\n end",
"def encrypt(data)\n return nil if !@key\n Base64::encode64(@key.private_encrypt(data)).delete(\"\\n\").strip\n end",
"def sign_then_encrypt(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n custom_bytes = cipher.custom_params\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNATURE,\n generate_signature(bytes, private_key)\n )\n\n public_key = extract_public_key(private_key)\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNER_ID,\n wrap_bytes(public_key.id)\n )\n encrypt_for_recipients(bytes, cipher, public_keys)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def encrypt(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to encrypt data with.\") unless key\n options = settings[:crypt].merge(options)\n unless data.is_a?(String)\n data = JSON.generate(data)\n end\n encrypted_data = crypt(:encrypt, data, key, options)\n encode(encrypted_data, options)\n end",
"def public_encrypt(plaintext)\n @public_key.public_encrypt(plaintext)\n end",
"def encrypt(data, key=nil)\n Crypto.new(key.nil? ? config.key : key).encrypt(data)\n end",
"def urlsafe_base64_asymmetric_encrypt(data, public_key)\n # Load key\n pkey = OpenSSL::PKey::RSA.new(public_key, nil)\n raise 'Invalid public key.' unless pkey.public?\n\n # Encrypt data\n encrypted_data = pkey.public_encrypt(data)\n # Encode encrypted data with custom Encoder\n custom_base64_urlsafe_encode(encrypted_data)\n end",
"def encrypt_with_public(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_public(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_public(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt_with_public(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_public(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_public(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt_data(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end",
"def encrypt_key(key, public_key)\n encrypted_key = public_key.public_encrypt(key)\n encode encrypted_key\n end",
"def encrypt_message plaintext\n key_pair.encrypt plaintext\n end",
"def encrypt(data)\n pipe_to_stdin command('--encrypt'), data\n end",
"def encrypt(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end",
"def encrypt(data)\n _encrypt(data, \"#{NOT_SEARCHABLE.chr}\\0#{@key_id.chr}\\0\")\n end",
"def encrypt(value)\n if !@private_key.present? && encrypted?(value)\n value\n else\n escape_and_execute_sql([\"SELECT pgp_pub_encrypt(?, dearmor(?))\", value.to_s, @public_key])['pgp_pub_encrypt']\n end\n end",
"def encrypt(data)\n crypto_key.encrypt64(data)\n end",
"def encrypt(string, public_key = nil)\n require_key unless public_key\n\n key = OpenSSL::PKey::RSA.new(public_key || @private_key.public_key.to_pem)\n\n Base64.encode64(key.public_encrypt(string))\n end",
"def encrypt(data)\n self.class.encrypt(data + salt.to_s)\n end",
"def initialize(data, public_key = nil, encoding = :none, opts = {})\n @encoding = encoding\n\n if !public_key && !opts[:public_key_file]\n # If no public key was provided the data should already be encrypted\n @data = data\n elsif File.exists?(opts[:public_key_file].to_s)\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n elsif public_key\n public_key = OpenSSL::PKey::RSA.new(public_key)\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n end\n end",
"def encrypt data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final \n end",
"def encrypt(text)\n Base64.encode64(@public_key.public_encrypt(text)).gsub(/\\n/, \"\") if text\n end",
"def encrypt(text)\n Base64.encode64(@public_key.public_encrypt(text)).gsub(/\\n/, \"\") if text\n end",
"def encrypt_stream(input_stream, cipher_stream, *public_keys)\n begin\n cipher = Core::VirgilChunkCipher.new\n public_keys.each do |public_key|\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n cipher.add_key_recipient(public_key.id, public_key.raw_key)\n end\n source = VirgilStreamDataSource.new(input_stream)\n sink = VirgilStreamDataSink.new(cipher_stream)\n cipher.encrypt(source, sink)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def pack(data)\n if @pubkey && [email protected]?\n block_size = @pubkey.n.num_bytes - 11\n\n edata = ''\n index = 0\n\n loop do\n break if index >= data.length\n\n edata << @pubkey.public_encrypt(data[index, block_size])\n\n index += block_size\n end\n\n data = edata\n end\n\n zdata = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION)\n Base64.strict_encode64(zdata)\n end",
"def encrypt_data(plaintext, &encrypted)\n written = @engine.write plaintext\n\n if written < plaintext.length\n exit -1\n end\n\n read_data = []\n\n while(read_chunk = @engine.extract)\n read_data << read_chunk\n end\n\n if block_given?\n read_data.each do |data|\n encrypted.call data\n end\n else\n read_data.join\n end\n end",
"def encrypt(msg, rng: Botan::RNG.new)\n msg_buf = FFI::MemoryPointer.from_data(msg)\n Botan.call_ffi_with_buffer(lambda { |b, bl|\n LibBotan.botan_pk_op_encrypt(@ptr, rng.ptr, b, bl,\n msg_buf, msg_buf.size)\n })\n end",
"def encrypt(to, plaintext, ascii_armor = true)\n to = [to] unless to.is_a? Array\n to = to.map do |e|\n case e\n when String\n begin\n OpenSSL::X509::Certificate.new(Akero.replate(e, Akero::PLATE_CERT, true))\n rescue OpenSSL::X509::CertificateError\n raise ERR_INVALID_RECIPIENT_CERT\n end\n else\n raise ERR_INVALID_RECIPIENT\n end\n end\n out = _sign(_encrypt(to, _sign(plaintext, false)))\n ascii_armor ? Akero.replate(out.to_s, PLATE_CRYPTED) : out.to_der\n end",
"def encrypt(plaintext, options = {})\n # TODO\n end",
"def pgp_pub_encrypt(value)\n encode_to_hex Arel::Nodes::NamedFunction.new 'pgp_pub_encrypt',\n [ bind_param(value),\n dearmor(public_key),\n Arel::Nodes::Quoted.new(ENCRYPT_OPTS.map{|k,v| \"#{k}=#{v}\" }.join(',')) ]\n end",
"def rsa_encrypt_with_public(plain_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_encrypt(plain_string)\n end",
"def rsa_encrypt_with_public(plain_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_encrypt(plain_string)\n end",
"def private_encrypt(plaintext)\n @private_key.private_encrypt(plaintext)\n end",
"def encrypt(data, key = nil, iv = nil)\n key ||= @request[:secret]\n iv ||= @request[:iv]\n\n @cipher.encrypt\n @cipher.key = key\n @cipher.iv = iv\n\n @cipher.update(data)\n end",
"def encode(data)\n @encryptor.encrypt_and_sign(data)\n end",
"def encrypt(data, passphrase)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.encrypt\n\n cipher.key = Digest::SHA256.digest(passphrase)\n cipher.iv = obtain_iv(passphrase)\n\n rsize = rand(32)\n data = '' << rsize << random_data(rsize) << data\n\n encrypted = cipher.update(data)\n encrypted << cipher.final\n\n return encrypted\n end",
"def encrypt(data, password = nil)\n salt = random_bytes(@salt_len)\n iv = random_bytes(@salt_len)\n aes_key, mac_key = keys(salt, password)\n\n aes = cipher(aes_key, iv, true)\n ciphertext = aes.update(data) + aes.final\n mac = sign(iv + ciphertext, mac_key)\n\n encrypted = salt + iv + ciphertext + mac\n encrypted = Base64.strict_encode64(encrypted) if @base64\n encrypted\n rescue TypeError, ArgumentError => e\n error_handler e\n end",
"def encrypt(*args, &block)\n crypt :encrypt, *args, &block\n end",
"def searchable_encrypt(data)\n _encrypt(data, _search_prefix(data, SEARCHABLE, @key_id, @key))\n end",
"def encrypt_with_private(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_private(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_private(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt_with_private(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_private(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_private(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt(keys, plain)\n ::Fernet.generate(keys.last, plain)\n end",
"def encrypt(data)\n\tarray = splitencrypt(data)\n\tencryptedBlock = ''\n\tfor i in 0...array.length\n\t encryptedBlock << @blowfish.encrypt_block(array[i])\n\tend\n\treturn encryptedBlock\n end",
"def update_keys\n public_key = params.require(:public_key)\n private_key = params.require(:private_key)\n salt = params.require(:salt)\n\n # Check if encrypt settings are visible to user.\n groups = current_user.groups.pluck(:name)\n encrypt_groups = SiteSetting.encrypt_groups.split('|')\n raise Discourse::InvalidAccess if !SiteSetting.encrypt_groups.empty? && (groups & encrypt_groups).empty?\n\n # Check if encryption is already enabled (but not changing passphrase).\n old_public_key = current_user.custom_fields['encrypt_public_key']\n if old_public_key && old_public_key != public_key\n return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)\n end\n\n current_user.custom_fields['encrypt_public_key'] = public_key\n current_user.custom_fields['encrypt_private_key'] = private_key\n current_user.custom_fields['encrypt_salt'] = salt\n current_user.save_custom_fields\n\n render json: success_json\n end",
"def encrypt; end",
"def encrypt(plaintext, rsa_key)\n # Generate a random symmetric key (K1) and use it to generate\n # ciphertext (CT) from our plaintext (PT)\n \n aes = OpenSSL::Cipher::Cipher.new(\"AES-256-CBC\")\n aes.encrypt\n # generate a random IV\n iv = aes.random_iv\n # generate the session key\n session_key = aes.random_key\n # encrypt the payload with session key\n ciphertext = aes.update(plaintext) + aes.final\n \n # Key wrapping: at this point we (A) have CT and K1. The only way\n # to decrypt the CT back to PT is via K1. To securely transfer K1\n # to our receiver (B), we encrypt it with the provided (public) key\n \n # encrypt the session key with the public key\n encrypted_session_key = rsa_key.public_encrypt(session_key)\n \n [ciphertext, iv, encrypted_session_key]\n end",
"def encrypt(data)\n # Create a random 32 byte string to act as the initialization vector.\n iv = SecureRandom.random_bytes(32)\n # Pyro pads the data with zeros\n cipher = FirebugMcrypt.new(:rijndael_256, :cbc, @key, iv, :zeros)\n add_noise(iv + cipher.encrypt(data))\n end",
"def update_keys\n public_identity = params.require(:public)\n private_identity = params[:private]\n private_id_label = params[:label]\n\n # Check if encryption is already enabled (but not changing passphrase).\n old_identity = current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]\n if params[:overwrite].blank? && old_identity && old_identity != public_identity\n return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)\n end\n\n current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD] = public_identity\n\n if private_identity.present?\n if private_id_label.present?\n data = JSON.parse(current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD]) rescue {}\n data[private_id_label.downcase] = private_identity\n current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = JSON.dump(data)\n else\n current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = private_identity\n end\n end\n\n current_user.save_custom_fields\n\n render json: success_json\n end",
"def encode(data, passphrase)\n pack64(encrypt(data, passphrase))\n end",
"def encrypt(text_to_encrypt, base64_encode=true)\n encrytped = public_key.public_encrypt(text_to_encrypt)\n base64_encode ? Base64UrlSafe.encode(encrytped) : encrytped\n end",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def encrypt(data, key_hex)\n key = hex_to_bytes(key_hex)\n (encrypted_data_bytes, iv_bytes) = encrypt_bytes(data, key)\n encrypted_data_hex = bytes_to_hex(encrypted_data_bytes)\n iv_hex = bytes_to_hex(iv_bytes)\n [encrypted_data_hex, iv_hex]\n end",
"def aes_ecb_encrypt(data, key, params: {})\n key_arr = key.unpack(\"C*\")\n\n data = pad_data(data, 16)\n encrypted_data = data.unpack(\"C*\").each_slice(16).map do |slice|\n state = array_to_matrix(slice)\n encrypted_state = aes_encrypt_block(state, key_arr)\n matrix_to_array(encrypted_state).pack(\"C*\")\n end\n\n # return base64 encoded data\n [encrypted_data.join].pack(\"m\")\n end",
"def encrypt(plaintext)\n @cipher.encrypt(@secret_key, plaintext)\n end",
"def encrypt(plaintext)\n begin\n ciphertext_blob = client.encrypt_and_sign(plaintext)\n\n success_with_data(\n ciphertext_blob: ciphertext_blob\n )\n rescue Exception => e\n error_with_data('lc_1',\n \"LocalCipher could not encrypt text with message => #{e.message}\",\n 'Something Went Wrong.',\n GlobalConstant::ErrorAction.default,\n {})\n end\n end",
"def encrypt(key, message)\n key.public_key? or raise \"Must have public key to encrypt\"\n @cipher.reset\n\n ephemeral_key = OpenSSL::PKey::EC.generate(key.group)\n ephemeral_public_key_octet = ephemeral_key.public_key.to_octet_string(:compressed)\n\n shared_secret = ephemeral_key.dh_compute_key(key.public_key)\n\n key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)\n cipher_key = key_pair.byteslice(0, @cipher.key_len)\n hmac_key = key_pair.byteslice(-@mac_length, @mac_length)\n\n @cipher.encrypt\n @cipher.iv = IV\n @cipher.key = cipher_key\n ciphertext = @cipher.update(message) + @cipher.final\n\n mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)\n\n ephemeral_public_key_octet + ciphertext + mac\n end",
"def aes_encrypt(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, \"randomString\", 1024, aes.key_len)\n aes.iv = iv if iv != nil\n aes.update(data.to_s) + aes.final \n end",
"def encrypt(*attributes) \n \tinclude ActiveCrypto::Encrypted\n \tbefore_save :encrypt_attributes\n \tafter_save :decrypt_attributes\n options=attributes.last.is_a?(Hash) ? attributes.pop : {}\n keyholder\n if options and options[:key]\n \t\t\t\tmodule_eval <<-\"end;\"\t\t\t\t \n \t\t\t\t\tdef session_key\n \t\t\t\t\t\t(send :#{options[:key]} ).send :session_key\n \t\t\t\t\tend\t \n \t\t\t\t\t@@external_key=true\n \t\t\t\tend;\n end\n\n base64_encode = (options and options[:base64])\n module_eval <<-\"end;\"\n def self.ezcrypto_base64?\n #{base64_encode.to_s}\n end\n end;\n \n self.encrypted_attributes=attributes\n end",
"def decrypt_and_encrypt(data)\n ## ** Decrypt\n keys = @keys\n begin\n #@@window.puts(\"Attempting to decrypt with primary key\")\n data = _decrypt_packet_internal(keys, data)\n #@@window.puts(\"Successfully decrypted with primary key\")\n\n # If it was successfully decrypted, make sure the @old_keys will no longer work\n @old_keys = nil\n rescue Encryptor::Error => e\n # Attempt to fall back to old keys\n if(@old_keys.nil?)\n @@window.puts(\"No secondary key to fallback to\")\n raise(e)\n end\n\n @@window.puts(\"Attempting to decrypt with secondary key\")\n keys = @old_keys\n data = _decrypt_packet_internal(@old_keys, data)\n @@window.puts(\"Successfully decrypted with secondary key\")\n end\n\n # Send the decrypted data up and get the encrypted data back\n data = yield(data, ready?(keys))\n\n # If there was an error of some sort, return nothing\n if(data.nil? || data == '')\n return ''\n end\n\n # If encryption is turned off, return unencrypted data\n if(!ready?(keys))\n @@window.puts(\"Returning an unencrypted response\")\n return data\n end\n\n ## ** Encrypt\n #@@window.puts(\"Encrypting the response\")\n\n # Split the packet into a header and a body\n header, body = data.unpack(\"a5a*\")\n\n # Encode the nonce properly\n nonce = [keys[:my_nonce]].pack(\"n\")\n\n # Encrypt the body\n encrypted_body = Salsa20.new(keys[:my_write_key], nonce.rjust(8, \"\\0\")).encrypt(body)\n\n # Sign it\n signature = SHA3::Digest::SHA256.digest(keys[:my_mac_key] + header + nonce + encrypted_body)\n\n # Arrange things appropriately\n return [header, signature[0,6], nonce, encrypted_body].pack(\"a5a6a2a*\")\n end",
"def encrypt(data)\n Digest::SHA1.hexdigest(data + @salt)\n end",
"def encrypt(data)\n cipher = OpenSSL::Cipher.new(\"AES-256-CBC\")\n cipher.encrypt\n cipher.iv = @enc_iv\n cipher.key = @enc_key\n encrypted = cipher.update(data) + cipher.final\n enc = Base64.strict_encode64(encrypted)\nend",
"def encrypt(x)\n @aes_key.encrypt(x)\n end",
"def write_encrypted(data)\n @writer.print(@encrypter.encrypt(data))\n end",
"def crypt( decrypt_or_encrypt, data, pwhash, iv )\n c = OpenSSL::Cipher.new CIPHER\n c.send decrypt_or_encrypt.to_sym\n c.key = pwhash\n c.iv = iv\n c.update( data ) << c.final\n end",
"def encript_ep \n\t\tsign_in_data = {\n\t\t\temail: email\n\t\t}\n\t\t\n\t sign_in_data.each do |key,attr_val|\n encrypted_data = AseEncriptDecriptJob::encryption(attr_val)\n self.send(\"#{key}=\",encrypted_data) \n\t end\n\tend",
"def encrypt_and_send_message(opts={})\n opts.merge!(:persistent => true)\n encrypted_message = encrypt_message(opts[:message], opts[:password])\n exchange.publish(encrypted_message,opts)\n end",
"def decrypt_and_encrypt(d_data)\n _ensure_shared_secret!()\n\n ## Figure out which key to use\n keys = @keys\n begin\n d_data = _decrypt_packet_internal(keys, d_data)\n\n # If it was successfully decrypted, make sure the @old_keys will no longer work\n @old_keys = nil\n rescue Error => e\n # Attempt to fall back to old keys\n if(@old_keys.nil?)\n raise(e)\n end\n\n keys = @old_keys\n d_data = _decrypt_packet_internal(@old_keys, d_data)\n end\n\n # Send the decrypted data up and get the encrypted data back\n e_data = yield(d_data)\n\n return _encrypt_packet_internal(keys, e_data)\n end",
"def update!(**args)\n @public_key_data = args[:public_key_data] if args.key?(:public_key_data)\n end",
"def send_message(data,opts={})\n opts.merge!(:persistent => true)\n # Encrypt the message using the password supplied\n data = encrypt_message(data, opts[:password]) if opts[:password]\n exchange.publish(data,opts)\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def set_encrypt_messages\n @rsa = Rsa.find(params[:rsa_id])\n end",
"def encrypt(plaintext)\n begin\n\n e_resp = client.encrypt({\n plaintext: plaintext,\n key_id: key_id\n }).to_h\n\n ciphertext_blob = e_resp[:ciphertext_blob]\n\n return success_with_data(\n ciphertext_blob: ciphertext_blob\n )\n\n rescue => e\n return exception_with_data(\n e,\n 'a_k_2',\n GlobalConstant::ErrorAction.default,\n {\n purpose: @purpose,\n role: @role,\n plaintext: plaintext\n }\n )\n end\n end",
"def encrypt_secret(path_to_public_key)\n @public_key = OpenSSL::PKey::RSA.new(File.read(path_to_public_key))\n @public_key.public_encrypt(@secret)\n end",
"def encrypt(*args, &block)\n ::ActiveRecord::Base.connection.unescape_bytea(escape_and_execute_sql([\"SELECT encode(pgp_sym_encrypt(?::text, ?::text), 'escape') pgp_sym_encrypt\", value(args), key(args)])['pgp_sym_encrypt'])\n end",
"def _encrypt(data, prefix)\n padding = @padding\n random_data = SecureRandom.random_bytes(32)\n cipher = OpenSSL::Cipher.new(\"aes-256-gcm\")\n cipher.encrypt\n cipher.key = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, @key, random_data)\n cipher_iv = cipher.random_iv\n cipher.auth_data = @auth_data\n\n cipher_text = String.new\n data_size = data.bytesize\n\n padding_size = if padding\n (padding * rand(1)) + padding - (data.bytesize % padding)\n else\n 0\n end\n\n cipher_text << cipher.update(padding_size.chr)\n cipher_text << cipher.update(SecureRandom.random_bytes(padding_size)) if padding_size > 0\n cipher_text << cipher.update(data) if data_size > 0\n cipher_text << cipher.final\n\n Base64.urlsafe_encode64(\"#{prefix}#{random_data}#{cipher_iv}#{cipher.auth_tag}#{cipher_text}\")\n end",
"def edit_with_public_keys(&block)\n # Set public key values for view\n set_public_key_values\n\n # Previous routine\n edit_without_public_keys(&block)\n end",
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def protecting_encrypted_data(&block)\n with_encryption_context encryptor: ActiveRecord::Encryption::EncryptingOnlyEncryptor.new, frozen_encryption: true, &block\n end",
"def encrypt(data)\n cipher = OpenSSL::Cipher.new 'AES-256-CBC'\n cipher.encrypt\n cipher.key, cipher.iv = @password, @iv\n data.nil? ? '' : (cipher.update(data) + cipher.final).unpack('H*')[0]\n end",
"def encrypt_message pub_key, message\n p_key = pub_key.shuffle[0 .. pub_key.length / 2] # randomly select half the values\n sum = 0\n p_key.each{ |i| sum += i}\n return sum + message\nend",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def rsa_encrypt_with_private(plain_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_encrypt(plain_string)\n end",
"def rsa_encrypt_with_private(plain_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_encrypt(plain_string)\n end",
"def sign_and_encrypt_combined(message)\n source_part = body_to_part(message)\n restrict_encoding(source_part)\n signer = find_signer_for(message)\n recipients = find_recipients_for(message)\n encrypted =\n sign_and_encrypt_string(source_part.encoded, signer, recipients).to_s\n encrypted_part = build_encrypted_part(encrypted)\n control_part = build_encryption_control_part\n\n rewrite_body(\n message,\n content_type: multipart_encrypted_content_type,\n parts: [control_part, encrypted_part],\n )\n end",
"def crypt(decrypt_or_encrypt, data, key, iv)\n c = OpenSSL::Cipher.new(CIPHER)\n c.send(decrypt_or_encrypt.to_sym)\n c.key = key\n c.iv = iv\n c.update(data) << c.final\n end",
"def set_data(data)\n data = data.pack('c*') if data.class == Array\n raise \"No increment has been set. It is necessary to encrypt the data\" if @increment.nil?\n \n # Set the length\n self.length = data.length+2\n \n # Save the decrypted message\n @decrypted_data = @data\n \n # Set the message\n @data = TkCrypt::encrypt(data, self.increment)\n end",
"def sign_and_encrypt_encapsulated(message)\n sign(message)\n encrypt(message)\n end",
"def encrypt(\n data, key, salt, iter, iv = SecureRandom.random_bytes(16), key_length = 32\n )\n cipher = OpenSSL::Cipher.new \"AES-256-CBC\"\n cipher.encrypt\n cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, iter, key_length)\n cipher.iv = iv\n {\n data: cipher.update(data) + cipher.final,\n iv: iv\n }\n end",
"def encrypt(plainText, key)\n shiftText(plainText, key)\n end",
"def send_to_recipients(stanzas, recipients)\n recipients.each do |recipient|\n stanzas.each do |el|\n el[TO] = recipient.user.jid.to_s\n recipient.write(el)\n end\n end\n end",
"def seal(plaintext, associated_data = [])\n raise TypeError, \"expected String, got #{plaintext.class}\" unless plaintext.is_a?(String)\n\n v = _s2v(associated_data, plaintext)\n ciphertext = @ctr.encrypt(_zero_iv_bits(v), plaintext)\n v + ciphertext\n end",
"def chat(data)\n # uid of the intended recipient\n # only the intended recipient will be able to decrypt\n to = data['to'].to_s\n\n if ConnectedList.include?(to)\n relay_message(to, data)\n else\n intended_recipient_not_found(to)\n end\n end",
"def encrypt data, opts={}\r\n opts = opts.to_hwia :ttl, :password\r\n payload = { data:data }\r\n payload[:ttl] = Time.now.to_i + opts.ttl.to_i if opts.ttl\r\n\r\n JWT.encode payload, secret+opts.password.to_s, ALGORITHM\r\n end",
"def encrypt(plaintext)\n box.encrypt(plaintext)\n end",
"def encrypt(message)\n xcrypt(:encrypt, message)\n end"
] | [
"0.7157979",
"0.685075",
"0.66326123",
"0.65123576",
"0.64897233",
"0.6386013",
"0.62958753",
"0.6275172",
"0.62656736",
"0.62612504",
"0.62299573",
"0.6107599",
"0.6107599",
"0.60174876",
"0.5987157",
"0.5954661",
"0.5951951",
"0.58724535",
"0.5861233",
"0.5855871",
"0.58490753",
"0.58446926",
"0.5827315",
"0.5809472",
"0.57970345",
"0.57900864",
"0.57900864",
"0.57415944",
"0.5685722",
"0.56646055",
"0.5639926",
"0.56140596",
"0.56061006",
"0.56043464",
"0.5602209",
"0.5602209",
"0.5568956",
"0.5553727",
"0.5551991",
"0.5508474",
"0.55004066",
"0.54893124",
"0.54834455",
"0.5476851",
"0.5476851",
"0.54634535",
"0.545676",
"0.54310095",
"0.5394554",
"0.53916717",
"0.53867805",
"0.53419256",
"0.5333539",
"0.53223675",
"0.5299048",
"0.5275793",
"0.5253516",
"0.5236941",
"0.5230302",
"0.521839",
"0.52048373",
"0.5143389",
"0.51379645",
"0.5120864",
"0.5119488",
"0.511415",
"0.5113103",
"0.5105604",
"0.5098345",
"0.50782377",
"0.50779897",
"0.5059713",
"0.50527143",
"0.50525326",
"0.50525326",
"0.5001476",
"0.4999016",
"0.499393",
"0.49921468",
"0.4989816",
"0.49841037",
"0.49704364",
"0.49696434",
"0.4967691",
"0.4966319",
"0.49526232",
"0.49470043",
"0.49470043",
"0.49327686",
"0.49310565",
"0.4926467",
"0.4918253",
"0.49000072",
"0.48815674",
"0.48787254",
"0.48753244",
"0.48670962",
"0.48665854",
"0.48618054",
"0.485917"
] | 0.69187206 | 1 |
Decrypts the specified bytes using Private key. | def decrypt(cipher_bytes, private_key)
cipher_bytes = Validation.check_filled_array_argument!(cipher_bytes)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
cipher = Core::VirgilCipher.new
decrypted_bytes = cipher.decrypt_with_key(
cipher_bytes,
private_key.id,
private_key.raw_key
)
wrap_bytes(decrypted_bytes)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private_decrypt(ciphertext)\n @private_key.private_decrypt(ciphertext)\n end",
"def decrypt(data)\n raise NoPrivateKeyError, \"Private key file: #{@private_key_file}\" unless private?\n \n decrypted_data = Base64.decode64(data)\n private_rsa.private_decrypt(decrypted_data)\n end",
"def decrypt(string)\n require_key\n\n @private_key.private_decrypt(Base64.decode64(string))\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def decrypt_message ciphertext\n key_pair.decrypt ciphertext\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt(data)\n crypto_key.decrypt64(data)\n end",
"def decrypt(data)\n @cert_chain[0].public_key.public_decrypt(Base64::decode64(data))\n end",
"def decrypt(msg, private_key)\n # 1\n rsa_encrypted_aes_key = msg[0..255] # 256 bits\n rsa_encrypted_aes_iv = msg[256..511] # next 256 bits\n aes_encrypted_message = msg[512..msg.length]\n\n # 2\n rsa_decryptor = OpenSSL::PKey::RSA.new private_key\n aes_key = rsa_decryptor.private_decrypt rsa_encrypted_aes_key\n aes_iv = rsa_decryptor.private_decrypt rsa_encrypted_aes_iv\n\n # 3\n decipher = OpenSSL::Cipher::AES256.new(AES_MODE)\n decipher.decrypt\n decipher.key = aes_key\n decipher.iv = aes_iv\n\n decipher.update(aes_encrypted_message) + decipher.final\n end",
"def decrypt()\n \t@private_key = AES.decrypt(self.encrypted_private_key, ENV[\"DECRYPTION_KEY\"])\n end",
"def decrypt_byte\n temp = (@key2 | 2) & 0x0000ffff\n ((temp * (temp ^ 1)) >> 8) & 0x000000ff\n end",
"def decrypt(ciphertext)\n @cipher.decrypt(@secret_key, ciphertext)\n end",
"def decrypt(private_key_file, passphrase = nil)\n if File.exists?(private_key_file.to_s)\n private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), passphrase)\n decoded_string = decode(@data)\n private_key.private_decrypt(decoded_string)\n else\n private_key = OpenSSL::PKey::RSA.new(private_key_file, passphrase)\n decoded_string = decode(@data)\n private_key.private_decrypt(decoded_string)\n end\n rescue => e\n $stderr.puts e\n raise Cryptic::KeyNotFound\n end",
"def _decrypt_packet_internal(keys, data)\n @l.debug(\"Encryptor: Decrypting a #{data.length}-byte packet\")\n # Don't decrypt if we don't have a key set\n# if(@keys[:shared_secret].nil?)\n# return data\n# end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Check if it was truncated\n if(nonce.nil? || nonce.length < 2)\n raise(Error, \"Invalid encrypted packet!\")\n end\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + header + nonce + encrypted_body)\n if(correct_signature[0,6] != signature)\n raise(Error, \"Invalid signature on incoming packet!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n raise(Error, \"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n return header + body\n end",
"def decrypt_then_verify(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n decrypted_bytes = cipher.decrypt_with_key(\n bytes,\n private_key.id,\n private_key.raw_key\n )\n signature = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNATURE)\n\n signer_public_key = public_keys.first\n\n if public_keys.count > 1\n signer_id = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNER_ID)\n signer_public_key = public_keys.find {|public_key| public_key.id == signer_id}\n end\n\n is_valid = verify_signature(signature, decrypted_bytes, signer_public_key)\n raise VirgilCryptoException, 'Signature is not valid' unless is_valid\n\n wrap_bytes(decrypted_bytes)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def decrypt(data)\n\t\tbegin\n\t\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/victim.pem'\n\t\t\treturn key.private_decrypt(data)\n\t\trescue\n\t\t\treturn false\n\t\tend\n\tend",
"def decrypt(ciphertext, passwd, options = {})\n iv_and_ciphertext = Base64.decode64(ciphertext)\n cipher = new_cipher(:decrypt, passwd, options)\n cipher.iv, ciphertext = iv_and_ciphertext(cipher, iv_and_ciphertext)\n plaintext = cipher.update(ciphertext)\n plaintext << cipher.final\n plaintext\n end",
"def decrypt(data, padding: nil)\n dec = Botan::PK::Decrypt.new(key: self, padding: padding)\n dec.decrypt(data)\n end",
"def decrypt_data(data, private_key, iv)\n aes = OpenSSL::Cipher::AES.new(256, :CBC)\n aes.decrypt\n aes.iv = iv\n aes.key = private_key\n aes.update(data) + aes.final\n end",
"def decrypt(*args, &block)\n crypt :decrypt, *args, &block\n end",
"def decrypt(value)\n return unless value\n fail ArgumentError, 'Value is not encrypted' unless value.match(REGEXP)\n @key.private_decrypt(Base64.strict_decode64(Regexp.last_match(:value)))\n end",
"def decrypt(msg)\n msg_buf = FFI::MemoryPointer.from_data(msg)\n Botan.call_ffi_with_buffer(lambda { |b, bl|\n LibBotan.botan_pk_op_decrypt(@ptr, b, bl, msg_buf, msg_buf.size)\n })\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def decrypt(data, key=nil)\n Crypto.new(key.nil? ? config.key : key).decrypt(data)\n end",
"def _decrypt_packet_internal(keys, data)\n # Don't decrypt if we don't have a key set\n if(!ready?(keys))\n @@window.puts(\"Not decrypting data (incoming data seemed to be cleartext): #{data.unpack(\"H*\")}\")\n return data\n end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Put together the data to sign\n signed_data = header + nonce + encrypted_body\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + signed_data)\n if(correct_signature[0,6] != signature)\n @@window.puts(\"Couldn't verify packet signature!\")\n raise(Encryptor::Error, \"Invalid signature!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n @@window.puts(\"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n raise(Encryptor::Error, \"Invalid nonce!\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n #@@window.puts(\"Decryption successful\")\n return header+body\n end",
"def decrypt(ciphertext, options = {})\n # TODO\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, &b)\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, password, mtime, &b)\n end",
"def decrypt(data)\n pipe_to_stdin command('--decrypt'), data\n end",
"def import_private_key(key_bytes, password = nil)\n key_bytes = Validation.check_filled_array_argument!(key_bytes)\n\n begin\n decrypted_private_key = if !password\n Core::VirgilKeyPair.private_key_to_der(key_bytes)\n else\n Core::VirgilKeyPair.decrypt_private_key(\n key_bytes,\n Bytes.from_string(password)\n )\n end\n\n public_key_bytes = Core::VirgilKeyPair.extract_public_key(\n decrypted_private_key, []\n )\n key_pair_id = compute_public_key_hash(public_key_bytes)\n private_key_bytes = Core::VirgilKeyPair.private_key_to_der(\n decrypted_private_key\n )\n return VirgilPrivateKey.new(key_pair_id, wrap_bytes(private_key_bytes))\n rescue => error\n raise VirgilCryptoException, error.message\n end\n\n end",
"def decrypt64(str)\n dec = ''\n str = Base64.decode64(str)\n while str.length != 0\n dec += self.private_decrypt(str[0..self.decrypt_block_size])\n str = str[self.decrypt_block_size+1..-1] if str.length > self.decrypt_block_size\n end\n dec\n end",
"def decrypt(data)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n cipher.key = @passphrase\n cipher.iv = @iv\n decrypted = cipher.update(data)\n decrypted << cipher.final\n json = JSON.parse(decrypted)\n self.identifier = json['identifier']\n @expiry = Time.parse(json['expiry'])\n rescue OpenSSL::Cipher::CipherError => e\n raise Kennedy::BadTicketException, \"Given data was not decryptable\"\n end",
"def decrypt(text_to_decrypt, base64_encoded=true)\n text = base64_encoded ? Base64UrlSafe.decode(text_to_decrypt) : text_to_decrypt\n begin\n @key.private_decrypt(text)\n rescue OpenSSL::PKey::RSAError\n nil\n end\n end",
"def decrypt(msg)\n msg = Bytes.new(msg) unless msg.is_a?(Bytes)\n\n @cipher.decrypt\n @cipher.padding = 0\n @cipher.key = @key.ascii\n\n ptext = []\n (0..msg.length/BLOCK_SZ - 1).each do |block_i|\n block = msg.slice(block_i*BLOCK_SZ, BLOCK_SZ)\n\n dec = Bytes.new(@cipher.update(block.ascii) + @cipher.final)\n dec ^= @state\n ptext << dec\n\n @state = block\n end\n\n ptext = ptext.reduce(:concat)\n\n # Strip off padding.\n Bytes.new(ptext.reject { |b| b == ptext[-1] })\n end",
"def decrypt(data, password = nil)\n data = Base64.strict_decode64(data) if @base64\n\n salt = data[0, @salt_len]\n iv = data[@salt_len, @iv_len]\n ciphertext = data[@salt_len + @iv_len..-@mac_len - 1]\n mac = data[data.length - @mac_len, @mac_len]\n\n aes_key, mac_key = keys(salt, password)\n verify(iv + ciphertext, mac, mac_key)\n\n aes = cipher(aes_key, iv, false)\n plaintext = aes.update(ciphertext) + aes.final\n plaintext\n rescue TypeError, ArgumentError, NoMethodError => e\n error_handler e\n rescue OpenSSL::OpenSSLError => e\n error_handler e\n end",
"def decrypt(encrypted_text)\n len = encrypted_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(encrypted_text.length == 0) || (encrypted_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = encrypted_text.scan(/.{8}/m)\n decrypted_blocks = []\n blocks.each do |block|\n decryptedBlock = self.class.decryptBlock(block, @keys)\n decrypted_blocks << decryptedBlock\n end\n output = decrypted_blocks.join\n return output\n end",
"def decrypt(data)\n data = remove_noise(data)\n # The first 32 bytes of the data is the original IV\n iv = data[0..31]\n cipher = FirebugMcrypt.new(:rijndael_256, :cbc, @key, iv, :zeros)\n cipher.decrypt(data[32..-1])\n end",
"def decrypt(data)\n\tarray = splitdencrypt(data)\n\tdecryptedBlock = ''\n\tfor i in 0...array.length\n\t val = array[i]\n\t decryptedBlock << @blowfish.decrypt_block([val].pack('H*'))\n\tend\n\treturn decryptedBlock\n end",
"def decrypt(ciphertext)\n ciphertext = ciphertext.unpack('m').first\n tag = ciphertext[0, hmac_length]\n ciphertext = ciphertext[hmac_length..-1]\n\n # make sure we actually had enough data for the tag too.\n if tag && ciphertext && verify_message(tag, ciphertext)\n decrypt_ciphertext(ciphertext)\n else\n nil\n end\n end",
"def decrypt_stream(cipher_stream, output_stream, private_key)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n begin\n cipher = Core::VirgilChunkCipher.new\n source = VirgilStreamDataSource.new(cipher_stream)\n sink = VirgilStreamDataSink.new(output_stream)\n cipher.decrypt_with_key(source, sink, private_key.id, private_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def decrypt(ciphertext_blob)\n begin\n\n d_resp = client.decrypt({\n ciphertext_blob: ciphertext_blob\n }).to_h\n\n plaintext = d_resp[:plaintext]\n\n return success_with_data(\n plaintext: plaintext\n )\n\n rescue => e\n return exception_with_data(\n e,\n 'a_k_1',\n GlobalConstant::ErrorAction.default,\n {\n purpose: @purpose,\n role: @role,\n ciphertext_blob: ciphertext_blob\n }\n )\n end\n end",
"def decrypt(encrypted_string)\n CRYPTO.decrypt_string(encrypted_string.decode64)\nend",
"def public_decrypt(ciphertext)\n @public_key.public_decrypt(ciphertext)\n end",
"def decrypt(passphrase)\n self.user.decrypt(self.encrypted_message, passphrase)\n end",
"def decrypt(message)\n xcrypt(:decrypt, message)\n rescue OpenSSL::Cipher::CipherError\n raise CipherError, 'invalid password'\n end",
"def decrypt(ciphertext, key)\n plaintext = []\n i = 0\n ciphertext.each_byte do |c|\n p = c ^ key[i % 3][0]\n i += 1\n plaintext << p.chr\n end\n return plaintext.join\nend",
"def decrypt(x)\n @aes_key.decrypt(x)\n end",
"def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n decrypted_data = cipher.update(crypt_string) + cipher.final\n end",
"def decrypt data, key, salt, iter, iv, key_length = 32\n decipher = OpenSSL::Cipher.new \"AES-256-CBC\"\n decipher.decrypt\n decipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, iter, key_length)\n decipher.iv = iv\n decipher.update(data) + decipher.final\n end",
"def decrypt(enc)\n\n des = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC')\n des.decrypt\n des.key = \"7304912f3d62b5efcd837373bf6b7ff4f1f438b6b67008ef\".unhex\n des.iv = \"0a0a0a0a0a0a0a0a\".unhex\n des.padding = 0\n\n # libCARSReposMgr.so 3DES padding handling is wrong...\n # we try to mimick the behavior here.\n enc += \"00\" * ( 8 - ( (enc.length / 2) & 7 ) )\n\n decrypted_passwd = des.update(enc.unhex) + des.final\n decrypted_passwd.gsub(/\\x00.*/, '')\n\n end",
"def urlsafe_base64_asymmetric_decrypt(urlsafe_base64_encrypted_data, private_key)\n # Load key\n pkey = OpenSSL::PKey::RSA.new(private_key, nil)\n raise 'Invalid private key.' unless pkey.private?\n\n # Decode encrypted data with custom decoding\n encrypted_data = custom_base64_urlsafe_decode(urlsafe_base64_encrypted_data)\n # Decrypt encrypted data\n pkey.private_decrypt(encrypted_data)\n end",
"def decrypt!(encrypted_data, options = {})\n secret = options[:secret]\n cipher = Gibberish::AES.new(secret)\n cipher.decrypt(encrypted_data).strip\n end",
"def decrypt(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to decrypt data with.\") unless key\n options = settings[:crypt].merge(options)\n decoded_data = decode(data, options)\n decrypted_data = crypt(:decrypt, decoded_data, key, options)\n return data unless decrypted_data\n begin\n JSON.parse(decrypted_data)\n rescue JSON::ParserError\n decrypted_data\n end\n end",
"def decrypt(str)\n str = str.unpack('m0').first\n aes = OpenSSL::Cipher::Cipher.new('aes-128-cbc').decrypt\n aes.key = @secret\n iv = str[0, aes.iv_len]\n aes.iv = iv\n crypted_text = str[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end",
"def decrypt(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decrypt(key, encrypted_message)\n key.private_key? or raise \"Must have private key to decrypt\"\n @cipher.reset\n\n ephemeral_public_key_length = key.group.generator.to_octet_string(:compressed).bytesize\n ciphertext_length = encrypted_message.bytesize - ephemeral_public_key_length - @mac_length\n ciphertext_length > 0 or raise OpenSSL::PKey::ECError, \"Encrypted message too short\"\n\n ephemeral_public_key_octet = encrypted_message.byteslice(0, ephemeral_public_key_length)\n ciphertext = encrypted_message.byteslice(ephemeral_public_key_length, ciphertext_length)\n mac = encrypted_message.byteslice(-@mac_length, @mac_length)\n\n ephemeral_public_key = OpenSSL::PKey::EC::Point.new(key.group, OpenSSL::BN.new(ephemeral_public_key_octet, 2))\n\n shared_secret = key.dh_compute_key(ephemeral_public_key)\n\n key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)\n cipher_key = key_pair.byteslice(0, @cipher.key_len)\n hmac_key = key_pair.byteslice(-@mac_length, @mac_length)\n\n computed_mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)\n computed_mac == mac or raise OpenSSL::PKey::ECError, \"Invalid Message Authenticaton Code\"\n\n @cipher.decrypt\n @cipher.iv = IV\n @cipher.key = cipher_key\n\n @cipher.update(ciphertext) + @cipher.final\n end",
"def decrypt(ciphertext_blob)\n begin\n plaintext = client.decrypt_and_verify(ciphertext_blob)\n\n success_with_data(\n plaintext: plaintext\n )\n rescue Exception => e\n error_with_data('lc_2',\n \"LocalCipher could not decrypt cipher with message => #{e.message}\",\n 'Something Went Wrong.',\n GlobalConstant::ErrorAction.default,\n {})\n end\n end",
"def decrypt(encrypted_data_hex, key_hex, iv_hex)\n encrypted_data_bytes = hex_to_bytes(encrypted_data_hex)\n key = hex_to_bytes(key_hex)\n iv = hex_to_bytes(iv_hex)\n decrypt_bytes(encrypted_data_bytes, key, iv)\n end",
"def decrypt(value)\n if @private_key.present? && encrypted?(value)\n escape_and_execute_sql([\"SELECT pgp_pub_decrypt(?, dearmor(?), ?)\",\n value, @private_key, @key])['pgp_pub_decrypt']\n else\n value\n end\n end",
"def decrypt!(cipher, options={})\n opt = { salt: '', parse: true }.merge!(options)\n\n set_crypto cipher, opt[:intmode]\n iv = compute_iv_for_decrypting(force_binary(opt[:salt]), self[:content])\n\n if authenticated?\n if @icv_length.zero?\n @icv_length = opt[:icv_length].to_i if opt[:icv_length]\n raise PacketGen::ParseError, 'unknown ICV size' if @icv_length.zero?\n end\n icv = self[:content].slice!(-@icv_length, @icv_length)\n end\n\n authenticate_if_needed iv, icv\n private_decrypt opt\n end",
"def decrypt_secret(ciphertext, plugin: 'pkcs7')\n unless plugins.by_name(plugin)\n raise Bolt::Plugin::PluginError::Unknown, plugin\n end\n\n plugins.get_hook(plugin, :secret_decrypt)\n .call('encrypted_value' => ciphertext)\n end",
"def decrypt( string, pass, salt)\n key, iv = derive_key_iv( pass, salt)\n \n decipher = OpenSSL::Cipher::AES.new(256, :CBC)\n decipher.decrypt\n decipher.key = key\n decipher.iv = iv\n\n decipher.update( string) + decipher.final\n end",
"def decrypt(data, passphrase)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n\n cipher.key = Digest::SHA256.digest(passphrase)\n cipher.iv = obtain_iv(passphrase)\n\n decrypted = cipher.update(data)\n decrypted << cipher.final\n\n rsize = decrypted[0]\n return decrypted[rsize + 1..-1]\n rescue\n return nil\n end",
"def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n cipher.update(crypt_string) + cipher.final\n end",
"def decrypt!(data, options = {})\n unless options.has_key?(:secret)\n options[:secret] = PreciousCargo::Secret.decrypt!(options)\n end\n\n PreciousCargo::Data.decrypt!(data, options)\n end",
"def decrypt(password = nil, salt = nil)\n Hoodie::Crypto.decrypt(self, password, salt)\n end",
"def decrypt_data(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.padding = 0\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decode(data, passphrase)\n decrypt(unpack64(data), passphrase)\n rescue\n return nil\n end",
"def decipher(key, user_iv, text)\n ssl_decipher = OpenSSL::Cipher.new('AES-256-CBC')\n ssl_decipher.decrypt\n ssl_decipher.key = key\n ssl_decipher.iv = user_iv\n ssl_decipher.update(text) + ssl_decipher.final\n end",
"def decrypt_from_file(secure)\n secure.open('rb') { |s| basic_decrypt(StringIO.new, s).string }\n end",
"def decrypt encrypted_data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final \n end",
"def decrypt(encrypted)\n return nil unless encrypted =~ /Validation: (.*?)\\n(.*)\\n\\*\\*\\*/m\n begin\n decipher = OpenSSL::Cipher.new(\"AES-128-CBC\")\n decipher.decrypt\n # puts \"**** $1=#{$1}, $2=#{$2}\"\n decipher.key = EMAIL_KEY\n decipher.iv = Base64.decode64($1)\n encrypted_data = Base64.decode64($2)\n # puts \"**** decipher.iv=#{Base64.encode64 iv}\"\n # puts \"**** encrypted=#{Base64.encode64 encrypted}\"\n return decipher.update(encrypted_data) + decipher.final \n rescue\n return nil\n end \n end",
"def decrypt(encrypted_str)\n return encrypted_str unless encrypted_str.is_a?(String) && @derived_key\n return encrypted_str unless encrypted_str.start_with?(ENCRYPTED_PREFIX)\n\n decrypt_str = encrypted_str[ENCRYPTED_PREFIX.length..-1]\n params = decode_aes(decrypt_str)\n\n cipher = OpenSSL::Cipher.new(CIPHER).decrypt\n\n cipher.key = @derived_key\n cipher.iv = params.nonce\n cipher.auth_tag = params.auth_tag\n cipher.auth_data = \"\"\n\n decoded_str = cipher.update(params.data) + cipher.final\n\n # force to utf-8 encoding. We already ensured this when we encoded in the first place\n decoded_str.force_encoding(Encoding::UTF_8)\n end",
"def decrypt; end",
"def decrypt(keystream)\n\t\tdecrypted_stream = String.new\n\t\[email protected] do |i|\n\t\t\ta = if keystream[i] % 26 == 0\n\t\t\t\t26\n\t\t\telse\n\t\t\t\tkeystream[i] % 26\n\t\t\tend\n\t\t\tb = string[i].ord - 64\n\t\t\tdecrypted_stream << if b - a <= 0\n\t\t\t\t((b - a + 26) + 64).chr\n\t\t\telse\n\t\t\t\t((b - a) + 64).chr\n\t\t\tend\n\t\tend\n\t\tdecrypted_stream\n\tend",
"def decrypt(encrypted_text, password = nil, salt = nil)\n password = password.nil? ? Hoodie.crypto.password : password\n salt = salt.nil? ? Hoodie.crypto.salt : salt\n\n iv_ciphertext = Base64.decode64(encrypted_text)\n cipher = new_cipher(:decrypt, password, salt)\n cipher.iv, ciphertext = separate_iv_ciphertext(cipher, iv_ciphertext)\n plain_text = cipher.update(ciphertext)\n plain_text << cipher.final\n plain_text\n end",
"def decrypt_text(checksum)\n key = key_from_checksum(checksum, decode_bytes(pbkdf2_salt))\n decrypt_string decode_bytes(crypted_text), decode_bytes(auth_tag), key, decode_bytes(iv), label\n end",
"def decrypt_byte(iv, block, known)\n c = BLOCK_SIZE.times.map { rand(0..255) }\n p = known.length + 1\n\n # During encryption we:\n # 1. XOR (block, iv)\n # 2. Encrypt the value above ending with an \"encrypted value\"\n #\n # During decryption we do:\n # 1. decrypted_value = aes_cbc_decrypt(encrypted_value, KEY)\n # 2. XOR(decrypted_value, iv)\n # 3. We now have our plaintext\n #\n # So let's deconstruct what \"c[byte_pos] = x ^ p ^ iv[byte_pos]\" means.\n #\n # 1. We know \"x\" is part of our \"zeroing IV\", meaning:\n # * XOR(decrypted_value[pos], x) == 0\n # 2. p is the amount of zeroing bytes we already know\n # 3. iv[byte_pos] is our IV\n #\n # By doing c[byte_pos] = x ^ p ^ iv[byte_pos]\n #\n # We know that doing XOR(XOR(decrypted_block, iv), iv) will return decrypted_block\n # Following with XOR(decrypted_block[pos], x) will return 0 since x is equal the block\n # byte.\n # Followed by XOR(0, p) will return p, setting the byte to the padding value we want\n\n known.each_with_index do |x, i|\n byte_pos = BLOCK_SIZE - i - 1\n c[byte_pos] = x ^ p ^ iv[byte_pos]\n end\n\n i = 0\n\n loop do\n c[BLOCK_SIZE - p] = i\n break if check_credentials(c, block)\n raise \"Couldn't guess byte\" if i > 256\n i += 1\n end\n\n # So here we know c[BLOCK_SIZE - p] = i generated a value that\n # when XORed creates a valid padding for that specific byte.\n # Now we need to find the value for the \"zeroing IV\".\n #\n # We know that \"iv[BLOCK_SIZE - p] ^ i\" generates a number for a valid padding\n # when XORing it with our decrypted_value\n # and \"p\" represents that number for the current iteration. So XORing\n # \"iv[BLOCK_SIZE - p] ^ i\" with \"p\" will generate a number that when XORed\n # with the decrypted block will zero it.\n\n iv[BLOCK_SIZE - p] ^ i ^ p\nend",
"def decrypt\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\t\t\r\n\t\t_rt = Encryptor.decrypt(Base64.decode64(@data))\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\t\r\n\t end",
"def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end",
"def decrypt(bin64, iv64)\n aes = OpenSSL::Cipher::Cipher.new($alg)\n aes.decrypt\n aes.key = $key\n aes.iv = Base64.urlsafe_decode64(iv64)\n aes.update(Base64.urlsafe_decode64(bin64)) + aes.final\nend",
"def decrypt(text64, iv)\n if @cipher\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-#{@cipher}-cbc\")\n cipher.decrypt\n cipher.key = @secret[0..cipher_block_size]\n if iv != \"\"\n cipher.iv = Base64.decode64(iv)\n end\n decrypted_text = cipher.update(Base64.decode64(text64))\n decrypted_text << cipher.final\n return decrypted_text\n else\n return text64\n end\n end",
"def decrypt(data)\n return nil if data.to_s.empty?\n\n password =\n if /^(1\\.[0-9.]+|2\\.0)(\\.[0-9]+)?/ =~ GPGME::Engine.info.first.version || @pinmode\n { password: @gpg_pass }\n else\n { password: @gpg_pass,\n pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK }\n end\n\n crypto = GPGME::Crypto.new(armor: true)\n crypto\n .decrypt(data, password)\n .read.force_encoding('utf-8')\n rescue => e\n raise \"#{I18n.t('error.gpg_file.decrypt')}\\n#{e}\"\n end",
"def lookup(encrypted_string)\n crypted_iv, crypted_value = encrypted_string.split('|')\n fail ArgumentError, 'invalid value for decryption' unless crypted_iv && crypted_value\n iv = Base64.decode64(crypted_iv)\n value = Base64.decode64(crypted_value)\n @cipher.iv = iv\n @cipher.update(value) + @cipher.final\n end",
"def decrypt_password(crypted=false, key=encryption_key, encryption_mehtod=self.auth_method)\n self.class.decrypt(crypted||self.send(props[:crypted_password]), key, encryption_mehtod)\n end",
"def decrypt(txt)\n x = -1\n return txt.unpack('U*').pack('S*').unpack(\"U*\").collect do |i| \n x += 1\n x %= CRYPT.size\n i - CRYPT[x].unpack('U').first > 0 ? i - CRYPT[x].unpack('U').first : i\n end.pack('U*')\n end",
"def decrypt(data, key = nil, iv = nil)\n key ||= @request[:secret]\n iv ||= @request[:iv]\n\n @cipher.decrypt\n @cipher.key = key\n @cipher.iv = iv\n\n @cipher.update(data)\n end",
"def base_decrypt(ciphertext)\n RbNaCl::SimpleBox\n .from_secret_key(key)\n .decrypt(ciphertext)\n .force_encoding(Encoding::UTF_8)\n end",
"def decrypt\n self.class.decrypt(@encrypted_name, @id)\n end",
"def decrypt_string(ciphertext, auth_tag, key, iv, auth_data = '')\n cipher = OpenSSL::Cipher.new(CIPHER_TYPE)\n cipher.decrypt\n cipher.key = key\n cipher.iv = iv[0, IV_LENGTH]\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = auth_data\n\n cipher.update(ciphertext) + cipher.final\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt(string)\n d_salt, d_iv, ciphertext = p_unpack_string(\n string,\n profile.key_len,\n profile.iv_len,\n profile.salt_bytes\n )\n p_decrypt_string(ciphertext, key(d_salt), d_iv, profile.algorithm)\n end",
"def decrypt_ciphertext(ciphertext)\n aes = OpenSSL::Cipher.new(@cipher).decrypt\n aes.key = @encryption_key\n iv = ciphertext[0, aes.iv_len]\n aes.iv = iv\n crypted_text = ciphertext[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end",
"def decrypt(base64_string)\r\n encrypted = Base64.decode64(base64_string)\r\n aes = decipher\r\n aes.update(encrypted) + aes.final\r\n end",
"def decipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.decrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end"
] | [
"0.7711891",
"0.73947483",
"0.7364903",
"0.72615296",
"0.72615296",
"0.7042651",
"0.7042651",
"0.70365864",
"0.7018639",
"0.7018639",
"0.69881797",
"0.69086564",
"0.6836868",
"0.6815539",
"0.68030435",
"0.658077",
"0.6578454",
"0.65765536",
"0.65653026",
"0.65250695",
"0.6521881",
"0.6501917",
"0.64998937",
"0.6499708",
"0.64766026",
"0.6459116",
"0.638805",
"0.63814604",
"0.6327006",
"0.63042945",
"0.62540394",
"0.6239298",
"0.62186146",
"0.621559",
"0.6210448",
"0.6187783",
"0.61779356",
"0.6174558",
"0.61649984",
"0.61597973",
"0.6143708",
"0.613031",
"0.60869616",
"0.6085015",
"0.6068548",
"0.60674214",
"0.60487825",
"0.6043859",
"0.60235214",
"0.6021773",
"0.6009997",
"0.59885585",
"0.5988456",
"0.5975878",
"0.596622",
"0.5966069",
"0.59634256",
"0.59441596",
"0.5942423",
"0.5932463",
"0.5904598",
"0.5904207",
"0.5903458",
"0.58873975",
"0.5883952",
"0.58826584",
"0.5871877",
"0.58557725",
"0.5848594",
"0.58250314",
"0.5822951",
"0.58173597",
"0.5808517",
"0.58070904",
"0.5801195",
"0.5800182",
"0.57930136",
"0.5783938",
"0.5781838",
"0.57557106",
"0.57551306",
"0.57500875",
"0.5742427",
"0.5737602",
"0.57370937",
"0.57324034",
"0.5714669",
"0.56932014",
"0.5692501",
"0.5688482",
"0.56868076",
"0.567993",
"0.56689",
"0.5658702",
"0.565865",
"0.565865",
"0.5624253",
"0.5615584",
"0.56124276",
"0.56073165"
] | 0.7909941 | 0 |
Signs and encrypts the data. | def sign_then_encrypt(bytes, private_key, *public_keys)
bytes = Validation.check_filled_array_argument!(bytes)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
cipher = Core::VirgilCipher.new
custom_bytes = cipher.custom_params
custom_bytes.set_data(
CUSTOM_PARAM_KEY_SIGNATURE,
generate_signature(bytes, private_key)
)
public_key = extract_public_key(private_key)
custom_bytes.set_data(
CUSTOM_PARAM_KEY_SIGNER_ID,
wrap_bytes(public_key.id)
)
encrypt_for_recipients(bytes, cipher, public_keys)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(data)\n @key.sign(@algo.new, data)\n end",
"def sign data\n return unless @key\n\n @key.sign @digest_algorithm.new, data\n end",
"def encode(data)\n @encryptor.encrypt_and_sign(data)\n end",
"def sign\n validate!\n\n @voter.update(\n data: @data,\n signature: @signature,\n signed_vote_at: Time.now\n )\n\n signer = @signer.new(@admin_key)\n signer.sign(@data.to_i)\n end",
"def sign_and_encrypt_encapsulated(message)\n sign(message)\n encrypt(message)\n end",
"def encrypt(data, expires_at: nil, expires_in: nil, purpose: nil)\n return nil unless data\n\n service.encrypt_and_sign(\n data,\n expires_at: expires_at,\n expires_in: expires_in,\n purpose: purpose\n )\n end",
"def sign(data, key)\n hmac = OpenSSL::HMAC.new(key, OpenSSL::Digest::SHA256.new)\n hmac.update data\n hmac.digest\n end",
"def sign!\n @signed_date_time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n @signature = Cybersource::Security.generate_signature(signed_data)\n\n self\n end",
"def sign( key, data )\n blob = @buffers.writer\n blob.write_key key\n\n packet_data = @buffers.writer\n packet_data.write_string blob.to_s\n packet_data.write_string data.to_s\n packet_data.write_long 0\n\n type, reply = send_with_reply SSH2_AGENT_SIGN_REQUEST, packet_data\n if agent_failed( type )\n raise AgentError,\n \"agent could not sign data with requested identity\"\n elsif type != SSH2_AGENT_SIGN_RESPONSE\n raise AgentError, \"bad authentication response #{type}\"\n end\n\n return reply.read_string\n end",
"def sign(data, padding: nil, rng: Botan::RNG.new)\n sign = Botan::PK::Sign.new(key: self, padding: padding)\n sign << data\n sign.finish(rng)\n end",
"def sign(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to sign data with.\") unless key\n options = settings[:sign].merge(options)\n digest = OpenSSL::Digest.new(options[:algorithm])\n signature = OpenSSL::HMAC.digest(digest, key, data)\n encode(signature, options)\n end",
"def sign(data)\n key.dsa_sign_asn1(data)\n end",
"def encrypt_and_sign(value)\n Base64.urlsafe_encode64(@box.encrypt(::JSON.dump(value)))\n end",
"def sign( identity, data )\n info = find_identity( identity )\n\n if info[:key].nil? && info[:from] == :file\n begin\n info[:key] = @keys.load_private_key( info[:file] )\n rescue Exception => e \n raise UserKeyManagerError,\n \"the given identity is known, \" +\n \"but the private key could not be loaded \" +\n \"(#{e.message} [#{e.class}])\"\n end\n end\n\n if info[:key]\n sig_blob = @buffers.writer\n sig_blob.write_string identity.ssh_type\n sig_blob.write_string info[:key].ssh_do_sign( data.to_s )\n return sig_blob.to_s\n end\n\n if info[:from] == :agent\n raise UserKeyManagerError,\n \"the agent is no longer available\" unless @agent\n return @agent.sign( identity, data.to_s )\n end\n\n raise UserKeyManagerError,\n \"[BUG] can't determine identity origin (#{info.inspect})\"\n end",
"def sign()\n # TODO\n end",
"def signed_or_encrypted; end",
"def sign; adapter_class.new(self).sign; end",
"def aws_sign(key, data)\n OpenSSL::HMAC.digest(\"SHA256\", key, data)\n end",
"def encrypt(data)\n Digest::SHA1.hexdigest(data + @salt)\n end",
"def encrypt(data)\n self.class.encrypt(data + salt.to_s)\n end",
"def sign\n begin\n data64 = params[:data]\n data = Base64.decode64(data64)\n crypto = GPGME::Crypto.new(password: ENV[\"PASSPHRASE\"].to_s)\n signature = crypto.sign(data, signer: ENV[\"EMAIL\"].to_s, mode: GPGME::SIG_MODE_DETACH)\n render json: {\"email\": ENV[\"EMAIL\"].to_s,\n \"signature\": Base64.strict_encode64(signature.to_s)}, \n status: 200\n\n rescue => error\n render json: {\"error\": error.message},\n status: 500\n end\n end",
"def encrypt_and_sign(value, **options)\n create_message(value, **options)\n end",
"def sign_key; end",
"def encrypt(value)\n encryptor.encrypt_and_sign(value)\n end",
"def sign(string)\n @key.sign OpenSSL::Digest::SHA256.new, string\n end",
"def encrypt(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to encrypt data with.\") unless key\n options = settings[:crypt].merge(options)\n unless data.is_a?(String)\n data = JSON.generate(data)\n end\n encrypted_data = crypt(:encrypt, data, key, options)\n encode(encrypted_data, options)\n end",
"def sign!(key, sign_nonce = T.unsafe(nil)); end",
"def public_encrypt(data)\n Base64.encode64(@key.public_encrypt(data))\n end",
"def encrypt(data)\n crypto_key.encrypt64(data)\n end",
"def encrypt( data )\n rsa = OpenSSL::PKey::RSA.new( File.read( @public_pem ) )\n\n # encrypt with 256 bit AES with CBC\n aes = OpenSSL::Cipher::Cipher.new( 'aes-256-cbc' )\n aes.encrypt\n\n # use random key and IV\n aes.key = key = aes.random_key\n aes.iv = iv = aes.random_iv\n\n # this will hold all primitives and ciphertext\n primitives = {}\n\n primitives['ciphertext'] = aes.update( data )\n primitives['ciphertext'] << aes.final\n\n primitives['key'] = rsa.public_encrypt( key )\n primitives['iv'] = rsa.public_encrypt( iv )\n\n # serialize everything and base64 encode it\n Base64.encode64( primitives.to_yaml )\n end",
"def encrypt; end",
"def sign(data)\n if rsa?\n @priv.sign(OpenSSL::Digest::SHA1.new,data)\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @priv.sign(OpenSSL::Digest::DSS1.new,data)\n raise StandardError, 'DSA is not supported'\n end\n end",
"def encrypt data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final \n end",
"def to_encrypted_string\n self.class.send(:encryptor).encrypt_and_sign to_hash\n end",
"def sign(t_outputs)\n # binding.pry\n Base64.encode64(private_key.sign(OpenSSL::Digest::SHA256.new, t_outputs.to_json))\n end",
"def encrypt(data)\n return nil if !@key\n Base64::encode64(@key.private_encrypt(data)).delete(\"\\n\").strip\n end",
"def encrypt\n self\n end",
"def sign(secret_key_base, salt, data, options = {})\n encoded = encode(data, options)\n key = get_secret(secret_key_base, salt, options)\n MessageVerifier.sign(encoded, key)\n end",
"def sign()\n exp_payload = { :data => to_json, :exp => validto.to_s}\n JWT.encode exp_payload, secret, 'HS512'\n end",
"def encrypt(data, key=nil)\n Crypto.new(key.nil? ? config.key : key).encrypt(data)\n end",
"def sign(signed_data, algo: nil)\n algo ||= self.algo\n raise AlgorithmError unless algo == self.algo\n openssl_sig = openssl.sign(public_key.digest.new, signed_data)\n raw_sig = PublicKey::ECDSA.ssh_signature(openssl_sig)\n Encoding.encode_signature(algo, raw_sig)\n end",
"def encode h\n return h.init_data if h.vanila?\n str = h.to_json\n str = @cipher_key ? cipher(str) : encode64(str)\n digest = @dss.digest str\n return h.init_data if digest == h.init_digest\n\n sig = @dsa.syssign digest\n \"#{encode64 sig}/#{str}\"\n end",
"def computed_signed_info\n \n llave = CFDI::Key.new @key, @password\n\n return Base64::encode64(llave.sign(OpenSSL::Digest::SHA1.new, CGI::unescapeHTML(self.canonicalized_signed_info.gsub('<TEST/>','').gsub(/\\n/, ''))))\n \n end",
"def encrypt\n self\n end",
"def signature\n Base64.encode64(encryption_key.sign(OpenSSL::Digest::SHA256.new, id_string))\n end",
"def sign(message); end",
"def encrypt_data(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end",
"def encrypt(data)\n _encrypt(data, \"#{NOT_SEARCHABLE.chr}\\0#{@key_id.chr}\\0\")\n end",
"def signing_input; end",
"def signing_input; end",
"def encrypt(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end",
"def sign_request\n # By default OpenSSL generates an all-zero array for the encriptation vector\n # You can read it here: http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-i-iv-3D\n # If you want to declare it, you can take a look at the next couple of lines\n #bytes = Array.new(8,0)\n #iv = bytes.map(&:chr).join\n # We need to decode the secret key\n key = Base64.strict_decode64(credentials[:secret_key])\n # In thee cipher initialization we need to speficy the encryptation like method-length-mode (http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html#method-c-new).\n # Sermepa needs DES3 in CBC mode\n # The direct way the declare it's: des-ede3-cbc\n # You can also declare like 'des3' wich use CBC mode by default\n des3 = OpenSSL::Cipher::Cipher.new('des-ede3-cbc')\n # OpenSSL use by default PKCS padding. But Sermepa (mcrypt_encrypt PHP function) use zero padding.\n # OpenSSL do not allow zero padding. So we need to disable the default padding and make zero padding by hand\n # Padding in cryptography is to fill the data with especial characteres in order to use the data in blocks of N (https://en.wikipedia.org/wiki/Padding_(cryptography))\n # We need to use blocks of 8 bytes\n block_length = 8\n # We tell OpenSSL not to pad\n des3.padding = 0\n # We want to encrypt\n des3.encrypt\n # Key set\n des3.key = key\n #des3.iv = iv\n order_number = @fields[\"Ds_Merchant_Order\"]\n # Here is the 'magic'. Instead use the default OpenSSL padding (PKCS). We fill with \\0 till the data have\n # a multiple of the block size (8, 16, 24...)\n order_number += \"\\0\" until order_number.bytesize % block_length == 0\n # For example: the string \"123456789\" will be transform in \"123456789\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n # data must be in blocks of 8 or the update will break\n key_des3 = des3.update(order_number) + des3.final\n # The next step is to encrypt in SHA256 the resulting des3 key with the base64 json\n result = OpenSSL::HMAC.digest('sha256', key_des3, merchant_parameters_base64_json)\n # The last step is to encode the data in base64\n Base64.strict_encode64(result)\n end",
"def encrypt(data)\n pipe_to_stdin command('--encrypt'), data\n end",
"def encrypt(data)\n cipher = OpenSSL::Cipher.new(\"AES-256-CBC\")\n cipher.encrypt\n cipher.iv = @enc_iv\n cipher.key = @enc_key\n encrypted = cipher.update(data) + cipher.final\n enc = Base64.strict_encode64(encrypted)\nend",
"def encrypt(data)\n raise NoPublicKeyError, \"Public key file: #{@public_key_file}\" unless public?\n \n encrypted_data = public_rsa.public_encrypt(data)\n Base64.encode64(encrypted_data)\n end",
"def encrypt(data, password = nil)\n salt = random_bytes(@salt_len)\n iv = random_bytes(@salt_len)\n aes_key, mac_key = keys(salt, password)\n\n aes = cipher(aes_key, iv, true)\n ciphertext = aes.update(data) + aes.final\n mac = sign(iv + ciphertext, mac_key)\n\n encrypted = salt + iv + ciphertext + mac\n encrypted = Base64.strict_encode64(encrypted) if @base64\n encrypted\n rescue TypeError, ArgumentError => e\n error_handler e\n end",
"def encrypt(data)\n cipher = OpenSSL::Cipher.new 'AES-256-CBC'\n cipher.encrypt\n cipher.key, cipher.iv = @password, @iv\n data.nil? ? '' : (cipher.update(data) + cipher.final).unpack('H*')[0]\n end",
"def sign(wallet)\n tx = Arweave::Transaction.new(data: @commit.message.to_s)\n @commit.to_tags.each do |name, value|\n tx.add_tag(name: name, value: value)\n end\n tx.sign(wallet)\n end",
"def encrypt(data)\n\t\t# The limit of the encryption scheme is 235 bytes, so if the string is longer than that we need to limit it\n\t\tif data.length > 234\n\t\t\tdata = data[0..234] + \"\\n\"\n\t\tend\n\n\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/attacker.pub'\n\t\treturn key.public_key.public_encrypt(data)\n\tend",
"def encrypt(password, salt = self.generate_salt)\n serialize(hash(password, salt), salt)\n end",
"def encrypt_hash(hash)\n encryptor = ActiveSupport::MessageEncryptor.new($encryption_key)\n encryptor.encrypt_and_sign(hash.to_json)\nend",
"def sign!(ha)\n ha[:sig] = compute_checksum(ha)\n end",
"def write_encrypted(data)\n @writer.print(@encrypter.encrypt(data))\n end",
"def sign(key, string)\n SSL.new(nil, key).sign(string, true)\n end",
"def encode\n [@signature1].pack('L*') <<\n [@signature2].pack('L*') <<\n [@flags].pack('L*') <<\n [@version].pack('L*') <<\n @master_seed <<\n @encryption_iv <<\n [@groups_count].pack('L*') <<\n [@entries_count].pack('L*') <<\n @content_hash <<\n @master_seed2 <<\n [@rounds].pack('L*')\n end",
"def encode(data, passphrase)\n pack64(encrypt(data, passphrase))\n end",
"def pack(data)\n if @pubkey && [email protected]?\n block_size = @pubkey.n.num_bytes - 11\n\n edata = ''\n index = 0\n\n loop do\n break if index >= data.length\n\n edata << @pubkey.public_encrypt(data[index, block_size])\n\n index += block_size\n end\n\n data = edata\n end\n\n zdata = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION)\n Base64.strict_encode64(zdata)\n end",
"def encrypt_message plaintext\n key_pair.encrypt plaintext\n end",
"def sign(str)\n @signer.sign(str) unless str.nil? || str.empty?\n end",
"def sign_and_encode(text_to_sign, base64_encode=true)\n return nil if text_to_sign.nil? || text_to_sign.empty?\n sig = @key.sign(OpenSSL::Digest::SHA256.new, text_to_sign)\n base64_encode ? Base64UrlSafe.encode(sig) : sig\n end",
"def encrypt data, opts={}\r\n opts = opts.to_hwia :ttl, :password\r\n payload = { data:data }\r\n payload[:ttl] = Time.now.to_i + opts.ttl.to_i if opts.ttl\r\n\r\n JWT.encode payload, secret+opts.password.to_s, ALGORITHM\r\n end",
"def short_encrypt data, ttl=nil\r\n # expires in one day by deafult\r\n ttl ||= 1.day\r\n ttl = ttl.to_i + Time.now.to_i\r\n\r\n data = [data, ttl].to_json\r\n sha1(data)[0,8] + base64(data).sub(/=+$/, '')\r\n end",
"def encrypt_token *args\n raw = [\"Ra\", ThreeScale::SSO::VERSION, \"%10.5f\" % Time.now.utc, @expires_at, \"zZ\"]\n raw.insert 3, *args\n @me.encrypt_and_sign raw.join(ThreeScale::SSO::SEPARATOR)\n end",
"def signer\n end",
"def encrypt(*attributes) \n \tinclude ActiveCrypto::Encrypted\n \tbefore_save :encrypt_attributes\n \tafter_save :decrypt_attributes\n options=attributes.last.is_a?(Hash) ? attributes.pop : {}\n keyholder\n if options and options[:key]\n \t\t\t\tmodule_eval <<-\"end;\"\t\t\t\t \n \t\t\t\t\tdef session_key\n \t\t\t\t\t\t(send :#{options[:key]} ).send :session_key\n \t\t\t\t\tend\t \n \t\t\t\t\t@@external_key=true\n \t\t\t\tend;\n end\n\n base64_encode = (options and options[:base64])\n module_eval <<-\"end;\"\n def self.ezcrypto_base64?\n #{base64_encode.to_s}\n end\n end;\n \n self.encrypted_attributes=attributes\n end",
"def encript_ep \n\t\tsign_in_data = {\n\t\t\temail: email\n\t\t}\n\t\t\n\t sign_in_data.each do |key,attr_val|\n encrypted_data = AseEncriptDecriptJob::encryption(attr_val)\n self.send(\"#{key}=\",encrypted_data) \n\t end\n\tend",
"def save\n # get a new KEK\n kek = OpenSSL::Random.random_bytes(32)\n \n # set up a cipher to encrypt the keystore\n cipher = get_cipher\n cipher.encrypt(kek)\n iv = cipher.random_iv\n\n # dump the keystore and pad it with a random length\n ksdata = OpenSSL::Random.random_bytes(2)\n len = ksdata.unpack(\"n\").first\n ksdata << OpenSSL::Random.random_bytes(len)\n ksdata << Marshal.dump(@ks)\n\n # encrypt the keystore with its KEK\n ciphertext = cipher.update(ksdata)\n ciphertext << cipher.final\n\n # encrypt the KEK\n public_rsa = @config[:SSLPrivateKey].public_key\n encrypted_key = public_rsa.public_encrypt(kek)\n\n # write out the encrypted KEK, the IV and the ciphertext\n File.open(@config[:filename], \"w\") do |fp| \n fp << encrypted_key\n fp << iv\n fp << ciphertext\n end\n end",
"def encrypt()\n cipher_type = \"aes-128-ecb\"\n data = password;\n key = master_password;\n \n self.encrypted_password = aes_encrypt(data,key,nil,cipher_type).to_s\n end",
"def sign\n write_attr('mid', SecureRandom.uuid)\n write_attr('ts', Time.now.utc.to_i)\n canonical_msg = self.canonicalize\n\n #priv_key = OmfCommon::Key.instance.private_key\n #digest = OpenSSL::Digest::SHA512.new(canonical_msg)\n\n #signature = Base64.encode64(priv_key.sign(digest, canonical_msg)).encode('utf-8') if priv_key\n #write_attr('digest', digest)\n #write_attr('signature', signature) if signature\n\n if OmfCommon::Measure.enabled?\n MPMessage.inject(Time.now.to_f, operation.to_s, mid, cid, self.to_s.gsub(\"\\n\",''))\n @@mid_list << mid\n end\n self\n end",
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def sign(payload)\n payload = payload.merge({\n :client_id => @client_id,\n :client_secret => @client_secret,\n })\n\n scope = create_scope\n context = create_context(payload)\n s2s = create_string_to_sign(scope, context)\n signing_key = get_signing_salt\n OpenSSL::HMAC.hexdigest(@hash_algo, signing_key, s2s)\n end",
"def signed_data\n @signed_data ||= @signed_fields.index_with { |field| send(field) }\n end",
"def encrypt(data)\n\tarray = splitencrypt(data)\n\tencryptedBlock = ''\n\tfor i in 0...array.length\n\t encryptedBlock << @blowfish.encrypt_block(array[i])\n\tend\n\treturn encryptedBlock\n end",
"def presign_upload\n render plain: hmac_data, status: :ok\n end",
"def mark_signed!\n @signed = true\n end",
"def sign(params)\n string = params_to_string(params)\n\n case @sign_type\n when 'RSA'\n ::Alipay::Sign::RSA.sign(@app_private_key, string)\n when 'RSA2'\n ::Alipay::Sign::RSA2.sign(@app_private_key, string)\n else\n raise \"Unsupported sign_type: #{@sign_type}\"\n end\n end",
"def sign\n fail NotImplementedError\n end",
"def signature_for(data, secret)\n Base64.encode64(hmac_sha256(data, secret)).strip\n end",
"def _encrypt(data, prefix)\n padding = @padding\n random_data = SecureRandom.random_bytes(32)\n cipher = OpenSSL::Cipher.new(\"aes-256-gcm\")\n cipher.encrypt\n cipher.key = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, @key, random_data)\n cipher_iv = cipher.random_iv\n cipher.auth_data = @auth_data\n\n cipher_text = String.new\n data_size = data.bytesize\n\n padding_size = if padding\n (padding * rand(1)) + padding - (data.bytesize % padding)\n else\n 0\n end\n\n cipher_text << cipher.update(padding_size.chr)\n cipher_text << cipher.update(SecureRandom.random_bytes(padding_size)) if padding_size > 0\n cipher_text << cipher.update(data) if data_size > 0\n cipher_text << cipher.final\n\n Base64.urlsafe_encode64(\"#{prefix}#{random_data}#{cipher_iv}#{cipher.auth_tag}#{cipher_text}\")\n end",
"def sign!\n params = {\n :if_updated_at => @contract.content_updated_at\n }\n\n response = @client.put self.url, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } }\n\n if response.status != 201\n raise Inkdit::Error.new(response)\n end\n\n Inkdit::Signature.new(@client, response.parsed)\n end",
"def sign_and_encrypt_combined(message)\n source_part = body_to_part(message)\n restrict_encoding(source_part)\n signer = find_signer_for(message)\n recipients = find_recipients_for(message)\n encrypted =\n sign_and_encrypt_string(source_part.encoded, signer, recipients).to_s\n encrypted_part = build_encrypted_part(encrypted)\n control_part = build_encryption_control_part\n\n rewrite_body(\n message,\n content_type: multipart_encrypted_content_type,\n parts: [control_part, encrypted_part],\n )\n end",
"def encrypt(data)\n # Create a random 32 byte string to act as the initialization vector.\n iv = SecureRandom.random_bytes(32)\n # Pyro pads the data with zeros\n cipher = FirebugMcrypt.new(:rijndael_256, :cbc, @key, iv, :zeros)\n add_noise(iv + cipher.encrypt(data))\n end",
"def sign_compact(data, privkey)\n sig, rec = sign_ecdsa(data, privkey, nil)\n [ECDSA::Format::SignatureDerString.decode(sig), rec]\n end",
"def store_encryption_key_sha\n self.encryption_key_sha = ENCRYPTION_KEY_SHA\n end",
"def signed_data\n @signed_data = @signed_fields.index_with { |field| @fields[field] }\n end",
"def seal(plaintext, associated_data = [])\n raise TypeError, \"expected String, got #{plaintext.class}\" unless plaintext.is_a?(String)\n\n v = _s2v(associated_data, plaintext)\n ciphertext = @ctr.encrypt(_zero_iv_bits(v), plaintext)\n v + ciphertext\n end",
"def sign content\n Utils::BinUtil.to_hex(sign_to_bin(content))\n end",
"def encrypt(data, key = nil, iv = nil)\n key ||= @request[:secret]\n iv ||= @request[:iv]\n\n @cipher.encrypt\n @cipher.key = key\n @cipher.iv = iv\n\n @cipher.update(data)\n end",
"def sign secret, string_to_sign, digest_method = 'sha256'\n Base64.encode64(hmac(secret, string_to_sign, digest_method)).strip\n end",
"def sign!(cert)\n openssl_cert = cert.cert # because model -> OpenSSL object\n openssl_cert.serial = self.next_serial\n cert.serial = self.next_serial\n openssl_cert.issuer = ca_cert.subject\n openssl_cert.sign private_key, OpenSSL::Digest::SHA1.new\n self.next_serial = self.next_serial + 1\n self.save\n nil\n end"
] | [
"0.76435906",
"0.7394445",
"0.7299908",
"0.7150961",
"0.70019794",
"0.6999661",
"0.68502325",
"0.6750051",
"0.6711967",
"0.662519",
"0.65527093",
"0.6552388",
"0.6443249",
"0.6415161",
"0.6407446",
"0.63529307",
"0.6345217",
"0.63389593",
"0.63039935",
"0.6285561",
"0.6257333",
"0.6230039",
"0.620443",
"0.619853",
"0.617093",
"0.61671776",
"0.61276025",
"0.6123582",
"0.6119058",
"0.6111757",
"0.6077012",
"0.60568285",
"0.60560644",
"0.6046823",
"0.6040274",
"0.60401195",
"0.60327375",
"0.60167813",
"0.60165447",
"0.59955955",
"0.5995167",
"0.59683436",
"0.5941777",
"0.59393615",
"0.5935621",
"0.5928157",
"0.59268427",
"0.59265184",
"0.5916881",
"0.5916881",
"0.59167844",
"0.5915923",
"0.5908774",
"0.59008694",
"0.588449",
"0.58752745",
"0.58386874",
"0.5838526",
"0.5832",
"0.5810308",
"0.5806799",
"0.5790678",
"0.5756828",
"0.5751587",
"0.57260764",
"0.57122695",
"0.57008374",
"0.56947786",
"0.569114",
"0.5674784",
"0.56595093",
"0.56563026",
"0.56407017",
"0.56354237",
"0.561845",
"0.56142306",
"0.56136644",
"0.5598999",
"0.5585767",
"0.5584654",
"0.557499",
"0.55602694",
"0.55586207",
"0.55568206",
"0.555455",
"0.55536854",
"0.55522346",
"0.5544233",
"0.55413413",
"0.5536664",
"0.553156",
"0.55259144",
"0.5521538",
"0.5521138",
"0.55195963",
"0.5518145",
"0.55161875",
"0.5515092",
"0.5511117",
"0.5478352"
] | 0.64224654 | 13 |
Decrypts and verifies the data. | def decrypt_then_verify(bytes, private_key, *public_keys)
bytes = Validation.check_filled_array_argument!(bytes)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
cipher = Core::VirgilCipher.new
decrypted_bytes = cipher.decrypt_with_key(
bytes,
private_key.id,
private_key.raw_key
)
signature = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNATURE)
signer_public_key = public_keys.first
if public_keys.count > 1
signer_id = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNER_ID)
signer_public_key = public_keys.find {|public_key| public_key.id == signer_id}
end
is_valid = verify_signature(signature, decrypted_bytes, signer_public_key)
raise VirgilCryptoException, 'Signature is not valid' unless is_valid
wrap_bytes(decrypted_bytes)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(data)\n\t\tbegin\n\t\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/victim.pem'\n\t\t\treturn key.private_decrypt(data)\n\t\trescue\n\t\t\treturn false\n\t\tend\n\tend",
"def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end",
"def decrypt(data)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n cipher.key = @passphrase\n cipher.iv = @iv\n decrypted = cipher.update(data)\n decrypted << cipher.final\n json = JSON.parse(decrypted)\n self.identifier = json['identifier']\n @expiry = Time.parse(json['expiry'])\n rescue OpenSSL::Cipher::CipherError => e\n raise Kennedy::BadTicketException, \"Given data was not decryptable\"\n end",
"def decrypt(data)\n crypto_key.decrypt64(data)\n end",
"def decrypt(data)\n pipe_to_stdin command('--decrypt'), data\n end",
"def decrypt; end",
"def decrypt(value)\n encryptor.decrypt_and_verify(value)\n end",
"def decode(data)\n @encryptor.decrypt_and_verify(data)\n rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveSupport::MessageEncryptor::InvalidMessage\n 'Wrong password'\n end",
"def decrypt(data)\n @cert_chain[0].public_key.public_decrypt(Base64::decode64(data))\n end",
"def decrypt(data)\n data = remove_noise(data)\n # The first 32 bytes of the data is the original IV\n iv = data[0..31]\n cipher = FirebugMcrypt.new(:rijndael_256, :cbc, @key, iv, :zeros)\n cipher.decrypt(data[32..-1])\n end",
"def decrypt\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\t\t\r\n\t\t_rt = Encryptor.decrypt(Base64.decode64(@data))\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\t\r\n\t end",
"def decrypt(data, key=nil)\n Crypto.new(key.nil? ? config.key : key).decrypt(data)\n end",
"def decrypt_data(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.padding = 0\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decrypt(data, password = nil)\n data = Base64.strict_decode64(data) if @base64\n\n salt = data[0, @salt_len]\n iv = data[@salt_len, @iv_len]\n ciphertext = data[@salt_len + @iv_len..-@mac_len - 1]\n mac = data[data.length - @mac_len, @mac_len]\n\n aes_key, mac_key = keys(salt, password)\n verify(iv + ciphertext, mac, mac_key)\n\n aes = cipher(aes_key, iv, false)\n plaintext = aes.update(ciphertext) + aes.final\n plaintext\n rescue TypeError, ArgumentError, NoMethodError => e\n error_handler e\n rescue OpenSSL::OpenSSLError => e\n error_handler e\n end",
"def decrypt(data)\n\tarray = splitdencrypt(data)\n\tdecryptedBlock = ''\n\tfor i in 0...array.length\n\t val = array[i]\n\t decryptedBlock << @blowfish.decrypt_block([val].pack('H*'))\n\tend\n\treturn decryptedBlock\n end",
"def decrypt(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to decrypt data with.\") unless key\n options = settings[:crypt].merge(options)\n decoded_data = decode(data, options)\n decrypted_data = crypt(:decrypt, decoded_data, key, options)\n return data unless decrypted_data\n begin\n JSON.parse(decrypted_data)\n rescue JSON::ParserError\n decrypted_data\n end\n end",
"def decrypt(encrypted)\n return nil unless encrypted =~ /Validation: (.*?)\\n(.*)\\n\\*\\*\\*/m\n begin\n decipher = OpenSSL::Cipher.new(\"AES-128-CBC\")\n decipher.decrypt\n # puts \"**** $1=#{$1}, $2=#{$2}\"\n decipher.key = EMAIL_KEY\n decipher.iv = Base64.decode64($1)\n encrypted_data = Base64.decode64($2)\n # puts \"**** decipher.iv=#{Base64.encode64 iv}\"\n # puts \"**** encrypted=#{Base64.encode64 encrypted}\"\n return decipher.update(encrypted_data) + decipher.final \n rescue\n return nil\n end \n end",
"def decrypt encrypted_data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final \n end",
"def decrypt!(data, options = {})\n unless options.has_key?(:secret)\n options[:secret] = PreciousCargo::Secret.decrypt!(options)\n end\n\n PreciousCargo::Data.decrypt!(data, options)\n end",
"def decrypt(data)\n raise NoPrivateKeyError, \"Private key file: #{@private_key_file}\" unless private?\n \n decrypted_data = Base64.decode64(data)\n private_rsa.private_decrypt(decrypted_data)\n end",
"def decrypt_data(data, private_key, iv)\n aes = OpenSSL::Cipher::AES.new(256, :CBC)\n aes.decrypt\n aes.iv = iv\n aes.key = private_key\n aes.update(data) + aes.final\n end",
"def decrypt\n self\n end",
"def decrypt(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decrypt_and_verify(value)\n ::JSON.parse(\n @box.decrypt(\n Base64.urlsafe_decode64(value)),\n symbolize_names: true)\n rescue RbNaCl::CryptoError\n raise InvalidMessage\n end",
"def decrypt_data(encrypted, &decrypted)\n injected = @engine.inject encrypted\n\n unless injected\n exit -1\n end\n\n read_data = []\n\n begin\n while(read_chunk = @engine.read)\n read_data << read_chunk\n end\n rescue Exception => e\n unless @engine.state == 'SSLOK '\n raise e\n end\n end\n\n if block_given? then\n read_data.each do |data|\n decrypted.call data\n end\n else\n read_data.join\n end\n end",
"def decrypt\n self\n end",
"def decrypt(data, passphrase)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n\n cipher.key = Digest::SHA256.digest(passphrase)\n cipher.iv = obtain_iv(passphrase)\n\n decrypted = cipher.update(data)\n decrypted << cipher.final\n\n rsize = decrypted[0]\n return decrypted[rsize + 1..-1]\n rescue\n return nil\n end",
"def decrypt\n data = Tools.get_data4\n potential_payloads = []\n \n data.each do |encrypted|\n potential_payloads << xor_cypher(encrypted)\n end\n \n potential_payloads.flatten(1)\n .sort { |a,b| a[1] <=> b[1] }\n .last(5)\n end",
"def _decrypt_packet_internal(keys, data)\n # Don't decrypt if we don't have a key set\n if(!ready?(keys))\n @@window.puts(\"Not decrypting data (incoming data seemed to be cleartext): #{data.unpack(\"H*\")}\")\n return data\n end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Put together the data to sign\n signed_data = header + nonce + encrypted_body\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + signed_data)\n if(correct_signature[0,6] != signature)\n @@window.puts(\"Couldn't verify packet signature!\")\n raise(Encryptor::Error, \"Invalid signature!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n @@window.puts(\"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n raise(Encryptor::Error, \"Invalid nonce!\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n #@@window.puts(\"Decryption successful\")\n return header+body\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def decrypt!(encrypted_data, options = {})\n secret = options[:secret]\n cipher = Gibberish::AES.new(secret)\n cipher.decrypt(encrypted_data).strip\n end",
"def decrypt_message ciphertext\n key_pair.decrypt ciphertext\n end",
"def _decrypt_packet_internal(keys, data)\n @l.debug(\"Encryptor: Decrypting a #{data.length}-byte packet\")\n # Don't decrypt if we don't have a key set\n# if(@keys[:shared_secret].nil?)\n# return data\n# end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Check if it was truncated\n if(nonce.nil? || nonce.length < 2)\n raise(Error, \"Invalid encrypted packet!\")\n end\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + header + nonce + encrypted_body)\n if(correct_signature[0,6] != signature)\n raise(Error, \"Invalid signature on incoming packet!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n raise(Error, \"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n return header + body\n end",
"def decrypt(salt, iterations, key, iv, tag, data, debug_text=nil)\n\n # Initialize plaintext variable to be false so we can check if we don't succeed\n decrypt_result = false\n\n # Warn the user if we come across something encrypted and they haven't provided a password list\n if @passwords.length == 0 and !@warned_about_empty_password_list\n puts \"Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success\"\n @logger.error(\"Apple Decrypter: Attempting to decrypt objects without a password list set, check the -w option for more success\")\n @warned_about_empty_password_list = true\n end\n\n # Start with the known good passwords\n @successful_passwords.each do |password|\n decrypt_result = decrypt_with_password(password, salt, iterations, key, iv, tag, data, debug_text)\n if decrypt_result\n break\n end\n end\n\n # Only try the full list if we haven't already found the password\n if !decrypt_result\n @passwords.each do |password|\n decrypt_result = decrypt_with_password(password, salt, iterations, key, iv, tag, data, debug_text)\n if decrypt_result\n @successful_passwords.push(password)\n break\n end\n end\n end\n\n return decrypt_result\n end",
"def decrypt data, key, salt, iter, iv, key_length = 32\n decipher = OpenSSL::Cipher.new \"AES-256-CBC\"\n decipher.decrypt\n decipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, iter, key_length)\n decipher.iv = iv\n decipher.update(data) + decipher.final\n end",
"def decode(data, passphrase)\n decrypt(unpack64(data), passphrase)\n rescue\n return nil\n end",
"def decrypt(data, padding: nil)\n dec = Botan::PK::Decrypt.new(key: self, padding: padding)\n dec.decrypt(data)\n end",
"def decrypt(data)\n return nil if data.to_s.empty?\n\n password =\n if /^(1\\.[0-9.]+|2\\.0)(\\.[0-9]+)?/ =~ GPGME::Engine.info.first.version || @pinmode\n { password: @gpg_pass }\n else\n { password: @gpg_pass,\n pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK }\n end\n\n crypto = GPGME::Crypto.new(armor: true)\n crypto\n .decrypt(data, password)\n .read.force_encoding('utf-8')\n rescue => e\n raise \"#{I18n.t('error.gpg_file.decrypt')}\\n#{e}\"\n end",
"def decrypt()\n \t@private_key = AES.decrypt(self.encrypted_private_key, ENV[\"DECRYPTION_KEY\"])\n end",
"def decrypt_and_verify(message, **options)\n catch_and_raise :invalid_message_format, as: InvalidMessage do\n catch_and_raise :invalid_message_serialization, as: InvalidMessage do\n catch_and_ignore :invalid_message_content do\n read_message(message, **options)\n end\n end\n end\n end",
"def decrypt(txt)\n x = -1\n return txt.unpack('U*').pack('S*').unpack(\"U*\").collect do |i| \n x += 1\n x %= CRYPT.size\n i - CRYPT[x].unpack('U').first > 0 ? i - CRYPT[x].unpack('U').first : i\n end.pack('U*')\n end",
"def maybe_decrypt(context)\n # TODO determine if we should be decrypting data coming from pre-4.2\n # servers, potentially using legacy wire protocols. If so we need\n # to implement decryption for those wire protocols as our current\n # encryption/decryption code is OP_MSG-specific.\n self\n end",
"def decrypt(data, key = nil, iv = nil)\n key ||= @request[:secret]\n iv ||= @request[:iv]\n\n @cipher.decrypt\n @cipher.key = key\n @cipher.iv = iv\n\n @cipher.update(data)\n end",
"def decrypt(data)\n begin\n data = Base64.urlsafe_decode64(data)\n rescue ArgumentError\n raise Error, \"Unable to decode encrypted column: invalid base64\"\n end\n\n unless data.getbyte(1) == 0 && data.getbyte(3) == 0\n raise Error, \"Unable to decode encrypted column: invalid format\"\n end\n\n flags = data.getbyte(0)\n\n key, auth_data = @key_map[data.getbyte(2)]\n unless key\n raise Error, \"Unable to decode encrypted column: invalid key id\"\n end\n\n case flags\n when NOT_SEARCHABLE\n if data.bytesize < 65\n raise Error, \"Decoded encrypted column smaller than minimum size\"\n end\n\n data.slice!(0, 4)\n when SEARCHABLE, LOWERCASE_SEARCHABLE\n if data.bytesize < 97\n raise Error, \"Decoded encrypted column smaller than minimum size\"\n end\n\n data.slice!(0, 36)\n else\n raise Error, \"Unable to decode encrypted column: invalid flags\"\n end\n\n key_part = data.slice!(0, 32)\n cipher_iv = data.slice!(0, 12)\n auth_tag = data.slice!(0, 16)\n\n cipher = OpenSSL::Cipher.new(\"aes-256-gcm\")\n cipher.decrypt\n cipher.iv = cipher_iv\n cipher.key = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, key, key_part)\n cipher.auth_data = auth_data\n cipher.auth_tag = auth_tag\n begin\n decrypted_data = cipher.update(data) << cipher.final\n rescue OpenSSL::Cipher::CipherError => e\n raise Error, \"Unable to decrypt encrypted column: #{e.class} (probably due to encryption key or auth data mismatch or corrupt data)\"\n end\n\n # Remove padding\n decrypted_data.slice!(0, decrypted_data.getbyte(0) + 1)\n\n decrypted_data\n end",
"def decode_aes256 data\n length = data.length\n length16 = length % 16\n length64 = length % 64\n\n if length == 0\n ''\n elsif length16 == 0\n decode_aes256_ecb_plain data\n elsif length64 == 0 || length64 == 24 || length64 == 44\n decode_aes256_ecb_base64 data\n elsif length16 == 1\n decode_aes256_cbc_plain data\n elsif length64 == 6 || length64 == 26 || length64 == 50\n decode_aes256_cbc_base64 data\n else\n raise RuntimeError, \"'#{data.inspect}' doesn't seem to be AES-256 encrypted\"\n end\n end",
"def decrypt(ciphertext_blob)\n begin\n plaintext = client.decrypt_and_verify(ciphertext_blob)\n\n success_with_data(\n plaintext: plaintext\n )\n rescue Exception => e\n error_with_data('lc_2',\n \"LocalCipher could not decrypt cipher with message => #{e.message}\",\n 'Something Went Wrong.',\n GlobalConstant::ErrorAction.default,\n {})\n end\n end",
"def decrypt\n self.class.decrypt(@encrypted_name, @id)\n end",
"def decrypt(ciphertext, passwd, options = {})\n iv_and_ciphertext = Base64.decode64(ciphertext)\n cipher = new_cipher(:decrypt, passwd, options)\n cipher.iv, ciphertext = iv_and_ciphertext(cipher, iv_and_ciphertext)\n plaintext = cipher.update(ciphertext)\n plaintext << cipher.final\n plaintext\n end",
"def decrypt(encrypted_data_hex, key_hex, iv_hex)\n encrypted_data_bytes = hex_to_bytes(encrypted_data_hex)\n key = hex_to_bytes(key_hex)\n iv = hex_to_bytes(iv_hex)\n decrypt_bytes(encrypted_data_bytes, key, iv)\n end",
"def decrypt(value)\n result = Crypt::ExplicitDecryptionContext.new(\n @crypt_handle,\n @encryption_io,\n { 'v': value },\n ).run_state_machine['v']\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt(*args, &block)\n crypt :decrypt, *args, &block\n end",
"def decypt_and_verify(passphrase)\n decrypted_message = decrypt(passphrase)\n\n expected = Digest::SHA256.digest(decrypted_message)\n raise SlyErrors::StateError, \"Failed SHA-256 checksum\" unless expected == Base64.decode64(message_hash)\n\n decrypted_message\n end",
"def data\n return {} unless File.exist?(vault_path)\n\n encrypted_file_content = File.open(vault_path, 'rb') { |f| f.read }\n cipher = new_decryption_cipher\n decrypted_file_content = cipher.update(encrypted_file_content) + cipher.final\n\n password_data = YAML.load(decrypted_file_content)\n end",
"def decrypt(value)\n Crypt::ExplicitDecryptionContext.new(\n @crypt_handle,\n @encryption_io,\n { v: value }\n ).run_state_machine['v']\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def decrypt_from_file(secure)\n secure.open('rb') { |s| basic_decrypt(StringIO.new, s).string }\n end",
"def decrypt(value,key,context)\n plaintext = @vault.logical.write(\"transit/decrypt/#{key}\", ciphertext: value, context: Base64.encode64(context).gsub('\\n',''))\n return Base64.decode64(plaintext.data[:plaintext]).gsub('\\n','')\n end",
"def decrypt(keys, cypher)\n keys.each do |key|\n verifier = ::Fernet.verifier(key, cypher, enforce_ttl: false)\n next unless verifier.valid?\n return verifier.message\n end\n cypher # Return cypher has it's probably just plain text\n end",
"def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n decrypted_data = cipher.update(crypt_string) + cipher.final\n end",
"def decrypt(ciphertext, options = {})\n # TODO\n end",
"def decrypt(x)\n @aes_key.decrypt(x)\n end",
"def decrypt(value)\n return unless value\n fail ArgumentError, 'Value is not encrypted' unless value.match(REGEXP)\n @key.private_decrypt(Base64.strict_decode64(Regexp.last_match(:value)))\n end",
"def decrypt_text(checksum)\n key = key_from_checksum(checksum, decode_bytes(pbkdf2_salt))\n decrypt_string decode_bytes(crypted_text), decode_bytes(auth_tag), key, decode_bytes(iv), label\n end",
"def decrypt(encrypted_text)\n len = encrypted_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(encrypted_text.length == 0) || (encrypted_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = encrypted_text.scan(/.{8}/m)\n decrypted_blocks = []\n blocks.each do |block|\n decryptedBlock = self.class.decryptBlock(block, @keys)\n decrypted_blocks << decryptedBlock\n end\n output = decrypted_blocks.join\n return output\n end",
"def decrypt_with_password(password, salt, iterations, key, iv, tag, data, debug_text=nil)\n\n\n # Create the key with our password\n @logger.debug(\"Apple Decrypter: #{debug_text} Attempting decryption with password #{password}\")\n\n # Create variables to track our generated and unwrapped keys between blocks\n decrypt_result = false\n plainext = false\n\n # Generate the key-encrypting key from the user's password\n generated_key = generate_key_encrypting_key(password, salt, iterations)\n\n # Unwrap the key\n unwrapped_key = aes_key_unwrap(key, generated_key) if generated_key\n\n # Decrypt the content only if we have a key\n plaintext = aes_gcm_decrypt(unwrapped_key, iv, tag, data, debug_text) if unwrapped_key\n\n if plaintext\n decrypt_result = { plaintext: plaintext, password: password }\n @logger.debug(\"Apple Decrypter: #{debug_text} generated a decrypt using password #{password}\")\n end\n\n return decrypt_result\n end",
"def decrypt(ciphertext)\n @cipher.decrypt(@secret_key, ciphertext)\n end",
"def decode_aes256_cbc_plain data\n if data.empty?\n ''\n else\n # TODO: Check for input validity!\n _decode_aes256 :cbc, data[1, 16], data[17..-1]\n end\n end",
"def decrypt(encrypted_string)\n CRYPTO.decrypt_string(encrypted_string.decode64)\nend",
"def decrypt(msg)\n msg_buf = FFI::MemoryPointer.from_data(msg)\n Botan.call_ffi_with_buffer(lambda { |b, bl|\n LibBotan.botan_pk_op_decrypt(@ptr, b, bl, msg_buf, msg_buf.size)\n })\n end",
"def decrypt(ciphertext_blob)\n begin\n\n d_resp = client.decrypt({\n ciphertext_blob: ciphertext_blob\n }).to_h\n\n plaintext = d_resp[:plaintext]\n\n return success_with_data(\n plaintext: plaintext\n )\n\n rescue => e\n return exception_with_data(\n e,\n 'a_k_1',\n GlobalConstant::ErrorAction.default,\n {\n purpose: @purpose,\n role: @role,\n ciphertext_blob: ciphertext_blob\n }\n )\n end\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def decryptHex\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\r\n\t\t_ret = \"\"\r\n\t\t([email protected]()/2).each{|index| _ret += [@data[index*2, 2]].pack(\"H2\")}\t\t\r\n\t\t_rt = Encryptor.decrypt(_ret)\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\r\n\t end",
"def decipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.decrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end",
"def decrypt(encrypted_text, password = nil, salt = nil)\n password = password.nil? ? Hoodie.crypto.password : password\n salt = salt.nil? ? Hoodie.crypto.salt : salt\n\n iv_ciphertext = Base64.decode64(encrypted_text)\n cipher = new_cipher(:decrypt, password, salt)\n cipher.iv, ciphertext = separate_iv_ciphertext(cipher, iv_ciphertext)\n plain_text = cipher.update(ciphertext)\n plain_text << cipher.final\n plain_text\n end",
"def decrypt(string)\n require_key\n\n @private_key.private_decrypt(Base64.decode64(string))\n end",
"def decipher(key, user_iv, text)\n ssl_decipher = OpenSSL::Cipher.new('AES-256-CBC')\n ssl_decipher.decrypt\n ssl_decipher.key = key\n ssl_decipher.iv = user_iv\n ssl_decipher.update(text) + ssl_decipher.final\n end",
"def _decode_aes256 cipher, iv, data\n aes = OpenSSL::Cipher::Cipher.new \"aes-256-#{cipher}\"\n aes.decrypt\n aes.key = @encryption_key\n aes.iv = iv\n aes.update(data) + aes.final\n end",
"def decrypt(message)\n xcrypt(:decrypt, message)\n rescue OpenSSL::Cipher::CipherError\n raise CipherError, 'invalid password'\n end",
"def decrypt!(settings)\n if settings.encryption_configured?\n xpath(\"//xenc:EncryptedData\", Onelogin::NAMESPACES).each do |node|\n decrypted_xml = decrypt_node(settings, node.to_s)\n if decrypted_xml\n decrypted_doc = Nokogiri::XML(decrypted_xml)\n decrypted_node = decrypted_doc.root\n node.parent.next = decrypted_node\n node.parent.unlink\n end\n end\n end\n true\n end",
"def decrypt(text64, iv)\n if @cipher\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-#{@cipher}-cbc\")\n cipher.decrypt\n cipher.key = @secret[0..cipher_block_size]\n if iv != \"\"\n cipher.iv = Base64.decode64(iv)\n end\n decrypted_text = cipher.update(Base64.decode64(text64))\n decrypted_text << cipher.final\n return decrypted_text\n else\n return text64\n end\n end",
"def decrypt_files\n not_implemented(__method__)\n end",
"def private_decrypt(ciphertext)\n @private_key.private_decrypt(ciphertext)\n end",
"def can_decrypt?\n false\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, &b)\n end",
"def decrypt_string(ciphertext, auth_tag, key, iv, auth_data = '')\n cipher = OpenSSL::Cipher.new(CIPHER_TYPE)\n cipher.decrypt\n cipher.key = key\n cipher.iv = iv[0, IV_LENGTH]\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = auth_data\n\n cipher.update(ciphertext) + cipher.final\n end",
"def decrypt(base64_encrypted_data,key,base64_init_vector,ciper='aes-128-cbc')\n SymmetricEncryption.cipher = SymmetricEncryption::Cipher.new(:key => key,:iv => Base64.urlsafe_decode64(base64_init_vector), :cipher => ciper )\n SymmetricEncryption.decrypt(Base64.urlsafe_decode64(base64_encrypted_data))\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, password, mtime, &b)\n end",
"def decrypt_token(data)\n cipher = OpenSSL::Cipher::AES.new(128, :CBC)\n cipher.decrypt\n cipher.key = @client_secret.byteslice(0..15)\n cipher.iv = @client_id.byteslice(0..15)\n json = cipher.update(data) + cipher.final\n JSON.parse(json)\n end",
"def decrypt(cipher_bytes, private_key)\n cipher_bytes = Validation.check_filled_array_argument!(cipher_bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n decrypted_bytes = cipher.decrypt_with_key(\n cipher_bytes,\n private_key.id,\n private_key.raw_key\n )\n wrap_bytes(decrypted_bytes)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def decrypt(bin64, iv64)\n aes = OpenSSL::Cipher::Cipher.new($alg)\n aes.decrypt\n aes.key = $key\n aes.iv = Base64.urlsafe_decode64(iv64)\n aes.update(Base64.urlsafe_decode64(bin64)) + aes.final\nend",
"def decrypt_and_encrypt(data)\n ## ** Decrypt\n keys = @keys\n begin\n #@@window.puts(\"Attempting to decrypt with primary key\")\n data = _decrypt_packet_internal(keys, data)\n #@@window.puts(\"Successfully decrypted with primary key\")\n\n # If it was successfully decrypted, make sure the @old_keys will no longer work\n @old_keys = nil\n rescue Encryptor::Error => e\n # Attempt to fall back to old keys\n if(@old_keys.nil?)\n @@window.puts(\"No secondary key to fallback to\")\n raise(e)\n end\n\n @@window.puts(\"Attempting to decrypt with secondary key\")\n keys = @old_keys\n data = _decrypt_packet_internal(@old_keys, data)\n @@window.puts(\"Successfully decrypted with secondary key\")\n end\n\n # Send the decrypted data up and get the encrypted data back\n data = yield(data, ready?(keys))\n\n # If there was an error of some sort, return nothing\n if(data.nil? || data == '')\n return ''\n end\n\n # If encryption is turned off, return unencrypted data\n if(!ready?(keys))\n @@window.puts(\"Returning an unencrypted response\")\n return data\n end\n\n ## ** Encrypt\n #@@window.puts(\"Encrypting the response\")\n\n # Split the packet into a header and a body\n header, body = data.unpack(\"a5a*\")\n\n # Encode the nonce properly\n nonce = [keys[:my_nonce]].pack(\"n\")\n\n # Encrypt the body\n encrypted_body = Salsa20.new(keys[:my_write_key], nonce.rjust(8, \"\\0\")).encrypt(body)\n\n # Sign it\n signature = SHA3::Digest::SHA256.digest(keys[:my_mac_key] + header + nonce + encrypted_body)\n\n # Arrange things appropriately\n return [header, signature[0,6], nonce, encrypted_body].pack(\"a5a6a2a*\")\n end",
"def decrypt(alg, password, cipher)\n \n begin\n case alg\n when \"3DES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'des3')\n when \"AES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256')\n when \"Blowfish\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'blowfish')\n when \"Plaintext\" then return cipher\n else key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256')\n end\n decrypted_text = key.decrypt64(cipher)\n rescue => e\n p e.message\n end\n return decrypted_text\n \n end",
"def perform_decryption(\n encryption_data,\n password,\n content_entry,\n roo_content_xml_path\n )\n # Extract various expected attributes from the manifest that\n # describe the encryption\n\n algorithm_node = encryption_data.xpath('manifest:algorithm').first\n key_derivation_node =\n encryption_data.xpath('manifest:key-derivation').first\n start_key_generation_node =\n encryption_data.xpath('manifest:start-key-generation').first\n\n # If we have all the expected elements, then we can perform\n # the decryption.\n\n if !algorithm_node.nil? && !key_derivation_node.nil? &&\n !start_key_generation_node.nil?\n\n # The algorithm is a URI describing the algorithm used\n algorithm = algorithm_node['manifest:algorithm-name']\n\n # The initialization vector is base-64 encoded\n iv = Base64.decode64(\n algorithm_node['manifest:initialisation-vector']\n )\n key_derivation_name = key_derivation_node['manifest:key-derivation-name']\n iteration_count = key_derivation_node['manifest:iteration-count'].to_i\n salt = Base64.decode64(key_derivation_node['manifest:salt'])\n\n # The key is hashed with an algorithm represented by this URI\n key_generation_name =\n start_key_generation_node[\n 'manifest:start-key-generation-name'\n ]\n\n hashed_password = password\n\n if key_generation_name == 'http://www.w3.org/2000/09/xmldsig#sha256'\n\n hashed_password = Digest::SHA256.digest(password)\n else\n fail ArgumentError, \"Unknown key generation algorithm #{key_generation_name}\"\n end\n\n cipher = find_cipher(\n algorithm,\n key_derivation_name,\n hashed_password,\n salt,\n iteration_count,\n iv\n )\n\n begin\n decrypted = decrypt(content_entry, cipher)\n\n # Finally, inflate the decrypted stream and overwrite\n # content.xml\n IO.binwrite(\n roo_content_xml_path,\n Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(decrypted)\n )\n rescue StandardError => error\n raise ArgumentError, \"Invalid password or other data error: #{error}\"\n end\n else\n fail ArgumentError, 'manifest.xml missing encryption-data elements'\n end\n end",
"def decrypt(ciphertext)\n ciphertext = ciphertext.unpack('m').first\n tag = ciphertext[0, hmac_length]\n ciphertext = ciphertext[hmac_length..-1]\n\n # make sure we actually had enough data for the tag too.\n if tag && ciphertext && verify_message(tag, ciphertext)\n decrypt_ciphertext(ciphertext)\n else\n nil\n end\n end",
"def read_safe\n pwdata_enc_base64 = File.read(@pwfile)\n pwdata_encrypted = pwdata_enc_base64.unpack('m')[0] # fix for Ruby 1.9 also works with 1.8\n # was: unpack('m*').to_s\n # the cryptographic initialization vector is the first 32 chars of the unpacked string\n Encryptor.iv = pwdata_encrypted[0...32]\n pwdata_encrypted = pwdata_encrypted[32..-1]\n @pwdata = Encryptor.decrypt(pwdata_encrypted, @pwhash)\n end",
"def aes_decrypt(key, crypt_string)\n cipher = OpenSSL::Cipher.new(ssl_cipher)\n\n cipher.decrypt\n cipher.key = key\n cipher.pkcs5_keyivgen(key)\n cipher.update(crypt_string) + cipher.final\n end"
] | [
"0.77103",
"0.7624082",
"0.74206156",
"0.71239746",
"0.71051866",
"0.70907927",
"0.70387435",
"0.70204955",
"0.7012142",
"0.6976619",
"0.69380146",
"0.6928157",
"0.68955165",
"0.6889988",
"0.6867216",
"0.6863906",
"0.68593055",
"0.6845139",
"0.6824685",
"0.6809739",
"0.6800857",
"0.6774006",
"0.6759371",
"0.67129815",
"0.66983503",
"0.66956073",
"0.6662103",
"0.6609384",
"0.6576029",
"0.6548899",
"0.6548899",
"0.65357924",
"0.65134275",
"0.6440892",
"0.64369595",
"0.64341456",
"0.64312536",
"0.64184636",
"0.64129806",
"0.6407236",
"0.6405091",
"0.63610077",
"0.6350552",
"0.6327851",
"0.6326459",
"0.6319697",
"0.63016844",
"0.6259791",
"0.6227757",
"0.62251306",
"0.6208301",
"0.62077624",
"0.62077624",
"0.6207404",
"0.6201866",
"0.6196505",
"0.61859906",
"0.61822003",
"0.61817414",
"0.61633533",
"0.6148813",
"0.6144012",
"0.61388135",
"0.61218834",
"0.61196566",
"0.6114046",
"0.6112622",
"0.6099683",
"0.609277",
"0.60871124",
"0.60867536",
"0.6066605",
"0.605717",
"0.6052497",
"0.6052497",
"0.60444874",
"0.6030294",
"0.6028425",
"0.6012885",
"0.601032",
"0.59968877",
"0.5994794",
"0.59791255",
"0.59727573",
"0.59720385",
"0.5968299",
"0.5967452",
"0.59647924",
"0.59539276",
"0.59476155",
"0.59431607",
"0.59400094",
"0.59373856",
"0.5928595",
"0.5920739",
"0.59201264",
"0.59127283",
"0.59126765",
"0.59037083",
"0.5873835"
] | 0.6274647 | 47 |
Signs the specified data using Private key. | def generate_signature(bytes, private_key)
bytes = Validation.check_filled_array_argument!(bytes)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)
signer = Core::VirgilSigner.new(native_algorithm)
wrap_bytes(signer.sign(bytes, private_key.raw_key))
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(data)\n @key.sign(@algo.new, data)\n end",
"def sign data\n return unless @key\n\n @key.sign @digest_algorithm.new, data\n end",
"def sign(data)\n if rsa?\n @priv.sign(OpenSSL::Digest::SHA1.new,data)\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @priv.sign(OpenSSL::Digest::DSS1.new,data)\n raise StandardError, 'DSA is not supported'\n end\n end",
"def sign( identity, data )\n info = find_identity( identity )\n\n if info[:key].nil? && info[:from] == :file\n begin\n info[:key] = @keys.load_private_key( info[:file] )\n rescue Exception => e \n raise UserKeyManagerError,\n \"the given identity is known, \" +\n \"but the private key could not be loaded \" +\n \"(#{e.message} [#{e.class}])\"\n end\n end\n\n if info[:key]\n sig_blob = @buffers.writer\n sig_blob.write_string identity.ssh_type\n sig_blob.write_string info[:key].ssh_do_sign( data.to_s )\n return sig_blob.to_s\n end\n\n if info[:from] == :agent\n raise UserKeyManagerError,\n \"the agent is no longer available\" unless @agent\n return @agent.sign( identity, data.to_s )\n end\n\n raise UserKeyManagerError,\n \"[BUG] can't determine identity origin (#{info.inspect})\"\n end",
"def sign(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to sign data with.\") unless key\n options = settings[:sign].merge(options)\n digest = OpenSSL::Digest.new(options[:algorithm])\n signature = OpenSSL::HMAC.digest(digest, key, data)\n encode(signature, options)\n end",
"def sign(data, padding: nil, rng: Botan::RNG.new)\n sign = Botan::PK::Sign.new(key: self, padding: padding)\n sign << data\n sign.finish(rng)\n end",
"def sign(data, key)\n hmac = OpenSSL::HMAC.new(key, OpenSSL::Digest::SHA256.new)\n hmac.update data\n hmac.digest\n end",
"def sign(data)\n key.dsa_sign_asn1(data)\n end",
"def sign( key, data )\n blob = @buffers.writer\n blob.write_key key\n\n packet_data = @buffers.writer\n packet_data.write_string blob.to_s\n packet_data.write_string data.to_s\n packet_data.write_long 0\n\n type, reply = send_with_reply SSH2_AGENT_SIGN_REQUEST, packet_data\n if agent_failed( type )\n raise AgentError,\n \"agent could not sign data with requested identity\"\n elsif type != SSH2_AGENT_SIGN_RESPONSE\n raise AgentError, \"bad authentication response #{type}\"\n end\n\n return reply.read_string\n end",
"def sign_compact(data, privkey)\n sig, rec = sign_ecdsa(data, privkey, nil)\n [ECDSA::Format::SignatureDerString.decode(sig), rec]\n end",
"def aws_sign(key, data)\n OpenSSL::HMAC.digest(\"SHA256\", key, data)\n end",
"def sign\n validate!\n\n @voter.update(\n data: @data,\n signature: @signature,\n signed_vote_at: Time.now\n )\n\n signer = @signer.new(@admin_key)\n signer.sign(@data.to_i)\n end",
"def sign(message, private_key)\n msg_point = BLS.norm_p2h(message)\n msg_point * BLS.normalize_priv_key(private_key)\n end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def sign(params)\n string = params_to_string(params)\n\n case @sign_type\n when 'RSA'\n ::Alipay::Sign::RSA.sign(@app_private_key, string)\n when 'RSA2'\n ::Alipay::Sign::RSA2.sign(@app_private_key, string)\n else\n raise \"Unsupported sign_type: #{@sign_type}\"\n end\n end",
"def sign(secret_key_base, salt, data, options = {})\n encoded = encode(data, options)\n key = get_secret(secret_key_base, salt, options)\n MessageVerifier.sign(encoded, key)\n end",
"def sign(private_key)\n # Our multiline hash for authorization will be encoded in multiple header\n # lines - X-Ops-Authorization-1, ... (starts at 1, not 0!)\n header_hash = {\n \"X-Ops-Sign\" => SIGNING_DESCRIPTION,\n \"X-Ops-Userid\" => user_id,\n \"X-Ops-Timestamp\" => canonical_time,\n \"X-Ops-Content-Hash\" => hashed_body,\n }\n\n string_to_sign = canonicalize_request\n signature = Base64.encode64(private_key.private_encrypt(string_to_sign)).chomp\n signature_lines = signature.split(/\\n/)\n signature_lines.each_index do |idx|\n key = \"X-Ops-Authorization-#{idx + 1}\"\n header_hash[key] = signature_lines[idx]\n end\n \n Mixlib::Authentication::Log.debug \"String to sign: '#{string_to_sign}'\\nHeader hash: #{header_hash.inspect}\"\n \n header_hash\n end",
"def sign(signed_data, algo: nil)\n algo ||= self.algo\n raise AlgorithmError unless algo == self.algo\n openssl_sig = openssl.sign(public_key.digest.new, signed_data)\n raw_sig = PublicKey::ECDSA.ssh_signature(openssl_sig)\n Encoding.encode_signature(algo, raw_sig)\n end",
"def sign(message, privkey)\n group = ECDSA::Group::Secp256k1\n digest = Digest::SHA256.digest(message)\n signature = nil\n while signature.nil?\n temp_key = 1 + SecureRandom.random_number(group.order - 1)\n signature = ECDSA.sign(group, privkey.to_i(16), digest, temp_key)\n return ECDSA::Format::SignatureDerString.encode(signature).unpack(\"H*\").first\n end\n end",
"def sign(t_outputs)\n # binding.pry\n Base64.encode64(private_key.sign(OpenSSL::Digest::SHA256.new, t_outputs.to_json))\n end",
"def sign!\n @signed_date_time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n @signature = Cybersource::Security.generate_signature(signed_data)\n\n self\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def signstuff(revision, data, pkeypath)\n pkey = OpenSSL::PKey::EC.new File.read pkeypath\n\n revm = revision.match(/([0-9]+)-.+/)\n oldrev = revm[1]\n newrev = oldrev.to_i + 1\n\n signature = Base64.encode64(pkey.dsa_sign_asn1(newrev.to_s+data))\nend",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def sign_then_encrypt(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n custom_bytes = cipher.custom_params\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNATURE,\n generate_signature(bytes, private_key)\n )\n\n public_key = extract_public_key(private_key)\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNER_ID,\n wrap_bytes(public_key.id)\n )\n encrypt_for_recipients(bytes, cipher, public_keys)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def sign\n begin\n data64 = params[:data]\n data = Base64.decode64(data64)\n crypto = GPGME::Crypto.new(password: ENV[\"PASSPHRASE\"].to_s)\n signature = crypto.sign(data, signer: ENV[\"EMAIL\"].to_s, mode: GPGME::SIG_MODE_DETACH)\n render json: {\"email\": ENV[\"EMAIL\"].to_s,\n \"signature\": Base64.strict_encode64(signature.to_s)}, \n status: 200\n\n rescue => error\n render json: {\"error\": error.message},\n status: 500\n end\n end",
"def sign(string)\n @key.sign OpenSSL::Digest::SHA256.new, string\n end",
"def sign!(options = {})\n binary_security_token_node if options[:security_token]\n x509_data_node if options[:issuer_serial]\n\n if options[:inclusive_namespaces]\n c14n_method_node = signed_info_node.at_xpath('ds:CanonicalizationMethod', ds: 'http://www.w3.org/2000/09/xmldsig#')\n inclusive_namespaces_node = Nokogiri::XML::Node.new('ec:InclusiveNamespaces', document)\n inclusive_namespaces_node.add_namespace_definition('ec', c14n_method_node['Algorithm'])\n inclusive_namespaces_node['PrefixList'] = options[:inclusive_namespaces].join(' ')\n c14n_method_node.add_child(inclusive_namespaces_node)\n end\n\n signed_info_canon = canonicalize(signed_info_node, options[:inclusive_namespaces])\n\n signature = private_key.sign(@sign_digester.digester, signed_info_canon)\n signature_value_digest = Base64.encode64(signature).delete(\"\\n\")\n\n signature_value_node = Nokogiri::XML::Node.new('SignatureValue', document)\n signature_value_node.content = signature_value_digest\n signed_info_node.add_next_sibling(signature_value_node)\n self\n end",
"def sign(message)\n Ed25519.provider.sign(@keypair, message)\n end",
"def encode(data)\n @encryptor.encrypt_and_sign(data)\n end",
"def signature_for(data, secret)\n Base64.encode64(hmac_sha256(data, secret)).strip\n end",
"def initialize(data, cert, key)\n @p7 = OpenSSL::PKCS7.sign(cert.raw_cert, key.raw_key, data, [], FLAGS)\n @store = OpenSSL::X509::Store.new\n end",
"def to_signed_tx(private_key)\n sign_tx to_raw_tx, private_key\n end",
"def rsa(data, alg)\n rsa_private = OpenSSL::PKey::RSA.generate(2048)\n rsa_public = @rsa_private.public_key\n signature = @rsa_private.sign(OpenSSL::Digest.new(alg.sub('RS', 'sha')), data)\n\n {public_key: rsa_public, private_key: rsa_private, signature: signature}\n # FIXME: need to sign using public key\n # cert = File.open('pub_cert.pem').read\n # @public_key = OpenSSL::PKey::RSA.new(cert)\n # raise 'Not a public certificate' unless public_key.public?\n end",
"def sign!(key, sign_nonce = T.unsafe(nil)); end",
"def sign_key; end",
"def verify_signature signature, data, chain, time = Time.now\n Gem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n opt = Gem::Security::OPT.merge(@opt)\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = opt[:dgst_algo]\n\n # verify the data signature (this is the most important part, so don't\n # screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n\n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate against it's\n # issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc]\n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root',\n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc]\n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exist?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject }\n end\n end",
"def sign(message); end",
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n # OpenSSH compatibility: if a the number of bytes in the signature is less than the number of bytes of the RSA\n # modulus, prepend the signature with zeros.\n # See https://github.com/openssh/openssh-portable/blob/ac383f3a5c6f529a2e8a5bc44af79a08c7da294e/ssh-rsa.c#L531\n difference = n.num_bytes - raw_sig.bytesize\n raw_sig = \"\\0\" * difference + raw_sig if difference.positive?\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def sign!(cert)\n openssl_cert = cert.cert # because model -> OpenSSL object\n openssl_cert.serial = self.next_serial\n cert.serial = self.next_serial\n openssl_cert.issuer = ca_cert.subject\n openssl_cert.sign private_key, OpenSSL::Digest::SHA1.new\n self.next_serial = self.next_serial + 1\n self.save\n nil\n end",
"def sign(key, string)\n SSL.new(nil, key).sign(string, true)\n end",
"def encrypt(data, expires_at: nil, expires_in: nil, purpose: nil)\n return nil unless data\n\n service.encrypt_and_sign(\n data,\n expires_at: expires_at,\n expires_in: expires_in,\n purpose: purpose\n )\n end",
"def encrypt(data)\n return nil if !@key\n Base64::encode64(@key.private_encrypt(data)).delete(\"\\n\").strip\n end",
"def sign(pvt, id, txn)\n raise 'pvt must be of type Key' unless pvt.is_a?(Key)\n raise 'id must be of type Id' unless id.is_a?(Id)\n raise 'txn must be of type Txn' unless txn.is_a?(Txn)\n pvt.sign(body(id, txn))\n end",
"def verify(sig,data)\n if rsa?\n @pub.verify( OpenSSL::Digest::SHA1.new, sig, data )\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @pub.verify( OpenSSL::Digest::DSS1.new, sig, data )\n raise StandardError, 'DSA is not supported'\n else\n false\n end\n end",
"def hmac_signature(key, data)\n sha = HMAC::SHA1.new(key)\n sha.update(data)\n base64(sha.digest)\n end",
"def load_data_private_key(data, passphrase = T.unsafe(nil), ask_passphrase = T.unsafe(nil), filename = T.unsafe(nil), prompt = T.unsafe(nil)); end",
"def get_secure_signature(message)\n digest = OpenSSL::Digest.new('SHA256')\n Base64.strict_encode64(private_key.sign(digest, message))\n end",
"def signature\n subject = self.class.sig_subject([@payload,\n DATA_TYPE,\n ENCODING,\n ALGORITHM])\n @rsa_pkey.sign(DIGEST, subject)\n end",
"def pack(data)\n if @pubkey && [email protected]?\n block_size = @pubkey.n.num_bytes - 11\n\n edata = ''\n index = 0\n\n loop do\n break if index >= data.length\n\n edata << @pubkey.public_encrypt(data[index, block_size])\n\n index += block_size\n end\n\n data = edata\n end\n\n zdata = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION)\n Base64.strict_encode64(zdata)\n end",
"def sign_block(key_private, timestamp)\r\n # RSA Encryption (Formula: C = M^d mod n)\r\n timestamp = timestamp.to_i % key_private[1].to_i\r\n signature = timestamp.to_bn.mod_exp(key_private[0],key_private[1])\r\n return signature\r\nend",
"def sign(string, base64=false)\n sig = @private_key.sign(OpenSSL::Digest.new(\"SHA1\"), string)\n\n base64 ? base64_encode(sig) : sig\n end",
"def sign_with(fingerprint_id, signature)\n @signatures[fingerprint_id] = signature\n end",
"def sign(str)\n @signer.sign(str) unless str.nil? || str.empty?\n end",
"def sign\n write_attr('mid', SecureRandom.uuid)\n write_attr('ts', Time.now.utc.to_i)\n canonical_msg = self.canonicalize\n\n #priv_key = OmfCommon::Key.instance.private_key\n #digest = OpenSSL::Digest::SHA512.new(canonical_msg)\n\n #signature = Base64.encode64(priv_key.sign(digest, canonical_msg)).encode('utf-8') if priv_key\n #write_attr('digest', digest)\n #write_attr('signature', signature) if signature\n\n if OmfCommon::Measure.enabled?\n MPMessage.inject(Time.now.to_f, operation.to_s, mid, cid, self.to_s.gsub(\"\\n\",''))\n @@mid_list << mid\n end\n self\n end",
"def sign\n fail NotImplementedError\n end",
"def verify_signature(data)\n Signature.valid?(data.merge('api_key' => api_key))\n end",
"def get_signature(data, salt=nil)\n if salt == nil\n salt = (Time.now.to_i * 1000).to_s\n end\n\n hmac = OpenSSL::HMAC.new(get_key,OpenSSL::Digest.new('sha1'))\n hmac << data.force_encoding(\"utf-8\")\n hmac << salt.force_encoding(\"utf-8\")\n sig = Base64.urlsafe_encode64(hmac.digest).chop\n\n return sig,salt\n end",
"def send_data data\n\t size = data.bytesize if data.respond_to?(:bytesize)\n\t size ||= data.size\n\t\tEventMachine::send_data @signature, data, size\n\tend",
"def sign()\n # TODO\n end",
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def sign(message)\n OpenSSL::HMAC.digest('SHA256', @key, message)\n end",
"def rsaes_pkcs_signature(key, input)\n private_key = if BSON::Environment.jruby?\n # JRuby cannot read DER format, we need to convert key into PEM first.\n key_pem = [\n \"-----BEGIN PRIVATE KEY-----\",\n Base64.strict_encode64(Base64.decode64(key)).scan(/.{1,64}/),\n \"-----END PRIVATE KEY-----\",\n ].join(\"\\n\")\n OpenSSL::PKey::RSA.new(key_pem)\n else\n OpenSSL::PKey.read(Base64.decode64(key))\n end\n private_key.sign(OpenSSL::Digest::SHA256.new, input)\n end",
"def decrypt(data)\n raise NoPrivateKeyError, \"Private key file: #{@private_key_file}\" unless private?\n \n decrypted_data = Base64.decode64(data)\n private_rsa.private_decrypt(decrypted_data)\n end",
"def signed_data\n @signed_data ||= @signed_fields.index_with { |field| send(field) }\n end",
"def export_private_key(private_key, password = nil)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n unless password\n return Core::VirgilKeyPair.private_key_to_der(\n private_key.raw_key\n )\n end\n password_bytes = Bytes.from_string(password)\n private_key_bytes = Core::VirgilKeyPair.encrypt_private_key(\n private_key.raw_key,\n password_bytes\n )\n wrap_bytes(\n Core::VirgilKeyPair.private_key_to_der(\n private_key_bytes,\n password_bytes\n )\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def set_private(object,data)\n JS::Lib.JSObjectSetPrivate(object,data)\n end",
"def sign_certificate\n sign_certificate_for(default)\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def validate_signature!(signature, data)\n raise InvalidSignature unless valid_signature?(signature, data)\n end",
"def sign; adapter_class.new(self).sign; end",
"def sign(params, shared_secret = nil)\n shared_secret ||= params.delete['sharedSecret']\n raise ArgumentError, \"Cannot verify a signature without a shared secret\" unless shared_secret\n sig = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), Array(shared_secret).pack(\"H*\"), string_to_sign(params))\n params.merge('merchantSig' => Base64.encode64(sig).strip)\n end",
"def sign_tx(raw_tx, pkey_wif)\n # Seems like this is your quintessential reference: \n # http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html\n\n # I think this is the right way to do it...\n Bitcoin.network = (bitcoin.is_testing?) ? :testnet3 : :bitcoin\n\n # This parses the binary-encoded raw transaction:\n tx = Bitcoin::P::Tx.new [raw_tx].pack('H*')\n\n # This is the input transaction, which we'll need for signining:\n prev_hash = tx.in[0].prev_out.reverse_hth\n\n # let's parse the keys:\n key = Bitcoin::Key.from_base58 pkey_wif\n\n pubkey = [key.pub].pack('H*')\n\n # And parse the input transaction:\n prev_tx = Bitcoin::P::Tx.new [bitcoin.getrawtransaction(prev_hash)].pack('H*')\n\n # And, now we're ready to sign: \n subscript = tx.signature_hash_for_input 0, prev_tx\n sig = Bitcoin.sign_data Bitcoin.open_key(key.priv), subscript\n tx.in[0].script_sig = Bitcoin::Script.to_signature_pubkey_script sig, pubkey \n\n tx.to_payload.unpack('H*')[0]\n end",
"def public_encrypt(data)\n Base64.encode64(@key.public_encrypt(data))\n end",
"def sign\n url.query = url.query.to_s + \"&Signature=#{Utils.encode signature}\"\n self\n end",
"def private_key=(private_key); end",
"def set_private(data)\n res = super(self,data)\n return res\n end",
"def sign!(signing_profile={})\n raise \"Invalid certificate #{self.errors.full_messages}\" unless valid?\n merge_profile_with_extensions(signing_profile)\n\n openssl_cert = OpenSSL::X509::Certificate.new\n openssl_cert.version = 2\n openssl_cert.not_before = self.not_before\n openssl_cert.not_after = self.not_after\n openssl_cert.public_key = self.key_material.public_key\n\n openssl_cert.serial = self.serial_number.number\n\n openssl_cert.subject = self.distinguished_name.to_x509_name\n openssl_cert.issuer = parent.distinguished_name.to_x509_name\n\n factory = OpenSSL::X509::ExtensionFactory.new\n factory.subject_certificate = openssl_cert\n\n #NB: If the parent doesn't have an SSL body we're making this a self-signed cert\n if parent.openssl_body.nil?\n factory.issuer_certificate = openssl_cert\n else\n factory.issuer_certificate = parent.openssl_body\n end\n\n factory.config = build_openssl_config\n\n # Order matters: e.g. for self-signed, subjectKeyIdentifier must come before authorityKeyIdentifier\n self.extensions.keys.sort{|a,b| b<=>a}.each do |k|\n e = extensions[k]\n next if e.to_s.nil? or e.to_s == \"\" ## If the extension returns an empty string we won't include it\n ext = factory.create_ext(e.openssl_identifier, e.to_s, e.critical)\n openssl_cert.add_extension(ext)\n end\n\n if signing_profile[\"digest\"].nil?\n digest = OpenSSL::Digest.new(\"SHA512\")\n else\n digest = OpenSSL::Digest.new(signing_profile[\"digest\"])\n end\n\n self.openssl_body = openssl_cert.sign(parent.key_material.private_key, digest)\n end",
"def sign(wallet)\n tx = Arweave::Transaction.new(data: @commit.message.to_s)\n @commit.to_tags.each do |name, value|\n tx.add_tag(name: name, value: value)\n end\n tx.sign(wallet)\n end",
"def verify_signature\n @spki.verify(public_key)\n end",
"def sign()\n exp_payload = { :data => to_json, :exp => validto.to_s}\n JWT.encode exp_payload, secret, 'HS512'\n end",
"def sign(payload)\n payload = payload.merge({\n :client_id => @client_id,\n :client_secret => @client_secret,\n })\n\n scope = create_scope\n context = create_context(payload)\n s2s = create_string_to_sign(scope, context)\n signing_key = get_signing_salt\n OpenSSL::HMAC.hexdigest(@hash_algo, signing_key, s2s)\n end",
"def public_key(private_key)\n private_key_int = private_key.to_i(16)\n KeyGen::GROUP.generator.multiply_by_scalar(private_key_int)\n end",
"def sign_base_string(base_string)\n key = OpenSSL::PKey::RSA.new File.read @private_key\n signature = key.sign(OpenSSL::Digest::SHA256.new, base_string)\n\n Base64.encode64(signature).delete(\"\\n\")\n end",
"def sign!(request,options = {})\n consumer.sign!(request,self,options)\n end",
"def verify_gem(signature, data, chain, time = Time.now)\n\tGem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = @opt[:dgst_algo]\n\n # verify the data signature (this is the most important part,\n # so don't screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n \n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate\n # against it's issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc] \n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root', \n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc] \n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = @opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, @opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exists?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject } \n end\n end",
"def signing_input; end",
"def signing_input; end",
"def rsa_sign arr\n # RFC 3447 / 9.2.\n hash = Digest::SHA1.digest arr.map(&:chr).join\n\n # RFC 3447 / page 43\n digest_info = [0x30, 0x21, 0x30, 0x09, 0x06,\n 0x05, 0x2b, 0x0e, 0x03, 0x02,\n 0x1a, 0x05, 0x00, 0x04, 0x14].map(&:chr).join\n\n # i don't do the padding, openssl does that for me\n # i'll reimplement RSA later on\n signature = HOST_KEY.private_encrypt(digest_info + hash)\nend",
"def signed_data\n @signed_data = @signed_fields.index_with { |field| @fields[field] }\n end",
"def recover_compact(data, signature, rec, compressed)\n r = ECDSA::Format::IntegerOctetString.decode(signature[1...33])\n s = ECDSA::Format::IntegerOctetString.decode(signature[33..-1])\n ECDSA.recover_public_key(Bitcoin::Secp256k1::GROUP, data, ECDSA::Signature.new(r, s)).each do |p|\n if p.y & 1 == rec\n return Bitcoin::Key.from_point(p, compressed: compressed)\n end\n end\n end",
"def sign!(ha)\n ha[:sig] = compute_checksum(ha)\n end",
"def digest(data)\n OpenSSL::HMAC.digest(digest_class.new, key, data)[0,mac_length]\n end",
"def signature_params\n params.require(:signature).permit(:sign)\n end",
"def private_key\n encode64(curve.private_key.to_s(2))\n end",
"def sign_with(secret)\n #puts \"Signing #{string_to_sign.inspect} with #{secret.inspect}\"\n digest = OpenSSL::Digest.new('sha256')\n Base64.encode64(OpenSSL::HMAC.digest(digest, secret, string_to_sign)).strip\n end",
"def sign_request(options)\n options.merge!(:pub => @api_key)\n options.merge!(:key => Digest::MD5.hexdigest(@api_secret + @api_key))\n end",
"def sign(path)\n status \"Signing #{File.basename(path)} ...\"\n\n run 'gpg', '--sign', '--detach-sign', '--armor', path\n end"
] | [
"0.7947322",
"0.786024",
"0.7407691",
"0.7184251",
"0.71586293",
"0.7139596",
"0.7115777",
"0.708158",
"0.69725597",
"0.6740559",
"0.6612138",
"0.6592608",
"0.63898736",
"0.6369639",
"0.6331517",
"0.6224096",
"0.62032676",
"0.6201918",
"0.6174239",
"0.6172403",
"0.6150139",
"0.6005663",
"0.5997823",
"0.5931525",
"0.59315056",
"0.59075737",
"0.58513105",
"0.5806233",
"0.57640195",
"0.5722337",
"0.5670631",
"0.56317586",
"0.56265455",
"0.5577168",
"0.557008",
"0.5567987",
"0.55447036",
"0.55428207",
"0.5514774",
"0.5500281",
"0.5484564",
"0.5443067",
"0.5442387",
"0.54286885",
"0.5407596",
"0.54017127",
"0.53784025",
"0.53596",
"0.53591514",
"0.5333894",
"0.533312",
"0.5313384",
"0.53018004",
"0.52785385",
"0.52640265",
"0.5258587",
"0.5253887",
"0.5222512",
"0.5213242",
"0.52050984",
"0.51988876",
"0.51985884",
"0.51847434",
"0.5184665",
"0.5150521",
"0.5118443",
"0.51137197",
"0.505013",
"0.50449014",
"0.50410956",
"0.50242674",
"0.50150466",
"0.5010142",
"0.50003463",
"0.49816892",
"0.49796304",
"0.49720255",
"0.4966246",
"0.49614322",
"0.495443",
"0.49491593",
"0.49433437",
"0.49321127",
"0.49182582",
"0.49167645",
"0.49135724",
"0.49073923",
"0.4906194",
"0.49057463",
"0.49057463",
"0.49048573",
"0.48966303",
"0.48920915",
"0.48876846",
"0.48771754",
"0.48759657",
"0.48594096",
"0.48570785",
"0.48471633",
"0.48414558"
] | 0.5454354 | 41 |
Verifies the specified signature using original data and signer's public key. | def verify_signature(signature, bytes, signer_public_key)
signature = Validation.check_filled_array_argument!(signature)
bytes = Validation.check_filled_array_argument!(bytes)
signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)
begin
native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)
signer = Core::VirgilSigner.new(native_algorithm)
signer.verify(bytes, signature, signer_public_key.raw_key)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n # OpenSSH compatibility: if a the number of bytes in the signature is less than the number of bytes of the RSA\n # modulus, prepend the signature with zeros.\n # See https://github.com/openssh/openssh-portable/blob/ac383f3a5c6f529a2e8a5bc44af79a08c7da294e/ssh-rsa.c#L531\n difference = n.num_bytes - raw_sig.bytesize\n raw_sig = \"\\0\" * difference + raw_sig if difference.positive?\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def verify_signature(public_key, payload, signature, timestamp)\n verify_engine\n timestamped_playload = \"#{timestamp}#{payload}\"\n payload_digest = Digest::SHA256.digest(timestamped_playload)\n decoded_signature = Base64.decode64(signature)\n public_key.dsa_verify_asn1(payload_digest, decoded_signature)\n rescue StandardError\n false\n end",
"def verify_signature\n @spki.verify(public_key)\n end",
"def verify_signature(data)\n Signature.valid?(data.merge('api_key' => api_key))\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def validate_signature!(signature, data)\n raise InvalidSignature unless valid_signature?(signature, data)\n end",
"def verify_signature(params = {})\n version = params[:version]\n webhook_secret = params[:webhook_secret]\n stringified_data = params[:stringified_data]\n request_timestamp = params[:request_timestamp]\n signature = params[:signature]\n\n signature_params = \"#{request_timestamp}.#{version}.#{stringified_data}\"\n digest = OpenSSL::Digest.new('sha256')\n signature_to_be_verified = OpenSSL::HMAC.hexdigest(digest, webhook_secret, signature_params)\n\n signature == signature_to_be_verified\n\n end",
"def match_signature(signature)\n if !signature[:ok]\n msg_mismatch(text)\n elsif expected_signer && signature[:email] != expected_signer\n msg_wrong_signer(signature[:email])\n end\n end",
"def verify_signature(signature, signed_text, base64_encoded=true)\n sig = base64_encoded ? Base64UrlSafe.decode(signature) : signature\n self.public_key.verify(OpenSSL::Digest::SHA256.new, sig, signed_text)\n end",
"def verify_signature signature, data, chain, time = Time.now\n Gem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n opt = Gem::Security::OPT.merge(@opt)\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = opt[:dgst_algo]\n\n # verify the data signature (this is the most important part, so don't\n # screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n\n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate against it's\n # issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc]\n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root',\n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc]\n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exist?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject }\n end\n end",
"def verify_ecdsa_signature(signature, hash)\n BTC::OpenSSL.ecdsa_verify(signature, hash, self.public_key)\n end",
"def verify(*args, **options)\n verified(*args, **options) || raise(InvalidSignature)\n end",
"def valid_signature?(signature, data)\n generate_signature(data) == signature\n end",
"def verify\n @sigs = []\n @orig_data = request.params['data']\n if @orig_data.nil?\n # XXX: Implement HTTP error here.\n end\n begin\n GPGME::verify(request.params['data'], nil, @plain) do |signature|\n @sigs << signature\n end\n rescue GPGME::Error => e\n @error = \"GPGME Error: #{e.to_s}\"\n #rescue\n # @error = \"Unspecified Error.\"\n end\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n end",
"def verify(sig,data)\n if rsa?\n @pub.verify( OpenSSL::Digest::SHA1.new, sig, data )\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @pub.verify( OpenSSL::Digest::DSS1.new, sig, data )\n raise StandardError, 'DSA is not supported'\n else\n false\n end\n end",
"def verify_signature(result); end",
"def verify_stream_signature(signature, input_stream, signer_public_key)\n signature = Validation.check_filled_array_argument!(signature)\n signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilStreamSigner.new(native_algorithm)\n source = VirgilStreamDataSource.new(input_stream)\n signer.verify(source, signature, signer_public_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def verify(key)\n plaintext = plaintext_sig(body, type, encoding, alg)\n key.public_key.verify(digest, sig, plaintext)\n rescue BadError\n false\n end",
"def verify_signature(cleartext, signature_string)\n cmd_output = run_verify(cleartext, signature_string)\n cmd_result = analyse_verify_output(*cmd_output)\n\n if cmd_result[:well_formed_pgp_data]\n match_constraints(**cmd_result)\n else\n msg_no_pgg_data(signature_string)\n end\n end",
"def verify_signature(signature, string, base64=false)\n signature = base64_decode(signature) if base64\n\n @public_key.verify(OpenSSL::Digest.new(\"SHA1\"), signature, string)\n end",
"def verify_compact_signature(signature, hash)\n raise BTCError, \"Not implemented\"\n end",
"def verify!(ha)\n passed_signature = ha[:sig] || ha[\"sig\"]\n raise Tampered, \"No signature given\" unless passed_signature\n raise Tampered, \"Checksum differs\" unless compute_checksum(ha) == passed_signature.to_s\n true\n end",
"def verify(file)\n # Read YAML file and comment\n data = YAML.load(File.open(file + SIGEXT))\n raise KeyfileError, \"Invalid file #{file + SIGEXT} content\" unless data && data.is_a?(Hash)\n\n puts \"Signature in file: #{file + SIGEXT}\" if @options[:verbose]\n clearsg = !File.file?(file)\n\n # Hash data\n start = Time.now\n sha = if clearsg\n raise VerificationError, \"File #{file} does not exist, no signed data\" if data[:data].nil?\n Digest::SHA512.new\n else\n puts \"⚠ Warning: clear sign data found but ignored\" if data.has_key?(:data)\n Digest::SHA512.file(file)\n end\n sha << \"\\0x00\" + data[:comment] unless data[:comment].nil?\n sha << \"\\0x00\" + data[:datetime].to_s\n sha << \"\\0x00\" + data[:data] if clearsg\n\n # Control data\n ctn = Enc.decode(data[:signature])\n pub = Ed25519::VerifyKey.new Enc.decode_key(data[:verifykey])\n puts \"Signed with key: #{abbrev_key(data[:verifykey])}\" if @options[:verbose]\n t = get_trusted_keys.include?(data[:verifykey]) ? \"with trusted key\" :\n \"but the verify key is ✖ not trusted\\n (#{data[:verifykey]})\"\n pub.verify(ctn, sha.digest) || raise(VerificationError, \"BAD signature\")\n if clearsg\n $stderr.puts \"✔ Good signature #{t}\\n signed on #{Time.at(data[:datetime])}\"\n $stdout.print data[:data]\n $stderr.puts \"Comment: #{data[:comment]}\\n\" unless data[:comment].nil?\n else\n puts \"✔ Good signature #{t}\\n signed on #{Time.at(data[:datetime])}\"\n puts \"(⏲ #{'%.2f' % ((Time.now - start) * 1000)} ms)\" if @options[:verbose]\n puts \"Comment: #{data[:comment]}\\n\" unless data[:comment].nil?\n end\nend",
"def signature_is_valid?\n node = @ar.at_css('xmlns|SignedInfo',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#')\n\n node = node.canonicalize\n\n signature = @ar.at_css(\n 'xmlns|SignatureValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content\n\n signature = Base64.decode64(signature)\n\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def verify(signed_message)\n verified(signed_message)\n end",
"def verify_sig(data, sig, pubkey, algo: :ecdsa)\n case algo\n when :ecdsa\n verify_ecdsa(data, sig, pubkey)\n when :schnorr\n verify_schnorr(data, sig, pubkey)\n else\n false\n end\n end",
"def validate!\n Cybersource::Security.validate_signature!(@fields['signature'], signed_data)\n raise PaymentFailed unless payment_success?\n\n self\n end",
"def verify(message, signature, signature_encoding = :raw)\n signature = Encoder[signature_encoding].decode(signature)\n Util.check_length(signature, NaCl::SIGNATUREBYTES, \"signature\")\n\n sig_and_msg = signature + message\n buffer = Util.zeros(sig_and_msg.bytesize)\n buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)\n\n NaCl.crypto_sign_open(buffer, buffer_len, sig_and_msg, sig_and_msg.bytesize, @key)\n end",
"def valid?(other)\n self.signature === other\n end",
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_GEOTIX_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, \"#{auth_token}#{@payload_raw}\")\n halt [401, \"Signatures don't match.\"] unless their_digest == our_digest\n end",
"def verify_signatures spec, digests, signatures\n if only_signed and signatures.empty? then\n raise Gem::Security::Exception,\n \"unsigned gems are not allowed by the #{name} policy\"\n end\n\n digests.each do |file, digest|\n signature = signatures[file]\n raise Gem::Security::Exception, \"missing signature for #{file}\" unless\n signature\n verify_signature signature, digest.digest, spec.cert_chain\n end\n end",
"def verify_gem(signature, data, chain, time = Time.now)\n\tGem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = @opt[:dgst_algo]\n\n # verify the data signature (this is the most important part,\n # so don't screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n \n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate\n # against it's issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc] \n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root', \n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc] \n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = @opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, @opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exists?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject } \n end\n end",
"def valid_signature? signature\n # We create a new XML document in Nokogiri to canonicalize the\n # signature. Nokogiri needs the xmlns:ds tag on the root element to\n # preserve the 'ds:' namespace on all the elements. Not exactly sure\n # why this is needed, but it works if we do it.\n info = signature.find_first('.//ds:SignedInfo', DS)\n\n canon = LibXML::XML::Document.new\n canon.root = canon.import info\n canonicalized = canon.canonicalize\n\n b64_sig = signature.find_first('.//ds:SignatureValue', DS).content\n dec_sig = Base64.decode64 b64_sig\n\n b64_cert = signature.find_first('.//ds:X509Certificate', DS).content\n cert = OpenSSL::X509::Certificate.new(Base64.decode64(b64_cert))\n\n digest = OpenSSL::Digest::SHA1.new\n cert.public_key.verify(digest, dec_sig, canonicalized)\n end",
"def verify_signatures?; end",
"def verify(message, signature, signature_encoding = :raw)\n signature = Encoder[signature_encoding].decode(signature)\n Util.check_length(signature, signature_bytes, \"signature\")\n\n sig_and_msg = signature + message\n buffer = Util.zeros(sig_and_msg.bytesize)\n buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)\n\n NaCl.crypto_sign_ed25519_open(buffer, buffer_len, sig_and_msg, sig_and_msg.bytesize, @key)\n end",
"def signature_valid?; end",
"def validate_signature(doc, certificate, canonicalization_method)\n node = doc.at('xmlns|SignedInfo', xmlns: DSIG)\n\n return false unless node\n\n node = case canonicalization_method\n when :normal\n node.canonicalize\n when :exclusive\n canonicalize_exclusively node\n end\n\n signature = doc.at('xmlns|SignatureValue', xmlns: DSIG).content\n signature = decode(signature)\n\n # Return true or false\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def verify_signature\n return_code, response = send_command(\"verify_signature\", token)\n return_code == \"200\"\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return false if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return false\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return true\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return FALSE if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return FALSE\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return TRUE\n end",
"def verify(signed_message, message, signing_key = admin_key)\n msg_int = rsa.text_to_int(message)\n rsa.verify(signed: signed_message, message: msg_int, key: signing_key)\n end",
"def verifySignature _args\n \"verifySignature _args;\" \n end",
"def validate_signature(test_doc = nil)\n test_doc ||= @prepared_doc\n\n doc_signature = get_document_tag :esigncode, from: test_doc\n doc_salt = get_document_tag :esignuniquecode, from: test_doc\n validate_prepared_doc_digest test_doc\n\n new_pdd = prepared_doc_digest(from: test_doc)\n new_signature = Hashing.sign_with(doc_salt, new_pdd)\n raise ESignatureUserError, 'Document signature is invalid' unless doc_signature == new_signature\n\n true\n end",
"def check_server_signature(payload_data)\n if verifier = payload_data['v']\n if compare_digest(verifier, server_signature)\n @server_verified = true\n else\n raise Error::InvalidSignature.new(verifier, server_signature)\n end\n end\n end",
"def validate_signature(key_public, signature, timestamp)\r\n # RSA Decryption (Formula: M = C^e mod n)\r\n timestamp = timestamp.to_i % key_public[1].to_i\r\n signature = signature.to_i\r\n decipher = signature.to_bn.mod_exp(key_public[0].to_i,key_public[1].to_i)\r\n return true if (decipher == timestamp)\r\n return false\r\nend",
"def check(params)\n params = params.dup\n\n signature = params.delete('sig')\n\n ::JWT::SecurityUtils.secure_compare(signature, digest(params))\n end",
"def verify_signature(url, params)\n submit VerifySignature.new(:url_end_point => url, :http_parameters => params)\n end",
"def valid?\n return false unless given_signature\n Relax::Query.unescape_value(correct_signature) == given_signature\n end",
"def signature_is_valid?\n validate_signature(doc, certificate, :normal)\n end",
"def safe_equals?(signature, other_signature)\n check = signature.bytesize ^ other_signature.bytesize\n signature.bytes.zip(other_signature.bytes) { |x, y| check |= x ^ y.to_i }\n check.zero?\n end",
"def verify_tx_signed_by(transaction_envelope:, keypair:)\n hashed_signature_base = transaction_envelope.tx.hash\n\n transaction_envelope.signatures.any? do |sig| \n keypair.verify(sig.signature, hashed_signature_base)\n end\n end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def verify(params, shared_secret = nil)\n their_sig = params.delete('merchantSig')\n raise ArgumentError, \"params must include 'merchantSig' for verification\" if their_sig.empty?\n our_sig = sign(params, shared_secret)['merchantSig']\n secure_compare(their_sig, our_sig)\n end",
"def check_for_signature\n if signature_file_name_changed?\n sign if signature.present?\n end\n true\n end",
"def verify(payload, header, tolerance: nil)\n begin\n timestamp, signatures = get_timestamp_and_signatures(header)\n rescue StandardError\n raise InvalidSignature, \"Unable to extract timestamp and signatures from header\"\n end\n\n if signatures.empty?\n raise InvalidSignature, \"No signatures found with expected version #{@version}\"\n end\n\n expected_sig = generate(payload, timestamp)\n unless signatures.any? { |s| secure_compare(expected_sig, s) }\n raise InvalidSignature, \"No signatures found matching the expected signature for payload\"\n end\n\n if tolerance && timestamp < Time.now - tolerance\n raise InvalidSignature, \"Timestamp outside the tolerance zone (#{Time.at(timestamp)})\"\n end\n\n true\n end",
"def verify_signature\n if @local_path\n if RUBY_PLATFORM =~ /java/\n begin\n jarfile = java.util.jar.JarInputStream.new(FileInputStream.new(@local_path), true)\n @signature_verified = true\n rescue NativeException\n @signature_verified = false\n end\n else\n # Use IO.popen instead of system() to absorb\n # jarsigners messages to $stdout\n response = IO.popen(\"jarsigner -verify #{@local_path}\"){|io| io.gets}\n @signature_verified = ($?.exitstatus == 0)\n end\n else\n nil\n end\n end",
"def valid_signature?\n Rack::Utils.secure_compare(signature, signature_for(body))\n end",
"def verify!(config, params)\n sent_signature = params.find { |key, _value| key.to_s.casecmp('BRQ_SIGNATURE').zero? }&.last\n generated_signature = Signature.generate(config, params)\n\n if sent_signature.nil? || generated_signature.nil? || !safe_equals?(sent_signature, generated_signature)\n raise SignatureException.new(sent_signature, generated_signature)\n end\n end",
"def verify content, sign\n # raise OpenSSL::PKey::ECError(ECDSA_verify: nested asn1 error) when sign is wrong\n @ec.dsa_verify_asn1 content, Utils::BinUtil.from_hex(sign)\n rescue\n false\n end",
"def validate(url, params, signature)\r\n params_hash = params.to_unsafe_h\r\n expected = build_signature_for(url, params_hash)\r\n ActiveSupport::SecurityUtils.secure_compare(expected, signature)\r\n end",
"def verify(msg)\n \t\t\t\tbegin\n \t\t\t\t\tx,y,z,cmd,sig,iv = msg.split(/\\|/)\n \t\t\t\t\treturn nil unless iv\n \t\t\t\t\tdigest = Digest::MD5.hexdigest(cmd+iv).upcase\n \t\t\t\t\tsb1 = [@signature_block + digest].pack(\"h*\")\n \t\t\t\t\tsb2 = @signingkey_pub.public_decrypt([sig].pack(\"h*\"))\n \t\t\t\t\treturn nil unless sb1 == sb2\n \t\t\t\t\tcmd\n \t\t\t\trescue NoMethodError\n \t\t\t\t\tputs \"verify exception: #{msg}\"\n \t\t\t\tend\n \t\t\tend",
"def has_valid_signature?\n Adyen::HPP::Signature.verify(params, shared_secret)\n end",
"def verify_content(body, signature)\n hmac = HMAC::SHA1.hexdigest(@secret, body)\n check = \"sha1=\" + hmac\n check == signature\n end",
"def process_signature? (signature)\n\t\n\t\tlogger.debug 'Estamos procesando la firma'\t\n\t\t\n\t\tif not signature.signed?\n\n\t\t\[email protected] = Base64.decode64(params[:xmlSigned2])\n\t\t\t\n\t\t\tbegin\n\t\t\t\tvalidation = @signature.validate_signature\n\t\t\trescue\n\t\t\t\tflash[:error] = \"Ha ocurrido un error al intentar validar el certificado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif not validation.isValid?\n\t\t\t\tflash[:error] = \"La firma no es válida. Compruebe que el certificado no esté caducado o revocado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif validation.psisNIF != signature.dni\n\t\t\t\tflash[:error] = \"El DNI introducido en el formulario no coincide con el DNI del Certificado\"\n\t\t\t\treturn false\t\t\t\n\t\t\tend\n\n\t\t\[email protected] = 1\n\t\t\t\n\t\t\tif @signature.valid?\n\t\t\t\t@proposal = @signature.proposal\n\t\t\t\[email protected]_afirma_signature\t\t\n\t\t\t\tshare_texts(@proposal, @signature)\n\t\t\t\tsignature.notifier\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\tflash[:error] = @signature.errors.map {|a,m| \"#{m.capitalize}\"}.uniq.join(\"<br/>\\n\")\n\t\t\t\treturn false\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Este identificador de firma ya ha sido firmado\"\n\t\t\treturn false\n\t\tend\n\tend",
"def matches_signature(signature)\n @name == signature.name\n end",
"def ==(other)\n return false unless other.is_a?(Signature)\n r == other.r && s == other.s\n end",
"def correct_signature?\n client = RestClient.where(:api_key => @api_key).first\n sign=client.nil? ? \"\" : client.secret + @request_uri.gsub(/\\?.*/,\"\")+@timestamp\n calculated_sign= (Digest::SHA256.new << sign).to_s\n Digest::SHA1.hexdigest(@signature)==Digest::SHA1.hexdigest(calculated_sign)\n end",
"def verify(data, mac, key)\n data_mac = sign(data, key)\n unless constant_time_comparison(mac, data_mac)\n raise ArgumentError, 'MAC check failed!'\n end\n end",
"def sign data\n return unless @key\n\n @key.sign @digest_algorithm.new, data\n end",
"def verify_request(verb, path, params, key, signature_param = nil)\n params ||= {}\n _path = path.dup\n _params = params.dup\n sign_request(verb, _path, _params, key, signature_param)\n return (path == _path and params == _params)\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def valid?\n # If payload does not contain the sha_sign definitely return false.\n return false unless payload.sha_sign\n\n signature == payload.sha_sign\n end",
"def decrypt_then_verify(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n decrypted_bytes = cipher.decrypt_with_key(\n bytes,\n private_key.id,\n private_key.raw_key\n )\n signature = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNATURE)\n\n signer_public_key = public_keys.first\n\n if public_keys.count > 1\n signer_id = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNER_ID)\n signer_public_key = public_keys.find {|public_key| public_key.id == signer_id}\n end\n\n is_valid = verify_signature(signature, decrypted_bytes, signer_public_key)\n raise VirgilCryptoException, 'Signature is not valid' unless is_valid\n\n wrap_bytes(decrypted_bytes)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def verify_signatures(request)\n data, _status_code, _headers = verify_signatures_with_http_info(request)\n data\n end",
"def verify(build)\n # TODO might as well cache this and store in the db so we dont have to\n # convert every time\n pkey = to_rsa_pkey\n signature = Base64.decode64(build.signature)\n digest = OpenSSL::Digest::SHA256.new\n\n # If the user submits html were going to expect the\n # signature to match the html they are submitting.\n # However, if the user gives a url where we can download\n # the html, we're going to expect the signature to match\n # the app name and the url.\n if build.endpoint.present?\n expected = \"#{build.app.name}-#{build.endpoint}\"\n else\n expected = build.html\n end\n\n match = expected &&\n signature &&\n pkey.verify(digest, signature, expected)\n # Bug in ruby's OpenSSL implementation.\n # SSL connection with PostgreSQL can fail, after a call to\n # OpenSSL::X509::Certificate#verify with result 'false'. Root cause is\n # the thread local error queue of OpenSSL, that is used to transmit\n # textual error messages to the application after a failed crypto\n # operation. A failure in Certificate#verify leaves some messages on the\n # error queue, which can lead to errors in a SSL communication of other\n # parts of the application. The only solution at the moment is running:\n # OpenSSL.errors.clear after certificate verifying. This clears OpenSSL\n # errors array and keeps database connection alive.\n # From https://bugs.ruby-lang.org/issues/7215\n OpenSSL.errors.clear\n match # return true/false\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def verify_tx_signed_by(transaction_envelope:, keypair:)\n Stellar::SEP10.verify_tx_signed_by(\n tx_envelope: transaction_envelope, keypair: keypair\n )\n end",
"def signstuff(revision, data, pkeypath)\n pkey = OpenSSL::PKey::EC.new File.read pkeypath\n\n revm = revision.match(/([0-9]+)-.+/)\n oldrev = revm[1]\n newrev = oldrev.to_i + 1\n\n signature = Base64.encode64(pkey.dsa_sign_asn1(newrev.to_s+data))\nend",
"def verify(app_id)\n # Chapter 4.3 in\n # http://fidoalliance.org/specs/fido-u2f-raw-message-formats-v1.0-rd-20141008.pdf\n data = [\n \"\\x00\",\n ::U2F::DIGEST.digest(app_id),\n ::U2F::DIGEST.digest(client_data_json),\n key_handle_raw,\n public_key_raw\n ].join\n\n begin\n parsed_certificate.public_key.verify(::U2F::DIGEST.new, signature, data)\n rescue OpenSSL::PKey::PKeyError\n false\n end\n end",
"def validate_sig(pkey,sig)\r\n\t\t\t\r\n\t\tend",
"def check_signature\n signature == \"\\x2a\\x2a\\x00\\x00\"\n end",
"def recover_compact(data, signature, rec, compressed)\n r = ECDSA::Format::IntegerOctetString.decode(signature[1...33])\n s = ECDSA::Format::IntegerOctetString.decode(signature[33..-1])\n ECDSA.recover_public_key(Bitcoin::Secp256k1::GROUP, data, ECDSA::Signature.new(r, s)).each do |p|\n if p.y & 1 == rec\n return Bitcoin::Key.from_point(p, compressed: compressed)\n end\n end\n end",
"def valid_hashes? signature\n refs = signature.find('.//ds:Reference', DS).map{ |r| r['URI'][1..-1] }\n\n without_signature = LibXML::XML::Document.document(signature.doc)\n without_signature.find_first('//ds:Signature', DS).remove!\n # The XML digested must be canonicalized as per the W3's specification\n # at http://www.w3.org/TR/xml-c14n\n c14n = without_signature.canonicalize\n digest = Base64.encode64(Digest::SHA1.digest(c14n)).chomp\n\n refs.all? do |ref|\n hashed_element = @doc.find_first(\"//*[ID='#{ref}']\")\n digest_listed = signature.find_first('.//ds:DigestValue', DS).content\n\n digest == digest_listed\n end\n end",
"def validate_signature\n\t\t::Rails.logger.debug \"--- Realizando comprobación de la firma con PSEIS ---\"\n\t\tdoc = Nokogiri::XML(xmlSigned)\n\t\tdoc.remove_namespaces!\n\t\t\n\t\tcert = doc.xpath('//X509Data/X509Certificate').first.inner_text\n\t\t\n\t\tmyValidation = PSISApi.new\n\t\tmyValidation.validate cert\n\t\treturn myValidation\n\tend",
"def verify(message, public_keys)\n ll_array = []\n rr_array = []\n\n public_keys.each_with_index do |k, i|\n ll_array[i] = hasher.group.generator * r_array[i] + k.point * c_array[i]\n rr_array[i] = hasher.hash_point(k.point) * r_array[i] + key_image * c_array[i]\n end\n\n c_sum = c_array.inject{|a, b| a + b} % hasher.group.order\n\n message_digest = hasher.hash_string(message)\n challenge = hasher.hash_array([message_digest] + ll_array + rr_array)\n\n c_sum == challenge\n end",
"def sign(data)\n @key.sign(@algo.new, data)\n end",
"def verifier\n Verifier.new(public_key)\n end",
"def valid_signature?\n params['verifier'] == Digest::MD5.hexdigest([ params['id'], params['snuid'], params['currency'], Offerpal.secret_key ].join(':'))\n end",
"def secure?\n self.generated_signature == self.signature\n end",
"def verify_signature(result) # :nodoc:\n response = build_signature_buffer(result)\n\n hash = digester.digest(response.to_s)\n\n server_key = result[:server_key]\n server_sig = result[:server_sig]\n unless connection.host_key_verifier.verify_signature { server_key.ssh_do_verify(server_sig, hash, host_key: algorithms.host_key) }\n raise Net::SSH::Exception, 'could not verify server signature'\n end\n\n hash\n end",
"def call\n unless current_user && current_user.authentication_token == data[:authentication_token]\n raise(ActiveSupport::MessageVerifier::InvalidSignature)\n end\n\n current_user\n end"
] | [
"0.75810474",
"0.731252",
"0.7081596",
"0.70555514",
"0.7023932",
"0.6910729",
"0.6750778",
"0.6750778",
"0.67338645",
"0.6727219",
"0.6724313",
"0.67084795",
"0.6613674",
"0.6583732",
"0.6560663",
"0.6543195",
"0.653375",
"0.6525398",
"0.6461024",
"0.6444515",
"0.64012206",
"0.63654757",
"0.6334101",
"0.6305413",
"0.6291606",
"0.6288845",
"0.62866855",
"0.622017",
"0.61690915",
"0.6162621",
"0.61610097",
"0.61399186",
"0.6109993",
"0.61065274",
"0.610194",
"0.6099748",
"0.6096425",
"0.6096224",
"0.60470885",
"0.6035392",
"0.6035042",
"0.60311663",
"0.6019788",
"0.60021037",
"0.5999874",
"0.59944445",
"0.59829104",
"0.59412456",
"0.59199643",
"0.5919769",
"0.58938843",
"0.5875175",
"0.58646566",
"0.58625084",
"0.586117",
"0.5826491",
"0.5817689",
"0.5817689",
"0.5817689",
"0.58156985",
"0.580766",
"0.5794924",
"0.5751556",
"0.574598",
"0.5722512",
"0.57192194",
"0.5718105",
"0.57064664",
"0.568278",
"0.56824124",
"0.5675783",
"0.56686705",
"0.5661034",
"0.5642132",
"0.5640154",
"0.56309474",
"0.5595757",
"0.55830383",
"0.55814517",
"0.5578371",
"0.5562565",
"0.55458176",
"0.5523323",
"0.5510087",
"0.5510087",
"0.55086935",
"0.54994875",
"0.54811686",
"0.5477952",
"0.54524785",
"0.545065",
"0.5443663",
"0.5436774",
"0.54324645",
"0.5431924",
"0.5416984",
"0.5409915",
"0.5408195",
"0.5404691",
"0.5396578"
] | 0.70169884 | 5 |
Encrypts the specified stream using public_keys Public keys. | def encrypt_stream(input_stream, cipher_stream, *public_keys)
begin
cipher = Core::VirgilChunkCipher.new
public_keys.each do |public_key|
public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)
cipher.add_key_recipient(public_key.id, public_key.raw_key)
end
source = VirgilStreamDataSource.new(input_stream)
sink = VirgilStreamDataSink.new(cipher_stream)
cipher.encrypt(source, sink)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rsa_encrypt_with_public(plain_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_encrypt(plain_string)\n end",
"def rsa_encrypt_with_public(plain_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_encrypt(plain_string)\n end",
"def encrypt(data)\n raise NoPublicKeyError, \"Public key file: #{@public_key_file}\" unless public?\n \n encrypted_data = public_rsa.public_encrypt(data)\n Base64.encode64(encrypted_data)\n end",
"def public_encrypt(plaintext)\n @public_key.public_encrypt(plaintext)\n end",
"def encrypt(string, public_key = nil)\n require_key unless public_key\n\n key = OpenSSL::PKey::RSA.new(public_key || @private_key.public_key.to_pem)\n\n Base64.encode64(key.public_encrypt(string))\n end",
"def encrypt_with_public(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_public(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_public(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt_with_public(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_public(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_public(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt(keystream)\n\t\tencrypted_stream = String.new\n\t\[email protected] do |i|\n\t\t\ta = if keystream[i] % 26 == 0\n\t\t\t\t26\n\t\t\telse\n\t\t\t\tkeystream[i] % 26\n\t\t\tend\n\t\t\tb = string[i].ord - 64\n\t\t\tencrypted_stream << if a + b > 26\n\t\t\t\t((a + b - 26) + 64).chr\n\t\t\telse\n\t\t\t\t((a + b) + 64).chr\n\t\t\tend\n\t\tend\n\t\tencrypted_stream\n\tend",
"def encrypt(bytes, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n\n begin\n encrypt_for_recipients(bytes, Core::VirgilCipher.new, public_keys)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def encrypt_secret(path_to_public_key)\n @public_key = OpenSSL::PKey::RSA.new(File.read(path_to_public_key))\n @public_key.public_encrypt(@secret)\n end",
"def public_encrypt(data)\n Base64.encode64(@key.public_encrypt(data))\n end",
"def encrypt_key(key, public_key)\n encrypted_key = public_key.public_encrypt(key)\n encode encrypted_key\n end",
"def encrypt(text)\n Base64.encode64(@public_key.public_encrypt(text)).gsub(/\\n/, \"\") if text\n end",
"def encrypt(text)\n Base64.encode64(@public_key.public_encrypt(text)).gsub(/\\n/, \"\") if text\n end",
"def encrypt(value)\n if !@private_key.present? && encrypted?(value)\n value\n else\n escape_and_execute_sql([\"SELECT pgp_pub_encrypt(?, dearmor(?))\", value.to_s, @public_key])['pgp_pub_encrypt']\n end\n end",
"def encrypt( data )\n rsa = OpenSSL::PKey::RSA.new( File.read( @public_pem ) )\n\n # encrypt with 256 bit AES with CBC\n aes = OpenSSL::Cipher::Cipher.new( 'aes-256-cbc' )\n aes.encrypt\n\n # use random key and IV\n aes.key = key = aes.random_key\n aes.iv = iv = aes.random_iv\n\n # this will hold all primitives and ciphertext\n primitives = {}\n\n primitives['ciphertext'] = aes.update( data )\n primitives['ciphertext'] << aes.final\n\n primitives['key'] = rsa.public_encrypt( key )\n primitives['iv'] = rsa.public_encrypt( iv )\n\n # serialize everything and base64 encode it\n Base64.encode64( primitives.to_yaml )\n end",
"def initialize(data, public_key = nil, encoding = :none, opts = {})\n @encoding = encoding\n\n if !public_key && !opts[:public_key_file]\n # If no public key was provided the data should already be encrypted\n @data = data\n elsif File.exists?(opts[:public_key_file].to_s)\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n elsif public_key\n public_key = OpenSSL::PKey::RSA.new(public_key)\n encrypted_data = public_key.public_encrypt(data)\n @data = encode(encrypted_data)\n end\n end",
"def encrypt(data)\n\t\t# The limit of the encryption scheme is 235 bytes, so if the string is longer than that we need to limit it\n\t\tif data.length > 234\n\t\t\tdata = data[0..234] + \"\\n\"\n\t\tend\n\n\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/attacker.pub'\n\t\treturn key.public_key.public_encrypt(data)\n\tend",
"def set_ssl_public_key_in_session\n if encryption_required?\n key = OpenSSL::PKey::RSA.new(session[:key] || 1024)\n @public_modulus = key.public_key.n.to_s(16)\n @public_exponent = key.public_key.e.to_s(16)\n session[:key] = key.to_pem\n end\n end",
"def pgp_pub_encrypt(value)\n encode_to_hex Arel::Nodes::NamedFunction.new 'pgp_pub_encrypt',\n [ bind_param(value),\n dearmor(public_key),\n Arel::Nodes::Quoted.new(ENCRYPT_OPTS.map{|k,v| \"#{k}=#{v}\" }.join(',')) ]\n end",
"def run_me\r\n key_strings = create_public_private_rsa_key_pair_strings\r\n public_key_string = key_strings['public_key_string']\r\n public_key_file = 'my-public-key.pem'\r\n private_key_string = key_strings['private_key_string']\r\n private_key_file = 'my-private-key.pem'\r\n content_to_encrypt = 'Hello, World!'\r\n bucket_name = 'doc-example-bucket'\r\n object_key = 'my-file.txt'\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n unless public_private_rsa_key_pair_files_created?(\r\n public_key_string,\r\n public_key_file,\r\n private_key_string,\r\n private_key_file\r\n )\r\n puts 'Program will stop.'\r\n exit 1\r\n end\r\n\r\n encrypted_content = encrypt_and_return_object_content(\r\n public_key_file,\r\n content_to_encrypt\r\n )\r\n puts \"Encrypted representation of '#{content_to_encrypt}' is:\"\r\n puts encrypted_content\r\n\r\n if encrypted_object_uploaded?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n encrypted_content\r\n )\r\n puts 'Uploaded.'\r\n else\r\n puts 'Not uploaded.'\r\n end\r\nend",
"def sign_then_encrypt(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n custom_bytes = cipher.custom_params\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNATURE,\n generate_signature(bytes, private_key)\n )\n\n public_key = extract_public_key(private_key)\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNER_ID,\n wrap_bytes(public_key.id)\n )\n encrypt_for_recipients(bytes, cipher, public_keys)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def urlsafe_base64_asymmetric_encrypt(data, public_key)\n # Load key\n pkey = OpenSSL::PKey::RSA.new(public_key, nil)\n raise 'Invalid public key.' unless pkey.public?\n\n # Encrypt data\n encrypted_data = pkey.public_encrypt(data)\n # Encode encrypted data with custom Encoder\n custom_base64_urlsafe_encode(encrypted_data)\n end",
"def parse_public_keys\n # Convert keys to compressed_hex format for bitcoin-ruby\n @public_keys_hex = @cosigners_nodes.map { |index, key| key.public_key.to_hex }\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def set_public_key\n @public_key = PublicKey.find(params[:id])\n end",
"def encrypt_message plaintext\n key_pair.encrypt plaintext\n end",
"def edit_with_public_keys(&block)\n # Set public key values for view\n set_public_key_values\n\n # Previous routine\n edit_without_public_keys(&block)\n end",
"def update_keys\n public_key = params.require(:public_key)\n private_key = params.require(:private_key)\n salt = params.require(:salt)\n\n # Check if encrypt settings are visible to user.\n groups = current_user.groups.pluck(:name)\n encrypt_groups = SiteSetting.encrypt_groups.split('|')\n raise Discourse::InvalidAccess if !SiteSetting.encrypt_groups.empty? && (groups & encrypt_groups).empty?\n\n # Check if encryption is already enabled (but not changing passphrase).\n old_public_key = current_user.custom_fields['encrypt_public_key']\n if old_public_key && old_public_key != public_key\n return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)\n end\n\n current_user.custom_fields['encrypt_public_key'] = public_key\n current_user.custom_fields['encrypt_private_key'] = private_key\n current_user.custom_fields['encrypt_salt'] = salt\n current_user.save_custom_fields\n\n render json: success_json\n end",
"def encrypt(text_to_encrypt, base64_encode=true)\n encrytped = public_key.public_encrypt(text_to_encrypt)\n base64_encode ? Base64UrlSafe.encode(encrytped) : encrytped\n end",
"def encrypt(keys, plain)\n ::Fernet.generate(keys.last, plain)\n end",
"def public_key\n # Base64 encode without line feeds\n Base64.strict_encode64(public_key_raw)\n end",
"def public_key_params\n params.require(:public_key).permit(:body, :algorithm)\n end",
"def rsa_encrypt_with_private(plain_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_encrypt(plain_string)\n end",
"def rsa_encrypt_with_private(plain_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_encrypt(plain_string)\n end",
"def public_key_params\n params[:public_key]\n end",
"def public_key_params\n params[:public_key]\n end",
"def encrypt(plaintext, rsa_key)\n # Generate a random symmetric key (K1) and use it to generate\n # ciphertext (CT) from our plaintext (PT)\n \n aes = OpenSSL::Cipher::Cipher.new(\"AES-256-CBC\")\n aes.encrypt\n # generate a random IV\n iv = aes.random_iv\n # generate the session key\n session_key = aes.random_key\n # encrypt the payload with session key\n ciphertext = aes.update(plaintext) + aes.final\n \n # Key wrapping: at this point we (A) have CT and K1. The only way\n # to decrypt the CT back to PT is via K1. To securely transfer K1\n # to our receiver (B), we encrypt it with the provided (public) key\n \n # encrypt the session key with the public key\n encrypted_session_key = rsa_key.public_encrypt(session_key)\n \n [ciphertext, iv, encrypted_session_key]\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def set_PublicKey(value)\n set_input(\"PublicKey\", value)\n end",
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def add_public_key_file(path)\n @keys << Net::SSH::KeyFactory.load_public_key(path)\n end",
"def public_key\n public_key_object.to_pem\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def public_key\n OpenSSL::PKey.read(public_to_der)\n end",
"def encrypt_with_private(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_private(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_private(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def encrypt_with_private(plain_text, base64=true)\n crypted = aes_encrypt(plain_text)\n\n if base64\n key = base64_encode(rsa_encrypt_with_private(crypted[:key]))\n data = base64_encode(crypted[:data])\n else\n key = rsa_encrypt_with_private(crypted[:key])\n data = crypted[:data]\n end\n\n {:key => key, :data => data}\n end",
"def transcend_public_key\n connection = Faraday.new() do |conn|\n conn.request :authorization, 'Bearer', $TRANSCEND_API_KEY\n conn.method :get\n end\n response = connection.get($PUBLIC_KEY_URL)\n OpenSSL::PKey.read(response.body)\nend",
"def ssh_public=(key_content)\n @ssh_public_file = temp_file_manager.path('key.pub')\n IO.write(@ssh_public_file, key_content)\n end",
"def private_encrypt(plaintext)\n @private_key.private_encrypt(plaintext)\n end",
"def set_public_key\n @public_key = PublicKey.first || PublicKey.create(body: 'public key body', algorithm: PublicKey::ALGORITHMS.first)\n end",
"def encrypt(plain_text)\n len = plain_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(plain_text.length == 0) || (plain_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = plain_text.scan(/.{8}/m)\n encrypted_blocks = []\n blocks.each do |block|\n encryptedBlock = self.class.encryptBlock(block, @keys)\n encrypted_blocks << encryptedBlock\n end\n output = encrypted_blocks.join\n return output\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def public_rsa\n @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)\n end",
"def export_public_key(public_key)\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n\n begin\n wrap_bytes(\n Core::VirgilKeyPair.public_key_to_der(public_key.raw_key)\n )\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def set_encrypt_messages\n @rsa = Rsa.find(params[:rsa_id])\n end",
"def set_public_key(obj, priv)\n case priv\n when OpenSSL::PKey::EC\n obj.public_key = priv\n when OpenSSL::PKey::RSA\n obj.public_key = priv.public_key\n else\n raise ArgumentError, 'priv must be EC or RSA'\n end\n end",
"def encrypt(plaintext)\n @cipher.encrypt(@secret_key, plaintext)\n end",
"def encrypt(data)\n return nil if !@key\n Base64::encode64(@key.private_encrypt(data)).delete(\"\\n\").strip\n end",
"def encrypt(data)\n pipe_to_stdin command('--encrypt'), data\n end",
"def encrypt(value)\n return unless value\n fail ArgumentError, 'Value is already encrypted' if value.match(REGEXP)\n HEADER + Base64.strict_encode64(@key.public_encrypt(value))\n end",
"def encrypt(str)\n return nil if @key_id.empty?\n # The option --trust-model always omits the requirement for you to type y about trusting this key.\n result = IO.popen(\"gpg --trust-model always -e -a -r #{@key_id}\", \"r+\") do |pipe|\n pipe.write(str)\n pipe.close_write\n pipe.read\n end\n result[/-----BEGIN PGP MESSAGE-----/] ? result : nil\n end",
"def encrypt; end",
"def encode_to(stream)\n ::Protobuf::Encoder.encode(self, stream)\n end",
"def publish\n create_stream unless stream_exists?\n\n kinesis.put_record({\n stream_name: stream_name,\n data: \"Some data with a random number #{rand(100)}\",\n partition_key: \"#{rand(100000)}\",\n })\n end",
"def encrypt(plaintext)\n begin\n ciphertext_blob = client.encrypt_and_sign(plaintext)\n\n success_with_data(\n ciphertext_blob: ciphertext_blob\n )\n rescue Exception => e\n error_with_data('lc_1',\n \"LocalCipher could not encrypt text with message => #{e.message}\",\n 'Something Went Wrong.',\n GlobalConstant::ErrorAction.default,\n {})\n end\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def encrypt(key, message)\n key.public_key? or raise \"Must have public key to encrypt\"\n @cipher.reset\n\n ephemeral_key = OpenSSL::PKey::EC.generate(key.group)\n ephemeral_public_key_octet = ephemeral_key.public_key.to_octet_string(:compressed)\n\n shared_secret = ephemeral_key.dh_compute_key(key.public_key)\n\n key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)\n cipher_key = key_pair.byteslice(0, @cipher.key_len)\n hmac_key = key_pair.byteslice(-@mac_length, @mac_length)\n\n @cipher.encrypt\n @cipher.iv = IV\n @cipher.key = cipher_key\n ciphertext = @cipher.update(message) + @cipher.final\n\n mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)\n\n ephemeral_public_key_octet + ciphertext + mac\n end",
"def update_keys\n public_identity = params.require(:public)\n private_identity = params[:private]\n private_id_label = params[:label]\n\n # Check if encryption is already enabled (but not changing passphrase).\n old_identity = current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]\n if params[:overwrite].blank? && old_identity && old_identity != public_identity\n return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)\n end\n\n current_user.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD] = public_identity\n\n if private_identity.present?\n if private_id_label.present?\n data = JSON.parse(current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD]) rescue {}\n data[private_id_label.downcase] = private_identity\n current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = JSON.dump(data)\n else\n current_user.custom_fields[DiscourseEncrypt::PRIVATE_CUSTOM_FIELD] = private_identity\n end\n end\n\n current_user.save_custom_fields\n\n render json: success_json\n end"
] | [
"0.6866947",
"0.6866947",
"0.68546635",
"0.68318695",
"0.66694975",
"0.65578586",
"0.65578586",
"0.64710706",
"0.64654475",
"0.6457335",
"0.6340315",
"0.6297364",
"0.62039274",
"0.59877986",
"0.59877986",
"0.5960488",
"0.58886224",
"0.587759",
"0.5829395",
"0.5815585",
"0.57852703",
"0.56219184",
"0.5597553",
"0.55402315",
"0.5530094",
"0.550579",
"0.550579",
"0.54908824",
"0.5438934",
"0.5428769",
"0.54179597",
"0.53719705",
"0.532717",
"0.53226197",
"0.53110665",
"0.53110665",
"0.53091425",
"0.53091425",
"0.5293869",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.52516335",
"0.5234441",
"0.52227086",
"0.521336",
"0.52101773",
"0.52101773",
"0.5202519",
"0.5202519",
"0.519431",
"0.5188",
"0.51848215",
"0.5168551",
"0.51439565",
"0.51250815",
"0.51250815",
"0.51250607",
"0.5114583",
"0.5107199",
"0.5081467",
"0.50766313",
"0.50675845",
"0.506061",
"0.5057559",
"0.5056068",
"0.50457007",
"0.5020091",
"0.5019925",
"0.5009192",
"0.4994461",
"0.49926853"
] | 0.85049194 | 0 |
Decrypts the specified stream using Private key. | def decrypt_stream(cipher_stream, output_stream, private_key)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
cipher = Core::VirgilChunkCipher.new
source = VirgilStreamDataSource.new(cipher_stream)
sink = VirgilStreamDataSink.new(output_stream)
cipher.decrypt_with_key(source, sink, private_key.id, private_key.raw_key)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt(keystream)\n\t\tdecrypted_stream = String.new\n\t\[email protected] do |i|\n\t\t\ta = if keystream[i] % 26 == 0\n\t\t\t\t26\n\t\t\telse\n\t\t\t\tkeystream[i] % 26\n\t\t\tend\n\t\t\tb = string[i].ord - 64\n\t\t\tdecrypted_stream << if b - a <= 0\n\t\t\t\t((b - a + 26) + 64).chr\n\t\t\telse\n\t\t\t\t((b - a) + 64).chr\n\t\t\tend\n\t\tend\n\t\tdecrypted_stream\n\tend",
"def decrypt(data)\n raise NoPrivateKeyError, \"Private key file: #{@private_key_file}\" unless private?\n \n decrypted_data = Base64.decode64(data)\n private_rsa.private_decrypt(decrypted_data)\n end",
"def private_decrypt(ciphertext)\n @private_key.private_decrypt(ciphertext)\n end",
"def decrypt(string)\n require_key\n\n @private_key.private_decrypt(Base64.decode64(string))\n end",
"def decrypt(private_key_file, passphrase = nil)\n if File.exists?(private_key_file.to_s)\n private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), passphrase)\n decoded_string = decode(@data)\n private_key.private_decrypt(decoded_string)\n else\n private_key = OpenSSL::PKey::RSA.new(private_key_file, passphrase)\n decoded_string = decode(@data)\n private_key.private_decrypt(decoded_string)\n end\n rescue => e\n $stderr.puts e\n raise Cryptic::KeyNotFound\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_private(crypt_string)\n raise \"No private key set\" unless @private_key\n\n @private_key.private_decrypt(crypt_string)\n end",
"def decrypt(msg, private_key)\n # 1\n rsa_encrypted_aes_key = msg[0..255] # 256 bits\n rsa_encrypted_aes_iv = msg[256..511] # next 256 bits\n aes_encrypted_message = msg[512..msg.length]\n\n # 2\n rsa_decryptor = OpenSSL::PKey::RSA.new private_key\n aes_key = rsa_decryptor.private_decrypt rsa_encrypted_aes_key\n aes_iv = rsa_decryptor.private_decrypt rsa_encrypted_aes_iv\n\n # 3\n decipher = OpenSSL::Cipher::AES256.new(AES_MODE)\n decipher.decrypt\n decipher.key = aes_key\n decipher.iv = aes_iv\n\n decipher.update(aes_encrypted_message) + decipher.final\n end",
"def decrypt()\n \t@private_key = AES.decrypt(self.encrypted_private_key, ENV[\"DECRYPTION_KEY\"])\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def decrypt(text)\n @private_key.private_decrypt(Base64.decode64(text)) if text\n end",
"def decrypt_message ciphertext\n key_pair.decrypt ciphertext\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_private(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_private(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_private(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt(data)\n\t\tbegin\n\t\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/victim.pem'\n\t\t\treturn key.private_decrypt(data)\n\t\trescue\n\t\t\treturn false\n\t\tend\n\tend",
"def decrypt(value)\n return unless value\n fail ArgumentError, 'Value is not encrypted' unless value.match(REGEXP)\n @key.private_decrypt(Base64.strict_decode64(Regexp.last_match(:value)))\n end",
"def decrypt(data, key=nil)\n Crypto.new(key.nil? ? config.key : key).decrypt(data)\n end",
"def decrypt_from_file(secure)\n secure.open('rb') { |s| basic_decrypt(StringIO.new, s).string }\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, password, mtime, &b)\n end",
"def decrypt(data)\n pipe_to_stdin command('--decrypt'), data\n end",
"def decrypt(data)\n @cert_chain[0].public_key.public_decrypt(Base64::decode64(data))\n end",
"def decryptor(io, password, &b)\n Decrypt.open(io, &b)\n end",
"def decrypt_data(data, private_key, iv)\n aes = OpenSSL::Cipher::AES.new(256, :CBC)\n aes.decrypt\n aes.iv = iv\n aes.key = private_key\n aes.update(data) + aes.final\n end",
"def decrypt(passphrase)\n self.user.decrypt(self.encrypted_message, passphrase)\n end",
"def decrypt(cipher_bytes, private_key)\n cipher_bytes = Validation.check_filled_array_argument!(cipher_bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n decrypted_bytes = cipher.decrypt_with_key(\n cipher_bytes,\n private_key.id,\n private_key.raw_key\n )\n wrap_bytes(decrypted_bytes)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def decrypt(value)\n if @private_key.present? && encrypted?(value)\n escape_and_execute_sql([\"SELECT pgp_pub_decrypt(?, dearmor(?), ?)\",\n value, @private_key, @key])['pgp_pub_decrypt']\n else\n value\n end\n end",
"def public_decrypt(data)\n @key.public_decrypt(Base64.decode64(data))\n end",
"def decrypt(data)\n crypto_key.decrypt64(data)\n end",
"def decrypt(ciphertext)\n @cipher.decrypt(@secret_key, ciphertext)\n end",
"def decrypt(msg)\n msg_buf = FFI::MemoryPointer.from_data(msg)\n Botan.call_ffi_with_buffer(lambda { |b, bl|\n LibBotan.botan_pk_op_decrypt(@ptr, b, bl, msg_buf, msg_buf.size)\n })\n end",
"def private_rsa\n if password\n options = {:password => password}\n options[:algorithm] = algorithm if algorithm\n \n private_key = @private_key.decrypt(:symmetric, options)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def _decrypt_packet_internal(keys, data)\n @l.debug(\"Encryptor: Decrypting a #{data.length}-byte packet\")\n # Don't decrypt if we don't have a key set\n# if(@keys[:shared_secret].nil?)\n# return data\n# end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Check if it was truncated\n if(nonce.nil? || nonce.length < 2)\n raise(Error, \"Invalid encrypted packet!\")\n end\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + header + nonce + encrypted_body)\n if(correct_signature[0,6] != signature)\n raise(Error, \"Invalid signature on incoming packet!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n raise(Error, \"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n return header + body\n end",
"def decrypt(data, padding: nil)\n dec = Botan::PK::Decrypt.new(key: self, padding: padding)\n dec.decrypt(data)\n end",
"def public_decrypt(ciphertext)\n @public_key.public_decrypt(ciphertext)\n end",
"def decrypt(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def _decrypt_packet_internal(keys, data)\n # Don't decrypt if we don't have a key set\n if(!ready?(keys))\n @@window.puts(\"Not decrypting data (incoming data seemed to be cleartext): #{data.unpack(\"H*\")}\")\n return data\n end\n\n # Parse out the important fields\n header, signature, nonce, encrypted_body = data.unpack(\"a5a6a2a*\")\n\n # Put together the data to sign\n signed_data = header + nonce + encrypted_body\n\n # Check the signature\n correct_signature = SHA3::Digest::SHA256.digest(keys[:their_mac_key] + signed_data)\n if(correct_signature[0,6] != signature)\n @@window.puts(\"Couldn't verify packet signature!\")\n raise(Encryptor::Error, \"Invalid signature!\")\n end\n\n # Check the nonce *after* checking the signature (otherwise, we might update the nonce to a bad value and Bad Stuff happens)\n nonce_int = nonce.unpack(\"n\").pop()\n if(nonce_int < keys[:their_nonce])\n @@window.puts(\"Client tried to use an invalid nonce: #{nonce_int} < #{keys[:their_nonce]}\")\n raise(Encryptor::Error, \"Invalid nonce!\")\n end\n keys[:their_nonce] = nonce_int\n\n # Decrypt the body\n body = Salsa20.new(keys[:their_write_key], nonce.rjust(8, \"\\0\")).decrypt(encrypted_body)\n\n #@@window.puts(\"Decryption successful\")\n return header+body\n end",
"def decrypt(password = nil, salt = nil)\n Hoodie::Crypto.decrypt(self, password, salt)\n end",
"def decrypt(data, key = nil, iv = nil)\n key ||= @request[:secret]\n iv ||= @request[:iv]\n\n @cipher.decrypt\n @cipher.key = key\n @cipher.iv = iv\n\n @cipher.update(data)\n end",
"def decrypt_file(keyphrase)\n # Open input file\n file_in_handle = open_in_file @file_in_path\n file_in_handle.seek FILE_HEADER_BYTES\n\n # Convert key in binary\n keyphrase_bin = [keyphrase].pack('H*')\n crypto = Mcrypt.new(:'blowfish-compat', :ecb, keyphrase_bin)\n\n # Open output file and begin with decryption\n file_out_handle = open_out_file @file_out_path\n begin\n while (data = file_in_handle.readpartial(BUFFER_SIZE))\n if data.length < BUFFER_SIZE\n # End of data\n # Write decrypted blocks\n last_block_size = data.length - (data.length % 8)\n file_out_handle.write(crypto.decrypt(data[0...last_block_size]))\n # Write padding unencrypted\n file_out_handle.write(data[last_block_size..-1])\n else\n # Full block read\n file_out_handle.write(crypto.decrypt(data))\n end\n end\n rescue EOFError\n # Okay, read to the end\n ensure\n file_in_handle.close\n file_out_handle.close\n end\n end",
"def decrypt(message, hash: nil)\n # 0\n message = Base64.decode64(message)\n hmac = message[0..63] # 64 bits of hmac signature\n\n case\n when hash && hmac != hash\n raise Error, \"Provided hash mismatch for encrypted file!\"\n when hmac != hmac_signature(message[64..-1])\n raise Error, \"HMAC signature mismatch for encrypted file!\"\n end\n\n # 1\n rsa_encrypted_aes_key = message[64..319] # next 256 bits\n rsa_encrypted_aes_iv = message[320..575] # next 256 bits\n aes_encrypted_message = message[576..-1]\n\n # 2\n aes_key = @rsa.private_decrypt rsa_encrypted_aes_key\n aes_iv = @rsa.private_decrypt rsa_encrypted_aes_iv\n\n # 3\n @cipher.reset\n @cipher.decrypt\n @cipher.key = aes_key\n @cipher.iv = aes_iv\n content = @cipher.update(aes_encrypted_message) + @cipher.final\n\n { signature: hmac, content: content }\n rescue OpenSSL::OpenSSLError => e\n raise Error.new(e.message)\n end",
"def decrypt(key, encrypted_message)\n key.private_key? or raise \"Must have private key to decrypt\"\n @cipher.reset\n\n ephemeral_public_key_length = key.group.generator.to_octet_string(:compressed).bytesize\n ciphertext_length = encrypted_message.bytesize - ephemeral_public_key_length - @mac_length\n ciphertext_length > 0 or raise OpenSSL::PKey::ECError, \"Encrypted message too short\"\n\n ephemeral_public_key_octet = encrypted_message.byteslice(0, ephemeral_public_key_length)\n ciphertext = encrypted_message.byteslice(ephemeral_public_key_length, ciphertext_length)\n mac = encrypted_message.byteslice(-@mac_length, @mac_length)\n\n ephemeral_public_key = OpenSSL::PKey::EC::Point.new(key.group, OpenSSL::BN.new(ephemeral_public_key_octet, 2))\n\n shared_secret = key.dh_compute_key(ephemeral_public_key)\n\n key_pair = kdf(shared_secret, @cipher.key_len + @mac_length, ephemeral_public_key_octet)\n cipher_key = key_pair.byteslice(0, @cipher.key_len)\n hmac_key = key_pair.byteslice(-@mac_length, @mac_length)\n\n computed_mac = OpenSSL::HMAC.digest(@mac_digest, hmac_key, ciphertext + @mac_shared_info).byteslice(0, @mac_length)\n computed_mac == mac or raise OpenSSL::PKey::ECError, \"Invalid Message Authenticaton Code\"\n\n @cipher.decrypt\n @cipher.iv = IV\n @cipher.key = cipher_key\n\n @cipher.update(ciphertext) + @cipher.final\n end",
"def decrypt(x)\n @aes_key.decrypt(x)\n end",
"def decrypt(data)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n cipher.key = @passphrase\n cipher.iv = @iv\n decrypted = cipher.update(data)\n decrypted << cipher.final\n json = JSON.parse(decrypted)\n self.identifier = json['identifier']\n @expiry = Time.parse(json['expiry'])\n rescue OpenSSL::Cipher::CipherError => e\n raise Kennedy::BadTicketException, \"Given data was not decryptable\"\n end",
"def decrypt!(data, options = {})\n unless options.has_key?(:secret)\n options[:secret] = PreciousCargo::Secret.decrypt!(options)\n end\n\n PreciousCargo::Data.decrypt!(data, options)\n end",
"def decrypt!(encrypted_data, options = {})\n secret = options[:secret]\n cipher = Gibberish::AES.new(secret)\n cipher.decrypt(encrypted_data).strip\n end",
"def decrypt(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to decrypt data with.\") unless key\n options = settings[:crypt].merge(options)\n decoded_data = decode(data, options)\n decrypted_data = crypt(:decrypt, decoded_data, key, options)\n return data unless decrypted_data\n begin\n JSON.parse(decrypted_data)\n rescue JSON::ParserError\n decrypted_data\n end\n end",
"def decrypt encrypted_data, key, iv, cipher_type\n aes = OpenSSL::Cipher::Cipher.new cipher_type\n aes.decrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final \n end",
"def decrypt(*args, &block)\n crypt :decrypt, *args, &block\n end",
"def decrypt_data(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.padding = 0\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end",
"def decrypt(message)\n xcrypt(:decrypt, message)\n rescue OpenSSL::Cipher::CipherError\n raise CipherError, 'invalid password'\n end",
"def decrypt(string)\n d_salt, d_iv, ciphertext = p_unpack_string(\n string,\n profile.key_len,\n profile.iv_len,\n profile.salt_bytes\n )\n p_decrypt_string(ciphertext, key(d_salt), d_iv, profile.algorithm)\n end",
"def decrypt(ciphertext, passwd, options = {})\n iv_and_ciphertext = Base64.decode64(ciphertext)\n cipher = new_cipher(:decrypt, passwd, options)\n cipher.iv, ciphertext = iv_and_ciphertext(cipher, iv_and_ciphertext)\n plaintext = cipher.update(ciphertext)\n plaintext << cipher.final\n plaintext\n end",
"def decrypt!(cipher, options={})\n opt = { salt: '', parse: true }.merge!(options)\n\n set_crypto cipher, opt[:intmode]\n iv = compute_iv_for_decrypting(force_binary(opt[:salt]), self[:content])\n\n if authenticated?\n if @icv_length.zero?\n @icv_length = opt[:icv_length].to_i if opt[:icv_length]\n raise PacketGen::ParseError, 'unknown ICV size' if @icv_length.zero?\n end\n icv = self[:content].slice!(-@icv_length, @icv_length)\n end\n\n authenticate_if_needed iv, icv\n private_decrypt opt\n end",
"def decrypt(ciphertext, options = {})\n # TODO\n end",
"def decrypt!(private_key = '', passphrase = '')\n return true if !encrypted?\n\n private_key = private_key.to_s\n passphrase = passphrase.to_s\n\n if private_key.empty?\n private_key = CreditCard.private_key.to_s\n end\n\n if passphrase.empty?\n passphrase = CreditCard.passphrase.to_s\n end\n\n if private_key.empty? || passphrase.empty?\n return false\n end\n\n # Is there a way to pass an ASCII armored secret key filename to GPG\n # directly?\n #\n # Couldn't find one, so we must set up temporary GPG staging area\n tmpdir = Dir.mktmpdir\n\n data = ''\n begin\n gpg_import_private_key!(tmpdir, private_key)\n data = gpg_decrypt!(tmpdir, number, passphrase)\n\n # Remove tmpdir\n Kernel.system(\"rm -rf \" + tmpdir)\n\n if data && !data.empty?\n self.number = data\n\n return true\n end\n rescue Exception => e\n # Remove tmpdir\n Kernel.system(\"rm -rf \" + tmpdir)\n end\n\n false\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def rsa_decrypt_with_public(crypt_string)\n raise \"No public key set\" unless @public_key\n\n @public_key.public_decrypt(crypt_string)\n end",
"def decrypt(data, passphrase)\n cipher = OpenSSL::Cipher::Cipher.new(\"aes-256-cbc\")\n cipher.decrypt\n\n cipher.key = Digest::SHA256.digest(passphrase)\n cipher.iv = obtain_iv(passphrase)\n\n decrypted = cipher.update(data)\n decrypted << cipher.final\n\n rsize = decrypted[0]\n return decrypted[rsize + 1..-1]\n rescue\n return nil\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt_with_public(crypted, base64=true)\n raise \"Crypted data should include a key\" unless crypted.include?(:key)\n raise \"Crypted data should include data\" unless crypted.include?(:data)\n\n if base64\n key = rsa_decrypt_with_public(base64_decode(crypted[:key]))\n aes_decrypt(key, base64_decode(crypted[:data]))\n else\n key = rsa_decrypt_with_public(crypted[:key])\n aes_decrypt(key, crypted[:data])\n end\n end",
"def decrypt(data, password = nil)\n data = Base64.strict_decode64(data) if @base64\n\n salt = data[0, @salt_len]\n iv = data[@salt_len, @iv_len]\n ciphertext = data[@salt_len + @iv_len..-@mac_len - 1]\n mac = data[data.length - @mac_len, @mac_len]\n\n aes_key, mac_key = keys(salt, password)\n verify(iv + ciphertext, mac, mac_key)\n\n aes = cipher(aes_key, iv, false)\n plaintext = aes.update(ciphertext) + aes.final\n plaintext\n rescue TypeError, ArgumentError, NoMethodError => e\n error_handler e\n rescue OpenSSL::OpenSSLError => e\n error_handler e\n end",
"def decrypt(str)\n str = str.unpack('m0').first\n aes = OpenSSL::Cipher::Cipher.new('aes-128-cbc').decrypt\n aes.key = @secret\n iv = str[0, aes.iv_len]\n aes.iv = iv\n crypted_text = str[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end",
"def decrypt_encrypted_package_stream(encrypted_package, key)\n # Get the length of the real data in the cleartext (which may be shorter\n # than the full decrypted ciphertext)\n final_length = encrypted_package[0,8].unpack(\"Q<\").first\n # The rest of the encrypted package is the ciphertext\n ciphertext = encrypted_package[8..-1]\n\n chunk_size = 4096\n ciphertext_chunks = (0..(ciphertext.length-1)/chunk_size).map{|i| ciphertext[i*chunk_size, chunk_size]}\n\n plaintext = \"\"\n ciphertext_chunks.each_with_index do |ciphertext_chunk, index|\n iv = hash(@salt + [index].pack(\"V\"))\n iv.pad_or_trim!(@block_size)\n\n plaintext += decrypt(ciphertext_chunk, key, iv)\n end\n\n return plaintext[0,final_length]\n end",
"def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end",
"def decrypt(content_entry, cipher)\n # Zip::Entry.extract writes a 0-length file when trying\n # to extract an encrypted stream, so we read the\n # raw bytes based on the offset and lengths\n decrypted = ''\n File.open(@filename, 'rb') do |zipfile|\n zipfile.seek(\n content_entry.local_header_offset +\n content_entry.calculate_local_header_size\n )\n total_to_read = content_entry.compressed_size\n\n block_size = 4096\n block_size = total_to_read if block_size > total_to_read\n\n while (buffer = zipfile.read(block_size))\n decrypted += cipher.update(buffer)\n total_to_read -= buffer.length\n\n break if total_to_read == 0\n\n block_size = total_to_read if block_size > total_to_read\n end\n end\n\n decrypted + cipher.final\n end",
"def decrypt(encrypted_string)\n CRYPTO.decrypt_string(encrypted_string.decode64)\nend",
"def decrypt_data(encrypted, &decrypted)\n injected = @engine.inject encrypted\n\n unless injected\n exit -1\n end\n\n read_data = []\n\n begin\n while(read_chunk = @engine.read)\n read_data << read_chunk\n end\n rescue Exception => e\n unless @engine.state == 'SSLOK '\n raise e\n end\n end\n\n if block_given? then\n read_data.each do |data|\n decrypted.call data\n end\n else\n read_data.join\n end\n end",
"def decrypt(value)\n encryptor.decrypt_and_verify(value)\n end",
"def decrypt(provider)\n raise Yasst::Error::AlreadyDecrypted,\n 'File is already decrypted' unless encrypted?\n @encrypted = false\n replace(provider.decrypt(to_s))\n end",
"def decode_openssh_private_key(raw)\n total_read = 0\n\n magic = raw.byteslice(total_read, OPENSSH_PRIVATE_KEY_MAGIC.bytesize)\n unless magic == OPENSSH_PRIVATE_KEY_MAGIC\n raise DecodeError, \"bad OpenSSH private key\"\n end\n total_read += OPENSSH_PRIVATE_KEY_MAGIC.bytesize\n\n data, read = decode_fields(raw, OPENSSH_PRIVATE_KEY_FIELDS, total_read)\n total_read += read\n\n # TODO: add support for encrypted private keys\n unless data[:ciphername] == \"none\" && data[:kdfname] == \"none\"\n raise DecryptError, \"cannot decode encrypted private keys\"\n end\n\n data[:public_keys], read = decode_n_strings(raw, total_read, data[:nkeys])\n total_read += read\n\n privs, read = decode_string(raw, total_read)\n total_read += read\n\n privs_read = 0\n\n data[:checkint1], read = decode_uint32(privs, privs_read)\n privs_read += read\n\n data[:checkint2], read = decode_uint32(privs, privs_read)\n privs_read += read\n\n unless data[:checkint1] == data[:checkint2]\n raise DecryptError, \"bad private key checksum\"\n end\n\n data[:private_keys] = data[:nkeys].times.map do\n algo, read = decode_string(privs, privs_read)\n privs_read += read\n\n unless fields = KEY_FIELDS_BY_PRIVATE_KEY_ALGO[algo]\n raise AlgorithmError, \"unknown algorithm: #{algo.inspect}\"\n end\n\n priv_data, read = decode_fields(privs, fields, privs_read)\n privs_read += read\n\n comment, read = decode_string(privs, privs_read)\n privs_read += read\n\n priv_data.merge(algo: algo, comment: comment)\n end\n\n # padding at end is bytes 1, 2, 3, 4, etc...\n data[:padding] = privs.byteslice(privs_read..-1)\n unless data[:padding].bytes.each_with_index.all? { |b, i| b == (i + 1) % 255 }\n raise DecodeError, \"bad padding: #{data[:padding].inspect}\"\n end\n\n [data, total_read]\n end",
"def decipher(key, user_iv, text)\n ssl_decipher = OpenSSL::Cipher.new('AES-256-CBC')\n ssl_decipher.decrypt\n ssl_decipher.key = key\n ssl_decipher.iv = user_iv\n ssl_decipher.update(text) + ssl_decipher.final\n end",
"def decrypt\n self.class.decrypt(@encrypted_name, @id)\n end",
"def decrypt_byte\n temp = (@key2 | 2) & 0x0000ffff\n ((temp * (temp ^ 1)) >> 8) & 0x000000ff\n end",
"def private_rsa\n if @key\n private_key = @private_key.decrypt(:symmetric, :key => @key, :algorithm => @algorithm)\n OpenSSL::PKey::RSA.new(private_key)\n else\n @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)\n end\n end",
"def decrypt(msg)\n msg = Bytes.new(msg) unless msg.is_a?(Bytes)\n\n @cipher.decrypt\n @cipher.padding = 0\n @cipher.key = @key.ascii\n\n ptext = []\n (0..msg.length/BLOCK_SZ - 1).each do |block_i|\n block = msg.slice(block_i*BLOCK_SZ, BLOCK_SZ)\n\n dec = Bytes.new(@cipher.update(block.ascii) + @cipher.final)\n dec ^= @state\n ptext << dec\n\n @state = block\n end\n\n ptext = ptext.reduce(:concat)\n\n # Strip off padding.\n Bytes.new(ptext.reject { |b| b == ptext[-1] })\n end",
"def decipher\r\n aes = OpenSSL::Cipher::AES.new(128, :CBC)\r\n aes.decrypt\r\n aes.key = key\r\n aes.iv = iv\r\n return aes\r\n end",
"def decrypt_pin(msg)\n msg = Base64.strict_decode64 msg\n iv = msg[0..15]\n cipher = msg[16..47]\n aes_key = JOSE::JWA::PKCS1.rsaes_oaep_decrypt('SHA256', pin_token, private_key, session_id)\n alg = 'AES-256-CBC'\n decode_cipher = OpenSSL::Cipher.new(alg)\n decode_cipher.decrypt\n decode_cipher.iv = iv\n decode_cipher.key = aes_key\n decoded = decode_cipher.update(cipher)\n decoded[0..5]\n end",
"def decrypt(ciphertext)\n ciphertext = ciphertext.unpack('m').first\n tag = ciphertext[0, hmac_length]\n ciphertext = ciphertext[hmac_length..-1]\n\n # make sure we actually had enough data for the tag too.\n if tag && ciphertext && verify_message(tag, ciphertext)\n decrypt_ciphertext(ciphertext)\n else\n nil\n end\n end",
"def decrypt\n self\n end",
"def decrypt data, key, salt, iter, iv, key_length = 32\n decipher = OpenSSL::Cipher.new \"AES-256-CBC\"\n decipher.decrypt\n decipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, iter, key_length)\n decipher.iv = iv\n decipher.update(data) + decipher.final\n end",
"def decrypt(data)\n\tarray = splitdencrypt(data)\n\tdecryptedBlock = ''\n\tfor i in 0...array.length\n\t val = array[i]\n\t decryptedBlock << @blowfish.decrypt_block([val].pack('H*'))\n\tend\n\treturn decryptedBlock\n end",
"def decrypt phrase, key\n decrypt = encrypt phrase, key\n return decrypt\nend",
"def decrypt(encrypted_text)\n len = encrypted_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(encrypted_text.length == 0) || (encrypted_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = encrypted_text.scan(/.{8}/m)\n decrypted_blocks = []\n blocks.each do |block|\n decryptedBlock = self.class.decryptBlock(block, @keys)\n decrypted_blocks << decryptedBlock\n end\n output = decrypted_blocks.join\n return output\n end",
"def set_decrypt_messages\n @rsa = Rsa.find(params[:rsa_id])\n end",
"def set_decrypt_messages\n @rsa = Rsa.find(params[:rsa_id])\n end",
"def decrypt\r\n\t \r\n\t \tif @IV.empty?\r\n\t\t\t_iv = OpenSSL::Cipher::Cipher.new(\"aes-#{ @cipher }-#{ @mode }\").random_iv\r\n\t\telse\r\n\t\t\t_iv= @IV\r\n\t\tend\r\n\t\t\r\n\t\tEncryptor.default_options.merge!(:algorithm => \"aes-#{ @cipher }-#{ @mode }\", :key => @key, :iv => _iv)\t\t\r\n\t\t_rt = Encryptor.decrypt(Base64.decode64(@data))\r\n\t\t\t\r\n\t\treturn _rt\r\n\t\t\t\r\n\t end",
"def decrypt; end",
"def decrypt\n self\n end",
"def decrypt(data)\n data = remove_noise(data)\n # The first 32 bytes of the data is the original IV\n iv = data[0..31]\n cipher = FirebugMcrypt.new(:rijndael_256, :cbc, @key, iv, :zeros)\n cipher.decrypt(data[32..-1])\n end",
"def decrypt( string, pass, salt)\n key, iv = derive_key_iv( pass, salt)\n \n decipher = OpenSSL::Cipher::AES.new(256, :CBC)\n decipher.decrypt\n decipher.key = key\n decipher.iv = iv\n\n decipher.update( string) + decipher.final\n end",
"def decrypt(encrypted_str)\n return encrypted_str unless encrypted_str.is_a?(String) && @derived_key\n return encrypted_str unless encrypted_str.start_with?(ENCRYPTED_PREFIX)\n\n decrypt_str = encrypted_str[ENCRYPTED_PREFIX.length..-1]\n params = decode_aes(decrypt_str)\n\n cipher = OpenSSL::Cipher.new(CIPHER).decrypt\n\n cipher.key = @derived_key\n cipher.iv = params.nonce\n cipher.auth_tag = params.auth_tag\n cipher.auth_data = \"\"\n\n decoded_str = cipher.update(params.data) + cipher.final\n\n # force to utf-8 encoding. We already ensured this when we encoded in the first place\n decoded_str.force_encoding(Encoding::UTF_8)\n end",
"def decrypt64(str)\n dec = ''\n str = Base64.decode64(str)\n while str.length != 0\n dec += self.private_decrypt(str[0..self.decrypt_block_size])\n str = str[self.decrypt_block_size+1..-1] if str.length > self.decrypt_block_size\n end\n dec\n end",
"def decrypt(data)\n return nil if data.to_s.empty?\n\n password =\n if /^(1\\.[0-9.]+|2\\.0)(\\.[0-9]+)?/ =~ GPGME::Engine.info.first.version || @pinmode\n { password: @gpg_pass }\n else\n { password: @gpg_pass,\n pinentry_mode: GPGME::PINENTRY_MODE_LOOPBACK }\n end\n\n crypto = GPGME::Crypto.new(armor: true)\n crypto\n .decrypt(data, password)\n .read.force_encoding('utf-8')\n rescue => e\n raise \"#{I18n.t('error.gpg_file.decrypt')}\\n#{e}\"\n end",
"def private_key\n @private_key ||= case private_key_type\n when 'p12'\n OpenSSL::PKCS12.new(private_key_string, private_key_password).key\n else\n OpenSSL::PKey::RSA.new(private_key_string, private_key_password)\n end if private_key_string\n end",
"def unlock(str)\n str = str.unpack('m0').first\n aes = cipher.decrypt\n aes.key = @key.size > 32 ? @key[0..31] : @key\n iv = str[0, aes.iv_len]\n aes.iv = iv\n crypted_text = str[aes.iv_len..-1]\n return nil if crypted_text.nil? || iv.nil?\n aes.update(crypted_text) << aes.final\n rescue\n nil\n end",
"def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end",
"def decrypt_jwe(body)\n key = OpenSSL::PKey::RSA.new File.read @private_key\n JWE.decrypt(body, key)\n end",
"def load_private_key\n @private_rsa = nil\n \n if private_key_file && File.file?(private_key_file)\n @private_key = File.read(private_key_file)\n end\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end"
] | [
"0.69801337",
"0.68589413",
"0.66194046",
"0.6616936",
"0.64834505",
"0.6472006",
"0.6472006",
"0.6417519",
"0.63320905",
"0.631232",
"0.631232",
"0.6243049",
"0.6159586",
"0.6159586",
"0.6146012",
"0.60956144",
"0.60793203",
"0.606548",
"0.60199994",
"0.59886336",
"0.597278",
"0.5956471",
"0.59375197",
"0.590293",
"0.5883887",
"0.5871144",
"0.58256346",
"0.58042717",
"0.57760876",
"0.5726695",
"0.5661968",
"0.5647983",
"0.5613283",
"0.5599626",
"0.5577999",
"0.5559878",
"0.55553365",
"0.5528024",
"0.5522642",
"0.5502325",
"0.54913235",
"0.5474021",
"0.5468377",
"0.5441955",
"0.54394877",
"0.54363054",
"0.54335874",
"0.54242504",
"0.5411782",
"0.5411212",
"0.5386388",
"0.53860205",
"0.5383055",
"0.53821826",
"0.5368134",
"0.53265667",
"0.53265667",
"0.53235453",
"0.5323175",
"0.5323175",
"0.5314013",
"0.5309675",
"0.5278245",
"0.52646226",
"0.52614707",
"0.5252828",
"0.5243918",
"0.52347815",
"0.5228895",
"0.52280354",
"0.52252054",
"0.52227694",
"0.5217576",
"0.52126354",
"0.52111465",
"0.5195675",
"0.5194064",
"0.5187044",
"0.5183517",
"0.5176742",
"0.5164389",
"0.5159301",
"0.5153819",
"0.5150787",
"0.5150787",
"0.5144902",
"0.5143296",
"0.51353794",
"0.5117911",
"0.5112238",
"0.510963",
"0.51084876",
"0.5105627",
"0.5102849",
"0.51024073",
"0.5101189",
"0.51006734",
"0.5065057",
"0.50578",
"0.50578"
] | 0.81989044 | 0 |
Signs the specified stream using Private key. | def generate_stream_signature(input_stream, private_key)
private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)
begin
native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)
signer = Core::VirgilStreamSigner.new(native_algorithm)
source = VirgilStreamDataSource.new(input_stream)
wrap_bytes(signer.sign(source, private_key.raw_key))
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(private_key)\n # Our multiline hash for authorization will be encoded in multiple header\n # lines - X-Ops-Authorization-1, ... (starts at 1, not 0!)\n header_hash = {\n \"X-Ops-Sign\" => SIGNING_DESCRIPTION,\n \"X-Ops-Userid\" => user_id,\n \"X-Ops-Timestamp\" => canonical_time,\n \"X-Ops-Content-Hash\" => hashed_body,\n }\n\n string_to_sign = canonicalize_request\n signature = Base64.encode64(private_key.private_encrypt(string_to_sign)).chomp\n signature_lines = signature.split(/\\n/)\n signature_lines.each_index do |idx|\n key = \"X-Ops-Authorization-#{idx + 1}\"\n header_hash[key] = signature_lines[idx]\n end\n \n Mixlib::Authentication::Log.debug \"String to sign: '#{string_to_sign}'\\nHeader hash: #{header_hash.inspect}\"\n \n header_hash\n end",
"def sign(params)\n string = params_to_string(params)\n\n case @sign_type\n when 'RSA'\n ::Alipay::Sign::RSA.sign(@app_private_key, string)\n when 'RSA2'\n ::Alipay::Sign::RSA2.sign(@app_private_key, string)\n else\n raise \"Unsupported sign_type: #{@sign_type}\"\n end\n end",
"def sign(t_outputs)\n # binding.pry\n Base64.encode64(private_key.sign(OpenSSL::Digest::SHA256.new, t_outputs.to_json))\n end",
"def sign(message, private_key)\n msg_point = BLS.norm_p2h(message)\n msg_point * BLS.normalize_priv_key(private_key)\n end",
"def sign( identity, data )\n info = find_identity( identity )\n\n if info[:key].nil? && info[:from] == :file\n begin\n info[:key] = @keys.load_private_key( info[:file] )\n rescue Exception => e \n raise UserKeyManagerError,\n \"the given identity is known, \" +\n \"but the private key could not be loaded \" +\n \"(#{e.message} [#{e.class}])\"\n end\n end\n\n if info[:key]\n sig_blob = @buffers.writer\n sig_blob.write_string identity.ssh_type\n sig_blob.write_string info[:key].ssh_do_sign( data.to_s )\n return sig_blob.to_s\n end\n\n if info[:from] == :agent\n raise UserKeyManagerError,\n \"the agent is no longer available\" unless @agent\n return @agent.sign( identity, data.to_s )\n end\n\n raise UserKeyManagerError,\n \"[BUG] can't determine identity origin (#{info.inspect})\"\n end",
"def verify_stream_signature(signature, input_stream, signer_public_key)\n signature = Validation.check_filled_array_argument!(signature)\n signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilStreamSigner.new(native_algorithm)\n source = VirgilStreamDataSource.new(input_stream)\n signer.verify(source, signature, signer_public_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def sign(private_key, chain_id)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(Chains.to_v(recovery_id, chain_id))\n result.pack('c*')\n end",
"def chunk_signed_stream req, key\n args = []\n args << req.body_stream\n args << req.headers['x-amz-decoded-content-length'].to_i\n args << key\n args << key_path(req.headers['x-amz-date'])\n args << req.headers['x-amz-date']\n args << req.headers['authorization'].split('Signature=')[1]\n ChunkSignedStream.new(*args)\n end",
"def sign(string)\n @key.sign OpenSSL::Digest::SHA256.new, string\n end",
"def sign data\n return unless @key\n\n @key.sign @digest_algorithm.new, data\n end",
"def sign!\n @signed_date_time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')\n @signature = Cybersource::Security.generate_signature(signed_data)\n\n self\n end",
"def to_signed_tx(private_key)\n sign_tx to_raw_tx, private_key\n end",
"def sign(data)\n @key.sign(@algo.new, data)\n end",
"def sign(key, string)\n SSL.new(nil, key).sign(string, true)\n end",
"def sign!(request,options = {})\n consumer.sign!(request,self,options)\n end",
"def sign!(request, options = {})\n consumer.sign!(request, self, options)\n end",
"def decrypt_stream(cipher_stream, output_stream, private_key)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n begin\n cipher = Core::VirgilChunkCipher.new\n source = VirgilStreamDataSource.new(cipher_stream)\n sink = VirgilStreamDataSink.new(output_stream)\n cipher.decrypt_with_key(source, sink, private_key.id, private_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def generate_signature(bytes, private_key)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilSigner.new(native_algorithm)\n wrap_bytes(signer.sign(bytes, private_key.raw_key))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sign(data)\n if rsa?\n @priv.sign(OpenSSL::Digest::SHA1.new,data)\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @priv.sign(OpenSSL::Digest::DSS1.new,data)\n raise StandardError, 'DSA is not supported'\n end\n end",
"def sign(message, privkey)\n group = ECDSA::Group::Secp256k1\n digest = Digest::SHA256.digest(message)\n signature = nil\n while signature.nil?\n temp_key = 1 + SecureRandom.random_number(group.order - 1)\n signature = ECDSA.sign(group, privkey.to_i(16), digest, temp_key)\n return ECDSA::Format::SignatureDerString.encode(signature).unpack(\"H*\").first\n end\n end",
"def sign\n url.query = url.query.to_s + \"&Signature=#{Utils.encode signature}\"\n self\n end",
"def sign(message); end",
"def aws_sign(key, data)\n OpenSSL::HMAC.digest(\"SHA256\", key, data)\n end",
"def verify_signature\n @spki.verify(public_key)\n end",
"def rsaes_pkcs_signature(key, input)\n private_key = if BSON::Environment.jruby?\n # JRuby cannot read DER format, we need to convert key into PEM first.\n key_pem = [\n \"-----BEGIN PRIVATE KEY-----\",\n Base64.strict_encode64(Base64.decode64(key)).scan(/.{1,64}/),\n \"-----END PRIVATE KEY-----\",\n ].join(\"\\n\")\n OpenSSL::PKey::RSA.new(key_pem)\n else\n OpenSSL::PKey.read(Base64.decode64(key))\n end\n private_key.sign(OpenSSL::Digest::SHA256.new, input)\n end",
"def sign_block(key_private, timestamp)\r\n # RSA Encryption (Formula: C = M^d mod n)\r\n timestamp = timestamp.to_i % key_private[1].to_i\r\n signature = timestamp.to_bn.mod_exp(key_private[0],key_private[1])\r\n return signature\r\nend",
"def encrypt_stream(input_stream, cipher_stream, *public_keys)\n begin\n cipher = Core::VirgilChunkCipher.new\n public_keys.each do |public_key|\n public_key = Validation.check_type_argument!(VirgilPublicKey, public_key)\n cipher.add_key_recipient(public_key.id, public_key.raw_key)\n end\n source = VirgilStreamDataSource.new(input_stream)\n sink = VirgilStreamDataSink.new(cipher_stream)\n cipher.encrypt(source, sink)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sign!(key, sign_nonce = T.unsafe(nil)); end",
"def sign_key; end",
"def sign(string, base64=false)\n sig = @private_key.sign(OpenSSL::Digest.new(\"SHA1\"), string)\n\n base64 ? base64_encode(sig) : sig\n end",
"def signature\n subject = self.class.sig_subject([@payload,\n DATA_TYPE,\n ENCODING,\n ALGORITHM])\n @rsa_pkey.sign(DIGEST, subject)\n end",
"def sign(data, key, options = {})\n raise KeyError.new(\"Please provide a secret key to sign data with.\") unless key\n options = settings[:sign].merge(options)\n digest = OpenSSL::Digest.new(options[:algorithm])\n signature = OpenSSL::HMAC.digest(digest, key, data)\n encode(signature, options)\n end",
"def sign_then_encrypt(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n custom_bytes = cipher.custom_params\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNATURE,\n generate_signature(bytes, private_key)\n )\n\n public_key = extract_public_key(private_key)\n custom_bytes.set_data(\n CUSTOM_PARAM_KEY_SIGNER_ID,\n wrap_bytes(public_key.id)\n )\n encrypt_for_recipients(bytes, cipher, public_keys)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sign( key, data )\n blob = @buffers.writer\n blob.write_key key\n\n packet_data = @buffers.writer\n packet_data.write_string blob.to_s\n packet_data.write_string data.to_s\n packet_data.write_long 0\n\n type, reply = send_with_reply SSH2_AGENT_SIGN_REQUEST, packet_data\n if agent_failed( type )\n raise AgentError,\n \"agent could not sign data with requested identity\"\n elsif type != SSH2_AGENT_SIGN_RESPONSE\n raise AgentError, \"bad authentication response #{type}\"\n end\n\n return reply.read_string\n end",
"def save!(private_key)\n bitcoin.sendrawtransaction to_signed_tx(private_key)\n end",
"def get_secure_signature(message)\n digest = OpenSSL::Digest.new('SHA256')\n Base64.strict_encode64(private_key.sign(digest, message))\n end",
"def sign(message)\n Ed25519.provider.sign(@keypair, message)\n end",
"def sign(data, padding: nil, rng: Botan::RNG.new)\n sign = Botan::PK::Sign.new(key: self, padding: padding)\n sign << data\n sign.finish(rng)\n end",
"def sign(path)\n status \"Signing #{File.basename(path)} ...\"\n\n run 'gpg', '--sign', '--detach-sign', '--armor', path\n end",
"def sign(data)\n key.dsa_sign_asn1(data)\n end",
"def sign(wallet)\n tx = Arweave::Transaction.new(data: @commit.message.to_s)\n @commit.to_tags.each do |name, value|\n tx.add_tag(name: name, value: value)\n end\n tx.sign(wallet)\n end",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def signing_request\n req = OpenSSL::X509::Request.new\n req.public_key = key.public_key\n req.subject = OpenSSL::X509::Name.new([['CN', domain]])\n req.sign(key, OpenSSL::Digest::SHA256.new)\n end",
"def sign_request(options)\n options.merge!(:pub => @api_key)\n options.merge!(:key => Digest::MD5.hexdigest(@api_secret + @api_key))\n end",
"def sign()\n # TODO\n end",
"def sign!(options = {})\n binary_security_token_node if options[:security_token]\n x509_data_node if options[:issuer_serial]\n\n if options[:inclusive_namespaces]\n c14n_method_node = signed_info_node.at_xpath('ds:CanonicalizationMethod', ds: 'http://www.w3.org/2000/09/xmldsig#')\n inclusive_namespaces_node = Nokogiri::XML::Node.new('ec:InclusiveNamespaces', document)\n inclusive_namespaces_node.add_namespace_definition('ec', c14n_method_node['Algorithm'])\n inclusive_namespaces_node['PrefixList'] = options[:inclusive_namespaces].join(' ')\n c14n_method_node.add_child(inclusive_namespaces_node)\n end\n\n signed_info_canon = canonicalize(signed_info_node, options[:inclusive_namespaces])\n\n signature = private_key.sign(@sign_digester.digester, signed_info_canon)\n signature_value_digest = Base64.encode64(signature).delete(\"\\n\")\n\n signature_value_node = Nokogiri::XML::Node.new('SignatureValue', document)\n signature_value_node.content = signature_value_digest\n signed_info_node.add_next_sibling(signature_value_node)\n self\n end",
"def sign_legacy(private_key)\n ctx = Secp256k1::Context.new\n signature, recovery_id = ctx.sign_recoverable(private_key, hash).compact\n result = signature.bytes\n result = result.append(27 + recovery_id)\n result.pack('c*')\n end",
"def signature\n # Remove 'sha_sign' key from request params and concatenate all\n # key value pairs\n params = payload.to_h\n .reject { |key, value| key == :sha_sign }\n .reject { |key, value| value == '' || value == false }.sort\n .map { | key, value| \"#{key}=#{value}#{passphrase}\" }.join\n\n # Calculate SHA512 and upcase all letters, since Digistore will\n # also return upcased letters in the signature.\n Digest::SHA512.hexdigest(params).upcase\n end",
"def sign_with(fingerprint_id, signature)\n @signatures[fingerprint_id] = signature\n end",
"def sign(str)\n @signer.sign(str) unless str.nil? || str.empty?\n end",
"def sign!(cert)\n openssl_cert = cert.cert # because model -> OpenSSL object\n openssl_cert.serial = self.next_serial\n cert.serial = self.next_serial\n openssl_cert.issuer = ca_cert.subject\n openssl_cert.sign private_key, OpenSSL::Digest::SHA1.new\n self.next_serial = self.next_serial + 1\n self.save\n nil\n end",
"def sign\n write_attr('mid', SecureRandom.uuid)\n write_attr('ts', Time.now.utc.to_i)\n canonical_msg = self.canonicalize\n\n #priv_key = OmfCommon::Key.instance.private_key\n #digest = OpenSSL::Digest::SHA512.new(canonical_msg)\n\n #signature = Base64.encode64(priv_key.sign(digest, canonical_msg)).encode('utf-8') if priv_key\n #write_attr('digest', digest)\n #write_attr('signature', signature) if signature\n\n if OmfCommon::Measure.enabled?\n MPMessage.inject(Time.now.to_f, operation.to_s, mid, cid, self.to_s.gsub(\"\\n\",''))\n @@mid_list << mid\n end\n self\n end",
"def sign\n validate!\n\n @voter.update(\n data: @data,\n signature: @signature,\n signed_vote_at: Time.now\n )\n\n signer = @signer.new(@admin_key)\n signer.sign(@data.to_i)\n end",
"def sign(message)\n OpenSSL::HMAC.digest('SHA256', @key, message)\n end",
"def sign!(request, access_key_id, secret, options = nil)\n credentials = { access_key_id => secret }\n new(credentials, options).sign!(request, access_key_id)\n end",
"def sign_tx(raw_tx, pkey_wif)\n # Seems like this is your quintessential reference: \n # http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html\n\n # I think this is the right way to do it...\n Bitcoin.network = (bitcoin.is_testing?) ? :testnet3 : :bitcoin\n\n # This parses the binary-encoded raw transaction:\n tx = Bitcoin::P::Tx.new [raw_tx].pack('H*')\n\n # This is the input transaction, which we'll need for signining:\n prev_hash = tx.in[0].prev_out.reverse_hth\n\n # let's parse the keys:\n key = Bitcoin::Key.from_base58 pkey_wif\n\n pubkey = [key.pub].pack('H*')\n\n # And parse the input transaction:\n prev_tx = Bitcoin::P::Tx.new [bitcoin.getrawtransaction(prev_hash)].pack('H*')\n\n # And, now we're ready to sign: \n subscript = tx.signature_hash_for_input 0, prev_tx\n sig = Bitcoin.sign_data Bitcoin.open_key(key.priv), subscript\n tx.in[0].script_sig = Bitcoin::Script.to_signature_pubkey_script sig, pubkey \n\n tx.to_payload.unpack('H*')[0]\n end",
"def sign(accessKeySecret, parameters)\n signature = sign_without_encoding(accessKeySecret, parameters)\n Addressable::URI.encode_component(signature, Addressable::URI::CharacterClasses::UNRESERVED + '|')\n end",
"def sign_compact(data, privkey)\n sig, rec = sign_ecdsa(data, privkey, nil)\n [ECDSA::Format::SignatureDerString.decode(sig), rec]\n end",
"def sign(data, key)\n hmac = OpenSSL::HMAC.new(key, OpenSSL::Digest::SHA256.new)\n hmac.update data\n hmac.digest\n end",
"def sign_with(secret)\n #puts \"Signing #{string_to_sign.inspect} with #{secret.inspect}\"\n digest = OpenSSL::Digest.new('sha256')\n Base64.encode64(OpenSSL::HMAC.digest(digest, secret, string_to_sign)).strip\n end",
"def sign(payload)\n payload = payload.merge({\n :client_id => @client_id,\n :client_secret => @client_secret,\n })\n\n scope = create_scope\n context = create_context(payload)\n s2s = create_string_to_sign(scope, context)\n signing_key = get_signing_salt\n OpenSSL::HMAC.hexdigest(@hash_algo, signing_key, s2s)\n end",
"def signature_params\n params.require(:signature).permit(:sign)\n end",
"def rsa_sign arr\n # RFC 3447 / 9.2.\n hash = Digest::SHA1.digest arr.map(&:chr).join\n\n # RFC 3447 / page 43\n digest_info = [0x30, 0x21, 0x30, 0x09, 0x06,\n 0x05, 0x2b, 0x0e, 0x03, 0x02,\n 0x1a, 0x05, 0x00, 0x04, 0x14].map(&:chr).join\n\n # i don't do the padding, openssl does that for me\n # i'll reimplement RSA later on\n signature = HOST_KEY.private_encrypt(digest_info + hash)\nend",
"def process_signing\n if sign_file?\n @appearance = @stamper.getSignatureAppearance().to_java(Java::ComLowagieTextPdf::PdfSignatureAppearance)\n @appearance.setCrypto(@private_key, @cert_chain, nil, Java::ComLowagieTextPdf::PdfSignatureAppearance::WINCER_SIGNED)\n end\n end",
"def sign(signed_data, algo: nil)\n algo ||= self.algo\n raise AlgorithmError unless algo == self.algo\n openssl_sig = openssl.sign(public_key.digest.new, signed_data)\n raw_sig = PublicKey::ECDSA.ssh_signature(openssl_sig)\n Encoding.encode_signature(algo, raw_sig)\n end",
"def sign_base_string(base_string)\n key = OpenSSL::PKey::RSA.new File.read @private_key\n signature = key.sign(OpenSSL::Digest::SHA256.new, base_string)\n\n Base64.encode64(signature).delete(\"\\n\")\n end",
"def sign\n res = HTTParty.post(\n sign_url,\n body: body.to_json,\n headers: { 'Content-Type' => 'application/json' }\n )\n\n check_for_error(res)\n\n res.parsed_response\n end",
"def signature(request, secret, options = nil)\n new(nil, options).signature(request, secret)\n end",
"def sign(params, shared_secret = nil)\n shared_secret ||= params.delete['sharedSecret']\n raise ArgumentError, \"Cannot verify a signature without a shared secret\" unless shared_secret\n sig = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), Array(shared_secret).pack(\"H*\"), string_to_sign(params))\n params.merge('merchantSig' => Base64.encode64(sig).strip)\n end",
"def signature\n digest = \"SHA256\"\n OpenSSL::HMAC.hexdigest(digest, signing_key, string_to_sign)\n end",
"def sign(body)\n signed = OpenSSL::HMAC.digest('sha256', access_key, body)\n Base64.strict_encode64(signed)\n end",
"def wrap(to_sign)\n {\n 'signatures' => [],\n 'signed' => to_sign,\n }\n end",
"def sign!\n params = {\n :if_updated_at => @contract.content_updated_at\n }\n\n response = @client.put self.url, { :body => params.to_json, :headers => { 'Content-Type' => 'application/json' } }\n\n if response.status != 201\n raise Inkdit::Error.new(response)\n end\n\n Inkdit::Signature.new(@client, response.parsed)\n end",
"def sign_file(path, key)\n hmac = OpenSSL::HMAC.new(key, OpenSSL::Digest::SHA256.new)\n file_chunks(path, 0, @mac_len).each { |chunk| hmac.update chunk }\n hmac.digest\n end",
"def sign_mask(stream)\n byte = BinData::Uint8.read(stream)\n sign = byte & 0x80\n byte.assign(byte ^ 0x80)\n stream.rewind\n byte.write(stream)\n stream.rewind\n sign.zero? ? -1 : 0\n end",
"def sign(msg)\n Digest::SHA1.hexdigest(@secret + msg)\n end",
"def sign(cmd)\n \t\t\t\tiv = rand(0xffffffff).to_i.to_s(16).upcase.rjust(8,\"0\")\n \t\t\t\tdigest = Digest::MD5.hexdigest(cmd+iv).upcase\n \t\t\t\tsb = [@signature_block + digest].pack(\"h*\")\n \t\t\t\tsig = @signingkey_priv.private_encrypt(sb).unpack(\"h*\")[0].upcase\n \t\t\t\t# i haven't a clue what those numbers are on the front, 10|3|22\n \t\t\t\t\"10|3|22|#{cmd}|#{sig}|#{iv}\"\n \t\t\tend",
"def sign(pvt, id, txn)\n raise 'pvt must be of type Key' unless pvt.is_a?(Key)\n raise 'id must be of type Id' unless id.is_a?(Id)\n raise 'txn must be of type Txn' unless txn.is_a?(Txn)\n pvt.sign(body(id, txn))\n end",
"def sign!(current_user, _password)\n @current_user = current_user\n unless current_user == signing_user\n raise ESignatureUserError, 'The current user does not match the user that prepared the document for signature'\n end\n\n validate_prepared_doc_digest\n set_signature_timestamp\n salt_document\n sign_document\n\n validate_signature\n @prepared_doc\n end",
"def sign!(signing_profile={})\n raise \"Invalid certificate #{self.errors.full_messages}\" unless valid?\n merge_profile_with_extensions(signing_profile)\n\n openssl_cert = OpenSSL::X509::Certificate.new\n openssl_cert.version = 2\n openssl_cert.not_before = self.not_before\n openssl_cert.not_after = self.not_after\n openssl_cert.public_key = self.key_material.public_key\n\n openssl_cert.serial = self.serial_number.number\n\n openssl_cert.subject = self.distinguished_name.to_x509_name\n openssl_cert.issuer = parent.distinguished_name.to_x509_name\n\n factory = OpenSSL::X509::ExtensionFactory.new\n factory.subject_certificate = openssl_cert\n\n #NB: If the parent doesn't have an SSL body we're making this a self-signed cert\n if parent.openssl_body.nil?\n factory.issuer_certificate = openssl_cert\n else\n factory.issuer_certificate = parent.openssl_body\n end\n\n factory.config = build_openssl_config\n\n # Order matters: e.g. for self-signed, subjectKeyIdentifier must come before authorityKeyIdentifier\n self.extensions.keys.sort{|a,b| b<=>a}.each do |k|\n e = extensions[k]\n next if e.to_s.nil? or e.to_s == \"\" ## If the extension returns an empty string we won't include it\n ext = factory.create_ext(e.openssl_identifier, e.to_s, e.critical)\n openssl_cert.add_extension(ext)\n end\n\n if signing_profile[\"digest\"].nil?\n digest = OpenSSL::Digest.new(\"SHA512\")\n else\n digest = OpenSSL::Digest.new(signing_profile[\"digest\"])\n end\n\n self.openssl_body = openssl_cert.sign(parent.key_material.private_key, digest)\n end",
"def sign_certificate\n sign_certificate_for(default)\n end",
"def signing_input; end",
"def signing_input; end",
"def send_secret(stream)\n if DRab.current_server.secret != nil\n shared_secret = DRab.current_server.secret\n stream.write([shared_secret.size].pack('N') + shared_secret)\n end\n end",
"def sign(secret_key_base, salt, data, options = {})\n encoded = encode(data, options)\n key = get_secret(secret_key_base, salt, options)\n MessageVerifier.sign(encoded, key)\n end",
"def sign(str, secret)\n OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(\"sha256\"), secret, str)\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def sign!(ha)\n ha[:sig] = compute_checksum(ha)\n end",
"def sign(request, signer)\n signature = signer.sign(request.method, request.uri, request.headers)\n request.headers[\"Authorization\"] = \"#{signer.name} #{account_name}:#{signature}\"\n request\n end",
"def sign(url, *options)\n temp_signer = UrlSigner::Signer.new(url, *options)\n temp_signer.sign\n end",
"def sign; adapter_class.new(self).sign; end",
"def signature\n Base64.encode64(encryption_key.sign(OpenSSL::Digest::SHA256.new, id_string))\n end",
"def sign(unsigned_query)\n raise MissingSecret unless @locale.secret\n\n digest = OpenSSL::Digest::Digest.new('sha256')\n url_string = ['GET', @locale.host, '/onca/xml', unsigned_query].join(\"\\n\")\n hmac = OpenSSL::HMAC.digest(digest, @locale.secret, url_string)\n signature = escape([hmac].pack('m').chomp)\n\n \"#{unsigned_query}&Signature=#{signature}\"\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def verify_tx_signed_by(transaction_envelope:, keypair:)\n Stellar::SEP10.verify_tx_signed_by(\n tx_envelope: transaction_envelope, keypair: keypair\n )\n end",
"def signer\n end",
"def set_sign\n @sign = Sign.find(params[:id])\n end",
"def smb2_sign(packet)\n packet.smb2_header.flags.signed = 1\n packet.smb2_header.signature = \"\\x00\" * 16\n hmac = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), session_key, packet.to_binary_s)\n packet.smb2_header.signature = hmac[0, 16]\n\n packet\n end",
"def set_signature\n @signature = Signature.find(params[:id])\n end"
] | [
"0.61230457",
"0.61045754",
"0.60865486",
"0.6081972",
"0.59344697",
"0.58916974",
"0.5887304",
"0.5880879",
"0.58089775",
"0.5762871",
"0.57435554",
"0.57255197",
"0.56761134",
"0.5669075",
"0.5647609",
"0.5610663",
"0.5542152",
"0.5532891",
"0.5517412",
"0.5514751",
"0.54904217",
"0.54820526",
"0.54563755",
"0.5445879",
"0.54205996",
"0.5420076",
"0.54175794",
"0.53663474",
"0.5362009",
"0.5336267",
"0.5336196",
"0.53001934",
"0.5297391",
"0.5295593",
"0.52533495",
"0.52435946",
"0.52255774",
"0.520447",
"0.51958716",
"0.51953554",
"0.51891196",
"0.5184935",
"0.51836103",
"0.51677895",
"0.5154174",
"0.5129408",
"0.5122824",
"0.51087326",
"0.5075988",
"0.5066366",
"0.5056799",
"0.50293714",
"0.5021779",
"0.5005903",
"0.50037545",
"0.5000007",
"0.4999243",
"0.49962544",
"0.49751875",
"0.49684602",
"0.49620566",
"0.49551174",
"0.49539894",
"0.49283448",
"0.49225324",
"0.48991942",
"0.48938113",
"0.48932055",
"0.48591134",
"0.48568454",
"0.48545343",
"0.4837645",
"0.48334405",
"0.480548",
"0.479624",
"0.47926",
"0.47914416",
"0.47727573",
"0.4750989",
"0.4745752",
"0.47429404",
"0.47423238",
"0.47373518",
"0.47373518",
"0.47368813",
"0.47231972",
"0.4707796",
"0.47049388",
"0.4695726",
"0.46829814",
"0.46741214",
"0.4668623",
"0.46581432",
"0.46539253",
"0.46502376",
"0.46501118",
"0.46478954",
"0.46441907",
"0.46379268",
"0.4635572"
] | 0.7210573 | 0 |
Verifies the specified signature using original stream and signer's Public key. | def verify_stream_signature(signature, input_stream, signer_public_key)
signature = Validation.check_filled_array_argument!(signature)
signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)
begin
native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)
signer = Core::VirgilStreamSigner.new(native_algorithm)
source = VirgilStreamDataSource.new(input_stream)
signer.verify(source, signature, signer_public_key.raw_key)
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_signature\n @spki.verify(public_key)\n end",
"def verify_signature\n @req.verify(public_key)\n end",
"def verify_signature(public_key, payload, signature, timestamp)\n verify_engine\n timestamped_playload = \"#{timestamp}#{payload}\"\n payload_digest = Digest::SHA256.digest(timestamped_playload)\n decoded_signature = Base64.decode64(signature)\n public_key.dsa_verify_asn1(payload_digest, decoded_signature)\n rescue StandardError\n false\n end",
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n # OpenSSH compatibility: if a the number of bytes in the signature is less than the number of bytes of the RSA\n # modulus, prepend the signature with zeros.\n # See https://github.com/openssh/openssh-portable/blob/ac383f3a5c6f529a2e8a5bc44af79a08c7da294e/ssh-rsa.c#L531\n difference = n.num_bytes - raw_sig.bytesize\n raw_sig = \"\\0\" * difference + raw_sig if difference.positive?\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def verify_signature(signature, bytes, signer_public_key)\n signature = Validation.check_filled_array_argument!(signature)\n bytes = Validation.check_filled_array_argument!(bytes)\n signer_public_key = Validation.check_type_argument!(VirgilPublicKey, signer_public_key)\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(HashAlgorithm::SHA512)\n signer = Core::VirgilSigner.new(native_algorithm)\n signer.verify(bytes, signature, signer_public_key.raw_key)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify!\n verify\n rescue InvalidDigest, InvalidSignedValue => e\n raise InvalidSignature, e.message\n end",
"def verify(signed_data, signature)\n sig_algo, raw_sig, _ = Encoding.decode_signature(signature)\n digest = ALGO_DIGESTS[sig_algo]\n\n if digest.nil?\n raise DecodeError, \"bad signature algorithm: #{sig_algo.inspect}\"\n end\n\n openssl.verify(digest.new, raw_sig, signed_data)\n end",
"def verify_signature(signature, signed_text, base64_encoded=true)\n sig = base64_encoded ? Base64UrlSafe.decode(signature) : signature\n self.public_key.verify(OpenSSL::Digest::SHA256.new, sig, signed_text)\n end",
"def match_signature(signature)\n if !signature[:ok]\n msg_mismatch(text)\n elsif expected_signer && signature[:email] != expected_signer\n msg_wrong_signer(signature[:email])\n end\n end",
"def verify_signature(signature, string, base64=false)\n signature = base64_decode(signature) if base64\n\n @public_key.verify(OpenSSL::Digest.new(\"SHA1\"), signature, string)\n end",
"def verify_signature(params = {})\n version = params[:version]\n webhook_secret = params[:webhook_secret]\n stringified_data = params[:stringified_data]\n request_timestamp = params[:request_timestamp]\n signature = params[:signature]\n\n signature_params = \"#{request_timestamp}.#{version}.#{stringified_data}\"\n digest = OpenSSL::Digest.new('sha256')\n signature_to_be_verified = OpenSSL::HMAC.hexdigest(digest, webhook_secret, signature_params)\n\n signature == signature_to_be_verified\n\n end",
"def verify_ecdsa_signature(signature, hash)\n BTC::OpenSSL.ecdsa_verify(signature, hash, self.public_key)\n end",
"def verify_signature(result); end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n end",
"def verify_signature\n #puts \"sing in params: #{@params[\"sign\"]}\" unless @params[\"sign\"] == Alipay.generate_signature(@params, @key)\n #puts Alipay.generate_signature(@params, @key)\n @params[\"sign\"] == Tenpay.generate_signature(@params, @key) #.tap{|sig| puts \"Generated sig #{sig}\"}\n end",
"def verify(*args, **options)\n verified(*args, **options) || raise(InvalidSignature)\n end",
"def verify(message, signature, signature_encoding = :raw)\n signature = Encoder[signature_encoding].decode(signature)\n Util.check_length(signature, NaCl::SIGNATUREBYTES, \"signature\")\n\n sig_and_msg = signature + message\n buffer = Util.zeros(sig_and_msg.bytesize)\n buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)\n\n NaCl.crypto_sign_open(buffer, buffer_len, sig_and_msg, sig_and_msg.bytesize, @key)\n end",
"def verify_compact_signature(signature, hash)\n raise BTCError, \"Not implemented\"\n end",
"def signature_is_valid?\n node = @ar.at_css('xmlns|SignedInfo',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#')\n\n node = node.canonicalize\n\n signature = @ar.at_css(\n 'xmlns|SignatureValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content\n\n signature = Base64.decode64(signature)\n\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def verify(signed_message)\n verified(signed_message)\n end",
"def verify(key)\n plaintext = plaintext_sig(body, type, encoding, alg)\n key.public_key.verify(digest, sig, plaintext)\n rescue BadError\n false\n end",
"def valid_signature? signature\n # We create a new XML document in Nokogiri to canonicalize the\n # signature. Nokogiri needs the xmlns:ds tag on the root element to\n # preserve the 'ds:' namespace on all the elements. Not exactly sure\n # why this is needed, but it works if we do it.\n info = signature.find_first('.//ds:SignedInfo', DS)\n\n canon = LibXML::XML::Document.new\n canon.root = canon.import info\n canonicalized = canon.canonicalize\n\n b64_sig = signature.find_first('.//ds:SignatureValue', DS).content\n dec_sig = Base64.decode64 b64_sig\n\n b64_cert = signature.find_first('.//ds:X509Certificate', DS).content\n cert = OpenSSL::X509::Certificate.new(Base64.decode64(b64_cert))\n\n digest = OpenSSL::Digest::SHA1.new\n cert.public_key.verify(digest, dec_sig, canonicalized)\n end",
"def verify_signature\n if @local_path\n if RUBY_PLATFORM =~ /java/\n begin\n jarfile = java.util.jar.JarInputStream.new(FileInputStream.new(@local_path), true)\n @signature_verified = true\n rescue NativeException\n @signature_verified = false\n end\n else\n # Use IO.popen instead of system() to absorb\n # jarsigners messages to $stdout\n response = IO.popen(\"jarsigner -verify #{@local_path}\"){|io| io.gets}\n @signature_verified = ($?.exitstatus == 0)\n end\n else\n nil\n end\n end",
"def validate_signature!(signature, data)\n raise InvalidSignature unless valid_signature?(signature, data)\n end",
"def verify_signature\n return_code, response = send_command(\"verify_signature\", token)\n return_code == \"200\"\n end",
"def verify\n @sigs = []\n @orig_data = request.params['data']\n if @orig_data.nil?\n # XXX: Implement HTTP error here.\n end\n begin\n GPGME::verify(request.params['data'], nil, @plain) do |signature|\n @sigs << signature\n end\n rescue GPGME::Error => e\n @error = \"GPGME Error: #{e.to_s}\"\n #rescue\n # @error = \"Unspecified Error.\"\n end\n end",
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_GEOTIX_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, \"#{auth_token}#{@payload_raw}\")\n halt [401, \"Signatures don't match.\"] unless their_digest == our_digest\n end",
"def verify_signature(url, params)\n submit VerifySignature.new(:url_end_point => url, :http_parameters => params)\n end",
"def valid?(other)\n self.signature === other\n end",
"def verify_signature(data)\n Signature.valid?(data.merge('api_key' => api_key))\n end",
"def verify_content(body, signature)\n hmac = HMAC::SHA1.hexdigest(@secret, body)\n check = \"sha1=\" + hmac\n check == signature\n end",
"def signature_valid?; end",
"def verify(message, signature, signature_encoding = :raw)\n signature = Encoder[signature_encoding].decode(signature)\n Util.check_length(signature, signature_bytes, \"signature\")\n\n sig_and_msg = signature + message\n buffer = Util.zeros(sig_and_msg.bytesize)\n buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)\n\n NaCl.crypto_sign_ed25519_open(buffer, buffer_len, sig_and_msg, sig_and_msg.bytesize, @key)\n end",
"def validate_signature(key_public, signature, timestamp)\r\n # RSA Decryption (Formula: M = C^e mod n)\r\n timestamp = timestamp.to_i % key_public[1].to_i\r\n signature = signature.to_i\r\n decipher = signature.to_bn.mod_exp(key_public[0].to_i,key_public[1].to_i)\r\n return true if (decipher == timestamp)\r\n return false\r\nend",
"def verify_signatures?; end",
"def verify_signature(cleartext, signature_string)\n cmd_output = run_verify(cleartext, signature_string)\n cmd_result = analyse_verify_output(*cmd_output)\n\n if cmd_result[:well_formed_pgp_data]\n match_constraints(**cmd_result)\n else\n msg_no_pgg_data(signature_string)\n end\n end",
"def verify(signed_message, message, signing_key = admin_key)\n msg_int = rsa.text_to_int(message)\n rsa.verify(signed: signed_message, message: msg_int, key: signing_key)\n end",
"def verify(file)\n # Read YAML file and comment\n data = YAML.load(File.open(file + SIGEXT))\n raise KeyfileError, \"Invalid file #{file + SIGEXT} content\" unless data && data.is_a?(Hash)\n\n puts \"Signature in file: #{file + SIGEXT}\" if @options[:verbose]\n clearsg = !File.file?(file)\n\n # Hash data\n start = Time.now\n sha = if clearsg\n raise VerificationError, \"File #{file} does not exist, no signed data\" if data[:data].nil?\n Digest::SHA512.new\n else\n puts \"⚠ Warning: clear sign data found but ignored\" if data.has_key?(:data)\n Digest::SHA512.file(file)\n end\n sha << \"\\0x00\" + data[:comment] unless data[:comment].nil?\n sha << \"\\0x00\" + data[:datetime].to_s\n sha << \"\\0x00\" + data[:data] if clearsg\n\n # Control data\n ctn = Enc.decode(data[:signature])\n pub = Ed25519::VerifyKey.new Enc.decode_key(data[:verifykey])\n puts \"Signed with key: #{abbrev_key(data[:verifykey])}\" if @options[:verbose]\n t = get_trusted_keys.include?(data[:verifykey]) ? \"with trusted key\" :\n \"but the verify key is ✖ not trusted\\n (#{data[:verifykey]})\"\n pub.verify(ctn, sha.digest) || raise(VerificationError, \"BAD signature\")\n if clearsg\n $stderr.puts \"✔ Good signature #{t}\\n signed on #{Time.at(data[:datetime])}\"\n $stdout.print data[:data]\n $stderr.puts \"Comment: #{data[:comment]}\\n\" unless data[:comment].nil?\n else\n puts \"✔ Good signature #{t}\\n signed on #{Time.at(data[:datetime])}\"\n puts \"(⏲ #{'%.2f' % ((Time.now - start) * 1000)} ms)\" if @options[:verbose]\n puts \"Comment: #{data[:comment]}\\n\" unless data[:comment].nil?\n end\nend",
"def verify_signatures spec, digests, signatures\n if only_signed and signatures.empty? then\n raise Gem::Security::Exception,\n \"unsigned gems are not allowed by the #{name} policy\"\n end\n\n digests.each do |file, digest|\n signature = signatures[file]\n raise Gem::Security::Exception, \"missing signature for #{file}\" unless\n signature\n verify_signature signature, digest.digest, spec.cert_chain\n end\n end",
"def valid_signature?(signature, data)\n generate_signature(data) == signature\n end",
"def verifySignature _args\n \"verifySignature _args;\" \n end",
"def validate_signature(doc, certificate, canonicalization_method)\n node = doc.at('xmlns|SignedInfo', xmlns: DSIG)\n\n return false unless node\n\n node = case canonicalization_method\n when :normal\n node.canonicalize\n when :exclusive\n canonicalize_exclusively node\n end\n\n signature = doc.at('xmlns|SignatureValue', xmlns: DSIG).content\n signature = decode(signature)\n\n # Return true or false\n certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)\n end",
"def verify!(ha)\n passed_signature = ha[:sig] || ha[\"sig\"]\n raise Tampered, \"No signature given\" unless passed_signature\n raise Tampered, \"Checksum differs\" unless compute_checksum(ha) == passed_signature.to_s\n true\n end",
"def verify_signature signature, data, chain, time = Time.now\n Gem.ensure_ssl_available\n cert_class = OpenSSL::X509::Certificate\n exc = Gem::Security::Exception\n chain ||= []\n\n chain = chain.map{ |str| cert_class.new(str) }\n signer, ch_len = chain[-1], chain.size\n opt = Gem::Security::OPT.merge(@opt)\n\n # make sure signature is valid\n if @verify_data\n # get digest algorithm (TODO: this should be configurable)\n dgst = opt[:dgst_algo]\n\n # verify the data signature (this is the most important part, so don't\n # screw it up :D)\n v = signer.public_key.verify(dgst.new, signature, data)\n raise exc, \"Invalid Gem Signature\" unless v\n\n # make sure the signer is valid\n if @verify_signer\n # make sure the signing cert is valid right now\n v = signer.check_validity(nil, time)\n raise exc, \"Invalid Signature: #{v[:desc]}\" unless v[:is_valid]\n end\n end\n\n # make sure the certificate chain is valid\n if @verify_chain\n # iterate down over the chain and verify each certificate against it's\n # issuer\n (ch_len - 1).downto(1) do |i|\n issuer, cert = chain[i - 1, 2]\n v = cert.check_validity(issuer, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain', cert.subject, v[:desc]\n ] unless v[:is_valid]\n end\n\n # verify root of chain\n if @verify_root\n # make sure root is self-signed\n root = chain[0]\n raise exc, \"%s: %s (subject = '%s', issuer = '%s')\" % [\n 'Invalid Signing Chain Root',\n 'Subject does not match Issuer for Gem Signing Chain',\n root.subject.to_s,\n root.issuer.to_s,\n ] unless root.issuer.to_s == root.subject.to_s\n\n # make sure root is valid\n v = root.check_validity(root, time)\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Invalid Signing Chain Root', root.subject, v[:desc]\n ] unless v[:is_valid]\n\n # verify that the chain root is trusted\n if @only_trusted\n # get digest algorithm, calculate checksum of root.subject\n algo = opt[:dgst_algo]\n path = Gem::Security::Policy.trusted_cert_path(root, opt)\n\n # check to make sure trusted path exists\n raise exc, \"%s: cert = '%s', error = '%s'\" % [\n 'Untrusted Signing Chain Root',\n root.subject.to_s,\n \"path \\\"#{path}\\\" does not exist\",\n ] unless File.exist?(path)\n\n # load calculate digest from saved cert file\n save_cert = OpenSSL::X509::Certificate.new(File.read(path))\n save_dgst = algo.digest(save_cert.public_key.to_s)\n\n # create digest of public key\n pkey_str = root.public_key.to_s\n cert_dgst = algo.digest(pkey_str)\n\n # now compare the two digests, raise exception\n # if they don't match\n raise exc, \"%s: %s (saved = '%s', root = '%s')\" % [\n 'Invalid Signing Chain Root',\n \"Saved checksum doesn't match root checksum\",\n save_dgst, cert_dgst,\n ] unless save_dgst == cert_dgst\n end\n end\n\n # return the signing chain\n chain.map { |cert| cert.subject }\n end\n end",
"def verify(sig,data)\n if rsa?\n @pub.verify( OpenSSL::Digest::SHA1.new, sig, data )\n elsif dsa?\n # DSS1 was dropped from OpenSSL in version 1.1\n # @pub.verify( OpenSSL::Digest::DSS1.new, sig, data )\n raise StandardError, 'DSA is not supported'\n else\n false\n end\n end",
"def valid?\n return false unless given_signature\n Relax::Query.unescape_value(correct_signature) == given_signature\n end",
"def check_for_signature\n if signature_file_name_changed?\n sign if signature.present?\n end\n true\n end",
"def validate!\n Cybersource::Security.validate_signature!(@fields['signature'], signed_data)\n raise PaymentFailed unless payment_success?\n\n self\n end",
"def verify(payload, header, tolerance: nil)\n begin\n timestamp, signatures = get_timestamp_and_signatures(header)\n rescue StandardError\n raise InvalidSignature, \"Unable to extract timestamp and signatures from header\"\n end\n\n if signatures.empty?\n raise InvalidSignature, \"No signatures found with expected version #{@version}\"\n end\n\n expected_sig = generate(payload, timestamp)\n unless signatures.any? { |s| secure_compare(expected_sig, s) }\n raise InvalidSignature, \"No signatures found matching the expected signature for payload\"\n end\n\n if tolerance && timestamp < Time.now - tolerance\n raise InvalidSignature, \"Timestamp outside the tolerance zone (#{Time.at(timestamp)})\"\n end\n\n true\n end",
"def verify(msg)\n \t\t\t\tbegin\n \t\t\t\t\tx,y,z,cmd,sig,iv = msg.split(/\\|/)\n \t\t\t\t\treturn nil unless iv\n \t\t\t\t\tdigest = Digest::MD5.hexdigest(cmd+iv).upcase\n \t\t\t\t\tsb1 = [@signature_block + digest].pack(\"h*\")\n \t\t\t\t\tsb2 = @signingkey_pub.public_decrypt([sig].pack(\"h*\"))\n \t\t\t\t\treturn nil unless sb1 == sb2\n \t\t\t\t\tcmd\n \t\t\t\trescue NoMethodError\n \t\t\t\t\tputs \"verify exception: #{msg}\"\n \t\t\t\tend\n \t\t\tend",
"def verify_tx_signed_by(transaction_envelope:, keypair:)\n hashed_signature_base = transaction_envelope.tx.hash\n\n transaction_envelope.signatures.any? do |sig| \n keypair.verify(sig.signature, hashed_signature_base)\n end\n end",
"def valid_signature?\n Rack::Utils.secure_compare(signature, signature_for(body))\n end",
"def correct_signature?\n client = RestClient.where(:api_key => @api_key).first\n sign=client.nil? ? \"\" : client.secret + @request_uri.gsub(/\\?.*/,\"\")+@timestamp\n calculated_sign= (Digest::SHA256.new << sign).to_s\n Digest::SHA1.hexdigest(@signature)==Digest::SHA1.hexdigest(calculated_sign)\n end",
"def safe_equals?(signature, other_signature)\n check = signature.bytesize ^ other_signature.bytesize\n signature.bytes.zip(other_signature.bytes) { |x, y| check |= x ^ y.to_i }\n check.zero?\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return FALSE if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return FALSE\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return TRUE\n end",
"def signature_verify( doc )\n # 1. Figure out signature namespace prefix\n sig_ns, prefix = signature_namespace_and_prefix( doc )\n\n # 2.a Signer present?\n @signer_node = doc.xpath( \"//#{ namespace_prefix( doc, doc.root.namespace.href ) }:Signer\" )\n if @signer_node.size != 1\n @messages << \"#{ @signer_node.size == 0 ? 'No' : @signer_node.size } Signer node#{ @signer_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.b Signature present?\n @signature_node = doc.xpath( \"//#{ prefix }:Signature\", sig_ns )\n if @signature_node.size != 1\n @messages << \"#{ @signature_node.size == 0 ? 'No' : @signature_node.size } Signature node#{ @signature_node.size > 1 ? 's' : '' } found\"\n end\n\n # 2.c Abort if none or more than 1 Signer or Signature node\n return false if ( @signer_node.size != 1 or @signature_node.size != 1 )\n\n # 3. Extract and check signer certs\n certs = extract_certs( doc, sig_ns, prefix )\n @crypto = DC_Signer_Crypto_Compliance.new( certs )\n\n if ! @crypto.valid?\n if ! @crypto.errors[ :pre_context ].empty?\n @crypto.errors[ :pre_context ].each do |e|\n @messages << e\n end\n return false\n else\n # Compliance issues in the extracted certs.\n # List those errors but then try to continue anyway,\n # thus allowing for inspection of compliance issues and signature in context.\n @crypto.messages.each do |e|\n @messages << e\n end\n end\n else # cc is valid\n @messages << \"Certificate chain is complete and compliant (#{ @crypto.type })\"\n end\n\n # 3.a Might check here whether the signer chain is known, trustworthy etc.\n #\n # See 3 for @crypto validity hop-over\n #\n\n # 4. Get signer's public key\n pub_k = @crypto.context.first.public_key\n\n # 5. Check references and signature value\n @reference_digests_check = check_references( doc, sig_ns, prefix )\n @signature_value_check = check_signature_value( doc, sig_ns, prefix, pub_k )\n\n return true\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def is_validate_signature\n signature = request.headers[\"X-LINE-Signature\"]\n http_request_body = request.raw_post\n hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, CHANNEL_SECRET, http_request_body)\n signature_answer = Base64.strict_encode64(hash)\n signature == signature_answer\n end",
"def ==(other)\n return false unless other.is_a?(Signature)\n r == other.r && s == other.s\n end",
"def validate(url, params, signature)\r\n params_hash = params.to_unsafe_h\r\n expected = build_signature_for(url, params_hash)\r\n ActiveSupport::SecurityUtils.secure_compare(expected, signature)\r\n end",
"def check(params)\n params = params.dup\n\n signature = params.delete('sig')\n\n ::JWT::SecurityUtils.secure_compare(signature, digest(params))\n end",
"def signature_is_valid?\n validate_signature(doc, certificate, :normal)\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\n end",
"def process_signature? (signature)\n\t\n\t\tlogger.debug 'Estamos procesando la firma'\t\n\t\t\n\t\tif not signature.signed?\n\n\t\t\[email protected] = Base64.decode64(params[:xmlSigned2])\n\t\t\t\n\t\t\tbegin\n\t\t\t\tvalidation = @signature.validate_signature\n\t\t\trescue\n\t\t\t\tflash[:error] = \"Ha ocurrido un error al intentar validar el certificado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif not validation.isValid?\n\t\t\t\tflash[:error] = \"La firma no es válida. Compruebe que el certificado no esté caducado o revocado\"\n\t\t\t\treturn false\n\t\t\tend\n\t\t\t\n\t\t\tif validation.psisNIF != signature.dni\n\t\t\t\tflash[:error] = \"El DNI introducido en el formulario no coincide con el DNI del Certificado\"\n\t\t\t\treturn false\t\t\t\n\t\t\tend\n\n\t\t\[email protected] = 1\n\t\t\t\n\t\t\tif @signature.valid?\n\t\t\t\t@proposal = @signature.proposal\n\t\t\t\[email protected]_afirma_signature\t\t\n\t\t\t\tshare_texts(@proposal, @signature)\n\t\t\t\tsignature.notifier\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\tflash[:error] = @signature.errors.map {|a,m| \"#{m.capitalize}\"}.uniq.join(\"<br/>\\n\")\n\t\t\t\treturn false\n\t\t\tend\n\t\telse\n\t\t\tflash[:error] = \"Este identificador de firma ya ha sido firmado\"\n\t\t\treturn false\n\t\tend\n\tend",
"def validate_signature(test_doc = nil)\n test_doc ||= @prepared_doc\n\n doc_signature = get_document_tag :esigncode, from: test_doc\n doc_salt = get_document_tag :esignuniquecode, from: test_doc\n validate_prepared_doc_digest test_doc\n\n new_pdd = prepared_doc_digest(from: test_doc)\n new_signature = Hashing.sign_with(doc_salt, new_pdd)\n raise ESignatureUserError, 'Document signature is invalid' unless doc_signature == new_signature\n\n true\n end",
"def validate_signature\n\t\t::Rails.logger.debug \"--- Realizando comprobación de la firma con PSEIS ---\"\n\t\tdoc = Nokogiri::XML(xmlSigned)\n\t\tdoc.remove_namespaces!\n\t\t\n\t\tcert = doc.xpath('//X509Data/X509Certificate').first.inner_text\n\t\t\n\t\tmyValidation = PSISApi.new\n\t\tmyValidation.validate cert\n\t\treturn myValidation\n\tend",
"def verify!(config, params)\n sent_signature = params.find { |key, _value| key.to_s.casecmp('BRQ_SIGNATURE').zero? }&.last\n generated_signature = Signature.generate(config, params)\n\n if sent_signature.nil? || generated_signature.nil? || !safe_equals?(sent_signature, generated_signature)\n raise SignatureException.new(sent_signature, generated_signature)\n end\n end",
"def matches_signature(signature)\n @name == signature.name\n end",
"def valid?\n # If payload does not contain the sha_sign definitely return false.\n return false unless payload.sha_sign\n\n signature == payload.sha_sign\n end",
"def check_signature\n signature == \"\\x2a\\x2a\\x00\\x00\"\n end",
"def signed?\n # Fail immediately if the request is not signed at all\n return false unless oauth_request? and authenticating_client\n # mash and compare with given signature\n self.signature == build_signature\n end",
"def has_valid_signature?\n Adyen::HPP::Signature.verify(params, shared_secret)\n end",
"def verify_signature(result) # :nodoc:\n response = build_signature_buffer(result)\n\n hash = digester.digest(response.to_s)\n\n server_key = result[:server_key]\n server_sig = result[:server_sig]\n unless connection.host_key_verifier.verify_signature { server_key.ssh_do_verify(server_sig, hash, host_key: algorithms.host_key) }\n raise Net::SSH::Exception, 'could not verify server signature'\n end\n\n hash\n end",
"def verify_request(verb, path, params, key, signature_param = nil)\n params ||= {}\n _path = path.dup\n _params = params.dup\n sign_request(verb, _path, _params, key, signature_param)\n return (path == _path and params == _params)\n end",
"def signed?\n !signature.nil?\n end",
"def secure?\n self.generated_signature == self.signature\n end",
"def verify_signature\n begin\n signature = OAuth::Signature.build(request) do |token, consumer_key|\n self.current_application = find_application_by_key(consumer_key)\n self.current_token = find_token(token)\n\n token_secret = self.current_token ? self.current_token.secret : nil\n app_secret = self.current_application ? self.current_application.secret : nil\n \n self.oauth_logger.debug \"Signature build: application-secret: #{app_secret}; token-secret: #{token_secret}\"\n \n [token_secret, app_secret]\n end\n # Rescue requests made with unacceptable signature methods. \n # OAuth::Signature.available_methods holds a Hash of acceptable\n # signature methods. Provide a sane error message to the Consumer.\n rescue OAuth::Signature::UnknownSignatureMethod => e\n throw :halt, render(\"Unknown Signature Method: #{e.message}. Accepts: #{OAuth::Signature.available_methods.keys.join(', ')}\", :status => 401, :layout => false)\n end\n \n if signature.verify\n remember_request(signature)\n else\n self.oauth_logger.debug(\"Signature verify fail: Base: #{signature.signature_base_string}. Signature: #{signature.signature}\")\n \n throw :halt, render(\"Invalid OAuth Request. Signature could not be verified. Base: #{signature.signature_base_string}. Signature: #{signature.signature}\", :status => 401, :layout => false)\n end\n end",
"def verify_signatures(request)\n data, _status_code, _headers = verify_signatures_with_http_info(request)\n data\n end",
"def verify_tx_signed_by(transaction_envelope:, keypair:)\n Stellar::SEP10.verify_tx_signed_by(\n tx_envelope: transaction_envelope, keypair: keypair\n )\n end",
"def signature_ok?(timestamp)\n slack_signature = request.headers['X-Slack-Signature']\n signature = Slack::Utils.signature(\n SLACK_SIGNING_SECRET, timestamp, request.raw_post\n )\n\n return unless slack_signature != signature\n\n raise Unauthorized, \"ERROR: you're not Slack (wrong signature)\"\n end",
"def verify(params, shared_secret = nil)\n their_sig = params.delete('merchantSig')\n raise ArgumentError, \"params must include 'merchantSig' for verification\" if their_sig.empty?\n our_sig = sign(params, shared_secret)['merchantSig']\n secure_compare(their_sig, our_sig)\n end",
"def verify content, sign\n # raise OpenSSL::PKey::ECError(ECDSA_verify: nested asn1 error) when sign is wrong\n @ec.dsa_verify_asn1 content, Utils::BinUtil.from_hex(sign)\n rescue\n false\n end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def ssh_do_verify(sig, data, options = T.unsafe(nil)); end",
"def verifier\n Verifier.new(public_key)\n end",
"def verify_sig(data, sig, pubkey, algo: :ecdsa)\n case algo\n when :ecdsa\n verify_ecdsa(data, sig, pubkey)\n when :schnorr\n verify_schnorr(data, sig, pubkey)\n else\n false\n end\n end",
"def valid_hashes? signature\n refs = signature.find('.//ds:Reference', DS).map{ |r| r['URI'][1..-1] }\n\n without_signature = LibXML::XML::Document.document(signature.doc)\n without_signature.find_first('//ds:Signature', DS).remove!\n # The XML digested must be canonicalized as per the W3's specification\n # at http://www.w3.org/TR/xml-c14n\n c14n = without_signature.canonicalize\n digest = Base64.encode64(Digest::SHA1.digest(c14n)).chomp\n\n refs.all? do |ref|\n hashed_element = @doc.find_first(\"//*[ID='#{ref}']\")\n digest_listed = signature.find_first('.//ds:DigestValue', DS).content\n\n digest == digest_listed\n end\n end",
"def valid_signature?\n params['verifier'] == Digest::MD5.hexdigest([ params['id'], params['snuid'], params['currency'], Offerpal.secret_key ].join(':'))\n end",
"def test_signed\n mail = Notifier.fufu_signed(\"<[email protected]>\", \"<[email protected]>\")\n\n assert_equal mail.delivery_method.settings[:address], 'smtp.com'\n assert_equal mail.from, [ \"[email protected]\" ]\n\n found = false\n for part in mail.parts do\n if part.content_type =~ /application\\/x-pkcs7-signature/\n found = true\n break\n end\n end\n assert_equal found, true\n\n require 'tempfile'\n\n tf = Tempfile.new('actionmailer_x509')\n tf.write mail.encoded\n tf.flush\n\n comm = \"openssl smime -verify -in #{tf.path} -CAfile #{File.dirname(__FILE__)}/../lib/certs/ca.crt 2>&1\"\n\n success = false\n output = IO.popen(comm)\n while output.gets do\n if $_ =~ /^Verification successful/\n success = true\n end\n end\n assert_equal(success, true)\n end",
"def decrypt_then_verify(bytes, private_key, *public_keys)\n bytes = Validation.check_filled_array_argument!(bytes)\n private_key = Validation.check_type_argument!(VirgilPrivateKey, private_key)\n\n begin\n cipher = Core::VirgilCipher.new\n decrypted_bytes = cipher.decrypt_with_key(\n bytes,\n private_key.id,\n private_key.raw_key\n )\n signature = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNATURE)\n\n signer_public_key = public_keys.first\n\n if public_keys.count > 1\n signer_id = cipher.custom_params.get_data(CUSTOM_PARAM_KEY_SIGNER_ID)\n signer_public_key = public_keys.find {|public_key| public_key.id == signer_id}\n end\n\n is_valid = verify_signature(signature, decrypted_bytes, signer_public_key)\n raise VirgilCryptoException, 'Signature is not valid' unless is_valid\n\n wrap_bytes(decrypted_bytes)\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def check_signature\n signature == \"ElfChnk\\x00\"\n end",
"def verify_signature(payload_body)\n signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['WEBHOOK_SECRET_TOKEN'], payload_body)\n return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])\nend",
"def verify(build)\n # TODO might as well cache this and store in the db so we dont have to\n # convert every time\n pkey = to_rsa_pkey\n signature = Base64.decode64(build.signature)\n digest = OpenSSL::Digest::SHA256.new\n\n # If the user submits html were going to expect the\n # signature to match the html they are submitting.\n # However, if the user gives a url where we can download\n # the html, we're going to expect the signature to match\n # the app name and the url.\n if build.endpoint.present?\n expected = \"#{build.app.name}-#{build.endpoint}\"\n else\n expected = build.html\n end\n\n match = expected &&\n signature &&\n pkey.verify(digest, signature, expected)\n # Bug in ruby's OpenSSL implementation.\n # SSL connection with PostgreSQL can fail, after a call to\n # OpenSSL::X509::Certificate#verify with result 'false'. Root cause is\n # the thread local error queue of OpenSSL, that is used to transmit\n # textual error messages to the application after a failed crypto\n # operation. A failure in Certificate#verify leaves some messages on the\n # error queue, which can lead to errors in a SSL communication of other\n # parts of the application. The only solution at the moment is running:\n # OpenSSL.errors.clear after certificate verifying. This clears OpenSSL\n # errors array and keeps database connection alive.\n # From https://bugs.ruby-lang.org/issues/7215\n OpenSSL.errors.clear\n match # return true/false\n end",
"def verify_signed_request(request)\n\n begin\n authenticator = Mixlib::Authentication::SignatureVerification.new(request)\n username = authenticator.user_id\n user_key_file = \"#{EdmundsChefRailsProxy::Application.config.user_keys_dir}/#{username}.pem\"\n user_key = OpenSSL::PKey::RSA.new( ::File.read( user_key_file ) )\n authenticator.authenticate_request(user_key)\n\n rescue Mixlib::Authentication::MissingAuthenticationHeader => e\n logger.debug \" verify_signed_request: MissingAuthenticationHeader\"\n logger.debug \"Authentication failed: #{e.class.name}: #{e.message}\"\n #logger.debug \"#{e.backtrace.join(\"\\n\")}\"\n return false\n\n rescue StandardError => se\n logger.debug \" verify_signed_request: StandardError\"\n logger.debug \"Authentication failed: #{se}\"\n #logger.debug \"#{se.backtrace.join(\"\\n\")}\"\n return false\n\n end\n\n logger.debug \" verify_signed_request: OK\"\n return true\n\nend",
"def valid_signature?(params)\n (Time.at(params['ts'].to_i) > 30.minutes.ago) &&\n params['sig'] == signed_request_params(params['ts'])['sig']\n end",
"def verify(message, public_keys)\n ll_array = []\n rr_array = []\n\n public_keys.each_with_index do |k, i|\n ll_array[i] = hasher.group.generator * r_array[i] + k.point * c_array[i]\n rr_array[i] = hasher.hash_point(k.point) * r_array[i] + key_image * c_array[i]\n end\n\n c_sum = c_array.inject{|a, b| a + b} % hasher.group.order\n\n message_digest = hasher.hash_string(message)\n challenge = hasher.hash_array([message_digest] + ll_array + rr_array)\n\n c_sum == challenge\n end",
"def validate_sig(pkey,sig)\r\n\t\t\t\r\n\t\tend"
] | [
"0.72716933",
"0.722627",
"0.71475154",
"0.70844406",
"0.703887",
"0.68283224",
"0.68283224",
"0.66831076",
"0.6665898",
"0.6576083",
"0.6566004",
"0.6550251",
"0.6531383",
"0.64342684",
"0.64220667",
"0.64215004",
"0.6335991",
"0.63291556",
"0.62223065",
"0.6200806",
"0.6177742",
"0.61410266",
"0.61382115",
"0.6115748",
"0.6080005",
"0.6055394",
"0.60477453",
"0.60430086",
"0.6041877",
"0.6033773",
"0.60296106",
"0.6024697",
"0.6019049",
"0.6015749",
"0.600185",
"0.5970482",
"0.59651154",
"0.5952097",
"0.59373385",
"0.59342015",
"0.5917242",
"0.59134716",
"0.59010434",
"0.589657",
"0.5891355",
"0.58867395",
"0.5866837",
"0.58567506",
"0.58498996",
"0.58235013",
"0.5815249",
"0.5815245",
"0.5807437",
"0.57976323",
"0.5775651",
"0.57727456",
"0.57665056",
"0.5757632",
"0.5757632",
"0.57558197",
"0.5749873",
"0.57496816",
"0.5733833",
"0.5710767",
"0.570873",
"0.5694975",
"0.5691571",
"0.56888646",
"0.5684412",
"0.56815016",
"0.5619746",
"0.561201",
"0.5603321",
"0.5594768",
"0.5586028",
"0.55780166",
"0.55638146",
"0.5563457",
"0.5560825",
"0.55534387",
"0.5546462",
"0.5545286",
"0.5539407",
"0.553894",
"0.5517684",
"0.5517684",
"0.5517684",
"0.5516221",
"0.5469307",
"0.5452068",
"0.5451554",
"0.54167694",
"0.5411461",
"0.54026437",
"0.53904516",
"0.53889203",
"0.53762",
"0.53728986",
"0.53529036",
"0.5338002"
] | 0.759501 | 0 |
Computes the hash of specified data and the specified [HashAlgorithm] | def generate_hash(bytes, algorithm = nil)
bytes = Validation.check_filled_array_argument!(bytes)
alg = algorithm
alg ||= use_SHA256_fingerprints ? HashAlgorithm::SHA256 : HashAlgorithm::SHA512
begin
native_algorithm = HashAlgorithm.convert_to_native(alg)
native_hasher = Core::VirgilHash.new(native_algorithm)
wrap_bytes(native_hasher.hash(bytes))
rescue StandardError => error
raise VirgilCryptoException, error.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createSHAHash(data)\n\t\treturn Digest::SHA1.digest(data)\n\tend",
"def digest(data)\n OpenSSL::HMAC.digest(digest_class.new, key, data)[0,mac_length]\n end",
"def build_hash data\n digest = OpenSSL::Digest::Digest.new('md5')\n OpenSSL::HMAC.hexdigest(digest, @project_secret, data)\n end",
"def filehash(filename, algorithm = DEFAULT_ALGORITHM)\n algo_class = Digest.const_get(algorithm.to_s.upcase)\n\n # Safety check\n unless algo_class.class == Class and algo_class.respond_to?(:new)\n raise \"Unknown filehash provider #{algo_class}\"\n end\n\n hash = algo_class.new()\n File.open(filename,'r') do |f|\n until f.eof?\n hash.update(f.read(READ_SIZE))\n end\n end\n\n return hash.hexdigest\n end",
"def digest(data); end",
"def parse_hash_packet(data)\n hashes = []\n\n algo = data.read_string\n size = case algo\n when \"md5\" then 128\n when \"sha256\" then 256\n when \"sha384\" then 284\n when \"sha512\" then 512\n else raise NotImplementedError, \"unsupported algorithm: #{algo}\"\n end\n\n while !data.eof? do\n hashes << data.read(size)\n end\n\n { :algo => algo, :hashes => hashes }\n end",
"def compute_checksums data\n\n digest = OpenSSL::Digest::Digest.new('sha256')\n tree_digest = OpenSSL::Digest::Digest.new('sha256')\n tree_parts = []\n\n until data.eof?\n\n chunk = data.read(1024 * 1024) # read 1MB\n tree_parts << tree_digest.update(chunk).digest\n tree_digest.reset\n\n digest.update(chunk)\n\n end\n\n data.rewind\n\n [digest.to_s, compute_tree_hash(tree_parts)]\n\n end",
"def md5_hash(data)\n md5 = Digest::MD5.new\n md5 << data\n md5.hexdigest\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def generate_digest(data)\n OpenSSL::HMAC.hexdigest(DIGEST, @secret, data)\n end",
"def generate_digest(data)\n OpenSSL::HMAC.hexdigest(DIGEST, @secret, data)\n end",
"def data_hash(code, params)\n OpenSSL::Digest::SHA256.digest(JWT.canonical_json(data(code, params)))\n end",
"def digest(string, algorithm)\n Base64.encode64 digester(algorithm).digest(string)\n end",
"def createMD5Hash(data)\n\t\treturn Digest::MD5.digest(data)\n\tend",
"def digest_hash_function\n decode[:hash_function]\n end",
"def hash(*) end",
"def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end",
"def compute_checksum(data_)\n data = data_.dup\n data[22..25] = [0].pack(\"V\")\n crc = 0\n \n data.each_byte do |byte|\n crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte]\n crc = crc & 0xffffffff\n end\n crc\n end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def sha256 key, data\n OpenSSL::HMAC.digest('sha256', key, data)\n rescue RuntimeError\n require 'hmac-sha2'\n HMAC::SHA256.digest(key, data)\n end",
"def hex_digest(data)\n OpenSSL::Digest::SHA512.hexdigest(data)\n end",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def key_for(data)\n data.hash\n end",
"def get_hmac_hash(secret, data)\n algo = 'SHA1'\n _digest = OpenSSL::Digest.new(algo)\n OpenSSL::HMAC.hexdigest(_digest, secret, data)\n end",
"def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end",
"def generate_digest(data)\n Digest::SHA512.hexdigest \"#{data}#{@secret}\"\n end",
"def hmac_sha256(data, secret)\n OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), secret, data)\n end",
"def hash_this(word)\n\t\tdigest = Digest::MD5.hexdigest(word) # get the hex version of the MD5 for the specified string\n\t\tdigest[@offset, @digits].to_i(16) % @max_value # offset it using the initial seed value and get a subset of the md5. then modulo it to get the bit array location\n\tend",
"def hash\n @hash || calculate_hash!\n end",
"def hash\n [ data, type ].hash\n end",
"def calculate_hash(input, prep_hashes)\n result = 0\n input.unpack('U*').each do |x|\n result += prep_hashes.hash(x)\n end\n (result % MOD_VALUE).to_s(HEX)\nend",
"def algorithm\n \"HS256\"\n end",
"def create_tps_hash(data, hash_type)\n return \"SECRET KEY NOT PROVIDED\" if !defined? @SECRET_KEY\n case hash_type \n when 'HMAC_SHA256'\n OpenSSL::HMAC.hexdigest('sha256', @SECRET_KEY, data)\n when 'SHA512'\n Digest::SHA512.hexdigest(@SECRET_KEY + data)\n when 'SHA256'\n Digest::SHA256.hexdigest(@SECRET_KEY + data)\n when 'MD5'\n Digest::MD5.hexdigest(@SECRET_KEY + data)\n else\n OpenSSL::HMAC.hexdigest('sha512', @SECRET_KEY, data)\n end\n end",
"def hash_sha256(input)\n Digest::SHA2.new(256).digest(input)\n end",
"def crypto_hash(name, digest_class)\n digest_length = digest_class.digest('').length\n\n defines = Proc.new do \n define_method :\"#{name}\" do |data|\n data = data.pack 'C*' unless data.kind_of? String\n digest_class.digest(data).unpack 'C*'\n end\n define_method(:\"#{name}_digest_class\") { digest_class }\n define_method(:\"#{name}_length\") { digest_length }\n end\n \n @target.class_eval(&defines)\n (class << @target; self; end).module_eval(&defines) \n end",
"def digest(password, salt, algo = nil)\n raise ArgumentError, \"digest_size is required\" unless @digest_size\n\n digest = Util.zeros(@digest_size)\n salt = Util.check_string(salt, SALTBYTES, \"salt\")\n\n if algo.nil?\n algorithm = ALG_DEFAULT\n elsif algo == :argon2i\n algorithm = ALG_ARGON2I13\n elsif algo == :argon2id && Sodium::Version::ARGON2ID_SUPPORTED\n algorithm = ALG_ARGON2ID13\n else\n raise ArgumentError, \"digest algorithm is not supported\"\n end\n\n status = self.class.pwhash(\n digest, @digest_size,\n password, password.bytesize, salt,\n @opslimit, @memlimit, algorithm\n )\n raise CryptoError, ARGON_ERROR_CODES[status] if status.nonzero?\n\n digest\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def hashkey_calculation(query)\n validate(query)\n query += '&' + api_key.to_s\n Digest::SHA1.hexdigest(query)\n end",
"def compute_hmac(data)\n s = [compute_raw_hmac(data)].pack('m').chomp!(\"=\\n\")\n s.tr!('+/', '-_')\n s\n end",
"def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend",
"def keccak256(data)\n Digest::SHA3.new(256).digest(data)\nend",
"def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end",
"def core_hmac_sha1(key, data)\n bkey = str2binb(key)\n bkey = core_sha1(bkey, key.length * $chrsz) if bkey.length > 16\n\n ipad = Array.new(16, 0)\n opad = Array.new(16, 0)\n # for(var i = 0; i < 16; i++)\n i = 0\n while i < 16\n ipad[i] = (bkey[i] || 0) ^ 0x36363636\n opad[i] = (bkey[i] || 0) ^ 0x5C5C5C5C\n i += 1\n end\n\n hash = core_sha1((ipad + str2binb(data)), 512 + data.length * $chrsz)\n core_sha1((opad + hash), 512 + 160)\n end",
"def get_hash(input)\n return $hasher.reset.update(input).to_s\nend",
"def calc_hash(pass)\n salt_cost = SCrypt::Engine.autodetect_cost(self[:salt])\n SCrypt::Engine.scrypt(pass, self[:salt], salt_cost, 32).unpack('H*').first\n end",
"def hash_hash(h)\n require 'digest/md5'\n Digest::MD5.hexdigest(Marshal::dump(h.sort))\n end",
"def checksum\n source[digest_type]\n end",
"def hash_bytes(blob)\n tlsh_hash(blob)\n end",
"def hash_hmac(data)\n digest = OpenSSL::Digest.new('sha1')\n OpenSSL::HMAC.hexdigest(digest, merchant_key , data)\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def gnu_hash(s)\n s.bytes.reduce(5381) { |acc, elem| (acc * 33 + elem) & 0xffffffff }\n end",
"def core_hmac_sha1(key, data)\n bkey = str2binb(key)\n if(bkey.length > 16) \n bkey = core_sha1(bkey, key.length * $chrsz)\n end\n\n ipad = Array.new(16, 0)\n opad = Array.new(16, 0)\n #for(var i = 0; i < 16; i++)\n i = 0\n while(i < 16)\n ipad[i] = (bkey[i] || 0) ^ 0x36363636\n opad[i] = (bkey[i] || 0) ^ 0x5C5C5C5C\n i += 1\n end\n\n hash = core_sha1((ipad + str2binb(data)), 512 + data.length * $chrsz)\n return core_sha1((opad + hash), 512 + 160)\n end",
"def call( *args )\n text = args.shift.to_s\n bitlength = (args.shift || 256).to_i\n Digest::SHA2.new( bitlength ).hexdigest( text )\n end",
"def block_hash\n\t\tdigest = Digest::SHA2.new\n\n\t\tdigest << '%d' % [ self.index ]\n\t\tdigest << self.timestamp.strftime( '%s%N' )\n\t\tdigest << self.payload\n\t\tdigest << self.payload_hash\n\t\tdigest << self.proof.to_s\n\t\tdigest << self.previous_hash\n\t\t\n\t\treturn digest.hexdigest\n\tend",
"def calc_digest(password)\n return nil unless password\n algorithm.encode(password)\n end",
"def image_checksum(data, index1 = 0, index2 = 0) #:nodoc:\n case @checksum_method\n when 3\n Digest::MD5.hexdigest(data)\n when 1\n # Digest::MD4\n # return Digest::MD4::md4_hex($data);\n when 2\n # Digest::Perl::MD4\n # return Digest::Perl::MD4::md4_hex($data);\n else\n # Default\n # return sprintf('%016X%016X', index2, index1)\n end\n end",
"def sha_hash (arg)\r\n Digest::SHA2.hexdigest(arg)\r\n end",
"def hashFromWeb(uri, auth, algo)\n URI::NI.buildFromHTTP(auth, URI(uri), nil, algo)\nend",
"def hash_function_and_value\n return if hash_value.nil?\n if hash_function.nil? then\n return if errors.include?( :hash_value )\n errors.add( :hash_value, I18n.t( 'cfr_records.msg.hash_wo_fct' ))\n else\n case hash_function\n when 0 # MD5\n hash_size = 32\n when 1 # SHA-256\n hash_size = 64\n else\n return if errors.includes( :hash_function )\n errors.add( :hash_function, I18n.t( 'cfr_records.msg.unknown_fct' ))\n return\n end\n if hash_value.length != hash_size then\n return if errors.include?( :hash_value )\n errors.add( :hash_value, :wrong_length, count: hash_size )\n end\n end\n end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def odk_hash\n @odk_hash ||= Digest::SHA256.base64digest @data\n end",
"def calculate_hash(apikey, apisecret, timestamp, parameters)\n # gather values included in hash, sort them alphabetically\n\tsig_params = Hash.new\n\tsig_params[:apikey] = apikey\n\tsig_params[:apisecret] = apisecret\n\tsig_params[:ts] = timestamp\n\t\n\t# stringify the values to be hashed - e.g. key1=value1&key2=value2&key3=value3\n\tstring_to_hash = ''\n\tsig_params.sort.map do |key,value|\n\t string_to_hash = string_to_hash + key.to_s + \"=\" + value.to_s + \"&\"\n\tend\n\tstring_to_hash = string_to_hash.chomp('&') # Ensuring that the last '&' is removed.\n\t\n\t# compute the SHA256 hash and return as a string\n\tDigest::SHA256.hexdigest(string_to_hash).to_s\nend",
"def hash(message)\n return Digest::SHA1.hexdigest(message)\n end",
"def hash\n data.hash\n end",
"def hash=(_arg0); end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def calculate_block_hash(block)\n Digest::SHA256.hexdigest(block.block_index.to_s + block.previous_block_hash + block.timestamp + block.data)\n end",
"def hash!\n\t\t@@email.downcase!\n\t\thash = Digest::MD5.hexdigest(@@email)\n\t\treturn hash\n\tend",
"def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end",
"def computed_sha(string)\n provider.computed_sha(string)\n end",
"def sha256; end",
"def compute_checksum(h)\n begin\n signed_h = h.dup.with_indifferent_access\n CLEAR_OPTIONS.map{|o| signed_h.delete(o) }\n marshaled = ActionController::Routing::Route.new.build_query_string(signed_h)\n marshaled = marshaled.gsub(/^\\?/, '').split(/&/).sort.join('&')\n digest.call(self, Base64.encode64(marshaled.to_s.reverse)).to_s\n ensure\n end\n end",
"def digest_class\n Digest::SHA256\n end",
"def digest_class\n Digest::SHA256\n end",
"def digest_algorithm\n @digester.symbol || @digester.digest_name\n end",
"def create_checksum(hrp, data, spec)\n values = expand_hrp(hrp) + data\n const = (spec == Bech32::Encoding::BECH32M ? Bech32::BECH32M_CONST : 1)\n polymod = polymod(values + [0, 0, 0, 0, 0, 0]) ^ const\n (0..5).map{|i|(polymod >> 5 * (5 - i)) & 31}\n end",
"def calc_digest input\n Digest::SHA1.hexdigest(input.to_s).\n\n # XXX: surround all digits with alphabets so\n # Maruku doesn't change them into HTML\n gsub(/\\d/, 'z\\&z')\n end",
"def hash_secure\n sha256 = OpenSSL::Digest::SHA256.new\n enc64(sha256.digest)\n end",
"def update(data)\n i = 0\n while i < data.length\n data[i,i+NMAX].each_byte do |b|\n @s1 = @s1 + b\n @s2 = @s2 + @s1\n end\n @s1 = @s1 % BASE\n @s2 = @s2 % BASE\n i = i + NMAX\n end\n @count = @count + data.length\n return self.digest\n end",
"def hash(key); end",
"def _hash_digest(key)\n m = Digest::MD5.new\n m.update(key)\n\n # No need to ord each item since ordinary array access\n # of a string in Ruby converts to ordinal value\n return m.digest\n end",
"def calculate_secret(data, secret)\n data = data.sort{|a,b| a.to_s <=> b.to_s}.inject({}){|a,(k,v)| a[k.downcase.to_sym] = v; a}\n calculated_secret = Digest::SHA1.hexdigest(data.to_query + secret)\n data.merge(:sign => calculated_secret).to_query\n end",
"def calcChecksum(data)\n \n # calculate checksum\n checksum = 0xFF\n data.each_byte {|x| checksum ^= x }\n \n return checksum\n end",
"def fingerprint(algorithm = 'sha256')\n message_digest = R509::MessageDigest.new(algorithm)\n md = message_digest.digest\n md.update(@cert.to_der)\n md.to_s\n end",
"def hash\n bytes.hash\n end",
"def hash( *strs )\n return Digest::MD5.hexdigest( strs.join )\n end",
"def algorithm\n secret ? (@algorithm || ALGORITHM_HMAC_HS256) : 'none'\n end",
"def get_hash(key)\n (Zlib.crc32(key).abs % 100).to_s(36)\n end",
"def compute_hmac( payload )\n @hmac.digest( [ @sequence_number, payload ].pack( \"NA*\" ) )\n end",
"def hash\n prime = 31\n result = 1\n result = result * prime + (@decision_target == nil ? 0 : @decision_target.hash)\n result = prime * result + (@string_id == nil ? 0 : @string_id.hash)\n result\n end",
"def hash\n h = @e.nil? ? 0 : @e\n h = (h << 1) ^ @r.hash\n h = (h << 1) ^ @v.hash\n end"
] | [
"0.6684769",
"0.65408105",
"0.65167636",
"0.65106875",
"0.64701897",
"0.6467093",
"0.64469534",
"0.64468247",
"0.6390521",
"0.62007564",
"0.62007564",
"0.62007564",
"0.62007564",
"0.62007564",
"0.62007564",
"0.62007564",
"0.6139959",
"0.61081904",
"0.61081904",
"0.60989916",
"0.60687554",
"0.60189855",
"0.60123193",
"0.6012097",
"0.59486943",
"0.5871304",
"0.58681375",
"0.58636147",
"0.58147824",
"0.5804943",
"0.5790052",
"0.5756457",
"0.5752817",
"0.57525545",
"0.5717857",
"0.56682134",
"0.5658866",
"0.565225",
"0.5642687",
"0.5619776",
"0.5612174",
"0.5605095",
"0.55975544",
"0.5585585",
"0.557149",
"0.55514836",
"0.55455333",
"0.5540709",
"0.55377096",
"0.55296886",
"0.55275",
"0.55261993",
"0.5525277",
"0.5524476",
"0.5521064",
"0.55207634",
"0.55177104",
"0.5503213",
"0.5501128",
"0.549361",
"0.5474805",
"0.54610443",
"0.5460703",
"0.5460234",
"0.5459625",
"0.5445769",
"0.5434094",
"0.5433882",
"0.5424965",
"0.54208165",
"0.5414249",
"0.54001576",
"0.53951204",
"0.5394723",
"0.5393828",
"0.53931093",
"0.5385113",
"0.5382781",
"0.5376764",
"0.53765",
"0.5374473",
"0.53544116",
"0.53544116",
"0.53538597",
"0.5346929",
"0.5330953",
"0.5322373",
"0.5316665",
"0.5311975",
"0.5307376",
"0.53051335",
"0.53016",
"0.52984375",
"0.52927595",
"0.52810353",
"0.5270851",
"0.52649057",
"0.5260083",
"0.52597964",
"0.5259289"
] | 0.6242279 | 9 |
Computes the hash of specified public key using SHA256 algorithm. | def compute_public_key_hash(public_key)
public_key_der = Core::VirgilKeyPair.public_key_to_der(public_key)
if use_SHA256_fingerprints
return generate_hash(public_key_der, HashAlgorithm::SHA256)
end
generate_hash(public_key_der, HashAlgorithm::SHA512)[0..7]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sha256_fingerprint\n Base64.encode64(Digest::SHA256.digest(ssh_public_key_conversion)).gsub(\"\\n\", \"\")\n end",
"def hash_sha256(input)\n Digest::SHA2.new(256).digest(input)\n end",
"def sha256; end",
"def public_key_hash(hex)\n\t\trmd160(sha256(hex))\n\tend",
"def sha256_fingerprint(key)\n if key.match(/PRIVATE/)\n new(key).sha256_fingerprint\n else\n Base64.encode64(Digest::SHA256.digest(decoded_key(key))).gsub(\"\\n\", \"\")\n end\n end",
"def to_sha256(salt = \"\")\n hashsum(:sha256, salt)\n end",
"def sha256 key, data\n OpenSSL::HMAC.digest('sha256', key, data)\n rescue RuntimeError\n require 'hmac-sha2'\n HMAC::SHA256.digest(key, data)\n end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def public_key_hash\n Crypto.hash_public_key(public_key)\n end",
"def keccak256(data)\n Digest::SHA3.new(256).digest(data)\nend",
"def hash256(hex)\n binary = [hex].pack(\"H*\")\n hash1 = Digest::SHA256.digest(binary)\n hash2 = Digest::SHA256.digest(hash1)\n result = hash2.unpack(\"H*\")[0]\n return result\nend",
"def get_hash(key)\n (Zlib.crc32(key).abs % 100).to_s(36)\n end",
"def file_sha256_hash(file_path)\n file = File.read(file_path)\n Digest::SHA256.hexdigest(file) if file\n end",
"def sha256\n @sha256 ||= digest(path, :sha256)\n end",
"def calc_sha256 (secret)\n return nil if dummy_user?\n if provider == 'facebook'\n # uid cannot be used as global id for fb users. different uid f\n sha256_input = \"#{secret},#{self.api_profile_picture_url}/#{self.provider},#{self.user_name}\"\n else\n sha256_input = \"#{secret},#{self.uid}/#{self.provider},#{self.user_name}\"\n end\n Base64.encode64(Digest::SHA256.digest(sha256_input)).gsub(/\\n$/,'') # remove last /n - used as hash key in JS\n end",
"def hash\n keccak256(prefixed_message)\n end",
"def hash\n keccak256(prefixed_message)\n end",
"def hash256(hex)\n binary = [hex].pack(\"H*\")\n hash1 = Digest::SHA256.digest(binary)\n hash2 = Digest::SHA256.digest(hash1)\n return hash2.unpack(\"H*\").join\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash_secure\n sha256 = OpenSSL::Digest::SHA256.new\n enc64(sha256.digest)\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def compute_hashkey api_key, params\n joined_params = params.sort.map do |k,v|\n \"#{k}=#{v}\"\n end.join(JOIN_CHAR)\n Digest::SHA1.hexdigest \"#{joined_params}#{JOIN_CHAR}#{api_key}\"\n end",
"def hashkey_calculation(query)\n validate(query)\n query += '&' + api_key.to_s\n Digest::SHA1.hexdigest(query)\n end",
"def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end",
"def to_sha256\n Tapyrus.sha256(to_payload).bth\n end",
"def get_lh_hash(key)\n res = 0\n key.upcase.bytes do |byte|\n res *= 37\n res += byte.ord\n end\n return res % 0x100000000\n end",
"def sha_hash (arg)\r\n Digest::SHA2.hexdigest(arg)\r\n end",
"def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend",
"def fnvhash( key, len=key.length )\n state = 0x811C9DC5\n\n len.times{ |i|\n state ^= key[i]\n state *= 0x1000193\n }\n\n return state\nend",
"def calculate_hash(apikey, apisecret, timestamp, parameters)\n # gather values included in hash, sort them alphabetically\n\tsig_params = Hash.new\n\tsig_params[:apikey] = apikey\n\tsig_params[:apisecret] = apisecret\n\tsig_params[:ts] = timestamp\n\t\n\t# stringify the values to be hashed - e.g. key1=value1&key2=value2&key3=value3\n\tstring_to_hash = ''\n\tsig_params.sort.map do |key,value|\n\t string_to_hash = string_to_hash + key.to_s + \"=\" + value.to_s + \"&\"\n\tend\n\tstring_to_hash = string_to_hash.chomp('&') # Ensuring that the last '&' is removed.\n\t\n\t# compute the SHA256 hash and return as a string\n\tDigest::SHA256.hexdigest(string_to_hash).to_s\nend",
"def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end",
"def hash(message)\n return Digest::SHA1.hexdigest(message)\n end",
"def SHA256 arr\n Digest::SHA256.digest(arr.map(&:chr).join).bytes\nend",
"def sha\n result_hash['sha']\n end",
"def sha256\n # get all dependency checksums\n deps = Hash[locked_dependencies.list.map { |k, v| [k, v.profile.sha256] }]\n\n res = OpenSSL::Digest::SHA256.new\n files = source_reader.tests.to_a + source_reader.libraries.to_a +\n source_reader.data_files.to_a +\n [[\"inspec.yml\", source_reader.metadata.content]] +\n [[\"inspec.lock.deps\", YAML.dump(deps)]]\n\n files.sort_by { |a| a[0] }\n .map { |f| res << f[0] << \"\\0\" << f[1] << \"\\0\" }\n\n res.digest.unpack(\"H*\")[0]\n end",
"def sign(message)\n OpenSSL::HMAC.digest('SHA256', @key, message)\n end",
"def hash(key); end",
"def compute_hash( path )\n res = '0'\n autorelease_pool { res = NSData.sha1FromContentsOfFile(path) }\n res\n end",
"def sha256(options = {})\n required_input_files :path\n required_output_values :sha256\n\n path = input_file(:path)\n\n unless File.exist?(path)\n raise \"path '#{path}' does not exist\"\n end\n \n sha256 = FileHash.sha256(path)\n output_value(:sha256, sha256)\n\n return true\n end",
"def computed_sha(string)\n provider.computed_sha(string)\n end",
"def hash_key(style_name = default_style)\n raise ArgumentError, \"Unable to generate hash without :hash_secret\" unless @options[:hash_secret]\n\n require \"openssl\" unless defined?(OpenSSL)\n data = interpolate(@options[:hash_data], style_name)\n OpenSSL::HMAC.hexdigest(OpenSSL::Digest.const_get(@options[:hash_digest]).new, @options[:hash_secret], data)\n end",
"def call( *args )\n text = args.shift.to_s\n bitlength = (args.shift || 256).to_i\n Digest::SHA2.new( bitlength ).hexdigest( text )\n end",
"def hash(*) end",
"def test_sha256_of_prime\n n = BIG_PRIME_N\n nhex = '%x' % [n]\n assert_equal \"494b6a801b379f37c9ee25d5db7cd70ffcfe53d01b7c9e4470eaca46bda24b39\",\n sha256_hex(nhex)\n end",
"def calc_hash(pass)\n salt_cost = SCrypt::Engine.autodetect_cost(self[:salt])\n SCrypt::Engine.scrypt(pass, self[:salt], salt_cost, 32).unpack('H*').first\n end",
"def hmac_sha256(data, secret)\n OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), secret, data)\n end",
"def public_key_fingerprint\n Cryptosphere.kdf(public_key).unpack('H*').first.scan(/.{4}/).join(\":\")\n end",
"def hash(block)\n Digest::SHA256.hexdigest(block.to_s.encode)\n end",
"def generate_hash(*args)\n Digest::SHA3.hexdigest(args.join(''))\n end",
"def generate_hash(*args)\n Digest::SHA3.hexdigest(args.join(''))\n\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def digest(message)\n OpenSSL::HMAC.digest SHA256, @secret, message\n end",
"def fingerprint(filename)\n \"SHA256: \" + X509.fingerprint(\"SHA256\", Path.named_path(filename))\n end",
"def digest_class\n Digest::SHA256\n end",
"def digest_class\n Digest::SHA256\n end",
"def dave(new_str)\r\n new_hash = Digest::SHA256.hexdigest new_str\r\n return new_hash\r\nend",
"def algorithm\n \"HS256\"\n end",
"def hash_secure\n # TODO: Use sha256 from openssl to create a cryptographically secure hash.\n # Credit cards with identical information should produce the same hash.\n\n sha256 = OpenSSL::Digest::SHA256.new\n sha256.digest(self.to_s).unpack('h*')\nend",
"def signature\n Digest::SHA256.hexdigest(@hash.to_json)\n end",
"def pubkey_hash160\n if set_pubkey_hash160\n set_pubkey_hash160 \n elsif multisig_pubkey\n hash160 multisig_pubkey\n else\n hash160( pubkey )\n end\n end",
"def HMAC_SHA2_256 key, msg\n # skipping the key hashing step, as we can assume that it's small enough\n blockSize = 512 / 8\n key = key.ljust blockSize, 0\n o_padded = key.xor ([0x5c] * blockSize).each\n i_padded = key.xor ([0x36] * blockSize).each\n\n o = SHA256(o_padded + SHA256(i_padded + msg))\nend",
"def aws_sign(key, data)\n OpenSSL::HMAC.digest(\"SHA256\", key, data)\n end",
"def hpkp_sha256_pin\n @hpkp_sha256_pin ||= @node['hpkpSha256Pin']\n end",
"def c_hash\n sha256 = Digest::SHA256.new\n token = @code.token.token\n hashed_token = sha256.digest(token)\n first_half = hashed_token[0...hashed_token.length / 2]\n Base64.urlsafe_encode64(first_half).tr('=', '')\n end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def file_sha256\n Digest::SHA256.file(self).hexdigest\n end",
"def generate_hash(bytes, algorithm = nil)\n bytes = Validation.check_filled_array_argument!(bytes)\n\n alg = algorithm\n alg ||= use_SHA256_fingerprints ? HashAlgorithm::SHA256 : HashAlgorithm::SHA512\n\n begin\n native_algorithm = HashAlgorithm.convert_to_native(alg)\n native_hasher = Core::VirgilHash.new(native_algorithm)\n wrap_bytes(native_hasher.hash(bytes))\n rescue StandardError => error\n raise VirgilCryptoException, error.message\n end\n end",
"def sha256(files)\n sha = Digest::SHA2.new\n files.each do |f|\n next if File.directory?(f)\n\n content = File.binread(f)\n # work around possible git checkout issues by removing CR and LF from the file\n content.gsub!(\"\\n\", \"\")\n content.gsub!(\"\\r\", \"\")\n sha << content\n end\n sha.hexdigest\n end",
"def hashcode_with_internal_hashes(key)\n h, full_hs = phf_with_hashes(key)\n if @g[h] == @r\n return NON_KEY, full_hs # no key\n end\n a, b = h.divmod(RANK_SUPERBLOCKSIZE)\n if a == 0\n result = 0\n else\n result = @rs[a-1]\n end\n b, c = b.divmod(RANK_BLOCKSIZE)\n if b != 0\n result += @rb[a*(RANK_SUPERBLOCKSIZE/RANK_BLOCKSIZE-1)+b-1]\n end\n (h-c).upto(h-1) {|i|\n result += 1 if @g[i] != @r\n }\n return result, full_hs\n end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def generate_hashkey_for(params, api_key)\n sorted_params = sort_params(params)\n params_string = concat_params(sorted_params)\n Digest::SHA1.hexdigest \"#{params_string}&#{api_key}\"\n end",
"def verify_sha256_hash(filename, hash)\n require 'digest/sha2'\n compare_hash(filename, Digest::SHA2, hash)\n end",
"def get_hash(input)\n return $hasher.reset.update(input).to_s\nend",
"def pubkey\n # Split every 2 bytes\n paths = combined_hash.unpack('S>*')\n paths.inject(payment_base) { |key, p| key.derive(p) }\n end",
"def public_key_to_address(public_key_bin)\n Secp256k1::Util.bin_to_hex(keccak256(public_key_bin[1..-1])[-20..-1])\nend",
"def hash_secure\n # TODO: implement this method\n # - Use sha256 from openssl to create a cryptographically secure hash.\n # - Credit cards with identical information should produce the same hash\n OpenSSL::Digest::SHA256.digest(to_s).unpack(\"H*\")\n end",
"def jshash( key, len=key.length )\n state = 1315423911\n len.times{ |i|\n state ^= ( ( state << 5 ) + key[i] + ( state >> 2 ) )\n }\n return state\nend",
"def ecdh_public_key_bytes; end",
"def makehash(body)\n Log.debug(\"Creating message hash using #{private_key_file}\")\n\n sign(private_key_file, body.to_s)\n end",
"def hash_code\n prime = 31\n result = 1\n result = prime * result + x\n result = prime * result + y\n return result;\n end",
"def bphash( key, len=key.length )\n state = 0\n \n len.times{ |i|\n state = state << 7 ^ key[i]\n }\n return state\nend",
"def ssh_public_key_bits(ssh_public_key)\n ssh_type, encoded_key = parse_ssh_public_key(ssh_public_key)\n sections = unpacked_byte_array(ssh_type, encoded_key)\n\n case ssh_type\n when \"ssh-rsa\", \"ssh-dss\", \"ssh-ed25519\"\n sections.last.num_bytes * 8\n\n when \"ecdsa-sha2-nistp256\", \"ecdsa-sha2-nistp384\", \"ecdsa-sha2-nistp521\"\n raise PublicKeyError, \"invalid ECDSA key\" unless sections.count == 2\n\n # https://tools.ietf.org/html/rfc5656#section-3.1\n identifier = sections[0].to_s(2)\n q = sections[1].to_s(2)\n ecdsa_bits(ssh_type, identifier, q)\n\n else\n raise PublicKeyError, \"unsupported key type #{ssh_type}\"\n end\n end",
"def digest\n Digest::SHA1.hexdigest(@pub.to_der)\n end",
"def data_hash(code, params)\n OpenSSL::Digest::SHA256.digest(JWT.canonical_json(data(code, params)))\n end",
"def makehash(body)\n signer = SSH::Key::Signer.new\n if @config.pluginconf[\"sshkey\"]\n signer.add_key_file(@config.pluginconf[\"sshkey\"])\n signer.use_agent = false\n end\n signatures = signer.sign(body).collect { |s| s.signature }\n return Marshal.dump(signatures)\n end",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def sha1_fingerprint\n Digest::SHA1.hexdigest(ssh_public_key_conversion).gsub(/(.{2})(?=.)/, '\\1:\\2')\n end",
"def hashcode(key)\n hashcode_with_internal_hashes(key).first\n end",
"def H(n, *a)\n nlen = 2 * ((('%x' % [n]).length * 4 + 7) >> 3)\n hashin = a.map {|s|\n next unless s\n shex = s.class == String ? s : \"%x\" % s\n if shex.length > nlen\n raise \"Bit width does not match - client uses different prime\"\n end\n \"0\" * (nlen - shex.length) + shex\n }.join('')\n sha1_hex(hashin).hex % n\n end",
"def get_pre_keyed_hash(password)\n md = OpenSSL::Digest::SHA1.new\n passwd_bytes = []\n password.unpack('c*').each do |byte|\n passwd_bytes << (byte >> 8)\n passwd_bytes << byte\n end\n md << passwd_bytes.pack('c*')\n md << 'Mighty Aphrodite'.force_encoding('UTF-8')\n md\n end",
"def hexhash\n hash.to_s(16)\n end",
"def gnu_hash(s)\n s.bytes.reduce(5381) { |acc, elem| (acc * 33 + elem) & 0xffffffff }\n end",
"def H(n, *a)\n nlen = 2 * (((n.to_hex_string).length * 4 + 7) >> 3)\n hashin = a.map {|s|\n next unless s\n shex = s.class == String ? s : s.to_hex_string\n if shex.length > nlen\n raise 'Bit width does not match - client uses different prime'\n end\n '0' * (nlen - shex.length) + shex\n }.join('')\n sha512_hex(hashin).hex % n\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end"
] | [
"0.7054746",
"0.70079035",
"0.69625574",
"0.68718785",
"0.680094",
"0.6739665",
"0.6704688",
"0.6531241",
"0.6473964",
"0.64384395",
"0.64201456",
"0.6352545",
"0.63488555",
"0.6336968",
"0.63226444",
"0.62910837",
"0.62347096",
"0.6221486",
"0.62204427",
"0.6139459",
"0.61155945",
"0.6093482",
"0.60785824",
"0.60556394",
"0.6032766",
"0.59821546",
"0.5972263",
"0.5916433",
"0.59071505",
"0.5900642",
"0.58609873",
"0.5822714",
"0.58107066",
"0.57980657",
"0.57844424",
"0.5779195",
"0.576414",
"0.5755612",
"0.5754673",
"0.57537943",
"0.5746331",
"0.5743779",
"0.57404524",
"0.5736509",
"0.57219857",
"0.57004565",
"0.5698603",
"0.5681407",
"0.5673271",
"0.5668527",
"0.56670743",
"0.56670743",
"0.56670743",
"0.56670743",
"0.56670743",
"0.56670743",
"0.56670743",
"0.5658507",
"0.5633853",
"0.5633339",
"0.5633339",
"0.5620544",
"0.560474",
"0.56033903",
"0.5586034",
"0.55775785",
"0.5559289",
"0.5553155",
"0.5537811",
"0.55363214",
"0.552903",
"0.5527437",
"0.55130017",
"0.55045474",
"0.55011594",
"0.5494151",
"0.5491497",
"0.54874384",
"0.5484189",
"0.5481905",
"0.54759026",
"0.54643726",
"0.5463983",
"0.546273",
"0.5451807",
"0.54323274",
"0.54301214",
"0.54290056",
"0.54231745",
"0.54112226",
"0.54042286",
"0.5382225",
"0.53721666",
"0.5367146",
"0.5363963",
"0.53616023",
"0.535645",
"0.5356398",
"0.53451747",
"0.53370243"
] | 0.7633406 | 0 |
GET /attachments/1 GET /attachments/1.json | def show
@attachment = Attachment.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @attachment }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attachment(id)\n response = conn.get 'api/files/attachments/' + id\n\n unless response.status == 200\n error_model = JSON.load(response.body)\n mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \\'' + response.status.to_s + '\\'', error_model)\n raise mailosaur_error\n end\n\n response.body\n end",
"def show\n @message_attachment = MessageAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @message_attachment }\n end\n end",
"def index\n @channel = Channel.find_by_name(params[:channel_id])\n @attachments = @channel.attachments.order(\"created_at DESC\")\n\n respond_to do |format|\n format.json { render :json => @attachments.to_json(:methods => :url) }\n end\n end",
"def get_attachment(name)\n\n unless (model.properties.has_property?(:attachments) &&\n model.properties[:attachments].type == DataMapper::Types::JsonObject &&\n model.properties[:attachments].field == :_attachments)\n raise ArgumentError, \"Attachments require ' property :attachments, JsonObject, :field => :_attachments'\"\n end\n\n unless self.id && self.attachments && self.attachments[name]\n nil\n else\n http = Net::HTTP.new(repository.adapter.uri.host, repository.adapter.uri.port)\n uri = attachment_path(name)\n response, data = http.get(uri, { 'Content-Type' => self.attachments[name]['content_type'] })\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end",
"def index\n @attachments = Attachment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attachments }\n end\n end",
"def index\n @attachments = Attachment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @attachments }\n end\n end",
"def retrieve_attachment(name)\n { :file => RestClient.get(\"#{ uri }/#{ CGI.escape(name) }\"),\n :content_type => JSON.parse(RestClient.get(uri))['_attachments']['name'] }\n end",
"def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end",
"def index\n @attachments = Attachment.all\n end",
"def index\n @attachments = Attachment.all\n end",
"def index\n @attachments = Attachment.all\n end",
"def index\n @attachments = Attachment.all\n end",
"def index\n @attachments = Attachment.all\n end",
"def get_attachment(attachment_id)\n params = {'key' => @api_key}\n RestClient.get(\"#{@base_uri}/attachment/#{attachment_id}\", {:params => params}).body\n end",
"def get_attachment(name)\n assert_attachments_property\n\n attachment = self.attachments[name] if self.attachments\n\n unless self.id && attachment\n nil\n else\n adapter = repository.adapter\n http = Net::HTTP.new(adapter.uri.host, adapter.uri.port)\n uri = Addressable::URI.encode_component(attachment_path(name))\n response, data = http.get(uri, 'Content-Type' => attachment['content_type'])\n\n unless response.kind_of?(Net::HTTPSuccess)\n nil\n else\n data\n end\n end\n\n end",
"def attachment( document_id, attachment_id )\n new( :id => document_id ).attachments.get!( attachment_id )\n end",
"def fetch_attachment(document_id, attachment_name)\n server.get(\"#{name}/#{CGI.escape(document_id)}/#{CGI.escape(attachment_name)}\", :no_json => true)\n end",
"def getAttachment(attachmentId)\n params = Hash.new\n params['key'] = @API_KEY\n response = RestClient.get(@BASE_URI + '/attachment/' + attachmentId, {:params => params})\n return response.body\n end",
"def list_attachments\n @artifact_answer = ArtifactAnswer.find(params[:id])\n @attachments = @artifact_answer.attachments\n render layout: false\n end",
"def get_issue_attachments(issue_id_or_key)\n get(\"issues/#{issue_id_or_key}/attachments\")\n end",
"def show\n @attachment_datum = AttachmentDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attachment_datum }\n end\n end",
"def get_attachment(*params)\n tid = params[0]\n aid = params[1]\n dir = nil\n dir = params[2] if params.size > 2\n if params[0].class == Hash\n params = params[0]\n tid = params[:ticket] if params.has_key? :ticket\n aid = params[:attachment] if params.has_key? :attachment\n dir = params[:dir] if params.has_key? :dir\n end\n tid = $~[1] if tid =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{tid}/attachments/#{aid}\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss HTTP response\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n headers = response_to_h(resp)\n reply = {}\n headers.each do |k,v|\n reply[\"#{k}\"] = v.to_s\n end\n content = resp.match(/Content:\\s+(.*)/m)[1]\n content.gsub!(/\\n\\s{9}/,\"\\n\") # strip leading spaces on each line\n content.chomp!\n content.chomp!\n content.chomp! # 3 carriage returns at the end\n if (RUBY_VERSION.to_f >= 1.9)\n binary = content.encode(\"ISO-8859-1\",\"UTF-8\", { :invalid => :replace, :undef => :replace })\n else\n binary = Iconv.conv(\"ISO-8859-1\",\"UTF-8\",content) # convert encoding\n end\n if dir\n fh = File.new(\"#{dir}/#{headers['Filename'].to_s}\",\"wb\")\n fh.write binary\n fh.close\n else\n reply[\"content\"] = binary\n end\n reply\n end",
"def attachments(message_id, params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment\", params: params)\n end",
"def attachment(name)\n name = name.to_s\n return attachments[name][:file] if @attachments.try(:[], :name).try(:[], :file)\n begin\n result = retrieve_attachment(name)\n @attachments = (@attachments || {}).merge(name => {:file => result[:file], :dirty => false, :content_type => result[:content_type]})\n result[:file]\n rescue RestClient::ResourceNotFound\n nil\n end\n end",
"def get_attachment attachment_index\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if attachment_index == ''\n raise 'attachment index not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/attachments/' + attachment_index.to_s\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Attachment']\n \n \n rescue Exception=>e\n print e\n end\n end",
"def show\n @attachment = @page.attachments.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @attachment.to_xml }\n end\n end",
"def index\n @attachments = @pad.attachments\n @attachment = @pad.attachments.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attachments }\n end\n end",
"def show\n @attachments = @document.attachments\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def get_attachment(db, locale, version, attachment_name, ttl=settings.long_ttl)\n id = get_topic_or_image_id(locale, version, attachment_name)\n return get_from_db_or_cache(db, id, {:trx => CouchDBTransaction::FETCH_ATTACHMENT, :attachment_name => attachment_name}, ttl)\n end",
"def show\n # These are expected and required by the file_handler route: \"file_attachments/:content_type/:parent_id/:id\"\n id = params[:id]\n parent_id = params[:parent_id]\n \n case params[:content_type]\n when \"PrivateMessage\" \n # Only users involved in PM conversations can view attachments\n file_attachment = PrivateMessage.with_recipients.with_user(session[:user_id]).with_attachments.find(parent_id).file_attachments.find(id)\n when \"NewsArticle\"\n file_attachment = NewsArticle.include_attachments.find(parent_id).file_attachments.find(id)\n else \n end\n \n # Sanitize path to ensure that the path is not pointing anywhere malicious on the server \n path = file_attachment.attachment.path\n raise MissingFile, \"Couldn't read #{file_attachment.attachment_file_name}\" unless\n File.readable?(path) and\n File.file?(path)\n \n send_file file_attachment.attachment.path, :type => file_attachment.attachment_content_type\n end",
"def attachments\n @attachments\n end",
"def get_all_attachments(page_id)\n\n url = \"#{@@conf_url}/#{@@urn}/#{page_id}/child/attachment?os_username=#{@@login}&os_password=#{@@pwd}&status=current\"\n\n begin\n atts = RestClient.get url, :content_type => 'application/json', :accept => 'json'\n rescue RestClient::ExceptionWithResponse => e\n puts Nokogiri.XML(e.response)\n nil\n end\n\n unless atts.nil?\n JSON.parse(atts)[\"results\"]\n end\n end",
"def show\n @pattachment = Pattachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pattachment }\n end\n end",
"def attachments\n Easybill::Api::Attachments\n end",
"def show\n @meeting = Meeting.find(params[:id])\n @json_from_file = 0\n for file in @meeting.file.attachments\n if file.content_type == 'application/json'\n download_file_from_s3('smartmeetingsbelieving', \"./tmp/\" + file.filename.to_s(), file.filename.to_s())\n @json_from_file = File.read(\"tmp/\" + file.filename.to_s())\n end\n end\n end",
"def get(\n id,\n deadline: nil\n )\n return @account_attachments.get(\n id,\n deadline: deadline,\n )\n end",
"def attachments\n load_object\n load_attachments\n render layout: false\n end",
"def show\n email = Gmailer.gmail.inbox.find(:all).find {|e| e.msg_id == @message.message_id.to_i } #convert due to wrong type\n @attachments = email ? email.message.attachments : []\n end",
"def show\n @record_id = params[:id]\n\n # run the where clause globally\n @relevant_record = Record.find(@record_id)\n @relevant_attachments = RecordAttachment.where(record_id: @record_id).order(\"id\")\n\n # make the record attachments an array if it isn't already \n if @relevant_attachments.length > 1\n @record_attachments = @relevant_attachments\n else \n @record_attachments = [@relevant_attachments[0]]\n end\n\n respond_to do |format|\n format.html {}\n format.json { render json: {\n record: @relevant_record, \n attachments: @record_attachments,\n }.to_json }\n end\n end",
"def attachments\n @attachments ||= []\n end",
"def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end",
"def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end",
"def show\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @attachment }\n end\n end",
"def get_email_attachments\n\t\tresp = @resp\n\n\t\tparams[\"email\"] ||= \"\"\n\t\tparams[\"password\"] ||= \"\"\n\n\t\t# Authorize and process attachments in mail account\n\t\tresp = Resume.gmail_attachments(resp, params)\n\n\t\trender :json => resp\n end",
"def index\n @post_attachments = PostAttachment.all\n end",
"def index\n @post_attachments = PostAttachment.all\n end",
"def get_attachment\n @document = EcoDocument.find(params[:id])\n send_data(@document.data,\n :filename => @document.name,\n :type => @document.content_type,\n :disposition => \"inline\")\n end",
"def show\n @cause_analyasis = CauseAnalysis.find(params[:id])\n @attachment = @cause_analyasis.attachment\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cause_analyasis }\n end\n end",
"def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NotesApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n path = \"/Notes/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<APIFileAttachment>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: NotesApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def attachments\n parts.attachments\n end",
"def show\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @attached_asset }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def index\n @embedded_attachments = EmbeddedAttachment.page params[:page]\n end",
"def index\n @cms_attachments = Cms::Attachment.all\n end",
"def index\n @pub_attachments = PubAttachment.all\n end",
"def find_attachment(resource_id, attachment_id)\n http.get(\"#{attachment_endpoint(resource_id)}/#{attachment_id}\") do |response|\n Rexpense::Entities::Attachment.new response.parsed_body\n end\n end",
"def index\n @file_attachments = FileAttachment.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_attachments }\n end\n end",
"def show\n @post_attachments = @post.post_attachments.all\n end",
"def show\n @post_attachments = @post.post_attachments.all\n end",
"def attachment\n @attachment\n end",
"def attachments\n if attachment_ids\n attachment_ids.map {|id| Attachment.find(id)}\n else\n []\n end\n end",
"def show\n @file_upload_attachments = @file_upload.file_upload_attachments.all\n end",
"def get_document_attachments_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PdfApi.get_document_attachments ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PdfApi.get_document_attachments\"\n end\n # resource path\n local_var_path = \"/pdf/{name}/attachments\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].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 # Fix header in file\n post_body = nil\n\n # http body (model)\n # Fix header in file\n # post_body = nil\n auth_names = ['JWT']\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 => 'AttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PdfApi#get_document_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def attachments\n @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name)\n end",
"def show\n @file_attachment = FileAttachment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end",
"def index\n @user_attachments = UserAttachment.all\n end",
"def retrieveImages\n posting = Posting.find(params[:id])\n post_attachments = posting.post_attachments.all\n respond_to do |format|\n format.json { render json: {\n status: 'ok',\n rowcount: post_attachments.length,\n results: post_attachments.map { |b| {\n id: b.id,\n imageData: b.image,\n description: b.description\n }}\n }}\n end\n end",
"def item_only_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = @relevant_object.media_items\n end",
"def fetch_attachment(post, attachment_name, attachment_type)\n server_urls = perform_legacy_discovery(post[:entity])\n return unless server_urls.any?\n\n res = server_urls.inject(nil) do |memo, server_url|\n url = \"#{server_url}/posts/#{URI.encode_www_form_component(post[:entity])}/#{post[:public_id]}/attachments/#{attachment_name}\"\n res = Faraday.get(url) do |req|\n req.headers['Accept'] = attachment_type\n end\n\n if res.status == 200\n break res\n end\n\n res\n end\n\n res\n end",
"def index\n @note_attachments = NoteAttachment.all\n end",
"def retrieve_fresh_attachment\n Attachment.find(attachment.id)\n end",
"def get_file_attachments_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: EmailsApi#get_file_attachments ...\"\n end\n \n # verify the required parameter 'id' is set\n fail \"Missing the required parameter 'id' when calling get_file_attachments\" if id.nil?\n \n # resource path\n local_var_path = \"/Emails/{id}/FileAttachments\".sub('{format}','json').sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'updated_after_utc'] = opts[:'updated_after_utc'] if opts[:'updated_after_utc']\n query_params[:'skip'] = opts[:'skip'] if opts[:'skip']\n query_params[:'top'] = opts[:'top'] if opts[:'top']\n query_params[:'count_total'] = opts[:'count_total'] if opts[:'count_total']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<InlineResponse2002>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: EmailsApi#get_file_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @file_upload_attachments = FileUploadAttachment.all\n end",
"def get_document_attachments(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = get_document_attachments_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def index\n @link_attachments = LinkAttachment.all\n end",
"def attachments\n @_message.attachments\n end",
"def attachments(params={})\n raise ArgumentError, \"Error: ids or attachment_ids must be set\" unless params[:ids] || params[:attachment_ids]\n rpc_call :attachments, params\n end",
"def attachment_get\n c_user = current_user()\n course = Course.where(id: params[:course_id]).first()\n\n # Course not found case\n if course.nil?\n return ( render status: 404, json: { result: \"Course Not Found\" } )\n end\n\n # Course found case\n if params[:type] == \"Document\"\n attache = Document.where(id: params[:attach_id], attachable_id: course.id).first()\n elsif params[:type] == \"Embed\"\n attache = Embed.where(id: params[:attach_id], attachable_id: course.id).first()\n end\n\n # Attachment not found case\n if attache.nil?\n return ( render status: 404, json: { result: \"Attachable Not Found\" } )\n end\n\n # Public case:\n if course.visibility == Visibility.published \n render status: 200, json: { result: attache}\n\n # Authenticated case:\n elsif logged_in? # Ensure that the user is logged in\n # Checks IF user is privledged or owns the course, ELSE return unauthorized\n if c_user.role == Role.admin or c_user.role == Role.moderator or\n c_user.id == course.user_id then\n render status: 200, json: { result: attache }\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n\n # Course is not (public) AND (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end",
"def attachments\n return @attachments\n end",
"def attachments\n return @attachments\n end",
"def attachments\n return @attachments\n end",
"def get_attachment_by_message_id(token, id, fields = nil, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id << \"/attachments/\"\n request_params = nil\n\n unless fields.nil?\n request_params = { '$select' => fields.join(',') }\n end\n\n get_message_response = make_api_call \"GET\", request_url, token, request_params\n\n parse_response(get_message_response)\n end",
"def attachment(key)\n # Use to_a.find to take advantage of the eager-loaded attachments and blobs.\n attachments.to_a.find { |a| a.key == key && a.file&.attached? }\n end",
"def show\n @ticket_attachments = @ticket.ticket_attachments.all\n end",
"def index\n @order_attachments = OrderAttachment.all\n end",
"def index\n @gallery_attachments = GalleryAttachment.all\n end",
"def show\n @attachment = @specification.attachment\n end",
"def list_attachments_with_http_info(identifier, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AlertApi.list_attachments ...\"\n end\n # verify the required parameter 'identifier' is set\n if @api_client.config.client_side_validation && identifier.nil?\n fail ArgumentError, \"Missing the required parameter 'identifier' when calling AlertApi.list_attachments\"\n end\n if @api_client.config.client_side_validation && opts[:'alert_identifier_type'] && !['id', 'alias', 'tiny'].include?(opts[:'alert_identifier_type'])\n fail ArgumentError, 'invalid value for \"alert_identifier_type\", must be one of id, alias, tiny'\n end\n # resource path\n local_var_path = \"/v2/alerts/{identifier}/attachments\".sub('{' + 'identifier' + '}', identifier.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'alertIdentifierType'] = opts[:'alert_identifier_type'] if !opts[:'alert_identifier_type'].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 = ['GenieKey']\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 => 'ListAlertAttachmentsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AlertApi#list_attachments\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get(\n id,\n deadline: nil\n )\n req = V1::AccountAttachmentGetRequest.new()\n if not @parent.snapshot_time.nil?\n req.meta = V1::GetRequestMetadata.new()\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.id = (id)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.get(req, metadata: @parent.get_metadata(\"AccountAttachments.Get\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + [email protected](tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = AccountAttachmentGetResponse.new()\n resp.account_attachment = Plumbing::convert_account_attachment_to_porcelain(plumbing_response.account_attachment)\n resp.meta = Plumbing::convert_get_response_metadata_to_porcelain(plumbing_response.meta)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp\n end",
"def get_mail_attachment\n Log.add_info(request, params.inspect)\n\n attached_id = params[:id].to_i\n begin\n mail_attach = MailAttachment.find(attached_id)\n rescue => evar\n end\n\n if mail_attach.nil?\n redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html')\n return\n end\n\n begin\n email = Email.find(mail_attach.email_id)\n rescue => evar\n end\n if email.nil? or email.user_id != @login_user.id\n render(:text => '')\n return\n end\n\n mail_attach_name = mail_attach.name\n\n agent = request.env['HTTP_USER_AGENT']\n unless agent.nil?\n ie_ver = nil\n agent.scan(/\\sMSIE\\s?(\\d+)[.](\\d+)/){|m|\n ie_ver = m[0].to_i + (0.1 * m[1].to_i)\n }\n mail_attach_name = CGI::escape(mail_attach_name) unless ie_ver.nil?\n end\n\n filepath = mail_attach.get_path\n if FileTest.exist?(filepath)\n send_file(filepath, :filename => mail_attach_name, :stream => true, :disposition => 'attachment')\n else\n send_data('', :type => 'application/octet-stream;', :disposition => 'attachment;filename=\"'+mail_attach_name+'\"')\n end\n end",
"def get_attachments()\n\t\t\n\t\tmessages = list_of_messages()\n\n\t\t#Initializing Nested Hash so that we can store message_id, file_name and attachemnt id\n\t\tfiles= Hash.new { |l, k| l[k] = Hash.new(&l.default_proc) }\n\t\tmessages.each do |message_id|\n\t\t\n\t\t\t#Create a new request\n\t\t\trequest_url = \"https://www.googleapis.com/gmail/v1/users/#{@email}/messages/#{message_id}?access_token=#{@access_token}\"\n\n\t\t\t#GET REQUEST\n\t\t\tresponse = RestClient.get request_url\n\t\t\tresponse_body = JSON.parse(response.body)\n\n\t\t\t#Getting list of attachments based on message id\n\t\t\ttemp = response_body['payload']['parts']\n\t\t\ttemp.each do |item|\n\t\t\t\tif item['filename'] !=''\n\t\t\t\t\tfiles[message_id][item['filename']]=item['body']['attachmentId']\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\t\treturn files\n\tend",
"def show\n @conference=Conference.find(params[:conference_id])\n @issue = @conference.issues.find(params[:id])\n @[email protected]\n respond_to do |format|\n format.html # show.html.erb\n format.js\n end\n end",
"def get_sas_logical_jbod_attachments(client)\n OneviewSDK::Resource.find_with_pagination(client, ATTACHMENT_URI)\n end",
"def show\n attachment = current_attachment\n\n respond_to do |format|\n format.csv do\n send_data(\n attachment.file.blob.download,\n type: 'text/csv',\n filename: \"#{attachment.key}.#{attachment.scenario_id}.csv\"\n )\n end\n\n format.any do\n render json: attachment_json(attachment)\n end\n end\n end",
"def index\n @design_image_attachments = DesignImageAttachment.all\n end"
] | [
"0.7399391",
"0.72964424",
"0.72533566",
"0.7209824",
"0.7198998",
"0.7198998",
"0.7146045",
"0.7035432",
"0.7027209",
"0.7027209",
"0.7027209",
"0.7027209",
"0.7027209",
"0.69881076",
"0.698674",
"0.6962234",
"0.6919316",
"0.68941605",
"0.68771505",
"0.68515855",
"0.6847571",
"0.6832826",
"0.68288106",
"0.68180805",
"0.681422",
"0.6808292",
"0.6800862",
"0.67679405",
"0.6749378",
"0.67490685",
"0.67100513",
"0.67003244",
"0.66753167",
"0.6670686",
"0.66577566",
"0.6648303",
"0.6636511",
"0.6632548",
"0.65756",
"0.6553501",
"0.65228766",
"0.65228766",
"0.65228766",
"0.6520082",
"0.6502678",
"0.6502678",
"0.6500793",
"0.6491026",
"0.6490284",
"0.6481953",
"0.6458639",
"0.64582765",
"0.64582765",
"0.6457385",
"0.6428891",
"0.6415365",
"0.63983554",
"0.63769287",
"0.6368925",
"0.6362036",
"0.6362036",
"0.63610697",
"0.63460094",
"0.63404197",
"0.63369274",
"0.6334946",
"0.63319683",
"0.6313881",
"0.63071346",
"0.6304966",
"0.6303732",
"0.62977904",
"0.62804025",
"0.626594",
"0.6265914",
"0.62569785",
"0.6233461",
"0.6231466",
"0.6221325",
"0.6217792",
"0.62165487",
"0.62165487",
"0.62165487",
"0.62056464",
"0.61996967",
"0.6194821",
"0.61848664",
"0.61784863",
"0.61779314",
"0.61772484",
"0.6169584",
"0.61653024",
"0.61447936",
"0.61335605",
"0.6132967",
"0.6123112",
"0.60943896"
] | 0.7392096 | 3 |
GET /attachments/new GET /attachments/new.json | def new
@attachment = Attachment.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @attachment }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @message_attachment = MessageAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message_attachment }\n end\n end",
"def new\n @attachment_datum = AttachmentDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment_datum }\n end\n end",
"def new\n @attached = Attached.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached }\n end\n end",
"def new\n @attached = Attached.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached }\n end\n end",
"def new\n @pattachment = Pattachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pattachment }\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 @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attachment }\n end\n end",
"def new\n @file_attachment = FileAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @file_attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n @courses = Course.where(:user_id => current_user)\n @assignments = Assignment.where(:user_id => current_user)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def new\n @attached_asset = AttachedAsset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attached_asset }\n end\n end",
"def new\n @event = Event.new\n 3.times { @event.attachments.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end",
"def new\n @importation_attachment = ImportationAttachment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @importation_attachment }\n end\n end",
"def new\n @task = Task.new\n @project = Project.find(params[:project_id])\n @attachment = @task.attachments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end",
"def new\n @gig = Gig.new()\n @gig.build_attachment\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gig }\n end\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @action_file = ActionFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_file }\n end\n end",
"def new\n @bulletin_file = BulletinFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bulletin_file }\n end\n end",
"def new\n @mfile = Mfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mfile }\n end\n end",
"def create\n @message_attachment = MessageAttachment.new(params[:message_attachment])\n\n respond_to do |format|\n if @message_attachment.save\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully created.' }\n format.json { render json: @message_attachment, status: :created, location: @message_attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @file_record = FileRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_record }\n end\n end",
"def new\n @download = Download.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @download }\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to \"/\", notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @article = Article.new\n @user = User.find_by_id(session[:user_id])\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @article }\n end\n \n # def uri?(attachment_url)\n # uri = URI.parse(attachment_url)\n # %w( http https ).include?(uri.scheme)\n # rescue URI::BadURIError\n # false\n # end\n # \n #\n end",
"def new\n KyuEntry.invalid_attachments\n @kyu_entry = KyuEntry.new\n new_kyu = render_to_string(partial: \"newentry\",\n locals: {kyu_entry: @kyu_entry})\n respond_to do |format|\n format.json { render json: new_kyu.to_json }\n end\n end",
"def new\n @file_version = FileVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_version }\n end\n end",
"def new\n @job_application_attachment = JobApplicationAttachment.new\n @job_applications = JobApplication.find :all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @job_application_attachment }\n end\n end",
"def new\n @fileversion = Fileversion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fileversion }\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @attachment }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mail_item = MailItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mail_item }\n end\n end",
"def new\n @file_sequence = FileSequence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_sequence }\n end\n end",
"def new\n @up_file = UpFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @up_file }\n end\n end",
"def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end",
"def new\n @arquivo = Arquivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arquivo }\n end\n end",
"def new\n @course = Course.new\n @course.attachments.new \n end",
"def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end",
"def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end",
"def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end",
"def new\n @upload = Upload.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upload }\n end\n end",
"def new\n @mailbox = Mailbox.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mailbox }\n end\n end",
"def new\n @content_item = ContentItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content_item }\n end\n end",
"def new\n @inventory_file = InventoryFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @inventory_file }\n end\n end",
"def new\n @kf_course_knowledge_attachment = Kf::CourseKnowledgeAttachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_course_knowledge_attachment }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @post = Post.find(params[:post_id])\n @attach = Attach.new\n end",
"def new\n @media_item = MediaItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @media_item }\n end\n end",
"def new\n @file_info = FileInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_info }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announce }\n end\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @upload }\n end\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @part }\n end\n end",
"def new\n @wallpaper = Wallpaper.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wallpaper }\n end\n end",
"def new\n\t\t@product = Product.new\n\t\t@products = Product.all\n\t\t@attachment_file = AttachmentFile.new\n\t\t@action = 'create'\n\t\trespond_to do |format|\n\t\t format.html # new.html.erb\n\t\t format.json { render :json => @product }\n\t\tend\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\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 create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end",
"def new\n @part = Part.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @part }\n end\n end",
"def new\n @title = \"New Subject\"\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subject }\n end\n end",
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @test_file = TestFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_file }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @content }\n end\n end",
"def new\r\n @gallery_activity = GalleryActivity.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @gallery_activity }\r\n end\r\n end",
"def new\n @cause_analyasis = CauseAnalysis.new()\n @cause_analyasis.build_attachment\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cause_analyasis }\n end\n end",
"def new\n @medium_body_part = MediumBodyPart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium_body_part }\n end\n end",
"def new\n @backup_file = BackupFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backup_file }\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 new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def new\n @digital_content_file = DigitalContentFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @digital_content_file }\n end\n end",
"def new\n authorize Answer\n @answer = Answer.new\n @answer.attachments.build\n end",
"def create\n @cms_attachment = Cms::Attachment.new(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @item = Item.new\n @item.item_attachments.build\n @panels = Panel.where(\"active=?\", true)\n @items = Item.where(\"active=?\", true).order(\"title asc\")\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @resource_file = ResourceFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_file }\n end\n end",
"def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announcement }\n end\n end",
"def new\n @content = Content.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @content }\n end\n end",
"def new\n @photo = @allbum.photos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\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 @medium = Medium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @medium }\n end\n end",
"def new\n @pgn_file = PgnFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pgn_file }\n end\n end",
"def new\n @file_project = FileProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @file_project }\n end\n end"
] | [
"0.7850828",
"0.76186186",
"0.75798947",
"0.75798947",
"0.7561675",
"0.75612336",
"0.7499064",
"0.7499064",
"0.7325541",
"0.7198492",
"0.7149169",
"0.6943176",
"0.69420123",
"0.69367063",
"0.69170254",
"0.6755561",
"0.6755561",
"0.67437774",
"0.67054135",
"0.6672305",
"0.66654754",
"0.6655869",
"0.6596383",
"0.65926903",
"0.65848804",
"0.6566288",
"0.6554525",
"0.6548405",
"0.65302414",
"0.6524509",
"0.65160316",
"0.64859134",
"0.6483953",
"0.6482833",
"0.64720756",
"0.64719415",
"0.64598566",
"0.64597535",
"0.6459102",
"0.6459102",
"0.6459102",
"0.64359593",
"0.64144474",
"0.64140296",
"0.6408088",
"0.6395512",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63946784",
"0.63945776",
"0.63903487",
"0.63896173",
"0.6377407",
"0.6375233",
"0.63678163",
"0.6364612",
"0.6355654",
"0.63552713",
"0.63552713",
"0.6345457",
"0.6345024",
"0.63409925",
"0.6340705",
"0.63388556",
"0.6338688",
"0.6336416",
"0.6336416",
"0.6336416",
"0.6336416",
"0.6336416",
"0.6336416",
"0.63363963",
"0.6333345",
"0.6330813",
"0.6329388",
"0.6325046",
"0.63073856",
"0.63057077",
"0.63052595",
"0.63048375",
"0.63030034",
"0.6302875",
"0.6300278",
"0.62908137",
"0.6287161",
"0.6285356",
"0.62820697",
"0.6281106",
"0.6275191"
] | 0.81698227 | 2 |
POST /attachments POST /attachments.json | def create
@attachment = Attachment.new(params[:attachment])
@attachment.save
flash[:notice] = 'El archivo ha sido subido correctamente.'
return redirect_to :action => :index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @document = Document.new(document_params)\n\n respond_to do |format|\n if @document.save\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n hash = []\n params[:files].each do |i,file_io|\n path = File.join(Rails.root,'public','attach',file_io.original_filename)\n File.open(path, \"wb\") { |f| f.write(file_io.read)}\n attachment = Attachment.create do |attach|\n attach.name = file_io.original_filename\n attach.describe = params[:describe]\n end \n hash.push attachment\n end\n render json: hash\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to \"/\", notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @attachment }\n else\n format.html { render :new }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_attachment(file_s)\n setup\n @req = Net::HTTP::Post.new(\"/uploads.json\")\n auth\n @req[\"Content-Type\"] = \"application/octet-stream\"\n @req[\"Content-Length\"] = file_s.length\n @req.body = file_s\n res = @http.request(@req)\n\n if res.code.to_i == 201\n return [true, JSON.load(res.body)[\"upload\"][\"token\"]]\n else\n return [false, JSON.load(res.body)[\"errors\"].first]\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n\n respond_to do |format|\n if @post.save\n params[:post_attachments]['avatar'].each do |a|\n @post_attachment = @post.post_attachments.create(:avatar => a, :post_id => @post.id)\n end\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 @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n expire_action( news_url(nil) )\n expire_action( home_url() )\n \n params[:attachments].each do |att|\n @post.attachments.create :uploadedfile=>att\n end if params.has_key?( :attachments )\n \n flash[:notice] = 'Post was successfully created.'\n format.html { redirect_to posts_url }\n format.xml { head :created, :location => posts_url }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end",
"def multi_upload\n authenticate!\n attachments = []\n (attachment_params[:attachments] || []).each do |key, value|\n if value[:file]\n attachment = value[:file]\n attachment_params = {\n :filename => attachment[:filename],\n :type => attachment[:type],\n :headers => attachment[:head],\n :tempfile => attachment[:tempfile]\n }\n file = ActionDispatch::Http::UploadedFile.new(attachment_params)\n attachments << Attachment.create(file: file, user: current_user)\n end\n end\n {\n code: 0,\n data: attachments\n }\n end",
"def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end",
"def add_attachments\n frm.button(:value=>\"Add Attachments\").click\n AnnouncementsAttach.new(@browser)\n end",
"def create\n @travel_post_attachment = TravelPostAttachment.new(travel_post_attachment_params)\n\n respond_to do |format|\n if @travel_post_attachment.save\n format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully created.' }\n format.json { render :show, status: :created, location: @travel_post_attachment }\n else\n format.html { render :new }\n format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload\n permitted_params = params[:attachment]\n file = permitted_params.delete(:file)\n attr = {file: file, user: current_user}\n\n if permitted_params[:attachmentable_type].present? && permitted_params[:attachmentable_id].present?\n attachmentable_type = permitted_params[:attachmentable_type]\n attachmentable_id = permitted_params[:attachmentable_id]\n attr = attr.merge(attachmentable_type: attachmentable_type, attachmentable_id: attachmentable_id)\n end\n\n attachment = Attachment.new(attr)\n if attachment.savee\n render json:{\n code: 0,\n data: AttachmentSerializer.new(attachment)\n }\n else\n render json:{\n code: -1,\n data: {\n message: attachment.errors.full_messages,\n }\n }\n end\n\n end",
"def create\n @message_attachment = MessageAttachment.new(params[:message_attachment])\n\n respond_to do |format|\n if @message_attachment.save\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully created.' }\n format.json { render json: @message_attachment, status: :created, location: @message_attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_attachments attachments\n Attachment.add(attachments, self)\n end",
"def test_issue_attachements\n log_user('jsmith', 'jsmith')\n\n post 'issues/edit/1',\n :notes => 'Some notes',\n :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}\n assert_redirected_to \"issues/show/1\"\n \n # make sure attachment was saved\n attachment = Issue.find(1).attachments.find_by_filename(\"testfile.txt\")\n assert_kind_of Attachment, attachment\n assert_equal Issue.find(1), attachment.container\n assert_equal 'This is an attachment', attachment.description\n # verify the size of the attachment stored in db\n #assert_equal file_data_1.length, attachment.filesize\n # verify that the attachment was written to disk\n assert File.exist?(attachment.diskfile)\n \n # remove the attachments\n Issue.find(1).attachments.each(&:destroy)\n assert_equal 0, Issue.find(1).attachments.length\n end",
"def create\n a=JSON.parse(params.to_json)\n Attachment.create_file(params[:encoded],@current_user)\n respond_to do |format|\n format.json { render :json => success }\n format.xml { render :xml => success }\n end\n end",
"def create\n @post_attachment = PostAttachment.new(post_attachment_params.merge(:post_id => @post.id))\n respond_to do |format|\n if @post.save\n unless params[:post_attachments].nil?\n params[:post_attachments]['picture'].each do |a|\n @post_attachment = @post.post_attachments.create!(:picture => a, :post_id => @post.id)\n end\n else format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :ok, location: @post }\n end\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def permitted_attachments_params\n params.permit(attachments: [])\n end",
"def test_attach_file\n# post :upload, \"note\"=>{\"title\"=>\"my note\"}, \"courseid\"=>\"806350272748085520\",\n# \"processor\"=>{\"id\"=>\"1000001\"}, \"success\"=>\"/course/806350272748085520/ACMA-320/share_notes\", \n# \"upload_id\"=>\"1169944954\", \n# \"failure\"=>\"/course/806350272748085520/ACMA-320/share_notes\"\n \n post :upload, \"noteid\"=>\"816717565610925385\", \"processor\"=>{\"id\"=>\"1000001\"}\n \n end",
"def attachments(*params)\n id = params[0]\n unnamed = params[1]\n if params[0].class == Hash\n params = params[0]\n id = params[:id] if params.has_key? :id\n unnamed = params[:unnamed] if params.has_key? :unnamed\n end\n unnamed = false if unnamed.to_s == \"0\"\n id = $~[1] if id =~ /ticket\\/(\\d+)/\n resp = @site[\"ticket/#{id}/attachments\"].get\n resp.gsub!(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n resp.gsub!(/^\\n/m,\"\") # toss blank lines\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/) #replace CF spaces with underscores\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n th = response_to_h(resp)\n list = []\n pattern = /(\\d+:\\s.*?\\))(?:,|$)/\n match = pattern.match(th['attachments'].to_s)\n while match != nil\n list.push match[0]\n s = match.post_match\n match = pattern.match(s)\n end\n attachments = []\n list.each do |v|\n attachment = {}\n m=v.match(/(\\d+):\\s+(.*?)\\s+\\((.*?)\\s+\\/\\s+(.*?)\\)/)\n if m.class == MatchData\n next if m[2] == \"(Unnamed)\" and !unnamed\n attachment[:id] = m[1]\n attachment[:name] = m[2]\n attachment[:type] = m[3]\n attachment[:size] = m[4]\n attachments.push attachment\n end\n end\n attachments\n end",
"def create_attachment\n @artifact_answer = ArtifactAnswer.find(params[:id])\n if params[:file]\n params[:file].each do |attachment|\n @artifact_answer.attachments.create(attachment_file: attachment, :company_id => current_company.id)\n @attachment_error = @artifact_answer.attachments.last.errors[:\"file_size_exceeds\"][0] if @artifact_answer.attachments.last.errors.present?\n end\n end\n @attachments = @artifact_answer.attachments\n end",
"def call(attachments)\n Attachment.where({canvas_user_id: attachment_conf[:canvas_user_id], submission_id: attachment_conf[:submission_id]}).\n delete_all\n attachments.each do |attachment|\n Attachment.create(attachment_conf.merge({date: Time.parse(attachment['updated_at']),\n attachment_id: attachment['id'], image_url: attachment['url'], content_type: attachment['content-type']})\n )\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n params[:ticket_attachments]['image'].each do |i|\n @ticket_attachment = @ticket.ticket_attachments.create!(:image => i)\n end\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @document.update(document_params)\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\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 create\n @attachment_datum = AttachmentDatum.new(params[:attachment_datum])\n\n respond_to do |format|\n if @attachment_datum.save\n format.html { redirect_to @attachment_datum, notice: 'Attachment datum was successfully created.' }\n format.json { render json: @attachment_datum, status: :created, location: @attachment_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @file_upload_attachment = FileUploadAttachment.new(file_upload_attachment_params)\n\n respond_to do |format|\n if @file_upload_attachment.save\n format.html { redirect_to @file_upload_attachment, notice: 'File upload attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @file_upload_attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @file_upload_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attachment_params\n params.require(:attachment).permit( :attachment)\n end",
"def create\n @cms_attachment = Cms::Attachment.new(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event_attachment = EventAttachment.new(event_attachment_params)\n\n respond_to do |format|\n if @event_attachment.save\n format.html { redirect_to @event_attachment, notice: 'Event attachment was successfully created.' }\n format.json { render :show, status: :created, location: @event_attachment }\n else\n format.html { render :new }\n format.json { render json: @event_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_attachment!(params={})\n raise ArgumentError, \"Error: ids, data, file_name, summary, and content_type are required args\" unless check_params([:ids, :data, :file_name, :summary, :content_type], params)\n rpc_call :add_attachment, params\n end",
"def create\n @applicant = Applicant.find(params[:applicant_id])\n @attachment = @applicant.attachments.build(params[:attachment])\n\n respond_to do |format|\n if @attachment.save!\n @activity = Activity.create \\\n\t :actor => current_user,\n\t :job_id => @applicant.job_id,\n\t :account_id => @applicant.account_id,\n\t :applicant_id => @applicant.id,\n :action => 'attached',\n :subject_id => @attachment.id,\n :subject_type => 'Attachment'\n \n format.html { redirect_to(applicant_path(@applicant), :notice => 'Attachment was successfully created.') }\n format.xml { render :xml => @attachment, :status => :created, :location => @attachment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @friends_attachment = FriendsAttachment.new(friends_attachment_params)\n\n respond_to do |format|\n if @friends_attachment.save\n format.html { redirect_to @friends_attachment, notice: \"Friends attachment was successfully created.\" }\n format.json { render :show, status: :created, location: @friends_attachment }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @friends_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_attachments(issue, args)\n if issue.persisted?\n delete_ids = args[:delete_attachments]\n issue.attachments.in(id: delete_ids).update_all(deleted: true)\n end\n\n return if (attachments.nil? || attachments.empty?)\n\n attachments.each do |attachment|\n if attachment[:id].blank?\n new_file = issue.attachments.build\n new_file.file = attachment[:data] # <json string>\n new_file.save!\n end\n end\n end",
"def create\n @attachment = Attachment.new(uploaded_data: params[:file], col_sep: params[:col_sep], quote_char: params[:quote_char], encoding: params[:encoding])\n @attachment.user = current_user\n @attachment.save!\n # TODO rescue parser errors -> rows empty\n rows = @attachment.rows(4)\n render json: {errors: @attachment.parse_error, id: @attachment.id, rows: rows}, status: :ok\n end",
"def create\n @attachfile = Attachfile.new(attachfile_params)\n\n respond_to do |format|\n if @attachfile.save\n format.html { redirect_to @attachfile, notice: 'Attachfile was successfully created.' }\n format.json { render :show, status: :created, location: @attachfile }\n else\n format.html { render :new }\n format.json { render json: @attachfile.errors, status: :unprocessable_entity }\n end\n end\n 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 upload\n requires_user_can :edit, task\n\n attachment = paper_attachment.file\n paper_attachment.worker.download(\n paper,\n paper_attachment.s3_url,\n current_user\n )\n\n render json: attachment,\n status: paper_attachment.existing_file ? 200 : 201,\n root: 'attachment',\n serializer: AttachmentSerializer\n end",
"def add_attachments\n frm.button(:name=>\"attach\").click\n AssignmentsAttachments.new(@browser)\n end",
"def create\n @order_attachment = OrderAttachment.new(order_attachment_params)\n\n respond_to do |format|\n if @order_attachment.save\n format.html { redirect_to @order_attachment, notice: 'Order attachment was successfully created.' }\n format.json { render :show, status: :created, location: @order_attachment }\n else\n format.html { render :new }\n format.json { render json: @order_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params[:travel_post][:user_id] = current_user.id\n @travel_post = TravelPost.new(travel_post_params)\n\n respond_to do |format|\n if @travel_post.save\n if params[:travel_post_attachments].present?\n params[:travel_post_attachments]['s3'].each do |a|\n @travel_post_attachment = @travel_post.travel_post_attachments.create!(:s3 => a, :travel_post_id => @travel_post.id)\n end\n end\n format.html { redirect_to travel_posts_path, notice: 'Travel post was successfully created.' }\n format.json { render :show, status: :created, location: @travel_post }\n else\n format.html { render :new }\n format.json { render json: @travel_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @note_attachment = NoteAttachment.new(note_attachment_params)\n\n respond_to do |format|\n if @note_attachment.save\n format.html { redirect_to @note_attachment, notice: 'Note attachment was successfully created.' }\n format.json { render :show, status: :created, location: @note_attachment }\n else\n format.html { render :new }\n format.json { render json: @note_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !user_signed_in?\n redirect_to login_path, :alert => \"You need to sign in or sign up before continuing.\"\n else\n @post = Post.new(post_params)\n @post.user = current_user\n respond_to do |format|\n if @post.save\n notifyTagUsers(@post)\n\n if params.has_key?(:post_attachments)\n params[:post_attachments]['avatar'].each do |a|\n @post_attachment = @post.post_attachments.create!(:avatar => a)\n end\n end\n\n format.html { redirect_to timeline_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @second = Second.new(params[:second])\n\n #add attachment\n @second.attachments << Attachment.new(:source => params[:attachment]) unless params[:attachment].blank?\n\n respond_to do |format|\n if @second.save\n format.html { redirect_to @second, notice: 'Second was successfully created.' }\n format.json { render json: @second, status: :created, location: @second }\n else\n format.html { render action: \"new\" }\n format.json { render json: @second.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attachment_params\n params.require(:attachment).permit(:title, :data, :mime_type, :thumbnail, :content)\n end",
"def add_attachments(obj)\n if !email.attachments.nil? && email.attachments.size > 0\n email.attachments.each do |attachment|\n obj.attachments << Attachment.create(:container => obj,\n :file => attachment.decoded,\n :filename => attachment.filename,\n :author => user,\n :content_type => attachment.mime_type)\n end\n end\n end",
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def add_attachments(value)\n if value.instance_of? AttachmentJson\n @attachments.push(value)\n end\n end",
"def attachment_params\n params.require(:attachment).permit(:file)\n end",
"def attachment_params\n params.require(:attachment).permit(:file)\n end",
"def add_attachments\n frm.button(:value=>\"Add Attachments\").click\n AssignmentAttachments.new(@browser)\n end",
"def create\n @channel = Channel.find_by_name(params[:channel_id])\n @attachment = Attachment.new(params[:attachment])\n\n # {\"file\"=>#<ActionDispatch::Http::UploadedFile:0x00000005bc3158 @original_filename=\"investor_faq.org\", @content_type=\"application/octet-stream\",\n # @headers=\"Content-Disposition: form-data; name=\\\"file\\\"; filename=\\\"investor_faq.org\\\"\\r\\nContent-Type: application/octet-stream\\r\\n\", @tempfile=#<File:/tmp/RackMultipart20111212-24212-4znzta>>\n # \"commit\"=>\"Upload\",\n # \"utf8\"=>\"✓\",\n # \"authenticity_token\"=>\"SrS7bnPQ76RQJLWOx58bm1uyDsQq5f4FObPLl9Zh+Ao=\",\n # \"remotipart_submitted\"=>\"true\",\n # \"X-Requested-With\"=>\"IFrame\",\n # \"X-Http-Accept\"=>\"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01\",\n # \"channel_id\"=>\"Shiro\"\n # }\n\n @attachment.user = current_user\n @attachment.channel = Channel.find_by_name(params[:channel_id])\n @attachment.file = params[:file]\n\n respond_to do |format|\n if @attachment.save\n format.html { }\n format.js\n format.json { render json: @attachment, status: :created }\n else\n format.html { render action: \"new\" }\n format.js\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def new\n @attachment = Attachment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attachment }\n end\n end",
"def add_attachments\n frm.button(:name=>\"attach\").click\n AssignmentAttachments.new(@browser)\n end",
"def create\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n params[:project_attachments].each do |a|\n # logger.debug \"New attachment: #{a}\"\n @project_attachment = @project.project_attachments.create!(attachment: a)\n end\n end\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render :show, status: :created, location: @project }\n else\n format.html { render :new }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rent_post = RentPost.new(rent_post_params)\n # @post_attachment = @rent_post.post_attachments.build\n\n respond_to do |format|\n if @rent_post.save\n if params[:post_attachments]!=nil\n params[:post_attachments]['image'].each do |a|\n @post_attachment = @rent_post.post_attachments.create!(:image => a, :rent_post_id => @rent_post.id)\n end\n else\n @post_attachment = @rent_post.post_attachments.create!(:image => nil, :rent_post_id => @rent_post.id)\n end\n format.html { redirect_to @rent_post, notice: 'Rent post was successfully created.' }\n format.json { render :show, status: :created, location: @rent_post }\n else\n format.html { render :new }\n format.json { render json: @rent_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @documentable = find_documentable\n @document = @documentable.documents.build(document_params)\n\n respond_to do |format|\n if @document.save\n format.html { redirect_to @document, notice: t('.notice', document: @document) }\n format.json\n else\n format.html { render :new }\n format.json {\n render json: @document.errors[:attachment], status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n\n @attachments = []\n @programs_target_program = Programs::TargetedProgram.where(:id => params[:programs_attachment][:program_id]).first\n\n params['attachment'].each do |f|\n doc = Programs::Attachment.new\n doc.attachment = f\n doc.programs_target_program = @programs_target_program\n params[:programs_attachment][:title].present? ? doc.title = params[:programs_attachment][:title] : doc.title = f.original_filename\n doc.author = current_user.email\n doc.save\n @attachments << doc\n\n end unless params['attachment'].nil?\n\n respond_to do |format|\n format.js {}\n end\n\n\n end",
"def create\n @publication = current_user.publications.new(publication_params)\n\n respond_to do |format|\n if @publication.save\n unless params[:publication_attachments].nil?\n params[:publication_attachments]['photo'].each do |a|\n @publication_attachment = @publication.publication_attachments.create!(:photo => a)\n end\n end\n format.html { redirect_to @publication, notice: 'Publication was successfully created.' }\n format.json { render :show, status: :created, location: @publication }\n else\n format.html { render :new }\n format.json { render json: @publication.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boat_attachment = BoatAttachment.new(boat_attachment_params)\n\n respond_to do |format|\n if @boat_attachment.save\n format.html { redirect_to @boat_attachment, notice: 'Boat attachment was successfully posted.' }\n format.json { render :show, status: :created, location: @boat_attachment }\n else\n format.html { render :new }\n format.json { render json: @boat_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @attachments = @pad.attachments\n @attachment = @pad.attachments.new\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @attachments }\n end\n end",
"def attachment_params\n params.fetch(:attachment).permit(:file)\n end",
"def attachment_params\n params.require(:attachment).permit(:file_id, :name)\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n \n # set current user as the creator of the attachment \n @attachment.user = User.find(current_user)\n \n #from jquery upload\n @attachment.name = params[:title] if params[:title]\n \n \n if params[:assignment_id]\n @attachment.assignment = Assignment.find(params[:assignment_id])\n @attachment.course = @attachment.assignment.course\n end\n \n respond_to do |format|\n if @attachment.save\n format.html { redirect_to @attachment, notice: 'Attachment was successfully created.' }\n format.json { render :json => [@attachment.to_jq_upload].to_json }\n else\n format.html { render action: \"new\" }\n format.json { render :json => [{:error => \"custom_failure\"}], :status => 304 }\n end\n end\n end",
"def create \n return if params[:attachment].blank?\n\n @attachment = Attachment.new\n @attachment.uploaded_file = params[:attachment]\n @attachment.thumbnail = thumb(@attachment.data, 0.25) if @attachment.mime_type =~ /image/\n case \n when params[:publication_id]\n\t @attachment.publications << Publication.find(params[:publication_id])\n when params[:article_id]\n @attachment.articles << Article.find(params[:article_id])\n when params[:issue_id]\n @attachment.issues << Issue.find(params[:issue_id])\n end\n if @attachment.save\n\t flash[:notice] = \"Thank you for your submission...\"\n\t redirect_to :back\n else\n\t flash[:error] = \"There was a problem submitting your attachment.\"\n\t render :action => \"new\"\n end\n end",
"def create\n @attachment = Attachment.new(params[:attachment])\n\n if @attachment.model_id != nil\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to \"/#{@attachment.model_name}/#{@attachment.model_id}/edit/\", notice: 'Attachment was successfully created.' }\n format.json { render json: @attachment, status: :created, location: @attachment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end \n end\n\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n if file_data.respond_to?(:read)\n @@world = file_data.read\n xml_contents = file_data.read\n elsif file_data.respond_to?(:path)\n xml_contents = File.read(file_data.path)\n else\n logger.error \"Bad file_data: #{file_data.class.name}: #{file_data.inspect}\"\n end\n\n\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to attachments_path, notice: 'Document was successfully created.' }\n format.json { render action: 'show', status: :created, location: @attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @dattachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end",
"def create\n\n uploaded_io = params[:new_file]\n File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file|\n file.write(uploaded_io.read)\n end\n\n @attachment = @pad.attachments.new(params[:attachment])\n @attachment.name = uploaded_io.original_filename;\n\n respond_to do |format|\n if @attachment.save\n format.html { redirect_to(pad_attachments_path(@pad), :notice => 'Attachment was successfully created.') }\n format.xml { render :xml => @attachment, :status => :created, :location => @attachment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_attachments_to_existing_note(note, attachments)\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to note ID #{note.id}\"\n existing_note_attachment_input(note).when_present 1\n existing_note_attachment_input(note).send_keys Utils.asset_file_path(attach.file_name)\n existing_note_attachment_delete_button(note, attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.updated_date = Time.now\n note.attachments << attach\n end\n end",
"def create\n @attachment = Attachment.new(attachment_params)\n @attachment.name = @attachment.file.blob.checksum\n respond_to do |format|\n if @attachment.save\n convert_to_line\n format.html { redirect_to attachment_line_list_path(@attachment), notice: 'Attachment was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def attachments(params={})\n raise ArgumentError, \"Error: ids or attachment_ids must be set\" unless params[:ids] || params[:attachment_ids]\n rpc_call :attachments, params\n end",
"def create\n @teacher_attachment = TeacherAttachment.new(teacher_attachment_params)\n\n respond_to do |format|\n if @teacher_attachment.save\n format.html { redirect_to @teacher_attachment.teacher, notice: 'Teacher attachment was successfully created.' }\n format.json { render :show, status: :created, location: @teacher_attachment }\n else\n format.html { render :new }\n format.json { render json: @teacher_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_attachments_to_new_note(note, attachments)\n show_adv_note_options\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to an unsaved note\"\n new_note_attach_input_element.send_keys Utils.asset_file_path(attach.file_name)\n new_note_attachment_delete_button(attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.attachments << attach\n end\n end",
"def attachments(struct)\n struct.remapkeys!\n if struct.has_key? :user and struct.has_key? :pass\n rt = RT_Client.new(:user => struct[:user], :pass => struct[:pass])\n struct.delete(:user)\n struct.delete(:pass)\n else\n rt = RT_Client.new\n end\n rt = RT_Client.new\n val = rt.attachments(struct)\n rt = nil\n val\n end",
"def attachment_upload(id, stream, options={})\n body, headers = http_multipart_data({:id => id, :stream => stream})\n post(\"wrike.attachment.upload\", body, headers)\n end",
"def upload_supporting_documents\n validate_documents_content_type\n validate_documents_page_size\n\n claim = ClaimsApi::AutoEstablishedClaim.get_by_id_or_evss_id(params[:id])\n raise ::Common::Exceptions::ResourceNotFound.new(detail: 'Resource not found') unless claim\n\n ClaimsApi::Logger.log(\n '526',\n claim_id: claim.id,\n detail: \"/attachments called with #{documents.length} #{'attachment'.pluralize(documents.length)}\"\n )\n\n documents.each do |document|\n claim_document = claim.supporting_documents.build\n claim_document.set_file_data!(document, EVSS_DOCUMENT_TYPE, params[:description])\n claim_document.save!\n ClaimsApi::ClaimUploader.perform_async(claim_document.id)\n end\n\n render json: claim, serializer: ClaimsApi::ClaimDetailSerializer, uuid: claim.id\n end",
"def create\n @design_image_attachment = DesignImageAttachment.new(design_image_attachment_params)\n\n respond_to do |format|\n if @design_image_attachment.save\n format.html { redirect_to @design_image_attachment, notice: 'Design image attachment was successfully created.' }\n format.json { render :show, status: :created, location: @design_image_attachment }\n else\n format.html { render :new }\n format.json { render json: @design_image_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @link_attachment = LinkAttachment.new(link_attachment_params)\n\n respond_to do |format|\n if @link_attachment.save\n format.html { redirect_to @link_attachment, notice: 'Link attachment was successfully created.' }\n format.json { render action: 'show', status: :created, location: @link_attachment }\n else\n format.html { render action: 'new' }\n format.json { render json: @link_attachment.errors, status: :unprocessable_entity }\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\n @case = Case.new(case_params)\n\n respond_to do |format|\n if @case.save\n params[:case_attachments]['photo'].each do |a|\n @case_attachment = @case.case_attachments.create!(:photo => a, :case_id => @case.id)\n end\n format.html { redirect_to admin_cases_path, notice: \"Caso Clínico (#{@case.title}), cadastrado com sucesso!\" }\n format.json { render :show, status: :created, location: [:admin, @case] }\n else\n format.html { render :new }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:)\n @client.post(@webhook_url) do |request|\n request.headers['Content-Type'] = 'application/json'\n request.body = {\n channel: channel,\n username: username,\n icon_url: icon_url,\n attachments: attachments,\n link_names: link_names\n }.to_json\n end\n end",
"def create\n @incidentattachment = Incidentattachment.new(incidentattachment_params)\n @incidentattachment.filepath = \"N/A\"\n\n respond_to do |format|\n if @incidentattachment.save\n format.html { redirect_to @incidentattachment, notice: 'Incidentattachment was successfully created.' }\n format.json { render :show, status: :created, location: @incidentattachment }\n else\n format.html { render :new }\n format.json { render json: @incidentattachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @event = Event.find(params[:event_id])\n file = {}\n\n if params[:flash]\n file[\"name\"] = params[:Filedata].original_filename\n \n extname = File.extname(params[:Filedata].original_filename)[1..-1]\n mime_type = Mime::Type.lookup_by_extension(extname)\n params[:Filedata].content_type = mime_type.to_s unless mime_type.nil?\n\n file[\"attached\"] = params[:Filedata]\n else\n file[\"name\"] = params[:attached].original_filename\n file[\"attached\"] = params[:attached]\n end\n\n file[\"event_id\"] = @event.id\n @attached = Attached.new(file)\n \n\n respond_to do |format|\n if @attached.save\n format.html { redirect_to @event, notice: 'File was successfully uploaded.' }\n format.json { render json: @attached, status: :created, location: @attached }\n else\n format.html { render action: \"edit\"}\n format.json { render json: @attached.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path = '/files/', params = {})\n request :post, path, params\n end",
"def add_attachments\n frm.button(:value=>/(Add|Add \\/ Remove) Attachments/).click\n AssignmentsAttachments.new(@browser)\n end",
"def create\n @cms_attachment = current_portal.cms_attachments.build(cms_attachment_params)\n\n respond_to do |format|\n if @cms_attachment.save\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully created.' }\n format.json { render :show, status: :created, location: @cms_attachment }\n else\n format.html { render :new }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attachment; end",
"def create\n @message = Message.new(message_params)\n @message[:external_links] = params[:message][:external_links].first.split(\"\\r\\n\").map(&:strip)\n @message.images.attach(params[:message][:images])\n @message.images.attach(params[:message][:vi_images])\n @message.images.attach(params[:message][:zh_cn_images])\n @message.images.attach(params[:message][:zh_tw_images])\n @message.images.attach(params[:message][:hmn_images])\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: \"Message was successfully created.\" }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dispatch_create_item!(msg)\n if msg.has_attachments?\n draft = msg.draft\n msg.draft = true\n resp = validate_created_item(ews.create_item(msg.to_ews))\n msg.file_attachments.each do |f|\n next unless f.kind_of?(File)\n resp.add_file_attachment(f)\n end\n if draft\n resp.submit_attachments!\n resp\n else\n resp.submit!\n end\n else\n resp = ews.create_item(msg.to_ews)\n validate_created_item resp\n end\n end",
"def create\n @document = Document.new(document_params)\n # @document.images.attach(params[:document][:images])\n respond_to do |format|\n if @document.save\n @records = Document.all.with_attached_images\n\n format.html { redirect_to @document, notice: 'Document was successfully created.' }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event = Event.new(event_params)\n @event.user_id = current_user.id\n\n respond_to do |format|\n if @event.save\n params[:event_attachments]['image'].each do |a|\n @event_attachment = @event.event_attachments.create!(:image => a, :event_id => @event.id)\n end\n format.html { redirect_to edit_event_path(@event), notice: 'event was successfully created.' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def deliver(opts = {})\n options = OpenStruct.new(opts)\n params = params_from(options)\n response = client.post(path, params, attachments: options.attachments).parsed_body\n new(response)\n end",
"def post_params\n params.require(:post).permit(:title, post_attachments_attributes: [:id, :post_id, :avatar])\n end",
"def create\n p_attr = params[:post_attachment]\n #note that the name of the file is a little different with blueimp uploader\n ttt=[]\n uuu = params[:post_attachment].first if params[:post_attachment].class == Array\n #ttt[:image]=uuu\n# uuu = []\n# uuu[:image] = ttt\n @posting=Posting.find(params[:id])\n @picture = @posting.post_attachments.build\n @picture.image=uuu\n\n if @picture.save\n respond_to do |format|\n format.html {\n render :json => [@picture.to_jq_upload].to_json,\n :content_type => 'text/html',\n :layout => false\n }\n format.json {\n render :json => { :files => [@picture.to_jq_upload] }\n }\n end\n else\n render :json => [{:error => \"custom_failure\"}], :status => 304\n end\n\n# @post_attachment = PostAttachment.new(post_attachment_params)\n# if !@post_attachment.image.nil?\n# respond_to do |format|\n# if @post_attachment.save\n# format.html { redirect_to @post_attachment, notice: 'Post attachment was successfully created.' }\n# format.json { render :show, status: :created, location: @post_attachment }\n# else\n# format.html { render :new }\n# format.json { render json: @post_attachment.errors, status: :unprocessable_entity }\n# end\n# end\n# end\n end",
"def post_multipart(url, data, filename, headers = {})\n request(:post, url, headers, {:data => data, :file => filename, :multipart => true})\n end"
] | [
"0.67856145",
"0.67284447",
"0.6717782",
"0.6717782",
"0.6710522",
"0.66664606",
"0.6630575",
"0.65930396",
"0.65218943",
"0.6507676",
"0.6459344",
"0.6454859",
"0.6453828",
"0.6449482",
"0.6444526",
"0.64219415",
"0.640342",
"0.6388061",
"0.63603103",
"0.6320983",
"0.6305493",
"0.63046354",
"0.62687516",
"0.6250236",
"0.62367105",
"0.62254184",
"0.6207826",
"0.6205038",
"0.61971086",
"0.618682",
"0.61827695",
"0.61743313",
"0.6169514",
"0.6150966",
"0.61423886",
"0.61411",
"0.6109793",
"0.610545",
"0.6100233",
"0.60965765",
"0.6070404",
"0.6069253",
"0.6066806",
"0.60656273",
"0.60642767",
"0.60447735",
"0.60386974",
"0.6031303",
"0.6030309",
"0.6025589",
"0.60068804",
"0.60068804",
"0.6002398",
"0.60018635",
"0.6000098",
"0.5999386",
"0.5999386",
"0.59946203",
"0.5992669",
"0.5962225",
"0.5934623",
"0.59260833",
"0.5926034",
"0.59211946",
"0.5912828",
"0.5902288",
"0.58989877",
"0.5892094",
"0.58914787",
"0.58849114",
"0.5884589",
"0.58738536",
"0.58669335",
"0.58568215",
"0.5853694",
"0.5848191",
"0.5842109",
"0.58321565",
"0.58227473",
"0.5822297",
"0.5821766",
"0.58141947",
"0.5813571",
"0.5791661",
"0.57847947",
"0.5780869",
"0.57802486",
"0.5773509",
"0.57681334",
"0.5764805",
"0.57618856",
"0.5758853",
"0.57525074",
"0.57520837",
"0.57497853",
"0.5744028",
"0.5743214",
"0.5742331",
"0.5742053",
"0.57415694"
] | 0.5768439 | 88 |
PUT /attachments/1 PUT /attachments/1.json | def update
@attachment = Attachment.find(params[:id])
respond_to do |format|
if @attachment.update_attributes(params[:attachment])
format.html { redirect_to attachments_path, notice: 'El archivo ha sido cambiado de categoria correctamente' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @attachment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @document.update(document_params)\n if params[:attachments]\n params[:attachments].each do |a|\n @attachment = @document.attachments.create!(:attachment => a)\n end\n end\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 ti_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { head :no_content }\n format.json { head :no_content }\n else\n format.html { head :no_content }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @attachment = Attachment.find_by_name(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def co_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n #$attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_attachment(name)\n return unless attachments[name]\n result = JSON.parse(RestClient.put(\"#{ uri }/#{ CGI.escape(name) }#{ '?rev=' + @_rev if @_rev }\", attachments[name][:file], {:content_type => attachments[name][:content_type], :accept => 'text/json'}))\n @_rev = result['rev']\n end",
"def cc_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment.avatar = params[:file]\n $attachment.id = 1\n #$attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def update_attachments(issue, args)\n if issue.persisted?\n delete_ids = args[:delete_attachments]\n issue.attachments.in(id: delete_ids).update_all(deleted: true)\n end\n\n return if (attachments.nil? || attachments.empty?)\n\n attachments.each do |attachment|\n if attachment[:id].blank?\n new_file = issue.attachments.build\n new_file.file = attachment[:data] # <json string>\n new_file.save!\n end\n end\n end",
"def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @attachment.update(attachment_params)\n format.html { redirect_to @attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachment }\n else\n format.html { render :edit }\n format.json { render json: @attaessay_file_namechment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def si_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def of_update_attachment\n if !$attachment.nil?\n $attachment.destroy\n $attachment = Attachment.new\n end\n $attachment_changed = true\n $attachment.avatar = params[:file]\n $attachment.id = 1\n $attachment.save!\n if $attachment.save\n render json: { \"image\" => $attachment.avatar }\n else\n render json: { \"image\" => \"\" }\n end\n end",
"def update\n upload = params.require(:file)\n handler = create_handler(params[:id], upload)\n\n if handler.valid?\n render json: attachment_json(handler.call)\n else\n render json: errors_json(handler), status: :unprocessable_entity\n end\n end",
"def update\n @message_attachment = MessageAttachment.find(params[:id])\n\n respond_to do |format|\n if @message_attachment.update_attributes(params[:message_attachment])\n format.html { redirect_to @message_attachment, notice: 'Message attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @message_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n if @attachment.model_id != nil\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to \"/#{@attachment.model_name}/#{@attachment.model_id}/edit/\", notice: 'Attachment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n else \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end \n end\n end",
"def update!(**args)\n @add_attachments = args[:add_attachments] if args.key?(:add_attachments)\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to(@attachment, :notice => 'Attachment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n format.html { redirect_to(@attachment, :notice => 'Attachment was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @attachment = Attachment.find(params[:id])\n\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n flash[:notice] = 'Attachment was successfully updated.'\n format.html { redirect_to(@attachment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event_attachment.update(event_attachment_params)\n format.html { redirect_to @event_attachment, notice: 'Event attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_attachment }\n else\n format.html { render :edit }\n format.json { render json: @event_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @project.update(project_params)\n if params[:project_attachments]\n params[:project_attachments].each do |a|\n # logger.debug \"New attachment: #{a}\"\n @project_attachment = @project.project_attachments.create!(attachment: a)\n end\n end\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @file_upload_attachment.update(file_upload_attachment_params)\n format.html { redirect_to @file_upload_attachment, notice: 'File upload attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @file_upload_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @file_attachment = FileAttachment.find(params[:id])\n\n respond_to do |format|\n if @file_attachment.update_attributes(params[:file_attachment])\n flash[:notice] = 'FileAttachment was successfully updated.'\n format.html { redirect_to(@file_attachment) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @file_attachment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @attached = Attached.find(params[:id])\n\n respond_to do |format|\n if @attached.update_attributes(params[:attached])\n format.html { redirect_to @attached, notice: 'Attached was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attached.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @incidentattachment.update(incidentattachment_params)\n format.html { redirect_to @incidentattachment, notice: 'Incidentattachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @incidentattachment }\n else\n format.html { render :edit }\n format.json { render json: @incidentattachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n attachment = Attachment.find_by!(:slug => params[:id],\n :conversation_id => current_account.conversation_ids + [nil])\n\n if params[:task_list] and !params[:task_list][:tasks].empty?\n attachment.update_attribute(:tasks, params[:task_list][:tasks])\n end\n\n render :json => attachment\n end",
"def update\n respond_to do |format|\n if @cms_attachment.update(cms_attachment_params)\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_attachment }\n else\n format.html { render :edit }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cms_attachment.update(cms_attachment_params)\n format.html { redirect_to @cms_attachment, notice: 'Attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @cms_attachment }\n else\n format.html { render :edit }\n format.json { render json: @cms_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_note\n id = unsafe_params[:id].to_i\n fail \"id needs to be an Integer\" unless id.is_a?(Integer)\n\n title = unsafe_params[:title]\n fail \"title needs to be a String\" unless title.is_a?(String)\n\n content = unsafe_params[:content] || \"\"\n fail \"content needs to be a String\" unless content.is_a?(String)\n\n attachments_to_save = unsafe_params[:attachments_to_save] || []\n fail \"attachments_to_save needs to be an array\" unless attachments_to_save.is_a?(Array)\n\n attachments_to_delete = unsafe_params[:attachments_to_delete] || []\n fail \"attachments_to_delete neeeds to be an array\" unless attachments_to_delete.is_a?(Array)\n\n note = nil\n Note.transaction do\n note = Note.find_by!(id: unsafe_params[:id])\n fail '' unless note.editable_by?(@context)\n\n attachments_to_save.each do |uid|\n item = item_from_uid(uid)\n note.attachments.find_or_create_by(item: item)\n end\n\n attachments_to_delete.each do |uid|\n item = item_from_uid(uid)\n note.attachments.where(item: item).destroy_all\n end\n\n note.update!(title: title, content: content)\n end\n\n render json: {\n id: note.id,\n path: note_path(note),\n }\n end",
"def update\n respond_to do |format|\n if @user_attachment.update(user_attachment_params)\n format.html { redirect_to @user_attachment, notice: 'User attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n expire_action( news_url(:slug=>@post.slug) )\n expire_action( news_url(nil) )\n expire_action( home_url() )\n\n # Add/Remove attachments\n params[:attachments].each do |att|\n @post.attachments.create :uploadedfile=>att\n end if params.has_key?( :attachments )\n params[:removed_attachments].each do |att_id|\n begin # Let's be safe about it...\n @post.attachments.find(att_id).destroy\n rescue\n STDERR.puts \"#{att_id} isn't a valid ID for this post.\"\n end\n end if params.has_key?( :removed_attachments )\n\n flash[:notice] = 'Post was successfully updated.'\n format.html { redirect_to posts_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors.to_xml }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order_attachment.update(order_attachment_params)\n format.html { redirect_to @order_attachment, notice: 'Order attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_attachment }\n else\n format.html { render :edit }\n format.json { render json: @order_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n params[:case_attachments]['photo'].each do |a|\n @case_attachment = @case.case_attachments.create!(:photo => a, :case_id => @case.id)\n end\n format.html { redirect_to admin_cases_path, notice: \"Caso Clínico (#{@case.title}), alterado com sucesso!\" }\n format.json { render :show, status: :ok, location: [:admin, @case] }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_attachment(args={})\n raise ArgumentError unless args[:file] && args[:name]\n return unless has_attachment?(args[:name])\n delete_attachment(args[:name])\n set_attachment_attr(args)\n rescue ArgumentError => e\n raise ArgumentError, 'You must specify :file and :name'\n end",
"def put(path = '/files/', params = {})\n request :put, path, params\n end",
"def test_issue_attachements\n log_user('jsmith', 'jsmith')\n\n post 'issues/edit/1',\n :notes => 'Some notes',\n :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}\n assert_redirected_to \"issues/show/1\"\n \n # make sure attachment was saved\n attachment = Issue.find(1).attachments.find_by_filename(\"testfile.txt\")\n assert_kind_of Attachment, attachment\n assert_equal Issue.find(1), attachment.container\n assert_equal 'This is an attachment', attachment.description\n # verify the size of the attachment stored in db\n #assert_equal file_data_1.length, attachment.filesize\n # verify that the attachment was written to disk\n assert File.exist?(attachment.diskfile)\n \n # remove the attachments\n Issue.find(1).attachments.each(&:destroy)\n assert_equal 0, Issue.find(1).attachments.length\n end",
"def update!(**args)\n @attachment_id = args[:attachment_id] unless args[:attachment_id].nil?\n @data = args[:data] unless args[:data].nil?\n @size = args[:size] unless args[:size].nil?\n end",
"def update\n respond_to do |format|\n if @attachfile.update(attachfile_params)\n format.html { redirect_to @attachfile, notice: 'Attachfile was successfully updated.' }\n format.json { render :show, status: :ok, location: @attachfile }\n else\n format.html { render :edit }\n format.json { render json: @attachfile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @friends_attachment.update(friends_attachment_params)\n format.html { redirect_to @friends_attachment, notice: \"Friends attachment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @friends_attachment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @friends_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload_attachment index, id, pipeline, document\n document_for_reporting = document.clone\n document_for_reporting[\"data\"] = document_for_reporting[\"data\"] ? \"[...#{document_for_reporting[\"data\"].length} characters long]\" : \"none\"\n\n es_uri = \"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}?pipeline=#{pipeline}\"\n\n log.debug(\"Uploading attachment through call: #{es_uri}\")\n log.debug(\"Uploading approximate body: #{document_for_reporting}\")\n\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}?pipeline=#{pipeline}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end",
"def connect_attachments(params)\n json_attachments = params['data'].try(:[], 'relationships').try(:[], 'attachments')\n return if json_attachments.blank?\n\n attachment_list = resource_list('attachment', json_attachments)\n\n attachment_list.each do |attachment|\n attachment.attachable = self\n attachment.save\n end\n end",
"def update\n @aboutshetuan = Aboutshetuan.find(params[:id])\n\n respond_to do |format|\n if @aboutshetuan.update_attributes(params[:aboutshetuan])\n Attachment.create(:attachment => params[:attachment], :attachmentable => @aboutshetuan) if params[:attachment]\n format.html { redirect_to @aboutshetuan, notice: 'Aboutshetuan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aboutshetuan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @attached_asset = AttachedAsset.find(params[:id])\n\n respond_to do |format|\n if @attached_asset.update_attributes(params[:attached_asset])\n format.html { redirect_to @attached_asset, notice: 'Attached asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attached_asset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @capa = Capa.find(params[:id])\n\n respond_to do |format|\n if @capa.update_attributes(params[:capa])\n unless params[:capa_files].blank?\n params[:capa_files]['file'].each do |a|\n @capa_file = @capa.capa_files.create!(:file => a, :capa_id => @capa.id)\n end\n end\n format.html { redirect_to @capa, notice: 'Capa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @capa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n @body = args[:body] if args.key?(:body)\n @create_time = args[:create_time] if args.key?(:create_time)\n @name = args[:name] if args.key?(:name)\n @permissions = args[:permissions] if args.key?(:permissions)\n @title = args[:title] if args.key?(:title)\n @trash_time = args[:trash_time] if args.key?(:trash_time)\n @trashed = args[:trashed] if args.key?(:trashed)\n @update_time = args[:update_time] if args.key?(:update_time)\n end",
"def update\n respond_to do |format|\n if @embedded_attachment.update(embedded_attachment_params)\n format.html { redirect_to @embedded_attachment, notice: 'Video was successfully updated.' }\n format.json { render :show, status: :ok, location: @embedded_attachment }\n else\n format.html { render :edit }\n format.json { render json: @embedded_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @attachment_id = args[:attachment_id] if args.key?(:attachment_id)\n @initiator = args[:initiator] if args.key?(:initiator)\n @uri = args[:uri] if args.key?(:uri)\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def update\n @attachment_datum = AttachmentDatum.find(params[:id])\n\n respond_to do |format|\n if @attachment_datum.update_attributes(params[:attachment_datum])\n format.html { redirect_to @attachment_datum, notice: 'Attachment datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @attachment_datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n params[:event_attachments]['image'].each do |a|\n @event_attachment = @event.event_attachments.create!(:image => a, :event_id => @event.id)\n end\n format.html { redirect_to edit_event_path(@event), notice: 'event was successfully edited.' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @travel_post_attachment.update(travel_post_attachment_params)\n format.html { redirect_to @travel_post_attachment, notice: 'Travel post attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @travel_post_attachment }\n else\n format.html { render :edit }\n format.json { render json: @travel_post_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @attachment_name = args[:attachment_name] if args.key?(:attachment_name)\n @namespaced_type = args[:namespaced_type] if args.key?(:namespaced_type)\n @data = args[:data] if args.key?(:data)\n end",
"def update\n respond_to do |format|\n if @post_attachment.update(post_attachment_params)\n format.html { redirect_to @post_attachment.post, notice: 'Post attachment was successfully updated.' }\n end \n end\nend",
"def update\n @pattachment = Pattachment.find(params[:id])\n\n respond_to do |format|\n if @pattachment.update_attributes(params[:pattachment])\n format.html { redirect_to @pattachment, notice: 'Pattachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pattachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @article.update(article_params)\n unless params[:draft_img].blank?\n attachment = Attachment.create(attachment_entity_type: \"Article\",attachment_entity_id: @article.id , path: params[:draft_img], created_by: 1 ) \n @article.cover_img = attachment.id\n @article.save\n end\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @note_attachment.update(note_attachment_params)\n format.html { redirect_to @note_attachment.note, notice: 'Note attachment was successfully updated.' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @meeting.update(edit_params)\n @meeting.file.attach(params[:meeting][:my_file])\n format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }\n format.json { render :show, status: :ok, location: @meeting }\n analyze\n else\n format.html { render :edit }\n format.json { render json: @meeting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @link_attachment.update(link_attachment_params)\n format.html { redirect_to @link_attachment, notice: 'Link attachment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @link_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @knowledge_article.update(knowledge_article_params)\n #update file attachments\n\n format.html { redirect_to @knowledge_article, notice: 'Knowledge article was successfully updated.' }\n format.json { render :show, status: :ok, location: @knowledge_article }\n else\n format.html { render :edit }\n format.json { render json: @knowledge_article.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",
"def set_attachment\n @attachment = Attachment.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @teacher_attachment.update(teacher_attachment_params)\n format.html { redirect_to @teacher_attachment, notice: 'Teacher attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @teacher_attachment }\n else\n format.html { render :edit }\n format.json { render json: @teacher_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end",
"def update\n @documentary.thumbnail = params[:file]\n @documentary.save!\n json_response({ message: Message.media_created })\n end",
"def update\n respond_to do |format|\n if @attachment.update(programs_attachment_params)\n format.js {}\n format.json { head :no_content, status: :updated }\n else\n format.js { render status: :unprocessable_entity }\n format.json { render json: @attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n @timestamp = args[:timestamp] if args.key?(:timestamp)\n @value = args[:value] if args.key?(:value)\n end",
"def update\n respond_to do |format|\n if @property_attachment.update(property_attachment_params)\n format.html { redirect_to @property_attachment, notice: \"Property attachment was successfully updated.\" }\n format.json { render :show, status: :ok, location: @property_attachment }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @property_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @attachment_id = args[:attachment_id] if args.key?(:attachment_id)\n @client_name_space = args[:client_name_space] if args.key?(:client_name_space)\n @comment = args[:comment] if args.key?(:comment)\n @messages = args[:messages] if args.key?(:messages)\n @type_id = args[:type_id] if args.key?(:type_id)\n end",
"def update\n @attachment = Attachment.find(params[:id])\n params[:attachment]['role_ids'] ||=[]\n if params[:public_page]==\"public\"\n params[:attachment]['role_ids']=[]\n end\n # RAILS_DEFAULT_LOGGER.error(\"\\n create_attachment params[:position]=#{params[:position]}\\n\")\n if params[:position] && !params[:position].blank?\n params[:attachment]['position']=params[:position]\n # RAILS_DEFAULT_LOGGER.error(\"\\n create_attachment params[:attachment]['position']= #{params[:attachment]['position']}\\n\")\n end\n respond_to do |format|\n if @attachment.update_attributes(params[:attachment])\n flash[:notice] = 'attachment was successfully updated.'.t\n format.html { redirect_to page_attachments_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @attachment.errors.to_xml }\n end\n end\n end",
"def update!(**args)\n @attachment = args[:attachment] if args.key?(:attachment)\n @segment = args[:segment] if args.key?(:segment)\n end",
"def upload_attachment(documentname,locale,fullpath, mime_type,attachmentname)\n thisfile = File.new(\"#{fullpath}\")\n # Create the hash of the file for comparison, since we don't want to update the attachment if it hasn't changed\n this_attachment_hash = Digest::SHA256.file(thisfile).hexdigest\n dupe = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).count > 0\n unless dupe\n then\n# begin\n @thisattachment = Topic.create!({\n :locale => locale,\n :attachment_hash => this_attachment_hash,\n :topicname => documentname})\n @thisattachment.create_attachment(\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type)\n # rescue\n # STDERR.puts \"Could not create a new topic with lang/locale: #{locale} and filename #{documentname}\"\n # end\n else\n # Hopefully we don't need the first, but just in case\n @thisattachment = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).first\n begin\n @thisattachment.update_attributes(\n :version_removed => CURRENT_PATCH,\n :api_version_removed => CURRENT_API_VERSION,\n :locale => locale,\n :topicname => documentname)\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n # If there is already an attachment with this filename, check to see if it needs to be updated\n if (@thisattachment.has_attachment?(attachmentname))\n then\n # Only update it if it's changed\n couch_attachment_hash = Digest::SHA256.hexdigest(@thisattachment.read_attachment(attachmentname))\n if (couch_attachment_hash != this_attachment_hash)\n then\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.update_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes, or the attachment on lang/locale: #{locale} and filename #{documentname}, for #{attachmentname}\"\n end\n end\n else\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.create_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n end\n end\n begin\n # This may not be required, but the couchrest::model doc isn't clear if create_attachment saves the document or not.\n @thisattachment.save\n rescue\n STDERR.puts \"Could not save filename #{documentname}\"\n end\n thisfile.close\nend",
"def add_attachment_to_results_section(attachment, results)\n attachments_elemnt = add_element_to_section(results,\"attachments\",attachment.to_s)\n url = @base + \"/api/v1/attachments/#{attachment[\"id\"]}.json\"\n params = {token: token, item: {element_id: attachments_elemnt[\"id\"]}}\n response = JSON.parse(RestClient.put(url,params))\nend",
"def update\n respond_to do |format|\n if @pdf_attachment.update(pdf_attachment_params)\n format.html { redirect_to @pdf_attachment, notice: 'File was successfully updated.' }\n format.json { render :show, status: :ok, location: @pdf_attachment }\n else\n format.html { render :edit }\n format.json { render json: @pdf_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat_attachment.update(boat_attachment_params)\n format.html { redirect_to @boat_attachment, notice: 'Boat attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat_attachment }\n else\n format.html { render :edit }\n format.json { render json: @boat_attachment.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update_attachment(name, values)\n attachment = find(name)\n if attachment\n attachment.headers.merge! values\n write_headers\n end\n end",
"def update!(**args)\n @attachment_sha1 = args[:attachment_sha1] if args.key?(:attachment_sha1)\n @cosmo_id = args[:cosmo_id] if args.key?(:cosmo_id)\n @cosmo_name_space = args[:cosmo_name_space] if args.key?(:cosmo_name_space)\n @encrypted_id = args[:encrypted_id] if args.key?(:encrypted_id)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @share_scope = args[:share_scope] if args.key?(:share_scope)\n end",
"def update\n @article.thumbnail = params[:file]\n @article.save!\n json_response({ message: Message.media_created })\n end",
"def add_attachments_to_existing_note(note, attachments)\n attachments.each do |attach|\n logger.debug \"Adding attachment '#{attach.file_name}' to note ID #{note.id}\"\n existing_note_attachment_input(note).when_present 1\n existing_note_attachment_input(note).send_keys Utils.asset_file_path(attach.file_name)\n existing_note_attachment_delete_button(note, attach).when_present Utils.short_wait\n sleep Utils.click_wait\n note.updated_date = Time.now\n note.attachments << attach\n end\n end",
"def update\n respond_to do |format|\n if @design_image_attachment.update(design_image_attachment_params)\n format.html { redirect_to @design_image_attachment, notice: 'Design image attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @design_image_attachment }\n else\n format.html { render :edit }\n format.json { render json: @design_image_attachment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subject_file.update(subject_file_params)\n format.html { redirect_to @subject_file, notice: 'Subject file was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject_file }\n else\n format.html { render :edit }\n format.json { render json: @subject_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event_subscription.update(event_subscription_params)\n @event_subscription.save\n\n file_params.each do |requirement|\n if(requirement[\"doc\"])\n requirement.symbolize_keys\n requirement[:doc].symbolize_keys\n path = \"data:#{requirement[:doc][:filetype]};base64, #{requirement[:doc][:base64]}\"\n Document.update(id: requirement[:doc][:id],\n user_id: @event_subscription.user_id,\n requirement_id: requirement[:id],\n state: \"pending_review\",\n path: path\n )\n end\n end\n render json: @event_subscription, status: :updated\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @pub_attachment.update(pub_attachment_params)\n format.html { redirect_to root_path, notice: 'Pub attachment was successfully updated.' }\n format.js\n else\n format.html { render :edit }\n format.js\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update!(**args)\n @attachment_data_ref = args[:attachment_data_ref] if args.key?(:attachment_data_ref)\n @content_name = args[:content_name] if args.key?(:content_name)\n @content_type = args[:content_type] if args.key?(:content_type)\n @download_uri = args[:download_uri] if args.key?(:download_uri)\n @drive_data_ref = args[:drive_data_ref] if args.key?(:drive_data_ref)\n @name = args[:name] if args.key?(:name)\n @source = args[:source] if args.key?(:source)\n @thumbnail_uri = args[:thumbnail_uri] if args.key?(:thumbnail_uri)\n end",
"def update!(**args)\n @attachment_data_ref = args[:attachment_data_ref] if args.key?(:attachment_data_ref)\n @content_name = args[:content_name] if args.key?(:content_name)\n @content_type = args[:content_type] if args.key?(:content_type)\n @download_uri = args[:download_uri] if args.key?(:download_uri)\n @drive_data_ref = args[:drive_data_ref] if args.key?(:drive_data_ref)\n @name = args[:name] if args.key?(:name)\n @source = args[:source] if args.key?(:source)\n @thumbnail_uri = args[:thumbnail_uri] if args.key?(:thumbnail_uri)\n end",
"def destroy\n @attachments = Attachment.find_by_id(params[:id])\n if @attachments.present?\n @attachments.destroy\n render :json=>{:response=>\"success\"}\n\t\tend\n end",
"def attachment_edit\n c_user = current_user()\n return ( render status: 401, json: { result: \"Not Authorized\" } ) unless logged_in? # Ensure the user is logged in\n course = Course.where(id: params[:course_id]).first()\n\n # Course Not Found case\n if course.nil?\n return ( render status: 404, json: { result: \"Course Not Found\" } )\n end\n\n # Course found case\n if attach_type_params[:type] == \"Document\"\n attache = Document.where(id: params[:attach_id], attachable_id: course.id).first()\n elsif attach_type_params[:type] == \"Embed\"\n attache = Embed.where(id: params[:attach_id], attachable_id: course.id).first()\n else\n render status: 400, json: { result: \"Invalid Type\" }\n end\n\n # Attachment not found case\n if attache.nil?\n return ( render status: 404, json: { result: \"Attachable Not Found\" } )\n end\n\n # Draft Course case\n if course.visibility == Visibility.draft and course.user_id == c_user.id and attache.class != Embed\n status = update_attachable(params[:attach_id], course.id, attach_params)\n if status\n render status: 200, json: { result: attache }\n else\n render status: 400, json: { result: attache.errors }\n end\n\n # Privledged User case\n elsif c_user.role == Role.admin or c_user.role == Role.moderator\n status = update_attachable(params[:attach_id], course.id, attach_params) \n if status\n render status: 200, json: { result: attache }\n else\n render status: 400, json: { result: attache.errors }\n end\n\n # Course is not (owned by user and editable) AND (user is not privledged)\n else\n render status: 401, json: { result: \"Not Authorized\" }\n end\n end"
] | [
"0.70723903",
"0.6969434",
"0.69647133",
"0.69444317",
"0.6940061",
"0.6824948",
"0.6824948",
"0.6770707",
"0.67692095",
"0.6754012",
"0.67488635",
"0.6722136",
"0.6639801",
"0.6639801",
"0.66233605",
"0.6618303",
"0.6527931",
"0.65129924",
"0.65124446",
"0.6488836",
"0.6397283",
"0.6387737",
"0.6387737",
"0.6385568",
"0.6332543",
"0.62781924",
"0.62697965",
"0.6253373",
"0.6253059",
"0.6226126",
"0.62085354",
"0.6192825",
"0.6192825",
"0.61793905",
"0.6162506",
"0.6148625",
"0.61435074",
"0.61080366",
"0.6082014",
"0.6078186",
"0.60741305",
"0.60737246",
"0.60709965",
"0.605416",
"0.60501957",
"0.60337055",
"0.6021548",
"0.5992908",
"0.5973636",
"0.5962731",
"0.59579897",
"0.59575427",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5955311",
"0.5954912",
"0.59444183",
"0.5929586",
"0.5925387",
"0.59241474",
"0.5908296",
"0.59079283",
"0.59018534",
"0.5900956",
"0.58884764",
"0.5879866",
"0.58772796",
"0.58756816",
"0.58686733",
"0.58679354",
"0.5867066",
"0.58368784",
"0.5835658",
"0.58310497",
"0.58247787",
"0.5812731",
"0.58102304",
"0.5793075",
"0.5788195",
"0.5783098",
"0.57728344",
"0.5766731",
"0.5764316",
"0.5762936",
"0.5753317",
"0.5736508",
"0.57264537",
"0.5725122",
"0.5723346",
"0.5720463",
"0.5718344",
"0.5717452",
"0.5717452",
"0.5711298",
"0.56992376"
] | 0.6439156 | 20 |
DELETE /attachments/1 DELETE /attachments/1.json | def destroy
@attachment = Attachment.find(params[:id])
@attachment.destroy
respond_to do |format|
format.html { redirect_to attachments_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @attachment = Attachment.find_by_name(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @attachments = Attachment.find_by_id(params[:id])\n if @attachments.present?\n @attachments.destroy\n render :json=>{:response=>\"success\"}\n\t\tend\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_attachment = MessageAttachment.find(params[:id])\n @message_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to message_attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(attachments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @file_upload_attachment.destroy\n respond_to do |format|\n format.html { redirect_to file_upload_attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment = Attachment.find(params[:id])\n #TODO: delete file from disk (folder too)\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.js { render :nothing => true }\n format.json { render :json => true }\n end\n end",
"def destroy\n @attachment_datum = AttachmentDatum.find(params[:id])\n @attachment_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to attachment_data_url }\n format.json { head :no_content }\n end\n end",
"def delete\n model.delete_attachment(@path)\n end",
"def destroy\n @link_attachment.destroy\n respond_to do |format|\n format.html { redirect_to link_attachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.detach\n head :no_content\n end",
"def destroy\n @post_attachment.destroy\n respond_to do |format|\n format.html { redirect_to post_attachments_url, notice: 'Post attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.file.purge\n @attachment.destroy\n respond_to do |format|\n format.html { redirect_to lines_url, notice: 'Attachment was successfully destroyed.' }\n end\n end",
"def delete\n Attachment.destroy(params[:id]) unless params[:id].blank? if request.delete?\n @attachment_count = params[:attachment_number] || 0\n end",
"def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(pad_attachments_path(@pad)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @attachfile.destroy\n respond_to do |format|\n format.html { redirect_to attachfiles_url, notice: 'Attachfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cms_attachment.destroy\n respond_to do |format|\n format.html { redirect_to cms_attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cms_attachment.destroy\n respond_to do |format|\n format.html { redirect_to cms_attachments_url, notice: 'Attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pattachment = Pattachment.find(params[:id])\n @pattachment.destroy\n\n respond_to do |format|\n format.html { redirect_to pattachments_url }\n format.json { head :no_content }\n end\n end",
"def destroy_attachment\n a = Attachment.find(1) rescue nil\n if !a.nil?\n a.destroy\n end\n end",
"def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n flash[:notice] = 'attachment was successfully destroyed.'.t\n respond_to do |format|\n format.html { redirect_to page_attachments_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @note_attachment.destroy\n respond_to do |format|\n format.html { redirect_to note_attachments_url, notice: 'Note attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incidentattachment.destroy\n respond_to do |format|\n format.html { redirect_to incidentattachments_url, notice: 'Incidentattachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @travel_post_attachment.destroy\n respond_to do |format|\n format.html { redirect_to travel_post_attachments_url, notice: 'Travel post attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attachment.destroy\n respond_to do |format|\n format.js {}\n end\n\n end",
"def destroy\n @order_attachment.destroy\n respond_to do |format|\n format.html { redirect_to order_attachments_url, notice: 'Order attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_attachment.destroy\n respond_to do |format|\n format.html { redirect_to event_attachments_url, notice: 'Event attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pdf_attachment.destroy\n respond_to do |format|\n format.html { redirect_to pdf_attachments_url, notice: 'File was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attached_asset = AttachedAsset.find(params[:id])\n @attached_asset.destroy\n\n respond_to do |format|\n format.html { redirect_to attached_assets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @submission_detail.attachment = nil\n @submission_detail.destroy\n respond_to do |format|\n format.html { redirect_to submissions_url, notice: 'Document was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_attachment.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'Your image was successfully deleted.'\n redirect_to :back\n }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat_attachment.destroy\n respond_to do |format|\n format.html { redirect_to boat_attachments_url, notice: 'Boat attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @friends_attachment.destroy\n respond_to do |format|\n format.html { redirect_to friends_attachments_url, notice: \"Friends attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n Attachment.find(@equip_person.id_attachment).destroy\n @equip_person.destroy\n respond_to do |format|\n format.html { redirect_to equip_people_url, notice: 'Le membre de l\\'équipe a bien été retiré.' }\n format.json { head :no_content }\n end\n end",
"def delete_attachment(name,id)\n delete_attachment_queue[name] = id if id.is_a?(BSON::ObjectId)\n write_attribute(\"#{name}_id\", nil)\n write_attribute(\"#{name}_name\", nil)\n write_attribute(\"#{name}_size\", nil)\n write_attribute(\"#{name}_type\", nil)\n end",
"def destroy\n \n @attachment = Attachment.find(params[:attachment_id])\n @attachment.destroy\n Keys.where(attachment_id: @attachment.id).destroy_all\n GetModel(params[:type]).where(file_id: @attachment.id).destroy_all\n \n respond_to do |format| \n format.html { redirect_to '/imports/'+params[:profile_id].to_s+'/csv/'+params[:type].to_s,notice: 'File has been deleted!' }\n end\n \n end",
"def delete_attachment(attachable:)\n raw_response = connection.post do |request|\n request.url \"#{realm_id}/attachable?operation=delete\"\n request.body = attachable.to_json\n end\n\n response(raw_response, entity: :attachable)\n end",
"def destroy\n @subject_file.destroy\n respond_to do |format|\n format.html { redirect_to subject_files_path(:subject => \"all\"), notice: 'Subject file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @file_attachment = FileAttachment.find(params[:id])\n @test_case = @file_attachment.test_case\n @file_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(@test_case || file_attachments_path) }\n format.xml { head :ok }\n end\n end",
"def delete_image_attachment\n @image = ActiveStorage::Attachment.find(params[:id])\n @image.purge\n redirect_back(fallback_location: items_path)\n end",
"def destroy\n @attachinaryfile.destroy\n respond_to do |format|\n format.html { redirect_to attachinaryfiles_url, notice: 'Attachinaryfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @design_image_attachment.destroy\n respond_to do |format|\n format.html { redirect_to design_image_attachments_url, notice: 'Design image attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gallery_attachment.destroy\n respond_to do |format|\n format.html { redirect_to gallery_attachments_url, notice: 'Gallery attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n attachable_id = attachable.try(:id) || attachable\n response = api.delete(\n \"user/#{api.user_name}/\" \\\n \"realestate/#{attachable_id}/\" \\\n \"attachment/#{id}\"\n )\n handle_response(response)\n self\n end",
"def delete_attachment(id, name)\n unless @model = model_class.get(id)\n flash[:error] = \"No such #{model_class.to_s.downcase} (#{h id}) exists.\"\n redirect rs()\n end\n\n # You need to be able to edit the model before removing attachments!\n for_auth do |u|\n u.can_edit? @model\n end\n\n unless attachment = @model.attachment(name)\n flash[:error] = \"No such attachment (#{h name}) exists.\"\n redirect @model.url\n end\n\n begin\n attachment.delete\n flash[:notice] = \"Deleted attachment #{h name}.\"\n rescue => e\n flash[:error] = \"Couldn't delete attachment #{h name}: #{h e.message}.\"\n end\n\n redirect @model.url\n end",
"def destroy\n @teacher_attachment.destroy\n respond_to do |format|\n format.html { redirect_to teacher_attachments_url, notice: 'Teacher attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @embedded_attachment.destroy\n respond_to do |format|\n format.html { redirect_to embedded_attachments_url, notice: 'Video was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts \"------------------------\"\n document_item = ActiveStorage::Attachment.find(@document.doc.id)\n p document_item.purge\n puts \"------------------------\"\n\n @document.destroy\n respond_to do |format|\n\n\n\n\n format.html { redirect_to property_property_unit_documents_path(@property, @property_unit), notice: 'Dokumentet ble slettet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attached = Attached.find(params[:id])\n @event = Event.find(@attached.event_id)\n @attached.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/manage_attached/\" + @event.id.to_s }\n format.json { head :no_content }\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(path = '/files/', params = {})\n request :delete, path, params\n end",
"def destroy_unsaved_attachments\n @client_side_timestamp = params[:client_side_timestamp]\n @filename = params[:filename]\n @cas_user = session[:cas_user]\n\n RecordAttachment.where(:client_side_timestamp => @client_side_timestamp, \n :filename => @filename, :cas_user_name => @cas_user).destroy_all\n render :nothing => true\n end",
"def destroy\n query = \"created_by = \\\"#{current_user.email}\\\"\"\n @photo = Photo.where(query).with_attached_images.find(params[:id])\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to photos_path, notice: 'Destroyed successfully.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @battle_attachment.destroy\n respond_to do |format|\n format.html { redirect_to battle_attachments_url, notice: 'Battle attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bulletin_file = BulletinFile.find(params[:id])\n @bulletin_file.destroy\n\n respond_to do |format|\n format.html { redirect_to bulletin_files_url }\n format.json { head :no_content }\n end\n end",
"def delete_file(file)\n delete_attachment(file)\n end",
"def destroy\n @product_attachment.destroy\n respond_to do |format|\n format.html { redirect_to product_attachments_url, notice: 'Product attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article.images.purge if @article.images.attached?\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url, notice: '記事を削除しました。' }\n format.json { head :no_content }\n end\n end",
"def delete_attachments\n delete_attachment_queue.each {|k,v| delete_grid_attachment(k,v)}\n end",
"def destroy\n @property_attachment.destroy\n respond_to do |format|\n format.html { redirect_to property_attachments_url, notice: \"Property attachment was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kf_course_knowledge_attachment = Kf::CourseKnowledgeAttachment.find(params[:id])\n @kf_course_knowledge_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_course_knowledge_attachments_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @action_file = ActionFile.find(params[:id])\n @action_file.destroy\n\n respond_to do |format|\n format.html { redirect_to action_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end",
"def destroy\n @file.destroy\n respond_to do |format|\n format.html { render text: 'created', layout: false, status: :created }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product_attachment_file.destroy\n respond_to do |format|\n format.html { redirect_to product_attachment_files_url, notice: 'Product attachment file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pin_attachment.destroy\n respond_to do |format|\n format.html { redirect_to pin_attachments_url, notice: 'Pin attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_grid_attachment(name,id)\n grid.delete(id) if id.is_a?(BSON::ObjectId)\n delete_attachment_queue.delete(name)\n end",
"def destroy\n @pub_attachment.destroy\n respond_to do |format|\n format.js { head :ok, notice: 'Anexo excluído com sucesso.' }\n end\n end",
"def destroy\n @work_order_attachment.destroy\n respond_to do |format|\n format.html { redirect_to work_order_attachments_url, notice: 'Work order attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testfile.destroy\n respond_to do |format|\n format.html { redirect_to materials_path }\n format.json { head :no_content }\n end\n end",
"def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end",
"def destroy\n @job_application_attachment = JobApplicationAttachment.find(params[:id])\n @job_application_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_application_attachments_url) }\n format.xml { head :ok }\n end\n end",
"def delete_media_by_id id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/media/{id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"id\" => id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"APIMATIC 2.0\",\r\n \"accept\" => \"application/json\",\r\n \"Content-Type\" => Configuration.content_type\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params headers\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers:headers\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n else \r\n puts \"Media ID Deleted\"\r\n end\r\n\r\n response.body\r\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @paperclip_client = PaperclipClient.find(params[:id])\n @client = @paperclip_client\n @paperclip_client.destroy\n\n respond_to do |format|\n format.html { redirect_to(paperclip_clients_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @school_attachment.destroy\n respond_to do |format|\n format.html { redirect_to school_attachments_url, notice: 'School attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_attachments_from_existing_note(note, attachments)\n attachments.each do |attach|\n logger.info \"Removing attachment '#{attach.file_name}' from note ID #{note.id}\"\n wait_for_update_and_click existing_note_attachment_delete_button(note, attach)\n confirm_delete\n existing_note_attachment_delete_button(note, attach).when_not_visible Utils.short_wait\n note.attachments.delete attach\n attach.deleted_at = Time.now\n note.updated_date = Time.now\n end\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @center_attachment.destroy\n respond_to do |format|\n format.html { redirect_to center_attachments_url, notice: 'Center attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_file.destroy\n respond_to do |format|\n format.html { redirect_to post_files_url, notice: 'Post file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_attachment(resource_id, attachment_id)\n http.delete(\"#{attachment_endpoint(resource_id)}/#{attachment_id}\") do |response|\n true\n end\n end",
"def destroy\n @avatar.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo1 = Photo1.find(params[:id])\n @photo1.destroy\n\n respond_to do |format|\n format.html { redirect_to photo1s_url }\n format.json { head :no_content }\n end\n end",
"def delete_attachment(message_id, slot)\n @api.delete(\"#{@api.path}/List/#{@id}/Email/#{message_id}/#{slot}\")\n end",
"def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to uploads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @filename.destroy\n respond_to do |format|\n format.html { redirect_to filenames_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @digital_content_file = DigitalContentFile.find(params[:id])\n @digital_content_file.destroy\n\n respond_to do |format|\n format.html { redirect_to digital_content_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock_attachment.destroy\n respond_to do |format|\n format.html { redirect_to stock_attachments_url, notice: 'Stock attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventory_file.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_files_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inventory_file.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_files_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n if id.is_a? Array then\n id = id.join(',')\n end\n\n make_post_call('/files/delete?file_ids=%s' % [id]).status == \"OK\"\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @incidentfile.destroy\n respond_to do |format|\n format.html { redirect_to incidentfiles_url, notice: 'Incidentfile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @upload = @upload = Upload.find_by(id: params[:id], user_id: current_or_guest_user.id)\n @file = ActiveStorage::Attachment.find(params[:file])\n @file&.purge\n @upload.destroy unless @upload.files.present?\n flash[:success] = 'File Deleted Successful!'\n redirect_to root_path\n rescue StandardError => error\n flash[:danger] = 'File Does Not Exist!'\n flash[:error] = error.message\n redirect_to root_path\n end"
] | [
"0.7916613",
"0.79112893",
"0.780301",
"0.780301",
"0.780301",
"0.7648198",
"0.75550735",
"0.75268084",
"0.75268084",
"0.7502376",
"0.7484949",
"0.74717665",
"0.743859",
"0.73886263",
"0.7363452",
"0.73258376",
"0.73152924",
"0.7278792",
"0.72650313",
"0.72303075",
"0.72301185",
"0.7216653",
"0.7216653",
"0.72162294",
"0.7210308",
"0.72033423",
"0.7171855",
"0.7161647",
"0.70944935",
"0.70774776",
"0.7037978",
"0.70379555",
"0.7029702",
"0.7025915",
"0.7021321",
"0.69998616",
"0.6984929",
"0.6984463",
"0.6981674",
"0.69508517",
"0.6940797",
"0.6937764",
"0.6902654",
"0.6902036",
"0.68988657",
"0.6893214",
"0.6874965",
"0.6868198",
"0.6866467",
"0.68640906",
"0.6844699",
"0.6839022",
"0.6835348",
"0.68349224",
"0.6776542",
"0.6771497",
"0.67643094",
"0.67508096",
"0.673062",
"0.6722993",
"0.6705728",
"0.67055273",
"0.67052394",
"0.66944176",
"0.6689338",
"0.6684574",
"0.6682248",
"0.6680252",
"0.6673648",
"0.6670325",
"0.6668663",
"0.6631442",
"0.6623201",
"0.66226023",
"0.6618685",
"0.6614975",
"0.65828294",
"0.6575129",
"0.65751076",
"0.6568256",
"0.6566976",
"0.6565117",
"0.6549893",
"0.65391684",
"0.65354407",
"0.6534947",
"0.65335286",
"0.65136737",
"0.6508646",
"0.65066403",
"0.6505789",
"0.65006864",
"0.64938295",
"0.64930916",
"0.6486351",
"0.6486351",
"0.64838755",
"0.6475477",
"0.6467498",
"0.6466703"
] | 0.7848189 | 2 |
GET /level_containers/1 GET /level_containers/1.json | def show
@level_container = LevelContainer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @level_container }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @level_container = LevelContainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_container }\n end\n end",
"def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @containers }\n end\n end",
"def index\n @containers = Container.all\n end",
"def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end",
"def containers\n TestLab::Container.all\n end",
"def index_containers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_containers ...'\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'comment'] = opts[:'comment'] if !opts[:'comment'].nil?\n query_params[:'quota_total_size'] = opts[:'quota_total_size'] if !opts[:'quota_total_size'].nil?\n query_params[:'quota_on_cache'] = opts[:'quota_on_cache'] if !opts[:'quota_on_cache'].nil?\n query_params[:'stat_total_files'] = opts[:'stat_total_files'] if !opts[:'stat_total_files'].nil?\n query_params[:'stat_total_size'] = opts[:'stat_total_size'] if !opts[:'stat_total_size'].nil?\n query_params[:'stat_size_on_cache'] = opts[:'stat_size_on_cache'] if !opts[:'stat_size_on_cache'].nil?\n query_params[:'guest_right'] = opts[:'guest_right'] if !opts[:'guest_right'].nil?\n query_params[:'last_update'] = opts[:'last_update'] if !opts[:'last_update'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_containers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def containers(key = nil, options = {})\n key ||= properties.key1\n\n query = \"comp=list\"\n options.each { |okey, ovalue| query += \"&#{okey}=#{[ovalue].flatten.join(',')}\" }\n\n response = blob_response(key, query)\n\n doc = Nokogiri::XML(response.body)\n\n results = doc.xpath('//Containers/Container').collect do |element|\n Container.new(Hash.from_xml(element.to_s)['Container'])\n end\n\n results.concat(next_marker_results(doc, :containers, key, options))\n end",
"def show\n @level_category = LevelCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_category }\n end\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 get_containers\n assert_not_nil @rdigg.info.get_containers\n end",
"def read_containers\n []\n end",
"def list # rubocop:disable Metrics/AbcSize\n if @options[:container]\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n containerview = containerview.contents(@options[:container])\n if containerview.code == '201' || containerview.code == '200'\n containerview.body\n elsif containerview.code == '204'\n print 'the container is empty'\n else\n @util.response_handler(containerview)\n end\n else\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.list\n @util.response_handler(newcontainer)\n newcontainer.body if newcontainer.code == '200'\n puts 'there are no containers' if newcontainer.code == '204'\n end \n end",
"def get_levels\n if params[:levels_by_nf] == 'true'\n @foundation = Foundation.find_by(name: params[:name])\n if @foundation\n render json: {levels: @foundation.levels.pluck(:name)}, status: 200\n else\n render json: {\n levels: []\n }, status: 200\n end\n return\n end\n\n @foundation = Foundation.find_by(id: params[:id])\n if @foundation\n render template: 'levels/get_levels.json', status: 200\n else\n render json: {\n levels: []\n }, status: 200\n end\n end",
"def index\n @containers_pages = @page.containers_pages\n end",
"def list_containers(options={})\n query = { }\n if options\n query['prefix'] = options[:prefix] if options[:prefix]\n query['marker'] = options[:marker] if options[:marker]\n query['maxresults'] = options[:max_results].to_s if options[:max_results]\n query['include'] = 'metadata' if options[:metadata] == true\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n end\n\n uri = containers_uri(query)\n response = call(:get, uri)\n\n Serialization.container_enumeration_results_from_xml(response.body)\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 index\n @serverhascontainers = Serverhascontainer.all\n end",
"def containers\n @containers ||= Docker::Container.all(\n all: true, # include stopped containers\n filters: { id: container_ids }.to_json\n ).map(&:json)\n end",
"def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def update\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n if @level_container.update_attributes(params[:level_container])\n format.html { redirect_to @level_container, notice: 'Level container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def container\n return nil if container_type.blank? || container_id.blank?\n container_type.constantize.where(id: container_id).first\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 show\n @level = Level.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level }\n end\n end",
"def containers\n return @containers unless @containers.nil?\n container_codes = []\n codes = code.split('|')\n container_codes << (codes = codes[0..-2]).join('|') while codes.size > 1\n # first is country code\n @containers = [country]\n # second, third can be parent administrative division if not nil\n # NOTE container codes is like: [\"ES|58|PO\", \"ES|58\", \"ES\"] (country is last)\n @containers += Division.find_all_by_code container_codes[0..-2], :order => :level if container_codes.size > 1\n return @containers\n end",
"def find_container\n if action_name.in? ['create', 'update']\n cid = params[:container_id]\n else\n cid = params[:id]\n params[:id] = params[:download_id]\n alid = params[:activity_log_id]\n altype = params[:activity_log_type]\n end\n @container = NfsStore::Browse.open_container id: cid, user: current_user\n @retrieval_type = params[:retrieval_type]\n\n @activity_log = ActivityLog.open_activity_log altype, alid, current_user if alid.present? && altype.present?\n\n case @retrieval_type\n when 'stored_file'\n @download = @container.stored_files.find_by(id: params[:download_id])\n when 'archived_file'\n @download = @container.archived_files.find_by(id: params[:download_id])\n else\n raise FphsException, 'Incorrect retrieval_type set'\n end\n\n @container.parent_item = @activity_log\n @master = @container.master\n @master.current_user ||= current_user\n # object_instance.container = @container\n @container\n end",
"def index\n status = get_health_status( )\n response = make_response( status )\n #render json: response, :status => response.is_healthy? ? 200 : 500\n render json: response, :status => 200 # dont want to continuously restart the container\n end",
"def containers\n obj = parse_object(1)\n return nil unless obj && obj.m_Container && obj.m_Container.array?\n obj.m_Container.value.map do |e|\n {:name => e.first.value, :preload_index => e.second.preloadIndex.value, :path_id => e.second.asset.m_PathID.value}\n end\n end",
"def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end",
"def get_container\n container_id_key = params.keys.find_all { |key| key =~ /\\w+_id/ }.last\n container_class = eval(container_id_key.humanize.titleize.delete(' '))\n @container = container_class.find_by_id(params[container_id_key])\n redirect_with_error 'Invalid project id' unless @container\n end",
"def containers_from_solr\n containers(:response_format => :load_from_solr)\n end",
"def containers_ids\n containers(:response_format => :id_array)\n end",
"def index\n @declaration_containers = @declaration.declaration_containers.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @declaration_containers }\n end\n end",
"def index_containers(opts = {})\n data, _status_code, _headers = index_containers_with_http_info(opts)\n data\n end",
"def get_container(container_name)\n assert_not_nil @rdigg.info.get_container(\"technology\")\n end",
"def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end",
"def containers\n return @containers\n end",
"def get # replace this with the call that I use in my class that follows redirects\n @debug and $stderr.puts \"getting container\"\n @debug and $stderr.puts self.uri, {accept: \"text/turtle\"}, self.client.username, self.client.password\n response = LDP::HTTPUtils.get(self.uri, {accept: \"text/turtle\"}, self.client.username, self.client.password)\n etag = Digest::SHA2.hexdigest `date` \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle'}\n\n response = LDP::HTTPUtils.get(self.uri, headers, self.client.username, self.client.password)\n\n if response\n return response\n else\n @debug and $stderr.puts \"FAILED to find this container #{self.uri.to_s}\" # do something more useful, one day\n return false\n end\n end",
"def show\n @containers_pages = @page.containers_pages \n end",
"def get_container_properties(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end",
"def get_container(container_name = \"lightstructures\")\n containers = $azure_blob_service.list_containers()\n return containers.detect { |c| c.name == container_name } # Must be better ways?!\nend",
"def get_container_properties(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end",
"def index\n #@collections = Collection.all\n @root_collections = []\n \n #filter by parent collection id if requested\n if params.include?('parent_id')\n #@all_collections = Collection.where(:collection_id => params['parent_id'].to_i)\n #TODO: ancestry?\n else\n #only root collections\n #TODO\n #@all_collections = Collection.where(:collection_id => nil).order('name')\n @all_collections = Collection.roots.order('name')\n end\n \n #add additional data, mostly for json requests\n @all_collections.each do |c|\n c.validated = collection_is_validated(c)\n end\n\n #filter for permission\n @all_collections.each do |c|\n if collection_is_viewable(c, current_user)\n @root_collections << c\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @root_collections }\n end\n end",
"def top_containers\n container_information.select do |container|\n container[\"label\"].to_s.downcase.include?(\"box\") || container[\"profile\"].include?(\"OS folder\")\n end\n end",
"def index_container_privileges_with_http_info(container_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_container_privileges ...'\n end\n # verify the required parameter 'container_id' is set\n if @api_client.config.client_side_validation && container_id.nil?\n fail ArgumentError, \"Missing the required parameter 'container_id' when calling ContainersApi.index_container_privileges\"\n end\n # resource path\n local_var_path = '/containers/{container_id}/container_privileges'.sub('{' + 'container_id' + '}', CGI.escape(container_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'privilege'] = opts[:'privilege'] if !opts[:'privilege'].nil?\n query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerPrivilegeCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_container_privileges\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def containers=(value)\n @containers = value\n end",
"def id\n container.id\n end",
"def container(container_id)\n if container_id\n container = ::Docker::Container.send(:new, @dockerd, container_id)\n # return the container json if we can retrieve it.\n begin\n # check the container exists by querying its json\n container.json\n container\n # if the container doesn't exist we get an Excon 404\n rescue Excon::Errors::NotFound\n nil\n end\n else\n nil\n end\n end",
"def info\n container.info\n end",
"def index\n render json: @owner.cats\n end",
"def index\n if @container\n @container_contents = @container.container_contents\n else\n @container_contents = ContainerContent.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @container_contents }\n end\n end",
"def index\n @levels = Level.all\n end",
"def index\n @levels = Level.all\n end",
"def levels\n response = JSON.parse(@client.get(\"/api/v1/levels\").body)\n return response[\"levels\"] || response\n end",
"def show\n @level = Level.find(params[:id])\n Level.increment_counter :view_count, @level.id\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @level }\n end\n end",
"def show\n @container = Container.get!(params[:id])\n @dropbox = Dropbox.new(@container)\n @upload_url = upload_container_url(@container.id)\n if Ixtlan::Guard.check(self, :containers, :edit, nil) || @container.public?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @container }\n end\n else\n redirect_to container_url(Container.root.id)\n end\n end",
"def running_containers\n containers = ::Docker::Container.all(all: true, filters: { status: [\"running\"] }.to_json)\n return containers\n end",
"def x_show\n get_tagdata(Container.find_by_id(from_cid(params[:id])))\n identify_container(from_cid(params[:id]))\n generic_x_show(x_tree(:containers_tree))\n end",
"def index\n @health_levels = HealthLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @health_levels }\n end\n end",
"def index\n @level = Level.find(params[:level_id])\n \n \n end",
"def inspect(container_s)\n containers = container_s\n containers = [containers] unless container_s.is_a?(Array)\n return [] if containers.empty?\n out = run!('inspect', containers)\n result = JSON.parse(out).map { |c| Container.new(c, session:self)}\n if container_s.is_a?(Array)\n result\n else\n result.first\n end\n end",
"def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end",
"def show\n @breadcrumb = 'read'\n @infrastructure_type = InfrastructureType.find(params[:id])\n @infrastructures = @infrastructure_type.infrastructures.paginate(:page => params[:page], :per_page => per_page).order(:code)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @infrastructure_type }\n end\n end",
"def get_containers_by_given_name(given_name)\n @containers.select { |label, container|\n container.attributes[:name].match(/#{ComposeUtils.dir_name}_#{given_name}_\\d+/)\n }.values\n end",
"def index\n if (params[:user])\n @containers = User.find_by_login(params[:user]).containers\n else\n if (current_user.nil?)\n redirect_to :controller => :users, :action => :login\n return\n else\n @containers = current_user.containers\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :layout => false }\n end\n end",
"def containers\n containers_exited(days_old: 1)\n containers_running(days_old: 1)\n end",
"def container\n @container ||= Docker::Container.get(@name)\n rescue Docker::Error::NotFoundError\n @container = nil\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @health_level }\n end\n end",
"def container\n namespace + '_container'\n end",
"def set_container\n @container = Container.find(params[:id])\n end",
"def set_container\n @container = Container.find(params[:id])\n end",
"def active_item_container_for(level)\n case level\n when :all then primary_navigation\n when :leaves then primary_navigation.active_leaf_container\n when Integer then primary_navigation.active_item_container_for(level)\n when Range then primary_navigation.active_item_container_for(level.min)\n else\n fail ArgumentError, \"Invalid navigation level: #{level}\"\n end\n end",
"def recipebook\n @levels = Level.all\n\n respond_to do |format|\n format.html # recipebook.html.erb\n format.json { render json: @levels }\n end\n end",
"def index\n @collections = @institution.collections.order(:name)\n\n respond_to do |format|\n format.html { render layout: 'fluid' }# index.html.erb\n format.json { render json: @collections }\n end\n end",
"def container_properties(name, key = nil)\n key ||= properties.key1\n\n response = blob_response(key, \"restype=container\", name)\n\n ContainerProperty.new(response.headers)\n end",
"def show_container_with_http_info(container_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.show_container ...'\n end\n # verify the required parameter 'container_id' is set\n if @api_client.config.client_side_validation && container_id.nil?\n fail ArgumentError, \"Missing the required parameter 'container_id' when calling ContainersApi.show_container\"\n end\n # resource path\n local_var_path = '/containers/{container_id}'.sub('{' + 'container_id' + '}', CGI.escape(container_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[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#show_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def objects(container = @default_container,\n path: nil, limit: nil, gt: nil, lt: nil)\n path = path[1..-1] if path && path[0] == ?/\n p = { path: path, limit: limit, marker: gt, end_marker: lt\n }.delete_if {|k,v| v.nil? }\n j,h = api_openstack(:get, container, p)\n Hash[j.map {|o| [ o['name'], {\n :hash => o['hash'],\n :lastmod => Time.parse(o['last_modified']),\n :size => o['bytes'].to_i,\n :type => o['content_type'],\n :contuse => h['x-container-bytes-used'],\n :contoct => h['x-container-object-coun'],\n :storpol => h['x-storage-policy'],\n } ] } ]\n end",
"def show\n @village = Village.find(params[:id])\n @collections = @village.collections\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @village }\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 get_containers_by(params)\n @containers.values.select do |container|\n (params.to_a - container.attributes.to_a).empty?\n end\n end",
"def container_id\n @container_info[\"Id\"]\n end",
"def get_api_node(path_array)\n return JSON.parse(lxc(['query', '--wait', '-X', 'GET', return_api_path(path_array)]))\n end",
"def get_container_metadata(name, options={})\n # Query\n query = { 'comp' => 'metadata' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n response = call(:get, container_uri(name, query), nil, {}, options)\n\n # result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end",
"def get_container_metadata(name, options={})\n query = { 'comp' => 'metadata'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n response = call(:get, container_uri(name, query))\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container\n end",
"def show\n @admin_level = AdminLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_level }\n end\n end",
"def data\n\t\t@levels = (params[:id].nil?) ? Level.all(:select => 'title,id', :order => 'order_index') : Level.find(params[:id], :select => 'title,id')\n\t\trespond_to do |format|\n\t\t\tformat.xml { render :xml => @levels }\n\t\t\tformat.json { render :json => @levels }\n\t\tend\n\tend",
"def index\n @sectors = Sector.all.order(\"created_at DESC\")\n render json: @sectors\n end",
"def get_container(container_name)\n container = Docker::Container.all().find do |container|\n container.json['Name'] == \"/#{container_name}\"\n end\n\n if container.nil?\n Kernel.abort(\"Error: Docker container '#{container_name}' does not appear to be running. Please use 'docker logs -f #{container_name}' to investigate any start-up failures.\")\n # This return statement is required as we mock the Kernel.abort call in unit testing.\n return\n end\n\n container\nend",
"def find_container_instances (record_json)\n \n current_uri = record_json['uri']\n \n Rails.logger.info(\"Aeon Fulfillment Plugin\") { \"Checking \\\"#{current_uri}\\\" for Top Container instances...\" }\n if log_record?\n Rails.logger.debug(\"Aeon Fulfillment Plugin\") { \"#{record_json.to_json}\" }\n end\n\n instances = record_json['instances']\n .reject { |instance| instance['digital_object'] }\n\n if instances.any?\n Rails.logger.info(\"Aeon Fulfillment Plugin\") { \"Top Container instances found\" }\n return instances\n end\n\n # If we're in top container mode, we can skip this step, \n # since we only want to present containers associated with the current record.\n if (!self.repo_settings[:top_container_mode])\n parent_uri = ''\n\n if record_json['parent'].present?\n parent_uri = record_json['parent']['ref']\n parent_uri = record_json['parent'] unless parent_uri.present?\n elsif record_json['resource'].present?\n parent_uri = record_json['resource']['ref']\n parent_uri = record_json['resource'] unless parent_uri.present?\n end\n\n if parent_uri.present?\n Rails.logger.debug(\"Aeon Fulfillment Plugin\") { \"No Top Container instances found. Checking parent. (#{parent_uri})\" }\n parent = archivesspace.get_record(parent_uri)\n parent_json = parent['json']\n return find_container_instances(parent_json)\n end\n end\n\n Rails.logger.debug(\"Aeon Fulfillment Plugin\") { \"No Top Container instances found.\" }\n\n []\n end",
"def show\n @indicator_category = IndicatorCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indicator_category }\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 @collections = Rack::WebProfiler::Model::CollectionRecord.order(Sequel.desc(:created_at))\n .limit(20)\n\n return json(@collections, to_json_opts: {\n only: [:token, :http_method, :http_status, :url, :ip]\n }) if prefer_json?\n\n erb \"panel/index.erb\", layout: \"panel/layout.erb\"\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def container(property)\n return '@set' if property == '@graph'\n @containers.fetch(property.to_s, nil)\n end",
"def init_containers\n return @init_containers\n end",
"def show\n @konfig = Konfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konfig }\n end\n end",
"def index\n @goods_categories = GoodsCategory.roots\n @goods_category = GoodsCategory.new\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goods_categories }\n end\n end",
"def show\n @price_level = PriceLevel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @price_level }\n end\n end",
"def show\n @label = Label.find_by_id(params[:id])\n if @label.nil?\n @label = Label.find_by_name(params[:id])\n end\n\n @repos = Repo.tagged_with(@label.name, on: :labels).order(\"watchers DESC\")\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @label }\n end\n end"
] | [
"0.66490954",
"0.6480713",
"0.64376557",
"0.6209083",
"0.6160761",
"0.6030286",
"0.6016257",
"0.59843445",
"0.58678746",
"0.58255917",
"0.5691087",
"0.56846285",
"0.5670138",
"0.56534827",
"0.5628714",
"0.5626149",
"0.5616102",
"0.5604705",
"0.55708253",
"0.555228",
"0.5535543",
"0.54782414",
"0.54586583",
"0.5456884",
"0.5453813",
"0.5441707",
"0.54302675",
"0.5425529",
"0.54177797",
"0.5414295",
"0.5402216",
"0.5369577",
"0.5352175",
"0.5326376",
"0.5324673",
"0.5311284",
"0.52765816",
"0.52555823",
"0.52519363",
"0.52479535",
"0.5244416",
"0.5241234",
"0.52356964",
"0.5229257",
"0.5224867",
"0.52158725",
"0.5187313",
"0.5155641",
"0.5150206",
"0.51482356",
"0.51401156",
"0.51361084",
"0.51212806",
"0.51212806",
"0.51012284",
"0.51006377",
"0.5098931",
"0.50865835",
"0.5086267",
"0.50775254",
"0.5069969",
"0.5064297",
"0.5060768",
"0.5027992",
"0.5026502",
"0.5024641",
"0.50227225",
"0.5021979",
"0.5020988",
"0.50197923",
"0.501923",
"0.501923",
"0.5006398",
"0.50040674",
"0.5002339",
"0.49879506",
"0.4984964",
"0.49841154",
"0.49735433",
"0.49660343",
"0.49503857",
"0.49465492",
"0.49373013",
"0.49364245",
"0.49307802",
"0.49307188",
"0.4923631",
"0.4919017",
"0.49166375",
"0.4902724",
"0.48937523",
"0.4887018",
"0.48802537",
"0.4870724",
"0.486417",
"0.48625267",
"0.48563516",
"0.48464957",
"0.48463964",
"0.48420683"
] | 0.7470914 | 0 |
GET /level_containers/new GET /level_containers/new.json | def new
@level_container = LevelContainer.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @level_container }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @level_category = LevelCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_category }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @level = Level.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level }\n end\n end",
"def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def new\n @level = Level.new\n @level.set_defaults\n bingo!(\"create_level_button\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @level }\n end\n end",
"def new\n @collection = Collection.new(:parent_id => params[:parent_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end",
"def new\n @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 puts @category.inspect\n @internal = @category.internals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @internal }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @health_level }\n end\n end",
"def new\n @layer = Layer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @layer }\n end\n end",
"def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\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 create\n @level_category = LevelCategory.new(params[:level_category])\n\n respond_to do |format|\n if @level_category.save\n format.html { redirect_to @level_category, notice: 'Level category was successfully created.' }\n format.json { render json: @level_category, status: :created, location: @level_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def new\n @admin_level = AdminLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_level }\n end\n end",
"def new\n @container = Container.new\n \n respond_to do |format|\n format.html { render :action => :edit }\n format.xml { render :action => :edit, :xml => @container }\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 new_for_creating_stack\n infra_id = params.require(:infrastructure_id)\n\n histories = CfTemplate.for_infra(infra_id)\n # TODO: 変数名変えたほうがいいんじゃ\n globals = CfTemplate.global\n\n render json: {\n histories: histories,\n globals: globals,\n } and return\n end",
"def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end",
"def new\n @price_level = PriceLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @price_level }\n end\n end",
"def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end",
"def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cloud }\n end\n end",
"def new\n @lab = Lab.find(params[:lab_id])\n @machine = Machine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @machine }\n end\n end",
"def new\n @title = t('view.tags.new_title')\n @tag = Tag.new(parent_id: params[:parent])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @holder = Holder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @holder }\n end\n end",
"def create\n @level = Level.new(params[:level])\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render json: @level, status: :created, location: @level }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @level = Level.new(params[:level])\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render json: @level, status: :created, location: @level }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @collection = Collection.new\n respond_to do |format|\n format.html { create }\n format.json { render :json => @collection }\n end\n end",
"def new\n @collection = Collection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @collection }\n end\n end",
"def new\n @container_content = @container.container_contents.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @container_content }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def 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\n @cluster = Cluster.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cluster }\n end\n end",
"def new\n @collection = @user.collections.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection }\n end\n end",
"def new\n @slab = Slab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @slab }\n end\n end",
"def create\n @resource = Catalogs::Level.new(catalogs_level_params)\n\n respond_to do |format|\n if @resource.save\n index\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Level was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def new\n @pcategory = Pcategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pcategory }\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 @map_node = Map::Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map_node }\n end\n end",
"def new\n get_status\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def show\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_container }\n end\n end",
"def new\n @overlay = Overlay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @overlay }\n end\n end",
"def new\n @breadcrumb = 'create'\n @infrastructure_type = InfrastructureType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @infrastructure_type }\n end\n end",
"def new\n @logstash = Logstash.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logstash }\n end\n end",
"def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end",
"def new\n @cat = Cat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cat }\n end\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def new\n @tree = Tree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tree }\n end\n end",
"def new\n @category = current_mall.categories.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @level_goal = LevelGoal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_goal }\n end\n end",
"def new\n @quest_tree = QuestTree.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest_tree }\n end\n end",
"def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end",
"def new\n @threshold = Threshold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @threshold }\n end\n end",
"def new\n @breadcrumb = 'create'\n @inventory_count_type = InventoryCountType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_count_type }\n end\n end",
"def new\n @pclevel = Pclevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pclevel }\n end\n end",
"def new\n @label = Label.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @label }\n end\n end",
"def new\n @konfig = Konfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @konfig }\n end\n end",
"def new\n @lifecycle = Lifecycle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lifecycle }\n end\n end",
"def new\n @isgrey = true;\n @current_page = \"ADD PROJECT\"\n @project = Project.new\n @project_attachment = @project.project_attachments.build\n @slider_object = @project.slider_objects.build\n @project_field = @project.project_fields.build\n @project_other_field = @project.project_other_fields.build\n\n @types = Type.all\n @new_nav = true;\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @pinglun = Pinglun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pinglun }\n end\n end",
"def new\n @map = Map.find(params[:map_id])\n\n #@node = Node.new\n @node = @map.nodes.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node }\n end\n end",
"def new\n @goods_categories = GoodsCategory.roots\n @goods_category = GoodsCategory.new\n\n respond_to do |format|\n format.html {render action: \"index\"}\n format.json { render json: @goods_category }\n end\n end",
"def new\n @orthodb_level = OrthodbLevel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orthodb_level }\n end\n end",
"def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end",
"def new\n @lab = Lab.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lab }\n end\n end",
"def new\n @physical_rack = PhysicalRack.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @physical_rack }\n end\n end",
"def new\n @attribute_layer = AttributeLayer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attribute_layer }\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",
"def new\n @space_cat = SpaceCat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space_cat }\n end\n end",
"def new\n @quest = Quest.new\n\t@categories = find_all_categories\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end",
"def new\n @chef_mapping = ChefMapping.new\n @source = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chef_mapping }\n end\n end",
"def new\n @server_node = ServerNode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_node }\n end\n end",
"def new\n add_breadcrumb 'Your hubs', :hubs_path\n add_breadcrumb 'New hub', new_hub_path\n append_title 'New hub'\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @hub }\n end\n end",
"def create\n if admin?\n @level = Level.new(level_params)\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render :show, status: :created, location: @level }\n else\n format.html { render :new }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n authorize! :create, :level\n type_class = level_params[:type].constantize\n\n # Set some defaults.\n params[:level].reverse_merge!(skin: type_class.skins.first) if type_class <= Blockly\n if type_class <= Grid\n params[:level][:maze_data] = Array.new(8){Array.new(8){0}}\n params[:level][:maze_data][0][0] = 2\n end\n if type_class <= Studio\n params[:level][:maze_data][0][0] = 16 # studio must have at least 1 actor\n params[:level][:soft_buttons] = nil\n params[:level][:timeout_after_when_run] = true\n params[:level][:success_condition] = Studio.default_success_condition\n params[:level][:failure_condition] = Studio.default_failure_condition\n end\n params[:level][:maze_data] = params[:level][:maze_data].to_json if type_class <= Grid\n params.merge!(user: current_user)\n\n begin\n @level = type_class.create_from_level_builder(params, level_params)\n rescue ArgumentError => e\n render status: :not_acceptable, text: e.message and return\n rescue ActiveRecord::RecordInvalid => invalid\n render status: :not_acceptable, text: invalid and return\n end\n\n render json: { redirect: edit_level_path(@level) }\n end",
"def new\n @console_pool = ConsolePool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @console_pool }\n end\n end",
"def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @category = Category.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category }\n end\n end",
"def new\n @civil_status = CivilStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @civil_status }\n end\n end",
"def new\n @map = Map.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end",
"def new\n @loadbalancer = Loadbalancer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loadbalancer }\n end\n end",
"def new\n @node_template = NodeTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @node_template }\n end\n end",
"def new\n @smallmap = Smallmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @smallmap }\n end\n end",
"def new\n @collection = @institution.collections.new\n\n respond_to do |format|\n format.html { render layout: 'form' }# new.html.erb\n format.json { render json: @collection }\n end\n end",
"def new\n @keyword = Keyword.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end",
"def new\n @category = Category.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category}\n end\n end",
"def new\n @kind = Kind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kind }\n end\n end",
"def new\n @lid = Lid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lid }\n end\n end"
] | [
"0.7540073",
"0.6921353",
"0.6890227",
"0.68889314",
"0.6888748",
"0.6850067",
"0.68158525",
"0.6496244",
"0.6387826",
"0.6346345",
"0.63002974",
"0.6281766",
"0.6270102",
"0.6269996",
"0.62044543",
"0.6190622",
"0.6184238",
"0.6122632",
"0.61143756",
"0.6113332",
"0.6098171",
"0.60762656",
"0.6058095",
"0.6051868",
"0.60475236",
"0.60310614",
"0.5993702",
"0.59891534",
"0.59891534",
"0.5988885",
"0.5987413",
"0.5984273",
"0.5970805",
"0.5956725",
"0.59527713",
"0.59495074",
"0.5949399",
"0.5948327",
"0.59409285",
"0.5936142",
"0.5923644",
"0.5919379",
"0.59155285",
"0.59140605",
"0.5906002",
"0.59058064",
"0.58958185",
"0.58958185",
"0.5885552",
"0.5885552",
"0.5882194",
"0.58778393",
"0.5876479",
"0.58760893",
"0.5874609",
"0.5868335",
"0.5864526",
"0.58583367",
"0.58570474",
"0.58513314",
"0.58401334",
"0.5831644",
"0.58297306",
"0.58187306",
"0.5815033",
"0.58147436",
"0.5814093",
"0.5814093",
"0.5811555",
"0.5799634",
"0.57966536",
"0.57906866",
"0.57882124",
"0.5785509",
"0.5780447",
"0.57800597",
"0.5780006",
"0.57798696",
"0.57757866",
"0.5775493",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5775013",
"0.5774349",
"0.57695633",
"0.57623637",
"0.57554865",
"0.5754963",
"0.57547146",
"0.57527965",
"0.5752342",
"0.57499224",
"0.5747845",
"0.5747079"
] | 0.80521065 | 0 |
POST /level_containers POST /level_containers.json | def create
@level_container = LevelContainer.new(params[:level_container])
respond_to do |format|
if @level_container.save
format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }
format.json { render json: @level_container, status: :created, location: @level_container }
else
format.html { render action: "new" }
format.json { render json: @level_container.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 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 create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def new\n @level_container = LevelContainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_container }\n end\n end",
"def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end",
"def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end",
"def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_container(collection, container = nil)\n active_container = container\n if active_container.nil?\n active_container = {\n \"metadata\": [\n {\n \"key\": \"dc.title\",\n \"language\": \"en_US\",\n \"value\": \"Empty Container Document\"\n },\n {\n \"key\": \"dc.contributor.author\",\n \"language\": \"en_US\",\n \"value\": \"Data Services, Bobst Library\"\n }\n ]\n }\n end\n cmd = `curl -X POST -H \"Content-Type: application/json\" -H \"Accept: application/json\" -H \"rest-dspace-token: #{@token}\" -d '#{JSON.generate(active_container)}' #{ENV[\"FDA_REST_ENDPOINT\"]}/collections/#{collection}/items --insecure -s`\n return JSON.parse(cmd)\n end",
"def build_containers_tree\n TreeBuilderContainers.new(\"containers_tree\", \"containers\", @sb)\n end",
"def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end",
"def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end",
"def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end",
"def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end",
"def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end",
"def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def create\n @container_row = ContainerRow.new(container_row_params)\n respond_to do |format|\n if @container_row.save\n flash[:success] = 'Row was successfully created.'\n format.html { redirect_to admin_container_row_url(@container_row) }\n format.json { render :show, status: :created, location: @container_row }\n else\n set_new\n format.html { render :new }\n format.json { render json: @container_row.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_container\n\t\t\t\[email protected]_class.new\n\t\t\tend",
"def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end",
"def containers=(value)\n @containers = value\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend",
"def patch_containers(containers)\n (containers || Array.new).each do |container|\n if container[\"image\"] =~ /.*velum.*/\n container[\"image\"] = \"sles12/velum:development\"\n container[\"volumeMounts\"] ||= Array.new\n container[\"volumeMounts\"] << {\n \"mountPath\" => \"/srv/velum\",\n \"name\" => \"velum-devel\"\n }\n container[\"env\"] ||= Array.new\n container[\"env\"].each do |env|\n env[\"value\"] = \"development\" if env[\"name\"] == \"RAILS_ENV\"\n end\n\n # Ensure the velum_production db is used, this is what the\n # salt mysql returner is configured to use\n container[\"env\"] << {\n \"name\" => \"VELUM_DB_NAME\",\n \"value\" => \"velum_production\"\n }\n end\n end\nend",
"def create\n @container_item = ContainerItem.new(container_item_params)\n respond_to do |format|\n if @container_item.save\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :created, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully created.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def containerize(\n project_name: '',\n project_id: 0,\n app: {}\n )\n\n puts \"#{__method__.to_s} enter\"\n\n # Where to push the docker image\n #docker_remote_registry_uri = \"\"\n #docker_remote_registry_uri = \"localhost:5000\" if server.compute_engine == 'minikube'\n #docker_remote_registry_uri = \"gcr.io/#{project_name}-#{project_id}\" if server.compute_engine == 'gce'\n\n\n app_name = \"#{project_name}-#{project_id}\"\n image_name = \"#{project_name}-#{project_id}\"\n\n\n docker_context_directory = docker_ready_context_directory(\n app_name: app_name,\n app_source_directory: app.source_url\n )\n\n passenger_prep(container_context_directory: docker_context_directory, app_types: app.type)\n\n dockerfile_contents = docker_ready_dockerfile(app_directory: app_name, app_types: app.type)\n\n make_file(\"#{docker_context_directory}/Dockerfile\", dockerfile_contents)\n\n\n\n docker_create_container_image(image_name: image_name, context_directory: docker_context_directory)\n\n container_info = { image_name: image_name }\n\n puts \"#{__method__.to_s} exit\"\n\n # Convert data structure (hashes and arrays) into a\n # dot notation accessable structure (ex. config.project.name)\n #\n return RecursiveOpenStruct.new(container_info, recurse_over_arrays: true )\n\nend",
"def create\n @level_category = LevelCategory.new(params[:level_category])\n\n respond_to do |format|\n if @level_category.save\n format.html { redirect_to @level_category, notice: 'Level category was successfully created.' }\n format.json { render json: @level_category, status: :created, location: @level_category }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_container }\n end\n end",
"def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end",
"def create\n @collection = Collection.new(collection_params)\n build_kiosks(params)\n respond_to do |format|\n if @collection.save\n format.html { redirect_to @collection, notice: 'Collection was successfully created.' }\n format.json { render :show, status: :created, location: @collection }\n else\n format.html { render :new }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create body = {}\n @connection.request(method: :post, path: \"/volumes/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def update\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n if @level_container.update_attributes(params[:level_container])\n format.html { redirect_to @level_container, notice: 'Level container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end",
"def create\n @containers_page = ContainersPage.new(containers_page_params)\n respond_to do |format|\n if @containers_page.save\n @containers_pages = @page.containers_pages\n format.js\n format.html do \n flash[:success] = 'Container was successfully added to page.'\n redirect_to @containers_page\n end\n format.json { render :show, status: :created, location: @containers_page }\n else\n format.js { head :ok }\n format.html { render :new }\n format.json { render json: @containers_page.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 create\n authorize! :create, :level\n type_class = level_params[:type].constantize\n\n # Set some defaults.\n params[:level].reverse_merge!(skin: type_class.skins.first) if type_class <= Blockly\n if type_class <= Grid\n params[:level][:maze_data] = Array.new(8){Array.new(8){0}}\n params[:level][:maze_data][0][0] = 2\n end\n if type_class <= Studio\n params[:level][:maze_data][0][0] = 16 # studio must have at least 1 actor\n params[:level][:soft_buttons] = nil\n params[:level][:timeout_after_when_run] = true\n params[:level][:success_condition] = Studio.default_success_condition\n params[:level][:failure_condition] = Studio.default_failure_condition\n end\n params[:level][:maze_data] = params[:level][:maze_data].to_json if type_class <= Grid\n params.merge!(user: current_user)\n\n begin\n @level = type_class.create_from_level_builder(params, level_params)\n rescue ArgumentError => e\n render status: :not_acceptable, text: e.message and return\n rescue ActiveRecord::RecordInvalid => invalid\n render status: :not_acceptable, text: invalid and return\n end\n\n render json: { redirect: edit_level_path(@level) }\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def save_container(name, expire, **data)\n data.each do |k, v|\n @client.hset(name, k, v)\n @client.expire(name, expire)\n @logger.debug(\"Saving container: #{name} with fields #{data.keys} and expire set to #{expire}\")\n end\n @logger.debug('Container data has been saved to database')\n rescue StandardError => e\n @logger.error(\" Unable to save the to database: #{e} \")\n end",
"def create\n @container_clone.name = params[:container_clone][:name]\n respond_to do |format|\n if @container_clone.save\n @container.container_rows.each do |row|\n clone_row = ContainerRow.create!(container_id: @container_clone.id,css_classes: row.css_classes, position: row.position)\n row.row_columns.each do |col|\n clone_col = col.dup\n clone_col.container_row_id = clone_row.id\n clone_col.save\n end\n end\n flash[:success] = 'Container was successfully cloned.'\n format.html { redirect_to admin_container_url(@container_clone) }\n format.json { render :show, status: :created, location: @container_clone }\n else\n format.html { render :new }\n format.json { render json: @container_clone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_container_with_http_info(container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.create_container ...'\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.create_container\"\n end\n # resource path\n local_var_path = '/containers'\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[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#create_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_and_run_container args\n \t# update the timeout for the Excon Http Client\n \t# set the chunk size to enable streaming of log files\n ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}\n container = ::Docker::Container.create(\n \t\t'Image' => args[:image],\n \t\t'Cmd' => args[:command],\n \t\t\"Binds\" => args[:volumes],\n \t\t\"Env\" => args[:environment],\n \t\t'WorkingDir' => args[:working_directory],\n 'NetworkMode' => @network,\n 'name' => args[:name],\n 'PublishAllPorts' => true\n )\n\n output = ''\n\n unless args[:deamon] == true\n thread = Thread.new do\n container.attach(:stream => true, :stdin => nil, :stdout => true, :stderr => true, :logs => false, :tty => false) do\n |stream, chunk|\n if chunk.index('[ERROR]') != nil # deal with hidden characters\n @logger.error chunk.gsub(/\\[.*\\]/,'')\n else\n output += chunk.gsub(/\\[.*\\]/,'') if output == ''\n output += chunk.gsub(/\\[.*\\]/,'').prepend(\" \") unless output == ''\n @logger.debug chunk.gsub(/\\[.*\\]/,'')\n end\n end\n end\n end\n\n \n\n container.start\n \n thread.join unless args[:deamon] == true\n\n success = (container.json['State']['ExitCode'] == 0) ? true: false \n \n @logger.error(output) unless success \n\n \treturn container, success\n end",
"def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @containers }\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_container\n UI.important(\"Creating container: #{container_name}\")\n CpuLoadHandler.print_cpu_load\n begin\n container = create_container_call\n set_container_name(container)\n rescue StandardError\n UI.important(\"Something went wrong while creating: #{container_name}, will retry in #{@sleep_interval} seconds\")\n CpuLoadHandler.print_cpu_load\n @docker_commander.delete_container\n sleep @sleep_interval\n container = create_container_call\n set_container_name(container)\n end\n @container = get_container_instance(container)\n\n if @container.nil?\n sleep 3\n @container = get_container_instance(container)\n end\n end",
"def create\n @level = Level.new(params[:level])\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render json: @level, status: :created, location: @level }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @level = Level.new(params[:level])\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render json: @level, status: :created, location: @level }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def hits_containers=(value)\n @hits_containers = value\n end",
"def add_chef_object(container_name, requestor, object_json)\n post(api_url(\"/#{container_name}\"), requestor, :payload => object_json)\n end",
"def index\n @containers = Container.all\n end",
"def create_post!(params)\n @children.create! params\n end",
"def init_containers=(value)\n @init_containers = value\n end",
"def create\n @docker_instance = DockerInstance.new(docker_instance_params)\n @docker_instance.creating!\n respond_to do |format|\n if @docker_instance.save\n format.js\n else\n format.html { render :new }\n format.json { render json: @docker_instance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @updated_container = params([:container])\n @container = DeployedContainer.find(params[:container][:id])\n\n nova_ip = nil\n quantum_ip = nil\n if request.headers[\"X-Auth-Token\"] != \"\"\n token = request.headers[\"X-Auth-Token\"]\n begin\n services = Donabe::KEYSTONE.get_endpoints(token)\n services[\"endpoints\"].each do |endpoint|\n if endpoint[\"name\"] == \"nova\"\n nova_ip = endpoint[\"internalURL\"]\n elsif endpoint[\"name\"] == \"quantum\"\n quantum_ip = endpoint[\"internalURL\"]\n end\n end\n rescue\n token = Storage.find(cookies[:current_token]).data\n nova_ip = Storage.find(cookies[:nova_ip]).data\n quantum_ip = Storage.find(cookies[:quantum_ip]).data\n end\n end\n\n novaIP = URI.parse(nova_ip)\n nova = Ropenstack::Nova.new(novaIP, token)\n\n quantumIP = URI.parse(quantum_ip)\n quantum = Ropenstack::Quantum.new(quantumIP, token)\n\n # Make a note of how many networks this container already has\n networks_count = @container.deployed_networks.count\n # Define an array to keep track of how many existing networks have been sent back\n existing_networks = Array.new()\n @updated_container[\"deployed_networks\"].each do |network|\n if network[\"deployStatus\"] == false\n # This is a new network. Create it and store its data\n\n else\n # This is an existing network\n existing_networks << network[\"temp_id\"]\n end\n end\n \n if existing_networks.count < networks_count\n # Some existing networks were not sent back. Delete these networks\n end \n\n # Make a note of how many VMs this container already has\n vms_count = @container.deployed_vms.count\n # Define an array to keep track of how many existing VMs have been sent back\n existing_vms = Array.new()\n @updated_container[\"deployed_vms\"].each do |vm|\n if vm[\"deployStatus\"] == false\n # This is a new VM. Create it and store its data\n v = @container.deployed_vms.build()\n ports = Array.new()\n port_list = Array.new()\n vm[\"deployed_connected_networks\"].each do |network|\n port = quantum.create_port(network[\"openstack_id\"],'',\"compute:nova\")\n ports << port[\"port\"][\"id\"]\n data = {'uuid'=>network[\"openstack_id\"]}\n port_list << data\n connected_network = v.deployed_connected_networks.build()\n connected_network.openstack_id = network[\"openstack_id\"]\n connected_network.save \n end\n else\n # This is an existing VM\n existing_vms << vm[\"temp_id\"]\n end\n end\n \n if existing_vms.count < vms_count\n # Some existing vms were not sent back. Delete these vms\n end \n \n # Make a note of how many routers this container already has\n routers_count = @container.deployed_routers.count\n # Define an array to keep track of how many existing routers have been sent back\n existing_routers = Array.new()\n @updated_container[\"deployed_routers\"].each do |router|\n if router[\"deployStatus\"] == false\n # This is a new router. Create it and store its data\n else\n # This is an existing router\n existing_routers << router[\"temp_id\"] \n end\n end\n\n if existing_routers.count < routers_count\n # Some existing routers were not sent back. Delete these routers\n end \n\n @updated_container[\"deployed_conatiners\"].each do |container|\n # Do some magic. Possibly recursive magic.\n end\n\n end",
"def create\n if admin?\n @level = Level.new(level_params)\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render :show, status: :created, location: @level }\n else\n format.html { render :new }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @level = Level.find(params[:level_id])\n @compartment = @level.compartments.new(params[:compartment])\n \n \n\n\n respond_to do |format|\n if @compartment.save\n format.html { redirect_to ([@level, @compartment]), notice: 'Compartment was successfully created.' }\n format.json { render json: @compartment, status: :created, location: @compartment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @compartment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign_containers_to_pods!(pods, containers)\n pods.each do |pod|\n pod['containers'] = containers.select do |container|\n container.key?('pod') && container['pod'] == pod['name']\n end\n end\nend",
"def create\n @category = Category.new(params[:category])\n\n respond_to do |format|\n if @category.save\n format.html { redirect_to([:admin,@category], :notice => 'Category was successfully created.') }\n format.xml { render :xml => @category, :status => :created, :location => @category }\n format.json do \n level = @category.parents_array.size\n varb = render_to_string :partial => \"item.html.erb\",:locals => { :level => level, :category=>@category }\n #varb = \"\"\n render :json => {\n :html=>varb,\n :category=>@category.attributes,\n :level => level\n \n }, \n :content_type => 'text/json',\n :status => :created\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n format.json { render :status=>:unprocessable_entity ,:json => @category.errors, :content_type => 'text/json' }\n end\n end\n end",
"def wrap_container( payload )\n\n raise Dossia::BadArgumentError, 'This method expects a Nokogiri NodeSet or Element' unless payload.class == Nokogiri::XML::NodeSet or payload.class == Nokogiri::XML::Element\n\n builder = Nokogiri::XML::Builder.new do |xml|\n \n xml.container(\n \"xmlns\" => \"http://www.dossia.org/v2.0/api\",\n \"xmlns:xsi\" => \"http://www.w3.org/2001/XMLSchema-instance\", \n \"xsi:schemaLocation\" => \"http://www.dossia.org/v2.0/api http://www.dossia.org/v2.0/api/container.xsd\"\n )\n\n end\n\n builder = Nokogiri::XML builder.to_xml\n\n if payload.class == Nokogiri::XML::NodeSet\n payload.each {|node| builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child node }\n else\n builder.xpath('//api:container', 'api' => 'http://www.dossia.org/v2.0/api').first.add_child payload\n end\n\n builder\n\n end",
"def createVolume\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view the clusters in this project\" }, :unauthorized)\n return\n end\n\n # Service name in the query\n volumeName = params[\"volume_name\"]\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'name' => volumeName,\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, :created)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def handle_start(event)\n @bus.request 'containers', 'started', event: event.json, container: container_info(event.id)\n end",
"def prune params = {}\n @connection.post(build_path(\"/containers/prune\", params))\n end",
"def create\n @frame = Frame.new(frame_params)\n frame_storage = FrameStorage.find(params[:frame_storage_id].to_i)\n begin\n Frame.transaction do\n @frame.save\n frame_storage.update_attributes(:frame_id=>@frame.id)\n @frame.batch_create_boxer_storage\n end\n redirect_to @frame, notice: 'Container was successfully created.'\n rescue\n puts '创建架子规格及存储架子的空间出错!'\n render :new\n end\n\n end",
"def create\n @operation_level = OperationLevel.new(operation_level_params)\n authorize! :create, @operation_level\n \n respond_to do |format|\n if @operation_level.save\n format.html { redirect_to @operation_level, notice: 'Operation level was successfully created.' }\n format.json { render :show, status: :created, location: @operation_level }\n else\n format.html { render :new }\n format.json { render json: @operation_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @stack = Stack.new(stack_params)\n\n if @stack.save\n render json: @stack, status: :created, location: @stack\n else\n render json: @stack.errors, status: :unprocessable_entity\n end\n end",
"def create_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = container_uri(name, query)\n\n headers = service_properties_headers\n\n add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n\n headers['x-ms-blob-public-access'] = options[:public_access_level].to_s if options[:public_access_level]\n\n response = call(:put, uri, nil, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.metadata = options[:metadata]\n container\n end",
"def create\n authorize! :create, :level\n type_class = level_params[:type].constantize\n\n # Set some defaults.\n params[:level].reverse_merge!(skin: type_class.skins.first) if type_class <= Blockly\n params.merge!(user: current_user)\n\n begin\n @level = type_class.create_from_level_builder(params, level_params)\n rescue ArgumentError => e\n render status: :not_acceptable, text: e.message and return\n rescue ActiveRecord::RecordInvalid => invalid\n render status: :not_acceptable, text: invalid and return\n end\n\n render json: { redirect: level_url(@level) }.to_json\n end",
"def containers_page_params\n params.require(:containers_page).permit(:container_id,:page_id)\n end",
"def new_for_creating_stack\n infra_id = params.require(:infrastructure_id)\n\n histories = CfTemplate.for_infra(infra_id)\n # TODO: 変数名変えたほうがいいんじゃ\n globals = CfTemplate.global\n\n render json: {\n histories: histories,\n globals: globals,\n } and return\n end",
"def create_container_call\n # When CPU is under load we cannot create a healthy container\n CpuLoadHandler.wait_cpu_to_idle\n\n additional_env = ''\n environment_variables.each do |variable|\n additional_env += \" -e #{variable}\"\n end\n emulator_args = is_running_on_emulator ? \"-p #{no_vnc_port}:6080 -e DEVICE='#{device_name}'\" : ''\n emulator_args = \"#{emulator_args}#{additional_env}\"\n @docker_commander.start_container(emulator_args: emulator_args, docker_image: docker_image,\n core_amount: core_amount)\n end",
"def create\n @container_content = @container.container_contents.new(params[:container_content])\n\n respond_to do |format|\n if @container_content.save\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully created.') }\n format.xml { render :xml => @container_content, :status => :created, :location => @container_content }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_new_container\n puts 'Start creating a new container..'\n host = get_available_host\n if host.nil?\n puts 'Could not found a host with limit enough to create more containers'\n return\n end\n puts \"getting an available port to #{host}\"\n port = get_available_port(host)\n if port.nil?\n puts 'Could not found an available port'\n return\n end\n\n puts \"using port #{port} from #{host}\"\n\n Docker.url = \"tcp://#{host}:#{@docker_port}/\"\n container = Docker::Container.create(\n 'Image' => \"#{@ws_image}\",\n 'ExposedPorts' => { \n '8070/tcp' => {}\n },\n 'HostConfig' => {\n 'CpuPeriod' => 25000,\n 'PortBindings' => {\n '8070/tcp' => [ { 'HostPort' => \"#{port}\" } ]\n }\n }\n )\n container.start\n register_container(host, port, container.id)\n end",
"def create\n @level = Level.new(params[:level])\n\n base64png = params[:level][:json]['backgroundUrl']\n filename = Digest::MD5.hexdigest(base64png) + \".png\"\n\n File.open(File.join('public','uploads','maps', filename), 'wb') do |f|\n f.write(Base64.decode64(base64png.sub('data:image/png;base64,','')))\n end\n\n @level.json[\"backgroundUrl\"] = \"/uploads/maps/#{filename}\"\n @level.creator = current_user\n\n respond_to do |format|\n if @level.save\n format.html { redirect_to(@level, :notice => 'Level was successfully created.') }\n format.json { render :json => @level, :status => :created, :location => @level }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @level.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @collection = Admin::Collection.new(collection_params)\n\n if @collection.save\n render json: @collection, status: :created#, location: @collection\n else\n render json: @collection.errors, status: :unprocessable_entity\n end\n end",
"def create\n collection = Collection.create(collection_params)\n\n render json: collection\n end",
"def create\n @receipt_container = ReceiptContainer.new(params[:receipt_container])\n @receipt_container.company_id = current_user.company_id\n respond_to do |format|\n if @receipt_container.save\n format.html { redirect_to @receipt_container, notice: 'Receipt container was successfully created.' }\n format.json { render json: @receipt_container, status: :created, location: @receipt_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receipt_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_level = Admin::Level.new(admin_level_params)\n\n respond_to do |format|\n if @admin_level.save\n format.html { redirect_to edit_admin_level_path(@admin_level), notice: 'Level was successfully created.' }\n format.json { render :show, status: :created, location: @admin_level }\n else\n format.html { render :new }\n format.json { render json: @admin_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_container\n @container = Container.find(params[:id])\n end",
"def set_container\n @container = Container.find(params[:id])\n end",
"def container_clone_params\n params.require(:container_clone).permit(:name)\n end",
"def create\n @level = Level.new(level_params)\n sess = PlaySession.where(id:@level.session_id).first\n if(!sess)\n render :status => :bad_request, :text => \"Unknown session\" and return\n end\n respond_to do |format|\n if @level.save\n format.html { redirect_to @level, notice: 'Level was successfully created.' }\n format.json { render action: 'show', status: :created, location: @level }\n else\n format.html { render action: 'new' }\n format.json { render json: @level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index_containers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_containers ...'\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'comment'] = opts[:'comment'] if !opts[:'comment'].nil?\n query_params[:'quota_total_size'] = opts[:'quota_total_size'] if !opts[:'quota_total_size'].nil?\n query_params[:'quota_on_cache'] = opts[:'quota_on_cache'] if !opts[:'quota_on_cache'].nil?\n query_params[:'stat_total_files'] = opts[:'stat_total_files'] if !opts[:'stat_total_files'].nil?\n query_params[:'stat_total_size'] = opts[:'stat_total_size'] if !opts[:'stat_total_size'].nil?\n query_params[:'stat_size_on_cache'] = opts[:'stat_size_on_cache'] if !opts[:'stat_size_on_cache'].nil?\n query_params[:'guest_right'] = opts[:'guest_right'] if !opts[:'guest_right'].nil?\n query_params[:'last_update'] = opts[:'last_update'] if !opts[:'last_update'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_containers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n chef_server_rest.post(\"data/#{data_bag}\", self)\n self\n end",
"def get_containers\n assert_not_nil @rdigg.info.get_containers\n end",
"def create\n \n @slice = Xen::Slice.new(params)\n\n respond_to do |format|\n if @slice.create_image(params)\n @slice = Xen::Slice.find(params[:hostname])\n flash[:notice] = 'Slice was successfully created.'\n format.html { redirect_to(slice_path(@slice.name)) }\n format.xml { render :xml => @slice, :status => :created, :location => @slice }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @slice.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Catalogs::Level.new(catalogs_level_params)\n\n respond_to do |format|\n if @resource.save\n index\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Level was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end",
"def create\n @control_loop = ControlLoop.new(control_loop_params)\n\n respond_to do |format|\n if @control_loop.save\n format.html { redirect_to @control_loop, notice: 'Control loop was successfully created.' }\n format.json { render :show, status: :created, location: @control_loop }\n else\n format.html { render :new }\n format.json { render json: @control_loop.errors, status: :unprocessable_entity }\n end\n end\n end",
"def container=(value)\n @container = value\n end",
"def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end",
"def serverhascontainer_params\n params.require(:serverhascontainer).permit(:container_id, :server_id)\n end",
"def create\n @dumb_counter = DumbCounter.new(dumb_counter_params)\n\n respond_to do |format|\n if @dumb_counter.save\n format.html { redirect_to @dumb_counter, notice: 'Dumb counter was successfully created.' }\n format.json { render :show, status: :created, location: @dumb_counter }\n else\n format.html { render :new }\n format.json { render json: @dumb_counter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def read_containers\n []\n end",
"def run_container(port:, password:, name:)\n response_of_create = create_container(port: port, password: password, name: name)\n return unless response_of_create.success?\n\n container_id = JSON.parse(response_of_create.body).fetch('Id')\n start_container(container_id: container_id)\n rescue StandardError\n false\n end",
"def submit_databag(run_status, env)\n # TODO: too expensive to load them. all we want to do is to check if databag exists\n #begin\n # Chef::DataBag.load(\"jenkins\")\n #rescue Net::HTTPServerException => e\n # if e.response.code==\"404\"\n # bag = Chef::DataBag.new\n # bag.name \"jenkins\"\n # bag.save\n # end\n #end\n\n i = Chef::DataBagItem.new\n i.data_bag(\"jenkins\") # set the name\n\n id = run_status.node.name + '_' + run_status.end_time.strftime(\"%Y%m%d-%H%M%S\")\n\n i.raw_data = env\n i.save id\n end",
"def create\n json_create(category_params, Category)\n end",
"def containers\n TestLab::Container.all\n end",
"def container_item_params\n params.require(:container_item).permit(:user_id, :parent_id, :name)\n end",
"def create\n respond_to do |format|\n if @health_level.save\n format.html { redirect_to @health_level, notice: 'Health level was successfully created.' }\n format.json { render json: @health_level, status: :created, location: @health_level }\n else\n format.html { render action: \"new\" }\n format.json { render json: @health_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def level_type= new_level_type\n\t\t\t\tunless [:archive_container, :collection_container, :box, :folder].include? new_level_type.to_sym\n\t\t\t\t\traise \"'#{new_level_type}' is not a valid container level_type.\"\n\t\t\t\tend\n\t\t\t\t@level_type = new_level_type.to_sym\n\t\t\tend",
"def create\n params = run_params.clone\n pass_plaintxt = params[:password]\n params[:password] = BCrypt::Password.create(params[:password])\n heroku_netrc = nil\n if params[\"heroku_netrc\"]\n heroku_netrc = params[\"heroku_netrc\"].read\n end\n params[\"heroku_netrc\"] = \"dummystring\"\n # By default run is running :)\n params[\"status_id\"] = 1\n @run = Run.new(params)\n respond_to do |format|\n if @run.save\n @docker_kickstart = DockerKickstartsController.new(@run, params[\"rundockerservers_attributes\"], pass_plaintxt, heroku_netrc)\n number_of_containers = @docker_kickstart.docker_kickstart\n set_run_status(@run[:id], number_of_containers)\n\n format.html { redirect_to @run, notice: 'Run was successfully created.' }\n format.json { render :show, status: :created, location: @run }\n else\n format.html { render :new }\n format.json { render json: @run.errors, status: :unprocessable_entity }\n end\n end\n end",
"def containers_ids\n containers(:response_format => :id_array)\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"
] | [
"0.6953396",
"0.68528384",
"0.6707599",
"0.61446357",
"0.60053307",
"0.5751163",
"0.5740514",
"0.5722212",
"0.56487346",
"0.5613509",
"0.5599725",
"0.55909336",
"0.556263",
"0.55002916",
"0.54819936",
"0.5418743",
"0.5352435",
"0.5347443",
"0.53390723",
"0.53294116",
"0.5309498",
"0.52292913",
"0.5221549",
"0.5195028",
"0.51775664",
"0.51699907",
"0.51550317",
"0.51534665",
"0.5140322",
"0.51307",
"0.51222324",
"0.509329",
"0.5078623",
"0.5078443",
"0.50730246",
"0.50648135",
"0.5046167",
"0.5037334",
"0.5015444",
"0.4972005",
"0.49647588",
"0.49292183",
"0.4927588",
"0.49235448",
"0.49235448",
"0.49051592",
"0.4890183",
"0.4889353",
"0.48657343",
"0.48352456",
"0.4815062",
"0.48054832",
"0.47974733",
"0.47533944",
"0.47529355",
"0.47442502",
"0.47436363",
"0.47422343",
"0.47393146",
"0.4738166",
"0.4737388",
"0.47361124",
"0.4719949",
"0.4715349",
"0.4714537",
"0.47087845",
"0.46892738",
"0.46818987",
"0.46725047",
"0.4669611",
"0.46690282",
"0.466058",
"0.46587726",
"0.46515256",
"0.46446306",
"0.4643888",
"0.4643888",
"0.46430165",
"0.46421257",
"0.46410286",
"0.46375543",
"0.4636396",
"0.46363202",
"0.46356782",
"0.46306768",
"0.4630466",
"0.461827",
"0.46179822",
"0.46154785",
"0.46142235",
"0.46138304",
"0.4612751",
"0.46071368",
"0.4589712",
"0.45724848",
"0.4569219",
"0.45686615",
"0.45677614",
"0.4567653",
"0.45557633"
] | 0.7345584 | 0 |
PUT /level_containers/1 PUT /level_containers/1.json | def update
@level_container = LevelContainer.find(params[:id])
respond_to do |format|
if @level_container.update_attributes(params[:level_container])
format.html { redirect_to @level_container, notice: 'Level container was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @level_container.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @level_container = LevelContainer.new(params[:level_container])\n\n respond_to do |format|\n if @level_container.save\n format.html { redirect_to @level_container, notice: 'Level container was successfully created.' }\n format.json { render json: @level_container, status: :created, location: @level_container }\n else\n format.html { render action: \"new\" }\n format.json { render json: @level_container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @containers = args[:containers] if args.key?(:containers)\n end",
"def update\n @container = Container.find(params[:id])\n\n respond_to do |format|\n if @container.update_attributes(params[:container])\n format.html { redirect_to @container, notice: 'Container was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @level_container = LevelContainer.find(params[:id])\n @level_container.destroy\n\n respond_to do |format|\n format.html { redirect_to level_containers_url }\n format.json { head :no_content }\n end\n end",
"def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @id = args[:id] if args.key?(:id)\n end",
"def update\n respond_to do |format|\n if @container.update(container_params)\n format.html { redirect_to @container, notice: 'Container was successfully updated.' }\n format.json { render :show, status: :ok, location: @container }\n else\n format.html { render :edit }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @container = Container.get!(params[:id])\n\n respond_to do |format|\n if @container.update(params[:container])\n flash[:notice] = 'Container was successfully updated.'\n format.html { redirect_to(edit_container_url(@container.id)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n if @container_stack.update_attributes(params[:container_stack])\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @updated_container = params([:container])\n @container = DeployedContainer.find(params[:container][:id])\n\n nova_ip = nil\n quantum_ip = nil\n if request.headers[\"X-Auth-Token\"] != \"\"\n token = request.headers[\"X-Auth-Token\"]\n begin\n services = Donabe::KEYSTONE.get_endpoints(token)\n services[\"endpoints\"].each do |endpoint|\n if endpoint[\"name\"] == \"nova\"\n nova_ip = endpoint[\"internalURL\"]\n elsif endpoint[\"name\"] == \"quantum\"\n quantum_ip = endpoint[\"internalURL\"]\n end\n end\n rescue\n token = Storage.find(cookies[:current_token]).data\n nova_ip = Storage.find(cookies[:nova_ip]).data\n quantum_ip = Storage.find(cookies[:quantum_ip]).data\n end\n end\n\n novaIP = URI.parse(nova_ip)\n nova = Ropenstack::Nova.new(novaIP, token)\n\n quantumIP = URI.parse(quantum_ip)\n quantum = Ropenstack::Quantum.new(quantumIP, token)\n\n # Make a note of how many networks this container already has\n networks_count = @container.deployed_networks.count\n # Define an array to keep track of how many existing networks have been sent back\n existing_networks = Array.new()\n @updated_container[\"deployed_networks\"].each do |network|\n if network[\"deployStatus\"] == false\n # This is a new network. Create it and store its data\n\n else\n # This is an existing network\n existing_networks << network[\"temp_id\"]\n end\n end\n \n if existing_networks.count < networks_count\n # Some existing networks were not sent back. Delete these networks\n end \n\n # Make a note of how many VMs this container already has\n vms_count = @container.deployed_vms.count\n # Define an array to keep track of how many existing VMs have been sent back\n existing_vms = Array.new()\n @updated_container[\"deployed_vms\"].each do |vm|\n if vm[\"deployStatus\"] == false\n # This is a new VM. Create it and store its data\n v = @container.deployed_vms.build()\n ports = Array.new()\n port_list = Array.new()\n vm[\"deployed_connected_networks\"].each do |network|\n port = quantum.create_port(network[\"openstack_id\"],'',\"compute:nova\")\n ports << port[\"port\"][\"id\"]\n data = {'uuid'=>network[\"openstack_id\"]}\n port_list << data\n connected_network = v.deployed_connected_networks.build()\n connected_network.openstack_id = network[\"openstack_id\"]\n connected_network.save \n end\n else\n # This is an existing VM\n existing_vms << vm[\"temp_id\"]\n end\n end\n \n if existing_vms.count < vms_count\n # Some existing vms were not sent back. Delete these vms\n end \n \n # Make a note of how many routers this container already has\n routers_count = @container.deployed_routers.count\n # Define an array to keep track of how many existing routers have been sent back\n existing_routers = Array.new()\n @updated_container[\"deployed_routers\"].each do |router|\n if router[\"deployStatus\"] == false\n # This is a new router. Create it and store its data\n else\n # This is an existing router\n existing_routers << router[\"temp_id\"] \n end\n end\n\n if existing_routers.count < routers_count\n # Some existing routers were not sent back. Delete these routers\n end \n\n @updated_container[\"deployed_conatiners\"].each do |container|\n # Do some magic. Possibly recursive magic.\n end\n\n end",
"def update\n @container = Container.find(params[:id])\n\n respond_to do |format|\n if @container.update_attributes(params[:container])\n flash[:notice] = 'Container was successfully updated.'\n format.html { redirect_to(@container) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.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 set_container\n @container = Container.find(params[:id])\n end",
"def set_container\n @container = Container.find(params[:id])\n end",
"def show\n @level_container = LevelContainer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @level_container }\n end\n end",
"def container_params\n params.require(:container).permit(:name, :container_name, :image)\n end",
"def add_container(params = {})\n now = Time.now.strftime(\"%Y-%m-%dT%H:%M:%S\")\n now = now.gsub(':', '--')\n\n @slug = params.fetch(:slug, now)\n \n containers = self.get_containers\n containers.each do |c|\n return c if c.uri.to_s.match(/\\/#{@slug}\\/?$/) # check if it already exists\n end\n \n # headers = {accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n payload = \"\"\"@prefix ldp: <http://www.w3.org/ns/ldp#> . \n <> a ldp:Container, ldp:BasicContainer .\"\"\"\n etag = Digest::SHA2.hexdigest payload \n headers = {ETag: \"#{etag}\", accept: 'text/turtle', content_type: 'text/turtle', \"Slug\" => @slug, \"Link\" => '<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\"'}\n \n \n response = LDP::HTTPUtils::post(self.uri, headers, payload, self.client.username, self.client.password)\n if response\n newuri = response.headers[:location] \n newcont = self._add_container({:uri => newuri,\n :client => self.client,\n :parent => self,\n :top => self.toplevel_container,\n :init => true})\n unless newcont\n abort \"PROBLEM - cannot add new container with id #{newuri}. BAILING just to be safe\"\n end\n return newcont\n else\n abort \"PROBLEM - cannot create container into #{self.uri}. BAILING just to be safe\"\n end\n \n end",
"def update!(**args)\n @container_id = args[:container_id] if args.key?(:container_id)\n @permission = args[:permission] if args.key?(:permission)\n end",
"def new\n @level_container = LevelContainer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @level_container }\n end\n end",
"def update!(**args)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_type = args[:container_type] if args.key?(:container_type)\n @extended_data = args[:extended_data] if args.key?(:extended_data)\n @materialized = args[:materialized] if args.key?(:materialized)\n end",
"def update\n respond_to do |format|\n if @serverhascontainer.update(serverhascontainer_params)\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully updated.' }\n format.json { render :show, status: :ok, location: @serverhascontainer }\n else\n format.html { render :edit }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\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 patch_containers(containers)\n (containers || Array.new).each do |container|\n if container[\"image\"] =~ /.*velum.*/\n container[\"image\"] = \"sles12/velum:development\"\n container[\"volumeMounts\"] ||= Array.new\n container[\"volumeMounts\"] << {\n \"mountPath\" => \"/srv/velum\",\n \"name\" => \"velum-devel\"\n }\n container[\"env\"] ||= Array.new\n container[\"env\"].each do |env|\n env[\"value\"] = \"development\" if env[\"name\"] == \"RAILS_ENV\"\n end\n\n # Ensure the velum_production db is used, this is what the\n # salt mysql returner is configured to use\n container[\"env\"] << {\n \"name\" => \"VELUM_DB_NAME\",\n \"value\" => \"velum_production\"\n }\n end\n end\nend",
"def create\n @container = current_user.containers.build(params[:container])\n \n respond_to do |format|\n if @container.save\n flash[:notice] = 'Container was successfully created.'\n format.html { redirect_to(@container) }\n format.xml { render :xml => @container, :status => :created, :location => @container }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def container_params\n params.require(:container).permit(:name, :image, :command, :exposed_port, :host_port, :server_id)\n end",
"def set_container_item\n @container_item = ContainerItem.find(params[:id])\n end",
"def update\n \n @accessory = Accessory.find(params[:id])\n @ibox = Ibox.find(session[:ibox_id])\n @users = @ibox.users.where(:isAdmin => false)\n @containerOld = IboxAccessoriesContainer.find_by_ibox_id_and_accessory_type_id(@ibox.id, @accessory.accessory_type.id)\n @containerOld.accessories.destroy(@accessory)\n @accessoryTypes= AccessoryType.all\n @accessoryTypes.delete(AccessoryType.find_by_name(\"Sensores\"))\n respond_to do |format|\n if @accessory.update_attributes(params[:accessory])\n #guardo el nombre del accesorio en el ibox\n name = @accessory.name #lo asigno para borrarle los espacios para pasarselo al webservice\n iboxExecute(@ibox.ip, @ibox.port, '/cgi-bin/Set.cgi?ZID=' + @accessory.zid + '&ALIAS=' + name.delete(' ') + '&X=' + @accessory.x + '&Y=' + @accessory.y + '&W=' + @accessory.w + '&H=' + @accessory.h + '&Layer=0',@ibox.user,@ibox.password) \n # se agrega al nuevo containter\n if ([email protected]_types.find_by_name(@accessory.accessory_type.name))\n @ibox.accessory_types << @accessory.accessory_type\n end\n @container = IboxAccessoriesContainer.find_by_ibox_id_and_accessory_type_id(@ibox.id, @accessory.accessory_type.id)\n \n @container.update_attribute(:name, @accessory.accessory_type.name)\n @container.accessories << @accessory \n\n @containers = IboxAccessoriesContainer.where(\"ibox_id = ?\", @ibox.id)\n @accessories = []\n logger.debug \"#################################### container length = #{@containers.length}\"\n @containers.each do |container|\n @accessories << container.accessories\n end\n logger.debug \"#################################### accessories length = #{@accessories.length}\"\n format.js\n else\n logger.debug \"########################################33RENDERIZANDO DENUEVO EDIT\"\n format.js { render :action => \"edit\" }\n end\n end\n end",
"def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def update!(**args)\n @container = args[:container] if args.key?(:container)\n @container_type = args[:container_type] if args.key?(:container_type)\n @deleted = args[:deleted] if args.key?(:deleted)\n @id = args[:id] if args.key?(:id)\n @last_updated = args[:last_updated] if args.key?(:last_updated)\n @last_updated_micros = args[:last_updated_micros] if args.key?(:last_updated_micros)\n @source_etag = args[:source_etag] if args.key?(:source_etag)\n end",
"def update\n upload_slides(params)\n build_kiosks(params)\n respond_to do |format|\n if @collection.update(collection_params)\n format.html { redirect_to @collection, notice: 'Collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @collection }\n else\n format.html { render :edit }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify\n debug(\"#{self.class}::modify\")\n\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n end\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n\n\n\n @payload = {}\n if !($description.to_s.empty?)\n @payload[:description] = $description\n end\n if !($peak_latency.to_s.empty?)\n @payload[:peak_latency] = $peak_latency\n end\n if !($peak_iops_per_tb.to_s.empty?)\n @payload[:peak_iops_per_tb] = $peak_iops_per_tb\n end\n if !($expected_iops_per_tb.to_s.empty?)\n @payload[:expected_iops_per_tb] = $expected_iops_per_tb\n end\n resourceType = \"storageservicelevel\"\n\n if(transport.http_put_request(apiUri , @payload.to_json , resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully modified\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully modified\"\n end\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully modified\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully modified\"\n end\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} modification failed\"\n\t\t else\n\t\t puts \" #{resourceType} modification failed\"\n end\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} modification failed\"\n\t\t else\n\t\t puts \" #{resourceType} modification failed\"\n end\n end\n\n end",
"def set_container_acl(name, public_access_level, options={})\n # Query\n query = { 'comp' => 'acl' }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Scheme + path\n uri = container_uri(name, query)\n\n # Headers + body\n headers = StorageService.common_headers\n headers['x-ms-blob-public-access'] = public_access_level if public_access_level && public_access_level.to_s.length > 0\n\n signed_identifiers = nil\n signed_identifiers = options[:signed_identifiers] if options[:signed_identifiers]\n\n body = nil\n body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers\n\n # Call\n response = call(:put, uri, body, headers, options)\n\n # Result\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.public_access_level = public_access_level\n\n return container, signed_identifiers || []\n end",
"def update!(**args)\n @acl_choices = args[:acl_choices] if args.key?(:acl_choices)\n @additional_container_info = args[:additional_container_info] if args.key?(:additional_container_info)\n @affinity = args[:affinity] if args.key?(:affinity)\n @contact_visibility = args[:contact_visibility] if args.key?(:contact_visibility)\n @container = args[:container] if args.key?(:container)\n @container_id = args[:container_id] if args.key?(:container_id)\n @container_primary = args[:container_primary] if args.key?(:container_primary)\n @container_type = args[:container_type] if args.key?(:container_type)\n @cross_device_allowed = args[:cross_device_allowed] if args.key?(:cross_device_allowed)\n @default_acl_choice = args[:default_acl_choice] if args.key?(:default_acl_choice)\n @deprecated_contact_container_id = args[:deprecated_contact_container_id] if args.key?(:deprecated_contact_container_id)\n @edge_key = args[:edge_key] if args.key?(:edge_key)\n @edge_key_info = args[:edge_key_info] if args.key?(:edge_key_info)\n @encoded_container_id = args[:encoded_container_id] if args.key?(:encoded_container_id)\n @field_acl = args[:field_acl] if args.key?(:field_acl)\n @last_update_time = args[:last_update_time] if args.key?(:last_update_time)\n @matching_info = args[:matching_info] if args.key?(:matching_info)\n @other_deduped_containers = args[:other_deduped_containers] if args.key?(:other_deduped_containers)\n @primary = args[:primary] if args.key?(:primary)\n @product_metadata = args[:product_metadata] if args.key?(:product_metadata)\n @verified = args[:verified] if args.key?(:verified)\n @visibility = args[:visibility] if args.key?(:visibility)\n @writeable = args[:writeable] if args.key?(:writeable)\n end",
"def update!(**args)\n @container_version = args[:container_version] if args.key?(:container_version)\n @container_version_header = args[:container_version_header] if args.key?(:container_version_header)\n end",
"def create # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n newcontainer = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n newcontainer = newcontainer.create(@options[:container])\n if newcontainer.code == '201'\n puts \"Container #{@options[:container]} created\"\n else\n @util.response_handler(newcontainer)\n end \n end",
"def assign_containers_to_pods!(pods, containers)\n pods.each do |pod|\n pod['containers'] = containers.select do |container|\n container.key?('pod') && container['pod'] == pod['name']\n end\n end\nend",
"def set_container_acl(name, public_access_level, options={})\n query = { 'comp' => 'acl'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n uri =container_uri(name, query)\n\n headers = service_properties_headers\n headers['x-ms-blob-public-access'] = public_access_level if public_access_level && public_access_level.to_s.length > 0\n\n signed_identifiers = nil\n signed_identifiers = options[:signed_identifiers] if options[:signed_identifiers]\n\n body = nil\n body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers\n\n response = call(:put, uri, body, headers)\n\n container = Serialization.container_from_headers(response.headers)\n container.name = name\n container.public_access_level = public_access_level\n\n return container, signed_identifiers || []\n\n end",
"def set_new\n @container = Container.find(params[:container_id])\n @container_row = ContainerRow.new\n end",
"def containers=(value)\n @containers = value\n end",
"def update!(**args)\n @container_port = args[:container_port] if args.key?(:container_port)\n end",
"def set_serverhascontainer\n @serverhascontainer = Serverhascontainer.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @container_item.update(container_item_params)\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was successfully created.')}\n format.json { render json: @container_item, status: :ok, location: @container_item }\n else\n format.html {redirect_back(fallback_location: (request.referer || root_path), notice: 'Container item was NOT successfully updated.')}\n format.json { render json: @container_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_container_with_http_info(container_id, container_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.update_container ...'\n end\n # verify the required parameter 'container_id' is set\n if @api_client.config.client_side_validation && container_id.nil?\n fail ArgumentError, \"Missing the required parameter 'container_id' when calling ContainersApi.update_container\"\n end\n # verify the required parameter 'container_body' is set\n if @api_client.config.client_side_validation && container_body.nil?\n fail ArgumentError, \"Missing the required parameter 'container_body' when calling ContainersApi.update_container\"\n end\n # resource path\n local_var_path = '/containers/{container_id}'.sub('{' + 'container_id' + '}', CGI.escape(container_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(container_body) \n\n # return_type\n return_type = opts[:return_type] || 'Container' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#update_container\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update!(**args)\n @container_runtime = args[:container_runtime] if args.key?(:container_runtime)\n @max_pods_per_node = args[:max_pods_per_node] if args.key?(:max_pods_per_node)\n end",
"def update\n respond_to do |format|\n if @root_collection.update(root_collection_params)\n format.html { redirect_to @root_collection, notice: 'Root collection was successfully updated.' }\n format.json { render :show, status: :ok, location: @root_collection }\n else\n format.html { render :edit }\n format.json { render json: @root_collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if level_params[:name] &&\n @level.name != level_params[:name] &&\n @level.name.downcase == level_params[:name].downcase\n # do not allow case-only changes in the level name because that confuses git on OSX\n @level.errors.add(:name, 'Cannot change only the capitalization of the level name (it confuses git on OSX)')\n render json: @level.errors, status: :unprocessable_entity\n return\n end\n if @level.update(level_params)\n render json: { redirect: level_url(@level, show_callouts: true) }\n else\n render json: @level.errors, status: :unprocessable_entity\n end\n end",
"def add_chef_object(container_name, requestor, object_json)\n post(api_url(\"/#{container_name}\"), requestor, :payload => object_json)\n end",
"def update!\n @etcd_node = etcd.set(etcd_key, value: to_json, prevExist: true).node\n end",
"def level_type= new_level_type\n\t\t\t\tunless [:archive_container, :collection_container, :box, :folder].include? new_level_type.to_sym\n\t\t\t\t\traise \"'#{new_level_type}' is not a valid container level_type.\"\n\t\t\t\tend\n\t\t\t\t@level_type = new_level_type.to_sym\n\t\t\tend",
"def create\n @container_stack = ContainerStack.new(params[:container_stack])\n\n respond_to do |format|\n if @container_stack.save\n format.html { redirect_to @container_stack, notice: 'Container stack was successfully created.' }\n format.json { render json: @container_stack, status: :created, location: @container_stack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @container_stack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index_containers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ContainersApi.index_containers ...'\n end\n # resource path\n local_var_path = '/containers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'comment'] = opts[:'comment'] if !opts[:'comment'].nil?\n query_params[:'quota_total_size'] = opts[:'quota_total_size'] if !opts[:'quota_total_size'].nil?\n query_params[:'quota_on_cache'] = opts[:'quota_on_cache'] if !opts[:'quota_on_cache'].nil?\n query_params[:'stat_total_files'] = opts[:'stat_total_files'] if !opts[:'stat_total_files'].nil?\n query_params[:'stat_total_size'] = opts[:'stat_total_size'] if !opts[:'stat_total_size'].nil?\n query_params[:'stat_size_on_cache'] = opts[:'stat_size_on_cache'] if !opts[:'stat_size_on_cache'].nil?\n query_params[:'guest_right'] = opts[:'guest_right'] if !opts[:'guest_right'].nil?\n query_params[:'last_update'] = opts[:'last_update'] if !opts[:'last_update'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'ContainerCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ContainersApi#index_containers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\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 update\n @level_category = LevelCategory.find(params[:id])\n\n respond_to do |format|\n if @level_category.update_attributes(params[:level_category])\n format.html { redirect_to @level_category, notice: 'Level category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @level_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def handle_create(event)\n @bus.request 'containers', 'created', event: event.json, container: container_info(event.id)\n end",
"def index\n @containers = Container.all\n end",
"def container=(value)\n @container = value\n end",
"def create\n begin\n #get the server chosen container_params[:server_id]\n @currentServer = Server.where(id: container_params[:server_id])\n Docker.url = 'tcp://' + @currentServer[0].ip + \":\" + @currentServer[0].port\n\n #create the container in docker\n if container_params[:exposed_port].blank?\n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image]\n ) \n else \n @con = Docker::Container.create(\n 'name' => container_params[:name],\n 'Image' => container_params[:image],\n 'ExposedPorts' => { container_params[:exposed_port]+'/tcp' => {} },\n 'HostConfig' => {\n 'PortBindings' => {\n container_params[:exposed_port]+'/tcp' => [{ 'HostPort' => container_params[:host_port] }]\n }\n }\n )\n end\n\n #adds the container into the database\n @container = Container.new(:name => container_params[:name], :image => container_params[:image], :command => container_params[:command], :exposed_port => container_params[:exposed_port], \n :host_port => container_params[:host_port], :dockercontainer_id => @con.id, :status => 'Created')\n\n Docker.url = ''\n\n respond_to do |format|\n if @container.save\n Serverhascontainer.new(:server_id => @currentServer[0].id, :container_id => @container.id).save\n format.html { redirect_to root_path, notice: 'Container was successfully created.' }\n format.json { render :show, status: :created, location: @container }\n else\n format.html { render :new }\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n\n rescue Docker::Error::ClientError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::NotFoundError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: #{e.message}\" }\n end\n\n end\n end",
"def update\n @container_content = ContainerContent.find(params[:id])\n\n respond_to do |format|\n if @container_content.update_attributes(params[:container_content])\n format.html { redirect_to(@container_content.container, :notice => 'Container content was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @container_content.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put_collection_key(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: args[:json] )\nend",
"def upd_storage_container_fields\n if self.storage_container\n self.container_type = self.storage_container.container_type\n self.container_name = self.storage_container.container_name\n self.freezer_location_id = self.storage_container.freezer_location_id\n else\n # This is needed for bulk upload where StorageContainer model is not accessed directly\n new_container = StorageContainer.where(\"container_type = ? and container_name = ? and freezer_location_id = ?\",\n self.container_type, self.container_name, self.freezer_location_id).first\n self.storage_container_id = (new_container ? new_container.id : self.storage_container_id)\n end\n end",
"def assign_tenant_circles_to_an_aos_version_box(args = {}) \n body_put(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args[:array_of_ids])\nend",
"def update\n @stack = Stack.find(params[:id])\n\n if @stack.update(stack_params)\n head :no_content\n else\n render json: @stack.errors, status: :unprocessable_entity\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def id\n container.id\n end",
"def index\n user_session[:current_container]=nil\n if params[:label].blank?\n @containers = Container.list(params[:filter])\n else\n @container = Container.find_by_label(params[:label])\n render action: 'show' and return\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @containers }\n end\n end",
"def create\n @serverhascontainer = Serverhascontainer.new(serverhascontainer_params)\n\n respond_to do |format|\n if @serverhascontainer.save\n format.html { redirect_to @serverhascontainer, notice: 'Serverhascontainer was successfully created.' }\n format.json { render :show, status: :created, location: @serverhascontainer }\n else\n format.html { render :new }\n format.json { render json: @serverhascontainer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_container(name, expire, **data)\n data.each do |k, v|\n @client.hset(name, k, v)\n @client.expire(name, expire)\n @logger.debug(\"Saving container: #{name} with fields #{data.keys} and expire set to #{expire}\")\n end\n @logger.debug('Container data has been saved to database')\n rescue StandardError => e\n @logger.error(\" Unable to save the to database: #{e} \")\n end",
"def container_id=(value)\n @container_id = value\n end",
"def update\n authorize! :update, @operation_level\n respond_to do |format|\n if @operation_level.update(operation_level_params)\n format.html { redirect_to @operation_level, notice: 'Operation level was successfully updated.' }\n format.json { render :show, status: :ok, location: @operation_level }\n else\n format.html { render :edit }\n format.json { render json: @operation_level.errors, status: :unprocessable_entity }\n end\n end\n end",
"def containerize(\n project_name: '',\n project_id: 0,\n app: {}\n )\n\n puts \"#{__method__.to_s} enter\"\n\n # Where to push the docker image\n #docker_remote_registry_uri = \"\"\n #docker_remote_registry_uri = \"localhost:5000\" if server.compute_engine == 'minikube'\n #docker_remote_registry_uri = \"gcr.io/#{project_name}-#{project_id}\" if server.compute_engine == 'gce'\n\n\n app_name = \"#{project_name}-#{project_id}\"\n image_name = \"#{project_name}-#{project_id}\"\n\n\n docker_context_directory = docker_ready_context_directory(\n app_name: app_name,\n app_source_directory: app.source_url\n )\n\n passenger_prep(container_context_directory: docker_context_directory, app_types: app.type)\n\n dockerfile_contents = docker_ready_dockerfile(app_directory: app_name, app_types: app.type)\n\n make_file(\"#{docker_context_directory}/Dockerfile\", dockerfile_contents)\n\n\n\n docker_create_container_image(image_name: image_name, context_directory: docker_context_directory)\n\n container_info = { image_name: image_name }\n\n puts \"#{__method__.to_s} exit\"\n\n # Convert data structure (hashes and arrays) into a\n # dot notation accessable structure (ex. config.project.name)\n #\n return RecursiveOpenStruct.new(container_info, recurse_over_arrays: true )\n\nend",
"def update_level_\n end",
"def create\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers/\"+params[:containerID].to_s+\"/deploy.json\"), (sesh :current_token))\n json_respond response.body\n end",
"def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @intersect_type = args[:intersect_type] if args.key?(:intersect_type)\n @remodelings = args[:remodelings] if args.key?(:remodelings)\n @same_type = args[:same_type] if args.key?(:same_type)\n @union_type = args[:union_type] if args.key?(:union_type)\n end",
"def remove_container(name)\n render :update do |page|\n page.remove name\n end\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\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 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 serverhascontainer_params\n params.require(:serverhascontainer).permit(:container_id, :server_id)\n end",
"def show\n @container_stack = ContainerStack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def update!(**args)\n @all_namespaces = args[:all_namespaces] if args.key?(:all_namespaces)\n @cluster_metadata = args[:cluster_metadata] if args.key?(:cluster_metadata)\n @complete_time = args[:complete_time] if args.key?(:complete_time)\n @config_backup_size_bytes = args[:config_backup_size_bytes] if args.key?(:config_backup_size_bytes)\n @contains_secrets = args[:contains_secrets] if args.key?(:contains_secrets)\n @contains_volume_data = args[:contains_volume_data] if args.key?(:contains_volume_data)\n @create_time = args[:create_time] if args.key?(:create_time)\n @delete_lock_days = args[:delete_lock_days] if args.key?(:delete_lock_days)\n @delete_lock_expire_time = args[:delete_lock_expire_time] if args.key?(:delete_lock_expire_time)\n @description = args[:description] if args.key?(:description)\n @encryption_key = args[:encryption_key] if args.key?(:encryption_key)\n @etag = args[:etag] if args.key?(:etag)\n @labels = args[:labels] if args.key?(:labels)\n @manual = args[:manual] if args.key?(:manual)\n @name = args[:name] if args.key?(:name)\n @pod_count = args[:pod_count] if args.key?(:pod_count)\n @resource_count = args[:resource_count] if args.key?(:resource_count)\n @retain_days = args[:retain_days] if args.key?(:retain_days)\n @retain_expire_time = args[:retain_expire_time] if args.key?(:retain_expire_time)\n @selected_applications = args[:selected_applications] if args.key?(:selected_applications)\n @selected_namespaces = args[:selected_namespaces] if args.key?(:selected_namespaces)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n @state = args[:state] if args.key?(:state)\n @state_reason = args[:state_reason] if args.key?(:state_reason)\n @uid = args[:uid] if args.key?(:uid)\n @update_time = args[:update_time] if args.key?(:update_time)\n @volume_count = args[:volume_count] if args.key?(:volume_count)\n end",
"def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end",
"def component_status_update(statuspage_id, component, container, details, current_status)\n request :method => :post,\n :url => @url + 'component/status/update',\n :payload => {\n 'statuspage_id' => statuspage_id,\n 'component' => component,\n 'container' => container,\n 'details' => details,\n 'current_status' => current_status\n }\n end",
"def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @container_stack }\n end\n end",
"def update\n unless @category.name == \"ROOT\"\n if @category.update(category_params)\n render 'show', :status => 200, :layout => false, notice: 'Category was successfully created.'\n else\n render :json => {:message => \"Error in updating category\"}, notice: @category.errors, :layout => false, :status => 400\n end\n else\n render :json => {:message => \"Root can't be edited.\"}, :layout => false, :status => 400\n end\n end",
"def update\n \n @category = Category.find(params[:id])\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to(admin_categories_url ,:notice => 'Category was successfully updated.') }\n format.xml { head :ok }\n format.json do \n \n level = @category.parents_array.size\n varb = render_to_string :partial => \"item.html.erb\",:locals => { :level => level, :category=>@category }\n \n render :json => {\n :html=>varb,\n :category=>@category.attributes,\n :level => level\n \n }, \n :content_type => 'text/json',\n :status => :created\n end\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @category.errors, :status => :unprocessable_entity }\n format.json { render :status=>:unprocessable_entity ,:json => @category.errors, :content_type => 'text/json' }\n\n end\n end\n end",
"def test_put_new_resource_locked_collection_zero_depth\n setup_hr\n\n resumes_locktoken = lock('httplock/hr/recruiting/resumes',\n :depth => 0).token\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), :if_none_match => '*')\n assert_equal '423', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"lisa resume\"), { :if_none_match => '*', :if => { 'httplock/hr/recruiting/resumes/' => resumes_locktoken } })\n assert_equal '201', response.status\n\n response = @request.put('httplock/hr/recruiting/resumes/ldusseault.txt', StringIO.new(\"hello\"))\n assert_equal '204', response.status\n\n # cleanup\n unlock('httplock/hr/recruiting/resumes/', resumes_locktoken)\n delete_coll 'httplock'\n end",
"def add_container(container)\n # Avoid duplicated labels on compose\n while @containers.has_key?(container.attributes[:label]) do\n container.attributes[:label].succ!\n end\n\n @containers[container.attributes[:label]] = container\n true\n end",
"def update\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.attributes = params[:physical_rack]\n @physical_rack.audits << Audit.new(source: 'controller', action: 'update', admin_user: current_user)\n respond_to do |format|\n if @physical_rack.save\n format.html { redirect_to @physical_rack, notice: 'Physical rack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @physical_rack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @template_container = TemplateContainer.find(params[:id])\n\n respond_to do |format|\n if @template_container.update_attributes(params[:template_container])\n flash[:notice] = 'TemplateContainer was successfully updated.'\n format.html { redirect_to(@template_container) }\n format.xml { head :ok }\n format.js { render :layout => false }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @template_container.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n render_json :status => :forbidden and return unless @collection.write?(@user, @client)\n if !params[:collection]\n render_json :status => :bad_request, :messages => \"Tried to update collection with no data.\" and return\n end\n @collection.update_attributes(params[:collection].slice(:metadata, :read_only, :title, :tags, :priv))\n render_json :entry => @collection.to_hash(@user, @client) and return\n end",
"def update\n json_update(category,category_params, Category)\n end",
"def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && [email protected]?)\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 @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def replace_container(name, content)\n render :update do |page|\n page.replace name, content\n end\n end",
"def update!(**args)\n @container = args[:container] if args.key?(:container)\n @elementary_streams = args[:elementary_streams] if args.key?(:elementary_streams)\n @encryption_id = args[:encryption_id] if args.key?(:encryption_id)\n @file_name = args[:file_name] if args.key?(:file_name)\n @key = args[:key] if args.key?(:key)\n @segment_settings = args[:segment_settings] if args.key?(:segment_settings)\n end",
"def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end",
"def update_dimension\n dimension_id = BSON::ObjectID.from_string(params[:id])\n dimension = @current_knowledge.get_dimension_by_id(dimension_id)\n if parent_id = params[:dimension][:parent_id]\n params[:dimension][:parent_id] = BSON::ObjectID.from_string(parent_id)\n end\n dimension.update_attributes(params[:dimension])\n render :update do |page|\n page.replace_html(\"list_dimensions\", :partial => \"dimensions\",\n :locals => { :dimensions => [@current_knowledge.dimension_root] })\n end\n end",
"def init_containers=(value)\n @init_containers = value\n end",
"def update_level\n tags = []\n user_level = 0\n tags = labels.with_private_scope\n .map { |l| [l.key, l.value].join ':' }\n\n levels = Level.all.order(id: :asc)\n levels.each do |lvl|\n break unless tags.include?(lvl.key + ':' + lvl.value)\n\n user_level = lvl.id\n end\n\n update(level: user_level)\n end",
"def update!(**args)\n @container_type = args[:container_type] if args.key?(:container_type)\n @display_name = args[:display_name] if args.key?(:display_name)\n @display_name_last_first = args[:display_name_last_first] if args.key?(:display_name_last_first)\n end",
"def update\n @slice = Xen::Slice.find(params[:id])\n\n respond_to do |format|\n if @slice.update_attributes(params[:slice])\n flash[:notice] = 'Slice was successfully updated.'\n format.html { redirect_to(@slice) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @slice.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.64348024",
"0.6189901",
"0.61400276",
"0.60906875",
"0.6009078",
"0.5988657",
"0.589103",
"0.5844507",
"0.5731526",
"0.57260954",
"0.5683184",
"0.5628287",
"0.5628287",
"0.55352783",
"0.5526222",
"0.54877126",
"0.54833376",
"0.5463547",
"0.54536074",
"0.54386973",
"0.54207444",
"0.5372791",
"0.5338512",
"0.5286862",
"0.5244814",
"0.5239783",
"0.522799",
"0.5201719",
"0.51582414",
"0.51555955",
"0.51489115",
"0.5138672",
"0.5107137",
"0.50997216",
"0.5068034",
"0.50616693",
"0.5049919",
"0.504424",
"0.5041769",
"0.50149167",
"0.49912322",
"0.4980153",
"0.49766523",
"0.49691662",
"0.49655518",
"0.49495476",
"0.49453768",
"0.4943879",
"0.4940934",
"0.49379265",
"0.4917051",
"0.49043626",
"0.4902012",
"0.49006042",
"0.48933858",
"0.48826793",
"0.4880543",
"0.48691487",
"0.48674777",
"0.4857396",
"0.4850497",
"0.48198727",
"0.48174566",
"0.48049393",
"0.48049128",
"0.4802258",
"0.4801032",
"0.4788205",
"0.477937",
"0.47644877",
"0.476265",
"0.47605005",
"0.47603118",
"0.47581193",
"0.4755236",
"0.47485545",
"0.4747665",
"0.4738065",
"0.47369352",
"0.47340137",
"0.47262147",
"0.4720534",
"0.47100103",
"0.47086045",
"0.46679494",
"0.46657354",
"0.46655422",
"0.4656025",
"0.46537787",
"0.46474633",
"0.46473765",
"0.46412352",
"0.46278828",
"0.46240902",
"0.46000633",
"0.4592032",
"0.4591442",
"0.45899218",
"0.45807132",
"0.45726466"
] | 0.69577956 | 0 |
DELETE /level_containers/1 DELETE /level_containers/1.json | def destroy
@level_container = LevelContainer.find(params[:id])
@level_container.destroy
respond_to do |format|
format.html { redirect_to level_containers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end",
"def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to containers_url, notice: 'Container was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container = Container.find(params[:id])\n @container.destroy\n\n respond_to do |format|\n format.html { redirect_to(containers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @container = Container.get(params[:id])\n @container.destroy if(@container && [email protected]?)\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 @docker_instance.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @container_stack = ContainerStack.find(params[:id])\n @container_stack.destroy\n\n respond_to do |format|\n format.html { redirect_to container_stacks_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 @serverhascontainer.destroy\n respond_to do |format|\n format.html { redirect_to serverhascontainers_url, notice: 'Serverhascontainer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container = @container_row.container\n @container_row.destroy\n respond_to do |format|\n flash[:success] = 'Row was successfully deleted.' \n format.html { redirect_to admin_container_url(@container) }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n #finds the current server that the container is on and sets it as Docker.ulr\n #@serverid = Serverhascontainer.where(container_id: @container.id)[0].server_id;\n #@currentServer = Server.where(id: @serverid)\n #Docker.url = 'tcp://' + @currentServer[0][\"ip\"] + \":\" + @currentServer[0][\"port\"]\n Docker.url = findServer()\n\n #removes the container from docker\n Docker::Container.get(Container.find(params[:id]).dockercontainer_id).remove;\n\n #removes the Server-container relation from the database\n @d = Serverhascontainer.where(container_id: @container.id) \n Serverhascontainer.destroy(@d[0].id);\n\n #removes the container from the database\n @container.destroy\n Docker.url = ''\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'deleted.' }\n format.json { head :no_content }\n end\n\n rescue Docker::Error::ConflictError => e\n respond_to do |format| \n format.html { redirect_to root_path, notice: \"Oops: You cannot remove a running container. Stop the container before attempting removal\" }\n end\n end\n end",
"def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end",
"def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend",
"def destroy\n @level.destroy\n respond_to do |format|\n format.html { redirect_to levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @level_category = LevelCategory.find(params[:id])\n @level_category.destroy\n\n respond_to do |format|\n format.html { redirect_to level_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container_item.destroy\n respond_to do |format|\n format.html { destroy_redirect @container_item, notice: 'Container item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @container_content = ContainerContent.find(params[:id])\n container = @container_content.container\n @container_content.destroy\n\n respond_to do |format|\n format.html { redirect_to(container) }\n format.xml { head :ok }\n end\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(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 destroy\n @cephalopod.destroy\n respond_to do |format|\n format.html { redirect_to cephalopods_url }\n format.json { head :no_content }\n end\n end",
"def 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 @health_level.destroy\n\n respond_to do |format|\n format.html { redirect_to health_levels_url }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end",
"def destroy\n @receipt_container = ReceiptContainer.find(params[:id])\n @receipt_container.destroy\n\n respond_to do |format|\n format.html { redirect_to receipt_containers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @level = Level.find(params[:id])\n @level.destroy\n\n respond_to do |format|\n format.html { redirect_to levels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominium_child.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @level = Level.find(params[:id])\n @level.destroy\n\n respond_to do |format|\n format.html { redirect_to levels_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @template_container = TemplateContainer.find(params[:id])\n @template_container.destroy\n respond_to do |format|\n format.html { redirect_to(template_containers_url) }\n format.xml { head :ok }\n format.js { render :layout => false }\n end\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: DELETE_SUCCESS }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to physical_racks_url }\n format.json { head :ok }\n end\n end",
"def destroy\n log_debug \"[ #{@node}/#{@environment} ] - Destroy Podman Container #{@container} ...\"\n @cmd_runner.run_cmd \"#{podman_cmd} container rm #{@container}\"\n end",
"def remove_container(name)\n render :update do |page|\n page.remove name\n end\n end",
"def deleteFlatpack( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack\",params)\n end",
"def destroy\n @node = Node.find_key(params[:id] || params[:name])\n @node.destroy\n respond_to do |format|\n format.html { redirect_to deployment_path(@node.deployment_id) }\n format.json { render api_delete @node }\n end\n end",
"def destroy\n IndicatorCategory.delete_hack(params[:id])\n\n respond_to do |format|\n format.html { redirect_to indicator_categories_url }\n format.json { head :ok }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @contamination_level.destroy\n respond_to do |format|\n format.html { redirect_to contamination_levels_url, notice: 'Contamination level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leafs_url, notice: t('common.message.destroyed_success')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @docker_cfg.destroy\n respond_to do |format|\n format.html { redirect_to docker_cfgs_url, notice: 'Docker cfg was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection = Collection.find(params[:id])\n \n #destroy all child documents\n @collection.documents.each do |d|\n upload_remove(d) #Removes upload record if file is deleted\n d.destroy\n end\n \n #destroy all child collections\n @collection.collections.each do |c|\n collection_recursive_destroy(c)\n end\n \n @collection.destroy\n\n respond_to do |format|\n format.html { redirect_to collections_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @konfig = Konfig.find(params[:id])\n @konfig.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_konfigs_url }\n format.json { head :no_content }\n end\n end",
"def delete(labels = [])\n call_container_method(:delete, labels)\n end",
"def destroy\n @root_collection.destroy\n respond_to do |format|\n format.html { redirect_to root_collections_url, notice: 'Root collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # The correct implementation, with garbage collection:\n # if params.has_key?(:container_id)\n # container = ActiveFedora::Base.load_instance(params[:container_id]) \n # container.file_objects_remove(params[:id])\n # FileAsset.garbage_collect(params[:id])\n # else\n \n # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)\n ActiveFedora::Base.load_instance(params[:id]).delete \n flash[:notice] = \"Deleted #{params[:id]} from #{params[:container_id]}.\"\n \n if !params[:container_id].nil?\n redirect_params = {:controller => \"catalog\", :action => \"edit\", :id => params[:container_id], :anchor => \"file_assets\"}\n end\n redirect_params ||= {:action => 'index', :q => nil , :f => nil}\n \n redirect_to redirect_params\n \n end",
"def destroy\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @datacenter.destroy\n\n respond_to do |format|\n format.html { redirect_to datacenters_url }\n format.json { head :ok }\n end\n end",
"def delete(args)\n args = {:path => args} unless args.is_a?(Hash)\n assert_supported_keys(args, [:path, :version, :callback, :context])\n assert_required_keys(args, [:path])\n args[:version] ||= -1\n\n if args[:callback] ## asynchronous\n raise KeeperException::BadArguments unless args[:callback].kind_of?(VoidCallback)\n return zoo_adelete(@zk_handle, args[:path], args[:version], args[:callback].proc, YAML.dump(args[:context]))\n end\n\n ## synchronous\n rc = zoo_delete(@zk_handle, args[:path], args[:version])\n raise KeeperException.by_code(rc), ZooKeeperFFI::zerror(rc) unless rc == ZOK\n return rc\n end",
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @admin_level.destroy\n respond_to do |format|\n format.html { redirect_to admin_levels_url, notice: 'Level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\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 destroy\n @fnss_simple_kary_tree.destroy\n respond_to do |format|\n format.html { redirect_to fnss_simple_kary_trees_url, notice: 'Fnss simple kary tree was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @leaf.destroy\n respond_to do |format|\n format.html { redirect_to leaves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @declaration_container.destroy\n\n respond_to do |format|\n format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }\n format.json { head :no_content }\n end\n end",
"def delete_container(name, options={})\n # Query\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n # Call\n call(:delete, container_uri(name, query), nil, {}, options)\n \n # result\n nil\n end",
"def destroy\n @level2.destroy\n respond_to do |format|\n format.html { redirect_to level2s_url, notice: 'Level2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = @containers_page.page\n @containers_page.destroy\n @containers_pages = @page.containers_pages\n respond_to do |format|\n format.js\n format.html do \n flash[:success] = 'Container was successfully removed from page.' \n redirect_to containers_pages_url \n end\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_level = AdminLevel.find(params[:id])\n @admin_level.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_levels_url }\n format.json { head :ok }\n end\n end",
"def delete!\n\t\t\tClient.delete @root\n\t\tend",
"def destroy\n authorize! :destroy, @operation_level\n @operation_level.destroy\n respond_to do |format|\n format.html { redirect_to operation_levels_url, notice: 'Operation level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection.destroy\n\n render json: @collection, status: :ok#, location: @collection\n end",
"def destroy\n @dumb_counter.destroy\n respond_to do |format|\n format.html { redirect_to dumb_counters_url, notice: 'Dumb counter was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @child.destroy\n respond_to do |format|\n format.html { redirect_to children_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lifecycle = Lifecycle.find(params[:id])\n @lifecycle.destroy\n\n respond_to do |format|\n format.html { redirect_to lifecycles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quest_tree = QuestTree.find(params[:id])\n @quest_tree.destroy\n\n respond_to do |format|\n format.html { redirect_to quest_trees_url }\n format.json { head :ok }\n end\n end",
"def delete_container(name, options={})\n query = { }\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n call(:delete, container_uri(name, query))\n nil\n end",
"def destroy\n @category_db.destroy\n respond_to do |format|\n format.html { redirect_to category_dbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if admin?\n @level.destroy\n respond_to do |format|\n format.html { redirect_to levels_url, notice: 'Level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @storage_lun = StorageLun.find(params[:id])\n @storage_lun.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_luns_url }\n format.json { head :no_content }\n end\n end",
"def handle_destroy(event)\n @bus.request 'containers', 'destroyed', event: event.json, container: container_info(event.id)\n end",
"def destroy\n @glo_collection.destroy\n respond_to do |format|\n format.html { redirect_to glo_collections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shipping_container = ShippingContainer.find(params[:id])\n @shipping_container.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_shipping_containers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n n = Node.find_key(params[:id] || params[:name])\n render api_delete Node\n end",
"def destroy\n @slab = Slab.find(params[:id])\n @slab.destroy\n\n respond_to do |format|\n format.html { redirect_to slabs_url }\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 @phase_level.destroy\n respond_to do |format|\n format.html { redirect_to phase_levels_url, notice: 'Phase level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @sub_collection.destroy\n respond_to do |format|\n format.html { redirect_to sub_collections_url, notice: 'Sub collection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tree.destroy\n respond_to do |format|\n format.html { redirect_to trees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_state.destroy\n\n head :no_content\n end",
"def destroy\n @inside.destroy\n respond_to do |format|\n format.html { redirect_to insides_url, notice: 'Inside was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n NamedMap.stats_aggregator.timing('named-map.delete') do\n response = self.class.http_client.delete( url + '?api_key=' + @parent.api_key,\n {\n headers: @parent.headers,\n ssl_verifypeer: @parent.verify_cert,\n ssl_verifyhost: @parent.verify_host,\n followlocation: true,\n connecttimeout: HTTP_CONNECT_TIMEOUT,\n timeout: HTTP_REQUEST_TIMEOUT\n } )\n raise HTTPResponseError, \"DELETE:#{response.code} #{response.request.url} #{response.body}\" unless response.code == 204\n end\n end",
"def destroy\n @lab_rack = LabRack.find(params[:id])\n @lab_rack.destroy\n\n respond_to do |format|\n format.html { redirect_to(lab_racks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n response = connection.delete(\"/collections/#{id}\")\n (200..299).include?(response.status)\n end",
"def destroy\n @collab = Collab.find(params[:id])\n @collab.destroy\n\n respond_to do |format|\n format.html { redirect_to collabs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @health_record.destroy\n respond_to do |format|\n format.html { redirect_to health_records_url }\n format.json { head :no_content }\n end\n end",
"def remove_container(message)\n begin\n parameters = message.parameters\n \n @log.info(\"LB create_container command received from #{message.from}: #{message.command} #{message.parameters.to_s}\")\n \n case parameters.fetch(\"lb_type\")\n when \"f5\" then \n podName = parameters.fetch('PodName')\n containerName = parameters.fetch('ContainerName')\n minorVLAN = parameters.fetch('MinorVLAN') \n \n @log.info(\"PodName is #{podName}\") \n @log.info(\"ContainerName is #{containerName}\") \n @log.info(\"MinorVLAN is #{minorVLAN}\") \n \n # log.info hangs on some messages so use plain 'puts' instead \n for i in 1..11\n suffix = \"%03d\" %[i]\n nextF5Msg = \"tmsh delete /ltm node /#{podName}/#{containerName}#{suffix} \"\n puts nextF5Msg\n f5_command(message, nextF5Msg)\n end\n firstF5Msg = \"tmsh delete /ltm snat /#{podName}/VLAN#{minorVLAN}-Out\"\n puts firstF5Msg \n f5_command(message, firstF5Msg)\n secondF5Msg = \"tmsh delete /net self /#{podName}/SelfIP-LB-#{minorVLAN}\"\n puts secondF5Msg \n f5_command(message, secondF5Msg) \n thirdF5Msg = \"tmsh delete /net self /#{podName}/SelfIP-LB1-#{minorVLAN} \"\n puts thirdF5Msg \n f5_command(message, thirdF5Msg)\n fourthF5Msg = \"tmsh delete /net route-domain RD#{minorVLAN}\" \n puts fourthF5Msg \n f5_command(message, fourthF5Msg) \n fifthF5Msg = \"tmsh delete /net vlan VLAN#{minorVLAN}\" \n puts fifthF5Msg\n f5_command(message, fifthF5Msg) \n \n when \"array\" then array_command(\"...\")\n when \"alteon\" then alteon_command(\"Lol, really?\")\n else message.create_fail_msg(\"Load balancer model unspecified.\",9)\n end\n return message.create_success_msg(\"success\")\n rescue F5_command_error\n return message.create_fail_msg(\"F5 command failure\", 7)\n end\n end",
"def api_remove\n data_hash = make_hash\n delete_hash = { division: data_hash[:division][:value] }\n handler.remove(delete_hash, path, subscriber_id)\n end",
"def destroy\n @competency_level.destroy\n respond_to do |format|\n format.html { redirect_to competency_levels_url, notice: 'Competency level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wrapper.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @small_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/small_concerts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n format.html { redirect_to rubies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end",
"def destroy\n @control_loop.destroy\n respond_to do |format|\n format.html { redirect_to control_loops_url, notice: 'Control loop was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7366254",
"0.6975811",
"0.68506867",
"0.6807022",
"0.67010915",
"0.6654879",
"0.66404635",
"0.66291106",
"0.65641856",
"0.64803624",
"0.6452543",
"0.6412548",
"0.63961846",
"0.6387078",
"0.6377407",
"0.6320939",
"0.63036215",
"0.63035065",
"0.6289525",
"0.62680393",
"0.6251626",
"0.6239479",
"0.62350553",
"0.62209785",
"0.62061274",
"0.61951894",
"0.6179867",
"0.61769176",
"0.61725473",
"0.6158845",
"0.6154832",
"0.61524135",
"0.61333346",
"0.6121608",
"0.61124766",
"0.6112072",
"0.6099296",
"0.60860616",
"0.60806394",
"0.60744554",
"0.6058159",
"0.60536873",
"0.6041177",
"0.60259384",
"0.601571",
"0.600983",
"0.60042137",
"0.6003207",
"0.5999379",
"0.59984934",
"0.5984101",
"0.598284",
"0.59731436",
"0.59705925",
"0.59658563",
"0.595988",
"0.5951145",
"0.5950122",
"0.59474415",
"0.5930816",
"0.5928074",
"0.5925583",
"0.5923048",
"0.5913492",
"0.5908616",
"0.589918",
"0.58990496",
"0.5879184",
"0.58790934",
"0.58771056",
"0.58652943",
"0.58635235",
"0.58595586",
"0.5858759",
"0.5855619",
"0.5854478",
"0.5851687",
"0.5847283",
"0.5844763",
"0.5839544",
"0.5836697",
"0.5830496",
"0.58274233",
"0.5826803",
"0.5826803",
"0.58240104",
"0.581867",
"0.5818501",
"0.58090377",
"0.5805469",
"0.5803673",
"0.58023065",
"0.5800791",
"0.5800215",
"0.58000195",
"0.5796005",
"0.5795117",
"0.57913816",
"0.5790726",
"0.57887685"
] | 0.7960961 | 0 |
we're assuming this is used in a IO.select for reading | def to_s
"iostream(input=#{@input.to_s},output=#{@output.to_s})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select\n ::IO.select([ self.fd ], nil, [ self.fd ], 0.10)\n end",
"def select; end",
"def select; end",
"def select(&blk); end",
"def select(&block); end",
"def select!(&block); end",
"def select(*) end",
"def depatch_io\n IO.class_exec do\n class << self\n alias_method :select, :select_for_real\n end\n end\nend",
"def read() end",
"def select(&blk)\n alter do\n @lines = @lines.select(&blk)\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 select_loop\n loop do\n readable, = IO.select([socket_server, signal_pipe_r])\n readable.each do |reader|\n if reader == socket_server\n accept_client_connection\n elsif reader == signal_pipe_r\n signal = reader.gets.chomp\n process_signal(signal)\n end\n end\n end\n end",
"def sockets_ready_for_reading\n\t\n\t\t# Start by creating an array of sockets. The array is composed\n\t\t# of the @server_socket and appending the array of client sockets. \n\t\t# To get the array of client sockets, we call get_client_sockets()\n\n\t\tsocket_array = []\t\t\t\t\t# make a new empty array\n\t\tsocket_array << @server_socket\t\t# append the @server_socket\n\t\tsocket_array << get_client_sockets\t# append an array of clients\n\t\tsocket_array.flatten!\t\t\t\t# flatten! the array\n\n\t\t# Here is a tutorial of how to create the socket array, only with\n\t\t# integers instead of sockets:\n\t\t# irb(main):001:0> a=[] \t\t# make a new empty array\n\t\t# => []\n\t\t# irb(main):002:0> a << 1\t\t\t# append a digit to the array\t\n\t\t# => [1]\n\t\t# irb(main):004:0> a << [2,3,4]\t\t# append an array to the array\n\t\t# => [1, [2, 3, 4]]\n\t\t# irb(main):005:0> a.flatten!\t\t# flatten! does just that\n\t\t# => [1, 2, 3, 4]\n\n\t\t# IO.select monitors IO objects and returns a proper subset\n\t\t# that have something pending. Take four arguments, a array of of \n\t\t# objects to scan for reads, writes, errors, and timeouts. We \n\t\t# are only concerned with sockets ready to read, so we pass nil\n\t\t# for the rest. IO.select returns four arrays of arrays, we \n\t\t# pluck of first array which is the array of sockets ready to be\n\t\t# read from.\n\n\t\tio_ready \t= IO.select(socket_array, nil, nil, nil)\n\t\tready2read\t= io_ready[0]\n\n\t\treturn ready2read\n\tend",
"def wait(seq)\n nseq = nil\n while not nseq\n nseq,data = read_data(seq)\n select\n end\n end",
"def select(*rest) end",
"def select(*rest) end",
"def readchar_nonblock io, &block\n begin\n done = false\n until done do\n ch = io.read_nonblock(1)\n done = block.call(ch)\n end\n rescue IO::WaitReadable\n logger.trace \"got WaitReadable exception\"\n t1 = Time.now\n IO.select([io], [io], [io])\n logger.trace \"got event, waited #{Time.now - t1}\"\n retry\n end\n end",
"def read_one_nonblock\n read_one if has_any?\n end",
"def read_wait(timeout: nil)\n !!IO.select([io], [], [], timeout)\n end",
"def select(&block)\n alter do\n @lines = @lines.select(&block)\n end\n end",
"def read_all(&block); end",
"def select(&block)\n @select = block if block\n @select\n end",
"def select(timeout = 1)\n ::IO.select([@io], [@io], [], timeout)\n end",
"def read_blocked\n end",
"def all_by_magic(io); end",
"def sleep\n # Returns with active IO objects if any of them are written to.\n # Otherwise it times out after two seconds.\n if needy = IO.select(@lifelines.values, nil, @lifelines.values, 2)\n log.debug(\"Detected activity on: #{needy.inspect}\") \n # Read everything coming in on the lifelines and discard it because\n # the contents doesn't matter.\n needy.flatten.each do |lifeline|\n loop { lifeline.read_nonblock(READ_BUFFER_SIZE) } unless lifeline.closed?\n end if needy\n end\n rescue EOFError, Errno::EAGAIN, Errno::EINTR, Errno::EBADF, IOError\n end",
"def readpartial(size)\n reset_timer\n\n loop do\n result = socket.read_nonblock(size, :exception => false)\n if result.nil?\n return :eof\n elsif result != :wait_readable\n return result\n end\n\n IO.select([socket], nil, nil, time_left)\n log_time\n end\n end",
"def read\n return if @read_flag\n\n process_reading\n end",
"def select( &block )\r\n\t\t\treturn @contents.select( &block )\r\n\t\tend",
"def non_blocking_gets\n loop do\n result, _, _ = IO.select([@socket], nil, nil, 0.2)\n next unless result\n return result[0].gets\n end\n end",
"def next_line_readable?\r\n readfds, writefds, exceptfds = select([@socket], nil, nil, 0.1)\r\n readfds #Will be nil if next line can't be red\r\n end",
"def read_one_nonblock\n synchronize {\n read_many_nonblock.slice!(0)\n }\n end",
"def thread_select\n selection = Array.new\n thread_each do |e|\n selection << e if yield(e)\n end\n selection\n end",
"def wait_readable\n if evented?\n Celluloid.current_actor.wait_readable(self.to_io)\n else\n Kernel.select([self.to_io])\n end\n end",
"def run_internal\n monitors = @monitors\n selector = @selector\n\n while true\n begin\n ready = selector.select @sleep_for\n rescue IOError => e\n Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue\n if monitors.any? { |mon| mon.value.closed? }\n STDERR.puts \"Error in select: #{e.message} (#{e.class})\"\n STDERR.puts e.backtrace\n\n monitors.reject! do |mon|\n if mon.value.closed?\n selector.deregister mon.value\n true\n end\n end\n\n retry\n else\n raise\n end\n end\n\n if ready\n ready.each do |mon|\n if mon.value == @ready\n @mutex.synchronize do\n case @ready.read(1)\n when \"*\"\n @input.each do |c|\n mon = nil\n begin\n begin\n mon = selector.register(c, :r)\n rescue ArgumentError\n # There is a bug where we seem to be registering an already registered\n # client. This code deals with this situation but I wish we didn't have to.\n monitors.delete_if { |submon| submon.value.to_io == c.to_io }\n selector.deregister(c)\n mon = selector.register(c, :r)\n end\n rescue IOError\n # Means that the io is closed, so we should ignore this request\n # entirely\n else\n mon.value = c\n @timeouts << mon if c.timeout_at\n monitors << mon\n end\n end\n @input.clear\n\n @timeouts.sort! { |a,b| a.value.timeout_at <=> b.value.timeout_at }\n calculate_sleep\n when \"c\"\n monitors.reject! do |submon|\n if submon.value == @ready\n false\n else\n submon.value.close\n begin\n selector.deregister submon.value\n rescue IOError\n # nio4r on jruby seems to throw an IOError here if the IO is closed, so\n # we need to swallow it.\n end\n true\n end\n end\n when \"!\"\n return\n end\n end\n else\n c = mon.value\n\n # We have to be sure to remove it from the timeout\n # list or we'll accidentally close the socket when\n # it's in use!\n if c.timeout_at\n @mutex.synchronize do\n @timeouts.delete mon\n end\n end\n\n begin\n if c.try_to_finish\n @app_pool << c\n clear_monitor mon\n end\n\n # Don't report these to the lowlevel_error handler, otherwise\n # will be flooding them with errors when persistent connections\n # are closed.\n rescue ConnectionError\n c.write_error(500)\n c.close\n\n clear_monitor mon\n\n # SSL handshake failure\n rescue MiniSSL::SSLError => e\n @server.lowlevel_error(e, c.env)\n\n ssl_socket = c.io\n begin\n addr = ssl_socket.peeraddr.last\n # EINVAL can happen when browser closes socket w/security exception\n rescue IOError, Errno::EINVAL\n addr = \"<unknown>\"\n end\n\n cert = ssl_socket.peercert\n\n c.close\n clear_monitor mon\n\n @events.ssl_error @server, addr, cert, e\n\n # The client doesn't know HTTP well\n rescue HttpParserError => e\n @server.lowlevel_error(e, c.env)\n\n c.write_error(400)\n c.close\n\n clear_monitor mon\n\n @events.parse_error @server, c.env, e\n rescue StandardError => e\n @server.lowlevel_error(e, c.env)\n\n c.write_error(500)\n c.close\n\n clear_monitor mon\n end\n end\n end\n end\n\n unless @timeouts.empty?\n @mutex.synchronize do\n now = Time.now\n\n while @timeouts.first.value.timeout_at < now\n mon = @timeouts.shift\n c = mon.value\n c.write_error(408) if c.in_data_phase\n c.close\n\n clear_monitor mon\n\n break if @timeouts.empty?\n end\n\n calculate_sleep\n end\n end\n end\n end",
"def reader_ready?\n IO.select([@socket],nil,nil,0) != nil\n end",
"def next_line_readable?(socket)\n readfds, writefds, exceptfds = select([socket], nil, nil, 0.1)\n readfds \n end",
"def next_line_readable?(socket)\n readfds, writefds, exceptfds = select([socket], nil, nil, 0.1)\n readfds \n end",
"def request_select\n end",
"def non_blocking_gets\n loop do\n result, _, _ = IO.select( [@socket], nil, nil, 0.2 )\n next unless result\n return result[0].gets\n end\n end",
"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 wait_readable_or_timeout; end",
"def select!(aid)\n \tselect(aid).raise_errno!\n end",
"def read\n end",
"def read\n end",
"def read\n end",
"def read\n end",
"def wait_readable\n ::IO.select([@io], [], [])\n true\n rescue IOError\n false\n end",
"def close_read() end",
"def close_read() end",
"def close_read() end",
"def fill\n begin\n @buffer << @io.read_nonblock(@buffer_size)\n rescue ::IO::WaitReadable\n IO.select([@io], nil, nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n rescue ::IO::WaitWritable\n IO.select(nil, [@io], nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n end\n end",
"def fill\n begin\n @buffer << @io.read_nonblock(@buffer_size)\n rescue ::IO::WaitReadable\n IO.select([@io], nil, nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n rescue ::IO::WaitWritable\n IO.select(nil, [@io], nil, @read_timeout) ? retry : (raise ::Timeout::Error)\n end\n end",
"def read_and_process\n process(read)\n end",
"def select_loop\n loop do\n # Wait for descriptors or a 1 second timeout\n readable, = IO.select(@active_descriptors, [], [], 1)\n # Only process one descriptor per iteration.\n # We don't want to process a descriptor that has been deleted.\n reader = readable&.first\n if reader == signal_pipe_r\n signal = reader.gets.chomp\n process_signal(signal)\n elsif reader == file_descriptor_server.socket_server\n file_descriptor_server.serve_file_descriptor\n @active_descriptors.delete(file_descriptor_server.socket_server)\n graceful_shutdown\n elsif reader == socket_server\n accept_client_connection\n end\n\n if @shutdown\n if active_connections.zero?\n logger.debug \"No more active connections. Exiting'\"\n Process.exit(0)\n else\n logger.debug \"#{active_connections} connections still active\"\n end\n end\n\n end\n end",
"def read\n \n end",
"def io_lock; end",
"def select_line\n buffer_current.select_current_line\n update_status_line\n end",
"def sysread(amt=99) end",
"def _read maxlen = DEFAULT_MAXLEN\n begin\n data = nil\n\n loop do\n data = read_from_socket maxlen\n case data\n when :wait_readable\n IO.select selector\n when NilClass\n break\n else\n begin\n @client << data\n rescue HTTP2::Error::ProtocolError => pe\n STDERR.puts \"protocol error: #{pe.message}\"\n STDERR.puts pe.backtrace.map {|l| \"\\t\" + l}\n end\n end\n end\n\n rescue IOError, Errno::EBADF\n close\n ensure\n unblock!\n end\n end",
"def _exec_select\n result = []\n csv = CSV.parse(File.read(@table_name), headers: true)\n if @join_flag != 1\n _parse_when_not_join(result, csv)\n else\n _parse_when_join(result, csv)\n end\n if @order_flag == 1\n result = _parse_order(result)\n end\n p result\n end",
"def read\n if !@derived_queue.empty?\n p1 = @derived_queue.shift\n return p1\n else\n\n # This is a blocking call to wait for an actual packet to come over the wire\n packet = super()\n\n agg_pkt_map.select do |agg_packet, simple_packet|\n agg_pkt = System.telemetry.packet(target, agg_packet)\n if(agg_pkt.identify?(packet.buffer)) \n process(packet: packet, target: target, agg_packet: agg_packet, simple_packet: simple_packet)\n end\n end\n \n return packet\n end \n end",
"def run\n begin\n each { |d| d.process }\n end while (IO.select(self, [], [], 0) rescue nil)\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def read( ioin=$ioin )\n super\n self\n end",
"def select_next\n raise NotImplementedError.new \n end",
"def read\nend",
"def log_select(arr, name)\n @p.puts \"\"\n @p.puts \"Select a #{name}:\"\n @p.in\n arr.each_with_index do |k, i|\n @p.puts \"#{i+1}. #{k.name}\"\n end\n @p.out.readline.to_i-1\n end",
"def read_buffer; end",
"def read\n end",
"def read; @connection.readline end",
"def verify_channel\n while ! self.channel\n raise EOFError if ! self.thread.alive?\n ::IO.select(nil, nil, nil, 0.10)\n end\n end",
"def close_read(*) end",
"def prepare\n self[:in].read\n end",
"def read_data_available?(timeout = 0)\n (rh, wh, eh) = IO::select([@io], nil, nil, timeout)\n ! rh.nil?\n end",
"def read_fully(count, timeout = nil)\n value = ''\n\n begin\n loop do\n value << read_nonblock(count - value.bytesize)\n break if value.bytesize >= count\n end\n rescue EOFError\n # JRuby specific fix via https://github.com/jruby/jruby/issues/1694#issuecomment-54873532\n IO.select([self], nil, nil, timeout)\n retry\n rescue *READ_RETRY_EXCEPTION_CLASSES\n if IO.select([self], nil, nil, timeout)\n retry\n else\n raise Timeout::Error, \"IO timeout when reading #{count} bytes\"\n end\n end\n\n value\n end",
"def read(pos)\n end",
"def read!\n\t\t\t\t\tread\n\t\t\trescue\n\t\t\t\tnil\n\t\t\tend",
"def finished_reading?; @finished_read; end",
"def sysread(*rest) end",
"def sysread(*rest) end",
"def inner_loop\n return if @stop\n\n data = @socket.readpartial 4096\n driver.parse data unless data.nil? or data.empty?\n end",
"def read\n @lines.shift\n end",
"def select_all\n buffer_current.select_all\n end",
"def read_lines(path, selector)\n # IO.open is deliberately not used directly to avoid potential security risks.\n # TODO: Get rid of 'open-uri' (URI.open).\n io = target_http?(path) ? URI : File\n\n io.open(path) do |f|\n if selector\n f.each.select.with_index(1, &selector)\n else\n f.read\n end\n end\n end",
"def gather\n return unless select([$stdin], nil, nil, 2)\n\n lines, line = [], nil\n while (line = gets) != \"---\\n\"\n lines << line\n end\n lines.join\nend",
"def read(io, size)\n io.read_nonblock(size)\n rescue IO::WaitReadable\n IO.select([io])\n retry\n rescue EOFError\n nil\n end",
"def gets_safe(socket, timeout=nil)\n if r = select([socket], nil, nil, timeout)\n return r[0].first.gets\n else\n return :timeout\n end\nrescue Exception => ex\n log_error(\"gets_safe: #{ex.class}: #{ex.message}\\n\\t#{ex.backtrace[0]}\")\n return :exception\nend",
"def select_text(str_or_rx)\n select.select(str_or_rx)\n end",
"def select how_much\n res = []\n how_much.times { res << select_one }\n res\n end",
"def ssl_socket_read(ssl_socket, bytes)\n log.chunder('ssl_socket_read')\n\n begin\n return ssl_socket.read_nonblock(bytes)\n rescue IO::WaitReadable\n log.chunder('WaitReadable') # XXX\n IO.select([ssl_socket.io])\n log.chunder('WaitReadable retry') # XXX\n retry\n rescue IO::WaitWritable\n log.chunder('WaitWritable') # XXX\n IO.select(nil, [ssl_socket.io])\n log.chunder('WaitWritable retry') # XXX\n retry\n end\n\n ensure\n log.chunder('done ssl_socket_read')\n end",
"def readline\n end"
] | [
"0.7025364",
"0.6552576",
"0.6552576",
"0.64534914",
"0.63984203",
"0.6094436",
"0.6084067",
"0.6067785",
"0.593327",
"0.5744053",
"0.5673677",
"0.5673677",
"0.5673677",
"0.5673677",
"0.5673677",
"0.5673677",
"0.5673677",
"0.56581086",
"0.55706966",
"0.55486184",
"0.5508078",
"0.5508078",
"0.55059487",
"0.5486792",
"0.5476326",
"0.546393",
"0.54318464",
"0.54185385",
"0.5417873",
"0.53895044",
"0.5386357",
"0.5385209",
"0.5383894",
"0.5377417",
"0.53665084",
"0.5363556",
"0.53509647",
"0.5340893",
"0.53394103",
"0.5322269",
"0.5318805",
"0.5292933",
"0.5292045",
"0.5292045",
"0.52824676",
"0.5268594",
"0.52661216",
"0.5266109",
"0.524393",
"0.52373505",
"0.52373505",
"0.52373505",
"0.52373505",
"0.52327764",
"0.5223697",
"0.5223697",
"0.5223697",
"0.5222358",
"0.5222358",
"0.5212475",
"0.5202495",
"0.51996446",
"0.51878655",
"0.51850426",
"0.5179573",
"0.5175446",
"0.5140025",
"0.5135202",
"0.512652",
"0.5122176",
"0.5122176",
"0.5122176",
"0.5122176",
"0.5122176",
"0.511652",
"0.5107647",
"0.50952464",
"0.5079584",
"0.50731945",
"0.50670874",
"0.5063716",
"0.5059699",
"0.5043609",
"0.5040736",
"0.5034908",
"0.50265867",
"0.50254166",
"0.50247794",
"0.50207657",
"0.50207657",
"0.5011881",
"0.5009567",
"0.50091887",
"0.5008853",
"0.50045216",
"0.4998413",
"0.49967083",
"0.4976159",
"0.4975311",
"0.49733737",
"0.49705365"
] | 0.0 | -1 |
Should work for future stock, need to program in future predictor method. | def stock_picker(prices)
buy_date = 0
sell_date = 0
max_profit = 0
(0...prices.size).each do |buy|
((buy + 1)...prices.size).each do |sell|
profit = prices[sell] - prices[buy]
if max_profit < profit
max_profit = profit
buy_date = buy
sell_date = sell
end
end
end
[buy_date, sell_date]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_market; end",
"def stock_picker(history)\n best_sell_array = [0]\n history.each_with_index do |eo, io|\n best_sell_array[io] = get_best_sell(io, eo, history)\n end\n result_day_pairs = get_result_day_pairs(best_sell_array)\n profit = history[result_day_pairs[0]-1] - history[result_day_pairs[1]-1]\n \"Buy on day #{result_day_pairs[0]} and sell on day #{result_day_pairs[1]} for a profit of #{profit}\"\nend",
"def market\n end",
"def analyse_data data, training: true\n if @contract.bars.size <= 1\n @current_price_signal = data.close\n else\n signal = (-(@contract.bars.last.pivot[:pp] - data.pivot[:pp]) <=> 0 )\n if !@raw_data.empty? && @raw_data.last[:signal] != signal\n @cum_result += (@current_price_signal - data.price_signal(signal).round(2)) * signal\n action = signal == 1 ? :buy : :sell\n @current_price_signal = data.price_signal( signal ).round(2)\n if training\n logger.info \"#{data.time.strftime(\"%X\")} #{@contract.symbol} -> would fire a #{action}-order @ #{data.close} result: #{@cum_result}\"\n else #--------- change to place to execute the orders -------\n logger.info \"#{data.time.strftime(\"%X\")} #{@contract.symbol} ->: FIRE a #{action}-order @ #{data.close} result: #{@cum_result}\"\n G.clients.first.preview contract: @contract,\n order: Limit.order( size: @default_size, action: action, price: data.close )\n end\n else\n # just print the actual signal\n logger.info \"#{data.time.strftime(\"%X\")} #{@contract.symbol} --> #{signal <0 ? \"still short\" : \"still long\"} #{data.close}\"\n end\n @raw_data.push( RawData.new data.time,\n signal,\n data.close,\n @contract.bars.last.pivot[:pp].round(2),\n data.pivot[:pp].round(2),\n @cum_result )\n # verbose output\n out = @raw_data.last\n end\n\n end",
"def stocks\n\n end",
"def get_basic_info\n yahoo_client = YahooFinance::Client.new\n @data = yahoo_client.quotes([@stock.ticker_symbol], [:open, :high, :low, :close, :last_trade_price, :change, :change_in_percent, :dividend_yield])\n respond_to do |format|\n format.json { render json: @data, status: :ok }\n format.html { @data }\n end\n url = \"https://www.quandl.com/api/v3/datasets/SF0/\" + @stock.ticker_symbol + \"_BVPS_MRY.json?api_key=rWvJtw9jPu2px-yskKZ4\"\n resp = HTTP.get(url)\n @history = JSON.parse(resp, symbolize_keys: true)\n\n end_date = Date.today\n start_date = Date.today.prev_month \n\n fred_url = \"https://api.stlouisfed.org/fred/series/observations?series_id=DGS5&api_key=d9f592689a18d841cab93825d4e060c7&file_type=json&observation_start=\" + start_date.strftime('%Y-%m-%e') + \"&observation_end=\" + end_date.strftime('%Y-%m-%e') + \"\"\n fred_resp = HTTP.get(fred_url)\n five_year_interest_rates = JSON.parse(fred_resp, symbolize_keys: true)\n interest_rate = five_year_interest_rates[\"observations\"].last[\"value\"].to_f\n\n if @history[\"dataset\"].nil?\n @derivative_fypm = \"N/A\"\n @linear_fypm = \"N/A\"\n @rate_fypm = \"N/A\"\n else\n book_values = @history[\"dataset\"][\"data\"]\n # derivative FYPM values\n v1 = book_values[3][1].to_f - book_values[4][1].to_f\n v2 = book_values[2][1].to_f - book_values[3][1].to_f\n v3 = book_values[1][1].to_f - book_values[2][1].to_f\n v4 = book_values[0][1].to_f - book_values[1][1].to_f\n @div = @data[0].dividend_yield.to_f\n price = @data[0].last_trade_price.to_f\n five_year_div_yield = ((((@div * 0.01) + 1.0) ** 5.0) - 1.0) * 100.0\n five_year_interest_rate_yield = 100 * ((((interest_rate/100) + 1) ** 5) - 1)\n # variables for derivative book value linear fit\n sigma_x = 6.0\n sigma_x_squared = 14.0\n sigma_y = v1 + v2 + v3 + v4\n sigma_xy = v2 + v3*2.0 + v4*3.0\n n = 4.0\n # derivative book value linear fit\n a = ((sigma_y*sigma_x_squared) - (sigma_x*sigma_xy))/((n*sigma_x_squared)-(sigma_x**2))\n b = ((n*sigma_xy) - (sigma_x*sigma_y))/((n*sigma_x_squared)-(sigma_x**2))\n five_year_book_value_added = (6.5*b + a)*5.0\n five_year_book_value_yield = (five_year_book_value_added/price)*100\n # derivative FYPM final calc\n @derivative_fypm = ((five_year_book_value_yield + five_year_div_yield)/five_year_interest_rate_yield)\n\n # non- derivative FYPM values\n v1 = book_values[4][1].to_f\n v2 = book_values[3][1].to_f\n v3 = book_values[2][1].to_f\n v4 = book_values[1][1].to_f\n v5 = book_values[0][1].to_f\n # variables for non-derivative book value linear fit\n sigma_x = 10.0\n sigma_x_squared = 30.0\n sigma_y = v1 + v2 + v3 + v4 + v5\n sigma_xy = v2 + v3*2.0 + v4*3.0 + v5*4.0\n n = 5.0\n # non-derivative book value linear fit\n a = ((sigma_y*sigma_x_squared) - (sigma_x*sigma_xy))/((n*sigma_x_squared)-(sigma_x**2))\n b = ((n*sigma_xy) - (sigma_x*sigma_y))/((n*sigma_x_squared)-(sigma_x**2))\n five_year_book_value_added_linear = (10.0*b + a) - v5\n five_year_book_value_added_rate = 5.0*b\n five_year_book_value_yield_linear = (five_year_book_value_added_linear/price)*100\n five_year_book_value_yield_rate = (five_year_book_value_added_rate/price)*100\n # non-derivative FYPM final calc\n @linear_fypm = ((five_year_book_value_yield_linear + five_year_div_yield)/five_year_interest_rate_yield)\n @rate_fypm = ((five_year_book_value_yield_rate + five_year_div_yield)/five_year_interest_rate_yield)\n\n # get change from previous day\n last_fypm = StockDatum.where(ticker_symbol: @stock.ticker_symbol).order(\"created_at DESC\").first\n if last_fypm.nil?\n @linear_change = nil\n @rate_change = nil\n @derivative_change = nil\n else\n @linear_change = ((@linear_fypm / last_fypm.linear_fypm ) - 1.0) * 100.0\n @rate_change = ((@rate_fypm / last_fypm.rate_fypm ) - 1) * 100\n @derivative_change = ((@derivative_fypm / last_fypm.derivative_fypm ) - 1) * 100\n end\n\n end\n end",
"def trade; end",
"def get_current_stock_price(input)\n url = \"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=#{input}&apikey=#{ENV['STOCKS_API_KEY']}\"\n response = RestClient.get(url)\n my_response = JSON.parse(response)\n if my_response[\"Error Message\"] == \"Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_DAILY.\" || my_response[\"Note\"] == \"Thank you for using Alpha Vantage! Our standard API call frequency is 5 calls per minute and 500 calls per day. Please visit https://www.alphavantage.co/premium/ if you would like to target a higher API call frequency.\"\n false\n else\n my_response[\"Time Series (Daily)\"][current_date_to_YYYYMMDD][\"1. open\"].to_f\n end\nend",
"def forecast\n deck = data.decks.first\n Statistics.forecast(deck: deck.deck)\n end",
"def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend",
"def calculate_stocks\n stocks = stocks_owned\n .map { |stock| {ticker: stock[0], shares: stock[1]} }\n .sort_by { |stock| stock[:ticker] }\n\n # url = \"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=#pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=\"\n # stocks.each { |stock| url += \"#{stock[:ticker]},\"}\n # response = JSON.parse(open(url).read)\n\n stocks.each_with_index do |stock, idx| \n response = JSON.parse(open(\"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=#{stock[:ticker]}\").read)\n\n \n stock[:price] = response[stock[:ticker]]['quote']['latestPrice']\n stock[:intraday] = response[stock[:ticker]]['chart']\n end\n\n stocks\n end",
"def get_latest_price(ticker)\n result = get_historic_stock_data(ticker, @fake_time - 2.days, @fake_time + 2.days, \"1d\")\n price_result = 0\n result.each { |point| \n # Since markets are closed on weekends and holidays, we must take the latest day the market was open\n if point.date < @fake_time \n price_result = point.average_price\n end\n }\n price_result\n end",
"def stock_details_for_list(symbol_list)\n\t\t\tsymbol_list = symbol_list.collect { |symbol| sanitize_symbol(symbol) }\n\n return [] if symbol_list.blank?\n\n\t\t\tfield_mappings = {\n\t\t\t\tname: 'n',\n\t\t\t\tsymbol: 's',\n\t\t\t\task: 'a',\n\t\t\t\task_realtime: 'b2',\n\t\t\t\tbid: 'b',\n\t\t\t\tbid_realtime: 'b3',\n\t\t\t\tdays_range: 'm',\n\t\t\t\tyear_range: 'w',\n\t\t\t\topen: 'o',\n\t\t\t\tprevious_close: 'p',\n\t\t\t\tvolume: 'v',\n\t\t\t\tdividend_yield: 'y',\n\t\t\t\tearnings_share: 'e',\n\t\t\t\tstock_exchange: 'x',\n\t\t\t\tlast_trade_time: 't1',\n\t\t\t\teps_estimate_current_year: 'e7',\n\t\t\t\teps_estimate_next_year: 'e8',\n\t\t\t\teps_estimate_next_quarter: 'e9',\n\t\t\t\tpe_ratio: 'r',\n\t\t\t\ttwo_hundred_day_moving_average: 'm4',\n\t\t\t\tfifty_day_moving_average: 'm3',\n\t\t\t\tlast_trade_date: 'd1'\n\t\t\t}\n\n\t\t\tstart_time = Time.now.to_f\n\n csv = RestClient.get \"http://download.finance.yahoo.com/d/quotes.csv?s=#{symbol_list.join(',')}&f=#{field_mappings.values.join}\"\n\n\t\t\tall_details = CSV.parse(csv).collect do |row|\n\t\t\t\tdetails = Hash[field_mappings.keys.zip(row.collect { |v| v.to_s.strip.gsub(/['\"]/, '')} )]\n\n quote = create_openstruct(details)\n\n\t\t\t\tunless quote.name == quote.symbol\n\t\t\t\t\tquote.currently_trading = (Date.strptime(quote.last_trade_date, '%m/%d/%Y') == Date.today)\n\n quote.current_price = [quote.ask_realtime, quote.ask, quote.previous_close].detect do |value|\n\t\t\t\t\t\tvalue.to_f > 0.0\n end\n\n\t\t\t\t\tquote.current_bid = quote.bid_realtime || quote.bid\n\n\t\t\t\t\tquote.buy_price = quote.current_price.to_f + Order::TRANSACTION_FEE\n\n\t\t\t\t\tquote.statements_url = \"http://investing.money.msn.com/investments/sec-filings/?symbol=#{quote.symbol}\"\n\n # calculate stock trend\n close = quote.previous_close.to_f\n\n current = quote.current_price.to_f\n\n point_change = (current - close)\n\n quote.point_change = (point_change >= 0 ? '+' : '') + point_change.round(2).to_s\n\n\t\t\t\t\tquote.percent_change = ((point_change / close)*100).round(2)\n\n quote.trend_direction = quote.percent_change >= 0 ? 'up' : 'down'\n\n\t\t\t\t\tquote\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t#Rails.logger.debug \" Yahoo (#{((Time.now.to_f-start_time)*1000.0).round} ms): #{symbol_list}\" unless Rails.env.production?\n\n return Hash[symbol_list.zip(all_details)]\n\n\t\tend",
"def build_stock_return_data\n open_values = []\n close_values = []\n\n @values.dig(:values).map do |_codes, _date, open, _high, _low, close|\n open_values.push [open]\n close_values.push [close]\n end\n\n @open = calculate_average(open_values)\n @close = calculate_average(close_values)\n @stock_return = stock_return_formula\n end",
"def get_current_stock_data(input)\n url = \"https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=#{input}&apikey=#{ENV['STOCKS_API_KEY']}\"\n response = RestClient.get(url)\n my_response = JSON.parse(response)\n if my_response[\"Error Message\"] == \"Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_DAILY.\" || my_response[\"Note\"] == \"Thank you for using Alpha Vantage! Our standard API call frequency is 5 calls per minute and 500 calls per day. Please visit https://www.alphavantage.co/premium/ if you would like to target a higher API call frequency.\"\n false\n else\n daily_stock_info = my_response[\"Time Series (Daily)\"][current_date_to_YYYYMMDD]\n end\nend",
"def weighIntrade()\n\n end",
"def update_stock_price(tckr)\n #return a float with current price\n\n #api\n url = 'https://cloud.iexapis.com/stable'\n end_point = \"/stock/#{tckr.downcase}/batch?\"\n query_string = \"types=quote&\"\n\n composite_url = \"#{url}#{end_point}#{query_string}token=#{TOKEN}\"\n\n response = Validation.validate_api(composite_url)\n # stock_valid(response)\n #url\n #endpoints\n #querystring => transform some array of companytickers into string separated by commas\n\n #parse with json\n\n json = JSON.parse(response[1])\n\n #pp json[\"quote\"]\n\n return [json[\"quote\"][\"companyName\"], json[\"quote\"][\"latestPrice\"]]\n\n\n end",
"def stock_picker(stock_prices)\n buying_price = 0\n buying_index = 0\n selling_price = 0\n max_profit = -1\n max_buy_index = 0\n max_sell_index = 0\n\n change_buy = true\n\n stock_prices.each_with_index do |price, day|\n selling_price = stock_prices[day + 1].to_i\n\n if change_buy\n buying_price = price.to_i\n buying_index = day\n end\n\n if buying_price > selling_price\n change_buy = true;\n else\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n max_sell_index = day + 1\n max_buy_index = buying_index\n end\n change_buy = false;\n end\n\n end\n\n [max_buy_index, max_sell_index]\n\nend",
"def stock_picker(prices)\n acc_profit = 0\n acc_buy_date = 0\n acc_sell_date = 0\n \n profits = prices.map.with_index do |price, index|\n remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0\n maximum = remaining_days.max # to identify the maximum number in that iteration's array\n highest_value = maximum - price # price is at index 0, so maximum minus minimum for each one will help identify the best buy/sell dates\n \n # create accumilator for index and value of highest profit\n if highest_value > acc_profit\n acc_profit = highest_value\n acc_buy_date = prices.index(price)\n acc_sell_date = prices.index(maximum)\n end\n\n end\n \n p \"Buy on day #{acc_buy_date} and sell on day #{acc_sell_date} for a profit of $#{acc_profit}.\"\n end",
"def stock_picker(stock_prices)\n\n\tstock_prices.map!{|price| price.to_i}\t#Convert array values to integers\n\n#Empty array for buy-low and sell-high differences\n\tdifference = []\n\n#Each day is considered a (low_price) and respective (high_price) is determined\n\tstock_prices.map.with_index do |price, i|\n\t\tlow_price = price\n\t\thigh_price = stock_prices[i+1..-1].max\n#The differnces array collects all high-low differences\t\t\n\t\tdifference.push(high_price.to_i - low_price.to_i)\n\tend\n\n\tday_1 = difference.index(difference.max)\t#Get day of highest difference possible\n\tday_2 = stock_prices.index(stock_prices[day_1+1..-1].max)\t#Calculate correspoinding high value\n\n\ta = [day_1]\n\tb = [day_2]\n\n\tprint a + b\nend",
"def in_stock?\n true\n end",
"def trade_value\n 0.4\n\n end",
"def trade(ticker, day)\n # this day's price\n price = @account.broker.exchange.quote(ticker, day)\n\n# if @last_purchase.key? ticker # If we've purchased this stock before, we continue with Dr. Rushton's trading rule.\n if @account.portfolio[ticker] == 0 # try to buy the given ticker\n last_hold_time = if @last_purchase[ticker][:buy_day] && @last_purchase[ticker][:sell_day]\n @last_purchase[ticker][:buy_day] - @last_purchase[ticker][:sell_day]\n else\n 0\n end\n \n # Wait for a time interval equal to gamma * HT to pass (cool-down period) OR Price < P to buy more\n if(!@last_purchase.key?(ticker) || \n price < @last_purchase[ticker][:price] || \n @last_purchase[ticker][:sell_day] - day >= @gamma * last_hold_time)\n s = @account.buy_amap(ticker, day, @amount_per_company)\n @last_purchase[ticker] = {price: price, buy_day: day}\n puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n else # try to sell our holdings of the given ticker\n # compute t, the return multiplier, given the interval between now and last purchase of the given stock (ticker)\n t = @fn_t.call(@last_purchase[ticker][:buy_day] - day)\n\n # compute alpha, given the value t, to determine the percentage gain multiplier\n alpha = @fn_alpha.call(t)\n\n puts \"t = #{t}\", \"alpha = #{alpha}\" if $DEBUG\n\n puts \"price of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date} is #{price}\" if $DEBUG\n\n if(price > (1.0 + alpha) * @last_purchase[ticker][:price])\n s = @account.sell_all(ticker, day)\n @last_purchase[ticker][:sell_day] = day\n puts \"sold #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n end\n end\n# else # We use SMA to make our initial purchase of each stock\n# # compute average over number of days\n# avg = average_price(ticker, day)\n\n # if price > avg -> price - avg = positive\n # price < avg -> price - avg = negative\n # price = avg -> price - avg = 0\n# @price_relation_to_average[\"#{ticker}#{day}\"] = price - avg\n\n # decide whether the price has just upcrossed or downcrossed the MA line\n# if(price > avg && @price_relation_to_average[\"#{ticker}#{day + 1}\"] < 0) # upcross - BUY as much as possible\n# s = @account.buy_amap(ticker, day, @amount_per_company)\n# @last_purchase[ticker] = {price: price, buy_day: day}\n# puts \"bought #{s} shares of #{ticker} on #{@account.broker.exchange.eod(ticker, day).date}\" if $DEBUG\n# end\n# end\n \n puts \"account: #{@account.to_s(day)}\" if $DEBUG\n end",
"def _naive_forecast(components, horizon)\n #\n # Computing the forecast for the naive model\n #\n return _trivial_forecast(components, horizon)\n\nend",
"def livequote(ticker)\n\tfunction = 'TIME_SERIES_INTRADAY'\n\tsymbol = ticker\n\tinterval = '1min' \n\tapikey = '4528' #provided at registration\n\turl = \"http://www.alphavantage.co/query?function=#{function}&symbol=#{symbol}&interval=#{interval}&apikey=#{apikey}\"\n\turi = URI(url)\n\tresponse = Net::HTTP.get(uri)\n\tinfo = JSON.parse(response)\n\treturn info.values[1].values[0].values[3].to_f.round(2)\nend",
"def rates_prediction\r\n final_array = []\r\n today = today_rate\r\n weekly_change = weekly_percentage_change_array\r\n\r\n first = ((weekly_change[0] / 100) * today) + today\r\n final_array << first\r\n\r\n if @time > 1\r\n i = 0\r\n while i < weekly_change[1].length\r\n rate = ((weekly_change[1][i] / 100) * final_array[i]) + final_array[i]\r\n final_array << rate\r\n i += 1\r\n end\r\n end\r\n final_array\r\n end",
"def computeBuySellToMaximizeProfit()\n currentStock = \"\"\n i = 0 # Loop counter\n while i < @days.size do # Traverse the data for each date to find price differences\n if i == @days.size - 1 # For the final week\n puts \"#{@days[i]} SELL #{currentStock}\"\n break\n end\n weeklyDifferences = [] # Stores the price differences between closing prices for all stocks in a particular week\n @data.each_with_index do |(key, value), index| # Traverse the data corresponding to current date for each key (stock)\n stockDifferences = {} # Stores the price difference between closing prices for a stock in a particular week\n stockDifferences[:stock] = key\n stockDifferences[:difference] = (value[i+1][:close].to_f - value[i][:close].to_f).round(5) # value[i+1] represents the next date for the stock data\n weeklyDifferences << stockDifferences\n end\n mostProfitableStock = getMostProfitableStock(weeklyDifferences)\n if i == 0 # For week 1\n puts \"#{@days[i]} BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock\n elsif mostProfitableStock == currentStock # If the stock already bought is more profitable\n puts \"#{@days[i]} HOLD #{mostProfitableStock}\"\n else\n puts \"#{@days[i]} SELL #{currentStock}, BUY #{mostProfitableStock}\"\n currentStock = mostProfitableStock \n end\n i = i + 1\n end\n end",
"def get_price_change_52w_l(stock)\n stock_price = get_stock_price(stock)\n week_52_low = get_52w_low(stock)\n return (stock_price - week_52_low).round(4)\nend",
"def get_value\n current_price = YahooFinance::get_quotes(YahooFinance::StandardQuote, @ticker.upcase)[@ticker.upcase].lastTrade\n current_price * @shares\n end",
"def stock_price(ticker)\r\n\tstock_price = StockQuote::Stock.quote(ticker).last_trade_price_only\r\n\t\"The price of #{ticker} is $#{stock_price}\"\r\nend",
"def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end",
"def historic_stock(year)\n\n data = query_strategy.historic_stock(year)\n\n end",
"def stock_analysis(symbol, current_info = nil)\n # Grab current price\n logger.debug \"Looking up symbol #{symbol}\\n\"\n\n # Lookup stock info if we didn't already get it in batch\n if not current_info\n if @stock_source == nil\n @stock_source = GoogleFinanceScraper.new(DebugLogger.modes[:debug])\n end\n\n current_info = @stock_source.lookup_by_symbol(symbol)\n end\n\n # Get all transactions (group by lots when available)\n tran_records = Transaction.joins(:user).where(transactions: {:symbol => symbol, :user_id => current_user.id}).order(\"date\")\n\n lots = []\n lots.append(tran_records)\n\n summary = {}\n summary[:totalRealizedDollar] = 0.00\n summary[:totalRealizedPercent] = 0.00\n summary[:totalUnrealizedDollar] = 0.00\n summary[:totalUnrealizedPercent] = 0.00\n\n # Compute the gains and losses for each \"lot\"\n lots.each do |lot|\n quantity = 0.0\n cost = 0.0\n\n lot.each do |tran|\n if (tran.action)\n if (tran.action.is_dividend? or tran.action.is_interest?)\n summary[:totalRealizedDollar] += tran.amount\n elsif (tran.action.is_sell?)\n summary[:totalRealizedDollar] += tran.amount\n quantity -= tran.quantity\n elsif (tran.action.is_buy?)\n quantity += tran.quantity\n # Buy amounts are negative\n cost += tran.amount.abs\n elsif (tran.action.is_fee?)\n cost += tran.amount.abs\n end\n end # if tran.action\n end\n summary[:totalUnrealizedDollar] = quantity * current_info[\"price\"]\n summary[:totalCost] = 0-cost\n summary[:netValue] = summary[:totalUnrealizedDollar] + summary[:totalRealizedDollar] - cost\n summary[:percent] = summary[:netValue] / cost\n end\n\n result = {}\n result[:lots] = lots\n result[:summary] = summary\n result[:symbol] = symbol\n result[:currentPrice] = current_info[\"price\"]\n result[:change_amt] = current_info[\"change_amt\"]\n\n return result\n end",
"def predict_price_after_discounts!\n m_discounts = []\n f = build_discount_items :fixed_amount\n m_discounts += f\n \n self.price_after_fixed_discounts = (self.price * self.qty).to_i + m_discounts.each {|discount| discount.price_extend }.sum(&:price_extend).to_i\n\n p = build_discount_items :percentage\n m_discounts += p\n \n self.price_after_all_discounts = (self.price * self.qty).to_i + m_discounts.each {|discount| discount.price_extend }.sum(&:price_extend).to_i\n \n if self.price_after_all_discounts < 0\n discount_amount = self.price_after_all_discounts * -1\n discount_sku = Product.find_by_name(\"Discount\").sku\n discount_attributes = {:product_sku => discount_sku, :qty => 1, \n :currency_used => \"BTC\", \n :price => discount_amount, :price_extend => discount_amount,\n :description => \"Discount to prevent line_item from less than zero condition\" }\n \n self.discounts.create(discount_attributes)\n end\n \n [self.price_after_all_discounts, m_discounts]\n end",
"def stock_quote(stocks, bulb)\n\n quotes = YahooFinance::get_standard_quotes( stocks )\n quotes.each do |symbol, qt|\n\tchange_light(bulb, qt) # call change light function\n end\n\nend",
"def stock_picker(price_arr)\n profit = 0\n trade_days = [0,0]\n price_arr.each_with_index do |buy_value, buy_day|\n price_arr.each_with_index do |sell_value, sell_day|\n if (sell_value - buy_value) > profit\n profit = (sell_value - buy_value)\n trade_days[0] = buy_day\n trade_days[1] = sell_day\n end\n end\n end\n \"buy on #{trade_days[0]} and sell on #{trade_days[1]} for a profit of #{profit}\"\nend",
"def index\n @stocks = Stock.all \n \n @stocks.each do |x|\n x.price = StockQuote::Stock.quote(x.ticker).last_trade_price_only\n x.save\n end \n end",
"def get_target\n\n\n # get the price for the last trade\n response = HTTParty.get(\"#{@@base_url}/venues/#{@venue}/stocks/#{@stock}/quote\")\n\n last = response.parsed_response[\"last\"].to_i\n\n #set the limit for the first offer as one dollar less than the last price\n limit = last - 100\n\n # Order parameters hash\n order = {\n \"account\" => @account,\n \"venue\" => @venue,\n \"symbol\" => @stock,\n \"price\" => limit,\n \"qty\" => 1,\n \"direction\" => \"buy\",\n \"orderType\" => \"limit\"\n }\n\n #make the first offer to activate the flash message in the UI\n response = HTTParty.post(\"#{@@base_url}/venues/#{@venue}/stocks/#{@stock}/orders\",\n :body => JSON.dump(order),\n :headers => {\"X-Starfighter-Authorization\" => @apikey}\n )\n\n\n # wait untill the order is closed\n id = response.parsed_response[\"id\"]\n\n status = response.parsed_response[\"open\"]\n\n while status\n\n response = HTTParty.get(\"#{@@base_url}/venues/#{@venue}/stocks/#{@stock}/orders/#{id}\",\n :headers => {\"X-Starfighter-Authorization\" => @apikey})\n\n status = response.parsed_response[\"open\"]\n\n\n end\n\n # wait a few seconds for the message in the UI to be generated\n sleep(5)\n\n # catch the treshold from the message in the UI\n response = HTTParty.get(\"https://www.stockfighter.io/gm/instances/#{@instance}\",\n :headers => {\"X-Starfighter-Authorization\" => @apikey})\n\n flash_message = response.parsed_response[\"flash\"][\"info\"]\n\n\n regex = /\\d\\d\\.\\d\\d\\.$/\n\n threshold = regex.match(flash_message).to_s.chop.to_f\n\n unless threshold\n\n puts \"There has been a problem getting the target price\"\n\n nil\n\n end\n\n puts \"Target price has been fetched\"\n\n (threshold * 100).to_i\n\n end",
"def predict_gas_change(city_id, gas_grade_id)\n change_days = -7\n oil_change_percentage = get_oil_change_percentage(Date.today, change_days)\n gas_change_percentage = get_gas_change_percentage(Date.today, change_days, city_id, gas_grade_id)\n if oil_change_percentage > gas_change_percentage\n # when oil prices go up, gas prices quickly follow\n multiplier = 1.5\n else\n # when oil prices go down, gas prices follow more slowly\n multiplier = 0.5\n end\n puts \"oil change percentage = #{oil_change_percentage}\"\n puts \"gas change percentage = #{gas_change_percentage}\"\n delta = (oil_change_percentage - gas_change_percentage) * multiplier\n gas_change_percentage_prediction = ((gas_change_percentage + delta) / change_days.to_f.abs).round(4)\n current_gas_price_obj = get_gas_price_obj(Date.today, city_id, gas_grade_id)\n if current_gas_price_obj == nil\n current_gas_price = 0.0\n else\n current_gas_price = current_gas_price_obj.gas_price\n end\n\n return gas_change_percentage_prediction, current_gas_price\n end",
"def did_stock_perform date,company_id,price\n\t\tprofit_book_price = price - price * @profit_book_percentage\n\t\tstop_loss_price = price + price * @stop_loss_percentage\n\t\tprofit_book_quote = Quote.get_worst_performer_after_interval date,company_id,profit_book_price\n\t\tstop_loss_quote = Quote.get_best_performer_after_interval date,company_id,stop_loss_price\n\n\t\treturn find_performance_by_profit_quote_and_loss_quote(profit_book_quote,stop_loss_quote)\n \tend",
"def set_finance\r\n end",
"def future_given_present(present_value, interest, term)\n (present_value.to_f * (1 + interest.to_f) ** term).round(4)\n end",
"def available_stock\n @available_stock ||= current_stock - stocks.sum('quantity')\n end",
"def stock_picker(stock_prices)\n lowest, highest = 9999999999, 0\n index_of_highest, index_of_lowest = 0\n\n stock_prices.each_with_index do |price, index|\n \n if price > highest\n highest, index_of_highest = price, index\n end\n\n end\n\n index = 0\n while index < index_of_highest\n\n if stock_prices[index] < lowest\n lowest, index_of_lowest = stock_prices[index], index\n end\n\n index += 1\n end\n \n\n\n\n puts \"You bought stock on Day #{index_of_lowest + 1}, for $#{lowest}, and sold it on Day #{index_of_highest + 1} for $#{highest}. Your profit is $#{highest - lowest}.\"\nend",
"def souvenir_trading_options(stock_code:, current_position:, current_average_price:, target_average_price:, enter_price: nil, operation_market_value: nil, min_position_delta: 100)\n position_delta = min_multiple_of(operation_market_value / enter_price, min_position_delta)\n\n new_average_price = find_new_average_price(current_position: current_position, current_average_price: current_average_price, position_delta: position_delta, operation_price: enter_price)\n\n result = [\n \"Buy #{position_delta} #{stock_code} at #{format_price(enter_price)} (#{format_price(enter_price * position_delta)}) for a new average of #{format_price(new_average_price)}\"\n ]\n\n result.concat(list_operation_target_price_options(\n current_position: current_position + position_delta,\n current_average_price: new_average_price,\n target_average_price: target_average_price,\n ).select do |operation_target_price_option|\n operation_target_price_option[:price] > (enter_price * 1.025) && operation_target_price_option[:position_delta] > - position_delta\n end.map do |operation_target_price_option|\n final_position = current_position + position_delta + operation_target_price_option[:position_delta]\n\n operation_target_price_option[:text] + \" - keep #{final_position} (#{format_price(final_position * target_average_price)})\"\n end).join \"\\n\"\nend",
"def last_years_performance\n client = YahooFinance::Client.new\n quotes = client.historical_quotes(self.stock_symbol, {period: :monthly})\n last_years_quotes = quotes.select {|quote| quote.trade_date.include?(1.year.ago.year.to_s)}\n last_years_quotes.map {|quote| quote.close.to_f * quantity}.reverse\n end",
"def stock_picker(data) \n\tday1 = 0\n\twhile day1 < data.length - 1\n\t\tday2 = day1 + 1\t\n\t\twhile day2 < data.length\n\t\t\tprofit ||= 0 #initialize profit at 0\n\t\t\tif data[day2] - data[day1] > profit\n\t\t\t\tprofit = data[day2] - data[day1] #update these variables if profit margin is larger than existing\n\t\t\t\tsellDate = day2\n\t\t\t\tbuyDate = day1\n\t\t\tend\n\t\t\tday2 += 1\n\t\tend\n\t\tday1 += 1\n\tend\n\treturn [buyDate, sellDate] \nend",
"def stock_picker(stock_prices)\n best_pick = 0\n first_index = 0\n second_index = 0\n\n stock_prices.each_with_index do |val, idx|\n current_pick = stock_prices.slice((idx + 1)..(stock_prices.length - 1))\n current_pick.each_with_index do |num, i|\n new_pick = num - val\n if new_pick > best_pick\n best_pick = new_pick\n first_index = idx\n second_index = idx + i + 1\n end\n end\n end\n p \"Best day to buy: #{first_index}. Best day to sell: #{second_index}\"\n p \"Profit: #{best_pick}\"\nend",
"def lookup_stock(name)\n return StockQuote::Stock.quote(name)\nend",
"def stock_picker(prices)\n profits_per_day = {}\n prices.each_with_index do |value, index|\n break if index == prices.length - 1\n profit = prices[index + 1] - value\n if (index + 1 == prices.length - 1)\n profits_per_day[profit] = [index, index + 1]\n break\n end\n for i in (index + 2..prices.length - 1)\n profit = prices[i] - value > profit ? prices[i] - value : profit\n end\n profits_per_day[value] = profit\n end\n return profits_per_day.max_by{|k,v| v}\nend",
"def stock_picker(stock_prices)\n\n max_profit = 0\n best_days = []\n\n stock_prices.each_with_index do |buying_price, index|\n (index+1).upto(stock_prices.length - 1) do |selling_index|\n selling_price = stock_prices[selling_index]\n profit = selling_price - buying_price\n if profit > max_profit\n max_profit = profit\n best_days = [index, selling_index]\n end\n\n end\n end\n best_days\nend",
"def stock_picker(stock_array)\n\n day_hash = Hash.new(0)\n day_index = 0\n stock_array.each { |day_number|\n day_hash[day_index] = day_number\n day_index += 1\n }\n\n day_hash_sell = day_hash.clone\n profit_best = Hash.new(0)\n profit_best_counter = nil\n day_hash.each do |key, value|\n\n buy = -value \n day_hash_sell.each do |key_sell, value_sell|\n\n #ensure day is only in futue\n if key_sell <= key then \n next\n end\n\n profit = buy + value_sell \n if profit_best_counter == nil || profit > profit_best_counter then \n #reset hash to ensure only 1 answer given\n profit_best = Hash.new(0)\n\n #track best days to buy/sell in array\n profit_best[key] = key_sell\n\n #keep track of best profit so far\n profit_best_counter = profit\n end \n end \n end\n puts profit_best\nend",
"def predict_now\n timestamp = Time.now\n day_of_week = timestamp.wday\n minute_of_day = timestamp.hour * 60 + timestamp.min\n predict(day_of_week, minute_of_day)\n end",
"def stock_picker(prices)\n #results array indicates the best time to buy and then sell the stock\n results = [0, 0]\n #this variable keeps tabs of the best positive price difference\n greatest_price_difference = 0\n prices.each_with_index do |price, current_index|\n #index_counter keeps track of the index in the array as it's being\n #looped in the while loop\n \n index_counter = current_index + 1\n #the while loop loops through the array starting with the first \n #potential day to buy and compares the potential difference\n #each day going forward to determine which day would be best to sell on\n #should they buy the stock today\n while index_counter < prices.length\n \n price_difference = prices[index_counter] - prices[current_index]\n if price_difference > greatest_price_difference\n #price difference is updated if a greater difference is found\n greatest_price_difference = price_difference\n results[0] = current_index \n results[1] = index_counter \n end\n index_counter += 1\n end\n end\n\n\n\n puts results\nend",
"def return\n \t@stock += 1\n end",
"def to_be_done()\r\n\t\t#\r\n\t\t# loss_trig_price = price - loss\r\n\t\t# loss_price = price - loss - 10\r\n\t\t# obuy \t = push_buy( \t\t quantity: quantity, price: price )\r\n\t\t# monitor_filled( obuy )\r\n\t\t# obuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\t\t#\r\n\t\t#\r\n\t\t# loss_trig_price = price + loss\r\n\t\t# loss_price = price + loss + 10\r\n\t\t# osell = push_sell( \t\t quantity: quantity, price: price)\r\n\t\t# monitor_filled( osell )\r\n\t\t# osell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\t\t#\r\n\r\n\r\n\t\t# modo mais simples primeiro\r\n\t\t# entrar a market\r\n\t\tloss_trig_price = price - loss\r\n\t\tloss_price = price - loss - 10\r\n\t\tobuy \t = push_buy( \t\t quantity: quantity, price: 0 )\r\n\t\tmonitor_filled( obuy )\r\n\t\tobuy_stp = push_buy_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price )\r\n\r\n\r\n\t\tloss_trig_price = price + loss\r\n\t\tloss_price = price + loss + 10\r\n\t\tosell = push_sell( \t\t quantity: quantity, price: 0)\r\n\t\tmonitor_filled( osell )\r\n\t\tosell_stp = push_sell_stop( quantity: quantity, loss_trig_price: loss_trig_price, loss_price: loss_price)\r\n\tend",
"def price(raw_coin, raw_date=nil)\r\n \r\n coin = raw_coin.downcase.split.map(&:capitalize).join(' ')\r\n \r\n return self.coin(coin).quote['USD']['price'].to_f if raw_date.nil?\r\n puts 'raw_date: ' + raw_date.inspect if @debug\r\n \r\n date = if raw_date.is_a? Date then\r\n raw_date.strftime(\"%Y%m%d\")\r\n else\r\n Chronic.parse(raw_date.gsub('-',' ')).strftime(\"%d%m%Y\")\r\n end\r\n puts 'date: ' + date.inspect if @debug\r\n \r\n # if date is today then return today's price\r\n \r\n if date == Date.today.strftime(\"%d%m%Y\")\r\n puts 'same day' if @debug\r\n return self.coin(coin).quote['USD']['price'].to_f \r\n end\r\n \r\n \r\n if @history_prices[coin] and @history_prices[coin][date] then\r\n @history_prices[coin][date]\r\n else\r\n begin\r\n \r\n if @debug then\r\n puts 'coin: ' + coin.inspect \r\n puts 'date: ' + date.inspect\r\n end\r\n \r\n #a = Coinmarketcap.get_historical_price(coin.gsub(/ /,'-'), date, date)\r\n #puts 'a: ' + a.inspect if @debug \r\n \r\n #r = a.any? ? a.first[:close] : self.coin(coin).quote['USD']['price'].to_f \r\n price = @cq.historical_price coin, date\r\n r = price ? price.to_f : self.coin(coin).quote['USD']['price'].to_f \r\n @history_prices[coin] ||= {}\r\n @history_prices[coin][date] = r\r\n File.write @historic_prices_file, @history_prices.to_yaml\r\n \r\n return r\r\n \r\n rescue\r\n puts ($!).inspect if @debug\r\n end\r\n end\r\n \r\n end",
"def stock_picker(prices)\r\n\tprice_to_buy = 0\r\n\tprice_to_sell = 0\r\n\tprofit = 0\r\n\r\n\tprices[0..-2].each_with_index do |buy, index_buy|\r\n\t\tprices[(index_buy + 1)..-1].each_with_index do |sell, index_sell|\r\n\t\t\tif profit < sell - buy\r\n\t\t\t\tprofit = sell - buy\r\n\t\t\t\tprice_to_buy = index_buy\r\n\t\t\t\tprice_to_sell = index_sell + (index_buy + 1)\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t[price_to_buy, price_to_sell]\r\nend",
"def stock_picker (stocks)\n result = []\n diff = 0\n\n stocks[0..-2].each do |stock|\n stocks[stocks.index(stock)..-1].each do |s|\n if (stock - s < diff)\n diff = stock - s\n result[0] = stocks.index(stock)\n result[1] = stocks.index(s)\n end\n end\n end\n return result\nend",
"def get_quarterly\n # get last year earnings\n l_year = latest_eps.year\n\n # get which quarters are the last 4\n fp = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Fiscal Period\" }\n fp = fp.xpath('./td') if fp\n\n if fp.nil?\n puts \"--------------------------------------Cannot get info for #{ticker}\"\n return false\n end\n # Find last year by counting 'td's up to \"TMM\"\n years_available = 0 # Some stocks may not have 10 years worth of data\n for i in 1..fp.size\n if fp[i].nil? || !fp[i].text.match(\"TTM\").nil?\n break\n end\n years_available = i\n end\n\n puts \"Counted #{years_available} years of available data for #{ticker}\"\n\n update_year = 1 # Some stocks may not be updated for 2012 yet\n update_year = 0 if fp[years_available].text.last == \"2\"\n\n\n\n\n #Acces data page\n url = \"http://www.gurufocus.com/financials/#{ticker}\"\n doc = open_url_or_nil(url)\n if doc.nil?\n puts \"Could not get quarterly finantial data from gurufocus.com\"\n return false\n end\n\n # Get last 4 quarters quarterly data\n # Check first if all 4 quarters are available?\n (1..4).each do |i|\n if fp[i].nil? || !fp[i].text.match(\"TTM\").nil?\n break\n end\n years_available = i\n end\n\n puts \"Counted #{years_available} years of available data for #{ticker}\"\n\n update_year = 1 # Some stocks may not be updated for 2012 yet\n update_year = 0 if fp[years_available].text.last == \"2\"\n\n # A boolean to test if current asset values are available\n using_current_data = true\n\n # Scrape data from doc\n # Current Assets\n ca = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Current Assets\" }\n if ca\n ca = ca.xpath('./td')\n else\n using_current_data = false\n end\n\n ta = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Assets\" }\n ta = ta.xpath('./td') if ta\n\n cl = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Current Liabilities\" }\n if cl\n cl = cl.xpath('./td')\n else\n using_current_data = false\n end\n\n tl = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Liabilities\" }\n tl = tl.xpath('./td') if tl\n\n # Debt, book value, net tangible assets\n ltd = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Long-Term Debt\" }\n ltd = ltd.xpath('./td') if ltd\n\n bv = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Total Equity\" }\n bv = bv.xpath('./td') if bv\n\n ocs = doc.xpath('//tr').detect{ |tr| tr.xpath('./td').first != nil && tr.xpath('./td').first['title'] == \"Other Current Assets\" }\n ocs = ocs.xpath('./td') if ocs\n\n # Create balance sheet for 10 years\n (1..years_available).each do |i|\n cas = \"\"\n cls = \"\"\n ntas = \"\"\n if using_current_data\n cas = (clean_string(ca[i].text).to_f.round * MILLION).to_s\n cls = (clean_string(cl[i].text).to_f.round * MILLION).to_s\n if ocs\n ntas = (( clean_string(ca[i].text).to_f - clean_string(ocs[i].text).to_f - clean_string(cl[i].text).to_f ).round * MILLION ).to_s\n else\n ntas = cas\n end\n end\n\n # Some trusts don't have liabilities\n tler = \"\"\n tler = (clean_string(tl[i].text).to_f.round * MILLION).to_s if tl\n der = \"\"\n der = (clean_string(ltd[i].text).to_f.round * MILLION).to_s if ltd\n bver = \"\"\n bver = (clean_string(bv[i].text).to_f.round * MILLION).to_s if bv\n bs = BalanceSheet.create(:stock_id => self.id,\n :year => YEAR - (years_available+1 - i) - update_year, #This reveses the year from i\n :current_assets => cas,\n :total_assets => (clean_string(ta[i].text).to_f.round * MILLION).to_s,\n :current_liabilities => cls,\n :total_liabilities => tler,\n :long_term_debt => der,\n :net_tangible_assets => ntas,\n :book_value => bver,\n :quarter => q)\n puts \"Got bs data for #{ticker}, year: #{bs.year}, ta = #{bs.total_assets}\" if !bs.id.nil?\n end\n\n update_attributes( :has_currant_ratio => using_current_data)\n\n end",
"def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end",
"def on_hand_stock(outstanding_orders)\n self.movie_copies.pluck(:stock).sum - outstanding_orders\n end",
"def closing_ason_stock_quantity(start_date, end_date, branch_id)\n quantity=0\n purchase_line_items = PurchaseLineItem.by_company(company_id).non_draft.by_product(id).by_record_date(start_date, end_date).by_branch(branch_id).order(\"purchases.record_date DESC\")\n purchased_quantity = purchase_line_items.sum(:quantity)\n\n stock_receipt_line_items = StockReceiptLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n receipt_quantity = stock_receipt_line_items.sum(:quantity)\n\n invoice_line_items = InvoiceLineItem.by_company(company_id).by_product(id).by_invoice_date(start_date, end_date).by_branch(branch_id)\n invoiced_quantity = invoice_line_items.sum(:quantity)\n\n stock_wastage_line_items = StockWastageLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n wastage_quantity = stock_wastage_line_items.sum(:quantity)\n\n stock_issue_line_items = StockIssueLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n issued_quantity = stock_issue_line_items.sum(:quantity)\n\n purchase_return_line_items=PurchaseReturnLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n invoice_return_line_items=InvoiceReturnLineItem.by_company(company_id).by_product(id).by_voucher_date(start_date, end_date).by_branch(branch_id)\n purchase_return_quantity=purchase_return_line_items.sum(:quantity)\n invoice_return_quantity=invoice_return_line_items.sum(:quantity)\n quantity = (receipt_quantity + purchased_quantity + invoice_return_quantity) - (invoiced_quantity + wastage_quantity + issued_quantity + purchase_return_quantity)\n end",
"def product_stock(toy)\n \"Toy Stock: #{toy.stock}\"\n end",
"def stock_picker(stocks)\n buy_day, sell_day, max_profit = 0, 0, 0\n for i in (0...stocks.length - 1)\n buy, possible_sales = stocks[i], stocks[i+1..-1]\n best_sale = possible_sales.max # Find the best price we can still sell for\n current_profit = best_sale - buy\n if current_profit > max_profit\n max_profit = current_profit # New standard we'll have to beat\n buy_day = i + 1 # If i is 0, we should buy on day 1\n sell_day = sales.index(best_sale) + buy_day + 1 # Add 1 in both cases to correct for indexing\n end\n end\n print [buy_day,sell_day]\nend",
"def lowest_stock # A refactoriser via méthode SQL, on peut faire beaucoup plus court\n # Pour chaque produit récupérer la remaining quantity\n # Vérifier si cette valeur est inférieure à un critère donné\n # Renvoyer la liste de tous les produits concernés\n @products = Product.all\n @products = @products.sort_by do |product|\n product.total_remaining_quantity\n end\n low_stock_trigger = 3 # Plancher de quantité qui trigger l'alimentation de la liste des low_stocks\n low_stock_list = Array.new\n @products.each do |product|\n if product.total_remaining_quantity < low_stock_trigger\n low_stock_list << product\n end\n end\n return low_stock_list.first # Pour l'instant on ne renvoit qu'un item pour qu'on ait une seule notif pour stock bas\n end",
"def in_stock?()\n if self.stock >0\n return true\n else\n return false\n end\n end",
"def get_ROI\n require 'yahoo_stock'\n\n stocks = []\n qtys = []\n for purchase in PurchasedStock.for_user_game(self.id)\n stocks += [purchase.stock_code]\n qtys += [purchase.total_qty]\n end\n\n values = [0] * stocks.length\n for i in (0..stocks.length-1)\n yesterday_price = (YahooStock::History.new(:stock_symbol => stocks[i], :start_date => Date.today-1, :end_date => Date.today-1)).results(:to_array).output[0][4].to_f\n values[i] = yesterday_price\n end\n\n qtys_and_values = [0] * stocks.length\n for i in (0..stocks.length-1)\n qtys_and_values[i] = [qtys[i] * values[i]]\n end\n total_value = 0\n for price in qtys_and_values\n total_value += price[0]\n end\n return (self.total_value_in_stocks-(total_value * 100))/(total_value * 100)\n end",
"def in_stock?\n \t\tif stock > 0 \n \t\t\tTRUE\n \t\telse \n \t\t\tFALSE \n \t\tend\n \tend",
"def stock_historical_data(ticker)\n ############################################################################\n # Yahoo Finance historical quotes has been deprecated\n # YahooFinance::Client.new.historical_quotes(ticker, { start_date: Date.today - days, end_date: Date.today })\n ############################################################################\n i = 0\n history = { date: [], price: [] }\n\n url = \"https://finance.yahoo.com/quote/\" + ticker + \"/history?\"\n doc = Nokogiri::HTML(open(url))\n data = doc.at('table[data-test=\"historical-prices\"]')\n\n while i < data.children[1].children.length do\n check = data.children[1].children[i].text\n\n if (!check.include?('Dividend') && !check.include?('Split'))\n \thistory[:date] << data.children[1].children[i].children[0].text\n \thistory[:price] << data.children[1].children[i].children[5].text.to_f\n end\n\n i+=1\n end\n history\n end",
"def in_stock?\n stock\n end",
"def generate_sell_signal(processed_data,back_day,sell_policy_class,date)\n \n sell_signal=true\n price_hash=processed_data[0]\n macd_hash=processed_data[1]\n low_price_hash=processed_data[2]\n high_price_hash=processed_data[3]\n volume_hash=processed_data[4]\n\n full_price_array=price_hash.to_a\n\n date=full_price_array[back_day][0]\n #puts \"first date=#{date},index=#{index}\"\n price_array=full_price_array[back_day][1]\n\n macd_array=macd_hash[date]\n low_price_array=low_price_hash[date]\n high_price_array=high_price_hash[date]\n volume_array=volume_hash[date]\n #puts \"last price =#{price_array[27]}\"\n last_date=full_price_array[back_day+1][0]\n last_price=full_price_array[back_day+1][1]\n last_macd_array=macd_hash[last_date]\n last_low_price_array=low_price_hash[last_date]\n last_high_price_array=high_price_hash[last_date]\n last_volume_array=volume_hash[last_date]\n\n price_signal = generate_price_buy_signal(price_array,sell_policy_class)\n macd_signal = generate_macd_buy_signal(macd_array,sell_policy_class,date)\n last_macd_signal = generate_last_macd_buy_signal(last_macd_array,sell_policy_class,date)\n low_price_signal = generate_low_price_buy_signal(low_price_array,price_array,sell_policy_class)\n high_price_signal = generate_high_price_buy_signal(high_price_array,price_array,sell_policy_class)\n volume_signal = generate_volume_buy_signal(volume_array,sell_policy_class)\n \n sell_signal=price_signal && macd_signal && last_macd_signal && low_price_signal && high_price_signal && volume_signal\n \n return sell_signal\nend",
"def price\n return self[:price] if market_open?\n previous_close\n end",
"def get_price_change_ytd(stock)\n stock_price = get_stock_price(stock)\n ytd_pct_change = get_pct_change_ytd(stock)\n # Calculate the price at the start of the year\n year_start_price = stock_price - (ytd_pct_change*stock_price)\n # get the price change from the start of year to date\n ytd_price_change = stock_price - year_start_price\n return ytd_price_change.round(2)\nend",
"def stock_picker(stocks)\n biggest_price = 0\n profitable_days = []\n (0...stocks.length).each do |i|\n (i + 1...stocks.length).each do |j|\n day = stocks[i][0]\n price = stocks[i][1]\n other_day = stocks[j][0]\n other_price = stocks[j][1]\n stock_price = price - other_price\n if stock_price.abs > biggest_price\n biggest_price = stock_price\n profitable_days = [day, other_day]\n end\n end\n end\n\n profitable_days\nend",
"def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end",
"def opening_stock_amount_on_date(given_date, branch_id)\n quantity=0\n purchases = purchase_line_items.joins(:purchase)\n .where(:purchases =>{:status_id => [0,1,3], :branch_id => branch_id})\n .where(\"purchases.record_date < ?\", given_date)\n .sum(:amount)\n\n #we need the below call to compute average purchase price of stock issue\n purchases_qty = purchase_line_items.joins(:purchase)\n .where(:purchases =>{:status_id => [0,1,3], :branch_id => branch_id})\n .where(\"purchases.record_date < ?\", given_date)\n .sum(:quantity)\n if purchases_qty.present? && purchases_qty != 0\n average_purchase_price = (purchases/purchases_qty)\n else\n average_purchase_price = 0\n end\n\n sold= invoice_line_items.joins(:invoice)\n .where(:invoices =>{:invoice_status_id => [0,2,3,4], :branch_id => branch_id})\n .where(\"invoices.invoice_date < ?\", given_date)\n .sum(:amount)\n issued = stock_issue_line_items.joins(:stock_issue_voucher)\n .where(:stock_issue_vouchers => {:branch_id => branch_id})\n .where(\"stock_issue_vouchers.voucher_date < ?\",given_date)\n .sum(:quantity)\n issued_amount = issued * average_purchase_price\n received= stock_receipt_line_items.select(\" sum(stock_receipt_line_items.quantity * stock_receipt_line_items.unit_rate) as amount \").joins(:stock_receipt_voucher)\n .where(:stock_receipt_vouchers =>{:branch_id => branch_id})\n .where(\"stock_receipt_vouchers.voucher_date < ?\",given_date)\n received_amount = received[0].amount.blank? ? 0 : received[0].amount\n\n transaction_amount = (purchases + received_amount)-(sold + issued_amount)\n amount = get_opening_stock_amount.to_f + transaction_amount\n end",
"def closing_stock\n closing_stock_on_date(Time.zone.now.to_date, nil)\n end",
"def stock_prices(array)\n\tlargest_difference = 0\n\tarray.each_with_index {| value, index| \n\t\tarray.each { |i|\n\t\t\tdifference = value - i\n\t\t\tif (difference <= largest_difference) && (index < array.rindex(i))\n\t\t\t\tnegative_array = [] << difference\n\t\t\t\tnegatives = [index, array.rindex(i)]\n\t\t\t\tlargest_difference = difference\n\t\t\tend\n\t\t\t}\n\t\t}\n\t\tif negative_array.nil?\n\t\t\tputs \"Buy/sell [0,1]\"\n\t\telse\n\t\t\tputs \"Buy/sell #{negatives}\"\n\t\tend\n\tend",
"def stock_picker(price_arr)\n\n profit = 0\n \n # Handles edge case of first price being a low point\n if price_arr[0] < price_arr[1]\n if price_arr.max - price_arr[0] > profit\n profit = price_arr.max - price_arr[0]\n best_range = [0, price_arr.index(price_arr.max)]\n end\n end\n \n #finds low points and their max earning potential updating the best range as it goes\n index = 1 # index is stepped up each loop to keep up with the index of the price\n price_arr[1..-2].each do |price|\n remaining_prices = price_arr[index..-1]\n if price_arr[index - 1] > price && price_arr[index + 1] > price\n if remaining_prices.max - price > profit\n profit = remaining_prices.max - price\n best_range = [price_arr.index(price), remaining_prices.index(remaining_prices.max) + index]\n end\n end\n index +=1 # index stepper\n end\n \n puts \"profit = #{profit}$\"\n best_range\n end",
"def predict\n raise NotImplementedError, \"#{__method__} has to be implemented in #{self.class}.\"\n end",
"def predict\n raise NotImplementedError, \"#{__method__} has to be implemented in #{self.class}.\"\n end",
"def normalize_stock\n self.stock = 0 if self.stock.nil?\n end",
"def market_value\n mp = self.clearing_price\n mp * self.open_volume * self.instrument_multiplier * self.instrument_currency_exchange_rate\n end",
"def extract_stock_value_on(historical_date)\n # FIXME should be set to the extracted value, not the wanted\n av = AssetValue.new(historical_date)\n search_date = Util.ensure_string(historical_date)\n search_url = construct_search_url(search_date)\n history_page = @agent.get(search_url)\n td_set = history_page.parser().xpath(\"//span[.='#{search_date}']/../../following-sibling::td\")\n raise RuntimeError, \"Could not get a stock price for the given date (#{search_date})\", caller if td_set.nil? || td_set.size != 5\n av.opening = Util.l10n_f_k(td_set[0].content().strip())\n av.closing = Util.l10n_f_k(td_set[3].content().strip())\n Rails.logger.debug(\"#{self.class}: Opening value #{av.opening}\")\n Rails.logger.debug(\"#{self.class}: Closing value #{av.closing}\")\n return av\n end",
"def update_stock\n operador = self.notas_creditos_debito.tipo == 'DevolucionCompra' ? -1 : 1\n if deleted?\n MercaderiaExtracto.eliminar_movimiento(self, self.notas_creditos_debito.fecha, cantidad * operador*-1)\n else\n MercaderiaExtracto.crear_o_actualizar_extracto(self, self.notas_creditos_debito.fecha, cantidad_was.to_f * operador, cantidad * operador)\n end\n end",
"def initialize(submitted_stock)\n @stock_ticker = submitted_stock\n \tend",
"def stock_price(ticker)\n\tstock_price = StockQuote::Stock.quote(ticker).last_trade_price_only\n\t\"The price of #{ticker} is $#{stock_price}\"\nend",
"def updatePrice()\n\t\t# ビットコインヒストリカルデータの取得\n\t\tget_btc_api()\n\n\t\t# 日経平均を中心にkabutanで取得できる国内銘柄\n\t\tarrCode = getKabutanTicker()\n # 一気に250銘柄進めようとすると負荷をかけてしまうためまずい→updated_atを見ながら当日取得していない銘柄を5銘柄ずつくらい取得する\n\t\tif !arrCode.nil?\n\t arrCode.each do |code|\n\t\t\t\tticker_without_t = code.gsub(/-T/, '').to_s\n\t getPriceKabutan(ticker_without_t)\n\t end\n\t\tend\n\n\t\t#株価指数(YahooFinanceで取得可能なもの)\n\t\tarrCode = getYahooTicker()\n\t\tif !arrCode.nil?\n\t\t\tarrCode.each_with_index do |code, i|\n\t\t\t\tp \"#{i}番目の株価取得中\"\n\t\t\t\tgetPriceYahoo(code)\n\t\t\tend\n\t\tend\n\tend",
"def trader\n\n# Rappel des methodes :\n\tsymbols_array = scrap_symbols \n\tprices_array = scrap_prices \n\ta = [] # Initialisation d'un array pour les stocker\n\n\tsymbols_array.each_with_index do |x, y|\t\n\t# -> On associe pour chaque item de symbols_array un item de prices_array\n\t\ta << {x => (prices_array)[y]} \n\t# -> On sauvegarde sous forme d'hash dans le tableau\n\tend\n\tprint a\n\treturn a \nend",
"def get_weighted_quote\n\t\t\tif @current_stock_price.nil?\n\t\t\t\tquote_array = [method(:get_ask).call, method(:get_bid).call, method(:get_low).call, method(:get_high).call, method(:get_last).call]\n\t\t\t\t@current_stock_price = quote_array.compact.reduce(:+) / quote_array.compact.count\n\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend\n\t\tend",
"def quote\n endpoint = 'https://www.alphavantage.co/'\n query = \"query?function=GLOBAL_QUOTE&symbol=#{@current_symbol}&apikey=#{@api}\"\n\n resp = JSON.parse(URI.open(\"#{endpoint}#{query}\").read)['Global Quote']\n\n if resp.nil?\n @value = Stock::NO_VALUE\n @movement = Stock::NO_CHANGE\n else\n @value = resp['05. price'].to_i\n change = resp['09. change'].to_i\n\n @movement = if change.positive?\n Stock::POS_CHANGE\n elsif change.negative?\n Stock::NEG_CHANGE\n elsif change.zero?\n Stock::NO_CHANGE\n else\n Stock::NO_CHANGE\n end\n end\n\n old_value = @cache[@current_symbol]\n @cache[@current_symbol] = \"#{@current_symbol} $#{@value} #{@movement}\"\n\n return unless @cache[@current_symbol] != old_value\n\n # TODO: DRY this up, make sure it isn't being called too much (see init_cache)\n # TODO: simple file operations like this are a good candidate for optimization/moving\n File.open(Stock::CACHE_FILENAME, 'w') do |file|\n file.write(@cache.to_json)\n end\n\n @cache[@current_symbol]\n end",
"def set_stock\n if params[:id]\n @stock = Stock.find(params[:id])\n elsif params[:ticker_symbol]\n @stock = Stock.find_by_ticker_symbol(params[:ticker_symbol])\n end\n @stock.update_price if @stock and Time.now - @stock.updated_at > 1.minute \n end",
"def price\n closing_price = StockQuote::Stock.quote(ticker).close\n return \"#{closing_price} (Closing)\" if closing_price\n \n opening_price = StockQuote::Stock.quote(ticker).open\n return \"#{opening_price} (Opening)\" if opening_price\n 'Unavailable' #retrun unavailable to neither closing price or opending price is available\n end",
"def get_price_change_52w_h(stock)\n stock_price = get_stock_price(stock)\n week_52_high = get_52w_high(stock)\n return (stock_price - week_52_high).round(4)\nend",
"def initialize(\n float: VendingMachine::Float.new,\n stock: []\n )\n @float = float\n @stock = stock \n end",
"def stock_picker(prices, best_profit = -(2**(0.size * 8 -2)) )\t\n\tabs_max_sell = prices[1..-1].max\n\n\tmin_buy = prices[0..-2].min\n\tmin_buy_index = prices.index(min_buy)\n\n\tmax_sell = prices[(min_buy_index+1)..-1].max\n\tmax_sell_index = (min_buy_index + 1) + prices[(min_buy_index+1)..-1].index(max_sell)\n\n\tprofit = max_sell - min_buy\n\t\n\tif (profit > best_profit)\n\t\tbest_profit = profit\n\tend\n\tif (max_sell == abs_max_sell || prices[0..(min_buy_index-1)].length == 1)\n\t\tputs \"Best profit is #{best_profit}, buying on day #{min_buy_index} and selling on day #{max_sell_index}\"\n\telse\n\t\tprices = prices[0..(min_buy_index-1)]\n\t\tstock_picker(prices, best_profit)\n\tend\nend",
"def get_value\n portfolio_value = 0\n @stocks.each do |stock|\n portfolio_value += stock.get_value\n end\n portfolio_value\n end",
"def stock_picker(stock_arr)\n highest_profit = 0 \n best_day_to_buy = 0 \n best_day_to_sell = 0 \n\n # Return 0- 9 but due to \"...\" it means it will exclude running the last number \n for i in 0...stock_arr.length \n #I am using a nested array so I can keep track of one number and use the other to iterate \n # Ex. [0, 1-8],[1, 2-8], [2, 3-8], .. [8, 8-8] and so on \n #I am doing this so I can use the i index postion to keep track of each day \n # Then I will use the second for loop to iterate through the stock_arr again and compare and calculate\n # those value to what I have in i(the tracked day) \n # I keep the calculation in profit_calculating until I find the profit_calculating becomes a number with the highest_profit \n for j in i+1...stock_arr.length do \n profit_calculating = stock_arr[j] - stock_arr[i]\n if highest_profit < profit_calculating\n highest_profit = profit_calculating\n best_day_to_buy = i \n best_day_to_sell = j \n end\n end \n end\n return \"[#{best_day_to_buy}, #{best_day_to_sell}] with a profit of #{highest_profit}\"\n\nend",
"def stock_in_hand(company, current_financial_year, as_on, branch_id)\n total_valuation=0\n if as_on.blank?\n total_valuation=Product.closing_balance(company, current_financial_year, branch_id)\n else\n as_on=as_on.to_date\n if as_on<current_financial_year.start_date\n previous_financial_year=current_financial_year.get_previous_year\n if previous_financial_year.blank?\n return total_valuation=0\n else\n total_valuation=Product.stock_in_hand(company, previous_financial_year, as_on, branch_id)\n end\n else\n # total_valuation=Product.opening_balance(company, current_financial_year, branch_id)\n total_valuation+=Product.current_year_transactions(company, current_financial_year, as_on, branch_id)\n end\n end\n total_valuation\n end",
"def stock_picker(arr)\n\thighestGain = 0\n\tbuyDay = 0\n\tsellDay = 0\n\n\tarr.each_index do |i|\n\t\tbiggestGainDayFrom = findDayWithHighestGainFrom(i, arr)\n\t\tif arr[biggestGainDayFrom] - arr[i] > highestGain\n\t\t\thighestGain = arr[biggestGainDayFrom] - arr[i]\n\t\t\tbuyDay = i\n\t\t\tsellDay = biggestGainDayFrom\n\t\tend\n\tend\n\treturn [buyDay,sellDay]\nend"
] | [
"0.67755294",
"0.63820624",
"0.6118608",
"0.6052072",
"0.6012018",
"0.5974223",
"0.59681636",
"0.5949421",
"0.59275514",
"0.5904586",
"0.58935654",
"0.5853072",
"0.5835974",
"0.5811444",
"0.5807802",
"0.5776646",
"0.57609785",
"0.57280576",
"0.5714926",
"0.5696709",
"0.56867087",
"0.56763756",
"0.5672767",
"0.567066",
"0.56646097",
"0.5662103",
"0.56495637",
"0.5646659",
"0.5646347",
"0.56416184",
"0.5634285",
"0.56334937",
"0.563299",
"0.5625741",
"0.56191343",
"0.56174904",
"0.56143844",
"0.5607269",
"0.5596712",
"0.5590825",
"0.5590812",
"0.5581935",
"0.5551469",
"0.5548078",
"0.5542372",
"0.552784",
"0.5524927",
"0.5521515",
"0.5502746",
"0.5500207",
"0.54936856",
"0.54917973",
"0.54913014",
"0.5490378",
"0.54882383",
"0.54880947",
"0.5487225",
"0.548201",
"0.547881",
"0.54731345",
"0.5471416",
"0.5469768",
"0.5467728",
"0.5461587",
"0.5461341",
"0.5455729",
"0.5454764",
"0.54540503",
"0.54476464",
"0.5447538",
"0.54474324",
"0.5444204",
"0.54409796",
"0.54380894",
"0.54379976",
"0.543103",
"0.5420391",
"0.5406141",
"0.54021406",
"0.5398376",
"0.53949726",
"0.53949726",
"0.53949213",
"0.5393777",
"0.5392683",
"0.53917176",
"0.5389347",
"0.53872144",
"0.5385055",
"0.53838044",
"0.53824955",
"0.53817374",
"0.53797734",
"0.536852",
"0.5367209",
"0.53667444",
"0.53653795",
"0.5365122",
"0.5361995",
"0.53619164",
"0.5360652"
] | 0.0 | -1 |
=begin Questionnaire responses: a1walk_overall a21walk_pct_unaided a22walk_pct_unilateral a23walk_pct_bilateral a24walk_pct_wheelchair b1visual_double b2swallowing b3vertigo b4hearing balbalance c1mood f1metavar_strength f1astrength_right_arm f1bstrength_left_arm f1cstrength_right_leg f1dstrength_left_leg f1flface_left f1frface_right f2metavar_coord f2acoord_right_arm f2bcoord_left_arm f2ccoord_right_leg f2dcoord_left_leg f2sspeaking f4metavar_sense f4asense_right_arm f4bsense_left_arm f4csense_right_leg f4dsense_left_leg f4flsense_face_left f4frsense_face_right f5tmetavar_bowelbladder f5tabowel f5tbbladder f6avisual_right f6bvisual_left f6tmetavar_visual f7tcog_overall f8metavar_spasm f8aspasm_right_arm f8bspasm_left_arm f8cspasm_right_leg f8dspasm_left_leg FSfuncional_overall Algorithm: sfs f1f < f1fl, f1fr f1u = f1a + f1b f1l = f1c + f1d f2u = f2a + f2b f2l = f2c + f2d f1h = (f1a + f1c f1b f1d ) / 2 f2h = (f2a + f2c f2b f2d ) / 2 f4f < f14r, f4fr, f4fl f14r DOES NOT EXIST!!!!!!!!!!!!!!!!!!!!!! f4u = f4a + f4d f4l = f4c + f4d f4h = (f4a + f4c f4b f4d ) / 2 =end | def initialize(redcap_data)
# Everything is pretty self-explainatory. You're essentially creating the 'data' hash to prepare for a data download of all individuals
@data_set = []
redcap_data.each do |participant|
sfs = calculate_sfs(participant)
edss = calculate_edss(participant, sfs)
aI = calculate_AI(participant)
nrs = calculate_nrs(participant, sfs)
mds = calculate_mds(edss, nrs, aI, participant["fs"].to_i, sfs)
data = {
record_id: participant["record_id"].to_i,
first_name: participant["first_name"],
last_name: participant["last_name"],
sfs: sfs[:sfs],
edss: edss,
aI: aI,
nrs: nrs,
mds: mds,
f1: sfs[:f1],
f2: sfs[:f2],
f3: sfs[:f3],
f4:sfs[:f4],
f5: sfs[:f5],
f6: sfs[:f6],
f7: sfs[:f7],
f8: sfs[:f8],
a1: participant["a1"],
a21: participant["a21"],
a22: participant["a22"],
a23: participant["a23"],
a24: participant["a24"],
f2a: participant["f2a"],
f2b: participant["f2b"],
f2c: participant["f2c"],
f2d: participant["f2d"],
bal: participant["bal"],
b3: participant["b3"],
f1fr: participant["f1fr"],
f1fl: participant["f1fl"],
f4fr: participant["f4fr"],
frfl: participant["frfl"],
b1: participant["b1"],
f2s: participant["f2s"],
b2: participant["b2"],
b4: participant["b4"],
f4a: participant["f4a"],
f4b: participant["f4b"],
f4c: participant["f4c"],
f4d: participant["f4d"],
f5ta: participant["f5ta"],
f6a: participant["f6a"],
f6b: participant["f6b"],
f7t: participant["f7t"],
c1: participant["c1"],
f1a: participant["f1a"],
f1b: participant["f1b"],
f1c: participant["f1c"],
f1d: participant["f1d"],
f8a: participant["f8a"],
f8b: participant["f8b"],
f8c: participant["f8c"],
f8d: participant["f8d"]
}
@data_set<< data
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_metareview_metrics(review, submission, rubricqns_array)\n preprocess = TextPreprocessing.new\n feature_values = Hash.new #contains the values for each of the metareview features calculated\n preprocess = TextPreprocessing.new\n\n #fetch the review data as an array \n @review_array = review \n \n # puts \"self.responses #{self.responses}\"\n speller = FFI::Aspell::Speller.new('en_US')\n # speller.suggestion_mode = Aspell::NORMAL\n @review_array = preprocess.check_correct_spellings(@review_array, speller)\n\n #checking for plagiarism by comparing with question and responses\n plag_instance = PlagiarismChecker.new\n result_comparison = plag_instance.compare_reviews_with_questions_responses(@review_array, rubricqns_array)\n\n if(result_comparison == ALL_RESPONSES_PLAGIARISED)\n content_summative = 0\n content_problem = 0 \n content_advisory = 0\n relevance = 0\n quantity = 0\n tone_positive = 0\n tone_negative = 0\n tone_neutral = 0\n plagiarism = true\n # puts \"All responses are copied!!\"\n feature_values[\"plagiarism\"] = plagiarism\n feature_values[\"relevance\"] = relevance\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n feature_values[\"coverage\"] = coverage\n feature_values[\"tone_positive\"] = tone_positive\n feature_values[\"tone_negative\"] = tone_negative\n feature_values[\"tone_neutral\"] = tone_neutral\n feature_values[\"volume\"] = quantity\n #Even if a review is plagiarised, we are still required to find other metrics for experiment.\n #return feature_values\n elsif(result_comparison == SOME_RESPONSES_PLAGIARISED)\n plagiarism = true\n end\n\n #checking plagiarism (by comparing responses with search results from google), we look for quoted text, exact copies i.e.\n\n #enable this check later-to_do\n #\n #google_plagiarised = plag_instance.google_search_response(self)\n\n #if(google_plagiarised == true)\n # plagiarism = true\n #else\n # plagiarism = false\n #end\n\n if(@review_array.length > 0)\n\n #formatting the review responses, segmenting them at punctuations\n review_text = preprocess.segment_text(0, @review_array)\n #removing quoted text from reviews\n review_text = preprocess.remove_text_within_quotes(review_text) #review_text is an array\n puts \"review_text #{review_text}\"\n #fetching submission data as an array and segmenting them at punctuations \n submissions = submission\n subm_text = preprocess.check_correct_spellings(submissions, speller)\n subm_text = preprocess.segment_text(0, subm_text)\n subm_text = preprocess.remove_text_within_quotes(subm_text)\n puts \"subm_text #{subm_text}\"\n # #initializing the pos tagger and nlp tagger/semantic parser \n pos_tagger = EngTagger.new\n core_NLP_tagger = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)\n \n #--------- \n #relevance\n beginning_time = Time.now\n relev = DegreeOfRelevance.new\n relevance = relev.get_relevance(review_text, subm_text, 1, pos_tagger, core_NLP_tagger, speller) #1 indicates the number of reviews\n #assigninging the graph generated for the review to the class variable, in order to reuse it for content classification\n review_graph = relev.review\n #calculating end time\n end_time = Time.now\n relevance_time = end_time - beginning_time\n #--------- \n # checking for plagiarism\n if(plagiarism != true) #if plagiarism hasn't already been set\n beginning_time = Time.now\n result = plag_instance.check_for_plagiarism(review_text, subm_text)\n if(result == true)\n plagiarism = \"TRUE\"\n else\n plagiarism = \"FALSE\"\n end\n end_time = Time.now\n plagiarism_time = end_time - beginning_time\n puts \"************* plagiarism time taken - #{plagiarism_time}\"\n end\n #--------- \n #content\n beginning_time = Time.now\n content_instance = PredictClass.new\n pattern_files_array = [\"app/data/patterns-assess.csv\",\"app/data/patterns-prob-detect.csv\",\"app/data/patterns-suggest.csv\"]\n #predcting class - last parameter is the number of classes\n content_probs = content_instance.predict_classes(pos_tagger, core_NLP_tagger, review_text, review_graph, pattern_files_array, pattern_files_array.length)\n content = \"SUMMATIVE - #{(content_probs[0] * 10000).round.to_f/10000}, PROBLEM - #{(content_probs[1] * 10000).round.to_f/10000}, SUGGESTION - #{(content_probs[2] * 10000).round.to_f/10000}\"\n end_time = Time.now\n content_time = end_time - beginning_time\n content_summative = content_probs[0]# * 10000).round.to_f/10000\n content_problem = content_probs[1] #* 10000).round.to_f/10000\n content_advisory = content_probs[2] #* 10000).round.to_f/10000\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n return feature_values\n puts \"************* content time taken - #{content_time}\"\n# puts \"*************\"\n #--------- \n #coverage\n cover = ReviewCoverage.new\n coverage = cover.calculate_coverage(subm_text, review_text, pos_tagger, core_NLP_tagger, speller)\n# puts \"************* coverage - #{coverage}\"\n# puts \"*************\"\n #--------- \n # tone\n beginning_time = Time.now\n ton = Tone.new\n tone_array = Array.new\n tone_array = ton.identify_tone(pos_tagger, speller, core_NLP_tagger, review_text, review_graph)\n tone_positive = tone_array[0]#* 10000).round.to_f/10000\n tone_negative = tone_array[1]#* 10000).round.to_f/10000\n tone_neutral = tone_array[2]#* 10000).round.to_f/10000\n #tone = \"POSITIVE - #{(tone_array[0]* 10000).round.to_f/10000}, NEGATIVE - #{(tone_array[1]* 10000).round.to_f/10000}, NEUTRAL - #{(tone_array[2]* 10000).round.to_f/10000}\"\n end_time = Time.now\n tone_time = end_time - beginning_time\n puts \"************* tone time taken - #{tone_time}\"\n# puts \"*************\"\n # #---------\n # quantity\n beginning_time = Time.now\n quant = TextQuantity.new\n quantity = quant.number_of_unique_tokens(review_text)\n end_time = Time.now\n quantity_time = end_time - beginning_time \n puts \"************* quantity time taken - #{quantity_time}\"\n \n feature_values[\"plagiarism\"] = plagiarism\n feature_values[\"relevance\"] = relevance\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n feature_values[\"coverage\"] = coverage\n feature_values[\"tone_positive\"] = tone_positive\n feature_values[\"tone_negative\"] = tone_negative\n feature_values[\"tone_neutral\"] = tone_neutral\n feature_values[\"volume\"] = quantity\n return feature_values\n end\n end",
"def calculate_metareview_metrics(review, submission, rubricqns_array)\n \n feature_values = Hash.new #contains the values for each of the metareview features calculated\n # puts \"inside perform_metareviews!!\" \n preprocess = TextPreprocessing.new\n # puts \"map_id #{map_id}\"\n #fetch the review data as an array \n @review_array = review \n \n # puts \"self.responses #{self.responses}\"\n speller = FFI::Aspell::Speller.new('en_US')\n # speller.suggestion_mode = Aspell::NORMAL\n @review_array = preprocess.check_correct_spellings(@review_array, speller)\n# puts \"printing review_array\"\n# @review_array.each{\n# |rev|\n# puts rev\n# }\n \n #checking for plagiarism by comparing with question and responses\n plag_instance = PlagiarismChecker.new\n result_comparison = plag_instance.compare_reviews_with_questions_responses(@review_array, rubricqns_array)\n # puts \"review_array.length #{@review_array.length}\"\n \n if(result_comparison == ALL_RESPONSES_PLAGIARISED)\n content_summative = 0\n content_problem = 0 \n content_advisory = 0\n relevance = 0\n quantity = 0\n tone_positive = 0\n tone_negative = 0\n tone_neutral = 0\n plagiarism = true\n # puts \"All responses are copied!!\"\n feature_valuee[\"plagiarism\"] = plagiarism\n feature_valuee[\"relevance\"] = relevance\n feature_valuee[\"content_summative\"] = content_summative\n feature_valuee[\"content_problem\"] = content_problem\n feature_valuee[\"content_advisory\"] = content_advisory\n feature_valuee[\"coverage\"] = coverage\n feature_valuee[\"tone_positive\"] = tone_positive\n feature_valuee[\"tone_negative\"] = tone_negative\n feature_valuee[\"tone_neutral\"] = tone_neutral\n feature_valuee[\"quantity\"] = quantity\n return feature_valuee\n \n return\n elsif(result_comparison == SOME_RESPONSES_PLAGIARISED)\n plagiarism = true\n end\n \n #checking plagiarism (by comparing responses with search results from google), we look for quoted text, exact copies i.e.\n google_plagiarised = plag_instance.google_search_response(self)\n if(google_plagiarised == true)\n plagiarism = true\n else\n plagiarism = false\n end\n #puts \"No plagiarism\"\n \n # puts \"length of review array after google check - #{@review_array.length}\"\n if(@review_array.length > 0)\n #formatting the review responses, segmenting them at punctuations\n review_text = preprocess.segment_text(0, @review_array)\n #removing quoted text from reviews\n review_text = preprocess.remove_text_within_quotes(review_text) #review_text is an array\n puts \"review_text #{review_text}\"\n #fetching submission data as an array and segmenting them at punctuations \n submissions = submission\n subm_text = preprocess.check_correct_spellings(submissions, speller)\n subm_text = preprocess.segment_text(0, subm_text)\n subm_text = preprocess.remove_text_within_quotes(subm_text)\n puts \"subm_text #{subm_text}\"\n # #initializing the pos tagger and nlp tagger/semantic parser \n pos_tagger = EngTagger.new\n core_NLP_tagger = StanfordCoreNLP.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref)\n \n #--------- \n #relevance\n beginning_time = Time.now\n relev = DegreeOfRelevance.new\n relevance = relev.get_relevance(review_text, subm_text, 1, pos_tagger, core_NLP_tagger, speller) #1 indicates the number of reviews\n #assigninging the graph generated for the review to the class variable, in order to reuse it for content classification\n review_graph = relev.review\n #calculating end time\n end_time = Time.now\n relevance_time = end_time - beginning_time\n# puts \"************* relevance - #{relevance}\" \n# puts \"************* relevance_time - #{relevance_time}\" \n #--------- \n # checking for plagiarism\n if(plagiarism != true) #if plagiarism hasn't already been set\n beginning_time = Time.now\n result = plag_instance.check_for_plagiarism(review_text, subm_text)\n if(result == true)\n plagiarism = \"TRUE\"\n else\n plagiarism = \"FALSE\"\n end\n end_time = Time.now\n plagiarism_time = end_time - beginning_time\n puts \"************* plagiarism time taken - #{plagiarism_time}\"\n end\n #--------- \n #content\n beginning_time = Time.now\n content_instance = PredictClass.new\n pattern_files_array = [\"data/patterns-assess.csv\",\n \"data/patterns-prob-detect.csv\",\n \"data/patterns-suggest.csv\"]\n #predcting class - last parameter is the number of classes\n content_probs = content_instance.predict_classes(pos_tagger, core_NLP_tagger, review_text, review_graph, pattern_files_array, pattern_files_array.length)\n content = \"SUMMATIVE - #{(content_probs[0] * 10000).round.to_f/10000}, PROBLEM - #{(content_probs[1] * 10000).round.to_f/10000}, SUGGESTION - #{(content_probs[2] * 10000).round.to_f/10000}\"\n end_time = Time.now\n content_time = end_time - beginning_time\n content_summative = content_probs[0]# * 10000).round.to_f/10000\n content_problem = content_probs[1] #* 10000).round.to_f/10000\n content_advisory = content_probs[2] #* 10000).round.to_f/10000\n puts \"************* content time taken - #{content_time}\"\n# puts \"*************\"\n #--------- \n #coverage\n cover = ReviewCoverage.new\n coverage = cover.calculate_coverage(subm_text, review_text, pos_tagger, core_NLP_tagger, speller)\n# puts \"************* coverage - #{coverage}\"\n# puts \"*************\"\n #--------- \n # tone\n beginning_time = Time.now\n ton = Tone.new\n tone_array = Array.new\n tone_array = ton.identify_tone(pos_tagger, speller, core_NLP_tagger, review_text, review_graph)\n tone_positive = tone_array[0]#* 10000).round.to_f/10000\n tone_negative = tone_array[1]#* 10000).round.to_f/10000\n tone_neutral = tone_array[2]#* 10000).round.to_f/10000\n #tone = \"POSITIVE - #{(tone_array[0]* 10000).round.to_f/10000}, NEGATIVE - #{(tone_array[1]* 10000).round.to_f/10000}, NEUTRAL - #{(tone_array[2]* 10000).round.to_f/10000}\"\n end_time = Time.now\n tone_time = end_time - beginning_time\n puts \"************* tone time taken - #{tone_time}\"\n# puts \"*************\"\n # #---------\n # quantity\n beginning_time = Time.now\n quant = TextQuantity.new\n quantity = quant.number_of_unique_tokens(review_text)\n end_time = Time.now\n quantity_time = end_time - beginning_time \n puts \"************* quantity time taken - #{quantity_time}\"\n \n feature_values[\"plagiarism\"] = plagiarism\n feature_values[\"relevance\"] = relevance\n feature_values[\"content_summative\"] = content_summative\n feature_values[\"content_problem\"] = content_problem\n feature_values[\"content_advisory\"] = content_advisory\n feature_values[\"coverage\"] = coverage\n feature_values[\"tone_positive\"] = tone_positive\n feature_values[\"tone_negative\"] = tone_negative\n feature_values[\"tone_neutral\"] = tone_neutral\n feature_values[\"quantity\"] = quantity\n return feature_values\n end\n end",
"def main\n puts \"pos\\ttitv\\tqual\\tratio\\tref1\\tref2\\talt1\\talt2\\tsb\\tqb\\tmb\\ttb\"\n\n while line = ARGF.gets do\n next if line.match(/^#/)\n cols = line.split(/\\s+/)\n chr, pos , ref, alt, qual, info = cols[0], cols[1].to_i, cols[3], cols[4], cols[5].to_f, cols[7]\n\n ti = judgeTiTv(ref, alt)\n ref1, ref2, alt1, alt2 = 0, 0, 0, 0\n sb , qb, mb, tb = 0.0, 0.0, 0.0, 0.0\n ratio = 0\n\n info.split(';').each do |f|\n if f=~ /DP4\\=(\\d+)\\,(\\d+)\\,(\\d+),(\\d+)/\n ref1, ref2, alt1, alt2 = $1.to_i, $2.to_i, $3.to_i, $4.to_i\n ratio = (alt1 + alt2).to_f / (ref1 + ref2 + alt1 + alt2)\n elsif f=~ /PV4\\=(\\S+)\\,(\\S+),(\\S+),(\\S+)/\n sb , qb, mb, tb = $1.to_f, $2.to_f, $3.to_f, $4.to_f\n end\n end\n\n if sb < 1e-300 \n sb = 1e-300 \n end\n \n if qb < 1e-300\n qb = 1e-300\n end\n \n if mb < 1e-300\n mb = 1e-300\n end\n\n if tb < 1e-300\n tb = 1e-300\n end\n\n puts \"#{pos}\\t#{ti}\\t#{qual}\\t#{ratio}\\t#{ref1}\\t#{ref2}\\t#{alt1}\\t#{alt2}\\t#{sb}\\t#{qb}\\t#{mb}\\t#{tb}\"\n \n end\nend",
"def match_percentage incorrect, possible\n #Creates character arrays for both words\n incorrect_array = incorrect.split(\"\")\n possible_array = possible.split(\"\")\n\n #Hashes to hold count of each char\n incorrect_hash = Hash.new(0)\n possible_hash = Hash.new(0)\n\n #Counts the characters in each word\n incorrect_array.each do |char|\n incorrect_hash[char] += 1\n end\n possible_array.each do |char|\n possible_hash[char] += 1\n end\n \n ##Compares the two hashes and returns similarity as a decimal\n #The overall percentage and total characters, used to calculate final percentage\n overall_percentage = 0.to_f\n total_chars = [incorrect_hash.keys.length, possible_hash.keys.length].max\n #Iterates over the hash for the possible correction\n possible_hash.each do |chars|\n #Sets char to the actual character\n char = chars[0]\n #Sets value_possible to count in possible hash\n value_possible = chars[1]\n #Sets value_incorrect to count in incorrect hash\n value_incorrect = incorrect_hash[char]\n\n #If neither value is zero calcluates similarity and adds to overall_percentage, otherwise its 0\n if value_possible != 0 && value_incorrect != 0\n min = [value_possible, value_incorrect].min\n max = [value_possible, value_incorrect].max\n overall_percentage += (min.to_f / max.to_f)\n end\n end\n #Calculates similarity percentage and returns\n overall_percentage /= total_chars\n\n return overall_percentage * $lexicon[possible[0]][possible.length][possible]\nend",
"def get_explanations(knowledge, sorted_affinities)\n hash_dimension2answers = answers.group_by do |answer|\n answer.has_opinion? ? answer.question(knowledge).dimension : :no_opinion\n end\n\n explanations = {}\n hash_question_idurl2min_max_weight = {}\n answers.each do |answer|\n question = answer.question(knowledge)\n hash_pidurl2weight = question.delta_weight(answer)\n hash_pidurl2weight = hash_pidurl2weight * question.weight\n min_weight, max_weight = hash_pidurl2weight.min_max\n hash_question_idurl2min_max_weight[answer.question_idurl] = [min_weight, max_weight]\n ab = (min_weight == max_weight) ? nil : Root.rule3_ab(min_weight, max_weight)\n sorted_affinities.each do |affinity|\n product_idurl = affinity.product_idurl\n weight = hash_pidurl2weight[product_idurl]\n explanations[product_idurl] ||= {}\n explanations[product_idurl][answer.question_idurl] = { :sum => weight, :percentage => (ab ? Root.rule3_cache(weight, ab) : 1.0) }\n end\n end\n\n # compute the sum per dimension\n hash_dimension2answers.each do |dimension, answers_4_dimension|\n puts \"answers_4_dimension=#{answers_4_dimension.class}\"\n sum_weight_questions = answers_4_dimension.inject(0.0) { |s, answer| s += answer.question(knowledge).weight }\n explanations.each do |product_idurl, explanation|\n sum_weight = 0.0\n sum_percentage = 0.0\n sum_weight_questions = 0.0\n answers_4_dimension.each do |answer|\n question_weight = answer.question(knowledge).weight\n sum_weight += explanation[answer.question_idurl][:sum]\n sum_percentage += (explanation[answer.question_idurl][:percentage] * question_weight)\n sum_weight_questions += question_weight\n end\n explanation[\"dimension_#{dimension}\"] = {:sum => sum_weight, :percentage => sum_percentage / sum_weight_questions }\n end\n end\n\n # compute the total sum\n sum_weight_questions = answers.inject(0.0) { |s, answer| s += answer.question(knowledge).weight }\n explanations.each do |product_idurl, explanation|\n sum_weight = answers.inject(0.0) { |s, answer| s += explanation[answer.question_idurl][:sum] }\n sum_percentage = answers.inject(0.0) { |s, answer| s += (explanation[answer.question_idurl][:percentage] * answer.question(knowledge).weight) }\n\n explanation[\"aggregated_dimensions\"] = {:sum => sum_weight, :percentage => sum_percentage / sum_weight_questions }\n end\n\n [explanations, hash_dimension2answers, hash_question_idurl2min_max_weight]\n end",
"def evaluate_answer(answer)\n question = answer.question.actable\n answer_text_array = answer.normalized_answer_text.downcase.gsub(/([^a-z ])/, ' ').split(' ')\n answer_text_lemma_array = []\n answer_text_array.each { |a| answer_text_lemma_array.push(WordNet::Synset.morphy_all(a).first || a) }\n\n hash_lifted_word_points = hash_compre_lifted_word(question)\n hash_keyword_solutions = hash_compre_keyword(question)\n\n lifted_word_status = find_compre_lifted_word_in_answer(answer_text_lemma_array, hash_lifted_word_points)\n keyword_status = find_compre_keyword_in_answer(answer_text_lemma_array, lifted_word_status, hash_keyword_solutions)\n\n answer_text_lemma_status = {\n 'compre_lifted_word': lifted_word_status,\n 'compre_keyword': keyword_status\n }\n\n answer_grade = grade_for(question, answer_text_lemma_status)\n\n [\n correctness_for(question, answer_grade),\n answer_grade,\n explanations_for(question, answer_grade, answer_text_array, answer_text_lemma_status)\n ]\n end",
"def identify(verse_string)\n # 1. Get basic information about input\n v_syllables = syllables(verse_string)\n v_weight = syllables_weights(v_syllables)\n\n # 2. Discover possible meter candidates\n # Should return list of meters with relevant information for generating correction if appropriate.\n # (Including size of match, etc.)\n m = analyze_syllables(v_syllables)\n\n # 3. Explain meter candidates\n\n # 3.1 Exact match => Show meter name, information, split input according to match (if possible).\n\n # 3.2 Fuzzy match => Generate possible corrections between input and candidates\n\n # 4. Output object containing input data, result status, and candidate meters\n # (with corrections if appropriate). No un-necessary results.\n\n meter_candidates = m[:meters]\n v_padas = []\n m_hsh = metercount\n\n if meter_candidates == {}\n m[:status] = \"Verse highly defective , Can't find neter\"\n v_meters = {}\n correct = []\n\n elsif m[:status] == \"exact match\"\n meter = meter_candidates.keys.first\n\n len = m_hsh[meter]\n v_padas << m[:syllables].slice!(0, len[0]).join(\"\")\n v_padas << m[:syllables].slice!(0, len[1]).join(\"\")\n v_padas << m[:syllables].slice!(0, len[2]).join(\"\")\n v_padas << m[:syllables].slice!(0, len[3]).join(\"\")\n\n defect_percentage = nil\n correct = []\n else\n d = 100.0\n pattern = []\n meter_candidates.each do |(key, val)|\n next unless val[0][:edit_distance].to_i < d # multiple verses with same edit distance???\n d = val[0][:edit_distance]\n meter = key\n pattern = val[0][:pattern].split(\"\")\n end\n\n defect_percentage = Rational(d, meter_candidates[meter][0][:pattern].length)\n n = fuzzy_correction(m[:weights], meter, pattern, m[:syllables])\n correct = n[:correct_weights]\n v_padas = n[:correct_padas]\n end\n\n v_corrections = {\n weights: correct.join(\"\"),\n padas: v_padas,\n }\n\n v_meters = {\n name: meter,\n size: \"full/half/pada\",\n defectiveness: defect_percentage,\n corrections: [v_corrections],\n }\n\n result = {\n verse: verse_string,\n syllables: v_syllables,\n weights: v_weight,\n status: m[:status],\n meter: [v_meters],\n }\n\n if result[:status] == \"exact match\"\n result[:meter] = v_meters[:name]\n result[:padas] = v_padas\n end\n\n result\n end",
"def determine_correctness\n answer = self.question.answer\n \t#Upcase to take care of all capitalization issues\n \tresponse = self.content.upcase\n\n \tanswer = answer.split(', ')\n\n \t#Score Keeping\n \tscore = 0\n \tscore_incremental = 1.0/answer.length\n \t\n \t#Determining how many of keywords are in response\n \tanswer.each do |correct_word|\n \t\tcorrect_word = correct_word.upcase\n \t\tif response.include?(correct_word)\n \t\t\tscore += score_incremental\n \t\tend\n \tend\n \tself.correctness = score\n end",
"def red_correct\n if @guess.grep(\"r\").size == 0 && @answer.grep(\"r\").size == 0\n total = 0\n elsif @guess.grep(\"r\").size == 1 && @answer.grep(\"r\").size == 0\n total = 0\n elsif @guess.grep(\"r\").size == 2 && @answer.grep(\"r\").size == 0\n total = 0\n elsif @guess.grep(\"r\").size == 3 && @answer.grep(\"r\").size == 0\n total = 0\n elsif @guess.grep(\"r\").size == 4 && @answer.grep(\"r\").size == 0\n total = 0\n elsif @guess.grep(\"r\").size == 0 && @answer.grep(\"r\").size == 1\n total = 0\n elsif @guess.grep(\"r\").size == 1 && @answer.grep(\"r\").size == 1\n total = 1\n elsif @guess.grep(\"r\").size == 2 && @answer.grep(\"r\").size == 1\n total = 1\n elsif @guess.grep(\"r\").size == 3 && @answer.grep(\"r\").size == 1\n total = 1\n elsif @guess.grep(\"r\").size == 4 && @answer.grep(\"r\").size == 1\n total = 1\n elsif @guess.grep(\"r\").size == 0 && @answer.grep(\"r\").size == 2\n total = 0\n elsif @guess.grep(\"r\").size == 1 && @answer.grep(\"r\").size == 2\n total = 1\n elsif @guess.grep(\"r\").size == 2 && @answer.grep(\"r\").size == 2\n total = 2\n elsif @guess.grep(\"r\").size == 3 && @answer.grep(\"r\").size == 2\n total = 2\n elsif @guess.grep(\"r\").size == 4 && @answer.grep(\"r\").size == 2\n total = 2\n elsif @guess.grep(\"r\").size == 0 && @answer.grep(\"r\").size == 3\n total = 0\n elsif @guess.grep(\"r\").size == 1 && @answer.grep(\"r\").size == 3\n total = 1\n elsif @guess.grep(\"r\").size == 2 && @answer.grep(\"r\").size == 3\n total = 2\n elsif @guess.grep(\"r\").size == 3 && @answer.grep(\"r\").size == 3\n total = 3\n elsif @guess.grep(\"r\").size == 4 && @answer.grep(\"r\").size == 3\n total = 3\n elsif @guess.grep(\"r\").size == 0 && @answer.grep(\"r\").size == 4\n total = 0\n elsif @guess.grep(\"r\").size == 1 && @answer.grep(\"r\").size == 4\n total = 1\n elsif @guess.grep(\"r\").size == 2 && @answer.grep(\"r\").size == 4\n total = 2\n elsif @guess.grep(\"r\").size == 3 && @answer.grep(\"r\").size == 4\n total = 3\n else @guess.grep(\"r\").size == 4 && @answer.grep(\"r\").size == 4\n total = 4\n end\n end",
"def getDecision(output, data_source)\r\n key = data_source.to_sym\r\n\r\n # Last sold check\r\n idx = output[key][:metricsNames].index(\"Last Sold History\")\r\n output[:reason][0] = \"Sold too recently\" if !output[key][:metricsPass][idx]\r\n\r\n # Rurality Checks\r\n rs_idx = output[:Census][:metricsNames].index(\"Rurality Score\")\r\n vol_idx = output[key][:metricsNames].index(\"St. Dev. of Historical Home Price\")\r\n\r\n if output[:region] == \"East\"\r\n output[:reason][1] = \"Too rural\" if (!output[:Census][:metricsPass][rs_idx] || !output[key][:metricsPass][vol_idx]) \r\n end\r\n\r\n if output[:region] == \"West\"\r\n output[:reason][1] = \"Too rural\" if !output[:Census][:metricsPass][rs_idx]\r\n end\r\n\r\n # Typicality\r\n typ_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Typicality\" }\r\n typ_fail_cnt = typ_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n\r\n if data_source == \"Zillow\"\r\n neigh_idx = output[key][:metricsNames].index(\"Neighbors Available\")\r\n sqft_idx = output[key][:metricsNames].index(\"SqFt Typicality - Comps\")\r\n est_idx = output[key][:metricsNames].index(\"Estimate Typicality - Comps\")\r\n\r\n if output[key][:metrics][neigh_idx] >= 4\r\n sqfi_nb_idx = output[key][:metricsNames].index(\"SqFt Typicality - Neighbors\")\r\n est_nb_idx = output[key][:metricsNames].index(\"Estimate Typicality - Neighbors\")\r\n\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 3\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 65.0 || output[key][:metrics][est_idx] > 65.0)\r\n output[:reason][2] = \"Atypical property\" if !output[key][:metricsPass][sqft_idx] && !output[key][:metricsPass][sqfi_nb_idx]\r\n output[:reason][2] = \"Atypical property\" if !output[key][:metricsPass][est_idx] && !output[key][:metricsPass][est_nb_idx]\r\n else\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 2\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 60.0 || output[key][:metrics][est_idx] > 60.0)\r\n end\r\n else\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 2\r\n output[:reason][2] = \"Atypical property\" if typ_fail_cnt >= 1 && (output[key][:metrics][sqft_idx] > 60.0 || output[key][:metrics][est_idx] > 60.0)\r\n end\r\n\r\n # Liquidity (allow one false)\r\n liq_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Liquidity\" }\r\n liq_fail_cnt = liq_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n output[:reason][3] = \"Illiquidity\" if liq_fail_cnt >= 2\r\n\r\n # Investment Guidelines\r\n est_idx = output[key][:metricsNames].index(\"Estimated Value\")\r\n type_idx = output[key][:metricsNames].index(\"Property Use\")\r\n build_idx = output[key][:metricsNames].index(\"Build Date\")\r\n msa_idx = output[key][:metricsNames].index(\"Pre-approval\")\r\n\r\n output[:reason][4] = \"Out of $ Range\" if !output[key][:metricsPass][est_idx]\r\n output[:reason][5] = \"Not Prop Type\" if !output[key][:metricsPass][type_idx]\r\n output[:reason][6] = \"New Construction\" if !output[key][:metricsPass][build_idx]\r\n output[:reason][7] = \"Not in MSAs\" if !output[key][:metricsPass][msa_idx]\r\n\r\n # Volatility (allow one false)\r\n vol_idx = output[key][:metricsUsage].each_index.select { |i| output[key][:metricsUsage][i] == \"Volatility\" }\r\n vol_fail_cnt = vol_idx.inject([]) { |tot, a| tot << output[key][:metricsPass][a] }.count(false)\r\n output[:reason][8] = \"Price Vol\" if vol_fail_cnt >= 2\r\n\r\n # Combo Rural (if applicable)\r\n cr_idx = output[:Census][:metricsNames].index(\"Combo Rural\")\r\n output[:reason][9] = \"Combo Rural\" if !output[:Census][:metricsPass][cr_idx]\r\n\r\n # Distance\r\n output[:reason][10] = \"MSA Distance\" if !output[:Google][:metricsPass].any?\r\n\r\n # Approve if not issues\r\n output[:reason][11] = \"Approved\" if output[:reason].compact.size == 0\r\n end",
"def calculate_match_probability\n # two heuristics: \n # 1 is are their multiple words in term_text? if so, mark as probable\n # if not, does it match the anchor regexp? if so, mark as probable\n # else, mark as improbable\n \n # multiple words?\n anchor_regexp = \"(featuring|plus|the|presents|with|plus|and|\\,|\\&|[()]|\\/|\\:|\\-|^|$)\"\n nix_regexp = \"parking|\\svs\\.?\\s\" \n if artist_name=~/#{nix_regexp}/i\n self.match_probability=\"unlikely\"\n return nil\n end\n text=term_text.strip\n if text[\" \"]\n self.match_probability=\"likely\"\n return \"multpl\"\n end\n if artist_name=~/#{anchor_regexp}\\s*#{text}\\s*#{anchor_regexp}/i\n self.match_probability=\"likely\"\n return \"regexp\"\n end\n# if artist_name=~/#{anchor_regexp}\\s+?#{text}\\s+?#{anchor_regexp}/i\n# match_probability=\"likely\"\n# return \"regexp\"\n# end\n self.match_probability=\"unlikely\"\n return nil\n end",
"def linearAccuracy\n wrong = 0\n correct = 0\n tp = 0\n tn = 0\n fp = 0\n fn = 0\n\n @label = Array.new(@total_line) {0.00}\n @evaluate = Array.new(@total_line) {0.00}\n @bayes_part = Array.new(@total_line) {0.00}\n\n t_file = File.open(\"./true_label.txt\", \"r\").to_enum\n e_file = File.open(\"./p_zh.txt\", \"r\").to_enum\n b_file = File.open(\"./decision_label.txt\", \"r\").to_enum\n\n array_count = 0\n loop do\n #access next line in each file with .next\n line_t = t_file.next.to_f\n line_e = e_file.next.to_f\n line_b = b_file.next.to_f\n\n if line_e != 0.0\n if line_t == 1.0\n if line_e == 1.0\n tp += 1\n elsif line_e == -1.0\n fp += 1\n else\n puts \"what?\"\n end\n elsif line_t == -1.0\n if line_e == 1.0\n fn += 1\n elsif line_e == -1.0\n tn += 1\n else\n puts \"what??\"\n end\n else\n puts \"what???\"\n end \n\n @evaluate[array_count] = line_e\n @label[array_count] = line_t\n @bayes_part[array_count] = line_b\n array_count += 1\n end\n end\n\n # write best results in simple linear to file\n File.open('true_label_linear.txt', 'w') do |f1| \n # use \"\\n\" for two lines of text \n @label.each do |line|\n f1.puts line\n end\n end\n\n File.open('decision_label_linear.txt', 'w') do |f2| \n # use \"\\n\" for two lines of text \n @evaluate.each do |line|\n f2.puts line\n end\n end\n\n File.open('decision_label_bayes_part.txt', 'w') do |f3| \n # use \"\\n\" for two lines of text \n @bayes_part.each do |line|\n f3.puts line\n end\n end\n\n puts (\"#{@label.size} lines\")\n correct = tp + tn\n wrong = fp + fn\n @Accuracy = 0.0\n @Accuracy = correct.to_f * 100 / (correct + wrong)\n puts \"Simple Accuracy #{@Accuracy}%\"\n tpr = tp.to_f / (tp + fn)\n fpr = fp.to_f / (fp + tn)\n puts \"fp: #{fp} fn: #{fn} tp: #{tp} tn: #{tn}\"\n puts \"tpr #{tpr} fpr: #{fpr}\"\n\n print \"linear \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_linear.txt')\n\n print \"bayes part accordingly \"\n system('./calc_auc ./true_label_linear.txt ./decision_label_bayes_part.txt')\nend",
"def process_question\n #There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n if @line.start_with? \"how many Credits is \"\n main_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n trademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n if trademetal && galatic_literals\n trademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n puts \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n return\n end\n elsif @line.start_with? \"how much is \"\n main_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n galatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n if galatic_literals\n conversion_value = galatic_literals.galactic_words_to_numeral\n puts \"#{galatic_literals} is #{conversion_value}\"\n return\n end\n end\n throw_away_meaningless_line\n end",
"def compute_ruby\n check_frequencies\n #\n # INITIALIZATION\n #\n @r = 0\n sdzero = 0\n @sdr = 0\n @itype = 0\n @ifault = 0\n delta = 0\n \n\n # GOTO (4, 1, 2 , 92), kdelta\n #\n # delta IS 0.0, 0.5 OR -0.5 ACCORDING TO WHICH CELL IS 0.0\n #\n\n if(@kdelta==2)\n # 1\n delta=0.5\n @r=-1 if (@a==0 and @d==0)\n elsif(@kdelta==3)\n # 2\n delta=-0.5\n @r=1 if (@b==0 and @c==0)\n end\n # 4\n if @r!=0\n @itype=3\n end\n\n #\n # STORE FREQUENCIES IN AA, BB, CC AND DD\n #\n @aa = @a + delta\n @bb = @b - delta\n @cc = @c - delta\n @dd = @d + delta\n @tot = @aa+@bb+@cc+@dd\n #\n # CHECK IF CORRELATION IS NEGATIVE, 0.0, POSITIVE\n # IF (AA * DD - BB * CC) 7, 5, 6\n\n corr_dir=@aa * @dd - @bb * @cc\n if(corr_dir < 0)\n # 7\n @probaa = @bb.quo(@tot)\n @probac = (@bb + @dd).quo(@tot)\n @ksign = 2\n # -> 8\n else\n if (corr_dir==0)\n # 5\n @itype=4\n end\n # 6\n #\n # COMPUTE PROBABILITIES OF QUADRANT AND OF MARGINALS\n # PROBAA AND PROBAC CHOSEN SO THAT CORRELATION IS POSITIVE.\n # KSIGN INDICATES WHETHER QUADRANTS HAVE BEEN SWITCHED\n #\n\n @probaa = @aa.quo(@tot)\n @probac = (@aa+@cc).quo(@tot)\n @ksign=1\n end\n # 8\n\n @probab = (@aa+@bb).quo(@tot)\n\n #\n # COMPUTE NORMAL DEVIATES FOR THE MARGINAL FREQUENCIES\n # SINCE NO MARGINAL CAN BE 0.0, IE IS NOT CHECKED\n #\n @zac = Distribution::Normal.p_value(@probac.to_f)\n @zab = Distribution::Normal.p_value(@probab.to_f)\n @ss = Math::exp(-0.5 * (@zac ** 2 + @zab ** 2)).quo(TWOPI)\n #\n # WHEN R IS 0.0, 1.0 OR -1.0, TRANSFER TO COMPUTE SDZERO\n #\n if (@r != 0 or @itype > 0)\n compute_sdzero\n return true\n end\n #\n # WHEN MARGINALS ARE EQUAL, COSINE EVALUATION IS USED\n #\n if (@a == @b and @b == @c)\n calculate_cosine\n return true\n end\n #\n # INITIAL ESTIMATE OF CORRELATION IS YULES Y\n #\n @rr = ((Math::sqrt(@aa * @dd) - Math::sqrt(@bb * @cc)) ** 2) / (@aa * @dd - @bb * @cc).abs\n @iter = 0\n begin\n #\n # IF RR EXCEEDS RCUT, GAUSSIAN QUADRATURE IS USED\n #\n #10\n if @rr>RCUT\n gaussian_quadrature\n return true\n end\n #\n # TETRACHORIC SERIES IS COMPUTED\n #\n # INITIALIZATION\n #\n va=1.0\n [email protected]_f\n wa=1.0\n [email protected]_f\n term = 1.0\n iterm = 0.0\n @sum = @probab * @probac\n deriv = 0.0\n sr = @ss\n #15\n begin\n if(sr.abs<=CONST)\n #\n # RESCALE TERMS TO AVOID OVERFLOWS AND UNDERFLOWS\n #\n sr = sr / CONST\n va = va * CHALF\n vb = vb * CHALF\n wa = wa * CHALF\n wb = wb * CHALF\n end\n #\n # FORM SUM AND DERIVATIVE OF SERIES\n #\n # 20\n dr = sr * va * wa\n sr = sr * @rr / term\n cof = sr * va * wa\n #\n # ITERM COUNTS NO. OF CONSECUTIVE TERMS < CONV\n #\n iterm+= 1\n iterm=0 if (cof.abs > CONV)\n @sum = @sum + cof\n deriv += dr\n vaa = va\n waa = wa\n va = vb\n wa = wb\n vb = @zac * va - term * vaa\n wb = @zab * wa - term * waa\n term += 1\n end while (iterm < 2 or term < 6)\n #\n # CHECK IF ITERATION CONVERGED\n #\n if((@sum-@probaa).abs <= CITER)\n @itype=term\n calculate_sdr\n return true\n end\n #\n # CALCULATE NEXT ESTIMATE OF CORRELATION\n #\n #25\n @iter += 1\n #\n # IF TOO MANY ITERATlONS, RUN IS TERMINATED\n #\n delta = (@sum - @probaa) / deriv\n @rrprev = @rr\n @rr = @rr - delta\n @rr += 0.5 * delta if(@iter == 1)\n @rr= RLIMIT if (@rr > RLIMIT)\n @rr =0 if (@rr < 0.0)\n end while @iter < NITER\n raise \"Too many iteration\"\n # GOTO 10\n end",
"def tell_fortune()\r\n print \"The answer is \" + $prediction + \". \\n\\n: \"\r\n end",
"def compare_reviews_with_questions_responses(reviews, questions)\n review_text_arr = reviews\n #response = Response.find(:first, :conditions => [\"map_id = ?\", map_id])\n #scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n #questions = Array.new\n #fetching the questions for the responses\n# for i in 0..scores.length - 1\n# questions << Question.find_by_sql([\"Select * from questions where id = ?\", scores[i].question_id])[0].txt\n# end\n \n count_copies = 0 #count of the number of responses that are copies either of questions of other responses\n rev_array = Array.new #holds the non-plagiairised responses\n #comparing questions with text\n for i in 0..questions.length - 1\n if(!questions[i].nil? and !review_text_arr[i].nil? and questions[i].downcase == review_text_arr[i].downcase)\n count_copies+=1\n next #skip comparing with other responses\n end\n \n #comparing response with other responses\n flag = 0\n for j in 0..review_text_arr.length - 1\n if(i != j and !review_text_arr[i].nil? and !review_text_arr[j].nil? and review_text_arr[i].downcase == review_text_arr[j].downcase)\n count_copies+=1\n flag = 1\n break\n end\n end\n\n if(flag == 0) #ensuring no match with any of the review array's responses\n rev_array << review_text_arr[i]\n end\n end\n \n #setting @review_array as rev_array\n if(count_copies > 0) #resetting review_array only when plagiarism was found\n auto_metareview.review_array = rev_array\n end\n \n if(count_copies > 0 and count_copies == scores.length)\n return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0\n elsif(count_copies > 0)\n return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics\n end\n end",
"def get_fortune\n\t\trandomNo = 1 + rand(6)\n\n\t\t#Assign answer based on random generated number\n\t\tcase randomNo\n\t\t\twhen 1\n\t\t\t\t$prediction = \"yes\"\n\t\t\twhen 2\n\t\t\t\t$prediction = \"no\"\n\t\t\twhen 3\n\t\t\t\t$prediction = \"maybe\"\n\t\t\twhen 4\n\t\t\t\t$prediction = \"hard to tell. Try again\"\n\t\t\twhen 5\n\t\t\t\t$prediction = \"unlikely\"\n\t\t\twhen 6\n\t\t\t\t$prediction = \"unknown\"\n\t\tend\n\n\tend",
"def find_quality_of_answer(text, typos, attempt, answer_time)\n if typos < text.size / 3.0\n quality = 5 - attempt\n quality = [quality - 1, 3].max if answer_time.to_f > 30.0\n else\n quality = [(text.size / typos).floor, 2].min\n end\n quality\n end",
"def process_question\n\t\t#There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n\t\tif @line.start_with? \"how many Credits is \"\n\t\t\tmain_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n\t\t\ttrademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n\t\t\tif trademetal && galatic_literals\n\t\t\t\ttrademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n\t\t\t\tputs \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n\t\t\t\treturn\n\t\t\tend\n\t\telsif @line.start_with? \"how much is \"\n\t\t\tmain_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n\t\t\tif galatic_literals\n\t\t\t\tconversion_value = galatic_literals.galactic_words_to_numeral\n\t\t\t\tputs \"#{galatic_literals} is #{conversion_value}\"\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\tthrow_away_meaningless_line\n\tend",
"def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend",
"def corrections\n #For each word to be looked at\n $words.each do |word_array|\n #If the word is misspelled attempt corrections\n possible_matches = Array.new\n if word_array[1] == false\n #Sets word to the actual word, instead of array pair\n word = word_array[0]\n # Get lexicon searching vars\n first_char = word[0]\n len = word.length\n\n ##Find words with similar letters\n #Saves the length of the word for eaiser access\n size = word.length\n #Iterates over words with matching starting letter and length +- 1\n $lexicon[first_char][len].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n # only check shorter words if length is greater than 1\n if len > 1\n $lexicon[first_char][len-1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n end\n\n $lexicon[first_char][len+1].each do |word_compare|\n possible_matches << word_compare[0]\n end\n\n #Iterate over the possible matches, taking the match with the highest percentage\n #Hash to hold similarity\n similarity = Hash.new(0.0)\n possible_matches.each do |word_to_compare|\n similarity[word_to_compare] = match_percentage word, word_to_compare\n end\n\n best_match = ''\n similarity.each do |match|\n if match[1] > similarity[best_match]\n best_match = match[0]\n end\n end\n $correction[word] = best_match\n end\n end\nend",
"def tell_fortune()\r\n\t\tprint \"The answer is \" + $predicition + \". \\n\\n: \"\r\n\tend",
"def fleiss(matrix)\n debug = true\n\n # n Number of rating per subjects (number of human raters)\n n = checkEachLineCount(matrix) # PRE : every line count must be equal to n\n i_N = matrix.size\n k = matrix[0].size\n\n if debug\n puts \"#{n} raters.\"\n puts \"#{i_N} subjects.\"\n puts \"#{k} categories.\"\n end\n\n # Computing p[]\n p = [0.0] * k\n (0...k).each do |j|\n p[j] = 0.0\n (0...i_N).each {|i| p[j] += matrix[i][j] } \n p[j] /= i_N*n \n end\n\n puts \"p = #{p.join(',')}\" if debug\n\n # Computing f_P[] \n f_P = [0.0] * i_N\n\n (0...i_N).each do |i|\n f_P[i] = 0.0\n (0...k).each {|j| f_P[i] += matrix[i][j] * matrix[i][j] } \n f_P[i] = (f_P[i] - n) / (n * (n - 1)) \n end \n\n puts \"f_P = #{f_P.join(',')}\" if debug\n\n # Computing Pbar\n f_Pbar = sum(f_P) / i_N\n puts \"f_Pbar = #{f_Pbar}\" if debug\n\n # Computing f_PbarE\n f_PbarE = p.inject(0.0) { |acc,el| acc + el**2 }\n\n puts \"f_PbarE = #{f_PbarE}\" if debug \n\n kappa = (f_Pbar - f_PbarE) / (1 - f_PbarE)\n puts \"kappa = #{kappa}\" if debug \n\n kappa \nend",
"def answers\n [].tap do |a|\n a << teaching_maths_or_physics\n a << current_school\n a << initial_teacher_training_subject\n a << initial_teacher_training_subject_specialism if eligibility.initial_teacher_training_subject_specialism.present?\n a << has_uk_maths_or_physics_degree if eligibility.has_uk_maths_or_physics_degree.present?\n a << qts_award_year\n a << employed_as_supply_teacher\n a << has_entire_term_contract if eligibility.employed_as_supply_teacher?\n a << employed_directly if eligibility.employed_as_supply_teacher?\n a << disciplinary_action\n a << formal_performance_action\n end\n end",
"def percent_satisfied(content)\n if ['yes', 'extremely likely', 'very satisfied'].include?(content)\n 100\n elsif ['somewhat likely', 'satisfied'].include?(content)\n 80\n elsif ['neutral'].include?(content)\n 60\n elsif ['not very likely', 'dissatisfied'].include?(content)\n 40\n elsif ['not at all likely', 'very dissatisfied'].include?(content)\n 20\n elsif ['no'].include?(content)\n 0\n else\n 0\n end\n end",
"def satisfiable_assignment?(assignment)\n\t\tsentence_eval = 1\n\t\tindex = 0\n\t\twhile(sentence_eval == 1 && index < @kb.size)\n\t\t\tsentence_eval = 0\n\t\t\tall_false = true\n##############################################3\n#\t\t\tputs \"kb is: \" + @kb.to_s\n#\t\t\tputs \"the assignments are : \" + assignment.to_s\n\t\t\n\t\t\t@kb[index].each do |id|\n################################################33\n#\t\t\tputs \" the atom to check : \" + id.to_s\t\t\t\t\n\n\t\t\t\ttemp_id = id\n\t\t\t\tif(temp_id >0)\n\t\t\t\t\tassign = assignment[temp_id - 1]\n###################################################\n#\t\t\t\tputs \"the atom is : \" + id.to_s \n#\t\t\t\tputs \"the variable is assigned to: \" + assignment[temp_id-1].to_s\n#\t\t\t\tputs \"which evaluates to: \" + assign.to_s\n \t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tassign = assignment[temp_id*-1 -1].to_i * -1\n\n###################################################\n#\t\t\t\tputs \"the atom is : \" + id.to_s \n#\t\t\t\tputs \"the variable is assigned to: \" + (assignment[temp_id*-1 - 1] - 1).to_s\n#\t\t\t\tputs \"which evaluates to: \" + assign.to_s\n\n\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\tif(assign==1)\n\t\t\t\t\tsentence_eval = 1\n\t\t\t\t\tall_false = false\t\t\t\t\n\t\t\t\t\tbreak\n\t\t\t\telsif(assign == 0)\n\t\t\t\t\tall_false = false\n\t\t\t\tend\n\t\t\tend\n\t\t\tif(all_false)\n\t\t\t\tsentence_eval = -1\n\t\t\tend\n\t\t\tindex+=1\n\t\tend\t\t\n\t\treturn sentence_eval\n\tend",
"def to_question(parse_tree)\n np, vp = parse_tree.extract_tree(@matcher_tree).children.first.children\n if np.children.first.label == \"PRP\" and np.children.first.to_sentence != \"It\"\n question_word = \"Who\" \n elsif np.children.first.label == \"PRP$\" and np.children.length == 1\n question_word = \"Whose\"\n else\n question_word = \"What\"\n end\n q = question_word + ' ' + vp.to_sentence.gsub(/\\.$/, \"\") + '?'\n [q, np.to_sentence]\n end",
"def test_855\n want = <<~EDI.gsub(/\\n/, \"\")\n ST*855*0001~\n BAK*00*AC*00000007397108*19700101~\n N1*ST*Sweeney Todd~\n N3*2705 Fleet St~\n N4*Birmingham*AL*35226*US~\n PO1*1*1*EA*59.95**UP*860001662184*VP*860001662184~\n PID*F****CBD Topical Cream 400mg THC Free~\n ACK*IA*1*EA****UP*860001662184*VP*860001662184~\n PO1*2*2*EA*49.95**UP*860001662108*VP*860001662108~\n PID*F****500mg Full Spectrum Garden Mint Oil Tincture~\n ACK*IA*2*EA****UP*860001662108*VP*860001662108~\n CTT*2~\n SE*13*0001\n EDI\n store = Eddy::Data::Store.new(time: @epoch)\n ts = Eddy::TransactionSets::TS855::TS.new(store)\n ts.BAK do |bak|\n bak.TransactionSetPurposeCode = \"00\"\n bak.AcknowledgmentType = \"AC\"\n bak.PurchaseOrderNumber = \"00000007397108\"\n bak.Date = @epoch\n end\n ts.L_N1 do |rep|\n # N1\n rep.N1.EntityIdentifierCode = \"ST\"\n rep.N1.Name = \"Sweeney Todd\"\n # N3\n rep.N3.AddressInformation1 = \"2705 Fleet St\"\n # N4\n rep.N4.CityName = \"Birmingham\"\n rep.N4.StateOrProvinceCode = \"AL\"\n rep.N4.PostalCode = \"35226\"\n rep.N4.CountryCode = \"US\"\n end\n ts.L_PO1 do |rep|\n rep.PO1.AssignedIdentification = \"1\"\n rep.PO1.QuantityOrdered = 1\n rep.PO1.UnitOrBasisForMeasurementCode = \"EA\"\n rep.PO1.UnitPrice = 59.95\n rep.PO1.ProductServiceIdQualifier1 = \"UP\"\n rep.PO1.ProductServiceId1 = \"860001662184\"\n rep.PO1.ProductServiceIdQualifier2 = \"VP\"\n rep.PO1.ProductServiceId2 = \"860001662184\"\n rep.L_PID do |rep|\n rep.PID.ItemDescriptionType = \"F\"\n rep.PID.Description = \"CBD Topical Cream 400mg THC Free\"\n end\n rep.L_ACK do |rep|\n rep.ACK.LineItemStatusCode = \"IA\"\n rep.ACK.Quantity = 1\n rep.ACK.UnitOrBasisForMeasurementCode = \"EA\"\n rep.ACK.ACK07 = \"UP\"\n rep.ACK.ACK08 = \"860001662184\"\n rep.ACK.ACK09 = \"VP\"\n rep.ACK.ACK10 = \"860001662184\"\n end\n end\n ts.L_PO1 do |rep|\n rep.PO1.AssignedIdentification = \"2\"\n rep.PO1.QuantityOrdered = 2\n rep.PO1.UnitOrBasisForMeasurementCode = \"EA\"\n rep.PO1.UnitPrice = 49.95\n rep.PO1.ProductServiceIdQualifier1 = \"UP\"\n rep.PO1.ProductServiceId1 = \"860001662108\"\n rep.PO1.ProductServiceIdQualifier2 = \"VP\"\n rep.PO1.ProductServiceId2 = \"860001662108\"\n rep.L_PID do |rep|\n rep.PID.ItemDescriptionType = \"F\"\n rep.PID.Description = \"500mg Full Spectrum Garden Mint Oil Tincture\"\n end\n rep.L_ACK do |rep|\n rep.ACK.LineItemStatusCode = \"IA\"\n rep.ACK.Quantity = 2\n rep.ACK.UnitOrBasisForMeasurementCode = \"EA\"\n rep.ACK.ACK07 = \"UP\"\n rep.ACK.ACK08 = \"860001662108\"\n rep.ACK.ACK09 = \"VP\"\n rep.ACK.ACK10 = \"860001662108\"\n end\n end\n ts.CTT.NumberOfLineItems = 2\n result = ts.render()\n assert_equal(want, result)\n end",
"def arv_regimen_answers(options = {})\n answer_array = Array.new\n regimen_types = ['FIRST LINE ANTIRETROVIRAL REGIMEN', \n 'ALTERNATIVE FIRST LINE ANTIRETROVIRAL REGIMEN',\n 'SECOND LINE ANTIRETROVIRAL REGIMEN'\n ]\n\n regimen_types.collect{|regimen_type|\n Concept.find_by_name(regimen_type).concept_members.flatten.collect{|member|\n next if member.concept.fullname.include?(\"Triomune Baby\") and !options[:patient].child? rescue nil\n next if member.concept.fullname.include?(\"Triomune Junior\") and !options[:patient].child? rescue nil\n if options[:use_short_names]\n include_fixed = member.concept.fullname.match(\"(fixed)\")\n answer_array << [member.concept.shortname, member.concept_id] unless include_fixed\n answer_array << [\"#{member.concept.shortname} (fixed)\", member.concept_id] if include_fixed\n member.concept.shortname\n else\n answer_array << [member.concept.fullname.titleize, member.concept_id] unless member.concept.fullname.include?(\"+\")\n answer_array << [member.concept.fullname, member.concept_id] if member.concept.fullname.include?(\"+\")\n end\n }\n }\n \n if options[:show_other_regimen]\n answer_array << \"Other\" if !answer_array.blank?\n end\n answer_array\n\n # raise answer_array.inspect\n end",
"def wrestler_output\n\n\t\tputs \"Name: #{self.values[:name]}\"\n\t\tputs \"Set: #{self.values[:set]}\"\n\t\tputs \"Singles Priority: #{self.values[:prioritys]}\"\n\t\tputs \"Tag Team Priority: #{self.values[:priorityt]}\"\n\t\tputs \"TT Probability: #{self.statistics[:tt_probability]}\"\n\t\tputs \"Card Rating: #{self.statistics[:total_card_rating]}\"\n\t\tputs \"OC Probability: #{self.statistics[:oc_probability]}\"\n\t\tputs \"Total Points-Per-Round: #{self.statistics[:total_card_points_per_round]}\"\n\t\tputs \"DQ Probability-Per-Round: #{self.statistics[:dq_probability_per_round]}\"\n\t\tputs \"P/A Probability-Per-Round: #{self.statistics[:pa_probability_per_round]}\"\n\t\tputs \"Submission Roll Probability-Per-Round: #{self.statistics[:sub_probability_per_round]}\"\n\t\tputs \"XX Roll Probability-Per-Round: #{self.statistics[:xx_probability_per_round]}\"\n\t\tputs \"Submission Loss Probability: #{self.points[:sub_prob]}\"\n\t\tputs \"Tag Team Save Probability: #{self.points[:tag_prob]}\"\n\t\tputs \"\\n\"\n\n\t\ttt_probability = \"%.1f\" % (self.statistics[:tt_probability] * 100) + \"%\"\n\t\tcard_rating = \"%.1f\" % self.statistics[:total_card_rating]\n\t\toc_probability = \"%.1f\" % (self.statistics[:oc_probability] * 100) + \"%\"\n\t\ttotal_card_points_per_round = \"%.3f\" % self.statistics[:total_card_points_per_round]\n\t\tdq_probability_per_round = \"%.1f\" % (self.statistics[:dq_probability_per_round] * 100) + \"%\"\n\t\tpa_probability_per_round = \"%.1f\" % (self.statistics[:pa_probability_per_round] * 100) + \"%\"\n\t\tsub_probability_per_round = \"%.1f\" % (self.statistics[:sub_probability_per_round] * 100) + \"%\"\n\t\txx_probability_per_round = \"%.1f\" % (self.statistics[:xx_probability_per_round] * 100) + \"%\"\n\t\t\n\t\tsub_prob = \"%.1f\" % (self.points[:sub_prob] * 100) + \"%\"\n\t\ttag_prob = \"%.1f\" % (self.points[:tag_prob] * 100) + \"%\"\n\n\t\tf = File.new('files/results.csv', 'a')\n\t\tf.write(\"#{self.values[:name]},#{self.values[:set]}, #{self.values[:prioritys]}, #{self.values[:priorityt]}, #{tt_probability}, #{card_rating}, #{oc_probability}, #{total_card_points_per_round}, #{dq_probability_per_round}, #{pa_probability_per_round}, #{sub_probability_per_round}, #{xx_probability_per_round}, #{sub_prob}, #{tag_prob}, \\n\")\n\t\tf.close\n\tend",
"def get_fortune\r\n\t\trandomNo = 1 + rand(10)\r\n\t\t\r\n\t\t#Assign an answer based on the randomly generated\r\n\t\t#number\r\n\t\tcase randomNo\r\n\t\t\twhen 1\r\n\t\t\t\t$predicition = \"yes\"\r\n\t\t\twhen 2\r\n\t\t\t\t$predicition = \"no\"\r\n\t\t\twhen 3\r\n\t\t\t\t$predicition = \"maybe\"\r\n\t\t\twhen 4\r\n\t\t\t\t$predicition = \"hard to tell. Try again\"\r\n\t\t\twhen 5\r\n\t\t\t\t$predicition = \"unlikely\"\r\n\t\t\twhen 6\r\n\t\t\t\t$predicition = \"unknown\"\r\n\t\t\twhen 7\r\n\t\t\t\t$predicition = \"ask again later\"\r\n\t\t\twhen 8\r\n\t\t\t\t$predicition = \"hazy try again\"\r\n\t\t\twhen 9\r\n\t\t\t\t$predicition = \"better not tell you now\"\r\n\t\t\twhen 10\r\n\t\t\t\t$predicition = \"concentrate and ask again\"\r\n\t\tend\r\n\tend",
"def corrections; end",
"def solve_score_matching_info(book_td_labels)\n submited_report_counts = book_td_labels.shift.split('>')[3].split('<')[0]\n current_mark = book_td_labels.pop.split('>')[3].split('<')[0]\n score_reds = []\n book_td_labels.each_index do |index|\n td = book_td_labels[index]\n td = td.match('>.+<').to_s\n l = td.size\n td = td.slice(1, l-2)\n score_reds << td\n end\n \n score_arrs = score_reds.each_slice(2).to_a\n [submited_report_counts, current_mark, score_arrs]\n end",
"def process_specification_page(response_body, short_dataset_only=true)\n hash = {}\n\n if !response_body.nil?\n doc = Nokogiri.HTML(response_body)\n\n # msrp\n hash['msrp'] = nil\n x = doc.css('#style-price a').first\n hash['msrp'] = x.text.gsub('$', '').gsub(',', '').to_i if !x.nil? && x.text.length > 0\n\n get_specifications_value(doc, hash, 'style', 'Style Name')\n get_specifications_value(doc, hash, 'body_style', 'Body Style')\n get_specifications_value(doc, hash, 'passenger_doors', 'Passenger Doors', integer: true)\n get_specifications_value(doc, hash, 'transmission', 'Transmission')\n\n # DIMENSIONS\n get_specifications_value(doc, hash, 'epa_classification', 'EPA Classification')\n get_specifications_value(doc, hash, 'passenger_capacity', 'Passenger Capacity', integer: true)\n get_specifications_value(doc, hash, 'front_head_room', 'Front Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_shoulder_room', 'Front Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_hip_room', 'Front Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'front_leg_room', 'Front Leg Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_head_room', 'Second Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_shoulder_room', 'Second Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_hip_room', 'Second Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'second_leg_room', 'Second Leg Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_head_room', 'Third Head Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_shoulder_room', 'Third Shoulder Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_hip_room', 'Third Hip Room (in)', float: true)\n get_specifications_value(doc, hash, 'third_leg_room', 'Third Leg Room (in)', float: true)\n\n get_specifications_value(doc, hash, 'width', 'Width, Max w/o mirrors (in)', float: true)\n get_specifications_value(doc, hash, 'height', 'Height, Overall (in)', float: true)\n get_specifications_value(doc, hash, 'length', 'Length, Overall (in)', float: true)\n get_specifications_value(doc, hash, 'ground_clearance', 'Min Ground Clearance (in)', float: true)\n\n get_specifications_value(doc, hash, 'trunk_volume', 'Trunk Volume (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_width', 'Cargo Box Width @ Wheelhousings (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_height', 'Cargo Box (Area) Height (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_length_floor_to_seat2', 'Cargo Area Length @ Floor to Seat 2 (in)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_volume_to_seat1', 'Cargo Volume to Seat 1 (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_area_volume_to_seat2', 'Cargo Volume to Seat 2 (ft³)', float: true)\n get_specifications_value(doc, hash, 'cargo_are_volume_to_seat3', 'Cargo Volume to Seat 3 (ft³)', float: true)\n\n\n # FUEL ECONOMY\n get_specifications_value(doc, hash, 'fuel_tank_capacity', 'Fuel Tank Capacity, Approx (gal)', integer: true)\n get_specifications_value(doc, hash, 'mpg_city', 'EPA Fuel Economy Est - City (MPG)', integer: true)\n get_specifications_value(doc, hash, 'mpg_highway', 'EPA Fuel Economy Est - Hwy (MPG)', integer: true)\n get_specifications_value(doc, hash, 'mpg_combined', 'Fuel Economy Est-Combined (MPG)', integer: true)\n get_specifications_value(doc, hash, 'battery_range', 'Battery Range (mi)')\n get_specifications_value(doc, hash, 'mpg_equivalent_city', 'EPA MPG Equivalent - City')\n get_specifications_value(doc, hash, 'mpg_equivalent_hwy', 'EPA MPG Equivalent - Hwy')\n get_specifications_value(doc, hash, 'mpg_equivalent_combined', 'EPA MPG Equivalent - Combined')\n\n\n # PERFORMANCE SPECS\n get_specifications_value(doc, hash, 'engine_type', 'Engine Type')\n get_specifications_value(doc, hash, 'engine_displacement', 'Displacement')\n get_specifications_value(doc, hash, 'horsepower', 'SAE Net Horsepower @ RPM')\n get_specifications_value(doc, hash, 'fuel_system', 'Fuel System')\n\n get_specifications_value(doc, hash, 'brakes_abs', 'Brake ABS System')\n get_specifications_value(doc, hash, 'brakes_disc_front', 'Disc - Front (Yes or )')\n get_specifications_value(doc, hash, 'brakes_disc_rear', 'Disc - Rear (Yes or )')\n get_specifications_value(doc, hash, 'brakes_drum_rear', 'Drum - Rear (Yes or )')\n\n get_specifications_value(doc, hash, 'steering_type', 'Steering Type')\n get_specifications_value(doc, hash, 'turning_diameter', 'Turning Diameter - Curb to Curb (ft)', float: true)\n\n\n # SAFETY FEATURES\n get_specifications_value(doc, hash, 'air_bag_front_driver', 'Air Bag-Frontal-Driver')\n get_specifications_value(doc, hash, 'air_bag_front_passenger', 'Air Bag-Frontal-Passenger')\n get_specifications_value(doc, hash, 'air_bag_front_passenger_switch', 'Air Bag-Passenger Switch (On/Off)')\n get_specifications_value(doc, hash, 'air_bag_side_head_front', 'Air Bag-Side Head-Front')\n get_specifications_value(doc, hash, 'air_bag_side_body_front', 'Air Bag-Side Body-Front')\n get_specifications_value(doc, hash, 'air_bag_side_head_rear', 'Air Bag-Side Head-Rear')\n get_specifications_value(doc, hash, 'air_bag_side_body_rear', 'Air Bag-Side Body-Rear')\n get_specifications_value(doc, hash, 'brakes_abs', 'Brakes-ABS')\n get_specifications_value(doc, hash, 'child_door_locks', 'Child Safety Rear Door Locks')\n get_specifications_value(doc, hash, 'other_features', 'Other Features')\n\n\n\n # if the entire dataset is desired, continue\n if !short_dataset_only\n\n # DIMENSIONS\n get_specifications_value(doc, hash, 'base_curb_weight', 'Base Curb Weight (lbs)', integer: true)\n get_specifications_value(doc, hash, 'passenger_volume', 'Passenger Volume (ft³)', float: true)\n get_specifications_value(doc, hash, '', 'Gross Combined Wt Rating (lbs)')\n get_specifications_value(doc, hash, '', 'Curb Weight - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Curb Weight - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Axle Wt Rating - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Axle Wt Rating - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Gross Vehicle Weight Rating Cap (lbs)')\n\n get_specifications_value(doc, hash, 'wheelbase', 'Wheelbase (in)', float: true)\n get_specifications_value(doc, hash, 'track_width_front', 'Track Width, Front (in)', float: true)\n get_specifications_value(doc, hash, 'track_width_rear', 'Track Width, Rear (in)', float: true)\n get_specifications_value(doc, hash, 'liftover_height', 'Liftover Height (in)', float: true)\n get_specifications_value(doc, hash, '', 'Ground Clearance, Front (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Rear w/o bumper (in)')\n get_specifications_value(doc, hash, '', 'Ground to Top of Frame (in)')\n get_specifications_value(doc, hash, '', 'Cab to End of Frame (in)')\n get_specifications_value(doc, hash, '', 'Ground Clearance, Rear (in)')\n get_specifications_value(doc, hash, '', 'Length, Overall w/o rear bumper (in)')\n get_specifications_value(doc, hash, '', 'Front Bumper to Back of Cab (in)')\n get_specifications_value(doc, hash, '', 'Frame Width, Rear (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Front (in)')\n get_specifications_value(doc, hash, '', 'Ground to Top of Load Floor (in)')\n get_specifications_value(doc, hash, '', 'Cab to Axle (in)')\n get_specifications_value(doc, hash, '', 'Rear Door Type')\n get_specifications_value(doc, hash, '', 'Rear Door Opening Height (in)')\n get_specifications_value(doc, hash, '', 'Step Up Height - Side (in)')\n get_specifications_value(doc, hash, '', 'Side Door Opening Width (in)')\n get_specifications_value(doc, hash, '', 'Overhang, Rear w/bumper (in)')\n get_specifications_value(doc, hash, '', 'Rear Door Opening Width (in)')\n get_specifications_value(doc, hash, '', 'Step Up Height - Front (in)')\n get_specifications_value(doc, hash, '', 'Length, Overall w/rear bumper (in)')\n get_specifications_value(doc, hash, '', 'Side Door Opening Height (in)')\n\n\n get_specifications_value(doc, hash, '', 'Cargo Box Length @ Floor (in)')\n get_specifications_value(doc, hash, '', 'Cargo Box Width @ Floor (in)')\n get_specifications_value(doc, hash, '', 'Cargo Box Width @ Top, Rear (in)')\n get_specifications_value(doc, hash, '', 'Cargo Volume (ft³)')\n get_specifications_value(doc, hash, '', 'Ext\\'d Cab Cargo Volume (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Area Width @ Beltline (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 1 (in)')\n get_specifications_value(doc, hash, '', 'Tailgate Width (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 4 (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Console (in)')\n get_specifications_value(doc, hash, '', 'Cargo Area Length @ Floor to Seat 3 (in)')\n get_specifications_value(doc, hash, '', 'Cargo Volume to Seat 4 (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Volume with Rear Seat Up (ft³)')\n get_specifications_value(doc, hash, '', 'Cargo Volume with Rear Seat Down (ft³)')\n\n # PERFORMANCE SPECS\n get_specifications_value(doc, hash, 'torque', 'SAE Net Torque @ RPM')\n get_specifications_value(doc, hash, 'engine_order_code', 'Engine Order Code')\n\n get_specifications_value(doc, hash, '', 'Aux Fuel Tank Location')\n get_specifications_value(doc, hash, '', 'Aux Fuel Tank Capacity, Approx (gal)')\n get_specifications_value(doc, hash, '', 'Fuel Tank Location')\n\n get_specifications_value(doc, hash, '', 'Engine Oil Cooler')\n\n get_specifications_value(doc, hash, 'drivetrain', 'Drivetrain')\n get_specifications_value(doc, hash, 'first_gear_ratio', 'First Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Second Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Third Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Fourth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Fifth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Sixth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Seventh Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Eighth Gear Ratio (:1)')\n get_specifications_value(doc, hash, '', 'Clutch Size (in)')\n get_specifications_value(doc, hash, '', 'Transfer Case Gear Ratio (:1), Low')\n get_specifications_value(doc, hash, '', 'Transfer Case Model')\n get_specifications_value(doc, hash, '', 'Trans Power Take Off')\n get_specifications_value(doc, hash, '', 'Transfer Case Power Take Off')\n get_specifications_value(doc, hash, '', 'Transfer Case Gear Ratio (:1), High')\n get_specifications_value(doc, hash, '', 'Trans PTO Access')\n\n get_specifications_value(doc, hash, '', 'Axle Type - Front')\n get_specifications_value(doc, hash, '', 'Axle Capacity - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Axle Ratio (:1) - Front')\n get_specifications_value(doc, hash, '', 'Axle Type - Rear')\n get_specifications_value(doc, hash, '', 'Axle Ratio (:1) - Rear')\n get_specifications_value(doc, hash, '', 'Axle Capacity - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Spring Capacity - Front (lbs)')\n get_specifications_value(doc, hash, '', 'Shock Absorber Diameter - Front (mm)')\n get_specifications_value(doc, hash, '', 'Stabilizer Bar Diameter - Front (in)')\n get_specifications_value(doc, hash, '', 'Spring Capacity - Rear (lbs)')\n get_specifications_value(doc, hash, '', 'Shock Absorber Diameter - Rear (mm)')\n get_specifications_value(doc, hash, '', 'Stabilizer Bar Diameter - Rear (in)')\n\n get_specifications_value(doc, hash, 'reverse_ratio', 'Reverse Ratio (:1)', float: true)\n get_specifications_value(doc, hash, 'final_drive_axle_ratio', 'Final Drive Axle Ratio (:1)', float: true)\n get_specifications_value(doc, hash, 'trans_type', 'Trans Type')\n get_specifications_value(doc, hash, 'trans_desc_cont', 'Trans Description Cont.')\n get_specifications_value(doc, hash, 'trans_desc_cont2', 'Trans Description Cont. Again')\n get_specifications_value(doc, hash, 'trans_order_code', 'Trans Order Code')\n\n get_specifications_value(doc, hash, 'brakes_front_drum_thickness', 'Front Brake Rotor Diam x Thickness (in)', float: true)\n get_specifications_value(doc, hash, 'brakes_rear_drum_thickness', 'Rear Brake Rotor Diam x Thickness (in)', float: true)\n get_specifications_value(doc, hash, 'brakes_rear_drum_width', 'Rear Drum Diam x Width (in)', float: true)\n get_specifications_value(doc, hash, '', 'Brake Type')\n get_specifications_value(doc, hash, '', 'Brake ABS System (Second Line)')\n\n get_specifications_value(doc, hash, '', 'Steering Ratio (:1), On Center')\n get_specifications_value(doc, hash, '', 'Turning Diameter - Wall to Wall (ft)')\n get_specifications_value(doc, hash, '', 'Steering Ratio (:1), At Lock')\n\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Rear')\n get_specifications_value(doc, hash, '', 'Spare Tire Capacity (lbs)')\n get_specifications_value(doc, hash, '', 'Front Tire Capacity (lbs)')\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Spare')\n get_specifications_value(doc, hash, '', 'Revolutions/Mile @ 45 mph - Front')\n get_specifications_value(doc, hash, '', 'Rear Tire Capacity (lbs)')\n\n get_specifications_value(doc, hash, 'tire_front_size', 'Front Tire Size')\n get_specifications_value(doc, hash, 'tire_front_code', 'Front Tire Order Code')\n get_specifications_value(doc, hash, 'tire_rear_size', 'Rear Tire Size')\n get_specifications_value(doc, hash, 'tire_rear_code', 'Rear Tire Order Code')\n get_specifications_value(doc, hash, 'tire_spare_size', 'Spare Tire Size')\n get_specifications_value(doc, hash, 'tire_spare_code', 'Spare Tire Order Code')\n\n get_specifications_value(doc, hash, 'wheel_front_size', 'Front Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_front_material', 'Front Wheel Material')\n get_specifications_value(doc, hash, 'wheel_rear_size', 'Rear Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_rear_material', 'Rear Wheel Material')\n get_specifications_value(doc, hash, 'wheel_spare_size', 'Spare Wheel Size (in)')\n get_specifications_value(doc, hash, 'wheel_spare_material', 'Spare Wheel Material')\n\n get_specifications_value(doc, hash, 'suspension_type_front', 'Suspension Type - Front')\n get_specifications_value(doc, hash, 'suspension_type_front2', 'Suspension Type - Front (Cont.)')\n get_specifications_value(doc, hash, 'suspension_type_rear', 'Suspension Type - Rear')\n get_specifications_value(doc, hash, 'suspension_type_rear2', 'Suspension Type - Rear (Cont.)')\n\n\n # SAFETY FEATURES\n get_specifications_value(doc, hash, 'daytime_lights', 'Daytime Running Lights')\n get_specifications_value(doc, hash, 'fog_lamps', 'Fog Lamps')\n get_specifications_value(doc, hash, 'night_vision', 'Night Vision')\n get_specifications_value(doc, hash, 'backup_camera', 'Back-Up Camera')\n get_specifications_value(doc, hash, 'parking_aid', 'Parking Aid')\n get_specifications_value(doc, hash, 'traction_control', 'Traction Control')\n get_specifications_value(doc, hash, 'tire_pressure_monitor', 'Tire Pressure Monitor')\n get_specifications_value(doc, hash, 'stability_control', 'Stability Control')\n get_specifications_value(doc, hash, 'rollover_protection_bars', 'Rollover Protection Bars')\n\n\n # WARRANTY\n get_specifications_value(doc, hash, 'warranty_years', 'Basic Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_miles', 'Basic Miles/km')\n get_specifications_value(doc, hash, 'warranty_drivetrain_year', 'Drivetrain Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_drivetrain_mils', 'Drivetrain Miles/km')\n get_specifications_value(doc, hash, 'warranty_corrosion_years', 'Corrosion Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_corrosion_miles', 'Corrosion Miles/km')\n get_specifications_value(doc, hash, 'warranty_roadside_years', 'Roadside Assistance Years', integer: true)\n get_specifications_value(doc, hash, 'warranty_roadside_miles', 'Roadside Assistance Miles/km')\n get_specifications_value(doc, hash, '', 'Hybrid/Electric Components Miles/km')\n get_specifications_value(doc, hash, '', 'Hybrid/Electric Components Years')\n get_specifications_value(doc, hash, '', 'Maintenance Miles/km')\n get_specifications_value(doc, hash, '', 'Maintenance Years')\n get_specifications_value(doc, hash, '', 'Drivetrain Note')\n get_specifications_value(doc, hash, '', 'Maintenance Note')\n get_specifications_value(doc, hash, '', 'Roadside Assistance Note')\n get_specifications_value(doc, hash, '', 'Emissions Miles/km')\n get_specifications_value(doc, hash, '', 'Emissions Years')\n\n\n\n # OTHER SPECS\n get_specifications_value(doc, hash, 'cold_cranking_amps', 'Cold Cranking Amps @ 0° F (Primary)', integer: true)\n get_specifications_value(doc, hash, '', 'Total Cooling System Capacity (qts)')\n get_specifications_value(doc, hash, '', 'Maximum Alternator Watts')\n get_specifications_value(doc, hash, '', 'Cold Cranking Amps @ 0° F (2nd)')\n get_specifications_value(doc, hash, 'max_alternator_capacity', 'Maximum Alternator Capacity (amps)', integer: true)\n get_specifications_value(doc, hash, 'max_trailering_capacity', 'Maximum Trailering Capacity (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_trailer_weight_distributing_hitch', 'Wt Distributing Hitch - Max Trailer Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_tongue_weight_distributing_hitch', 'Wt Distributing Hitch - Max Tongue Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_trailer_weight_dead_weight_hitch', 'Dead Weight Hitch - Max Trailer Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, 'max_tongue_weight_dead_weight_hitch', 'Dead Weight Hitch - Max Tongue Wt. (lbs)', integer: true)\n get_specifications_value(doc, hash, '', 'Fifth Wheel Hitch - Max Tongue Wt. (lbs)')\n get_specifications_value(doc, hash, '', 'Fifth Wheel Hitch - Max Trailer Wt. (lbs)')\n get_specifications_value(doc, hash, '', 'Wt Distributing Hitch - Max Trailer Wt. (lbs)')\n\n end\n\n end\n\n return hash\nend",
"def is_correct_answer?(correct, answer)\n correct = correct.gsub(/^(the|a|an) /i, \"\")\n .gsub(/^(the|a|an) /i, \"\")\n .gsub(\"one\", \"1\")\n .gsub(\"two\", \"2\")\n .gsub(\"three\", \"3\")\n .gsub(\"four\", \"4\")\n .gsub(\"five\", \"5\")\n .gsub(\"six\", \"6\")\n .gsub(\"seven\", \"7\")\n .gsub(\"eight\", \"8\")\n .gsub(\"nine\", \"9\")\n .gsub(\"ten\", \"10\")\n .strip\n .downcase\n\n correct_no_parenthetical = correct.gsub(/\\(.*\\)/, \"\").gsub(/[^\\w\\s]/i, \"\").strip\n correct_sanitized = correct.gsub(/[^\\w\\s]/i, \"\")\n\n answer = answer\n .gsub(/\\s+( |&)\\s+/i, \" and \")\n .gsub(/[^\\w\\s]/i, \"\")\n .gsub(/^(what|whats|where|wheres|who|whos|when|whens) /i, \"\")\n .gsub(/^(is|are|was|were) /, \"\")\n .gsub(/^(the|a|an) /i, \"\")\n .gsub(/\\?+$/, \"\")\n .gsub(\"one\", \"1\")\n .gsub(\"two\", \"2\")\n .gsub(\"three\", \"3\")\n .gsub(\"four\", \"4\")\n .gsub(\"five\", \"5\")\n .gsub(\"six\", \"6\")\n .gsub(\"seven\", \"7\")\n .gsub(\"eight\", \"8\")\n .gsub(\"nine\", \"9\")\n .gsub(\"ten\", \"10\")\n .strip\n .downcase\n [correct_sanitized, correct_no_parenthetical].each do |solution|\n white = Text::WhiteSimilarity.new\n similarity = white.similarity(solution, answer)\n if solution == answer || similarity >= ENV[\"SIMILARITY_THRESHOLD\"].to_f\n return true\n end\n end\n false\nend",
"def the_lineup #in short, this returns only phrases that have situations which are selected AND scores (familiarity levels) which have been selected\n the_situations = []\n the_scores = []\n the_phrases = []\n @situations.each do |s|\n if s.studying_now == true\n the_situations << s.id\n else\n next\n end\n end\n#the_situations = @situations.map do {|s| s.studying_now == true}\n# do this for scores (with map)\n# do this for phrases (with map)\n\n @scores.each do |s|\n if s.studying_now == true\n the_scores << s.id\n else\n next\n end\n end\n\n the_situations.each do |this_situation_id| #checking situations that are true\n a_situation = @situations.find(this_situation_id) #a single situation that is true\n\n the_scores.each do |this_score_id| #checking scores that are true\n a_score = @scores.find(this_score_id) #a single true score for this iteration\n\n all_phrases_in_a_situation = a_situation.phrases.all #all the phrases for the relevant situation\n all_phrases_in_a_situation.each do |this_phrase| #cycling over a given phrase in a true situation\n if (this_phrase.score_id == a_score.id) && (this_phrase.familiarity_score < 100.0)\n the_phrases << this_phrase\n else\n next\n end\n end\n\n end\n end\n\n the_phrases\n\n #a phrase should have the correct id from situations array\n #a phrase should have the correct id from scores array\n #a phrase should also have a score less than the trip wire\n\n #phrase.familiarity score should autoset at situations home (it does)\n end",
"def match_sentiment(form_feeling)\n if form_feeling == \"sad\"\n audio_features.valence < 0.4\n elsif form_feeling == \"angry\"\n audio_features.valence >= 0.4 && audio_features.valence <= 0.6\n elsif form_feeling == \"calm\"\n audio_features.valence > 0.4 && audio_features.tempo < 100\n elsif form_feeling == \"happy\"\n audio_features.valence > 0.6\n end\n end",
"def tell_fortunte()\n\t\tprint \"The answer is \" + $prediction + \". \\n\\n: \"\n\tend",
"def check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n if count_copies > 0 #resetting review_array only when plagiarism was found\n auto_metareview.review_array = rev_array\n\n\n if count_copies == scores.length\n return ALL_RESPONSES_PLAGIARISED #plagiarism, with all other metrics 0\n else\n return SOME_RESPONSES_PLAGIARISED #plagiarism, while evaluating other metrics\n end\n end\nend",
"def rearrange_questions(questions)\n if (check_threshold)\n return questions\n end\n\n # Initialize local variables\n panel_questions=Hash.new\n panel_scores=Hash.new\n questions_response_count=Hash.new\n sorted_panel_questions=Array.new\n prev_topic=nil\n current_topic=nil\n primary_response_count=0\n sorted_questions=Array.new\n grouped_questions=Array.new\n\n # Loop through questions array and store in a hash with its response counts\n questions.each {\n |question|\n question_type=question.question_type\n current_topic = question_type.parameters.split(\"::\")[0]\n grouping_position= question_type.parameters.split(\"::\").length==1 ? nil : question_type.parameters.split(\"::\").last.split(\"|\")[0]\n grouping_count= question_type.parameters.split(\"::\").length==1 ? nil : question_type.parameters.split(\"::\").last.split(\"|\")[1].to_i\n # grouping_position > 1 implies secondary questions among questions grouped by 1|2 logic\n # we need to call to_i method on grouping_position if it is a string\n if grouping_position.to_i<=1\n # create new hash set for new accordion panel\n unless (!current_topic.nil? && (current_topic==prev_topic || prev_topic.nil?))\n panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)\n panel_questions[prev_topic]=sorted_panel_questions\n panel_scores[prev_topic]=panel_score/sorted_panel_questions.length\n\n questions_response_count=Hash.new\n end\n # calculate response count when first checkbox type question comes\n # for the rest of the checkbox questions; assign the same calculated response count\n if question_type.q_type.eql? 'Checkbox'\n unless (!current_topic.eql? prev_topic)\n checkbox_questions=questions.select { |checkbox_question| checkbox_question.question_type.parameters.split(\"::\")[0].eql?(current_topic) }\n primary_response_count= find_number_of_responses_for_checkbox(checkbox_questions)\n end\n # calculate response count for corresponding comment for Rating type of questions\n elsif (question_type.q_type.eql? 'Rating') && (grouping_position.to_i==1)\n current_question_index=questions.index(question)\n curr_question=questions.fetch(current_question_index+1)\n primary_response_count= find_number_of_responses(curr_question)\n else # ungrouped questions\n primary_response_count= find_number_of_responses(question)\n end\n end\n questions_response_count[question.id]= primary_response_count\n prev_topic=current_topic\n }\n\n # Ensure last hash of questions is also included in the final rearranged question array\n unless (questions_response_count.empty?)\n panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)\n panel_questions[prev_topic]=sorted_panel_questions\n panel_scores[prev_topic]=panel_score/questions_response_count.length\n end\n\n # Create final array of rearranged questions by sorting hash of each panel\n panel_scores=Hash[panel_scores.sort_by { |k, v| v }]\n panel_scores.each {\n |key, value|\n panel_questions.fetch(key).each { |question| sorted_questions << question }\n }\n return sorted_questions\n end",
"def compute_reviews_hash\n @review_scores = {}\n @response_type = 'ReviewResponseMap'\n # @myreviewers = ResponseMap.select('DISTINCT reviewer_id').where(['reviewed_object_id = ? && type = ? ', self.id, @response_type])\n\n # if this assignment uses vary rubric by rounds feature, load @questions for each round\n if self.varying_rubrics_by_round? # [reviewer_id][round][reviewee_id] = score\n rounds = self.rounds_of_reviews\n for round in 1..rounds\n @response_maps = ResponseMap.where(['reviewed_object_id = ? && type = ?', self.id, @response_type])\n review_questionnaire_id = review_questionnaire_id(round)\n\n @questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n\n @response_maps.each do |response_map|\n # Check if response is there\n @corresponding_response = Response.where(['map_id = ?', response_map.id])\n unless @corresponding_response.empty?\n @corresponding_response = @corresponding_response.reject {|response| response.round != round }\n end\n @respective_scores = {}\n @respective_scores = @review_scores[response_map.reviewer_id][round] if !@review_scores[response_map.reviewer_id].nil? && !@review_scores[response_map.reviewer_id][round].nil?\n\n if !@corresponding_response.empty?\n # @corresponding_response is an array, Answer.get_total_score calculate the score for the last one\n @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)\n if @this_review_score_raw\n @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0\n end\n else\n @this_review_score = -1.0\n end\n\n @respective_scores[response_map.reviewee_id] = @this_review_score\n @review_scores[response_map.reviewer_id] = {} if @review_scores[response_map.reviewer_id].nil?\n @review_scores[response_map.reviewer_id][round] = {} if @review_scores[response_map.reviewer_id][round].nil?\n @review_scores[response_map.reviewer_id][round] = @respective_scores\n end\n end\n else # [reviewer_id][reviewee_id] = score\n @response_maps = ResponseMap.where(['reviewed_object_id = ? && type = ?', self.id, @response_type])\n review_questionnaire_id = review_questionnaire_id()\n\n @questions = Question.where(['questionnaire_id = ?', review_questionnaire_id])\n\n @response_maps.each do |response_map|\n # Check if response is there\n @corresponding_response = Response.where(['map_id = ?', response_map.id])\n @respective_scores = {}\n @respective_scores = @review_scores[response_map.reviewer_id] unless @review_scores[response_map.reviewer_id].nil?\n\n if !@corresponding_response.empty?\n # @corresponding_response is an array, Answer.get_total_score calculate the score for the last one\n @this_review_score_raw = Answer.get_total_score(response: @corresponding_response, questions: @questions)\n if @this_review_score_raw\n @this_review_score = ((@this_review_score_raw * 100) / 100.0).round if @this_review_score_raw >= 0.0\n end\n else\n @this_review_score = -1.0\n end\n @respective_scores[response_map.reviewee_id] = @this_review_score\n @review_scores[response_map.reviewer_id] = @respective_scores\n end\n\n end\n @review_scores\n end",
"def determine_percent_complete(log_string)\n message = log_string[/.*PerfAnal_CECNRes.-.(.*)$/, 1].chomp\n update_percent_complete(5, message)\n\n # find where we are\n states = [\n {/initializing ruleset/i => 0.5},\n {/loading sdd model/i => 2},\n {/back from loading sdd model/i => 2},\n {/defaulting model/i => 2},\n {/defaulting model/i => 5},\n {/writing user input to analysis results xml/i => 5},\n {/checking sdd model/i => 5},\n {/preparing model zb/i => 5},\n {/calling perfsim_e. for zb model/i => 5},\n {/back from perfsim_e. (zb model, 0 return value)/i => 35},\n {/exporting zb model details to results xml/i => 35},\n {/preparing model ap/i => 40},\n {/calling perfsim_e. for ap model/i => 40},\n {/back from perfsim_e. (ap model, 0 return value)/i => 40},\n {/preparing model ab/i => 40},\n {/calling perfsim_e. for ab model/i => 40},\n {/back from perfsim_e. (ab model, 0 return value)/i => 100},\n {/umlh check on ab model/i => 100},\n {/exporting ab model details to results xml/i => 100}\n ]\n\n states.reverse.each do |s|\n if log_string =~ s.keys.first\n update_percent_complete(s.values.first, message)\n break\n end\n end\n end",
"def calculate\n candidates = []\n\n generalized_cause = NLU::Generalization.new(symbols: @symbols).generalize(@cause)\n\n #ap \"sentence: #{cause_sentence}\"\n #ap \"learned: #{@learned.inspect}\"\n\n # We go through everything that was learned before\n @learned.each do |function_name, criteria|\n criteria[:generalizations].each do |generalization|\n\n # We generate a pre-candidate for this generalization. It starts\n # with score zero because we don't know yet whether this criteria\n # fits the sentence or not.\n local_candidate = {\n fn: function_name,\n attrs: { },\n score: 0.0\n }\n\n #ap \"generalized_cause #{generalized_cause}\"\n\n # We then generalize the cause sentence and go through it.\n # We will match *each* learned generalization against the cause\n # generalization.\n generalized_cause.each_with_index do |cause_rule, cause_index|\n\n\n # Wildcard\n #\n # Matches these:\n #\n # > i want a [type:wildcard:some_name_for_this_wildcard]\n # > i want a ford\n #\n wildcard = \"[#{NLU::Generalization::RESERVED_TYPES[:wildcard]}]\"\n #ap \"wildcard: #{wildcard}\"\n wildcard_regex = Regexp.escape(wildcard)\n if generalization =~ /wildcard/i\n wildcard_generalization = generalization\n .gsub(/\\[(type:wildcard)(.+)\\]/i, '[\\1]')\n end\n #ap \"wildcard_generalization(#{wildcard_generalization}) =~ cause_rule(#{wildcard_regex})\"\n if wildcard_generalization.to_s =~ Regexp.new(wildcard_regex, Regexp::IGNORECASE)\n #ap \"true -> #{wildcard_generalization} =~ /#{Regexp.new(wildcard_regex, Regexp::IGNORECASE)}/i\"\n\n rule = wildcard_generalization.gsub(\"#{wildcard}\", \"(.+)\")\n #ap \"rule #{rule}\"\n #binding.pry\n if value = cause_sentence.join(\" \").match(Regexp.new(rule, Regexp::IGNORECASE))\n value = value[-1]\n prop = attr_name_from_type_param(generalization)\n\n local_candidate = local_candidate.merge({\n attrs: {\n prop => value\n },\n score: 0.75\n })\n end\n\n # If we find a learned generalization that matches the generalized\n # sentence, we will save it.\n elsif generalization == cause_rule\n cause_rule.split(\" \").each_with_index do |typed_string, index|\n\n # If the learned generalization has a type anywhere, we will\n # check what is the corresponding word in the cause sentence.\n #\n # For example, consider the following sentence:\n #\n # [type:subject] want a [type:make]\n #\n # and the sentence\n #\n # I want a ford\n #\n # Finding `[type:make]` at position 3 of the array, we will\n # get `ford` at the position 3 of the cause sentence. With\n # that we can come up with `{make: 'ford'}`.\n #\n if typed_string =~ /\\[type/i\n local_candidate[:score] += 1\n type = attr_name_from_type_param(typed_string)\n prop = type_properties(type)\n type_token_length = prop[:token_length]\n\n # In `i want a car`, this will get the `i`. If the type\n # says instead that it's formed by two symbols (e.g\n # `i want`), then it will take `i want`.\n #\n # The -1 in the brackets is because otherwise it would be\n # translated to the following if the type had 1 symbol\n #\n # cause_sentence[1..1+1]\n #\n # That would take 2 words (`[1..2]`). We want one word, so\n #\n # cause_sentence[1..1+1-1]\n #\n word_for_type = cause_sentence[index..index+(type_token_length-1)]\n #ap \"> type: #{type} - #{index} #{cause_sentence[index..index+type_token_length]}\"\n\n local_candidate[:attrs][type] = word_for_type.join(\" \")\n\n # When it's just the same sentence as one seen before, no\n # generalizations\n else\n local_candidate[:score] = 1\n end\n end\n\n end\n end\n\n if local_candidate[:score] > 0\n candidates << local_candidate\n end\n end\n end\n\n # TODO - normalization is taking out some elements that are good.\n #candidates = normalize_scores(candidates)\n candidates = pick_candidates(candidates)\n candidates = merge_attributes(candidates)\n\n candidates\n end",
"def classificateResult(label, sampleMap, foundAllArr)\n puts \"[classificateResult] started label #{label}\"\n foundArr = foundAllArr.select{|found| matchLabels?(found.label, label)}\n expRecognitionResult = Spnt::Exp::Data::ExpRecognitionResult.new()\n expRecognitionResult.falseNegative = []\n expRecognitionResult.falsePostive = []\n #missed = sampleArr - foundArr\n #1 step. filter that was found and transform to array\n substituted = sampleMap.select{|ekey, sample|\n if(matchLabels?( label, sample.label))\n nil == foundArr.detect{|found| sample.ekey == found.ekey && found.shouldStart != @@UNDEFINED_CELL} \n end\n }.collect { |k, v| v }\n deleted =foundArr.select{|found|\n found.foundStart == nil || found.foundStart == @@UNDEFINED_CELL \n }\n inserted =foundArr.select{|found|\n found.shouldStart == nil || found.shouldStart == @@UNDEFINED_CELL \n }\n \n puts \"[classificateResult] %s substituted: %i\" % [label, substituted.length]\n puts \"[classificateResult] %s deleted: %i\" % [label, deleted.length]\n puts \"[classificateResult] %s inserted: %i\" % [label, inserted.length]\n\n expRecognitionResult.falseNegative = (expRecognitionResult.falseNegative << substituted).flatten\n expRecognitionResult.falseNegative = (expRecognitionResult.falseNegative << deleted).flatten\n expRecognitionResult.falsePostive = (expRecognitionResult.falsePostive << inserted).flatten\n \n puts \"[classificateResult] %s falseNegative: %i\" % [label, expRecognitionResult.falseNegative.length]\n puts \"[classificateResult] %s falsePostive: %i\" % [label, expRecognitionResult.falsePostive.length]\n\n\n puts \"[classificateResult]substituted: \" + substituted.collect{|v| \" %i => %s[%s]\" % [v.id, v.ekey, v.foundStart]}.join(\"; \")\n\n# foundDuplicates = {}\n# expRecognitionResult.correct = foundArr.select{|found|\n# sample = sampleMap[found.ekey]\n# if(sample != nil && matchLabels?( label, found.label))\n# if(found.foundStart == nil)\n# #puts \"[classificateResult]falseNegative [#{found.ekey}] no start: #{sample.shouldStart} #{found.foundStart}\"\n# expRecognitionResult.falseNegative << sample\n# false\n# else\n# absStartDelta = (sample.shouldStart - found.foundStart).abs\n# absEndDelta = (sample.shouldEnd - found.foundEnd).abs\n# matched = sample.ekey == found.ekey && absStartDelta <= @@thresholdStart && absEndDelta <= @@thresholdEnd\n# if matched == true\n# foundDuplicateElement = foundDuplicates[found.ekey]\n# if foundDuplicateElement == nil\n# foundDuplicateElement = []\n# foundDuplicates[found.ekey] = foundDuplicateElement\n# end\n# foundDuplicateElement << found\n# #puts \"foundDuplicates[#{sample.ekey}] #{foundDuplicates[sample.ekey].length} #{matched && foundDuplicates[sample.ekey].length == 1}\"\n# end\n# matched && foundDuplicates[sample.ekey].length == 1\n# end\n# else\n# false\n# end\n# }\n #expRecognitionResult.falsePostive = foundArr.select{|found| !expRecognitionResult.correct.include?(found) && !expRecognitionResult.falseNegative.include?(found)}\n# expRecognitionResult.correct = foundArr.select{|found|\n# expRecognitionResult.falsePostive.include?(found) && expRecognitionResult.falseNegative.include?(found)\n# }\n expRecognitionResult.correct = foundArr.to_set - expRecognitionResult.falsePostive.to_set - expRecognitionResult.falseNegative.to_set;\n puts \"falsePostive[#{expRecognitionResult.falsePostive.length}] + falseNegative[#{expRecognitionResult.falseNegative.length}]+correct[#{expRecognitionResult.correct.length}] = foundArr[#{foundArr.length}]\"\n expRecognitionResult\n end",
"def hypothesis4(countsXmajor) \n\tcriteria = 0\n\tphotoeuks = 0\n\tnonPhotoeuks = 0\n\tphotoeuks += 1 if countsXmajor['Sr'] >= 0.25\n\tphotoeuks += 1 if countsXmajor['Pl'] >= 0.25\n\tphotoeuks += 1 if countsXmajor['EE'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Op'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Am'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] >= 0\n\tcriteria += 1 if countsXmajor['Za'] < 0.25\n\tcriteria += 1 if photoeuks >= 2\n\tcriteria += 1 if nonPhotoeuks == 0\n\tif criteria == 4\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def advanced_prediction(location=nil, choice_code=nil, outputs=nil)\n if outputs != nil\n puts \"\"\n puts \" Here is the predicted annual kWhac (kiloWattHours AC) for your system\"\n puts \"\"\n puts \" #{outputs} kWhac\"\n puts \" ---------------\"\n puts \"\"\n puts \"\"\n puts \" ...........\"\n sleep(1)\n puts \" . . . .\"\n sleep(1)\n puts \" . . .\"\n sleep(1)\n puts \" . ..... .\"\n sleep(1)\n puts \" ...........\"\n puts \"\"\n puts \" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"\n puts \"\"\n puts \"\"\n puts \" send feedback to : [email protected]\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n exit(true) #comment out to save in memory\n SolarVerde::CLI.new.initialize #restarts program if above commented out\n end\n if choice_code == \"1\"\n outputs = AdvancedGather.simple(location)\n puts \"\"\n puts \" Here is the predicted annual kWhac (kiloWattHours AC) for your system\"\n puts \"\"\n puts \" #{outputs} kWhac\"\n puts \" ---------------\"\n puts \"\"\n puts \"\"\n puts \" ...........\"\n sleep(1)\n puts \" . . . .\"\n sleep(1)\n puts \" . . .\"\n sleep(1)\n puts \" . ..... .\"\n sleep(1)\n puts \" ...........\"\n puts \"\"\n puts \" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\"\n puts \"\"\n puts \"\"\n puts \" send feedback to : [email protected]\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n #exit(true) #comment out to save in memory\n SolarVerde::CLI.new #restart intialize if exit was commented out\n elsif choice_code == \"2\"\n puts \"\"\n puts \" Please answer the following questions to the best of your ability.\"\n puts \" ------------------------------------------------------------------\"\n puts \"\"\n puts \" The units will be described in the question. NUMBERS ONLY, 'h' for help. \"\n puts \" ::::::::::::::::::::::::::::::::::::::::::::::::::\"\n puts \"\"\n puts \"\"\n #call methods for question variables\n system_capacity = capacity()\n azimuth = direction()\n tilt = til()\n array_type = type_arr()\n module_type = type_mod()\n losses = loss()\n\n outputs = AdvancedGather.complex(location, system_capacity, azimuth, tilt, array_type, module_type, losses)\n puts \"\"\n puts \" Here is the predicted annual kWhac (kiloWattHours AC) for your system\"\n puts \"\"\n puts \" #{outputs} kWhac\"\n puts \" ---------------\"\n puts \"\"\n puts \"\"\n puts \" send feedback to : [email protected]\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n # exit(true) #comment out to save.\n #exit(true)\n SolarVerde::CLI.new\n end\nend",
"def hypothesis6(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\n\tcriteria += 1 if countsXmajor['Ba'] < 0.25\n\tcriteria += 1 if countsXmajor['Za'] < 0.25\n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def compare_reviews_with_responses(auto_metareview, map_id)\n review_text_arr = auto_metareview.review_array\n response = Response.find(:first, :conditions => [\"map_id = ?\", map_id])\n scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n\n #fetching the questions for the responses\n\n\n count_copies = 0 #count of the number of responses that are copies either of questions of other responses\n rev_array = Array.new #holds the non-plagiairised responses\n\n\n\n #comparing response with other responses\n flag = 0\n for j in 0..review_text_arr.length - 1\n if(i != j and !review_text_arr[i].nil? and !review_text_arr[j].nil? and review_text_arr[i].downcase == review_text_arr[j].downcase)\n count_copies+=1\n flag = 1\n break\n end\n end\n\n if(flag == 0) #ensuring no match with any of the review array's responses\n rev_array << review_text_arr[i]\n end\n\n\n #setting @review_array as rev_array\n check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n\n end",
"def hypothesis5(countsXmajor) \n\tcriteria = 0\n\tphotoeuks = 0\n\tnonPhotoeuks = 0\n\tphotoeuks += 1 if countsXmajor['Sr'] >= 0.25\n\tphotoeuks += 1 if countsXmajor['Pl'] >= 0.25\n\tphotoeuks += 1 if countsXmajor['EE'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Op'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Am'] >= 0.25\n\tnonPhotoeuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] >= 0\n\tcriteria += 1 if countsXmajor['Za'] < 0.25\n\tcriteria += 1 if photoeuks == 3\n\tcriteria += 1 if nonPhotoeuks == 0\n\tif criteria == 4\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def get_fortune\r\n randomNo = 1 + rand(10)\r\n\r\n #Assign an answer based on the randomly generated number\r\n case randomNo\r\n when 1\r\n $prediction = \"It is certain\"\r\n when 2\r\n $prediction = \"Reply hazy, try again\"\r\n when 3\r\n $prediction = \"Don't count on it\"\r\n when 4\r\n $prediction = \"Without a doubt\"\r\n when 5\r\n $prediction = \"Concentrate and ask again\"\r\n when 6\r\n $prediction = \"My sources say no\"\r\n when 7\r\n $prediction = \"You may rely on it\"\r\n when 8\r\n $prediction = \"Ask again later\"\r\n when 9\r\n $prediction = \"Very doubtful\"\r\n when 10\r\n $prediction = \"Outlook is good\"\r\n end\r\n\r\n end",
"def correct_answer(x)\n \t return true if x =~ /Empate: /\n \t \n return true if x =~ /Gana maquina. Maquina (\\w+) versus Jugador (\\w+)/ and RockPaperScissors.defeat[$1.to_sym] == $2.to_sym\n return true if x =~ /Bien, gana el jugador. Jugador: (\\W+) versus Maquina: (\\w+)/ and RockPaperScissors.defeat[$1.to_sym] == $2.to_sym\n \tend",
"def fitness_question1(fitness_answer1)\n if fitness_answer1 == \"3 or more times per week\"\n @fitness_score1 = 0\n elsif fitness_answer1 == \"1 - 2 times per week\"\n @fitness_score1 = 1\n elsif fitness_answer1 == \"never\"\n @fitness_score1 = 2\n end\n @fitness_score1\nend",
"def generate_predictions\n stat_hash = @email_statistics.hashed_statistics\n temp = stat_hash.sort_by{ |k, v| v }\n max_value = temp.last.last\n stat_hash.each{ |k,v| @predictions << k if v == max_value }\n # puts @predictions\n # puts \"-\" * 30\n end",
"def approximate_recommendation\n segments = self.segments\n\n segments.pop while segments.any? {|s| String === s }\n segments.pop while segments.size > 2\n segments.push 0 while segments.size < 2\n\n recommendation = \"~> #{segments.join(\".\")}\"\n recommendation += \".a\" if prerelease?\n recommendation\n end",
"def get_correct_answer(question_prompt, answers)\n question_prompt = question_prompt.downcase\n answer = nil\n case question_prompt\n when /which number goes with your street on/\n answer = answers[answers.index('3612') || answers.index('5555') || answers.index('None of the above')]\n when /which street have you lived on/\n answer = answers[answers.index('BEACH') || answers.index('None of the above') || 0]\n when /in which city is/\n answer = answers[answers.index('ATLANTA') || answers.index('None of the above')]\n when /in which county was your/\n answer = answers[answers.index('FULTON') || answers.index('None of the above')]\n when /what year is your/\n answer = answers[answers.index('2005')]\n when /which of the following people do you know/\n answer = answers[answers.index('ANTHONY BROWN') || answers.index('None of the above')]\n when /in wich year were you born/\n answer = answers[answers.index('1975')]\n when /what type of residence is/\n answer = answers[answers.index('Single Family Residence')]\n when /in which month month were you born/\n answer = answers[answers.index('FEBRUARY')]\n when /in which county have you lived/\n answer = answers[answers.index('FULTON') || answers.index('None of the above')]\n when /what are the last two digits of your social security number/\n answer = answers[answers.index('33')]\n when /at which of the following addresses have you lived/\n answer = answers[answers.index('None of the above')]\n when /which person is not a relative or someone that you know/\n answer = answers.grep(/SMITH/).first\n when /with which name are you associated/\n answer = answers[answers.index('None of the above')]\n when /what are the first two digits of your social security number/\n answer = answers[answers.index('11') || answers.index('None of the above')]\n when /which of the following phone numbers is related to you/\n answer = answers[answers.index('None of the above')]\n when /from whom did you purchase the property at/\n answer = answers[answers.index('JOE ANDERSON') || answers.index('None of the above')]\n when /how long have you been associated with the property at/\n answer = answers[answers.index('Over 5 years')]\n when /what is the approximate square footage of the property at/\n answer = answers[answers.index('Over 2,500')]\n when /when did you purchase the property at/\n answer = answers[answers.index('August 1999') || answers.index('None of the above')]\n when /between/ && /in which state did you live/\n answer = answers[answers.index('NEW YORK')]\n when /when did you purchase or lease your/\n answer = answers[answers.index('December 2006')]\n when /with which name are you associated/\n answer = answers[answers.index('None of the above')]\n end\n answer\n end",
"def satisfaction (profile_a, profile_b)\n earned_points = 0\n possible_points = 0\n\n profile_a_answers = answer_dictionary(profile_a)\n profile_b_answers = answer_dictionary(profile_b)\n\n profile_a_answers.each do |question|\n # if profile_b answered the question\n if profile_b_answers[question]\n # calculate importance of question\n importance = IMPORTANCE[question['importance']]\n\n # increase possible points by the importance\n possible_points += importance\n\n # if profile_b's answered one of the acceptable answers\n if question['acceptableAnswers'].include? profile_b_answers[question].answer\n earned_points += importance\n end\n end\n end\n\n # return the float divison\n satisfaction = earned_points.fdiv(possible_points)\nend",
"def orf_find(prediction = @prediction)\n\n if prediction.seq_type != \"nucleotide\"\n \"-\"\n end\n \n #stop codons\n stop_codons = [\"TAG\", \"TAA\", \"TGA\"]\n #minimimum ORF length\n orf_length = 100\n \n seq = prediction.raw_sequence\n stops = {}\n result = {}\n\n stop_codons.each do |codon|\n occurences = (0 .. seq.length - 1).find_all { |i| seq[i,3].downcase == codon.downcase }\n occurences.each do |occ|\n stops[occ + 3] = codon\n end\n end\n\n\n #direct strand\n stop_positions = stops.map{|x| x[0]}\n result[\"+1\"] = []\n result[\"+2\"] = []\n result[\"+3\"] = []\n result[\"-1\"] = []\n result[\"-2\"] = []\n result[\"-3\"] = []\n\n #reading frame 1, direct strand\n m3 = stops.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"+1\"\n result[\"+1\"].push([m3[i-1], m3[i]])\n end\n end\n \n #reading frame 2, direct strand\n m3_1 = stops.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n# result[[m3_1[i-1], m3_1[i]]] = \"+2\"\n result[\"+2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n #reading frame 3, direct strand\n m3_2 = stops.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n# result[[m3_2[i-1], m3_2[i]]] = \"+3\"\n result[\"+3\"].push([m3_2[i-1], m3_2[i]])\n end\n end\n\n #reverse strand\n stops_reverse = {}\n seq_reverse = seq.reverse.downcase.gsub('a','T').gsub('t','A').gsub('c','G').gsub('g','C')\n stop_codons.each do |codon|\n occurences = (0 .. seq_reverse.length - 1).find_all { |i| seq_reverse[i,3].downcase == codon.downcase }\n #puts \"-1 #{codon}: #{occurences.to_s}\"\n occurences.each do |occ|\n stops_reverse[occ + 3] = codon\n end\n end\n\n stop_positions_reverse = stops_reverse.map{|x| x[0]}\n m3 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 0}.sort\n m3 = [1, m3, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3: #{m3.to_s}\"\n (1..m3.length-1).each do |i|\n if m3[i] - m3[i-1] > orf_length\n# result[[m3[i-1], m3[i]]] = \"-1\"\n result[\"-1\"].push([m3[i-1], m3[i]])\n end\n end\n\n m3_1 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 1}.sort\n m3_1 = [2, m3_1, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 1: #{m3_1.to_s}\"\n (1..m3_1.length-1).each do |i|\n if m3_1[i] - m3_1[i-1] > orf_length\n result[\"-2\"].push([m3_1[i-1], m3_1[i]])\n end\n end\n\n m3_2 = stops_reverse.map{|x| x[0]}.select{|y| y % 3 == 2}.sort\n m3_2 = [3, m3_2, prediction.raw_sequence.length].flatten\n #puts \"-1 multiple of 3 + 2: #{m3_2.to_s}\"\n (1..m3_2.length-1).each do |i|\n if m3_2[i] - m3_2[i-1] > orf_length\n result[\"-3\"].push([m3_2[i-1], m3_2[i]])\n# result[[m3_2[i-1], m3_2[i]]] = \"-3\"\n end\n end\n\n result\n end",
"def decision_tree_evaluate(i,j)\n rules = IO.read(Constant.new(@c,\"decision_rules\").filename(i))\n data = CSV.read(Constant.new(@c,\"csv_test\").filename(j))\n data.shift\n correct, count, unmatched = 0,0,[]\n data.each do |d|\n puts d[0..-2].inspect\n puts d[-1].inspect\n indegree_ratio, outdegree_ratio, outindegree_ratio = d[0], d[1], d[2]\n inmsg_ratio, outmsg_ratio, mutualin_nbrs_ratio = d[3], d[4], d[5]\n reciprocated = nil\n eval(rules)\n begin\n correct += 1 if reciprocated == d[-1]\n rescue\n unmatched << d\n end\n count += 1\n end\n \n File.open(Constant.new(@c,\"decision_results_basedon\",[i]).filename(j),\"w\") do |f|\n f.puts \"Using rules of %d on %j\" % [i,j]\n f.puts \"XAccuracy: %d %d %.4f\" % [correct, count, (correct-0.0)/count]\n f.puts \"Unmatched: \"\n unmatched.each { |u| f.puts u.inspect }\n end\n end",
"def rearrange_questions(questions)\n return questions if check_threshold\n\n # Initialize local variables\n panel_questions = {}\n panel_scores = {}\n questions_response_count = {}\n sorted_panel_questions = []\n prev_topic = nil\n current_topic = nil\n primary_response_count = 0\n sorted_questions = []\n grouped_questions = []\n\n # Loop through questions array and store in a hash with its response counts\n questions.each do |question|\n question_type = question.question_type\n current_topic = question_type.parameters.split(\"::\")[0]\n grouping_position = question_type.parameters.split(\"::\").length == 1 ? nil : question_type.parameters.split(\"::\").last.split(\"|\")[0]\n grouping_count = question_type.parameters.split(\"::\").length == 1 ? nil : question_type.parameters.split(\"::\").last.split(\"|\")[1].to_i\n # grouping_position > 1 implies secondary questions among questions grouped by 1|2 logic\n # we need to call to_i method on grouping_position if it is a string\n if grouping_position.to_i <= 1\n # create new hash set for new accordion panel\n unless !current_topic.nil? && (current_topic == prev_topic || prev_topic.nil?)\n panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)\n panel_questions[prev_topic] = sorted_panel_questions\n panel_scores[prev_topic] = panel_score / sorted_panel_questions.length\n\n questions_response_count = {}\n end\n # calculate response count when first checkbox type question comes\n # for the rest of the checkbox questions; assign the same calculated response count\n if question_type.q_type.eql? 'Checkbox'\n if current_topic.eql? prev_topic\n checkbox_questions = questions.select {|checkbox_question| checkbox_question.question_type.parameters.split(\"::\")[0].eql?(current_topic) }\n primary_response_count = find_number_of_responses_for_checkbox(checkbox_questions)\n end\n # calculate response count for corresponding comment for Rating type of questions\n elsif (question_type.q_type.eql? 'Rating') && (grouping_position.to_i == 1)\n current_question_index = questions.index(question)\n curr_question = questions.fetch(current_question_index + 1)\n primary_response_count = find_number_of_responses(curr_question)\n else # ungrouped questions\n primary_response_count = find_number_of_responses(question)\n end\n end\n questions_response_count[question.id] = primary_response_count\n prev_topic = current_topic\n end\n\n # Ensure last hash of questions is also included in the final rearranged question array\n unless questions_response_count.empty?\n panel_score, sorted_panel_questions = process_panel(questions, questions_response_count)\n panel_questions[prev_topic] = sorted_panel_questions\n panel_scores[prev_topic] = panel_score / questions_response_count.length\n end\n\n # Create final array of rearranged questions by sorting hash of each panel\n panel_scores = Hash[panel_scores.sort_by {|_k, v| v }]\n panel_scores.each do |key, _value|\n panel_questions.fetch(key).each {|question| sorted_questions << question }\n end\n sorted_questions\n end",
"def convertToBoard(text)\n response=text\n\n responseArray=response.split(\" \")\n # responseArray = Capture.find(:all)\n responseArray.delete('and')\n # responseArray.reject! { |item| item.text =~ 'and' }\n puts response.size\n puts responseArray.size\n if responseArray.size==1\n if response.size<=4\n response=response.upcase\n else \n puts \"shortening response\"\n response=response[0..3].upcase\n end\n elsif responseArray.size==2\n if not is_num(responseArray[1])\n if responseArray[0].size<=3\n response=responseArray[0][0..responseArray[0].size].upcase + responseArray[1][0].upcase\n else\n response=responseArray[0][0..2].upcase + responseArray[1][0].upcase\n end\n else\n if responseArray[1].size>=2\n response=responseArray[0][0..1].upcase + responseArray[1][responseArray[1].size-3..responseArray[1].size-1]\n else\n response=responseArray[0][0..1].upcase + responseArray[1][0..responseArray[1].size-1]\n end\n end\n else\n puts\"size invalid\"\n response=responseArray[0][0].upcase+responseArray[1][0].upcase+responseArray[2][0].upcase\n end\n return response\nend",
"def proof_of_stake\n title(\"Proof of Stake\")\n\n eco_scale = \"https://en.wikipedia.org/wiki/Economies_of_scale\"\n pros1 = \"Energy efficient\"\n pros2 = \"More expensive to attack for attackers\"\n pros3 = \"Not susceptible to ecnomies of scale \\n\\t (for more details about this topic click on this link:\\n\\t #{eco_scale}).\"\n\n pros = [pros1, pros2, pros3]\n\n nothing_at_stake = \"https://medium.com/coinmonks/understanding-proof-of-stake-the-nothing-at-stake-theory-1f0d71bc027\"\n cons = \"nothing-at-stake problem \\n(for more details click on this link:\\n#{nothing_at_stake})\"\n\n\n ppc = {name: \"Peercoin\", website: \"https://peercoin.net/\"}\n pivx = {name: \"Pivx\", website: \"https://pivx.org/\"}\n rdd = {name: \"Reddcoin\", website: \"https://reddcoin.com/\"}\n\n used_by = [ppc, pivx, rdd]\n\n consensus_type = \"Competitive consensus\"\n\n\n explanation = \"\"\"\n The proof of stake was created as an alternative to the proof of work (PoW),\n to tackle inherent issues in the latter. Here instead of using mining, you\n have to have some stake(coins) in the system. So, if you own 10% of the\n stake(coins), then your probability of mining next block will be 10%.\n \"\"\"\n\n further_reading = \"https://en.wikipedia.org/wiki/Proof_of_stake\"\n\n p_o_s = {\n \"pros\" => pros,\n \"cons\" => cons,\n \"used_by\" => used_by,\n \"consensus_type\" => consensus_type,\n \"explanation\" => explanation,\n \"further_reading\" => further_reading\n }\n\n choice = \"0\"\n\n while !choice.include?(\"Q\") && !choice.include?(\"q\")\n choice = consensus_features\n if choice.include?(\"1\")\n puts \"Pros:\"\n p_o_s[\"pros\"].each_with_index { |val, index| puts \"\\t#{index+1}) #{val}\" }\n\n cons = p_o_s[\"cons\"]\n puts \"Cons: #{cons}\"\n elsif choice.include?(\"2\")\n puts \"Used by:\"\n p_o_s[\"used_by\"].each_with_index do\n |valeur, index|\n puts \"#{index+1})\"\n valeur.each do\n |key, value| puts \" #{key}: #{value}\"\n end\n end\n puts \"And others.\"\n elsif choice.include?(\"3\")\n consensus_type = p_o_s[\"consensus_type\"]\n puts \"Type: #{consensus_type}\"\n elsif choice.include?(\"4\")\n explanation = p_o_s[\"explanation\"]\n puts \"Explanation: #{explanation}\"\n elsif choice.include?(\"5\")\n further_reading = p_o_s[\"further_reading\"]\n puts \"Further Reading: #{further_reading}\"\n elsif choice.include?(\"Q\") || choice.include?(\"q\")\n break\n else\n puts \"Error\"\n end\n end\n\nend",
"def questionnaire_params\n params.require(:questionnaire).permit(:fio, :school_number, :index, :city, :street, :building, :apartment, :phone_number, :filling_date, :stay_duration, :industrial_presence, :age, :birth_date, :sex, \n :a_1, :a_2, :a_3, :a_4, :a_5, :a_6, :a_7, :a_8, \n :b_1, :b_2, :b_3, :b_4_01, :b_4_02, :b_4_03, :b_4_04, :b_4_05, :b_4_06, :b_4_07, :b_4_08, :b_4_09, :b_4_10, :b_4_11, :b_4_12, :b_5, :b_6, \n :c_1, :c_2, :c_3, :c_4, :c_5, :c_6, :c_7, \n :d_1_1, :d_1_2, :d_1_3, :d_1_4, :d_1_5, :d_1_6, :d_1_7, :d_1_8, :d_1_9, :d_1_10, :d_1_11, :d_1_12, :d_1_13, :d_1_14, :d_1_15, :d_1_16, :d_1_17, :d_1_18, :d_1_19, :d_1_20, :d_1_20_description, :d_1_0, :d_2_1, :d_2_2, :d_2_3, :d_2_4, :d_2_5, :d_2_6, :d_2_7, :d_2_8, :d_2_9, :d_2_10, :d_2_11, :d_2_12, :d_2_13, :d_2_14, :d_2_15, :d_2_16, :d_2_17, :d_2_18, :d_2_19, :d_2_20, :d_2_0, :d_3,\n :dop_1, :dop_2_1, :dop_2_2, :dop_2_3, :dop_2_4, :dop_2_5, :dop_3, :dop_4, :dop_5, :dop_6_1, :dop_6_2, :dop_6_3, :dop_6_4, :dop_6_5, :dop_7_1, :dop_7_2, :dop_7_3, :dop_7_4, :dop_7_5, :dop_8_1, :dop_8_2, :dop_8_3, :dop_8_4, :dop_8_5, :dop_9_1, :dop_9_2, :dop_9_3, :dop_9_4, :dop_10_1, :dop_10_2, :dop_10_3, :dop_10_4, :dop_10_5, :dop_10_6, :dop_11, :dop_12, :dop_13, :dop_14, :dop_15,\n :page)\n end",
"def checkRIS(inputStr)\n \n img1 = 'Actions/RNA/RIS_QC_image.JPG'\n show do \n title \"Verfying mRNA Bands & RNA Integrity\"\n separator\n note \"The image below is an example of different levels of RNA integrity.\"\n bullet \"The more prominent the two mRNA peaks are the higher the RNA integrity.\"\n image img1\n note \"<b>Continue on to the next step to evaluate samples for RNA Integrity</b>\"\n end\n \n ops_by_row = operations.group_by {|op| op.get(:qc_row) }\n log_info 'ops_by_row', ops_by_row\n \n rows = ('A'..'H').to_a\n ops_by_row.each do |row, ops|\n \n data = show do\n title \"Row #{row.to_i + 1}: Verify mRNA Bands & RNA Integrity\"\n separator\n note \"Select each well under <b>analyze</b> -> <b>electropherogram</b> to see mRNA peaks.\"\n bullet \"There should be two bands that correspond to yeast mRNA at ~<b>1800bp</b> (18S) and ~<b>3500bp</b> (28S).\"\n ops.each do |op|\n select ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],\n var: \"[#{op.get(:qc_row)}, #{op.get(:qc_column)}]\",\n label: \"What is the RNA Integrity Score of the electropherogram at position #{rows[row.to_i] + (op.get(:qc_column) + 1).to_s}\"# \"What is the RNA integrity number based on the electropherogram?\"\n end\n end\n \n # Associate RIN to plan and to item that the sample in the well orginally came from - should be able to pull the matrix associate to stripwell\n ops.each do |op|\n stripwell = op.input(inputStr).item\n ris_val = data[\"[#{op.get(:qc_row)}, #{op.get(:qc_column)}]\".to_sym]\n \n op.plan.associate(\"RNA Integrity Score for #{stripwell.id} Well #{op.get(:qc_column) + 1}\", ris_val)\n stripwell.associate(\"RNA Integrity Score for Well #{op.get(:qc_column)}\", ris_val)\n \n # Associate RNA Integrity Number to RNA Stock item\n well_to_item_hash = stripwell.get('well_to_item') # [row, col] => RNA Stock item id\n if !well_to_item_hash.nil?\n rna_stock_item_id = well_to_item_hash[\"[0, #{op.get(:qc_column)}]\"]\n rna_stock_item = Item.find(rna_stock_item_id)\n rna_stock_item.associate(\"RNA_Integrity_Score\", ris_val)\n # rna_stock_item.set_output_data(\"RNA_Integrity_Score\".to_sym, ris_val)\n end\n end\n end\n end",
"def class_disambiguation(rdfdata,transitive)\n puts \"RDF to SVM WITH META PROPERTIES ...\"\n number_homonyms=[]\n max=nil\n min=nil\n svmmodelbygroup=[]\n ftotal = 0\n max_featuresbygroup=[]\n min_featuresbygroup=[]\n global_maximum=0\n\n # puts \"DATA DEBUG 1\"\n # puts rdfdata[0][0]\n puts \"############# RESTRICTED INVERSE FUNCTIONAL PROPERTIES\"\n # puts $textp\n ifp = restricted_IFP(rdfdata) + $textp + propertyoverflow(rdfdata)\n ifp.uniq!\n # puts ifp\n ifp.map!{|x| getCode(x.to_s.hash.abs)}\n\n groups_counter=[]\n count=-1\n pivot = nil # the smallest ambiguous set\n\n rdfdata.each{|group|\n count=count+1\n ######################## All Predicates ##########################\n # puts \"Encoding group ...\"\n #puts group.uniq.map{|s,p,o| s.to_s + \" \" + p.to_s + \" \" + o.to_s}\n new_group = group.uniq.map{|s,p,o| [getCode(s.to_s.hash.abs),getCode(p.to_s.hash.abs),getCode(o.to_s.hash.abs),o.instance_of?(RDFS::Resource) ] }.compact\n # new_group = group.uniq.map{|s,p,o| [ (s.to_s ), (p.to_s ), (o.to_s),o.instance_of?(RDFS::Resource) ] }.compact\n # puts \"Selecting items of measurement ...\"\n predicate_counter = new_group.map{|s,p| p }.compact\n datatype_objects = new_group.map{|s,p,o,t| o if !t and !ifp.include?(p) }.compact\n object_properties = new_group.map{|s,p,o,t| o if t and !ifp.include?(p) }.compact\n tuple_counter = new_group.map{|s,p,o,t| p.to_s + \" \" + o.to_s if !ifp.include?(p) }.compact\n #tuple_counter = new_group.map{|s,p,o,t| p.to_s + \" \" + o.to_s if !ifp.include?(p) && discriminative_predicates.include?(p) }.compact\n\n # puts \"Grouping subjects ...\"\n subjects = new_group.map{|s,p,o,t| s}.uniq\n groupedsubject = subjects.map{|x| new_group.find_all{|s,p,o,t| s==x}}\n groups_counter << [groupedsubject,predicate_counter,datatype_objects,object_properties,tuple_counter]\n }\n\n puts \"Buiding Model ...\"\n #####################################################################\n groups_counter_idx = -1\n groups_counter.each{|gs, group_predicates, group_datatype, group_objects, group_tuple|\n groups_counter_idx = groups_counter_idx + 1\n ################ GLOBAL PREDICATES AND OBJECTS ##############\n lines=[]\n max=nil\n count=count+1\n puts \"GROUP############## - \" + groups_counter_idx.to_s\n puts gs.size\n number_homonyms << gs.size\n gs.each{|subject|\n predicates = subject.map{|s,p| p }.compact\n datatype_objects = subject.map{|s,p,o,t| o if !t and !ifp.include?(p) }.compact\n object_properties = subject.map{|s,p,o,t| o if t and !ifp.include?(p) }.compact\n tuple_counter = subject.map{|s,p,o| p.to_s + \" \" + o.to_s if !ifp.include?(p) }.compact\n # tuple_counter = subject.map{|s,p,o| p.to_s + \" \" + o.to_s if !ifp.include?(p) && discriminative_predicates.include?(p) }.compact\n\n features = []\n sim1 = 0\n sim2 = 0\n sim3 = 0\n sim4 = 0\n counter1 = -1\n # puts \"SUBJECT\"\n puts subject[0][0]\n # puts tuple_counter\n ############################ Resource Vs. Origin Pivot\n if groups_counter_idx < $origin_subjects.size\n # puts \"ORIGIN SIZE \"\n # puts $origin_subjects.size\n # puts $origin_subjects[groups_counter_idx].size\n\n origin_s = $origin_subjects[groups_counter_idx].map{|p,o| [ getCode(p.to_s.hash.abs),getCode(o.to_s.hash.abs),o.instance_of?(RDFS::Resource) ] }.compact\n # origin_s = $origin_subjects[groups_counter_idx].map{|p,o| [ (p.to_s ), (o.to_s),o.instance_of?(RDFS::Resource) ] }.compact\n origin_predicates = origin_s.map{|p,o| p}.compact\n origin_datatype_objects = origin_s.map{|p,o,t| o if !t }.compact\n origin_object_properties = origin_s.map{|p,o,t| o if t }.compact\n origin_tuple_counter = origin_s.map{|p,o| p.to_s + \" \" + o.to_s }.compact\n\n groups_counter.each{|gs,group_predicates,group_datatype, group_objects, group_tuple|\n sim1 = sim1 + hm(origin_predicates,predicates, gs.size.to_f)\n sim2 = sim2 + hm(origin_datatype_objects, datatype_objects, gs.size.to_f)\n sim3 = sim3 + hm(origin_object_properties, object_properties, gs.size.to_f)\n sim4 = sim4 + hm(origin_tuple_counter, tuple_counter, gs.size.to_f)\n }\n end\n # puts \"PIVOT SIMILARITY\"\n # puts sim1\n # puts sim2\n # puts sim3\n # puts sim4\n ############################ Resource Vs. Pseudo-Homonyms\n groups_counter.each{|gs,group_predicates,group_datatype, group_objects, group_tuple|\n counter1 = counter1 + 1\n next if groups_counter_idx == counter1\n sim1 = sim1 + hm(group_predicates,predicates, gs.size.to_f)\n sim2 = sim2 + hm(group_datatype, datatype_objects, gs.size.to_f)\n sim3 = sim3 + hm(group_objects, object_properties, gs.size.to_f)\n sim4 = sim4 + hm(group_tuple, tuple_counter, gs.size.to_f)\n }\n # puts \"SIMILARITY\"\n # puts sim1\n # puts sim2\n # puts sim3\n # puts sim4\n # features << sim1\n # features << sim2\n # features << sim3\n # features << sim4\n features << (sim1 + sim2 + sim3 + sim4 ).abs\n\n lines << features\n max = Array.new(features) if max == nil\n max.each_index{|idx| max[idx] = features[idx] if max[idx] < features[idx]}\n }\n max.each {|gg| global_maximum = gg if global_maximum < gg}\n max_featuresbygroup << max\n svmmodelbygroup << lines\n # lines.each{|ss| puts ss.join (\" \") }\n puts \"END GROUP ###\"\n }\n # put \"####### Maximum Absolute\"\n # max_featuresbygroup.map{|v| }\n puts \"########### Normalizing Features\"\n idx=-1\n svmmodelbygroup.map!{|g|\n idx=idx+1\n subidx = -1\n g.map!{|f|\n subidx = subidx+1\n line = \"\"\n f.each_index{|i|\n v = f[i]\n if max_featuresbygroup[idx][i] != 0\n v = f[i] / global_maximum\n\n # v = f[i] / max_featuresbygroup[idx][i]\n\n if f[i] == global_maximum\n # add_pivot(rdfdata[idx], @searchedlabels[idx] ,subidx) if $usepivot\n add_pivot(rdfdata[idx], nil ,subidx) if $usepivot\n end\n end\n line = line + \"#{i+1}:#{v} \" if !v.nan?\n }\n line\n }\n }\n # puts \"THRESHOLD USED\"\n # # change this if more than one feature is used.\n # $threshold_global = (max_featuresbygroup.flatten.sum.to_f/ max_featuresbygroup.size.to_f) / global_maximum\n # if $threshold_global > 0.90\n # $threshold_global = max_featuresbygroup.flatten.min\n # end\n puts $threshold_global\n # svmmodelbygroup.each{|g| puts \"GROUP ########\"\n # puts g\n # puts \"############3\"\n # }\n puts \"NUMBER OF GROUPS\"\n puts svmmodelbygroup.size\n puts \"NUMBER OF ELEMENTS BY GROUPS 0\"\n puts svmmodelbygroup[0].size if svmmodelbygroup.size > 0\n puts \"NUMBER OF HOMONYMS\"\n number_homonyms.each{|v | $number_homonyms = $number_homonyms + v}\n $list_number_homonyms = $list_number_homonyms + number_homonyms\n puts number_homonyms.sort.join(\"\\t\")\n puts number_homonyms.join(\"\\t\")\n\n return svmmodelbygroup\n end",
"def compare_reviews_with_questions(auto_metareview)\n\n review_text_arr = auto_metareview.review_array\n\n scores = Score.find(:all, :conditions => [\"response_id = ?\", response.id])\n\n questions = Array.new\n\n #fetching the questions for the responses\n for i in 0..scores.length - 1\n questions << Question.find_by_sql([\"Select * from questions where id = ?\", scores[i].question_id])[0].txt\n end\n\n\n count_copies = 0 #count of the number of responses that are copies either of questions of other responses\n rev_array = Array.new #holds the non-plagiairised responses\n #comparing questions with text\n for i in 0..scores.length - 1\n if(!questions[i].nil? and !review_text_arr[i].nil? and questions[i].downcase == review_text_arr[i].downcase)\n count_copies+=1\n\n end\n\n #comparing response with other responses\n\n end\n\n\n #setting @review_array as rev_array\n check_plagiarism_state(auto_metareview, count_copies, rev_array, scores)\n\n end",
"def process_overview_page(response_body)\n hash = {}\n\n if !response_body.nil?\n doc = Nokogiri.HTML(response_body)\n\n # default specs page url\n hash['specs_url_slug'] = nil\n x = doc.css('#ymm-nav-specs-btn').first\n hash['specs_url_slug'] = x['href'].split('/').last if !x.nil?\n\n # ranking - number\n hash['expert_ranking_number'] = nil\n x = doc.css('.primary-rank span').first\n hash['expert_ranking_number'] = x.text.gsub('#', '').to_i if !x.nil?\n\n # ranking - category\n hash['expert_ranking_category'] = nil\n x = doc.css('.primary-rank a').first\n hash['expert_ranking_category'] = x.text if !x.nil?\n\n # user reviews - rating\n hash['used_reviews_rating'] = nil\n x = doc.css('.user-reviews .star-actual').first\n hash['used_reviews_rating'] = (x['data-width'].to_i / 26) if !x.nil?\n\n # user reviews - number\n hash['used_reviews_number'] = nil\n x = doc.css('.user-reviews .total-review').first\n hash['used_reviews_number'] = x.text.to_i if !x.nil?\n\n # expert rating\n hash['expert_rating'] = Hash.new\n if !doc.css('.expert-ratings-block').nil?\n # - overall\n hash['expert_rating']['overview'] = nil\n x = doc.css('.expert-ratings-block .ratingNumber').first\n hash['expert_rating']['overview'] = x.text.to_f if !x.nil?\n\n doc.css('.expert-ratings-block table > tr').each do |row|\n key = @expert_ratings[row.css('td:eq(1)').text]\n if !key.nil?\n hash['expert_rating'][key] = nil\n rating = row.css('td:eq(2)').text\n hash['expert_rating'][key] = rating.to_i if !rating.nil? && rating != '' && rating.downcase != 'n/a'\n end\n end\n end\n\n # expert likes\n hash['expert_likes'] = []\n doc.css('#likes ul li').each do |item|\n hash['expert_likes'] << item.text\n end\n\n # expert dislikes\n hash['expert_dislikes'] = []\n doc.css('#dislikes ul li').each do |item|\n hash['expert_dislikes'] << item.text\n end\n\n # user price range\n hash['used_price_range'] = nil\n x = doc.css('.used-yrmd-price a').first\n hash['used_price_range'] = x.text if !x.nil?\n\n end\n\n return hash\nend",
"def find_best_ratio(samples, n, step_sz)\n spam = samples.select { |s| s.kind == :spam }.shuffle\n ham = samples.select { |s| s.kind == :ham }.shuffle\n\n # bests = {\n # :accuracy => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # :precision => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # :recall => {:step => 0, :value => 0.0, :ratio => nil, :mat => nil},\n # }\n\n steps = {}\n\n (step_sz).step(0.99, step_sz).each do |i|\n ratio = {:spam => (n * i).round, :ham => (n * (1 - i)).round}\n limited_samples = spam.take(ratio[:spam]) + ham.take(ratio[:ham])\n\n STDERR.puts \"Step %0.2f, #{ratio.inspect}, n=#{ratio.values.reduce(:+)}\" % i\n\n mat = CrossValidate.run(limited_samples, Classifier.fetch(0, :unigram))\n\n steps[i] = {:ratio => ratio, :mat => mat}\n # if mat[:accuracy] > bests[:accuracy][:value]\n # bests[:accuracy] = {:step => i, :value => mat[:accuracy], :ratio => ratio, :mat => mat}\n # end\n\n # if mat[:precision] > bests[:precision][:value]\n # bests[:precision] = {:step => i, :value => mat[:precision], :ratio => ratio, :mat => mat}\n # end\n\n # if mat[:recall] > bests[:recall][:value]\n # bests[:recall] = {:step => i, :value => mat[:recall], :ratio => ratio, :mat => mat}\n # end\n end\n\n steps\n # bests\nend",
"def q1_score(map, answer, print_out)\r\n return q2_score(map, answer, print_out, 0)\r\nend",
"def hypothesis1(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] >= 0.25 \n\tcriteria += 1 if countsXmajor['Za'] >= 0.25 \n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def get_question_stats\n question_stats = {}\n question_overview = @base_url + @question_overview_hash[@question].href\n @agent.get question_overview\n view_links = @agent.page.links.find_all{|link| link.text.include? 'view'}\n submission_page = view_links.first.click\n html = submission_page.body\n html_nokogiri = Nokogiri::HTML submission_page.body\n\n # regexp match to pull scores\n public_test_score = html[/[0-9]\\/[0-9]\\s*points for public test cases./]\n release_test_score = html[/[0-9]\\/[0-9]\\s*points for release tests./]\n release_tokens = html[/[0-9]\\s*release\\s*tokens\\s*/]\n release_token_regeneration = html_nokogiri.xpath('//ul').text.gsub!(/[^0-9A-Za-z ]/, '')\n\n question_stats['public_test'] = public_test_score[/[0-9]\\/[0-9]/] if public_test_score\n question_stats['release_test'] = release_test_score[/[0-9]\\/[0-9]/] if release_test_score\n question_stats['release_tokens'] = release_tokens[/[0-9]/] if release_tokens\n question_stats['release_token_regeneration'] = release_token_regeneration\n\n return question_stats\n end",
"def offensive_implants_results(roll)\n def weapon_arm_roll(roll) # Hub Rules p. 92\n case\n when 1..4\n @@implants << \"Weapon Arm ~ Razor Sword\"\n when 5..9\n @@implants << \"Weapon Arm ~ Spring Spike\"\n when 10..14\n @@implants << \"Weapon Arm ~ Discsaw\"\n @@equipment << \"Discsaw #{d(4)} power cells\"\n when 15..18\n @@implants << \"Weapon Arm ~ Chainsaw\"\n @@equipment << \"Chainsaw #{d(4)} power cells\"\n when 19..21\n @@implants << \"Weapon Arm ~ Laser Torch\"\n @@equipment << \"Laser torch #{d(4)} power cells\"\n when 22..25\n @@implants << \"Weapon Arm ~ Stun stick\"\n @@equipment << \"Stun stick #{d(6)} mini power cells\"\n when 26..29\n @@implants << \"Weapon Arm ~ Stun Pistol\"\n @@equipment << \"Stun pistol #{d(6)} power cells\"\n when 30..35\n @@implants << \"Weapon Arm ~ Laser sword\"\n @@equipment << \"Laser sword #{d(6)} power cells\"\n when 36..39\n @@implants << \"Weapon Arm ~ Assault shotgun\"\n @@equipment << \"Assault shotgun #{d(2)} 40-round drum, #{d(20)} loose shells\"\n when 40..43\n @@implants << \"Weapon Arm ~ Sniper rifle\"\n @@equipment << \"Sniper rifle #{d(2)} full mags, #{d(20)} loose HCR shells\"\n when 44..50\n @@implants << \"Weapon Arm ~ Submachine gun\"\n @@equipment << \"SMG #{d(2)} full mags, #{d(100)} loose pistol rounds\"\n when 51..60\n @@implants << \"Weapon Arm ~ Assault rifle\"\n @@equipment << \"AR #{d(3)} full mags, #{d(100)} loose rifle rounds\"\n when 61..64\n @@implants << \"Weapon Arm ~ Rocket launcher\"\n @@equipment << \"#{(d(6)+d(6))} battle rockets\"\n when 65..68\n @@implants << \"Weapon Arm ~ Flamethrower\"\n @@equipment << \"Flamethrower #{(d(6)+1)} fuel canisters\"\n when 69..76\n @@implants << \"Weapon Arm ~ Chain gun\"\n @@equipment << \"Chain gun ammo drum (200-rd) and #{d(100)} loose rifle rounds\"\n when 77..79\n @@implants << \"Weapon Arm ~ Chain gun\"\n @@equipment << \"Chain gun ammo belt pack with #{d(100) + 100} rifle rounds\"\n when 80..84\n @@implants << \"Weapon Arm ~ Heavy machine gun\"\n @@equipment << \"HMG 100-round drum and #{d(100)} loose HCR rounds\"\n when 85..87\n @@implants << \"Weapon Arm ~ Heavy machine gun\"\n @@equipment << \"HMG ammo belt pack with #{d(100) + 100} HCR rounds\"\n when 88..92\n @@implants << \"Weapon Arm ~ Laser carbine\"\n @@equipment << \"Laser carbine #{d(6) + 1} power cells\"\n when 93..94\n @@implants << \"Weapon Arm ~ Heavy laser carbine\"\n @@equipment << \"HLC #{d(6) + 1} power cells\"\n when 95..96\n @@implants << \"Weapon Arm ~ Pulse rifle\"\n @@equipment << \"Pulse rifle #{d(6) + 1} power cells\"\n when 97\n @@implants << \"Weapon Arm ~ Pulse rifle\"\n @@equipment << \"Pulse rifle power pack: 250 bursts\"\n when 98\n @@implants << \"Weapon Arm ~ Heavy pulse rifle\"\n @@equipment << \"Heavy pulse rifle #{d(6) + 1} power cells\"\n when 99\n @@implants << \"Weapon Arm ~ Light laser cannon (cyborg mod)\"\n @@equipment << \"1 light laser cannon power pack\"\n when 100\n 2.times do weapon_arm_roll(d(100))\n end\n end\n\n # Default attack: attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"Hub Rules p.\", :notes => \"Notes\"}\n\n case roll\n when 1..6\n @@implants << \"Alloy Razor Claws\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 7..10\n @@implants << \"Fold Out Manipulator Arm ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 11..14\n @@implants << \"Hypodermic Tendril ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 15..18\n @@implants << \"Manipulator Tendril ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 19..24\n @@implants << \"Pincer ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 25..30\n @@implants << \"Power Arm ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 31..36\n @@implants << \"Retractable Laser Pistol ~\"\n @@attacks << {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 37..39\n @@implants << \"Shoulder Turret\"\n @@attacks = {:attack_mode => \"Punch\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0}\n when 40..45\n @@implants << \"Telescoping Thrust Blade\"\n @@attacks = {:attack_mode => \"Thrust Blade Implant\", :SV => \"+60/+8\", :rate => 1, :range => \"2m\", :damage => \"d20+10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"92\", :notes => \"+60SV and +5 initiative to first attack per combat, +8SV after\"}\n when 46..50\n @@implants << \"Tentacle ~\"\n @@attacks = {:attack_mode => \"Tentacle Implant\", :SV => \"+10\", :rate => 1, :range => \"3m\", :damage => \"d12 + 4 stun or lethal\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"92\", :notes => \"Tentacle has DV -20, END 20\"}\n @@appearance = [@@appearance - (d(6)+3), 1].max\n when 51..100\n weapon_arm_roll(d(100))\n\n end\n end\n\n def defensive_implants_results(roll)\n case roll\n when 1..8\n @@implants << \"Anti Toxin Array **\"\n when 9..48\n @@implants << \"Armor Enhancement ~\"\n when 49..55\n @@implants << \"Electrical Defense Mechanism\"\n when 56..59\n @@implants << \"Energy Absorption Cell\"\n when 60..73\n @@implants << \"Force Field Generator\"\n when 74..79\n @@implants << \"Force Shield\"\n when 80..84\n @@implants << \"Mental Defense Screen\"\n when 85..87\n @@implants << \"Optical Concealment Generator\"\n when 88..92\n @@implants << \"Radiation Leeching Unit\"\n when 93..95\n @@implants << \"Smoke Screen Generator\"\n when 96..97\n @@implants << \"Sonic Defense Screen\"\n when 98..100\n @@implants << \"Stun Inhibitor Device\"\n end\n end\n\n def misc_implants_results(roll)\n case roll\n when 1..7\n @@implants << \"Artificial Heart **\"\n when 8..13\n @@implants << \"Atmospheric Hydro Converter\"\n when 14..18\n @@implants << \"Back-Up Sensor Array\"\n when 19..23\n @@implants << \"Communication Implant ~\"\n when 24..27\n @@implants << \"Computerized Brain\"\n when 28..30\n @@implants << \"Cybernetic Legs\"\n when 31..33\n @@implants << \"Detachable Lower Arm\"\n when 34..36\n @@implants << \"Floodlight Orb\"\n when 37..41\n @@implants << \"Grappling Hook\"\n when 42..46\n @@implants << \"Hover Jets\"\n when 47..51\n @@implants << \"Hydraulic Walker Legs\"\n when 52..54\n @@implants << \"Internal Gyroscope\"\n when 55..58\n @@implants << \"Internal Healer Drones\"\n when 59..61\n @@implants << \"Internal Nutriment Supply\"\n when 62..64\n @@implants << \"Iron Stomach\"\n when 65..67\n @@implants << \"Loudspeaker\"\n when 68..69\n @@implants << \"Mini-Robotics Hanger\"\n when 70..79\n @@implants << \"Optical Enhancement ~\"\n when 80..83\n @@implants << \" Oxygen Supply Unit\"\n when 84..86\n @@implants << \"Panoramic Optics Node\"\n when 87..89\n @@implants << \"Portable Computer Station\"\n when 90..91\n @@implants << \"Radio Scanner\"\n when 92..93\n @@implants << \"Self Destruct Mode\"\n when 94..95\n @@implants << \"Sensor Probe Launcher\"\n when 96..97\n @@implants << \"Solar Power Generator\"\n when 98\n @@implants << \"Surveillance Tendril ~\"\n when 99..100\n @@implants << \"Tracked Locomotion\"\n end\n end\n\n off_implants.times do\n offensive_implants_results(d(100))\n end\n\n def_implants.times do\n defensive_implants_results(d(100))\n end\n\n misc_implants.times do\n misc_implants_results(d(100))\n end\n end",
"def analyze(_evidence, _current)\n {\n # Your return has to go here. This reformats the hashed return into\n # chief understands. Remember the output must corrospond to one of the\n # values in the database structure.\n # Typically This would be in the form.\n\n # blank_status:\n # {\n # value: 'Met', # or Unmet\n # confidence: 3, # or what ever you think it should be.\n # explanation: \"My Text to appear in the evidence field\"\n # }\n }\n end",
"def prepare_chart(body)\n if res = /([0-9]*) scenarios \\(([0-9]*) failed, ([0-9]*) passed\\)/.match(body)\n res\n elsif res = /([0-9]*) scenarios \\(([0-9]*) failed, ([0-9]*) undefined, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], res[2], res[4]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[2]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) undefined, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[3]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) pending, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[3]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) failed, ([0-9]*) pending, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[4]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) failed, ([0-9]*) undefined, ([0-9]*) pending, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[5]]\n elsif res =/([0-9]*) scenarios \\(([0-9]*) failed, ([0-9]*) skipped, ([0-9]*) passed\\)/.match(body)\n [res[0], res[1], 0, res[4]]\n else\n ['error', 1, 1, 0]\n end\nrescue\n ['error', 1, 1, 0]\nend",
"def happy_unhappy_unhappiness\n # The distance between 'i' and 'y' is 0.5. The distance between and two\n # other non-equal phone pairs is 1. This ensures that 'i' and 'y' will tend\n # align with each other.\n happy_unhappy_phones =<<-EOTEXT\n FORM, LETTER, CLASS\n i, i, iy\n y, y, iy\n a, a, a\n e, e, e\n h, h, h\n n, n, n\n p, p, p\n s, s, s\n u, u, u\n EOTEXT\n phone_table = PhoneticAlign::PhoneTable.new(happy_unhappy_phones)\n # Phonetic sequences\n # Meanings\n un_meaning = PhoneticAlign::FeatureValueMatrix[:POL => :neg]\n happy_meaning = PhoneticAlign::FeatureValueMatrix[:LEMMA => :happy]\n ness_meaning = PhoneticAlign::FeatureValueMatrix[:POS => :noun]\n # Morphemes\n un_morph = PhoneticAlign::SurfaceMorpheme.new(un_meaning, phone_table.phone_sequence(\"un\"))\n happy_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happy\"))\n happy_happi_morph = PhoneticAlign::SurfaceMorpheme.new(happy_meaning, phone_table.phone_sequence(\"happi\"), \n [phone_table.phone_sequence(\"happy\"),\n phone_table.phone_sequence(\"happi\")])\n ness_morph = PhoneticAlign::SurfaceMorpheme.new(ness_meaning, phone_table.phone_sequence(\"ness\"))\n # Words consisting of all phones.\n happy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"happy\"), happy_meaning)\n unhappy_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappy\"), un_meaning + happy_meaning)\n unhappiness_p = PhoneticAlign::Word.new(phone_table.phone_sequence(\"unhappiness\"), un_meaning + happy_meaning + ness_meaning)\n # Words consisting of phones and morphemes.\n unhappy_pm = PhoneticAlign::Word.new([un_morph] + phone_table.phone_sequence(\"happy\"), un_meaning + happy_meaning)\n # Words consisting of all morphemes\n happy_m = PhoneticAlign::Word.new([happy_morph], happy_meaning)\n unhappy_m = PhoneticAlign::Word.new([un_morph, happy_morph], un_meaning + happy_meaning)\n happy_happi_ness_m = PhoneticAlign::Word.new([happy_happi_morph, ness_morph], happy_meaning)\n unhappy_happi_ness_m = PhoneticAlign::Word.new([un_morph, happy_happi_morph, ness_morph], un_meaning + happy_meaning + ness_meaning)\n return Struct.new(:phone_table,\n :happy_p, :unhappy_p, :unhappiness_p,\n :unhappy_pm,\n :happy_m, :unhappy_m, :happy_happi_ness_m, :unhappy_happi_ness_m,\n :un_meaning, :happy_meaning, :ness_meaning).new(\n phone_table,\n happy_p, unhappy_p, unhappiness_p,\n unhappy_pm,\n happy_m, unhappy_m, happy_happi_ness_m, unhappy_happi_ness_m,\n un_meaning, happy_meaning, ness_meaning)\nend",
"def skier_quest; end",
"def answers\n [].tap do |a|\n a << qts_award_year\n a << claim_school\n a << current_school\n a << subjects_taught\n a << leadership_position\n a << mostly_performed_leadership_duties if eligibility.had_leadership_position?\n a << student_loan_amount\n end\n end",
"def prime_mutation_determination(roll)\n case roll\n when 1..9\n @@primary_mutations << \"Acid Blood\"\n @@attacks << {:attack_mode => \"Acid blood spray\", :SV => 20, :rate => 1, :range => 2, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"automatic on melee or point-blank puncturing attack\"}\n\n when 10..20\n @@primary_mutations << \"Acid Spit\"\n @@attacks << {:attack_mode => \"Acid Spit\", :SV => 6, :rate => 1, :range => 6, :damage => \"d6 + 2 per dround for d6 rounds\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"does same damage to ropes, bars, locks, etc.\"}\n when 21..32\n @@primary_mutations << \"Advanced Mind\"\n @@intelligence += (d(10 + d(10) + d(10)))\n @@character_notes << \"character gains two hazard checks against insanity and mental attacks that require hazard checks\"\n\n when 33..36\n @@primary_mutations << \"Agony Sphere\"\n @@attacks << {:attack_mode => \"Agony Sphere\", :SV => \"auto\", :rate => 1, :range => (@@willpower/2), :damage => \"d6 + +10DV to targets\", :ammo => \"1/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"requires 3 full rounds of concentration to unleash; can be sustained for 1 rd/willpower point\"}\n\n when 37..44\n @@primary_mutations << \"Amphibian\"\n @@character_notes << \"Can breathe as well in water as air\"\n @@character_notes << \"Suffers d3 dmg per day in arid environments\"\n\n when 45..52\n @@primary_mutations << \"Amplification\"\n @@character_notes << \"Doubles daily/rank-based rate of limited-use mutations\"\n\n when 53..59\n @@primary_mutations << \"Aquatic Adaptation\"\n @@character_notes << \"Webbed hands and feet\"\n @@character_notes << \"Withstands cold 2x vs. humans\"\n @@character_notes << \"Must be fully immersed in water 1hr per day or suffer d3 dmg; d6 in desert areas\"\n\n when 60..71\n @@primary_mutations << \"Arid Adaptation\"\n @@dv -= 3\n @@appearance = [@@appearance - d(8), 1].max\n @@character_notes << \"Needs 1/10th as much water as pure stock human\"\n @@character_notes << \"Specialized organ holds 2 liters drinking water (can yak up in 250 or 500ml portions)\"\n\n when 72..79\n @@primary_mutations << \"Asphyxiation Zone\"\n @@attacks << {:attack_mode => \"Asphyxiation Zone\", :SV => \"auto\", :rate => 1, :range => (@@willpower * 2), :damage => \"d10\", :ammo => \"2/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"lasts 2 rounds per rank\"}\n\n when 80..89\n @@primary_mutations << \"Aura of Protection\"\n @@character_notes << \"2 uses / rank / day; DV -10 + 10 pt force field dmg soak per round; duration willpower rounds; 2 rounds to activate\"\n\n when 90..102\n @@primary_mutations << \"Ballistic Hide\"\n @@dv -= 4\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Additional -20DV vs. blunt/crushing attacks including non-AP bullets\"\n\n when 103..109\n @@primary_mutations << \"Beak\"\n @@appearance = [@@appearance - (d(6) + d(6)), 1].max\n @@attacks << {:attack_mode => \"Beak\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n @@character_notes << \"Character cannot speak clearly\"\n\n when 110..127\n @@primary_mutations << \"Beam Eyes\"\n @@attacks << {:attack_mode => \"Beam Eyes\", :SV => 15, :rate => 1, :range => (@@willpower + @@perception), :damage => \"10 + d6/rank\", :ammo => \"2 / rank / day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n\n when 128..134\n @@primary_mutations << \"Berserker Rage\"\n @@character_notes << \"Berserker Rage: 2/day/rank usage; duration 1 battle; -5DV, +10SV, +10dmg (melee weapons only); +20 strength; can fight on for d6 rounds after suffering fatal damage\"\n when 135..144\n @@primary_mutations << \"Bladed Limbs\"\n def bladed_limbs_location(roll)\n case roll\n when 1 then result = \"Shoulder\"\n when 2 then result = \"Back\"\n when 3 then result = \"Chest\"\n when 4 then result = \"Side\"\n when 5 then result = \"Hip\"\n when 6 then result = \"Abdomen\"\n end\n end\n\n d(4).times do\n bladed_limbs_location(d(6))\n @@character_notes << \"Sword-like bone blade protruding from #{result}\"\n @@appearance = [@@appearance - 2, 1].max\n @@character_weight += 5\n end\n\n @@attacks << {:attack_mode => \"Bladed limb(s)\", :SV => 5, :rate => \"1 per bladed limb\", :range => 0, :damage => \"d12 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n\n\n when 145..149\n @@primary_mutations << \"Blurred Movement\"\n @@character_notes << \"Blurred Movement: -20DV; willpower rounds/day; can be used to blur entire body or only parts\"\n\n when 150..179\n @@character_notes << \"Due to body disporportion, no relic shell armor can be worn, but other types can be modified to fit\"\n def body_disproportion_location(roll)\n case roll\n when 1\n @@primary_mutations << \"Body Disproportion: Dominant arm is massive!\"\n @@character_notes << \"Dominant arm has strength of #{(@@strength + @@strength + d(20) + d(20))} which applies to all 1- and 2-handed melee weapons character wields\"\n @@appearance = [@@appearance - d(4), 1].max\n @@move -= 0.5\n @@character_weight += (20 + d(20))\n when 2\n @@primary_mutations << \"Body Disproportion: Character's head is massive!\"\n @@intelligence += (d(20) + 20)\n @@move -= 1\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"TWO intelligence-based hazard checks, when called for\"\n @@character_weight += (20 + d(10))\n when 3\n @@primary_mutations << \"Body Disproportion: Upper body incredibly over-muscled!\"\n @@strength += (20 + d(20))\n @@endurance += (20 + d(20))\n @@move -= 1\n @@agility = [@@agility - d(10), 1].max\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_weight += (20 + d(20) + d(20))\n when 4\n @@primary_mutations << \"Body Disproportion: hips and legs are twice normal length!\"\n @@move += @@move\n @@character_height += 100\n @@appearance = [@@appearance - d(4), 1].max\n @@attacks << {:attack_mode => \"Wicked kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_weight += (30 + d(20) + d(20))\n when 5\n @@primary_mutations << \"Body Disproportion: comically giant hands and feet!\"\n @@attacks << {:attack_mode => \"Punch or kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_notes << \"Weapons with triggers, keyboards, or other items requiring normal human hands are unusable without modifying item.\"\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@character_weight += (d(6) + d(6) + d(6) + d(6))\n when 6\n @@primary_mutations << \"Body Disproportion: extra long arms!\"\n @@character_notes << \"+5 SV in melee combat\"\n @@character_notes << \"+5 thrown weapon DMG\"\n @@appearance = [@@appearance - (d(4) + 1), 1].max\n when 7\n @@primary_mutations << \"Body Disproportion: greatly elongated torso!\"\n @@character_notes << \"If pregnant, gives birth to a litter of d4 + 1 offspring.\"\n @@endurance += (d(10) + d(10))\n @@appearance = [@@appearance - d(6), 1].max\n @@character_height += (20 + d(20))\n @@character_weight += (10 + d(20))\n def elongated_torso_bonus(roll1, roll2, roll3, roll4) # need to add actual mutation results via primary_mutations_roll(xx)\n case roll1\n when 1..50\n @@primary_mutations << \"Reserve heart\"\n end\n case roll2\n when 1..65\n @@primary_mutations << \"Radiation absorption\"\n end\n case roll3\n when 1..37\n @@primary_mutations << \"Breath holding\"\n end\n case roll4\n when 1..72\n @@primary_mutations << \"Nutriment cache\"\n end\n\n end\n elongated_torso_bonus(d(100),d(100),d(100),d(100))\n when 8\n 2.times do\n elongated_torso_bonus(d(7))\n end\n end\n\n end\n body_disproportion_location(d(8))\n\n when 180..195\n def body_regeneration_rate(roll)\n case roll\n when 1..12\n @@endurance_healing_rate += 4\n when 13..32\n @@endurance_healing_rate += 7\n when 33..40\n @@endurance_healing_rate += 10\n when 41..64\n @@endurance_healing_rate = 15\n when 65..87\n @@endurance_healing_rate = \"1 pt per hour\"\n when 88..93\n @@endurance_healing_rate = \"2 pts per hour\"\n when 94..96\n @@endurance_healing_rate = \"4 pts per hour\"\n when 97..98\n @@endurance_healing_rate = \"6 pts per hour\"\n when 99\n @@endurance_healing_rate = \"10 pts per hour\"\n when 100\n @@endurance_healing_rate = \"1 pt per round\"\n end\n end\n body_regeneration_rate(d(100))\n @@primary_mutations << \"Body Regeneration: #{@@endurance_healing_rate} healing rate bonus\"\n\n when 196..201\n @@primary_mutations << \"Breath Holding: triple base endurance rate + regular breath holding rate (Hub Rules p. 122)\"\n when 202..224\n @@primary_mutations << \"Claws: don’t hinder her from using bows, crossbows, or weapons that use a trigger, but disallow her from using keyboards or doing fne electronics work\"\n @@attacks << {:attack_mode => \"Claw\", :SV => 7, :rate => \"1 per hand\", :range => 0, :damage => \"d12 each\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62-63\", :notes => \"\"}\n @@character_notes << \"Thanks to claws, character climbs as though she has 2 points in Climbing skill\"\n when 225..230\n @@primary_mutations << \"Climbing Suckers: like a gecko, character can climb on anything at 1/2 move\"\n @@character_notes << \"When falling, type A agility based hazard check to catch side of building/pit and stop fall\"\n when 231..239\n @@primary_mutations << \"Coma Inducement\"\n @@attacks << {:attack_mode => \"Coma inducement\", :SV => 0, :rate => \"\", :range => @@willpower + @@willpower, :damage => \"coma\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"victim gets tybe B willpower based hazard check; see p. 63 for details\"}\n when 240..253\n number_of_pincers = 0\n arms_too = \"True\"\n pincer_size = \"Small\"\n def pincer_formation_on_mutant(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Crab Pincers: 1 pincer replacing 1 arm\"\n number_of_pincers += 1\n @@character_weight -= 15\n when 3..6\n @@primary_mutations << \"Crab Pincers: 2 pincers replacing both human arms\"\n number_of_pincers += 2\n @@character_weight -= 30\n when 7\n @@primary_mutations << \"Crab Pincers: 1 pincer growing from shoulder, both human arms intact\"\n number_of_pincers += 1\n when 8..9\n @@primary_mutations << \"Crab Pincers: 2 pincers in addition to human arms\"\n number_of_pincers += 2\n when 10\n number_of_pincers = (2 + d(2))\n def arms_too(roll)\n case roll\n when 79..100\n arms_too = \"False\"\n @@character_weight -= 30\n end\n end\n @@primary_mutations << \"Crab Pincers: #{number_of_pincers} total\"\n arms_too(d(100))\n end\n end\n def pincer_size(roll)\n case roll\n when 1..3\n pincer_size = \"Small\"\n @@character_weight += (number_of_pincers * 15)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 2, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d10 + 1\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 4..6\n pincer_size = \"Medium\"\n @@movement_rate_base -= (0.25 * number_of_pincers)\n @@character_weight += (number_of_pincers * 20)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 4, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d12 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 7..9\n pincer_size = \"Large\"\n @@movement_rate_base -= (0.5 * number_of_pincers)\n @@character_weight += (number_of_pincers * 35)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 7, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 10\n pincer_size = \"Massive\"\n @@movement_rate_base -= (0.75 * number_of_pincers)\n @@character_weight += (number_of_pincers * 50)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 10, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n end\n end\n\n pincer_formation_on_mutant(d(10))\n pincer_size(d(10))\n @@primary_mutations << \"Pincers: #{number_of_pincers} of #{pincer_size} size\"\n if arms_too == \"False\"\n @@appearance = [@@appearance - (number_of_pincers * d(4) + 2), 1].max\n @@character_notes << \"No human arms - character cannot use triggers, keyboards, or complex items\"\n elsif arms_too == \"True\"\n @@appearance = [@@appearance - (number_of_pincers * d(4)), 1].max\n end\n\n\n when 254..292\n def deviant_skin_structure(roll)\n case roll\n when 1..3\n @@primary_mutations << \"Fire-proof skin\"\n @@character_notes << \"No damage from fire for 10 rounds; 1/2 damage after\"\n @@character_notes << \"1/2 damage from explosions\"\n when 4..5\n @@primary_mutations << \"Reflective skin\"\n @@character_notes << \"1/2 damage from beam weapons when clothed; 70 percent resistance to beam weapons vs. bare skin\"\n @@appearance += d(6)\n when 6..7\n @@primary_mutations << \"Alkaline skin\"\n @@character_notes << \"Character totally immune to acid attacks (which still ruin character's gear)\"\n when 8..10\n @@primary_mutations << \"Weather sensitive skin\"\n @@character_notes << \"Sense weather changes in 20km radius; can sense open bodies of water within 2 km\"\n when 11\n @@primary_mutations << \"Glow in the dark skin\"\n @@character_notes << \"3m radius green glow; visible up to 12km away - character can't turn off glow\"\n when 12\n @@primary_mutations << \"Photosynthetic skin\"\n @@character_notes << \"4 hrs in sunlight = 1 meal; 1 hr in sunlight = 3 pts healing (in addition to normal resting healing)\"\n end\n end\n deviant_skin_structure(d(12))\n\n when 293..298\n @@primary_mutations << \"Devastator Pulse\"\n @@attacks << {:attack_mode => \"Devastator Pulse\", :SV => (@@accuracy + @@willpower), :rate => \"4 rounds to charge, release on 5th\", :range => @@willpower, :damage => \"3d20 / d100 + 40 vs. machines\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"\"}\n\n when 299..300\n @@primary_mutations << \"Displacement\"\n @@character_notes << \"Displacement: #{@@willpower} rounds per day, DV -30\"\n when 301..305\n @@primary_mutations << \"Doom Sphere\"\n @@attacks << {:attack_mode => \"Doom Sphere\", :SV => \"01-95\", :rate => \"1/10 days\", :range => (@@willpower * 10), :damage => \"3d20 vs organics; 6d20 vs electronics\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"User must make intelligence type B hazard check or go insane for 1 hour (p. 126)\"}\n when 306..314\n @@primary_mutations << \"Dread Zone\"\n @@attacks << {:attack_mode => \"Dread Zone\", :SV => \"01-95\", :rate => 1, :range => @@intelligence, :damage => \"tybe B hazard check vs. intelligence or +10SV to attack\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Duration: rank in rounds; does not affect inorganic beings or creatures with morale = n/a\"}\n when 315..322\n @@primary_mutations << \"Earth Thump\"\n @@attacks << {:attack_mode => \"Earth Thump\", :SV => (@@willpower + 30), :rate => \"3 rounds to generate\", :range => @@willpower, :damage => \"d10/user rank\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Targets 1 human-sized enemy per rank of user (assuming multiple targets close together)\"}\n when 323..341\n @@primary_mutations << \"Electrical Charge\"\n @@attacks << {:attack_mode => \"Electrical Charge\", :SV => 20, :rate => \"1\", :range => 0, :damage => \"d20 + HC\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Victim makes END-based tybe B hazard check or stunned for d3 rounds\"}\n @@character_notes << \"Four Electrical Charge jolts are suffcient to fully re-charge a standard power cell.\"\n when 342..349\n @@primary_mutations << \"Electrical Pulse\"\n @@attacks << {:attack_mode => \"Electrical Pulse\", :SV => 20, :rate => 1, :range => (@@willpower), :damage => \"d20 / 3d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"Can be used to start fires as well\"}\n when 350..355\n @@primary_mutations << \"Electro Magnetic Pulse\"\n @@attacks << {:attack_mode => \"Electro Magnetic Pulse\", :SV => 30, :rate => 1, :range => @@willpower, :damage => \"d10/d100 vs electronics\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"\"}\n when 356..376\n @@primary_mutations << \"Empathy\"\n @@character_notes << \"Empathy: #{@@willpower} range. Unlimited uses. The subject is allowed a type C, intelligence based hazard check. If failed, mutant knows victim's emotions. Alternately, emotions can be projected.\"\n when 377..388\n @@primary_mutations << \"Energy Blade\"\n def energy_blade_type(roll) # table Hub Rules p. 65\n case roll\n when 1..20\n @@attacks << {:attack_mode => \"Energy Blade: Blue\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 21..40\n @@attacks << {:attack_mode => \"Energy Blade: Green\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 41..65\n @@attacks << {:attack_mode => \"Energy Blade: Red\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 66..85\n @@attacks << {:attack_mode => \"Energy Blade: Orange\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 86..97\n @@attacks << {:attack_mode => \"Energy Blade: Purple\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 98..99\n @@attacks << {:attack_mode => \"Energy Blade: White\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 100\n @@attacks << {:attack_mode => \"Energy Blade: Gold\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n end\n end\n if @@primary_mutations.include? \"Energy Blade\" # Note: NO duplication -- reroll if this result comes up twice.\n @@primary_mutations_rolls += 1\n else\n energy_blade_type(d(100))\n end\n\n when 389..401\n @@primary_mutations << \"Extreme Size Decrease\"\n @@character_height = (22 + d(20) + d(20)) # NOTE: should be dependent on GENDER, ignored that.\n 3.times @@skills << \"Stealth\"\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Cannot wield two-handed weapons. Normal one-handed weapons including pistols must be employed with both hands (except knifes and daggers, which are considered swords for this mutant)\"\n @@character_notes << \"Relic armor cannot be worn except scrap relic.\"\n def extreme_size_decrease(height) # Hub Rules p. 65\n case height\n when 22..27\n @@character_weight = (15 + d(10))\n @@agility += 20\n @@movement_rate_base == 4.5\n @@strength = [@@strength - 15, 1].max\n @@endurance = [@@endurance - 10, 1].max\n when 28..35\n @@character_weight = (20 + d(12))\n @@agility += 15\n @@movement_rate_base = 5\n @@strength = [@@strength - 10, 1].max\n @@endurance = [@@endurance - 7, 1].max\n when 36..45\n @@character_weight = (25 + d(20))\n @@agility += 10\n @@movement_rate_base = 5.5\n @@strength = [@@strength - 5, 1].max\n @@endurance = [@@endurance - 5, 1].max\n when 46..65\n @@character_weight = (30 + d(20) + d(20))\n @@agility += 7\n @@movement_rate_base = 6\n @@strength = [@@strength - 3, 1].max\n @@endurance = [@@endurance - 3, 1].max\n end\n end\n\n extreme_size_decrease(@@character_height)\n\n when 402..419\n def fang_size(roll) # Hub rules p. 65\n case roll\n when 1..3\n sizeoffangs = \"Small\"\n fangsv = 2\n fangdmg = \"d6\"\n @@appearance = [@@appearance - 1, 1].max\n when 4..8\n sizeoffangs = \"Medium\"\n fangsv = 4\n fangdmg = \"d10\"\n @@appearance = [@@appearance - (1 + d(2)), 1].max\n when 9..10\n sizeoffangs = \"Huge\"\n fangsv = 6\n fangdmg = \"d20\"\n @@appearance = [@@appearance - (d(3) + 2), 1].max\n @@character_notes << \"Ability to speak clearly greatly reduced\"\n end\n @@attacks << {:attack_mode => \"Fangs\", :SV => fangsv, :rate => 1, :range => 0, :damage => fangdmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"This attack can only be employed as a supplemental melee attack if involved in close fighting\"}\n @@primary_mutations << \"Fanged: #{sizeoffangs} size\"\n end\n\n fang_size(d(10))\n\n when 420..427\n @@primary_mutations << \"Flame Breath\"\n @@attacks << {:attack_mode => \"Flame Breath\", :SV => 10, :rate => 1, :range => \"3/rank\", :damage => \"d6/rd for 2d6 rds\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66\", :notes => \"Up to 3 man sized targets can be attacked at once if close together\"}\n when 428..438\n def force_field_strength(roll) # Hub rules p. 66\n case roll\n when 1..10\n force_field = d(10)\n when 11..24\n force_field = (d(10) + 3)\n when 25..53\n force_field = (d(10) + 5)\n when 54..78\n force_field = (d(10) + 10)\n when 79..94\n force_field = (d(10) + 12)\n when 95\n force_field = (d(10) + 15)\n when 96\n force_field = (d(10) + 17)\n when 97\n force_field = (d(10) + 20)\n when 98\n force_field = (d(10) + 23)\n when 99\n force_field = (d(10) + 26)\n when 100\n force_field = (d(10) + 30)\n end\n @@primary_mutations << \"Force Field: 2 uses/rank/day; #{willpower} rounds duration; absorbs #{force_field} dmg/round\"\n end\n force_field_strength(d(100))\n\n when 439..445\n @@primary_mutations << \"Foul Flesh\"\n @@character_notes << \"Will not eat mutant: all mammals, all humanoids except moaners, horrlify, all amphibians, fsh, birds except black vultures, reptilius, all reptiles, except alligators and crocodilians.\"\n when 446..453\n def furred_mutation(roll)\n case roll\n when 1..3\n fur_type = \"Fine, cat-like\"\n fur_dv = -3\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - d(3), 1].max\n when 4..5\n fur_type = \"Wool, sheep-like\"\n fur_dv = -6\n fur_cold = \"Triple normal human cold resistance\"\n @@appearance = [@@appearance - (1 + d(4)), 1].max\n when 6..7\n fur_type = \"Thick, sheep-like wool\"\n fur_dv = -9\n fur_cold = \"Quadruple normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + 2), 1].max\n when 8..9\n fur_type = \"Badger-like bristles\"\n fur_dv = -11\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 2), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n when 10\n fur_type = \"Porcupine-like quills\"\n fur_dv = -13\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 3), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n end\n @@primary_mutations << \"Furred: #{fur_type}, #{fur_cold} cold resistance. #{fur_dv} DV bonus\"\n @@dv += fur_dv\n end\n furred_mutation(d(10))\n when 454..459\n\n def gaseous_discharge(roll) # Hub Rules p. 67\n case roll\n when 1..2\n gas_type = \"Sleep\"\n gas_effect = \"All must make an Endurance-based type A hazard check or pass out for d100 rounds.\"\n when 3..4\n gas_type = \"Blindness\"\n gas_effect = \"All must make an Endurance-based type A hazard check or go blind for d6 days.\"\n when 5\n gas_type = \"Stink\"\n gas_effect = \"All must make an Endurance-based type C hazard check or spend 2 rounds vomiting, becoming +30 to strike, with their own SV being reduced to half, rounded down.\"\n when 6\n gas_type = \"Corrosive\"\n gas_effect = \"All must make an Endurance-based type B hazard check suffer d6 damage/rd from corrosive acids. Those who succeed vs. hazard check take 1 dmg/rd.\"\n when 7\n gas_type = \"Hallucinogenic\"\n gas_effect = \"All must make an Intelligence-based tybe B hazard check or hallucinate, +30SV to strike and -30SV to retaliate. Animals must make a morale check or flee immediately.\"\n when 8\n gas_type = \"Poison\"\n gas_effect = \"All must make an Endurance-based type A hazard check or drop unconscious for 10 rounds. Their breathing ceases on the 11th round and if not resuscitated by artifcial respiration, will die on the 14th round.\"\n end\n @@primary_mutations << \"Gaseous Discharge: #{gas_type}\"\n @@attacks << {:attack_mode => \"Gaseous Discharge: #{gas_type}\", :SV => \"Auto\", :rate => 1, :range => \"10 m radius\", :damage => \"Special\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66-67\", :notes => \"#{gas_effect} Gas dissipates in 2 rounds outdoors or lingers 2d10 + 4 rounds in enclosed areas.\"}\n @@character_notes << \"Character immune to #{gas_type}\"\n end\n\n gaseous_discharge(d(8))\n\n when 460..472\n def gaping_maw(roll) #Hub Rules p. 67\n case roll\n when 1..5\n maw_size = \"Large\"\n maw_sv = 4\n maw_damage = \"d12\"\n maw_mv_mod = 0\n maw_added_weight = 15\n @@appearance = [@@appearance - (d(4) + d(4) + 2), 1].max\n when 6..7\n maw_size = \"Huge\"\n maw_sv = 7\n maw_damage = \"d20\"\n maw_mv_mod -= 0.25\n maw_added_weight = 30\n @@appearance = [@@appearance - (d(4) + d(4) + 4), 1].max\n when 8..9\n maw_size = \"Massive\"\n maw_sv = 12\n maw_damage = \"2d20\"\n maw_mv_mod -= 0.5\n maw_added_weight = 70\n @@appearance = [@@appearance - (d(6) + d(6) + 5), 1].max\n when 10\n maw_size = \"Colossal\"\n maw_sv = 20\n maw_damage = \"3d20\"\n maw_mv_mod -= 1\n maw_added_weight = 120\n @@appearance = [@@appearance - (d(6) + d(6) + 8), 1].max\n end\n @@primary_mutations << \"Gaping Maw: #{maw_size} in size\"\n @@attacks << {:attack_mode => \"Gaping Maw\", :SV => maw_sv, :rate => 1, :range => 0, :damage => maw_damage, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"Can be employed as a supplemental melee attack \"}\n @@character_notes << \"Almost totally carnivorous diet. Mutant drools and spits when speaking in a low, gruff voice difficult for strangers to understand.\"\n @@character_weight += maw_added_weight\n @@movement_rate_base -= maw_mv_mod\n end\n\n gaping_maw(d(10))\n\n\n when 473..497\n def heal_touch(willpower)\n case willpower\n when 1..6\n healrate = \"d8\"\n when 7..14\n healrate = \"d12\"\n when 15..34\n healrate = \"d20\"\n when 35..64\n healrate = \"d20 + 10\"\n when 65..84\n healrate = \"d20 + 20\"\n when 85..105\n healrate = \"d20 + 30\"\n when 106..200\n healrate = \"d20 + 40\"\n end\n @@primary_mutations << \"Heal Touch: 2/day/rank, #{healrate} trait points healed. Diseases healed if victim makes Type B willpower based hazard check.\"\n end\n\n heal_touch(@@willpower)\n\n @@primary_mutations << \"Heal Touch\"\n when 498..511\n def heat_pulse(willpower) # Hub Rules p. 67\n case willpower\n when 1..6\n heat_pulse_sv = -5\n heat_pulse_dmg = \"d6\"\n heat_pulse_range = 5\n when 7..14\n heat_pulse_sv = 0\n heat_pulse_dmg = \"d10\"\n heat_pulse_range = 10\n when 15..34\n heat_pulse_sv = 4\n heat_pulse_dmg = \"d20\"\n heat_pulse_range = @@willpower\n when 35..64\n heat_pulse_sv = 6\n heat_pulse_dmg = \"d20 + 10\"\n heat_pulse_range = (@@willpower * 2)\n when 65..84\n heat_pulse_sv = 9\n heat_pulse_dmg = \"d20 + 20\"\n heat_pulse_range = (@@willpower * 3)\n when 85..105\n heat_pulse_sv = 12\n heat_pulse_dmg = \"d20 + 30\"\n heat_pulse_range = (@@willpower * 4)\n when 106..200\n heat_pulse_sv = 15\n heat_pulse_dmg = \"d20 + 40\"\n heat_pulse_range = (@@willpower * 5)\n end\n @@primary_mutations << \"Heat Pulse\"\n @@attacks << {:attack_mode => \"Heat Pulse\", :SV => heat_pulse_sv, :rate => 1, :range => heat_pulse_range, :damage => heat_pulse_dmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"\"}\n end\n\n heat_pulse(@@willpower)\n\n\n when 512..556\n\n def heightened_attributes(roll) # Hub Rules p. 68\n case roll\n when 1\n heightened_attributes_type = \"Cat Balance\"\n @@agility += (d(20) + 20)\n @@accuracy += (d(10) + d(10))\n @@perception += (d(20) + d(20))\n @@appearance += d(10)\n 2.times @@skills << \"Stealth\"\n @@character_notes << \"Due to cat balance, character always gets two hazard checks when agility or accuracy are involved.\"\n when 2\n heightened_attributes_type = \"Eagle Eyes\"\n @@accuracy += (d(10) + d(10))\n @@perception += (d(10) + d(10) + d(10))\n @@character_notes << \"Due to eagle eyes, character sees 10x better than typical human, including at night.\"\n when 3..4\n heightened_attributes_type = \"Strength\"\n @@strength += (d(20) + 30)\n @@appearance += (d(10) + d(10))\n @@character_notes << \"Due to heightened strength, character always gets two hazard checks when strength involved.\"\n when 5..6\n heightened_attributes_type = \"Endurance\"\n @@endurance += (d(20) + 30)\n @@character_notes << \"Due to heightened endurance, character always gets two hazard checks when endurance involved (eg, poison).\"\n when 7\n heightened_attributes_type = \"Hand-Eye Coordination\"\n @@accuracy += (d(20) + 20)\n @@character_notes << \"Due to superior hand-eye coordination, character always gets two hazard checks when accuracy involved.\"\n when 8\n heightened_attributes_type = \"Beauty\"\n @@appearance += (d(20) + 30)\n @@agility += d(6)\n @@accuracy += d(6)\n @@strength += d(6)\n @@character_notes << \"Due to heightened beauty, character always gets two hazard checks when appearance involved.\"\n when 9\n heightened_attributes_type = \"Auditory\"\n @@dv -= 5\n @@character_notes << \"+2 initiative when operating alone or more than 10m from companions.\"\n @@character_notes << \"Sonic attacks do double damage, while crying babies, crowded pubs, and other intense noises are painful.\"\n @@character_notes << \"Due to heightened hearing, character receives 4 attempts on hazard checks related to listening/hearing.\"\n when 10\n heightened_attributes_type = \"Olfactory\"\n (d(2) + 1).times @@skills << \"Tracking\"\n @@character_notes << \"Due to heightened sense of smell, character gets no hazard checks vs. stink-based attacks.\"\n @@character_notes << \"Character cannot be fooled by illusions at less than 10m\"\n @@character_notes << \"Bloodhound-like tracking abilities; however, after 12 hours, or rain, sand storms, or crossing water, all result in lost trails.\"\n when 11\n heightened_attributes_type = \"Willpower\"\n @@willpower += (d(20) + 30)\n @@character_notes << \"Due to heightened willpower, character always gets two hazard checks when willpower involved.\"\n when 12\n heightened_attributes_type = \"Intelligence\"\n @@intelligence += (d(20) + 30)\n @@character_notes << \"Due to heightened intelligence, character always gets two hazard checks when intelligence involved.\"\n end\n @@primary_mutations << \"Heightened Attributes: #{heightened_attributes_type}\"\n end\n\n heightened_attributes(d(12))\n\n\n when 557..566\n number_of_horns = d(4)\n @@primary_mutations << \"Horns: #{number_of_horns} on head\"\n @@character_weight += (2 * number_of_horns)\n @@attacks << {:attack_mode => \"Horns\", :SV => (3 * number_of_horns), :rate => 1, :range => 0, :damage => \"#{number_of_horns}d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"68\", :notes => \"This attack can be employed as a supplemental melee attack\"}\n @@character_notes << \"Due to horns, character can't wear relic helmets or shell-class armor unless horns permanently removed.\"\n when 567..571\n @@primary_mutations << \"Image Multiplication: #{@@willpower} duration, 2 uses/day/rank. Up to #{@@willpower/10.floor} images of mutant's self created. Hub Rules p. 68\"\n when 572..578\n def image_projection(intelligence)\n case intelligence\n when 1..9\n image_projection_range = \"1 km\"\n image_projection_duration = \"d4 rounds\"\n when 10..34\n image_projection_range = \"#{@@intelligence/2} km\"\n image_projection_duration = \"2d4 rounds\"\n when 35..54\n image_projection_range = \"#{@@intelligence} km\"\n image_projection_duration = \"10 + d10 rounds\"\n when 55..74\n image_projection_range = \"#{@@intelligence * 2} km\"\n image_projection_duration = \"20 + d20 rounds\"\n when 75..94\n image_projection_range = \"#{@@intelligence * 100} km\"\n image_projection_duration = \"100 + d100 rounds\"\n when 95..200\n image_projection_range = \"anywhere within solar system\"\n image_projection_duration = \"200 + 2d100 rounds\"\n end\n @@primary_mutations << \"Image Projection: #{image_projection_range} range, #{image_projection_duration} duration. 1/rank/day. Illusion can repeat 2 words/round. Creatures with 35+ intelligence can make a type B intelligence based hazard check to recognize projection as an illusion. Hub Rules p. 69\"\n end\n\n image_projection(@@intelligence)\n\n when 579..603\n def immunity_mutation(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Poison immunity: totally immune to all forms of poison. Also, cannot get drunk.\"\n when 3..4\n @@primary_mutations << \"Disease immunity: All forms of infection, disease, sickness, parasites, etc. don't affect character. Immune to parasites as well.\"\n when 5..6\n @@primary_mutations << \"Radiation immunity: unaffected by all forms of radiation.\"\n end\n end\n\n immunity_mutation(d(6))\n\n when 605..613\n @@primary_mutations << \"Increased Cellular Activity\"\n @@endurance_healing_rate = (@@endurance_healing_rate * 3)\n @@character_notes << \"Character suffers no ill effects from aging (only benefits) and will live forever if not killed in combat, disease, poison, or accident.\"\n when 614..617\n @@primary_mutations << \"Light Burst: 10m radius, 2/day/rank\"\n @@attacks << {:attack_mode => \"Light Burst\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Type C agility HC or blinded for 2d5 rounds. Blindness: -2 MV, -20 SV, +20 SV to be struck.\"}\n when 618..624\n @@primary_mutations << \"Limb Regeneration: see Hub Rules p. 69 for regeneration rates.\"\n when 625..630\n def mandibles_mutation(roll)\n case roll\n when 1..2\n mandibles_size = \"Small\"\n mandibles_sv = 3\n mandibles_dmg = \"d10\"\n mandibles_weight = 5\n mandibles_appearance = -(d(4) + 3)\n when 3..5\n mandibles_size = \"Medium\"\n mandibles_sv = 5\n mandibles_dmg = \"d12\"\n mandibles_weight = 15\n mandibles_appearance = -(d(6) + 4)\n when 6..7\n mandibles_size = \"Large\"\n mandibles_sv = 8\n mandibles_dmg = \"d20\"\n mandibles_weight = 20\n mandibles_appearance = -(d(8) + 6)\n @@movement_rate_base -= 0.25\n when 8..9\n mandibles_size = \"Huge\"\n mandibles_sv = 11\n mandibles_dmg = \"d20 + 5\"\n mandibles_weight = 30\n mandibles_appearance = -(d(6) + d(6) + 5)\n @@movement_rate_base -= 0.5\n when 10\n mandibles_size = \"Massive\"\n mandibles_sv = 15\n mandibles_dmg = \"d20 + 10\"\n mandibles_weight = 40\n mandibles_appearance = -(d(6) + d(6) + d(6) + 6)\n @@movement_rate_base -= 1\n\n end\n\n @@attacks << {:attack_mode => \"Mandibles\", :SV => mandibles_sv, :rate => 1, :range => 0, :damage => mandibles_dmg, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Can be employed as a supplemental melee attack\"}\n @@character_weight += mandibles_weight\n @@appearance += mandibles_appearance #due to implementation method no protection here from =< 0...\n @@primary_mutations << \"Mandibles: #{mandibles_size} size\"\n end\n\n mandibles_mutation(d(10))\n\n when 631..641\n @@primary_mutations << \"Mental Mine\"\n when 642..655\n @@primary_mutations << \"Mental Screen\"\n when 656..687\n @@primary_mutations << \"Mind Crush\"\n when 688..693\n @@primary_mutations << \"Mind Waste\"\n when 694..699\n @@primary_mutations << \"Monstrous Morph\"\n when 700..718\n def multi_arm_mutation(roll) # Hub Rules p. 71\n case roll\n when 1..10\n additional_arms = 1\n when 11..85\n additional_arms = 2\n when 86..90\n additional_arms = 3\n when 91..97\n additional_arms = 4\n when 98\n additional_arms = 5\n when 99\n additional_arms = 6\n when 100\n additional_arms = (d(6) +6)\n end\n if additional_arms % 2 == 1\n def odd_arm_side(roll)\n case roll\n when 1\n odd_arm = \"right\"\n when 2\n odd_arm = \"left\"\n end\n end\n odd_arm_side(d(2))\n @@character_notes << \"Odd arm is on the #{odd_arm_side} side.\"\n end\n\n @@primary_mutations << \"Multi-Arm: #{additional_arms} additional arms\"\n end\n\n multi_arm_mutation(d(100))\n\n when 719..728\n def multi_head_mutation(roll)\n case roll\n when 1..70\n additional_heads = 1\n multi_head_appearance = -d(4)\n multi_head_mv = 0\n multi_head_initiative = 1\n when 71..88\n additional_heads = 2\n multi_head_appearance = -(d(4) + 1 )\n multi_head_mv = 0.25\n multi_head_initiative = 1\n when 89..95\n additional_heads = 3\n multi_head_appearance = -(d(6) + 2)\n multi_head_mv = 0.5\n multi_head_initiative = 2\n when 96..97\n additional_heads = 4\n multi_head_appearance = -(d(6) + 4)\n multi_head_mv = 0.75\n multi_head_initiative = 2\n when 98..99\n additional_heads = 5\n multi_head_appearance = -(d(6) + 6)\n multi_head_mv = 1\n multi_head_initiative = 3\n when 100\n additional_heads = 6\n multi_head_appearance = -(d(6) + 8)\n multi_head_mv = 1.25\n multi_head_initiative = 4\n end\n\n @@primary_mutations << \"Multi-Head: #{additional_heads} additional heads.\"\n @@appearance += multi_head_appearance\n @@movement_rate_base -= multi_head_mv\n @@initiative += multi_head_initiative\n @@character_notes << \"Heads tend to sleep at different times, with wakeful heads acting as lookout.\"\n\n while extra_heads > 0 do\n intelligence = attributes_roll(d100)\n wisdom = attributes_roll(d100)\n puts \"Extra head no. #{extra_heads} has INT of #{intelligence} and WIS of #{wisdom}\"\n def extra_head_mutations(roll2)\n case roll2\n when 1..62\n extra_head_mutation = ghost_mutations(d(100))\n @@primary_mutations << extra_head_mutation\n @@character_notes << \"Extra head no. #{extra_heads} has the mental mutation #{extra_head_mutation}\" # HOW to pick just the name of the mental mutation??\n end\n end\n end\n additional_heads -= 1\n end\n multi_head_mutation(d(100))\n\n when 729..738\n @@primary_mutations << \"Night Vision: can see as well at night as a typical human can in daylight (at least starlight must be present).\"\n when 739..745\n @@primary_mutations << \"Peeling Radius\"\n @@attacks << {:attack_mode => \"Peeling Radius\", :SV => 0, :rate => 1, :range => 10, :damage => \"d6/rd\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"10m radius. Automatic hit. Duration: 3 rds/rank\"}\n when 746..754\n def poison_bite_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Bite: #{poison_bite_type} venom, strength #{poison_bite_strength}, 4/day. Sufficient to coat 4 arrows/darts or 1 blade per injection's worth of poison.\"\n @@attacks << {:attack_mode => \"Poison Bite\", :SV => 0, :rate => 1, :range => 0, :damage => \"d6 plus poison\", :ammo => \"4/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"#{poison_bite_type} venom, #{poison_bite_strength} strength.\"}\n end\n\n poison_bite_mutation(d(100),d(10))\n\n\n when 755..760\n\n def poison_blood_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Blood: #{poison_bite_type} venom, #{poison_bite_strength} strength. Any creature biting mutant poisoned.\"\n\n end\n\n poison_blood_mutation(d(100),d(10))\n\n when 761..767\n paralysis_tendrils = d(6)\n @@primary_mutations << \"Paralysis Tendrils: #{paralysis_tendrils} 3m length grow from mutant's chest\"\n @@appearance = [@@appearance - (4 * paralysis_tendrils), 1].max\n @@attacks << {:attack_mode => \"Paralysis Tendrils\", :SV => 10, :rate => 1, :range => 3, :damage => \"d12 stun, 2d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"#{paralysis_tendrils} tendrils, each capable of attack 3/day/rank.\"}\n\n\n when 768..773\n @@primary_mutations << \"Radiation Absorption: mutant immune to radioactivity, except for radioactive weapons, which do half damage.\"\n when 774..780\n @@primary_mutations << \"Radiation Detection: automatically senses the presence of radiation within a twenty meter radius, including those rare sources found in special radiation using robots, relic weapons and life forms.\"\n when 781..786\n @@primary_mutations << \"Radioactive Pulse\"\n @@attacks << {:attack_mode => \"Radioactive Pulse\", :SV => 10, :rate => 1, :range => @@willpower, :damage => \"d20 plus radiation\", :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Victim makes type B endurance hazard check or suffer medium exposure; then type A hazard check or suffer strong exposure.\"}\n when 787..794\n @@primary_mutations << \"Reserve Heart: If character deemed to be killed by poison or electricity, or a critical hit which specifcally states a piercing of the heart, she will appear to be quite dead for 2d20+10 rounds. After this comatose period without a pulse or heartbeat, her back up heart will suddenly kick in and induce 2d10 endurance of healing, bringing the character slowly back to life.\"\n when 795..802\n @@primary_mutations << \"Reserve Mind: back-up brain takes over in case of brain damage, unconsciousness, insanity, or lethal damage. Hub Rules p. 72\"\n when 803..809\n @@primary_mutations << \"Scaled Skin\"\n @@dv -= 8\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Scaled skin: immune to damage from sunburn, sand storms, insect bites, and topical irritants.\"\n when 810..814\n @@primary_mutations << \"Serpentine Body: +4 mv on land or swimming\"\n @@dv -= 5\n serpent_body_length = d(3) + 1\n @@character_weight += (40 * serpent_body_length)\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@movement_rate_base += 4\n @@movement_rate_swimming += 4\n @@character_notes << \"Unable to wear relic shell class armor\"\n @@attacks << {:attack_mode => \"Serpentine Body Strike\", :SV => 0, :rate => 1, :range => serpent_body_length, :damage => \"d20 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Constrict for d10 lethal dmg/rd after successful strike.\"}\n\n when 815..839\n def shell_mutation(roll) # Hub Rules p. 73\n case roll\n when 1..4\n shell_rating = \"Light\"\n shell_defense_value = 10\n shell_movement_penalty = 0.5\n shell_appearance_penalty = (d(4) + 1)\n shell_weight = 20\n when 5..7\n shell_rating = \"Medium\"\n shell_defense_value = 20\n shell_movement_penalty = 1\n shell_appearance_penalty = (d(6) + 2)\n shell_weight = 30\n when 8..9\n shell_rating = \"Heavy\"\n shell_defense_value = 30\n shell_movement_penalty = 1.5\n shell_appearance_penalty = (d(6) + 4)\n shell_weight = 40\n when 10\n shell_rating = \"Extra Heavy\"\n shell_defense_value = 40\n shell_movement_penalty = 2\n shell_appearance_penalty = (d(6) + 6)\n shell_weight = 50\n end\n @@primary_mutations << \"#{shell_rating} Shell: #{shell_defense_value} DV, -#{shell_movement_penalty} MV\"\n @@appearance = [@@appearance - shell_appearance_penalty, 1].max\n @@dv -= shell_defense_value\n @@movement_rate_base -= shell_movement_penalty\n @@character_weight += shell_weight\n @@character_notes << \"Due to Shell mutation, punches, kicks, head-butts etc. deal 2d6 dmg instead of typical d6.\"\n @@character_notes << \"Shell mutation: no relic armor OTHER than ballistic, riot, and bomb squad armor can be worn. Combat armor can be modified, d6+1 days.\"\n end\n\n shell_mutation(d(10))\n\n when 840..849\n def size_decrease_mutation(height)\n case height\n when 61..95\n @@agility += (d(8) + d(8))\n @@strength = [@@strength - d(10), 1].max\n @@endurance = [@@endurance - (d(6) + d(6)), 1].max\n 4.times @@skills << \"Stealth\"\n when 66..90\n @@agility += (d(6) + d(6))\n @@strength = [@@strength - d(8), 1].max\n @@endurance = [@@endurance - (d(4) + d(4)), 1].max\n 3.times @@skills << \"Stealth\"\n when 91..110\n @@agility += (d(4) + d(4))\n @@strength = [@@strength - d(6), 1].max\n @@endurance = [@@endurance - d(6), 1].max\n 2.times @@skills << \"Stealth\"\n when 111..130\n @@agility += d(6)\n @@strength = [@@strength - d(4), 1].max\n @@endurance = [@@endurance - d(4), 1].max\n 2.times @@skills << \"Stealth\"\n when 131..140\n @@agility += d(6)\n @@strength = [@@strength - d(3), 1].max\n @@endurance = [@@endurance - 2, 1].max\n @@skills << \"Stealth\"\n when 141..159\n @@agility += d(4)\n @@skills << \"Stealth\"\n when 160..199\n @@agility += d(3)\n @@skills << \"Stealth\"\n end\n end\n\n @@character_height -= d(100)\n size_decrease_mutation(@@character_height)\n @@primary_mutations << \"Size Decrease\"\n when 850..860\n @@primary_mutations << \"Size Increase\"\n @@character_height += (d(100) + d(100) + d(100) + d(100))\n\n def size_increase_mutation(height) # Hub Rules p. 73\n case height\n when 164..184\n @@strength += d(10)\n @@endurance && @@character_weight += (d(10) + 5)\n when 185..199\n @@movement_rate_base += 0.25\n @@strength += (d(10) + 5)\n @@endurance && @@character_weight += (d(10) + 10)\n when 200..250\n @@movement_rate_base += 0.5\n @@strength += (d(10) + 10)\n @@endurance && @@character_weight += (d(20) + 15)\n when 251..299\n @@movement_rate_base += 0.75\n @@strength += (d(20) + 15)\n @@endurance && @@character_weight += (d(20) + 20)\n when 300..350\n @@movement_rate_base += 1\n @@strength += (d(20) + 20)\n @@endurance && @@character_weight += (d(20) + 30)\n when 351..399\n @@movement_rate_base += 1.25\n @@strength += (d(20) + 30)\n @@endurance && @@character_weight += (d(20) + 40)\n when 400..425\n @@movement_rate_base += 1.5\n @@strength += (d(20) + 40)\n @@endurance && @@character_weight += (d(20) + 50)\n when 426..450\n @@movement_rate_base += 1.75\n @@strength += (d(20) + 50)\n @@endurance && @@character_weight += (d(20) + 60)\n when 451..475\n @@movement_rate_base += 2\n @@strength += (d(20) + 60)\n @@endurance && @@character_weight += (d(20) + 75)\n when 476..499\n @@movement_rate_base += 3\n @@strength += (d(20) + 75)\n @@endurance && @@character_weight += (d(20) + 88)\n when 500..525\n @@movement_rate_base += 4\n @@strength += (d(20) + 88)\n @@endurance && @@character_weight += (d(20) + 100)\n when 526..560\n @@movement_rate_base += 5\n @@strength += (d(20) + 100)\n @@endurance && @@character_weight += (d(20) + 130)\n when 561..580\n @@movement_rate_base += 6\n @@strength += (d(20) + 130)\n @@endurance && @@character_weight += (d(20) + 160)\n end\n end\n\n size_increase_mutation(@@character_height)\n\n when 861..869\n def sonic_wave_radius_mutation(willpower) # Hub Rules p. 73\n case willpower\n when 1..9\n attack_radius = 1\n damage = \"d4\"\n deafness_duration = \"1 minute\"\n when 10..23\n attack_radius = 2\n damage = \"d6\"\n deafness_duration = \"5 minutes\"\n when 24..34\n attack_radius = 4\n damage = \"d8\"\n deafness_duration = \"10 minutes\"\n when 35..60\n attack_radius = 5\n damage = \"d10\"\n deafness_duration = \"30 minutes\"\n when 61..70\n attack_radius = 7\n damage = \"d12\"\n deafness_duration = \"1 hour\"\n when 71..80\n attack_radius = 9\n damage = \"d20\"\n deafness_duration = \"2d4 hours\"\n when 81..90\n attack_radius = 15\n damage = \"d20 + 5\"\n deafness_duration = \"3d6 hours\"\n when 91..100\n attack_radius = 20\n damage = \"d20 + 10\"\n deafness_duration = \"d6 days\"\n when 101..110\n attack_radius = 25\n damage = \"d20 + 15\"\n deafness_duration = \"2d4 days\"\n when 111..120\n attack_radius = 30\n damage = \"d20 + 20\"\n deafness_duration = \"3d6 days\"\n when 121..130\n attack_radius = 40\n damage = \"d20 + 30\"\n deafness_duration = \"3d6 + 10 days\"\n when 131..140\n attack_radius = 50\n damage = \"d20 + 40\"\n deafness_duration = \"3d6 + 20 days\"\n when 141..150\n attack_radius = 60\n damage = \"d20 + 50\"\n deafness_duration = \"3d6 + 30 days\"\n end\n\n @@primary_mutations << \"Sonic Wave Radius: 2/day/rank, #{attack_radius} radius, #{damage} damage, #{deafness_duration} deafness.\"\n @@attacks << {:attack_mode => \"Sonic Wave Radius\", :SV => 100, :rate => 1, :range => attack_radius, :damage => damage, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"73\", :notes => \"#{deafness_duration} deafness\"}\n end\n\n sonic_wave_radius_mutation(@@willpower)\n\n\n when 870..876\n @@primary_mutations << \"Spines: #{d(10) + 10} cm length, + d6 dmg to punch/kick\"\n @@dv -= (d(20) + 10)\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"Unable to wear relic armor unless spines are sawed off monthly.\"\n when 877..880\n @@primary_mutations << \"Sprint: 2/day/rank, duration 2d10 + rank rounds. -20DV (-20SV with misslie weapons) while sprinting OR double melee attack rate.\"\n when 881..886\n def stalked_eyes_mutation(roll)\n case roll\n when 1..67\n eye_stalks = (d(4) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long instead of typical eyes.\"\n when 68..100\n eye_stalks = (d(3) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long in addition to typical eyes.\"\n end\n\n @@dv -= (eye_stalks * 3)\n @@initiative += 2\n @@appearance = [@@appearance - (eye_stalks * d(6)), 1].max\n end\n\n stalked_eyes_mutation(d(100))\n\n when 887..892\n def stench_spray_location(roll) # Hub Rules p. 74\n case roll\n when 1..2\n location = \"Groin\"\n when 3..4\n location = \"Stomach\"\n when 5..6\n location = \"Chest\"\n when 7\n location = \"Left armpit\"\n when 8\n location = \"Right armpit\"\n when 9\n location = \"Back\"\n when 10\n location = \"Butt\"\n end\n\n stench_spray_app = (6 + d(6))\n @@primary_mutations << \"Stench Spray: #{20 + d(20) + d(20)} cm organ located on character's #{location}\"\n @@attacks << {:attack_mode => \"Stench Spray\", :SV => 10, :rate => 1, :range => (@@strength / 2), :damage => \"Special\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Endurance-based type B hazard check or d6 + 1 rds vomiting, +30SV to strike, -30SV to attack others.\"}\n @@character_notes << \"Character's appearance -#{stench_spray_app} penalty after stench organ seen.\"\n\n end\n\n stench_spray_location(d(10))\n\n when 893..901\n @@primary_mutations << \"Strength Burst: 2/rank/day, 4 rds/rank duration, character's strength 4x regular amount. Contributes to strength-based hazard checks, melee damage, etc.\"\n when 902..909\n def stun_ray_launcher(roll)\n case roll\n when 1..17\n stun_location = \"eyes\"\n when 18..59\n stun_location = \"left hand\"\n when 60..101\n stun_location = \"right hand\"\n end\n\n @@primary_mutations << \"Stun Ray fired from #{stun_location}.\"\n @@attacks << {:attack_mode => \"Stun Ray\", :SV => 10, :rate => 1, :range => (@@willpower * 2), :damage => \"2d20 stun, x2 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Stun damage fades after 1 hour.\"}\n end\n\n stun_ray_launcher(d(101))\n\n when 910..924\n def tail_mutation(roll) # Hub Rules p. 74\n case roll\n when 1..2\n tail_type = \"Club\"\n tail_length = 1.5\n tail_agility_bonus = d(4)\n tail_move = -1\n tail_sv = 6\n tail_attack_dmg = \"d12 + 2 lethal or stun\"\n when 3\n tail_type = \"Crocodile\"\n tail_length = 1.7\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 5\n tail_attack_dmg = \"d12 stun\"\n when 4\n tail_type = \"Dolphin\"\n tail_length = 1.5\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 6\n tail_sv = 4\n tail_attack_dmg = \"d12 stun\"\n when 5\n tail_type = \"Eagle\"\n tail_length = 1\n tail_agility_bonus = d(6)\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n when 6\n tail_type = \"Fish\"\n tail_length = 1.3\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 5\n tail_sv = 4\n tail_attack_dmg = \"d10 stun\"\n when 7\n tail_type = \"Fox\"\n tail_length = 1.25\n tail_agility_bonus = (d(6) + d(6))\n tail_move = 1.5\n tail_sv = 0\n tail_attack_dmg = nil\n when 8\n tail_type = \"Cat\"\n tail_length = 1.5\n tail_agility_bonus = (d(8) + d(8))\n tail_move = 2\n tail_sv = 0\n tail_attack_dmg = nil\n when 9\n tail_type = \"Whip\"\n tail_length = (3 + d(4))\n tail_agility_bonus = d(6)\n tail_move = -0.25\n tail_sv = 4\n tail_attack_dmg = \"d8\"\n @@character_notes << \"Whip tail can be used as #{tail_length} rope.\"\n when 10..13\n tail_type = \"Prehensile (monkey)\"\n tail_length = 3\n tail_agility_bonus = (d(4) + d(4))\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Prehensile tail can wield dagger or knife for additional melee attack.\"\n when 14\n tail_type = \"Newt\"\n tail_length = 1.5\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 3\n tail_attack_dmg = \"d10 stun\"\n when 15\n tail_type = \"Porcupine\"\n tail_length = 0.75\n tail_agility_bonus = 0\n tail_move = -1\n tail_sv = 5\n tail_attack_dmg = \"d12 + 1\"\n when 16..17\n tail_type = \"Rat\"\n tail_length = 1.8\n tail_agility_bonus = d(6)\n tail_move = 0.5\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Rat tail can wield dagger or knife for additional melee attack.\"\n when 18\n tail_type = \"Scorpion\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 8\n tail_attack_dmg = \"d12 + Type A poison\"\n when 19\n tail_type = \"Spiked\"\n tail_length = 1.75\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d12 + 3\"\n when 20\n tail_type = \"Bladed\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d20\"\n end\n\n @@primary_mutations << \"Tailed: #{tail_type} tail of #{tail_length} m length.\"\n @@appearance += tail_agility_bonus\n @@movement_rate_base += tail_move\n @@movement_rate_swimming += tail_move_water\n if tail_attack_dmg != nil\n @@attacks << {:attack_mode => \"#{tail_type} tail strike\", :SV => tail_sv, :rate => 1, :range => tail_length, :damage => \"#{tail_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"\"}\n end\n end\n\n tail_mutation(d(20))\n\n when 925..936\n @@primary_mutations << \"Telekinesis\"\n when 937..961\n @@primary_mutations << \"Telepathy\"\n when 962..967\n def tentacle_mutation(roll)\n case roll\n when 1..28\n number_of_tentacles = (d(4) + d(4) + 2)\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} instead of arms.\"\n when 29..100\n number_of_tentacles = (d(4) + d(4))\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} in addition to arms.\"\n end\n\n @@appearance = [@@appearance - (number_of_tentacles * 2), 1].max\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Tentacles add #{number_of_tentacles * 0.5} m to character's climbing & swimming move rates.\"\n @@character_notes << \"Tentacles can wield simple melee weapons but lack the dexterity needed to operate a keyboard, stringed, or triggered weapon.\"\n @@attacks << {:attack_mode => \"Tentacle strike\", :SV => 5, :rate => number_of_tentacles, :range => 0, :damage => \"d8 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"75\", :notes => \"Tentacles gain unarmed combat modifiers, too.\"}\n end\n\n tentacle_mutation(d(100))\n\n when 968..975\n @@primary_mutations << \"Throwing Quills: fire 1/rd, up to 20/day\"\n @@dv -= 18\n @@character_notes << \"Due to quills, mutant cannot wear relic armor (except specially-designed junk or scrap relic armor)\"\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@attacks << {:attack_mode => \"Throwing Quill\", :SV => 6, :rate => 1, :range => (@@strength / 2), :damage => \"d10\", :ammo => \"20/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"incl. strength and wpn expert skill modifiers\"}\n\n when 976..982\n def thrust_spike_mutation(roll)\n case roll\n when 1\n poison = \"type A death poison\"\n when 2..10\n poison = \"None\"\n end\n thrust_spike_length = (d(4) + d(4))\n @@primary_mutations << \"Thrust Spike #{thrust_spike_length} long.\"\n @@character_notes << \"After seeing thrust spike mutant's appearance score reduced for witness by d1- + 10.\" #obvious typo here\n if poison == \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack.\"}\n elsif poison != \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack. Also: #{poison}\"}\n end\n end\n\n thrust_spike_mutation(d(10))\n\n\n when 983..986\n @@primary_mutations << \"Tusks\"\n @@attacks << {:attack_mode => \"Tusk bite\", :SV => 6, :rate => 1, :range => 0, :damage => \"2d8 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"Additional melee attack/rd.\"}\n @@appearance = [@@appearance - (d(8) + 2), 1].max\n when 987..992\n @@primary_mutations << \"Webbed Hands: character nearly impossible to drown & can hold breath 2x normal. Double swim speed.\"\n @@movement_rate_swimming += @@movement_rate_swimming\n\n when 993..1000\n def wings_mutation(roll1,roll2) # Hub Rules p. 76\n case roll1\n when 1\n wing_type = \"Bird\"\n air_speed += 6\n @@character_notes << \"Bird wings are fragile - this character suffers double damage from fire and burst radius explosives like grenades and bombs.\"\n when 2\n wing_type = \"Insect\"\n air_speed += 3\n @@character_notes << \"Due to insect wings, character has -2 MV in enclosed spaces.\"\n when 3..6\n wing_type = \"Bat\"\n end\n\n case roll2\n when 1\n wing_size = \"Tiny\"\n flight_mode = \"Glide only\"\n air_speed += (d(6) + 10)\n flying_dv = -5\n wing_attack_dmg = nil\n wing_weight = 6\n when 2\n wing_size = \"Small\"\n flight_mode = \"Flies poorly\"\n air_speed += (d(6) + 12)\n flying_dv = -10\n wing_attack_dmg = \"d4 stun\"\n wing_weight = 12\n when 3..4\n wing_size = \"Medium\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 15)\n flying_dv = -14\n wing_attack_dmg = \"d6 stun\"\n wing_weight = 20\n when 5\n wing_size = \"Large\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 20)\n flying_dv = -20\n wing_attack_dmg = \"d8 stun\"\n wing_weight = 30\n when 6\n wing_size = \"Vast\"\n flight_mode = \"Flies excellently\"\n air_speed += (d(10) + 25)\n flying_dv = -25\n wing_attack_dmg = \"d10 stun\"\n wing_weight = 40\n end\n\n @@primary_mutations << \"Wings: #{wing_size} #{wing_type} wings. Mutant #{flight_mode} at #{air_speed} MV and #{flying_dv} DV when airborne.\"\n @@movement_rate_flying += air_speed\n\n if wing_attack_dmg != nil\n @@attacks << {:attack_mode => \"Wing bash\", :SV => 0, :rate => 2, :range => 0, :damage => \"#{wing_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"\"}\n end\n\n @@character_notes << \"Character able to fly at full air speed with full gear, arms, and armor. See Hub Rules p. 76 for more.\"\n @@character_notes << \"Due to wings, standard and relic armor must be modified and fitted to this character.\"\n\n\n end\n\n wings_mutation(d(6),d(6))\n\n end\nend",
"def parse_assessment_target(text)\n text.strip!\n assessment_target = nil\n #domain_regex = @domains.keys.join(\"|\")\n #space_or_dashes = \"[\\s|-|–|-]+\"\n # (ESS)\\s*([0-9]+)\\s*\\(([K|0-9|\\-|\\–|\\-|\\s])+\\)[\\s|\\-|\\–|\\-][\\s|\\-|\\–|\\-]*([A-Z|\\s|\\+]+)\\s*[\\s|\\-|\\–|\\-]*(\\d+)(.+)\n #regex = /(#{domain_regex})\\s*([0-9]+)\\s*\\(([K|0-9|\\-|\\–|\\s])+\\)[\\s|\\-|\\–]*([A-Z|\\s|\\+]+)\\s*[\\s|\\-|\\–|\\-]*(\\d+)(.+)/mx\n\n regex = @assessment_target_regex\n\n matches = text.match(regex)\n if (matches)\n (domain_key,ek_key,grade_span,unifying_theme_key) = matches.captures\n ## Getting number and target seperately because number of matches\n ## for unifying_theme_key is variable\n (number, target) = matches.captures[-2..-1] \n\n themes = unifying_theme_key.split(/[\\+\\s]+/);\n #unifying_theme_key = themes[0]\n\n domain = @domains[domain_key.strip]\n\n if (domain)\n knowledge_statement = RiGse::KnowledgeStatement.find(\n :first, \n :conditions => { :domain_id => domain.id, :number => ek_key })\n else\n logger.warn \"could not find domain for #{domain_key}\"\n end\n\n assessment_target = RiGse::AssessmentTarget.new(:knowledge_statement => knowledge_statement, :number => number)\n #unifying_theme = @themes[unifying_theme_key.strip]\n #if (unifying_theme)\n # assessment_target.unifying_theme = unifying_theme\n #else\n # logger.warn \"could not find unifying theme that matches: #{unifying_theme_key}\"\n #end\n assessment_target.description = target.strip\n assessment_target.grade_span = grade_span\n assessment_target.save\n themes.each do |theme|\n assessment_target.add_unifying_theme(@themes[theme])\n end\n return assessment_target\n elsif !text.match(/\\ANo further targets/i)\n logger.warn \"can't parse assessment target text is #{text}\"\n end\n nil\n end",
"def difficultly(qoph_ridding, fadedness_santalaceae)\n biopsychologist_hamidian_tachardiinae()\n inigo()\n huddock_konde(phrenitic, mistake, condurango_cymoscope)\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 match\n \n # Identify matching cells, track them\n \n # Match skill names\n i = 0\n \n 5.times do |search_row_i|\n 5.times do |result_row_i|\n # Match skill name (column = 0)\n match_keyword(i, [search_row_i, 0], [result_row_i, 0])\n \n if match_id_exists?(i)\n \n # Match skill years experience\n match_integer(i, [search_row_i, 1], [result_row_i, 1])\n \n # Match skill details\n match_keyword_array(i, [search_row_i, 2], [result_row_i, 2])\n end\n \n i += 1\n end\n end\n \n # Match additional job-related stuff (job type, job location)\n \n \n # Calculate points\n calc_skill_names([[0, 1], [5, 6]], false, 50, 10)\n calc_skill_names([[2, 3, 4], [7, 8, 9], [10, 15, 20], [11, 16, 21]], (pct > 0), 40, 10) \n calc_skill_names([[12, 13, 14], [17, 18, 19], [22, 23, 24]], (pct > 0), 30, 10)\n \n calc_additional_attributes({:years_experience_pct => 5, :skill_details_first_pct => 2.5, :skill_details_additional_pct => 1})\n \n # puts \"---------- PCT: \" + @pct.to_s\n \n end",
"def challenge4(file)\n file.each_line.map(&:chomp).map(&method(:challenge3)).min_by(&Cryptanalysis::Frequency.method(:english_score))\n end",
"def questions(number: T.unsafe(nil), supplemental: T.unsafe(nil), exclude_words: T.unsafe(nil)); end",
"def diagnose(text)\n # Tag important words from a sentence to start the diagnosis.\n tag = EngTagger.new\n diagnosis = tag.get_words(text).keys\n extracted = diagnosis\n diagnosis.each { |d| diagnosis = d.split(' ').uniq.join(' ') if d.include?(' ') }\n diagnosis = { 'diagnosis' => diagnosis, 'keywords' => extracted }\n\n # Diagnose illness by counting relevant keywords in the FLU and COUGH datasets.\n FLU['symptoms'].map do |f|\n FLU['score'] += 1 if diagnosis['keywords'].include?(f)\n end\n\n COUGH['symptoms'].map do |c|\n COUGH['score'] += 1 if diagnosis['keywords'].include?(c)\n end\n\n # Calculate condition probability.\n fluprob = FLU['score'].to_f / FLU['symptoms'].length.to_f\n coughprob = COUGH['score'].to_f / COUGH['symptoms'].length.to_f\n probabilities = { 'the flu' => fluprob, 'a cough' => coughprob }\n likely = probabilities.max_by { |_k, v| v }\n @value += likely[1]\n data = { 'the flu' => FLU, 'a cough' => COUGH }\n\n { 'likely_condition' => likely[0], 'likelyhood' => likely[1], 'condition_data' => data[likely[0]] }\n end",
"def solution(s, p, q)\n counts = [nil, [0], [0], [0], [0]]\n factors = s.split(//).map do |nu|\n case nu\n when 'A'\n 1\n when 'C'\n 2\n when 'G'\n 3\n when 'T'\n 4\n end\n end\n for i in (1..factors.length)\n fa = factors[i - 1]\n for j in [1, 2, 3, 4]\n counts[j][i] = counts[j][i - 1]\n end\n counts[fa][i] += 1\n end\n \n (0..p.count - 1).map { |k|\n if p[k] == q[k]\n factors[p[k]]\n else\n [1, 2, 3, 4].index do |i|\n counts[i][q[k] + 1] - counts[i][p[k]] > 0\n end + 1\n end\n }\nend",
"def incorrectAnswerAccuracy( studentStringArray, keyString )\n incAccuracyArray = findIncorrectAccuracies( studentStringArray, keyString )\n numStudents = studentStringArray.size\n # Array to return, answer[frequency]\n returnArray = Array.new()\n # go through each given answer for a question\n incAccuracyArray.each{ |question| \n highestFreq = 0\n highestAnswer = Hash.new()\n question.each{ |key, value| \n if(value > highestFreq) then\n highestFreq = value\n highestAnswer = key\n end\n }\n h = Hash.new \n h[highestAnswer] = highestFreq / numStudents\n returnArray.push( h )\n } \n returnArray\n end",
"def calc_draft_probs_fo(fo,n_teams = 30)\n ###fo means finishing order\n ###pick means draft order\n\n probs_fo = {}\n probs_pick = {}\n (1..n_teams).each{|fo| probs_fo[fo] = 0;probs_pick[fo] = 0}\n probs_fo[fo] = 1\n\n fn_fo = TF1.new(\"fn_fo\",\"gaus\")\n\n if (fo <= 14)\n (1..14).each{|pick| probs_pick[pick] += (probs_fo[fo]*$lottery_odds[fo][pick-1])}\n elsif fo > 14\n probs_pick[fo] = probs_fo[fo]#.to_N(5)\n end\n\n return probs_pick\nend",
"def demographics_label(patient_id)\n patient = Patient.find(patient_id)\n patient_bean = PatientService.get_patient(patient.person)\n demographics = mastercard_demographics(patient)\n hiv_staging = Encounter.where([\"encounter_type = ? and patient_id = ?\",\n EncounterType.find_by_name(\"HIV Staging\").id,patient.id]).last\n\n tb_within_last_two_yrs = \"tb within last 2 yrs\" unless demographics.tb_within_last_two_yrs.blank?\n eptb = \"eptb\" unless demographics.eptb.blank?\n pulmonary_tb = \"Pulmonary tb\" unless demographics.pulmonary_tb.blank?\n\n cd4_count_date = nil ; cd4_count = nil ; pregnant = 'N/A'\n\n (hiv_staging.observations).map do | obs |\n concept_name = obs.to_s.split(':')[0].strip rescue nil\n next if concept_name.blank?\n case concept_name\n when 'CD4 COUNT DATETIME'\n cd4_count_date = obs.value_datetime.to_date\n when 'CD4 COUNT'\n cd4_count = obs.value_numeric\n when 'IS PATIENT PREGNANT?'\n pregnant = obs.to_s.split(':')[1] rescue nil\n end\n end rescue []\n\n office_phone_number = PatientService.get_attribute(patient.person, 'Office phone number')\n home_phone_number = PatientService.get_attribute(patient.person, 'Home phone number')\n cell_phone_number = PatientService.get_attribute(patient.person, 'Cell phone number')\n\n phone_number = office_phone_number if not office_phone_number.downcase == \"not available\" and not office_phone_number.downcase == \"unknown\" rescue nil\n phone_number= home_phone_number if not home_phone_number.downcase == \"not available\" and not home_phone_number.downcase == \"unknown\" rescue nil\n phone_number = cell_phone_number if not cell_phone_number.downcase == \"not available\" and not cell_phone_number.downcase == \"unknown\" rescue nil\n\n initial_height = PatientService.get_patient_attribute_value(patient, \"initial_height\")\n initial_weight = PatientService.get_patient_attribute_value(patient, \"initial_weight\")\n\n label = ZebraPrinter::StandardLabel.new\n label.draw_text(\"Printed on: #{Date.today.strftime('%A, %d-%b-%Y')}\",450,300,0,1,1,1,false)\n label.draw_text(\"#{demographics.arv_number}\",575,30,0,3,1,1,false)\n label.draw_text(\"PATIENT DETAILS\",25,30,0,3,1,1,false)\n label.draw_text(\"Name: #{demographics.name} (#{demographics.sex})\",25,60,0,3,1,1,false)\n label.draw_text(\"DOB: #{PatientService.birthdate_formatted(patient.person)}\",25,90,0,3,1,1,false)\n label.draw_text(\"Phone: #{phone_number}\",25,120,0,3,1,1,false)\n if demographics.address.length > 48\n label.draw_text(\"Addr: #{demographics.address[0..47]}\",25,150,0,3,1,1,false)\n label.draw_text(\" : #{demographics.address[48..-1]}\",25,180,0,3,1,1,false)\n last_line = 180\n else\n label.draw_text(\"Addr: #{demographics.address}\",25,150,0,3,1,1,false)\n last_line = 150\n end\n\n if !demographics.guardian.nil?\n if last_line == 180 and demographics.guardian.length < 48\n label.draw_text(\"Guard: #{demographics.guardian}\",25,210,0,3,1,1,false)\n last_line = 210\n elsif last_line == 180 and demographics.guardian.length > 48\n label.draw_text(\"Guard: #{demographics.guardian[0..47]}\",25,210,0,3,1,1,false)\n label.draw_text(\" : #{demographics.guardian[48..-1]}\",25,240,0,3,1,1,false)\n last_line = 240\n elsif last_line == 150 and demographics.guardian.length > 48\n label.draw_text(\"Guard: #{demographics.guardian[0..47]}\",25,180,0,3,1,1,false)\n label.draw_text(\" : #{demographics.guardian[48..-1]}\",25,210,0,3,1,1,false)\n last_line = 210\n elsif last_line == 150 and demographics.guardian.length < 48\n label.draw_text(\"Guard: #{demographics.guardian}\",25,180,0,3,1,1,false)\n last_line = 180\n end\n else\n if last_line == 180\n label.draw_text(\"Guard: None\",25,210,0,3,1,1,false)\n last_line = 210\n elsif last_line == 180\n label.draw_text(\"Guard: None}\",25,210,0,3,1,1,false)\n last_line = 240\n elsif last_line == 150\n label.draw_text(\"Guard: None\",25,180,0,3,1,1,false)\n last_line = 210\n elsif last_line == 150\n label.draw_text(\"Guard: None\",25,180,0,3,1,1,false)\n last_line = 180\n end\n end\n\n label.draw_text(\"TI: #{demographics.transfer_in ||= 'No'}\",25,last_line+=30,0,3,1,1,false)\n label.draw_text(\"FUP: (#{demographics.agrees_to_followup})\",25,last_line+=30,0,3,1,1,false)\n\n\n label2 = ZebraPrinter::StandardLabel.new\n #Vertical lines\n=begin\n label2.draw_line(45,40,5,242)\n label2.draw_line(805,40,5,242)\n label2.draw_line(365,40,5,242)\n label2.draw_line(575,40,5,242)\n\n #horizontal lines\n label2.draw_line(45,40,795,3)\n label2.draw_line(45,80,795,3)\n label2.draw_line(45,120,795,3)\n label2.draw_line(45,200,795,3)\n label2.draw_line(45,240,795,3)\n label2.draw_line(45,280,795,3)\n=end\n label2.draw_line(25,170,795,3)\n #label data\n label2.draw_text(\"STATUS AT ART INITIATION\",25,30,0,3,1,1,false)\n label2.draw_text(\"(DSA:#{patient.date_started_art.strftime('%d-%b-%Y') rescue 'N/A'})\",370,30,0,2,1,1,false)\n label2.draw_text(\"#{demographics.arv_number}\",580,20,0,3,1,1,false)\n label2.draw_text(\"Printed on: #{Date.today.strftime('%A, %d-%b-%Y')}\",25,300,0,1,1,1,false)\n\n label2.draw_text(\"RFS: #{demographics.reason_for_art_eligibility}\",25,70,0,2,1,1,false)\n label2.draw_text(\"#{cd4_count} #{cd4_count_date}\",25,110,0,2,1,1,false)\n label2.draw_text(\"1st + Test: #{demographics.hiv_test_date}\",25,150,0,2,1,1,false)\n\n label2.draw_text(\"TB: #{tb_within_last_two_yrs} #{eptb} #{pulmonary_tb}\",380,70,0,2,1,1,false)\n label2.draw_text(\"KS:#{demographics.ks rescue nil}\",380,110,0,2,1,1,false)\n label2.draw_text(\"Preg:#{pregnant}\",380,150,0,2,1,1,false)\n label2.draw_text(\"#{demographics.first_line_drugs.join(',')[0..32] rescue nil}\",25,190,0,2,1,1,false)\n label2.draw_text(\"#{demographics.alt_first_line_drugs.join(',')[0..32] rescue nil}\",25,230,0,2,1,1,false)\n label2.draw_text(\"#{demographics.second_line_drugs.join(',')[0..32] rescue nil}\",25,270,0,2,1,1,false)\n\n label2.draw_text(\"HEIGHT: #{initial_height}\",570,70,0,2,1,1,false)\n label2.draw_text(\"WEIGHT: #{initial_weight}\",570,110,0,2,1,1,false)\n label2.draw_text(\"Init Age: #{PatientService.patient_age_at_initiation(patient, demographics.date_of_first_line_regimen) rescue nil}\",570,150,0,2,1,1,false)\n\n line = 190\n extra_lines = []\n label2.draw_text(\"STAGE DEFINING CONDITIONS\",450,190,0,3,1,1,false)\n (hiv_staging.observations).each{|obs|\n name = obs.to_s.split(':')[0].strip.upcase rescue nil\n condition = obs.to_s.split(':')[1].strip.humanize rescue nil\n next unless name == 'WHO STAGES CRITERIA PRESENT'\n line+=25\n if line <= 290\n label2.draw_text(condition[0..35],450,line,0,1,1,1,false)\n end\n extra_lines << condition[0..79] if line > 290\n } rescue []\n\n if line > 310 and !extra_lines.blank?\n line = 30\n label3 = ZebraPrinter::StandardLabel.new\n label3.draw_text(\"STAGE DEFINING CONDITIONS\",25,line,0,3,1,1,false)\n label3.draw_text(\"#{PatientService.get_patient_identifier(patient, 'ARV Number')}\",370,line,0,2,1,1,false)\n label3.draw_text(\"Printed on: #{Date.today.strftime('%A, %d-%b-%Y')}\",450,300,0,1,1,1,false)\n extra_lines.each{|condition|\n label3.draw_text(condition,25,line+=30,0,2,1,1,false)\n } rescue []\n end\n return \"#{label.print(1)} #{label2.print(1)} #{label3.print(1)}\" if !extra_lines.blank?\n return \"#{label.print(1)} #{label2.print(1)}\"\n end",
"def prediction_payment\n group.ffs_payment * 3\n end",
"def getRecommendations()\n totals=Hash.new(0)\n simSum=Hash.new(0)\n \n \n @prefs.each_pair do |other,ranks|\n \n # next if it's me\n next if other == @person\n \n # check the affinity \n sim = @similarity.compute(other)\n \n # next if no affinity\n next if sim <= 0\n \n # for each unranked element\n ranks.each_pair do |name,rank|\n if !@prefs[@person].include?(name) or @prefs[@person].length == 0\n \n totals[name] += rank * sim\n simSum[name] += sim\n \n end\n end \n end\n \n # Array creation\n totals.to_a.collect do |e|\n [e[1]/simSum[e[0]],e[0]]\n end.sort do |a,b|\n b[0] <=> a[0]\n end\n \n end",
"def token!\n # at line 1:8: ( HTML | HEAD | TITLE | BODY | H1 | H2 | H3 | H4 | H5 | H6 | P | DIV | I | B | U | TABLE | TR | TH | TD | A | IMG | BR | OPENING_TAG | CLOSING_TAG | END_TAG | END_NOPAIR_TAG | ID | CLASS | STYLE | BGCOLOR | BACKGROUND | ALIGN | SRC | ALT | WIDTH | HEIGHT | BORDER | VALIGN | BORDERCOLOR | ANAME | HREF | TARGET | SVALUE | NAME | ASSIGN | WS | PCDATA )\n alt_9 = 47\n alt_9 = @dfa9.predict( @input )\n case alt_9\n when 1\n # at line 1:10: HTML\n html!\n\n when 2\n # at line 1:15: HEAD\n head!\n\n when 3\n # at line 1:20: TITLE\n title!\n\n when 4\n # at line 1:26: BODY\n body!\n\n when 5\n # at line 1:31: H1\n h_1!\n\n when 6\n # at line 1:34: H2\n h_2!\n\n when 7\n # at line 1:37: H3\n h_3!\n\n when 8\n # at line 1:40: H4\n h_4!\n\n when 9\n # at line 1:43: H5\n h_5!\n\n when 10\n # at line 1:46: H6\n h_6!\n\n when 11\n # at line 1:49: P\n p!\n\n when 12\n # at line 1:51: DIV\n div!\n\n when 13\n # at line 1:55: I\n i!\n\n when 14\n # at line 1:57: B\n b!\n\n when 15\n # at line 1:59: U\n u!\n\n when 16\n # at line 1:61: TABLE\n table!\n\n when 17\n # at line 1:67: TR\n tr!\n\n when 18\n # at line 1:70: TH\n th!\n\n when 19\n # at line 1:73: TD\n td!\n\n when 20\n # at line 1:76: A\n a!\n\n when 21\n # at line 1:78: IMG\n img!\n\n when 22\n # at line 1:82: BR\n br!\n\n when 23\n # at line 1:85: OPENING_TAG\n opening_tag!\n\n when 24\n # at line 1:97: CLOSING_TAG\n closing_tag!\n\n when 25\n # at line 1:109: END_TAG\n end_tag!\n\n when 26\n # at line 1:117: END_NOPAIR_TAG\n end_nopair_tag!\n\n when 27\n # at line 1:132: ID\n id!\n\n when 28\n # at line 1:135: CLASS\n class!\n\n when 29\n # at line 1:141: STYLE\n style!\n\n when 30\n # at line 1:147: BGCOLOR\n bgcolor!\n\n when 31\n # at line 1:155: BACKGROUND\n background!\n\n when 32\n # at line 1:166: ALIGN\n align!\n\n when 33\n # at line 1:172: SRC\n src!\n\n when 34\n # at line 1:176: ALT\n alt!\n\n when 35\n # at line 1:180: WIDTH\n width!\n\n when 36\n # at line 1:186: HEIGHT\n height!\n\n when 37\n # at line 1:193: BORDER\n border!\n\n when 38\n # at line 1:200: VALIGN\n valign!\n\n when 39\n # at line 1:207: BORDERCOLOR\n bordercolor!\n\n when 40\n # at line 1:219: ANAME\n aname!\n\n when 41\n # at line 1:225: HREF\n href!\n\n when 42\n # at line 1:230: TARGET\n target!\n\n when 43\n # at line 1:237: SVALUE\n svalue!\n\n when 44\n # at line 1:244: NAME\n name!\n\n when 45\n # at line 1:249: ASSIGN\n assign!\n\n when 46\n # at line 1:256: WS\n ws!\n\n when 47\n # at line 1:259: PCDATA\n pcdata!\n\n end\n end",
"def initVectorial\n docs = Array.new\n docs_names = Array.new\n terms = Array.new\n @question.each { |word| docs += (@postings.find_one({:term => word}).to_a) }\n for i in [email protected]\n terms[i] = @postings.find_one({:term => @question[i]}).to_a\n end\n for i in 0..docs.size-1\n docs_names[i] = docs[i][0]\n end\n docs_names = docs_names - ['_id', 'term']\n docs_names = docs_names.uniq\n data = Array.new(docs_names.size) { Array.new(terms.size, 0) }\n data_w = Array.new(docs_names.size) { Array.new(terms.size, 0) }\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n for k in 0..terms[j].size-1\n if docs_names[i].eql?(terms[j][k][0])\n data[i][j] = terms[j][k][1]\n end\n end\n end\n end\n#CONTAR.SI\n count_if = Array.new(@question.size, 0)\n log_count_if = Array.new(@question.size, 0)\n for j in 0..docs_names.size-1\n for i in [email protected]\n count_if[i] += data[j][i]\n end\n end\n#LOGARITHM count_if\n#--------------------------------\n log_count_if = Array.new(count_if.size, 0)\n for i in 0..count_if.size-1\n #WARNING HERE\n log_count_if[i] = Math.log10(count_if[i]) \n end\n#DATA_W--------------------------------\n#MISSING Q¿?\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n data_w[i][j] = data[i][j]/log_count_if[j]\n end\n end\n#SUM---------------------------------\n sum = Array.new(docs_names.size,0)\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n sum[i] += data_w[i][j]\n end\n end\n#SUM---------------------------------\n e1 = Array.new(docs_names.size,0)\n for i in 0..docs_names.size-1\n for j in 0..terms.size-1\n e1[i] += (data_w[i][j])**2\n end\n end\n sum.each_index { |i| e1[i] += sum[i]**2 } \n#E2---------------------------------\n e2 = e1.collect{|item| item*terms.size}\n#SUMA/E2----------------------------\n ranking = Array.new(docs_names.size,0)\n results = Array.new(docs_names.size) { Array.new(4) }\n for i in 0..e1.size-1\n results[i][0] = docs_names[i]\n results[i][1] = 1 - sum[i]/e2[i]\n results[i][2] = getIdDoc(docs_names[i])\n results[i][3] = getDocPath(docs_names[i])\n end\n results = results.sort_by{|e| e[1]}\n results = results.reverse\n return results\n end",
"def generate_dummy_data_for_presentation(pt1,user)\n\n#generate the exercises:\n# For the legs session type\n legs1 = Exercise.new(\"Full Squat\", \"Legs\", true, 10, 5, 1.2,4,3) \n legs2 = Exercise.new(\"Barbell Lunge\", \"Legs\", false, 15, 5, 1.1,4,2) \n legs3 = Exercise.new(\"Deadlift\", \"Legs\", true, 15, 5, 1.3,2,4) \n legs4 = Exercise.new(\"Leg Press\", \"Legs\", false, 20, 5, 1.25,6,5) \n legs5 = Exercise.new(\"Ham String Curl\", \"Legs\", true, 12, 5, 1.15,4,4) \n # For the Biceps, Triceps, Forearms and Abs (aka BTFA) session type \n btfa1 = Exercise.new(\"Bicep Curls\", \"BTFA\",true, 10, 5, 1.2,4,3) \n btfa2 = Exercise.new(\"Shoulder Press\", \"BTFA\", false, 10, 5, 1.2,4,3) \n btfa3 = Exercise.new(\"Bench Press\", \"BTFA\", true, 10, 5, 1.2,4,3) \n btfa4 = Exercise.new(\"Triceps Extension\", \"BTFA\", false, 10, 5, 1.2,4,3) \n btfa5 = Exercise.new(\"Sit Up\", \"BTFA\", true, 10, 5, 1.2,4,3) \n # For the Shoulders and Traps session type\n shoulders_traps1 = Exercise.new(\"Dumbell Shoulder Press\", \"Shoulders and Traps\",true, 10, 5, 1.2,4,3) \n shoulders_traps2 = Exercise.new(\"Upright Barbell Row\", \"Shoulders and Traps\", false, 10, 5, 1.2,4,3) \n shoulders_traps3 = Exercise.new(\"Seated Bent-over Rear Delt Raise\", \"Shoulders and Traps\", true, 10, 5, 1.2,4,3) \n shoulders_traps4 = Exercise.new(\"Side Lateral Raise\", \"Shoulders and Traps\", false, 10, 5, 1.2,4,3) \n shoulders_traps5 = Exercise.new(\"Barbell Shrug\", \"Shoulders and Traps\", true, 10, 5, 1.2,4,3) \n # For the Back session type\n back1 = Exercise.new(\"Barbell Deadlift\", \"Back\", true, 10, 5, 1.2,4,3) \n back2 = Exercise.new(\"Wide-Grip Pull Up\", \"Back\", false, 10, 5, 1.2,4,3) \n back3 = Exercise.new(\"Bent-Over Barbell Deadlift\", \"Back\", true, 10, 5, 1.2,4,3) \n back4 = Exercise.new(\"Standing T-Bar Row\", \"Back\", false, 10, 5, 1.2,4,3) \n # For the Chest session type\n chest1 = Exercise.new(\"Barbell Bench Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n chest2 = Exercise.new(\"Flat Bench Dumbbell Press\", \"Chest\", false, 10, 5, 1.2,4,3) \n chest3 = Exercise.new(\"Seated Machine Chest Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n chest4 = Exercise.new(\"Incline Dumbbell Press\", \"Chest\", false, 10, 5, 1.2,4,3) \n chest5 = Exercise.new(\"Machine Decline Press\", \"Chest\", true, 10, 5, 1.2,4,3) \n\n# add exercises to the PT object so that it's aware of them\n pt1.add_exercises(legs1)\n pt1.add_exercises(legs2)\n pt1.add_exercises(legs3)\n pt1.add_exercises(legs4)\n pt1.add_exercises(legs5)\n pt1.add_exercises(btfa1)\n pt1.add_exercises(btfa2)\n pt1.add_exercises(btfa3)\n pt1.add_exercises(btfa4)\n pt1.add_exercises(btfa5)\n pt1.add_exercises(shoulders_traps1)\n pt1.add_exercises(shoulders_traps2)\n pt1.add_exercises(shoulders_traps3)\n pt1.add_exercises(shoulders_traps4)\n pt1.add_exercises(shoulders_traps5)\n pt1.add_exercises(back1)\n pt1.add_exercises(back2)\n pt1.add_exercises(back3)\n pt1.add_exercises(back4)\n pt1.add_exercises(chest1)\n pt1.add_exercises(chest2)\n pt1.add_exercises(chest3)\n pt1.add_exercises(chest4)\n pt1.add_exercises(chest5)\n\n\n # establish id for user\n user.username = \"jim\"\n user.password = \"password\"\n user.first_name = \"Jimmy\"\n user.last_name = \"Coder\"\n user.gender = \"Male\"\n user.body_type = \"Mesomorph\"\n user.goal = \"musclebuild\"\n user.disclaimer = \"accept\"\n user.date_of_birth = Date.new(1990,9,9)\n # binding.pry\n user.weight = 56\n user.goal_weight = 75\n\n#establish some dummy workout history for our user:\n # (weight, completed_reps, exercise_performed, duration, date, session_number, session_type)\n workout_history_for_user = ExerciseInput.new(10, 8, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 9, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 10, chest1.name, 10, Date.new(2017,8,1), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(10, 11, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 9, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 9, chest1.name, 10, Date.new(2017,8,2), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,3), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,4), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 5, chest1.name, 10, Date.new(2017,8,5), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(15, 8, chest1.name, 10, Date.new(2017,8,6), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(20, 8, chest1.name, 10, Date.new(2017,8,7), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(20, 10, chest1.name, 10, Date.new(2017,8,8), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 7, chest1.name, 10, Date.new(2017,8,9), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 8, chest1.name, 10, Date.new(2017,8,10), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 9, chest1.name, 10, Date.new(2017,8,11), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n workout_history_for_user = ExerciseInput.new(25, 10, chest1.name, 10, Date.new(2017,8,12), 1, chest1.session_type)\n user.add_completed_session(workout_history_for_user)\n #\n\n\nend",
"def askQuestion(timeframe=1*DAY_TO_SECONDS)\n facts = @kb.getFacts(timeframe)\n while facts.length > 0\n fact = facts.sample\n matched = []\n @qat.each do |qat|\n ismatch = qat.matches(fact)\n matched.push(ismatch) if ismatch\n end\n qat,matchesArr = matched.sample\n if not qat #matching failed to match QAT and Tag\n facts = facts - [fact]\n next\n else\n #write question\n question,answers = qat.generateQuestionAnswerPair(fact,matchesArr)\n answers = [answers]\n if qat.aconds.first[:type] and qat.aconds.first[:type].include? 'list'\n similar = @kb.getSimilar(fact,timeframe,(not qat.aconds.first[:type].include? 'anysubclass'))\n similar.each do |simfact|\n answers << qat.generateQuestionAnswerPair(simfact,matchesArr)[1]\n end\n end\n puts \"Question:#{question}\"\n puts \"Possible Answers:#{answers.map {|a| a.gsub(\"\\n\",\"\")}}\"\n return [question,answers]\n end\n end\n return false\n end",
"def find_concepts( s )\n jump_count = 0 #prevent matched word from matching again\n ret = []\n return ret if s.blank?\n \n words = s.scan(LanguageModel::PTN_TERM).map{|w|w.downcase}\n 0.upto(words.length-1) do |i| #foreach word in sentence\n h = @ch\n if jump_count > 0 then jump_count-=1 ; next end\n \n i.upto(words.length-1) do |j| #foreach word try matching with concept table\n #p \" >Checking words[#{i},#{j}] = #{w}\"\n w = words[j] #'current word\n wn = words[j+1] if j+1 < words.length # next word\n if !h[w] # no concept is matched\n break \n elsif h[w].class == Hash #many concepts are matched\n # Next Word doesn't match & key was found\n if !h[w][wn] && h[w][:_key_]\n if block_given?\n yield h[w][:_key_] , words[i..j].join(' ')\n else\n #puts \"Found: #{words[i..j].join(' ')}\"\n ret << [h[w][:_key_], words[i..j].join(' ')]\n end\n break\n else #Move to Next Word\n jump_count += 1\n h = h[w]\n end\n elsif h[w].class == Fixnum #one concept is matched\n if block_given?\n yield h[w] , words[i..j].join(' ')\n else\n #puts \"Found: #{words[i..j].join(' ')}\"\n ret << [h[w], words[i..j].join(' ')]\n end\n break\n else\n error \"[ConceptStorage#find_concept] Invalid value #{h[w].inspect}\"\n end\n end#do\n end#do\n ret\n end",
"def hypothesis2(countsXmajor) \n\tcriteria = 0\n\teuks = 0\n\teuks += 1 if countsXmajor['Sr'] >= 0.25\n\teuks += 1 if countsXmajor['Pl'] >= 0.25\n\teuks += 1 if countsXmajor['Op'] >= 0.25\n\teuks += 1 if countsXmajor['EE'] >= 0.25\n\teuks += 1 if countsXmajor['Am'] >= 0.25\n\teuks += 1 if countsXmajor['Ex'] >= 0.25\t\t\n\tcriteria += 1 if countsXmajor['Ba'] < 0.25 \n\tcriteria += 1 if countsXmajor['Za'] >= 0.25 \n\tcriteria += 1 if euks >= 5\n\tif criteria == 3\n\t\treturn 1\n\telse\n\t\treturn 0 \n\tend\nend",
"def generate_personality_map\n return nil if @quiz_answers.empty?\n\n # Reset personality profile map in case user wants to take test multiple times\n @profile_map = {\n extraverted: 0,\n introverted: 0,\n sensing: 0,\n intuition: 0,\n thinking: 0,\n feeling: 0,\n judging: 0,\n perceiving: 0\n }\n \n # Create personality profile based on answer key\n @quiz_answers.each_with_index do |answer, i|\n if answer == \"a\"\n if i % 7 == 0\n @profile_map[:extraverted] += 1\n elsif ((i+6) % 7 == 0 || (i+5) % 7 == 0)\n @profile_map[:sensing] += 1\n elsif ((i+4) % 7 == 0 || (i+3) % 7 == 0)\n @profile_map[:thinking] += 1\n else \n @profile_map[:judging] += 1\n end\n else \n if i % 7 == 0 \n @profile_map[:introverted] += 1\n elsif ((i+6) % 7 == 0 || (i+5) % 7 == 0)\n @profile_map[:intuition] += 1\n elsif ((i+4) % 7 == 0 || (i+3) % 7 == 0)\n @profile_map[:feeling] += 1\n else \n @profile_map[:perceiving] += 1\n end\n end\n end\n end",
"def solutions(args)\n book = require_arg(args,'book')\n hw = get_hw_from_file_or_die(require_arg(args,'in_file'))\n sets = hw_to_sets(hw,book)\n stream_labels = assign_starts_of_streams_to_sets(sets,hw)\n out_file = require_arg(args,'out_file')\n class_title = require_arg(args,'class_title')\n sets = require_arg(args,'sets')\n gb_file = require_arg(args,'gb_file')\n sample = (args.has_key?('sample') && args['sample'].to_i==1)\n roster = get_roster_from_opengrade(gb_file) # roster[\"blow_joe\"]={last, first, class, id_string, and id_int}\n solution_in_book = {} # [label]=boolean\n sources_parent_dir = File.expand_path(require_arg(args,'sources_parent_dir'))\n subdir_list = []\n Dir.chdir(sources_parent_dir) do # do block so we chdir back afterward\n subdir_list=Dir[\"*\"].reject{|o| not File.directory?(o)}.sort\n end\n probs = {}\n n_hw_defined=0\n header = true\n students_encountered = {}\n problem_labels_encountered = []\n File.readlines(sets).each { |line|\n if header then\n header = false\n else\n # set,book,ch,num,parts,flags,chunk,student\n unless line=~/(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*)/ then fatal_error(\"illegal line in #{sets}: #{line}\") end\n hw,ch,num,student = [$1.to_i,$3.to_i,$4,$8] # no to_i on num, could be \"g7\"\n if hw>n_hw_defined then n_hw_defined=hw end\n students_encountered[student] = true\n if probs[student].nil? then probs[student] = {} end\n if probs[student][hw].nil? then probs[student][hw] = [] end\n l = $num_to_label[[ch,num]]\n if l.nil? then fatal_error(\"no label found for ch. #{ch}, problem #{num}\") end\n problem_labels_encountered.push(l)\n probs[student][hw].push(l)\n end\n }\n students_encountered.keys.each { |k|\n unless roster.has_key?(k) then fatal_error(\"student #{k} occurs in #{sets}, but not in #{gb_file}\") end\n }\n roster.keys.each { |k|\n unless students_encountered.has_key?(k) then fatal_error(\"student #{k} occurs in #{gb_file}, but not in #{sets}\") end\n }\n label_to_source_file = {}\n problem_labels_encountered.each { |l|\n p = $label_to_num[l]\n solution_in_book[l] = $has_solution[p]\n subdir_list.each { |d|\n t = sources_parent_dir+\"/\"+d+\"/\"+l+\".tex\"\n if File.exists?(t) then label_to_source_file[l] = t; next end\n }\n if !solution_in_book[l] && label_to_source_file[l].nil? then $stderr.print \"warning: no solution found for #{l} in any subdirectory of #{sources_parent_dir}\\n\" end\n }\n head = <<-\"HEAD\"\n \\\\documentclass{simplesolns}\n \\\\begin{document}\n {\\\\Huge\\\\textbf{Solutions for #{class_title}}}\\\\\\\\\\n\n HEAD\n tail = <<-'TAIL'\n \\end{document}\n TAIL\n toc = ''\n tex = ''\n 1.upto(n_hw_defined) { |hw|\n toc = toc + \"\\\\noindent Homework #{hw} ... \\\\pageref{set#{hw}}\\\\\\\\\\n\"\n first_student = true\n roster.keys.sort.each { |student|\n label_for_toc = ''\n if sample && !first_student then break end\n if first_student then label_for_toc = \"\\\\label{set#{hw}}\" end\n tex = tex + <<-\"TEX\"\n\n \\\\pagebreak\n\n \\\\noindent%\n {\\\\large\\\\textbf{Solutions to Homework #{hw}, #{class_title},\n #{roster[student][\"first\"]} #{roster[student][\"last\"]} }}#{label_for_toc}\\\\\\\\\\n\n TEX\n first_student = false\n probs[student][hw].each { |label|\n p = $label_to_num[label]\n if solution_in_book[label] then\n tex = tex+solution_helper(p,'solution in the back of the book')\n else\n source_file = label_to_source_file[label]\n missing = false\n if source_file.nil?\n missing = true\n else\n s,err = slurp_file_with_detailed_error_reporting(source_file)\n if s.nil? then \n missing=true \n $stderr.print \"warning: error reading file #{source_file}, #{err}\"\n else\n tex = tex+solution_helper(p,s)\n end\n end\n if missing then\n tex = tex+solution_helper(p,'!!!!!!!!!!! missing solution !!!!!!!!!!!!!!')\n end\n end\n }\n }\n }\n File.open(out_file,'w') { |f|\n f.print head+toc + \"\\\\pagebreak\" + tex+tail\n }\nend",
"def food_question1(food_answer1)\n if food_answer1 == \"never\"\n @food_score1 = 0\n elsif food_answer1 == \"1 - 3 days per week\"\n @food_score1 = 1\n elsif food_answer1 == \"4 or more days per week\"\n @food_score1 = 2\n end\n @food_score1\nend",
"def compute_actual\n line[1] = @ho_form.line['sqft']\n line[2] = @ho_form.line['total_sqft']\n line[3] = (line[1] * 100.0 / line[2]).round(2)\n\n line['4/gross_inc'] = gross_income\n\n # We make a simplifying assumption that (1) every Home Office Expense\n # applies to every Home Office form, and (2) all expenses are indirect.\n categorize_records('Home Office Expense')\n #\n # We assume that the home office using the actual method is being rented and\n # thus there are no mortgage payments or such on it.\n #\n #fill_for_categories(self, '5b', 'Casualty_Losses')\n #fill_for_categories(self, '6b', 'Mortgage_Interest')\n #fill_for_categories(self, '7b', 'Real_Estate_Taxes')\n\n line['8b'] = sum_lines('5b', '6b', '7b')\n line[9] = (line['8b'] * line[3] / 100.0).round\n line[10] = line[9]\n\n line[11] = other_business_expenses\n\n line[12] = sum_lines(10, 11)\n line['13/ho_max_ded'] = line[4] - line[12]\n\n fill_for_categories(self, '16b', 'Insurance')\n fill_for_categories(self, '17b', 'Rent')\n fill_for_categories(self, '18b', 'Repairs')\n fill_for_categories(self, '19b', 'Utilities')\n fill_other_categories(\n self, '20b', continuation: 'Other Home Office Expenses'\n )\n line['21b'] = sum_lines(*%w(14b 15b 16b 17b 18b 19b 20b))\n line[22] = (line['21b'] * line[3] / 100.0).round\n\n # Assume no carryover for line 23\n line['24/ho_ded'] = sum_lines('21a', 22, 23)\n line[25] = [ line[13], line[24] ].min\n line[26] = line[13] - line[25]\n\n # Assume no casualty losses or depreciation for lines 27-29 and 33\n line[30] = sum_lines(27, 28, 29)\n line[31] = [ line[26], line[30] ].min\n line[32] = sum_lines(10, 25, 31)\n\n line[33] = BlankZero\n line['34/ho_expenses'] = line[32] - line[33]\n\n end",
"def match_to_preflabel(name)\n name = name.downcase\n case name\n when /reconstruction/\n standard_name = 'University of York. Post-war Reconstruction and'\\\n ' Development Unit'\n when /applied human rights/\n standard_name = 'University of York. Centre for Applied Human Rights'\n when /health economics/\n standard_name = 'University of York. Centre for Health Economics'\n when /health sciences/\n standard_name = 'University of York. Department of Health Sciences'\n when /lifelong learning/\n standard_name = 'University of York. Centre for Lifelong Learning'\n when /medieval studies/\n standard_name = 'University of York. Centre for Medieval Studies'\n when /renaissance/\n standard_name = 'University of York. Centre for Renaissance and Early'\\\n ' Modern Studies'\n when /reviews/\n standard_name = 'University of York. Centre for Reviews and'\\\n ' Disseminations'\n when /women/\n standard_name = \"University of York. Centre for Women's Studies\"\n when /school of social and political science/\n standard_name = 'University of York. School of Social and Political'\\\n ' Science'\n when /social policy/\n standard_name = 'University of York. Department of Social Policy and'\\\n ' Social Work'\n when /school of politics economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /politics/\n standard_name = 'University of York. Department of Politics'\n when /economics and related/\n standard_name = 'University of York. Department of Economics and Related'\\\n ' Studies'\n when /economics and philosophy/\n standard_name = 'University of York. School of Politics Economics and'\\\n ' Philosophy'\n when /history of art/\n standard_name = 'University of York. Department of History of Art'\n when /history/\n standard_name = 'University of York. Department of History'\n when /electronic/\n standard_name = 'University of York. Department of Electronic Engineering'\n when /theatre/\n standard_name = 'University of York. Department of Theatre, Film and'\\\n ' Television'\n when /physics/\n standard_name = 'University of York. Department of Physics'\n when /computer/\n standard_name = 'University of York. Department of Computer Science'\n when /psychology/\n standard_name = 'University of York. Department of Psychology'\n when /law/\n standard_name = 'University of York. York Law School'\n when /mathematics/\n standard_name = 'University of York. Department of Mathematics'\n when /advanced architectural/\n standard_name = 'University of York. Institute of Advanced Architectural'\\\n ' Studies'\n when /conservation/\n standard_name = 'University of York. Centre for Conservation Studies'\n when /eighteenth century/\n standard_name = 'University of York. Centre for Eighteenth Century\n Studies'\n when /chemistry/\n standard_name = 'University of York. Department of Chemistry'\n when /sociology/\n standard_name = 'University of York. Department of Sociology'\n when /education/\n standard_name = 'University of York. Department of Education'\n when /music/\n standard_name = 'University of York. Department of Music'\n when /archaeology/\n standard_name = 'University of York. Department of Archaeology'\n when /biology/\n standard_name = 'University of York. Department of Biology'\n when /biochemistry/ # confirmed with metadata team - recheck?\n standard_name = 'University of York. Department of Biology'\n when /english and related/ # confirmed directly with English department\n standard_name = 'University of York. Department of English and Related'\\\n ' Literature'\n when /philosophy/\n standard_name = 'University of York. Department of Philosophy'\n when /management studies/\n standard_name = 'University of York. Department of Management Studies'\n when /management school/\n # older versionof department name which should be retained if match found\n standard_name = 'University of York. The York Management School'\n when /language and linguistic science/\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /language and lingusitic science/ # deal with common typo\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science'\n when /for all/ # this is 'languages for all' but in some records 'language'\n standard_name = 'University of York. Department of Language and'\\\n ' Linguistic Science. Languages for All'\n when /hull/\n standard_name = 'Hull York Medical School'\n when /international pathway/\n standard_name = 'University of York. International Pathway College'\n when /school of criminology/\n standard_name = 'University of York. School of Criminology'\n when /natural sciences/\n standard_name = 'University of York. School of Natural Sciences'\n when /environment and geography/ # order important, more precise must be first\n standard_name = 'University of York. Department of Environment and Geography'\n when /environment/\n standard_name = 'University of York. Environment Department'\n else\n standard_name = 'COULD NOT MATCH ' + name\n end\n standard_name\n end"
] | [
"0.6192346",
"0.6157222",
"0.58506584",
"0.58418137",
"0.5756591",
"0.57231456",
"0.5683203",
"0.5663828",
"0.56184596",
"0.5471711",
"0.5414442",
"0.5408823",
"0.53773904",
"0.5366379",
"0.53661245",
"0.53519434",
"0.5348606",
"0.5348154",
"0.5348067",
"0.5347627",
"0.53369117",
"0.53277487",
"0.53167164",
"0.5281771",
"0.5273724",
"0.52726465",
"0.52529496",
"0.52391464",
"0.52388686",
"0.523659",
"0.5218143",
"0.52151835",
"0.52044785",
"0.5204013",
"0.5197384",
"0.5196505",
"0.5195761",
"0.51909816",
"0.51856494",
"0.51801616",
"0.51754814",
"0.5174007",
"0.516679",
"0.5134441",
"0.5132559",
"0.5132388",
"0.5121772",
"0.5112247",
"0.5102395",
"0.5100661",
"0.50966614",
"0.509146",
"0.5078216",
"0.507244",
"0.50720155",
"0.50628185",
"0.505622",
"0.50545806",
"0.50366807",
"0.5036606",
"0.5031753",
"0.5017428",
"0.50168",
"0.5009931",
"0.5000293",
"0.4998529",
"0.4997559",
"0.49953187",
"0.4994904",
"0.49876785",
"0.49782294",
"0.49742267",
"0.49711668",
"0.49709228",
"0.49708268",
"0.4970696",
"0.49657586",
"0.49566147",
"0.49539092",
"0.49516404",
"0.49512976",
"0.49495265",
"0.49474078",
"0.49454623",
"0.4937707",
"0.49365252",
"0.49349314",
"0.4929999",
"0.4918031",
"0.4916467",
"0.49126154",
"0.49100897",
"0.49065915",
"0.49004665",
"0.48984018",
"0.4895584",
"0.48935315",
"0.48921162",
"0.48921135",
"0.4890646",
"0.4890361"
] | 0.0 | -1 |
the artist class needs an instance method, the add_song that takes in an argument of a song and adds the song to the artist collection of songs. The add_song method should also tell the song that belongs to the artist. | def add_song(song)
@songs << song
song.artist = self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_song(song) #=> we found out by looking at the test that the argument is a song instance\n # the following code tells the current artist calling the method what new song it has:\n self.songs << song\n # but the test is asking us for the inverse of this - instead of telling artist \n # about its songs, we need to tell song about its artist:\n song.artist = self\n # inside the Artist instance scope, Self refers to the artist object calling the add_song method\n end",
"def add_song(song) # Third, we create 'add_song' to associate a song name with a particular artist.\n song.artist = self # When we call 'song.artist', we set the result equal to 'self', or the artist on which we are calling the method.\n end",
"def add_song(song)\n #associates a song to the artist's collection\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n # We want to tell the song_name passed in that it belongs to the instance\n # of Artist for which this method is called on aka self.\n song.artist = self\n end",
"def add_song(song)\n # song.artist = self # assigns the current artist to the song's 'artist' property (song belongs to artist)\n #@songs << song #adds the song to the current artist's 'songs' collection \n ##does not assign the artist if the song already has an artist\n if song.artist == self\n song.artist\n else\n song.artist = self\n end \n # does not add the song to the current artist's collection of songs if it already exists therein\n if songs.include?(song)\n song\n else\n songs << song\n end \n songs\n end",
"def add_song(song) ### arg is song instance ###\n\t\tsong.artist = self\n\t\tsong.artist.songs << song\n\tend",
"def add_song(song)\n @songs << song\n song.artist = self\n\n end",
"def add_song(song)\n song.artist= self\n @songs << song\n end",
"def add_song(song)\n @@songs << song\n song.artist = self\n end",
"def add_song(song)\n song.artist = self \n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n @songs << song\n end",
"def add_song(song)\n song.artist = self\n @songs << song\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n self.songs << song\n new_song = Song.new(song)\n new_song.artist = self\n end",
"def add_song(song)\n @songs << song #add songs by sheveling song into the @song instance\n song.artist = self #add artists name of the songs\n end",
"def add_song(song)\r\n @songs << song\r\n song.artist = self\r\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n song.artist = self #associate the song with this artist\n end",
"def add_song(song)\n @songs << song\n #here we use the self keyword to refer to the artist on which we are calling this method. We call the =artist method onto the song that is being passed as an argument and set that to self (the artist)\n song.artist = self\n#once we add a new song we want to increase the class array song count\n @@song_count +=1\n end",
"def add_song(song)\n song.artist = self\n end",
"def add_song(song)\n if song.artist!=self\n song.artist = self\n elsif [email protected]?(song)\n @songs << song\n end\n end",
"def add_song(song)\n song.artist = self #instead of @songs << song\n \n # - TEST -\n # hello = Song.new(\"Hello\")\n # adele.add_song(hello)\n # expect(adele.songs).to include(hello)\n # expect(hello.artist).to eq(adele) \n end",
"def add_song(song) #Add the instance of the song to the @songs array (but do NOT add duplicated)\n if @songs.include?(song) == false #So, check first to see if it has been added yet or not.\n @songs << song #Push the song into the array if it has not been added yet\n song.artist = self if song.artist == nil #If no artist (nil) then the Song's artist is self (this instance of the song/artist) Associates the two. else nil #If else (i.e. song is already included in the array, do not add it.)\n end\n end",
"def add_song(song)\n song.artist = self unless song.artist == self #the song's artist property here\n @songs << song unless @songs.include?(song)\n end",
"def add_song(song)\n @song = song\n @songs << song\n\n @@song_count = @@song_count + 1\n song.artist = self\n end",
"def add_song(song)\n if self.songs.include?(song) == false\n @songs << song\n end\n\n if song.artist.nil? || song.artist == false\n song.artist = self\n end\n\n end",
"def add_song(song)\n @@song_count += 1\n @songs << song\n song.artist = self #self refers to Artist\n\n end",
"def add_song(song)\n if song.artist == nil #does not assign the song if the song already has an artist\n song.artist = self #assigns current artist to songs artist property\n else\n nil\n end\n if @songs.include?(song)\n nil\n else\n @songs << song #adds song, does not add the song if already exists\n end\n song\n end",
"def add_song(song)\n # Add song to @songs if it doesn't already exist\n @songs << song if [email protected]?(song)\n # Add artist if not already assigned\n song.artist = self if song.artist ==nil\n save\n end",
"def add_song(song)\n song.artist = self unless song.artist == self\n @songs << song unless @songs.include? song\n end",
"def add_song(song)\n if(!song.artist)\n song.artist = self\n end\n \n if(!self.songs.include?song)\n self.songs << song\n end\n end",
"def add_song(song)\n song.artist = self \n #binding.pry\n end",
"def add_song(song)\n # I hava class varaible @@all in Song class\n # the song is adding to self (refering to the \n # Artist)\n # adds that song to the artist's collection\n # HOW??? \n @song << song # without it\n song.artist = self \n #binding.pry\n end",
"def add_song(song_title)\n #adds the song to the current artist's 'songs' collection = @songs\n #does not add the song to the current artist's collection of songs if it already exists therein\n songs << song_title if !songs.detect{|song| song == song_title}\n\n\n #assigns the current artist to the song's 'artist' property (song belongs to artist)\n #does not assign the artist if the song already has an artist\n\n song_title.artist = self if song_title.artist == nil\n end",
"def add_song(song)\n @songs << song \n end",
"def add_song(song)\n @songs << song\nend",
"def add_song(song)\n @songs << song\n song.artist = self\n @@sounds_count += 1\n\n end",
"def add_song(song) #song = #<Song:0x007fc75eb94420 @genre=#<Genre:0x007fc75eb94498 @name=\"rap\", @songs=[]>, @name=\"99 Problems\">\n\n self.songs << song\n end",
"def artist=(artist) #assigns an artist to the song (song belongs to artist)\n @artist = artist #artist is reading from Song class artist method(reader)\n artist.add_song(self) #invokes Artist#add_song to add itself to the artist's collection of songs (artist has many songs)\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n @artist.add_song(self)\n end",
"def add_song(song_instance)\n songs << song_instance\n end",
"def add_song_by_name(name) #takes in argument name of (song)\n song = Song.new(name) #creating a new instance of a song\n song.artist = self #Right here all we're doing is associating the objects its that simple\n end",
"def artist=(artist)\n @artist = artist\n if artist.class == Artist\n artist.add_song(self)\n end\n end",
"def add_song(song)\n songs << song\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self)\n end",
"def artist= (artist)\n @artist = artist\n artist.add_song(self)\n end",
"def add_song(song)\n songs << song\n end",
"def add_song(song)\n #@song << song\n #song.artist = self \n self.songs << song \n \n # self.songs << song \n #binding.pry \n end",
"def add_song_by_name(song_name)\n # Create a new song called \"song\" with argument passed in.\n song = Song.new(song_name)\n # Associate it with the artist\n song.artist = self\n end",
"def add_song_by_name(name)\nartist = Song.new(name)\nadd_song(artist)\nend",
"def artist=(artist_obj)\n @artist = artist_obj\n\n #self is a song obj\n artist_obj.songs.push(self)\n end",
"def add_song(song_to_be_added)\n @songs << song_to_be_added\n end",
"def artist=(artist)\n @artist = artist\n artist.add_song(self) #=> invokes Artist#add_song to add itself to the artist's collection of songs (artist has many songs)\n end",
"def artist=(the_artist)\n @artist = the_artist\n if @artist \n @artist.add_song(self)\n end\n @artist\n end",
"def add_song(song)\n\t\t@songs <<(song)\n\t\t\n\tend",
"def artist=(artist)\n @artist = artist\n #Invokes Artist#add_song to add itself to the artist's songs collection \n # (artist has-many songs) \n self.artist.add_song(self)\n end",
"def artist_name=(name)\n self.artist = Artist.find_or_create_by_name(name)\n #return the new song instance\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n \n # invokes Artist#add_song to add itself to the artist's\n # collection of songs (artist has many songs)\n artist.add_song(self)\n end",
"def artist=(artist)\n @artist = artist\n if artist != nil\n @artist.add_song(self)\n end\n end",
"def artists(artist)\n if song.artist = nil || !Artist.find_by_name(name)\n song.artist = artist \n Artist.all << artist \n end \n end",
"def add_song_by_name(name)\n\t\tSong.new(name).artist = self \n\tend",
"def initialize #initializes songs belonging to artist\r\n @song = artist\r\n end",
"def add_song_by_name(title)\n new_song = Song.new(title)\n #tell the song it belongs to a specific artist\n add_song(new_song) #invoking previously written method\n end",
"def initialize(name)\n @name = name\n @songs = [ ]\n #peter.song = (\"pit\") How to attribute song to the artist after the artist is create.\n end",
"def initialize(name, genre)\n @name = name\n @genre = genre\n genre.add_song(self)\nend",
"def artist_name=(name)\n #object attr\n self.artist = Artist.find_or_create_by_name(name)\n\n artist.add_song(self)\n\n end",
"def add_song(x)\n \t@songs << x\n end",
"def add_song_by_name(song_name)\n song = Song.new(song_name)\n @@songs << song\n song.artist = self\n end",
"def add_song_by_name(name)\n song = Song.new(name)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n song.genre = self unless song.genre\n @songs << song unless @songs.include?(song)\n end",
"def add_song_by_name(name)\n song = Song.new(name)\n @songs << song\n song.artist = self\n end",
"def add_song(song)\n @songs.push(song)\n end",
"def artist=(artist)\n #associates an artist with a song\n @artist = artist\n end"
] | [
"0.8756985",
"0.8594919",
"0.85546535",
"0.84989583",
"0.83455676",
"0.83399445",
"0.83282304",
"0.83179665",
"0.82847553",
"0.828099",
"0.8276707",
"0.8276707",
"0.8276707",
"0.8276707",
"0.8276707",
"0.8276707",
"0.8270203",
"0.8270203",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.826477",
"0.8249213",
"0.82365245",
"0.82210106",
"0.8193631",
"0.8193631",
"0.8193631",
"0.81932074",
"0.81494135",
"0.81131744",
"0.8080299",
"0.8078271",
"0.80232835",
"0.8019593",
"0.7972002",
"0.797046",
"0.7960794",
"0.79471785",
"0.79009175",
"0.7898768",
"0.78651524",
"0.78087896",
"0.7800338",
"0.7671734",
"0.7618063",
"0.7614779",
"0.75427157",
"0.7528009",
"0.75024843",
"0.74930906",
"0.74930906",
"0.74930906",
"0.74930906",
"0.74930906",
"0.74930906",
"0.74874914",
"0.74874914",
"0.74874914",
"0.747329",
"0.74684346",
"0.7465496",
"0.7444331",
"0.7434331",
"0.74235785",
"0.74080604",
"0.7381325",
"0.7377552",
"0.73749346",
"0.73662573",
"0.73588413",
"0.735428",
"0.7344424",
"0.7284787",
"0.7275118",
"0.7248903",
"0.7180725",
"0.7162248",
"0.7153804",
"0.7152797",
"0.7152757",
"0.71326274",
"0.70874965",
"0.70692503",
"0.7042868",
"0.70392543",
"0.70375276",
"0.69602686",
"0.69490105",
"0.6927628",
"0.69210935",
"0.69038916",
"0.68986"
] | 0.83697146 | 4 |
returns the songs array | def songs
@songs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n # @@songs.select { |song| song.name == @name }\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end",
"def songs \n @songs\n end",
"def songs\n @songs ||= Song.where(:artist => info(:name))\n end",
"def songs_found\n get_songs\n return @songs\n end",
"def songs\n Song.all\n end",
"def all_songs\n end",
"def songs\n Song.all_by_artist(self)\n end",
"def songs\n Song.all\n end",
"def hardcoded_songs\n [\n Song.new(\"Maroon 5 - This love\", [13, 68, 13, 68, 13, 45, 68, 13]),\n Song.new(\"Ben l'oncle soul - Seven nation army\", [68, 13, 0, 68, 13, 0, 68]),\n Song.new(\"Ornatos Violeta - Para de olhar para mim\", [77, 125, 93, 77])\n ]\n end",
"def list_songs \n self.lib.songs.each do |song|\n puts song.to_s_simple\n end\n end",
"def get_songs\r\n # create array of to_tab's of song obj using .collect. join this array with a newline separator.\r\n return @songs.collect{|song| song.to_tab }.join(\"\\n\")\r\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.find_by_album(@id)\n end",
"def songs\n #use select to iterate thru songs\n Song.all.select{|song| song.artist == self}\n end",
"def songs\n MusicImporter.new(path).print_songs\n end",
"def songs\n Song.all.select {|song| song.artist == self }\n end",
"def song_plays\n SongPlay.where(:song_path => path)\n end",
"def get_songs_ids\n if @song_ids\n return @song_ids\n else\n return get_songs.map { |x| x[IDX_SONG_ID] }\n end\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end",
"def songs\n Song.all.select do |song| \n song.artist == self\n end \n end",
"def songs\n Song.all.select{|song| song.artist == self}\n end",
"def list\n for song in self.songs\n puts song.name\n end\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def songs\n Song.all.select {|songs|songs.artist == self}\n end",
"def songs\n Song.all.select{|song|song.artist == self}\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self\n end\n end",
"def songs \n Song.all.select{|song| add_song(song)}.to_a\n # binding.pry\n end",
"def related_songs\n unless self.spotify_track_id.nil?\n related_artists = self.spotify_track.artists.first.related_artists\n\n related_artists.shuffle[0..4].map do |artist|\n artist.top_tracks('IE').shuffle.first\n end.flatten\n else\n Array.new\n end\n\n\n end",
"def plays\n return @plays_array\n end",
"def songs\n Song.all.select do |song|\n song.artist == self.name\n end\n end",
"def songs\n Song.all.select {|song| song.artist = self}\n end",
"def songs # to entre the Song class then within the song class take the class variable all to use to select and go thought the songs listed in that array\n Song.all.select { |song| song.artist == self } # use the .select to gather the information we want from the all array in songs - go thought and assign each song artist to this current instance\n end",
"def names\n @songs.map(&:name).uniq\n end",
"def songs\n Song.all.select {|s| s.artist == self}\n end",
"def initialize\n @songs = []\n end",
"def initialize\n @songs = []\n end",
"def songs\n Song.all.select {|songs| songs.artist == self}\n end",
"def songs\n Song.all.select {|song| song.genre == self}\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def index\n @songs = Song.all\n @songs_with_names = Song.all.map{|s| [s, s.artist ? s.artist.name : \"\"]}\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def initialize\n @songs = []\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self \n end\n end",
"def get_play_list_song_ids\n return [] if !@play_list\n\n if @play_list_song_ids\n return @play_list_song_ids\n else\n return get_songs.map { |x| x[IDX_PLAYLIST_ID] }\n end\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def songs\n Song.all.select{|song| song.genre == self}\n end",
"def songs\n Song.all.select{|song| song.genre == self}\n end",
"def list_songs\n puts \"Here are the songs in your music library:\"\n Song.all.each.with_index(1){|song, index|\n puts \"#{index}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n }\n end",
"def songs\n Song.all.select{|song| song.artist == self}\n end",
"def paginated_songs\n\t\treturn @paginated_songs\n\tend",
"def genres\n songs.map do |song| song.genre end\n end",
"def genres\n songs.map {|song| song.genre}\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def list_songs\n self.sorted_list_songs.each_with_index do |song, idx|\n puts \"#{(idx + 1).to_s}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n end\n end",
"def print_songs\n song_names = []\n self.songs.collect {|song| song_names << song.name}\n puts song_names\n end",
"def genres\n songs.map {|song| song.genre }\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def songs\n Song.all.select do |song| song.artist == self end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.artist == self \n end \n end",
"def genres\n songs.map do |song|\n song.genre\n end\nend",
"def song_ids\n @song_ids ||= input[\"songs\"].map{|song| song[\"id\"]}\nend",
"def genres\n self.songs.map do |artist_song|\n artist_song.genre\n end\n end",
"def songs \n Song.all.select do |e|\n e.artist == self\n end\n end",
"def songs\n Song.all.select {|song_name| song_name.genre == self}\n end",
"def songs\n\t\t@musician = User.find_by_id(current_user.id)\n\tend",
"def index\n @songs = @album.songs.all\n end",
"def genres\n self.songs.map {|x| x.genre}\n end",
"def print_songs\n self.songs.each {|s| puts s.name}\n end",
"def initialize\n\t\t@songs = Array.new\n\tend",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def songs\n ret = Jbuilder.encode do |json|\n _songs = Song.where(category_id: params[:id])\n json.array! _songs do |song|\n json.(song, :title, :id, :artist, :category_id, :created_at) \n json.path song.path\n end\n end\n render json: ret\n end",
"def song\n fetch('bossa_nova.songs')\n end",
"def albums_with_one_song(n = 10)\n single_songs = []\n @albums.each do |a|\n b = @tracks.find_all {|s| s.album == a}\n single_songs << b.first unless b.length > 1\n end\n return single_songs[0..n-1]\n end",
"def all_top_songs\n songs = Hash.new\n Artist.all.each do |artist|\n begin\n song = artist.top_song_names[0]\n songs[artist.name] = song\n rescue URI::InvalidURIError\n puts \"Unable to retrive song for #{artist.name}\"\n rescue NoMethodError\n puts \"'NoMethodError' for #{artist.name}\"\n end\n end\n return songs\n end",
"def read_tracks(music_file)\n\t\tcount = music_file.gets().to_i()\n\t\ttracks = Array.new()\n\t# Put a while loop here which increments an index to read the tracks\n\t\ti = 0 \n\t\twhile i < count do \n\t\t\ttracks << read_track(music_file) \n\t\t\ti +=1\n\t\tend \n\treturn tracks\n end",
"def show_songs_in_playlist\n \n file_name = params[:file_name]\n\n @song_list = []\n File.read(\"#{Rails.root}/public/Playlist/#{params[:file_name]}\").each_line do |line|\n @song_list << line.chop\n end\n end"
] | [
"0.8498246",
"0.8498246",
"0.83441764",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.830164",
"0.8173747",
"0.8162238",
"0.8016703",
"0.8003093",
"0.7837545",
"0.7820602",
"0.76459885",
"0.74929166",
"0.7467641",
"0.74629813",
"0.7452518",
"0.74410987",
"0.7428181",
"0.74046767",
"0.7390436",
"0.7384258",
"0.73712695",
"0.7367499",
"0.73423535",
"0.73423535",
"0.73423356",
"0.7323485",
"0.7318463",
"0.7302355",
"0.7301986",
"0.7299148",
"0.728716",
"0.728269",
"0.728269",
"0.7274263",
"0.72654206",
"0.7264598",
"0.7234671",
"0.7216249",
"0.7212013",
"0.7146963",
"0.7123239",
"0.7070979",
"0.7046349",
"0.7046349",
"0.7040776",
"0.70394814",
"0.70381033",
"0.7031804",
"0.702298",
"0.70206636",
"0.7020247",
"0.7019014",
"0.7014162",
"0.7013728",
"0.7012272",
"0.7012272",
"0.70098746",
"0.7001779",
"0.69990176",
"0.6988488",
"0.6979401",
"0.69755286",
"0.6963919",
"0.6955882",
"0.69534725",
"0.6940655",
"0.6933848",
"0.69205606",
"0.69205606",
"0.69019985",
"0.6899983",
"0.6899983",
"0.6899983",
"0.6861846",
"0.6851976",
"0.68316096",
"0.68297666",
"0.6819243",
"0.6805222",
"0.6779608",
"0.6769841",
"0.6769362",
"0.6767272",
"0.6756794",
"0.67493135",
"0.6736837",
"0.67333144",
"0.67311585",
"0.6727882",
"0.6715747",
"0.6715342"
] | 0.7618532 | 20 |
iterates over that artist's songs and collects the genre of each song | def genres
self.songs.collect {|song| song.genre}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end",
"def genres\n self.songs.collect do |song| #call the artist class on the songs method and collect the song\n song.genre #then call the genre on the song\n end\n end",
"def genres\n songs.collect do |song|\n song.genre\n end\n .uniq #does not return duplicate genres if the artist has more than one song of a particular genre (artist has many genres through songs)\n end",
"def genres\n self.songs.map do |artist_song|\n artist_song.genre\n end\n end",
"def genres\n songs.map{|song| song.genre} # giving back all the genres under that particular artist. artists can have nmany genres and calling of theirmany genres.\n # Song.all.map{|ind_song| ind_song.genre} #giving back all the different genres from the collection of song array. giving back all the genres of the songs\n # binding.pry\n end",
"def genres\n @new_array_of_genres = []\n @songs.each do |song| #iterate through each song to find the genre\n if @new_array_of_genres.include?(song.genre) #does not return duplicate genres\n nil\n else\n @new_array_of_genres << song.genre #collects genres through its songs\n end\n end\n @new_array_of_genres #returns a collection of genres for all of the artists songs\n end",
"def artists\n songs.collect do |song|\n song.artist\n end\n .uniq #does not return duplicate artists if the genre has more than one song by a particular artist (genre has many artists through songs)\n end",
"def genres\n songs.map do |song| song.genre end\n end",
"def genres\n songs.map {|song| song.genre }\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n self.songs.collect do |song|\n song.genre\n end\n end",
"def genres\n songs.map {|song| song.genre}\n end",
"def genres\r\n self.songs.collect do |song|\r\n song.genre\r\n end\r\n end",
"def genres\n\t\[email protected] {|g| g.genre}\n\tend",
"def genres\n @songs.collect {|s| s.genre}\n end",
"def genres\n songs.collect{|song| song.genre}.uniq\n end",
"def artists\n genre_artists = []\n Song.all.each {|song|\n if song.genre == self &&\n !genre_artists.include?(song.artist)\n genre_artists << song.artist\n end\n }\n genre_artists\n end",
"def genres\n songs.map{|song|song.genre}.uniq\n end",
"def genres\n @songs.collect do |song|\n song.genre\n end.uniq\n end",
"def genres\n songs.map do |song|\n song.genre\n end\nend",
"def genres\n all_genres = []\n Song.all.each do |x|\n if x.artist == self\n all_genres << x.genre\n end\n end\nall_genres\nend",
"def genres\n @songs.collect { |song| song.genre }.uniq\n end",
"def genres\n @songs.collect{|song| song.genre }.uniq\n end",
"def genres\n self.songs.map { |song| song.genre }.uniq\n end",
"def genres\n self.songs.collect {|song| (song.genre) }.uniq\n end",
"def genres\n self.songs.collect {|song| song.genre}.uniq\n end",
"def genres \n songs.collect {|song| song.genre}.uniq \n\n end",
"def genres\n self.songs.map {|x| x.genre}\n end",
"def genres\n Song.all.collect{|song|song.genre}\n end",
"def list_genre\n genre = gets.chomp\n Genre.all.each do |a|\n if a.name == genre\n a.songs.collect { |s| puts \"#{s.artist.name} - #{s.name} - #{s.genre.name}\" }\n end\n end\n end",
"def songs\n Song.all.select {|song_name| song_name.genre == self}\n end",
"def songs\n Song.all.select{|song| song.genre == self}\n end",
"def songs\n Song.all.select{|song| song.genre == self}\n end",
"def genres #How to shorten? \n array = []\n songs.each do |song_instance|\n array << song_instance.genre \n end\n array.uniq\n end",
"def genres\n # look for a local variable called songs\n # look for a method on self. called songs => self.songs\n # looks up the parent chain\n self.songs.map do |song|\n song.genre\n end\n end",
"def songs\n Song.all.select {|song| song.genre == self}\n end",
"def all_songs_with_genre(songs=songs_array, genre)\n songs.select do |song|\n binding.pry\n # song[:genre] == genre\n end\n end",
"def artists\n @songs.collect do |song| #<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">\n song.artist ##<Artist:0x007f874c4ef0b8 @name=\"Jay-Z\", @songs=[#<Song:0x007f874c4eeed8 @artist=#<Artist:0x007f874c4ef0b8 ...>, @genre=#<Genre:0x007f874c4ef018 @name=\"rap\", @songs=[#<Song:0x007f874c4eeed8 ...>]>, @name=\"99 Problems\">]>\n end\n end",
"def artists\n songs.collect do |song|\n song.artist\n\n end\nend",
"def songs\n Song.all.select do |song|\n song.genre == self\n end\n end",
"def songs\n Song.all.select do |song|\n song.genre == self\n end\n end",
"def artist_by_genre\n all_genres = Artist.all.map{|artist| artist.genre}.uniq.sort\n genre_name = prompt(\"Choose a genre: \", all_genres)\n artists = Artist.all.where(genre: genre_name).map{|artist| artist.name}\n puts \"**************************\"\n puts \"For #{genre_name}\"\n puts \"**************************\"\n prompt(\"Choose an Artist from #{genre_name}\", artists)\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n end\n end",
"def songs\n Song.all.select do |song|\n song.genre == self \n end\n end",
"def artists\n songs.map {|song| song.artist}\n end",
"def artists\n @songs.collect{|song| song.artist}.uniq\n end",
"def artists\n @songs.map { |m| m.artist }.uniq\n end",
"def artists\n # - this method will show the connection between songs and artists \n self.songs.collect do |f| \n f.artist\n end\n end",
"def artists\n artists = []\n self.songs.each do |song|\n artists << song.artist\n end\n artists.uniq\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n @songs.collect do |song|\n song.artist\n end\n end",
"def artists\n self.songs.map {|song| song.artist}\n end",
"def artists\n self.songs.collect{|song| song.artist}\n end",
"def genres\n self.songs.map do |song|\n song.genre\n end.uniq\n #unduped.uniq #uniq only works on an array\n end",
"def songs # to entre the Song class then within the song class take the class variable all to use to select and go thought the songs listed in that array\n Song.all.select { |song| song.artist == self } # use the .select to gather the information we want from the all array in songs - go thought and assign each song artist to this current instance\n end",
"def songs \t\t\t\t\t\t\t# Have a songs for 2 classes... \n\t\tSong.all.select do |song| \t\t# Uninitialized constant Genre::Songs. Should be SELF????? select, not collect!\n\t\t\tsong.genre == self\n\t\t\t#song.genre == self #.name \t## what genre exactly?? self=Genre.\n\t\t\t\t#song \t\t\t\t\t# Was song.genre.. we want all song objects of given genre?\n\t\t\t\t#\tbinding.pry\n\t\t\t#end\n\t\tend\n\tend",
"def songs\n Song.all_by_artist(self)\n end",
"def genres\n MusicImporter.new(path).print_genres\n end",
"def list_songs_by_genre\n puts \"Please enter the name of a genre:\"\n input = gets.chomp\n if genre = Genre.find_by_name(input)\n sort_by_name = genre.songs.sort_by do |genre|\n genre.name\n end\n sort_by_name.each.with_index(1) do |genre, i|\n puts \"#{i}. #{genre.artist.name} - #{genre.name}\"\n end\n end\n end",
"def artists\n self.songs.collect {|song| song.artist}\nend",
"def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self) # could've used the artist.add_song way \n end",
"def songs\n Song.all.select {|song| song.artist = self}\n end",
"def relatedartists(genre = \"\")\n @related = Array.new\n @genre = \"\\\"#{genre}\\\"\"\n genreSearch = RSpotify::Artist.search(\"genre:#{@genre}\")\n genreSearch.each do |artist|\n name = artist.name\n @related.push(name)\n end\n session[:related] = @related\nend",
"def songs\n #use select to iterate thru songs\n Song.all.select{|song| song.artist == self}\n end",
"def genre=(genre)\n @genre = genre\n \n # adds the song to the genre's collection of songs \n # (genre has many songs).\n # Doesn't add the song to the genre's collection of\n # songs if it already exists therein\n if !(genre.songs.include?(self))\n genre.songs << self\n end\n end",
"def list_genres\n sorted_list = Genre.all.sort_by {|artist| artist.name}\n sorted_list.each_with_index do |genre, idx|\n puts \"#{(idx + 1).to_s}. #{genre.name}\"\n end\n end",
"def songs\n Song.all.select do |song|\n song.genre == self\n end\nend",
"def artists\nSong.all.collect{|x| x.artist}\nend",
"def songs\n Song.all.select{|x| x.genre == self}\nend",
"def songs\n @songs ||= Song.where(:artist => info(:name))\n end",
"def related_songs\n unless self.spotify_track_id.nil?\n related_artists = self.spotify_track.artists.first.related_artists\n\n related_artists.shuffle[0..4].map do |artist|\n artist.top_tracks('IE').shuffle.first\n end.flatten\n else\n Array.new\n end\n\n\n end",
"def all_artist_names_by_gallery\n all_artists_by_gallery.map do |artist|\n # artist.name == Painting.artist.name\n artist.name\n end\n end",
"def artists\n songs.map do |song|\n song.artist\n # binding.pry\n end\n end",
"def genres\n to_array search_by_itemprop 'genre'\n end",
"def genre=(genre)\n @genre = genre #assigns a genre to the song (song belongs to genre)\n genre.songs << self unless genre.songs.include?(self) #adds the song to the genre's collection of songs (genre has many songs); does not add the song to the genre's collection of songs if it already exists therein\n end",
"def songs\n Song.all.select do |song| \n song.artist == self\n end \n end",
"def artists # it looks like a reader but it's more complicated\n # a has many through\n @songs.collect{|song| song.artist}.uniq #=> This is called a <<has-many-through>>\n end",
"def list_songs\n self.sorted_list_songs.each_with_index do |song, idx|\n puts \"#{(idx + 1).to_s}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n end\n end",
"def print_songs\n self.songs.each{|song| puts \"#{song.name}\"} \n #Artist.songs.each runs through the array of Artist songs and puts out the #songs name\nend",
"def plays_genres\n genres = Array.new\n self.genres.each do |genre|\n genres << genre.printable\n end\n genres.uniq\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def store_genres(attrs)\n attrs[:genres].each { |genre| genre.downcase! }\n existing_genres = self.get_genres(attrs[:song_id])\n attrs[:genres].each do |genre|\n if existing_genres.include?(genre) == false\n Genre.create({ song_id: attrs[:song_id], genre: genre })\n end\n end\n end",
"def songs\n Song.all.select {|song| song.artist == self }\n end",
"def genre=(genre)\n @genre = genre\n genre.songs << self unless genre.songs.include?(self)\n end",
"def genre_array\n Genre.list.each { |genre| @available_genres << genre.kind }\n end",
"def songs\n Song.all.select do |song_instance|\n song_instance.artist == self\n end\n end",
"def songs\n Song.all.select{|song| song.artist == self}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def songs\n Song.all.select {|song| song.artist == self}\n end",
"def list_songs\n puts \"Here are the songs in your music library:\"\n Song.all.each.with_index(1){|song, index|\n puts \"#{index}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n }\n end",
"def artist_names #return array of the names of all artists that have a painting in a gallery\n artists.name #pull array from artists method and call reader to get their name\n end",
"def songs\n Song.all.select {|songs|songs.artist == self}\n end",
"def songs\n Song.all.select{|song|song.artist == self}\n end",
"def list_songs\n # print songs out in alphabetical order with index\n # 'each.with_index' allows for index to start at 1\n Song.all.uniq.sort { |title1, title2| title1.name <=> title2.name }.each.with_index(1) do |song, i|\n puts \"#{i}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n end\n end",
"def genre=(genre)\n @genre = genre\n if genre.class == Genre\n genre.songs << self unless genre.songs.include?(self)\n end\n end",
"def genre\n genres = tracks.map{|t| t.genre}.compact\n genres.uniq.size == 1 and genres.first\n end"
] | [
"0.8228723",
"0.8051361",
"0.80295527",
"0.792299",
"0.7882845",
"0.7811391",
"0.7784677",
"0.77668774",
"0.7731068",
"0.76861495",
"0.76861495",
"0.76861495",
"0.76861495",
"0.76861495",
"0.76860166",
"0.7677061",
"0.7591977",
"0.75689876",
"0.75387913",
"0.7531827",
"0.7529012",
"0.7528447",
"0.750691",
"0.74817824",
"0.7473784",
"0.7451875",
"0.74506253",
"0.74473405",
"0.7389937",
"0.7385223",
"0.73437303",
"0.7336651",
"0.730052",
"0.7166916",
"0.7139707",
"0.7139707",
"0.7137245",
"0.71341354",
"0.7132436",
"0.7126022",
"0.71199936",
"0.7077011",
"0.7006552",
"0.7006552",
"0.6889851",
"0.68559396",
"0.68559396",
"0.6851541",
"0.68246466",
"0.67951906",
"0.6792172",
"0.67780846",
"0.67632383",
"0.6755716",
"0.6755716",
"0.66985166",
"0.66554195",
"0.6649824",
"0.66165054",
"0.6591297",
"0.65846205",
"0.6577072",
"0.6556578",
"0.65475845",
"0.6544864",
"0.65314305",
"0.6521164",
"0.6514412",
"0.6513592",
"0.6512596",
"0.65012515",
"0.6497448",
"0.64566076",
"0.64423716",
"0.64320964",
"0.6420621",
"0.64205235",
"0.64012563",
"0.63997257",
"0.63948363",
"0.638578",
"0.637121",
"0.63449717",
"0.63220644",
"0.63108855",
"0.6309872",
"0.628045",
"0.62780356",
"0.62770975",
"0.6264673",
"0.6260329",
"0.6255852",
"0.6255852",
"0.62258154",
"0.6224927",
"0.622456",
"0.6222479",
"0.6215551",
"0.6214426",
"0.61956716"
] | 0.7145418 | 34 |
GET /agencies GET /agencies.json | def index
id = params[:id].to_i
if id != 0
@agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find_all_by_id(id)
if @agencies.any?
@agency_name = @agencies.first.name
end
else
@agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find(:all)
end
@records_returned = @agencies.count
respond_to do |format|
format.html # index.html.erb
format.json { render json: @agencies }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def index\n @agencies = Agency.all\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def index\n @agencies = current_user.agencies.all\n end",
"def agencies_get(id, opts = {})\n data, _status_code, _headers = agencies_get_with_http_info(id, opts)\n data\n end",
"def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end",
"def index\n @agencies = Agency.where(:status => 'Y').paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def agencies_search_with_http_info(q, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_search ...'\n end\n # verify the required parameter 'q' is set\n if @api_client.config.client_side_validation && q.nil?\n fail ArgumentError, \"Missing the required parameter 'q' when calling AgenciesApi.agencies_search\"\n end\n # resource path\n local_var_path = '/v1/agencies'\n\n # query parameters\n query_params = {}\n query_params[:'q'] = q\n query_params[:'pageNumber'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<DomainAgencyServiceV2ModelAgencySummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_agencies\n @type = params[:value]\n agencies= Agency.where(:deleted => false)\n render :layout => false \n end",
"def agencies_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_get ...'\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 AgenciesApi.agencies_get\"\n end\n # resource path\n local_var_path = '/v1/agencies/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @registering_agencies = RegisteringAgency.all\n end",
"def agencies\n Agency.where(id: transportation_agencies.pluck(:id) + oversight_agencies.pluck(:id))\n end",
"def index\n # Fetch all the categories the current user has preferred.\n @agencies = UsersAgency.preferrence_of current_user\n render template: 'api/v1/agencies/index', locals: { current_user: current_user }, status: :ok\n\n end",
"def agencies_head(q, opts = {})\n agencies_head_with_http_info(q, opts)\n nil\n end",
"def services\n Service.where(agency: agencies)\n end",
"def departures\n json = Client511.new.departures(agency.name, name)\n parse_departures(json)\n end",
"def agency_chart\n if(params[ :year ].nil?)\n params[ :year ] = '2015'\n else\n # Nothing to do.\n end\n expenses_of_public_agency = HelperController.expenses_year( \n params[ :id ].to_i, params[ :year ] )\n expenses_list = change_type_list_expenses( \n expenses_of_public_agency, params[ :year ] )\n\n respond_to do |format|\n format.json { render json: expenses_list }\n end\n end",
"def get_agreements\n get_agreements_response = Echochamber::Request.get_agreements(token)\n get_agreements_response.fetch(\"userAgreementList\")\n end",
"def agency\n\t\treturn @agency if @agency_loaded\n\t\t@agency_loaded = true\n\t\tcc = cost_center.to_s[0, 2]\n\t\tagens = Agency.find(:all, :conditions => ['find_in_set(?, vacancy_data_codes)', cc])\n\t\t@agency = agens[0] if agens.size == 1\n\t\t@agency ||= Agency.find_by_abbreviation('MC')\n\tend",
"def show\n find_agencies(params[:id])\n increment_views_amount(@public_agency)\n end",
"def all\n f = options[:format]\n a = options[:agency]\n ::Taxi::Status.list_all(format: f, agency: a)\n end",
"def accessible_agencies\n Agency.accessible_by(Ability.new(self))\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def allergies\n raise UserNotAuthenticated unless access_token\n\n get('records/allergies')\n end",
"def index\n @apartments = @building.apartments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apartments }\n end\n end",
"def show\n respond_to do |format|\n \tformat.html # show.html.erb\n \tformat.json { render json: @agency }\n end\n end",
"def agencies_head_with_http_info(q, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_head ...'\n end\n # verify the required parameter 'q' is set\n if @api_client.config.client_side_validation && q.nil?\n fail ArgumentError, \"Missing the required parameter 'q' when calling AgenciesApi.agencies_head\"\n end\n # resource path\n local_var_path = '/v1/agencies'\n\n # query parameters\n query_params = {}\n query_params[:'q'] = q\n query_params[:'pageNumber'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:HEAD, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_head\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def statuses\n request(:get, \"applicant_tracking/statuses\")\n end",
"def get_vendor_relationships()\n build_header_auth('/vendor_relationships', API_VERSION_1, 'GET')\n build_request()\n request = Net::HTTP::Get.new(@uri.request_uri)\n @header.each do |name, value|\n request[name] = value\n end\n response = @http.request(request)\n # response.body = JSON.parse(response.body)\n return response\n end",
"def index\n @event_requirements = EventRequirement.all\n\n render json: @event_requirements\n end",
"def trends_available\n get(\"/trends/available.json\")\n end",
"def available_trends\n get(\"/trends/available.json\")\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def index\n @allocations = Allocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @allocations }\n end\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def index\n @acquired_energies = AcquiredEnergy.all\n end",
"def agencies_search(q, opts = {})\n data, _status_code, _headers = agencies_search_with_http_info(q, opts)\n data\n end",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def gather_issues\n url = \"#{URL}/projects/foreman/issues.json?status_id=1&limit=100&release_id=#{@current_release_id}\"\n puts url\n uri = URI(URI.escape(url))\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def index\n @ge_asset_list = GeCityApi.get_asset_list\n @historical_data = GeCityApi.get_asset_historical_data\n @current_data = GeCityApi.get_asset_current_data(@historical_data.keys)\n @anomaly = GeCityApi.check_anomalies(@current_data, @historical_data)\n # @ge_city_apis = GeCityApi.all\n end",
"def index\n @ag_apartments = Ag::Apartment.all\n end",
"def show\n @admin_agency = Admin::Agency.where(:id => params[:id]).includes(:pages)[0]\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def get_resolved_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"resolved\", :fields => \"incident_number\" }\n end",
"def show\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agency_type }\n end\n end",
"def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def orgs\n client.organizations\n end",
"def show\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tenancy_agreement }\n end\n end",
"def index\n @allocations = @license.allocations.all\n end",
"def get_all_orders() \n\tputs \"Getting all orders\"\n\tresponse = request_get(\"/api/order\")\n\tputs response.body\nend",
"def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end",
"def get_architect_dependencytracking_types_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking_types ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking/types\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud 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 => 'DependencyTypeEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking_types\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def agg_trades(options)\n request :public, :get, :aggTrades, options\n end",
"def index\n @endorsements = Endorsement.all\n\n render json: @endorsements\n end",
"def index\n @agencia = Agencium.all\n end",
"def get_architect_dependencytracking_types_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking_types ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking/types\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud Auth']\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 => 'DependencyTypeEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking_types\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @audiences = Audience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @audiences }\n end\n end",
"def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend",
"def index\n client = find_client(request.headers[\"X-CLIENT-TOKEN\"], request.headers[\"X-CLIENT-EMAIL\"])\n @appointments = client.appointments.includes(:stylist).includes(:offerings).order(\"created_at DESC\")\n respond_to do |f|\n f.json {\n render :json => @appointments\n }\n end\n end",
"def show\n @agents = Agent.employees.order('created_at ASC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lead }\n end\n end",
"def agency_names(options = {})\n autolink = true unless options[:no_links]\n\n if agencies.present?\n agencies = model.agencies.map{|a| \"the #{h.link_to_if autolink, a.name, a.url}\" }\n else\n agencies = model.agencies.map(&:name)\n end\n\n agencies.to_sentence.html_safe\n end",
"def frequent_foods\n get(\"/user/#{@user_id}/foods/log/frequent.json\")\n end",
"def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end",
"def index\n @leads = Lead.upcoming\n .includes(:updates, :agents, :agent)\n .order(created_at: :desc)\n .page(params[:page])\n .per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end",
"def index\n @vendor_fulfillments = @order.vendor_fulfillments\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def index\n if (params[:client_id])\n @engagements = Engagement.find_all_by_client_id(params[:client_id])\n else\n @engagements = Engagement.all\n end\n\n respond_with(@engagements)\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def overview\n request_uri = \"#{@api_endpoint}/#{@key}\"\n HTTParty.get(request_uri)\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def index\n @emergencies = Emergency.all\n end",
"def index\n render json: @authority.all\n end",
"def parse_agencies(elem)\n #funding agency, detect country if Unknown\n agencies = elem.following_siblings()[0].search(\"li\")\n @agencies = []\n agencies.each { |agency| \n @agencies << agency.inner_html \n } \n end",
"def index\n @big_emergencies = BigEmergency.all\n end",
"def index\n @releases = @environment.releases.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @releases }\n end\n end",
"def get_ack_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"acknowledged\", :fields => \"incident_number\" }\n end",
"def index\n @robots = scope.order('id desc')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @robots }\n end\n end",
"def index\n @vendor_relationships = current_user.vendor_relationships\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vendor_relationships }\n end\n end",
"def index\n @incidents = apply_scopes(Incident).order(\"occured_on\").page(params[:page]).per(50)\n @location_groups = LocationGroup.all\n\n if params[:location] && params[:location] > \"\"\n location = Location.find(params[:location])\n @location_name = location.name\n end\n\n @start_date = params[:by_period].try(:[], :start_date).try(:to_date) ||\n Incident.default_period_range.first\n @end_date = params[:by_period].try(:[], :end_date).try(:to_date) ||\n Incident.default_period_range.end\n @incident_types = Incident.uniq.order(\"incident_type\").pluck(:incident_type)\n logger.debug @incident_types\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @incidents }\n end\n end",
"def get_architect_dependencytracking_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking ...\"\n end\n \n \n # verify the required parameter 'name' is set\n fail ArgumentError, \"Missing the required parameter 'name' when calling ArchitectApi.get_architect_dependencytracking\" if name.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'name'] = name\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'objectType'] = @api_client.build_collection_param(opts[:'object_type'], :multi) if opts[:'object_type']\n query_params[:'consumedResources'] = opts[:'consumed_resources'] if opts[:'consumed_resources']\n query_params[:'consumingResources'] = opts[:'consuming_resources'] if opts[:'consuming_resources']\n query_params[:'consumedResourceType'] = @api_client.build_collection_param(opts[:'consumed_resource_type'], :multi) if opts[:'consumed_resource_type']\n query_params[:'consumingResourceType'] = @api_client.build_collection_param(opts[:'consuming_resource_type'], :multi) if opts[:'consuming_resource_type']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud Auth']\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 => 'DependencyObjectEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_architect_dependencytracking_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking ...\"\n end\n \n \n # verify the required parameter 'name' is set\n fail ArgumentError, \"Missing the required parameter 'name' when calling ArchitectApi.get_architect_dependencytracking\" if name.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'name'] = name\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'objectType'] = @api_client.build_collection_param(opts[:'object_type'], :multi) if opts[:'object_type']\n query_params[:'consumedResources'] = opts[:'consumed_resources'] if opts[:'consumed_resources']\n query_params[:'consumingResources'] = opts[:'consuming_resources'] if opts[:'consuming_resources']\n query_params[:'consumedResourceType'] = @api_client.build_collection_param(opts[:'consumed_resource_type'], :multi) if opts[:'consumed_resource_type']\n query_params[:'consumingResourceType'] = @api_client.build_collection_param(opts[:'consuming_resource_type'], :multi) if opts[:'consuming_resource_type']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud 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 => 'DependencyObjectEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def interesting(options = {})\n response = Typhoeus::Request.get(\"#{DARKSKY_API_URL}/interesting/#{@api_key}\", DEFAULT_OPTIONS.dup.merge(options))\n JSON.parse(response.body) if response.code == 200 \n end",
"def get_array_counts_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/arrays/summary/#{args[:tenantId]}\", args)\nend",
"def index\n @allocations = Allocation.all.includes(:project).page(params[:page]).per(20)\n end",
"def index\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @leases }\n end\n end",
"def index\n render jsonapi: Seances::UseCases::FetchAll.new.call\n end",
"def index\n @user_agents = UserAgent.all\n\n render json: @user_agents\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def show\n @asistence = Asistence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asistence }\n end\n end",
"def get_availabillity(request_parameters: {})\r\n default_parameters = {\r\n room1: \"A,A\",\r\n }\r\n http_service.request_post(\"/json/getHotelAvailabilityV2\", default_parameters.merge(request_parameters))\r\n end",
"def index\n @client_releases = ClientRelease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @client_releases }\n end\n end",
"def index\n @geofences = Geofence.all\n end",
"def index\n @ads = @org.ads\n end",
"def index\n @resource_allocations = ResourceAllocation.scoped\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @resource_allocations }\n end\n end",
"def accessories\n render json: { collections: Collection.published_accessories }\n end",
"def index\n @departures = Departure.ordered\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"
] | [
"0.72728944",
"0.72049415",
"0.7114258",
"0.7005254",
"0.6730379",
"0.6693094",
"0.6380399",
"0.6327348",
"0.6307817",
"0.62743366",
"0.6254967",
"0.61001647",
"0.6029806",
"0.6023754",
"0.5979423",
"0.5936777",
"0.592993",
"0.58421415",
"0.5778642",
"0.5707717",
"0.57029617",
"0.56285584",
"0.56023765",
"0.5577798",
"0.5568743",
"0.55647355",
"0.553254",
"0.5490477",
"0.5455335",
"0.54540575",
"0.54453945",
"0.5438072",
"0.54330635",
"0.5429442",
"0.54217684",
"0.54173964",
"0.5409743",
"0.53749704",
"0.53335136",
"0.5322651",
"0.5317559",
"0.5315168",
"0.53112453",
"0.53067094",
"0.53065836",
"0.530047",
"0.5294889",
"0.52752924",
"0.5268425",
"0.5256978",
"0.52494305",
"0.52384686",
"0.5209797",
"0.5195698",
"0.51947594",
"0.5194075",
"0.517817",
"0.5175498",
"0.5174169",
"0.5164716",
"0.5157079",
"0.51475716",
"0.51410544",
"0.51382875",
"0.51341784",
"0.5128852",
"0.512815",
"0.5126169",
"0.51074064",
"0.51054883",
"0.5104624",
"0.5104624",
"0.51002496",
"0.50981075",
"0.5094876",
"0.5085116",
"0.5078446",
"0.50708705",
"0.50683075",
"0.50654525",
"0.50614846",
"0.5054643",
"0.5053519",
"0.5053519",
"0.505335",
"0.50518394",
"0.5048519",
"0.5046677",
"0.50465167",
"0.50461257",
"0.5044887",
"0.5032846",
"0.50306433",
"0.50291115",
"0.50283754",
"0.50261015",
"0.5025408",
"0.5023258",
"0.50126433",
"0.50066227"
] | 0.65971005 | 6 |
GET /agencies/1 GET /agencies/1.json | def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @agency }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def index\n @agencies = Agency.all\n end",
"def index\n id = params[:id].to_i\n\n if id != 0\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find_all_by_id(id)\n if @agencies.any?\n @agency_name = @agencies.first.name\n end\n else\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find(:all)\n end\n\n\t\t@records_returned = @agencies.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agencies }\n end\n end",
"def agencies_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_get ...'\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 AgenciesApi.agencies_get\"\n end\n # resource path\n local_var_path = '/v1/agencies/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def agencies_get(id, opts = {})\n data, _status_code, _headers = agencies_get_with_http_info(id, opts)\n data\n end",
"def index\n @agencies = current_user.agencies.all\n end",
"def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def agencies_search_with_http_info(q, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_search ...'\n end\n # verify the required parameter 'q' is set\n if @api_client.config.client_side_validation && q.nil?\n fail ArgumentError, \"Missing the required parameter 'q' when calling AgenciesApi.agencies_search\"\n end\n # resource path\n local_var_path = '/v1/agencies'\n\n # query parameters\n query_params = {}\n query_params[:'q'] = q\n query_params[:'pageNumber'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<DomainAgencyServiceV2ModelAgencySummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_agencies\n @type = params[:value]\n agencies= Agency.where(:deleted => false)\n render :layout => false \n end",
"def index\n @agencies = Agency.where(:status => 'Y').paginate(:page => params[:page], :per_page => 10)\n end",
"def show\n find_agencies(params[:id])\n increment_views_amount(@public_agency)\n end",
"def agencies_head(q, opts = {})\n agencies_head_with_http_info(q, opts)\n nil\n end",
"def agency_chart\n if(params[ :year ].nil?)\n params[ :year ] = '2015'\n else\n # Nothing to do.\n end\n expenses_of_public_agency = HelperController.expenses_year( \n params[ :id ].to_i, params[ :year ] )\n expenses_list = change_type_list_expenses( \n expenses_of_public_agency, params[ :year ] )\n\n respond_to do |format|\n format.json { render json: expenses_list }\n end\n end",
"def index\n @registering_agencies = RegisteringAgency.all\n end",
"def agency\n\t\treturn @agency if @agency_loaded\n\t\t@agency_loaded = true\n\t\tcc = cost_center.to_s[0, 2]\n\t\tagens = Agency.find(:all, :conditions => ['find_in_set(?, vacancy_data_codes)', cc])\n\t\t@agency = agens[0] if agens.size == 1\n\t\t@agency ||= Agency.find_by_abbreviation('MC')\n\tend",
"def index\n # Fetch all the categories the current user has preferred.\n @agencies = UsersAgency.preferrence_of current_user\n render template: 'api/v1/agencies/index', locals: { current_user: current_user }, status: :ok\n\n end",
"def show\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agency_type }\n end\n end",
"def agencies_head_with_http_info(q, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_head ...'\n end\n # verify the required parameter 'q' is set\n if @api_client.config.client_side_validation && q.nil?\n fail ArgumentError, \"Missing the required parameter 'q' when calling AgenciesApi.agencies_head\"\n end\n # resource path\n local_var_path = '/v1/agencies'\n\n # query parameters\n query_params = {}\n query_params[:'q'] = q\n query_params[:'pageNumber'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:HEAD, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_head\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def agencies\n Agency.where(id: transportation_agencies.pluck(:id) + oversight_agencies.pluck(:id))\n end",
"def show\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tenancy_agreement }\n end\n end",
"def show\n @admin_agency = Admin::Agency.where(:id => params[:id]).includes(:pages)[0]\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def services\n Service.where(agency: agencies)\n end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def gather_issues\n url = \"#{URL}/projects/foreman/issues.json?status_id=1&limit=100&release_id=#{@current_release_id}\"\n puts url\n uri = URI(URI.escape(url))\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def get_resolved_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"resolved\", :fields => \"incident_number\" }\n end",
"def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend",
"def index\n @apartments = @building.apartments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apartments }\n end\n end",
"def departures\n json = Client511.new.departures(agency.name, name)\n parse_departures(json)\n end",
"def get_architect_dependencytracking_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking ...\"\n end\n \n \n # verify the required parameter 'name' is set\n fail ArgumentError, \"Missing the required parameter 'name' when calling ArchitectApi.get_architect_dependencytracking\" if name.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'name'] = name\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'objectType'] = @api_client.build_collection_param(opts[:'object_type'], :multi) if opts[:'object_type']\n query_params[:'consumedResources'] = opts[:'consumed_resources'] if opts[:'consumed_resources']\n query_params[:'consumingResources'] = opts[:'consuming_resources'] if opts[:'consuming_resources']\n query_params[:'consumedResourceType'] = @api_client.build_collection_param(opts[:'consumed_resource_type'], :multi) if opts[:'consumed_resource_type']\n query_params[:'consumingResourceType'] = @api_client.build_collection_param(opts[:'consuming_resource_type'], :multi) if opts[:'consuming_resource_type']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud Auth']\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 => 'DependencyObjectEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_architect_dependencytracking_with_http_info(name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking ...\"\n end\n \n \n # verify the required parameter 'name' is set\n fail ArgumentError, \"Missing the required parameter 'name' when calling ArchitectApi.get_architect_dependencytracking\" if name.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'name'] = name\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'objectType'] = @api_client.build_collection_param(opts[:'object_type'], :multi) if opts[:'object_type']\n query_params[:'consumedResources'] = opts[:'consumed_resources'] if opts[:'consumed_resources']\n query_params[:'consumingResources'] = opts[:'consuming_resources'] if opts[:'consuming_resources']\n query_params[:'consumedResourceType'] = @api_client.build_collection_param(opts[:'consumed_resource_type'], :multi) if opts[:'consumed_resource_type']\n query_params[:'consumingResourceType'] = @api_client.build_collection_param(opts[:'consuming_resource_type'], :multi) if opts[:'consuming_resource_type']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud 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 => 'DependencyObjectEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @allocations = Allocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @allocations }\n end\n end",
"def all\n f = options[:format]\n a = options[:agency]\n ::Taxi::Status.list_all(format: f, agency: a)\n end",
"def get_agreements\n get_agreements_response = Echochamber::Request.get_agreements(token)\n get_agreements_response.fetch(\"userAgreementList\")\n end",
"def index\n @competencies = Competency.all\n respond_to do |format|\n format.json { render json: @competencies }\n end\n end",
"def show\n @gtfs_agency = GtfsAgency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gtfs_agency }\n end\n end",
"def allergies\n raise UserNotAuthenticated unless access_token\n\n get('records/allergies')\n end",
"def new\n @admin_agency = Admin::Agency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def show\n @agency_relationship = AgencyRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def get_client_summary_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/clients/summary/#{args[:tenantId]}\", args)\nend",
"def agencies_create_test_agency_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_create_test_agency ...'\n end\n # resource path\n local_var_path = '/v1/agencies/_testAgency'\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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(: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 => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_create_test_agency\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency }\n end\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def show\n @audience = Audience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @audience }\n end\n end",
"def set_agency\n @agency = Agency.find_by_id(params[:id])\n end",
"def show\n @asistence = Asistence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @asistence }\n end\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n JSON.parse(Typhoeus::Request.get(API_URL + path, :params => params).body)[\"response\"]\n end",
"def get_architect_dependencytracking_types_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking_types ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking/types\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud 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 => 'DependencyTypeEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking_types\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @event_requirements = EventRequirement.all\n\n render json: @event_requirements\n end",
"def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end",
"def get_ack_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"acknowledged\", :fields => \"incident_number\" }\n end",
"def show\n @agents = Agent.employees.order('created_at ASC')\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lead }\n end\n end",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def get_architect_dependencytracking_types_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_architect_dependencytracking_types ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/architect/dependencytracking/types\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud Auth']\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 => 'DependencyTypeEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_architect_dependencytracking_types\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @acquired_energies = AcquiredEnergy.all\n end",
"def show\n @agent_status = AgentStatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agent_status }\n end\n end",
"def show\n @apartment = @building.apartments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @apartment }\n end\n end",
"def show\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @news_agency }\n end\n end",
"def show\n advertisement = nil\n consumer_page_view = @consumer.crumbs.map{ |crumb| crumb.beacon_id }.uniq.sample\n if consumer_page_view\n @sem3.products_field( \"upc\", Beacon.find(consumer_page_view).first_party_data.sample )\n advertisement = @sem3.get_products\n end\n\n logger.debug \"Advertisement : #{advertisement}\"\n\n respond_to do |format|\n if advertisement\n format.html # show.html.erb\n format.json { render json: advertisement['results'].first }\n else\n format.html # show.html.erb\n format.json { render json: {\"status\" => \"error\"}, status: :not_found }\n end\n end\n end",
"def statuses\n request(:get, \"applicant_tracking/statuses\")\n end",
"def get(path, params={})\n params = merge_set_up_params(params)\n @token = \"b3688c52-9235-45ca-b01f-c5b2b83a4f4f\"\n @result = Typhoeus::Request.get(API_URL + path, :params => params,\n :headers => {\"Authorization\" => \"Basic#{@token}\"})\n puts @result.body\n # check if the url looks correct in the log\n puts @result.effective_url\n # parse the result to json\n return JSON.parse(@result.body)\n end",
"def index\n @allocations = @license.allocations.all\n end",
"def get_vendor_relationships()\n build_header_auth('/vendor_relationships', API_VERSION_1, 'GET')\n build_request()\n request = Net::HTTP::Get.new(@uri.request_uri)\n @header.each do |name, value|\n request[name] = value\n end\n response = @http.request(request)\n # response.body = JSON.parse(response.body)\n return response\n end",
"def create\n @agency = Agency.new(agency_params)\n\n respond_to do |format|\n if @agency.save\n format.html { redirect_to @agency, notice: \"Agency was successfully created.\" }\n format.json { render :show, status: :created, location: @agency }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def accessible_agencies\n Agency.accessible_by(Ability.new(self))\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 @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def index\n @ag_apartments = Ag::Apartment.all\n end",
"def index\n @ge_asset_list = GeCityApi.get_asset_list\n @historical_data = GeCityApi.get_asset_historical_data\n @current_data = GeCityApi.get_asset_current_data(@historical_data.keys)\n @anomaly = GeCityApi.check_anomalies(@current_data, @historical_data)\n # @ge_city_apis = GeCityApi.all\n end",
"def set_agency\n @agency = Agency.find(params[:agency_id])\n end",
"def agencies_get_subscriptions_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_get_subscriptions ...'\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 AgenciesApi.agencies_get_subscriptions\"\n end\n # resource path\n local_var_path = '/v1/agencies/{id}/subscriptions'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'channel'] = opts[:'channel'] if !opts[:'channel'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<DomainAgencyServiceV1ModelAgencySubscriptionDto>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_get_subscriptions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def new\n @agency_type = AgencyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency_type }\n end\n end",
"def allocations(id)\n connection.get do |req|\n req.url \"job/#{id}/allocations\"\n end\n end",
"def index\n @vendor_fulfillments = @order.vendor_fulfillments\n end",
"def get_gen1_account_info(name) \n response = HTTParty.get(\"https://management.azure.com/subscriptions/#{subscriptionId}/resourceGroups/#{resourceGroupName}/providers/Microsoft.DataLakeStore/accounts/#{name}?api-version=2016-11-01\", {\n\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => '*/*',\n \"Cache-Control\" => 'no-cache',\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n \n verify: true,\n })\n\n return JSON.parse response.read_body\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 index\n @allocations = Allocation.all.includes(:project).page(params[:page]).per(20)\n end",
"def show\n @early_pregnancy = EarlyPregnancy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @early_pregnancy }\n end\n end",
"def show\n @agency = Agency.find(params[:id])\n redirect_to edit_agency_url(@agency)\n end",
"def events\n url = 'https://api.artic.edu/api/v1/exhibitions?limit=35'\n\n res = RestClient.get(url)\n JSON.parse(res)\nend",
"def get_course_overview(org_unit_id) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/overview\"\n ap query_string\n _get(query_string)\n # Returns: a Overview JSON data block containing\n # the course offering overview’s details.\nend",
"def index\n @audiences = Audience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @audiences }\n end\n end",
"def set_agency\n @agency = Agency.friendly.find(params[:id])\n end",
"def set_agency\n @agency = Agency.friendly.find(params[:id])\n end",
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def show\n @track = Track.find(params[:id])\n authorize! :show, @track\n gon.track_number = Track.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @track.to_json(:methods => [:polyline],:only => [:name])}\n #format.json { render json: { \"language\" => @languages.as_json(:root => false) }.to_json }\n # render :json => @track.to_json(:methods => [:polyline],:only => [:name])\n end\n end",
"def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end",
"def list_gen1_accounts() \n response = HTTParty.get(\"https://management.azure.com/subscriptions/#{subscriptionId}/providers/Microsoft.DataLakeStore/accounts?api-version=2016-11-01\", {\n\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => '*/*',\n \"Cache-Control\" => 'no-cache',\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n \n verify: true,\n })\n\n return JSON.parse response.read_body\n end",
"def get_array_counts_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/arrays/summary/#{args[:tenantId]}\", args)\nend"
] | [
"0.7371774",
"0.72503483",
"0.6988436",
"0.6682137",
"0.65387195",
"0.6531356",
"0.64928675",
"0.6466925",
"0.6358089",
"0.62040913",
"0.61793184",
"0.6165519",
"0.59969693",
"0.58776855",
"0.58126813",
"0.5778851",
"0.5777207",
"0.5745176",
"0.5732595",
"0.5725502",
"0.571413",
"0.5619105",
"0.5598505",
"0.5553732",
"0.5532323",
"0.5531496",
"0.5513199",
"0.5459651",
"0.54539084",
"0.5440702",
"0.54268",
"0.5374718",
"0.53738743",
"0.53738743",
"0.53443325",
"0.5343779",
"0.5341127",
"0.53001606",
"0.52996206",
"0.52899855",
"0.5288097",
"0.52810585",
"0.52710557",
"0.5270059",
"0.52527857",
"0.5248791",
"0.52410215",
"0.5226776",
"0.5226776",
"0.5226776",
"0.5226776",
"0.5226776",
"0.5226776",
"0.52082235",
"0.51538604",
"0.51462734",
"0.51448834",
"0.5143032",
"0.5137655",
"0.5132542",
"0.5131727",
"0.51267076",
"0.5126047",
"0.5125305",
"0.5122421",
"0.51218873",
"0.510279",
"0.51025665",
"0.5094746",
"0.5092201",
"0.50897497",
"0.50783026",
"0.5075487",
"0.50711566",
"0.50698656",
"0.50691175",
"0.506572",
"0.5061758",
"0.50573593",
"0.5052314",
"0.50511765",
"0.5049166",
"0.50430536",
"0.503796",
"0.50348026",
"0.5032483",
"0.5032483",
"0.5032092",
"0.5009868",
"0.500951",
"0.49952927",
"0.49853927",
"0.49820048",
"0.4981885",
"0.49771792",
"0.49749056",
"0.4972421",
"0.4962007",
"0.49614418",
"0.4961131"
] | 0.5718633 | 20 |
GET /agencies/new GET /agencies/new.json | def new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @agency }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @agency_type = AgencyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency_type }\n end\n end",
"def new\n @admin_agency = Admin::Agency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def new\n @agency = Agency.new\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def new\n @party = Party.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @party }\n end\n end",
"def new\n @news_agency = NewsAgency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @news_agency }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\n @gtfs_agency = GtfsAgency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gtfs_agency }\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n respond_to do |format|\n if @agency.save\n format.html { redirect_to @agency, notice: \"Agency was successfully created.\" }\n format.json { render :show, status: :created, location: @agency }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @audience = Audience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @audience }\n end\n end",
"def new\n @agency_relationship = AgencyRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @allocation = Allocation.new params[:allocation]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation }\n end\n end",
"def new\n @agent_status = AgentStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agent_status }\n end\n end",
"def new\n @absence = Absence.new\n @title = \"New Absence\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @absence }\n end\n end",
"def new\n @early_pregnancy = EarlyPregnancy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @early_pregnancy }\n end\n end",
"def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def create\n @admin_agency = Admin::Agency.new(params[:admin_agency])\n\n respond_to do |format|\n if @admin_agency.save\n format.html { redirect_to @admin_agency, notice: 'Agency was successfully created.' }\n format.json { render json: @admin_agency, status: :created, location: @admin_agency }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n respond_to do |format|\n if @agency.save\n format.html { redirect_to session[:redirect_to], notice: 'Agency was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @agency }\n else\n format.html { render action: 'new' }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @requirement_priority = RequirementPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @requirement_priority }\n end\n end",
"def new\n @path = '/orders'\n @method = 'post'\n @order = Order.new\n @bundles = Bundle.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @apartment = @building.apartments.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @apartment }\n end\n end",
"def new\n @vendor_relationship = VendorRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vendor_relationship }\n end\n end",
"def new\n @advocacy = Advocacy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advocacy }\n end\n end",
"def new\n @incident = Incident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announce }\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",
"def new\n @acquirement = Acquirement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @acquirement }\n end\n end",
"def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end",
"def create\n respond_to do |format|\n if @agency.save\n format.html { redirect_to @agency, notice: 'Agency was successfully created.' }\n format.json { render json: @agency, status: :created, location: @agency }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n \n if current_user != nil \n @current_user = current_user\n @role = current_user.current_role\n else\n @current_user == nil\n @role = nil\n end \n \n @maintenance_request = MaintenanceRequest.new\n @maintenance_request.access_contacts.build\n @maintenance_request.availabilities.build\n @maintenance_request.build_maintenance_request_image\n @customer_input = Query.find_by(id:session[:customer_input])\n @agencies = Agency.all.as_json(:include => {:agents => {}, :agency_admins => {}})\n\n end",
"def new\n @api_tracking = ApiTracking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @api_tracking }\n end\n end",
"def new\n @attendence = Attendence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attendence }\n end\n end",
"def new\n @routing = Routing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @routing }\n end\n end",
"def new\n @breadcrumb = 'create'\n @order_status = OrderStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_status }\n end\n end",
"def new\n @arrival = Arrival.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arrival }\n end\n end",
"def new\n @arrival = Arrival.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arrival }\n end\n end",
"def new\n @competency = Competency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency }\n end\n end",
"def new\n @incident_kind = IncidentKind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_kind }\n end\n end",
"def new\n @allocation_date = AllocationDate.new\n @allocation_date.res_allocations.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @allocation_date }\n end\n end",
"def new\n @beacon = Beacon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @beacon }\n end\n end",
"def new\n @dependent_relationship = DependentRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dependent_relationship }\n end\n end",
"def new\n @node_incident = NodeIncident.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @node_incident }\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 @important_issue = ImportantIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @important_issue }\n end\n end",
"def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end",
"def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end",
"def new\n \n @title = \"availabilities/new\"\n @availability = Availability.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @availability }\n end\n end",
"def new\n @breadcrumb = 'create'\n @ticket_priority = TicketPriority.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ticket_priority }\n end\n end",
"def new\n @engagement = Engagement.new\n @clients = Client.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @engagement }\n end\n end",
"def new\n @vendor = Vendor.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vendor }\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n if @agency.save\n @agency = Agency.new\n @agencies = Agency.all\n @flag = true\n else\n @flag = false\n end\n end",
"def new\n @delivery_order = DeliveryOrder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @delivery_order }\n end\n end",
"def new\n normal_id = Priority.find_by_description(\"Normal\")\n @passenger = Passenger.new({:routing_id => params[:routing_id], \n :priority_id => normal_id.id})\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @passenger }\n end\n end",
"def new\n @vendor = Vendor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @vendor }\n end\n end",
"def new\n @delivery = Delivery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @delivery }\n end\n end",
"def new\n @new_policy = NewPolicy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_policy }\n end\n end",
"def new\n @proficiency = Proficiency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proficiency }\n end\n end",
"def create\n @gtfs_agency = GtfsAgency.new(params[:gtfs_agency])\n\n respond_to do |format|\n if @gtfs_agency.save\n format.html { redirect_to(@gtfs_agency, :notice => 'Gtfs agency was successfully created.') }\n format.xml { render :xml => @gtfs_agency, :status => :created, :location => @gtfs_agency }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gtfs_agency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @official_tenure = OfficialTenure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @official_tenure }\n end\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subway }\n end\n end",
"def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end",
"def new\n @arrival_range = ArrivalRange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arrival_range }\n end\n end",
"def new\n @tracker = Tracker.new(:active => true, :user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tracker }\n end\n end",
"def new\n @anniversary = Anniversary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @anniversary }\n end\n end",
"def new\n @wadl = Wadl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wadl }\n end\n end",
"def new\n @energy = Energy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @energy }\n end\n end",
"def new\n @governor = Governor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @governor }\n end\n end",
"def new\n @breadcrumb = 'create'\n @insurance = Insurance.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insurance }\n end\n end",
"def new\n @time_gap = TimeGap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_gap }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end",
"def new\n @approval = Approval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @approval }\n end\n end",
"def new\n @occupant = Occupant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @occupant }\n end\n end",
"def new\n @breadcrumb = 'create'\n @reading_route = ReadingRoute.new\n set_projects_offices\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reading_route }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @encounter = Encounter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @encounter }\n end\n end",
"def new\n @order = Order.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @terms_of_use = TermsOfUse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @terms_of_use }\n end\n end",
"def new\n @announcement = Announcement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announcement }\n end\n end",
"def create\n @agency_type = AgencyType.new(params[:agency_type])\n\n respond_to do |format|\n if @agency_type.save\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully created.' }\n format.json { render json: @agency_type, status: :created, location: @agency_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tenancy_agreement = TenancyAgreement.new(params[:tenancy_agreement])\n @tenancy_agreement.estate_agent_id = current_user.estate_agent_id\n respond_to do |format|\n if @tenancy_agreement.save\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully created.' }\n format.json { render json: @tenancy_agreement, status: :created, location: @tenancy_agreement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @corp_location = CorpLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_location }\n end\n end",
"def new\n @electoral_district = ElectoralDistrict.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @electoral_district }\n end\n end",
"def new\n @enhancement = Enhancement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enhancement }\n end\n end"
] | [
"0.69824153",
"0.69289935",
"0.68514985",
"0.6794757",
"0.6707335",
"0.66374063",
"0.6602983",
"0.649957",
"0.64305085",
"0.64138395",
"0.64083123",
"0.64058983",
"0.639911",
"0.6366326",
"0.6362599",
"0.6361379",
"0.63423496",
"0.6337548",
"0.6321848",
"0.6320664",
"0.6293522",
"0.6289863",
"0.6288322",
"0.6282839",
"0.62771064",
"0.62699795",
"0.6268167",
"0.62590635",
"0.62484837",
"0.6221673",
"0.62201756",
"0.6214579",
"0.621415",
"0.6198654",
"0.6192867",
"0.61854285",
"0.61854285",
"0.6180117",
"0.61795527",
"0.6171547",
"0.61710477",
"0.6166842",
"0.61644894",
"0.6162611",
"0.6161921",
"0.6148863",
"0.6148863",
"0.6147969",
"0.61439353",
"0.61432046",
"0.6139646",
"0.6139557",
"0.61390895",
"0.6137948",
"0.613609",
"0.6130252",
"0.6129667",
"0.6128945",
"0.6124096",
"0.6121926",
"0.61207277",
"0.61197627",
"0.61088586",
"0.6102852",
"0.61010283",
"0.60961556",
"0.6096116",
"0.60958195",
"0.6092353",
"0.6092055",
"0.60869217",
"0.60847694",
"0.6082597",
"0.607746",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6074514",
"0.6072481",
"0.60706365",
"0.6066631",
"0.6064236",
"0.6063279",
"0.6060458",
"0.60601974",
"0.60584074",
"0.605399"
] | 0.71231866 | 0 |
POST /agencies POST /agencies.json | def create
respond_to do |format|
if @agency.save
format.html { redirect_to @agency, notice: 'Agency was successfully created.' }
format.json { render json: @agency, status: :created, location: @agency }
else
format.html { render action: "new" }
format.json { render json: @agency.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def index\n @agencies = Agency.all\n end",
"def create\n @agency = Agency.new(agency_params)\n\n respond_to do |format|\n if @agency.save\n format.html { redirect_to @agency, notice: \"Agency was successfully created.\" }\n format.json { render :show, status: :created, location: @agency }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n if @agency.save\n @agency = Agency.new\n @agencies = Agency.all\n @flag = true\n else\n @flag = false\n end\n end",
"def create\n @tenancy_agreement = TenancyAgreement.new(params[:tenancy_agreement])\n @tenancy_agreement.estate_agent_id = current_user.estate_agent_id\n respond_to do |format|\n if @tenancy_agreement.save\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully created.' }\n format.json { render json: @tenancy_agreement, status: :created, location: @tenancy_agreement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def agencies_create_test_agency_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_create_test_agency ...'\n end\n # resource path\n local_var_path = '/v1/agencies/_testAgency'\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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(: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 => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_create_test_agency\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def agency_params\n params.require(:agency).permit(:title, :reg_number, :address, :phone, :status)\n end",
"def create\n @agency = Agency.new(agency_params)\n respond_to do |format|\n if @agency.save\n format.html { redirect_to session[:redirect_to], notice: 'Agency was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @agency }\n else\n format.html { render action: 'new' }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def agency_params\n params.require(:agency).permit( :name, :phone, :contact_name, :contact_email, :address, :latitude, :longitude, :website_url, :num_employees, :golden_pitch, :silver_pitch, :medium_risk_pitch, :high_risk_pitch, :agency )\n end",
"def create\n @admin_agency = Admin::Agency.new(params[:admin_agency])\n\n respond_to do |format|\n if @admin_agency.save\n format.html { redirect_to @admin_agency, notice: 'Agency was successfully created.' }\n format.json { render json: @admin_agency, status: :created, location: @admin_agency }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def agency_params\n params.require(:agency).permit(:name)\n end",
"def index\n @agencies = current_user.agencies.all\n end",
"def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def agency_params\n params.require(:agency).permit(:name,\n :agycode,\n :photo,\n :description,\n :restrictions,\n :hours_of_operation,\n :address_id,\n :contact_name,\n :contact_phone,\n :contact_email,\n :services,\n :geographic_restrictions,\n :family_stipulations,\n :faith_based,\n :is_active,\n :general_information,\n { :service_ids => [] },\n address_attributes: [:id, :street_line_1, :street_line_2, :city, :state, :zip])\n end",
"def agency_params\n params.require(:agency).permit(I18n.t('agencies_controller.agency_params').map(&:to_sym))\n end",
"def agency_params\n params.require(:agency).permit(:code, :name, :description, :is_active)\n end",
"def agency_params\n params.require(:agency).permit(:title, :description)\n end",
"def index\n id = params[:id].to_i\n\n if id != 0\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find_all_by_id(id)\n if @agencies.any?\n @agency_name = @agencies.first.name\n end\n else\n \t @agencies = @agencies.paginate(page: params[:page], per_page: 10).order(:name).find(:all)\n end\n\n\t\t@records_returned = @agencies.count\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @agencies }\n end\n end",
"def agencies_create_test_agency(opts = {})\n data, _status_code, _headers = agencies_create_test_agency_with_http_info(opts)\n data\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def index\n @registering_agencies = RegisteringAgency.all\n end",
"def create\n @gtfs_agency = GtfsAgency.new(params[:gtfs_agency])\n\n respond_to do |format|\n if @gtfs_agency.save\n format.html { redirect_to(@gtfs_agency, :notice => 'Gtfs agency was successfully created.') }\n format.xml { render :xml => @gtfs_agency, :status => :created, :location => @gtfs_agency }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @gtfs_agency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @agency_type = AgencyType.new(params[:agency_type])\n\n respond_to do |format|\n if @agency_type.save\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully created.' }\n format.json { render json: @agency_type, status: :created, location: @agency_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params['cancel']\n redirect_to agencies_url and return\n end\n @agency = Agency.new(agencies_params)\n @agency.updated_by = current_user.login\n\n publication = Publication.new(publication_params)\n @agency.publications << publication unless publication.empty?\n\n #@agency.build_restriction\n #@agency.restriction.update_attributes(params[:restriction])\n #@agency.restriction.states=params[:state_abbrevs].collect{|s| State.find(s)} unless params[:state_abbrevs].to_s.blank?\n #@agency.restriction.counties=params[:county_ids].collect{|c| County.find(c)} unless params[:county_ids].nil?\n #@agency.restriction.cities=params[:city_ids].collect{|c| City.find(c)} unless params[:city_ids].nil?\n #@agency.restriction.zips=params[:zip_ids].collect{|c| Zip.find(c)} unless params[:zip_ids].nil?\n\n #composed_of fields must be created manually\n update_pha_contact\n\n if @agency.save\n flash[:notice] = 'Agency was successfully created.'\n redirect_to agencies_url() and return if params['update_and_return']\n redirect_to edit_agency_url(@agency)\n else\n render :action => \"new\"\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n @manager = Management.new\n @manager.user = current_user\n @manager.agency = @agency\n @manager.save\n\n respond_to do |format|\n if @agency.save\n AdminMailer.new_agency(@agency).deliver\n format.html { redirect_to @agency, notice: 'Agency was successfully created.' }\n format.json { render :show, status: :created, location: @agency }\n else\n format.html { render :new }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @agencies = Agency.where(:status => 'Y').paginate(:page => params[:page], :per_page => 10)\n end",
"def create\n @registering_agency = RegisteringAgency.new(registering_agency_params)\n\n respond_to do |format|\n if @registering_agency.save\n format.html { redirect_to @registering_agency, notice: 'Registering agency was successfully created.' }\n format.json { render action: 'show', status: :created, location: @registering_agency }\n else\n format.html { render action: 'new' }\n format.json { render json: @registering_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_arrays_to_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/arrays\", args)\nend",
"def agency_params\n params.require(:agency).permit(:name, :city, :adress, :zipcode, :phone_number, :logo_agency_url, :siren)\n end",
"def test_detailed_properties_for_leads_properties\n property_service = PropertyService.new(SAMPLE_UDPRN)\n agent = Agents::Branches::AssignedAgent.last\n branch = Agents::Branch.last\n agent.branch_id = branch.id\n branch.district = SAMPLE_DISTRICT\n assert agent.save!\n assert branch.save!\n vendor_id = Vendor.last.id\n\n get :detailed_properties, { agent_id: agent.id }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['properties'].length, 0\n\n ### Create a new lead\n property_service.attach_vendor_to_property(vendor_id)\n\n ### Claim that lead for the agent\n post :claim_property, { udprn: SAMPLE_UDPRN.to_i, agent_id: agent.id }\n\n get :detailed_properties, { agent_id: agent.id }\n\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['properties'].length, 1\n end",
"def agency_params\n params.require(:agency).permit(:name, :description, :address, :user_id, :where, :photo, :photo_cache)\n end",
"def create\n @observation = Observation.new(observation_params)\n\n \n\n respond_to do |format|\n if @observation.save\n format.html { redirect_to @observation, notice: 'Observation was successfully created.' }\n format.json { render :show, status: :created, location: @observation }\n else\n @services_of_dependence = current_user.dependence.service_of_dependences\n agents_of_service = AgentOfService.where(service_of_dependence: @services_of_dependence)\n @agents = Agent.where(id: agents_of_service.pluck(:agent_id))\n format.html { render :new }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new( order_params )\n @order.system_id = Order.set_system_id\n respond_to do |format|\n if @order.save\n set_order_values(@order,params)\n route = 'https://private-3643a-orderlordapi.apiary-mock.com/api/v1/jobs'\n respose = HTTParty.post(route, body: @body, :headers => @headers)\n parsed_response = respose.parsed_response.symbolize_keys!\n if \tparsed_response[:success] == \"true\"\n @order.tracker_hash = parsed_response[:tracker_hash]\n @order.save!\n end\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def agencies_search_with_http_info(q, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_search ...'\n end\n # verify the required parameter 'q' is set\n if @api_client.config.client_side_validation && q.nil?\n fail ArgumentError, \"Missing the required parameter 'q' when calling AgenciesApi.agencies_search\"\n end\n # resource path\n local_var_path = '/v1/agencies'\n\n # query parameters\n query_params = {}\n query_params[:'q'] = q\n query_params[:'pageNumber'] = opts[:'page_number'] if !opts[:'page_number'].nil?\n query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<DomainAgencyServiceV2ModelAgencySummary>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_search\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n #@incident = @quote.incidents.new(incident_params)\n logger.info params[:incident]\n params[:incident].each do |incident|\n @incident = @quote.incidents.new(incident)\n @incident.save\n end\n respond_to do |format|\n format.json { render :json => { :code => \"201\", :description => \"Created incidents\"} }\n end\n end",
"def create\n @agency_relationship = AgencyRelationship.new(params[:agency_relationship])\n\n respond_to do |format|\n if @agency_relationship.save\n flash[:notice] = 'AgencyRelationship was successfully created.'\n format.html { redirect_to(\n agency_relationship_url(@agency_relationship)) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end",
"def create\n @acquired_energy = AcquiredEnergy.new(acquired_energy_params)\n\n respond_to do |format|\n if @acquired_energy.save\n format.html { redirect_to @acquired_energy, notice: 'Acquired energy was successfully created.' }\n format.json { render :show, status: :created, location: @acquired_energy }\n else\n format.html { render :new }\n format.json { render json: @acquired_energy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dis_additive_frequency_params\n params.require(:dis_additive_frequency).permit(:name, :frequency_value, :status_id)\n end",
"def dis_additive_frequency_params\n params.require(:dis_additive_frequency).permit(:name, :frequency_value, :status_id)\n end",
"def get_agencies\n @type = params[:value]\n agencies= Agency.where(:deleted => false)\n render :layout => false \n end",
"def agencies\n Agency.where(id: transportation_agencies.pluck(:id) + oversight_agencies.pluck(:id))\n end",
"def create\n @audience = Audience.new(params[:audience])\n\n respond_to do |format|\n if @audience.save\n format.html { redirect_to @audience, notice: 'Audience was successfully created.' }\n format.json { render json: @audience, status: :created, location: @audience }\n else\n format.html { render action: \"new\" }\n format.json { render json: @audience.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @group = Group.find(params[:group_id])\n @asistence = Asistence.new(params[:asistence])\n\n respond_to do |format|\n if @asistence.save\n format.html { redirect_to @group, :notice => 'Asistence was successfully created.' }\n format.json { render :json => @asistence, :status => :created, :location => @asistence }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @asistence.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def registering_agency_params\n params.require(:registering_agency).permit(:name, :description)\n end",
"def create\n @advocacy = Advocacy.new(params[:advocacy])\n\n respond_to do |format|\n if @advocacy.save\n format.html { redirect_to @advocacy, notice: 'Advocacy was successfully created.' }\n format.json { render json: @advocacy, status: :created, location: @advocacy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advocacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @dis_additive_frequency = DisAdditiveFrequency.new(dis_additive_frequency_params)\n\n respond_to do |format|\n if @dis_additive_frequency.save\n format.html { redirect_to @dis_additive_frequency, notice: 'Dis additive frequency was successfully created.' }\n format.json { render :show, status: :created, location: @dis_additive_frequency }\n else\n format.html { render :new }\n format.json { render json: @dis_additive_frequency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @agency = Agency.new\n end",
"def departures\n json = Client511.new.departures(agency.name, name)\n parse_departures(json)\n end",
"def test_detailed_properties_for_leads_properties_for_rent\n property_service = PropertyService.new('123456')\n agent = Agents::Branches::AssignedAgent.last\n branch = Agents::Branch.last\n agent.branch_id = branch.id\n branch.district = SAMPLE_DISTRICT\n assert agent.save!\n assert branch.save!\n vendor_id = Vendor.last.id\n\n get :detailed_properties, { agent_id: agent.id, property_for: 'Rent' }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['properties'].length, 0\n\n ### Create a new lead\n property_service.attach_vendor_to_property(vendor_id)\n\n ### Claim that lead for the agent\n post :claim_property, { udprn: '123456'.to_i, agent_id: agent.id }\n sleep(3)\n get :detailed_properties, { agent_id: agent.id, property_for: 'Rent' }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['properties'].length, 1\n end",
"def test_agent_new_enquiries\n agent_id = Agents::Branches::AssignedAgent.last.id\n verification_status = true\n get :agent_new_enquiries, { agent_id: agent_id }\n attach_agent_to_property_and_update_details(agent_id, SAMPLE_UDPRN, 'Green', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n # assert_response 200\n # earlier_response = Oj.load(@response.body)\n # assert_equal earlier_response['enquiries'].length, 0\n len = 0\n buyer_id = PropertyBuyer.last.id\n\n property_details = get_es_address(SAMPLE_UDPRN)\n Trackers::Buyer::ENQUIRY_EVENTS.each do |event|\n process_event_helper(event, @address_doc['_source'], agent_id)\n get :agent_new_enquiries, { agent_id: agent_id }\n len += 1\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, len\n\n ### Test property attributes\n attrs = ['price', 'street_view_image_url', 'udprn', 'offers_over', \n 'fixed_price', 'asking_price', 'dream_price', 'current_valuation', 'verification_status']\n attrs.each do |attr_val|\n assert_equal response['enquiries'].last[attr_val], property_details['_source'][attr_val]\n end\n\n assert_equal response['enquiries'].last['status'], property_details['_source']['property_status_type']\n\n ### Test buyer attributes\n buyer = PropertyBuyer.find(buyer_id).as_json\n buyer_attrs = ['id', 'status', 'full_name', 'email', 'image_url', 'mobile', 'budget_from', 'budget_to']\n buyer_attrs.each do |attr_val|\n assert_equal response['enquiries'].last[\"buyer_#{attr_val}\"], buyer[attr_val]\n end\n\n assert_equal response['enquiries'].last['buyer_funding'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['funding']]\n assert_equal response['enquiries'].last['buyer_biggest_problem'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['biggest_problem']]\n assert_equal response['enquiries'].last['buyer_buying_status'], PropertyBuyer::REVERSE_FUNDING_STATUS_HASH[buyer['buying_status']]\n \n ### Test enquiries, views, hotness and qualifying_stage \n enquiries = response['enquiries'].last['enquiries']\n buyer_enquiries = enquiries.split('/')[0].to_i\n total_enquiries = enquiries.split('/')[1].to_i\n assert_equal buyer_enquiries, total_enquiries\n end\n\n ### Test viewed\n process_event_helper('viewed', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n views = response['enquiries'].last['views']\n buyer_views = views.split('/')[0].to_i\n total_views = views.split('/')[1].to_i\n assert_equal total_views, 1\n assert_equal buyer_views, 1\n\n\n ### Test hotness\n assert_equal response['enquiries'].last['hotness'], 'cold_property'\n process_event_helper('warm_property', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n hotness = response['enquiries'].last['hotness']\n assert_equal hotness, 'warm_property'\n\n process_event_helper('hot_property', @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n hotness = response['enquiries'].last['hotness']\n assert_equal hotness, 'hot_property'\n\n #### Test qualifying stage filter\n (Trackers::Buyer::QUALIFYING_STAGE_EVENTS-[:qualifying_stage, :viewing_stage]).each do |event|\n process_event_helper(event, @address_doc['_source'])\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n stage = response['enquiries'].last['qualifying']\n assert_equal stage, event.to_s\n\n get :agent_new_enquiries, { agent_id: agent_id, qualifying_stage: event }\n response = Oj.load(@response.body)\n response['enquiries'].each do |each_elem|\n assert_equal each_elem['qualifying'], event.to_s\n end\n\n end\n\n ### Test Filters\n ### i) enquiry_type\n (Trackers::Buyer::ENQUIRY_EVENTS-[:viewing_stage]).each do |event|\n get :agent_new_enquiries, { agent_id: agent_id, enquiry_type: event }\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, 1\n end\n\n ### ii) type_of_match\n get :agent_new_enquiries, { agent_id: agent_id }\n response = Oj.load(@response.body)\n response_length = response['enquiries'].length\n\n get :agent_new_enquiries, { agent_id: agent_id, type_of_match: 'Potential' }\n response = Oj.load(@response.body)\n assert_equal response['enquiries'].length, 0\n\n get :agent_new_enquiries, { agent_id: agent_id, type_of_match: 'Perfect' }\n response = Oj.load(@response.body)\n # assert_equal response['enquiries'].length, response_length\n\n ### Test for rent properties\n create_rent_enquiry_event\n attach_agent_to_property_and_update_details(agent_id, '123456', 'Rent', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n\n property_status_type = 'Rent'\n\n get :agent_new_enquiries, { agent_id: agent_id, property_for: 'Rent' }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 1\n destroy_rent_enquiry_event\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def create\n UsersAgency.selection_from_ids(current_user, params[:agency_selection])\n head :created\n end",
"def create_agent_via_api(agent_type, opts = {})\n case agent_type\n when :person\n agent_json = if opts[:create_subrecords]\n build(:json_agent_person_full_subrec)\n else\n build(:json_agent_person)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n when :corporate_entity\n agent_json = if opts[:create_subrecords]\n build(:json_agent_corporate_entity_full_subrec)\n else\n build(:json_agent_corporate_entity)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n when :family\n agent_json = if opts[:create_subrecords]\n build(:json_agent_family_full_subrec)\n else\n build(:json_agent_familly)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n when :software\n agent_json = if opts[:create_subrecords]\n build(:json_agent_software_full_subrec)\n else\n build(:json_agent_software)\n end\n url = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n end\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response['status'] == 'Created'\n json_response['id']\n else\n -1\n end\nrescue StandardError => e\n -1\nend",
"def agency_chart\n if(params[ :year ].nil?)\n params[ :year ] = '2015'\n else\n # Nothing to do.\n end\n expenses_of_public_agency = HelperController.expenses_year( \n params[ :id ].to_i, params[ :year ] )\n expenses_list = change_type_list_expenses( \n expenses_of_public_agency, params[ :year ] )\n\n respond_to do |format|\n format.json { render json: expenses_list }\n end\n end",
"def make_api_call_for_order_creation(url, api_params, access_token)\n RestClient.post(url, api_params, Authorization: \"Bearer #{access_token}\", content_type: :json)\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency }\n end\n end",
"def create\n @adj = Adj.new(adj_params)\n\n respond_to do |format|\n if @adj.save\n format.html { redirect_to @adj, notice: 'Adj was successfully created.' }\n format.json { render :show, status: :created, location: @adj }\n else\n format.html { render :new }\n format.json { render json: @adj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @news_agency = NewsAgency.new(params[:news_agency])\n\n respond_to do |format|\n if @news_agency.save\n format.html { redirect_to @news_agency, notice: 'News agency was successfully created.' }\n format.json { render json: @news_agency, status: :created, location: @news_agency }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @early_pregnancy = EarlyPregnancy.new(params[:early_pregnancy])\n\n respond_to do |format|\n if @early_pregnancy.save\n format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully created.' }\n format.json { render json: @early_pregnancy, status: :created, location: @early_pregnancy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @early_pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n Order.find_by!(aliexpress_number: @order.aliexpress_number, tracked: true)\n rescue ActiveRecord::RecordNotFound\n post_api_request 'http://aliexpress-tracker.herokuapp.com/orders/track', order_payload(@order) if @order.save\n end",
"def create\n @attendence = Attendence.new(params[:attendence])\n\n respond_to do |format|\n if @attendence.save\n format.html { redirect_to @attendence, notice: 'Attendence was successfully created.' }\n format.json { render json: @attendence, status: :created, location: @attendence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @attendence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lease = Lease.new(params[:lease])\n\n respond_to do |format|\n if @lease.save\n car = Car.where(:registration => @lease.registration).first\n car.update_attributes(:longtermassigned => true)\n format.html { redirect_to cars_url, :notice => 'Lease was successfully created.' }\n format.json { render :json => @lease, :status => :created, :location => @lease }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @lease.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ag_apartment = Ag::Apartment.new(ag_apartment_params)\n\n respond_to do |format|\n if @ag_apartment.save\n format.html { redirect_to @ag_apartment, notice: 'Apartment was successfully created.' }\n format.json { render :show, status: :created, location: @ag_apartment }\n else\n format.html { render :new }\n format.json { render json: @ag_apartment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tracker = Tracker.new(tracker_params)\n\n if @tracker.save\n render json: @tracker, status: :created, location: @tracker\n else\n render json: @tracker.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tenancy = Tenancy.new(tenancy_params)\n\n respond_to do |format|\n if @tenancy.save\n format.html { redirect_to @tenancy, notice: 'Tenancy was successfully created.' }\n format.json { render :show, status: :created, location: @tenancy }\n else\n format.html { render :new }\n format.json { render json: @tenancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @admin_agency = Admin::Agency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @admin_agency }\n end\n end",
"def index\n # Fetch all the categories the current user has preferred.\n @agencies = UsersAgency.preferrence_of current_user\n render template: 'api/v1/agencies/index', locals: { current_user: current_user }, status: :ok\n\n end",
"def create\n @absence = Absence.new(absence_params)\n\n respond_to do |format|\n if @absence.save\n format.html { redirect_to @absence, notice: 'Absence was successfully created.' }\n format.json { render :show, status: :created, location: @absence }\n else\n format.html { render :new }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @agency_type = AgencyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agency_type }\n end\n end",
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def create\n @event_requirement = EventRequirement.new(event_requirement_params)\n\n if @event_requirement.save\n render json: @event_requirement, status: :created, location: @event_requirement\n else\n render json: @event_requirement.errors, status: :unprocessable_entity\n end\n end",
"def create_agent_via_api(agent_type, opts = {})\n\tcase agent_type\n\twhen :person\n\t\tagent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_person_full_subrec) : \n\t\t\tbuild(:json_agent_person)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/people\")\n\twhen :corporate_entity\n\t agent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_corporate_entity_full_subrec) : \n\t\t\tbuild(:json_agent_corporate_entity)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/corporate_entities\")\n\twhen :family\n\t\tagent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_family_full_subrec) : \n\t\t\tbuild(:json_agent_familly)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/families\")\n\twhen :software\n agent_json = opts[:create_subrecords] ? \n\t\t\tbuild(:json_agent_software_full_subrec) : \n\t\t\tbuild(:json_agent_software)\n\t\turl = URI(\"#{JSONModel::HTTP.backend_url}/agents/software\")\n\tend\n\n response = JSONModel::HTTP.post_json(url, agent_json.to_json)\n json_response = ASUtils.json_parse(response.body)\n\n if json_response[\"status\"] == \"Created\"\n return json_response[\"id\"]\n else\n return -1\n\tend\nrescue => e\n\treturn -1\nend",
"def agencies_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_get ...'\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 AgenciesApi.agencies_get\"\n end\n # resource path\n local_var_path = '/v1/agencies/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def agreement_params\n params.require(:agreement).permit(:restaurant_id, :user_id, :start_date, :end_date, :agreement_length, :term_of_notice_in_months, :responsible_user_id, :invoicing_period_length, :invoicing_payment_time, :invoicing_date, :signed_by_customer)\n end",
"def ag_apartment_params\n params.require(:ag_apartment).permit(:unit_num, :num_bedrooms, :num_bathrooms, :has_kitchen, :has_living_room, :sq_footage, :ag_public_housing_devel_id)\n end",
"def create\n @apartment = @building.apartments.build(params[:apartment])\n\n respond_to do |format|\n if @apartment.save\n format.html { redirect_to @building, notice: 'Apartment was successfully created.' }\n format.json { render json: @apartment, status: :created, location: @apartment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @apartment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bank_agence = BankAgence.new(bank_agence_params)\n\n respond_to do |format|\n if @bank_agence.save\n format.html { redirect_to @bank_agence, notice: 'Bank agence was successfully created.' }\n format.json { render :show, status: :created, location: @bank_agence }\n else\n format.html { render :new }\n format.json { render json: @bank_agence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def create\n order = Order.create(order_params)\n render json: order\nend",
"def create\n @absence = Absence.new(params[:absence])\n @title = \"New Absence\"\n respond_to do |format|\n if @absence.save\n format.html { redirect_to @absence, notice: 'Absence was successfully created.' }\n format.json { render json: @absence, status: :created, location: @absence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @absence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def agency_rate_params\n # rubocop:disable Metrics/LineLength\n params.require(:agency_rate).permit(:agency_id, :visit_type_id, :amount, :arrangement)\n # rubocop:enable Metrics/LineLength\n end",
"def data_to_api(snack_name, snack_location, snack_optional)\n RestClient.post ENV['NERDERY_API'], { name: snack_name,\n location: snack_location,\n optional: snack_optional\n }.to_json, content_type: :json\n end",
"def get_availabillity(request_parameters: {})\r\n default_parameters = {\r\n room1: \"A,A\",\r\n }\r\n http_service.request_post(\"/json/getHotelAvailabilityV2\", default_parameters.merge(request_parameters))\r\n end",
"def index\n @apartments = @building.apartments\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apartments }\n end\n end",
"def agent_params\n params.require(:agent).permit(:unique_code, :comission_percentage, :lending_percentage, :user_id, :agency_id, :position, :deleted_at)\n end",
"def create\n @attendence = Attendence.new(attendence_params)\n\n respond_to do |format|\n if @attendence.save\n format.html { redirect_to @attendence, notice: 'Attendence was successfully created.' }\n format.json { render :show, status: :created, location: @attendence }\n else\n format.html { render :new }\n format.json { render json: @attendence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend",
"def create\n @flight = scope.new(flight_params)\n\n if @flight.save\n json_response(@flight.decorate.as_json(flight_details: true),\n :created)\n else\n json_response(@flight.errors, :unprocessable_entity)\n end\n end",
"def create\n @engagement_attendee = EngagementAttendee.new(engagement_params)\n if @engagement_attendee.save\n render :show, status: :created, location: api_v1_engagement_url(@engagement_attendee)\n else\n render json: @engagement_attendee.errors, status: :unprocessable_entity\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 index\n @event_requirements = EventRequirement.all\n\n render json: @event_requirements\n end",
"def create\n @acquirement = Acquirement.new(params[:acquirement])\n\n respond_to do |format|\n if @acquirement.save\n format.html { redirect_to @acquirement, notice: 'Acquirement was successfully created.' }\n format.json { render json: @acquirement, status: :created, location: @acquirement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @acquirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_agent_enquiries_by_property\n agent_id = Agents::Branches::AssignedAgent.last.id\n get :agent_enquiries_by_property, { agent_id: agent_id }\n earlier_response = Oj.load(@response.body)\n verification_status = true\n attach_agent_to_property_and_update_details(agent_id, SAMPLE_UDPRN, 'Green', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n enquiry_count = 0\n\n Trackers::Buyer::ENQUIRY_EVENTS.each do |event|\n process_event_helper(event, @address_doc['_source'])\n @address_doc['_source'].delete('agent_id')\n get :agent_enquiries_by_property, { agent_id: agent_id }\n assert_response 200\n\n ### Check for the event\n response = Oj.load(@response.body)\n event_value = response.first[event.to_s]\n if event.to_s != 'viewing_stage'\n assert_equal event_value, 1\n end\n\n assert_equal response.length, (earlier_response.length + 1)\n\n ### Check for the property attrs of the body\n attrs = ['udprn', 'beds', 'baths', 'receptions']\n attrs.each do |attr_val|\n assert_equal response.first[attr_val], eval(\"SAMPLE_#{attr_val.upcase}\")\n end\n\n enquiry_count = enquiry_count + 1\n #### Check if the total number of enquiries are increasing\n assert_equal response.first['total_enquiries'], enquiry_count\n end\n\n other_events = ['offer_made_stage', 'deleted']\n other_events.each do |event|\n process_event_helper(event, @address_doc['_source'])\n get :agent_enquiries_by_property, { agent_id: agent_id }\n response = Oj.load(@response.body)\n event_value = response.first[event.to_s]\n assert_equal event_value, 1\n end\n\n total_trackings = 0\n Trackers::Buyer::TRACKING_EVENTS.each do |event|\n process_event_helper(event, @address_doc['_source'])\n get :agent_enquiries_by_property, { agent_id: agent_id }\n response = Oj.load(@response.body)\n count = response.first['trackings']\n total_trackings += 1\n assert_equal count, total_trackings\n end\n\n ### Test for verification status filter\n new_verification_status = !verification_status\n get :agent_enquiries_by_property, { agent_id: agent_id, verification_status: new_verification_status }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 0\n\n new_verification_status = !new_verification_status\n get :agent_enquiries_by_property, { agent_id: agent_id, verification_status: new_verification_status }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 1\n\n\n ### Test for property_status_type_filter\n property_status_type = 'Red'\n get :agent_enquiries_by_property, { agent_id: agent_id, property_status_type: property_status_type }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 0\n\n property_status_type = 'Green'\n get :agent_enquiries_by_property, { agent_id: agent_id, property_status_type: property_status_type }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 1\n\n create_rent_enquiry_event\n attach_agent_to_property_and_update_details(agent_id, '123456', 'Rent', \n verification_status, SAMPLE_BEDS, SAMPLE_BATHS, \n SAMPLE_RECEPTIONS)\n\n\n property_status_type = 'Rent'\n\n get :agent_enquiries_by_property, { agent_id: agent_id, property_status_type: property_status_type }\n assert_response 200\n response = Oj.load(@response.body)\n assert_equal response.length, 1\n destroy_rent_enquiry_event\n ### TODO: Agent details have to be verified as well\n end",
"def create\n @age_tracker = AgeTracker.new(age_tracker_params)\n\n respond_to do |format|\n if @age_tracker.save\n format.html { redirect_to @age_tracker, notice: 'Age tracker was successfully created.' }\n format.json { render :show, status: :created, location: @age_tracker }\n else\n format.html { render :new }\n format.json { render json: @age_tracker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @absence = Absence.new(absence_params)\n\n respond_to do |format|\n if @absence.save\n format.html { redirect_to absences_url, notice: 'Отсутствие успешно создано.' }\n format.json { render :edit, status: :created, location: @absence }\n end\n end\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end"
] | [
"0.65139616",
"0.64378023",
"0.60881615",
"0.5974332",
"0.59158754",
"0.57886",
"0.5777596",
"0.56630564",
"0.5619346",
"0.56172913",
"0.56045616",
"0.55700403",
"0.55567896",
"0.5548369",
"0.55454",
"0.5529902",
"0.5528993",
"0.55177605",
"0.5492899",
"0.5431118",
"0.5429397",
"0.5393732",
"0.5382053",
"0.5363579",
"0.5360258",
"0.53129345",
"0.5289929",
"0.5254793",
"0.5245969",
"0.5203504",
"0.5191846",
"0.519043",
"0.51804996",
"0.51344484",
"0.5127804",
"0.51155514",
"0.50934976",
"0.50914913",
"0.50790936",
"0.5064998",
"0.5044552",
"0.50255257",
"0.50255257",
"0.5000837",
"0.49947152",
"0.49843824",
"0.4980613",
"0.49625996",
"0.49392644",
"0.49305296",
"0.49296382",
"0.49256888",
"0.49228463",
"0.49208966",
"0.4914097",
"0.49066448",
"0.49011096",
"0.48917446",
"0.48836178",
"0.487748",
"0.48569918",
"0.48495805",
"0.48484597",
"0.48465374",
"0.4845225",
"0.4837313",
"0.48340517",
"0.48268986",
"0.48179585",
"0.48174742",
"0.48030072",
"0.4802958",
"0.48014128",
"0.47990084",
"0.4795081",
"0.47810638",
"0.47779152",
"0.47769302",
"0.47757193",
"0.47755817",
"0.47699213",
"0.47641128",
"0.47455326",
"0.47425348",
"0.4742534",
"0.47386792",
"0.47385707",
"0.47384107",
"0.47309402",
"0.47239226",
"0.47212267",
"0.47186726",
"0.4707142",
"0.47004607",
"0.46913272",
"0.46886075",
"0.46797395",
"0.46792763",
"0.4678859",
"0.46708745"
] | 0.5401406 | 21 |
PUT /agencies/1 PUT /agencies/1.json | def update
respond_to do |format|
if @agency.update_attributes(params[:agency])
format.html { redirect_to @agency, notice: 'Agency was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @agency.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @agency.update(agency_params)\n @agency = Agency.new\n @agencies = Agency.all\n @flag = true\n else\n @flag = false\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @agency.update(agency_params)\n format.html { redirect_to @agency, notice: \"Agency was successfully updated.\" }\n format.json { render :show, status: :ok, location: @agency }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n if @agency.save\n render json: @agency, status: :created, location: @agency\n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def set_agency\n @agency = Agency.find(params[:id])\n end",
"def update\n @admin_agency = Admin::Agency.find(params[:id])\n\n respond_to do |format|\n if @admin_agency.update_attributes(params[:admin_agency])\n format.html { redirect_to @admin_agency, notice: 'Agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @agency.update(agency_params)\n format.html { redirect_to @agency, notice: 'Agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_agency\n @agency = Agency.find_by_id(params[:id])\n end",
"def update\n @gtfs_agency = GtfsAgency.find(params[:id])\n\n respond_to do |format|\n if @gtfs_agency.update_attributes(params[:gtfs_agency])\n format.html { redirect_to(@gtfs_agency, :notice => 'Gtfs agency was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gtfs_agency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @agency_associations = args[:agency_associations] if args.key?(:agency_associations)\n end",
"def set_agency\n @agency = Agency.find(params[:agency_id])\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def show\n @agencies = Agency.find(params[:id])\n\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n end",
"def index\n @agencies = Agency.all\n end",
"def update\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n\n respond_to do |format|\n if @tenancy_agreement.update_attributes(params[:tenancy_agreement])\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n if @agency_type.update_attributes(params[:agency_type])\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n\n respond_to do |format|\n if @agency.save\n format.html { redirect_to @agency, notice: \"Agency was successfully created.\" }\n format.json { render :show, status: :created, location: @agency }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def agency_params\n params.require(:agency).permit(:title, :reg_number, :address, :phone, :status)\n end",
"def set_tenant_scope(args = {}) \n put(\"/tenants.json/scope/#{args[:tenantId]}\", args)\nend",
"def set_agency\n @agency = Agency.find_by_hashid(params[:id])\n end",
"def agency_params\n params.require(:agency).permit(:name)\n end",
"def agency_params\n params.require(:agency).permit(:name,\n :agycode,\n :photo,\n :description,\n :restrictions,\n :hours_of_operation,\n :address_id,\n :contact_name,\n :contact_phone,\n :contact_email,\n :services,\n :geographic_restrictions,\n :family_stipulations,\n :faith_based,\n :is_active,\n :general_information,\n { :service_ids => [] },\n address_attributes: [:id, :street_line_1, :street_line_2, :city, :state, :zip])\n end",
"def update\n _ensure_user_can_edit(@agency)\n respond_to do |format|\n if @agency.update(agency_params)\n format.html { redirect_to @agency, notice: 'Agency was successfully updated.' }\n format.json { render :show, status: :ok, location: @agency }\n else\n format.html { render :edit }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend",
"def create\n @tenancy_agreement = TenancyAgreement.new(params[:tenancy_agreement])\n @tenancy_agreement.estate_agent_id = current_user.estate_agent_id\n respond_to do |format|\n if @tenancy_agreement.save\n format.html { redirect_to tenancy_agreements_path, notice: 'Tenancy agreement was successfully created.' }\n format.json { render json: @tenancy_agreement, status: :created, location: @tenancy_agreement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tenancy_agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def set_agency\n @agency = Agency.friendly.find(params[:id])\n end",
"def update\n if params['cancel']\n redirect_to agencies_url and return\n end\n @agency = Agency.find(params[:id])\n @agency.updated_by = current_user.login\n if @agency.publication\n @agency.publications[0].update_attributes(publication_params)\n else\n publication = Publication.new(publication_params)\n unless publication.empty?\n @agency.publications << publication\n @agency.publications.last.save!\n end\n end\n# @agency.build_restriction if [email protected]\n#\n# @agency.restriction.update_attributes(params[:restriction])\n# @agency.restriction.states=params[:state_abbrevs].collect{|s| State.find(s)} unless params[:state_abbrevs].to_s.blank?\n# @agency.restriction.counties=params[:county_ids].collect{|c| County.find(c)} unless params[:county_ids].nil?\n# @agency.restriction.cities=params[:city_ids].collect{|c| City.find(c)} unless params[:city_ids].nil?\n# @agency.restriction.zips=params[:zip_ids].collect{|c| Zip.find(c)} unless params[:zip_ids].nil?\n\n #composed_of fields must be created manually\n update_pha_contact\n\n begin\n if @agency.update_attributes(agencies_params)\n flash[:notice] = 'Agency was successfully updated.'\n redirect_to agencies_url() and return if params['update_and_return']\n redirect_to edit_agency_url(@agency)\n else\n render :action => \"edit\"\n end\n end\n end",
"def create\n @agency = Agency.new(agency_params)\n if @agency.save\n @agency = Agency.new\n @agencies = Agency.all\n @flag = true\n else\n @flag = false\n end\n end",
"def agency_params\n params.require(:agency).permit(:code, :name, :description, :is_active)\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 destroy\n @agency.update_attribute(:status, 'N')\n respond_to do |format|\n format.html { redirect_to agencies_url, notice: 'Agency was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def agency_params\n params.require(:agency).permit( :name, :phone, :contact_name, :contact_email, :address, :latitude, :longitude, :website_url, :num_employees, :golden_pitch, :silver_pitch, :medium_risk_pitch, :high_risk_pitch, :agency )\n end",
"def update\n @service_level_agreement = current_user.company.service_level_agreements.find(params[:id])\n\n if @service_level_agreement.update_attributes(params[:service_level_agreement])\n render :json => {:success => true}\n else\n render :json => {:success => false, :message => @service_level_agreement.errors.full_messages.join(\". \") }\n end\n end",
"def agency_params\n params.require(:agency).permit(:title, :description)\n end",
"def create\n @admin_agency = Admin::Agency.new(params[:admin_agency])\n\n respond_to do |format|\n if @admin_agency.save\n format.html { redirect_to @admin_agency, notice: 'Agency was successfully created.' }\n format.json { render json: @admin_agency, status: :created, location: @admin_agency }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def update_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 agencies_create_test_agency_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_create_test_agency ...'\n end\n # resource path\n local_var_path = '/v1/agencies/_testAgency'\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', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(: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 => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_create_test_agency\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end",
"def set_agency\n @agency = Agency.friendly.find(params[:id])\n end",
"def update\n @audience = Audience.find(params[:id])\n\n respond_to do |format|\n if @audience.update_attributes(params[:audience])\n format.html { redirect_to @audience, notice: 'Audience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @audience.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n find_agencies(params[:id])\n increment_views_amount(@public_agency)\n end",
"def agency_params\n params.require(:agency).permit(I18n.t('agencies_controller.agency_params').map(&:to_sym))\n end",
"def create\n @agency = Agency.new(agency_params)\n respond_to do |format|\n if @agency.save\n format.html { redirect_to session[:redirect_to], notice: 'Agency was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @agency }\n else\n format.html { render action: 'new' }\n format.json { render json: @agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n apartment = Apartment.find(params[:id])\n apartment.update_attributes(apartment_params)\n render json: apartment\n end",
"def update\n respond_to do |format|\n if @registering_agency.update(registering_agency_params)\n format.html { redirect_to @registering_agency, notice: 'Registering agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @registering_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def update\n respond_to do |format|\n if @observation.update(observation_params)\n format.html { redirect_to @observation, notice: 'Observation was successfully updated.' }\n format.json { render :show, status: :ok, location: @observation }\n else\n @services_of_dependence = current_user.dependence.service_of_dependences\n agents_of_service = AgentOfService.where(service_of_dependence: @services_of_dependence)\n @agents = Agent.where(id: agents_of_service.pluck(:agent_id))\n format.html { render :edit }\n format.json { render json: @observation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def agency_params\n params.require(:agency).permit(:name, :description, :address, :user_id, :where, :photo, :photo_cache)\n end",
"def update\n respond_to do |format|\n if @ag_apartment.update(ag_apartment_params)\n format.html { redirect_to @ag_apartment, notice: 'Apartment was successfully updated.' }\n format.json { render :show, status: :ok, location: @ag_apartment }\n else\n format.html { render :edit }\n format.json { render json: @ag_apartment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end",
"def update_agent\n res = {\n :success => true,\n :msg => 'order/update_agent'\n }\n render :json => res.to_json, :layout => false\n end",
"def update\n with_error_handling do\n attrs = parsed_body(format: ctype)\n\n Lark::Transactions::UpdateAuthority\n .new(event_stream: event_stream, adapter: adapter)\n .call(id: params['id'], attributes: attrs)\n\n [204, cors_allow_header, []]\n end\n end",
"def agency_io_id=(val)\n self.agency = Agency.find_by(io_id: val)\n end",
"def update_array_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/arrays/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def destroy\n @admin_agency = Admin::Agency.find(params[:id])\n @admin_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_agencies_url }\n format.json { head :no_content }\n end\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def agency_params\n params.require(:agency).permit(:name, :city, :adress, :zipcode, :phone_number, :logo_agency_url, :siren)\n end",
"def update\n respond_to do |format|\n if @agreement.update(agreement_params)\n format.html { redirect_to @agreement, notice: 'Agreement was successfully updated.' }\n format.json { render :show, status: :ok, location: @agreement }\n else\n format.html { render :edit }\n format.json { render json: @agreement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end",
"def update\n @agency_relationship = AgencyRelationship.find(params[:id])\n\n respond_to do |format|\n if @agency_relationship.update_attributes(params[:agency_relationship])\n flash[:notice] = 'AgencyRelationship was successfully updated.'\n format.html { redirect_to(\n agency_relationship_url(@agency_relationship)) }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def put(path, params)\n parse_response @client[path].put(params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(*args)\n request :put, *args\n end",
"def update!(**args)\n @beacon_name = args[:beacon_name] if args.key?(:beacon_name)\n @advertised_id = args[:advertised_id] if args.key?(:advertised_id)\n @status = args[:status] if args.key?(:status)\n @place_id = args[:place_id] if args.key?(:place_id)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @indoor_level = args[:indoor_level] if args.key?(:indoor_level)\n @expected_stability = args[:expected_stability] if args.key?(:expected_stability)\n @description = args[:description] if args.key?(:description)\n @properties = args[:properties] if args.key?(:properties)\n @ephemeral_id_registration = args[:ephemeral_id_registration] if args.key?(:ephemeral_id_registration)\n @provisioning_key = args[:provisioning_key] if args.key?(:provisioning_key)\n end",
"def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end",
"def agencies_get_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AgenciesApi.agencies_get ...'\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 AgenciesApi.agencies_get\"\n end\n # resource path\n local_var_path = '/v1/agencies/{id}'.sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'text/html', 'application/xml', 'text/xml'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DomainAgencyServiceV2ModelAgency')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AgenciesApi#agencies_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def set_api_v1_initiative_update\n @api_v1_initiative_update = Api::V1::InitiativeUpdate.find(params[:id])\n end",
"def set_agency_rate\n @agency_rate = AgencyRate.find(params[:id])\n end",
"def destroy\n @agency = Agency.find(params[:id])\n @agency.destroy\n redirect_to agencies_url\n end",
"def update\n @news_agency = NewsAgency.find(params[:id])\n\n respond_to do |format|\n if @news_agency.update_attributes(params[:news_agency])\n format.html { redirect_to @news_agency, notice: 'News agency was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @news_agency.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def index\n #pseudo scope \n if params[:phone] \n @agencies = Agency.find_by_phone(params[:phone]);\n if @agencies \n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end \n else\n head :not_found\n end\n else\n # Aqui estoy haciendo que el api responda en mas de 1 formato\n @agencies = Agency.all\n respond_to do |format|\n format.json { render :json => @agencies }\n format.xml { render :xml => @agencies }\n end\n\n end \n end",
"def put(path, params)\n request(:put, path, params)\n end",
"def update\n authorize @organization\n @organization.tag_list.add @tags\n if @organization.save\n render :json => @organization.reload.tags\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end"
] | [
"0.6383923",
"0.6370227",
"0.59582865",
"0.5884642",
"0.5827623",
"0.57707024",
"0.5707225",
"0.5662867",
"0.5662867",
"0.5662867",
"0.5662867",
"0.5662867",
"0.5662867",
"0.56472933",
"0.55932724",
"0.5577771",
"0.55759895",
"0.555988",
"0.5556898",
"0.5520727",
"0.55169487",
"0.5509786",
"0.5492731",
"0.5419311",
"0.54135334",
"0.5385746",
"0.5345483",
"0.5337158",
"0.5336204",
"0.5323036",
"0.5303863",
"0.52706754",
"0.5269591",
"0.5266025",
"0.5264803",
"0.5238754",
"0.5234333",
"0.5230025",
"0.5221847",
"0.5197845",
"0.518355",
"0.5180796",
"0.5168555",
"0.5160649",
"0.5155861",
"0.5144561",
"0.51400185",
"0.5130694",
"0.51234937",
"0.51167095",
"0.51073134",
"0.51032716",
"0.50994456",
"0.50865066",
"0.50839335",
"0.50696635",
"0.50623536",
"0.50471425",
"0.5038967",
"0.5037878",
"0.5030481",
"0.50216216",
"0.501984",
"0.50189495",
"0.5016991",
"0.50026006",
"0.49982947",
"0.49978787",
"0.4994948",
"0.49839726",
"0.4981742",
"0.4976612",
"0.49758792",
"0.49738038",
"0.4972556",
"0.49684456",
"0.49684456",
"0.49684456",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49600247",
"0.49529263",
"0.49505067",
"0.49449235",
"0.49434128",
"0.49422064",
"0.49413547",
"0.49401012",
"0.49379593",
"0.4935663",
"0.49315232",
"0.49315232",
"0.49229938",
"0.49189407",
"0.49004754"
] | 0.5761342 | 6 |
DELETE /agencies/1 DELETE /agencies/1.json | def destroy
@agency.destroy
if session[:customer_type] == @agency.class.name and session[:customer_id] == params[:id].to_i
session[:customer_type] = nil
session[:customer_id] = nil
end
respond_to do |format|
format.html { redirect_to :back, alert: @agency.errors[:base][0] }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @admin_agency = Admin::Agency.find(params[:id])\n @admin_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_agencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agency.update_attribute(:status, 'N')\n respond_to do |format|\n format.html { redirect_to agencies_url, notice: 'Agency was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gtfs_agency = GtfsAgency.find(params[:id])\n @gtfs_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to(gtfs_agencies_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @agency = Agency.find(params[:id])\n @agency.destroy\n redirect_to agencies_url\n end",
"def destroy\n @agency.destroy\n respond_to do |format|\n format.html { redirect_to agencies_url, notice: \"Agency was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @registering_agency.destroy\n respond_to do |format|\n format.html { redirect_to registering_agencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tenancy_agreement = TenancyAgreement.find(params[:id])\n @tenancy_agreement.destroy\n\n respond_to do |format|\n format.html { redirect_to tenancy_agreements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agency = Agency.find(params[:id])\n @agency.destroy\n\n #head :no_content\n head :accepted # o deberia dejarlo en not_content\n end",
"def destroy\n @agency_type = AgencyType.find(params[:id])\n @agency_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agency = Agency.find(params[:id])\n @agency.destroy\n\n #head :no_content\n head :accepted # o deberia dejarlo en not_content\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @news_agency = NewsAgency.find(params[:id])\n @news_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to news_agencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n _ensure_user_can_edit(@agency)\n @agency.destroy\n respond_to do |format|\n format.html { redirect_to agencies_url, notice: 'Agency was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @service_level_agreement = current_user.company.service_level_agreements.find(params[:id])\n @service_level_agreement.destroy\n\n render :json => {:success => true}\n end",
"def destroy\n @agency_relationship = AgencyRelationship.find(params[:id])\n @agency_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to(agency_relationships_url) }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @agent = @business.agents.find(params[:id])\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to business_agents_url(@business) }\n format.json { head :no_content }\n end\n end",
"def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end",
"def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end",
"def deleteEntityAdvertiser( 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/advertiser\",params)\n end",
"def destroy\n @agreement.destroy\n respond_to do |format|\n format.html { redirect_to agreements_url, notice: 'Agreement 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 delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @agency\n # if ComplianceRecord.exists?(compliance_type_id: @agency.id)\n # flash[:alert] = \"This Compliance Type is used in Transaction\"\n # else\n @agency.destroy\n @agencies = Agency.all\n #end\n redirect_to agencies_path\n end",
"def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end",
"def destroy\n @tracing.destroy\n respond_to do |format|\n format.html { redirect_to tracings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_dep_collector.destroy\n respond_to do |format|\n format.html {redirect_to test_dep_collectors_url, notice: 'Test dep collector was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @beacon = Beacon.find(params[:id])\n @beacon.destroy\n\n respond_to do |format|\n format.html { redirect_to beacons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @audience = Audience.find(params[:id])\n @audience.destroy\n\n respond_to do |format|\n format.html { redirect_to audiences_url }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\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 @dependence.destroy\n respond_to do |format|\n format.html { redirect_to dependences_url, notice: 'Dependence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete(path, params)\n parse_response @client[path].delete(:params => params)\n end",
"def destroy\n @acquired_energy.destroy\n respond_to do |format|\n format.html { redirect_to acquired_energies_url, notice: 'Acquired energy was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def destroy\n @adj.destroy\n respond_to do |format|\n format.html { redirect_to adjs_url, notice: 'Adj was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def destroy\n @subway.destroy\n respond_to do |format|\n format.html { redirect_to subways_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n src = Tagaly3::SRC\n # Code to connect with API\n @uri = URI.parse(src)\n http = Net::HTTP.start(@uri.host,@uri.port)\n request = Net::HTTP::Delete.new(\"/adexchange/advertiser/advertisement/#{id}\")\n response = http.request(request)\n http.finish\n redirect_to '/ads/'\n end",
"def destroy\n @traceroute.destroy\n respond_to do |format|\n format.html { redirect_to traceroutes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @traceroute.destroy\n respond_to do |format|\n format.html { redirect_to traceroutes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to agents_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.agent')) }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @allocation = Allocation.find(params[:id])\n @episode = @allocation.episode\n @allocation.destroy\n\n respond_to do |format|\n format.html { redirect_to client_path(@episode.client) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ag_apartment.destroy\n respond_to do |format|\n format.html { redirect_to ag_apartments_url, notice: 'Apartment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @reference_analytic.destroy\n respond_to do |format|\n format.html { redirect_to reference_analytics_url, notice: 'Reference analytic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aadt = Aadt.find(params[:id])\n @aadt.destroy\n\n respond_to do |format|\n format.html { redirect_to aadts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @violency = Violency.find(params[:id])\n @violency.destroy\n\n respond_to do |format|\n format.html { redirect_to(violencies_url) }\n format.xml { head :ok }\n end\n end",
"def delete(path, params={}, options={})\n request(:delete, api_path(path), params, options)\n end",
"def destroy\n @asistence = Asistence.find(params[:id])\n @asistence.destroy\n\n respond_to do |format|\n format.html { redirect_to asistences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent_status = AgentStatus.find(params[:id])\n @agent_status.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_statuses_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 @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\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",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params)\n request(:delete, path, {})\n end",
"def destroy\n @advert1.destroy\n respond_to do |format|\n format.html { redirect_to advert1s_url, notice: 'Advert1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apartment = @building.apartments.find(params[:id])\n @apartment.destroy\n\n respond_to do |format|\n format.html { redirect_to @building, notice: 'Apartment was successfully removed.'}\n format.json { head :no_content }\n end\n end",
"def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent.destroy\n respond_to do |format|\n format.html { redirect_to admin_agents_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete\n request(:delete)\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def destroy\n @apt = Apt.find(params[:id])\n @apt.destroy\n\n respond_to do |format|\n format.html { redirect_to apts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assumption.destroy\n respond_to do |format|\n format.html { redirect_to assumptions_url }\n format.json { head :no_content }\n end\n end",
"def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @engagement_attendee.destroy\n head :no_content\n end",
"def destroy\n @competency = Competency.find(params[:id])\n @competency.destroy\n\n respond_to do |format|\n format.html { redirect_to competencies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @encyclopaedia = Encyclopaedia.find(params[:id])\n @encyclopaedia.destroy\n\n respond_to do |format|\n format.html { redirect_to(encyclopaedias_url) }\n format.xml { head :ok }\n end\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 destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end",
"def destroy\n @service_dependance = ServiceDependance.find(params[:id])\n @service_dependance.destroy\n\n respond_to do |format|\n format.html { redirect_to service_dependances_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @absence = Absence.find(params[:id])\n @absence.destroy\n\n respond_to do |format|\n format.html { redirect_to absences_url }\n format.json { head :no_content }\n end\n end",
"def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend",
"def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end",
"def delete\n @delete ||= Verb.new do |verb|\n verb.entity :trip, :air, :lodging, :car, :profile, :rail, \\\n :transport, :cruise, :restaurant, :activity, :note, :map, \\\n :directions \\\n do |entity, id|\n do_request('delete', entity, {:id=>id}, nil)\n end\n end\n end",
"def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\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 destroy\n @home_indices_ad = Home::Indices::Ad.find(params[:id])\n @home_indices_ad.destroy\n\n respond_to do |format|\n format.html { redirect_to home_indices_ads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end"
] | [
"0.71593577",
"0.7031232",
"0.7006339",
"0.6925245",
"0.6912497",
"0.6776775",
"0.66877604",
"0.66677976",
"0.6647072",
"0.65896744",
"0.6581337",
"0.64700097",
"0.6455344",
"0.64393365",
"0.64218456",
"0.6416901",
"0.6416874",
"0.6395021",
"0.6336782",
"0.63129896",
"0.6270823",
"0.62604445",
"0.6260431",
"0.62596554",
"0.62554646",
"0.6252934",
"0.6233185",
"0.62129915",
"0.62010044",
"0.6184347",
"0.6179133",
"0.6176487",
"0.6170638",
"0.6155035",
"0.61421967",
"0.61421967",
"0.61421967",
"0.61421967",
"0.61161506",
"0.61087126",
"0.6104582",
"0.61040056",
"0.6103879",
"0.61024576",
"0.61011624",
"0.60998124",
"0.60987085",
"0.6095414",
"0.6095414",
"0.6080416",
"0.6076081",
"0.6069271",
"0.6066819",
"0.60629356",
"0.60614026",
"0.6054954",
"0.60443395",
"0.6044324",
"0.6043479",
"0.60379505",
"0.6034943",
"0.6030463",
"0.60251725",
"0.60251725",
"0.60251725",
"0.60251725",
"0.60251725",
"0.60251725",
"0.60251725",
"0.6024236",
"0.60239506",
"0.60231984",
"0.6023127",
"0.6017118",
"0.6017062",
"0.60125333",
"0.6004711",
"0.6001434",
"0.5998539",
"0.5994339",
"0.5992975",
"0.5991975",
"0.59880394",
"0.59872663",
"0.59871083",
"0.5983918",
"0.5983918",
"0.5983918",
"0.59833676",
"0.59833217",
"0.59750986",
"0.5973981",
"0.5973487",
"0.597042",
"0.5968012",
"0.5966093",
"0.5965035",
"0.5965035",
"0.5961139",
"0.5957741"
] | 0.59860694 | 85 |
GET /teams GET /teams.json | def index
@teams = Team.joins('LEFT OUTER JOIN clubs on teams.club_id = clubs.id').select('teams.*, clubs.name as club_name')
render json: @teams
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_team_list ( page = 1 )\n get_api_resource \"#{@@api_base_url}teams/#{page}\"\n end",
"def teams\n render json: @team_query\n end",
"def index\n @teams = Team.all\n render json: @teams\n end",
"def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end",
"def team(id)\n get \"/teams/#{id}\"\n end",
"def index\n @teams = Team.all\n render :json => @teams\n end",
"def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def show\n # @teams = ::Services::TeamService.show_teams\n end",
"def show\n @team = Team.find(params[:id])\n\n render json: @team\n end",
"def teams(org)\n get \"/orgs/#{org}/teams\"\n end",
"def index\n @teams = Team.all.order(:name)\n if params[:all]\n json_response(TeamSerializer, @teams)\n else\n @teams_paginated = @teams.page(current_page, per_page).per(per_page)\n json_response(TeamSerializer, @teams_paginated, options(@teams))\n end\n end",
"def get_teams_by_league(league_id)\n response = parse_api_request(\"#{BASE_URL}teams/league/#{league_id}\")[\"teams\"]\nend",
"def show\n\t\t@team = Team.find(params[:id])\n\t\trender '/teams/show.json.jbuilder'\n\tend",
"def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def index\n if current_user_total?\n @teams = Team.order(:description).page(params[:page]).per(5)\n else\n ids = []\n tus = TeamUser.where(user_id: current_user.id)\n tus.each do |tu| # user_id | team_id\n ids << tu.team_id # [1, 6, 7]\n end\n\n return @teams = Team.where(id: ids).order(:description).page(params[:page]).per(5)\n end\n=======\n\n # GET /teams\n # GET /teams.json\n def index\n @teams = Team.order(:description).page(params[:page]).per(5)\n>>>>>>> d0c6183c3349cba16c54d8ce4c0fb5ee26c49700\n end\n\n # GET /teams/1\n # GET /teams/1.json\n def show\n<<<<<<< HEAD\n=======\n @team = Team.find(params[:id])\n>>>>>>> d0c6183c3349cba16c54d8ce4c0fb5ee26c49700\n end",
"def index\n @teams = Team.page(params[:page])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = current_user.teams\n end",
"def index\n @teams = current_user.teams\n end",
"def index\n game = Game.all\n\n render json: game, include: :teams\n end",
"def get_teams\n reply = @client.call(:get_teams)\n data = reply.body.dig(:get_teams_response,\n :get_teams_result,\n :string)\n check_if_data_exists(data)\n rescue Savon::HTTPError => error\n logger.debug error.http.code\n return []\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @league }\n end\n end",
"def index\n\t\t@teams = Team.all\n\tend",
"def team\n fetch('esport.teams')\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n render status: 200, json: Team.find(params[:id])\n end",
"def index\n @teams = @organization.teams\n end",
"def get_team ( team_key )\n get_api_resource \"#{@@api_base_url}team/#{team_key}\"\n end",
"def show\n team = Team.find_by(:id => params[:id])\n render :json => team\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def get_teams\r\n response = HTTParty.get('https://www.balldontlie.io/api/v1/teams')[\"data\"]\r\n response.each do |i|\r\n team = Team.new\r\n \r\n team.full_name = i[\"full_name\"]\r\n team.division = i[\"division\"]\r\n team.conference = i[\"conference\"]\r\n\r\n team.save\r\n\r\n end \r\n end",
"def index\n\t\t@teams = Team.all\n\t\trender '/teams/index.json.jbuilder'\n\tend",
"def list_teams_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TeamApi.list_teams ...\"\n end\n # resource path\n local_var_path = \"/v2/teams\"\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['GenieKey']\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 => 'ListTeamsResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TeamApi#list_teams\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n # @teams = Team.all\n \n redirect_to \"/members\"\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @teams }\n # end\n end",
"def index\n @user_teams = UserTeam.all\n end",
"def get_team(params = {})\n params = Utils.symbolize_hash_keys(params)\n query_params = { }\n headers = {}\n body = nil\n\n path = \"/team\"\n\n @client.request(\n method: :get,\n path: path,\n query: query_params,\n headers: headers,\n body: body)\n end",
"def get_project_teams(project_id_or_key)\n get(\"projects/#{project_id_or_key}/teams\")\n end",
"def index\n @users_teams = UsersTeam.all\n end",
"def team\n @team = Team.where('team_id = ?', params[:id])\n @active_stats = ActiveStat.where('team_id = ?', params[:id])\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def teams\n @teams ||= @api.client.orgs.teams.list(org: @org)\n end",
"def index\n @teams = @competition.teams.sort_by{|t| t.number}\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def get_teams_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TeamsApi.get_teams ...'\n end\n # resource path\n local_var_path = '/teams'\n\n # query parameters\n query_params = {}\n query_params[:'conference'] = opts[:'conference'] if !opts[:'conference'].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 = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Team>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TeamsApi#get_teams\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @teams = Team.order(:id).page(params[:page]).per(10)\n end",
"def teams\n @teams\n end",
"def get_teams( org )\n teams = Homework.get(\"/orgs/#{org}/teams\", :headers => @auth)\n teams.each do |team|\n puts team['id']\n end\n end",
"def show\n @user_teams = @game.team.user_teams\n end",
"def org_teams(org)\n Hardmode.get(\"/orgs/#{org}/teams\", :headers => @auth)\n end",
"def show\n @ultimate_team = UltimateTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ultimate_team }\n end\n end",
"def user_team(team_id)\n get(\"/user_teams/#{team_id}\")\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(current_user.id)\n \n end",
"def app_teams(org_name:, platform:, app_id:)\n endpoint = \"/api/organizations/#{org_name}/platforms/#{platform}\"\\\n \"/apps/#{app_id}/teams\"\n res = api.get endpoint\n Response.new(res)\n end",
"def get_event_teams ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}/teams\"\n end",
"def teams\n @teams ||= ApiFactory.new 'Orgs::Teams'\n end",
"def index\n\t\t@teams = Team.order(\"name ASC\").all\n\n\t\t# Pulls upcoming fixtures in Premier League\n\t\t@data = party_time(\"http://api.statsfc.com/premier-league/fixtures.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&timezone=America/New_York&limit=10\")\n\n\t\t# Pulls top scorers in Premier League\n\t\t@data2 = party_time(\"http://api.statsfc.com/top-scorers.json?key=DThzCPsM_TI0XUGeUOJqr26JHwtYXVIfYvSSb0ui&competition=premier-league&year=2013/2014&limit=10\")\t\n\n\t\t# Pulls news articles about the league through Google RSS\n\t\tdata = party_time(\"https://news.google.com/news/feeds?q=barclays+premier+league&output=rss\")\n\t\t@articles = data[\"rss\"][\"channel\"][\"item\"]\n\tend",
"def index\n @games_teams = GamesTeam.all\n end",
"def get_teams\n TeamNode.get(node_object_id)\n end",
"def index\n @teams = current_user.recent_teams\n end",
"def load_teams\n tell \"Loading teams...\" unless options.quiet?\n teams = []\n\n doc = Nokogiri::HTML(open(TEAMS_URL))\n div1a = doc.css('div.mod-container > div.span-2').first\n list = div1a.css('div.mod-teams-list-medium ul li')\n \n list.each do |t|\n a_tag = t.search('h5 > a').first\n id = a_tag['href'].match(/_\\/id\\/([\\d]+)\\/.+\\Z/)[1]\n name = a_tag.content\n teams.push({:id => id, :name => name})\n end\n\n teams.sort_by { |team| team[:name] }\n end",
"def index\n @mens_teams = MensTeam.all\n end",
"def teams\n parse_domain_top '/Teams/TeamList.aspx', 'lnkTeamInfo'\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(session[:user_id])\n \n end",
"def show\n @swim_team = SwimTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @swim_team }\n end\n end",
"def show\n\n \t\t\trespond_with @team\n\n \t\tend",
"def get_team_details(params)\n get('team', params)\n end",
"def all_teams_in_league\n \treturnArray = []\n\t\tbase_uri = 'https://www.thesportsdb.com/api/v1/json/1/search_all_teams.php?l=' + @league_name.to_s\n\t\tresponse = RestClient.get(base_uri)\n\t\tjson_response = JSON.parse(response)\n\t\thashIds = json_response['teams'] \n\t\thashIds.length.times do |i|\n\t\t\treturnArray[i] = \"Team ID: #{hashIds[i]['idTeam']}, Name: #{hashIds[i]['strTeam']}, Short Name: #{hashIds[i]['strTeamShort']}, Formed Year: #{hashIds[i]['intFormedYear']}, Sport: #{hashIds[i]['strSport']}, Alternate Name: #{hashIds[i]['strAlternateName']}\"\n\t\tend\n\t\treturn returnArray\n\tend",
"def get\n service_response = ManagerManagement::Team::Get.new(params).perform\n return render_api_response(service_response)\n end",
"def index\n\t\t@team = Team.find(params[:team_id])\n\tend",
"def index\n @teams = Team.order(:description).page(params[:page]).per(5)\n>>>>>>> d0c6183c3349cba16c54d8ce4c0fb5ee26c49700\n end",
"def index\n @team = Team.find(params[:team_id])\n @sprints = @team.sprints.find(:all)\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n\t\tmembers = Member.where(team_id: params[:team_id]).all\n\t\trespond_with members\n\tend"
] | [
"0.81233996",
"0.8093715",
"0.78999794",
"0.78722113",
"0.78547835",
"0.78078264",
"0.7747201",
"0.77240586",
"0.77240586",
"0.76768875",
"0.76768875",
"0.7509183",
"0.748406",
"0.74762034",
"0.7434379",
"0.7405707",
"0.738585",
"0.73797023",
"0.73748475",
"0.73599476",
"0.7348547",
"0.7348547",
"0.7327408",
"0.7310985",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7307202",
"0.7301507",
"0.7300436",
"0.7277264",
"0.7245222",
"0.7245222",
"0.7245222",
"0.7245222",
"0.724455",
"0.7243269",
"0.7241881",
"0.7235316",
"0.71967894",
"0.7196733",
"0.71881753",
"0.71829146",
"0.71707696",
"0.71510035",
"0.71252704",
"0.711344",
"0.7109858",
"0.7069363",
"0.7067806",
"0.7058983",
"0.7032325",
"0.70113534",
"0.70083153",
"0.7007239",
"0.70044684",
"0.7001454",
"0.7000331",
"0.699491",
"0.6984708",
"0.6973587",
"0.6971218",
"0.6969064",
"0.6951376",
"0.693093",
"0.6930197",
"0.69199103",
"0.69005525",
"0.6894487",
"0.6893299",
"0.6874521",
"0.6866087",
"0.68473387",
"0.6843824",
"0.68262994",
"0.6817829",
"0.6816209",
"0.67961437",
"0.6793898",
"0.67862207",
"0.6779673"
] | 0.0 | -1 |
GET /teams/1 GET /teams/1.json | def show
@team = Team.find(params[:id])
render json: @team
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team(id)\n get \"/teams/#{id}\"\n end",
"def get_team_list ( page = 1 )\n get_api_resource \"#{@@api_base_url}teams/#{page}\"\n end",
"def show\n\t\t@team = Team.find(params[:id])\n\t\trender '/teams/show.json.jbuilder'\n\tend",
"def index\n @teams = Team.all\n render json: @teams\n end",
"def index\n @teams = @club.teams\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n render :json => @teams\n end",
"def show\n render status: 200, json: Team.find(params[:id])\n end",
"def show\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n team = Team.find_by(:id => params[:id])\n render :json => team\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def teams\n render json: @team_query\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def index\n @teams = Team.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teams }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @league }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def show\n @team = Team.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def index\n if current_user_total?\n @teams = Team.order(:description).page(params[:page]).per(5)\n else\n ids = []\n tus = TeamUser.where(user_id: current_user.id)\n tus.each do |tu| # user_id | team_id\n ids << tu.team_id # [1, 6, 7]\n end\n\n return @teams = Team.where(id: ids).order(:description).page(params[:page]).per(5)\n end\n=======\n\n # GET /teams\n # GET /teams.json\n def index\n @teams = Team.order(:description).page(params[:page]).per(5)\n>>>>>>> d0c6183c3349cba16c54d8ce4c0fb5ee26c49700\n end\n\n # GET /teams/1\n # GET /teams/1.json\n def show\n<<<<<<< HEAD\n=======\n @team = Team.find(params[:id])\n>>>>>>> d0c6183c3349cba16c54d8ce4c0fb5ee26c49700\n end",
"def get_team ( team_key )\n get_api_resource \"#{@@api_base_url}team/#{team_key}\"\n end",
"def index\n @teams = Team.page(params[:page])\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def show\n # @teams = ::Services::TeamService.show_teams\n end",
"def show\n @ultimate_team = UltimateTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ultimate_team }\n end\n end",
"def get_teams_by_league(league_id)\n response = parse_api_request(\"#{BASE_URL}teams/league/#{league_id}\")[\"teams\"]\nend",
"def team\n @team = Team.where('team_id = ?', params[:id])\n @active_stats = ActiveStat.where('team_id = ?', params[:id])\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all\n end",
"def index\n @teams = Team.all.order(:name)\n if params[:all]\n json_response(TeamSerializer, @teams)\n else\n @teams_paginated = @teams.page(current_page, per_page).per(per_page)\n json_response(TeamSerializer, @teams_paginated, options(@teams))\n end\n end",
"def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end",
"def index\n\t\t@teams = Team.all\n\tend",
"def show\n @swim_team = SwimTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @swim_team }\n end\n end",
"def index\n\t\t@team = Team.find(params[:team_id])\n\tend",
"def index\n game = Game.all\n\n render json: game, include: :teams\n end",
"def index\n\t\t@teams = Team.all\n\t\trender '/teams/index.json.jbuilder'\n\tend",
"def index\n # @teams = Team.all\n \n redirect_to \"/members\"\n\n # respond_to do |format|\n # format.html # index.html.erb\n # format.json { render json: @teams }\n # end\n end",
"def show\n @team = Team.find(params[:id])\n end",
"def show\n @team = Team.find(params[:id])\n end",
"def get_team(params = {})\n params = Utils.symbolize_hash_keys(params)\n query_params = { }\n headers = {}\n body = nil\n\n path = \"/team\"\n\n @client.request(\n method: :get,\n path: path,\n query: query_params,\n headers: headers,\n body: body)\n end",
"def index\n @teams = current_user.teams\n end",
"def index\n @teams = current_user.teams\n end",
"def team\n fetch('esport.teams')\n end",
"def index\n @teams = @organization.teams\n end",
"def user_team(team_id)\n get(\"/user_teams/#{team_id}\")\n end",
"def index\n @teams = @competition.teams.sort_by{|t| t.number}\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teams }\n end\n end",
"def show\n @team = Team.find(params[:id])\n @runners = @team.runners\n @count = @runners.length\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @team }\n end\n end",
"def show\n\t\t@team = Team.find(params[:id])\n\tend",
"def new\n @teammate = Teammate.new\n @teams = Hackathon.find(params[:hackathon_id]).teams\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teammate }\n end\n end",
"def show\n @id = @my_team.team_id\n @team_name = Teams.find(@id)\n roster = RestClient.get(\"https://statsapi.web.nhl.com/api/v1/teams/#{@id}/roster\")\n @roster = JSON.parse(roster)[\"roster\"]\n end",
"def get_teams\r\n response = HTTParty.get('https://www.balldontlie.io/api/v1/teams')[\"data\"]\r\n response.each do |i|\r\n team = Team.new\r\n \r\n team.full_name = i[\"full_name\"]\r\n team.division = i[\"division\"]\r\n team.conference = i[\"conference\"]\r\n\r\n team.save\r\n\r\n end \r\n end",
"def show\n\n \t\t\trespond_with @team\n\n \t\tend",
"def index\n @teams = Team.order(:id).page(params[:page]).per(10)\n end",
"def team( team_id )\n\n if( team_id.is_a?(String) && team_id.is_a?(Integer) )\n raise ArgumentError.new(format('wrong type. user \\'team_id\\' must be an String (for an Team name) or an Integer (for an Team Id), given \\'%s\\'', team_id.class.to_s))\n end\n raise ArgumentError.new('missing \\'team_id\\'') if( team_id.size.zero? )\n\n v, mv = version.values\n return { 'status' => 404, 'message' => format( 'team has been supported in Grafana since version 5. you use version %s', v) } if(mv < 5)\n\n if(team_id.is_a?(String))\n o_team = search_team(name: team_id)\n status = o_team.dig('status')\n total_count = o_team.dig('totalCount')\n\n return { 'status' => 404, 'message' => format( 'No Team \\'%s\\' found', team_id) } unless(status == 200 && total_count > 0)\n\n teams = o_team.dig('teams')\n team = teams.detect { |x| x['name'] == team_id }\n team_id = team.dig('id')\n end\n\n endpoint = format( '/api/teams/%s', team_id )\n\n @logger.debug(\"Getting team by Id #{team_id} (GET #{endpoint})\") if @debug\n get(endpoint)\n end",
"def show\n @team_test = TeamTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_test }\n end\n end",
"def index\n @team = Team.find(params[:team_id])\n @sprints = @team.sprints.find(:all)\n\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def show\n @nba_team = NbaTeam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nba_team }\n end\n end",
"def teams(org)\n get \"/orgs/#{org}/teams\"\n end",
"def get\n service_response = ManagerManagement::Team::Get.new(params).perform\n return render_api_response(service_response)\n end",
"def index\n @user_teams = UserTeam.all\n end",
"def get_team_details(params)\n get('team', params)\n end",
"def show\n @team=Team.find(params[:id])\n end",
"def index\n @team = Team.find(params[:team_id])\n @players = @team.players\n end",
"def show\n @team = Team.where(:id=>params[:id]).first\n end",
"def get_project_teams(project_id_or_key)\n get(\"projects/#{project_id_or_key}/teams\")\n end",
"def get_teams( org )\n teams = Homework.get(\"/orgs/#{org}/teams\", :headers => @auth)\n teams.each do |team|\n puts team['id']\n end\n end",
"def show\n @teamming = Teamming.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @teamming }\n end\n end",
"def show\n @teammate = Teammate.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @teammate }\n end\n end",
"def index\n @games_teams = GamesTeam.all\n end",
"def get_team_name_by_id(team_id)\n response = parse_api_request(\"#{BASE_URL}teams/team/#{team_id}\")[\"teams\"].values.first[\"name\"]\nend",
"def index\n @teams = Team.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @teams }\n end\n end",
"def index\n @users_teams = UsersTeam.all\n end",
"def get_players_by_team(team_id)\n response = parse_api_request(\"#{BASE_URL}players/2018/#{team_id}\")[\"players\"]\nend",
"def team\n @club = Club.find(params[:id])\n\n respond_to do |format|\n format.html #team.html.erb\n end\n end",
"def show\n @user = User.find(params[:id])\n @teams = TeamPlayer.where(:user_id => params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end",
"def show\n @user_teams = @game.team.user_teams\n end",
"def find(id:)\n request.get(\"#{teamsites_url}/#{id}\")\n end"
] | [
"0.7996014",
"0.7838169",
"0.7667755",
"0.7657437",
"0.76113945",
"0.7591232",
"0.758825",
"0.7579617",
"0.75722426",
"0.7572136",
"0.7572136",
"0.75414246",
"0.7532713",
"0.7532713",
"0.75120324",
"0.75120324",
"0.75120324",
"0.75120324",
"0.7472558",
"0.74704117",
"0.7470195",
"0.73370117",
"0.7311696",
"0.7295985",
"0.7294663",
"0.72875184",
"0.72543615",
"0.7209598",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71553546",
"0.71502715",
"0.7140834",
"0.7101897",
"0.70946467",
"0.7090414",
"0.70859087",
"0.7073245",
"0.7047894",
"0.70299345",
"0.70299345",
"0.7000277",
"0.6969165",
"0.6969165",
"0.69553185",
"0.6940152",
"0.6936311",
"0.69198287",
"0.69128263",
"0.6908827",
"0.6899722",
"0.68950254",
"0.6880371",
"0.6879452",
"0.6868598",
"0.6851805",
"0.68438226",
"0.6832526",
"0.6829368",
"0.68258226",
"0.6823184",
"0.68195516",
"0.6813455",
"0.6809654",
"0.6802575",
"0.6786394",
"0.6765887",
"0.6752096",
"0.6751437",
"0.672934",
"0.6703744",
"0.6700383",
"0.6697917",
"0.66946477",
"0.6693806",
"0.6691867",
"0.6689396",
"0.6683364",
"0.66759473"
] | 0.7753974 | 2 |
POST /teams POST /teams.json | def create
@team = Team.new(params[:team])
if @team.save
render json: @team, status: :created, location: @team
else
render json: @team.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @response = HTTParty.get('http://laxapi.herokuapp.com/api/teams')\n CreateTeamService.new.create_team_objects(@response)\n render :json => {\n :message => \" #{Team.count} teams have been created\",\n status: 200\n }\n end",
"def create\n @team = Team.new(team_params)\n respond_to do |format|\n if @team.save\n format.html { redirect_to '/teams', notice: 'Team was successfully created.' }\n format.json { render :index, status: :created }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team(name, params = {})\n params[:name] = name\n post('teams', params)\n end",
"def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, :notice => 'Team was successfully created.' }\n format.json { render :json => @team, :status => :created, :location => @team }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @team.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_teams\r\n response = HTTParty.get('https://www.balldontlie.io/api/v1/teams')[\"data\"]\r\n response.each do |i|\r\n team = Team.new\r\n \r\n team.full_name = i[\"full_name\"]\r\n team.division = i[\"division\"]\r\n team.conference = i[\"conference\"]\r\n\r\n team.save\r\n\r\n end \r\n end",
"def create\n\t\t@team = Team.new(team_params)\n\n\t\tif @team.save\n\t\t\trender json: @team\n\t\telse\n\t\t\trender json: {\n\t\t\t\terror: {\n\t\t\t\t\tmessage: @team.errors.full_messages.to_sentence\n\t\t\t\t}\n\t\t\t}\n\t\tend\n\tend",
"def create\n @team = Team.new(team_params)\n @leagues = League.all.order(:name)\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team created successfully.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = @race.teams.build team_params\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to [@race, @team], notice: I18n.t(:create, scope: 'messages.crud', model: Team.model_name.human) }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if team.save\n format.html { redirect_to team, notice: 'Team was successfully created.' }\n format.json { render json: team, status: ':created', location: team }\n else\n format.html { render action: 'new' }\n format.json { render json: team.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.create({:name => params[:name], :status => params[:status]})\n\n if request.xhr?\n render :json => @team\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to root_path, notice: 'Team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tTeam.create(params[:team])\n\n\t\tredirect_to teams_path\n\tend",
"def create\n @team = Team.new(params.required(:team).permit!)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team created successfully.' }\n format.json { render :my_team, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = @competition.teams.build(params[:team])\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to competition_team_url(@competition, @team), notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html do\n flash[:notice] = 'Team was successfully created.'\n current_user.is_admin? ? (redirect_to teams_path) : (redirect_to user_teams_path(current_user))\n end\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_team = UserTeam.new(user_team_params)\n\n respond_to do |format|\n if @user_team.save\n format.html { redirect_to @user_team, notice: 'User team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_team }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n respond_to do |format|\n begin\n @team.save!\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n rescue => e\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(params[:team])\n @team.user = current_user\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@team = Team.new(team_params)\n\n\t\trespond_to do |format|\n\t\t\tif @team.save\n\t\t\t\tformat.html { redirect_to @team, notice: 'Team was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @team }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @team.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @swim_team = SwimTeam.new(params[:swim_team])\n\n respond_to do |format|\n if @swim_team.save\n format.html { redirect_to swim_teams_path(), notice: 'Swim team was successfully created.' }\n format.json { render json: @swim_team, status: :created, location: @swim_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @swim_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n define_team_user\n end",
"def create\n @games_team = GamesTeam.new(games_team_params)\n\n respond_to do |format|\n if @games_team.save\n format.html { redirect_to @games_team, notice: 'Games team was successfully created.' }\n format.json { render :show, status: :created, location: @games_team }\n else\n format.html { render :new }\n format.json { render json: @games_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n @team.users << current_user\n\n respond_to do |format|\n if @team.save\n setup_team(@team)\n format.html { redirect_to user_root_url, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n \t\t\t@team = Team.new team_params\n\n \t\t\tif @team.save\n\n \t\t\t\trender json: @team,status: :created\n\n \t\t\telse\n\n \t\t\t\trender json: {error: true,errors: @team.errors},status: :unprocessable_entity\n\n \t\t\tend\n\n \t\tend",
"def create\n @ultimate_team = UltimateTeam.new(params[:ultimate_team])\n\n respond_to do |format|\n if @ultimate_team.save\n format.html { redirect_to @ultimate_team, notice: 'Ultimate team was successfully created.' }\n format.json { render json: @ultimate_team, status: :created, location: @ultimate_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ultimate_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(_team)\n # stub\n end",
"def create\n @my_team = MyTeam.new(my_team_params)\n\n respond_to do |format|\n if @my_team.save\n format.html { redirect_to @my_team, notice: 'My team was successfully created.' }\n format.json { render :show, status: :created, location: @my_team }\n else\n format.html { render :new }\n format.json { render json: @my_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def teams\n render json: @team_query\n end",
"def create\n puts \"IN CREATE ACTION\"\n if(current_user.role == \"guest\")\n redirect_to login_url and return\n end\n @coaches = Coach.all\n @divisions = Division.all\n @organizations = Organization.all\n @students = Student.all\n @team = Team.new(team_params)\n\n unless current_user.coach.nil?\n @team_organization = current_user.coach.organization\n #@team_name = @team.organization.short_name + \" \" + (@team.organization.teams.count+1).to_s\n @team.organization_id = @team_organization.id\n #@team.name = @team_name\n end\n\n puts \"TEAM IS #{@team.valid?} -- #{@team.to_yaml}\"\n \n respond_to do |format|\n if @team.save\n params[:team][:student_teams_attributes].each do |sta|\n st = StudentTeam.new\n puts \"PREVIEW -- #{@team.id} :: #{sta[1][1]}\"\n # @team.student_teams.each do |st|\n st.team_id = 86\n st.student_id = sta[1][1]\n if st.save\n puts \"StudentTeam ID: #{st.id}\"\n else\n puts \"FAIL\"\n end\n end\n format.html { redirect_to edit_team_url(@team), notice: 'Team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.find_by_name(params[:team][:team_name])\n if @team.nil?\n @team = Team.new(captain_id: params[:team][:captain_id],\n\t\t team_name: params[:team][:team_name])\n\n respond_to do |format|\n if @team.save\n format.json { render json: @team, status: :created, location: @team }\n if params[:players]\n \tTeamPlayers.create(params[:players], team_name: @team.name)\n end\n else\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n else \n Team.update(params[:team])\n end\n end",
"def create\n\t\t# league admin can add\n\t\t# anyone can add (own team) as pending iff league is addable\n\t\tds = DivisionSeason.find params[:division_season_id]\n\t\tteam = Team.find team[:team_id]\n\n\t\tif can? :manage_teams, ds\n\t\t\tTeamDSService.add_team(ds, team)\n\t\telse\n\t\t\tauthorize! :add_team, ds\n\t\t\tTeamDSService.add_pending_team(ds, team)\n\t\tend\n\n\t\trespond_with tdsr\n\tend",
"def create\n @team = current_user.teams.new(team_params)\n @league = League.find_by(id: params[:league_id])\n @team.league = @league\n if @team.save\n LeagueInvite.where(email: current_user.email, league: @league).destroy_all\n flash[:success] = \"Added team to league\"\n if @league.teams.count == 10 && current_season = Season.current.first\n if LeagueSeason.where(league: @league, season: current_season).count == 0\n LeagueSeason.create(league: @league, season: current_season)\n end\n end\n redirect_to league_players_path(@league)\n else\n render action: :new\n end\n end",
"def create\n match_day_team = MatchDayTeam.new(match_day_team_params)\n if match_day_team.save\n render json: match_day_team, status: 201, location: [:api, match_day_team]\n else\n failed_to_create(match_day_team, \"match_day_team\")\n end\n end",
"def create\n @users_team = UsersTeam.new(users_team_params)\n\n respond_to do |format|\n if @users_team.save\n format.html { redirect_to @users_team, notice: 'Membro adicionado com sucesso.' }\n format.json { render :show, status: :created, location: @users_team }\n else\n format.html { render :new }\n format.json { render json: @users_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n respond_to do |format|\n if @team.save\n # current_game.users.push(@team)\n format.html { redirect_to teams_path, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @team.save\n flash[:notice] = 'Team was successfully created.'\n @changed << @team.id\n \n format.html { redirect_to teams_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { render json: @team, status: :created, location: @team }\n else\n format.html { render action: 'new', template: 'shared/new' }\n format.js { render 'team'; flash.discard }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @team = @competition.teams.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def create_user_team(name, path)\n post(\"/user_teams\", :body => {:name => name, :path => path})\n end",
"def index\n @teams = Team.all\n render json: @teams\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@team = Team.new(team_params)\n\n\t\trespond_to do |format|\n\t\t\tif @team.save\n\t\t\t\tformat.html do\n\t\t\t\t\t# Add current user to team.\n\t\t\t\t\tmembership = Membership.new\n\t\t\t\t\tmembership.user_id = current_user.id\n\t\t\t\t\tmembership.team_id = @team.id\n\t\t\t\t\tmembership.started_at = DateTime.now\n\n\t\t\t\t\tredirect_to @team, notice: \"Team was successfully created.\", alert: (membership.save ? nil : \"Could not join created team.\")\n\t\t\t\tend\n\t\t\t\tformat.json { render action: \"show\", status: :created, location: @team }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @team.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @mens_team = MensTeam.new(mens_team_params)\n\n respond_to do |format|\n if @mens_team.save\n format.html { redirect_to @mens_team, notice: 'Mens team was successfully created.' }\n format.json { render :show, status: :created, location: @mens_team }\n else\n format.html { render :new }\n format.json { render json: @mens_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @event_team = EventTeam.new(event_team_params)\n\n respond_to do |format|\n if @event_team.save\n format.html { redirect_to @event_team, notice: 'Event team was successfully created.' }\n format.json { render :show, status: :created, location: @event_team }\n else\n format.html { render :new }\n format.json { render json: @event_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new\n @team.name = team_params[:name]\n @team.captain = current_user\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n authorize @team\n current_user.update team: @team\n\n respond_to do |format|\n if @team.persisted?\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n student_ids = params[:student_ids].to_a\n student_ids.each_with_index do |student_id|\n student = Student.where(id: student_id.to_i).first\n @team.students << student\n end\n end",
"def create\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n # create team\n team = Team.create(name: params[:team_name], course: $selected_course)\n\n # add students to teams\n student_ids = params[:student_ids]\n student_ids.each do |student_id|\n StudentTeam.create(student_id: student_id, team: team)\n end\n\n render json: { success: true }\n end",
"def create\n @team = Team.new(team_params)\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: \"Team was successfully created.\" }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n newTeam = TeamMemberRelation.new()\n newTeam.team_id = @team.id\n newTeam.user_id = session[:user]\n newTeam.team_role_id = 1\n newTeam.save\n end",
"def create\n @admin_team = Team.new(admin_team_params)\n\n respond_to do |format|\n if @admin_team.save\n format.html { redirect_to admin_teams_url, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @admin_team }\n else\n format.html { render :new }\n format.json { render json: @admin_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team_member\n clinics = params[:clinics].split(\", \")\n\n team_member = TeamMember.create(\n email: params[:email],\n first_name: params[:first_name],\n last_name: params[:last_name],\n user: params[:user],\n status: \"Active\",\n role: params[:role]\n )\n\n clinics.each do |clinic|\n Clinic.find(clinic).team_members << team_member\n end\n\n render json: team_member, include: ['clinics']\n end",
"def create\n @team = Team.new(team_params)\n if @team.save\n flash[:notice] = \"Team successfully created\"\n redirect_to teams_url\n else\n render \"new\"\n end\n end",
"def create\n @team = Team.new(team_params)\n @team.slug = @team.name.downcase.gsub(\" \", \"-\")\n\n @team.community_rating = 0\n\n # Set default picture url\n if [email protected]_url\n @team.picture_url = 'https://d13yacurqjgara.cloudfront.net/users/205424/screenshots/1953810/pandamoniumshot.png'\n end\n\n @user = User.find(session[:session_key])\n\n respond_to do |format|\n if @team.save\n @team.users.push(@user)\n @team.users\n @team.save\n user_teams = @team.user_teams.find_by(user_id: @user.id)\n user_teams.role = params[:role]\n user_teams.status = 1\n user_teams.save!\n\n # TODO: Add game to user profile if it's not already there\n\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n team_name = params[:name]\n description = params[:description]\n\n @okr_team = OkrTeam.new(name: team_name, description: description)\n\n respond_to do |format|\n if @okr_team.save\n format.json { render json: 'Team is created successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end",
"def new\n @teammate = Teammate.new\n @teams = Hackathon.find(params[:hackathon_id]).teams\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teammate }\n end\n end",
"def create_team(opts)\n HelloSign::Resource::Team.new post('/team/create', :body => opts)\n end",
"def create\n @sports_team = SportsTeam.new(sports_team_params)\n\n respond_to do |format|\n if @sports_team.save\n format.html { redirect_to @sports_team, notice: 'Sports team was successfully created.' }\n format.json { render :show, status: :created, location: @sports_team }\n else\n format.html { render :new }\n format.json { render json: @sports_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n\n @membership = Membership.new(team_id: @team.id, player_id: @team.player_id)\n @membership.save\n end",
"def create\n @manage_team = ManageTeam.new(manage_team_params)\n\n respond_to do |format|\n if @manage_team.save\n format.html { redirect_to @manage_team, notice: 'Manage team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @manage_team }\n else\n format.html { render action: 'new' }\n format.json { render json: @manage_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @teams = Team.all\n render :json => @teams\n end",
"def destroy_team\n post('/team/destroy')\n end",
"def destroy_team\n post('/team/destroy')\n end",
"def create\n @users = User.active\n @team = Team.new(team_params)\n @projects = Project.active\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team(opts)\n HelloSign::Resource::Team.new post('/team/create', body: opts)\n end",
"def create\n @sales_team = SalesTeam.new(params[:sales_team])\n\n respond_to do |format|\n if @sales_team.save\n format.html { redirect_to @sales_team, notice: 'Sales team was successfully created.' }\n format.json { render json: @sales_team, status: :created, location: @sales_team }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sales_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def team_params\n params.require(:team).permit(:name, :description, :company_id, :opportunity_ids => [], :team_ids => [])\n end",
"def create\n @ab_team = AbTeam.new(ab_team_params)\n\n respond_to do |format|\n if @ab_team.save\n format.html { redirect_to @ab_team, notice: 'Record was created.' }\n format.json { render :show, status: :created, location: @ab_team }\n else\n format.html { render :new }\n format.json { render json: @ab_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @team = fetch_team\n authorize @team\n @team.owners << current_user\n\n if @team.save\n @team.create_activity(:create,\n owner: current_user,\n parameters: { team: @team.name })\n respond_with(@team)\n else\n respond_with @team.errors, status: :unprocessable_entity\n end\n end",
"def create\n @mission_team = @game.mission_teams.new(mission_team_params)\n\n respond_to do |format|\n if @mission_team.save\n format.html { redirect_to [@game, @mission_team], notice: 'Mission team was successfully created.' }\n format.json { render :show, status: :created, location: @mission_team }\n else\n format.html { render :new }\n format.json { render json: @mission_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @monster_team = MonsterTeam.new(monster_team_params)\n\n respond_to do |format|\n if @monster_team.save\n format.html { redirect_to monster_teams_path, notice: 'Monster team was successfully created.' }\n format.json { render :show, status: :created, location: @monster_team }\n else\n format.html { render :new }\n format.json { render json: @monster_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def new\n @team = Team.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @team }\n end\n end",
"def create\n @team = @project.ae_teams.new(team_params)\n if @team.save\n redirect_to editor_project_ae_team_path(@project, @team), notice: \"Team was successfully created.\"\n else\n render :new\n end\n end",
"def create_teams\n parent = Object.const_get(session[:team_type]).find(params[:id])\n Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)\n undo_link(\"Random teams have been successfully created.\")\n ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)\n redirect_to action: 'list', id: parent.id\n end",
"def create\n unless team_registrable?\n respond_to do |format|\n format.html { redirect_to teams_path, alert: 'Team registration is closed.' }\n format.json { render json: { status: 'closed' } }\n end\n return\n end\n\n @team = Team.new(team_params)\n\n respond_to do |format|\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render action: 'show', status: :created, location: @team }\n else\n format.html { render action: 'new' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_teams\n number_of_teams.to_i.times do |i|\n self.teams << Team.create!(:name => TEAM_NAMES[i])\n end\n end",
"def create\n @team = @organization.teams.build(team_params)\n\n respond_to do |format|\n if @team.save\n current_user.add_role :admin, @team\n format.html { redirect_to @team, notice: 'Team was successfully created.' }\n format.json { render :show, status: :created, location: @team }\n else\n format.html { render :new }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_team\n new_team_code = genTeamCode(current_user.id)\n team_params = {\n :team_name => params[:teamname],\n :team_code => new_team_code,\n :advisor_users_id => current_user.id,\n }\n team = Team.new(team_params)\n team.save\n\n current_user.update_attribute( :team_name, params[:teamname] )\n current_user.update_attribute( :team_code, new_team_code)\n\n flash.now[:flash] = 'Team Created'\n render '/advisor/index'\n end",
"def new\n @team = Team.new\n @sports = Sport.all\n @levels = Level.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @team }\n end\n end"
] | [
"0.7407396",
"0.7206485",
"0.718551",
"0.7072946",
"0.70231295",
"0.70231295",
"0.70231295",
"0.69917685",
"0.6968914",
"0.6961326",
"0.6925406",
"0.6924325",
"0.69208974",
"0.6915442",
"0.6915442",
"0.6915442",
"0.6915442",
"0.6915442",
"0.6915442",
"0.6915442",
"0.6915442",
"0.691487",
"0.6897012",
"0.6885802",
"0.687426",
"0.6869534",
"0.6854169",
"0.684959",
"0.6833425",
"0.6782249",
"0.6753973",
"0.67536354",
"0.67467177",
"0.67306787",
"0.67260253",
"0.6723977",
"0.6710417",
"0.6708513",
"0.6690854",
"0.667287",
"0.66568995",
"0.6635294",
"0.6629767",
"0.6620084",
"0.66107553",
"0.660151",
"0.6555507",
"0.6544199",
"0.65373826",
"0.6528124",
"0.65230435",
"0.6521845",
"0.65193224",
"0.6517337",
"0.65124",
"0.65102404",
"0.65008736",
"0.64954656",
"0.647791",
"0.64731205",
"0.647152",
"0.6471185",
"0.6464023",
"0.6463967",
"0.6462042",
"0.64516133",
"0.64318794",
"0.6429072",
"0.64185417",
"0.64018047",
"0.6397698",
"0.6388893",
"0.6382905",
"0.6372583",
"0.6368922",
"0.6367536",
"0.6367536",
"0.6365669",
"0.6362158",
"0.6359281",
"0.6341911",
"0.6336048",
"0.63263804",
"0.6309423",
"0.62930655",
"0.62913465",
"0.62913465",
"0.62913465",
"0.62913465",
"0.62913465",
"0.62913465",
"0.62913465",
"0.6291088",
"0.6290849",
"0.6282641",
"0.6273453",
"0.6265422",
"0.6265101",
"0.6255548",
"0.6254365"
] | 0.73516417 | 1 |
PUT /teams/1 PUT /teams/1.json | def update
@team = Team.find(params[:id])
if @team.update_attributes(params[:team])
head :no_content
else
render json: @team.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\t\tteam_id = params[:id]\n\t\t@team = Team.find(team_id)\n\t\tif @team.update(team_params)\n\t\t\trender json: @team\n\t\telse\n\t\t\trender json: {\n\t\t\t\terror: {\n\t\t\t\t\tmessage: @team.errors.full_messages.to_sentence\n\t\t\t\t}\n\t\t\t}\n\t\tend\n\tend",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render json: @team }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params.required(:team).permit!)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_team\n @team.update(team_params)\n end",
"def update\n respond_to do |format|\n @team.name = team_params[:name]\n if @team.save\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, :notice => 'Team was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @team.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, :notice => 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @team.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, :notice => 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @team.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_team(id, team_name, options={})\n options.merge!(:name => team_name)\n patch \"/teams/#{id}\", :body => options\n end",
"def update\n team_name = params[:name]\n team_description = params[:description]\n team_id = params[:id]\n\n respond_to do |format|\n if OkrTeam.where(id: team_id).update_all(name: team_name, description: team_description)\n format.json { render json: 'Team is updated successfully!', status: :ok }\n else\n format.json { render json: 'Error!', status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = @club.teams.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to club_path(@club), notice: 'Mannschaft wurde aktualisiert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_team\n \n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to competition_team_url(@competition, @team), notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to organization_teams_path(@team.organization_id), notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tteam = Team.find(params[:id])\n\t\tteam.update_attributes(params[:team])\n\n\t\tredirect_to teams_path\n\tend",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to teams_path, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_team\n @team = Team.where(\"id=?\",params[:id]).first\n\n unless @team.present? \n render json:{ status: :error, data: \"team is not find\" }\n\n end\n end",
"def update\n @league = League.find(params[:league_id])\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @team = Team.find(params[:team][:team_id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n if params[:players]\n TeamPlayers.update(params[:players], team_name: @team.name)\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: \"Team was successfully updated.\" }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_team(opts)\n HelloSign::Resource::Team.new post('/team', :body => opts)\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to [@race, @team], notice: I18n.t(:update, scope: 'messages.crud', model: Team.model_name.human) }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_team(opts)\n HelloSign::Resource::Team.new post('/team', body: opts)\n end",
"def update\n @club = Club.find_by_slug(params[:club_id])\n @team = @club.teams.find_by_name(params[:id].upcase)\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to([@club, @team], :notice => 'Team was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to league_team_path, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if team.update(team_params)\n format.html { redirect_to team, notice: 'Team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: team.errors, status: ':unprocessable_entity' }\n end\n end\n end",
"def update\n\n if @team.update(team_params)\n\n render json: @team,status: :ok\n\n else\n\n render json: {error: true,errors: @team.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def update\n @ultimate_team = UltimateTeam.find(params[:id])\n\n respond_to do |format|\n if @ultimate_team.update_attributes(params[:ultimate_team])\n format.html { redirect_to @ultimate_team, notice: 'Ultimate team was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ultimate_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to user_root_url, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if :opr == 'edit'\n update\n else\n @team = Team.find_by_id(params[:id])\n @team.update_attributes({:id => params[:id], :name => params[:name], :status => params[:status]})\n\n if request.xhr?\n render :json => @team\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n define_team_user\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n flash[:success] = 'Team was successfully updated.'\n format.html { redirect_to @team}\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @swim_team = SwimTeam.find(params[:id])\n\n respond_to do |format|\n if @swim_team.update_attributes(params[:swim_team])\n format.html { redirect_to swim_teams_path(), notice: 'Swim team was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @swim_team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_team\n @team = @resource = Team.find(params[:id])\n end",
"def update\n @team = Team.find(params[:id])\n\n respond_to do |format|\n if @team.update_attributes(params[:team])\n format.html { redirect_to(@team, :notice => 'Team was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @team.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def update\n\n respond_to do |format|\n ap @team.name\n ap @categorys = Category.where(:team => @team.name)\n ap @admin_tasks = AdminTask.where(:team => @team.name)\n ap @eadmin_tasks = EadminTask.where(:team => @team.name)\n ap @users = User.where(:user_info => @team.name)\n\n if @team.update(team_params)\n ap @team.name\n @admin_tasks.update_all(:team => @team.name )\n @eadmin_tasks.update_all(:team => @team.name )\n @categorys.update_all(:team => @team.name )\n @users.update_all(:user_info => @team.name )\n\n\n format.html { redirect_to team_path, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @team.update(team_params)\n format.html { redirect_to @team, notice: 'Team was successfully updated.' }\n format.json { render :show, status: :ok, location: @team }\n else\n format.html { render :edit }\n format.json { render json: @team.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end",
"def set_team\n @team = Team.find(params[:id])\n end"
] | [
"0.7076347",
"0.6961297",
"0.6920335",
"0.6880125",
"0.6868699",
"0.6859074",
"0.6833043",
"0.6833043",
"0.6833043",
"0.6833043",
"0.6833043",
"0.6833043",
"0.68301904",
"0.68301904",
"0.68177104",
"0.67880267",
"0.667999",
"0.6662356",
"0.6653315",
"0.6644515",
"0.66386056",
"0.66373855",
"0.66295433",
"0.6593731",
"0.6580349",
"0.65734506",
"0.65724725",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65719974",
"0.65689105",
"0.6547912",
"0.6533836",
"0.6533836",
"0.6529848",
"0.651649",
"0.65154016",
"0.6509323",
"0.650666",
"0.6489534",
"0.64852035",
"0.64733636",
"0.64606357",
"0.6458392",
"0.6444805",
"0.6438982",
"0.6419913",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.641065",
"0.63879395",
"0.6382736",
"0.6374742",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397",
"0.6353397"
] | 0.72277266 | 0 |
DELETE /teams/1 DELETE /teams/1.json | def destroy
@team = Team.find(params[:id])
@team.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = @club.teams.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to club_teams_url(@club.id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ultimate_team = UltimateTeam.find(params[:id])\n @ultimate_team.destroy\n\n respond_to do |format|\n format.html { redirect_to ultimate_teams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to competition_teams_url(@competition) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_team(id)\n boolean_request :delete, \"/teams/#{id}\"\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to leagues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_team.destroy\n respond_to do |format|\n format.html { redirect_to user_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to view_teams_path, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to league_teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_team\n post('/team/destroy')\n end",
"def destroy_team\n post('/team/destroy')\n end",
"def delete(_team)\n # stub\n end",
"def destroy\n @swim_team = SwimTeam.find(params[:id])\n @swim_team.destroy\n\n respond_to do |format|\n format.html { redirect_to swim_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to user_root_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to team_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manage_team.destroy\n respond_to do |format|\n format.html { redirect_to manage_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\[email protected]\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to teams_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n\n if @team.destroy\n\n render json: {team: {id: params[:id].to_i}},status: :ok\n\n else\n\n render json: {error: true,errors: @team.errors},status: :unprocessable_entity\n\n end\n\n \t\tend",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to organization_teams_url(@organization), notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team_has_d.destroy\n respond_to do |format|\n format.html { redirect_to team_has_ds_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n (kick and return) if not is_god?\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @team.destroy\n # respond_to do |format|\n # format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to race_teams_url(@race), notice: I18n.t(:destroy, scope: 'messages.crud', model: Team.model_name.human) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_team.destroy\n respond_to do |format|\n format.html { redirect_to my_teams_url, notice: 'My team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n team_id = params[:id]\n status = OkrTeam.remove_team_from_system(team_id)\n\n respond_to do |format|\n if status == 200\n format.json { render json: 'Team is removed successfully from the system!', status: :ok }\n else\n format.json { render json: 'Unable to remove team from system!', status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @nfl_team = NflTeam.find(params[:id])\n @nfl_team.destroy\n\n respond_to do |format|\n format.html { redirect_to nfl_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nba_team = NbaTeam.find(params[:id])\n @nba_team.destroy\n\n respond_to do |format|\n format.html { redirect_to nba_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n allTeamRelation = TeamMemberRelation.where(team_id: @team.id)\n allTeamRelation.each do |r|\n r.destroy\n end\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: \"Team was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ab_team.destroy\n respond_to do |format|\n format.html { redirect_to ab_teams_url, notice: 'Record was destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_team = UserTeam.find(params[:id])\n @user_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team_test = TeamTest.find(params[:id])\n @team_test.destroy\n\n respond_to do |format|\n format.html { redirect_to team_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n authorize @team, :destroy?\n\n @team.destroy\n respond_to do |format|\n format.html { redirect_to root_url(subdomain: ENV[\"DEFAULT_SUBDOMAIN\"]), notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @games_team.destroy\n respond_to do |format|\n format.html { redirect_to games_teams_url, notice: 'Games team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teamstat.destroy\n respond_to do |format|\n format.html { redirect_to teamstats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id]);\n @team.destroy();\n redirect_to(user_path(current_user) + '/teams');\n end",
"def destroy\n match_day_team = MatchDayTeam.find(params[:id])\n match_day_team.destroy\n head 204\n end",
"def destroy\n @tournamentteam.destroy\n respond_to do |format|\n format.html { redirect_to tournamentteams_url, notice: 'Tournamentteam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nhl_team.destroy\n respond_to do |format|\n format.html { redirect_to pool_nhl_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_team.destroy\n respond_to do |format|\n format.html { redirect_to admin_teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n team = @player.team\n @player.destroy\n respond_to do |format|\n format.html { redirect_to team }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n respond_to do |format|\n format.html { redirect_to course_teams_path, notice: 'Team was successfully removed.' }\n end\n end",
"def destroy\n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sales_team = SalesTeam.find(params[:id])\n @sales_team.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @player.destroy\n @teams = @player.teams\n if @teams.exists?\n @teams.each do |t|\n t.destroy\n end\n end\n respond_to do |format|\n format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teammate = Teammate.find(params[:id])\n @teammate.destroy\n\n respond_to do |format|\n format.html { redirect_to teammates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @athletes_team.destroy\n respond_to do |format|\n format.html { redirect_to athletes_teams_url, notice: 'Athletes team was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_team_stat.destroy\n respond_to do |format|\n format.html { redirect_to test_team_stats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n team = Team.find(@users_team.team_id)\n @users_team.destroy\n respond_to do |format|\n format.html { redirect_to team_path(team), notice: 'Membro removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sim_team = SimTeam.find(params[:id])\n @sim_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(sim_teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id]).destroy\n flash[:notice] = \"Team successfully deleted\"\n redirect_to teams_url\n end",
"def destroy\n @team = Team.find_by_id(params[:id])\n @team.destroy\n\n if request.xhr?\n render :json => @team\n end\n end",
"def delete_team_with(id)\n visit teams_path\n click_button 'Delete'\n click_button 'OK'\n end",
"def delete()\n\n Team.destroy(self.id)\n end",
"def destroy\n if (current_user.team_id != @team.id || !current_user.admin?)\n return\n end \n @team.destroy\n respond_to do |format|\n format.html { redirect_to teams_url, notice: 'Team was successfully destroyed.' }\n format.json { head :no_content }\n end\n \n end",
"def delete(team_id)\n @client.team.delete(team_id)\n end"
] | [
"0.7868205",
"0.7819776",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.7807478",
"0.77657557",
"0.77657557",
"0.77657557",
"0.77657557",
"0.77476865",
"0.7617056",
"0.7555221",
"0.75439465",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7524412",
"0.7519429",
"0.75088274",
"0.7507463",
"0.75025505",
"0.74852633",
"0.74754584",
"0.74754584",
"0.7472454",
"0.74715775",
"0.74499106",
"0.7448884",
"0.7448884",
"0.7448884",
"0.7448884",
"0.7448884",
"0.7445441",
"0.74160564",
"0.74093455",
"0.7398133",
"0.7382918",
"0.73659605",
"0.7360807",
"0.73500395",
"0.7347468",
"0.7335934",
"0.7323845",
"0.7322313",
"0.7316011",
"0.7311703",
"0.73080206",
"0.73073286",
"0.7302544",
"0.72952795",
"0.72951007",
"0.72759116",
"0.7265425",
"0.7259331",
"0.72494084",
"0.7239291",
"0.72386765",
"0.72213286",
"0.7215611",
"0.7212721",
"0.71961856",
"0.7195722",
"0.71913254",
"0.71571153",
"0.71525866",
"0.71507204",
"0.71454084",
"0.7132882",
"0.71315974",
"0.7131328",
"0.71265703",
"0.7117115",
"0.7104823"
] | 0.75655633 | 20 |
todo : fix ImageRecognition::ImageLoader saving image place it into ram | def initialize(document)
@document = document
image_uri = ImageRecognition::ImageUriParser.parse(document)
ImageRecognition::ImageLoader.save_image(image_uri)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_image_enhenced\n file_name = \"#{Rails.root}/tmp/temp-#{self.id}.jpg\"\n\n open(file_name, 'wb') do |file|\n file << open(self.image_uncompressed.url).read\n end\n\n image = OpenCV::Cv::Mat.new\n image = OpenCV::Cv::imread file_name\n\n image.convertTo(image, -1, 1.4, 30)\n\n photo = OpenCV::Cv::imwrite \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\", image\n\n file = File.open \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\"\n\n self.image_enhenced = file\n\n begin\n self.save!\n rescue CarrierWave::ProcessingError => error\n raise error.cause\n end\n\n self.exam.check_for_enhenced\n end",
"def add_image \n image = CARMD.image(self.vin)\n if image == \"\"\n image = \"http://clipart-library.com/img/2050778.png\"\n end\n self.auto_image = image \n self.save \n end",
"def to_jpg\n load_image\n end",
"def update_image image\n temp_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n filename = File.basename(temp_path)\n image.image_number = @img_count\n\n @img_count += 1\n if temp_path.blank?\n InputBatch::Log.status_log.error \">>>>>>>>Image #{filename} not found<<<<<<<<<\"\n puts \">>>>>>>>>>>>Image #{filename} not found\"\n InputBatch::Log.error_log.error \"Error on line #{@row_index} : Image #{filename} not found\"\n else\n InputBatch::Log.status_log.info \"Image #{filename} found\"\n image.page_count = %x[identify #{temp_path}].split(filename).length-1 rescue nil\n end\n\n rename_image image if facility.index_file_parser_type == \"WellsFargo_bank\"\n return image\n end",
"def update_imagem(foto_64)\n foto_64 = \"data:image/jpeg;base64,#{foto_64}\"\n if foto_64 != \"\" && foto_64 != nil\n base_64_encoded_data = foto_64\n string_img = Base64.decode64(base_64_encoded_data['data:image/png;base64,'.length .. -1])\n File.open(\"#{Rails.root}/tmp/motorista2.jpg\", \"wb\") do |file| \n file.write(string_img)\n file.size\n self.imagem = file\n end\n end\n end",
"def set_img\n\n end",
"def prepare_image_apria\n images = []\n if @sitecode == \"00Q49\" # site code for DAP\n single_page_images = convert_multipage_to_singlepage\n single_page_images.each_with_index do |image_file, index|\n new_file_name = rename_image_for_dap(image_file, index)\n File.rename(image_file, new_file_name)\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n image = ImagesForJob.new :image => File.open(\"#{new_file_name}\",\"rb\")\n image.image_file_name = File.basename(new_file_name)\n image.is_splitted_image = true\n image = update_image image\n images << image\n end\n else\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n image.image = File.open(image_path, \"rb\")\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count, :is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n images << image\n end\n end\n return images\n end",
"def image; end",
"def scanned_image\n scanned_retreat\n end",
"def images; end",
"def camera_callback\n @image = Image.find(:all)\n if @image.size > 0\n @image.each do |img|\n img.destroy\n end\n end\n if @params['status'] == 'ok'\n image = Image.new({'image_uri' => @params['image_uri']})\n image.save\n WebView.execute_js('showImage(\"'+Rho::RhoApplication::get_blob_path(image.image_uri)+'\");')\n end\n end",
"def load_image(path)\n end",
"def sepia\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.sepiatone()\n img.write('public' + @photo.attachment_url)\n end",
"def proxy_image\n multiresimage = Multiresimage.find(params[:id])\n img_length = params[:image_length]\n\n begin\n if multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i <= params[:image_length].to_i\n img_length = multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i-1\n end\n rescue Exception\n #this is a fix so that smaller images get shown. Currently, they break since larger versions do not exist.\n end\n\n default_image = File.open(\"app/assets/images/site/missing2.png\", 'rb') do |f|\n f.read\n end\n filename = \"missing2.png\"\n resp = ''\n\n if can?(:read, multiresimage)\n\n Net::HTTP.start(DIL_CONFIG['dil_fedora_base_ip'], DIL_CONFIG['dil_fedora_port']) { |http|\n resp = http.get(\"#{DIL_CONFIG['dil_fedora_url']}#{params[:id]}#{DIL_CONFIG['dil_fedora_disseminator']}#{img_length}\")\n #open(\"/usr/local/proxy_images/#{params[:id]}.jpg\" ,\"wb\") { |new_file|\n #new_file.write(resp.body)\n #send_file(new_file, :type => \"image/jpeg\", :disposition=>\"inline\")\n #send data uses server memory instead of storage.\n if(resp.body.include? \"error\")\n image = default_image\n else\n image = resp.body\n filename = \"#{params[:id]}.jpg\"\n end\n send_data(image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n }\n #}\n else\n send_data(default_image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n end\n end",
"def process_image_grey_scale\n file_name = \"#{Rails.root}/tmp/temp-#{self.id}.jpg\"\n\n open(file_name, 'wb') do |file|\n file << open(self.image_uncompressed.url).read\n end\n\n image = OpenCV::Cv::Mat.new\n image = OpenCV::Cv::imread file_name\n\n OpenCV::Cv::cvtColor(image, image, OpenCV::Cv::COLOR_BGR2GRAY)\n\n photo = OpenCV::Cv::imwrite \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\", image\n\n file = File.open \"#{Rails.root}/tmp/black_and_white-#{self.id}.png\"\n\n self.image_grey_scale = file\n\n begin\n self.save!\n rescue CarrierWave::ProcessingError => error\n raise error.cause\n end\n\n self.exam.check_for_grey_scale\n end",
"def image\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n _size = File.size(uploaded_io)\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n redirect_to(@sys_image) \n end",
"def render_flex_image(img)\r\n img.to_jpg!\r\n send_data(img[img.class.binary_column], :type => 'image/jpeg', :disposition => 'inline')\r\n GC.start\r\n end",
"def store_image\n if @file_data\n FileUtils.mkdir_p Img_Store\n File.open(image_filename, 'wb') do |f|\n f.write (@file_data.read)\n end\n @file_data = nil\n end\n end",
"def create\n @image = Image.new(image_params)\n @image.text = ''\n respond_to do |format|\n if @image.save\n @image.text = RTesseract.new(Rails.root.join('public', 'assets', @image.id.to_s, @image.url.file.filename).to_s, lang: 'eng+khm', :processor => \"none\")\n @image.update(image_params)\n format.html { redirect_to @image, notice: 'Image was successfully created.' }\n format.json { render :show, status: :created, location: @image }\n else\n format.html { render :new }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def download_image\n if self.image_source_changed? && !self.image_source.empty?\n self.image = open(self.image_source)\n end\n end",
"def generate_images\n Docsplit.extract_images(@files.to_s)\n end",
"def prepare_image\n images_for_job = []\n images = []\n @images_from_index = row.slice(config['IMAGE']['image_file_name'][0]..-1).compact\n @images_from_index = @images_from_index.collect{|file| file.include?('.') ? \\\n file: file + \".#{@image_ext}\"}\n # identifying check and envelop images\n @check_image, @envelop_image = call_parser_specific_method \"prepare_check_and_envelop_images\" if @version == 'BANK_OF_AMERICA' and facility.index_file_parser_type != \"Apria_bank\"\n envelop_image_to_loaded = (@envelop_image.upcase)[0...-4].split(\"_\") unless @envelop_image.blank?\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n @images_from_index.each do |file_name|\n unless @hash_envelop_images.has_key?(\"#{file_name}\")\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == file_name.upcase}\n images_for_job << @image_folder.select{|file| file_name[0...-4] + \"B\" == File.basename(file)[0...-4].upcase}\n \n else\n unless @envelop_image.blank?\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == @envelop_image.upcase ||\n File.basename(file)[0...-4].upcase == @envelop_image.upcase[0...-4] +'B'}\n if envelop_image_to_loaded.size == 2\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n images_for_job << @image_folder.select{|file| File.basename(file)[0...-4].upcase == envelop_image_to_loaded[0]+'B_'+ envelop_image_to_loaded[1]}\n end\n end\n end\n end\n images_for_job.flatten!\n # @initial_image_name = images_for_job[0]\n multi_page_facilities = ['CHRISTIAN HOSPITAL LABORATORY','GENOPTIX MEDICAL LABORATORY']\n images_for_job = convert_single_page_to_multipage(images_for_job) if multi_page_facilities.include? facility.name.strip.upcase\n f = nil\n images_for_job.each_with_index do |image_name,img_count|\n f = File.open(\"#{image_name}\",\"rb\")\n image = ImagesForJob.new(:image => f)\n parse_values(\"IMAGE\", image, File.basename(image_name))\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n # initial_image = images_for_job[0]\n @initial_image_name = image_file_name if img_count == 0\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n image.save\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count,:is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n # image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n image.save\n images << image\n end\n f.close\n end\n return images\n end",
"def process_image path, placement = {}\n p 'Generating propeller data...'\n @propeller_data = @propeller_processor.process path, placement\n\n p 'Generating preview...'\n @preview = @preview_processor.generate @propeller_data\n\n @interface.processed @preview\n end",
"def image_hash; end",
"def prepare_image\n images = []\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n @multi_page_image_name = image.image_file_name.strip\n image_name = image.image_file_name.strip.split(\".\").first\n @job_images = Dir.glob(\"#{@location}/**/#{image_name}.*\", File::FNM_CASEFOLD)\n @job_images.sort!\n convert_single_page_to_multipage\n Dir.glob(\"#{@location}/**/images\")\n image = ImagesForJob.new(:image_file_name=>\"#{@multi_page_image_name}\")\n images,@initial_image_name = InputBatch.convert_multipage_to_singlepage(image,@location,@img_count)\n return images\n end",
"def process_cover_qrcode(cover, qrcode_path)\n @image = Magick::ImageList.new(\"#{Rails.root}/public/images/flyers/qrcode-with-image.jpg\")\n\n insert_image(\n full_path: \"#{Rails.root}/public#{qrcode_path}\",\n width: 415, height: 415,\n longitude: 823, latitude: 212\n )\n\n if Rails.env.development?\n cover_full_path = \"#{Rails.root}/public#{cover}\"\n else\n cover_full_path = \"#{cover}\"\n end\n\n if cover_full_path.present?\n insert_image(\n full_path: cover_full_path,\n width: 750, height: 750,\n longitude: 40, latitude: 40\n )\n end\n\n image.format = 'jpeg'\n self\n end",
"def stream_image(headers, index, is_retina)\n image_option = selected_image_at_index index.to_i\n return nil if image_option.nil?\n\n image_file_name = \"#{image_option['path']}\"\n image_file_name.gsub! /\\.png/i, '@2x.png' if (is_retina.to_i >= 1)\n image_file_path = \"#{@assets_path}/images/#{image_file_name}\"\n\n read_file headers, image_file_path, 'image/png'\n end",
"def get_timage_from_yd\n if (params['gid'].nil?)\n txt = \"\"\n else\n user = User.find_by_sql(\"select id, dh, yxmc, jm_tag,width,height from timage where id=#{params['gid']};\")\n dh,width,height = user[0]['dh'], user[0]['width'], user[0]['height']\n\n if !File.exists?(\"./dady/img_tmp/#{dh}/\")\n system\"mkdir -p ./dady/img_tmp/#{dh}/\" \n end\n \n convert_filename = \"./dady/img_tmp/#{dh}/\"+user[0][\"yxmc\"].gsub('$', '-').gsub('TIF','JPG').gsub('tif','JPG')\n local_filename = \"./dady/img_tmp/#{dh}/\"+user[0][\"yxmc\"].gsub('$', '-')\n\n if !File.exists?(local_filename)\n user = User.find_by_sql(\"select id, dh, yxmc, jm_tag from timage where id=#{params['gid']};\")\n im_data = get_image_by_gid(params['gid'])\n\n tmpfile = rand(36**10).to_s(36)\n ff = File.open(\"./tmp/#{tmpfile}\",'w')\n ff.write(im_data)\n ff.close\n puts \"./tmp/#{tmpfile} #{local_filename}\"\n if (user[0]['jm_tag'].to_i == 1)\n system(\"decrypt ./tmp/#{tmpfile} #{local_filename}\")\n else\n system(\"scp ./tmp/#{tmpfile} #{local_filename}\")\n end \n system(\"rm ./tmp/#{tmpfile}\")\n end\n \n system(\"convert '#{local_filename}' '#{convert_filename}'\")\n if (convert_filename.upcase.include?'JPG') || (convert_filename.upcase.include?'TIF') || (convert_filename.upcase.include?'TIFF') || (convert_filename.upcase.include?'JPEG') \n imagesize=FastImage.size convert_filename\n \n if imagesize[0].to_i > imagesize[1].to_i\n txt = \"/assets/#{convert_filename}?2\"\n else\n txt = \"/assets/#{convert_filename}?1\"\n end\n else\n txt = \"/assets/#{convert_filename}?2\"\n end\n archive= User.find_by_sql(\"select * from archive where dh='#{dh}';\")\n set_rz(archive[0]['mlh'],'','','','影像查看',params['userid'],user[0][\"yxmc\"],user[0][\"yxmc\"],dh)\n end\n render :text => txt\n end",
"def load_image\n Magick::Image.from_blob(data).first\n end",
"def image\n TmdbImage.new(@imdb_id.gsub(/^tt/, ''), @api_key, @logger, @filespec) rescue nil\n end",
"def img\n return @img unless @img.nil?\n _pos = @_io.pos\n @_io.seek(ofs_img)\n @img = @_io.read_bytes(len_img)\n @_io.seek(_pos)\n @img\n end",
"def image\n\n end",
"def prepare_image\n images = []\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n images,@initial_image_name = InputBatch.convert_multipage_to_singlepage(image,@location,@img_count)\n return images\n end",
"def extract_graphic\n if !Cache.screenshot(@save_number, header).nil?\n bitmap_screenshot = Cache.screenshot(@save_number, header)\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n else @virtualb = DataManager.load_screenshot(@save_number)\n if @virtualb.nil?\n bitmap_screenshot = black_bitmap\n else\n bitmap_screenshot = @virtualb.get_bitmap\n @screenshot.zoom_x = 2\n @screenshot.zoom_y = 2\n Cache.add_screenshot(@save_number, bitmap_screenshot, header[:key])\n end\n end\n @screenshot.bitmap = bitmap_screenshot\n @screenshot_loaded = false\n @loading_bar.disappear\n end",
"def se\r\n db = ITestUtils.newdb\r\n db.store(test_image1,:name => 'orig-1.jpg' )\r\n db.fetch('orig-1.jpg',:width => 102)\r\n db.store(test_image1,:name => 'notfound-1.jpg' )\r\n db.store(test_image1,:name => 'notfound-2.jpg' )\r\n db\r\n end",
"def set_preview()\n temporal = get_random_dir()\n FileUtils::mkdir_p \"./temp/#{temporal}\"\n\n File.open(\"./temp/#{temporal}/#{@name}\", 'wb') do |f|\n f.write(Base64.decode64(@data))\n f.close\n end\n\n img = ImageList.new(\"./temp/#{temporal}/#{@name}\")\n width, height = 150, 150\n thumb = img.resize_to_fit(width, height)\n thumb.write(\"./temp/#{temporal}/thumb_#{@name}\")\n img.destroy!\n thumb.destroy!\n GC.start\n\n f_thumb = File.open(\"./temp/#{temporal}/thumb_#{@name}\", 'rb')\n thumb_s = f_thumb.read\n encoded_string = Base64.strict_encode64(thumb_s)\n f_thumb.close\n\n @preview = encoded_string\n\n FileUtils.rm_rf(Dir.glob('./temp/#{temporal}/*'))\n FileUtils.rm_rf('./temp/#{temporal}/')\n true\n end",
"def image\n end",
"def image\n end",
"def image\n Pathname.new(\"#{PATH}#{self.path}\").open{|file|\n return Base64.strict_encode64(file.read)\n }\n end",
"def extract_exif_data\n #if !self.address.blank? && !self.latitude.blank? && !self.longitude.blank? \n if self.address.blank? && !image.blank? \n logger.debug(\"start extract_exif_data\")\n logger.debug(\"session id = #{id}\")\n logger.debug(\"image = #{image}\")\n logger.debug(\"image.url = #{image.url}\")\n logger.debug(\"image.current_path = #{image.current_path}\")\n logger.debug(\"image.identifier = #{image.identifier}\")\n #logger.debug(\"full path to image = #{Rails.root.join(\"public\", image)}\")\n \n logger.debug(\"extract_exif_data debug point a\")\n #img = Magick::Image.read(image)[0] rescue nil\n #img = Magick::Image.read(Rails.root.join(\"public\", image.url))[0]\n img = Magick::Image.read(image.current_path)[0]\n\n logger.debug(\"extract_exif_data debug point aa img = #{img}\")\n\n return unless img\n self.image_created_at = img.get_exif_by_entry('DateTime')[0][1] rescue nil\n\n logger.debug(\"extract_exif_data debug point b\")\n\n img_lat = img.get_exif_by_entry('GPSLatitude')[0][1].split(', ') rescue nil\n logger.debug(\"img_lat = #{img_lat}\")\n img_lng = img.get_exif_by_entry('GPSLongitude')[0][1].split(', ') rescue nil\n logger.debug(\"img_lng = #{img_lng}\")\n\n lat_ref = img.get_exif_by_entry('GPSLatitudeRef')[0][1] rescue nil\n logger.debug(\"lat_ref = #{lat_ref}\")\n lng_ref = img.get_exif_by_entry('GPSLongitudeRef')[0][1] rescue nil\n logger.debug(\"lng_ref = #{lng_ref}\")\n\n alt_ref = img.get_exif_by_entry('GPSAltitudeRef')[0][1] rescue nil\n logger.debug(\"alt_ref = #{alt_ref}\")\n\n logger.debug(\"extract_exif_data debug point c\")\n\n return unless img_lat && img_lng && lat_ref && lng_ref\n\n logger.debug(\"extract_exif_data debug point d\")\n\n latitude = to_frac(img_lat[0]) + (to_frac(img_lat[1])/60) + (to_frac(img_lat[2])/3600)\n longitude = to_frac(img_lng[0]) + (to_frac(img_lng[1])/60) + (to_frac(img_lng[2])/3600)\n\n latitude = latitude * -1 if lat_ref == 'S' # (N is +, S is -)\n longitude = longitude * -1 if lng_ref == 'W' # (W is -, E is +)\n\n self.latitude = latitude\n self.longitude = longitude\n self.altitude = alt_ref\n \n logger.debug(\"extract_exif_data debug point e\")\n\n if geo = Geocoder.search(\"#{latitude},#{longitude}\").first\n #self.city = geo.city\n #self.state = geo.state\n #self.zipcode = geo.postal_code\n logger.debug(\"extract_exif_data debug point f\")\n #self.address = geo.street + \" \" + geo.city\n self.address = geo.address(format = :full)\n logger.debug(\"geocoded address = #{self.address}\")\n end\n logger.debug(\"end extract_exif_data\")\n end # if \n end",
"def create\n @image = Image.new(image_params)\n @image.ip = ip2long request.remote_ip\n @image.delete_code = (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n @image.homepage = false\n @image.save\n end",
"def proxy_image\n multiresimage = Multiresimage.find(params[:id])\n\n src_width = multiresimage.DELIV_OPS.svg_image.svg_width.first.to_f\n src_height = multiresimage.DELIV_OPS.svg_image.svg_height.first.to_f\n\n # Max size is 1600 pixels or less, because we can't give away higher quality versions I guess!\n max_size = [ params[:image_length].to_i, 1600, src_width, src_height ].min\n\n image_url = multiresimage.image_url(max_size)\n\n if can?(:read, multiresimage)\n begin\n send_data( Net::HTTP.get_response(URI.parse(image_url)).body, type: 'image/jpeg' )\n rescue\n default_image = File.open(\"app/assets/images/site/missing2.png\", 'rb').read\n filename = \"missing2.png\"\n send_data( default_image, disposition: 'inline', type: 'image/jpeg', filename: filename )\n end\n end\n end",
"def initialize(image)\n @image_location = image\n @auto_size = false\n super()\n end",
"def create_image_files_where_needed()\n @file_info.data.each do |line|\n uri, filename = line\n process_file_info(uri, filename)\n end\n end",
"def update_db_record\n img_file = file.to_file\n img = ::Magick::Image::read(img_file).first\n model.height = img.rows\n model.width = img.columns\n \n new_filename = model.imageable.filename( file.extension )\n new_file = file.copy_to(type_dir + new_filename)\n model.url = access_dir + new_filename\n model.save\n end",
"def extract_first_page_images\n #######\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n Docsplit.extract_images(file.path, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"public/#{self.docsplit_dir}\" )\n \n # def store_path(for_file=filename)\n # # File.join([store_dir, full_filename(for_file)].compact)\n # \"#{self.model.class.to_s.underscore}\" + \"/\" + \"#{mounted_as}\" + \"/\" + \"#{self.model.user.uuid.to_s}\" + \"/\" + \"#{self.model.slug}\" + \"/\" + \"#{(version_name || :original).to_s}\" + \"_\" + \"#{self.file.basename}\" + \".jpg\"\n # end\n # if Rails.env.production?\n # document.store!(new_file=\"#{output_path}/200x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/700x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/1000x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # end\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"/tmp/uploads/docsplit/#{model.class.to_s.underscore}/#{model.slug}\")\n\n\n # ::Docsplit.extract_images(self.pdf, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n # if Rails.env.production?\n # # Rename file folders. \n # FileUtils.mv local_output_path + \"160x\", s3_output_path + \"160x\"\n # FileUtils.mv local_output_path + \"700x\", s3_output_path + \"700x\"\n # FileUtils.mv local_output_path + \"1000x\", s3_output_path + \"1000x\"\n # end\n \n true\n # self\n end",
"def save\n if !persisted?\n gps=EXIFR::JPEG.new(@contents).gps\n @location=Point.new(:lng=>gps.longitude,:lat=>gps.latitude)\n @contents.rewind\n\n description = {}\n description[:content_type]='image/jpeg' \n description[:metadata]={:location=>@location.to_hash} \n\n grid_file = Mongo::Grid::File.new(@contents.read,description)\n @id=Photo.mongo_client.database.fs.insert_one(grid_file).to_s\n end \n\tend",
"def load_image(url)\n require 'open-uri'\n temp = Tempfile.new 'split-vertically'\n image = nil\n\n seems_legit = false\n open(temp.path, 'wb') do |file|\n file << open(url).read\n # Images server returns literally \"0\" if no image exists\n seems_legit = file.size > 1\n end\n sleep 0.25 # Let's try to be nice to the images server\n\n Magick::Image.read(temp.path).first if seems_legit\nend",
"def load_image(image)\n @image = Magick::Image.read(image).first\n end",
"def process_file file\n ifile = ImageFile.new file, @options\n throw \"'#{file}' does not contain any image\" unless ifile.loaded?\n puts \"#{ifile.size} images loaded from #{ifile.file_name}\" if @options[:verbose]\n @files << ifile\n# new_pages = []\n ifile.images.each do |image|\n image.info\n @images << image\n# new_pages = image.analyse\n @pages += image.analyse\n image.free_data!\n image.pages.each{|page| page.free_data!}\n end\n=begin\n new_pages.each_with_index do |page, i|\n page.content.fill_invert\n page.threshold!\n page.export_data(\"page-%04d.tif\" % [@page_number_start + @pages.size*@page_number_step + @page_number_step*i])\n page.free_data!\n end\n @images.each {|img| img.free_data!}\n @pages += new_pages\n=end\n end",
"def img\n Magick::Image::read(self.image).first\n end",
"def image(local=1)\n unless cururl.index(Internet_path)\n fail \"You can only do this on a Researchr wikipage\"\n end\n wiki = cururl[22..-1]\n w,dummy = wiki.split(\"?\")\n wikipage = w.gsubs({:all_with => \"_\"}, \":\", \"%3A\", \"%20\").downcase\n\n if local==1\n curfile = File.last_added(\"#{Home_path}/Desktop/Screen*.png\") # this might be different between different OSX versions\n else\n dir = File.last_added_dir(Photostream_path) # this might be different between different OSX versions\n curfile = File.last_added(dir+\"*.JPG\")\n end\n if curfile == nil\n growl(\"No screenshots available\")\n exit\n end\n\n newfilename, pagenum = filename_in_series(\"#{Wiki_path}/data/media/pages/#{wikipage}\",\".png\")\n p newfilename\n if File.exists?(newfilename)\n pbcopy(\"\")\n fail(\"File already exists, aborting!\")\n end\n puts %Q(mv \"#{curfile.strip}\" \"#{newfilename}\")\n `mv \"#{curfile.strip}\" \"#{newfilename}\"`\n if defined?(dir) # if from iCloud\n `rm -rf \"#{dir}\"`\n `sips --resampleWidth 487 #{newfilename}`\n end\n `touch \"#{newfilename}\"` # to make sure it comes up as newest next time we run filename_in_series\n\n pbcopy(\"{{pages:#{wikipage}#{pagenum}.png}}\")\nend",
"def save_image(filename)\n\t\[email protected](filename, :interlace => true)\t\t\n\tend",
"def do_and_save_fits\n\n image_objects = load_or_fit_image_objects\n\n FileInteraction.write_position_data(image_objects, @parameters)\n\n image_objects\n\n end",
"def host\n self.image_path = Base64.encode64(\n SecureRandom.hex(10) + \n Time.now.to_i.to_s).chomp + \".jpg\"\n\n tempfile = Tempfile.new(image_path)\n file_path = tempfile.path\n\n system(\"wget --no-check-certificate \"\\\n \"-U '#{CONFIG[:user_agent]}' '#{orig_image_url}' \"\\\n \"-T 30 -t 3 \"\\\n \"--output-document '#{file_path}'\")\n\n\n if File.exists? file_path\n\n # Store original image\n #\n FileSystem.store(\n image_path,\n open(file_path),\n \"Content-Type\" => \"image/jpeg\",\n \"Expires\" => 1.year.from_now.\n strftime(\"%a, %d %b %Y %H:%M:%S GMT\"))\n\n # Create thumbnail\n #\n image = MiniMagick::Image.open(file_path)\n\n ImageUtilities.reduce_to_with_image(\n image,\n {:width => 180,:height => 180})\n\n FileSystem.store(\n thumbnail_path,\n open(image.path),\n \"Content-Type\" => \"image/jpeg\",\n \"Expires\" => 1.year.from_now.\n strftime(\"%a, %d %b %Y %H:%M:%S GMT\"))\n\n self.is_processed = true\n self.save!\n end\n\n rescue MiniMagick::Invalid => ex\n LoggedException.add(__FILE__,__method__,ex)\n end",
"def update_image_attributes\n if imageable.present?\n self.width, self.height = `identify -format \"%wx%h\" #{url.file.path}`.split(/x/)\n end\n end",
"def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end",
"def load_imageable\n klass = [Entree, Review].detect { |c| params[\"#{c.name.underscore}_id\"] }\n @imageable = klass.find(params[\"#{klass.name.underscore}_id\"])\n end",
"def create\n @image_4ye = Image4ye.upload(image_params[:file].tempfile)\n @mini_image = MiniMagick::Image.read(image_params[:file].tempfile)\n @image = Image.new(image_params)\n @image.url = @image_4ye.url\n @image.width = @mini_image[:width]\n @image.height = @mini_image[:height]\n\n respond_to do |format|\n if @image.save\n format.html { redirect_to images_path, notice: 'Image was successfully created.' }\n format.json { render :show, status: :created, location: @image }\n else\n format.html { render :new }\n format.json { render json: @image.errors, status: :unprocessable_entity }\n end\n end\n end",
"def render_image\n render_image_iterm2\n end",
"def image\n assert_file!\n @image ||= ChunkyPNG::Image.from_file(@path)\n end",
"def image\n return unless object.image.attached?\n\n # object.image.blob.attributes\n # .slice('filename', 'byte_size')\n # .merge(url: image_url)\n # .tap { |attrs| attrs['name'] = attrs.delete('filename') }\n object.image.service_url\n \n end",
"def get_image_bytes(face)\n\t\t\t\t\n\t\t\t\ttexturewriter = Sketchup.create_texture_writer\n\t\t\t\t\n\t\t\t\t# get the extension of the texture filename\n\t\t\t\t#file_name=face.material.texture.filename\n\t\t\t\text = face.material.texture.filename.split('.').last\n\t\t\t\tif (ext == nil)\n\t\t\t\t\t# puts 'face: ' + face.to_s\n\t\t\t\t\t# puts 'face.material: ' + face.material.to_s\n\t\t\t\t\t# puts 'face.material.texture: ' + face.material.texture.to_s\n\t\t\t\t\t# puts 'Extention is not found for texture: \"' + face.material.texture.filename + '\"'\n\t\t\t\t\t# Lev: looks like it's possible to have a valid texture object with an epmty filename string (need to investigate this further).\n\t\t\t\t\t# So we'll just assume it's a jpeg image, since most image loaders rely on tyhe actual header anyway (as opposed to the file extension).\n\t\t\t\t\text = \"jpg\"\n\t\t\t\telse\n\t\t\t\t\text.downcase!\n\t\t\t\tend\n\n\t\t\t\t# create a random file in the tmp directory\n\t\t\t\tn = Random.rand(100000) + 100000\n\t\t\t\tfile = File.join(Dir.tmpdir() , n.to_s + \".\"+ ext)\n\t\t\t\t#puts 'file: ' + file\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# load the texture, and write it to the file (why does this need to be separate operations?)\n\t\t\t\t# todo: put out a feature request so unmangled textures can be read straight into memory\n\t\t\t\tif face.class == Sketchup::Face\n\t\t\t\t\ttexturewriter.load face, true\n\t\t\t\t\ttxtWrt=texturewriter.write face, true, file\n\t\t\t\telse\n\t\t\t\t\ttexturewriter.load face\n\t\t\t\t\ttxtWrt=texturewriter.write face, file\n\t\t\t\tend\n\n\t\t\t\tif txtWrt!=0 # If failed use default texture instead\n\t\t\t\t\text=\"jpg\"\n\t\t\t\t\tdefaultTexture=__dir__+\"/Grey_Texture.jpg\"\n\t\t\t\t\tfile=file.split(\".\").first+\".\"+ext\n\t\t\t\t\tFileUtils.copy(defaultTexture,file)\t\t\t\n\t\t\t\tend\n\n\t\t\t\tif ext != 'jpg' && ext!= 'png'\n\t\t\t\t\ttype=\"png\"\n\t\t\t\t\ttemp_file=MiniMagick::Image.open(file)\n\t\t\t\t\tFile.delete(file)\n\t\t\t\t\ttemp_file.format(type)\t\t\n\t\t\t\t\tfile=temp_file.path\n\t\t\t\t\text=file.split(\".\").last\n\t\t\t\t\text.downcase!\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# read the file into memory\n\t\t\t\tbytes = File.binread(file)\n\t\t\t\t\n\t\t\t\t# we don't need the file, so delete it\n\t\t\t\tFile.delete(file)\n\t\t\t\t\n\t\t\t\treturn ext, bytes\n\t\t\tend",
"def scanned_prof_image\n scanned_prof\n end",
"def process_image(tmp)\n random = 2 + rand(10**24-10)+10\n path =\"public/data/\"\n file = File.join(path, random.to_s + \"-\" + params[:image][:filename].original_filename)\n\t\n\t#check extencion\n\t\text = File.extname(file)\n \tif ext.upcase == \".JPG\"\n \t\textfinal = \".jpg\"\n \t\timagevalid = true\n \telsif ext.upcase == \".JPEG\"\n \t\textfinal = \".jpg\"\n \t\timagevalid = true\n \telsif ext.upcase == \".GIF\"\n \t\textfinal = \".gif\"\n \t\timagevalid = true\n \telsif ext.upcase == \".PNG\"\n \t\textfinal = \".png\"\n \t\timagevalid = true\n \tend\t\n \t\n if imagevalid == true \n\t\n #Subo la imagen original recibida\n FileUtils.cp tmp.path, file\n\t\n\tarchivo_final = uploadoriginal(file,path)\n\t\n\t#utilizo su nombre\n\tfilenamethumb = random.to_s + \"-\" + params[:image][:filename].original_filename\n\t#width desired / ancho deseado\n\tw = 150\n\t#function call / llamada a la funcion\n\thubermann_thumbnail(path, filenamethumb,w,square=true, bw=true, q=99)\n\thubermann_thumbnail(path, filenamethumb,w,square=true, bw=false, q=99)\n\t\n\t\n\tFileUtils.rm file\n\t\n\t\n\[email protected] = archivo_final\n\t#end unless valid image\n\telse\n\[email protected] = nil\n\n\tend\nend",
"def convert_image\n [16, 32, 64, 128].each do |size|\n convert_to_cache(size)\n end\n end",
"def store_home_store_img\n $tracer.trace(__method__)\n return ToolTag.new(img.id(create_ats_regex_string(\"homeImage\")), __method__)\n end",
"def save\n\n properties = {}\n # exif = {}\n # KCGImagePropertyExifDictionary\n # exif[KCGImagePropertyExifUserComment] = 'Image downloaded from www.sheetmusicplus.com'\n # exif[KCGImagePropertyExifAuxOwnerName] = 'www.sheetmusicplus.com'\n if @filetype == :pdf\n CGPDFContextEndPage(@ctx)\n CGContextFlush(@ctx)\n return\n elsif @filetype == :png\n format = NSPNGFileType\n elsif @filetype == :tif\n format = NSTIFFFileType\n properties[NSImageCompressionMethod] = NSTIFFCompressionLZW\n #properties[NSImageCompressionMethod] = NSTIFFCompressionNone\n elsif @filetype == :gif\n format = NSGIFFileType\n #properties[NSImageDitherTransparency] = 0 # 1 = dithered, 0 = not dithered\n #properties[NSImageRGBColorTable] = nil # For GIF input and output. It consists of a 768 byte NSData object that contains a packed RGB table with each component being 8 bits.\n elsif @filetype == :jpg\n format = NSJPEGFileType\n properties[NSImageCompressionFactor] = @quality # (jpeg compression, 0.0 = max, 1.0 = none)\n #properties[NSImageEXIFData] = exif\n end\n cgimageref = CGBitmapContextCreateImage(@ctx) # => CGImageRef\n bitmaprep = NSBitmapImageRep.alloc.initWithCGImage(cgimageref) # => NSBitmapImageRep\n blob = bitmaprep.representationUsingType(format, properties:properties) # => NSConcreteData\n blob.writeToFile(@output, atomically:true)\n true\n end",
"def sequence_images\n \n end",
"def set_image\n @image = Image.find(params[:id]).decorate\n end",
"def path_to_image(source, options = T.unsafe(nil)); end",
"def image_store\n :local_flat\n end",
"def imagemagick?; end",
"def store_images\n self.images.each_key do |k|\n if self.send(\"store_#{k}\") == \"1\"\n if self.send(\"#{k}?\")\n image = Image.new\n image.image = self.send(k).to_file\n image.save\n end\n end\n end\n end",
"def profile_photo\n @profile = Profile.find(:all)\n \n for profile in @profile\n if !profile.profile_image.blank?\n original_image = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/#{File.basename(profile.profile_image)}\"\n # main = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/main/#{File.basename(profile.profile_image)}\"\n submain = RAILS_ROOT + \"/public/profile/profile_image/#{profile.id}/submain/#{File.basename(profile.profile_image)}\"\n image = Magick::ImageList.new(original_image) \n image = image.change_geometry!('171x171!') { |c, r, i| i.resize!(c, r) } \n image.write(submain) \n end \n end\n \n \n end",
"def image()\n @image__\n end",
"def save_image!(rmagick_image, model_image_attr, tmp_filename='custom')\n t_custom = Tempfile.new([tmp_filename, '.jpg'])\n rmagick_image.write(t_custom.path)\n model_image_attr.store!(File.open(t_custom.path))\n send(\"write_#{model_image_attr.mounted_as}_identifier\")\n save # pretty sure we need to save the model\n t_custom\n end",
"def process_image(image_path, output_directory)\n parts = image_path.split(\"/\")\n filename = parts[parts.length - 1]\n image_small_path = output_directory + lowercase_filetype(filename)\n ratio = 0.125\n ratio = 0.071\n command = \"CoreImageTool load my_image #{image_path} \\\n filter my_image CILanczosScaleTransform scale=#{ratio} \\\n store my_image #{image_small_path} public.jpeg\"\n puts \"processing #{image_path} #{image_small_path}\"\n system(command) \n end",
"def load_image(params)\n if params[:file]\n filnamn = params[:file][:filename].split(\".\")\n filnamn[0] = SecureRandom.hex(10)\n @filename = \"#{filnamn[0]}\" + \".\" + \"#{filnamn[1]}\"\n file = params[:file][:tempfile]\n File.open(\"./public/img/#{@filename}\", 'wb') do |f|\n f.write(file.read)\n end\n else\n @filename = nil\n end\n return @filename\n end",
"def robot_image_generator\n img_base_url = 'https://robohash.org/'\n @robot.img_sm = img_base_url + @robot.robot_name + '?size=80x80'\n @robot.img_lg = img_base_url + @robot.robot_name + '?size=300x300'\n end",
"def set_image(image_file_name)\n\t\t\tbegin\n\t\t\t\t@image = ImageList.new(image_file_name)\n\t\t\t\t@file_name = \"#{File.dirname(image_file_name)}/scanned_#{File.basename(image_file_name)}\"\n\t\t\t\[email protected]!(50,50).threshold(MaxRGB*0.55).write(@file_name)\n\t\t\t\t@image = ImageList.new(@file_name)\n\t\t\t\treturn true if scan\n\t\t\t\treturn false\n\t\t\trescue\n\t\t\t\traise InvalidImage, \"Invalid image - could not be processed by RMagick\"\n\t\t\tend\n\t\tend",
"def add_image( id, image_name, x_position, speed, width, height )\n OSX::NSLog(\"Received image ##{id} (#{image_name})\")\n# image_name = OSX::NSBundle.mainBundle.pathForImageResource( image_name )\n image_name = \"/Users/alpha/src/cyberart/images/#{image_name}.jpg\"\n image = CAImage.new( id, image_name, x_position, speed, width, height )\n @semaphore.synchronize { temp_images = @images.dup }\n temp_images << image\n @semaphore.synchronize { @images = temp_images }\n end",
"def change_image(&block)\n yield image\n @tempfile = nil\n @uri = nil # Once transformed, all external sources are invalid.\n @blob = nil # Once transformed, we need to reset the data. Now the getter can lazily load the blob.\n @persistent = false\n self\n end",
"def images\n end",
"def decode_image_data(img_data,fname)\n cid = URI.unescape(img_data)\n filename = fname\n file = File.open(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\",\"wb\")\n temp2 = ActiveSupport::Base64.decode64(cid)\n file.write(temp2)\n file.close\n f = File.open(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\")\n self.avatar = f\n f.close\n File.delete(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\")\n end",
"def save_book_cover_image\n view = Openlibrary::View\n return unless self.isbn_10.present?\n book = view.find_by_isbn(self.isbn_10)\n if(!self.image.present?)\n if book.thumbnail_url.present?\n self.remote_image_url = book.thumbnail_url \n self.save\n end\n end\n end",
"def save_book_cover_image\n view = Openlibrary::View\n return unless self.isbn_10.present?\n book = view.find_by_isbn(self.isbn_10)\n if(!self.image.present?)\n if book.thumbnail_url.present?\n self.remote_image_url = book.thumbnail_url \n self.save\n end\n end\n end",
"def fetch_image(host,old_file,new_file)\n\t`rm #{old_file}` \n\t`mv #{new_file} #{old_file}`\t\n\topen('assets/images/radar/new.png', 'wb') do |file|\n\t\tfile << open('host').read\n\tend\n\tnew_file\nend",
"def image\n @path\n end",
"def processed_image\n @image = @picture.image_file\n if @image.nil?\n raise MissingImageFileError, \"Missing image file for #{@picture.inspect}\"\n end\n if @size.present?\n if params[:crop_size].present? && params[:crop_from].present?\n @image = @image.thumb xy_crop_geometry_string(params)\n @image.thumb(resize_geometry_string)\n elsif params[:crop]\n @image.thumb(center_crop_geometry_string)\n else\n @image.thumb(resize_geometry_string)\n end\n else\n @image\n end\n end",
"def update_img\n @post = Post.find(self.id)\n image = @post.image.url(:gallery)\n image = '/public' + image.gsub(/\\?.*/, '')\n\n if [email protected]_text.nil?\n if File.exists? Rails.root.to_s + image\n PostsHelper.image_writer(image, @post.meme_text, @post.meme_position)\n end\n end\n end",
"def save_to_file image\n File.open('uml.png', 'wb') do |file|\n file << image.body\n end if image\n end",
"def image_from_url\n io = open(URI.parse(image_url))\n def io.original_filename; base_uri.path.split('/').last; end\n self.image = io.original_filename.blank? ? nil : io\n rescue # catch url errors with validations instead of exceptions (Errno::ENOENT, OpenURI::HTTPError, etc...) \n end",
"def image\n @image ||= MiniMagick::Image.open(source_path)\n end",
"def add_image # :prefetch: :norobots:\n pass_query_params\n if @observation = find_or_goto_index(Observation, params[:id].to_s)\n if !check_permission!(@observation)\n redirect_to(:controller => 'observer', :action => 'show_observation',\n :id => @observation.id, :params => query_params)\n elsif request.method != :post\n @image = Image.new\n @image.license = @user.license\n @image.copyright_holder = @user.legal_name\n @image.user = @user\n # Set the default date to the date of the observation\n # Don't know how to correctly test this.\n @image.when = @observation.when\n @licenses = License.current_names_and_ids(@image.license)\n init_project_vars_for_add_or_edit(@observation)\n else\n args = params[:image]\n i = 1\n while i < 5 or !params[:upload][\"image#{i}\"].blank?\n process_image(args, params[:upload][\"image#{i}\"])\n i += 1\n end\n redirect_to(:controller => 'observer', :action => 'show_observation',\n :id => @observation.id, :params => query_params)\n end\n end\n end",
"def picture_save \n \tuploader = ImageUploader.new\n \tuploader.store!(image)\n \timage = uploader.store_dir\n \tsave\n end",
"def convert_to_img\n\t\t\t`gs -sDEVICE=png16m '-r#{OCR::MIN_DENSITY}' -o '#{@image}' '#{@input_file}'`\n\t\tend",
"def image\n end",
"def image\n end",
"def newFromSource\n\n @kite = Kite.new\n @images = []\n @isAutoAdd = true\n\n if uri_is_valid?(params[:path])\n site = URI.parse(URI.encode(params[:path]))\n\n #grab the reference page passed in as parameter\n doc = Nokogiri::HTML(open(site))\n\n #find all of the images\n doc.css('img').each do |image|\n #debugger\n path = image.attribute('src').value\n\n if path[0..0] == '/'\n path = URI.join(site, path).to_s\n end\n begin\n dimensions = FastImage.size(path, :timeout => 10.0)\n rescue => ex\n logger.error(\"Failed to retrieve image dimensions for image: #{ex}\")\n end\n if(!dimensions.nil? && dimensions.length > 1 && dimensions[0] > IMAGE_SQUARE_DIMENSION_LIMIT && dimensions[1] > IMAGE_SQUARE_DIMENSION_LIMIT )\n img = {:path => path,\n :source => doc.title,\n :alttext => image.attribute('alt').nil? ? \"\" : image.attribute('alt').value\n }\n\n @images << img\n else\n logger.debug \"The image #{path} was rejected as under size limit\"\n end\n end\n else\n logger.error \"The image was rejected as invalid path #{path}\"\n end\n @site = site\n if @images.count > 0\n @images[0][:first] = true\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @kite }\n end\n end"
] | [
"0.6438749",
"0.6343522",
"0.62958634",
"0.62391263",
"0.62025964",
"0.6188804",
"0.6168109",
"0.6159204",
"0.61430806",
"0.60338736",
"0.6013589",
"0.60089177",
"0.59942913",
"0.5987419",
"0.59719896",
"0.5964547",
"0.5948647",
"0.59469134",
"0.59218293",
"0.5909293",
"0.5904112",
"0.590186",
"0.58894306",
"0.58688754",
"0.586337",
"0.58584905",
"0.5854043",
"0.5846741",
"0.5836587",
"0.5826066",
"0.5822564",
"0.58189297",
"0.5769711",
"0.57672584",
"0.5757368",
"0.5755518",
"0.57510954",
"0.57510954",
"0.5749288",
"0.57451403",
"0.5742845",
"0.5739758",
"0.573035",
"0.57264984",
"0.5718431",
"0.57177687",
"0.5715465",
"0.57045835",
"0.57037455",
"0.5696428",
"0.56947154",
"0.56893146",
"0.56825477",
"0.568212",
"0.5681066",
"0.56785446",
"0.5677444",
"0.5665671",
"0.56499183",
"0.5648888",
"0.5646608",
"0.5640761",
"0.5638053",
"0.56336415",
"0.5631332",
"0.5628203",
"0.56184834",
"0.5617617",
"0.56173354",
"0.5615512",
"0.56093174",
"0.5608472",
"0.5602927",
"0.5598955",
"0.5598599",
"0.5596072",
"0.5587613",
"0.558601",
"0.5580216",
"0.55739546",
"0.55719244",
"0.55698764",
"0.5567078",
"0.5566754",
"0.5566431",
"0.55600315",
"0.55600315",
"0.55596757",
"0.55595744",
"0.5558298",
"0.5555545",
"0.5555506",
"0.5551699",
"0.5548902",
"0.5548631",
"0.55473113",
"0.5545502",
"0.5543708",
"0.5543708",
"0.55422044"
] | 0.63088256 | 2 |
GET /units GET /units.json | def index
@units = Unit.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foods_units\n get('/foods/units.json')\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units = @units.uniq\n respond_to do |format|\n format.json { render json: @units }\n end\n end",
"def units\n attribute('yweather:units')\n end",
"def all_units\n services.map{|el| el[:units]} \n end",
"def units\n self.ListUnits.first.map { |u| map_unit(u) }\n end",
"def units(units=nil)\n cur_page.units(units)\n end",
"def units\n return @units\n end",
"def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end",
"def unit_of_measurement_find_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<UnitOfMeasurement>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def units\n\t\tret = []\n\t\[email protected]('sgt-structure:' + @id + ':units').each do |uid|\n\t\t\tret.push(getUnit(@db, uid))\n\t\tend\n\t\tret\n\tend",
"def index\n @units = if params[:order] == 'updated'\n Unit.order('updated_at ' + params[:updated_direction])\n elsif params[:order] == 'created'\n Unit.order('created_at ' + params[:created_direction])\n elsif params[:order] == 'note_updated'\n Unit.order('note_updated_at ' + params[:note_updated_direction])\n elsif params[:order] == 'first_name'\n Unit.joins(:resident).order('residents.first_name ' + params[:first_name_direction])\n elsif params[:order] == 'last_name'\n Unit.joins(:resident).order('residents.last_name ' + params[:last_name_direction])\n elsif params[:order] == 'name'\n Unit.order('name ' + params[:name_direction])\n elsif params[:order] == 'address'\n Kaminari.paginate_array(Address.joins(:street, :units).order(\"streets.name #{params[:address_direction]}\").order(\"addresses.street_number #{params[:address_direction]}\").map(&:units).flatten)\n else\n Unit.order('created_at desc')\n end.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @units }\n end\n end",
"def units=(value)\n @units = value\n end",
"def show\n query = {\n 'id' => unit_params[:id]\n }\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units/?id\", :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n @unit = JSON.parse(response.body)\n else\n redirect_to unit_path(params[:id]), notice: 'Hmm...thats strange...try that again.'\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def units\n @units = SQF.units @this\n @units\n end",
"def user_units\n @user.units\n end",
"def show\n @unit = Unit.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def transfer_unit\n if !params[:ic_number].nil?\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def unit(unit_id=nil, opts = {})\n units = connection.get(connection.build_url(\"units\", opts.merge(:unitids => unit_id))).body\n units.map!{|hash| hash.values.first}\n units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}\n units.first\n end",
"def show\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def get_units\n @agency, @depts = params[:agency], params[:dept]\n render :layout => false\n end",
"def show\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def index\n @unit_type = UnitType.all\n\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def emission_units\n data['emission_units']\n end",
"def unit\n return @units[@index]\n end",
"def unit\n return @units[@index]\n end",
"def index\n @base_units = BaseUnit.all\n end",
"def allowed_units\n @converter.list_units(true)\n end",
"def index\n @standard_units = StandardUnit.all\n end",
"def get_usage_rum_units_with_http_info(start_hr, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_rum_units ...'\n end\n # verify the required parameter 'start_hr' is set\n if @api_client.config.client_side_validation && start_hr.nil?\n fail ArgumentError, \"Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_rum_units\"\n end\n # resource path\n local_var_path = '/api/v1/usage/rum'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'start_hr'] = start_hr\n query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].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;datetime-format=rfc3339'])\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] || 'UsageRumUnitsResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :get_usage_rum_units,\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 :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsageMeteringAPI#get_usage_rum_units\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\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 @units = @gang.units.order( :id )\n @can_add_units = can_add_units\n end",
"def index\n @german_units = GermanUnit.all\n end",
"def units\n q = \"select distinct unit_id from master_files m inner join master_file_locations l on l.master_file_id=m.id\"\n q << \" where location_id = #{id}\"\n return Location.connection.query(q).flatten\n end",
"def unit_mappings\n {\n ApiUnitSystem.US => { :duration => \"milliseconds\", :distance => \"miles\", :elevation => \"feet\", :height => \"inches\", :weight => \"pounds\", :measurements => \"inches\", :liquids => \"fl oz\", :blood_glucose => \"mg/dL\" },\n ApiUnitSystem.UK => { :duration => \"milliseconds\", :distance => \"kilometers\", :elevation => \"meters\", :height => \"centimeters\", :weight => \"stone\", :measurements => \"centimeters\", :liquids => \"mL\", :blood_glucose => \"mmol/l\" },\n ApiUnitSystem.METRIC => { :duration => \"milliseconds\", :distance => \"kilometers\", :elevation => \"meters\", :height => \"centimeters\", :weight => \"kilograms\", :measurements => \"centimeters\", :liquids => \"mL\", :blood_glucose => \"mmol/l\" }\n }\n end",
"def show\n @extent_unit = ExtentUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @extent_unit }\n end\n end",
"def find_units(modids)\n # TODO: Rename unit_search?\n units = connection.get(connection.build_url(\"units/search\", :modids => modids)).body\n units.map!{|hash| hash.values.first}\n units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}\n end",
"def units(*list)\n @units.concat(makelist(list)) unless list.empty?\n @units\n end",
"def show\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def units _args\n \"units _args;\" \n end",
"def index\n authorize Unit\n @units_version = Unit.version\n @units = Unit.all\n render\n end",
"def index\n @police_units = PoliceUnit.all\n end",
"def index\n @display_units = DisplayUnit.all\n end",
"def index\n @org_units = OrgUnit.all\n end",
"def get_upgrade_units_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UpgradeApi.get_upgrade_units ...\"\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling UpgradeApi.get_upgrade_units, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling UpgradeApi.get_upgrade_units, must be greater than or equal to 0.'\n end\n\n # resource path\n local_var_path = \"/upgrade/upgrade-units\"\n\n # query parameters\n query_params = {}\n query_params[:'component_type'] = opts[:'component_type'] if !opts[:'component_type'].nil?\n query_params[:'current_version'] = opts[:'current_version'] if !opts[:'current_version'].nil?\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'group_id'] = opts[:'group_id'] if !opts[:'group_id'].nil?\n query_params[:'has_warnings'] = opts[:'has_warnings'] if !opts[:'has_warnings'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n query_params[:'upgrade_unit_type'] = opts[:'upgrade_unit_type'] if !opts[:'upgrade_unit_type'].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 => 'UpgradeUnitListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UpgradeApi#get_upgrade_units\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @units = Unit.search.\n institution(current_institution).\n include_children(false).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(9999)\n end",
"def unit_of_measurement_count_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_count ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/count\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'where'] = opts[:'where'] if !opts[:'where'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_count\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @breadcrumbs = [[t(:units)]]\n @units = @units.order(:name).page(params[:page])\n end",
"def show\n @unit_type = UnitType.find(params[:id])\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def index\n @unit_measures = UnitMeasure.all\n end",
"def getAllUnits\n deep_copy(@allUnits)\n end",
"def units(by=nil)\n Unit.units.values.select { |unit| unit.dimensions == self }.map(&by).to_a\n end",
"def show\n @electoral_unit = ElectoralUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @electoral_unit }\n end\n end",
"def get_measurements\n render json: @data_source.measurements\n end",
"def getuom\n @deliverable_type = DeliverableType.find(params[:id])\n respond_to do |format|\n format.json { render :json => @deliverable_type.uom}\n end\n end",
"def unit_rules\n Rules.raw[\"units\"][type]\n end",
"def playableUnits \n \"playableUnits\" \n end",
"def unit_params\n params.fetch(:unit, {})\n end",
"def index\n @study_units = StudyUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_units }\n end\n end",
"def show\n @resource = Resource.find(params[:resource_id])\n @incident = Incident.find(@resource.incident_id)\n @demob = Demob.find(params[:id])\n @logistics_units = @demob.units[0..5]\n @finance_units = @demob.units[6..8]\n @other_units = @demob.units[9..10]\n @plans_units = @demob.units[11..13]\n end",
"def index\n @storage_units = StorageUnit.all\n end",
"def available_units\n return 0 if status == NO_SPACE\n\n 999\n end",
"def get_upgrade_units(opts = {})\n data, _status_code, _headers = get_upgrade_units_with_http_info(opts)\n return data\n end",
"def units\n game.squares.each_with_object([]) do |square, collection|\n square.units.each do |unit|\n collection << unit if unit.player_number == number\n end\n end\n end",
"def total_units\n return @total_units\n end",
"def available_units\n # After manual set, duplicate map for form select lists\n all_units = ['gram', 'kg', 'lb', 'oz', 'liter', 'gal', 'qt', 'pt', 'us_fl_oz', 'tsp', 'tbsp', 'cup', 'each'].map { |unit| [unit, unit] }.sort\n return all_units\n\tend",
"def index\n @order_units = OrderUnit.all\n end",
"def index\n @army_units = ArmyUnit.all\n end",
"def units\n definitions = unit_counts\n\n units = []\n definitions.each do |type, count, flank|\n klass = \"Unit::#{type.camelcase}\".constantize\n count.times do\n unit = klass.new(:level => 1, :location => @planet, :flank => flank)\n unit.skip_validate_technologies = true\n\n units.push unit\n end\n end\n\n units\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_units }\n end\n end",
"def unit_of_measurement_find_one_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find_one ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/findOne\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'UnitOfMeasurement')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find_one\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def units=(list)\n @units = makelist(list)\n end",
"def show\n @retail_unit = RetailUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retail_unit }\n end\n end",
"def index\n @unit_names = UnitName.all\n end",
"def show\n @units = @commercial_lead.units\n end",
"def total_units=(value)\n @total_units = value\n end",
"def index\n @quotation_units = QuotationUnit.all\n end",
"def index\n @handbook_structual_units = HandbookStructualUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @handbook_structual_units }\n end\n end",
"def units(auth_name: nil, category: nil, allow_deprecated: false)\r\n # Create pointer to read the count output parameter\r\n out_result_count = FFI::MemoryPointer.new(:int)\r\n\r\n # Result is an array of pointers to structures\r\n pp_units = Api.proj_get_units_from_database(Context.current, auth_name, category, allow_deprecated ? 1 : 0, out_result_count)\r\n count = out_result_count.read(:int)\r\n array_p_units = pp_units.read_array_of_pointer(count)\r\n\r\n result = Array.new(count)\r\n count.times do |i|\r\n unit_info = Api::PROJ_UNIT_INFO.new(array_p_units[i])\r\n\r\n result[i] = Unit.new(unit_info[:auth_name],\r\n unit_info[:code],\r\n unit_info[:name],\r\n unit_info[:category],\r\n unit_info[:conv_factor],\r\n unit_info[:proj_short_name],\r\n unit_info[:deprecated])\r\n end\r\n\r\n Api.proj_unit_list_destroy(pp_units)\r\n\r\n result\r\n end",
"def index\n @unit_of_measures = UnitOfMeasure.all\n end",
"def unit(unit_id=nil)\n unit_content = @xbrl_content[\"unit\"]\n return nil if unit_content.nil?\n\n units=[]\n\n l = lambda {|measure_list| measures=[]; measure_list.each { |measure| measures << measure[\"content\"]}; return measures}\n unit_content.each do |unit|\n\n next unless unit_id.nil? || unit[\"id\"].to_s == unit_id\n\n _unit=nil\n unless unit[\"measure\"].nil?\n _unit = Unit.new(unit[\"id\"], l.call(unit[\"measure\"]))\n else\n divide_content = unit[\"divide\"][0]\n\n numerator = l.call(divide_content[\"unitNumerator\"][0][\"measure\"])\n denominator = l.call(divide_content[\"unitDenominator\"][0][\"measure\"])\n\n divide=Unit::Divide.new(numerator, denominator)\n _unit = Unit.new(unit[\"id\"], divide)\n end\n _unit.ns=unit[\"nspace\"]\n _unit.nsp=unit[\"nspace_prefix\"]\n units << _unit\n end\n return units[0] unless unit_id.nil?\n units\n end",
"def report_unit_statuses\n u_times = Unit.all.map do |u|\n { :id => u.id, :state => u.state, :duration => u.duration, :time_available => u.time_available }\n end\n respond_to do |format|\n format.html { render nothing: true }\n format.js { respond_with(u_times) }\n end\n end",
"def completed_units\n return @completed_units\n end",
"def units_hash\n {\n \"_hrs\" => \"hours\",\n \"_hours\"=>\"hours\",\n \"_min\"=>\"minutes\",\n \"_minutes\"=>\"minutes\",\n \"_ppm\"=>\"ppm\",\n \"_ppb\"=>\"ppb\",\n \"_mgm3\"=>\"mg/m3\",\n \"_f\"=>\"°f\",\n \"_c\"=>\"°c\",\n \"_rh\"=>\"% rh\",\n \"_utf\"=>\"\"\n }\n end",
"def single_usage\r\n meter = get_meters[3]\r\n date_ranges = get_date_ranges\r\n dtps = Meter.get_daily_time_periods [meter]\r\n\r\n# usage = meter.usage_by_meter(date_ranges, dtps)\r\n# usage = meter.usage_by_time(date_ranges, dtps)\r\n usage = meter.detailed_usage_by_meter(date_ranges, dtps)\r\n# usage = meter.detailed_usage_by_time(date_ranges, dtps)\r\n\r\n render :json => usage\r\n\r\n# redirect_to action: 'index'\r\n end",
"def get_units(dimension)\n nil\n end",
"def index\n @rent_units = RentUnit.all\n end",
"def get_usage_rum_units(start_hr, opts = {})\n data, _status_code, _headers = get_usage_rum_units_with_http_info(start_hr, opts)\n data\n end",
"def parse_units\n # extract the unit suffix\n if self =~ /(\\d[\\d_]*(?:\\.\\d+)?)\\s*([a-zA-Z]+\\b|%(?= \\s|$))/\n units = $2.downcase\n num = $1 #.to_f\n num = num[\".\"] ? num.to_f : num.to_i\n\n case units\n when \"%\"\n # 0.01\n num / 100.0\n when \"k\"\n # 10**3\n num.thousand\n when \"m\", \"mm\"\n # 10**6\n num.million\n when \"b\", \"bn\"\n # 10**9\n num.billion\n when \"gib\", \"gb\", \"g\"\n num * 2**30\n when \"mib\", \"mb\"\n num * 2**20\n when \"kib\", \"kb\"\n num * 2**10\n when \"t\", \"tb\"\n # 10**12\n num.trillion\n when \"q\"\n # 10**15\n num.quadrillion\n when \"Q\"\n # 10**18\n num.quintillion\n when \"min\"\n # 1.minute\n num.minutes\n when \"hours\", \"h\", \"hr\", \"hrs\"\n # 1.hour\n num.hours\n when \"d\", \"days\", \"dy\"\n num.days\n else\n raise \"Invalid units: #{units.inspect}, in: #{self.inspect}\"\n end\n else\n raise \"Couldn't find any units to parse! (expecting: '<a number><some letters>')\"\n end\n end",
"def to_units( units, thousands=0 )\n\t\treturn Units[ units ] + to_thousands( thousands )\n\tend",
"def measurements_get(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_get ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n query_params[:'user_id'] = opts[:'user_id'] if opts[:'user_id']\n query_params[:'client_id'] = opts[:'client_id'] if opts[:'client_id']\n query_params[:'connector_id'] = opts[:'connector_id'] if opts[:'connector_id']\n query_params[:'variable_id'] = opts[:'variable_id'] if opts[:'variable_id']\n query_params[:'source_id'] = opts[:'source_id'] if opts[:'source_id']\n query_params[:'start_time'] = opts[:'start_time'] if opts[:'start_time']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n query_params[:'unit_id'] = opts[:'unit_id'] if opts[:'unit_id']\n query_params[:'original_value'] = opts[:'original_value'] if opts[:'original_value']\n query_params[:'original_unit_id'] = opts[:'original_unit_id'] if opts[:'original_unit_id']\n query_params[:'duration'] = opts[:'duration'] if opts[:'duration']\n query_params[:'note'] = opts[:'note'] if opts[:'note']\n query_params[:'latitude'] = opts[:'latitude'] if opts[:'latitude']\n query_params[:'longitude'] = opts[:'longitude'] if opts[:'longitude']\n query_params[:'location'] = opts[:'location'] if opts[:'location']\n query_params[:'created_at'] = opts[:'created_at'] if opts[:'created_at']\n query_params[:'updated_at'] = opts[:'updated_at'] if opts[:'updated_at']\n query_params[:'error'] = opts[:'error'] if opts[:'error']\n query_params[:'limit'] = opts[:'limit'] if opts[:'limit']\n query_params[:'offset'] = opts[:'offset'] if opts[:'offset']\n query_params[:'sort'] = opts[:'sort'] if opts[:'sort']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_13')\n if Configuration.debugging\n Configuration.logger.debug \"API called: MeasurementApi#measurements_get. Result: #{result.inspect}\"\n end\n return result\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end"
] | [
"0.8416218",
"0.7555869",
"0.7451005",
"0.6968702",
"0.69407237",
"0.68924576",
"0.68458724",
"0.6776829",
"0.67726886",
"0.67339927",
"0.6626998",
"0.6626976",
"0.66150105",
"0.6614453",
"0.6612779",
"0.6612779",
"0.6612779",
"0.65958196",
"0.6577777",
"0.65643185",
"0.65463156",
"0.6461802",
"0.6442305",
"0.6418103",
"0.6340333",
"0.6324495",
"0.6323419",
"0.63086927",
"0.63086927",
"0.6301784",
"0.62958467",
"0.62924904",
"0.6284219",
"0.62822884",
"0.62750804",
"0.62660205",
"0.62203324",
"0.6219209",
"0.6212048",
"0.62011755",
"0.61966354",
"0.61934686",
"0.6190692",
"0.6172383",
"0.6164619",
"0.61526036",
"0.613219",
"0.612089",
"0.60931695",
"0.6080536",
"0.6077928",
"0.60607284",
"0.6059083",
"0.6032714",
"0.60229903",
"0.60132825",
"0.6011165",
"0.60098773",
"0.60028094",
"0.59974277",
"0.59808195",
"0.597419",
"0.59713024",
"0.5970725",
"0.5964095",
"0.59621495",
"0.59618473",
"0.5945153",
"0.5943176",
"0.59414655",
"0.59407747",
"0.59302676",
"0.59237224",
"0.59193105",
"0.590091",
"0.58957016",
"0.58774",
"0.58705974",
"0.5852639",
"0.5848431",
"0.58426857",
"0.58284444",
"0.5814263",
"0.58046347",
"0.58008134",
"0.5789729",
"0.5776536",
"0.57760227",
"0.5771593",
"0.57622045",
"0.5760859",
"0.57454306",
"0.5743044",
"0.5724068",
"0.57197636"
] | 0.6867695 | 11 |
GET /units/1 GET /units/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foods_units\n get('/foods/units.json')\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units = @units.uniq\n respond_to do |format|\n format.json { render json: @units }\n end\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def show\n query = {\n 'id' => unit_params[:id]\n }\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units/?id\", :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n @unit = JSON.parse(response.body)\n else\n redirect_to unit_path(params[:id]), notice: 'Hmm...thats strange...try that again.'\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def show\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def show\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def index\n @units = Unit.all\n end",
"def unit_of_measurement_find_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<UnitOfMeasurement>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def unit(unit_id=nil, opts = {})\n units = connection.get(connection.build_url(\"units\", opts.merge(:unitids => unit_id))).body\n units.map!{|hash| hash.values.first}\n units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}\n units.first\n end",
"def unit_of_measurement_find_one_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_find_one ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/findOne\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'UnitOfMeasurement')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_find_one\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @extent_unit = ExtentUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @extent_unit }\n end\n end",
"def index\n @units = if params[:order] == 'updated'\n Unit.order('updated_at ' + params[:updated_direction])\n elsif params[:order] == 'created'\n Unit.order('created_at ' + params[:created_direction])\n elsif params[:order] == 'note_updated'\n Unit.order('note_updated_at ' + params[:note_updated_direction])\n elsif params[:order] == 'first_name'\n Unit.joins(:resident).order('residents.first_name ' + params[:first_name_direction])\n elsif params[:order] == 'last_name'\n Unit.joins(:resident).order('residents.last_name ' + params[:last_name_direction])\n elsif params[:order] == 'name'\n Unit.order('name ' + params[:name_direction])\n elsif params[:order] == 'address'\n Kaminari.paginate_array(Address.joins(:street, :units).order(\"streets.name #{params[:address_direction]}\").order(\"addresses.street_number #{params[:address_direction]}\").map(&:units).flatten)\n else\n Unit.order('created_at desc')\n end.page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @units }\n end\n end",
"def show\n @unit_type = UnitType.find(params[:id])\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def transfer_unit\n if !params[:ic_number].nil?\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def show\n @retail_unit = RetailUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retail_unit }\n end\n end",
"def show\n @electoral_unit = ElectoralUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @electoral_unit }\n end\n end",
"def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end",
"def find_single(scope) \n JSON[RestClient.get \"#{@site}/unit/#{scope}\", :accept=>'json'][0]\n end",
"def index\n @unit_type = UnitType.all\n\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def unit\n return @units[@index]\n end",
"def unit\n return @units[@index]\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 show\n @log_unit = LogUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @log_unit }\n end\n end",
"def index\n authorize Unit\n @units_version = Unit.version\n @units = Unit.all\n render\n end",
"def getuom\n @deliverable_type = DeliverableType.find(params[:id])\n respond_to do |format|\n format.json { render :json => @deliverable_type.uom}\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit}\n end\n end",
"def index\n @base_units = BaseUnit.all\n end",
"def units\n self.ListUnits.first.map { |u| map_unit(u) }\n end",
"def single_usage\r\n meter = get_meters[3]\r\n date_ranges = get_date_ranges\r\n dtps = Meter.get_daily_time_periods [meter]\r\n\r\n# usage = meter.usage_by_meter(date_ranges, dtps)\r\n# usage = meter.usage_by_time(date_ranges, dtps)\r\n usage = meter.detailed_usage_by_meter(date_ranges, dtps)\r\n# usage = meter.detailed_usage_by_time(date_ranges, dtps)\r\n\r\n render :json => usage\r\n\r\n# redirect_to action: 'index'\r\n end",
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unit }\n end\n end",
"def units(units=nil)\n cur_page.units(units)\n end",
"def index\n @standard_units = StandardUnit.all\n end",
"def units\n attribute('yweather:units')\n end",
"def index\n @units = @gang.units.order( :id )\n @can_add_units = can_add_units\n end",
"def index\n @study_units = StudyUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @study_units }\n end\n end",
"def get_units\n @agency, @depts = params[:agency], params[:dept]\n render :layout => false\n end",
"def get_adapter_unit_by_moid_with_http_info(moid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AdapterApi.get_adapter_unit_by_moid ...'\n end\n # verify the required parameter 'moid' is set\n if @api_client.config.client_side_validation && moid.nil?\n fail ArgumentError, \"Missing the required parameter 'moid' when calling AdapterApi.get_adapter_unit_by_moid\"\n end\n # resource path\n local_var_path = '/api/v1/adapter/Units/{Moid}'.sub('{' + 'Moid' + '}', CGI.escape(moid.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'AdapterUnit'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"AdapterApi.get_adapter_unit_by_moid\",\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: AdapterApi#get_adapter_unit_by_moid\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def select_unit_by_id(unit_id)\n @units[unit_id]\n end",
"def select_unit_by_id(unit_id)\n @units[unit_id]\n end",
"def show\n @title = \"Prima Lingua: #{@section.name}\"\n if params[:unit_id]\n @overview_unit = Unit.find(params[:unit_id])\n else\n @overview_unit = @section.lesson.unit\n end\n respond_to do |format|\n format.html { render_flex_layout }\n format.json { render :json => @section }\n end\n end",
"def get_usage_rum_units_with_http_info(start_hr, opts = {})\n\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_rum_units ...'\n end\n # verify the required parameter 'start_hr' is set\n if @api_client.config.client_side_validation && start_hr.nil?\n fail ArgumentError, \"Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_rum_units\"\n end\n # resource path\n local_var_path = '/api/v1/usage/rum'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'start_hr'] = start_hr\n query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].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;datetime-format=rfc3339'])\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] || 'UsageRumUnitsResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]\n\n new_options = opts.merge(\n :operation => :get_usage_rum_units,\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 :api_version => \"V1\"\n )\n\n data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsageMeteringAPI#get_usage_rum_units\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def all_units\n services.map{|el| el[:units]} \n end",
"def show\n @study_unit = StudyUnit.find(params[:id])\n @logical_products = @study_unit.logical_products\n @data_collections = @study_unit.data_collections\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study_unit }\n end\n end",
"def show\n @resource = Resource.find(params[:resource_id])\n @incident = Incident.find(@resource.incident_id)\n @demob = Demob.find(params[:id])\n @logistics_units = @demob.units[0..5]\n @finance_units = @demob.units[6..8]\n @other_units = @demob.units[9..10]\n @plans_units = @demob.units[11..13]\n end",
"def show\n @unit = Unit.find(params[:id])\n @logs = @unit.logs.limit(15).order(:created_at)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @item_unit = ItemUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @account_units }\n end\n end",
"def index\n @german_units = GermanUnit.all\n end",
"def index\n @units = Unit.search.\n institution(current_institution).\n include_children(false).\n order(\"#{Unit::IndexFields::TITLE}.sort\").\n limit(9999)\n end",
"def index\n @police_units = PoliceUnit.all\n end",
"def index\n @display_units = DisplayUnit.all\n end",
"def set_unit\n @unit = Unit.friendly.find(params[:id])\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :ok }\n end\n end",
"def for_unit(unit); find(:all, :conditions => {:unit_id => (unit.nil? ? nil : unit.class == Fixnum ? unit : unit.id)}); end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def show\n @quantity_unit = QuantityUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @quantity_unit }\n end\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def units=(value)\n @units = value\n end",
"def unit_of_measurement_count_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UnitOfMeasurementApi.unit_of_measurement_count ...\"\n end\n # resource path\n local_var_path = \"/UnitsOfMeasurement/count\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'where'] = opts[:'where'] if !opts[:'where'].nil?\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json', 'application/xml', 'text/xml', 'application/javascript', 'text/javascript']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json', 'application/x-www-form-urlencoded', 'application/xml', 'text/xml']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UnitOfMeasurementApi#unit_of_measurement_count\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unidade_metrica }\n end\n end",
"def index\n @handbook_structual_units = HandbookStructualUnit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @handbook_structual_units }\n end\n end",
"def index\n @breadcrumbs = [[t(:units)]]\n @units = @units.order(:name).page(params[:page])\n end",
"def show\n @handbook_structual_unit = HandbookStructualUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @handbook_structual_unit }\n end\n end",
"def new\n @unit_of_measure = UnitOfMeasure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def unit_params\n params.fetch(:unit, {})\n end",
"def base_unit\n units[0]\n end",
"def show\n @ad_unit = AdUnit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad_unit }\n end\n end",
"def index\n # @units = Unit.all\n\n # dla formularza new\n @unit = current_user.units.build if signed_in?\n\n # dla tabeli index\n @units = Unit.find(:all, :conditions => [\"\\\"isDefault\\\" = ? or user_id = ?\", true, current_user.id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @units }\n end\n end",
"def index\n @army_units = ArmyUnit.all\n end",
"def show\n @metric = Metric.find(params[:id])\n\n render json: @metric\n end",
"def index\n @order_units = OrderUnit.all\n end",
"def show\n @usage = Usage.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usage }\n end\n end",
"def index\n @unit_measures = UnitMeasure.all\n end",
"def get_measurements\n render json: @data_source.measurements\n end",
"def units\n @units = SQF.units @this\n @units\n end",
"def index\n @unit_names = UnitName.all\n end",
"def show\n @unit_subtitle = UnitSubtitle.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit_subtitle }\n end\n end",
"def index\n @org_units = OrgUnit.all\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def destroy\n if @unit.blank?\n render json: {error: \"Can't delete unit\"}, status: :unprocessable_entity\n else\n @unit.destroy\n render json: {notice: \"Deleted!\"}, :status => 204\n end\n\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end",
"def set_unit\n @unit = Unit.find(params[:id])\n end"
] | [
"0.8020733",
"0.73784614",
"0.72970515",
"0.727637",
"0.7244588",
"0.7244588",
"0.7244588",
"0.7179953",
"0.6931644",
"0.68736583",
"0.683191",
"0.6751607",
"0.6751607",
"0.6751607",
"0.6751607",
"0.6751607",
"0.6751607",
"0.66951364",
"0.66746956",
"0.66559684",
"0.66320664",
"0.66216534",
"0.65614486",
"0.6516743",
"0.6497827",
"0.6450474",
"0.6429881",
"0.6411951",
"0.6371354",
"0.63544756",
"0.63544756",
"0.6346127",
"0.63220906",
"0.6301719",
"0.629736",
"0.62870854",
"0.62870854",
"0.62870854",
"0.62658626",
"0.6247907",
"0.62260103",
"0.62187296",
"0.6203214",
"0.6171249",
"0.6145495",
"0.6131283",
"0.6117874",
"0.6112714",
"0.61028135",
"0.60709625",
"0.60547614",
"0.60547614",
"0.6041017",
"0.6027766",
"0.60253257",
"0.6009498",
"0.6009325",
"0.6003673",
"0.6001278",
"0.59948546",
"0.5986672",
"0.5973913",
"0.59690535",
"0.59552425",
"0.59498966",
"0.59497595",
"0.59495646",
"0.59429145",
"0.59429145",
"0.59429145",
"0.59429145",
"0.59412235",
"0.59335417",
"0.5931545",
"0.59279644",
"0.5926747",
"0.59222466",
"0.5916337",
"0.5910377",
"0.59043235",
"0.58805025",
"0.58764493",
"0.587512",
"0.5862486",
"0.5854383",
"0.5852439",
"0.58514357",
"0.58491826",
"0.58465236",
"0.583529",
"0.58310306",
"0.58307433",
"0.5828413",
"0.5817525",
"0.58142066",
"0.58044827",
"0.5802077",
"0.5802077",
"0.5802077",
"0.5802077",
"0.5802077"
] | 0.0 | -1 |
POST /units POST /units.json | def create
go=true
@unit = Unit.new(unit_params)
unless params[:has_exam_date]
@unit.exam_date=DateTime.new(1900,1,1)
end
@temp_1=@unit_time=UnitTime.new(:start_time => parse_time(params[:start_time]) , :end_time =>parse_time( params[:end_time]), :day => params[:day].to_i)
if not @unit_time.save
@temp_1=UnitTime.where(:start_time => parse_time(params[:start_time]) , :end_time =>parse_time( params[:end_time]), :day => params[:day].to_i)[0]
if @temp_1.nil?
puts "11111111111111111111111111111111"
go=false
respond_to do |format|
format.html { render :new }
format.json { render json: @unit_time.errors, status: :unprocessable_entity }
end
return
end
end
if params[:has_time_2] && go
@temp_2=@unit_time_2=UnitTime.new(:start_time => parse_time(params[:start_time_2]) , :end_time =>parse_time( params[:end_time_2]), :day => params[:day_2].to_i)
if not @unit_time_2.save
@temp_2=UnitTime.where(:start_time => parse_time(params[:start_time_2]) , :end_time =>parse_time( params[:end_time_2]), :day => params[:day_2].to_i)[0]
if @temp_2.nil?
puts "22222222222222222222222222222"
go=false
respond_to do |format|
format.html { render :new }
format.json { render json: @unit_time_2.errors, status: :unprocessable_entity }
end
return
end
end
end
respond_to do |format|
if go
@unit.unit_times << @temp_1
if params[:has_time_2]
@unit.unit_times << @temp_2
end
if @unit.save
format.html { redirect_to @unit, notice: 'Unit was successfully created.' }
format.json { render :show, status: :created, location: @unit }
else
format.html { render :new }
format.json { render json: @unit.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit = Unit.new(params[:unit])\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def foods_units\n get('/foods/units.json')\n end",
"def unit_params\n params.require(:unit).permit(:date, :value)\n end",
"def unit_params\n params.require(:unit).permit(:name)\n end",
"def create\n @item = Item.find(params[:item_id])\n @unit = @item.units.create(params[:unit])\n \n redirect_to item_path(@item)\n end",
"def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end",
"def unit_params\n params.require(:unit).permit(:name, :weight, :package_dimensions)\n end",
"def unit_params\n params.require(:unit).permit(:user_id, :building_id, :floor_number, :side, :unit_number, :area, :resident_count)\n end",
"def create\n authorize Unit\n @unit = Unit.new(unit_params)\n\n if @unit.save\n render status: :created\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def unit_params\n params.require(:unit).permit(:short_label, :long_label, :universe)\n end",
"def create\n @item_unit = ItemUnit.new(params[:item_unit])\n\n respond_to do |format|\n if @item_unit.save\n format.html { redirect_to @item_unit, notice: 'Item unit was successfully created.' }\n format.json { render json: @item_unit, status: :created, location: @item_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @extent_unit = ExtentUnit.new(params[:extent_unit])\n\n respond_to do |format|\n if @extent_unit.save\n format.html { redirect_to @extent_unit, notice: 'Extent unit was successfully created.' }\n format.json { render json: @extent_unit, status: :created, location: @extent_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @extent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:libe, :amount, :points, :weapon)\n end",
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def units\n @units = Item.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units += Detail.select(\"DISTINCT unit\").where(\"unit like ?\", \"%#{params[:q]}%\").limit(20).map(&:unit)\n @units = @units.uniq\n respond_to do |format|\n format.json { render json: @units }\n end\n end",
"def create\n # @unit = Unit.new(params[:unit])\n @unit = current_user.units.build(params[:unit])\n\n respond_to do |format|\n if @unit.save\n # format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.html { redirect_to units_path, notice: 'Pomyślnie utworzono jednostkę.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n # format.html { render action: \"new\" }\n format.html { redirect_to units_path, :flash => { :error => 'Nie udało się utworzyć jednostki' } }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_of_measure = UnitOfMeasure.create(params[:unit_of_measure])\n get_data\n end",
"def unit_params\n params.fetch(:unit, {}).permit(:name)\n end",
"def unit_params\n params.require(:unit).permit(:featured, :number, :avail_date, :category_id, :building_id, :title, :description, :bedrooms, :bathrooms, :price, :link, :image, :phoneNum)\n end",
"def unit_params\n params.fetch(:unit, {})\n end",
"def create\n @unit_measure = UnitMeasure.new(unit_measure_params)\n\n respond_to do |format|\n if @unit_measure.save\n format.html { redirect_to @unit_measure, notice: 'Unit measure was successfully created.' }\n format.json { render :show, status: :created, location: @unit_measure }\n else\n format.html { render :new }\n format.json { render json: @unit_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def units=(value)\n @units = value\n end",
"def unit_of_measure_params\n params.require(:unit_of_measure).permit(:unit_id, :unit_description, :unit_status, :created_by, :updated_by)\n end",
"def create\n @unit_of_measure = UnitOfMeasure.new(params[:unit_of_measure])\n\n respond_to do |format|\n if @unit_of_measure.save\n format.html { redirect_to @unit_of_measure, notice: t(:unit_of_measure_created) }\n format.json { render json: @unit_of_measure, status: :created, location: @unit_of_measure }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_of_measure_params\n params.require(:unit_of_measure).permit(:name, :description, :code, :uom_type, :ratio, :uom_category_id)\n end",
"def unit_params\n params.require(:unit).permit(:Unitcode, :name, :Unitaccuracy, :Roundingtype,:fbillstatus,:Creator,:CreateDate,:Approver,:ApproverDate)\n end",
"def unit_params\n params.require(:unit).permit(:name, :circle_id)\n end",
"def create\n # I was not able to get this working. I suspected a change may have occurred in the API that hasn't been published to docs.\n # Used https://www.hurl.it/ to test requests to the API. Was getting a success response, but\n # never saw the newly created unit in either my SDK or in the stage environment. Could be in the DB but missing an attribute/flag that allows\n # association to the property and/or allows for display.\n puts 'test1'\n #@unit = Unit.new(params)\n puts 'XYZ'\n puts params[:name]\n puts 'ABC'\n end",
"def create\n @base_unit = BaseUnit.new(base_unit_params)\n\n respond_to do |format|\n if @base_unit.save\n format.html { redirect_to @base_unit, notice: 'Tray type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @base_unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @base_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.\n require(:unit).\n permit(:user_building_id, :unit_number, :sqfootage, :number_bedrooms,\n :number_bathrooms, :number_rooms, :number_occupants)\n end",
"def create\n @unit = Unit.new(unit_params)\n @unit.name = @unit.name.downcase\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to new_food_path, notice: 'Unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit }\n else\n flash[:error] = \"Unit can't be an empty string.\"\n format.html { redirect_to new_food_path }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retail_unit = RetailUnit.new(params[:retail_unit])\n\n respond_to do |format|\n if @retail_unit.save\n format.html { redirect_to @retail_unit, notice: 'Retail unit was successfully created.' }\n format.json { render json: @retail_unit, status: :created, location: @retail_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retail_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:title, :description, :use, :typology, :component_id, :ancestry, :parent_id)\n end",
"def unit_params\n params.require(:unit).permit(:name, :type, :attack, :defence)\n end",
"def transfer_unit\n if !params[:ic_number].nil?\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def create\n @property = @user.properties.new(params[:property])\n @number_of_units = params[:number_of_units].to_i\n \n respond_to do |format|\n if @property.save\n @number_of_units.times do |unit|\n @property.units.build(:name => unit.to_s, :bedrooms=>1, :bathrooms=>1, :square_feet => 1000, :base_rent=>1000)\n end\n if (@property.save)\n flash[:notice] = 'Property and units created!'\n else\n flash[:notice] = 'Property creted, but errors creating units.'\n end\n format.html { redirect_to(@property) }\n format.xml { render :xml => @property, :status => :created, :location => @property }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @property.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def unit_params \n params.require(:unit).permit(:name, :unit, :create_user, :edit_user, :comment)\n end",
"def create\n @storage_unit = StorageUnit.new(storage_unit_params)\n\n respond_to do |format|\n if @storage_unit.save\n format.html { redirect_to @storage_unit, notice: 'Storage unit was successfully created.' }\n format.json { render :show, status: :created, location: @storage_unit }\n else\n format.html { render :new }\n format.json { render json: @storage_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rented_unit_params\n params.require(:rented_unit).permit(:unit_no, :unit_model, :price, :bedrooms, :bathrooms, :half_baths, :square_footage, :leased, :appointment_id, :notes, :spanstart, :spanend)\n end",
"def unit_measure_params\n params.require(:unit_measure).permit(:nominal_reference, :unit_measure_id, :conversion_id, :metric_id)\n end",
"def create\n @unit = Unit.new(unit_params)\n respond_to do |format|\n if @unit.save\n Unit.transaction do\n auth = Signet::Rails::Factory.create_from_env :google, request.env\n client = Google::APIClient.new\n client.authorization = auth\n plusDomain = client.discovered_api('plusDomains')\n @result = client.execute(:api_method => plusDomain.circles.insert,\n :parameters => {'userId' => 'me'},\n :body =>MultiJson.dump('displayName' => @unit.name),\n :headers => {'Content-Type' => 'application/json'}\n )\n @unit.update_column(:circle_id, @result.data.id)\n end\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @article = Article.new(article_params)\n respond_to do |format|\n if @article.save\n @article_unit = ArticlesUnit.create(article: @article,\n unit_id: params[:articles_units][:unit_id],\n value: params[:articles_units][:value])\n format.html { redirect_to @article, notice: \"L'Article a été créé avec succès.\" }\n format.json { render :show, status: :created, location: @article }\n else\n format.html { render :new }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:name, :role, :power, :movement, :shooting_skill, :strength, :combat_skill, :attacks, :wounds, :leadership, :armor_save, :invul_shooting, :invul_combat, :single_model_point_cost, :model_count_increment, :power_for_each_increment, :min_model_count, :max_model_count, :detachment_id)\n end",
"def measurements_post(opts = {})\n if Configuration.debugging\n Configuration.logger.debug \"Calling API: MeasurementApi#measurements_post ...\"\n end\n \n # resource path\n path = \"/measurements\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'access_token'] = opts[:'access_token'] if opts[:'access_token']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'body'])\n \n\n auth_names = ['quantimodo_oauth2']\n result = @api_client.call_api(:POST, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'inline_response_200_13')\n if Configuration.debugging\n Configuration.logger.debug \"API called: MeasurementApi#measurements_post. Result: #{result.inspect}\"\n end\n return result\n end",
"def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end",
"def standard_unit_params\n params.require(:standard_unit).permit(:name)\n end",
"def create\n @standard_unit = StandardUnit.new(standard_unit_params)\n\n if @standard_unit.save\n render :show, status: :created, location: @standard_unit\n else\n render json: @standard_unit.errors, status: :unprocessable_entity\n end\n end",
"def create\n @electoral_unit = ElectoralUnit.new(params[:electoral_unit])\n\n respond_to do |format|\n if @electoral_unit.save\n format.html { redirect_to @electoral_unit, notice: 'Electoral unit was successfully created.' }\n format.json { render json: @electoral_unit, status: :created, location: @electoral_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @electoral_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_name = UnitName.new(unit_name_params)\n\n respond_to do |format|\n if @unit_name.save\n format.html { redirect_to @unit_name, notice: 'Unit name was successfully created.' }\n format.json { render action: 'show', status: :created, location: @unit_name }\n else\n format.html { render action: 'new' }\n format.json { render json: @unit_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def unit_params\n params.require(:unit).permit(:name, :subsystem_id)\n end",
"def units=(list)\n @units = makelist(list)\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end",
"def medical_unit_params\n params.permit(:name, :location, :speciality, :image)\n end",
"def create\n @unit = Unit.new(unit_params)\n authorize @unit\n begin\n ActiveRecord::Base.transaction do\n @unit.save!\n end\n rescue => e\n render partial: \"shared/validation_messages\",\n locals: { object: @unit.errors.any? ? @unit : e },\n status: :bad_request\n else\n RefreshOpensearchJob.perform_later\n toast!(title: \"Unit created\",\n message: \"The unit \\\"#{@unit.title}\\\" has been created.\")\n render \"shared/reload\"\n end\n end",
"def create\n @quotation_unit = QuotationUnit.new(quotation_unit_params)\n\n respond_to do |format|\n if @quotation_unit.save\n format.html { redirect_to @quotation_unit, notice: 'Quotation unit was successfully created.' }\n format.json { render :show, status: :created, location: @quotation_unit }\n else\n format.html { render :new }\n format.json { render json: @quotation_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit}\n end\n end",
"def create\n @german_unit = GermanUnit.new(german_unit_params)\n\n respond_to do |format|\n if @german_unit.save\n format.html { redirect_to @german_unit, notice: 'German unit was successfully created.' }\n format.json { render :show, status: :created, location: @german_unit }\n else\n format.html { render :new }\n format.json { render json: @german_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def storage_unit_params\n params.require(:storage_unit).permit(:name, :description, :length, :width, :height, :renter_id, :annual_rate, :monthly_rate)\n end",
"def create\n @quantity_unit = QuantityUnit.new(params[:quantity_unit])\n\n respond_to do |format|\n if @quantity_unit.save\n flash[:notice] = 'QuantityUnit was successfully created.'\n format.html { redirect_to(@quantity_unit) }\n format.xml { render :xml => @quantity_unit, :status => :created, :location => @quantity_unit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @quantity_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def unit_params\n #params.require(:unit).permit(:name, :email, :cname)\n params.permit(:id, :name, :email, :cname)\n end",
"def set_Units(value)\n set_input(\"Units\", value)\n end",
"def set_Units(value)\n set_input(\"Units\", value)\n end",
"def assign_unit \n if !params[:ic_number].nil?\n @val = params[:transfer_from][:agency]\n user = User.find_by_ic_number(params[:ic_number])\n departments = user.units.active.collect(&:name)\n render :json=>[departments] if departments\n end\n end",
"def measurement_type_params\n params.require(:measurement_type).permit(:name, :units, :description)\n end",
"def create\n @police_unit = PoliceUnit.new(police_unit_params)\n\n respond_to do |format|\n if @police_unit.save\n format.html { redirect_to @police_unit, notice: 'Police unit was successfully created.' }\n format.json { render :show, status: :created, location: @police_unit }\n else\n format.html { render :new }\n format.json { render json: @police_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def police_unit_params\n params.require(:police_unit).permit(:name)\n end",
"def cat_uni_measure_unit_params\n params.require(:cat_uni_measure_unit).permit(:key, :description)\n end",
"def update\n @unit = Unit.find(params[:id])\n\n if @unit.update(unit_params)\n render :create, status: :ok\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def measurement_unit_params\n params.require(:measurement_unit).permit(:name, :lock)\n end",
"def unit_name_params\n params.require(:unit_name).permit(:title, :description)\n end",
"def create\n @recipe_ingredients_unit = RecipeIngredientsUnit.new(recipe_ingredients_unit_params)\n\n respond_to do |format|\n if @recipe_ingredients_unit.save\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_ingredients_unit }\n else\n format.html { render :new }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rent_unit = RentUnit.new(rent_unit_params)\n\n respond_to do |format|\n if @rent_unit.save\n format.html { redirect_to @rent_unit, notice: 'Rent unit was successfully created.' }\n format.json { render :show, status: :created, location: @rent_unit }\n else\n format.html { render :new }\n format.json { render json: @rent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{raw_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create POST request\n post_params = {\n :verbose => DEBUG,\n :method => \"post\",\n :body => form_encode(data)\n }\n post_params[:params] = query_params unless query_params.empty?\n post = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", post_params)\n # Send request\n do_request(post, format) \n end",
"def quotation_unit_params\n params.require(:quotation_unit).permit(:quotation_unit_name)\n end",
"def create\n @study_unit = StudyUnit.new(params[:study_unit])\n\n respond_to do |format|\n if @study_unit.save\n format.html { redirect_to @study_unit, notice: 'Study unit was successfully created.' }\n format.json { render json: @study_unit, status: :created, location: @study_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @study_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def dataunit_params\n params.require(:dataunit).permit(:geoValue, :dataValue, :dataset_id, :user_id)\n end",
"def unit_params\n params.require(:unit).permit(\n :address1, :address2, :city, :state, :zip_code, :time_zone, :attach_consent_form,\n :use_consent_form, :consent_form, :url_consent_form, :home_address1, :home_address2, :home_zip_code,\n :home_state, :home_city, :home_map_url, :home_name, { health_form_coordinator_ids: [] }\n )\n end",
"def unit_group_params\n params.require(:unit_group).permit(:guid, :price, :group_key, :name, :available_units_count, :total_units_count, :total_non_excluded_units_count, :size, :standard_rate, :floor, :reduced_price, :occupancy_percent, :area, :length, :width, :height, :due_at_move_in, :due_at_move_in_without_fees, :due_monthly, :attribute_description, :description, :average_rent, :active_rate_type, :channel_rate_id, :unit_type_id)\n end",
"def create\n @unit_product = UnitProduct.new(unit_product_params)\n\n respond_to do |format|\n if @unit_product.save\n format.html { redirect_to @unit_product, notice: \"Unit product was successfully created.\" }\n format.json { render :show, status: :created, location: @unit_product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @unit_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def total_units=(value)\n @total_units = value\n end",
"def unit_params\n\t params.require(:unit).permit(:name, :semester_id)\n\t end",
"def create\n @currentunit = Currentunit.new(currentunit_params)\n\n respond_to do |format|\n if @currentunit.save\n format.html { redirect_to @currentunit, notice: 'Currentunit was successfully created.' }\n format.json { render :show, status: :created, location: @currentunit }\n else\n format.html { render :new }\n format.json { render json: @currentunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @army_unit = ArmyUnit.new(army_unit_params)\n\n respond_to do |format|\n if @army_unit.save\n format.html { redirect_to @army_unit, notice: 'Army unit was successfully created.' }\n format.json { render action: 'show', status: :created, location: @army_unit }\n else\n format.html { render action: 'new' }\n format.json { render json: @army_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end",
"def create\n @ad_unit = AdUnit.new(params[:ad_unit])\n\n respond_to do |format|\n if @ad_unit.save\n format.html { redirect_to @ad_unit, notice: 'Ad unit was successfully created.' }\n format.json { render json: @ad_unit, status: :created, location: @ad_unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ad_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @timeunit = Timeunit.new(params[:timeunit])\n\n respond_to do |format|\n if @timeunit.save\n format.html { redirect_to(@timeunit, :notice => 'Timeunit was successfully created.') }\n format.xml { render :xml => @timeunit, :status => :created, :location => @timeunit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @timeunit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @storage_unit = StorageUnit.new(params[:storage_unit])\n\n respond_to do |format|\n if @storage_unit.save\n flash[:notice] = 'StorageUnit was successfully created.'\n format.html { redirect_to(@storage_unit) }\n format.xml { render :xml => @storage_unit, :status => :created, :location => @storage_unit }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @storage_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @unit_type = UnitType.new\n respond_to do |format|\n format.json { render json: @unit_type }\n format.xml { render xml: @unit_type }\n end\n end",
"def create\n @unit = Unit.new(unit_params)\n @unit.organization = current_organization\n respond_to do |format|\n if @unit.save\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_succfully_created)}\" }\n else\n flash.now[:danger] = \"#{t(:failed_to_create)} #{t(:unit)}\"\n format.html { render action: 'new' }\n end\n end\n end",
"def new\n @item_unit = ItemUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_unit }\n end\n end",
"def new\n @extent_unit = ExtentUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @extent_unit }\n end\n end",
"def create\n @unit = Unit.new(params[:unit])\n if session[:resident_id]\n @unit.resident_id = session[:resident_id]\n session[:resident_id] = nil\n end\n\n respond_to do |format|\n if @unit.save\n format.html { redirect_to @unit, notice: 'Unit was successfully created.' }\n format.json { render json: @unit, status: :created, location: @unit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @unit_category = UnitCategory.new(unit_category_params)\n\n respond_to do |format|\n if @unit_category.save\n format.html { redirect_to @unit_category, notice: 'Unit category was successfully created.' }\n format.json { render :show, status: :created, location: @unit_category }\n else\n format.html { render :new }\n format.json { render json: @unit_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @unit_of_measure = UnitOfMeasure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit_of_measure }\n end\n end",
"def part_measurement_params\n params.require(:part_measurement).permit(:name, :unit, :value)\n end",
"def create\n @unit_group = UnitGroup.new(unit_group_params)\n\n respond_to do |format|\n if @unit_group.save\n format.html { redirect_to @unit_group, notice: 'Unit group was successfully created.' }\n format.json { render :show, status: :created, location: @unit_group }\n else\n format.html { render :new }\n format.json { render json: @unit_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rent_unit_params\n params.require(:rent_unit).permit(:name)\n end",
"def army_unit_params\n params.require(:army_unit).permit(:unit_id, :army_id)\n end"
] | [
"0.67017543",
"0.67017543",
"0.665163",
"0.66260743",
"0.65848905",
"0.6571388",
"0.6559905",
"0.6513941",
"0.64358485",
"0.643058",
"0.64260685",
"0.64147675",
"0.6377638",
"0.6371824",
"0.63462377",
"0.6335834",
"0.6332594",
"0.6331857",
"0.6330569",
"0.631212",
"0.6300642",
"0.62811875",
"0.6269009",
"0.6246745",
"0.6244873",
"0.6228291",
"0.62127006",
"0.6211468",
"0.61635095",
"0.6163071",
"0.6152031",
"0.6135335",
"0.6130623",
"0.6124361",
"0.6119586",
"0.61107767",
"0.6107671",
"0.60988545",
"0.60867715",
"0.608018",
"0.6051808",
"0.60513157",
"0.6045942",
"0.603699",
"0.6034467",
"0.60037124",
"0.5984483",
"0.5983168",
"0.59728163",
"0.59623504",
"0.5960372",
"0.59473234",
"0.5915013",
"0.5915013",
"0.5915013",
"0.5907898",
"0.59062356",
"0.5892365",
"0.589184",
"0.58906966",
"0.5886729",
"0.5873534",
"0.5868814",
"0.5854132",
"0.5854132",
"0.5846144",
"0.5843877",
"0.58182055",
"0.5817253",
"0.58150977",
"0.5783083",
"0.578286",
"0.5781806",
"0.5764004",
"0.5761108",
"0.57469064",
"0.57242024",
"0.572156",
"0.5709442",
"0.5707375",
"0.569352",
"0.5687306",
"0.56835973",
"0.56828755",
"0.5670335",
"0.5655355",
"0.56444335",
"0.56358874",
"0.56356585",
"0.5631565",
"0.5630403",
"0.56187975",
"0.56153435",
"0.5605503",
"0.5603294",
"0.5602921",
"0.56007236",
"0.56001174",
"0.5596223",
"0.5593767",
"0.55886316"
] | 0.0 | -1 |
PATCH/PUT /units/1 PATCH/PUT /units/1.json | def update
go=true
#@unit = Unit.new(unit_params)
@temp_1=@unit_time=UnitTime.new(:start_time => parse_time(params[:start_time]) , :end_time =>parse_time( params[:end_time]), :day => params[:day].to_i)
if not @unit_time.save
@temp_1=UnitTime.where(:start_time => parse_time(params[:start_time]) , :end_time =>parse_time( params[:end_time]), :day => params[:day].to_i)[0]
if @temp_1.nil?
go=false
end
end
if params[:has_time_2] && go
@temp_2=@unit_time_2=UnitTime.new(:start_time => parse_time(params[:start_time_2]) , :end_time =>parse_time( params[:end_time_2]), :day => params[:day_2].to_i)
if not @unit_time_2.save
@temp_2=UnitTime.where(:start_time => parse_time(params[:start_time_2]) , :end_time =>parse_time( params[:end_time_2]), :day => params[:day_2].to_i)[0]
if @temp_2.nil?
go=false
end
end
end
respond_to do |format|
if go
@unit.unit_times.clear
@unit.unit_times << @temp_1
if params[:has_time_2]
@unit.unit_times << @temp_2
end
if @unit.update(unit_params)
unless params[:has_exam_date]
@unit.update(:exam_date => DateTime.new(1900,1,1))
end
format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }
format.json { render :show, status: :ok, location: @unit }
else
format.html { render :edit }
format.json { render json: @unit.errors, status: :unprocessable_entity }
format.json { render json: @unit_time.errors, status: :unprocessable_entity }
format.json { render json: @unit_time_2.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end",
"def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit }\n else\n format.html { render :edit }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jobtype = Jobtype.find(params[:id])\n\n if @jobtype.update_attributes(params[:unit])\n render_json \"success\"\n else\n render_error \"failure\"\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n if @unit.update(unit_params)\n render :create, status: :ok\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def update_units(id, units, options = {})\n required = required_params(binding.send(:local_variables), binding, ['id'])\n call(:post, path(\"#{id}/actions/content/update/\"), :payload => { :required => required })\n end",
"def update\n @unit = Unit.find(params[:id])\n \n if params[:unit].andand[:note].present? && (@unit.note.blank? || (@unit.note != params[:unit][:note]))\n @unit.note_updated_by = current_person\n @unit.note_updated_at = Time.now\n end\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n if @item_unit.update_attributes(params[:item_unit])\n format.html { redirect_to @item_unit, notice: 'Item unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to new_food_path, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"Unit can't be an empty string.\"\n format.html { redirect_to new_food_path }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @base_unit.update(base_unit_params)\n format.html { redirect_to @base_unit, notice: 'Tray type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @base_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_name.update(unit_name_params)\n format.html { redirect_to @unit_name, notice: 'Unit name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: '修改成功!.' }\n format.json { render :show, status: :ok, location: @unit }\n else\n format.html { render :edit }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @extent_unit = ExtentUnit.find(params[:id])\n\n respond_to do |format|\n if @extent_unit.update_attributes(params[:extent_unit])\n format.html { redirect_to @extent_unit, notice: 'Extent unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @extent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n format.html { redirect_to @item, notice: 'Unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully update@datasheet.' }\n format.json { render :show, status: :ok, location: @unit }\n else\n format.html { render :edit }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n # format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.html { redirect_to units_path, notice: 'Pomyślnie zaktualizowano jednostkę.' }\n format.json { head :no_content }\n else\n # format.html { render action: \"edit\" }\n format.html { redirect_to units_path, :flash => { :error => 'Nie udało się zaktualizować jednostki' } }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n if params[:commit] == \"Save\"\n format.html { redirect_to @unit, notice: '<div class=\"alert alert-success\">Unit was successfully updated.</div>' }\n else\n @unit.toggle(current_user)\n format.html {\n redirect_to @unit, notice: \"<div class='alert alert-success'>Unit was successfully #{@unit.status_label}</div>\"\n }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @currentunit.update(currentunit_params)\n format.html { redirect_to @currentunit, notice: 'Currentunit was successfully updated.' }\n format.json { render :show, status: :ok, location: @currentunit }\n else\n format.html { render :edit }\n format.json { render json: @currentunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recipe_ingredients_unit.update(recipe_ingredients_unit_params)\n format.html { redirect_to recipe_ingredients_units_path, notice: 'Recipe ingredients unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_ingredients_unit }\n else\n format.html { render :edit }\n format.json { render json: @recipe_ingredients_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n\n respond_to do |format|\n if @unit_of_measure.update_attributes(params[:unit_of_measure])\n format.html { redirect_to @unit_of_measure, notice: t(:unit_of_measure_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @police_unit.update(police_unit_params)\n format.html { redirect_to @police_unit, notice: 'Police unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @police_unit }\n else\n format.html { render :edit }\n format.json { render json: @police_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @retail_unit = RetailUnit.find(params[:id])\n\n respond_to do |format|\n if @retail_unit.update_attributes(params[:retail_unit])\n format.html { redirect_to @retail_unit, notice: 'Retail unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retail_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @army_unit.update(army_unit_params)\n format.html { redirect_to @army_unit, notice: 'Army unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @army_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity_unit = QuantityUnit.find(params[:id])\n\n respond_to do |format|\n if @quantity_unit.update_attributes(params[:quantity_unit])\n flash[:notice] = 'QuantityUnit was successfully updated.'\n format.html { redirect_to(@quantity_unit) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quantity_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_measure.update(unit_measure_params)\n format.html { redirect_to @unit_measure, notice: 'Unit measure was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_measure }\n else\n format.html { render :edit }\n format.json { render json: @unit_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update!(**args)\n @quantity = args[:quantity] if args.key?(:quantity)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update\n respond_to do |format|\n if @storage_unit.update(storage_unit_params)\n format.html { redirect_to @storage_unit, notice: 'Storage unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @storage_unit }\n else\n format.html { render :edit }\n format.json { render json: @storage_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @first_level_unit.update(first_level_unit_params)\n format.html { redirect_to admin_first_level_units_path, notice: 'First level unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_level_unit }\n else\n format.html { render :edit }\n format.json { render json: @first_level_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @standard_unit.update(standard_unit_params)\n render :show, status: :ok, location: @standard_unit\n else\n render json: @standard_unit.errors, status: :unprocessable_entity\n end\n end",
"def update\n @contract = Contract.find(params[:id])\n @units = Unit.unsold(params[:tower_id])\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to tower_contract_path(@contract.unit.tower, @contract), notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n respond_to do |format|\n if @dataunit.update(dataunit_params)\n format.html { redirect_to @dataunit, notice: 'Dataunit was successfully updated.' }\n format.json { render :show, status: :ok, location: @dataunit }\n else\n format.html { render :edit }\n format.json { render json: @dataunit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_fuel.update(unit_fuel_params)\n format.html { redirect_to @unit_fuel, notice: (t 'unit_fuels.title')+(t 'actions.updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit_fuel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @article.update(article_params)\n @article.articles_units.last.update(unit_id: params[:articles_units][:unit_id],\n value: params[:articles_units][:value])\n format.html { redirect_to @article, notice: 'Article was successfully updated.' }\n format.json { render :show, status: :ok, location: @article }\n else\n format.html { render :edit }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quantity = Quantity.find(params[:id])\n\n respond_to do |format|\n if @quantity.update_attributes(params[:quantity])\n format.html { redirect_to @quantity, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quantity.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @quotation_unit.update(quotation_unit_params)\n format.html { redirect_to @quotation_unit, notice: 'Quotation unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @quotation_unit }\n else\n format.html { render :edit }\n format.json { render json: @quotation_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @study_unit = StudyUnit.find(params[:id])\n\n respond_to do |format|\n if @study_unit.update_attributes(params[:study_unit])\n format.html { redirect_to @study_unit, notice: 'Study unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @study_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_successfully_updated)}\" }\n else\n flash.now[:danger] = \"#{t(:failed_to_update)} #{t(:unit)}\"\n format.html { render action: 'show' }\n end\n end\n end",
"def update\n respond_to do |format|\n if @workout_unit.update(workout_unit_params)\n format.html { redirect_to @workout_unit, notice: 'Workout unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @workout_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @unit = Unit.find(params[:id])\n \n respond_to do |format|\n if @unit.update_attributes(params[:unit])\n flash[:notice] = 'Unit was successfully updated.'\n format.html { redirect_to(admin_army_unit_path(@unit.army,@unit)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @electoral_unit = ElectoralUnit.find(params[:id])\n\n respond_to do |format|\n if @electoral_unit.update_attributes(params[:electoral_unit])\n format.html { redirect_to @electoral_unit, notice: 'Electoral unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @electoral_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @org_unit.update(org_unit_params)\n format.html { redirect_to @org_unit, notice: 'Org unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @org_unit }\n else\n format.html { render :edit }\n format.json { render json: @org_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @storage_unit = StorageUnit.find(params[:id])\n\n respond_to do |format|\n if @storage_unit.update_attributes(params[:storage_unit])\n flash[:notice] = 'StorageUnit was successfully updated.'\n format.html { redirect_to(@storage_unit) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @storage_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_action.update(unit_action_params)\n format.html { redirect_to @unit_action, notice: 'Unit action was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_action }\n else\n format.html { render :edit }\n format.json { render json: @unit_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @account_unit.update_attributes(params[:account_unit])\n format.html { redirect_to @account_unit, notice: 'Account unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @account_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_rest\n @item_usage = ItemUsage.find(params[:id])\n\n respond_to do |format|\n if @item_usage.update_attributes(params[:item_usage])\n flash[:notice] = 'ItemUsage was successfully updated.'\n format.html { redirect_to(@item_usage) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @item_usage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @base_unit = args[:base_unit] if args.key?(:base_unit)\n @base_unit_conversion_factor = args[:base_unit_conversion_factor] if args.key?(:base_unit_conversion_factor)\n @base_unit_description = args[:base_unit_description] if args.key?(:base_unit_description)\n @display_quantity = args[:display_quantity] if args.key?(:display_quantity)\n @tiered_rates = args[:tiered_rates] if args.key?(:tiered_rates)\n @usage_unit = args[:usage_unit] if args.key?(:usage_unit)\n @usage_unit_description = args[:usage_unit_description] if args.key?(:usage_unit_description)\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @clase_unit.update(clase_unit_params)\n format.html { redirect_to @clase_unit, notice: 'Clase unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clase_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @order_unit.update(order_unit_params)\n format.html { redirect_to @order_unit, notice: '部件信息更新成功!' }\n format.json { render :show, status: :ok, location: @order_unit }\n else\n format.html { render :edit }\n format.json { render json: @order_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end",
"def update\n respond_to do |format|\n if @german_unit.update(german_unit_params)\n format.html { redirect_to @german_unit, notice: 'German unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @german_unit }\n else\n format.html { render :edit }\n format.json { render json: @german_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n @timeunit = Timeunit.find(params[:id])\n\n respond_to do |format|\n if @timeunit.update_attributes(params[:timeunit])\n format.html { redirect_to(@timeunit, :notice => 'Timeunit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @timeunit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n @unit_of_measure.update_attributes(params[:unit_of_measure])\n get_data\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rent_unit.update(rent_unit_params)\n format.html { redirect_to @rent_unit, notice: 'Rent unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @rent_unit }\n else\n format.html { render :edit }\n format.json { render json: @rent_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @test_metum.update(test_metum_params)\n format.html { redirect_to @test_metum, notice: 'Test metum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @test_metum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @functional_unit = FunctionalUnit.find(params[:id])\n\n respond_to do |format|\n if @functional_unit.update_attributes(params[:functional_unit])\n format.html { redirect_to(@functional_unit, :notice => 'Functional unit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @functional_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @unit_of_measure.modified_by = current_user.id\n respond_to do |format|\n if @unit_of_measure.update(unit_of_measure_params)\n format.html { redirect_to unit_of_measures_path, notice: 'Unit of measure was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_of_measure }\n else\n format.html { render :edit }\n format.json { render json: @unit_of_measure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @commecial_unit.update(commecial_unit_params)\n format.html { redirect_to @commecial_unit, notice: 'Commecial unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @commecial_unit }\n else\n format.html { render :edit }\n format.json { render json: @commecial_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usage.update(usage_params)\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_product.update(unit_product_params)\n format.html { redirect_to @unit_product, notice: \"Unit product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @unit_product }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @unit_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @unit_category.update(unit_category_params)\n format.html { redirect_to @unit_category, notice: 'Unit category was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_category }\n else\n format.html { render :edit }\n format.json { render json: @unit_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @amount = args[:amount] if args.key?(:amount)\n @unit = args[:unit] if args.key?(:unit)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @programme_unit.update(programme_unit_params)\n format.html { redirect_to @programme_unit, notice: 'Programme unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @programme_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n @todo.update_attributes(params[:todo])\n render :json => @todo\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update!(**args)\n @unit = args[:unit] if args.key?(:unit)\n @value = args[:value] if args.key?(:value)\n end",
"def update(id, attributes)\n # attributes = {name: 'chocolate and peanuts', calories: 10}\nend",
"def update\n @log_unit = LogUnit.find(params[:id])\n\n respond_to do |format|\n if @log_unit.update_attributes(params[:log_unit])\n format.html { redirect_to @log_unit, :notice => 'Log unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @log_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @instrument_patch.update(instrument_patch_params)\n format.html { redirect_to @instrument_patch, notice: 'Instrument patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instrument_patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n @ad_unit = AdUnit.find(params[:id])\n\n respond_to do |format|\n if @ad_unit.update_attributes(params[:ad_unit])\n format.html { redirect_to @ad_unit, notice: 'Ad unit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ad_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @commercial_unit.update(commercial_unit_params)\n format.html { redirect_to @commercial_unit, notice: 'Commercial unit was successfully updated.' }\n format.json { render :show, status: :ok, location: @commercial_unit }\n else\n format.html { render :edit }\n format.json { render json: @commercial_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @subset.update(subset_params)\n format.html { redirect_to @subset, notice: 'Subset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @subset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @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 @u = U.find(params[:id])\n\n respond_to do |format|\n if @u.update_attributes(params[:u])\n format.html { render action: \"edit\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @u.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usage = Usage.find(params[:id])\n\n respond_to do |format|\n if @usage.update_attributes(params[:usage])\n format.html { redirect_to @usage, notice: 'usage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @usage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n @uset = Uset.find(params[:id])\n\n respond_to do |format|\n if @uset.update_attributes(params[:uset])\n format.html { redirect_to @uset, notice: 'Uset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @uset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @unit_group.update(unit_group_params)\n format.html { redirect_to @unit_group, notice: 'Unit group was successfully updated.' }\n format.json { render :show, status: :ok, location: @unit_group }\n else\n format.html { render :edit }\n format.json { render json: @unit_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @meter = Meter.find(params[:id])\n\n respond_to do |format|\n if @meter.update_attributes(params[:meter])\n format.html { redirect_to @meter, notice: 'Meter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Extract return unit params\n query_params = {}\n query_params[:returnUnit] = data.delete(:returnUnit) if data[:returnUnit]\n query_params[:returnPerUnit] = data.delete(:returnPerUnit) if data[:returnPerUnit]\n # Create PUT request\n put_params = {\n :verbose => DEBUG,\n :method => \"put\",\n :body => form_encode(data)\n }\n put_params[:params] = query_params unless query_params.empty?\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", put_params)\n # Send request\n do_request(put, format)\n end",
"def update\n @unit = Unit.find(params[:id])\n if @unit.update(unit_params)\n redirect_to project_subsystem_path(:project_id => @unit.subsystem.project.id,\n :id => @unit.subsystem.id),\n :notice => 'Unit erfolgreich aktualisiert.'\n else\n render 'edit'\n end\n end",
"def update\n @shipping_unit = ShippingUnit.find(params[:id])\n\n respond_to do |format|\n if @shipping_unit.update_attributes(params[:shipping_unit])\n format.html { redirect_to(@shipping_unit, :notice => 'Shipping unit was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @shipping_unit.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @operation.update(operation_params)\n format.html { redirect_to @operation, notice: 'Operation was successfully updated.' }\n format.json { render :json => @operation.to_json(:include => :task) }\n else\n format.html { render json: @operation.errors, status: :unprocessable_entity }\n format.json { render json: @operation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @usertable = Usertable.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @usertable.update_attributes(params[:usertable])\r\n format.html { redirect_to @usertable, notice: 'Your mood was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @usertable.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @family_unit = FamilyUnit.find(params[:id])\n\n respond_to do |format|\n if @family_unit.update_attributes(params[:family_unit])\n format.html { redirect_to @family_unit, notice: 'Family unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @family_unit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @non_specific_value = args[:non_specific_value] if args.key?(:non_specific_value)\n @units = args[:units] if args.key?(:units)\n @units_string = args[:units_string] if args.key?(:units_string)\n @value = args[:value] if args.key?(:value)\n @value_string = args[:value_string] if args.key?(:value_string)\n end"
] | [
"0.78405803",
"0.71017027",
"0.69240105",
"0.6828834",
"0.67859524",
"0.67807686",
"0.6654957",
"0.6617484",
"0.659022",
"0.6557099",
"0.6543901",
"0.6528244",
"0.6519733",
"0.6517602",
"0.6511026",
"0.6488906",
"0.64756215",
"0.6440191",
"0.6405442",
"0.63572663",
"0.63474584",
"0.63111407",
"0.63005435",
"0.6289534",
"0.62852055",
"0.62741053",
"0.627263",
"0.627263",
"0.627263",
"0.627263",
"0.6248524",
"0.62421954",
"0.6233452",
"0.6181106",
"0.6125166",
"0.61189556",
"0.6111462",
"0.6104821",
"0.6103328",
"0.6103328",
"0.6083322",
"0.6068681",
"0.60668087",
"0.6056027",
"0.60538834",
"0.6049233",
"0.60448974",
"0.60361314",
"0.6034972",
"0.6017793",
"0.6017191",
"0.59879875",
"0.5984446",
"0.5957298",
"0.5948272",
"0.594786",
"0.59282166",
"0.5917523",
"0.5889896",
"0.58817315",
"0.58803415",
"0.58674216",
"0.58630556",
"0.5859677",
"0.5856777",
"0.58441824",
"0.5824348",
"0.5816592",
"0.58021516",
"0.58009005",
"0.5794311",
"0.5789234",
"0.5789029",
"0.578622",
"0.5780027",
"0.5776032",
"0.5776032",
"0.5776032",
"0.57750773",
"0.5764435",
"0.5758926",
"0.5751553",
"0.5750402",
"0.5750354",
"0.5734299",
"0.57320935",
"0.5731832",
"0.5731387",
"0.57232124",
"0.5714384",
"0.5713824",
"0.5709184",
"0.57075244",
"0.56882524",
"0.56847733",
"0.5678882",
"0.5677963",
"0.56778395",
"0.5676979",
"0.5668246",
"0.56665224"
] | 0.0 | -1 |
DELETE /units/1 DELETE /units/1.json | def destroy
@unit.destroy
respond_to do |format|
format.html { redirect_to units_url, notice: 'Unit was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do |format|\n format.html { redirect_to units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @base_unit.destroy\n respond_to do |format|\n format.html { redirect_to base_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @unit.blank?\n render json: {error: \"Can't delete unit\"}, status: :unprocessable_entity\n else\n @unit.destroy\n render json: {notice: \"Deleted!\"}, :status => 204\n end\n\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: '删除成功!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_unit = ItemUnit.find(params[:id])\n @item_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to item_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @unit.destroy\n head :no_content\n else\n render json: {errors: @unit.errors}, status: :unprocessable_entity\n end\n end",
"def destroy\n @unit = @lab_rack.units.find(params[:id])\n @unit.destroy\n \n redirect_to @lab_rack, :notice => \"Unit has been deleted\"\n end",
"def destroy\n @unit_name.destroy\n respond_to do |format|\n format.html { redirect_to unit_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: 'Unit was successfully destroye@datasheet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @extent_unit = ExtentUnit.find(params[:id])\n @extent_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to extent_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @retail_unit = RetailUnit.find(params[:id])\n @retail_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to retail_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @first_level_unit.destroy\n respond_to do |format|\n format.html { redirect_to first_level_units_url, notice: 'First level unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @army_unit.destroy\n respond_to do |format|\n format.html { redirect_to army_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage_unit = StorageUnit.find(params[:id])\n @storage_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(storage_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to new_food_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to units_url, notice: \"#{t(:unit)} #{t(:was_successfully_deleted)}\" }\n end\n end",
"def destroy\n @quantity_unit = QuantityUnit.find(params[:id])\n @quantity_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(quantity_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @storage_unit.destroy\n respond_to do |format|\n format.html { redirect_to storage_units_url, notice: 'Storage unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @study_unit = StudyUnit.find(params[:id])\n @study_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to study_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_measure.destroy\n respond_to do |format|\n format.html { redirect_to unit_measures_url, notice: 'Unit measure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clase_unit.destroy\n respond_to do |format|\n format.html { redirect_to clase_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataunit.destroy\n respond_to do |format|\n format.html { redirect_to dataunits_url, notice: 'Dataunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_of_measure.destroy\n respond_to do |format|\n format.html { redirect_to unit_of_measures_url, notice: 'Unit of measure was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_action.destroy\n respond_to do |format|\n format.html { redirect_to unit_actions_url, notice: 'Unit action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @log_unit = LogUnit.find(params[:id])\n @log_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to log_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @electoral_unit = ElectoralUnit.find(params[:id])\n @electoral_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to electoral_units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @account_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to account_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @currentunit.destroy\n respond_to do |format|\n format.html { redirect_to currentunits_url, notice: 'Currentunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quotation_unit.destroy\n respond_to do |format|\n format.html { redirect_to quotation_units_url, notice: 'Quotation unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @german_unit.destroy\n respond_to do |format|\n format.html { redirect_to german_units_url, notice: 'German unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_unit = AdUnit.find(params[:id])\n @ad_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_units_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @unit_fuel.destroy\n respond_to do |format|\n format.html { redirect_to unit_fuels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @building_id = @unit.building_id\n @unit.destroy\n respond_to do |format|\n format.html { redirect_to building_path(@building_id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timeunit = Timeunit.find(params[:id])\n @timeunit.destroy\n\n respond_to do |format|\n format.html { redirect_to(timeunits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @commecial_unit.destroy\n respond_to do |format|\n format.html { redirect_to commecial_units_url, notice: 'Commecial unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_ingredients_unit.destroy\n respond_to do |format|\n format.html { redirect_to recipe_ingredients_units_url, notice: 'Recipe ingredients unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @functional_unit = FunctionalUnit.find(params[:id])\n @functional_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(functional_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @rent_unit.destroy\n respond_to do |format|\n format.html { redirect_to rent_units_url, notice: 'Rent unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sampleunit = Sampleunit.find(params[:id])\n @sampleunit.destroy\n\n respond_to do |format|\n format.html { redirect_to(sampleunits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quantity = Quantity.find(params[:id])\n @quantity.destroy\n\n respond_to do |format|\n format.html { redirect_to quantities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @police_unit.destroy\n respond_to do |format|\n format.html { redirect_to police_units_url, notice: 'Police unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teaching_unit.destroy\n respond_to do |format|\n format.html { redirect_to teaching_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_action_type.destroy\n respond_to do |format|\n format.html { redirect_to unit_action_types_url, notice: 'Unit action type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @org_unit.destroy\n respond_to do |format|\n format.html { redirect_to org_units_url, notice: 'Org unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy_rest\n @item_usage = ItemUsage.find(params[:id])\n @item_usage.destroy\n\n respond_to do |format|\n format.html { redirect_to(item_usages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @unit_image.destroy\n respond_to do |format|\n format.html { redirect_to unit_images_url, notice: 'Unit image was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_category.destroy\n respond_to do |format|\n format.html { redirect_to unit_categories_url, notice: 'Unit category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_of_measure = UnitOfMeasure.find(params[:id])\n @unit_of_measure.destroy\n get_data\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @unidade_metrica = UnidadeMetrica.find(params[:id])\n @unidade_metrica.destroy\n\n respond_to do |format|\n format.html { redirect_to unidade_metricas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_amenity.destroy\n respond_to do |format|\n format.html { redirect_to unit_amenities_url, notice: 'Unit amenity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commercial_unit.destroy\n respond_to do |format|\n format.html { redirect_to commercial_units_url, notice: 'Commercial unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meter = Meter.find(params[:id])\n @meter.destroy\n\n respond_to do |format|\n format.html { redirect_to meters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @physical_unit = Probe::PhysicalUnit.find(params[:id])\n @physical_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(physical_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uset = Uset.find(params[:id])\n @uset.destroy\n\n respond_to do |format|\n format.html { redirect_to usets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @uom = Uom.find(params[:id])\r\n @uom.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_back_or_default(uoms_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @storage_lun = StorageLun.find(params[:id])\n @storage_lun.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_luns_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unitmark.destroy\n respond_to do |format|\n format.html { redirect_to unitmarks_url, notice: 'Unitmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hazmat_unit = HazmatUnit.find(params[:id])\n @hazmat_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(incident_timesheet_path, :notice => 'Hazmat Unit was successfully deleted.') }\n format.xml { head :ok }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @unit_group.destroy\n respond_to do |format|\n format.html { redirect_to unit_groups_url, notice: 'Unit group was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shipping_unit = ShippingUnit.find(params[:id])\n @shipping_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(shipping_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @relassignunit.destroy\n respond_to do |format|\n format.html { redirect_to relassignunits_url, notice: 'Relassignunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @k_measurement.destroy\n respond_to do |format|\n format.html { redirect_to k_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usage = Usage.find(params[:id])\n @usage.destroy\n\n respond_to do |format|\n format.html { redirect_to usages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @employing_unit = EmployingUnit.find(params[:id])\n @employing_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to employing_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product_unit.destroy\n respond_to do |format|\n format.html { redirect_to @product_unit.product, notice: 'Product unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @standard_unit.destroy\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @order_unit.destroy\n respond_to do |format|\n format.html { redirect_to order_units_url, notice: '部件信息已删除。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @common_expense_subunit.destroy\n respond_to do |format|\n format.html { redirect_to common_expense_subunits_url, notice: 'Common expense subunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\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(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @standard_measurement = StandardMeasurement.find(params[:id])\n @standard_measurement.destroy\n\n respond_to do |format|\n format.html { redirect_to standard_measurements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @m1.destroy\n respond_to do |format|\n format.html { redirect_to m1s_url, notice: 'M1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_stall.destroy\n respond_to do |format|\n format.html { redirect_to test_stalls_url, notice: 'Test stall was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @camp_unit = CampUnit.find(params[:id])\n @camp_unit.destroy\n\n respond_to do |format|\n format.html { redirect_to(camp_units_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @programme_unit.destroy\n respond_to do |format|\n format.html { redirect_to programme_units_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit = Unit.find(params[:id])\n @unit.unit_options.each do |uopt|\n uopt.unit_option_weapons.each do |uoptweapons|\n uoptweapons.destroy\n end\n uopt.destroy\n end\n @unit.destroy\n \n respond_to do |format|\n format.html { redirect_to(admin_army_path(@unit.army)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test1.destroy\n respond_to do |format|\n format.html { redirect_to test1s_url, notice: \"Test1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measure = Measure.find(params[:id])\n @measure.destroy\n\n respond_to do |format|\n format.html { redirect_to measures_url }\n format.json { head :no_content }\n end\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: \"Measurement was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url, notice: 'Measurement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_todo.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end"
] | [
"0.77861017",
"0.7669319",
"0.7640737",
"0.7640737",
"0.7640737",
"0.7640737",
"0.76394826",
"0.75945437",
"0.7526941",
"0.7451348",
"0.74230313",
"0.7408703",
"0.7381337",
"0.73444855",
"0.73303294",
"0.7308322",
"0.7215855",
"0.7208211",
"0.71699786",
"0.7147167",
"0.7145317",
"0.7115831",
"0.7077592",
"0.70701385",
"0.7004094",
"0.7001453",
"0.6983937",
"0.69713914",
"0.69690394",
"0.69573987",
"0.6953164",
"0.69123155",
"0.69118154",
"0.6902058",
"0.6893144",
"0.6863033",
"0.6857527",
"0.68123305",
"0.6797188",
"0.67762893",
"0.67586815",
"0.6725102",
"0.67164207",
"0.6709708",
"0.6706282",
"0.670255",
"0.66951257",
"0.66951257",
"0.6668271",
"0.6640182",
"0.6639936",
"0.66329664",
"0.6619875",
"0.6618753",
"0.66140854",
"0.6610746",
"0.6594457",
"0.65859413",
"0.6560964",
"0.6554923",
"0.6552109",
"0.6551015",
"0.65401095",
"0.6536416",
"0.65207446",
"0.6513875",
"0.650675",
"0.65061796",
"0.6496989",
"0.6496671",
"0.64925396",
"0.6489413",
"0.64775497",
"0.64732945",
"0.6471401",
"0.6468987",
"0.64550906",
"0.6452496",
"0.6448105",
"0.6447802",
"0.6438238",
"0.6432604",
"0.64307004",
"0.64278024",
"0.6425081",
"0.6423201",
"0.6422652",
"0.6421328",
"0.6413002",
"0.64110416",
"0.6407481",
"0.64048433",
"0.6404456",
"0.6399983",
"0.6396096",
"0.6390248",
"0.6390214",
"0.6390214",
"0.6390214",
"0.63900596"
] | 0.7406548 | 12 |
Use callbacks to share common setup or constraints between actions. | def set_unit
@unit = Unit.find(params[:id])
@unit_time = @unit.unit_times[1]
@unit_time_2 = @unit.unit_times[2]
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.